diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2025-02-22 10:43:41 -0500 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2025-02-22 10:43:41 -0500 |
| commit | e58b122fb00a337748df2de2451679f53b092d42 (patch) | |
| tree | 3b71d6554f10cdd5cb68ceeca4d6296abf5c434f /ArchipelagoManager.cs | |
| parent | d1baf62bea385c75ad4e7612e5caa285400ffaa7 (diff) | |
| download | manifold-garden-archipelago-e58b122fb00a337748df2de2451679f53b092d42.tar.gz manifold-garden-archipelago-e58b122fb00a337748df2de2451679f53b092d42.tar.bz2 manifold-garden-archipelago-e58b122fb00a337748df2de2451679f53b092d42.zip | |
Mapped out most of the game
Diffstat (limited to 'ArchipelagoManager.cs')
| -rw-r--r-- | ArchipelagoManager.cs | 68 |
1 files changed, 24 insertions, 44 deletions
| 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; | |||
| 4 | using Archipelago.MultiClient.Net.Packets; | 4 | using Archipelago.MultiClient.Net.Packets; |
| 5 | using System; | 5 | using System; |
| 6 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
| 7 | using System.Linq; | ||
| 8 | using System.Reflection; | ||
| 9 | using System.Text; | ||
| 10 | using System.Threading.Tasks; | 7 | using System.Threading.Tasks; |
| 11 | using UnityEngine.SceneManagement; | ||
| 12 | using static ManifoldGardenArchipelago.GameData; | ||
| 13 | 8 | ||
| 14 | namespace ManifoldGardenArchipelago | 9 | namespace ManifoldGardenArchipelago |
| 15 | { | 10 | { |
| @@ -18,24 +13,8 @@ namespace ManifoldGardenArchipelago | |||
| 18 | private ArchipelagoSession _session; | 13 | private ArchipelagoSession _session; |
| 19 | private int _itemIndex = 0; | 14 | private int _itemIndex = 0; |
| 20 | 15 | ||
| 21 | public Dictionary<string, Dictionary<int, bool>> chainListenersByScene = new(); | 16 | private HashSet<string> _items = []; |
| 22 | 17 | private HashSet<string> _locations = []; | |
| 23 | public ArchipelagoManager() | ||
| 24 | { | ||
| 25 | foreach (var item in GameData.door_by_item) | ||
| 26 | { | ||
| 27 | foreach (var chainListenerReference in item.Value) | ||
| 28 | { | ||
| 29 | if (!chainListenersByScene.TryGetValue(chainListenerReference.scene, out var listenersInScene)) | ||
| 30 | { | ||
| 31 | listenersInScene = []; | ||
| 32 | chainListenersByScene.Add(chainListenerReference.scene, listenersInScene); | ||
| 33 | } | ||
| 34 | |||
| 35 | listenersInScene[chainListenerReference.index] = false; | ||
| 36 | } | ||
| 37 | } | ||
| 38 | } | ||
| 39 | 18 | ||
| 40 | public async Task<LoginResult> Connect(string url, string slotName, string password) | 19 | public async Task<LoginResult> Connect(string url, string slotName, string password) |
| 41 | { | 20 | { |
| @@ -72,6 +51,23 @@ namespace ManifoldGardenArchipelago | |||
| 72 | _session = null; | 51 | _session = null; |
| 73 | } | 52 | } |
| 74 | 53 | ||
| 54 | public bool HasItem(string itemName) | ||
| 55 | { | ||
| 56 | return _items.Contains(itemName); | ||
| 57 | } | ||
| 58 | |||
| 59 | public void CheckLocation(string locationName) | ||
| 60 | { | ||
| 61 | if (_locations.Contains(locationName)) | ||
| 62 | { | ||
| 63 | return; | ||
| 64 | } | ||
| 65 | |||
| 66 | _locations.Add(locationName); | ||
| 67 | |||
| 68 | _session.Locations.CompleteLocationChecks(_session.Locations.GetLocationIdFromName("Manifold Garden", locationName)); | ||
| 69 | } | ||
| 70 | |||
| 75 | public void Update() | 71 | public void Update() |
| 76 | { | 72 | { |
| 77 | if (_session == null) | 73 | if (_session == null) |
| @@ -85,29 +81,13 @@ namespace ManifoldGardenArchipelago | |||
| 85 | { | 81 | { |
| 86 | ItemInfo item = _session.Items.AllItemsReceived[i]; | 82 | ItemInfo item = _session.Items.AllItemsReceived[i]; |
| 87 | string itemName = item.ItemName; | 83 | string itemName = item.ItemName; |
| 84 | Plugin.Logger.LogInfo($"Received {itemName}"); | ||
| 85 | |||
| 86 | _items.Add(itemName); | ||
| 88 | 87 | ||
| 89 | if (GameData.door_by_item.TryGetValue(itemName, out List<GameData.ChainListenerReference> door)) | 88 | if (GameData.listenersByItem.TryGetValue(itemName, out var listeners)) |
| 90 | { | 89 | { |
| 91 | foreach (GameData.ChainListenerReference chainListenerReference in door) | 90 | GameState.EvaluateGameStateListeners(listeners); |
| 92 | { | ||
| 93 | chainListenersByScene[chainListenerReference.scene][chainListenerReference.index] = true; | ||
| 94 | |||
| 95 | if (SceneManager.GetSceneByName(chainListenerReference.scene) is Scene doorScene && doorScene.isLoaded) | ||
| 96 | { | ||
| 97 | LevelSystems levelSystems = doorScene.GetRootGameObjects().Single((obj) => obj.name == "Level Systems").GetComponent<LevelSystems>(); | ||
| 98 | if (levelSystems.isActiveAndEnabled) | ||
| 99 | { | ||
| 100 | LineDoorController ldc = levelSystems.chainListeners[chainListenerReference.index].GetComponent<LineDoorController>(); | ||
| 101 | ldc.chains.Clear(); | ||
| 102 | |||
| 103 | FieldInfo fieldInfo = typeof(LineDoorController).GetField("doorShouldOpenImmediatelyOnEnable", BindingFlags.Instance | BindingFlags.NonPublic); | ||
| 104 | fieldInfo.SetValue(ldc, true); | ||
| 105 | |||
| 106 | MethodInfo methodInfo = typeof(LineDoorController).GetMethod("SetDoorOpenCloseStateAnimated", BindingFlags.NonPublic | BindingFlags.Instance); | ||
| 107 | methodInfo.Invoke(ldc, [true, false]); | ||
| 108 | } | ||
| 109 | } | ||
| 110 | } | ||
| 111 | } | 91 | } |
| 112 | } | 92 | } |
| 113 | 93 | ||
