Cyrus Mod Loader
Loading...
Searching...
No Matches
CoreObject.h
1#pragma once
2#include <cstdint>
3#include <memory>
4#include <string>
5#include <vector>
6
7#include <Cyrus/Classes/PropertyClass.h>
8#include <Cyrus/Classes/WizGameObjectTemplate.h>
9#include <Cyrus/shared.h>
10#include <cstdint>
11
12struct CoreObjectLayout;
13struct BehaviorInstanceLayout;
14
15#pragma pack(push, 1)
16class BehaviorInstance : public PropertyClass {
17private:
18 uint8_t pad[0x20]; // 0x48
19 uint32_t behaviorTemplateNameID; // 0x68
20};
21#pragma pack(pop)
22
23#pragma pack(push, 1)
29class CoreObject : public PropertyClass {
30public:
31 uint64_t globalID; // 0x48
32 uint64_t permID; // 0x50
34 uint64_t templateID; // 0x60
35 std::string debugName; // 0x68
36 std::string displayKey; // 0x88
39 short speedMultiplier; // 0xC0
40 unsigned short mobileID; // 0xC2
41 float scale; // 0xC4
42 void *unk1; // 0xC8
45 std::vector<std::shared_ptr<BehaviorInstance>> inactiveBehaviors; // 0xE0
46 std::vector<std::shared_ptr<BehaviorInstance>> activeBehaviors; // 0xF8
47 void *unk2; // 0x110
48 void *unk3; // 0x118
49 void *unk4; // 0x120
50 void *unk5; // 0x128
51 void *zoneData; // 0x130
52 void *unk6; // 0x138
53 void *unk7; // 0x140
54 void *unk8; // 0x148
55 void *unk9; // 0x150
56 uint32_t zoneTagID; // 0x158
57 uint32_t pad; // 0x15C
58 void *unk10; // 0x160
59 void *unk11; // 0x168
60 void *unk12; // 0x170
61 void *unk13; // 0x178
62 std::vector<std::shared_ptr<CoreObject>> children; // 0x180
63
64public:
78 template <class T> T *findChild(const std::string &name) {
79 for (auto &child : children) {
80 if (child->getName() == name) {
81 return child->as<T>();
82 }
83 }
84 return nullptr;
85 }
86
102 template <class T> T *findDescendant(const std::string &name) {
103 for (auto &child : children) {
104 if (child->getName() == name) {
105 return child->as<T>();
106 }
107 T *descendant = child->findDescendant<T>(name);
108 if (descendant != nullptr) {
109 return descendant;
110 }
111 }
112 return nullptr;
113 }
114
115 /*
116 * @brief Get the root CoreObject of the current CoreObject.
117 *
118 * This function returns the root CoreObject of the current CoreObject. If the
119 * current CoreObject has no parent, the current CoreObject is the root and is
120 * returned. Otherwise, the function recursively calls itself on the parent
121 * CoreObject until the root CoreObject is found.
122 *
123 * @return The root CoreObject of the current CoreObject.
124 */
126 CoreObject *root = this;
127 while (root->parent != nullptr) {
128 root = root->parent;
129 }
130 return root;
131 }
132
133 std::vector<std::shared_ptr<CoreObject>> getChildren() { return children; }
134
135private:
136 friend struct CoreObjectLayout;
137};
138
172};
173#pragma pack(pop)
Definition BehaviorInstance.h:5
Definition CoreObject.h:29
void * unk1
Definition CoreObject.h:42
std::vector< std::shared_ptr< CoreObject > > children
Definition CoreObject.h:62
WizGameObjectTemplate * m_template
Definition CoreObject.h:33
std::string displayKey
Definition CoreObject.h:36
std::vector< std::shared_ptr< BehaviorInstance > > inactiveBehaviors
Definition CoreObject.h:45
uint64_t templateID
Definition CoreObject.h:34
void * unk9
Definition CoreObject.h:55
void * unk5
Definition CoreObject.h:50
CoreObject * getRoot()
Definition CoreObject.h:125
void * unk10
Definition CoreObject.h:58
unsigned short mobileID
Definition CoreObject.h:40
void * unk2
Definition CoreObject.h:47
void * unk12
Definition CoreObject.h:60
T * findChild(const std::string &name)
Find a child CoreObject by name and cast it to the specified type.
Definition CoreObject.h:78
float scale
Definition CoreObject.h:41
void * zoneData
Definition CoreObject.h:51
uint32_t zoneTagID
Definition CoreObject.h:56
void * unk13
Definition CoreObject.h:61
void * unk8
Definition CoreObject.h:54
void * unk7
Definition CoreObject.h:53
T * findDescendant(const std::string &name)
Find a descendant CoreObject by name and cast it to the specified type.
Definition CoreObject.h:102
uint64_t permID
Definition CoreObject.h:32
CoreObject * parent
Definition CoreObject.h:43
std::string debugName
Definition CoreObject.h:35
Vector3D location
Definition CoreObject.h:37
uint64_t globalID
Definition CoreObject.h:31
short speedMultiplier
Definition CoreObject.h:39
void * unk6
Definition CoreObject.h:52
void * unk3
Definition CoreObject.h:48
SharedObjectDeleter< CoreObject * > * deleter
Definition CoreObject.h:44
std::vector< std::shared_ptr< BehaviorInstance > > activeBehaviors
Definition CoreObject.h:46
std::vector< std::shared_ptr< CoreObject > > getChildren()
Definition CoreObject.h:133
Vector3D orentiation
Definition CoreObject.h:38
void * unk11
Definition CoreObject.h:59
void * unk4
Definition CoreObject.h:49
uint32_t pad
Definition CoreObject.h:57
Base class for all property classes, providing reflection and serialization functionality.
Definition PropertyClass.h:86
Manages shared and weak references to an object and provides deletion management.
Definition PropertyClass.h:12
Definition WizGameObjectTemplate.h:17
Definition CoreObject.h:139
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, unk2, 0x110)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, zoneData, 0x130)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, unk4, 0x120)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, inactiveBehaviors, 0xE0)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, unk8, 0x148)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, unk1, 0xC8)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, unk11, 0x168)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, pad, 0x15C)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, scale, 0xC4)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, unk7, 0x140)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, unk6, 0x138)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, zoneTagID, 0x158)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, children, 0x180)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, unk13, 0x178)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, location, 0xA8)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, unk5, 0x128)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, templateID, 0x60)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, displayKey, 0x88)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, parent, 0xD0)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, globalID, 0x48)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, activeBehaviors, 0xF8)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, speedMultiplier, 0xC0)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, m_template, 0x58)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, unk3, 0x118)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, unk10, 0x160)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, orentiation, 0xB4)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, mobileID, 0xC2)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, unk12, 0x170)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, permID, 0x50)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, deleter, 0xD8)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, unk9, 0x150)
DEFINE_OFFSET_AND_STATIC_ASSERT(CoreObject, debugName, 0x68)
Definition shared.h:12