From c35f790350e8494677bcf200438561c3099c9c4a Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Thu, 23 May 2024 08:45:59 -0400 Subject: Added Card item --- AnodyneArchipelago/ArchipelagoManager.cs | 7 +++++++ AnodyneArchipelago/Plugin.cs | 10 ++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'AnodyneArchipelago') diff --git a/AnodyneArchipelago/ArchipelagoManager.cs b/AnodyneArchipelago/ArchipelagoManager.cs index 781a335..a882cd8 100644 --- a/AnodyneArchipelago/ArchipelagoManager.cs +++ b/AnodyneArchipelago/ArchipelagoManager.cs @@ -1,5 +1,6 @@ using AnodyneSharp.Entities; using AnodyneSharp.Entities.Enemy.Redcave; +using AnodyneSharp.Entities.Gadget.Treasures; using AnodyneSharp.Registry; using AnodyneSharp.Sounds; using Archipelago.MultiClient.Net; @@ -189,6 +190,12 @@ namespace AnodyneArchipelago { GlobalState.events.IncEvent("ProgressiveRedGrotto"); } + else if (itemName == "Card") + { + CardTreasure cardTreasure = new(Plugin.Player.Position, GlobalState.inventory.CardCount); + cardTreasure.GetTreasure(); + GlobalState.SpawnEntity(cardTreasure); + } string message; if (item.Player == _session.ConnectionInfo.Slot) diff --git a/AnodyneArchipelago/Plugin.cs b/AnodyneArchipelago/Plugin.cs index 24345fc..26f1274 100644 --- a/AnodyneArchipelago/Plugin.cs +++ b/AnodyneArchipelago/Plugin.cs @@ -6,6 +6,7 @@ using AnodyneSharp.Entities.Gadget; using AnodyneSharp.Entities.Gadget.Treasures; using AnodyneSharp.Entities.Interactive; using AnodyneSharp.Registry; +using AnodyneSharp.States; using AnodyneSharp.Utilities; using BepInEx; using BepInEx.NET.Common; @@ -23,6 +24,7 @@ namespace AnodyneArchipelago public class Plugin : BasePlugin { public static Plugin Instance = null; + public static Player Player = null; public override void Load() { @@ -48,11 +50,15 @@ namespace AnodyneArchipelago } } - [HarmonyPatch(typeof(AnodyneSharp.States.PlayState), nameof(AnodyneSharp.States.PlayState.Create))] + [HarmonyPatch(typeof(PlayState), nameof(PlayState.Create))] class PlayStateCreatePatch { - static void Prefix() + static void Prefix(PlayState __instance) { + // Get player for later access. + FieldInfo playerField = typeof(PlayState).GetField("_player", BindingFlags.NonPublic | BindingFlags.Instance); + Plugin.Player = (Player)playerField.GetValue(__instance); + // Handle Red Grotto stuff. GlobalState.events.SetEvent("red_cave_l_ss", 999); GlobalState.events.SetEvent("red_cave_n_ss", 999); -- cgit 1.4.1