about summary refs log tree commit diff stats
path: root/AnodyneArchipelago
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2024-05-25 15:37:05 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2024-05-25 15:37:05 -0400
commit6a518ca7bdb787ef6d37469d26648afb8385c987 (patch)
treee2e0374bfd158c33d6b87ae37d00bd3205f51fe8 /AnodyneArchipelago
parent6a9ff88b6c07a7f7d236da008f8a328418c49571 (diff)
downloadanodyne-archipelago-6a518ca7bdb787ef6d37469d26648afb8385c987.tar.gz
anodyne-archipelago-6a518ca7bdb787ef6d37469d26648afb8385c987.tar.bz2
anodyne-archipelago-6a518ca7bdb787ef6d37469d26648afb8385c987.zip
Block access to terminal without Red Key
Diffstat (limited to 'AnodyneArchipelago')
-rw-r--r--AnodyneArchipelago/Patches/GameplayPatches.cs23
-rw-r--r--AnodyneArchipelago/Patches/PatchHelper.cs16
2 files changed, 39 insertions, 0 deletions
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;
15using AnodyneSharp.Sounds; 15using AnodyneSharp.Sounds;
16using AnodyneSharp.States; 16using AnodyneSharp.States;
17using AnodyneSharp.Entities.Interactive.Npc; 17using AnodyneSharp.Entities.Interactive.Npc;
18using AnodyneSharp.MapData;
18 19
19namespace AnodyneArchipelago.Patches 20namespace AnodyneArchipelago.Patches
20{ 21{
@@ -321,4 +322,26 @@ namespace AnodyneArchipelago.Patches
321 } 322 }
322 } 323 }
323 } 324 }
325
326 [HarmonyPatch(typeof(PlayState), "Warp")]
327 class PlayWarpPatch
328 {
329 static void Postfix()
330 {
331 if (GlobalState.CURRENT_MAP_NAME == "FIELDS")
332 {
333 // Place a rock blocking access to Terminal without the red key.
334 PatchHelper.SetMapTile(31, 47, 11, Layer.BG);
335 }
336 }
337 }
338
339 /*[HarmonyPatch(typeof(Player), "Movement")]
340 class PlayerMovementPatch
341 {
342 static void Postfix(Player __instance)
343 {
344 Plugin.Instance.Log.LogInfo($"Player pos: {GlobalState.Map.ToMapLoc(__instance.Position)}");
345 }
346 }*/
324} 347}
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 @@
1using AnodyneSharp.Entities; 1using AnodyneSharp.Entities;
2using AnodyneSharp.MapData;
3using AnodyneSharp.Registry;
2using System; 4using System;
5using System.Collections.Generic;
3using System.Reflection; 6using System.Reflection;
7using Layer = AnodyneSharp.MapData.Layer;
4 8
5namespace AnodyneArchipelago.Patches 9namespace AnodyneArchipelago.Patches
6{ 10{
@@ -11,5 +15,17 @@ namespace AnodyneArchipelago.Patches
11 FieldInfo presetField = type.GetField("_preset", BindingFlags.NonPublic | BindingFlags.Instance); 15 FieldInfo presetField = type.GetField("_preset", BindingFlags.NonPublic | BindingFlags.Instance);
12 return presetField.GetValue(instance) as EntityPreset; 16 return presetField.GetValue(instance) as EntityPreset;
13 } 17 }
18
19 public static void SetMapTile(int x, int y, int value, Layer layer)
20 {
21 FieldInfo layersField = typeof(Map).GetField("mapLayers", BindingFlags.NonPublic | BindingFlags.Instance);
22 TileMap[] mapLayers = (TileMap[])layersField.GetValue(GlobalState.Map);
23 TileMap mapLayer = mapLayers[(int)layer];
24
25 FieldInfo tilesField = typeof(TileMap).GetField("tiles", BindingFlags.NonPublic | BindingFlags.Instance);
26 List<int> tiles = (List<int>)tilesField.GetValue(mapLayer);
27
28 tiles[x + y * mapLayer.Width] = value;
29 }
14 } 30 }
15} 31}