Cloak Module

This commit is contained in:
Noah Pilarski 2022-05-27 06:04:32 -04:00
parent 3ed6834f61
commit 855a4caa2f
6 changed files with 55 additions and 16 deletions

View File

@ -1,12 +1,14 @@
using NewHorizons.Components;
using NewHorizons.External.Modules;
using NewHorizons.Utility;
using UnityEngine;
namespace NewHorizons.Builder.Body
{
public static class CloakBuilder
{
public static void Make(GameObject planetGO, Sector sector, OWRigidbody OWRB, float radius, bool keepReferenceFrame)
public static void Make(GameObject planetGO, Sector sector, OWRigidbody OWRB, CloakModule module, bool keepReferenceFrame)
{
var radius = module.radius;
var cloak = SearchUtilities.Find("RingWorld_Body/CloakingField_IP");
var newCloak = GameObject.Instantiate(cloak, sector?.transform ?? planetGO.transform);

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using NewHorizons.External.Modules;
@ -45,6 +45,11 @@ namespace NewHorizons.External.Configs
#endregion Obsolete
/// <summary>
/// Add a cloaking field to this planet
/// </summary>
public CloakModule Cloak;
/// <summary>
/// `true` if you want to delete this planet
/// </summary>
@ -192,6 +197,12 @@ namespace NewHorizons.External.Configs
if (childrenToDestroy != null) removeChildren = childrenToDestroy;
if (Base.cloakRadius != 0)
Cloak = new CloakModule
{
radius = Base.cloakRadius
};
if (Base.hasAmbientLight) Base.ambientLight = 0.5f;
if (Atmosphere != null)

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.ComponentModel;
using System.Runtime.Serialization;
using NewHorizons.Utility;
@ -30,12 +30,6 @@ namespace NewHorizons.External.Modules
/// </summary>
public bool centerOfSolarSystem;
/// <summary>
/// Radius of the cloaking field around the planet. It's a bit finicky so experiment with different values. If you
/// don't want a cloak, leave this as 0.
/// </summary>
public float cloakRadius;
/// <summary>
/// If it has a comet tail, it'll be oriented according to these Euler angles.
/// </summary>
@ -112,6 +106,9 @@ namespace NewHorizons.External.Modules
[Obsolete("HasAmbientLight is deprecated, please use AmbientLight instead")]
public bool hasAmbientLight;
[Obsolete("CloakRadius is deprecated, please use CloakModule instead")]
public float cloakRadius;
#endregion Obsolete
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.ComponentModel;
using System.Runtime.Serialization;
using NewHorizons.Utility;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace NewHorizons.External.Modules
{
[JsonObject]
public class CloakModule
{
/// <summary>
/// Radius of the cloaking field around the planet. It's a bit finicky so experiment with different values. If you
/// don't want a cloak, leave this as 0.
/// </summary>
public float radius;
}
}

View File

@ -480,9 +480,9 @@ namespace NewHorizons.Handlers
}
// Has to go last probably
if (body.Config.Base.cloakRadius != 0f)
if (body.Config.Cloak != null && body.Config.Cloak.radius != 0f)
{
CloakBuilder.Make(go, sector, rb, body.Config.Base.cloakRadius, body.Config.Base.hasReferenceFrame);
CloakBuilder.Make(go, sector, rb, body.Config.Cloak, body.Config.Base.hasReferenceFrame);
}
return go;

View File

@ -30,6 +30,10 @@
"type": "boolean",
"description": "Should this planet ever be shown on the title screen?"
},
"Cloak": {
"description": "Add a cloaking field to this planet",
"$ref": "#/definitions/CloakModule"
},
"destroy": {
"type": "boolean",
"description": "`true` if you want to delete this planet"
@ -285,6 +289,17 @@
}
}
},
"CloakModule": {
"type": "object",
"additionalProperties": false,
"properties": {
"radius": {
"type": "number",
"description": "Radius of the cloaking field around the planet. It's a bit finicky so experiment with different values. If you\ndon't want a cloak, leave this as 0.",
"format": "float"
}
}
},
"CloudInfo": {
"type": "object",
"additionalProperties": false,
@ -384,11 +399,6 @@
"type": "boolean",
"description": "Set this to true if you are replacing the sun with a different body. Only one object in a star system should ever\nhave this set to true."
},
"cloakRadius": {
"type": "number",
"description": "Radius of the cloaking field around the planet. It's a bit finicky so experiment with different values. If you\ndon't want a cloak, leave this as 0.",
"format": "float"
},
"cometTailRotation": {
"description": "If it has a comet tail, it'll be oriented according to these Euler angles.",
"$ref": "#/definitions/MVector3"