/// <summary> /// sets the character's active rotation. /// Print the help located in the specific rotation /// </summary> /// <param name="rb">an instance of the rotationbase</param> private void SetActiveRotation(RotationBase rb) { CLULogger.Log(" Greetings, level {0} user!", Me.Level); CLULogger.Log(" I am CLU."); CLULogger.Log(" I will create the perfect system for you."); CLULogger.Log(" I suggest we use the " + rb.Name + " rotation. Revision: " + rb.Revision); CLULogger.Log(" as I know you have " + rb.KeySpell); CLULogger.Log(" BotBase: {0} ({1})", BotManager.Current.Name, BotChecker.SupportedBotBase() ? "Supported" : "Currently Not Supported"); CLULogger.Log(rb.Help); CLULogger.Log(" You can Access CLU's Settings by clicking the CLASS CONFIG button"); CLULogger.Log(" Let's execute the plan!"); this._rotationBase = rb; this.PulseEvent = null; this.PulseEvent += rb.OnPulse; // Check for Instancebuddy and warn user that healing is not supported. if (BotChecker.BotBaseInUse("Instancebuddy") && this.ActiveRotation.GetType().BaseType == typeof(HealerRotationBase)) { CLULogger.Log(" [BotChecker] Instancebuddy Detected. *UNABLE TO HEAL WITH CLU*"); StopBot("You cannot use CLU with InstanceBuddy as Healer"); } if (this.ActiveRotation.GetType().BaseType == typeof(HealerRotationBase)) { CLULogger.TroubleshootLog(" [HealingChecker] HealerRotationBase Detected. *Activating Automatic HealableUnit refresh*"); IsHealerRotationActive = true; } }
public bool CreateBehaviors() { CLULogger.TroubleshootLog("CreateBehaviors called."); // let behaviors be notified if context changes. if (OnLocationContextChanged != null) { OnLocationContextChanged(this, new LocationContextEventArg(LocationContext, LastLocationContext)); } //Caching the context to not recreate same behaviors repeatedly. LastLocationContext = LocationContext; _rotationBase = null; if (_combatBehavior != null) { this._combatBehavior = new Decorator(ret => AllowPulse, new LockSelector(this.Rotation)); } if (_combatBuffBehavior != null) { this._combatBuffBehavior = new Decorator(ret => AllowPulse, new LockSelector(this.Medic)); } if (_preCombatBuffBehavior != null) { this._preCombatBuffBehavior = new Decorator(ret => AllowPulse, new LockSelector(this.PreCombat)); } if (_restBehavior != null) { this._restBehavior = new Decorator(ret => !(CLUSettings.Instance.NeverDismount && IsMounted) && !Me.IsFlying, new LockSelector(this.Resting)); } if (_pullBehavior != null) { this._pullBehavior = new Decorator(ret => AllowPulse, new LockSelector(this.Pulling)); } return(true); }
/// <summary>This will: loop assemblies, /// loop types, /// filter types that are a subclass of RotationBase and not the abstract, /// create an instance of a RotationBase subclass so we can interigate KeySpell within the RotationBase subclass, /// Check if the character has the Keyspell, /// Set the active rotation to the matching RotationBase subclass.</summary> private void QueryClassTree() { try { Type type = typeof(RotationBase); //no need to get ALL Assemblies, need only the executed ones IEnumerable <Type> types = Assembly.GetExecutingAssembly().GetTypes().Where(p => p.IsSubclassOf(type)); //_rotations.AddRange(new TypeLoader<RotationBase>(null)); this._rotations = new List <RotationBase>(); foreach (Type x in types) { ConstructorInfo constructorInfo = x.GetConstructor(new Type[] { }); if (constructorInfo != null) { var rb = constructorInfo.Invoke(new object[] { }) as RotationBase; if (rb != null && SpellManager.HasSpell(rb.KeySpellId)) { CLULogger.TroubleshootLog(" Using " + rb.Name + " rotation. Character has " + rb.KeySpell); this._rotations.Add(rb); } else { if (rb != null) { //TroubleshootLog(" Skipping " + rb.Name + " rotation. Character is missing " + rb.KeySpell); } } } } // If there is more than one rotation then display the selector for the user, otherwise just load the one and only. if (this._rotations.Count > 1) { string value = "null"; if ( GUIHelpers.RotationSelector ("[CLU] " + Version + " Rotation Selector", this._rotations, "Please select your prefered rotation:", ref value) == DialogResult.OK) { this.SetActiveRotation(this._rotations.First(x => value != null && x.Name == value)); } } else { if (this._rotations.Count == 0) { CLULogger.Log("Couldn't finde a rotation for you, Contact us!"); StopBot("Unable to find Active Rotation"); } else { RotationBase r = this._rotations.FirstOrDefault(); if (r != null) { CLULogger.Log("Found rotation: " + r.Name); this.SetActiveRotation(r); } } } } catch (ReflectionTypeLoadException ex) { var sb = new StringBuilder(); foreach (Exception exSub in ex.LoaderExceptions) { sb.AppendLine(exSub.Message); if (exSub is FileNotFoundException) { var exFileNotFound = exSub as FileNotFoundException; if (!string.IsNullOrEmpty(exFileNotFound.FusionLog)) { sb.AppendLine("CLU Log:"); sb.AppendLine(exFileNotFound.FusionLog); } } sb.AppendLine(); } string errorMessage = sb.ToString(); CLULogger.Log(" Woops, we could not set the rotation."); CLULogger.Log(errorMessage); StopBot(" Unable to find Active Rotation: " + ex); } }