From 57ac9992ef3019e09b3686e1c911392f2625892f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E6=B0=B4?= <1123993881@qq.com> Date: Sun, 19 Mar 2023 21:18:42 +0800 Subject: [PATCH] fix: moving target choice. --- .../Rotations/CustomRotation_BasicInfo.cs | 2 +- RotationSolver.Basic/Rotations/CustomRotation_Invoke.cs | 5 +++-- RotationSolver.Basic/Rotations/ICustomRotation.cs | 1 - RotationSolver.Default/Tank/GNB_Default.cs | 5 ++--- RotationSolver/RotationSolverPlugin.cs | 6 ++---- RotationSolver/UI/ControlWindow.cs | 9 +++++++-- RotationSolver/UI/OverlayWindow.cs | 3 ++- RotationSolver/UI/RotationConfigWindow_Control.cs | 2 +- RotationSolver/Updaters/ActionUpdater.cs | 2 -- RotationSolver/Updaters/MajorUpdater.cs | 1 + 10 files changed, 19 insertions(+), 17 deletions(-) diff --git a/RotationSolver.Basic/Rotations/CustomRotation_BasicInfo.cs b/RotationSolver.Basic/Rotations/CustomRotation_BasicInfo.cs index 5c8fca91b..9434e3478 100644 --- a/RotationSolver.Basic/Rotations/CustomRotation_BasicInfo.cs +++ b/RotationSolver.Basic/Rotations/CustomRotation_BasicInfo.cs @@ -41,7 +41,7 @@ public bool IsEnabled public IRotationConfigSet Configs { get; } - public BattleChara MoveTarget { get; private set; } + public static BattleChara MoveTarget { get; private set; } public virtual string Description { get; } = string.Empty; diff --git a/RotationSolver.Basic/Rotations/CustomRotation_Invoke.cs b/RotationSolver.Basic/Rotations/CustomRotation_Invoke.cs index 89c4987ee..594d5c4ef 100644 --- a/RotationSolver.Basic/Rotations/CustomRotation_Invoke.cs +++ b/RotationSolver.Basic/Rotations/CustomRotation_Invoke.cs @@ -17,8 +17,9 @@ public bool TryInvoke(out IAction newAction, out IAction gcdAction) var role = Job.GetJobRole(); ActionMoveForwardGCD = MoveForwardGCD(out var act) ? act : null; - ActionMoveForwardAbility = MoveForwardAbility(1, out act, recordTarget: false) ? act : null; - MoveTarget = act is IBaseAction a ? a.Target : null; + var movingTarget = MoveForwardAbility(1, out act, recordTarget: false); + ActionMoveForwardAbility = movingTarget ? act : null; + MoveTarget = (movingTarget && act is IBaseAction a) ? a.Target : null; ActionMoveBackAbility = MoveBackAbility(DataCenter.AbilityRemainCount, out act) ? act : null; diff --git a/RotationSolver.Basic/Rotations/ICustomRotation.cs b/RotationSolver.Basic/Rotations/ICustomRotation.cs index 0b285f841..64c7bd3dd 100644 --- a/RotationSolver.Basic/Rotations/ICustomRotation.cs +++ b/RotationSolver.Basic/Rotations/ICustomRotation.cs @@ -18,7 +18,6 @@ public interface ICustomRotation : ITexture string RotationName { get; } IRotationConfigSet Configs { get; } MedicineType MedicineType { get; } - BattleChara MoveTarget { get; } IBaseAction[] AllBaseActions { get; } IAction[] AllActions { get; } diff --git a/RotationSolver.Default/Tank/GNB_Default.cs b/RotationSolver.Default/Tank/GNB_Default.cs index 84f5f65f1..01a3cf1fc 100644 --- a/RotationSolver.Default/Tank/GNB_Default.cs +++ b/RotationSolver.Default/Tank/GNB_Default.cs @@ -100,9 +100,6 @@ protected override bool DefenseSingleAbility(byte abilitiesRemaining, out IActio { if (abilitiesRemaining == 2) { - //10 - if (HeartofStone.CanUse(out act)) return true; - //30 if (Nebula.CanUse(out act)) return true; @@ -112,6 +109,8 @@ protected override bool DefenseSingleAbility(byte abilitiesRemaining, out IActio //10 if (Camouflage.CanUse(out act)) return true; } + //10 + if (HeartofStone.CanUse(out act)) return true; if (Reprisal.CanUse(out act)) return true; diff --git a/RotationSolver/RotationSolverPlugin.cs b/RotationSolver/RotationSolverPlugin.cs index 91b08ef1c..c5128b674 100644 --- a/RotationSolver/RotationSolverPlugin.cs +++ b/RotationSolver/RotationSolverPlugin.cs @@ -59,7 +59,6 @@ public unsafe RotationSolverPlugin(DalamudPluginInterface pluginInterface) ChangeUITranslation(); RotationUpdater.GetAllCustomRotations(); - OpenControlWindow(); } @@ -102,9 +101,8 @@ internal static void OpenConfigWindow() _comboConfigWindow.Toggle(); } - internal static void OpenControlWindow() + internal static void UpdateControlWindow() { - _controlWindow.IsOpen = Service.Config.ShowControlWindow; + _controlWindow.IsOpen = MajorUpdater.IsValid && Service.Config.ShowControlWindow; } - } diff --git a/RotationSolver/UI/ControlWindow.cs b/RotationSolver/UI/ControlWindow.cs index e6ed314fd..899502037 100644 --- a/RotationSolver/UI/ControlWindow.cs +++ b/RotationSolver/UI/ControlWindow.cs @@ -133,7 +133,12 @@ private static void DrawActionCooldown(IAction act) DrawIAction(act, width); ImGuiHelper.HoveredString(act.Name); - if (act.IsCoolingDown) + if (!act.EnoughLevel) + { + ImGui.GetWindowDrawList().AddRectFilled(new Vector2(pos.X, pos.Y) + winPos, + new Vector2(pos.X + width, pos.Y + width) + winPos, progressCol); + } + else if (act.IsCoolingDown) { var ratio = recast == 0 ? 0 : elapsed % recast / recast; ImGui.GetWindowDrawList().AddRectFilled(new Vector2(pos.X + width * ratio, pos.Y) + winPos, @@ -146,7 +151,7 @@ private static void DrawActionCooldown(IAction act) TextShade(fontPos, time, 1.5f, white, black); } - if(act is IBaseAction bAct && bAct.MaxCharges > 1) + if(act.EnoughLevel && act is IBaseAction bAct && bAct.MaxCharges > 1) { for (int i = 0; i < bAct.CurrentCharges; i++) { diff --git a/RotationSolver/UI/OverlayWindow.cs b/RotationSolver/UI/OverlayWindow.cs index aa829c99f..896dadce6 100644 --- a/RotationSolver/UI/OverlayWindow.cs +++ b/RotationSolver/UI/OverlayWindow.cs @@ -5,6 +5,7 @@ using RotationSolver.Basic; using RotationSolver.Basic.Data; using RotationSolver.Basic.Helpers; +using RotationSolver.Rotations.CustomRotation; using RotationSolver.Updaters; using System.Numerics; @@ -98,7 +99,7 @@ private unsafe static void DrawMoveTarget() var c = Service.Config.MovingTargetColor; var color = ImGui.GetColorU32(new Vector4(c.X, c.Y, c.Z, 1)); - var tar = RotationUpdater.RightNowRotation?.MoveTarget; + var tar = CustomRotation.MoveTarget; if (tar == null || tar == Service.Player) return; DrawTarget(tar, color, 8, out var scrPos); diff --git a/RotationSolver/UI/RotationConfigWindow_Control.cs b/RotationSolver/UI/RotationConfigWindow_Control.cs index e269065b9..efa2bae46 100644 --- a/RotationSolver/UI/RotationConfigWindow_Control.cs +++ b/RotationSolver/UI/RotationConfigWindow_Control.cs @@ -15,7 +15,7 @@ internal partial class RotationConfigWindow private void DrawControlTab() { DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_ShowControlWindow, - ref Service.Config.ShowControlWindow, otherThing: RotationSolverPlugin.OpenControlWindow); + ref Service.Config.ShowControlWindow); if (!Service.Config.ShowControlWindow) return; diff --git a/RotationSolver/Updaters/ActionUpdater.cs b/RotationSolver/Updaters/ActionUpdater.cs index f80095e16..524563741 100644 --- a/RotationSolver/Updaters/ActionUpdater.cs +++ b/RotationSolver/Updaters/ActionUpdater.cs @@ -16,7 +16,6 @@ internal static class ActionUpdater static RandomDelay _GCDDelay = new RandomDelay(() => (Service.Config.WeaponDelayMin, Service.Config.WeaponDelayMax)); - internal static IAction NextAction { get; private set; } internal static IBaseAction NextGCDAction { get; private set; } @@ -26,7 +25,6 @@ internal static class ActionUpdater internal static void UpdateNextAction() { - PlayerCharacter localPlayer = Service.Player; if (localPlayer == null) return; diff --git a/RotationSolver/Updaters/MajorUpdater.cs b/RotationSolver/Updaters/MajorUpdater.cs index 5b272dfe4..e304a13f7 100644 --- a/RotationSolver/Updaters/MajorUpdater.cs +++ b/RotationSolver/Updaters/MajorUpdater.cs @@ -15,6 +15,7 @@ internal static class MajorUpdater private static void FrameworkUpdate(Framework framework) { + RotationSolverPlugin.UpdateControlWindow(); if (!IsValid) return; //#if DEBUG