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

Commit

Permalink
feat: add OnTerritoryChanged method for all rotations.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Apr 26, 2023
1 parent 14397b5 commit cc57fec
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions RotationSolver.Basic/Rotations/CustomRotation_BasicInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,7 @@ public virtual void DisplayStatus()
ImGui.TextWrapped($"If you want to Display some extra information on this panel. Please override {nameof(DisplayStatus)} method!");
}

public virtual void OnTerritoryChanged() { }

public override string ToString() => RotationName;
}
5 changes: 5 additions & 0 deletions RotationSolver.Basic/Rotations/ICustomRotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,9 @@ public interface ICustomRotation : ITexture
/// This is an <seealso cref="ImGui"/> method for display the rotation status on Window.
/// </summary>
void DisplayStatus();

/// <summary>
/// It occur when territory changed or rotation changed.
/// </summary>
void OnTerritoryChanged();
}
7 changes: 6 additions & 1 deletion RotationSolver/Updaters/RotationUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,12 @@ public static void UpdateRotation()
{
if (!group.classJobIds.Contains(nowJob)) continue;

RightNowRotation = GetChooseRotation(group);
var rotation = GetChooseRotation(group);
if (rotation != RightNowRotation)
{
rotation?.OnTerritoryChanged();
}
RightNowRotation = rotation;
RightRotationActions = RightNowRotation.AllActions;
return;
}
Expand Down
10 changes: 10 additions & 0 deletions RotationSolver/Updaters/SocialUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Logging;
using FFXIVClientStructs.FFXIV.Client.UI;
using Lumina.Excel.GeneratedSheets;
using RotationSolver.Commands;
Expand Down Expand Up @@ -77,6 +78,15 @@ static void ClientState_TerritoryChanged(object sender, ushort e)
InPvp = territory.IsPvpZone;
DataCenter.TerritoryContentType = (TerritoryContentType)(territory?.ContentFinderCondition?.Value?.ContentType?.Value?.RowId ?? 0);
DataCenter.InHighEndDuty = HighEndDuties.Any(t => t.RowId == territory.RowId);

try
{
RotationUpdater.RightNowRotation?.OnTerritoryChanged();
}
catch(Exception ex)
{
PluginLog.Error(ex, "Failed on Territory changed.");
}
}

static void DutyState_DutyStarted(object sender, ushort e)
Expand Down

0 comments on commit cc57fec

Please sign in to comment.