diff options
Diffstat (limited to 'GameState.cs')
-rw-r--r-- | GameState.cs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/GameState.cs b/GameState.cs index bdf5760..9280eb3 100644 --- a/GameState.cs +++ b/GameState.cs | |||
@@ -33,6 +33,21 @@ namespace ManifoldGardenArchipelago | |||
33 | throw new Exception("Shouldn't happen"); | 33 | throw new Exception("Shouldn't happen"); |
34 | } | 34 | } |
35 | 35 | ||
36 | public static SceneItemReference GetGameplayComponentSceneReference(Component component) | ||
37 | { | ||
38 | LevelSystems levelSystem = GetLevelSystems(component); | ||
39 | |||
40 | for (int i = 0; i < levelSystem.gameplayComponentsInLevel.Count(); i++) | ||
41 | { | ||
42 | if (levelSystem.gameplayComponentsInLevel[i] == component) | ||
43 | { | ||
44 | return new(component.gameObject.scene.name, i); | ||
45 | } | ||
46 | } | ||
47 | |||
48 | throw new Exception("Shouldn't happen"); | ||
49 | } | ||
50 | |||
36 | public static SceneItemReference GetButtonSceneReference(ButtonLineActivator arg) | 51 | public static SceneItemReference GetButtonSceneReference(ButtonLineActivator arg) |
37 | { | 52 | { |
38 | LevelSystems levelSystem = GetLevelSystems(arg); | 53 | LevelSystems levelSystem = GetLevelSystems(arg); |
@@ -191,6 +206,37 @@ namespace ManifoldGardenArchipelago | |||
191 | } | 206 | } |
192 | } | 207 | } |
193 | } | 208 | } |
209 | |||
210 | foreach (var laser in listeners.lasers) | ||
211 | { | ||
212 | Requirement.Decision decision = laser.Value.Check(); | ||
213 | if (decision == Requirement.Decision.Maybe) | ||
214 | { | ||
215 | continue; | ||
216 | } | ||
217 | |||
218 | bool shouldOpen = (decision == Requirement.Decision.Yes); | ||
219 | |||
220 | if (SceneManager.GetSceneByName(laser.Key.scene) is Scene laserScene && laserScene.isLoaded) | ||
221 | { | ||
222 | LevelSystems levelSystems = GetLevelSystems(laserScene); | ||
223 | if (levelSystems.isActiveAndEnabled) | ||
224 | { | ||
225 | DarkModeCageController ldc = levelSystems.gameplayComponentsInLevel[laser.Key.index].GetComponent<DarkModeCageController>(); | ||
226 | |||
227 | if (shouldOpen) | ||
228 | { | ||
229 | MethodInfo methodInfo = typeof(DarkModeCageController).GetMethod("OpenLaserSource", BindingFlags.Instance | BindingFlags.NonPublic); | ||
230 | methodInfo.Invoke(ldc, [false]); | ||
231 | } | ||
232 | else | ||
233 | { | ||
234 | MethodInfo methodInfo = typeof(DarkModeCageController).GetMethod("CloseLaserSource", BindingFlags.Instance | BindingFlags.NonPublic); | ||
235 | methodInfo.Invoke(ldc, [false]); | ||
236 | } | ||
237 | } | ||
238 | } | ||
239 | } | ||
194 | } | 240 | } |
195 | } | 241 | } |
196 | } | 242 | } |