summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2025-02-24 15:26:02 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2025-02-24 15:26:02 -0500
commit24b4fb4f8fa0392c8a44aefa734ff6d558f3583d (patch)
treebf05c1eddf096301b3ca412c00e8bc05daff879a
parente40dbee06a652d0b25adfa89896b18c61004373f (diff)
downloadmanifold-garden-archipelago-24b4fb4f8fa0392c8a44aefa734ff6d558f3583d.tar.gz
manifold-garden-archipelago-24b4fb4f8fa0392c8a44aefa734ff6d558f3583d.tar.bz2
manifold-garden-archipelago-24b4fb4f8fa0392c8a44aefa734ff6d558f3583d.zip
Minor fixes/safety stuff
-rw-r--r--GameState.cs28
-rw-r--r--Plugin.cs9
-rw-r--r--Requirements.cs10
3 files changed, 30 insertions, 17 deletions
diff --git a/GameState.cs b/GameState.cs index 9280eb3..1f63018 100644 --- a/GameState.cs +++ b/GameState.cs
@@ -10,12 +10,21 @@ namespace ManifoldGardenArchipelago
10 { 10 {
11 public static LevelSystems GetLevelSystems(Component component) 11 public static LevelSystems GetLevelSystems(Component component)
12 { 12 {
13 return component.gameObject.scene.GetRootGameObjects().Single((obj) => obj.name == "Level Systems").GetComponent<LevelSystems>(); 13 return GetLevelSystems(component.gameObject.scene);
14 } 14 }
15 15
16 public static LevelSystems GetLevelSystems(Scene scene) 16 public static LevelSystems GetLevelSystems(Scene scene)
17 { 17 {
18 return scene.GetRootGameObjects().Single((obj) => obj.name == "Level Systems").GetComponent<LevelSystems>(); 18 foreach (GameObject gameObject in scene.GetRootGameObjects())
19 {
20 if (gameObject.name == "Level Systems")
21 {
22 return gameObject.GetComponent<LevelSystems>();
23 }
24 }
25
26 Plugin.Logger.LogWarning($"Could not find Level Systems for {scene.name}");
27 return null;
19 } 28 }
20 29
21 public static SceneItemReference GetChainListenerSceneReference(Component component) 30 public static SceneItemReference GetChainListenerSceneReference(Component component)
@@ -30,6 +39,7 @@ namespace ManifoldGardenArchipelago
30 } 39 }
31 } 40 }
32 41
42 Plugin.Logger.LogWarning($"Could not find SIR for chain listener {component.name}");
33 throw new Exception("Shouldn't happen"); 43 throw new Exception("Shouldn't happen");
34 } 44 }
35 45
@@ -45,6 +55,7 @@ namespace ManifoldGardenArchipelago
45 } 55 }
46 } 56 }
47 57
58 Plugin.Logger.LogWarning($"Could not find SIR for gameplay component {component.name}");
48 throw new Exception("Shouldn't happen"); 59 throw new Exception("Shouldn't happen");
49 } 60 }
50 61
@@ -60,6 +71,7 @@ namespace ManifoldGardenArchipelago
60 } 71 }
61 } 72 }
62 73
74 Plugin.Logger.LogWarning($"Could not find SIR for button {arg.name}");
63 throw new Exception("Shouldn't happen"); 75 throw new Exception("Shouldn't happen");
64 } 76 }
65 77
@@ -75,6 +87,7 @@ namespace ManifoldGardenArchipelago
75 } 87 }
76 } 88 }
77 89
90 Plugin.Logger.LogWarning($"Could not find SIR for pad {arg.name}");
78 throw new Exception("Shouldn't happen"); 91 throw new Exception("Shouldn't happen");
79 } 92 }
80 93
@@ -90,6 +103,7 @@ namespace ManifoldGardenArchipelago
90 } 103 }
91 } 104 }
92 105
106 Plugin.Logger.LogWarning($"Could not find SIR for socket {arg.name}");
93 throw new Exception("Shouldn't happen"); 107 throw new Exception("Shouldn't happen");
94 } 108 }
95 109
@@ -105,6 +119,7 @@ namespace ManifoldGardenArchipelago
105 } 119 }
106 } 120 }
107 121
122 Plugin.Logger.LogWarning($"Could not find SIR for sphere {arg.name}");
108 throw new Exception("Shouldn't happen"); 123 throw new Exception("Shouldn't happen");
109 } 124 }
110 125
@@ -120,6 +135,7 @@ namespace ManifoldGardenArchipelago
120 } 135 }
121 } 136 }
122 137
138 Plugin.Logger.LogWarning($"Could not find SIR for waterwheel {arg.name}");
123 throw new Exception("Shouldn't happen"); 139 throw new Exception("Shouldn't happen");
124 } 140 }
125 141
@@ -144,7 +160,7 @@ namespace ManifoldGardenArchipelago
144 bool shouldOpen = (decision == Requirement.Decision.Yes); 160 bool shouldOpen = (decision == Requirement.Decision.Yes);
145 //Plugin.Logger.LogInfo($"{door.Key}: {door.Value} -> {shouldOpen}"); 161 //Plugin.Logger.LogInfo($"{door.Key}: {door.Value} -> {shouldOpen}");
146 162
147 if (SceneManager.GetSceneByName(door.Key.scene) is Scene doorScene && doorScene.isLoaded) 163 if (SceneManager.GetSceneByName(door.Key.scene) is Scene doorScene && doorScene.IsValid() && doorScene.isLoaded)
148 { 164 {
149 LevelSystems levelSystems = GetLevelSystems(doorScene); 165 LevelSystems levelSystems = GetLevelSystems(doorScene);
150 if (levelSystems.isActiveAndEnabled) 166 if (levelSystems.isActiveAndEnabled)
@@ -174,7 +190,7 @@ namespace ManifoldGardenArchipelago
174 bool shouldOpen = (decision == Requirement.Decision.Yes); 190 bool shouldOpen = (decision == Requirement.Decision.Yes);
175 //Plugin.Logger.LogInfo($"{smokeWall.Key}: {smokeWall.Value} -> {shouldOpen}"); 191 //Plugin.Logger.LogInfo($"{smokeWall.Key}: {smokeWall.Value} -> {shouldOpen}");
176 192
177 if (SceneManager.GetSceneByName(smokeWall.Key.scene) is Scene smokeScene && smokeScene.isLoaded) 193 if (SceneManager.GetSceneByName(smokeWall.Key.scene) is Scene smokeScene && smokeScene.IsValid() && smokeScene.isLoaded)
178 { 194 {
179 LevelSystems levelSystems = GetLevelSystems(smokeScene); 195 LevelSystems levelSystems = GetLevelSystems(smokeScene);
180 if (levelSystems.isActiveAndEnabled) 196 if (levelSystems.isActiveAndEnabled)
@@ -192,7 +208,7 @@ namespace ManifoldGardenArchipelago
192 { 208 {
193 if (worldGrow.Value.Check() == Requirement.Decision.Yes) 209 if (worldGrow.Value.Check() == Requirement.Decision.Yes)
194 { 210 {
195 if (SceneManager.GetSceneByName(worldGrow.Key.scene) is Scene gardenScene && gardenScene.isLoaded) 211 if (SceneManager.GetSceneByName(worldGrow.Key.scene) is Scene gardenScene && gardenScene.IsValid() && gardenScene.isLoaded)
196 { 212 {
197 LevelSystems levelSystems = GetLevelSystems(gardenScene); 213 LevelSystems levelSystems = GetLevelSystems(gardenScene);
198 if (levelSystems.isActiveAndEnabled) 214 if (levelSystems.isActiveAndEnabled)
@@ -217,7 +233,7 @@ namespace ManifoldGardenArchipelago
217 233
218 bool shouldOpen = (decision == Requirement.Decision.Yes); 234 bool shouldOpen = (decision == Requirement.Decision.Yes);
219 235
220 if (SceneManager.GetSceneByName(laser.Key.scene) is Scene laserScene && laserScene.isLoaded) 236 if (SceneManager.GetSceneByName(laser.Key.scene) is Scene laserScene && laserScene.IsValid() && laserScene.isLoaded)
221 { 237 {
222 LevelSystems levelSystems = GetLevelSystems(laserScene); 238 LevelSystems levelSystems = GetLevelSystems(laserScene);
223 if (levelSystems.isActiveAndEnabled) 239 if (levelSystems.isActiveAndEnabled)
diff --git a/Plugin.cs b/Plugin.cs index a9fb284..a770542 100644 --- a/Plugin.cs +++ b/Plugin.cs
@@ -48,13 +48,4 @@ namespace ManifoldGardenArchipelago
48 } 48 }
49 } 49 }
50 50
51 [HarmonyPatch(typeof(ButtonLineActivator), nameof(ButtonLineActivator.OnInteract))]
52 static class ButtonLineActivatorOnInteractPatch
53 {
54 public static void Postfix(ButtonLineActivator __instance)
55 {
56 Plugin.Logger.LogInfo($"Interacted with {__instance.name} in {__instance.gameObject.scene.name}: {__instance.isButtonPressed}");
57 }
58 }
59
60} 51}
diff --git a/Requirements.cs b/Requirements.cs index 1613a47..954d1fe 100644 --- a/Requirements.cs +++ b/Requirements.cs
@@ -113,17 +113,23 @@ namespace ManifoldGardenArchipelago
113 113
114 public override Decision Check() 114 public override Decision Check()
115 { 115 {
116 bool sawMaybe = false;
117
116 foreach (var requirement in _requirements) 118 foreach (var requirement in _requirements)
117 { 119 {
118 Decision decision = requirement.Check(); 120 Decision decision = requirement.Check();
119 121
120 if (decision != Decision.No) 122 if (decision == Decision.Yes)
121 { 123 {
122 return decision; 124 return decision;
123 } 125 }
126 else if (decision == Decision.Maybe)
127 {
128 sawMaybe = true;
129 }
124 } 130 }
125 131
126 return Decision.No; 132 return sawMaybe ? Decision.Maybe : Decision.No;
127 } 133 }
128 134
129 public override string ToString() 135 public override string ToString()