Skip to content

Internals

pongo1231 edited this page Apr 10, 2023 · 10 revisions

Note: this page is written with the latest git master commit in mind

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 -> OnStop

And for timed effects: OnStart -> OnTick -> OnStop

Each call only occurs once per frame.

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