Well its hard to explain it
The Image i posted starts at A but in reality the A node could be any node in the tree so too could the B node it could be a great granchild or further.
if you imagine a long unbalanced tree were a specific type of node N has a certain type of property which will affect all child nodes under it. However nodes of other types can be added or removed to nodes of children below node N that is the origin of the affect such that they have no direct access to the grandparent to know of the affect. Further i might add other affects later on so that i would then need to deal with both the possibility of clashing affects and multiple affects to be tracked. In the case at hand though node N tracks the current node and could in fact keep a stack or list with a index to the current selected node. However this sort of implys offloading responsibility for things to the N node that previously were the responsibility of individual nodes so its all sort of maddening.
The way ive started to implement it is to make a special command method and add two additional public references to the base class commander and subordinate kinda like a army pattern were there is a hierarchical structure but orders are carried thru the ranks via a method. For, who it applys to, that directly bypasses the chain of command and establishes a connection with the command originator or commander.
I still haven’t worked out all the details that might end up trashed.
Basically the structure looks something like this well this is just conceptual i just typed the core idea and there is more going on that makes it more difficult.
BaseClass Subordinate; //active subordinate for commander
// abstract properties and methods ..
// ,, concrete properties and methods and concrete instance local methods ect.
// ,, do specific stuff. iterate recursively.
PassCommand(base commandnode, int commandCode)
if( ImeetSpecificConditions && commandCodeIsSuchNsuch)
this.Commander = commandnode;
this.Commander.Subordinate = this;
if(root && dirty)
// fire children and run down the chain