swwmgz_m/zscript/swwm_Polyobjects/PolyobjectEffector.zs
Marisa the Magician 0fbbb91b8e Revert "Remove ZPolyobject due to licensing concerns."
This reverts commit f134375f7e.

Library is now MIT licensed and can be included.
2022-10-08 15:55:42 +02:00

48 lines
1.2 KiB
Text

class swwm_PolyobjectEffector: Thinker abstract
{
// Base abstract class for Polyobject Effectors
// Polyobject Effectors affect how a polyobject behaves.
// Polyobject Effectors contain a pointer to the next Effector of a polyobject,
// forming a circular linked list.
// To add an effector to a polyobject, call AddEffector() on a PolyobjectHandle.
// To remove an effector, simply call Destroy() on it.
swwm_PolyobjectHandle Polyobject;
swwm_PolyobjectEffector Next;
// OnAdd() is called once after adding the effector to a PolyobjectHandle
virtual void OnAdd()
{
}
// PolyTick() is called every tic by a PolyobjectHandle
virtual void PolyTick()
{
}
override void OnDestroy()
{
swwm_PolyobjectEffector e = Polyobject.EffectorList;
if (e != NULL)
{
// Find previous effector
while (e && e.Next != self)
{
e = e.Next;
}
// Link previous effector to the next effector
e.Next = Next;
// Check if this effector is the last one
if (e == self)
{
// Polyobject has no other effectors, set EffectorList to NULL
Polyobject.EffectorList = NULL;
}
}
Super.OnDestroy();
}
}