You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Essentially, the code modder can add a component to their entity that gives the OnEnter/OnStay/OnLeave functionality as if it were a Trigger. This means modders will no longer need to manually track CollideChecks across frames in the entity Update.
I've currently named the component Triggerable to be similar in naming to Holdable, and the actions OnEnter/OnStay/OnLeave, with their virtual invocation methods called InvokeOnEnter/InvokeOnStay/InvokeOnLeave in case the modder wants to override the component instead of assigning actions.
These actions (or method groups) can be passed into the constructor and/or assigned directly in the object initialiser. The first argument is an optional collider to use instead of the entity's Collider property.
Since colliders can be specified, this means multiple trigger regions can be assigned to the same entity if desired, each with different functionality.
This is an example where I've added three separate trigger regions to a gravity field, using different instantiation styles.
// custom hitbox, method groupsAdd(newTriggerable(newHitbox(16,Height,-16,0),null,onStay,onLeave));// custom hitbox, object initialiserAdd(newTriggerable(newHitbox(16,Height,Width,0)){OnEnter= _ =>Audio.Play(SFX.char_gran_laugh_firstphrase),OnLeave= player =>player.Die(Vector2.Zero)});// default collider, object initialiserAdd(newTriggerable{OnEnter= player =>player.SuperBounce(Top)});privatevoidonStay(Playerplayer)=>player.Sprite.Scale.X=2;privatevoidonLeave(Playerplayer)=>player.Sprite.Scale.X=1;
I am planning on implementing this myself
Yes
Describe your request
Essentially, the code modder can add a component to their entity that gives the
OnEnter/OnStay/OnLeavefunctionality as if it were aTrigger. This means modders will no longer need to manually trackCollideChecks across frames in the entityUpdate.I've currently named the component
Triggerableto be similar in naming toHoldable, and the actionsOnEnter/OnStay/OnLeave, with their virtual invocation methods calledInvokeOnEnter/InvokeOnStay/InvokeOnLeavein case the modder wants to override the component instead of assigning actions.These actions (or method groups) can be passed into the constructor and/or assigned directly in the object initialiser. The first argument is an optional collider to use instead of the entity's Collider property.
Since colliders can be specified, this means multiple trigger regions can be assigned to the same entity if desired, each with different functionality.
This is an example where I've added three separate trigger regions to a gravity field, using different instantiation styles.
triggerable.mp4
Additional context
No response