- Home /
Best use cases for an observer pattern messenger system
I'm looking at implementing an observer pattern messenger/event system in my game, something like the Notification Center on the wiki, but I find myself confused when deciding what are the best use cases for it.
I can totally see something like, an "NPC Death" event being a great use case, because you'd want your effects manager to create some particle effects there, or your score manager to increment the player's score, stuff like that.
But what about an "NPC Take Damage" event? It makes sense that something like an effects manager would want to subscribe to such an event, to make some blood particles or something, but should every NPC subscribe to it? If they did, the NPC who took the hit would have to be passed with the event, and then every enemy would have to check if it was him, right? That seems like a lot of CPU cycles, as opposed to calling the "Take Damage" function on the enemy being hit directly, via either SendMessage or a GetComponent() direct function call, no?
Cross-post: http://forum.unity3d.com/threads/221965-Best-use-cases-for-observer-pattern-messenger-system
Your answer
Follow this Question
Related Questions
How do I add an event listener for the WWW class? 1 Answer
NullreferenceException with an Event 2 Answers
Setting ModelImporter's clipAnimations clears events for all referenced clips, is this intentional? 2 Answers
System.Diagnostics.Process.Exited not firing in executable 2 Answers
Is it good to use events more often? 0 Answers