Event System
Passive Check
class CollisionSystem { void Update(){ //.../ if(collisionHappened) { eventBus->EmitEvent<CollisionEvent>(); } } } class DamageSystem { void Update() { for (auto e: eventBus->GetEvents<CollisionEvent>() { //...... } } }
- Simple, keep the logic inside the System.
- the order running the Systems is matter.
- It need to wait certain System check and process.
Blocking
class CollisionSystem { void Update(){ //.../ if(collisionHappened) { eventBus->EmitEvent<CollisionEvent>(a, b); } } } class DamageSystem { eventBus->SubscribeToEvent<CollisionEvent>(onCollision); void onCollision(Entity a, Entity b) { //.... } }
- Run event as soon as possible.