-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBunburrowLoopingPlugin.cs
41 lines (37 loc) · 1.34 KB
/
BunburrowLoopingPlugin.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using BepInEx;
using HarmonyLib;
using Levels;
using Misc;
namespace BunburrowLoopingPlugin;
[BepInPlugin("au.sollyw.bunburrowlooping", "Bunburrow Looping", "1.0.0")]
public class BunburrowLoopingPlugin : BaseUnityPlugin
{
private void Awake()
{
Harmony.CreateAndPatchAll(typeof(BunburrowLoopingPlugin));
}
[HarmonyPatch(typeof(LevelsList))]
[HarmonyPatch("AdjacentBunburrows", MethodType.Getter)]
[HarmonyPostfix]
public static void AdjacentBunburrows(ref DirectionsListOf<LevelsList> __result)
{
DirectionsListOf<LevelsList> copy = new DirectionsListOf<LevelsList>(
__result[Direction.Left],
__result[Direction.Up],
__result[Direction.Right],
__result[Direction.Down]);
__result = copy;
FillVoids(copy, Direction.Left);
FillVoids(copy, Direction.Up);
FillVoids(copy, Direction.Right);
FillVoids(copy, Direction.Down);
static void FillVoids(DirectionsListOf<LevelsList> levelsLists, Direction direction) {
LevelsList levelList = levelsLists[direction];
if (levelList == null) {
Direction opposite = direction.GetOpposite();
levelsLists.SetPart(direction,
levelsLists[opposite]?.AdjacentBunburrows[opposite]);
}
}
}
}