about summary refs log tree commit diff stats
path: root/AnodyneArchipelago/Patches
diff options
context:
space:
mode:
Diffstat (limited to 'AnodyneArchipelago/Patches')
-rw-r--r--AnodyneArchipelago/Patches/StatePatches.cs29
1 files changed, 29 insertions, 0 deletions
diff --git a/AnodyneArchipelago/Patches/StatePatches.cs b/AnodyneArchipelago/Patches/StatePatches.cs index c1e03fe..6da5eb5 100644 --- a/AnodyneArchipelago/Patches/StatePatches.cs +++ b/AnodyneArchipelago/Patches/StatePatches.cs
@@ -10,9 +10,24 @@ using static AnodyneSharp.AnodyneGame;
10using AnodyneSharp.Drawing; 10using AnodyneSharp.Drawing;
11using System.IO; 11using System.IO;
12using System; 12using System;
13using AnodyneSharp.Resources;
14using BepInEx;
15using Microsoft.Xna.Framework.Graphics;
16using Microsoft.Xna.Framework;
17using System.Collections.Generic;
13 18
14namespace AnodyneArchipelago.Patches 19namespace AnodyneArchipelago.Patches
15{ 20{
21 [HarmonyPatch(typeof(AnodyneGame), "LoadContent")]
22 class AnodyneLoadContentPatch
23 {
24 static void Prefix(AnodyneGame __instance)
25 {
26 FieldInfo gdmField = typeof(AnodyneGame).GetField("graphics", BindingFlags.NonPublic | BindingFlags.Instance);
27 Plugin.GraphicsDevice = ((GraphicsDeviceManager)gdmField.GetValue(__instance)).GraphicsDevice;
28 }
29 }
30
16 [HarmonyPatch(typeof(AnodyneGame), "Update")] 31 [HarmonyPatch(typeof(AnodyneGame), "Update")]
17 class GameUpdatePatch 32 class GameUpdatePatch
18 { 33 {
@@ -127,4 +142,18 @@ namespace AnodyneArchipelago.Patches
127 Plugin.ArchipelagoManager.ActivateGoal(); 142 Plugin.ArchipelagoManager.ActivateGoal();
128 } 143 }
129 } 144 }
145
146 [HarmonyPatch(typeof(ResourceManager), nameof(ResourceManager.LoadResources))]
147 static class LoadResourcesPatch
148 {
149 static void Postfix()
150 {
151 FileStream filestream = File.OpenRead($"{Paths.GameRootPath}\\Resources\\archipelago.png");
152 Texture2D apSprite = Texture2D.FromStream(Plugin.GraphicsDevice, filestream);
153
154 FieldInfo texturesField = typeof(ResourceManager).GetField("_textures", BindingFlags.NonPublic | BindingFlags.Static);
155 Dictionary<string, Texture2D> textures = (Dictionary<string, Texture2D>)texturesField.GetValue(null);
156 textures["archipelago"] = apSprite;
157 }
158 }
130} 159}