about summary refs log tree commit diff stats
path: root/AnodyneArchipelago/Patches/PatchHelper.cs
diff options
context:
space:
mode:
Diffstat (limited to 'AnodyneArchipelago/Patches/PatchHelper.cs')
-rw-r--r--AnodyneArchipelago/Patches/PatchHelper.cs16
1 files changed, 16 insertions, 0 deletions
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}