Generate conditionals handler

This commit is contained in:
Joshua Thome 2025-02-16 16:51:13 -06:00
parent 25f36dcbb7
commit 3270580422
2 changed files with 16 additions and 7 deletions

View File

@ -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)
{

View File

@ -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<ConditionalsManager>();
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;