- CallOnanimate

This commit is contained in:
Christoph Oelckers 2022-01-19 18:52:52 +01:00
parent ba016c7c3a
commit e3aa1da175
5 changed files with 28 additions and 2 deletions

View file

@ -142,6 +142,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
for (unsigned j = 0; j < tsprites.Size(); j++)
{
t = tsprites.get(j);
h = static_cast<DDukeActor*>(t->ownerActor);
auto OwnerAc = h->GetOwner();
@ -180,6 +181,11 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
t->angle = h->interpolatedangle(interpfrac);
}
if (h->GetClass() != RUNTIME_CLASS(DDukeActor))
{
if (CallAnimate(h, t)) continue;
}
auto sectp = h->sector();
t1 = h->temp_data[1];
t3 = h->temp_data[3];

View file

@ -161,6 +161,11 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
t->angle = h->interpolatedangle(interpfrac);
}
if (h->GetClass() != RUNTIME_CLASS(DDukeActor))
{
if (CallAnimate(h, t)) continue;
}
auto sectp = h->sector();
t1 = h->temp_data[1];
t3 = h->temp_data[3];

View file

@ -117,6 +117,7 @@ void CallInitialize(DDukeActor* actor);
void CallTick(DDukeActor* actor);
void CallAction(DDukeActor* actor);
void CallOnHit(DDukeActor* actor, DDukeActor* hitter);
bool CallAnimate(DDukeActor* actor, tspritetype* hitter);
END_DUKE_NS

View file

@ -404,8 +404,8 @@ void CallInitialize(DDukeActor* actor)
{
IFVIRTUALPTR(actor, DDukeActor, Initialize)
{
VMValue val = actor;
VMCall(func, &val, 1, nullptr, 0);
VMValue val[2] = { actor };
VMCall(func, val, 1, nullptr, 0);
}
}
@ -437,4 +437,17 @@ void CallOnHit(DDukeActor* actor, DDukeActor* hitter)
}
bool CallAnimate(DDukeActor* actor, tspritetype* tspr)
{
int nval = false;
IFVIRTUALPTR(actor, DDukeActor, animate)
{
VMReturn ret(& nval);
VMValue val[2] = { actor, tspr };
VMCall(func, val, 2, &ret, 1);
}
return nval;
}
END_DUKE_NS

View file

@ -75,6 +75,7 @@ class DukeActor : CoreActor native
virtual void Initialize() {}
virtual void Tick() {}
virtual void onHit(DukeActor hitter) {}
virtual bool animate(tspritetype tspr) { return false; }
virtual void RunState() {} // this is the CON function.
}