-
Notifications
You must be signed in to change notification settings - Fork 1
6. Actions
Actions help keep clutter down by allowing proper separation between systems. If you are familiar with C# delegates or actions, you will likely be familiar here as well.
Actions can have methods subscribed to them, when the action is executed, all of the subscribed methods are executed.
Note: Actions currently only support methods with 0 parameters.
Creating an action is incredibly easy, all you need to do is create a public ECTAction
field within your system.
Ex.
public ECTAction OnLand
It is recommended you create a brand-new method for each action you are subscribing to.
To subscribe to an action, execute the Subscribe
method on the action using the method you want to subscribe as the parameter.
OnLand.Subscribe(OnLand)
Note: A method can only subscribe to an action once, allowing you to subscribe to an action in an
OnUpdate()
.
To execute an action, call Execute()
on it and all subscribed methods will be executed.