Good evening,
I am attempting to write a plugin that subscribes to RoutineManager.PickRoutineFired in order to build a combat routine switcher, based on use pre-chosen options per class.
While the selection and switching process works, I am having trouble getting it to properly dispose the previous routine, and load the new one. Specifically, the combat behaviors.
If I am to call the following within the RoutinePickFired Method, it does technically work, but is very clunky and very dirty, and straight does not work from time to time. (Too slow to re-start on the child task - thus failing to restart the botbase)
However, Trying to clear hooks, replace them with ActionAlwaysFails, or anything short of stopping, and starting the botbase itself leads to the same issue: The previous combat routine behaviors being loaded and used.
Example:
So, my question is this: What is the proper way to dispose of the combat routine being switched from, and replace it with the one being switched to?
Thank you!
I am attempting to write a plugin that subscribes to RoutineManager.PickRoutineFired in order to build a combat routine switcher, based on use pre-chosen options per class.
While the selection and switching process works, I am having trouble getting it to properly dispose the previous routine, and load the new one. Specifically, the combat behaviors.
If I am to call the following within the RoutinePickFired Method, it does technically work, but is very clunky and very dirty, and straight does not work from time to time. (Too slow to re-start on the child task - thus failing to restart the botbase)
Code:
if (BotManager.Current.EnglishName != "Order Bot" && BotManager.Current.Name != "Lisbeth" && BotManager.Current.Name != "ExFateBot")
Task.Factory.StartNew(async () =>
{
Task.Run(async () =>
{
await TreeRoot.StopGently(" " + "Preparing to switch Combat Routine.");
BotManager.SetCurrent(BotManager.Bots.FirstOrDefault(r => r.Name == botBaseName));
Logger.SwitcharooLog("Starting Botbase!");
TreeRoot.Start();
});
});
However, Trying to clear hooks, replace them with ActionAlwaysFails, or anything short of stopping, and starting the botbase itself leads to the same issue: The previous combat routine behaviors being loaded and used.
Example:
Code:
RoutineManager.Current.ShutDown();
RoutineManager.Current.Dispose();
TreeHooks.Instance.ClearHook("PreCombatBuff");
TreeHooks.Instance.ClearHook("Heal");
TreeHooks.Instance.ClearHook("Pull");
TreeHooks.Instance.ClearHook("CombatBuff");
TreeHooks.Instance.ClearHook("Combat");
TreeHooks.Instance.ClearHook("Combat");
TreeHooks.Instance.ClearHook("Rest");
(OR Treehooks.Instance.ClearAll(); in place of all of the above clears)
RoutineManager.PreferedRoutine = Utilities.RoutineManager.GetRoutine();
RoutineManager.Current.Initialize();
Logger.SwitcharooLog("New Routine Chosen, restarting");
So, my question is this: What is the proper way to dispose of the combat routine being switched from, and replace it with the one being switched to?
Thank you!