diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index 68247a08..b505aba2 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -1,4 +1,4 @@ -using NewHorizons.External.Configs; +using NewHorizons.External.Configs; using NewHorizons.External.Modules; using NewHorizons.Handlers; using NewHorizons.Utility; @@ -12,6 +12,7 @@ namespace NewHorizons.Builder.Props { public static class DetailBuilder { + private static readonly string VISION_TORCH_PATH = "DreamWorld_Body/Sector_DreamWorld/Sector_Underground/Sector_PrisonCell/Interactibles_PrisonCell/PrisonerSequence/VisionTorchWallSocket/Prefab_IP_VisionTorchItem"; private static Dictionary detailInfoToCorrespondingSpawnedGameObject = new Dictionary(); public static GameObject GetSpawnedGameObjectByDetailInfo(PropModule.DetailInfo detail) @@ -81,6 +82,8 @@ namespace NewHorizons.Builder.Props public static GameObject MakeDetail(GameObject go, Sector sector, string propToClone, MVector3 position, MVector3 rotation, float scale, bool alignWithNormal) { + if (propToClone == VISION_TORCH_PATH) return MakeVisionTorch(go, sector, position, rotation, scale, alignWithNormal); + var prefab = SearchUtilities.Find(propToClone); if (prefab == null) Logger.LogError($"Couldn't find detail {propToClone}"); return MakeDetail(go, sector, prefab, position, rotation, scale, alignWithNormal); @@ -219,5 +222,26 @@ namespace NewHorizons.Builder.Props return prop; } + + public static GameObject MakeVisionTorch(GameObject planetGO, Sector sector, MVector3 position, MVector3 rotation, float scale, bool alignWithNormal) + { + if (!Main.HasDLC) + { + Logger.LogError("Could not instantiate Prefab_IP_VisionTorchItem, user does not own the DLC."); + return null; + } + + var prefab = SearchUtilities.Find(VISION_TORCH_PATH); + if (prefab == null) Logger.LogError($"Couldn't find detail Prefab_IP_VisionTorchItem"); + + GameObject Prefab_IP_VisionTorchItem = MakeDetail(planetGO, sector, prefab, position, rotation, scale, alignWithNormal); + + Prefab_IP_VisionTorchItem.GetComponent().enabled = true; + Prefab_IP_VisionTorchItem.GetComponent().mindProjectorTrigger.enabled = true; + + Prefab_IP_VisionTorchItem.GetComponent().mindSlideProjector._mindProjectorImageEffect = GameObject.Find("Player_Body/PlayerCamera").GetComponent(); + + return Prefab_IP_VisionTorchItem; + } } } diff --git a/NewHorizons/Builder/Props/ProjectionBuilder.cs b/NewHorizons/Builder/Props/ProjectionBuilder.cs index d0f7f67d..07a7f531 100644 --- a/NewHorizons/Builder/Props/ProjectionBuilder.cs +++ b/NewHorizons/Builder/Props/ProjectionBuilder.cs @@ -18,7 +18,9 @@ namespace NewHorizons.Builder.Props public static void Make(GameObject go, Sector sector, PropModule.ProjectionInfo info, IModBehaviour mod) { if (info.type == "autoProjector") MakeAutoProjector(go, sector, info, mod); - else if (info.type == "slideReel") MakeSlideReel(go, sector, info, mod); + else if (info.type == "slideReel") MakeSlideReel(go, sector, info, mod); + else if (info.type == "playerVisionTorchTarget") MakeMindSlidesTarget(go, sector, info, mod); + else if (info.type == "standingVisionTorch") MakeStandingVisionTorch(go, sector, info, mod); else Logger.LogError($"Invalid projection type {info.type}"); } @@ -160,8 +162,7 @@ namespace NewHorizons.Builder.Props { // spawn a trigger for the vision torch var path = "DreamWorld_Body/Sector_DreamWorld/Sector_Underground/Sector_PrisonCell/Ghosts_PrisonCell/GhostNodeMap_PrisonCell_Lower/Prefab_IP_GhostBird_Prisoner/Ghostbird_IP_ANIM/Ghostbird_Skin_01:Ghostbird_Rig_V01:Base/Ghostbird_Skin_01:Ghostbird_Rig_V01:Root/Ghostbird_Skin_01:Ghostbird_Rig_V01:Spine01/Ghostbird_Skin_01:Ghostbird_Rig_V01:Spine02/Ghostbird_Skin_01:Ghostbird_Rig_V01:Spine03/Ghostbird_Skin_01:Ghostbird_Rig_V01:Spine04/Ghostbird_Skin_01:Ghostbird_Rig_V01:Neck01/Ghostbird_Skin_01:Ghostbird_Rig_V01:Neck02/Ghostbird_Skin_01:Ghostbird_Rig_V01:Head/PrisonerHeadDetector"; - var position = info.position; - GameObject g = DetailBuilder.MakeDetail(planetGO, sector, path, position, Vector3.zero, 1, false); + GameObject g = DetailBuilder.MakeDetail(planetGO, sector, path, info.position, Vector3.zero, 1, false); if (g == null) { @@ -204,6 +205,51 @@ namespace NewHorizons.Builder.Props return g; } + + public static GameObject MakeStandingVisionTorch(GameObject planetGO, Sector sector, PropModule.ProjectionInfo info, IModBehaviour mod) + { + // spawn the torch itself + var path = "RingWorld_Body/Sector_RingWorld/Sector_SecretEntrance/Interactibles_SecretEntrance/Experiment_1/VisionTorchApparatus/VisionTorchRoot/Prefab_IP_VisionTorchProjector"; + GameObject standingTorch = DetailBuilder.MakeDetail(planetGO, sector, path, info.position, info.rotation, 1, false); + + if (standingTorch == null) + { + Logger.LogWarning($"Tried to make a vision torch target but couldn't. Do you have the DLC installed?"); + return null; + } + + // The number of slides is unlimited, 15 is only for texturing the actual slide reel item. This is not a slide reel item + SlideInfo[] slides = info.slides; + var slidesCount = slides.Length; + var slideCollection = new SlideCollection(slidesCount); + + + for (int i = 0; i < slidesCount; i++) + { + var slide = new Slide(); + var slideInfo = slides[i]; + + // TODO: do this part asynchronously so that you can load all the slides you want without stalling the game out for 5 days + var texture = ImageUtilities.GetTexture(mod, slideInfo.imagePath); + slide.textureOverride = texture; //ImageUtilities.Invert(texture); + + AddModules(slideInfo, ref slide); + + slideCollection.slides[i] = slide; + } + + // attatch a component to store all the data for the slides that play when a vision torch scans this target + SlideCollectionContainer slideCollectionContainer = standingTorch.AddComponent(); + slideCollectionContainer.slideCollection = slideCollection; + MindSlideCollection mindlideCollection = standingTorch.AddComponent(); + mindlideCollection._slideCollectionContainer = slideCollectionContainer; + slideCollectionContainer = slideCollectionContainer; + + // Idk why but it wants reveals to be comma delimited not a list + if (info.reveals != null) slideCollectionContainer._shipLogOnComplete = string.Join(",", info.reveals); + + return standingTorch; + } private static void AddModules(PropModule.SlideInfo slideInfo, ref Slide slide) {