-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebugNames.h
More file actions
83 lines (66 loc) · 1.83 KB
/
Copy pathDebugNames.h
File metadata and controls
83 lines (66 loc) · 1.83 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
#pragma once
/// @file
/// The DebugNames feature: draws the UObject name of every actor in the world at
/// its screen position. Independent of the ESP — a debug aid for discovering
/// classes/objects. Heavy (one projection + text draw per actor), so it is
/// opt-in via Settings.VISUALS.DrawAllNames.
#include "Feature.h"
#include "../ue/Engine.h"
#include "../render/Render.h"
#include "../native/WorldToScreen.h"
#include <string>
/// Draws every actor's UObject name each frame while enabled (debug only).
class DebugNames : public Feature
{
public:
DebugNames()
{
Name = "DebugNames";
UpdateEnabled();
Log("Created");
};
void UpdateEnabled()
{
Enabled = Settings.VISUALS.DrawAllNames;
};
bool Check()
{
if (!Initialized) return false;
if (!Engine::PlayerController) return false;
if (!Engine::IsInGame) return false;
if (!Engine::Canvas) return false;
return true;
};
/// No game object to resolve; ready immediately.
void Init()
{
Initialized = true;
Log("Initialized");
};
void Destroy() {
};
void Run()
{
auto* controller = Engine::PlayerController;
const Render::Color color{1.f, 1.f, 1.f, 1.f};
const float scale = Settings.VISUALS.FontScale;
auto& Levels = Engine::World->Levels;
for (int l = 0, levelCount = Levels.Num(); l < levelCount; l++)
{
if (!Levels.IsValidIndex(l)) continue;
ULevel* Level = Levels[l];
if (!Level) continue;
auto& Actors = Level->Actors;
for (int a = 0, actorCount = Actors.Num(); a < actorCount; a++)
{
if (!Actors.IsValidIndex(a)) continue;
auto Actor = Actors[a];
if (!Actor || !Actor->RootComponent) continue;
FVector2D screen;
if (!Projection::WorldToScreen(Actor->K2_GetActorLocation(), screen)) continue;
if (!screen.X && !screen.Y) continue;
Render::Text(screen, Actor->GetName(), scale, color);
}
}
};
};