Reference Frame Module

This commit is contained in:
Noah Pilarski 2022-05-29 19:20:19 -04:00
parent 0e0766e870
commit 75ce7349cf
8 changed files with 75 additions and 21 deletions

View File

@ -1,4 +1,4 @@
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Handlers; using NewHorizons.Handlers;
using NewHorizons.Utility; using NewHorizons.Utility;
@ -34,7 +34,6 @@ namespace NewHorizons.Builder.Body
hasMapMarker = false, hasMapMarker = false,
surfaceGravity = 1, surfaceGravity = 1,
surfaceSize = size, surfaceSize = size,
hasReferenceFrame = false,
gravityFallOff = GravityFallOff.InverseSquared gravityFallOff = GravityFallOff.InverseSquared
}; };
@ -49,6 +48,11 @@ namespace NewHorizons.Builder.Body
showOrbitLine = false showOrbitLine = false
}; };
config.ReferenceFrame = new ReferenceFrameModule()
{
hideInMap = true
};
config.ProcGen = belt.procGen; config.ProcGen = belt.procGen;
if (config.ProcGen == null) if (config.ProcGen == null)
{ {

View File

@ -1,10 +1,11 @@
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using NewHorizons.External.Modules;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Builder.General namespace NewHorizons.Builder.General
{ {
public static class RFVolumeBuilder public static class RFVolumeBuilder
{ {
public static void Make(GameObject planetGO, OWRigidbody owrb, float sphereOfInfluence, bool hide = false) public static void Make(GameObject planetGO, OWRigidbody owrb, float sphereOfInfluence, ReferenceFrameModule module)
{ {
var rfGO = new GameObject("RFVolume"); var rfGO = new GameObject("RFVolume");
rfGO.transform.parent = planetGO.transform; rfGO.transform.parent = planetGO.transform;
@ -19,7 +20,7 @@ namespace NewHorizons.Builder.General
var RFV = rfGO.AddComponent<ReferenceFrameVolume>(); var RFV = rfGO.AddComponent<ReferenceFrameVolume>();
var RV = new ReferenceFrame(owrb); var RV = new ReferenceFrame(owrb);
RV._minSuitTargetDistance = sphereOfInfluence; RV._minSuitTargetDistance = module.targetWhenClose ? 0 : sphereOfInfluence;
RV._maxTargetDistance = 0; RV._maxTargetDistance = 0;
RV._autopilotArrivalDistance = 2.0f * sphereOfInfluence; RV._autopilotArrivalDistance = 2.0f * sphereOfInfluence;
RV._autoAlignmentDistance = sphereOfInfluence * 1.5f; RV._autoAlignmentDistance = sphereOfInfluence * 1.5f;
@ -28,7 +29,7 @@ namespace NewHorizons.Builder.General
RV._matchAngularVelocity = true; RV._matchAngularVelocity = true;
RV._minMatchAngularVelocityDistance = 70; RV._minMatchAngularVelocityDistance = 70;
RV._maxMatchAngularVelocityDistance = 400; RV._maxMatchAngularVelocityDistance = 400;
RV._bracketsRadius = sphereOfInfluence; RV._bracketsRadius = module.bracketRadius > -1 ? module.bracketRadius : sphereOfInfluence;
RFV._referenceFrame = RV; RFV._referenceFrame = RV;
RFV._minColliderRadius = sphereOfInfluence; RFV._minColliderRadius = sphereOfInfluence;
@ -38,7 +39,7 @@ namespace NewHorizons.Builder.General
owrb.SetAttachedReferenceFrameVolume(RFV); owrb.SetAttachedReferenceFrameVolume(RFV);
rfGO.SetActive(!hide); rfGO.SetActive(!module.hideInMap);
} }
} }
} }

View File

@ -1,4 +1,4 @@
using NewHorizons.Components.Orbital; using NewHorizons.Components.Orbital;
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Handlers; using NewHorizons.Handlers;
@ -59,7 +59,7 @@ namespace NewHorizons.Builder.Orbital
fakeMassConfig.name = config.name + "_FakeBarycenterMass"; fakeMassConfig.name = config.name + "_FakeBarycenterMass";
fakeMassConfig.Base.sphereOfInfluence = 0; fakeMassConfig.Base.sphereOfInfluence = 0;
fakeMassConfig.Base.hasMapMarker = false; fakeMassConfig.Base.hasMapMarker = false;
fakeMassConfig.Base.hasReferenceFrame = false; fakeMassConfig.ReferenceFrame.hideInMap = true;
fakeMassConfig.Orbit = new OrbitModule(); fakeMassConfig.Orbit = new OrbitModule();
fakeMassConfig.Orbit.CopyPropertiesFrom(config.Orbit); fakeMassConfig.Orbit.CopyPropertiesFrom(config.Orbit);

View File

@ -101,6 +101,11 @@ namespace NewHorizons.External.Configs
/// </summary> /// </summary>
public PropModule Props; public PropModule Props;
/// <summary>
/// Reference frame properties of this body
/// </summary>
public ReferenceFrameModule ReferenceFrame;
/// <summary> /// <summary>
/// A list of paths to child GameObjects to destroy on this planet /// A list of paths to child GameObjects to destroy on this planet
/// </summary> /// </summary>
@ -162,6 +167,7 @@ namespace NewHorizons.External.Configs
if (Base == null) Base = new BaseModule(); if (Base == null) Base = new BaseModule();
if (Orbit == null) Orbit = new OrbitModule(); if (Orbit == null) Orbit = new OrbitModule();
if (ShipLog == null) ShipLog = new ShipLogModule(); if (ShipLog == null) ShipLog = new ShipLogModule();
if (ReferenceFrame == null) ReferenceFrame = new ReferenceFrameModule();
} }
public void MigrateAndValidate() public void MigrateAndValidate()
@ -195,6 +201,8 @@ namespace NewHorizons.External.Configs
if (Base.isSatellite) Base.showMinimap = false; if (Base.isSatellite) Base.showMinimap = false;
if (!Base.hasReferenceFrame) ReferenceFrame.hideInMap = true;
if (childrenToDestroy != null) removeChildren = childrenToDestroy; if (childrenToDestroy != null) removeChildren = childrenToDestroy;
if (Base.cloakRadius != 0) if (Base.cloakRadius != 0)

View File

@ -56,11 +56,6 @@ namespace NewHorizons.External.Modules
/// </summary> /// </summary>
public bool hasMapMarker; public bool hasMapMarker;
/// <summary>
/// Allows the object to be targeted on the map.
/// </summary>
[DefaultValue(true)] public bool hasReferenceFrame = true;
/// <summary> /// <summary>
/// Can this planet survive entering a star? /// Can this planet survive entering a star?
/// </summary> /// </summary>
@ -106,6 +101,9 @@ namespace NewHorizons.External.Modules
[Obsolete("HasAmbientLight is deprecated, please use AmbientLight instead")] [Obsolete("HasAmbientLight is deprecated, please use AmbientLight instead")]
public bool hasAmbientLight; public bool hasAmbientLight;
[Obsolete("HasReferenceFrame is deprecated, please use ReferenceModule instead")]
[DefaultValue(true)] public bool hasReferenceFrame = true;
[Obsolete("CloakRadius is deprecated, please use CloakModule instead")] [Obsolete("CloakRadius is deprecated, please use CloakModule instead")]
public float cloakRadius; public float cloakRadius;

View File

@ -0,0 +1,28 @@
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 ReferenceFrameModule
{
/// <summary>
/// Stop the object from being targeted on the map.
/// </summary>
public bool hideInMap;
/// <summary>
/// Radius of the brackets that show up when you target this. Defaults to the sphereOfInfluence.
/// </summary>
[DefaultValue(-1)] public float bracketRadius = -1;
/// <summary>
/// If it should be targetable even when super close.
/// </summary>
public bool targetWhenClose;
}
}

View File

@ -1,4 +1,4 @@
using NewHorizons.Builder.Atmosphere; using NewHorizons.Builder.Atmosphere;
using NewHorizons.Builder.Body; using NewHorizons.Builder.Body;
using NewHorizons.Builder.General; using NewHorizons.Builder.General;
using NewHorizons.Builder.Orbital; using NewHorizons.Builder.Orbital;
@ -306,7 +306,7 @@ namespace NewHorizons.Handlers
GravityBuilder.Make(go, ao, owRigidBody, body.Config); GravityBuilder.Make(go, ao, owRigidBody, body.Config);
} }
RFVolumeBuilder.Make(go, owRigidBody, sphereOfInfluence, !body.Config.Base.hasReferenceFrame); RFVolumeBuilder.Make(go, owRigidBody, sphereOfInfluence, body.Config.ReferenceFrame);
if (body.Config.Base.hasMapMarker) if (body.Config.Base.hasMapMarker)
{ {
@ -482,7 +482,7 @@ namespace NewHorizons.Handlers
// Has to go last probably // Has to go last probably
if (body.Config.Cloak != null && body.Config.Cloak.radius != 0f) if (body.Config.Cloak != null && body.Config.Cloak.radius != 0f)
{ {
CloakBuilder.Make(go, sector, rb, body.Config.Cloak, body.Config.Base.hasReferenceFrame, body.Mod); CloakBuilder.Make(go, sector, rb, body.Config.Cloak, !body.Config.ReferenceFrame.hideInMap, body.Mod);
} }
return go; return go;

View File

@ -428,11 +428,6 @@
"type": "boolean", "type": "boolean",
"description": "If the body should have a marker on the map screen." "description": "If the body should have a marker on the map screen."
}, },
"hasReferenceFrame": {
"type": "boolean",
"description": "Allows the object to be targeted on the map.",
"default": true
},
"invulnerableToSun": { "invulnerableToSun": {
"type": "boolean", "type": "boolean",
"description": "Can this planet survive entering a star?" "description": "Can this planet survive entering a star?"
@ -459,6 +454,26 @@
} }
} }
}, },
"ReferenceFrameModule": {
"type": "object",
"additionalProperties": false,
"properties": {
"hideInMap": {
"type": "boolean",
"description": "Stop the object from being targeted on the map."
},
"bracketRadius": {
"type": "number",
"description": "Radius of the brackets that show up when you target this. Defaults to the sphereOfInfluence.",
"format": "float",
"default": -1
},
"targetWhenClose": {
"type": "boolean",
"description": "If it should be targetable even when super close."
}
}
},
"MVector3": { "MVector3": {
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,