From cb072e0515d8b0b9f67607d164f098f80393d82a Mon Sep 17 00:00:00 2001 From: ALittlePatate Date: Mon, 3 Oct 2022 20:15:07 +0200 Subject: [PATCH] add: GetObjectsThread --- DevourClient/Utils/Objects/Objects.cpp | 51 ++++++++++++++++++++++++++ DevourClient/Utils/Objects/Objects.hpp | 9 +++++ 2 files changed, 60 insertions(+) create mode 100644 DevourClient/Utils/Objects/Objects.cpp create mode 100644 DevourClient/Utils/Objects/Objects.hpp diff --git a/DevourClient/Utils/Objects/Objects.cpp b/DevourClient/Utils/Objects/Objects.cpp new file mode 100644 index 0000000..592a003 --- /dev/null +++ b/DevourClient/Utils/Objects/Objects.cpp @@ -0,0 +1,51 @@ +#include "Objects.hpp" +#include "../../Utils/Helpers/Helpers.hpp" + +namespace Objects { + std::vector ObjectList(NULL); +} + +void Objects::GetObjectsThread() { + /* + * Will always lop and get the objects + * This runs in a separate thread to avoid lags because we're fetching the components + * Used as a "cache" - sorta + * I use this instead of my good old corroutine + */ + + IL2CPP::Thread::Attach(IL2CPP::Domain::Get()); + while (1) { + ObjectList.clear(); + + auto list = Unity::Object::FindObjectsOfType("SurvivalInteractable"); + for (int i = 0; i < list->m_uMaxLength + 1; i++) + { + if (!list->operator[](i)) + continue; + + Unity::CGameObject* object = list->operator[](i)->GetMemberValue("gameObject"); + if (!object) { + continue; + } + + ObjectList.push_back(object); + } + + auto list2 = Unity::Object::FindObjectsOfType("KeyBehaviour"); + for (int j = 0; j < list2->m_uMaxLength + 1; j++) + { + if (!list2->operator[](j)) + continue; + + Unity::CGameObject* object2 = list2->operator[](j)->GetMemberValue("gameObject"); + if (!object2) { + continue; + } + + ObjectList.push_back(object2); + } + + Sleep(5000); + } + +} \ No newline at end of file diff --git a/DevourClient/Utils/Objects/Objects.hpp b/DevourClient/Utils/Objects/Objects.hpp new file mode 100644 index 0000000..3f2a914 --- /dev/null +++ b/DevourClient/Utils/Objects/Objects.hpp @@ -0,0 +1,9 @@ +#pragma once +#include "../Dependencies/IL2CPP_Resolver/il2cpp_resolver.hpp" + + +namespace Objects { + extern std::vector ObjectList; + + void GetObjectsThread(); +} \ No newline at end of file