Make this branch actually build again

This commit is contained in:
xen-42 2025-01-06 17:21:32 -05:00
parent 06eea16188
commit 3b19c81b42
6 changed files with 51 additions and 37 deletions

View File

@ -13,7 +13,7 @@ using System.IO;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
using UnityEngine.InputSystem; using UnityEngine.InputSystem;
using static NewHorizons.Main; using static NewHorizons.Utility.Files.AssetBundleUtilities;
namespace NewHorizons.Builder.Props namespace NewHorizons.Builder.Props
{ {
@ -543,12 +543,12 @@ namespace NewHorizons.Builder.Props
if (useInvertedCache && cacheExists) if (useInvertedCache && cacheExists)
{ {
// Load the inverted images used when displaying slide reels to a screen // 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 else
{ {
// Used to then make cached stuff // 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 else

View File

@ -6,6 +6,7 @@ using NewHorizons.Builder.ShipLog;
using NewHorizons.External; using NewHorizons.External;
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.External.Modules.Props.Quantum;
using NewHorizons.Utility; using NewHorizons.Utility;
using NewHorizons.Utility.OWML; using NewHorizons.Utility.OWML;
using OWML.Common; using OWML.Common;
@ -162,25 +163,25 @@ namespace NewHorizons.Builder.Props
} }
} }
if (config.Props.quantumGroups != null) var quantumPropsByGroup = new Dictionary<string, List<GameObject>>();
foreach (var detail in config.Props?.details)
{ {
var propsByGroup = new Dictionary<string, List<GameObject>>(); if (detail.quantumGroupID != null)
foreach (var detail in config.Props.details)
{ {
if (detail.quantumGroupID != null) if (!quantumPropsByGroup.ContainsKey(detail.quantumGroupID))
{ {
if (!propsByGroup.ContainsKey(detail.quantumGroupID)) quantumPropsByGroup[detail.quantumGroupID] = new List<GameObject>();
{
propsByGroup[detail.quantumGroupID] = new List<GameObject>();
}
propsByGroup[detail.quantumGroupID].Add(DetailBuilder.GetSpawnedGameObjectByDetailInfo(detail));
} }
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; if (!quantumPropsByGroup.ContainsKey(quantumGroup.id)) continue;
var propsInGroup = propsByGroup[quantumGroup.id]; var propsInGroup = quantumPropsByGroup[quantumGroup.id];
try 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; private static bool _ignoreParent;

View File

@ -1,6 +1,9 @@
using NewHorizons.Components.Quantum; using NewHorizons.Components.Quantum;
using NewHorizons.External.Configs;
using NewHorizons.External.Modules.Props.Quantum; using NewHorizons.External.Modules.Props.Quantum;
using NewHorizons.Utility.Geometry; using NewHorizons.Utility.Geometry;
using NewHorizons.Utility.OWML;
using OWML.Common;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
@ -9,21 +12,15 @@ namespace NewHorizons.Builder.Props
{ {
public static class QuantumBuilder 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, socketGroup, propsInGroup);
MakeSocketGroup(planetGO, sector, quantumGroup, propsInGroup); }
return; else if (quantumGroup is StateQuantumGroupInfo stateGroup)
case QuantumGroupType.States: {
MakeStateGroup(planetGO, sector, quantumGroup, propsInGroup); MakeStateGroup(planetGO, sector, stateGroup, propsInGroup);
return;
/*
case PropModule.QuantumGroupType.Shuffle:
MakeShuffleGroup(go, sector, quantumGroup, propsInGroup);
return;
*/
} }
} }
@ -43,10 +40,10 @@ namespace NewHorizons.Builder.Props
lightningController.enabled = true; lightningController.enabled = true;
} }
*/ */
// TODO: Socket groups that have an equal number of props and sockets // 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) // 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); var groupRoot = new GameObject("Quantum Sockets - " + quantumGroup.id);
groupRoot.transform.parent = sector?.transform ?? planetGO.transform; groupRoot.transform.parent = sector?.transform ?? planetGO.transform;
@ -58,7 +55,7 @@ namespace NewHorizons.Builder.Props
{ {
var socketInfo = quantumGroup.sockets[i]; 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<QuantumSocket>(); sockets[i] = socket.AddComponent<QuantumSocket>();
sockets[i]._lightSources = new Light[0]; // TODO: make this customizable? 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 // 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 // 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() public void Update()
{ {
if (meshFilter == null && skinnedMeshRenderer == null) if (meshFilter == null && skinnedMeshRenderer == null)
{ {
NHLogger.LogVerbose("Useless BoxShapeFixer, destroying"); NHLogger.LogVerbose("Useless BoxShapeFixer, destroying");
DestroyImmediate(this); DestroyImmediate(this);
} }
Mesh sharedMesh = null; Mesh sharedMesh = null;

View File

@ -5,5 +5,5 @@ namespace NewHorizons.External.Modules.Props.Quantum;
[JsonObject] [JsonObject]
public class SocketQuantumGroupInfo : BaseQuantumGroupInfo public class SocketQuantumGroupInfo : BaseQuantumGroupInfo
{ {
QuantumSocketInfo[] sockets; public QuantumSocketInfo[] sockets;
} }

View File

@ -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 /// 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
/// </summary> /// </summary>
[DefaultValue(true)] public bool loop = true; [DefaultValue(true)] public bool loop = true;
/// <summary>
/// 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.
/// </summary>
public bool hasEmptyState;
} }

View File

@ -7,6 +7,7 @@ using NewHorizons.Utility.OuterWilds;
using NewHorizons.Utility.OWML; using NewHorizons.Utility.OWML;
using UnityEngine; using UnityEngine;
using static NewHorizons.Main; using static NewHorizons.Main;
using static NewHorizons.Utility.Files.AssetBundleUtilities;
namespace NewHorizons.Handlers namespace NewHorizons.Handlers
{ {