This commit is contained in:
xen-42 2024-10-25 22:32:43 -04:00
parent 0622d2aa87
commit 162237d3ad
3 changed files with 55 additions and 5 deletions

View File

@ -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<SlideCollectionContainer>();
Component.DestroyImmediate(slideReelObj.GetComponent<SlideCollectionContainer>());
var slideCollectionContainer = slideReelObj.AddComponent<NHSlideCollectionContainer>();
foreach (var renderer in slideReelObj.GetComponentsInChildren<Renderer>())
{
@ -342,7 +344,8 @@ namespace NewHorizons.Builder.Props
var autoProjector = projectorObj.GetComponent<AutoSlideProjector>();
autoProjector._sector = sector;
var slideCollectionContainer = autoProjector.GetRequiredComponent<SlideCollectionContainer>();
Component.DestroyImmediate(autoProjector.GetComponent<SlideCollectionContainer>());
var slideCollectionContainer = autoProjector.gameObject.AddComponent<NHSlideCollectionContainer>();
// 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<VisionTorchTarget>();
var slideCollectionContainer = g.AddComponent<SlideCollectionContainer>();
var slideCollectionContainer = g.AddComponent<NHSlideCollectionContainer>();
slideCollectionContainer.slideCollection = slideCollection;
target.slideCollection = g.AddComponent<MindSlideCollection>();
target.slideCollection._slideCollectionContainer = slideCollectionContainer;
@ -486,7 +489,7 @@ namespace NewHorizons.Builder.Props
);
// Set up the containers for the slides
var slideCollectionContainer = standingTorch.AddComponent<SlideCollectionContainer>();
var slideCollectionContainer = standingTorch.AddComponent<NHSlideCollectionContainer>();
slideCollectionContainer.slideCollection = slideCollection;
var mindSlideCollection = standingTorch.AddComponent<MindSlideCollection>();
@ -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<string>();
slideCollectionContainer.conditionsToSet = info.conditionsToSet;
slideCollectionContainer.persistentConditionsToSet = info.persistentConditionsToSet;
}
}

View File

@ -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);
}
}
}
}
}
}

View File

@ -48,6 +48,16 @@ namespace NewHorizons.External.Modules.Props.EchoesOfTheEye
/// </summary>
public string[] reveals;
/// <summary>
/// The dialogue conditions to set after finishing this slide reel.
/// </summary>
public string[] conditionsToSet;
/// <summary>
/// The persistent conditions to set after finishing this slide reel.
/// </summary>
public string[] persistentConditionsToSet;
/// <summary>
/// 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.