mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Move GeneralPropInfo out into its own file
This commit is contained in:
parent
af96853afb
commit
3523bd3cab
@ -12,11 +12,11 @@ namespace NewHorizons.Builder.Props
|
||||
{
|
||||
public static class GeneralPropBuilder
|
||||
{
|
||||
public static GameObject MakeFromExisting(GameObject go, Transform parent, PropModule.GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null)
|
||||
public static GameObject MakeFromExisting(GameObject go, Transform parent, GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null)
|
||||
{
|
||||
if (info == null) return go;
|
||||
|
||||
if (info is PropModule.GeneralSolarSystemPropInfo solarSystemInfo && !string.IsNullOrEmpty(solarSystemInfo.parentBody))
|
||||
if (info is GeneralSolarSystemPropInfo solarSystemInfo && !string.IsNullOrEmpty(solarSystemInfo.parentBody))
|
||||
{
|
||||
// This can fail if the prop is built before the target planet. Only use it for SolarSystem module props
|
||||
var targetPlanet = AstroObjectLocator.GetAstroObject(solarSystemInfo.parentBody);
|
||||
@ -53,7 +53,7 @@ namespace NewHorizons.Builder.Props
|
||||
|
||||
var pos = (Vector3)(info.position ?? defaultPosition ?? Vector3.zero);
|
||||
var rot = Quaternion.identity;
|
||||
if (info is PropModule.GeneralPropInfo rotInfo)
|
||||
if (info is GeneralPropInfo rotInfo)
|
||||
{
|
||||
rot = rotInfo.rotation != null ? Quaternion.Euler(rotInfo.rotation) : Quaternion.identity;
|
||||
}
|
||||
@ -79,14 +79,14 @@ namespace NewHorizons.Builder.Props
|
||||
return go;
|
||||
}
|
||||
|
||||
public static GameObject MakeNew(string defaultName, Transform parent, PropModule.GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null)
|
||||
public static GameObject MakeNew(string defaultName, Transform parent, GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null)
|
||||
{
|
||||
var go = new GameObject(defaultName);
|
||||
go.SetActive(false);
|
||||
return MakeFromExisting(go, parent, info, alignToBody, normal, defaultPosition, defaultParentPath);
|
||||
}
|
||||
|
||||
public static GameObject MakeFromPrefab(GameObject prefab, string defaultName, Transform parent, PropModule.GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null)
|
||||
public static GameObject MakeFromPrefab(GameObject prefab, string defaultName, Transform parent, GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null)
|
||||
{
|
||||
var go = prefab.InstantiateInactive();
|
||||
go.name = defaultName;
|
||||
|
||||
@ -211,12 +211,12 @@ namespace NewHorizons.External.Configs
|
||||
[Obsolete("warpExitRotation is deprecated, use vesselSpawn.rotation instead")] public MVector3 warpExitRotation;
|
||||
|
||||
[JsonObject]
|
||||
public class VesselInfo : PropModule.GeneralSolarSystemPropInfo
|
||||
public class VesselInfo : GeneralSolarSystemPropInfo
|
||||
{
|
||||
}
|
||||
|
||||
[JsonObject]
|
||||
public class WarpExitInfo : PropModule.GeneralSolarSystemPropInfo
|
||||
public class WarpExitInfo : GeneralSolarSystemPropInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// If set, keeps the warp exit attached to the vessel. Overrides `parentPath`.
|
||||
|
||||
@ -78,7 +78,7 @@ namespace NewHorizons.External.Modules
|
||||
|
||||
|
||||
[JsonObject]
|
||||
public class BrambleNodeInfo : PropModule.GeneralPropInfo
|
||||
public class BrambleNodeInfo : GeneralPropInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// The physical scale of the node, as a multiplier of the original size.
|
||||
|
||||
48
NewHorizons/External/Modules/GeneralPropInfo.cs
vendored
Normal file
48
NewHorizons/External/Modules/GeneralPropInfo.cs
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
using NewHorizons.Utility;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace NewHorizons.External.Modules
|
||||
{
|
||||
[JsonObject]
|
||||
public abstract class GeneralPointPropInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Position of the object
|
||||
/// </summary>
|
||||
public MVector3 position;
|
||||
|
||||
/// <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 and rotational coordinates are relative to parent instead of the root planet object.
|
||||
/// </summary>
|
||||
public bool isRelativeToParent;
|
||||
|
||||
/// <summary>
|
||||
/// An optional rename of this object
|
||||
/// </summary>
|
||||
public string rename;
|
||||
}
|
||||
|
||||
[JsonObject]
|
||||
public abstract class GeneralPropInfo : GeneralPointPropInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Rotation of the object
|
||||
/// </summary>
|
||||
public MVector3 rotation;
|
||||
}
|
||||
|
||||
[JsonObject]
|
||||
public abstract class GeneralSolarSystemPropInfo : GeneralPropInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the planet that will be used with `parentPath`. Must be set if `parentPath` is set.
|
||||
/// </summary>
|
||||
public string parentBody;
|
||||
}
|
||||
}
|
||||
42
NewHorizons/External/Modules/PropModule.cs
vendored
42
NewHorizons/External/Modules/PropModule.cs
vendored
@ -98,48 +98,6 @@ namespace NewHorizons.External.Modules
|
||||
|
||||
[Obsolete("audioVolumes is deprecated. Use Volumes->audioVolumes instead.")] public VolumesModule.AudioVolumeInfo[] audioVolumes;
|
||||
|
||||
[JsonObject]
|
||||
public abstract class GeneralPointPropInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Position of the object
|
||||
/// </summary>
|
||||
public MVector3 position;
|
||||
|
||||
/// <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 and rotational coordinates are relative to parent instead of the root planet object.
|
||||
/// </summary>
|
||||
public bool isRelativeToParent;
|
||||
|
||||
/// <summary>
|
||||
/// An optional rename of this object
|
||||
/// </summary>
|
||||
public string rename;
|
||||
}
|
||||
|
||||
[JsonObject]
|
||||
public abstract class GeneralPropInfo : GeneralPointPropInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Rotation of the object
|
||||
/// </summary>
|
||||
public MVector3 rotation;
|
||||
}
|
||||
|
||||
[JsonObject]
|
||||
public abstract class GeneralSolarSystemPropInfo : GeneralPropInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the planet that will be used with `parentPath`. Must be set if `parentPath` is set.
|
||||
/// </summary>
|
||||
public string parentBody;
|
||||
}
|
||||
|
||||
[JsonObject]
|
||||
public class ScatterInfo
|
||||
{
|
||||
|
||||
2
NewHorizons/External/Modules/SignalModule.cs
vendored
2
NewHorizons/External/Modules/SignalModule.cs
vendored
@ -15,7 +15,7 @@ namespace NewHorizons.External.Modules
|
||||
public SignalInfo[] signals;
|
||||
|
||||
[JsonObject]
|
||||
public class SignalInfo : PropModule.GeneralPointPropInfo
|
||||
public class SignalInfo : GeneralPointPropInfo
|
||||
{
|
||||
[Obsolete("audioClip is deprecated, please use audio instead")]
|
||||
public string audioClip;
|
||||
|
||||
4
NewHorizons/External/Modules/SpawnModule.cs
vendored
4
NewHorizons/External/Modules/SpawnModule.cs
vendored
@ -24,7 +24,7 @@ namespace NewHorizons.External.Modules
|
||||
[Obsolete("startWithSuit is deprecated. Use playerSpawn.startWithSuit instead")] public bool startWithSuit;
|
||||
|
||||
[JsonObject]
|
||||
public class PlayerSpawnPoint : PropModule.GeneralPropInfo {
|
||||
public class PlayerSpawnPoint : GeneralPropInfo {
|
||||
/// <summary>
|
||||
/// If you spawn on a planet with no oxygen, you probably want to set this to true ;;)
|
||||
/// </summary>
|
||||
@ -32,7 +32,7 @@ namespace NewHorizons.External.Modules
|
||||
}
|
||||
|
||||
[JsonObject]
|
||||
public class ShipSpawnPoint : PropModule.GeneralPropInfo {
|
||||
public class ShipSpawnPoint : GeneralPropInfo {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ using Newtonsoft.Json.Converters;
|
||||
namespace NewHorizons.External.Modules.VariableSize
|
||||
{
|
||||
[JsonObject]
|
||||
public class SingularityModule : PropModule.GeneralPropInfo
|
||||
public class SingularityModule : GeneralPropInfo
|
||||
{
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum SingularityType
|
||||
|
||||
@ -117,7 +117,7 @@ namespace NewHorizons.External.Modules
|
||||
public LoadCreditsVolumeInfo[] creditsVolume;
|
||||
|
||||
[JsonObject]
|
||||
public class VolumeInfo : PropModule.GeneralPointPropInfo
|
||||
public class VolumeInfo : GeneralPointPropInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// The radius of this volume.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user