mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Reference Frame Module
This commit is contained in:
parent
0e0766e870
commit
75ce7349cf
@ -1,4 +1,4 @@
|
||||
using NewHorizons.External.Configs;
|
||||
using NewHorizons.External.Configs;
|
||||
using NewHorizons.External.Modules;
|
||||
using NewHorizons.Handlers;
|
||||
using NewHorizons.Utility;
|
||||
@ -34,7 +34,6 @@ namespace NewHorizons.Builder.Body
|
||||
hasMapMarker = false,
|
||||
surfaceGravity = 1,
|
||||
surfaceSize = size,
|
||||
hasReferenceFrame = false,
|
||||
gravityFallOff = GravityFallOff.InverseSquared
|
||||
};
|
||||
|
||||
@ -49,6 +48,11 @@ namespace NewHorizons.Builder.Body
|
||||
showOrbitLine = false
|
||||
};
|
||||
|
||||
config.ReferenceFrame = new ReferenceFrameModule()
|
||||
{
|
||||
hideInMap = true
|
||||
};
|
||||
|
||||
config.ProcGen = belt.procGen;
|
||||
if (config.ProcGen == null)
|
||||
{
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
using NewHorizons.External.Configs;
|
||||
using NewHorizons.External.Modules;
|
||||
using UnityEngine;
|
||||
namespace NewHorizons.Builder.General
|
||||
{
|
||||
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");
|
||||
rfGO.transform.parent = planetGO.transform;
|
||||
@ -19,7 +20,7 @@ namespace NewHorizons.Builder.General
|
||||
var RFV = rfGO.AddComponent<ReferenceFrameVolume>();
|
||||
|
||||
var RV = new ReferenceFrame(owrb);
|
||||
RV._minSuitTargetDistance = sphereOfInfluence;
|
||||
RV._minSuitTargetDistance = module.targetWhenClose ? 0 : sphereOfInfluence;
|
||||
RV._maxTargetDistance = 0;
|
||||
RV._autopilotArrivalDistance = 2.0f * sphereOfInfluence;
|
||||
RV._autoAlignmentDistance = sphereOfInfluence * 1.5f;
|
||||
@ -28,7 +29,7 @@ namespace NewHorizons.Builder.General
|
||||
RV._matchAngularVelocity = true;
|
||||
RV._minMatchAngularVelocityDistance = 70;
|
||||
RV._maxMatchAngularVelocityDistance = 400;
|
||||
RV._bracketsRadius = sphereOfInfluence;
|
||||
RV._bracketsRadius = module.bracketRadius > -1 ? module.bracketRadius : sphereOfInfluence;
|
||||
|
||||
RFV._referenceFrame = RV;
|
||||
RFV._minColliderRadius = sphereOfInfluence;
|
||||
@ -38,7 +39,7 @@ namespace NewHorizons.Builder.General
|
||||
|
||||
owrb.SetAttachedReferenceFrameVolume(RFV);
|
||||
|
||||
rfGO.SetActive(!hide);
|
||||
rfGO.SetActive(!module.hideInMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using NewHorizons.Components.Orbital;
|
||||
using NewHorizons.Components.Orbital;
|
||||
using NewHorizons.External.Configs;
|
||||
using NewHorizons.External.Modules;
|
||||
using NewHorizons.Handlers;
|
||||
@ -59,7 +59,7 @@ namespace NewHorizons.Builder.Orbital
|
||||
fakeMassConfig.name = config.name + "_FakeBarycenterMass";
|
||||
fakeMassConfig.Base.sphereOfInfluence = 0;
|
||||
fakeMassConfig.Base.hasMapMarker = false;
|
||||
fakeMassConfig.Base.hasReferenceFrame = false;
|
||||
fakeMassConfig.ReferenceFrame.hideInMap = true;
|
||||
|
||||
fakeMassConfig.Orbit = new OrbitModule();
|
||||
fakeMassConfig.Orbit.CopyPropertiesFrom(config.Orbit);
|
||||
|
||||
8
NewHorizons/External/Configs/PlanetConfig.cs
vendored
8
NewHorizons/External/Configs/PlanetConfig.cs
vendored
@ -101,6 +101,11 @@ namespace NewHorizons.External.Configs
|
||||
/// </summary>
|
||||
public PropModule Props;
|
||||
|
||||
/// <summary>
|
||||
/// Reference frame properties of this body
|
||||
/// </summary>
|
||||
public ReferenceFrameModule ReferenceFrame;
|
||||
|
||||
/// <summary>
|
||||
/// A list of paths to child GameObjects to destroy on this planet
|
||||
/// </summary>
|
||||
@ -162,6 +167,7 @@ namespace NewHorizons.External.Configs
|
||||
if (Base == null) Base = new BaseModule();
|
||||
if (Orbit == null) Orbit = new OrbitModule();
|
||||
if (ShipLog == null) ShipLog = new ShipLogModule();
|
||||
if (ReferenceFrame == null) ReferenceFrame = new ReferenceFrameModule();
|
||||
}
|
||||
|
||||
public void MigrateAndValidate()
|
||||
@ -195,6 +201,8 @@ namespace NewHorizons.External.Configs
|
||||
|
||||
if (Base.isSatellite) Base.showMinimap = false;
|
||||
|
||||
if (!Base.hasReferenceFrame) ReferenceFrame.hideInMap = true;
|
||||
|
||||
if (childrenToDestroy != null) removeChildren = childrenToDestroy;
|
||||
|
||||
if (Base.cloakRadius != 0)
|
||||
|
||||
8
NewHorizons/External/Modules/BaseModule.cs
vendored
8
NewHorizons/External/Modules/BaseModule.cs
vendored
@ -56,11 +56,6 @@ namespace NewHorizons.External.Modules
|
||||
/// </summary>
|
||||
public bool hasMapMarker;
|
||||
|
||||
/// <summary>
|
||||
/// Allows the object to be targeted on the map.
|
||||
/// </summary>
|
||||
[DefaultValue(true)] public bool hasReferenceFrame = true;
|
||||
|
||||
/// <summary>
|
||||
/// Can this planet survive entering a star?
|
||||
/// </summary>
|
||||
@ -106,6 +101,9 @@ namespace NewHorizons.External.Modules
|
||||
[Obsolete("HasAmbientLight is deprecated, please use AmbientLight instead")]
|
||||
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")]
|
||||
public float cloakRadius;
|
||||
|
||||
|
||||
28
NewHorizons/External/Modules/ReferenceFrameModule.cs
vendored
Normal file
28
NewHorizons/External/Modules/ReferenceFrameModule.cs
vendored
Normal 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;
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
using NewHorizons.Builder.Atmosphere;
|
||||
using NewHorizons.Builder.Atmosphere;
|
||||
using NewHorizons.Builder.Body;
|
||||
using NewHorizons.Builder.General;
|
||||
using NewHorizons.Builder.Orbital;
|
||||
@ -306,7 +306,7 @@ namespace NewHorizons.Handlers
|
||||
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)
|
||||
{
|
||||
@ -482,7 +482,7 @@ namespace NewHorizons.Handlers
|
||||
// Has to go last probably
|
||||
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;
|
||||
|
||||
@ -428,11 +428,6 @@
|
||||
"type": "boolean",
|
||||
"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": {
|
||||
"type": "boolean",
|
||||
"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": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user