From ba2a395da7026de4be32733fc27011e161ead255 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sun, 26 May 2024 12:06:27 -0400 Subject: Added AP icon for treasure chests --- AnodyneArchipelago/Patches/StatePatches.cs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'AnodyneArchipelago/Patches/StatePatches.cs') 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; using AnodyneSharp.Drawing; using System.IO; using System; +using AnodyneSharp.Resources; +using BepInEx; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; +using System.Collections.Generic; namespace AnodyneArchipelago.Patches { + [HarmonyPatch(typeof(AnodyneGame), "LoadContent")] + class AnodyneLoadContentPatch + { + static void Prefix(AnodyneGame __instance) + { + FieldInfo gdmField = typeof(AnodyneGame).GetField("graphics", BindingFlags.NonPublic | BindingFlags.Instance); + Plugin.GraphicsDevice = ((GraphicsDeviceManager)gdmField.GetValue(__instance)).GraphicsDevice; + } + } + [HarmonyPatch(typeof(AnodyneGame), "Update")] class GameUpdatePatch { @@ -127,4 +142,18 @@ namespace AnodyneArchipelago.Patches Plugin.ArchipelagoManager.ActivateGoal(); } } + + [HarmonyPatch(typeof(ResourceManager), nameof(ResourceManager.LoadResources))] + static class LoadResourcesPatch + { + static void Postfix() + { + FileStream filestream = File.OpenRead($"{Paths.GameRootPath}\\Resources\\archipelago.png"); + Texture2D apSprite = Texture2D.FromStream(Plugin.GraphicsDevice, filestream); + + FieldInfo texturesField = typeof(ResourceManager).GetField("_textures", BindingFlags.NonPublic | BindingFlags.Static); + Dictionary textures = (Dictionary)texturesField.GetValue(null); + textures["archipelago"] = apSprite; + } + } } -- cgit 1.4.1