mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Implement auto projectors
This commit is contained in:
parent
b59a03d15e
commit
0e120d3e4e
@ -9,21 +9,30 @@ using NewHorizons.Utility;
|
|||||||
using OWML.ModHelper;
|
using OWML.ModHelper;
|
||||||
using OWML.Common;
|
using OWML.Common;
|
||||||
using NewHorizons.Handlers;
|
using NewHorizons.Handlers;
|
||||||
|
using Logger = NewHorizons.Utility.Logger;
|
||||||
|
|
||||||
namespace NewHorizons.Builder.Props
|
namespace NewHorizons.Builder.Props
|
||||||
{
|
{
|
||||||
public static class SlideReelBuilder
|
public static class ProjectionBuilder
|
||||||
{
|
{
|
||||||
private static GameObject _prefab;
|
private static GameObject _slideReelPrefab;
|
||||||
public static void Make(GameObject go, Sector sector, PropModule.SlideReelInfo info, IModBehaviour mod)
|
private static GameObject _autoPrefab;
|
||||||
|
public static void Make(GameObject go, Sector sector, PropModule.ProjectionInfo info, IModBehaviour mod)
|
||||||
{
|
{
|
||||||
if (_prefab == null)
|
if (info.type == "Auto") MakeAutoProjector(go, sector, info, mod);
|
||||||
|
else if (info.type == "SlideReel") MakeSlideReel(go, sector, info, mod);
|
||||||
|
else Logger.LogError($"Invalid projection type {info.type}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void MakeSlideReel(GameObject go, Sector sector, PropModule.ProjectionInfo info, IModBehaviour mod)
|
||||||
|
{
|
||||||
|
if (_slideReelPrefab == null)
|
||||||
{
|
{
|
||||||
_prefab = GameObject.Find("RingWorld_Body/Sector_RingInterior/Sector_Zone1/Sector_SlideBurningRoom_Zone1/Interactables_SlideBurningRoom_Zone1/Prefab_IP_SecretAlcove/RotationPivot/SlideReelSocket/Prefab_IP_Reel_1_LibraryPath").gameObject.InstantiateInactive();
|
_slideReelPrefab = GameObject.Find("RingWorld_Body/Sector_RingInterior/Sector_Zone1/Sector_SlideBurningRoom_Zone1/Interactables_SlideBurningRoom_Zone1/Prefab_IP_SecretAlcove/RotationPivot/SlideReelSocket/Prefab_IP_Reel_1_LibraryPath").gameObject.InstantiateInactive();
|
||||||
_prefab.name = "Prefab_IP_Reel";
|
_slideReelPrefab.name = "Prefab_IP_Reel";
|
||||||
}
|
}
|
||||||
|
|
||||||
var slideReelObj = _prefab.InstantiateInactive();
|
var slideReelObj = _slideReelPrefab.InstantiateInactive();
|
||||||
slideReelObj.name = $"Prefab_IP_Reel_{mod.ModHelper.Manifest.Name}";
|
slideReelObj.name = $"Prefab_IP_Reel_{mod.ModHelper.Manifest.Name}";
|
||||||
|
|
||||||
var slideReel = slideReelObj.GetComponent<SlideReelItem>();
|
var slideReel = slideReelObj.GetComponent<SlideReelItem>();
|
||||||
@ -39,7 +48,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
slideReelObj.transform.parent = sector?.transform ?? go.transform;
|
slideReelObj.transform.parent = sector?.transform ?? go.transform;
|
||||||
slideReelObj.transform.localPosition = (Vector3)(info.position ?? Vector3.zero);
|
slideReelObj.transform.localPosition = (Vector3)(info.position ?? Vector3.zero);
|
||||||
slideReelObj.transform.rotation = Quaternion.Euler((Vector3)(info.position ?? Vector3.zero));
|
slideReelObj.transform.localRotation = Quaternion.Euler((Vector3)(info.rotation ?? Vector3.zero));
|
||||||
|
|
||||||
// Now we replace the slides
|
// Now we replace the slides
|
||||||
int slidesCount = info.slides.Length;
|
int slidesCount = info.slides.Length;
|
||||||
@ -67,11 +76,13 @@ namespace NewHorizons.Builder.Props
|
|||||||
// Else when you put them down you can't pick them back up
|
// Else when you put them down you can't pick them back up
|
||||||
slideReelObj.GetComponent<OWCollider>()._physicsRemoved = false;
|
slideReelObj.GetComponent<OWCollider>()._physicsRemoved = false;
|
||||||
|
|
||||||
// Idk why but it wants reveals to be comma delimited not a list
|
|
||||||
slideCollectionContainer.slideCollection = slideCollection;
|
slideCollectionContainer.slideCollection = slideCollection;
|
||||||
|
|
||||||
|
// Idk why but it wants reveals to be comma delimited not a list
|
||||||
if (info.reveals != null) slideCollectionContainer._shipLogOnComplete = string.Join(",", info.reveals);
|
if (info.reveals != null) slideCollectionContainer._shipLogOnComplete = string.Join(",", info.reveals);
|
||||||
|
|
||||||
OWAssetHandler.LoadObject(slideReelObj);
|
OWAssetHandler.LoadObject(slideReelObj);
|
||||||
|
sector.OnOccupantEnterSector.AddListener((x) => OWAssetHandler.LoadObject(slideReelObj));
|
||||||
|
|
||||||
var slidesBack = slideReelObj.transform.Find("Props_IP_SlideReel_7/Slides_Back").GetComponent<MeshRenderer>();
|
var slidesBack = slideReelObj.transform.Find("Props_IP_SlideReel_7/Slides_Back").GetComponent<MeshRenderer>();
|
||||||
var slidesFront = slideReelObj.transform.Find("Props_IP_SlideReel_7/Slides_Front").GetComponent<MeshRenderer>();
|
var slidesFront = slideReelObj.transform.Find("Props_IP_SlideReel_7/Slides_Front").GetComponent<MeshRenderer>();
|
||||||
@ -86,6 +97,56 @@ namespace NewHorizons.Builder.Props
|
|||||||
slideReelObj.SetActive(true);
|
slideReelObj.SetActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void MakeAutoProjector(GameObject go, Sector sector, PropModule.ProjectionInfo info, IModBehaviour mod)
|
||||||
|
{
|
||||||
|
if (_autoPrefab == null)
|
||||||
|
{
|
||||||
|
_autoPrefab = GameObject.Find("RingWorld_Body/Sector_RingInterior/Sector_Zone4/Sector_BlightedShore/Sector_JammingControlRoom_Zone4/Interactables_JammingControlRoom_Zone4/AutoProjector_SignalJammer/Prefab_IP_AutoProjector_SignalJammer").gameObject.InstantiateInactive();
|
||||||
|
_autoPrefab.name = "Prefab_IP_AutoProjector";
|
||||||
|
}
|
||||||
|
|
||||||
|
var projectorObj = _autoPrefab.InstantiateInactive();
|
||||||
|
projectorObj.name = $"Prefab_IP_AutoProjector_{mod.ModHelper.Manifest.Name}";
|
||||||
|
|
||||||
|
var autoProjector = projectorObj.GetComponent<AutoSlideProjector>();
|
||||||
|
autoProjector._sector = sector;
|
||||||
|
|
||||||
|
var slideCollectionContainer = autoProjector.GetRequiredComponent<SlideCollectionContainer>();
|
||||||
|
|
||||||
|
autoProjector.transform.parent = sector?.transform ?? go.transform;
|
||||||
|
autoProjector.transform.localPosition = (Vector3)(info.position ?? Vector3.zero);
|
||||||
|
autoProjector.transform.localRotation = Quaternion.Euler((Vector3)(info.rotation ?? Vector3.zero));
|
||||||
|
|
||||||
|
// Now we replace the slides
|
||||||
|
int slidesCount = info.slides.Length;
|
||||||
|
var slideCollection = new SlideCollection(slidesCount);
|
||||||
|
|
||||||
|
for (int i = 0; i < slidesCount; i++)
|
||||||
|
{
|
||||||
|
var slide = new Slide();
|
||||||
|
var slideInfo = info.slides[i];
|
||||||
|
|
||||||
|
var texture = ImageUtilities.GetTexture(mod, slideInfo.imagePath);
|
||||||
|
slide.textureOverride = ImageUtilities.Invert(texture);
|
||||||
|
|
||||||
|
AddModules(slideInfo, ref slide);
|
||||||
|
|
||||||
|
slideCollection.slides[i] = slide;
|
||||||
|
}
|
||||||
|
|
||||||
|
slideCollectionContainer.slideCollection = slideCollection;
|
||||||
|
|
||||||
|
OWAssetHandler.LoadObject(projectorObj);
|
||||||
|
sector.OnOccupantEnterSector.AddListener((x) => OWAssetHandler.LoadObject(projectorObj));
|
||||||
|
|
||||||
|
// Change the picture on the lens
|
||||||
|
var lens = projectorObj.transform.Find("Spotlight/Prop_IP_SingleSlideProjector/Projector_Lens").GetComponent<MeshRenderer>();
|
||||||
|
lens.materials[1].mainTexture = slideCollection.slides[0]._textureOverride;
|
||||||
|
lens.materials[1].SetTexture("_EmissionMap", slideCollection.slides[0]._textureOverride);
|
||||||
|
|
||||||
|
projectorObj.SetActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
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>();
|
||||||
@ -78,11 +78,11 @@ namespace NewHorizons.Builder.Props
|
|||||||
EntryLocationBuilder.Make(go, sector, entryLocationInfo, mod);
|
EntryLocationBuilder.Make(go, sector, entryLocationInfo, mod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(config.Props.SlideReels != null)
|
if(config.Props.SlideShows != null)
|
||||||
{
|
{
|
||||||
foreach (var slideReelInfo in config.Props.SlideReels)
|
foreach (var slideReelInfo in config.Props.SlideShows)
|
||||||
{
|
{
|
||||||
SlideReelBuilder.Make(go, sector, slideReelInfo, mod);
|
ProjectionBuilder.Make(go, sector, slideReelInfo, mod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
5
NewHorizons/External/PropModule.cs
vendored
5
NewHorizons/External/PropModule.cs
vendored
@ -18,7 +18,7 @@ namespace NewHorizons.External
|
|||||||
public DialogueInfo[] Dialogue;
|
public DialogueInfo[] Dialogue;
|
||||||
public RevealInfo[] Reveal;
|
public RevealInfo[] Reveal;
|
||||||
public EntryLocationInfo[] EntryLocation;
|
public EntryLocationInfo[] EntryLocation;
|
||||||
public SlideReelInfo[] SlideReels;
|
public ProjectionInfo[] SlideShows;
|
||||||
|
|
||||||
public class ScatterInfo
|
public class ScatterInfo
|
||||||
{
|
{
|
||||||
@ -102,12 +102,13 @@ namespace NewHorizons.External
|
|||||||
public MVector3 position;
|
public MVector3 position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SlideReelInfo
|
public class ProjectionInfo
|
||||||
{
|
{
|
||||||
public MVector3 position;
|
public MVector3 position;
|
||||||
public MVector3 rotation;
|
public MVector3 rotation;
|
||||||
public string[] reveals;
|
public string[] reveals;
|
||||||
public SlideInfo[] slides;
|
public SlideInfo[] slides;
|
||||||
|
public string type = "SlideReel";
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SlideInfo
|
public class SlideInfo
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user