Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
feat: removed the restriction of action sequencer.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Jul 25, 2023
1 parent 3a7bdd6 commit c19dd60
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 51 deletions.
5 changes: 0 additions & 5 deletions RotationSolver.Basic/Actions/IAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ public interface IAction : ITexture, IEnouthLevel
/// </summary>
uint SortKey { get; }

/// <summary>
/// Can be used in Action sequencer.
/// </summary>
bool IsActionSequencer { get; }

/// <summary>
/// Please don't use it.
/// </summary>
Expand Down
13 changes: 3 additions & 10 deletions RotationSolver/ActionSequencer/ActionCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ internal class ActionCondition : ICondition
public int Param2;
public float Time;

public bool IsTrue(ICustomRotation combo, bool isActionSequencer)
public bool IsTrue(ICustomRotation combo)
{
if (!isActionSequencer) return false;
if (!ConditionHelper.CheckBaseAction(combo, ID, ref _action)) return false;

var result = false;
Expand Down Expand Up @@ -77,19 +76,13 @@ public bool IsTrue(ICustomRotation combo, bool isActionSequencer)

string searchTxt = string.Empty;

public void Draw(ICustomRotation combo, bool isActionSequencer)
public void Draw(ICustomRotation combo)
{
ConditionHelper.CheckBaseAction(combo, ID, ref _action);

ImGuiHelper.DrawCondition(IsTrue(combo, isActionSequencer));
ImGuiHelper.DrawCondition(IsTrue(combo));
ImGui.SameLine();

if (!isActionSequencer)
{
ImGui.TextColored(ImGuiColors.DPSRed, LocalizationManager.RightLang.ActionSequencer_NotAllowed);
return;
}

var name = _action?.Name ?? string.Empty;
ImGui.SetNextItemWidth(Math.Max(80, ImGui.CalcTextSize(name).X + 30));

Expand Down
10 changes: 5 additions & 5 deletions RotationSolver/ActionSequencer/ConditionSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ namespace RotationSolver.ActionSequencer;

internal class ConditionSet : ICondition
{
public bool IsTrue(ICustomRotation combo, bool isActionSequencer) => Conditions.Count != 0 && (IsAnd ? Conditions.All(c => c.IsTrue(combo, isActionSequencer))
: Conditions.Any(c => c.IsTrue(combo, isActionSequencer)));
public bool IsTrue(ICustomRotation combo) => Conditions.Count != 0 && (IsAnd ? Conditions.All(c => c.IsTrue(combo))
: Conditions.Any(c => c.IsTrue(combo)));
public List<ICondition> Conditions { get; set; } = new List<ICondition>();
public bool IsAnd { get; set; }

[JsonIgnore]
public float Height => Conditions.Sum(c => c is ConditionSet ? c.Height + 10 : c.Height) + ICondition.DefaultHeight + 12;

public void Draw(ICustomRotation combo, bool isActionSequencer)
public void Draw(ICustomRotation combo)
{
if (ImGui.BeginChild("ConditionSet" + GetHashCode().ToString(), new Vector2(-1f, Height), true))
{
AddButton();

ImGui.SameLine();

ImGuiHelper.DrawCondition(IsTrue(combo, isActionSequencer));
ImGuiHelper.DrawCondition(IsTrue(combo));

ImGui.SameLine();
ImGui.SetNextItemWidth(65);
Expand All @@ -37,7 +37,7 @@ public void Draw(ICustomRotation combo, bool isActionSequencer)
ImGui.Separator();

var relay = Conditions;
if (ImGuiHelper.DrawEditorList(relay, i => i.Draw(combo, isActionSequencer)))
if (ImGuiHelper.DrawEditorList(relay, i => i.Draw(combo)))
{
Conditions = relay;
}
Expand Down
4 changes: 2 additions & 2 deletions RotationSolver/ActionSequencer/ICondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
internal interface ICondition
{
const float DefaultHeight = 33;
bool IsTrue(ICustomRotation rotation, bool isActionSequencer);
void Draw(ICustomRotation rotation, bool isActionSequencer);
bool IsTrue(ICustomRotation rotation);
void Draw(ICustomRotation rotation);
float Height { get; }
}
14 changes: 3 additions & 11 deletions RotationSolver/ActionSequencer/RotationCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ private void UpdateInfo(ICustomRotation rotation)
ConditionHelper.CheckMemberInfo(rotation, MethodName, ref _method);
}

public bool IsTrue(ICustomRotation rotation, bool isActionSequencer)
public bool IsTrue(ICustomRotation rotation)
{
if (!isActionSequencer) return false;

if (!Player.Available) return false;
UpdateInfo(rotation);

Expand Down Expand Up @@ -116,19 +114,13 @@ public bool IsTrue(ICustomRotation rotation, bool isActionSequencer)
public float Height => ICondition.DefaultHeight;

string searchTxt = string.Empty;
public void Draw(ICustomRotation rotation, bool isActionSequencer)
public void Draw(ICustomRotation rotation)
{
UpdateInfo(rotation);

ImGuiHelper.DrawCondition(IsTrue(rotation, isActionSequencer));
ImGuiHelper.DrawCondition(IsTrue(rotation));
ImGui.SameLine();

if (!isActionSequencer)
{
ImGui.TextColored(ImGuiColors.DPSRed, LocalizationManager.RightLang.ActionSequencer_NotAllowed);
return;
}

ConditionHelper.DrawByteEnum($"##Category{GetHashCode()}", ref ComboConditionType, EnumTranslations.ToName);

switch (ComboConditionType)
Expand Down
6 changes: 3 additions & 3 deletions RotationSolver/ActionSequencer/TargetCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private static StatusTexture[] AllStatus

public string CastingActionName = string.Empty;

public bool IsTrue(ICustomRotation combo, bool isActionSequencer)
public bool IsTrue(ICustomRotation combo)
{
if (!Player.Available) return false;

Expand Down Expand Up @@ -112,7 +112,7 @@ public bool IsTrue(ICustomRotation combo, bool isActionSequencer)
public float Height => ICondition.DefaultHeight;

string searchTxt = string.Empty;
public void Draw(ICustomRotation combo, bool isActionSequencer)
public void Draw(ICustomRotation combo)
{
ConditionHelper.CheckBaseAction(combo, ID, ref _action);

Expand All @@ -121,7 +121,7 @@ public void Draw(ICustomRotation combo, bool isActionSequencer)
Status = AllStatus.FirstOrDefault(a => a.ID == StatusId);
}

ImGuiHelper.DrawCondition(IsTrue(combo, isActionSequencer));
ImGuiHelper.DrawCondition(IsTrue(combo));
ImGui.SameLine();

var name = _action != null ? string.Format(LocalizationManager.RightLang.ActionSequencer_ActionTarget, _action.Name)
Expand Down
1 change: 0 additions & 1 deletion RotationSolver/Commands/RSCommands_Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ namespace RotationSolver.Commands
public static partial class RSCommands
{
static DateTime _lastClickTime = DateTime.MinValue;
static byte _loop = 0;
static StateCommandType _lastState;

internal static unsafe bool CanDoAnAction(bool isGCD)
Expand Down
2 changes: 0 additions & 2 deletions RotationSolver/Commands/RSCommands_OtherCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ private static void DoActionCommand(string str)
var actName = strs[0];
foreach (var iAct in RotationUpdater.RightRotationActions)
{
if (iAct is IBaseAction act && !act.IsActionSequencer) continue;

if (actName == iAct.Name)
{
DataCenter.AddCommandAction(iAct, time);
Expand Down
1 change: 0 additions & 1 deletion RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ internal partial class Strings
public string ActionSequencer_Player { get; set; } = "Player";
public string ActionSequencer_StatusSelf { get; set; } = "StatusSelf";
public string ActionSequencer_StatusSelfDesc { get; set; } = "StatusSelf";
public string ActionSequencer_NotAllowed { get; set; } = "This condition can't be used with this action.";
#endregion

#region Actions
Expand Down
11 changes: 4 additions & 7 deletions RotationSolver/UI/ImGuiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -660,14 +660,11 @@ private unsafe static void Display(this IBaseAction action, bool IsActive) => ac
Service.Config.Save();
}

if (action.IsActionSequencer)
{
ImGui.SameLine();
Spacing();
ImGui.SameLine();
Spacing();

OtherCommandType.DoActions.DisplayCommandHelp($"{action}-{5}",
type => string.Format(LocalizationManager.RightLang.ConfigWindow_Helper_InsertCommand, action, 5), false);
}
OtherCommandType.DoActions.DisplayCommandHelp($"{action}-{5}",
type => string.Format(LocalizationManager.RightLang.ConfigWindow_Helper_InsertCommand, action, 5), false);

if (Service.Config.InDebug)
{
Expand Down
4 changes: 2 additions & 2 deletions RotationSolver/UI/RotationConfigWindow_Action.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private static void DrawActionSequencerCondition()
{
conditionSet = set.Conditions[ActiveAction.ID] = new ConditionSet();
}
conditionSet?.Draw(rotation, ActiveAction.IsActionSequencer);
conditionSet?.Draw(rotation);
}

if (ImGui.CollapsingHeader(LocalizationManager.RightLang.ActionSequencer_DisableConditionSet))
Expand All @@ -80,7 +80,7 @@ private static void DrawActionSequencerCondition()
{
disableConditionSet = set.DiableConditions[ActiveAction.ID] = new ConditionSet();
}
disableConditionSet?.Draw(rotation, true);
disableConditionSet?.Draw(rotation);
}
}
}
4 changes: 2 additions & 2 deletions RotationSolver/Updaters/ActionSequencerUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static void UpdateActionSequencerAction()
var set = RightSet;
if (set == null) return;

DataCenter.DisabledAction = new HashSet<uint>(set.DiableConditions.Where(pair => pair.Value.IsTrue(customRotation, true))
DataCenter.DisabledAction = new HashSet<uint>(set.DiableConditions.Where(pair => pair.Value.IsTrue(customRotation))
.Select(pair => pair.Key));

bool find = false;
Expand All @@ -34,7 +34,7 @@ public static void UpdateActionSequencerAction()
var nextAct = allActions.FirstOrDefault(a => a.ID == conditionPair.Key);
if (nextAct == null) continue;

if (!conditionPair.Value.IsTrue(customRotation, nextAct.IsActionSequencer)) continue;
if (!conditionPair.Value.IsTrue(customRotation)) continue;

DataCenter.ActionSequencerAction = nextAct;
find = true;
Expand Down

0 comments on commit c19dd60

Please sign in to comment.