diff --git a/RotationSolver.Basic/Actions/BaseAction_Target.cs b/RotationSolver.Basic/Actions/BaseAction_Target.cs index 2baeccfbf..9b9b83aef 100644 --- a/RotationSolver.Basic/Actions/BaseAction_Target.cs +++ b/RotationSolver.Basic/Actions/BaseAction_Target.cs @@ -280,7 +280,7 @@ private static bool TargetDeath(out BattleChara target) #region Target Hostile private bool TargetHostile(float range, bool mustUse, int aoeCount, out BattleChara target) { - if (DataCenter.StateType == StateCommandType.Manual) + if (DataCenter.IsManual) { if (Svc.Targets.Target is BattleChara b && b.IsNPCEnemy() && b.DistanceToPlayer() <= range) { @@ -355,7 +355,7 @@ private bool TargetSelf(bool mustUse, int aoeCount) } //not use when aoe. - if (DataCenter.StateType == StateCommandType.Manual) + if (DataCenter.IsManual) { if (!Service.Config.GetValue(SettingsCommand.UseAOEWhenManual) && !mustUse) return false; } diff --git a/RotationSolver.Basic/DataCenter.cs b/RotationSolver.Basic/DataCenter.cs index 6cecd9f32..bef4239da 100644 --- a/RotationSolver.Basic/DataCenter.cs +++ b/RotationSolver.Basic/DataCenter.cs @@ -193,7 +193,9 @@ public static float AbilityRemain static SpecialCommandType _specialType = SpecialCommandType.EndSpecial; public static SpecialCommandType SpecialType => SpecialTimeLeft < 0 ? SpecialCommandType.EndSpecial : _specialType; - public static StateCommandType StateType { get; set; } = StateCommandType.Cancel; + public static bool State { get; set; } = false; + + public static bool IsManual { get; set; } = false; public static void SetSpecialType(SpecialCommandType specialType) { diff --git a/RotationSolver.Basic/Rotations/CustomRotation_OtherInfo.cs b/RotationSolver.Basic/Rotations/CustomRotation_OtherInfo.cs index f34d4217b..219d6e36d 100644 --- a/RotationSolver.Basic/Rotations/CustomRotation_OtherInfo.cs +++ b/RotationSolver.Basic/Rotations/CustomRotation_OtherInfo.cs @@ -202,7 +202,18 @@ public abstract partial class CustomRotation /// /// /// - protected static StateCommandType StateType => DataCenter.StateType; + [Obsolete("Please use State or IsManual instead!", true)] + protected static StateCommandType StateType => StateCommandType.None; + + /// + /// True for On, false for off. + /// + protected static bool State => DataCenter.State; + + /// + /// Ture for Manual Target, false for Auto Target. + /// + protected static bool IsManual => DataCenter.IsManual; #endregion #region GCD diff --git a/RotationSolver/Commands/RSCommands_Actions.cs b/RotationSolver/Commands/RSCommands_Actions.cs index bea90441d..0f8e6b1ea 100644 --- a/RotationSolver/Commands/RSCommands_Actions.cs +++ b/RotationSolver/Commands/RSCommands_Actions.cs @@ -13,17 +13,16 @@ namespace RotationSolver.Commands public static partial class RSCommands { static DateTime _lastClickTime = DateTime.MinValue; - static StateCommandType _lastState; + static bool _lastState; internal static unsafe bool CanDoAnAction(bool isGCD) { - if (_lastState == StateCommandType.Cancel - || DataCenter.StateType == StateCommandType.Cancel) + if (!_lastState || !DataCenter.State) { - _lastState = DataCenter.StateType; + _lastState = DataCenter.State; return false; } - _lastState = DataCenter.StateType; + _lastState = DataCenter.State; if (!Player.Available) return false; @@ -76,7 +75,7 @@ public static void DoAction() //Svc.Chat.Print($"{act}, {act.Target.Name}, {ActionUpdater.AbilityRemainCount}, {ActionUpdater.WeaponElapsed}"); #endif //Change Target - if (act.Target != null && (Service.Config.TargetFriendly && DataCenter.StateType != StateCommandType.Manual || ((Svc.Targets.Target?.IsNPCEnemy() ?? true) + if (act.Target != null && (Service.Config.TargetFriendly && !DataCenter.IsManual || ((Svc.Targets.Target?.IsNPCEnemy() ?? true) || Svc.Targets.Target?.GetObjectKind() == Dalamud.Game.ClientState.Objects.Enums.ObjectKind.Treasure) && act.Target.IsNPCEnemy())) { @@ -113,14 +112,14 @@ static async void PulseSimulation(uint id) internal static void ResetSpecial() => DoSpecialCommandType(SpecialCommandType.EndSpecial, false); private static void CancelState() { - if (DataCenter.StateType != StateCommandType.Cancel) DoStateCommandType(StateCommandType.Cancel); + if (DataCenter.State) DoStateCommandType(StateCommandType.Cancel); } static float _lastCountdownTime = 0; internal static void UpdateRotationState() { if(ActionUpdater._cancelTime != DateTime.MinValue && - (DataCenter.StateType == StateCommandType.Cancel || DataCenter.InCombat)) + (!DataCenter.State || DataCenter.InCombat)) { ActionUpdater._cancelTime = DateTime.MinValue; } @@ -158,7 +157,7 @@ internal static void UpdateRotationState() else if (Service.Config.StartOnAttackedBySomeone && target != null && !target.IsDummy()) { - if(DataCenter.StateType == StateCommandType.Cancel) + if(!DataCenter.State) { DoStateCommandType(StateCommandType.Manual); } @@ -167,7 +166,7 @@ internal static void UpdateRotationState() else if (Service.Config.StartOnCountdown && Service.CountDownTime > 0) { _lastCountdownTime = Service.CountDownTime; - if (DataCenter.StateType == StateCommandType.Cancel) + if (!DataCenter.State) { DoStateCommandType(StateCommandType.Auto); } diff --git a/RotationSolver/Commands/RSCommands_StateSpecialCommand.cs b/RotationSolver/Commands/RSCommands_StateSpecialCommand.cs index 13dbfbb3c..434b7bd23 100644 --- a/RotationSolver/Commands/RSCommands_StateSpecialCommand.cs +++ b/RotationSolver/Commands/RSCommands_StateSpecialCommand.cs @@ -23,7 +23,7 @@ private static void UpdateToast() private static unsafe void DoStateCommandType(StateCommandType stateType) => DoOneCommandType(EnumTranslations.ToSayout, role => { - if (DataCenter.StateType == StateCommandType.Auto + if (DataCenter.State && !DataCenter.IsManual && stateType == StateCommandType.Auto) { Service.Config.TargetingIndex += 1; @@ -32,13 +32,28 @@ private static unsafe void DoStateCommandType(StateCommandType stateType) => DoO } if (Service.Config.ToggleManual - && DataCenter.StateType == StateCommandType.Manual + && DataCenter.State && DataCenter.IsManual && stateType == StateCommandType.Manual) { stateType = StateCommandType.Cancel; } - DataCenter.StateType = stateType; + switch (stateType) + { + case StateCommandType.Cancel: + DataCenter.State = false; + break; + + case StateCommandType.Auto: + DataCenter.IsManual = false; + DataCenter.State = true; + break; + + case StateCommandType.Manual: + DataCenter.IsManual = true; + DataCenter.State = true; + break; + } UpdateStateNamePlate(); @@ -52,7 +67,7 @@ public static unsafe void UpdateStateNamePlate() if (!Player.Available) return; Player.Object.SetNamePlateIcon( - DataCenter.StateType == StateCommandType.Cancel ? 0u : (uint)Service.Config.NamePlateIconId); + !DataCenter.State ? 0u : (uint)Service.Config.NamePlateIconId); } private static void DoSpecialCommandType(SpecialCommandType specialType, bool sayout = true) => DoOneCommandType(sayout ? EnumTranslations.ToSayout : (s, r) => string.Empty, role => diff --git a/RotationSolver/UI/ControlWindow.cs b/RotationSolver/UI/ControlWindow.cs index 459680fb9..e3929fe70 100644 --- a/RotationSolver/UI/ControlWindow.cs +++ b/RotationSolver/UI/ControlWindow.cs @@ -322,7 +322,17 @@ static void DrawCommandAction(uint iconId, StateCommandType command, Vector4 col ImGui.EndGroup(); - if (DataCenter.StateType == command) + bool isMatch = false; + switch (command) + { + case StateCommandType.Auto when DataCenter.State && !DataCenter.IsManual: + case StateCommandType.Manual when DataCenter.State && DataCenter.IsManual: + case StateCommandType.Cancel when !DataCenter.State: + isMatch = true; + break; + } + + if (isMatch) { var size = ImGui.GetItemRectSize(); var winPos = ImGui.GetWindowPos(); @@ -451,7 +461,7 @@ internal static (Vector2, Vector2) DrawIAction(IAction action, float width, floa var result = DrawIAction(texture.ImGuiHandle, width, action == null ? -1 : percent); if (action != null) ImGuiHelper.HoveredString(action.Name, () => { - if (DataCenter.StateType == StateCommandType.Cancel) + if (!DataCenter.State) { bool canDoIt = false; if(action is IBaseAction act) diff --git a/RotationSolver/UI/NextActionWindow.cs b/RotationSolver/UI/NextActionWindow.cs index 0a61e5fd5..1ca4871a7 100644 --- a/RotationSolver/UI/NextActionWindow.cs +++ b/RotationSolver/UI/NextActionWindow.cs @@ -20,7 +20,7 @@ public override void Draw() var strs = new List(3); if(Service.Config.GetValue(SettingsCommand.UseAOEAction) - && (DataCenter.StateType != StateCommandType.Manual + && (!DataCenter.IsManual || Service.Config.GetValue(SettingsCommand.UseAOEWhenManual))) { strs.Add("AOE");