mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Fix #751
Uses socket rotation if non-null, adds field to props to choose whether to randomize Y rotation.
This commit is contained in:
parent
b9e0eb3b43
commit
27a3bfce3b
@ -164,13 +164,13 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
if (config.Props.quantumGroups != null)
|
if (config.Props.quantumGroups != null)
|
||||||
{
|
{
|
||||||
Dictionary<string, List<GameObject>> propsByGroup = new Dictionary<string, List<GameObject>>();
|
var propsByGroup = new Dictionary<string, List<(GameObject go, bool randomizeYRotation)>>();
|
||||||
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>();
|
if (!propsByGroup.ContainsKey(detail.quantumGroupID)) propsByGroup[detail.quantumGroupID] = new List<(GameObject go, bool randomizeYRotation)>();
|
||||||
propsByGroup[detail.quantumGroupID].Add(DetailBuilder.GetSpawnedGameObjectByDetailInfo(detail));
|
propsByGroup[detail.quantumGroupID].Add((DetailBuilder.GetSpawnedGameObjectByDetailInfo(detail), detail.quantumRandomizeYRotation));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,25 +13,27 @@ 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[] propsInGroup)
|
public static void Make(GameObject go, Sector sector, PlanetConfig config, IModBehaviour mod, QuantumGroupInfo quantumGroup, (GameObject go, bool randomizeY)[] propsInGroup)
|
||||||
{
|
{
|
||||||
switch (quantumGroup.type)
|
switch (quantumGroup.type)
|
||||||
{
|
{
|
||||||
case QuantumGroupType.Sockets: MakeSocketGroup(go, sector, config, mod, quantumGroup, propsInGroup); return;
|
case QuantumGroupType.Sockets: MakeSocketGroup(go, sector, config, mod, quantumGroup, propsInGroup); return;
|
||||||
case QuantumGroupType.States: MakeStateGroup(go, sector, config, mod, quantumGroup, propsInGroup); return;
|
case QuantumGroupType.States: MakeStateGroup(go, sector, config, mod, quantumGroup, propsInGroup.Select(x => x.go).ToArray()); return;
|
||||||
// case PropModule.QuantumGroupType.Shuffle: MakeShuffleGroup(go, sector, config, mod, quantumGroup, propsInGroup); return;
|
// case PropModule.QuantumGroupType.Shuffle: MakeShuffleGroup(go, sector, config, mod, quantumGroup, propsInGroup); return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 go, Sector sector, PlanetConfig config, IModBehaviour mod, QuantumGroupInfo quantumGroup, (GameObject go, bool randomizeY)[] 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++)
|
||||||
{
|
{
|
||||||
@ -46,16 +48,18 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
foreach (var prop in propsInGroup)
|
foreach (var prop in propsInGroup)
|
||||||
{
|
{
|
||||||
prop.SetActive(false);
|
prop.go.SetActive(false);
|
||||||
var quantumObject = prop.AddComponent<SocketedQuantumObject>();
|
var quantumObject = prop.go.AddComponent<SocketedQuantumObject>();
|
||||||
quantumObject._socketRoot = groupRoot;
|
quantumObject._socketRoot = groupRoot;
|
||||||
quantumObject._socketList = sockets.ToList();
|
quantumObject._socketList = sockets.ToList();
|
||||||
quantumObject._sockets = sockets;
|
quantumObject._sockets = sockets;
|
||||||
quantumObject._prebuilt = true;
|
quantumObject._prebuilt = true;
|
||||||
|
quantumObject._alignWithSocket = useSocketRotation;
|
||||||
|
quantumObject._randomYRotation = prop.randomizeY;
|
||||||
|
quantumObject._alignWithGravity = !useSocketRotation;
|
||||||
quantumObject._childSockets = new List<QuantumSocket>();
|
quantumObject._childSockets = new List<QuantumSocket>();
|
||||||
// TODO: support _alignWithGravity?
|
if (prop.go.GetComponentInChildren<VisibilityTracker>() == null) AddBoundsVisibility(prop.go);
|
||||||
if (prop.GetComponentInChildren<VisibilityTracker>() == null) AddBoundsVisibility(prop);
|
prop.go.SetActive(true);
|
||||||
prop.SetActive(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -53,6 +53,11 @@ namespace NewHorizons.External.Modules.Props
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string quantumGroupID;
|
public string quantumGroupID;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If this prop is quantum, and the quantum group is socketed, this field determines whether the prop will randomly choose a Y rotation when moving to a socket.
|
||||||
|
/// </summary>
|
||||||
|
public bool quantumRandomizeYRotation = 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