mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Not gonna use detail builder
This commit is contained in:
parent
ec9fe20c7c
commit
f283a8b2c8
@ -47,12 +47,12 @@ namespace NewHorizons.Builder.Props
|
|||||||
{
|
{
|
||||||
Logger.LogWarning($"Pairing missed for {dimensionName}");
|
Logger.LogWarning($"Pairing missed for {dimensionName}");
|
||||||
if (!_unpairedNodes.ContainsKey(dimensionName)) return;
|
if (!_unpairedNodes.ContainsKey(dimensionName)) return;
|
||||||
|
|
||||||
Logger.LogWarning("proceeding");
|
Logger.LogWarning("proceeding");
|
||||||
foreach (var nodeWarpController in _unpairedNodes[dimensionName])
|
foreach (var nodeWarpController in _unpairedNodes[dimensionName])
|
||||||
{
|
{
|
||||||
Logger.LogWarning($"Pairing node {nodeWarpController.gameObject.name} links to {dimensionName}");
|
Logger.LogWarning($"Pairing node {nodeWarpController.gameObject.name} links to {dimensionName}");
|
||||||
PairEntrance(nodeWarpController, dimensionName, dimensionAO);
|
PairEntrance(nodeWarpController, dimensionName, dimensionAO);
|
||||||
}
|
}
|
||||||
|
|
||||||
_unpairedNodes.Remove(dimensionName);
|
_unpairedNodes.Remove(dimensionName);
|
||||||
@ -61,7 +61,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
private static void RecordUnpairedNode(InnerFogWarpVolume warpVolume, string linksTo)
|
private static void RecordUnpairedNode(InnerFogWarpVolume warpVolume, string linksTo)
|
||||||
{
|
{
|
||||||
if (!_unpairedNodes.ContainsKey(linksTo)) _unpairedNodes[linksTo] = new();
|
if (!_unpairedNodes.ContainsKey(linksTo)) _unpairedNodes[linksTo] = new();
|
||||||
|
|
||||||
Logger.LogWarning($"Recording node {warpVolume.gameObject.name} links to {linksTo}");
|
Logger.LogWarning($"Recording node {warpVolume.gameObject.name} links to {linksTo}");
|
||||||
|
|
||||||
_unpairedNodes[linksTo].Add(warpVolume);
|
_unpairedNodes[linksTo].Add(warpVolume);
|
||||||
@ -81,7 +81,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
// The purpose of this function is to determine which signals any given node should play, based on which dimension it links to
|
// The purpose of this function is to determine which signals any given node should play, based on which dimension it links to
|
||||||
// you know how the main dark bramble node, the one that forms the core of the planet, plays Feldspar's harmonica signal, even though Feldspar isn't in the dimension that the node links directly to?
|
// you know how the main dark bramble node, the one that forms the core of the planet, plays Feldspar's harmonica signal, even though Feldspar isn't in the dimension that the node links directly to?
|
||||||
// that's what this function is for. it would determine that the main node should play Feldspar's signal
|
// that's what this function is for. it would determine that the main node should play Feldspar's signal
|
||||||
|
|
||||||
// New Strategy (thanks Damian):
|
// New Strategy (thanks Damian):
|
||||||
// 1) Run Floyd-Warshall on the dimensions (where each dimension is a vertex and each node is an edge)
|
// 1) Run Floyd-Warshall on the dimensions (where each dimension is a vertex and each node is an edge)
|
||||||
// 2) For each dimension A, if it's possible to reach dimension B, add dimension B's signals to the list propogatedSignals[A]
|
// 2) For each dimension A, if it's possible to reach dimension B, add dimension B's signals to the list propogatedSignals[A]
|
||||||
@ -97,18 +97,18 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
var dimensionNameToIndex = new Dictionary<string, int>();
|
var dimensionNameToIndex = new Dictionary<string, int>();
|
||||||
for (int dimensionIndex = 0; dimensionIndex < allDimensions.Count(); dimensionIndex++) dimensionNameToIndex[allDimensions[dimensionIndex].name] = dimensionIndex;
|
for (int dimensionIndex = 0; dimensionIndex < allDimensions.Count(); dimensionIndex++) dimensionNameToIndex[allDimensions[dimensionIndex].name] = dimensionIndex;
|
||||||
|
|
||||||
// set up the direct links (ie, if dimension 0 contains a node that links to dimension 3, set access[0, 3] = true)
|
// set up the direct links (ie, if dimension 0 contains a node that links to dimension 3, set access[0, 3] = true)
|
||||||
for (int dimensionIndex = 0; dimensionIndex < allDimensions.Count(); dimensionIndex++)
|
for (int dimensionIndex = 0; dimensionIndex < allDimensions.Count(); dimensionIndex++)
|
||||||
{
|
{
|
||||||
var dimension = allDimensions[dimensionIndex];
|
var dimension = allDimensions[dimensionIndex];
|
||||||
if (dimension.Bramble.nodes == null) continue;
|
if (dimension.Bramble.nodes == null) continue;
|
||||||
foreach (var node in dimension.Bramble.nodes)
|
foreach (var node in dimension.Bramble.nodes)
|
||||||
{
|
{
|
||||||
var destinationDimensionIndex = dimensionNameToIndex[node.linksTo];
|
var destinationDimensionIndex = dimensionNameToIndex[node.linksTo];
|
||||||
access[dimensionIndex, destinationDimensionIndex] = true;
|
access[dimensionIndex, destinationDimensionIndex] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// a node that links to dimension A should display all of dimension A's signals, so for the purposes of our function, we need to say that dimension A links to dimension A
|
// a node that links to dimension A should display all of dimension A's signals, so for the purposes of our function, we need to say that dimension A links to dimension A
|
||||||
for (int dimensionIndex = 0; dimensionIndex < allDimensions.Count(); dimensionIndex++) access[dimensionIndex, dimensionIndex] = true;
|
for (int dimensionIndex = 0; dimensionIndex < allDimensions.Count(); dimensionIndex++) access[dimensionIndex, dimensionIndex] = true;
|
||||||
@ -117,7 +117,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
for (int k = 0; k < allDimensions.Count(); k++)
|
for (int k = 0; k < allDimensions.Count(); k++)
|
||||||
for (int i = 0; i < allDimensions.Count(); i++)
|
for (int i = 0; i < allDimensions.Count(); i++)
|
||||||
for (int j = 0; j < allDimensions.Count(); j++)
|
for (int j = 0; j < allDimensions.Count(); j++)
|
||||||
if (access[i, k] && access[k, j])
|
if (access[i, k] && access[k, j])
|
||||||
access[i, j] = true;
|
access[i, j] = true;
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -131,7 +131,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
{
|
{
|
||||||
_propogatedSignals[dimension.name] = new();
|
_propogatedSignals[dimension.name] = new();
|
||||||
var dimensionIndex = dimensionNameToIndex[dimension.name];
|
var dimensionIndex = dimensionNameToIndex[dimension.name];
|
||||||
|
|
||||||
foreach (var destinationDimension in allDimensions)
|
foreach (var destinationDimension in allDimensions)
|
||||||
{
|
{
|
||||||
if (destinationDimension.Signal?.signals == null) continue;
|
if (destinationDimension.Signal?.signals == null) continue;
|
||||||
@ -146,7 +146,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static bool PairEntrance(InnerFogWarpVolume nodeWarp, string destinationName, AstroObject dimensionAO = null)
|
private static bool PairEntrance(InnerFogWarpVolume nodeWarp, string destinationName, AstroObject dimensionAO = null)
|
||||||
{
|
{
|
||||||
Logger.LogWarning($"Pairing node {nodeWarp.gameObject.name} to {destinationName}");
|
Logger.LogWarning($"Pairing node {nodeWarp.gameObject.name} to {destinationName}");
|
||||||
|
|
||||||
var destinationAO = dimensionAO ?? AstroObjectLocator.GetAstroObject(destinationName); // find child "Sector/OuterWarp"
|
var destinationAO = dimensionAO ?? AstroObjectLocator.GetAstroObject(destinationName); // find child "Sector/OuterWarp"
|
||||||
@ -157,7 +157,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
// link the node's warp volume to the destination's
|
// link the node's warp volume to the destination's
|
||||||
var destination = GetOuterFogWarpVolumeFromAstroObject(destinationAO.gameObject);
|
var destination = GetOuterFogWarpVolumeFromAstroObject(destinationAO.gameObject);
|
||||||
if (destination == null) return false;
|
if (destination == null) return false;
|
||||||
|
|
||||||
Logger.LogWarning($"Proceeding with pairing node {nodeWarp.gameObject.name} to {destinationName}. Path to outer fog warp volume: {destination.transform.GetPath()}");
|
Logger.LogWarning($"Proceeding with pairing node {nodeWarp.gameObject.name} to {destinationName}. Path to outer fog warp volume: {destination.transform.GetPath()}");
|
||||||
|
|
||||||
nodeWarp._linkedOuterWarpVolume = destination;
|
nodeWarp._linkedOuterWarpVolume = destination;
|
||||||
@ -175,7 +175,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
public static void Make(GameObject go, Sector sector, BrambleNodeInfo[] configs, IModBehaviour mod)
|
public static void Make(GameObject go, Sector sector, BrambleNodeInfo[] configs, IModBehaviour mod)
|
||||||
{
|
{
|
||||||
foreach(var config in configs)
|
foreach (var config in configs)
|
||||||
{
|
{
|
||||||
Make(go, sector, config, mod);
|
Make(go, sector, config, mod);
|
||||||
}
|
}
|
||||||
@ -183,49 +183,43 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
public static GameObject Make(GameObject go, Sector sector, BrambleNodeInfo config, IModBehaviour mod)
|
public static GameObject Make(GameObject go, Sector sector, BrambleNodeInfo config, IModBehaviour mod)
|
||||||
{
|
{
|
||||||
//
|
// Spawn the bramble node
|
||||||
// spawn the bramble node
|
|
||||||
//
|
|
||||||
|
|
||||||
var brambleSeedPrefabPath = "DB_PioneerDimension_Body/Sector_PioneerDimension/Interactables_PioneerDimension/SeedWarp_ToPioneer (1)";
|
var brambleSeedPrefabPath = "DB_PioneerDimension_Body/Sector_PioneerDimension/Interactables_PioneerDimension/SeedWarp_ToPioneer (1)";
|
||||||
var brambleNodePrefabPath = "DB_HubDimension_Body/Sector_HubDimension/Interactables_HubDimension/InnerWarp_ToCluster";
|
var brambleNodePrefabPath = "DB_HubDimension_Body/Sector_HubDimension/Interactables_HubDimension/InnerWarp_ToCluster";
|
||||||
|
|
||||||
var path = config.isSeed ? brambleSeedPrefabPath : brambleNodePrefabPath;
|
var path = config.isSeed ? brambleSeedPrefabPath : brambleNodePrefabPath;
|
||||||
var brambleNode = DetailBuilder.MakeDetail(go, sector, path, config.position, config.rotation, 1, false, leaveInactive:true);
|
var brambleNode = SearchUtilities.Find(path).InstantiateInactive();
|
||||||
brambleNode.name = "Bramble Node to " + config.linksTo;
|
brambleNode.transform.parent = sector.transform;
|
||||||
|
brambleNode.transform.position = go.transform.TransformPoint(config.position);
|
||||||
|
brambleNode.transform.rotation = go.transform.TransformRotation(Quaternion.Euler(config.rotation));
|
||||||
|
brambleNode.name = "Bramble Node to " + config.linksTo;
|
||||||
var warpController = brambleNode.GetComponent<InnerFogWarpVolume>();
|
var warpController = brambleNode.GetComponent<InnerFogWarpVolume>();
|
||||||
|
|
||||||
// this node comes with Feldspar's signal, we don't want that though
|
// This node comes with Feldspar's signal, we don't want that though
|
||||||
GameObject.Destroy(brambleNode.FindChild("Signal_Harmonica"));
|
GameObject.Destroy(brambleNode.FindChild("Signal_Harmonica"));
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Fix some components
|
// Fix some components
|
||||||
//
|
|
||||||
|
|
||||||
var fogLight = brambleNode.GetComponent<FogLight>();
|
var fogLight = brambleNode.GetComponent<FogLight>();
|
||||||
fogLight._parentBody = go.GetComponent<OWRigidbody>();
|
fogLight._parentBody = go.GetComponent<OWRigidbody>();
|
||||||
fogLight._sector = sector;
|
fogLight._sector = sector;
|
||||||
fogLight._linkedFogLights.Clear();
|
fogLight._linkedFogLights.Clear();
|
||||||
fogLight._linkedLightData.Clear();
|
fogLight._linkedLightData.Clear();
|
||||||
fogLight._linkedSector = null;
|
fogLight._linkedSector = null;
|
||||||
|
|
||||||
sector.RegisterFogLight(fogLight);
|
sector.RegisterFogLight(fogLight);
|
||||||
|
|
||||||
//
|
|
||||||
// Set the scale
|
// Set the scale
|
||||||
//
|
|
||||||
brambleNode.transform.localScale = Vector3.one * config.scale;
|
brambleNode.transform.localScale = Vector3.one * config.scale;
|
||||||
warpController._warpRadius *= config.scale;
|
warpController._warpRadius *= config.scale;
|
||||||
warpController._exitRadius *= config.scale;
|
warpController._exitRadius *= config.scale;
|
||||||
|
|
||||||
// seed fog works differently, so it doesn't need to be fixed (it's also located on a different child path, so the below FindChild calls wouldn't work)
|
// Seed fog works differently, so it doesn't need to be fixed (it's also located on a different child path, so the below FindChild calls wouldn't work)
|
||||||
if (!config.isSeed)
|
if (!config.isSeed)
|
||||||
{
|
{
|
||||||
var fog = brambleNode.FindChild("Effects").FindChild("InnerWarpFogSphere");
|
var fog = brambleNode.FindChild("Effects").FindChild("InnerWarpFogSphere");
|
||||||
var fogMaterial = fog.GetComponent<MeshRenderer>().sharedMaterial;
|
var fogMaterial = fog.GetComponent<MeshRenderer>().sharedMaterial;
|
||||||
fog.transform.localScale /= config.scale;
|
fog.transform.localScale /= config.scale;
|
||||||
fogMaterial.SetFloat("_Radius", fogMaterial.GetFloat("_Radius") * config.scale);
|
fogMaterial.SetFloat("_Radius", fogMaterial.GetFloat("_Radius") * config.scale);
|
||||||
fogMaterial.SetFloat("_Density", fogMaterial.GetFloat("_Density") / config.scale);
|
fogMaterial.SetFloat("_Density", fogMaterial.GetFloat("_Density") / config.scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,45 +231,32 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
// found under FogWarpDetector.FixedUpdate()
|
// found under FogWarpDetector.FixedUpdate()
|
||||||
// FogWarpVolume fogWarpVolume = _warpVolumes[i];
|
// FogWarpVolume fogWarpVolume = _warpVolumes[i];
|
||||||
// float num2 = Mathf.Abs(fogWarpVolume.CheckWarpProximity(this));
|
// float num2 = Mathf.Abs(fogWarpVolume.CheckWarpProximity(this));
|
||||||
// float b = Mathf.Clamp01(1f - Mathf.Abs(num2) / fogWarpVolume.GetFogThickness());
|
// float b = Mathf.Clamp01(1f - Mathf.Abs(num2) / fogWarpVolume.GetFogThickness());
|
||||||
// _targetFogFraction = Mathf.Max(_targetFogFraction, b);
|
// _targetFogFraction = Mathf.Max(_targetFogFraction, b);
|
||||||
|
|
||||||
// this means that either CheckWarpProximity() or GetFogThickness() is incorrect for the InnerWarpFogSpheres.
|
// this means that either CheckWarpProximity() or GetFogThickness() is incorrect for the InnerWarpFogSpheres.
|
||||||
// most likely it's CheckWarpProximity()
|
// most likely it's CheckWarpProximity()
|
||||||
|
|
||||||
|
// Change the colors
|
||||||
//
|
|
||||||
// change the colors
|
|
||||||
//
|
|
||||||
|
|
||||||
if (config.isSeed) SetSeedColors(brambleNode, config.fogTint?.ToColor(), config.lightTint?.ToColor());
|
if (config.isSeed) SetSeedColors(brambleNode, config.fogTint?.ToColor(), config.lightTint?.ToColor());
|
||||||
else SetNodeColors(brambleNode, config.fogTint?.ToColor(), config.lightTint?.ToColor());
|
else SetNodeColors(brambleNode, config.fogTint?.ToColor(), config.lightTint?.ToColor());
|
||||||
|
|
||||||
//
|
|
||||||
// set up warps
|
|
||||||
//
|
|
||||||
|
|
||||||
|
// Set up warps
|
||||||
warpController._sector = sector;
|
warpController._sector = sector;
|
||||||
warpController._attachedBody = go.GetComponent<OWRigidbody>(); // I don't think this is necessary, it seems to be set correctly on its own
|
warpController._attachedBody = go.GetComponent<OWRigidbody>(); // I don't think this is necessary, it seems to be set correctly on its own
|
||||||
warpController._containerWarpVolume = GetOuterFogWarpVolumeFromAstroObject(go); // the OuterFogWarpVolume of the dimension this node is inside of (null if this node is not inside of a bramble dimension (eg it's sitting on a planet or something))
|
warpController._containerWarpVolume = GetOuterFogWarpVolumeFromAstroObject(go); // the OuterFogWarpVolume of the dimension this node is inside of (null if this node is not inside of a bramble dimension (eg it's sitting on a planet or something))
|
||||||
var success = PairEntrance(warpController, config.linksTo);
|
var success = PairEntrance(warpController, config.linksTo);
|
||||||
if (!success) RecordUnpairedNode(warpController, config.linksTo);
|
if (!success) RecordUnpairedNode(warpController, config.linksTo);
|
||||||
|
|
||||||
warpController.Awake(); // I can't spawn this game object disabled, but Awake needs to run after _sector is set. That means I need to call Awake myself
|
|
||||||
|
|
||||||
//
|
|
||||||
// Cleanup for dimension exits
|
// Cleanup for dimension exits
|
||||||
//
|
|
||||||
if (config.name != null)
|
if (config.name != null)
|
||||||
{
|
{
|
||||||
NamedNodes[config.name] = warpController;
|
NamedNodes[config.name] = warpController;
|
||||||
BrambleDimensionBuilder.FinishPairingDimensionsForExitNode(config.name);
|
BrambleDimensionBuilder.FinishPairingDimensionsForExitNode(config.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Make signals
|
// Make signals
|
||||||
//
|
|
||||||
if (_propogatedSignals == null) PropogateSignals();
|
if (_propogatedSignals == null) PropogateSignals();
|
||||||
foreach (var signalConfig in _propogatedSignals[config.linksTo])
|
foreach (var signalConfig in _propogatedSignals[config.linksTo])
|
||||||
{
|
{
|
||||||
@ -293,25 +274,25 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
public static void SetNodeColors(GameObject brambleNode, Color? fogTint, Color? lightTint)
|
public static void SetNodeColors(GameObject brambleNode, Color? fogTint, Color? lightTint)
|
||||||
{
|
{
|
||||||
if (fogTint != null)
|
if (fogTint != null)
|
||||||
{
|
{
|
||||||
var fogRenderer = brambleNode.GetComponent<InnerFogWarpVolume>();
|
var fogRenderer = brambleNode.GetComponent<InnerFogWarpVolume>();
|
||||||
|
|
||||||
fogRenderer._fogColor = fogTint.Value;
|
fogRenderer._fogColor = fogTint.Value;
|
||||||
fogRenderer._useFarFogColor = false;
|
fogRenderer._useFarFogColor = false;
|
||||||
|
|
||||||
var fogBackdrop = brambleNode.FindChild("Terrain_DB_BrambleSphere_Inner_v2")?.FindChild("fogbackdrop_v2");
|
var fogBackdrop = brambleNode.FindChild("Terrain_DB_BrambleSphere_Inner_v2")?.FindChild("fogbackdrop_v2");
|
||||||
if (fogBackdrop != null) fogBackdrop.GetComponent<MeshRenderer>().sharedMaterial.color = (Color)fogTint;
|
if (fogBackdrop != null) fogBackdrop.GetComponent<MeshRenderer>().sharedMaterial.color = (Color)fogTint;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lightTint != null)
|
if (lightTint != null)
|
||||||
{
|
{
|
||||||
var lightShafts = brambleNode.FindChild("Effects/DB_BrambleLightShafts");
|
var lightShafts = brambleNode.FindChild("Effects/DB_BrambleLightShafts");
|
||||||
|
|
||||||
var lightShaft1 = lightShafts.FindChild("BrambleLightShaft1");
|
var lightShaft1 = lightShafts.FindChild("BrambleLightShaft1");
|
||||||
var mat = lightShaft1.GetComponent<MeshRenderer>().material;
|
var mat = lightShaft1.GetComponent<MeshRenderer>().material;
|
||||||
mat.color = lightTint.Value;
|
mat.color = lightTint.Value;
|
||||||
|
|
||||||
for (int i = 1; i <= 6; i++)
|
for (int i = 1; i <= 6; i++)
|
||||||
{
|
{
|
||||||
var lightShaft = lightShafts.FindChild($"BrambleLightShaft{i}");
|
var lightShaft = lightShafts.FindChild($"BrambleLightShaft{i}");
|
||||||
@ -322,24 +303,24 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
public static void SetSeedColors(GameObject brambleSeed, Color? fogTint, Color? lightTint)
|
public static void SetSeedColors(GameObject brambleSeed, Color? fogTint, Color? lightTint)
|
||||||
{
|
{
|
||||||
if (fogTint != null)
|
if (fogTint != null)
|
||||||
{
|
{
|
||||||
var fogRenderer = brambleSeed.FindChild("VolumetricFogSphere (2)");
|
var fogRenderer = brambleSeed.FindChild("VolumetricFogSphere (2)");
|
||||||
|
|
||||||
var fogMeshRenderer = fogRenderer.GetComponent<MeshRenderer>();
|
var fogMeshRenderer = fogRenderer.GetComponent<MeshRenderer>();
|
||||||
var mat = fogMeshRenderer.material;
|
var mat = fogMeshRenderer.material;
|
||||||
mat.color = fogTint.Value;
|
mat.color = fogTint.Value;
|
||||||
fogMeshRenderer.sharedMaterial = mat;
|
fogMeshRenderer.sharedMaterial = mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lightTint != null)
|
if (lightTint != null)
|
||||||
{
|
{
|
||||||
var lightShafts = brambleSeed.FindChild("Terrain_DB_BrambleSphere_Seed_V2 (2)/DB_SeedLightShafts");
|
var lightShafts = brambleSeed.FindChild("Terrain_DB_BrambleSphere_Seed_V2 (2)/DB_SeedLightShafts");
|
||||||
|
|
||||||
var lightShaft1 = lightShafts.FindChild("DB_SeedLightShafts1");
|
var lightShaft1 = lightShafts.FindChild("DB_SeedLightShafts1");
|
||||||
var mat = lightShaft1.GetComponent<MeshRenderer>().material;
|
var mat = lightShaft1.GetComponent<MeshRenderer>().material;
|
||||||
mat.color = lightTint.Value;
|
mat.color = lightTint.Value;
|
||||||
|
|
||||||
for (int i = 1; i <= 6; i++)
|
for (int i = 1; i <= 6; i++)
|
||||||
{
|
{
|
||||||
var lightShaft = lightShafts.FindChild($"DB_SeedLightShafts{i}");
|
var lightShaft = lightShafts.FindChild($"DB_SeedLightShafts{i}");
|
||||||
|
|||||||
@ -94,14 +94,14 @@ namespace NewHorizons.Builder.Props
|
|||||||
detailInfoToCorrespondingSpawnedGameObject[detail] = detailGO;
|
detailInfoToCorrespondingSpawnedGameObject[detail] = detailGO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameObject MakeDetail(GameObject go, Sector sector, string propToClone, MVector3 position, MVector3 rotation, float scale, bool alignWithNormal, bool leaveInactive=false)
|
public static GameObject MakeDetail(GameObject go, Sector sector, string propToClone, MVector3 position, MVector3 rotation, float scale, bool alignWithNormal)
|
||||||
{
|
{
|
||||||
var prefab = SearchUtilities.Find(propToClone);
|
var prefab = SearchUtilities.Find(propToClone);
|
||||||
if (prefab == null) Logger.LogError($"Couldn't find detail {propToClone}");
|
if (prefab == null) Logger.LogError($"Couldn't find detail {propToClone}");
|
||||||
return MakeDetail(go, sector, prefab, position, rotation, scale, alignWithNormal, leaveInactive);
|
return MakeDetail(go, sector, prefab, position, rotation, scale, alignWithNormal);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameObject MakeDetail(GameObject planetGO, Sector sector, GameObject prefab, MVector3 position, MVector3 rotation, float scale, bool alignWithNormal, bool leaveInactive=false)
|
public static GameObject MakeDetail(GameObject planetGO, Sector sector, GameObject prefab, MVector3 position, MVector3 rotation, float scale, bool alignWithNormal)
|
||||||
{
|
{
|
||||||
if (prefab == null) return null;
|
if (prefab == null) return null;
|
||||||
|
|
||||||
@ -271,7 +271,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
prop.transform.localScale = scale != 0 ? Vector3.one * scale : prefab.transform.localScale;
|
prop.transform.localScale = scale != 0 ? Vector3.one * scale : prefab.transform.localScale;
|
||||||
|
|
||||||
if (!leaveInactive) prop.SetActive(true);
|
prop.SetActive(true);
|
||||||
|
|
||||||
return prop;
|
return prop;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -388,8 +388,15 @@ namespace NewHorizons.Handlers
|
|||||||
|
|
||||||
body.Object = go;
|
body.Object = go;
|
||||||
|
|
||||||
// Now that we're done move the planet into place
|
// Now that we're done move the planet into place
|
||||||
UpdatePosition(go, body.Config.Orbit, primaryBody, ao);
|
if (body.Config.Orbit?.staticPosition != null)
|
||||||
|
{
|
||||||
|
SetPositionFromVector(go, body.Config.Orbit.staticPosition);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UpdatePosition(go, body.Config.Orbit, primaryBody, ao);
|
||||||
|
}
|
||||||
|
|
||||||
// Have to do this after setting position
|
// Have to do this after setting position
|
||||||
var initialMotion = InitialMotionBuilder.Make(go, primaryBody, ao, owRigidBody, body.Config.Orbit);
|
var initialMotion = InitialMotionBuilder.Make(go, primaryBody, ao, owRigidBody, body.Config.Orbit);
|
||||||
@ -410,11 +417,6 @@ namespace NewHorizons.Handlers
|
|||||||
{
|
{
|
||||||
DetectorBuilder.Make(go, owRigidBody, primaryBody, ao, body.Config);
|
DetectorBuilder.Make(go, owRigidBody, primaryBody, ao, body.Config);
|
||||||
}
|
}
|
||||||
else if (body.Config.Orbit.staticPosition != null)
|
|
||||||
{
|
|
||||||
// NH doesn't set the value of _centerOfTheUniverse for a few frames
|
|
||||||
ao.transform.position = body.Config.Orbit.staticPosition + Locator._centerOfTheUniverse._staticReferenceFrame._lastPosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ao.GetAstroObjectName() == AstroObject.Name.CustomString)
|
if (ao.GetAstroObjectName() == AstroObject.Name.CustomString)
|
||||||
{
|
{
|
||||||
@ -687,24 +689,29 @@ namespace NewHorizons.Handlers
|
|||||||
{
|
{
|
||||||
Logger.LogVerbose($"Placing [{secondaryBody?.name}] around [{primaryBody?.name}]");
|
Logger.LogVerbose($"Placing [{secondaryBody?.name}] around [{primaryBody?.name}]");
|
||||||
|
|
||||||
go.transform.parent = Locator.GetRootTransform();
|
|
||||||
|
|
||||||
if (primaryBody != null)
|
if (primaryBody != null)
|
||||||
{
|
{
|
||||||
var primaryGravity = new Gravity(primaryBody.GetGravityVolume());
|
var primaryGravity = new Gravity(primaryBody.GetGravityVolume());
|
||||||
var secondaryGravity = new Gravity(secondaryBody.GetGravityVolume());
|
var secondaryGravity = new Gravity(secondaryBody.GetGravityVolume());
|
||||||
|
|
||||||
go.transform.position = orbit.GetOrbitalParameters(primaryGravity, secondaryGravity).InitialPosition + primaryBody.transform.position;
|
var pos = orbit.GetOrbitalParameters(primaryGravity, secondaryGravity).InitialPosition + primaryBody.transform.position;
|
||||||
|
SetPositionFromVector(go, pos);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
go.transform.position = Vector3.zero;
|
SetPositionFromVector(go, Vector3.zero);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetPositionFromVector(GameObject go, Vector3 position)
|
||||||
|
{
|
||||||
|
go.transform.parent = Locator.GetRootTransform();
|
||||||
|
go.transform.position = position;
|
||||||
|
|
||||||
if (go.transform.position.magnitude > Main.FurthestOrbit)
|
if (go.transform.position.magnitude > Main.FurthestOrbit)
|
||||||
{
|
{
|
||||||
Main.FurthestOrbit = go.transform.position.magnitude + 30000f;
|
Main.FurthestOrbit = go.transform.position.magnitude + 30000f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user