mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Scatter parenting and fixes for tidally locked bodies (#872)
## Minor features - Added `parentPath` to scatter. This parent should be at the position where you'd like to scatter (which would usually be zero). ## Bug fixes - Fix scatter not working properly on tidally locked bodies
This commit is contained in:
commit
fe896a5bc2
@ -47,17 +47,6 @@ namespace NewHorizons.Builder.Props
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (config.Props.scatter != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ScatterBuilder.Make(go, sector, config, mod);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
NHLogger.LogError($"Couldn't make planet scatter for [{go.name}]:\n{ex}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (config.Props.details != null)
|
if (config.Props.details != null)
|
||||||
{
|
{
|
||||||
foreach (var detail in config.Props.details)
|
foreach (var detail in config.Props.details)
|
||||||
@ -72,6 +61,17 @@ namespace NewHorizons.Builder.Props
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (config.Props.scatter != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ScatterBuilder.Make(go, sector, config, mod);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
NHLogger.LogError($"Couldn't make planet scatter for [{go.name}]:\n{ex}");
|
||||||
|
}
|
||||||
|
}
|
||||||
if (config.Props.geysers != null)
|
if (config.Props.geysers != null)
|
||||||
{
|
{
|
||||||
foreach (var geyserInfo in config.Props.geysers)
|
foreach (var geyserInfo in config.Props.geysers)
|
||||||
|
|||||||
@ -3,6 +3,7 @@ using NewHorizons.External.Modules.Props;
|
|||||||
using NewHorizons.Utility;
|
using NewHorizons.Utility;
|
||||||
using NewHorizons.Utility.Files;
|
using NewHorizons.Utility.Files;
|
||||||
using NewHorizons.Utility.Geometry;
|
using NewHorizons.Utility.Geometry;
|
||||||
|
using NewHorizons.Utility.OWML;
|
||||||
using OWML.Common;
|
using OWML.Common;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -120,10 +121,28 @@ namespace NewHorizons.Builder.Props
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var parent = sector?.transform ?? go.transform;
|
||||||
|
|
||||||
|
if (go != null && !string.IsNullOrEmpty(propInfo.parentPath))
|
||||||
|
{
|
||||||
|
var newParent = go.transform.Find(propInfo.parentPath);
|
||||||
|
if (newParent != null)
|
||||||
|
{
|
||||||
|
parent = newParent;
|
||||||
|
sector = newParent.GetComponentInParent<Sector>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NHLogger.LogError($"Cannot find parent object at path: {go.name}/{propInfo.parentPath}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var prop = scatterPrefab.InstantiateInactive();
|
var prop = scatterPrefab.InstantiateInactive();
|
||||||
prop.transform.SetParent(sector?.transform ?? go.transform);
|
// Have to use SetParent method to work with tidally locked bodies #872
|
||||||
prop.transform.localPosition = go.transform.TransformPoint(point * height);
|
prop.transform.SetParent(parent, false);
|
||||||
var up = go.transform.InverseTransformPoint(prop.transform.position).normalized;
|
prop.transform.localPosition = point * height;
|
||||||
|
var up = (prop.transform.position - go.transform.position).normalized;
|
||||||
prop.transform.rotation = Quaternion.FromToRotation(Vector3.up, up);
|
prop.transform.rotation = Quaternion.FromToRotation(Vector3.up, up);
|
||||||
|
|
||||||
if (propInfo.offset != null) prop.transform.localPosition += prop.transform.TransformVector(propInfo.offset);
|
if (propInfo.offset != null) prop.transform.localPosition += prop.transform.TransformVector(propInfo.offset);
|
||||||
|
|||||||
@ -66,5 +66,10 @@ namespace NewHorizons.External.Modules.Props
|
|||||||
/// Should this detail stay loaded even if you're outside the sector (good for very large props)
|
/// Should this detail stay loaded even if you're outside the sector (good for very large props)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool keepLoaded;
|
public bool keepLoaded;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The relative path from the planet to the parent of this object. Optional (will default to the root sector). This parent should be at the position where you'd like to scatter (which would usually be zero).
|
||||||
|
/// </summary>
|
||||||
|
public string parentPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2046,6 +2046,10 @@
|
|||||||
"keepLoaded": {
|
"keepLoaded": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Should this detail stay loaded even if you're outside the sector (good for very large props)"
|
"description": "Should this detail stay loaded even if you're outside the sector (good for very large props)"
|
||||||
|
},
|
||||||
|
"parentPath": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The relative path from the planet to the parent of this object. Optional (will default to the root sector). This parent should be at the position where you'd like to scatter (which would usually be zero)."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user