This repository has been archived by the owner on Feb 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
GameObject.h
81 lines (60 loc) · 1.75 KB
/
GameObject.h
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
#pragma once
#include <vector>
std::vector<uintptr_t> componentTempList;
struct GameObjectCache;
struct ComponentCache
{
char pad[0x28];
uintptr_t component; // 0x28
GameObjectCache* gameobject; // 0x30
bool enabled; // 0x38
};
struct CachedComponentListEntry
{
char reserved[8];
ComponentCache* cachedcomponent;
};
struct GameObjectCache
{
uintptr_t vmt;
char pad[0x18];
uintptr_t reversed0; // 0x20
uintptr_t reversed1; // 0x28
CachedComponentListEntry* componentlist; // 0x30
uintptr_t reversed2; // 0x38
int componentlist_size; // 0x40
char pad2[0x1C];//char pad2[0x24];
char** tag; // 0x60
};
std::vector<uintptr_t> GetComponentsFast(uintptr_t gameObject, const char* componentname)
{
componentTempList.clear();
auto cache = Read<GameObjectCache*>(gameObject + 0x10);
if (!cache)
return componentTempList;
if (!cache->componentlist)
return componentTempList;
for (int i = 0; i < cache->componentlist_size; i++)
{
auto& item = cache->componentlist[i];
if (!item.cachedcomponent)
continue;
auto component = item.cachedcomponent->component;
if (!component)
continue;
auto componentBase = *(uintptr_t*)(component);
if (!componentBase)
continue;
auto componentClassName = (char*)*(uintptr_t*)(componentBase + 0x10);
if (componentClassName != componentname)
continue;
componentTempList.push_back(component);
}
return componentTempList;
}
uintptr_t GetComponentFast(uintptr_t gameObject, const char* componentname) {
auto cmp = GetComponentsFast(gameObject, componentname);
if (cmp.size() > 0)
return cmp[0];
return NULL;
}