initial commit of the files
This commit is contained in:
22
lib/object.cpp
Normal file
22
lib/object.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "pch-il2cpp.h"
|
||||
|
||||
#include "object.h"
|
||||
#include "helpers.h"
|
||||
|
||||
app::GameObject* GameObject::FindWithTag(const char* tag)
|
||||
{
|
||||
Il2CppString* newStr = il2cpp_string_new(tag);
|
||||
app::String* convert_to_appString = reinterpret_cast<app::String*>(newStr);
|
||||
|
||||
if (app::GameObject_FindWithTag(convert_to_appString, nullptr)) {
|
||||
return app::GameObject_FindWithTag(convert_to_appString, nullptr);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T* GameObject::GetComponent()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
16
lib/object.h
Normal file
16
lib/object.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
|
||||
class GameObject {
|
||||
public:
|
||||
GameObject() = default;
|
||||
|
||||
app::GameObject* FindWithTag(const char* tag);
|
||||
|
||||
template<typename T>
|
||||
T* GetComponent();
|
||||
private:
|
||||
app::GameObject* _currentGameObject = nullptr;
|
||||
};
|
||||
|
||||
52
lib/wrapper.cpp
Normal file
52
lib/wrapper.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
#include "pch-il2cpp.h"
|
||||
|
||||
#include "wrapper.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
Wrapper::Wrapper()
|
||||
{
|
||||
const Il2CppDomain* domain = il2cpp_domain_get();
|
||||
|
||||
const Il2CppAssembly** assemblies;
|
||||
size_t size;
|
||||
|
||||
assemblies = il2cpp_domain_get_assemblies(domain, &size);
|
||||
|
||||
assemblyMap.clear();
|
||||
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
const Il2CppAssembly* assembly = assemblies[i];
|
||||
|
||||
if (assembly) {
|
||||
const char* assemblyName = il2cpp_image_get_name(assembly->image);
|
||||
assemblyMap[assemblyName] = assembly;
|
||||
std::cout << "\t- " << assemblyName << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const Il2CppAssembly* Wrapper::GetAssembly(const char* _assembly) {
|
||||
for (const auto& entry : assemblyMap) {
|
||||
if (strcmp(entry.first, _assembly) == 0) {
|
||||
return entry.second;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const Il2CppImage* Wrapper::GetImage(const char* _assembly) {
|
||||
for (const auto& entry : assemblyMap) {
|
||||
if (strcmp(entry.first, _assembly) == 0) {
|
||||
return entry.second->image;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Il2CppObject* Wrapper::GetObjectFromClass(const Il2CppImage* _image, const char* _namespaze, const char* _name)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
15
lib/wrapper.h
Normal file
15
lib/wrapper.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
|
||||
class Wrapper {
|
||||
public:
|
||||
Wrapper();
|
||||
|
||||
const Il2CppAssembly* GetAssembly(const char* _assembly);
|
||||
const Il2CppImage* GetImage(const char* _assembly);
|
||||
|
||||
Il2CppObject* GetObjectFromClass(const Il2CppImage* _image, const char* _namespaze, const char* _name);
|
||||
private:
|
||||
std::map<const char*, const Il2CppAssembly*> assemblyMap;
|
||||
};
|
||||
Reference in New Issue
Block a user