From 982cea6b09445e8d8db5864df57e50d3c7a302b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E6=B0=B4?= <1123993881@qq.com> Date: Thu, 18 May 2023 20:28:46 +0800 Subject: [PATCH] fix: remove object Table. --- RotationSolver.Basic/Actions/BaseAction_ActionInfo.cs | 5 +++-- RotationSolver.Basic/Data/ActionEffectSet.cs | 9 +++++---- RotationSolver.Basic/Helpers/TargetFilter.cs | 2 +- RotationSolver.Basic/Rotations/Basic/SGE_Base.cs | 2 +- RotationSolver.Basic/Service.cs | 3 --- RotationSolver/UI/RotationConfigWindow_Debug.cs | 6 +++--- RotationSolver/Updaters/PreviewUpdater.cs | 2 +- RotationSolver/Updaters/TargetUpdater.cs | 5 ++--- RotationSolver/Watcher.cs | 4 ++-- 9 files changed, 18 insertions(+), 20 deletions(-) diff --git a/RotationSolver.Basic/Actions/BaseAction_ActionInfo.cs b/RotationSolver.Basic/Actions/BaseAction_ActionInfo.cs index 8d85d2c23..7f81e21dc 100644 --- a/RotationSolver.Basic/Actions/BaseAction_ActionInfo.cs +++ b/RotationSolver.Basic/Actions/BaseAction_ActionInfo.cs @@ -1,4 +1,5 @@ -using ECommons.GameHelpers; +using ECommons.DalamudServices; +using ECommons.GameHelpers; using FFXIVClientStructs.FFXIV.Client.Game; namespace RotationSolver.Basic.Actions; @@ -149,7 +150,7 @@ public unsafe bool Use() { return ActionManager.Instance()->UseActionLocation(ActionType.Spell, ID, Player.Object.ObjectId, &loc); } - else if(Service.ObjectTable.SearchById(_targetId) == null) + else if(Svc.Objects.SearchById(_targetId) == null) { return false; } diff --git a/RotationSolver.Basic/Data/ActionEffectSet.cs b/RotationSolver.Basic/Data/ActionEffectSet.cs index cf84d3e0d..7f8078bfe 100644 --- a/RotationSolver.Basic/Data/ActionEffectSet.cs +++ b/RotationSolver.Basic/Data/ActionEffectSet.cs @@ -1,4 +1,5 @@ -using FFXIVClientStructs.FFXIV.Client.Game; +using ECommons.DalamudServices; +using FFXIVClientStructs.FFXIV.Client.Game; using Lumina.Excel.GeneratedSheets; using System.Collections; using Action = Lumina.Excel.GeneratedSheets.Action; @@ -18,14 +19,14 @@ public ActionEffectSet(uint sourceId, ActionEffectHeader* effectHeader, ActionEf { Type = effectHeader->actionType; Action = Service.GetSheet().GetRow(effectHeader->actionId); - Target = Service.ObjectTable.SearchById(effectHeader->animationTargetId); - Source = Service.ObjectTable.SearchById(sourceId); + Target = Svc.Objects.SearchById(effectHeader->animationTargetId); + Source = Svc.Objects.SearchById(sourceId); AnimationLock = effectHeader->animationLockTime; TargetEffects = new TargetEffect[effectHeader->NumTargets]; for (int i = 0; i < effectHeader->NumTargets; i++) { - TargetEffects[i] = new TargetEffect(Service.ObjectTable.SearchById(effectTargets[i]), effectArray + 8 * i); + TargetEffects[i] = new TargetEffect(Svc.Objects.SearchById(effectTargets[i]), effectArray + 8 * i); } } diff --git a/RotationSolver.Basic/Helpers/TargetFilter.cs b/RotationSolver.Basic/Helpers/TargetFilter.cs index bd784ebf7..f1cd2fceb 100644 --- a/RotationSolver.Basic/Helpers/TargetFilter.cs +++ b/RotationSolver.Basic/Helpers/TargetFilter.cs @@ -177,7 +177,7 @@ internal static IEnumerable ProvokeTarget(IEnumerable && (target.TargetObject?.IsValid() ?? false)) { //the target is not a tank role - if (Service.ObjectTable.SearchById(target.TargetObjectId) is BattleChara battle + if (Svc.Objects.SearchById(target.TargetObjectId) is BattleChara battle && !battle.IsJobCategory(JobRole.Tank) && (!needDistance || Vector3.Distance(target.Position, loc) > 5)) { diff --git a/RotationSolver.Basic/Rotations/Basic/SGE_Base.cs b/RotationSolver.Basic/Rotations/Basic/SGE_Base.cs index 99cb88078..66eedcd6e 100644 --- a/RotationSolver.Basic/Rotations/Basic/SGE_Base.cs +++ b/RotationSolver.Basic/Rotations/Basic/SGE_Base.cs @@ -72,7 +72,7 @@ protected static bool AddersgallEndAfterGCD(uint gctCount = 0, float offset = 0) return TargetFilter.FindAttackedTarget(targets, mustUse); }, - ActionCheck = (b, m) => Service.ObjectTable.OfType() + ActionCheck = (b, m) => Svc.Objects.OfType() .Where(o => o.CurrentHp > 0) .All(o => !o.HasStatus(true, StatusID.Kardion)), }; diff --git a/RotationSolver.Basic/Service.cs b/RotationSolver.Basic/Service.cs index 60c7b8eee..25a1177a1 100644 --- a/RotationSolver.Basic/Service.cs +++ b/RotationSolver.Basic/Service.cs @@ -117,9 +117,6 @@ public unsafe static IEnumerable GetAddons() where T : struct [PluginService] private static DataManager DataManager { get; set; } - [PluginService] - public static ObjectTable ObjectTable { get; private set; } - [PluginService] public static TargetManager TargetManager { get; private set; } diff --git a/RotationSolver/UI/RotationConfigWindow_Debug.cs b/RotationSolver/UI/RotationConfigWindow_Debug.cs index f936a6bf6..a9a049e7a 100644 --- a/RotationSolver/UI/RotationConfigWindow_Debug.cs +++ b/RotationSolver/UI/RotationConfigWindow_Debug.cs @@ -63,7 +63,7 @@ private unsafe void DrawStatus() foreach (var status in Player.Object.StatusList) { - var source = status.SourceId == Player.Object.ObjectId ? "You" : Service.ObjectTable.SearchById(status.SourceId) == null ? "None" : "Others"; + var source = status.SourceId == Player.Object.ObjectId ? "You" : Svc.Objects.SearchById(status.SourceId) == null ? "None" : "Others"; ImGui.Text($"{status.GameData.Name}: {status.StatusId} From: {source}"); } } @@ -100,7 +100,7 @@ private unsafe void DrawTargetData() { ImGui.Text("Kind: " + Service.TargetManager.Target.GetObjectKind().ToString()); ImGui.Text("SubKind: " + Service.TargetManager.Target.GetBattleNPCSubKind().ToString()); - var owner = Service.ObjectTable.SearchById(Service.TargetManager.Target.OwnerId); + var owner = Svc.Objects.SearchById(Service.TargetManager.Target.OwnerId); if(owner != null) { ImGui.Text("Owner: " + owner.Name.ToString()); @@ -134,7 +134,7 @@ private unsafe void DrawTargetData() foreach (var status in b.StatusList) { - var source = status.SourceId == Player.Object.ObjectId ? "You" : Service.ObjectTable.SearchById(status.SourceId) == null ? "None" : "Others"; + var source = status.SourceId == Player.Object.ObjectId ? "You" : Svc.Objects.SearchById(status.SourceId) == null ? "None" : "Others"; ImGui.Text($"{status.GameData.Name}: {status.StatusId} From: {source}"); } } diff --git a/RotationSolver/Updaters/PreviewUpdater.cs b/RotationSolver/Updaters/PreviewUpdater.cs index 636175355..e6f70ec2b 100644 --- a/RotationSolver/Updaters/PreviewUpdater.cs +++ b/RotationSolver/Updaters/PreviewUpdater.cs @@ -63,7 +63,7 @@ private static void UpdateEntry() (Service.Config.StopCastingDelayMin, Service.Config.StopCastingDelayMax)); internal static void UpdateCastBarState() { - var tardead = Service.Config.UseStopCasting && Service.ObjectTable.SearchById(Player.Object.CastTargetObjectId) is BattleChara b + var tardead = Service.Config.UseStopCasting && Svc.Objects.SearchById(Player.Object.CastTargetObjectId) is BattleChara b && (b is PlayerCharacter ? b.HasStatus(false, StatusID.Raise) : b.CurrentHp == 0); _isTarNoNeedCast = _tarStopCastDelay.Delay(tardead); diff --git a/RotationSolver/Updaters/TargetUpdater.cs b/RotationSolver/Updaters/TargetUpdater.cs index 208e63d08..5d519207f 100644 --- a/RotationSolver/Updaters/TargetUpdater.cs +++ b/RotationSolver/Updaters/TargetUpdater.cs @@ -3,7 +3,6 @@ using ECommons.DalamudServices; using ECommons.GameHelpers; using FFXIVClientStructs.FFXIV.Client.UI; -using FFXIVClientStructs.FFXIV.Client.UI.Agent; using Lumina.Excel.GeneratedSheets; using RotationSolver.Basic.Configuration; using System.Text.RegularExpressions; @@ -15,11 +14,11 @@ internal static partial class TargetUpdater { internal static void UpdateTarget() { - DataCenter.AllTargets = Service.ObjectTable.GetObjectInRadius(30); + DataCenter.AllTargets = Svc.Objects.GetObjectInRadius(30); var battles = DataCenter.AllTargets.OfType(); UpdateHostileTargets(battles); UpdateFriends(battles); - UpdateNamePlate(Service.ObjectTable.OfType()); + UpdateNamePlate(Svc.Objects.OfType()); } internal static void ClearTarget() diff --git a/RotationSolver/Watcher.cs b/RotationSolver/Watcher.cs index 28e2c9d6f..6eef9a544 100644 --- a/RotationSolver/Watcher.cs +++ b/RotationSolver/Watcher.cs @@ -68,12 +68,12 @@ private static unsafe void ReceiveAbilityEffect(uint sourceId, IntPtr sourceChar private static void ActionFromEnemy(uint sourceId, ActionEffectSet set) { //Check Source. - var source = Service.ObjectTable.SearchById(sourceId); + var source = Svc.Objects.SearchById(sourceId); if (source == null) return; if (source is not BattleChara battle) return; if (battle is PlayerCharacter) return; if (battle.SubKind == 9) return; //Friend! - if (Service.ObjectTable.SearchById(battle.ObjectId) is PlayerCharacter) return; + if (Svc.Objects.SearchById(battle.ObjectId) is PlayerCharacter) return; var damageRatio = set.TargetEffects .Where(e => e.Target == Player.Object)