w
w
This commit is contained in:
commit
7bd33ca73b
98 files changed
+56670
No files matched your search
@@ -0,0 +1,69 @@
|
||||
#include "Vacuum.h"
|
||||
|
||||
#include "helpers.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace {
|
||||
constexpr float kAttractStrength = 1.0f;
|
||||
}
|
||||
|
||||
VacuumModule::VacuumModule()
|
||||
: BaseModule("Vacuum", "Vacuum", ModuleCategory::World) {}
|
||||
|
||||
void VacuumModule::RegisterTab() {
|
||||
monster_on_ = false;
|
||||
}
|
||||
|
||||
void VacuumModule::Render() {
|
||||
if (!ImGui::CollapsingHeader(Tr("Vacuum"), ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool vacuum_enabled = Enabled();
|
||||
const std::string vacuum_toggle_label = std::string(Tr("Vacuum")) + "##vacuum_toggle";
|
||||
if (ImGui::Checkbox(vacuum_toggle_label.c_str(), &vacuum_enabled)) {
|
||||
SetEnabled(vacuum_enabled);
|
||||
}
|
||||
ImGui::Checkbox(Tr("Monster"), &monster_on_);
|
||||
}
|
||||
|
||||
void VacuumModule::Update() {
|
||||
if (!Enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
using FnCameraMain = void* (*)(void*);
|
||||
using FnGetTransform = void* (*)(void*);
|
||||
using FnGetPosition = Vec3* (*)(void*);
|
||||
using FnAddForce = void (*)(void*, Vec3*, int);
|
||||
|
||||
auto camera_main = GetIl2cppFn<FnCameraMain>(IL2CPP::Camera_get_main);
|
||||
auto get_transform = GetIl2cppFn<FnGetTransform>(IL2CPP::GameObject_get_transform);
|
||||
auto get_position = GetIl2cppFn<FnGetPosition>(IL2CPP::Transform_get_position);
|
||||
auto add_force = GetIl2cppFn<FnAddForce>(IL2CPP::Rigidbody_AddForce);
|
||||
if (!camera_main || !get_transform || !get_position || !add_force) {
|
||||
return;
|
||||
}
|
||||
|
||||
void* camera = camera_main(nullptr);
|
||||
if (!camera) {
|
||||
return;
|
||||
}
|
||||
void* cam_transform = get_transform(camera);
|
||||
if (!cam_transform) {
|
||||
return;
|
||||
}
|
||||
Vec3* cam_pos = get_position(cam_transform);
|
||||
if (!cam_pos) {
|
||||
return;
|
||||
}
|
||||
|
||||
Vec3 force{};
|
||||
force.x = cam_pos->x * kAttractStrength;
|
||||
force.y = cam_pos->y * kAttractStrength;
|
||||
force.z = cam_pos->z * kAttractStrength;
|
||||
|
||||
(void)add_force;
|
||||
(void)monster_on_;
|
||||
}
|
||||
Reference in new issue
Block a user