I just woke up when i thought of an idea.
The current messaging system needs the rootEntityNode to be passed to it and your only allowed to pass messages to entities, not nodes. So my brilliant idea comes whereby you CAN pass messages to nodes, and they will pass the information to all of their children.
This proves useful if the entity tree is shaped like the scenegraph tree (like not identical). So that if say a gun was fired, and your in a room called "HelloHelloHello", you can pass a message to the "HelloHelloHello" Entity and everyone in the room gets alerted.
What do you think?
Sounds like a promising idea.
I think we’ll need to be careful to avoid lots of unneeded overhead, though. That is, if entities don’t need an event… we don’t want them to get it… ESPECIALLY if they can’t exit quickly and need to do some kind of lookup. (One way to help avoid that is to do any ‘source entity’ lookups at the top level and pass it down…?)
Hmm… Just brainstorming here.
Could you do something like a generic publish/subscribe system, with some different mechanisms for setting up the subscribers?
Eg: When creating entities, you also have an ‘EntityMessageSubscriber’ class that provides the general rules for when any given entity should be notified.
With your idea, you would have a ‘ParentChildEntityMessageSubscriber’ class that you would use. This class could be a child of (or an implementation of an interface) an ‘AbstractEntityMessageSubscriber’.
That way, if you knew when creating those entities that you wouldn’t want them to be notified when their parent was notified, you could use a different message-subscriber class.
Not a fully developed idea by any means, but it might be more flexible with little additional complication. (Well… little complication in the application code… writing the system might be a little harder.)
Just an idea. Am I expressing myself clearly enough, or should I explain more?