33#include " game/core/core.h"
44
55
6- bool Helper::SafeIsAlive (UT:: UnityObject* obj)
6+ bool Helper::SafeIsAlive (UnityObject* obj)
77{
88 if (!obj) return false ;
99
@@ -17,7 +17,7 @@ bool Helper::SafeIsAlive(UT::UnityObject* obj)
1717 }
1818}
1919
20- bool Helper::SafeGetTag (UT:: GameObject* obj, UT::String*& outTag)
20+ bool Helper::SafeGetTag (GameObject* obj, UT::String*& outTag)
2121{
2222 if (!obj) return false ;
2323
@@ -32,7 +32,7 @@ bool Helper::SafeGetTag(UT::GameObject* obj, UT::String*& outTag)
3232 }
3333}
3434
35- bool Helper::SafeGetActiveSelf (UT:: GameObject* obj, bool & outActive)
35+ bool Helper::SafeGetActiveSelf (GameObject* obj, bool & outActive)
3636{
3737 if (!obj) return false ;
3838
@@ -47,7 +47,7 @@ bool Helper::SafeGetActiveSelf(UT::GameObject* obj, bool& outActive)
4747 }
4848}
4949
50- bool Helper::SafeSetActive (UT:: GameObject* obj, bool value)
50+ bool Helper::SafeSetActive (GameObject* obj, bool value)
5151{
5252 if (!obj) return false ;
5353
@@ -62,7 +62,7 @@ bool Helper::SafeSetActive(UT::GameObject* obj, bool value)
6262 }
6363}
6464
65- bool Helper::SafeGetIsStatic (UT:: GameObject* obj, bool & outStatic)
65+ bool Helper::SafeGetIsStatic (GameObject* obj, bool & outStatic)
6666{
6767 if (!obj) return false ;
6868
@@ -165,111 +165,111 @@ bool Helper::SafeWriteBool(void* ptr, const int offset, const bool value)
165165 __except (EXCEPTION_EXECUTE_HANDLER) { return false ; }
166166}
167167
168- bool Helper::SafeReadVector2 (void * ptr, const int offset, UT::Vector2 & outValue)
168+ bool Helper::SafeReadVector2 (void * ptr, const int offset, Vec2 & outValue)
169169{
170170 if (!ptr || offset < 0 ) return false ;
171171 __try
172172 {
173- outValue = *reinterpret_cast <UT::Vector2 *>(reinterpret_cast <uintptr_t >(ptr) + offset);
173+ outValue = *reinterpret_cast <Vec2 *>(reinterpret_cast <uintptr_t >(ptr) + offset);
174174 return true ;
175175 }
176176 __except (EXCEPTION_EXECUTE_HANDLER) { return false ; }
177177}
178178
179- bool Helper::SafeWriteVector2 (void * ptr, const int offset, const UT::Vector2 & value)
179+ bool Helper::SafeWriteVector2 (void * ptr, const int offset, const Vec2 & value)
180180{
181181 if (!ptr || offset < 0 ) return false ;
182182 __try
183183 {
184- *reinterpret_cast <UT::Vector2 *>(reinterpret_cast <uintptr_t >(ptr) + offset) = value;
184+ *reinterpret_cast <Vec2 *>(reinterpret_cast <uintptr_t >(ptr) + offset) = value;
185185 return true ;
186186 }
187187 __except (EXCEPTION_EXECUTE_HANDLER) { return false ; }
188188}
189189
190- bool Helper::SafeReadVector3 (void * ptr, const int offset, UT::Vector3 & outValue)
190+ bool Helper::SafeReadVector3 (void * ptr, const int offset, Vec3 & outValue)
191191{
192192 if (!ptr || offset < 0 ) return false ;
193193 __try
194194 {
195- outValue = *reinterpret_cast <UT::Vector3 *>(reinterpret_cast <uintptr_t >(ptr) + offset);
195+ outValue = *reinterpret_cast <Vec3 *>(reinterpret_cast <uintptr_t >(ptr) + offset);
196196 return true ;
197197 }
198198 __except (EXCEPTION_EXECUTE_HANDLER) { return false ; }
199199}
200200
201- bool Helper::SafeWriteVector3 (void * ptr, const int offset, const UT::Vector3 & value)
201+ bool Helper::SafeWriteVector3 (void * ptr, const int offset, const Vec3 & value)
202202{
203203 if (!ptr || offset < 0 ) return false ;
204204 __try
205205 {
206- *reinterpret_cast <UT::Vector3 *>(reinterpret_cast <uintptr_t >(ptr) + offset) = value;
206+ *reinterpret_cast <Vec3 *>(reinterpret_cast <uintptr_t >(ptr) + offset) = value;
207207 return true ;
208208 }
209209 __except (EXCEPTION_EXECUTE_HANDLER) { return false ; }
210210}
211211
212- bool Helper::SafeReadVector4 (void * ptr, const int offset, UT::Vector4 & outValue)
212+ bool Helper::SafeReadVector4 (void * ptr, const int offset, Vec4 & outValue)
213213{
214214 if (!ptr || offset < 0 ) return false ;
215215 __try
216216 {
217- outValue = *reinterpret_cast <UT::Vector4 *>(reinterpret_cast <uintptr_t >(ptr) + offset);
217+ outValue = *reinterpret_cast <Vec4 *>(reinterpret_cast <uintptr_t >(ptr) + offset);
218218 return true ;
219219 }
220220 __except (EXCEPTION_EXECUTE_HANDLER) { return false ; }
221221}
222222
223- bool Helper::SafeWriteVector4 (void * ptr, const int offset, const UT::Vector4 & value)
223+ bool Helper::SafeWriteVector4 (void * ptr, const int offset, const Vec4 & value)
224224{
225225 if (!ptr || offset < 0 ) return false ;
226226 __try
227227 {
228- *reinterpret_cast <UT::Vector4 *>(reinterpret_cast <uintptr_t >(ptr) + offset) = value;
228+ *reinterpret_cast <Vec4 *>(reinterpret_cast <uintptr_t >(ptr) + offset) = value;
229229 return true ;
230230 }
231231 __except (EXCEPTION_EXECUTE_HANDLER) { return false ; }
232232}
233233
234- bool Helper::SafeReadQuaternion (void * ptr, const int offset, UT::Quaternion & outValue)
234+ bool Helper::SafeReadQuaternion (void * ptr, const int offset, Quat & outValue)
235235{
236236 if (!ptr || offset < 0 ) return false ;
237237 __try
238238 {
239- outValue = *reinterpret_cast <UT::Quaternion *>(reinterpret_cast <uintptr_t >(ptr) + offset);
239+ outValue = *reinterpret_cast <Quat *>(reinterpret_cast <uintptr_t >(ptr) + offset);
240240 return true ;
241241 }
242242 __except (EXCEPTION_EXECUTE_HANDLER) { return false ; }
243243}
244244
245- bool Helper::SafeWriteQuaternion (void * ptr, const int offset, const UT::Quaternion & value)
245+ bool Helper::SafeWriteQuaternion (void * ptr, const int offset, const Quat & value)
246246{
247247 if (!ptr || offset < 0 ) return false ;
248248 __try
249249 {
250- *reinterpret_cast <UT::Quaternion *>(reinterpret_cast <uintptr_t >(ptr) + offset) = value;
250+ *reinterpret_cast <Quat *>(reinterpret_cast <uintptr_t >(ptr) + offset) = value;
251251 return true ;
252252 }
253253 __except (EXCEPTION_EXECUTE_HANDLER) { return false ; }
254254}
255255
256- bool Helper::SafeReadColor (void * ptr, const int offset, UT:: Color& outValue)
256+ bool Helper::SafeReadColor (void * ptr, const int offset, Color& outValue)
257257{
258258 if (!ptr || offset < 0 ) return false ;
259259 __try
260260 {
261- outValue = *reinterpret_cast <UT:: Color*>(reinterpret_cast <uintptr_t >(ptr) + offset);
261+ outValue = *reinterpret_cast <Color*>(reinterpret_cast <uintptr_t >(ptr) + offset);
262262 return true ;
263263 }
264264 __except (EXCEPTION_EXECUTE_HANDLER) { return false ; }
265265}
266266
267- bool Helper::SafeWriteColor (void * ptr, const int offset, const UT:: Color& value)
267+ bool Helper::SafeWriteColor (void * ptr, const int offset, const Color& value)
268268{
269269 if (!ptr || offset < 0 ) return false ;
270270 __try
271271 {
272- *reinterpret_cast <UT:: Color*>(reinterpret_cast <uintptr_t >(ptr) + offset) = value;
272+ *reinterpret_cast <Color*>(reinterpret_cast <uintptr_t >(ptr) + offset) = value;
273273 return true ;
274274 }
275275 __except (EXCEPTION_EXECUTE_HANDLER) { return false ; }
@@ -450,7 +450,7 @@ bool Helper::SafeSetStaticFieldDouble(void* fieldHandle, double value)
450450 catch (...) { return false ; }
451451}
452452
453- bool Helper::SafeGetStaticFieldVector3 (void * fieldHandle, UT::Vector3 & outValue)
453+ bool Helper::SafeGetStaticFieldVector3 (void * fieldHandle, Vec3 & outValue)
454454{
455455 if (!fieldHandle) return false ;
456456 try
@@ -459,32 +459,32 @@ bool Helper::SafeGetStaticFieldVector3(void* fieldHandle, UT::Vector3& outValue)
459459 {
460460 void * vTable = UR::Invoke<void *, void *, void *>(" mono_class_vtable" , UR::pDomain,
461461 UR::Invoke<void *, void *>(" mono_field_get_parent" , fieldHandle));
462- UR::Invoke<void , void *, void *, UT::Vector3 *>(" mono_field_static_get_value" , vTable, fieldHandle, &outValue);
462+ UR::Invoke<void , void *, void *, Vec3 *>(" mono_field_static_get_value" , vTable, fieldHandle, &outValue);
463463 }
464464 else
465465 {
466- UR::Invoke<void , void *, UT::Vector3 *>(" il2cpp_field_static_get_value" , fieldHandle, &outValue);
466+ UR::Invoke<void , void *, Vec3 *>(" il2cpp_field_static_get_value" , fieldHandle, &outValue);
467467 }
468468 return true ;
469469 }
470470 catch (...) { return false ; }
471471}
472472
473- bool Helper::SafeSetStaticFieldVector3 (void * fieldHandle, const UT::Vector3 & value)
473+ bool Helper::SafeSetStaticFieldVector3 (void * fieldHandle, const Vec3 & value)
474474{
475475 if (!fieldHandle) return false ;
476476 try
477477 {
478- UT::Vector3 v = value;
478+ Vec3 v = value;
479479 if (Core::config->gameMode == UnityResolve::Mode::Mono)
480480 {
481481 void * vTable = UR::Invoke<void *, void *, void *>(" mono_class_vtable" , UR::pDomain,
482482 UR::Invoke<void *, void *>(" mono_field_get_parent" , fieldHandle));
483- UR::Invoke<void , void *, void *, UT::Vector3 *>(" mono_field_static_set_value" , vTable, fieldHandle, &v);
483+ UR::Invoke<void , void *, void *, Vec3 *>(" mono_field_static_set_value" , vTable, fieldHandle, &v);
484484 }
485485 else
486486 {
487- UR::Invoke<void , void *, UT::Vector3 *>(" il2cpp_field_static_set_value" , fieldHandle, &v);
487+ UR::Invoke<void , void *, Vec3 *>(" il2cpp_field_static_set_value" , fieldHandle, &v);
488488 }
489489 return true ;
490490 }
@@ -563,7 +563,7 @@ void* Helper::SafeInvokeMethod(void* obj, void* methodHandle, void** params, boo
563563 }
564564}
565565
566- bool Helper::SafeGetGameObject (UT:: Transform* transform, UT:: GameObject*& outGameObject)
566+ bool Helper::SafeGetGameObject (Transform* transform, GameObject*& outGameObject)
567567{
568568 if (!transform) return false ;
569569 __try
@@ -578,7 +578,37 @@ bool Helper::SafeGetGameObject(UT::Transform* transform, UT::GameObject*& outGam
578578 }
579579}
580580
581- bool Helper::SafeGetTransform (UT::GameObject* gameObject, UT::Transform*& outTransform)
581+ bool Helper::SafeGetGameObject (MonoBehaviour* mb, GameObject*& outGameObject)
582+ {
583+ if (!mb) return false ;
584+ __try
585+ {
586+ outGameObject = mb->GetGameObject ();
587+ return outGameObject != nullptr ;
588+ }
589+ __except (EXCEPTION_EXECUTE_HANDLER)
590+ {
591+ outGameObject = nullptr ;
592+ return false ;
593+ }
594+ }
595+
596+ bool Helper::SafeGetGameObject (Rigidbody* rb, GameObject*& outGameObject)
597+ {
598+ if (!rb) return false ;
599+ __try
600+ {
601+ outGameObject = rb->GetGameObject ();
602+ return outGameObject != nullptr ;
603+ }
604+ __except (EXCEPTION_EXECUTE_HANDLER)
605+ {
606+ outGameObject = nullptr ;
607+ return false ;
608+ }
609+ }
610+
611+ bool Helper::SafeGetTransform (GameObject* gameObject, Transform*& outTransform)
582612{
583613 if (!gameObject) return false ;
584614 __try
@@ -593,7 +623,22 @@ bool Helper::SafeGetTransform(UT::GameObject* gameObject, UT::Transform*& outTra
593623 }
594624}
595625
596- bool Helper::SafeGetParent (UT::Transform* transform, UT::Transform*& outParent)
626+ bool Helper::SafeGetTransform (Rigidbody* gameObject, Transform*& outTransform)
627+ {
628+ if (!gameObject) return false ;
629+ __try
630+ {
631+ outTransform = gameObject->GetTransform ();
632+ return outTransform != nullptr ;
633+ }
634+ __except (EXCEPTION_EXECUTE_HANDLER)
635+ {
636+ outTransform = nullptr ;
637+ return false ;
638+ }
639+ }
640+
641+ bool Helper::SafeGetParent (Transform* transform, Transform*& outParent)
597642{
598643 if (!transform) return false ;
599644 __try
@@ -608,7 +653,7 @@ bool Helper::SafeGetParent(UT::Transform* transform, UT::Transform*& outParent)
608653 }
609654}
610655
611- bool Helper::SafeGetName (UT:: UnityObject* obj, UT::String*& outName)
656+ bool Helper::SafeGetName (UnityObject* obj, UT::String*& outName)
612657{
613658 if (!obj) return false ;
614659 __try
@@ -623,7 +668,7 @@ bool Helper::SafeGetName(UT::UnityObject* obj, UT::String*& outName)
623668 }
624669}
625670
626- bool Helper::SafeGetChildCount (UT:: Transform* transform, int & outCount)
671+ bool Helper::SafeGetChildCount (Transform* transform, int & outCount)
627672{
628673 if (!transform) return false ;
629674 __try
@@ -638,7 +683,7 @@ bool Helper::SafeGetChildCount(UT::Transform* transform, int& outCount)
638683 }
639684}
640685
641- bool Helper::SafeGetChild (UT:: Transform* transform, int index, UT:: Transform*& outChild)
686+ bool Helper::SafeGetChild (Transform* transform, int index, Transform*& outChild)
642687{
643688 if (!transform) return false ;
644689 __try
@@ -653,11 +698,12 @@ bool Helper::SafeGetChild(UT::Transform* transform, int index, UT::Transform*& o
653698 }
654699}
655700
656- Vec3 Helper::TryGetPosition (Transform* go)
701+ bool Helper::TryGetPosition (Transform* go, Vec3& pos )
657702{
658703 __try
659704 {
660- return go->GetPosition ();
705+ pos = go->GetPosition ();
706+ return true ;
661707 }
662708 __except (EXCEPTION_EXECUTE_HANDLER)
663709 {
0 commit comments