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

Commit

Permalink
fix: change for ECommons.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed May 18, 2023
1 parent 81eb558 commit b5054a5
Show file tree
Hide file tree
Showing 19 changed files with 73 additions and 95 deletions.
11 changes: 6 additions & 5 deletions RotationSolver.Basic/Actions/BaseAction_Target.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Logging;
using ECommons.DalamudServices;
using ECommons.GameHelpers;
using FFXIVClientStructs.FFXIV.Client.Game;

Expand Down Expand Up @@ -91,7 +92,7 @@ private bool FindTarget(bool mustUse, out BattleChara target)
}
else
{
target = Service.TargetManager.Target is BattleChara battle ? battle : player;
target = Svc.Targets.Target is BattleChara battle ? battle : player;
return true;
}
}
Expand Down Expand Up @@ -150,11 +151,11 @@ private bool TargetAreaFriend(float range, bool mustUse, PlayerCharacter player)
//如果用户不想使用自动友方地面放置功能
if (!Configuration.PluginConfiguration.GetValue(SettingsCommand.UseGroundBeneficialAbility)) return false;

if (Service.Config.BeneficialAreaOnTarget && Service.TargetManager.Target != null)
if (Service.Config.BeneficialAreaOnTarget && Svc.Targets.Target != null)
{
_position = Service.TargetManager.Target.Position;
_position = Svc.Targets.Target.Position;
}
else if (Service.TargetManager.Target is BattleChara b && b.DistanceToPlayer() < range &&
else if (Svc.Targets.Target is BattleChara b && b.DistanceToPlayer() < range &&
b.IsBoss() && b.HasPositional() && b.HitboxRadius <= 8)
{
_position = b.Position;
Expand Down Expand Up @@ -262,7 +263,7 @@ private bool TargetHostile(float range, bool mustUse, int aoeCount, out BattleCh
//如果不用自动找目标,那就直接返回。
if (DataCenter.StateType == StateCommandType.Manual)
{
if (Service.TargetManager.Target is BattleChara b && b.IsNPCEnemy() && b.DistanceToPlayer() <= range)
if (Svc.Targets.Target is BattleChara b && b.IsNPCEnemy() && b.DistanceToPlayer() <= range)
{
return TargetHostileManual(b, mustUse, aoeCount, out target);
}
Expand Down
9 changes: 5 additions & 4 deletions RotationSolver.Basic/Data/MacroItem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
using ECommons.DalamudServices;
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
using FFXIVClientStructs.FFXIV.Client.UI.Shell;

namespace RotationSolver.Basic.Data;
Expand All @@ -20,8 +21,8 @@ public bool StartUseMacro()
{
if (RaptureShellModule.Instance->MacroCurrentLine > -1) return false;

_lastTarget = Service.TargetManager.Target;
Service.TargetManager.SetTarget(Target);
_lastTarget = Svc.Targets.Target;
Svc.Targets.SetTarget(Target);
RaptureShellModule.Instance->ExecuteMacro(Macro);

IsRunning = true;
Expand All @@ -32,7 +33,7 @@ public bool EndUseMacro()
{
if (RaptureShellModule.Instance->MacroCurrentLine > -1) return false;

Service.TargetManager.SetTarget(_lastTarget);
Svc.Targets.SetTarget(_lastTarget);

IsRunning = false;
return true;
Expand Down
3 changes: 2 additions & 1 deletion RotationSolver.Basic/DataCenter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Logging;
using ECommons.DalamudServices;
using ECommons.GameHelpers;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.Fate;
Expand Down Expand Up @@ -255,7 +256,7 @@ public static float RatioOfMembersIn2minsBurst
if (member.Level >= burstInfo.Level)
{
var tar = burstInfo.IsOnHostile
&& Service.TargetManager.Target is BattleChara b ? b
&& Svc.Targets.Target is BattleChara b ? b
: Player.Object;
if (tar.HasStatus(false, burstInfo.Status)
&& !tar.WillStatusEndGCD(0, 0, false, burstInfo.Status))
Expand Down
3 changes: 2 additions & 1 deletion RotationSolver.Basic/Rotations/CustomRotation_OtherInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Dalamud;
using Dalamud.Game.ClientState.Objects.SubKinds;
using ECommons.DalamudServices;

namespace RotationSolver.Basic.Rotations;
public abstract partial class CustomRotation
Expand Down Expand Up @@ -74,7 +75,7 @@ public abstract partial class CustomRotation
/// <summary>
/// The player's target.
/// </summary>
protected static BattleChara Target => Service.TargetManager.Target is BattleChara b ? b : Player;
protected static BattleChara Target => Svc.Targets.Target is BattleChara b ? b : Player;

/// <summary>
/// Shortcut for Target.IsDying();
Expand Down
41 changes: 6 additions & 35 deletions RotationSolver.Basic/Service.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
using Dalamud;
using Dalamud.Data;
using Dalamud.Game;
using Dalamud.Game.ClientState;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.GamePad;
using Dalamud.Game.ClientState.JobGauge;
using Dalamud.Game.ClientState.Keys;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Game.ClientState.Party;
using Dalamud.Game.Command;
using Dalamud.Game.DutyState;
using Dalamud.Game.Gui;
using Dalamud.Game.Gui.Dtr;
using Dalamud.Game.Gui.FlyText;
using Dalamud.Game.Gui.Toast;
using Dalamud.Hooking;
using Dalamud.IoC;
using Dalamud.Plugin;
using Dalamud.Utility.Signatures;
using ECommons.DalamudServices;
using FFXIVClientStructs.Attributes;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.Control;
using ImGuiScene;
using Lumina.Excel;
using RotationSolver.Basic.Configuration;
Expand Down Expand Up @@ -53,7 +38,7 @@ public class Service : IDisposable
public Service()
{
SignatureHelper.Initialise(this);
Framework.Update += Framework_Update;
Svc.Framework.Update += Framework_Update;
_countdownTimerHook?.Enable();
}

Expand Down Expand Up @@ -86,7 +71,7 @@ protected virtual void Dispose(bool disposing)
if (disposing)
{
_countdownTimerHook?.Dispose();
Framework.Update -= Framework_Update;
Svc.Framework.Update -= Framework_Update;
}
_disposed = true;
}
Expand All @@ -109,27 +94,13 @@ public unsafe static IEnumerable<IntPtr> GetAddons<T>() where T : struct
.Where(ptr => ptr != IntPtr.Zero);
}

public static ExcelSheet<T> GetSheet<T>() where T : ExcelRow => DataManager.GetExcelSheet<T>();
public static ExcelSheet<T> GetSheet<T>() where T : ExcelRow => Svc.Data.GetExcelSheet<T>();

internal static TextureWrap GetTextureIcon(uint id) => DataManager.GetImGuiTextureIcon(id);
internal static TextureWrap GetTexture(string path) => DataManager.GetImGuiTexture(path);
internal static TextureWrap GetTextureIcon(uint id) => Svc.Data.GetImGuiTextureIcon(id);
internal static TextureWrap GetTexture(string path) => Svc.Data.GetImGuiTexture(path);

[PluginService]
private static DataManager DataManager { get; set; }

[PluginService]
public static TargetManager TargetManager { get; private set; }

[PluginService]
public static ToastGui ToastGui { get; private set; }
[PluginService]
public static FlyTextGui FlyTextGui { get; private set; }
[PluginService]
public static KeyState KeyState { get; private set; }
[PluginService]
public static GamepadState GamepadState { get; private set; }
[PluginService]
public static Framework Framework { get; private set; }
public static DtrBar DtrBar { get; private set; }

[PluginService]
public static DutyState DutyState { get; private set; }
Expand Down
5 changes: 3 additions & 2 deletions RotationSolver/ActionSequencer/TargetCondition.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ECommons.GameHelpers;
using ECommons.DalamudServices;
using ECommons.GameHelpers;
using RotationSolver.Localization;
using RotationSolver.TextureItems;
using RotationSolver.UI;
Expand Down Expand Up @@ -45,7 +46,7 @@ public bool IsTrue(ICustomRotation combo, bool isActionSequencer)
}
else
{
tar = IsTarget ? Service.TargetManager.Target as BattleChara : Player.Object;
tar = IsTarget ? Svc.Targets.Target as BattleChara : Player.Object;
tar ??= Player.Object;
}

Expand Down
8 changes: 4 additions & 4 deletions RotationSolver/Commands/RSCommands_Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static void DoAction()
{
if ((_loop %= 5) == 0)
{
Service.ToastGui.ShowError(string.Format(LocalizationManager.RightLang.HighEndBan, str));
Svc.Toasts.ShowError(string.Format(LocalizationManager.RightLang.HighEndBan, str));
}
_loop++;
return;
Expand All @@ -73,11 +73,11 @@ public static void DoAction()
//Svc.Chat.Print($"{act}, {act.Target.Name}, {ActionUpdater.AbilityRemainCount}, {ActionUpdater.WeaponElapsed}");
#endif
//Change Target
if (((Service.TargetManager.Target?.IsNPCEnemy() ?? true)
|| Service.TargetManager.Target?.GetObjectKind() == Dalamud.Game.ClientState.Objects.Enums.ObjectKind.Treasure)
if (((Svc.Targets.Target?.IsNPCEnemy() ?? true)
|| Svc.Targets.Target?.GetObjectKind() == Dalamud.Game.ClientState.Objects.Enums.ObjectKind.Treasure)
&& (act.Target?.IsNPCEnemy() ?? false))
{
Service.TargetManager.SetTarget(act.Target);
Svc.Targets.SetTarget(act.Target);
}
}

Expand Down
4 changes: 2 additions & 2 deletions RotationSolver/Commands/RSCommands_OtherCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private static void ToggleActionCommand(string str)
{
act.IsEnabled = !act.IsEnabled;

//Service.ToastGui.ShowQuest(string.Format(LocalizationManager.RightLang.Commands_InsertAction, time),
//Svc.Toasts.ShowQuest(string.Format(LocalizationManager.RightLang.Commands_InsertAction, time),
// new Dalamud.Game.Gui.Toast.QuestToastOptions()
// {
// IconId = act.IconID,
Expand All @@ -81,7 +81,7 @@ private static void DoActionCommand(string str)
{
DataCenter.AddCommandAction(iAct, time);

Service.ToastGui.ShowQuest(string.Format(LocalizationManager.RightLang.Commands_InsertAction, time),
Svc.Toasts.ShowQuest(string.Format(LocalizationManager.RightLang.Commands_InsertAction, time),
new Dalamud.Game.Gui.Toast.QuestToastOptions()
{
IconId = iAct.IconID,
Expand Down
5 changes: 3 additions & 2 deletions RotationSolver/Commands/RSCommands_StateSpecialCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ECommons.GameHelpers;
using ECommons.DalamudServices;
using ECommons.GameHelpers;
using RotationSolver.Localization;

namespace RotationSolver.Commands;
Expand All @@ -13,7 +14,7 @@ private static void UpdateToast()
{
if (!Service.Config.ShowInfoOnToast) return;

Service.ToastGui.ShowQuest(" " + EntryString, new Dalamud.Game.Gui.Toast.QuestToastOptions()
Svc.Toasts.ShowQuest(" " + EntryString, new Dalamud.Game.Gui.Toast.QuestToastOptions()
{
IconId = 101,
});
Expand Down
12 changes: 6 additions & 6 deletions RotationSolver/UI/ControlWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ static void DrawIAction(nint handle, string id, float width, SpecialCommandType
{
InputUpdater.RecordingTime = DateTime.Now;
InputUpdater.RecordingSpecialType = command;
Service.ToastGui.ShowQuest($"Recording: {command}",
Svc.Toasts.ShowQuest($"Recording: {command}",
new Dalamud.Game.Gui.Toast.QuestToastOptions()
{
IconId = 101,
Expand All @@ -375,7 +375,7 @@ static void DrawIAction(nint handle, string id, float width, SpecialCommandType
OtherConfiguration.InputConfig.ButtonSpecial.Remove(command);
OtherConfiguration.SaveInputConfig();

Service.ToastGui.ShowQuest($"Clear Recording: {command}",
Svc.Toasts.ShowQuest($"Clear Recording: {command}",
new Dalamud.Game.Gui.Toast.QuestToastOptions()
{
IconId = 101,
Expand All @@ -401,7 +401,7 @@ static void DrawIAction(nint handle, string id, float width, StateCommandType co
{
InputUpdater.RecordingTime = DateTime.Now;
InputUpdater.RecordingStateType = command;
Service.ToastGui.ShowQuest($"Recording: {command}",
Svc.Toasts.ShowQuest($"Recording: {command}",
new Dalamud.Game.Gui.Toast.QuestToastOptions()
{
IconId = 101,
Expand All @@ -414,7 +414,7 @@ static void DrawIAction(nint handle, string id, float width, StateCommandType co
OtherConfiguration.InputConfig.ButtonState.Remove(command);
OtherConfiguration.SaveInputConfig();

Service.ToastGui.ShowQuest($"Clear Recording: {command}",
Svc.Toasts.ShowQuest($"Clear Recording: {command}",
new Dalamud.Game.Gui.Toast.QuestToastOptions()
{
IconId = 101,
Expand Down Expand Up @@ -576,7 +576,7 @@ static unsafe void DrawNextAction(float gcd, float ability, float width)
{
InputUpdater.RecordingTime = DateTime.Now;
InputUpdater.RecordingDoAction = true;
Service.ToastGui.ShowQuest($"Recording: Do Action",
Svc.Toasts.ShowQuest($"Recording: Do Action",
new Dalamud.Game.Gui.Toast.QuestToastOptions()
{
IconId = 101,
Expand All @@ -589,7 +589,7 @@ static unsafe void DrawNextAction(float gcd, float ability, float width)
OtherConfiguration.InputConfig.ButtonDoAction = null;
OtherConfiguration.SaveInputConfig();

Service.ToastGui.ShowQuest($"Clear Recording: Do Action",
Svc.Toasts.ShowQuest($"Clear Recording: Do Action",
new Dalamud.Game.Gui.Toast.QuestToastOptions()
{
IconId = 101,
Expand Down
4 changes: 2 additions & 2 deletions RotationSolver/UI/OverlayWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ private static void DrawPositional()

var target = ActionUpdater.NextGCDAction?.Target?.IsNPCEnemy() ?? false
? ActionUpdater.NextGCDAction.Target
: Service.TargetManager.Target?.IsNPCEnemy() ?? false
? Service.TargetManager.Target
: Svc.Targets.Target?.IsNPCEnemy() ?? false
? Svc.Targets.Target
: null;

if(target == null) return;
Expand Down
10 changes: 5 additions & 5 deletions RotationSolver/UI/RotationConfigWindow_Debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,17 @@ private unsafe void DrawParty()

private unsafe void DrawTargetData()
{
if(Service.TargetManager.Target != null)
if(Svc.Targets.Target != null)
{
ImGui.Text("Kind: " + Service.TargetManager.Target.GetObjectKind().ToString());
ImGui.Text("SubKind: " + Service.TargetManager.Target.GetBattleNPCSubKind().ToString());
var owner = Svc.Objects.SearchById(Service.TargetManager.Target.OwnerId);
ImGui.Text("Kind: " + Svc.Targets.Target.GetObjectKind().ToString());
ImGui.Text("SubKind: " + Svc.Targets.Target.GetBattleNPCSubKind().ToString());
var owner = Svc.Objects.SearchById(Svc.Targets.Target.OwnerId);
if(owner != null)
{
ImGui.Text("Owner: " + owner.Name.ToString());
}
}
if (Service.TargetManager.Target is BattleChara b)
if (Svc.Targets.Target is BattleChara b)
{
ImGui.Text("HP: " + b.CurrentHp + " / " + b.MaxHp);
ImGui.Text("Is Boss: " + b.IsBoss().ToString());
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Updaters/ActionUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ internal static void UpdateNextAction()
{
string positional = GcdAction.EnemyPositional.ToName();
if (Service.Config.SayPositional) SpeechHelper.Speak(positional);
if (Service.Config.ToastPositional) Service.ToastGui.ShowQuest(" " + positional, new Dalamud.Game.Gui.Toast.QuestToastOptions()
if (Service.Config.ToastPositional) Svc.Toasts.ShowQuest(" " + positional, new Dalamud.Game.Gui.Toast.QuestToastOptions()
{
IconId = GcdAction.IconID,
});
Expand Down
Loading

0 comments on commit b5054a5

Please sign in to comment.