Added OnLoad virtual

Allows for things to be reinitialized where needed for Thinkers. Moved hidden state of items over to OnLoad.
This commit is contained in:
Boondorl 2025-04-01 15:20:00 -04:00
parent 6f3032dc54
commit 1982f60318
5 changed files with 24 additions and 3 deletions

View file

@ -415,12 +415,12 @@ void FThinkerCollection::SerializeThinkers(FSerializer &arc, bool hubLoad)
else if (thinker->ObjectFlags & OF_JustSpawned)
{
FreshThinkers[i].AddTail(thinker);
thinker->PostSerialize();
thinker->CallPostSerialize();
}
else
{
Thinkers[i].AddTail(thinker);
thinker->PostSerialize();
thinker->CallPostSerialize();
}
}
}
@ -833,6 +833,16 @@ void DThinker::PostSerialize()
{
}
void DThinker::CallPostSerialize()
{
PostSerialize();
IFOVERRIDENVIRTUALPTRNAME(this, NAME_Thinker, OnLoad)
{
VMValue params[] = { this };
VMCall(func, params, 1, nullptr, 0);
}
}
//==========================================================================
//
//

View file

@ -105,6 +105,7 @@ public:
virtual void PostBeginPlay (); // Called just before the first tick
virtual void CallPostBeginPlay(); // different in actor.
virtual void PostSerialize();
void CallPostSerialize();
void Serialize(FSerializer &arc) override;
size_t PropagateMark();

View file

@ -242,7 +242,6 @@ void AActor::Serialize(FSerializer &arc)
A("angles", Angles)
A("frame", frame)
A("scale", Scale)
A("nolocalrender", NoLocalRender) // Note: This will probably be removed later since a better solution is needed
A("renderstyle", RenderStyle)
A("renderflags", renderflags)
A("renderflags2", renderflags2)

View file

@ -85,6 +85,11 @@ class Inventory : Actor
Inventory.PickupSound "misc/i_pkup";
Inventory.PickupMessage "$TXT_DEFAULTPICKUPMSG";
}
override void OnLoad()
{
UpdateLocalPickupStatus();
}
//native override void Tick();
@ -1113,6 +1118,11 @@ class Inventory : Actor
return pickedUp[client.PlayerNumber()];
}
void UpdateLocalPickupStatus()
{
DisableLocalRendering(consoleplayer, pickedUp[consoleplayer]);
}
// When items are dropped, clear their local pick ups.
void ClearLocalPickUps()
{

View file

@ -238,6 +238,7 @@ class Thinker : Object native play
virtual native void Tick();
virtual native void PostBeginPlay();
virtual void OnLoad() {}
native void ChangeStatNum(int stat);
static clearscope int Tics2Seconds(int tics)