about summary refs log tree commit diff stats
path: root/AnodyneArchipelago
diff options
context:
space:
mode:
Diffstat (limited to 'AnodyneArchipelago')
-rw-r--r--AnodyneArchipelago/ArchipelagoManager.cs12
-rw-r--r--AnodyneArchipelago/Patches/GameplayPatches.cs96
2 files changed, 107 insertions, 1 deletions
diff --git a/AnodyneArchipelago/ArchipelagoManager.cs b/AnodyneArchipelago/ArchipelagoManager.cs index 7c67114..4570c39 100644 --- a/AnodyneArchipelago/ArchipelagoManager.cs +++ b/AnodyneArchipelago/ArchipelagoManager.cs
@@ -107,6 +107,8 @@ namespace AnodyneArchipelago
107 NetworkItem item = _session.Items.AllItemsReceived[i]; 107 NetworkItem item = _session.Items.AllItemsReceived[i];
108 _itemsToCollect.Enqueue(item); 108 _itemsToCollect.Enqueue(item);
109 } 109 }
110
111 _itemIndex = _session.Items.AllItemsReceived.Count;
110 } 112 }
111 113
112 if (_itemsToCollect.Count > 0 && (GlobalState.Dialogue == null || GlobalState.Dialogue == "") && !GlobalState.ScreenTransition && Plugin.Player != null && GlobalState.black_overlay.alpha == 0f) 114 if (_itemsToCollect.Count > 0 && (GlobalState.Dialogue == null || GlobalState.Dialogue == "") && !GlobalState.ScreenTransition && Plugin.Player != null && GlobalState.black_overlay.alpha == 0f)
@@ -132,7 +134,7 @@ namespace AnodyneArchipelago
132 134
133 private void HandleItem(NetworkItem item) 135 private void HandleItem(NetworkItem item)
134 { 136 {
135 if (item.Player == _session.ConnectionInfo.Slot) 137 if (item.Player == _session.ConnectionInfo.Slot && item.Location >= 0)
136 { 138 {
137 string itemKey = $"ArchipelagoLocation-{item.Location}"; 139 string itemKey = $"ArchipelagoLocation-{item.Location}";
138 if (GlobalState.events.GetEvent(itemKey) > 0) 140 if (GlobalState.events.GetEvent(itemKey) > 0)
@@ -213,6 +215,14 @@ namespace AnodyneArchipelago
213 cardTreasure.GetTreasure(); 215 cardTreasure.GetTreasure();
214 GlobalState.SpawnEntity(cardTreasure); 216 GlobalState.SpawnEntity(cardTreasure);
215 } 217 }
218 else if (itemName == "Cardboard Box")
219 {
220 GlobalState.events.SetEvent("ReceivedCardboardBox", 1);
221 }
222 else if (itemName == "Biking Shoes")
223 {
224 GlobalState.events.SetEvent("ReceivedBikingShoes", 1);
225 }
216 226
217 string message; 227 string message;
218 if (item.Player == _session.ConnectionInfo.Slot) 228 if (item.Player == _session.ConnectionInfo.Slot)
diff --git a/AnodyneArchipelago/Patches/GameplayPatches.cs b/AnodyneArchipelago/Patches/GameplayPatches.cs index 9db87a5..ba33457 100644 --- a/AnodyneArchipelago/Patches/GameplayPatches.cs +++ b/AnodyneArchipelago/Patches/GameplayPatches.cs
@@ -10,6 +10,11 @@ using System;
10using System.Collections.Generic; 10using System.Collections.Generic;
11using System.Reflection; 11using System.Reflection;
12using Microsoft.Xna.Framework; 12using Microsoft.Xna.Framework;
13using AnodyneSharp.Entities.Interactive.Npc.RunningTradeNPCs;
14using AnodyneSharp.Dialogue;
15using AnodyneSharp.Sounds;
16using AnodyneSharp.States;
17using AnodyneSharp.Entities.Interactive.Npc;
13 18
14namespace AnodyneArchipelago.Patches 19namespace AnodyneArchipelago.Patches
15{ 20{
@@ -225,4 +230,95 @@ namespace AnodyneArchipelago.Patches
225 } 230 }
226 } 231 }
227 } 232 }
233
234 [HarmonyPatch(typeof(Box), nameof(Box.PlayerInteraction))]
235 class BoxOpenPatch
236 {
237 static bool Prefix(Box __instance, ref bool __result)
238 {
239 if (!GlobalState.events.SpookedMonster)
240 {
241 __result = false;
242 return false;
243 }
244
245 __instance.Play("open");
246 SoundManager.PlaySoundEffect("broom_hit");
247 GlobalState.StartCutscene = OnOpened(__instance);
248 __result = true;
249 return false;
250 }
251
252 static IEnumerator<CutsceneState.CutsceneEvent> OnOpened(Box box)
253 {
254 MethodInfo openedMethod = typeof(Box).GetMethod("OnOpened", BindingFlags.NonPublic | BindingFlags.Instance);
255 IEnumerator<CutsceneState.CutsceneEvent> subCutscene = (IEnumerator<CutsceneState.CutsceneEvent>)openedMethod.Invoke(box, new object[] { });
256
257 yield return subCutscene.Current;
258 while (subCutscene.MoveNext())
259 {
260 yield return subCutscene.Current;
261 }
262
263 GlobalState.inventory.tradeState = InventoryManager.TradeState.NONE;
264
265 Plugin.ArchipelagoManager.SendLocation("Fields - Cardboard Box");
266 }
267 }
268
269 [HarmonyPatch(typeof(ShopKeep), nameof(ShopKeep.PlayerInteraction))]
270 class ShopKeepTalkPatch
271 {
272 static bool Prefix(ShopKeep __instance)
273 {
274 if (GlobalState.events.GetEvent("ReceivedCardboardBox") == 1 && GlobalState.events.GetEvent("UsedCardboardBox") == 0)
275 {
276 GlobalState.Dialogue = GetDiag(2) + " " + GetDiag(4);
277 GlobalState.events.SetEvent("UsedCardboardBox", 1);
278
279 EntityPreset preset = PatchHelper.GetEntityPreset(typeof(ShopKeep), __instance);
280 preset.Activated = true;
281
282 Plugin.ArchipelagoManager.SendLocation("Fields - Shopkeeper Trade");
283
284 return false;
285 }
286
287 return true;
288 }
289
290 static string GetDiag(int i) => DialogueManager.GetDialogue("misc", "any", "tradenpc", i);
291 }
292
293 [HarmonyPatch(typeof(MitraFields), "GetInteractionText")]
294 class MitraFieldsTextPatch
295 {
296 static bool Prefix(ref string __result)
297 {
298 if (GlobalState.events.GetEvent("ReceivedBikingShoes") == 1 && GlobalState.events.GetEvent("UsedBikingShoes") == 0)
299 {
300 __result = DialogueManager.GetDialogue("misc", "any", "mitra", 1);
301
302 GlobalState.events.SetEvent("UsedBikingShoes", 1);
303
304 Plugin.ArchipelagoManager.SendLocation("Fields - Mitra Trade");
305
306 return false;
307 }
308
309 return true;
310 }
311 }
312
313 [HarmonyPatch("AnodyneSharp.Entities.Interactive.Npc.Windmill.Console", "PlayerInteraction")]
314 class WindmillInteractPatch
315 {
316 static void Prefix(object __instance)
317 {
318 if ((__instance as Entity).CurAnimName == "active")
319 {
320 Plugin.ArchipelagoManager.SendLocation("Windmill - Activation");
321 }
322 }
323 }
228} 324}