diff --git a/NewHorizons/Builder/Props/ProjectionBuilder.cs b/NewHorizons/Builder/Props/ProjectionBuilder.cs index 1a406d2b..7df34b6c 100644 --- a/NewHorizons/Builder/Props/ProjectionBuilder.cs +++ b/NewHorizons/Builder/Props/ProjectionBuilder.cs @@ -13,7 +13,7 @@ using System.IO; using System.Linq; using UnityEngine; using UnityEngine.InputSystem; -using static NewHorizons.Main; +using static NewHorizons.Utility.Files.AssetBundleUtilities; namespace NewHorizons.Builder.Props { @@ -543,12 +543,12 @@ namespace NewHorizons.Builder.Props if (useInvertedCache && cacheExists) { // Load the inverted images used when displaying slide reels to a screen - invertedImageLoader.PathsToLoad.Add((i, Path.Combine(Instance.ModHelper.Manifest.ModFolderPath, "Assets/textures/inverted_blank_slide_reel.png"))); + invertedImageLoader.PathsToLoad.Add((i, Path.Combine(Main.Instance.ModHelper.Manifest.ModFolderPath, "Assets/textures/inverted_blank_slide_reel.png"))); } else { // Used to then make cached stuff - imageLoader.PathsToLoad.Add((i, Path.Combine(Instance.ModHelper.Manifest.ModFolderPath, "Assets/textures/blank_slide_reel.png"))); + imageLoader.PathsToLoad.Add((i, Path.Combine(Main.Instance.ModHelper.Manifest.ModFolderPath, "Assets/textures/blank_slide_reel.png"))); } } else diff --git a/NewHorizons/Builder/Props/PropBuildManager.cs b/NewHorizons/Builder/Props/PropBuildManager.cs index 9aa7d823..de3b7073 100644 --- a/NewHorizons/Builder/Props/PropBuildManager.cs +++ b/NewHorizons/Builder/Props/PropBuildManager.cs @@ -6,6 +6,7 @@ using NewHorizons.Builder.ShipLog; using NewHorizons.External; using NewHorizons.External.Configs; using NewHorizons.External.Modules; +using NewHorizons.External.Modules.Props.Quantum; using NewHorizons.Utility; using NewHorizons.Utility.OWML; using OWML.Common; @@ -162,25 +163,25 @@ namespace NewHorizons.Builder.Props } } - if (config.Props.quantumGroups != null) + var quantumPropsByGroup = new Dictionary>(); + foreach (var detail in config.Props?.details) { - var propsByGroup = new Dictionary>(); - foreach (var detail in config.Props.details) + if (detail.quantumGroupID != null) { - if (detail.quantumGroupID != null) + if (!quantumPropsByGroup.ContainsKey(detail.quantumGroupID)) { - if (!propsByGroup.ContainsKey(detail.quantumGroupID)) - { - propsByGroup[detail.quantumGroupID] = new List(); - } - propsByGroup[detail.quantumGroupID].Add(DetailBuilder.GetSpawnedGameObjectByDetailInfo(detail)); + quantumPropsByGroup[detail.quantumGroupID] = new List(); } + quantumPropsByGroup[detail.quantumGroupID].Add(DetailBuilder.GetSpawnedGameObjectByDetailInfo(detail)); } + } - foreach (var quantumGroup in config.Props.quantumGroups) + void MakeQuantumGroup(BaseQuantumGroupInfo[] group) + { + foreach (var quantumGroup in group) { - if (!propsByGroup.ContainsKey(quantumGroup.id)) continue; - var propsInGroup = propsByGroup[quantumGroup.id]; + if (!quantumPropsByGroup.ContainsKey(quantumGroup.id)) continue; + var propsInGroup = quantumPropsByGroup[quantumGroup.id]; try { @@ -192,6 +193,16 @@ namespace NewHorizons.Builder.Props } } } + + if (config.Props.socketQuantumGroups != null) + { + MakeQuantumGroup(config.Props.socketQuantumGroups); + } + + if (config.Props.stateQuantumGroups != null) + { + MakeQuantumGroup(config.Props.stateQuantumGroups); + } } private static bool _ignoreParent; diff --git a/NewHorizons/Builder/Props/QuantumBuilder.cs b/NewHorizons/Builder/Props/QuantumBuilder.cs index b0f9d8da..61d631b2 100644 --- a/NewHorizons/Builder/Props/QuantumBuilder.cs +++ b/NewHorizons/Builder/Props/QuantumBuilder.cs @@ -1,6 +1,9 @@ using NewHorizons.Components.Quantum; +using NewHorizons.External.Configs; using NewHorizons.External.Modules.Props.Quantum; using NewHorizons.Utility.Geometry; +using NewHorizons.Utility.OWML; +using OWML.Common; using System.Collections.Generic; using System.Linq; using UnityEngine; @@ -9,21 +12,15 @@ namespace NewHorizons.Builder.Props { public static class QuantumBuilder { - public static void Make(GameObject planetGO, Sector sector, QuantumGroupInfo quantumGroup, GameObject[] propsInGroup) + public static void Make(GameObject planetGO, Sector sector, BaseQuantumGroupInfo quantumGroup, GameObject[] propsInGroup) { - switch (quantumGroup.type) + if (quantumGroup is SocketQuantumGroupInfo socketGroup) { - case QuantumGroupType.Sockets: - MakeSocketGroup(planetGO, sector, quantumGroup, propsInGroup); - return; - case QuantumGroupType.States: - MakeStateGroup(planetGO, sector, quantumGroup, propsInGroup); - return; - /* - case PropModule.QuantumGroupType.Shuffle: - MakeShuffleGroup(go, sector, quantumGroup, propsInGroup); - return; - */ + MakeSocketGroup(planetGO, sector, socketGroup, propsInGroup); + } + else if (quantumGroup is StateQuantumGroupInfo stateGroup) + { + MakeStateGroup(planetGO, sector, stateGroup, propsInGroup); } } @@ -43,10 +40,10 @@ namespace NewHorizons.Builder.Props lightningController.enabled = true; } */ - + // TODO: Socket groups that have an equal number of props and sockets // Nice to have: socket groups that specify a filledSocketObject and an emptySocketObject (eg the archway in the giant's deep tower) - public static void MakeSocketGroup(GameObject go, Sector sector, PlanetConfig config, IModBehaviour mod, QuantumGroupInfo quantumGroup, GameObject[] propsInGroup) + public static void MakeSocketGroup(GameObject planetGO, Sector sector, SocketQuantumGroupInfo quantumGroup, GameObject[] propsInGroup) { var groupRoot = new GameObject("Quantum Sockets - " + quantumGroup.id); groupRoot.transform.parent = sector?.transform ?? planetGO.transform; @@ -58,7 +55,7 @@ namespace NewHorizons.Builder.Props { var socketInfo = quantumGroup.sockets[i]; - var socket = GeneralPropBuilder.MakeNew("Socket " + i, go, sector, socketInfo, defaultParent: groupRoot.transform); + var socket = GeneralPropBuilder.MakeNew("Socket " + i, planetGO, sector, socketInfo, defaultParent: groupRoot.transform); sockets[i] = socket.AddComponent(); sockets[i]._lightSources = new Light[0]; // TODO: make this customizable? @@ -87,7 +84,7 @@ namespace NewHorizons.Builder.Props } - public static void MakeStateGroup(GameObject go, Sector sector, QuantumGroupInfo quantumGroup, GameObject[] propsInGroup) + public static void MakeStateGroup(GameObject go, Sector sector, StateQuantumGroupInfo quantumGroup, GameObject[] propsInGroup) { // NOTE: States groups need special consideration that socket groups don't // this is because the base class QuantumObject (and this is important) IGNORES PICTURES TAKEN FROM OVER 100 METERS AWAY @@ -242,10 +239,10 @@ namespace NewHorizons.Builder.Props public void Update() { - if (meshFilter == null && skinnedMeshRenderer == null) - { - NHLogger.LogVerbose("Useless BoxShapeFixer, destroying"); - DestroyImmediate(this); + if (meshFilter == null && skinnedMeshRenderer == null) + { + NHLogger.LogVerbose("Useless BoxShapeFixer, destroying"); + DestroyImmediate(this); } Mesh sharedMesh = null; diff --git a/NewHorizons/External/Modules/Props/Quantum/SocketQuantumGroupInfo.cs b/NewHorizons/External/Modules/Props/Quantum/SocketQuantumGroupInfo.cs index 09d0b264..54475773 100644 --- a/NewHorizons/External/Modules/Props/Quantum/SocketQuantumGroupInfo.cs +++ b/NewHorizons/External/Modules/Props/Quantum/SocketQuantumGroupInfo.cs @@ -5,5 +5,5 @@ namespace NewHorizons.External.Modules.Props.Quantum; [JsonObject] public class SocketQuantumGroupInfo : BaseQuantumGroupInfo { - QuantumSocketInfo[] sockets; + public QuantumSocketInfo[] sockets; } diff --git a/NewHorizons/External/Modules/Props/Quantum/StateQuantumGroupInfo.cs b/NewHorizons/External/Modules/Props/Quantum/StateQuantumGroupInfo.cs index 2888b931..4be2253b 100644 --- a/NewHorizons/External/Modules/Props/Quantum/StateQuantumGroupInfo.cs +++ b/NewHorizons/External/Modules/Props/Quantum/StateQuantumGroupInfo.cs @@ -15,4 +15,9 @@ public class StateQuantumGroupInfo : BaseQuantumGroupInfo /// Optional. Only used if `sequential` is true. If this is false, then after the last state has appeared, the object will no longer change state /// [DefaultValue(true)] public bool loop = true; + + /// + /// Optional. Only used if type is `states`. If this is true, then the first prop made part of this group will be used to construct a visibility box for an empty game object, which will be considered one of the states. + /// + public bool hasEmptyState; } diff --git a/NewHorizons/Handlers/VesselWarpHandler.cs b/NewHorizons/Handlers/VesselWarpHandler.cs index bac8fdf7..3469cdee 100644 --- a/NewHorizons/Handlers/VesselWarpHandler.cs +++ b/NewHorizons/Handlers/VesselWarpHandler.cs @@ -7,6 +7,7 @@ using NewHorizons.Utility.OuterWilds; using NewHorizons.Utility.OWML; using UnityEngine; using static NewHorizons.Main; +using static NewHorizons.Utility.Files.AssetBundleUtilities; namespace NewHorizons.Handlers {