In a tree architecture, getting the nodes to communicate without making a huge mess of links between nodes requires special attention. That’s where the EventManager comes in.
It provides a one or two way communication system among nodes in the system. The nodes don’t even need to know that the other node exists. It works on one to one and one to many modes with no difference.
The EventManager is a singleton, there is only one and shared by the whole system. Anyone can register a new event, with a specific name. Once an event has been added to the EventManager, anyone can register an EventHandler to it, and anyone can trigger it. When someone triggers an Event, everyone who registered an EventHandler gets notified. As this system is built on the delegate system of XNA, it incorporates sending extra information along with triggering an Event, mainly arguments and who triggered it.
This works fine for general purpose messages (like print subtree, that orders the root node to print it’s subtree) or for messages that require a reply (someone asking for a content manager, just send an argument object with a content manager memberto fill, and check it in the sender class.)
The main issue with this system is security, as messages are not guaranteed to be answered, but the Debug.Assert function covers almost all the dead ends in this case.