Skip to content

Internals

pongo1231 edited this page Mar 7, 2023 · 6 revisions

Effect Lifecycle

Effects have 3 functions which handle logic at different points of the lifecycle: OnStart, OnStop and OnTick. OnStart is called as soon as the effect is dispatched. OnStop is called as soon as the effect is about to be stopped, be it by the timer or the user. OnTick is called once each frame after OnStart has been called and before OnStop gets called.

For non-timed effects the lifecycle looks like this: OnStart -> OnTick -> OnStop

And for timed effects: OnStart -> OnStop

Between each call there is a 1 frame pause. So OnStart gets called, one frame pause, OnTick is then called for the remainder until the effect gets the stop signal and OnStop is called.

WAIT calls will pause an effect for X duration (in milliseconds). WAIT calls will not affect anything other than the effect itself as they run in individual fibers (aka lightweight threads). They are allowed at any stage of the lifecycle, though if the user is either clearing all effects or disabling the mod the following occurs:

  • The time passed to WAIT will be ignored; WAIT calls will behave as if X is always 0
  • Your effect will be forcefully terminated if more than 20 WAIT calls occur in either OnStart or OnStop, potentially causing the effect's cleanup routine to not be executed
Clone this wiki locally