Reorganized UnityEngine namespace
Reorganized UnityEngine namespace by splitting headers into individual classes
This commit is contained in:
@@ -1,81 +0,0 @@
|
||||
#include "pch-il2cpp.h"
|
||||
|
||||
#include "UnityEngine.h"
|
||||
#include <helpers.h>
|
||||
|
||||
app::Component* UnityEngine::GameObject::GetComponentByName(app::GameObject* go, const char* type)
|
||||
{
|
||||
app::Component* component = app::GameObject_GetComponentByName(go, ConvertToSystemString(type), nullptr);
|
||||
|
||||
return component ? component : nullptr;
|
||||
}
|
||||
|
||||
app::Component__Array* UnityEngine::GameObject::LogComponents(app::GameObject* go)
|
||||
{
|
||||
Wrapper obj("UnityEngine.CoreModule.dll");
|
||||
|
||||
Il2CppObject* object = obj.find_class("UnityEngine", "Component").get_class();
|
||||
|
||||
if (!object) return nullptr;
|
||||
|
||||
app::Type* type = reinterpret_cast<app::Type*>(object);
|
||||
if (!type) return nullptr;
|
||||
|
||||
app::Component__Array* __components = app::GameObject_GetComponents(go, type, nullptr);
|
||||
|
||||
return __components ? __components : nullptr;
|
||||
}
|
||||
|
||||
const char* UnityEngine::Math::Vector3::ToString(app::Vector3* v)
|
||||
{
|
||||
app::String* str = app::Vector3_ToString(v, nullptr);
|
||||
|
||||
return str ? il2cppi_to_string(str).c_str() : "Vector::ToString returned nullptr!\n";
|
||||
}
|
||||
|
||||
const char* UnityEngine::Math::Vector3::ToString(app::Vector3 v)
|
||||
{
|
||||
return ("x: " + std::to_string(v.x) + " y: " + std::to_string(v.y) + " z: " + std::to_string(v.z)).c_str();
|
||||
}
|
||||
|
||||
app::Transform* UnityEngine::Transform::Get(app::GameObject* go)
|
||||
{
|
||||
if (!go || !app::GameObject_get_transform) return nullptr;
|
||||
|
||||
app::Transform* __transform = app::GameObject_get_transform(go, nullptr);
|
||||
|
||||
return __transform ? __transform : nullptr;
|
||||
}
|
||||
|
||||
app::Vector3 UnityEngine::Transform::Position(app::Transform* transform)
|
||||
{
|
||||
if (!transform || !app::Transform_get_position) return app::Vector3();
|
||||
|
||||
return app::Transform_get_position(transform, nullptr);
|
||||
}
|
||||
|
||||
app::Camera* UnityEngine::Camera::GetMainCamera() {
|
||||
return app::Camera_get_main(nullptr) ? app::Camera_get_main(nullptr) : nullptr;
|
||||
}
|
||||
|
||||
const char* UnityEngine::Object::GetObjectName(app::Object_1* obj)
|
||||
{
|
||||
static std::string name = il2cppi_to_string(app::Object_1_GetName(obj, nullptr));
|
||||
return name.c_str();
|
||||
}
|
||||
|
||||
app::GameObject__Array* UnityEngine::Object::FindGameObjectsWithTag(const char* tag)
|
||||
{
|
||||
app::GameObject__Array* go_array_result = app::GameObject_FindGameObjectsWithTag(ConvertToSystemString(tag), nullptr);
|
||||
|
||||
return go_array_result ? go_array_result : nullptr;
|
||||
}
|
||||
|
||||
void UnityEngine::Object::FindObjectFromInstanceID(int32_t instanceID)
|
||||
{
|
||||
}
|
||||
|
||||
float UnityEngine::Input::GetAxis(const char* axisName)
|
||||
{
|
||||
return app::Input_1_GetAxis(ConvertToSystemString(axisName), nullptr);
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Wrapper.h"
|
||||
#include "helpers.h"
|
||||
#include "ClientHelper.h"
|
||||
|
||||
namespace UnityEngine {
|
||||
namespace GameObject {
|
||||
app::Component* GetComponentByName(app::GameObject* go, const char* type);
|
||||
app::Component__Array* LogComponents(app::GameObject* go);
|
||||
}
|
||||
|
||||
namespace Math {
|
||||
namespace Vector3 {
|
||||
const char* ToString(app::Vector3* v);
|
||||
const char* ToString(app::Vector3 v);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Transform {
|
||||
app::Transform* Get(app::GameObject* go);
|
||||
app::Vector3 Position(app::Transform* transform);
|
||||
}
|
||||
|
||||
struct Input {
|
||||
static float GetAxis(const char* axisName);
|
||||
};
|
||||
|
||||
struct Behaviour {
|
||||
template<typename T>
|
||||
static inline bool Enabled(T* behaviour) {
|
||||
return app::Behaviour_get_enabled((app::Behaviour*)behaviour, nullptr);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static inline void Enabled(T* behaviour, bool value) {
|
||||
app::Behaviour_set_enabled((app::Behaviour*)behaviour, value, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
struct Camera {
|
||||
static app::Camera* GetMainCamera();
|
||||
};
|
||||
|
||||
struct Object {
|
||||
|
||||
static const char* GetObjectName(app::Object_1* obj);
|
||||
|
||||
static app::GameObject__Array* FindGameObjectsWithTag(const char* tag);
|
||||
|
||||
// Object_1_FindObjectFromInstanceID
|
||||
static void FindObjectFromInstanceID(int32_t instanceID);
|
||||
|
||||
template<typename T>
|
||||
static inline T* FindObjectOfType(const char* className, const char* classNamespace = "", const char* assemblyName = "Assembly-CSharp.dll") {
|
||||
|
||||
Wrapper obj(assemblyName);
|
||||
|
||||
Il2CppObject* object = obj.find_class(classNamespace, className).get_class();
|
||||
|
||||
if (!object || !app::Object_1_FindObjectOfType) return nullptr;
|
||||
|
||||
app::Object_1* obj_1 = app::Object_1_FindObjectOfType(reinterpret_cast<app::Type*>(object), nullptr);
|
||||
|
||||
if (!obj_1 || IsNull(obj_1)) return nullptr;
|
||||
|
||||
return reinterpret_cast<T*>(obj_1);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "ClientHelper.h"
|
||||
#include "players/players.h"
|
||||
#include "UnityEngine.h"
|
||||
#include "UnityEngine/Engine.hpp"
|
||||
|
||||
bool IsSinglePlayer()
|
||||
{
|
||||
@@ -43,27 +43,23 @@ bool IsPlayerCrawling()
|
||||
|
||||
bool IsPlayerCrawling(app::GameObject* go)
|
||||
{
|
||||
if (go == NULL)
|
||||
if (go == nullptr) return false;
|
||||
|
||||
app::Component* nbComponent = GameObject::GetComponentByName(go, "NolanBehaviour");
|
||||
|
||||
if (nbComponent) return false;
|
||||
|
||||
app::NolanBehaviour* nb = reinterpret_cast<app::NolanBehaviour*>(nbComponent);
|
||||
|
||||
if (nb)
|
||||
return app::NolanBehaviour_IsCrawling(nb, nullptr);
|
||||
else
|
||||
return false;
|
||||
|
||||
if (app::GameObject_GetComponentByName != NULL) {
|
||||
app::Component* nbComponent = app::GameObject_GetComponentByName(go, ConvertToSystemString("NolanBehaviour"), nullptr);
|
||||
|
||||
if (nbComponent) {
|
||||
app::NolanBehaviour* nb = reinterpret_cast<app::NolanBehaviour*>(nbComponent);
|
||||
|
||||
if (nb) {
|
||||
return app::NolanBehaviour_IsCrawling(nb, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return app::NolanBehaviour_IsCrawling(Player::GetNolan(), nullptr);
|
||||
}
|
||||
|
||||
bool IsInGame()
|
||||
{
|
||||
app::OptionsHelpers* optionsHelpers = UnityEngine::Object::FindObjectOfType<app::OptionsHelpers>("OptionsHelpers");
|
||||
app::OptionsHelpers* optionsHelpers = Object::FindObjectOfType<app::OptionsHelpers>("OptionsHelpers");
|
||||
|
||||
if (optionsHelpers)
|
||||
return optionsHelpers->fields._inGame_k__BackingField;
|
||||
@@ -71,14 +67,6 @@ bool IsInGame()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsNull(app::Object_1* obj)
|
||||
{
|
||||
if (obj == nullptr)
|
||||
return true;
|
||||
|
||||
return !app::Object_1_op_Implicit(obj, nullptr);
|
||||
}
|
||||
|
||||
app::GameObject* GetAzazel(app::Survival* survival)
|
||||
{
|
||||
app::GameObject* ai = app::Survival_GetAzazel(survival, nullptr);
|
||||
8
lib/private/UnityEngine/Camera.cpp
Normal file
8
lib/private/UnityEngine/Camera.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#include "pch-il2cpp.h"
|
||||
|
||||
#include "UnityEngine/Camera.h"
|
||||
|
||||
app::Camera* Camera::GetMainCamera()
|
||||
{
|
||||
return app::Camera_get_main(nullptr) ? app::Camera_get_main(nullptr) : nullptr;
|
||||
}
|
||||
29
lib/private/UnityEngine/GameObject.cpp
Normal file
29
lib/private/UnityEngine/GameObject.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "pch-il2cpp.h"
|
||||
|
||||
#include "UnityEngine/GameObject.h"
|
||||
|
||||
#include "wrapper.h"
|
||||
#include <helpers.h>
|
||||
|
||||
app::Component* GameObject::GetComponentByName(app::GameObject* go, const char* type)
|
||||
{
|
||||
app::Component* component = app::GameObject_GetComponentByName(go, ConvertToSystemString(type), nullptr);
|
||||
|
||||
return component ? component : nullptr;
|
||||
}
|
||||
|
||||
app::Component__Array* GameObject::LogComponents(app::GameObject* go)
|
||||
{
|
||||
Wrapper obj("UnityEngine.CoreModule.dll");
|
||||
|
||||
Il2CppObject* object = obj.find_class("UnityEngine", "Component").get_class();
|
||||
|
||||
if (!object) return nullptr;
|
||||
|
||||
app::Type* type = reinterpret_cast<app::Type*>(object);
|
||||
if (!type) return nullptr;
|
||||
|
||||
app::Component__Array* __components = app::GameObject_GetComponents(go, type, nullptr);
|
||||
|
||||
return __components ? __components : nullptr;
|
||||
}
|
||||
9
lib/private/UnityEngine/Input.cpp
Normal file
9
lib/private/UnityEngine/Input.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "pch-il2cpp.h"
|
||||
|
||||
#include "UnityEngine/Input.h"
|
||||
#include <helpers.h>
|
||||
|
||||
float Input::GetAxis(const char* axisName)
|
||||
{
|
||||
return app::Input_1_GetAxis(ConvertToSystemString(axisName), nullptr);
|
||||
}
|
||||
16
lib/private/UnityEngine/Math.cpp
Normal file
16
lib/private/UnityEngine/Math.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "pch-il2cpp.h"
|
||||
|
||||
#include "UnityEngine/Math.h"
|
||||
#include <helpers.h>
|
||||
|
||||
const char* Math::Vector3::ToString(app::Vector3* v)
|
||||
{
|
||||
app::String* str = app::Vector3_ToString(v, nullptr);
|
||||
|
||||
return str ? il2cppi_to_string(str).c_str() : "Vector::ToString returned nullptr!\n";
|
||||
}
|
||||
|
||||
const char* Math::Vector3::ToString(app::Vector3 v)
|
||||
{
|
||||
return ("x: " + std::to_string(v.x) + " y: " + std::to_string(v.y) + " z: " + std::to_string(v.z)).c_str();
|
||||
}
|
||||
30
lib/private/UnityEngine/Object.cpp
Normal file
30
lib/private/UnityEngine/Object.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "pch-il2cpp.h"
|
||||
|
||||
#include "UnityEngine/Object.h"
|
||||
#include <string>
|
||||
#include <helpers.h>
|
||||
|
||||
const char* Object::GetObjectName(app::Object_1* obj)
|
||||
{
|
||||
static std::string name = il2cppi_to_string(app::Object_1_GetName(obj, nullptr));
|
||||
return name.c_str();
|
||||
}
|
||||
|
||||
app::GameObject__Array* Object::FindGameObjectsWithTag(const char* tag)
|
||||
{
|
||||
app::GameObject__Array* go_array_result = app::GameObject_FindGameObjectsWithTag(ConvertToSystemString(tag), nullptr);
|
||||
|
||||
return go_array_result ? go_array_result : nullptr;
|
||||
}
|
||||
|
||||
void Object::FindObjectFromInstanceID(int32_t instanceID)
|
||||
{
|
||||
}
|
||||
|
||||
bool Object::IsNull(app::Object_1* obj)
|
||||
{
|
||||
if (obj == nullptr)
|
||||
return true;
|
||||
|
||||
return !app::Object_1_op_Implicit(obj, nullptr);
|
||||
}
|
||||
19
lib/private/UnityEngine/Transform.cpp
Normal file
19
lib/private/UnityEngine/Transform.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "pch-il2cpp.h"
|
||||
|
||||
#include "UnityEngine/Transform.h"
|
||||
|
||||
app::Transform* Transform::Get(app::GameObject* go)
|
||||
{
|
||||
if (!go || !app::GameObject_get_transform) return nullptr;
|
||||
|
||||
app::Transform* __transform = app::GameObject_get_transform(go, nullptr);
|
||||
|
||||
return __transform ? __transform : nullptr;
|
||||
}
|
||||
|
||||
app::Vector3 Transform::Position(app::Transform* transform)
|
||||
{
|
||||
if (!transform || !app::Transform_get_position) return app::Vector3();
|
||||
|
||||
return app::Transform_get_position(transform, nullptr);
|
||||
}
|
||||
@@ -8,7 +8,6 @@ bool IsLocalPlayer(app::NolanBehaviour* player);
|
||||
bool IsPlayerCrawling();
|
||||
bool IsPlayerCrawling(app::GameObject* go);
|
||||
bool IsInGame();
|
||||
bool IsNull(app::Object_1* obj);
|
||||
|
||||
app::GameObject* GetAzazel(app::Survival* survival);
|
||||
|
||||
5
lib/public/UnityEngine/Camera.h
Normal file
5
lib/public/UnityEngine/Camera.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
struct Camera {
|
||||
static app::Camera* GetMainCamera();
|
||||
};
|
||||
7
lib/public/UnityEngine/Engine.hpp
Normal file
7
lib/public/UnityEngine/Engine.hpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "UnityEngine/Camera.h"
|
||||
#include "UnityEngine/GameObject.h"
|
||||
#include "UnityEngine/Input.h"
|
||||
#include "UnityEngine/Object.h"
|
||||
#include "UnityEngine/Transform.h"
|
||||
6
lib/public/UnityEngine/GameObject.h
Normal file
6
lib/public/UnityEngine/GameObject.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
namespace GameObject {
|
||||
app::Component* GetComponentByName(app::GameObject* go, const char* type);
|
||||
app::Component__Array* LogComponents(app::GameObject* go);
|
||||
};
|
||||
5
lib/public/UnityEngine/Input.h
Normal file
5
lib/public/UnityEngine/Input.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
struct Input {
|
||||
static float GetAxis(const char* axisName);
|
||||
};
|
||||
8
lib/public/UnityEngine/Math.h
Normal file
8
lib/public/UnityEngine/Math.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
namespace Math {
|
||||
namespace Vector3 {
|
||||
const char* ToString(app::Vector3* v);
|
||||
const char* ToString(app::Vector3 v);
|
||||
}
|
||||
}
|
||||
37
lib/public/UnityEngine/Object.h
Normal file
37
lib/public/UnityEngine/Object.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include "wrapper.h"
|
||||
|
||||
struct Object {
|
||||
static const char* GetObjectName(app::Object_1* obj);
|
||||
static app::GameObject__Array* FindGameObjectsWithTag(const char* tag);
|
||||
static void FindObjectFromInstanceID(int32_t instanceID);
|
||||
|
||||
static bool IsNull(app::Object_1* obj);
|
||||
|
||||
template<typename T>
|
||||
static inline T* FindObjectOfType(const char* className, const char* classNamespace = "", const char* assemblyName = "Assembly-CSharp.dll") {
|
||||
|
||||
Wrapper obj(assemblyName);
|
||||
|
||||
Il2CppObject* object = obj.find_class(classNamespace, className).get_class();
|
||||
|
||||
if (!object || !app::Object_1_FindObjectOfType) return nullptr;
|
||||
|
||||
app::Object_1* obj_1 = app::Object_1_FindObjectOfType(reinterpret_cast<app::Type*>(object), nullptr);
|
||||
|
||||
if (!obj_1 || IsNull(obj_1)) return nullptr;
|
||||
|
||||
return reinterpret_cast<T*>(obj_1);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static inline bool Enabled(T* behaviour) {
|
||||
return app::Behaviour_get_enabled((app::Behaviour*)behaviour, nullptr);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static inline void Enabled(T* behaviour, bool value) {
|
||||
app::Behaviour_set_enabled((app::Behaviour*)behaviour, value, nullptr);
|
||||
}
|
||||
};
|
||||
6
lib/public/UnityEngine/Transform.h
Normal file
6
lib/public/UnityEngine/Transform.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
namespace Transform {
|
||||
app::Transform* Get(app::GameObject* go);
|
||||
app::Vector3 Position(app::Transform* transform);
|
||||
}
|
||||
Reference in New Issue
Block a user