From e58b122fb00a337748df2de2451679f53b092d42 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 22 Feb 2025 10:43:41 -0500 Subject: Mapped out most of the game --- ArchipelagoManager.cs | 68 ++++++++++++++++++--------------------------------- 1 file changed, 24 insertions(+), 44 deletions(-) (limited to 'ArchipelagoManager.cs') diff --git a/ArchipelagoManager.cs b/ArchipelagoManager.cs index 7affa64..611ef30 100644 --- a/ArchipelagoManager.cs +++ b/ArchipelagoManager.cs @@ -4,12 +4,7 @@ using Archipelago.MultiClient.Net.Models; using Archipelago.MultiClient.Net.Packets; using System; using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; using System.Threading.Tasks; -using UnityEngine.SceneManagement; -using static ManifoldGardenArchipelago.GameData; namespace ManifoldGardenArchipelago { @@ -18,24 +13,8 @@ namespace ManifoldGardenArchipelago private ArchipelagoSession _session; private int _itemIndex = 0; - public Dictionary> chainListenersByScene = new(); - - public ArchipelagoManager() - { - foreach (var item in GameData.door_by_item) - { - foreach (var chainListenerReference in item.Value) - { - if (!chainListenersByScene.TryGetValue(chainListenerReference.scene, out var listenersInScene)) - { - listenersInScene = []; - chainListenersByScene.Add(chainListenerReference.scene, listenersInScene); - } - - listenersInScene[chainListenerReference.index] = false; - } - } - } + private HashSet _items = []; + private HashSet _locations = []; public async Task Connect(string url, string slotName, string password) { @@ -72,6 +51,23 @@ namespace ManifoldGardenArchipelago _session = null; } + public bool HasItem(string itemName) + { + return _items.Contains(itemName); + } + + public void CheckLocation(string locationName) + { + if (_locations.Contains(locationName)) + { + return; + } + + _locations.Add(locationName); + + _session.Locations.CompleteLocationChecks(_session.Locations.GetLocationIdFromName("Manifold Garden", locationName)); + } + public void Update() { if (_session == null) @@ -85,29 +81,13 @@ namespace ManifoldGardenArchipelago { ItemInfo item = _session.Items.AllItemsReceived[i]; string itemName = item.ItemName; + Plugin.Logger.LogInfo($"Received {itemName}"); + + _items.Add(itemName); - if (GameData.door_by_item.TryGetValue(itemName, out List door)) + if (GameData.listenersByItem.TryGetValue(itemName, out var listeners)) { - foreach (GameData.ChainListenerReference chainListenerReference in door) - { - chainListenersByScene[chainListenerReference.scene][chainListenerReference.index] = true; - - if (SceneManager.GetSceneByName(chainListenerReference.scene) is Scene doorScene && doorScene.isLoaded) - { - LevelSystems levelSystems = doorScene.GetRootGameObjects().Single((obj) => obj.name == "Level Systems").GetComponent(); - if (levelSystems.isActiveAndEnabled) - { - LineDoorController ldc = levelSystems.chainListeners[chainListenerReference.index].GetComponent(); - ldc.chains.Clear(); - - FieldInfo fieldInfo = typeof(LineDoorController).GetField("doorShouldOpenImmediatelyOnEnable", BindingFlags.Instance | BindingFlags.NonPublic); - fieldInfo.SetValue(ldc, true); - - MethodInfo methodInfo = typeof(LineDoorController).GetMethod("SetDoorOpenCloseStateAnimated", BindingFlags.NonPublic | BindingFlags.Instance); - methodInfo.Invoke(ldc, [true, false]); - } - } - } + GameState.EvaluateGameStateListeners(listeners); } } -- cgit 1.4.1