Skip to content

Commit

Permalink
Allow opening Kwolok statue keystone door from behind
Browse files Browse the repository at this point in the history
  • Loading branch information
timoschwarzer committed Nov 28, 2023
1 parent 08edeeb commit e6be72e
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 28 deletions.
4 changes: 2 additions & 2 deletions projects/Modloader/app/methods/RECT.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once
#include <Modloader/interception_macros.h>

#include <Modloader/app/structs/RECT__Boxed.h>
#include <Modloader/app/structs/Rect__Boxed.h>
#include <Modloader/app/structs/Object.h>
#include <Modloader/app/structs/RECT.h>
#include <Modloader/app/structs/Rect.h>
#include <Modloader/app/structs/String.h>

namespace app::classes::RECT {
Expand Down
2 changes: 1 addition & 1 deletion projects/Modloader/app/methods/WindowManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <Modloader/interception_macros.h>

#include <Modloader/app/structs/String.h>
#include <Modloader/app/structs/RECT.h>
#include <Modloader/app/structs/Rect.h>
#include <Modloader/app/structs/WindowManager.h>

namespace app::classes::WindowManager {
Expand Down
8 changes: 4 additions & 4 deletions projects/Modloader/app/structs/Rect__Boxed.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace app {
#elif defined(IL2CPP_STRUCTS_INITIALIZING)
#define IL2CPP_STRUCT_RECT__Boxed_INITIALIZING
#if !defined(IL2CPP_STRUCT_RECT__Boxed_DEFINED)
#include <Modloader/app/structs/RECT.h>
#include <Modloader/app/structs/Rect.h>
#if defined(IL2CPP_STRUCT_RECT_DEFINED)
#define IL2CPP_STRUCT_RECT__Boxed_DEFINED
struct RECT__Class;
Expand All @@ -47,16 +47,16 @@ struct RECT__Boxed {
#endif
#if !defined(IL2CPP_STRUCT_RECT__Boxed_FWDDECL)
#define IL2CPP_STRUCT_RECT__Boxed_FWDDECL
#include <Modloader/app/structs/RECT__Class.h>
#include <Modloader/app/structs/Rect__Class.h>
#endif
#undef IL2CPP_STRUCT_RECT__Boxed_INITIALIZING
#if !defined(IL2CPP_STRUCT_RECT__Boxed_DEFINED) && !defined(IL2CPP_STRUCT_RECT__Boxed_FWDDECL)
#include <Modloader/app/structs/RECT__Boxed.h>
#include <Modloader/app/structs/Rect__Boxed.h>
#endif
#else
namespace app {
#define IL2CPP_STRUCTS_INITIALIZING
#include <Modloader/app/structs/RECT__Boxed.h>
#include <Modloader/app/structs/Rect__Boxed.h>
#undef IL2CPP_STRUCTS_INITIALIZING
} // namespace app
#endif
8 changes: 4 additions & 4 deletions projects/Modloader/app/structs/Rect__Class.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace app {
#elif defined(IL2CPP_STRUCTS_INITIALIZING)
#define IL2CPP_STRUCT_RECT__Class_INITIALIZING
#if !defined(IL2CPP_STRUCT_RECT__Class_DEFINED)
#include <Modloader/app/structs/RECT__VTable.h>
#include <Modloader/app/structs/Rect__VTable.h>
#if defined(IL2CPP_STRUCT_RECT__VTable_DEFINED)
#define IL2CPP_STRUCT_RECT__Class_DEFINED
struct RECT__StaticFields;
Expand All @@ -53,16 +53,16 @@ struct RECT__Class {
#endif
#if !defined(IL2CPP_STRUCT_RECT__Class_FWDDECL)
#define IL2CPP_STRUCT_RECT__Class_FWDDECL
#include <Modloader/app/structs/RECT__StaticFields.h>
#include <Modloader/app/structs/Rect__StaticFields.h>
#endif
#undef IL2CPP_STRUCT_RECT__Class_INITIALIZING
#if !defined(IL2CPP_STRUCT_RECT__Class_DEFINED) && !defined(IL2CPP_STRUCT_RECT__Class_FWDDECL)
#include <Modloader/app/structs/RECT__Class.h>
#include <Modloader/app/structs/Rect__Class.h>
#endif
#else
namespace app {
#define IL2CPP_STRUCTS_INITIALIZING
#include <Modloader/app/structs/RECT__Class.h>
#include <Modloader/app/structs/Rect__Class.h>
#undef IL2CPP_STRUCTS_INITIALIZING
} // namespace app
#endif
4 changes: 2 additions & 2 deletions projects/Modloader/app/structs/Rect__StaticFields.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ struct RECT__StaticFields {
#endif
#undef IL2CPP_STRUCT_RECT__StaticFields_INITIALIZING
#if !defined(IL2CPP_STRUCT_RECT__StaticFields_DEFINED) && !defined(IL2CPP_STRUCT_RECT__StaticFields_FWDDECL)
#include <Modloader/app/structs/RECT__StaticFields.h>
#include <Modloader/app/structs/Rect__StaticFields.h>
#endif
#else
namespace app {
#define IL2CPP_STRUCTS_INITIALIZING
#include <Modloader/app/structs/RECT__StaticFields.h>
#include <Modloader/app/structs/Rect__StaticFields.h>
#undef IL2CPP_STRUCTS_INITIALIZING
} // namespace app
#endif
4 changes: 2 additions & 2 deletions projects/Modloader/app/structs/Rect__VTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ struct RECT__VTable {
#endif
#undef IL2CPP_STRUCT_RECT__VTable_INITIALIZING
#if !defined(IL2CPP_STRUCT_RECT__VTable_DEFINED) && !defined(IL2CPP_STRUCT_RECT__VTable_FWDDECL)
#include <Modloader/app/structs/RECT__VTable.h>
#include <Modloader/app/structs/Rect__VTable.h>
#endif
#else
namespace app {
#define IL2CPP_STRUCTS_INITIALIZING
#include <Modloader/app/structs/RECT__VTable.h>
#include <Modloader/app/structs/Rect__VTable.h>
#undef IL2CPP_STRUCTS_INITIALIZING
} // namespace app
#endif
8 changes: 4 additions & 4 deletions projects/Modloader/app/structs/Rect___Class.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace app {
#elif defined(IL2CPP_STRUCTS_INITIALIZING)
#define IL2CPP_STRUCT_RECT___Class_INITIALIZING
#if !defined(IL2CPP_STRUCT_RECT___Class_DEFINED)
#include <Modloader/app/structs/RECT___VTable.h>
#include <Modloader/app/structs/Rect___VTable.h>
#if defined(IL2CPP_STRUCT_RECT___VTable_DEFINED)
#define IL2CPP_STRUCT_RECT___Class_DEFINED
struct RECT___StaticFields;
Expand All @@ -53,16 +53,16 @@ struct RECT___Class {
#endif
#if !defined(IL2CPP_STRUCT_RECT___Class_FWDDECL)
#define IL2CPP_STRUCT_RECT___Class_FWDDECL
#include <Modloader/app/structs/RECT___StaticFields.h>
#include <Modloader/app/structs/Rect___StaticFields.h>
#endif
#undef IL2CPP_STRUCT_RECT___Class_INITIALIZING
#if !defined(IL2CPP_STRUCT_RECT___Class_DEFINED) && !defined(IL2CPP_STRUCT_RECT___Class_FWDDECL)
#include <Modloader/app/structs/RECT___Class.h>
#include <Modloader/app/structs/Rect___Class.h>
#endif
#else
namespace app {
#define IL2CPP_STRUCTS_INITIALIZING
#include <Modloader/app/structs/RECT___Class.h>
#include <Modloader/app/structs/Rect___Class.h>
#undef IL2CPP_STRUCTS_INITIALIZING
} // namespace app
#endif
4 changes: 2 additions & 2 deletions projects/Modloader/app/structs/Rect___StaticFields.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ struct RECT___StaticFields {
#endif
#undef IL2CPP_STRUCT_RECT___StaticFields_INITIALIZING
#if !defined(IL2CPP_STRUCT_RECT___StaticFields_DEFINED) && !defined(IL2CPP_STRUCT_RECT___StaticFields_FWDDECL)
#include <Modloader/app/structs/RECT___StaticFields.h>
#include <Modloader/app/structs/Rect___StaticFields.h>
#endif
#else
namespace app {
#define IL2CPP_STRUCTS_INITIALIZING
#include <Modloader/app/structs/RECT___StaticFields.h>
#include <Modloader/app/structs/Rect___StaticFields.h>
#undef IL2CPP_STRUCTS_INITIALIZING
} // namespace app
#endif
4 changes: 2 additions & 2 deletions projects/Modloader/app/structs/Rect___VTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ struct RECT___VTable {
#endif
#undef IL2CPP_STRUCT_RECT___VTable_INITIALIZING
#if !defined(IL2CPP_STRUCT_RECT___VTable_DEFINED) && !defined(IL2CPP_STRUCT_RECT___VTable_FWDDECL)
#include <Modloader/app/structs/RECT___VTable.h>
#include <Modloader/app/structs/Rect___VTable.h>
#endif
#else
namespace app {
#define IL2CPP_STRUCTS_INITIALIZING
#include <Modloader/app/structs/RECT___VTable.h>
#include <Modloader/app/structs/Rect___VTable.h>
#undef IL2CPP_STRUCTS_INITIALIZING
} // namespace app
#endif
6 changes: 3 additions & 3 deletions projects/Modloader/app/types/Rect.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ namespace app::classes::types {
} // namespace Rect
} // namespace app::classes::types
#pragma once
#include <Modloader/app/structs/RECT.h>
#include <Modloader/app/structs/RECT__Boxed.h>
#include <Modloader/app/structs/RECT__Class.h>
#include <Modloader/app/structs/Rect.h>
#include <Modloader/app/structs/Rect__Boxed.h>
#include <Modloader/app/structs/Rect__Class.h>
#include <Modloader/il2cpp_helpers.h>
#include <Modloader/macros.h>

Expand Down
6 changes: 6 additions & 0 deletions projects/Randomizer/conditions/condition_override.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <Modloader/app/methods/SeinAbilityCondition.h>
#include <Modloader/app/methods/UberStateConditionWrapper.h>
#include <Modloader/app/methods/VisibleOnWorldMap.h>
#include <Modloader/app/methods/PlayerInsideZoneChecker.h>
#include <Modloader/interception_macros.h>

#include <optional>
Expand Down Expand Up @@ -38,6 +39,11 @@ namespace randomizer::conditions {
return value.has_value() ? value.value() : next::UberStateConditionWrapper::Validate(this_ptr, context);
}

IL2CPP_INTERCEPT(PlayerInsideZoneChecker, bool, Validate, (app::PlayerInsideZoneChecker * this_ptr, app::IContext* context)) {
const auto value = intercept(ConditionType::PlayerInsideZoneChecker, this_ptr);
return value.has_value() ? value.value() : next::PlayerInsideZoneChecker::Validate(this_ptr, context);
}

IL2CPP_INTERCEPT(VisibleOnWorldMap, bool, get_MeetsRevealCondition, (app::VisibleOnWorldMap* this_ptr)) {
const auto value = intercept(ConditionType::VisibleOnWorldMap, this_ptr);
return value.has_value() ? value.value() : next::VisibleOnWorldMap::get_MeetsRevealCondition(this_ptr);
Expand Down
6 changes: 4 additions & 2 deletions projects/Randomizer/conditions/condition_override.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <functional>
#include <optional>
#include <string_view>

Expand All @@ -9,10 +10,11 @@ namespace randomizer {
SeinAbilityCondition,
HasAbilityCondition,
UberStateConditionWrapper,
VisibleOnWorldMap
VisibleOnWorldMap,
PlayerInsideZoneChecker,
};

using condition_intercept = std::optional<bool> (*)(std::string_view path, void* obj);
using condition_intercept = std::function<std::optional<bool>(std::string_view, void*)>;
void register_condition_intercept(ConditionType type, std::string_view path, condition_intercept callback);
} // namespace conditions
} // namespace randomizer
84 changes: 84 additions & 0 deletions projects/Randomizer/features/keystone_door.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,20 @@
#include <Modloader/app/methods/MoonDoorWithSlots.h>
#include <Modloader/app/methods/SeinLogicCycle.h>
#include <Modloader/app/methods/UberStateValueCondition.h>
#include <Modloader/app/methods/UnityEngine/Rect.h>
#include <Modloader/app/methods/Moon/Timeline/MoonTimeline.h>
#include <Modloader/app/types/Rect.h>
#include <Modloader/app/types/MoonCustomDoorWithSlots.h>
#include <Modloader/app/types/MoonTimeline.h>
#include <Modloader/app/structs/Boolean__Boxed.h>
#include <Modloader/interception_macros.h>

#include "conditions/condition_override.h"
#include "Core/api/game/player.h"
#include "Core/api/scenes/scene_load.h"
#include "Modloader/modloader.h"
#include "Modloader/windows_api/console.h"

using namespace app::classes;

namespace {
Expand Down Expand Up @@ -45,4 +56,77 @@ namespace {

return next::UberStateValueCondition::Validate(this_ptr, context);
}

auto on_game_ready = modloader::event_bus().register_handler(ModloaderEvent::GameReady, [](auto) {
randomizer::conditions::register_condition_intercept(randomizer::conditions::ConditionType::PlayerInsideZoneChecker, "kwoloksHollowEntrance/artSetups/frogHeadSetup/doorWithTwoSlots/doorWithTwoSlots/canUseKeystonesZone", [](auto, auto) {
const auto position = core::api::game::player::get_position();

auto x = UnityEngine::Rect::Contains_2(
types::Rect::box(app::Rect {-358.9f, -4235.f, 16.f, 11.f }), position
) || UnityEngine::Rect::Contains_2(
types::Rect::box(app::Rect {-312.8f, -4239.8f, 19.f, 12.f }), position
);

modloader::win::console::console_send(x ? "YES" : "NO");

return x;
});
});

// Allow opening the Kwolok state door from behind
auto on_scene_load_handle = core::api::scenes::event_bus().register_handler([](core::api::scenes::SceneLoadEventMetadata* metadata) {
if (metadata->state != app::SceneState__Enum::Loaded) {
return;
}

if (metadata->scene_name == "kwoloksHollowEntrance") {
const auto door_go = il2cpp::unity::find_child(
metadata->scene->fields.SceneRoot,
std::vector<std::string>{
"artSetups",
"frogHeadSetup",
"doorWithTwoSlots",
"doorWithTwoSlots",
"door"}
);

const auto open_door_timeline_go = il2cpp::unity::find_child(
metadata->scene->fields.SceneRoot,
std::vector<std::string>{
"artSetups",
"frogHeadSetup",
"doorWithTwoSlots",
"doorWithTwoSlots",
"timelines",
"doorOpeningTimeline",
"openDoor"}
);

const auto open_door_cinematic_character_go = il2cpp::unity::find_child(
metadata->scene->fields.SceneRoot,
std::vector<std::string>{
"artSetups",
"frogHeadSetup",
"doorWithTwoSlots",
"doorWithTwoSlots",
"timelines",
"doorOpeningTimeline",
"openDoor"}
);

if (il2cpp::unity::is_valid(door_go) && il2cpp::unity::is_valid(open_door_timeline_go)) {
const auto moon_custom_door_with_slots = il2cpp::unity::get_component<app::MoonCustomDoorWithSlots>(door_go, types::MoonCustomDoorWithSlots::get_class());
moon_custom_door_with_slots->fields._.Radius = 50.f;

// Skip eyestone animation sinece it doesn't make sense in this context and makes
// opening the door from the right look weird for a second
moon_custom_door_with_slots->fields._.OpenDoorTimeline = il2cpp::unity::get_component<app::MoonTimeline>(open_door_timeline_go, types::MoonTimeline::get_class());
}

// Destroy this entity to prevent Ori from staying in the air when opening the door
if (il2cpp::unity::is_valid(open_door_cinematic_character_go)) {
il2cpp::unity::destroy_object(open_door_cinematic_character_go);
}
}
});
} // namespace

0 comments on commit e6be72e

Please sign in to comment.