Entity communication: Message queue vs Publish/Subscribe vs Signal/Slots
- by deft_code
How do game engine entities communicate?
Two use cases:
How would entity_A send a take-damage message to entity_B?
How would entity_A query entity_B's HP?
Here's what I've encountered so far:
Message queue
entity_A creates a take-damage message and posts it to entity_B's message queue.
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
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.
entity_A subscribes to update-hp messages (possibly filtered). Every frame entity_B broadcasts update-hp messages.
Signal/Slots
???
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?