mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Add quantumAlignWithGravity field.
This commit is contained in:
parent
492907c173
commit
0796d751bd
@ -12,6 +12,7 @@ using OWML.Common;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using NewHorizons.External.Modules.Props;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace NewHorizons.Builder.Props
|
namespace NewHorizons.Builder.Props
|
||||||
@ -164,13 +165,13 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
if (config.Props.quantumGroups != null)
|
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)
|
foreach (var detail in config.Props.details)
|
||||||
{
|
{
|
||||||
if (detail.quantumGroupID != null)
|
if (detail.quantumGroupID != null)
|
||||||
{
|
{
|
||||||
if (!propsByGroup.ContainsKey(detail.quantumGroupID)) propsByGroup[detail.quantumGroupID] = new List<(GameObject go, bool randomizeYRotation)>();
|
if (!propsByGroup.ContainsKey(detail.quantumGroupID)) propsByGroup[detail.quantumGroupID] = new List<(GameObject go, DetailInfo detail)>();
|
||||||
propsByGroup[detail.quantumGroupID].Add((DetailBuilder.GetSpawnedGameObjectByDetailInfo(detail), detail.quantumRandomizeYRotation));
|
propsByGroup[detail.quantumGroupID].Add((DetailBuilder.GetSpawnedGameObjectByDetailInfo(detail), detail));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@ using NewHorizons.Utility.OWML;
|
|||||||
using OWML.Common;
|
using OWML.Common;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using NewHorizons.External.Modules.Props;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace NewHorizons.Builder.Props
|
namespace NewHorizons.Builder.Props
|
||||||
@ -13,7 +14,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
public static class QuantumBuilder
|
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)
|
switch (quantumGroup.type)
|
||||||
{
|
{
|
||||||
@ -25,15 +26,13 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
// 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 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);
|
var groupRoot = new GameObject("Quantum Sockets - " + quantumGroup.id);
|
||||||
groupRoot.transform.parent = sector?.transform ?? go.transform;
|
groupRoot.transform.parent = sector?.transform ?? go.transform;
|
||||||
groupRoot.transform.localPosition = Vector3.zero;
|
groupRoot.transform.localPosition = Vector3.zero;
|
||||||
groupRoot.transform.localEulerAngles = Vector3.zero;
|
groupRoot.transform.localEulerAngles = Vector3.zero;
|
||||||
|
|
||||||
var useSocketRotation = quantumGroup.sockets.All(x => x.rotation != null);
|
|
||||||
|
|
||||||
var sockets = new QuantumSocket[quantumGroup.sockets.Length];
|
var sockets = new QuantumSocket[quantumGroup.sockets.Length];
|
||||||
for (int i = 0; i < quantumGroup.sockets.Length; i++)
|
for (int i = 0; i < quantumGroup.sockets.Length; i++)
|
||||||
{
|
{
|
||||||
@ -54,9 +53,9 @@ namespace NewHorizons.Builder.Props
|
|||||||
quantumObject._socketList = sockets.ToList();
|
quantumObject._socketList = sockets.ToList();
|
||||||
quantumObject._sockets = sockets;
|
quantumObject._sockets = sockets;
|
||||||
quantumObject._prebuilt = true;
|
quantumObject._prebuilt = true;
|
||||||
quantumObject._alignWithSocket = useSocketRotation;
|
quantumObject._alignWithSocket = !prop.detail.quantumAlignWithGravity;
|
||||||
quantumObject._randomYRotation = prop.randomizeY;
|
quantumObject._randomYRotation = prop.detail.quantumRandomizeYRotation;
|
||||||
quantumObject._alignWithGravity = !useSocketRotation;
|
quantumObject._alignWithGravity = prop.detail.quantumAlignWithGravity;
|
||||||
quantumObject._childSockets = new List<QuantumSocket>();
|
quantumObject._childSockets = new List<QuantumSocket>();
|
||||||
if (prop.go.GetComponentInChildren<VisibilityTracker>() == null) AddBoundsVisibility(prop.go);
|
if (prop.go.GetComponentInChildren<VisibilityTracker>() == null) AddBoundsVisibility(prop.go);
|
||||||
prop.go.SetActive(true);
|
prop.go.SetActive(true);
|
||||||
|
|||||||
@ -58,6 +58,11 @@ namespace NewHorizons.External.Modules.Props
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(true)] public bool quantumRandomizeYRotation = true;
|
[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>
|
/// <summary>
|
||||||
/// Should this detail stay loaded (visible and collideable) even if you're outside the sector (good for very large props)?
|
/// 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.
|
/// Also makes this detail visible on the map.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user