Skip to content

Commit

Permalink
Luma door fix fix fix for rando
Browse files Browse the repository at this point in the history
  • Loading branch information
timoschwarzer committed Nov 3, 2023
1 parent 1fb20c6 commit bc7630f
Showing 1 changed file with 14 additions and 82 deletions.
Original file line number Diff line number Diff line change
@@ -1,116 +1,48 @@
#include <Modloader/app/methods/BoolStateMap.h>
#include <Modloader/app/methods/NewSetupStateController.h>
#include <Modloader/app/methods/UnityEngine/GameObject.h>
#include <Modloader/app/methods/UnityEngine/Transform.h>
#include <Modloader/app/types/NewSetupStateController.h>
#include <Modloader/il2cpp_helpers.h>

#include <Modloader/common.h>
#include <Modloader/windows_api/console.h>
#include <Core/enums/game_event.h>
#include <Core/utils/event_bus.h>
#include <Core/api/scenes/scene_load.h>
#include <Core/api/game/game.h>

using namespace app::classes;

namespace {
int open_door_in_frames = 2;
app::Transform* left_door_transform = nullptr;
app::Transform* right_door_transform = nullptr;
app::GameObject* keyrings_go = nullptr;
app::NewSetupStateController* door_controller = nullptr;

bool open_door() {
if (
!scenes::scene_is_enabled("lumaPoolsC") ||
!il2cpp::unity::is_valid(left_door_transform) ||
!il2cpp::unity::is_valid(right_door_transform) ||
!il2cpp::unity::is_valid(keyrings_go) ||
!il2cpp::unity::is_valid(door_controller)
) {
return false;
}

UnityEngine::Transform::set_position(left_door_transform, app::Vector3{ -0.9f, 8.0f, 0.0f });
UnityEngine::Transform::set_position(right_door_transform, app::Vector3{ 0.7f, -8.0f, 0.0f });
UnityEngine::GameObject::SetActive(keyrings_go, false);

return true;
}

IL2CPP_INTERCEPT(NewSetupStateController, void, OnPostTimeSlicedEnable, (app::NewSetupStateController * this_ptr)) {
next::NewSetupStateController::OnPostTimeSlicedEnable(this_ptr);

if (this_ptr == door_controller) {
open_door_in_frames = 20;
}
}

void on_scene_load(scenes::SceneLoadEventMetadata* metadata, EventTiming timing) {
if (metadata->state != app::SceneState__Enum::Enabled) {
if (metadata->state != app::SceneState__Enum::Loaded) {
return;
}

if (metadata->scene_name == "lumaPoolsC") {
auto scene_root_go = il2cpp::unity::get_game_object(metadata->scene->fields.SceneRoot);

auto door_container_go = il2cpp::unity::find_child(
auto enemy_arena_setup_go = il2cpp::unity::find_child(
scene_root_go,
std::vector<std::string>{
"arenaSetup",
"doors",
"enemyDoorVisualsLagoonLs",
"enemyDoorVisualsLagoonL",
"arenaA",
"enemyArenaSetup3Waves",
}
);

auto door_go = il2cpp::unity::find_child(
scene_root_go,
std::vector<std::string>{
"arenaSetup",
"doors",
"enemyDoorVisualsLagoonLs",
"enemyDoorVisualsLagoonL",
"doorVisualsA",
"sidewaysDoor",
"door",
}
);

if (il2cpp::unity::is_valid(door_container_go) && il2cpp::unity::is_valid(door_go)) {
door_controller = il2cpp::unity::get_component<app::NewSetupStateController>(door_container_go, types::NewSetupStateController::get_class());
if (il2cpp::unity::is_valid(enemy_arena_setup_go)) {
auto enemy_arena_setup_controller = il2cpp::unity::get_component<app::NewSetupStateController>(enemy_arena_setup_go, types::NewSetupStateController::get_class());

auto left_door_go = il2cpp::unity::find_child(door_go, "lagoonEnemyDoorLeft");
auto right_door_go = il2cpp::unity::find_child(door_go, "lagoonEnemyDoorRight");
keyrings_go = il2cpp::unity::find_child(door_go, "keyrings");
left_door_transform = il2cpp::unity::get_transform(left_door_go);
right_door_transform = il2cpp::unity::get_transform(right_door_go);

open_door_in_frames = 20;
auto modifier = enemy_arena_setup_controller->fields.StateHolder->fields.Modifiers->fields._items->vector[4];
for (int i = 0; i < modifier->fields.m_uberStateModifierDatas->fields._size; ++i) {
auto modifier_data = modifier->fields.m_uberStateModifierDatas->fields._items->vector[i];
if (modifier_data->fields.StateGUID == 1708336759) {
modifier_data->fields.StateGUID = 0;
}
}
}
}
}

void on_respawn(GameEvent game_event, EventTiming timing) {
open_door_in_frames = 20;
}

void on_update(GameEvent game_event, EventTiming timing) {
if (open_door_in_frames == 0 && !open_door()) {
open_door_in_frames = 1;
}

if (open_door_in_frames >= 0) {
open_door_in_frames--;
}
}

void initialize() {
game::event_bus().register_handler(GameEvent::Respawn, EventTiming::After, &on_respawn);
game::event_bus().register_handler(GameEvent::FixedUpdate, EventTiming::After, &on_update);
scenes::event_bus().register_handler(&on_scene_load);
}

CALL_ON_INIT(initialize);
} // namespace
} // namespace

0 comments on commit bc7630f

Please sign in to comment.