From 6a518ca7bdb787ef6d37469d26648afb8385c987 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 25 May 2024 15:37:05 -0400 Subject: Block access to terminal without Red Key --- AnodyneArchipelago/Patches/GameplayPatches.cs | 23 +++++++++++++++++++++++ AnodyneArchipelago/Patches/PatchHelper.cs | 16 ++++++++++++++++ 2 files changed, 39 insertions(+) (limited to 'AnodyneArchipelago') diff --git a/AnodyneArchipelago/Patches/GameplayPatches.cs b/AnodyneArchipelago/Patches/GameplayPatches.cs index ba33457..a6b572a 100644 --- a/AnodyneArchipelago/Patches/GameplayPatches.cs +++ b/AnodyneArchipelago/Patches/GameplayPatches.cs @@ -15,6 +15,7 @@ using AnodyneSharp.Dialogue; using AnodyneSharp.Sounds; using AnodyneSharp.States; using AnodyneSharp.Entities.Interactive.Npc; +using AnodyneSharp.MapData; namespace AnodyneArchipelago.Patches { @@ -321,4 +322,26 @@ namespace AnodyneArchipelago.Patches } } } + + [HarmonyPatch(typeof(PlayState), "Warp")] + class PlayWarpPatch + { + static void Postfix() + { + if (GlobalState.CURRENT_MAP_NAME == "FIELDS") + { + // Place a rock blocking access to Terminal without the red key. + PatchHelper.SetMapTile(31, 47, 11, Layer.BG); + } + } + } + + /*[HarmonyPatch(typeof(Player), "Movement")] + class PlayerMovementPatch + { + static void Postfix(Player __instance) + { + Plugin.Instance.Log.LogInfo($"Player pos: {GlobalState.Map.ToMapLoc(__instance.Position)}"); + } + }*/ } diff --git a/AnodyneArchipelago/Patches/PatchHelper.cs b/AnodyneArchipelago/Patches/PatchHelper.cs index 6b6d532..090533b 100644 --- a/AnodyneArchipelago/Patches/PatchHelper.cs +++ b/AnodyneArchipelago/Patches/PatchHelper.cs @@ -1,6 +1,10 @@ using AnodyneSharp.Entities; +using AnodyneSharp.MapData; +using AnodyneSharp.Registry; using System; +using System.Collections.Generic; using System.Reflection; +using Layer = AnodyneSharp.MapData.Layer; namespace AnodyneArchipelago.Patches { @@ -11,5 +15,17 @@ namespace AnodyneArchipelago.Patches FieldInfo presetField = type.GetField("_preset", BindingFlags.NonPublic | BindingFlags.Instance); return presetField.GetValue(instance) as EntityPreset; } + + public static void SetMapTile(int x, int y, int value, Layer layer) + { + FieldInfo layersField = typeof(Map).GetField("mapLayers", BindingFlags.NonPublic | BindingFlags.Instance); + TileMap[] mapLayers = (TileMap[])layersField.GetValue(GlobalState.Map); + TileMap mapLayer = mapLayers[(int)layer]; + + FieldInfo tilesField = typeof(TileMap).GetField("tiles", BindingFlags.NonPublic | BindingFlags.Instance); + List tiles = (List)tilesField.GetValue(mapLayer); + + tiles[x + y * mapLayer.Width] = value; + } } } -- cgit 1.4.1