Reorganized UnityEngine namespace
Reorganized UnityEngine namespace by splitting headers into individual classes
This commit is contained in:
106
lib/private/ClientHelper.cpp
Normal file
106
lib/private/ClientHelper.cpp
Normal file
@@ -0,0 +1,106 @@
|
||||
#include "pch-il2cpp.h"
|
||||
|
||||
#include <helpers.h>
|
||||
|
||||
#include "ClientHelper.h"
|
||||
#include "players/players.h"
|
||||
#include "UnityEngine/Engine.hpp"
|
||||
|
||||
bool IsSinglePlayer()
|
||||
{
|
||||
return app::BoltNetwork_get_IsSinglePlayer(NULL);
|
||||
}
|
||||
|
||||
bool IsOnline()
|
||||
{
|
||||
return not app::BoltNetwork_get_IsSinglePlayer(NULL);
|
||||
}
|
||||
|
||||
bool IsHost()
|
||||
{
|
||||
return app::BoltNetwork_get_IsServer(NULL);
|
||||
}
|
||||
|
||||
bool IsLocalPlayer(app::NolanBehaviour* player)
|
||||
{
|
||||
auto boltEntity = app::EntityBehaviour_get_entity((app::EntityBehaviour*)player, NULL);
|
||||
|
||||
if (not boltEntity
|
||||
|| not app::BoltEntity_get_IsAttached(boltEntity, NULL)
|
||||
|| not app::BoltEntity_get_IsOwner(boltEntity, NULL))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IsPlayerCrawling()
|
||||
{
|
||||
if (!Player::GetLocalPlayer())
|
||||
return false;
|
||||
|
||||
return app::NolanBehaviour_IsCrawling(Player::GetNolan(), nullptr);
|
||||
}
|
||||
|
||||
bool IsPlayerCrawling(app::GameObject* go)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
bool IsInGame()
|
||||
{
|
||||
app::OptionsHelpers* optionsHelpers = Object::FindObjectOfType<app::OptionsHelpers>("OptionsHelpers");
|
||||
|
||||
if (optionsHelpers)
|
||||
return optionsHelpers->fields._inGame_k__BackingField;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
app::GameObject* GetAzazel(app::Survival* survival)
|
||||
{
|
||||
app::GameObject* ai = app::Survival_GetAzazel(survival, nullptr);
|
||||
|
||||
if (ai) {
|
||||
return ai;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
std::string SceneName()
|
||||
{
|
||||
if (app::SaveHelpers_get_singleton != nullptr) {
|
||||
app::SaveHelpers* SaveHelper = app::SaveHelpers_get_singleton(nullptr);
|
||||
|
||||
if (SaveHelper) {
|
||||
|
||||
std::string str = il2cppi_to_string(SaveHelper->fields.sceneName);
|
||||
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
return std::string("");
|
||||
}
|
||||
|
||||
|
||||
float Time_DeltaTime()
|
||||
{
|
||||
if (app::Time_1_get_deltaTime) {
|
||||
return app::Time_1_get_deltaTime(nullptr);
|
||||
}
|
||||
|
||||
return 0.0f;
|
||||
}
|
||||
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);
|
||||
}
|
||||
98
lib/private/wrapper.cpp
Normal file
98
lib/private/wrapper.cpp
Normal file
@@ -0,0 +1,98 @@
|
||||
#include "pch-il2cpp.h"
|
||||
|
||||
#include "Wrapper.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string.h>
|
||||
|
||||
Wrapper::Wrapper(const char* imageName) : image(GetImage(imageName)), obj(nullptr) {}
|
||||
|
||||
const Il2CppImage* Wrapper::GetImage(const char* imageName)
|
||||
{
|
||||
if (image)
|
||||
return image;
|
||||
|
||||
const Il2CppDomain* domain = il2cpp_domain_get();
|
||||
size_t size;
|
||||
const Il2CppAssembly** assemblies = il2cpp_domain_get_assemblies(domain, &size);
|
||||
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
const Il2CppAssembly* assembly = assemblies[i];
|
||||
if (assembly) {
|
||||
const char* assemblyName = il2cpp_image_get_name(assembly->image);
|
||||
if (std::string(assemblyName) == imageName) {
|
||||
return assembly->image;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Wrapper& Wrapper::find_class(const char* classNamespace, const char* className)
|
||||
{
|
||||
Il2CppClass* _class = il2cpp_class_from_name(image, classNamespace, className);
|
||||
if (_class) {
|
||||
const Il2CppType* _type = il2cpp_class_get_type(_class);
|
||||
if (_type) {
|
||||
obj = il2cpp_type_get_object(_type);
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Wrapper::get_fields(const char* classNamespace, const char* className)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Wrapper::method_info(const char* classNamespace, const char* className)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Wrapper::classList()
|
||||
{
|
||||
size_t classCount = il2cpp_image_get_class_count(image);
|
||||
|
||||
std::cout << "{\n";
|
||||
|
||||
for (size_t i = 0; i < classCount; ++i) {
|
||||
const Il2CppClass* _klass = il2cpp_image_get_class(image, i);
|
||||
|
||||
if (_klass) {
|
||||
char* _name = const_cast<char*>(il2cpp_class_get_name(const_cast<Il2CppClass*>(_klass)));
|
||||
char* _namespace = const_cast<char*>(il2cpp_class_get_namespace(const_cast<Il2CppClass*>(_klass)));
|
||||
|
||||
std::cout << " [\n";
|
||||
std::cout << "\tName: " << _name << "\n";
|
||||
std::cout << "\tNamespace: " << _namespace << "\n";
|
||||
|
||||
std::cout << " ],\n";
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "\n}\n";
|
||||
}
|
||||
|
||||
Il2CppObject* Wrapper::get_class()
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
|
||||
const char* Wrapper::GetImageName()
|
||||
{
|
||||
if (image)
|
||||
return il2cpp_image_get_name(image);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const Il2CppImage* Wrapper::get_image()
|
||||
{
|
||||
if (image)
|
||||
return image;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
Reference in New Issue
Block a user