public static async Task <bool> RootLogic() { if (!CacheStaticLookUp.InitalizedCache) { CacheStaticLookUp.Update(); ObjectCacheManager.Initalize(); TargetManager.Initalize(); Movement.IgnoreTaxiCheck = false; //Simple Check if garrison can be accessed! if (Player.Level < 90 || Player.Inventory.GarrisonHearthstone == null) { GarrisonBase.Log("No access to garrison!"); TreeRoot.Stop("No Access to Garrison"); return(false); } } if (await Common.CheckCommonCoroutines()) { return(true); } //Do we need to hearth or fly to our garrison? if (await Common.PreChecks.BehaviorRoutine()) { return(true); } //Disable and reload UI if master plan is enabled.. //if (await Common.PreChecks.CheckAddons()) return true; //We need "open" the garrison up and initalize it.. (so we don't get errors trying to inject!) if (await Common.PreChecks.InitalizeGarrisonManager()) { return(true); } ////Inject our lua addon code for mission success function //if (!LuaEvents.LuaAddonInjected) //{ // if (LuaCommands.TestLuaInjectionCode()) // {//Prevent multiple injections by checking simple function return! // LuaEvents.LuaAddonInjected = true; // } // else // { // await LuaEvents.InjectLuaAddon(); // return true; // } //} if (!InitalizedBehaviorList) { InitalizeBehaviorsList(); } //Check for next behavior if (CurrentBehavior == null) { while (Behaviors.Count > 0) { if (!Behaviors[0].CheckCriteria()) { Behaviors.RemoveAt(0); } else { CurrentBehavior = Behaviors[0]; CurrentBehavior.Initalize(); break; } } } if (CurrentBehavior != null) { //Check for any switch behaviors.. (override current behavior temporarly) if (SwitchBehaviors.Count > 0 && SwitchBehavior == null) { while (SwitchBehaviors.Count > 0) { if (!SwitchBehaviors[0].CheckCriteria()) { SwitchBehaviors.RemoveAt(0); } else { SwitchBehavior = SwitchBehaviors[0]; break; } } } if (SwitchBehavior != null && CurrentBehavior != SwitchBehavior) { GarrisonBase.Debug("Switching behaviors to {0}", SwitchBehavior.Type); CurrentBehavior = SwitchBehavior; CurrentBehavior.Initalize(); } bool x = await CurrentBehavior.BehaviorRoutine(); if (x && !CurrentBehavior.IsDone) { return(true); } GarrisonBase.Debug( !x ? "Finishing Behavior {0} because it returned false!" : "Finishing Behavior {0} because IsDone is true", CurrentBehavior.Type); if (!CurrentBehavior.Disposed) { CurrentBehavior.Dispose(); } if (SwitchBehavior != null && CurrentBehavior.Equals(SwitchBehavior)) { CurrentBehavior = Behaviors[0]; CurrentBehavior.Initalize(); SwitchBehaviors.RemoveAt(0); SwitchBehavior = null; } else { Behaviors.RemoveAt(0); CurrentBehavior = null; } return(true); } //if (Common.PreChecks.DisabledMasterPlanAddon) //{ // Common.PreChecks.ShouldCheckAddons = false; // LuaCommands.EnableAddon("MasterPlan"); // LuaCommands.ReloadUI(); // Common.PreChecks.DisabledMasterPlanAddon = false; // await Coroutine.Wait(6000, () => StyxWoW.IsInGame); // return true; //} TreeRoot.StatusText = "GarrisonBase is finished!"; TreeRoot.Stop(); return(false); }