From 162237d3adaad50ac91c2d5faba9294ac3fdb399 Mon Sep 17 00:00:00 2001 From: xen-42 Date: Fri, 25 Oct 2024 22:32:43 -0400 Subject: [PATCH] Add them --- .../Builder/Props/ProjectionBuilder.cs | 16 ++++++--- .../EOTE/NHSlideCollectionContainer.cs | 34 +++++++++++++++++++ .../Props/EchoesOfTheEye/ProjectionInfo.cs | 10 ++++++ 3 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 NewHorizons/Components/EOTE/NHSlideCollectionContainer.cs diff --git a/NewHorizons/Builder/Props/ProjectionBuilder.cs b/NewHorizons/Builder/Props/ProjectionBuilder.cs index 8d9eaca6..642c3236 100644 --- a/NewHorizons/Builder/Props/ProjectionBuilder.cs +++ b/NewHorizons/Builder/Props/ProjectionBuilder.cs @@ -1,4 +1,5 @@ using HarmonyLib; +using NewHorizons.Components.EOTE; using NewHorizons.External.Modules.Props; using NewHorizons.External.Modules.Props.EchoesOfTheEye; using NewHorizons.Handlers; @@ -137,7 +138,8 @@ namespace NewHorizons.Builder.Props slideReel.SetSector(sector); slideReel.SetVisible(true); - var slideCollectionContainer = slideReelObj.GetRequiredComponent(); + Component.DestroyImmediate(slideReelObj.GetComponent()); + var slideCollectionContainer = slideReelObj.AddComponent(); foreach (var renderer in slideReelObj.GetComponentsInChildren()) { @@ -342,7 +344,8 @@ namespace NewHorizons.Builder.Props var autoProjector = projectorObj.GetComponent(); autoProjector._sector = sector; - var slideCollectionContainer = autoProjector.GetRequiredComponent(); + Component.DestroyImmediate(autoProjector.GetComponent()); + var slideCollectionContainer = autoProjector.gameObject.AddComponent(); // Now we replace the slides int slidesCount = info.slides.Length; @@ -419,7 +422,7 @@ namespace NewHorizons.Builder.Props // attach a component to store all the data for the slides that play when a vision torch scans this target var target = g.AddComponent(); - var slideCollectionContainer = g.AddComponent(); + var slideCollectionContainer = g.AddComponent(); slideCollectionContainer.slideCollection = slideCollection; target.slideCollection = g.AddComponent(); target.slideCollection._slideCollectionContainer = slideCollectionContainer; @@ -486,7 +489,7 @@ namespace NewHorizons.Builder.Props ); // Set up the containers for the slides - var slideCollectionContainer = standingTorch.AddComponent(); + var slideCollectionContainer = standingTorch.AddComponent(); slideCollectionContainer.slideCollection = slideCollection; var mindSlideCollection = standingTorch.AddComponent(); @@ -658,12 +661,15 @@ namespace NewHorizons.Builder.Props Slide.WriteModules(modules, ref slide._modulesList, ref slide._modulesData, ref slide.lengths); } - private static void LinkShipLogFacts(ProjectionInfo info, SlideCollectionContainer slideCollectionContainer) + private static void LinkShipLogFacts(ProjectionInfo info, NHSlideCollectionContainer slideCollectionContainer) { // Idk why but it wants reveals to be comma delimited not a list if (info.reveals != null) slideCollectionContainer._shipLogOnComplete = string.Join(",", info.reveals); // Don't use null value, NRE in SlideCollectionContainer.Initialize slideCollectionContainer._playWithShipLogFacts = info.playWithShipLogFacts ?? Array.Empty(); + + slideCollectionContainer.conditionsToSet = info.conditionsToSet; + slideCollectionContainer.persistentConditionsToSet = info.persistentConditionsToSet; } } diff --git a/NewHorizons/Components/EOTE/NHSlideCollectionContainer.cs b/NewHorizons/Components/EOTE/NHSlideCollectionContainer.cs new file mode 100644 index 00000000..d6a5bb7c --- /dev/null +++ b/NewHorizons/Components/EOTE/NHSlideCollectionContainer.cs @@ -0,0 +1,34 @@ +using HarmonyLib; + +namespace NewHorizons.Components.EOTE; + +[HarmonyPatch(typeof(SlideCollectionContainer))] +public class NHSlideCollectionContainer : SlideCollectionContainer +{ + public string[] conditionsToSet; + public string[] persistentConditionsToSet; + + public static void SlideCollectionContainer_SetReadFlag(SlideCollectionContainer __instance) + { + if (__instance is NHSlideCollectionContainer container) + { + if (container._unreadSlideIndices.Count == 0) + { + if (container.conditionsToSet != null) + { + foreach (var condition in container.conditionsToSet) + { + DialogueConditionManager.SharedInstance.SetConditionState(condition, true); + } + } + if (container.persistentConditionsToSet != null) + { + foreach (var condition in container.persistentConditionsToSet) + { + PlayerData.SetPersistentCondition(condition, true); + } + } + } + } + } +} diff --git a/NewHorizons/External/Modules/Props/EchoesOfTheEye/ProjectionInfo.cs b/NewHorizons/External/Modules/Props/EchoesOfTheEye/ProjectionInfo.cs index ba6a98d4..c61ef06b 100644 --- a/NewHorizons/External/Modules/Props/EchoesOfTheEye/ProjectionInfo.cs +++ b/NewHorizons/External/Modules/Props/EchoesOfTheEye/ProjectionInfo.cs @@ -48,6 +48,16 @@ namespace NewHorizons.External.Modules.Props.EchoesOfTheEye /// public string[] reveals; + /// + /// The dialogue conditions to set after finishing this slide reel. + /// + public string[] conditionsToSet; + + /// + /// The persistent conditions to set after finishing this slide reel. + /// + public string[] persistentConditionsToSet; + /// /// The ship log facts that make the reel play when they are displayed in the computer (by selecting entries or arrows). /// You should probably include facts from `reveals` here.