forked from Caraxi/SimpleTweaksPlugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStatusEffectsDebugging.cs
More file actions
142 lines (117 loc) · 5.54 KB
/
StatusEffectsDebugging.cs
File metadata and controls
142 lines (117 loc) · 5.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
using System;
using System.Linq;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Memory;
using FFXIVClientStructs.FFXIV.Client.Game.Character;
using FFXIVClientStructs.FFXIV.Client.Game.Object;
using FFXIVClientStructs.Interop;
using ImGuiNET;
using Lumina.Excel.Sheets;
namespace SimpleTweaksPlugin.Debugging;
public unsafe class StatusEffectsDebugging : DebugHelper {
public override string Name => "Status Effects Debugging";
private void DrawStatusExplorer(BattleChara* battleChara) {
var name = MemoryHelper.ReadSeStringNullTerminated(new IntPtr(battleChara->Character.GameObject.GetName()));
ImGui.Text($"{name.TextValue} ");
ImGui.SameLine();
DebugManager.ClickToCopyText($"{(ulong)battleChara:X}");
ImGui.SameLine();
DebugManager.PrintOutObject(*battleChara, (ulong)battleChara);
ImGui.Separator();
var statusManager = battleChara->GetStatusManager();
ImGui.Text($"Status Manager:");
ImGui.SameLine();
DebugManager.ClickToCopy(statusManager);
ImGui.SameLine();
DebugManager.PrintOutObject(statusManager);
ImGui.Separator();
if (ImGui.BeginTable("statusTable", 7)) {
ImGui.TableSetupColumn("Index", ImGuiTableColumnFlags.WidthFixed, 50);
ImGui.TableSetupColumn("ID", ImGuiTableColumnFlags.WidthFixed, 60);
ImGui.TableSetupColumn("Name", ImGuiTableColumnFlags.WidthFixed, 200);
ImGui.TableSetupColumn("Stack", ImGuiTableColumnFlags.WidthFixed, 50);
ImGui.TableSetupColumn("Time", ImGuiTableColumnFlags.WidthFixed, 100);
ImGui.TableSetupColumn("Source", ImGuiTableColumnFlags.WidthFixed, 150);
ImGui.TableSetupColumn("Object");
ImGui.TableHeadersRow();
var sheet = Service.Data.Excel.GetSheet<Status>();
for (var i = 0; i < statusManager->Status.Length; i++) {
var status = statusManager->Status.GetPointer(i);
ImGui.TableNextColumn();
ImGui.Text($"{i}");
ImGui.TableNextColumn();
ImGui.Text($"{status->StatusId}");
ImGui.TableNextColumn();
if (sheet.TryGetRow(status->StatusId, out var s)) {
var statusName = s.Name.ExtractText();
ImGui.Text($"{statusName}");
}
ImGui.TableNextColumn();
ImGui.Text($"{status->Param}");
ImGui.TableNextColumn();
if (s is { IsPermanent: true }) {
ImGui.Text("Permanent");
} else {
var ts = TimeSpan.FromSeconds(status->RemainingTime);
ImGui.Text($"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00}");
}
ImGui.TableNextColumn();
if (status->SourceId == 0xE0000000 || status->SourceId == 0) {
ImGui.Text("None");
} else {
var sourceObj = CharacterManager.Instance()->LookupBattleCharaByEntityId(status->SourceId);
if (sourceObj == null) {
DebugManager.ClickToCopyText($"0x{status->SourceId:X}");
} else {
var sourceName = SeString.Parse(sourceObj->Name);
DebugManager.ClickToCopyText($"{sourceName.TextValue}", $"0x{status->SourceId:X}");
}
}
ImGui.TableNextColumn();
DebugManager.PrintOutObject(status);
}
ImGui.EndTable();
}
}
private readonly ObjectKind[] battleCharaKinds = [ObjectKind.Pc, ObjectKind.BattleNpc];
public override void Draw() {
if (ImGui.BeginTabBar($"statusExplorerTabs")) {
if (ImGui.BeginTabItem($"Self")) {
var selfObject = GameObjectManager.Instance()->Objects.IndexSorted[0].Value;
if (selfObject == null || selfObject->ObjectKind != ObjectKind.Pc) {
ImGui.Text("Self Not Found");
} else {
DrawStatusExplorer((BattleChara*)selfObject);
}
ImGui.EndTabItem();
}
if (ImGui.BeginTabItem($"Target")) {
if (Service.Targets?.Target == null) {
ImGui.Text("No Target");
} else {
var targetObject = (GameObject*)Service.Targets?.Target?.Address;
if (targetObject == null || !battleCharaKinds.Contains(targetObject->ObjectKind)) {
ImGui.Text($"Unsupported Target Kind: {targetObject->ObjectKind}");
} else {
DrawStatusExplorer((BattleChara*)targetObject);
}
}
ImGui.EndTabItem();
}
if (ImGui.BeginTabItem($"Focus Target")) {
if (Service.Targets?.FocusTarget == null) {
ImGui.Text("No Focus Target");
} else {
var targetObject = (GameObject*)Service.Targets?.FocusTarget?.Address;
if (targetObject == null || !battleCharaKinds.Contains(targetObject->ObjectKind)) {
ImGui.Text($"Unsupported Target Kind: {targetObject->ObjectKind}");
} else {
DrawStatusExplorer((BattleChara*)targetObject);
}
}
ImGui.EndTabItem();
}
ImGui.EndTabBar();
}
}
}