Events
Events, so that arch notifies you of everything that happens.
With events, you get to know about all important entity actions and can react accordingly! This is exactly what the EVENTS
flag is for, which you can set in Arch to enable all hooks. However, you have to modify the source code for this, it's best to take a look at the chapter on PURE_ECS
!
Example
There is not much to say. As soon as the EVENTS
flag has been set, we can get started straight away and hook into all the important methods.
world.SubscribeEntityCreated((Entity entity) => {}); // Listen for entity creation events
world.SubscribeEntityDestroyed((Entity entity) => {}); // Listen for entity destruction events
world.SubscribeComponentAdded((Entity entity, ref Position _) => {}); // Listen for newly added components
world.SubscribeComponentSet((Entity entity, ref Position _) => {}); // Listen for newly set components
world.SubscribeComponentRemoved((Entity entity, ref Position _) => {}); // Listen for newly removed components
And now we know what's happening, we're finally complete control freaks!
There is now also a nuget that saves you this manual work: https://www.nuget.org/packages/Arch-Events/
Last updated
Was this helpful?