-
Notifications
You must be signed in to change notification settings - Fork 9
/
ExtraDebug.cs
152 lines (120 loc) · 6.28 KB
/
ExtraDebug.cs
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
143
144
145
146
147
148
149
150
151
152
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Reflection;
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Interface.Utility.Raii;
using Dalamud.Interface.Windowing;
using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Client.Game.Character;
using ImGuiNET;
using Companion = Lumina.Excel.Sheets.Companion;
namespace SimpleHeels;
public unsafe class ExtraDebug : Window {
private readonly Plugin plugin;
private readonly List<MethodInfo> tabs = new();
public ExtraDebug(Plugin plugin, PluginConfig config) : base("SimpleHeels Extended Debugging") {
this.plugin = plugin;
foreach (var m in GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance).Where(m => m.GetParameters().Length == 0 && m.Name.StartsWith("Tab"))) tabs.Add(m);
}
public override void OnOpen() {
Plugin.Config.ExtendedDebugOpen = true;
}
public override void OnClose() {
Plugin.Config.ExtendedDebugOpen = false;
}
private void TabDebug() {
ImGui.Text("Last Reported IPC:");
ImGui.Indent();
ImGui.TextWrapped(ApiProvider.LastReportedData);
ImGui.Spacing();
ImGui.Spacing();
ImGui.TextDisabled($"Time Since Report: {ApiProvider.TimeSinceLastReport.Elapsed:hh\\:mm\\:ss}");
ImGui.Separator();
var localPlayer = PluginService.ClientState.LocalPlayer;
if (localPlayer != null) {
var chr = (Character*)localPlayer.Address;
Util.ShowStruct(chr);
}
ImGui.Unindent();
}
private void TabPerformance() {
ImGui.Checkbox("Detailed", ref Plugin.Config.DetailedPerformanceLogging);
PerformanceMonitors.DrawTable(ImGui.GetContentRegionAvail().Y - ImGui.GetTextLineHeight() * 2);
}
private void TabBaseOffsets() {
foreach (var (index, offset) in plugin.BaseOffsets) ImGui.Text($"Object#{index} => {offset}");
}
private Vector4[] minionPositions = new Vector4[Constants.ObjectLimit];
private void TabStaticMinions() {
foreach (var c in PluginService.Objects.Where(o => o is IPlayerCharacter).Cast<IPlayerCharacter>()) {
if (c == null) continue;
var chr = (Character*)c.Address;
if (chr->CompanionData.CompanionObject == null) continue;
var companionId = chr->CompanionData.CompanionObject->Character.GameObject.BaseId;
var companion = PluginService.Data.GetExcelSheet<Companion>()?.GetRow(companionId);
if (companion == null) continue;
if (companion.Value.Behavior.RowId != 3) continue;
using (ImRaii.PushId($"chr_{c.EntityId:X}")) {
ImGui.Separator();
var go = &chr->CompanionData.CompanionObject->Character.GameObject;
if (minionPositions[go->ObjectIndex] == default) minionPositions[go->ObjectIndex] = new Vector4(go->Position, go->Rotation);
if (ImGui.DragFloat4($"{c.Name.TextValue}'s {companion.Value.Singular.ToDalamudString().TextValue}", ref minionPositions[go->ObjectIndex], 0.01f)) {
go->DrawObject->Object.Position.X = minionPositions[go->ObjectIndex].X;
go->DrawObject->Object.Position.Y = minionPositions[go->ObjectIndex].Y;
go->DrawObject->Object.Position.Z = minionPositions[go->ObjectIndex].Z;
go->DrawObject->Object.Rotation = Quaternion.CreateFromYawPitchRoll(minionPositions[go->ObjectIndex].W, 0, 0);
}
ImGui.SameLine();
ImGui.Text($"{go->EntityId:X}");
}
}
}
private void TabObjects() {
foreach (var actor in PluginService.Objects) {
if (actor is not IPlayerCharacter pc) continue;
if (ImGui.TreeNode($"[{actor.ObjectIndex} ({actor.GetType().Name})] {actor.ObjectKind}.{actor.SubKind} - {actor.Name}")) {
var obj = (Character*)pc.Address;
ImGui.Text($"Address: {actor.Address:X}");
if (ImGui.IsItemClicked()) ImGui.SetClipboardText($"{actor.Address:X}");
ImGui.Text($"Name: '{actor.Name}'");
ImGui.Text($"HomeWorld: '{pc.HomeWorld.RowId}'");
ImGui.Text($"Mode: {obj->Mode}");
ImGui.Text($"ModeParam: {obj->ModeParam}");
ImGui.Text($"Feet Model: {obj->DrawData.Equipment(DrawDataContainer.EquipmentSlot.Feet).Id}");
ImGui.Text($"Draw Offset: {obj->GameObject.DrawOffset}");
ImGui.Text($"Height: {obj->GameObject.Height}");
ImGui.Text("Character Data:");
ImGui.SameLine();
Util.ShowStruct(&obj->CharacterData);
ImGui.Text($"Reaper Shroud:");
ImGui.SameLine();
Util.ShowStruct(&obj->ReaperShroud);
if (Plugin.ActorMapping.TryGetValue(actor.ObjectIndex, out var map)) ImGui.Text($"Clone of {map.name} @ {map.homeWorld}");
var o = (Vector3)obj->GameObject.DrawOffset;
if (ImGui.DragFloat3($"Draw Offset##{obj->GameObject.ObjectIndex}", ref o, 0.001f)) obj->GameObject.SetDrawOffset(o.X, o.Y, o.Z);
if (plugin.TryGetCharacterConfig(obj, out var characterConfig))
if (characterConfig.TryGetFirstMatch(obj, out var offsetProvider)) {
var expectedOffset = offsetProvider.GetOffset();
ImGui.Text("Offset Provider: ");
Util.ShowObject(offsetProvider);
ImGui.Text($"Expected Offset: {expectedOffset}");
}
ImGui.Text($"IsManaged: {plugin.ManagedIndex[obj->GameObject.ObjectIndex]}");
ImGui.Text($"IsCharacter: {obj->GameObject.IsCharacter()}");
ImGui.Text($"PoseIdentifier: {EmoteIdentifier.Get(obj)}");
ImGui.TreePop();
}
}
}
public override void Draw() {
if (ImGui.BeginTabBar("tabs")) {
foreach (var t in tabs)
if (ImGui.BeginTabItem($"{t.Name[3..]}")) {
t.Invoke(this, null);
ImGui.EndTabItem();
}
ImGui.EndTabBar();
}
}
}