From 09a337eca0555099aa303be04c75ea845611d765 Mon Sep 17 00:00:00 2001 From: LTS-FFXIV <127939494+LTS-FFXIV@users.noreply.github.com> Date: Sat, 19 Oct 2024 10:13:03 -0500 Subject: [PATCH] Refactor ActionUpdater Removed `break` statements in `ActionCondition.cs` and directly returned `false` if conditions are not met. Changed `NextGCDActionChanged` and `NextActionChanged` events in `ActionUpdater.cs` from nullable `Action?` to non-nullable `Action` with default empty delegates to avoid null reference issues. --- .../Configuration/Conditions/ActionCondition.cs | 2 -- RotationSolver/Updaters/ActionUpdater.cs | 11 ++++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/RotationSolver.Basic/Configuration/Conditions/ActionCondition.cs b/RotationSolver.Basic/Configuration/Conditions/ActionCondition.cs index baedd6883..a98156479 100644 --- a/RotationSolver.Basic/Configuration/Conditions/ActionCondition.cs +++ b/RotationSolver.Basic/Configuration/Conditions/ActionCondition.cs @@ -67,8 +67,6 @@ protected override bool IsTrueInside(ICustomRotation rotation) break; case ActionConditionType.CanUse: return _action.CanUse(out var act); - break; - } return false; } diff --git a/RotationSolver/Updaters/ActionUpdater.cs b/RotationSolver/Updaters/ActionUpdater.cs index 270fc1c22..d7ff19cca 100644 --- a/RotationSolver/Updaters/ActionUpdater.cs +++ b/RotationSolver/Updaters/ActionUpdater.cs @@ -17,15 +17,16 @@ static ActionUpdater() { EzIPC.Init(typeof(ActionUpdater), "RotationSolverReborn.ActionUpdater"); } - [EzIPCEvent] public static Action? NextGCDActionChanged; - [EzIPCEvent] public static Action? NextActionChanged; + [EzIPCEvent] public static Action NextGCDActionChanged = delegate { }; + [EzIPCEvent] public static Action NextActionChanged = delegate { }; private static IAction? _nextAction; - internal static IAction? NextAction + internal static IAction? NextAction { get => _nextAction; - set { - if (_nextAction != value) + set + { + if (_nextAction != value) { _nextAction = value; NextActionChanged?.Invoke(_nextAction?.ID ?? 0);