Entity communication: Message queue vs Publish/Subscribe vs Signal/Slots

Posted by deft_code on Game Development See other posts from Game Development or by deft_code
Published on 2010-07-22T07:01:07Z Indexed on 2011/01/17 19:59 UTC
Read the original article Hit count: 217

How do game engine entities communicate?

Two use cases:

  1. How would entity_A send a take-damage message to entity_B?
  2. How would entity_A query entity_B's HP?

Here's what I've encountered so far:

  • Message queue
    1. entity_A creates a take-damage message and posts it to entity_B's message queue.
    2. entity_A creates a query-hp message and posts it to entity_B. entity_B in return creates an response-hp message and posts it to entity_A.
  • Publish/Subscribe
    1. entity_B subscribes to take-damage messages (possibly with some preemptive filtering so only relevant message are delivered). entity_A produces take-damage message that references entity_B.
    2. entity_A subscribes to update-hp messages (possibly filtered). Every frame entity_B broadcasts update-hp messages.
  • Signal/Slots
    1. ???
    2. entity_A connects an update-hp slot to entity_B's update-hp signal.
  • Something better?

Do I have a correct understanding of how these communication schemes would tie into a game engine's entity system?
How do entities in commercial game engines communicate?

© Game Development or respective owner

Related posts about engine

Related posts about architecture