Add optional parent path to nomai text info

This commit is contained in:
Noah Pilarski 2022-07-26 11:45:19 -04:00
parent 6e1480cbc4
commit e0269d05cb
2 changed files with 40 additions and 1 deletions

View File

@ -111,6 +111,12 @@ namespace NewHorizons.Builder.Props
var nomaiWallTextObj = MakeWallText(planetGO, sector, info, xmlPath).gameObject;
nomaiWallTextObj.transform.parent = sector?.transform ?? planetGO.transform;
if (!string.IsNullOrEmpty(info.parentPath))
{
nomaiWallTextObj.transform.parent = planetGO.transform.Find(info.parentPath);
}
nomaiWallTextObj.transform.position = planetGO.transform.TransformPoint(info.position);
if (info.normal != null)
{
@ -163,6 +169,12 @@ namespace NewHorizons.Builder.Props
// Place scroll
customScroll.transform.parent = sector?.transform ?? planetGO.transform;
if (!string.IsNullOrEmpty(info.parentPath))
{
customScroll.transform.parent = planetGO.transform.Find(info.parentPath);
}
customScroll.transform.position = planetGO.transform.TransformPoint(info.position ?? Vector3.zero);
var up = planetGO.transform.InverseTransformPoint(customScroll.transform.position).normalized;
@ -193,6 +205,12 @@ namespace NewHorizons.Builder.Props
var computerObject = _computerPrefab.InstantiateInactive();
computerObject.transform.parent = sector?.transform ?? planetGO.transform;
if (!string.IsNullOrEmpty(info.parentPath))
{
computerObject.transform.parent = planetGO.transform.Find(info.parentPath);
}
computerObject.transform.position = planetGO.transform.TransformPoint(info?.position ?? Vector3.zero);
var up = computerObject.transform.position - planetGO.transform.position;
@ -220,6 +238,11 @@ namespace NewHorizons.Builder.Props
var computerObject = DetailBuilder.MakeDetail(planetGO, sector, _preCrashComputerPrefab, info.position, Vector3.zero, 1, false);
computerObject.SetActive(false);
if (!string.IsNullOrEmpty(info.parentPath))
{
computerObject.transform.SetParent(planetGO.transform.Find(info.parentPath), true);
}
var up = computerObject.transform.position - planetGO.transform.position;
if (info.normal != null) up = planetGO.transform.TransformDirection(info.normal);
computerObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, up) * computerObject.transform.rotation;
@ -256,6 +279,12 @@ namespace NewHorizons.Builder.Props
var cairnObject = _cairnPrefab.InstantiateInactive();
cairnObject.transform.parent = sector?.transform ?? planetGO.transform;
if (!string.IsNullOrEmpty(info.parentPath))
{
cairnObject.transform.parent = planetGO.transform.Find(info.parentPath);
}
cairnObject.transform.position = planetGO.transform.TransformPoint(info?.position ?? Vector3.zero);
if (info.rotation != null)
@ -303,6 +332,12 @@ namespace NewHorizons.Builder.Props
var recorderObject = (info.type == PropModule.NomaiTextInfo.NomaiTextType.PreCrashRecorder ? _preCrashRecorderPrefab : _recorderPrefab).InstantiateInactive();
recorderObject.transform.parent = sector?.transform ?? planetGO.transform;
if (!string.IsNullOrEmpty(info.parentPath))
{
recorderObject.transform.parent = planetGO.transform.Find(info.parentPath);
}
recorderObject.transform.position = planetGO.transform.TransformPoint(info?.position ?? Vector3.zero);
if (info.rotation != null)
@ -335,7 +370,6 @@ namespace NewHorizons.Builder.Props
default:
Logger.LogError($"Unsupported NomaiText type {info.type}");
return null;
break;
}
}

View File

@ -512,6 +512,11 @@ namespace NewHorizons.External.Modules
/// The relative path to the xml file for this object.
/// </summary>
public string xmlFile;
/// <summary>
/// The relative path from the planet to the parent of this object. Optional (will default to the root sector).
/// </summary>
public string parentPath;
}
[JsonObject]