Show / Hide Table of Contents

Class ModTriggers

You can use this class in conjunction with the Triggers element in Mod.xml to define custom triggers for the level editor logic system.

Inheritance
Object
ModTriggers
Namespace: Modding
Assembly: Assembly-CSharp.dll
Syntax
public static class ModTriggers
Remarks

Mod.xml is used to define the properties of the triggers.. This class is used to activate your triggers, using either GetCallback or RegisterCallback. See their documentation for more details.

GetCallback is easiest to use but only allows activating all instances of the trigger across the whole level. RegisterCallback is slightly more complicated but in exchange allows finer control of which instances of the trigger / what entities get activated.

Multiplayer Note: You an only call the activation callbacks on the instance running a simulation (i.e. the server for global sim or the respective client for local sim). The effects of the activation are automatically propagated across the network. Calling the callbacks on a client will throw an InvalidOperationException.

Methods

GetCallback(Int32)

GetCallback returns an Action that you can later call to activate your trigger on all entities that have it set up.

Declaration
public static Action GetCallback(int id)
Parameters
Type Name Description
Int32 id

ID of the trigger you want to activate.

Returns
Type Description
Action

Callback to activate the trigger.

RegisterCallback(Int32, ModTriggers.OnTriggerChanged)

RegisterCallback registers an OnTriggerChanged callback for one of your triggers.

This callback will be called by the mod loader whenever the specified trigger is added to or removed from an entity. If the trigger was added, one of its arguments is another callback which you can call to activate the trigger, analogous to the one returned from GetCallback, except that this callback will only activate the trigger on the specified entity.

Declaration
public static void RegisterCallback(int id, ModTriggers.OnTriggerChanged callback)
Parameters
Type Name Description
Int32 id

ID of the trigger.

ModTriggers.OnTriggerChanged callback

OnTriggerChanged callback to register.

Remarks

The callback will be called on all connected instances. See documentation on ModTriggers for how your code should behave in MP.

Note that the callback will only be called for the non-simulation entities, never for a simulation clone.

Back to top Generated by DocFX