From 57670ca11e1cbe1a0a498d1046653f2fdac0d5df Mon Sep 17 00:00:00 2001 From: Timo Schwarzer Date: Fri, 30 Aug 2024 00:18:51 +0200 Subject: [PATCH] Add uber state to allow teleporting at the mapstone in ruins while the escape is running --- projects/Core/property/reactivity.h | 1 + projects/Randomizer/CMakeLists.txt | 1 + .../ruins_escape_allow_teleportation.cpp | 64 +++++++++++++++++++ .../uber_states/uber_state_initialization.cpp | 1 + 4 files changed, 67 insertions(+) create mode 100644 projects/Randomizer/features/scenes/modifications/ruins_escape_allow_teleportation.cpp diff --git a/projects/Core/property/reactivity.h b/projects/Core/property/reactivity.h index 62fb014c84..821f0488a2 100644 --- a/projects/Core/property/reactivity.h +++ b/projects/Core/property/reactivity.h @@ -8,6 +8,7 @@ #include +#include #include #include diff --git a/projects/Randomizer/CMakeLists.txt b/projects/Randomizer/CMakeLists.txt index 56a207edde..cc56e6bfa6 100644 --- a/projects/Randomizer/CMakeLists.txt +++ b/projects/Randomizer/CMakeLists.txt @@ -59,6 +59,7 @@ set( "features/scenes/modifications/marsh_burrow_fight_arena_allow_teleportation.cpp" "features/scenes/modifications/meeting_kwolok_cutscene_trigger_underwater_fix.cpp" "features/scenes/modifications/reactive_bone_bridge_state.cpp" + "features/scenes/modifications/ruins_escape_allow_teleportation.cpp" "features/scenes/modifications/sandless_feeding_grounds_to_elevator.cpp" "features/scenes/modifications/sandless_shriek_escape.cpp" "features/secrets.cpp" diff --git a/projects/Randomizer/features/scenes/modifications/ruins_escape_allow_teleportation.cpp b/projects/Randomizer/features/scenes/modifications/ruins_escape_allow_teleportation.cpp new file mode 100644 index 0000000000..36aedebac6 --- /dev/null +++ b/projects/Randomizer/features/scenes/modifications/ruins_escape_allow_teleportation.cpp @@ -0,0 +1,64 @@ +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace { + using namespace app::classes; + + std::optional> teleport_restrict_zone; + std::shared_ptr effect; + + core::api::uber_states::UberState fix_enabled_state(UberStateGroup::RandoConfig, 21); + + [[maybe_unused]] + auto on_scene_loaded_handler = core::api::scenes::single_event_bus().register_handler( + "desertRuinsBGChase", + [](const core::api::scenes::SceneLoadEventMetadata* metadata, const std::string&) { + if (metadata->state != app::SceneState__Enum::Loaded) { + return; + } + + const auto scene_root_go = il2cpp::unity::get_game_object(metadata->scene->fields.SceneRoot); + + const auto teleport_restrict_zone_go = il2cpp::unity::find_child( + scene_root_go, + std::vector{ + "wormSetup", + "teleportRestrictZone", + } + ); + + teleport_restrict_zone = il2cpp::WeakGCRef( + il2cpp::unity::get_component(teleport_restrict_zone_go, types::TeleportRestrictZone::get_class()) + ); + + effect = core::reactivity::watch_effect([] { + if (teleport_restrict_zone.has_value() && teleport_restrict_zone->is_valid()) { + auto cage_structure_tool = (**teleport_restrict_zone)->fields.CageStructureTool; + + if (fix_enabled_state.get()) { + cage_structure_tool->fields.Vertices->fields._items->vector[0]->fields.Position = app::Vector3{-94.740479f, -140.710449f, 0.f}; + cage_structure_tool->fields.Vertices->fields._items->vector[1]->fields.Position = app::Vector3{-94.369141f, -56.7434082f, 0.f}; + } else { + // Vanilla values + cage_structure_tool->fields.Vertices->fields._items->vector[0]->fields.Position = app::Vector3{-134.740479f, -140.710449f, 0.f}; + cage_structure_tool->fields.Vertices->fields._items->vector[1]->fields.Position = app::Vector3{-134.369141f, -56.7434082f, 0.f}; + } + + CageStructureTool::MarkDirty(cage_structure_tool); + } else { + effect = nullptr; + } + }); + } + ); +} // namespace diff --git a/projects/Randomizer/uber_states/uber_state_initialization.cpp b/projects/Randomizer/uber_states/uber_state_initialization.cpp index 6bff561c8f..97c9c0aaa8 100644 --- a/projects/Randomizer/uber_states/uber_state_initialization.cpp +++ b/projects/Randomizer/uber_states/uber_state_initialization.cpp @@ -380,6 +380,7 @@ namespace randomizer { add_state(UberStateGroup::RandoConfig, "allowTeleportingUnderwater", 18, false), add_state(UberStateGroup::RandoConfig, "allowTeleportingDuringCombatShrineFights", 19, false), add_state(UberStateGroup::RandoConfig, "disableWillowHeartCutscenes", 20, false), + add_state(UberStateGroup::RandoConfig, "allowTeleportingAtRuinsMapstone", 21, false), add_state(UberStateGroup::RandoConfig, "removeShriekEscapeSand", 100, false), add_state(UberStateGroup::RandoConfig, "removeFeedingGroundsToElevatorSand", 101, false), add_state(UberStateGroup::RandoConfig, "knockKnockWellspring", 102, false),