mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Add removeComponents option to DetailBuilder
This commit is contained in:
parent
07a5f0dade
commit
e9a400cadf
@ -51,6 +51,20 @@ namespace NewHorizons.Builder.Props
|
||||
else Logger.LogWarning($"Couldn't find {childPath}");
|
||||
}
|
||||
}
|
||||
|
||||
if(detailGO != null && detail.removeComponents)
|
||||
{
|
||||
// Just swap all the children to a new game object
|
||||
var newDetailGO = new GameObject(detailGO.name);
|
||||
newDetailGO.transform.position = detailGO.transform.position;
|
||||
newDetailGO.transform.parent = detailGO.transform.parent;
|
||||
foreach(Transform child in detailGO.transform.GetComponentsInChildren<Transform>())
|
||||
{
|
||||
child.parent = newDetailGO.transform;
|
||||
}
|
||||
GameObject.Destroy(detailGO);
|
||||
detailGO = newDetailGO;
|
||||
}
|
||||
}
|
||||
|
||||
public static GameObject MakeDetail(GameObject go, Sector sector, string propToClone, MVector3 position, MVector3 rotation, float scale, bool alignWithNormal)
|
||||
@ -153,12 +167,11 @@ namespace NewHorizons.Builder.Props
|
||||
prop.transform.position = position == null ? planetGO.transform.position : planetGO.transform.TransformPoint((Vector3)position);
|
||||
|
||||
Quaternion rot = rotation == null ? Quaternion.identity : Quaternion.Euler((Vector3)rotation);
|
||||
prop.transform.rotation = planetGO.transform.TransformRotation(Quaternion.identity);
|
||||
if (alignWithNormal)
|
||||
{
|
||||
// Apply the rotation after aligning it with normal
|
||||
var up = planetGO.transform.InverseTransformPoint(prop.transform.position).normalized;
|
||||
prop.transform.rotation = Quaternion.FromToRotation(prop.transform.up, up) * prop.transform.rotation;
|
||||
prop.transform.rotation = Quaternion.FromToRotation(Vector3.up, up);
|
||||
prop.transform.rotation *= rot;
|
||||
}
|
||||
else
|
||||
|
||||
1
NewHorizons/External/PropModule.cs
vendored
1
NewHorizons/External/PropModule.cs
vendored
@ -43,6 +43,7 @@ namespace NewHorizons.External
|
||||
public float scale { get; set; } = 1f;
|
||||
public bool alignToNormal;
|
||||
public string[] removeChildren;
|
||||
public bool removeComponents;
|
||||
}
|
||||
|
||||
public class RaftInfo
|
||||
|
||||
@ -666,6 +666,11 @@
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"removeComponents": {
|
||||
"type": "boolean",
|
||||
"description": "Do we reset all the components on this object? Useful for certain props that have dialogue components attached to them.",
|
||||
"default": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user