Listening to / Dispatching Events

Purpose

Create listeners for events and dispatch events in simulations. 

How to Use

Refer to the following examples for your own scenarios:

				
					
// add listeners
Globals.api.worldStateSystem.AddListener<TestEvent>(WorldEvent.waypointReached, OnWaypointReached);
Globals.api.worldStateSystem.AddListener<WaypointReachedEvent>(WorldEvent.waypointReached, OnWaypointReached2);
Globals.api.worldStateSystem.AddListener<int>(WorldEvent.waypointReached, OnWaypointReached3);
 
// dispatch
Globals.api.worldStateSystem.DispatchEvent<TestEvent>(WorldEvent.waypointReached, new TestEvent { x = 100 });
Globals.api.worldStateSystem.DispatchEvent<int>(WorldEvent.waypointReached, 10);
Globals.api.worldStateSystem.DispatchEvent<WaypointReachedEvent>(WorldEvent.waypointReached, new WaypointReachedEvent(wp, blueAgent));
 
// remove
Globals.api.worldStateSystem.RemoveListener<WaypointReachedEvent>(WorldEvent.waypointReached, OnWaypointReached2);