diff --git a/RotationSolver.Basic/Actions/BaseAction_BasicInfo.cs b/RotationSolver.Basic/Actions/BaseAction_BasicInfo.cs index 6aa824ac9..4cf4b1a37 100644 --- a/RotationSolver.Basic/Actions/BaseAction_BasicInfo.cs +++ b/RotationSolver.Basic/Actions/BaseAction_BasicInfo.cs @@ -88,13 +88,6 @@ public virtual unsafe uint MPNeed } } - public BaseAction(ActionID actionID) - : this(actionID, ActionOption.None) - { - - } - - public BaseAction(ActionID actionID, ActionOption option = ActionOption.None) { _action = Service.GetSheet().GetRow((uint)actionID); @@ -107,15 +100,5 @@ public BaseAction(ActionID actionID, ActionOption option = ActionOption.None) CoolDownGroup = _action.GetCoolDownGroup(); } - private static ActionOption GetOption(bool isFriendly = false, bool endSpecial = false, bool isEot = false, bool isTimeline = false) - { - ActionOption option = ActionOption.None; - if (isFriendly) option |= ActionOption.Friendly; - if (endSpecial) option |= ActionOption.EndSpecial; - if (isEot) option |= ActionOption.Eot; - if (isTimeline) option |= ActionOption.Friendly; - return option; - } - public override string ToString() => Name; } diff --git a/RotationSolver.Basic/Actions/BaseAction_Target.cs b/RotationSolver.Basic/Actions/BaseAction_Target.cs index 7b51d432c..281e258cc 100644 --- a/RotationSolver.Basic/Actions/BaseAction_Target.cs +++ b/RotationSolver.Basic/Actions/BaseAction_Target.cs @@ -23,7 +23,8 @@ public partial class BaseAction private uint _targetId = Service.Player?.ObjectId ?? 0; private Func, bool, BattleChara> _choiceTarget = null; - public Func, bool, BattleChara> ChoiceTarget + + internal Func, bool, BattleChara> ChoiceTarget { private get { @@ -35,7 +36,7 @@ private get internal Func, IEnumerable> FilterForHostiles { private get; set; } = null; - public StatusID[] TargetStatus { get; set; } = null; + public StatusID[] TargetStatus { get; internal set; } = null; internal static bool TankDefenseSelf(BattleChara chara) { diff --git a/RotationSolver.Basic/Actions/IBaseAction.cs b/RotationSolver.Basic/Actions/IBaseAction.cs index c0255beb7..5c31cfcc8 100644 --- a/RotationSolver.Basic/Actions/IBaseAction.cs +++ b/RotationSolver.Basic/Actions/IBaseAction.cs @@ -14,8 +14,13 @@ public interface IBaseAction : IAction float Range { get; } + [EditorBrowsable(EditorBrowsableState.Never)] bool IsFriendly { get; } + + [EditorBrowsable(EditorBrowsableState.Never)] bool IsTimeline { get; } + + [EditorBrowsable(EditorBrowsableState.Never)] bool IsEot { get; } EnemyPositional EnemyPositional { get; } @@ -123,7 +128,7 @@ public interface IBaseAction : IAction /// /// If target has these statuses from player self, this aciton will not used. /// - StatusID[] TargetStatus { get; set; } + StatusID[] TargetStatus { get; } BattleChara Target { get; } diff --git a/RotationSolver.Basic/Rotations/CustomRotation_BasicInfo.cs b/RotationSolver.Basic/Rotations/CustomRotation_BasicInfo.cs index 90af70998..5410f4237 100644 --- a/RotationSolver.Basic/Rotations/CustomRotation_BasicInfo.cs +++ b/RotationSolver.Basic/Rotations/CustomRotation_BasicInfo.cs @@ -1,4 +1,5 @@ -using Lumina.Excel.GeneratedSheets; +using Dalamud.Logging; +using Lumina.Excel.GeneratedSheets; namespace RotationSolver.Basic.Rotations; @@ -71,14 +72,27 @@ public bool IsEnabled public IAction AntiKnockbackAbility { get; private set; } - /// - /// Description about the actions. - /// - //public virtual SortedList DescriptionDict { get; } = new SortedList(); + public bool IsValid { get; } = false; + private protected CustomRotation() { IconID = IconSet.GetJobIcon(this); Configs = CreateConfiguration(); + + try + { + for (byte i = 0; i < 3; i++) + { + Ability(i, GCD(i, true, true), out _, true, true); + } + IsValid = true; + } + catch (Exception ex) + { + PluginLog.Warning(ex, $"The rotation {Name} is not valid, please tell to the author"); + IsValid = false; + } + } protected virtual IRotationConfigSet CreateConfiguration() diff --git a/RotationSolver.Basic/Rotations/ICustomRotation.cs b/RotationSolver.Basic/Rotations/ICustomRotation.cs index f0645a915..6a7fc6121 100644 --- a/RotationSolver.Basic/Rotations/ICustomRotation.cs +++ b/RotationSolver.Basic/Rotations/ICustomRotation.cs @@ -4,6 +4,8 @@ namespace RotationSolver.Basic.Rotations; public interface ICustomRotation : ITexture { + bool IsValid { get; } + ClassJob Job { get; } ClassJobID[] JobIDs { get; } diff --git a/RotationSolver/Localization/Strings.cs b/RotationSolver/Localization/Strings.cs index 81340531a..675ad1b5d 100644 --- a/RotationSolver/Localization/Strings.cs +++ b/RotationSolver/Localization/Strings.cs @@ -275,6 +275,7 @@ internal partial class Strings public string ConfigWindow_Control_NeedToEnable { get; set; } = " (Need to enable)"; public string ConfigWindow_Control_ClickToUse { get; set; } = "Click to use it!"; public string ConfigWindow_Rotation_BetaRotation { get; set; } = "Beta Rotation!"; + public string ConfigWindow_Rotation_InvalidRotation { get; set; } = "Invalid Rotation! Please contact to the author!"; public string ConfigWindow_Rotation_ResetToDefault { get; set; } = "Click to reset the rotation configuration to default!"; #endregion diff --git a/RotationSolver/RotationHelper.cs b/RotationSolver/RotationHelper.cs index 89922caed..35e4e3b63 100644 --- a/RotationSolver/RotationHelper.cs +++ b/RotationSolver/RotationHelper.cs @@ -131,7 +131,8 @@ public static bool IsAllowed(this Assembly assembly) } public static Vector4 GetColor(this ICustomRotation rotation) - => !rotation.IsAllowed(out _) ? ImGuiColors.DalamudViolet : rotation.IsBeta() + => ! rotation.IsValid ? ImGuiColors.DPSRed : + !rotation.IsAllowed(out _) ? ImGuiColors.DalamudViolet : rotation.IsBeta() ? ImGuiColors.DalamudOrange : ImGuiColors.DalamudWhite ; public static bool IsBeta(this ICustomRotation rotation) diff --git a/RotationSolver/UI/ImGuiHelper.cs b/RotationSolver/UI/ImGuiHelper.cs index 2dae058a3..494d5e8cb 100644 --- a/RotationSolver/UI/ImGuiHelper.cs +++ b/RotationSolver/UI/ImGuiHelper.cs @@ -457,6 +457,10 @@ public unsafe static void Display(this ICustomRotation rotation, ICustomRotation ImGui.PushStyleColor(ImGuiCol.Text, rotation.GetColor()); ImGui.Text(rotation.GetType().Assembly.GetName().Name); + if(!rotation.IsValid) + { + HoveredString(LocalizationManager.RightLang.ConfigWindow_Rotation_InvalidRotation); + } if (!rotation.IsAllowed(out _)) { var showStr = string.Format(LocalizationManager.RightLang.ConfigWindow_Helper_HighEndWarning, rotation) @@ -465,7 +469,7 @@ public unsafe static void Display(this ICustomRotation rotation, ICustomRotation HoveredString(showStr); } - if (rotation.IsBeta()) + else if (rotation.IsBeta()) { HoveredString(LocalizationManager.RightLang.ConfigWindow_Rotation_BetaRotation); } @@ -615,7 +619,7 @@ private unsafe static void Display(this IBaseAction action, bool IsActive) => ac ImGui.Text($"Can Use: {action.CanUse(out _, option)} "); ImGui.Text("Must Use:" + action.CanUse(out _, option | CanUseOption.MustUse).ToString()); ImGui.Text("Empty Use:" + action.CanUse(out _, option | CanUseOption.EmptyOrSkipCombo).ToString()); - ImGui.Text("Must & Empty Use:" + action.CanUse(out _, option | CanUseOption.MustUse | CanUseOption.EmptyOrSkipCombo).ToString()); + ImGui.Text("Must & Empty Use:" + action.CanUse(out _, option | CanUseOption.MustUseEmpty).ToString()); if (action.Target != null) { ImGui.Text("Target Name: " + action.Target.Name);