Animated nomai recorders (#263)

This commit is contained in:
Noah 2022-08-13 02:38:05 -04:00 committed by GitHub
commit ec2845b4cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -408,35 +408,23 @@ namespace NewHorizons.Builder.Props
case PropModule.NomaiTextInfo.NomaiTextType.PreCrashRecorder:
case PropModule.NomaiTextInfo.NomaiTextType.Recorder:
{
var recorderObject = (info.type == PropModule.NomaiTextInfo.NomaiTextType.PreCrashRecorder ? _preCrashRecorderPrefab : _recorderPrefab).InstantiateInactive();
var prefab = (info.type == PropModule.NomaiTextInfo.NomaiTextType.PreCrashRecorder ? _preCrashRecorderPrefab : _recorderPrefab);
var detailInfo = new PropModule.DetailInfo {
parentPath = info.parentPath,
rotation = info.rotation,
position = info.position
};
var recorderObject = DetailBuilder.MakeDetail(planetGO, sector, prefab, detailInfo);
recorderObject.SetActive(false);
if (!string.IsNullOrEmpty(info.rename))
{
recorderObject.name = info.rename;
}
recorderObject.transform.parent = sector?.transform ?? planetGO.transform;
if (!string.IsNullOrEmpty(info.parentPath))
{
var newParent = planetGO.transform.Find(info.parentPath);
if (newParent != null)
{
recorderObject.transform.parent = newParent;
}
else
{
Logger.LogWarning($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}");
}
}
recorderObject.transform.position = planetGO.transform.TransformPoint(info?.position ?? Vector3.zero);
if (info.rotation != null)
{
recorderObject.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(info.rotation));
}
else
if (info.rotation == null)
{
var up = recorderObject.transform.position - planetGO.transform.position;
recorderObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, up) * recorderObject.transform.rotation;
@ -451,9 +439,6 @@ namespace NewHorizons.Builder.Props
nomaiText._nomaiTextAsset.name = Path.GetFileNameWithoutExtension(info.xmlFile);
AddTranslation(xmlPath);
// Make sure the recorder model is loaded
StreamingHandler.SetUpStreaming(recorderObject, sector);
recorderObject.SetActive(true);
recorderObject.transform.Find("InteractSphere").gameObject.GetComponent<SphereShape>().enabled = true;