Skip to content

Event manager

Peter Shih edited this page Apr 1, 2017 · 6 revisions
  • Event types are defined at compile-time
  • Event handlers are pushed back at run-time
  • Each event type can be registered with several handlers at run-time
  • Each event handler is a callable object
    • It might be with type std::function if needs to capture some info
      • For example: capture self state::CardRef
    • If possible, prefer to use pure function pointer for performance concern
  • An event handler cannot be removed by outsiders
    • It can only be removed when the item is triggered, and returns false
      • Pros: quickly clone game state
      • Cons: each event handler needs to know when to remove itself
Clone this wiki locally