added standing vision torches (the kind that just sit in the environment and you walk into their projection beam)

This commit is contained in:
FreezeDriedMangoes 2022-05-24 12:25:34 -04:00
parent 2af257a35f
commit 667e68f7ac
2 changed files with 74 additions and 4 deletions

View File

@ -1,4 +1,4 @@
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Handlers; using NewHorizons.Handlers;
using NewHorizons.Utility; using NewHorizons.Utility;
@ -12,6 +12,7 @@ namespace NewHorizons.Builder.Props
{ {
public static class DetailBuilder 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<PropModule.DetailInfo, GameObject> detailInfoToCorrespondingSpawnedGameObject = new Dictionary<PropModule.DetailInfo, GameObject>(); private static Dictionary<PropModule.DetailInfo, GameObject> detailInfoToCorrespondingSpawnedGameObject = new Dictionary<PropModule.DetailInfo, GameObject>();
public static GameObject GetSpawnedGameObjectByDetailInfo(PropModule.DetailInfo detail) 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) 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); var prefab = SearchUtilities.Find(propToClone);
if (prefab == null) Logger.LogError($"Couldn't find detail {propToClone}"); if (prefab == null) Logger.LogError($"Couldn't find detail {propToClone}");
return MakeDetail(go, sector, prefab, position, rotation, scale, alignWithNormal); return MakeDetail(go, sector, prefab, position, rotation, scale, alignWithNormal);
@ -219,5 +222,26 @@ namespace NewHorizons.Builder.Props
return prop; 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<VisionTorchItem>().enabled = true;
Prefab_IP_VisionTorchItem.GetComponent<VisionTorchItem>().mindProjectorTrigger.enabled = true;
Prefab_IP_VisionTorchItem.GetComponent<VisionTorchItem>().mindSlideProjector._mindProjectorImageEffect = GameObject.Find("Player_Body/PlayerCamera").GetComponent<MindProjectorImageEffect>();
return Prefab_IP_VisionTorchItem;
}
} }
} }

View File

@ -19,6 +19,8 @@ namespace NewHorizons.Builder.Props
{ {
if (info.type == "autoProjector") MakeAutoProjector(go, sector, info, 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}"); else Logger.LogError($"Invalid projection type {info.type}");
} }
@ -160,8 +162,7 @@ namespace NewHorizons.Builder.Props
{ {
// spawn a trigger for the vision torch // 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 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, info.position, Vector3.zero, 1, false);
GameObject g = DetailBuilder.MakeDetail(planetGO, sector, path, position, Vector3.zero, 1, false);
if (g == null) if (g == null)
{ {
@ -205,6 +206,51 @@ namespace NewHorizons.Builder.Props
return g; 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>();
slideCollectionContainer.slideCollection = slideCollection;
MindSlideCollection mindlideCollection = standingTorch.AddComponent<MindSlideCollection>();
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) private static void AddModules(PropModule.SlideInfo slideInfo, ref Slide slide)
{ {
var modules = new List<SlideFunctionModule>(); var modules = new List<SlideFunctionModule>();