From 1dbfd6c6731eda35b6aa2dfd89642d0a1df8b748 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 1 Mar 2025 10:26:49 -0500 Subject: Entrance randomizer stuff --- GameplayPatches.cs | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'GameplayPatches.cs') diff --git a/GameplayPatches.cs b/GameplayPatches.cs index 03e3f13..5e551ea 100644 --- a/GameplayPatches.cs +++ b/GameplayPatches.cs @@ -453,4 +453,60 @@ namespace ManifoldGardenArchipelago return true; } } + + [HarmonyPatch(typeof(LevelSystems), nameof(LevelSystems.InitializeAndLoadLevel))] + static class LevelSystemsInitializeAndLoadLevelPatch + { + static void Prefix(LevelSystems __instance) + { + if (Plugin.archipelagoManager.RoomShuffle) + { + if (GameData.scenes.TryGetValue(__instance.levelName, out SceneDescription sceneDescription)) + { + foreach (var portal in __instance.LevelInfo.portalList) + { + if (sceneDescription.portals.TryGetValue(portal.portalName, out EntranceIdentifier exitId) && + Plugin.archipelagoManager.EntranceMapping.TryGetValue(exitId, out EntranceIdentifier enterId) && + GameData.portal_by_entrance.TryGetValue(enterId, out PortalDescription pairedPortalDescription)) + { + SceneLink secondLink = new() + { + portalName = pairedPortalDescription.name, + sceneName = pairedPortalDescription.scene.Substring(0, pairedPortalDescription.scene.Length - 10), + gravity = GravityDirection.DownBlue, + targetScene = portal, + }; + portal.targetScene = secondLink; + } + } + } + } + + /*if (__instance.gameObject.scene.name == "World_000_Optimized") + { + // 0: Portal_W001 + SceneLink sceneLink = __instance.LevelInfo.portalList[0]; + SceneLink secondLink = new() + { + portalName = "Portal_W063", + sceneName = "Hallway_W045_W073", + gravity = GravityDirection.DownBlue, + targetScene = sceneLink + }; + sceneLink.targetScene = secondLink; + } + else if (__instance.gameObject.scene.name == "Hallway_W045_W073_Optimized") + { + SceneLink sceneLink = __instance.LevelInfo.portalList[3]; + SceneLink secondLink = new() + { + portalName = "Portal_W001", + sceneName = "World_000", + gravity = GravityDirection.DownBlue, + targetScene = sceneLink + }; + sceneLink.targetScene = secondLink; + }*/ + } + } } -- cgit 1.4.1