- scriptified AInventory::Tick.

This was the last bit of code standing in the way of making AInventory a fully scripted class.
All that's left to sort out is some variable accesses - the vast majority of them in SBARINFO.
This commit is contained in:
Christoph Oelckers 2018-12-02 20:57:03 +01:00
parent d88d173b38
commit 807df33e1a
4 changed files with 41 additions and 43 deletions

View file

@ -75,48 +75,6 @@ DEFINE_FIELD(AInventory, SpawnPointClass)
DEFINE_FIELD(AInventory, PickupFlash)
DEFINE_FIELD(AInventory, PickupSound)
//===========================================================================
//
// AInventory :: Tick
//
//===========================================================================
void AInventory::Tick ()
{
if (Owner == NULL)
{
// AActor::Tick is only handling interaction with the world
// and we don't want that for owned inventory items.
Super::Tick ();
}
else if (tics != -1) // ... but at least we have to advance the states
{
tics--;
// you can cycle through multiple states in a tic
// [RH] Use <= 0 instead of == 0 so that spawnstates
// of 0 tics work as expected.
if (tics <= 0)
{
assert (state != NULL);
if (state == NULL)
{
Destroy();
return;
}
if (!SetState (state->GetNextState()))
return; // freed itself
}
}
if (DropTime)
{
if (--DropTime == 0)
{
flags |= GetDefault()->flags & (MF_SPECIAL|MF_SOLID);
}
}
}
//===========================================================================
//
// AInventory :: Serialize

View file

@ -71,7 +71,7 @@ class AInventory : public AActor
public:
virtual void Serialize(FSerializer &arc) override;
virtual void Tick() override;
//virtual void Tick() override;
TObjPtr<AActor*> Owner; // Who owns this item? NULL if it's still a pickup.
int Amount; // Amount of item this instance has

View file

@ -1013,6 +1013,7 @@ xx(FOVScale)
xx(YAdjust)
xx(Crosshair)
xx(WeaponFlags)
xx(DropTime)
xx(BlueCard)
xx(YellowCard)

View file

@ -49,6 +49,45 @@ class Inventory : Actor native
Inventory.PickupMessage "$TXT_DEFAULTPICKUPMSG";
}
//native override void Tick();
override void Tick()
{
if (Owner == null)
{
// AActor::Tick is only handling interaction with the world
// and we don't want that for owned inventory items.
Super.Tick();
}
else if (tics != -1) // ... but at least we have to advance the states
{
tics--;
// you can cycle through multiple states in a tic
// [RH] Use <= 0 instead of == 0 so that spawnstates
// of 0 tics work as expected.
if (tics <= 0)
{
if (curstate == null)
{
Destroy();
return;
}
if (!SetState (curstate.NextState))
return; // freed itself
}
}
if (DropTime)
{
if (--DropTime == 0)
{
bSpecial = default.bSpecial;
bSolid = default.bSolid;
}
}
}
native static void PrintPickupMessage (bool localview, String str);
States(Actor)