Mastahg, Code: private void AddHooks() { Logging.Write(Colors.Pink, string.Format("Adding Destiny V{0} Hooks", Version)); var counter = 0; foreach (var logic in Logic) { TreeHooks.Instance.InsertHook("TreeStart", counter, logic.Coroutine); counter++; } } Let's say I have the above code in my Plugin. Now let's say someone else has their own Plugin and it is using the same code because we're good developers and share code that works. Now let's say random user "X" is using BOTH of our plugins at the same time. If there ever becomes a point where the logic for the coroutines of both plugins becomes true at the same time, they will both try and fight each other to decide what to do. An example is with my plugin Destiny and Neverdyne's plugin Agil. If the end user is using the Patrol function of Destiny when Agil has decided it is time to go repair at a mender merchant, what ends up happening is Agil calls a MoveTo to get to the mender merchant and Destiny calls a MoveTo to get to the random mob we are passing by...resulting in a never ending loop of trying to fight back and forth. My question is this: Is there a safe way to insert a Hook and make sure that you don't get multiple hooks to the same "leaf"? Right now, there's nothing stopping multiple Plugins from hooking to position 0 in the tree...which is what I believe is causing the issue. Thanks, -Wheredidigo
Whos ever is at spot 0 goes first its that simple. If your hook needs to be doing something then it shouldn't be letting the control flow past it and as such there would be no fighting.
I guess the question really is: "What happens when 2 different Plugins Insert a Hook at spot 0?" Is it a matter of whichever routine inserted the hook at Spot 0 Last is the winner?