Add quantumAlignWithGravity field.

This commit is contained in:
_nebula 2025-01-06 20:36:07 +00:00
parent 492907c173
commit 0796d751bd
3 changed files with 15 additions and 10 deletions

View File

@ -12,6 +12,7 @@ using OWML.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using NewHorizons.External.Modules.Props;
using UnityEngine;
namespace NewHorizons.Builder.Props
@ -164,13 +165,13 @@ namespace NewHorizons.Builder.Props
if (config.Props.quantumGroups != null)
{
var propsByGroup = new Dictionary<string, List<(GameObject go, bool randomizeYRotation)>>();
var propsByGroup = new Dictionary<string, List<(GameObject go, DetailInfo detail)>>();
foreach (var detail in config.Props.details)
{
if (detail.quantumGroupID != null)
{
if (!propsByGroup.ContainsKey(detail.quantumGroupID)) propsByGroup[detail.quantumGroupID] = new List<(GameObject go, bool randomizeYRotation)>();
propsByGroup[detail.quantumGroupID].Add((DetailBuilder.GetSpawnedGameObjectByDetailInfo(detail), detail.quantumRandomizeYRotation));
if (!propsByGroup.ContainsKey(detail.quantumGroupID)) propsByGroup[detail.quantumGroupID] = new List<(GameObject go, DetailInfo detail)>();
propsByGroup[detail.quantumGroupID].Add((DetailBuilder.GetSpawnedGameObjectByDetailInfo(detail), detail));
}
}

View File

@ -6,6 +6,7 @@ using NewHorizons.Utility.OWML;
using OWML.Common;
using System.Collections.Generic;
using System.Linq;
using NewHorizons.External.Modules.Props;
using UnityEngine;
namespace NewHorizons.Builder.Props
@ -13,7 +14,7 @@ namespace NewHorizons.Builder.Props
public static class QuantumBuilder
{
public static void Make(GameObject go, Sector sector, PlanetConfig config, IModBehaviour mod, QuantumGroupInfo quantumGroup, (GameObject go, bool randomizeY)[] propsInGroup)
public static void Make(GameObject go, Sector sector, PlanetConfig config, IModBehaviour mod, QuantumGroupInfo quantumGroup, (GameObject go, DetailInfo detail)[] propsInGroup)
{
switch (quantumGroup.type)
{
@ -25,15 +26,13 @@ namespace NewHorizons.Builder.Props
// 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 go, bool randomizeY)[] propsInGroup)
public static void MakeSocketGroup(GameObject go, Sector sector, PlanetConfig config, IModBehaviour mod, QuantumGroupInfo quantumGroup, (GameObject go, DetailInfo detail)[] propsInGroup)
{
var groupRoot = new GameObject("Quantum Sockets - " + quantumGroup.id);
groupRoot.transform.parent = sector?.transform ?? go.transform;
groupRoot.transform.localPosition = Vector3.zero;
groupRoot.transform.localEulerAngles = Vector3.zero;
var useSocketRotation = quantumGroup.sockets.All(x => x.rotation != null);
var sockets = new QuantumSocket[quantumGroup.sockets.Length];
for (int i = 0; i < quantumGroup.sockets.Length; i++)
{
@ -54,9 +53,9 @@ namespace NewHorizons.Builder.Props
quantumObject._socketList = sockets.ToList();
quantumObject._sockets = sockets;
quantumObject._prebuilt = true;
quantumObject._alignWithSocket = useSocketRotation;
quantumObject._randomYRotation = prop.randomizeY;
quantumObject._alignWithGravity = !useSocketRotation;
quantumObject._alignWithSocket = !prop.detail.quantumAlignWithGravity;
quantumObject._randomYRotation = prop.detail.quantumRandomizeYRotation;
quantumObject._alignWithGravity = prop.detail.quantumAlignWithGravity;
quantumObject._childSockets = new List<QuantumSocket>();
if (prop.go.GetComponentInChildren<VisibilityTracker>() == null) AddBoundsVisibility(prop.go);
prop.go.SetActive(true);

View File

@ -58,6 +58,11 @@ namespace NewHorizons.External.Modules.Props
/// </summary>
[DefaultValue(true)] public bool quantumRandomizeYRotation = true;
/// <summary>
/// If this prop is quantum, and the quantum group is socketed, this field determines whether the prop will align with the GravityVolume (true) or align with the current socket (false).
/// </summary>
[DefaultValue(true)] public bool quantumAlignWithGravity = true;
/// <summary>
/// Should this detail stay loaded (visible and collideable) even if you're outside the sector (good for very large props)?
/// Also makes this detail visible on the map.