mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Quantum lightning works but has no lightning bolt
This commit is contained in:
parent
e8e8559cfe
commit
18f7de6ad8
@ -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;
|
||||||
using NewHorizons.External.Modules.Props.Quantum;
|
using NewHorizons.External.Modules.Props.Quantum;
|
||||||
using NewHorizons.Utility;
|
using NewHorizons.Utility;
|
||||||
using NewHorizons.Utility.OWML;
|
using NewHorizons.Utility.OWML;
|
||||||
@ -163,46 +164,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var quantumPropsByGroup = new Dictionary<string, List<GameObject>>();
|
QuantumBuilder.TryMake(go, sector, config);
|
||||||
foreach (var detail in config.Props?.details)
|
|
||||||
{
|
|
||||||
if (detail.quantumGroupID != null)
|
|
||||||
{
|
|
||||||
if (!quantumPropsByGroup.ContainsKey(detail.quantumGroupID))
|
|
||||||
{
|
|
||||||
quantumPropsByGroup[detail.quantumGroupID] = new List<GameObject>();
|
|
||||||
}
|
|
||||||
quantumPropsByGroup[detail.quantumGroupID].Add(DetailBuilder.GetSpawnedGameObjectByDetailInfo(detail));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MakeQuantumGroup(BaseQuantumGroupInfo[] group)
|
|
||||||
{
|
|
||||||
foreach (var quantumGroup in group)
|
|
||||||
{
|
|
||||||
if (!quantumPropsByGroup.ContainsKey(quantumGroup.id)) continue;
|
|
||||||
var propsInGroup = quantumPropsByGroup[quantumGroup.id];
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
QuantumBuilder.Make(go, sector, quantumGroup, propsInGroup.ToArray());
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
NHLogger.LogError($"Couldn't make quantum group [{quantumGroup.id}] for [{go.name}]:\n{ex}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
@ -1,8 +1,12 @@
|
|||||||
|
using Epic.OnlineServices;
|
||||||
using NewHorizons.Components.Quantum;
|
using NewHorizons.Components.Quantum;
|
||||||
|
using NewHorizons.External.Configs;
|
||||||
using NewHorizons.External.Modules.Props;
|
using NewHorizons.External.Modules.Props;
|
||||||
using NewHorizons.External.Modules.Props.Quantum;
|
using NewHorizons.External.Modules.Props.Quantum;
|
||||||
|
using NewHorizons.Utility.Files;
|
||||||
using NewHorizons.Utility.Geometry;
|
using NewHorizons.Utility.Geometry;
|
||||||
using NewHorizons.Utility.OWML;
|
using NewHorizons.Utility.OWML;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -11,34 +15,101 @@ namespace NewHorizons.Builder.Props
|
|||||||
{
|
{
|
||||||
public static class QuantumBuilder
|
public static class QuantumBuilder
|
||||||
{
|
{
|
||||||
public static void Make(GameObject planetGO, Sector sector, BaseQuantumGroupInfo quantumGroup, GameObject[] propsInGroup)
|
public static void TryMake(GameObject go, Sector sector, PlanetConfig config)
|
||||||
|
{
|
||||||
|
if (config.Props != null && config.Props.details != null)
|
||||||
|
{
|
||||||
|
var quantumPropsByGroup = new Dictionary<string, List<(GameObject go, DetailInfo info)>>();
|
||||||
|
foreach (var detail in config.Props?.details)
|
||||||
|
{
|
||||||
|
if (detail.quantumGroupID != null)
|
||||||
|
{
|
||||||
|
if (!quantumPropsByGroup.ContainsKey(detail.quantumGroupID))
|
||||||
|
{
|
||||||
|
quantumPropsByGroup[detail.quantumGroupID] = new();
|
||||||
|
}
|
||||||
|
quantumPropsByGroup[detail.quantumGroupID].Add((DetailBuilder.GetSpawnedGameObjectByDetailInfo(detail), detail));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MakeQuantumGroup(BaseQuantumGroupInfo[] group)
|
||||||
|
{
|
||||||
|
foreach (var quantumGroup in group)
|
||||||
|
{
|
||||||
|
if (!quantumPropsByGroup.ContainsKey(quantumGroup.id)) continue;
|
||||||
|
var propsInGroup = quantumPropsByGroup[quantumGroup.id];
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QuantumBuilder.Make(go, sector, quantumGroup, propsInGroup.ToArray());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
NHLogger.LogError($"Couldn't make quantum group [{quantumGroup.id}] for [{go.name}]:\n{ex}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.Props.socketQuantumGroups != null)
|
||||||
|
{
|
||||||
|
MakeQuantumGroup(config.Props.socketQuantumGroups);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.Props.stateQuantumGroups != null)
|
||||||
|
{
|
||||||
|
MakeQuantumGroup(config.Props.stateQuantumGroups);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.Props.lightningQuantumGroups != null)
|
||||||
|
{
|
||||||
|
MakeQuantumGroup(config.Props.lightningQuantumGroups);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Make(GameObject planetGO, Sector sector, BaseQuantumGroupInfo quantumGroup, (GameObject go, DetailInfo detail)[] propsInGroup)
|
||||||
{
|
{
|
||||||
if (quantumGroup is SocketQuantumGroupInfo socketGroup)
|
if (quantumGroup is SocketQuantumGroupInfo socketGroup)
|
||||||
{
|
{
|
||||||
MakeSocketGroup(planetGO, sector, socketGroup, propsInGroup);
|
MakeSocketGroup(planetGO, sector, socketGroup, propsInGroup.Select(x => x.go).ToArray());
|
||||||
}
|
}
|
||||||
else if (quantumGroup is StateQuantumGroupInfo stateGroup)
|
else if (quantumGroup is StateQuantumGroupInfo stateGroup)
|
||||||
{
|
{
|
||||||
MakeStateGroup(planetGO, sector, stateGroup, propsInGroup);
|
MakeStateGroup(planetGO, sector, stateGroup, propsInGroup.Select(x => x.go).ToArray());
|
||||||
|
}
|
||||||
|
else if (quantumGroup is LightningQuantumGroupInfo lightningGroup)
|
||||||
|
{
|
||||||
|
MakeQuantumLightning(planetGO, sector, lightningGroup, propsInGroup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
public static void MakeQuantumLightning(GameObject planetGO, Sector sector, LightningQuantumGroupInfo quantumGroup, (GameObject go, DetailInfo detail)[] propsInGroup)
|
||||||
public static void MakeQuantumLightning(GameObject planetGO, Sector sector, GameObject[] propsInGroup)
|
|
||||||
{
|
{
|
||||||
|
// Bases its position off the first object with position set
|
||||||
|
var root = propsInGroup.FirstOrDefault(x => x.detail.position != null || x.detail.rotation != null || x.detail.isRelativeToParent);
|
||||||
|
|
||||||
|
var rootGo = root == default ? sector.gameObject : root.go;
|
||||||
|
|
||||||
var lightning = DetailBuilder.Make(planetGO, sector, Main.Instance, AssetBundleUtilities.EyeLightning.LoadAsset<GameObject>("Prefab_EYE_QuantumLightningObject"), new DetailInfo());
|
var lightning = DetailBuilder.Make(planetGO, sector, Main.Instance, AssetBundleUtilities.EyeLightning.LoadAsset<GameObject>("Prefab_EYE_QuantumLightningObject"), new DetailInfo());
|
||||||
lightning.transform.position = prop.transform.position;
|
lightning.transform.position = rootGo.transform.position;
|
||||||
lightning.transform.rotation = prop.transform.rotation;
|
lightning.transform.rotation = rootGo.transform.rotation;
|
||||||
lightning.transform.parent = prop.transform.parent;
|
lightning.transform.parent = rootGo.transform.parent;
|
||||||
|
|
||||||
var lightningStatesParent = lightning.transform.Find("Models");
|
var lightningStatesParent = lightning.transform.Find("Models");
|
||||||
prop.transform.parent = lightningStatesParent;
|
foreach (var (go, _) in propsInGroup)
|
||||||
|
{
|
||||||
|
go.transform.parent = lightningStatesParent;
|
||||||
|
go.transform.localPosition = Vector3.zero;
|
||||||
|
go.transform.localRotation = Quaternion.identity;
|
||||||
|
}
|
||||||
|
|
||||||
var lightningController = lightning.GetComponent<QuantumLightningObject>();
|
var lightningController = lightning.GetComponent<QuantumLightningObject>();
|
||||||
lightningController._models = new GameObject[] { prop };
|
lightningController._models = propsInGroup.Select(x => x.go).ToArray();
|
||||||
lightningController.enabled = true;
|
lightningController.enabled = true;
|
||||||
|
|
||||||
|
lightning.name = "Quantum Lightning - " + quantumGroup.id;
|
||||||
|
lightning.SetActive(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)
|
||||||
|
|||||||
2
NewHorizons/External/Modules/PropModule.cs
vendored
2
NewHorizons/External/Modules/PropModule.cs
vendored
@ -122,6 +122,8 @@ namespace NewHorizons.External.Modules
|
|||||||
|
|
||||||
public StateQuantumGroupInfo[] stateQuantumGroups;
|
public StateQuantumGroupInfo[] stateQuantumGroups;
|
||||||
|
|
||||||
|
public LightningQuantumGroupInfo[] lightningQuantumGroups;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add campfires that allow you to enter the dream world/simulation (requires Echoes of the Eye DLC). Must be paired with a dream arrival point, which can be placed on this planet or elsewhere.
|
/// Add campfires that allow you to enter the dream world/simulation (requires Echoes of the Eye DLC). Must be paired with a dream arrival point, which can be placed on this planet or elsewhere.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
14
NewHorizons/External/Modules/Props/Quantum/LightningQuantumGroupInfo.cs
vendored
Normal file
14
NewHorizons/External/Modules/Props/Quantum/LightningQuantumGroupInfo.cs
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace NewHorizons.External.Modules.Props.Quantum;
|
||||||
|
|
||||||
|
[JsonObject]
|
||||||
|
public class LightningQuantumGroupInfo : BaseQuantumGroupInfo
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user