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/ArchipelagoTreasure.cs | 2 +- AnodyneArchipelago/Patches/StatePatches.cs | 29 +++++++++++++++++++++++++++++ AnodyneArchipelago/Plugin.cs | 2 ++ 3 files changed, 32 insertions(+), 1 deletion(-) (limited to 'AnodyneArchipelago') diff --git a/AnodyneArchipelago/ArchipelagoTreasure.cs b/AnodyneArchipelago/ArchipelagoTreasure.cs index 90f979c..9074108 100644 --- a/AnodyneArchipelago/ArchipelagoTreasure.cs +++ b/AnodyneArchipelago/ArchipelagoTreasure.cs @@ -9,7 +9,7 @@ namespace AnodyneArchipelago { private string _location; - public ArchipelagoTreasure(string location, Vector2 pos) : base("item_jump_shoes", pos, 0, -1) + public ArchipelagoTreasure(string location, Vector2 pos) : base("archipelago", pos, 0, -1) { _location = location; } 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; + } + } } diff --git a/AnodyneArchipelago/Plugin.cs b/AnodyneArchipelago/Plugin.cs index 18f0d36..6c1333d 100644 --- a/AnodyneArchipelago/Plugin.cs +++ b/AnodyneArchipelago/Plugin.cs @@ -3,6 +3,7 @@ using BepInEx; using BepInEx.NET.Common; using HarmonyLib; using HarmonyLib.Tools; +using Microsoft.Xna.Framework.Graphics; using System; using System.Reflection; @@ -13,6 +14,7 @@ namespace AnodyneArchipelago { public static Plugin Instance = null; + public static GraphicsDevice GraphicsDevice = null; public static Player Player = null; public static ArchipelagoManager ArchipelagoManager = null; public static bool IsGamePaused = false; -- cgit 1.4.1