24.11.2014, 12:20
You can create ChildNodes for different things. It's like making groups for events of the same kind.
For example, you can create a EventManagerNode for all VehicleEvents, and a EventManagerNode for all PlayerEvents.
You can unsubscribe to all VehicleEvents if you destroy just the node. So, if you mix all your events into one Manager, and you want to remove some events, you need to unregister all the events manually. When you use Nodes, you can just destroy the node, and all the registered events in this node will be destroyed.
If you mix all together, you can't delete just VehicleEvents.
For example, you can create a EventManagerNode for all VehicleEvents, and a EventManagerNode for all PlayerEvents.
You can unsubscribe to all VehicleEvents if you destroy just the node. So, if you mix all your events into one Manager, and you want to remove some events, you need to unregister all the events manually. When you use Nodes, you can just destroy the node, and all the registered events in this node will be destroyed.
PHP код:
EventManagerNode vehicleEventNode = eventManager.createChildNode();
vehicleEventNode.registerHandler(VehicleCreateEvent.class, (e) -> {
});
vehicleEventNode.registerHandler(VehicleDestroyEvent.class, (e) -> {
});
EventManagerNode playerEventNode = eventManager.createChildNode();
playerEventNode.registerHandler(PlayerConnectEvent.class, (e) -> {
});
playerEventNode.registerHandler(PlayerDisconnectEvent.class, (e) -> {
});
//Don't need vehicle events anymore, so just destroy. Player Events will still remain
vehicleEventNode.cancelAll();
vehicleEventNode.destroy();