diff options
Diffstat (limited to 'GameState.cs')
-rw-r--r-- | GameState.cs | 28 |
1 files changed, 22 insertions, 6 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) |