From 327058042283df3880c058ac638989188d645cfe Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Sun, 16 Feb 2025 16:51:13 -0600 Subject: [PATCH] Generate conditionals handler --- NewHorizons/Handlers/ConditionalsHandler.cs | 12 ++++++------ NewHorizons/Handlers/SystemCreationHandler.cs | 11 ++++++++++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/NewHorizons/Handlers/ConditionalsHandler.cs b/NewHorizons/Handlers/ConditionalsHandler.cs index a53263d4..90392fa8 100644 --- a/NewHorizons/Handlers/ConditionalsHandler.cs +++ b/NewHorizons/Handlers/ConditionalsHandler.cs @@ -16,27 +16,27 @@ namespace NewHorizons.Handlers var passed = true; if (check.allConditionsSet != null && check.allConditionsSet.Length > 0) { - passed = passed && check.allConditionsSet.All(c => dcm.GetConditionState(c)); + passed = passed && check.allConditionsSet.All(dcm.GetConditionState); } if (check.anyConditionsSet != null && check.anyConditionsSet.Length > 0) { - passed = passed && check.anyConditionsSet.Any(c => dcm.GetConditionState(c)); + passed = passed && check.anyConditionsSet.Any(dcm.GetConditionState); } if (check.allPersistentConditionsSet != null && check.allPersistentConditionsSet.Length > 0) { - passed = passed && check.allPersistentConditionsSet.All(c => PlayerData.GetPersistentCondition(c)); + passed = passed && check.allPersistentConditionsSet.All(PlayerData.GetPersistentCondition); } if (check.anyPersistentConditionsSet != null && check.anyPersistentConditionsSet.Length > 0) { - passed = passed && check.anyPersistentConditionsSet.Any(c => PlayerData.GetPersistentCondition(c)); + passed = passed && check.anyPersistentConditionsSet.Any(PlayerData.GetPersistentCondition); } if (check.allFactsRevealed != null && check.allFactsRevealed.Length > 0) { - passed = passed && check.allFactsRevealed.All(f => ShipLogHandler.KnowsFact(f)); + passed = passed && check.allFactsRevealed.All(ShipLogHandler.KnowsFact); } if (check.anyFactsRevealed != null && check.anyFactsRevealed.Length > 0) { - passed = passed && check.anyFactsRevealed.Any(f => ShipLogHandler.KnowsFact(f)); + passed = passed && check.anyFactsRevealed.Any(ShipLogHandler.KnowsFact); } if (check.invert) { diff --git a/NewHorizons/Handlers/SystemCreationHandler.cs b/NewHorizons/Handlers/SystemCreationHandler.cs index db2951a3..8d8a4fdd 100644 --- a/NewHorizons/Handlers/SystemCreationHandler.cs +++ b/NewHorizons/Handlers/SystemCreationHandler.cs @@ -9,7 +9,7 @@ using UnityEngine; using Object = UnityEngine.Object; using NewHorizons.OtherMods; using NewHorizons.Components.EOTE; -using Epic.OnlineServices.Presence; +using NewHorizons.Components.Conditionals; namespace NewHorizons.Handlers { @@ -32,6 +32,15 @@ namespace NewHorizons.Handlers SkyboxBuilder.Make(system.Config.Skybox, system.Mod); } + if (system.Config.conditionalChecks != null) + { + var conditionalsManager = new GameObject("ConditionalsManager").AddComponent(); + foreach (var check in system.Config.conditionalChecks) + { + conditionalsManager.AddCheck(check); + } + } + // No time loop or travel audio at the eye if (Main.Instance.CurrentStarSystem == "EyeOfTheUniverse") return;