mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Migrate more modules to the GeneralPropBuilder
This commit is contained in:
parent
cc9e86d712
commit
3ca6d9a3db
@ -12,7 +12,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
{
|
{
|
||||||
public static class GeneralPropBuilder
|
public static class GeneralPropBuilder
|
||||||
{
|
{
|
||||||
public static GameObject MakeFromExisting(GameObject go, GameObject planetGO, Sector sector, PropModule.PositionedPropInfo info, bool alignToBody)
|
public static GameObject MakeFromExisting(GameObject go, GameObject planetGO, Sector sector, PropModule.PositionedPropInfo info, bool alignToBody = false, MVector3 normal = null)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(info.rename))
|
if (!string.IsNullOrEmpty(info.rename))
|
||||||
{
|
{
|
||||||
@ -52,24 +52,25 @@ namespace NewHorizons.Builder.Props
|
|||||||
if (alignToBody)
|
if (alignToBody)
|
||||||
{
|
{
|
||||||
var up = (go.transform.position - planetGO.transform.position).normalized;
|
var up = (go.transform.position - planetGO.transform.position).normalized;
|
||||||
|
if (normal != null) up = planetGO.transform.TransformDirection(normal);
|
||||||
go.transform.rotation = Quaternion.FromToRotation(Vector3.up, up);
|
go.transform.rotation = Quaternion.FromToRotation(Vector3.up, up);
|
||||||
go.transform.rotation *= rot;
|
go.transform.rotation *= rot;
|
||||||
}
|
}
|
||||||
return go;
|
return go;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameObject MakeNew(string defaultName, GameObject planetGO, Sector sector, PropModule.PositionedPropInfo info, bool alignToBody)
|
public static GameObject MakeNew(string defaultName, GameObject planetGO, Sector sector, PropModule.PositionedPropInfo info, bool alignToBody = false, MVector3 normal = null)
|
||||||
{
|
{
|
||||||
GameObject go = new GameObject(defaultName);
|
GameObject go = new GameObject(defaultName);
|
||||||
go.SetActive(false);
|
go.SetActive(false);
|
||||||
return MakeFromExisting(go, planetGO, sector, info, alignToBody);
|
return MakeFromExisting(go, planetGO, sector, info, alignToBody, normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameObject MakeFromPrefab(GameObject prefab, string defaultName, GameObject planetGO, Sector sector, PropModule.PositionedPropInfo info, bool alignToBody)
|
public static GameObject MakeFromPrefab(GameObject prefab, string defaultName, GameObject planetGO, Sector sector, PropModule.PositionedPropInfo info, bool alignToBody = false, MVector3 normal = null)
|
||||||
{
|
{
|
||||||
GameObject go = prefab.InstantiateInactive();
|
GameObject go = prefab.InstantiateInactive();
|
||||||
go.name = defaultName;
|
go.name = defaultName;
|
||||||
return MakeFromExisting(go, planetGO, sector, info, alignToBody);
|
return MakeFromExisting(go, planetGO, sector, info, alignToBody, normal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -93,7 +93,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
if (_slideReelPrefab == null) return null;
|
if (_slideReelPrefab == null) return null;
|
||||||
|
|
||||||
var slideReelObj = GeneralPropBuilder.MakeFromPrefab(_slideReelPrefab, $"Prefab_IP_Reel_{mod.ModHelper.Manifest.Name}", planetGO, sector, info, false);
|
var slideReelObj = GeneralPropBuilder.MakeFromPrefab(_slideReelPrefab, $"Prefab_IP_Reel_{mod.ModHelper.Manifest.Name}", planetGO, sector, info);
|
||||||
|
|
||||||
var slideReel = slideReelObj.GetComponent<SlideReelItem>();
|
var slideReel = slideReelObj.GetComponent<SlideReelItem>();
|
||||||
slideReel.SetSector(sector);
|
slideReel.SetSector(sector);
|
||||||
@ -166,7 +166,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
if (_autoPrefab == null) return null;
|
if (_autoPrefab == null) return null;
|
||||||
|
|
||||||
var projectorObj = GeneralPropBuilder.MakeFromPrefab(_autoPrefab, $"Prefab_IP_AutoProjector_{mod.ModHelper.Manifest.Name}", planetGO, sector, info, false);
|
var projectorObj = GeneralPropBuilder.MakeFromPrefab(_autoPrefab, $"Prefab_IP_AutoProjector_{mod.ModHelper.Manifest.Name}", planetGO, sector, info);
|
||||||
|
|
||||||
var autoProjector = projectorObj.GetComponent<AutoSlideProjector>();
|
var autoProjector = projectorObj.GetComponent<AutoSlideProjector>();
|
||||||
autoProjector._sector = sector;
|
autoProjector._sector = sector;
|
||||||
|
|||||||
@ -50,7 +50,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
{
|
{
|
||||||
var socketInfo = quantumGroup.sockets[i];
|
var socketInfo = quantumGroup.sockets[i];
|
||||||
|
|
||||||
var socket = GeneralPropBuilder.MakeNew("Socket " + i, go, sector, socketInfo, false);
|
var socket = GeneralPropBuilder.MakeNew("Socket " + i, go, sector, socketInfo);
|
||||||
|
|
||||||
if (socketInfo.isRelativeToGroup)
|
if (socketInfo.isRelativeToGroup)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -52,7 +52,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
if (_prefab == null || sector == null) return null;
|
if (_prefab == null || sector == null) return null;
|
||||||
|
|
||||||
GameObject raftObject = GeneralPropBuilder.MakeFromPrefab(_prefab, "Raft_Body", planetGO, sector, info, false);
|
GameObject raftObject = GeneralPropBuilder.MakeFromPrefab(_prefab, "Raft_Body", planetGO, sector, info);
|
||||||
|
|
||||||
StreamingHandler.SetUpStreaming(raftObject, sector);
|
StreamingHandler.SetUpStreaming(raftObject, sector);
|
||||||
|
|
||||||
|
|||||||
@ -109,26 +109,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
public static GameObject Make(GameObject planetGO, Sector sector, SignalModule.SignalInfo info, IModBehaviour mod)
|
public static GameObject Make(GameObject planetGO, Sector sector, SignalModule.SignalInfo info, IModBehaviour mod)
|
||||||
{
|
{
|
||||||
var signalGO = new GameObject($"Signal_{info.name}");
|
var signalGO = GeneralPropBuilder.MakeNew($"Signal_{info.name}", planetGO, sector, info);
|
||||||
signalGO.SetActive(false);
|
|
||||||
signalGO.transform.parent = sector?.transform ?? planetGO.transform;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(info.parentPath))
|
|
||||||
{
|
|
||||||
var newParent = planetGO.transform.Find(info.parentPath);
|
|
||||||
if (newParent != null)
|
|
||||||
{
|
|
||||||
signalGO.transform.parent = newParent;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Logger.LogError($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var pos = (Vector3)(info.position ?? Vector3.zero);
|
|
||||||
if (info.isRelativeToParent) signalGO.transform.localPosition = pos;
|
|
||||||
else signalGO.transform.position = planetGO.transform.TransformPoint(pos);
|
|
||||||
signalGO.layer = LayerMask.NameToLayer("AdvancedEffectVolume");
|
signalGO.layer = LayerMask.NameToLayer("AdvancedEffectVolume");
|
||||||
|
|
||||||
var source = signalGO.AddComponent<AudioSource>();
|
var source = signalGO.AddComponent<AudioSource>();
|
||||||
|
|||||||
@ -100,7 +100,9 @@ namespace NewHorizons.Builder.Props
|
|||||||
{
|
{
|
||||||
var prefab = downwards ? _downPrefab.InstantiateInactive() : _upPrefab.InstantiateInactive();
|
var prefab = downwards ? _downPrefab.InstantiateInactive() : _upPrefab.InstantiateInactive();
|
||||||
var tornadoGO = GeneralPropBuilder.MakeFromPrefab(prefab, downwards ? "Tornado_Down" : "Tornado_Up", planetGO, sector, info, true);
|
var tornadoGO = GeneralPropBuilder.MakeFromPrefab(prefab, downwards ? "Tornado_Down" : "Tornado_Up", planetGO, sector, info, true);
|
||||||
if (info.position == null && !info.isRelativeToParent)
|
|
||||||
|
// Override general prop position with randomized default position
|
||||||
|
if (info.position == null)
|
||||||
{
|
{
|
||||||
tornadoGO.transform.position = planetGO.transform.TransformPoint(position);
|
tornadoGO.transform.position = planetGO.transform.TransformPoint(position);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -131,64 +131,25 @@ namespace NewHorizons.Builder.Props
|
|||||||
case PropModule.NomaiTextInfo.NomaiTextType.Wall:
|
case PropModule.NomaiTextInfo.NomaiTextType.Wall:
|
||||||
{
|
{
|
||||||
var nomaiWallTextObj = MakeWallText(planetGO, sector, info, xmlPath, nhBody).gameObject;
|
var nomaiWallTextObj = MakeWallText(planetGO, sector, info, xmlPath, nhBody).gameObject;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(info.rename))
|
if (info.normal != null)
|
||||||
{
|
{
|
||||||
nomaiWallTextObj.name = info.rename;
|
// In global coordinates (normal was in local coordinates)
|
||||||
}
|
var up = (nomaiWallTextObj.transform.position - planetGO.transform.position).normalized;
|
||||||
|
var forward = planetGO.transform.TransformDirection(info.normal).normalized;
|
||||||
|
|
||||||
nomaiWallTextObj.transform.parent = sector?.transform ?? planetGO.transform;
|
if (info.isRelativeToParent)
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(info.parentPath))
|
|
||||||
{
|
|
||||||
var newParent = planetGO.transform.Find(info.parentPath);
|
|
||||||
if (newParent != null)
|
|
||||||
{
|
{
|
||||||
nomaiWallTextObj.transform.parent = newParent;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Logger.LogError($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var pos = (Vector3)(info.position ?? Vector3.zero);
|
|
||||||
if (info.isRelativeToParent)
|
|
||||||
{
|
|
||||||
nomaiWallTextObj.transform.localPosition = pos;
|
|
||||||
if (info.normal != null)
|
|
||||||
{
|
|
||||||
// In global coordinates (normal was in local coordinates)
|
|
||||||
var up = (nomaiWallTextObj.transform.position - planetGO.transform.position).normalized;
|
|
||||||
var forward = planetGO.transform.TransformDirection(info.normal).normalized;
|
|
||||||
|
|
||||||
nomaiWallTextObj.transform.up = up;
|
nomaiWallTextObj.transform.up = up;
|
||||||
nomaiWallTextObj.transform.forward = forward;
|
nomaiWallTextObj.transform.forward = forward;
|
||||||
}
|
} else
|
||||||
if (info.rotation != null)
|
|
||||||
{
|
{
|
||||||
nomaiWallTextObj.transform.localRotation = Quaternion.Euler(info.rotation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nomaiWallTextObj.transform.position = planetGO.transform.TransformPoint(pos);
|
|
||||||
if (info.normal != null)
|
|
||||||
{
|
|
||||||
// In global coordinates (normal was in local coordinates)
|
|
||||||
var up = (nomaiWallTextObj.transform.position - planetGO.transform.position).normalized;
|
|
||||||
var forward = planetGO.transform.TransformDirection(info.normal).normalized;
|
|
||||||
|
|
||||||
nomaiWallTextObj.transform.forward = forward;
|
nomaiWallTextObj.transform.forward = forward;
|
||||||
|
|
||||||
var desiredUp = Vector3.ProjectOnPlane(up, forward);
|
var desiredUp = Vector3.ProjectOnPlane(up, forward);
|
||||||
var zRotation = Vector3.SignedAngle(nomaiWallTextObj.transform.up, desiredUp, forward);
|
var zRotation = Vector3.SignedAngle(nomaiWallTextObj.transform.up, desiredUp, forward);
|
||||||
nomaiWallTextObj.transform.RotateAround(nomaiWallTextObj.transform.position, forward, zRotation);
|
nomaiWallTextObj.transform.RotateAround(nomaiWallTextObj.transform.position, forward, zRotation);
|
||||||
}
|
}
|
||||||
if (info.rotation != null)
|
|
||||||
{
|
|
||||||
nomaiWallTextObj.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(info.rotation));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// nomaiWallTextObj.GetComponent<NomaiTextArcArranger>().DrawBoundsWithDebugSpheres();
|
// nomaiWallTextObj.GetComponent<NomaiTextArcArranger>().DrawBoundsWithDebugSpheres();
|
||||||
@ -200,16 +161,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
}
|
}
|
||||||
case PropModule.NomaiTextInfo.NomaiTextType.Scroll:
|
case PropModule.NomaiTextInfo.NomaiTextType.Scroll:
|
||||||
{
|
{
|
||||||
var customScroll = _scrollPrefab.InstantiateInactive();
|
var customScroll = GeneralPropBuilder.MakeFromPrefab(_scrollPrefab, _scrollPrefab.name, planetGO, sector, info);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(info.rename))
|
|
||||||
{
|
|
||||||
customScroll.name = info.rename;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
customScroll.name = _scrollPrefab.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
var nomaiWallText = MakeWallText(planetGO, sector, info, xmlPath, nhBody);
|
var nomaiWallText = MakeWallText(planetGO, sector, info, xmlPath, nhBody);
|
||||||
nomaiWallText.transform.parent = customScroll.transform;
|
nomaiWallText.transform.parent = customScroll.transform;
|
||||||
@ -237,36 +189,6 @@ namespace NewHorizons.Builder.Props
|
|||||||
// Else when you put them down you can't pick them back up
|
// Else when you put them down you can't pick them back up
|
||||||
customScroll.GetComponent<OWCollider>()._physicsRemoved = false;
|
customScroll.GetComponent<OWCollider>()._physicsRemoved = false;
|
||||||
|
|
||||||
// Place scroll
|
|
||||||
customScroll.transform.parent = sector?.transform ?? planetGO.transform;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(info.parentPath))
|
|
||||||
{
|
|
||||||
var newParent = planetGO.transform.Find(info.parentPath);
|
|
||||||
if (newParent != null)
|
|
||||||
{
|
|
||||||
customScroll.transform.parent = newParent;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Logger.LogError($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var pos = (Vector3)(info.position ?? Vector3.zero);
|
|
||||||
if (info.isRelativeToParent) customScroll.transform.localPosition = pos;
|
|
||||||
else customScroll.transform.position = planetGO.transform.TransformPoint(pos);
|
|
||||||
|
|
||||||
var up = planetGO.transform.InverseTransformPoint(customScroll.transform.position).normalized;
|
|
||||||
if (info.rotation != null)
|
|
||||||
{
|
|
||||||
customScroll.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(info.rotation));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
customScroll.transform.rotation = Quaternion.FromToRotation(customScroll.transform.up, up) * customScroll.transform.rotation;
|
|
||||||
}
|
|
||||||
|
|
||||||
customScroll.SetActive(true);
|
customScroll.SetActive(true);
|
||||||
|
|
||||||
Delay.FireOnNextUpdate(
|
Delay.FireOnNextUpdate(
|
||||||
@ -291,39 +213,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
}
|
}
|
||||||
case PropModule.NomaiTextInfo.NomaiTextType.Computer:
|
case PropModule.NomaiTextInfo.NomaiTextType.Computer:
|
||||||
{
|
{
|
||||||
var computerObject = _computerPrefab.InstantiateInactive();
|
var computerObject = GeneralPropBuilder.MakeFromPrefab(_computerPrefab, _computerPrefab.name, planetGO, sector, info, true, info.normal);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(info.rename))
|
|
||||||
{
|
|
||||||
computerObject.name = info.rename;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
computerObject.name = _computerPrefab.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
computerObject.transform.parent = sector?.transform ?? planetGO.transform;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(info.parentPath))
|
|
||||||
{
|
|
||||||
var newParent = planetGO.transform.Find(info.parentPath);
|
|
||||||
if (newParent != null)
|
|
||||||
{
|
|
||||||
computerObject.transform.parent = newParent;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Logger.LogError($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var pos = (Vector3)(info.position ?? Vector3.zero);
|
|
||||||
if (info.isRelativeToParent) computerObject.transform.localPosition = pos;
|
|
||||||
else computerObject.transform.position = planetGO.transform.TransformPoint(pos);
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
var computer = computerObject.GetComponent<NomaiComputer>();
|
var computer = computerObject.GetComponent<NomaiComputer>();
|
||||||
computer.SetSector(sector);
|
computer.SetSector(sector);
|
||||||
@ -395,48 +285,8 @@ namespace NewHorizons.Builder.Props
|
|||||||
case PropModule.NomaiTextInfo.NomaiTextType.Cairn:
|
case PropModule.NomaiTextInfo.NomaiTextType.Cairn:
|
||||||
case PropModule.NomaiTextInfo.NomaiTextType.CairnVariant:
|
case PropModule.NomaiTextInfo.NomaiTextType.CairnVariant:
|
||||||
{
|
{
|
||||||
var cairnObject = (info.type == PropModule.NomaiTextInfo.NomaiTextType.CairnVariant ? _cairnVariantPrefab : _cairnPrefab).InstantiateInactive();
|
var cairnPrefab = info.type == PropModule.NomaiTextInfo.NomaiTextType.CairnVariant ? _cairnVariantPrefab : _cairnPrefab;
|
||||||
|
var cairnObject = GeneralPropBuilder.MakeFromPrefab(cairnPrefab, _cairnPrefab.name, planetGO, sector, info, info.rotation == null);
|
||||||
if (!string.IsNullOrEmpty(info.rename))
|
|
||||||
{
|
|
||||||
cairnObject.name = info.rename;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cairnObject.name = _cairnPrefab.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
cairnObject.transform.parent = sector?.transform ?? planetGO.transform;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(info.parentPath))
|
|
||||||
{
|
|
||||||
var newParent = planetGO.transform.Find(info.parentPath);
|
|
||||||
if (newParent != null)
|
|
||||||
{
|
|
||||||
cairnObject.transform.parent = newParent;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Logger.LogError($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var pos = (Vector3)(info.position ?? Vector3.zero);
|
|
||||||
if (info.isRelativeToParent) cairnObject.transform.localPosition = pos;
|
|
||||||
else cairnObject.transform.position = planetGO.transform.TransformPoint(pos);
|
|
||||||
|
|
||||||
if (info.rotation != null)
|
|
||||||
{
|
|
||||||
var rot = Quaternion.Euler(info.rotation);
|
|
||||||
if (info.isRelativeToParent) cairnObject.transform.localRotation = rot;
|
|
||||||
else cairnObject.transform.rotation = planetGO.transform.TransformRotation(rot);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// By default align it to normal
|
|
||||||
var up = (cairnObject.transform.position - planetGO.transform.position).normalized;
|
|
||||||
cairnObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, up) * cairnObject.transform.rotation;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Idk do we have to set it active before finding things?
|
// Idk do we have to set it active before finding things?
|
||||||
cairnObject.SetActive(true);
|
cairnObject.SetActive(true);
|
||||||
@ -476,17 +326,12 @@ namespace NewHorizons.Builder.Props
|
|||||||
rotation = info.rotation,
|
rotation = info.rotation,
|
||||||
position = info.position,
|
position = info.position,
|
||||||
isRelativeToParent = info.isRelativeToParent,
|
isRelativeToParent = info.isRelativeToParent,
|
||||||
rename = info.rename
|
rename = info.rename,
|
||||||
|
alignToNormal = info.rotation == null,
|
||||||
};
|
};
|
||||||
var recorderObject = DetailBuilder.Make(planetGO, sector, prefab, detailInfo);
|
var recorderObject = DetailBuilder.Make(planetGO, sector, prefab, detailInfo);
|
||||||
recorderObject.SetActive(false);
|
recorderObject.SetActive(false);
|
||||||
|
|
||||||
if (info.rotation == null)
|
|
||||||
{
|
|
||||||
var up = recorderObject.transform.position - planetGO.transform.position;
|
|
||||||
recorderObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, up) * recorderObject.transform.rotation;
|
|
||||||
}
|
|
||||||
|
|
||||||
var nomaiText = recorderObject.GetComponentInChildren<NomaiText>();
|
var nomaiText = recorderObject.GetComponentInChildren<NomaiText>();
|
||||||
nomaiText.SetSector(sector);
|
nomaiText.SetSector(sector);
|
||||||
|
|
||||||
@ -504,52 +349,11 @@ namespace NewHorizons.Builder.Props
|
|||||||
}
|
}
|
||||||
case PropModule.NomaiTextInfo.NomaiTextType.Trailmarker:
|
case PropModule.NomaiTextInfo.NomaiTextType.Trailmarker:
|
||||||
{
|
{
|
||||||
var trailmarkerObject = _trailmarkerPrefab.InstantiateInactive();
|
var trailmarkerObject = GeneralPropBuilder.MakeFromPrefab(_trailmarkerPrefab, _trailmarkerPrefab.name, planetGO, sector, info, info.rotation == null);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(info.rename))
|
|
||||||
{
|
|
||||||
trailmarkerObject.name = info.rename;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
trailmarkerObject.name = _trailmarkerPrefab.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
trailmarkerObject.transform.parent = sector?.transform ?? planetGO.transform;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(info.parentPath))
|
|
||||||
{
|
|
||||||
var newParent = planetGO.transform.Find(info.parentPath);
|
|
||||||
if (newParent != null)
|
|
||||||
{
|
|
||||||
trailmarkerObject.transform.parent = newParent;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Logger.LogError($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var pos = (Vector3)(info.position ?? Vector3.zero);
|
|
||||||
if (info.isRelativeToParent) trailmarkerObject.transform.localPosition = pos;
|
|
||||||
else trailmarkerObject.transform.position = planetGO.transform.TransformPoint(pos);
|
|
||||||
|
|
||||||
// shrink because that is what mobius does on all trailmarkers or else they are the size of the player
|
// shrink because that is what mobius does on all trailmarkers or else they are the size of the player
|
||||||
trailmarkerObject.transform.localScale = Vector3.one * 0.75f;
|
trailmarkerObject.transform.localScale = Vector3.one * 0.75f;
|
||||||
|
|
||||||
if (info.rotation != null)
|
|
||||||
{
|
|
||||||
var rot = Quaternion.Euler(info.rotation);
|
|
||||||
if (info.isRelativeToParent) trailmarkerObject.transform.localRotation = rot;
|
|
||||||
else trailmarkerObject.transform.rotation = planetGO.transform.TransformRotation(rot);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// By default align it to normal
|
|
||||||
var up = (trailmarkerObject.transform.position - planetGO.transform.position).normalized;
|
|
||||||
trailmarkerObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, up) * trailmarkerObject.transform.rotation;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Idk do we have to set it active before finding things?
|
// Idk do we have to set it active before finding things?
|
||||||
trailmarkerObject.SetActive(true);
|
trailmarkerObject.SetActive(true);
|
||||||
|
|
||||||
@ -576,8 +380,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
private static NomaiWallText MakeWallText(GameObject go, Sector sector, PropModule.NomaiTextInfo info, string xmlPath, NewHorizonsBody nhBody)
|
private static NomaiWallText MakeWallText(GameObject go, Sector sector, PropModule.NomaiTextInfo info, string xmlPath, NewHorizonsBody nhBody)
|
||||||
{
|
{
|
||||||
GameObject nomaiWallTextObj = new GameObject("NomaiWallText");
|
GameObject nomaiWallTextObj = GeneralPropBuilder.MakeNew("NomaiWallText", go, sector, info);
|
||||||
nomaiWallTextObj.SetActive(false);
|
|
||||||
|
|
||||||
var box = nomaiWallTextObj.AddComponent<BoxCollider>();
|
var box = nomaiWallTextObj.AddComponent<BoxCollider>();
|
||||||
box.center = new Vector3(-0.0643f, 1.1254f, 0f);
|
box.center = new Vector3(-0.0643f, 1.1254f, 0f);
|
||||||
|
|||||||
@ -12,7 +12,7 @@ namespace NewHorizons.Builder.ShipLog
|
|||||||
private static readonly List<ShipLogEntryLocation> _locationsToInitialize = new List<ShipLogEntryLocation>();
|
private static readonly List<ShipLogEntryLocation> _locationsToInitialize = new List<ShipLogEntryLocation>();
|
||||||
public static void Make(GameObject go, Sector sector, PropModule.EntryLocationInfo info, IModBehaviour mod)
|
public static void Make(GameObject go, Sector sector, PropModule.EntryLocationInfo info, IModBehaviour mod)
|
||||||
{
|
{
|
||||||
GameObject entryLocationGameObject = GeneralPropBuilder.MakeNew("Entry Location (" + info.id + ")", go, sector, info, false);
|
GameObject entryLocationGameObject = GeneralPropBuilder.MakeNew("Entry Location (" + info.id + ")", go, sector, info);
|
||||||
|
|
||||||
ShipLogEntryLocation newLocation = entryLocationGameObject.AddComponent<ShipLogEntryLocation>();
|
ShipLogEntryLocation newLocation = entryLocationGameObject.AddComponent<ShipLogEntryLocation>();
|
||||||
newLocation._entryID = info.id;
|
newLocation._entryID = info.id;
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
using NewHorizons.Builder.Props;
|
||||||
using NewHorizons.Components;
|
using NewHorizons.Components;
|
||||||
using NewHorizons.External.Modules;
|
using NewHorizons.External.Modules;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -9,32 +10,7 @@ namespace NewHorizons.Builder.Volumes
|
|||||||
{
|
{
|
||||||
public static TVolume Make<TVolume>(GameObject planetGO, Sector sector, VolumesModule.VolumeInfo info) where TVolume : MonoBehaviour //Could be BaseVolume but I need to create vanilla volumes too.
|
public static TVolume Make<TVolume>(GameObject planetGO, Sector sector, VolumesModule.VolumeInfo info) where TVolume : MonoBehaviour //Could be BaseVolume but I need to create vanilla volumes too.
|
||||||
{
|
{
|
||||||
var go = new GameObject(typeof(TVolume).Name);
|
var go = GeneralPropBuilder.MakeNew(typeof(TVolume).Name, planetGO, sector, info);
|
||||||
go.SetActive(false);
|
|
||||||
|
|
||||||
go.transform.parent = sector?.transform ?? planetGO.transform;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(info.rename))
|
|
||||||
{
|
|
||||||
go.name = info.rename;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(info.parentPath))
|
|
||||||
{
|
|
||||||
var newParent = planetGO.transform.Find(info.parentPath);
|
|
||||||
if (newParent != null)
|
|
||||||
{
|
|
||||||
go.transform.parent = newParent;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Logger.LogError($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var pos = (Vector3)(info.position ?? Vector3.zero);
|
|
||||||
if (info.isRelativeToParent) go.transform.localPosition = pos;
|
|
||||||
else go.transform.position = planetGO.transform.TransformPoint(pos);
|
|
||||||
go.layer = LayerMask.NameToLayer("BasicEffectVolume");
|
go.layer = LayerMask.NameToLayer("BasicEffectVolume");
|
||||||
|
|
||||||
var shape = go.AddComponent<SphereShape>();
|
var shape = go.AddComponent<SphereShape>();
|
||||||
|
|||||||
17
NewHorizons/External/Modules/SignalModule.cs
vendored
17
NewHorizons/External/Modules/SignalModule.cs
vendored
@ -15,7 +15,7 @@ namespace NewHorizons.External.Modules
|
|||||||
public SignalInfo[] signals;
|
public SignalInfo[] signals;
|
||||||
|
|
||||||
[JsonObject]
|
[JsonObject]
|
||||||
public class SignalInfo
|
public class SignalInfo : PropModule.PositionedPropInfo
|
||||||
{
|
{
|
||||||
[Obsolete("audioClip is deprecated, please use audio instead")]
|
[Obsolete("audioClip is deprecated, please use audio instead")]
|
||||||
public string audioClip;
|
public string audioClip;
|
||||||
@ -61,11 +61,6 @@ namespace NewHorizons.External.Modules
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(true)] public bool onlyAudibleToScope = true;
|
[DefaultValue(true)] public bool onlyAudibleToScope = true;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Position of the signal's source
|
|
||||||
/// </summary>
|
|
||||||
public MVector3 position;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A ship log fact to reveal when the signal is identified.
|
/// A ship log fact to reveal when the signal is identified.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -75,16 +70,6 @@ namespace NewHorizons.External.Modules
|
|||||||
/// Radius of the sphere giving off the signal.
|
/// Radius of the sphere giving off the signal.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(1f)] public float sourceRadius = 1f;
|
[DefaultValue(1f)] public float sourceRadius = 1f;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The relative path from the planet to the parent of this signal. Optional (will default to the root sector).
|
|
||||||
/// </summary>
|
|
||||||
public string parentPath;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether the positional and rotational coordinates are relative to parent instead of the root planet object.
|
|
||||||
/// </summary>
|
|
||||||
public bool isRelativeToParent;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
22
NewHorizons/External/Modules/VolumesModule.cs
vendored
22
NewHorizons/External/Modules/VolumesModule.cs
vendored
@ -117,33 +117,13 @@ namespace NewHorizons.External.Modules
|
|||||||
public LoadCreditsVolumeInfo[] creditsVolume;
|
public LoadCreditsVolumeInfo[] creditsVolume;
|
||||||
|
|
||||||
[JsonObject]
|
[JsonObject]
|
||||||
public class VolumeInfo
|
public class VolumeInfo : PropModule.PositionedPropInfo
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// The location of this volume. Optional (will default to 0,0,0).
|
|
||||||
/// </summary>
|
|
||||||
public MVector3 position;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The radius of this volume.
|
/// The radius of this volume.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(1f)]
|
[DefaultValue(1f)]
|
||||||
public float radius = 1f;
|
public float radius = 1f;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The relative path from the planet to the parent of this object. Optional (will default to the root sector).
|
|
||||||
/// </summary>
|
|
||||||
public string parentPath;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether the positional coordinates are relative to parent instead of the root planet object.
|
|
||||||
/// </summary>
|
|
||||||
public bool isRelativeToParent;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// An optional rename of this volume.
|
|
||||||
/// </summary>
|
|
||||||
public string rename;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonObject]
|
[JsonObject]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user