diff options
Diffstat (limited to 'AnodyneArchipelago/Patches')
-rw-r--r-- | AnodyneArchipelago/Patches/StatePatches.cs | 29 |
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; | |||
10 | using AnodyneSharp.Drawing; | 10 | using AnodyneSharp.Drawing; |
11 | using System.IO; | 11 | using System.IO; |
12 | using System; | 12 | using System; |
13 | using AnodyneSharp.Resources; | ||
14 | using BepInEx; | ||
15 | using Microsoft.Xna.Framework.Graphics; | ||
16 | using Microsoft.Xna.Framework; | ||
17 | using System.Collections.Generic; | ||
13 | 18 | ||
14 | namespace AnodyneArchipelago.Patches | 19 | namespace 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 | } |