mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Cap gravity alignment radius at outer cloud radius
This commit is contained in:
parent
37a3dd969f
commit
98393f9909
@ -19,46 +19,50 @@ namespace NewHorizons.Builder.General
|
|||||||
else gravityRadius = Mathf.Min(gravityRadius, 15 * config.Base.SurfaceSize);
|
else gravityRadius = Mathf.Min(gravityRadius, 15 * config.Base.SurfaceSize);
|
||||||
if (config.Base.SphereOfInfluence != 0f) gravityRadius = config.Base.SphereOfInfluence;
|
if (config.Base.SphereOfInfluence != 0f) gravityRadius = config.Base.SphereOfInfluence;
|
||||||
|
|
||||||
GameObject gravityGO = new GameObject("GravityWell");
|
var gravityGO = new GameObject("GravityWell");
|
||||||
gravityGO.transform.parent = planetGO.transform;
|
gravityGO.transform.parent = planetGO.transform;
|
||||||
gravityGO.transform.localPosition = Vector3.zero;
|
gravityGO.transform.localPosition = Vector3.zero;
|
||||||
gravityGO.layer = 17;
|
gravityGO.layer = 17;
|
||||||
gravityGO.SetActive(false);
|
gravityGO.SetActive(false);
|
||||||
|
|
||||||
SphereCollider SC = gravityGO.AddComponent<SphereCollider>();
|
var SC = gravityGO.AddComponent<SphereCollider>();
|
||||||
SC.isTrigger = true;
|
SC.isTrigger = true;
|
||||||
SC.radius = gravityRadius;
|
SC.radius = gravityRadius;
|
||||||
|
|
||||||
OWCollider OWC = gravityGO.AddComponent<OWCollider>();
|
var owCollider = gravityGO.AddComponent<OWCollider>();
|
||||||
OWC.SetLODActivationMask(DynamicOccupant.Player);
|
owCollider.SetLODActivationMask(DynamicOccupant.Player);
|
||||||
|
|
||||||
OWTriggerVolume OWTV = gravityGO.AddComponent<OWTriggerVolume>();
|
var owTriggerVolume = gravityGO.AddComponent<OWTriggerVolume>();
|
||||||
|
|
||||||
GravityVolume GV = gravityGO.AddComponent<GravityVolume>();
|
var gravityVolume = gravityGO.AddComponent<GravityVolume>();
|
||||||
GV._cutoffAcceleration = 0.1f;
|
gravityVolume._cutoffAcceleration = 0.1f;
|
||||||
|
|
||||||
GravityVolume.FalloffType falloff = GravityVolume.FalloffType.linear;
|
GravityVolume.FalloffType falloff = GravityVolume.FalloffType.linear;
|
||||||
if (config.Base.GravityFallOff.ToUpper().Equals("LINEAR")) falloff = GravityVolume.FalloffType.linear;
|
if (config.Base.GravityFallOff.ToUpper().Equals("LINEAR")) falloff = GravityVolume.FalloffType.linear;
|
||||||
else if (config.Base.GravityFallOff.ToUpper().Equals("INVERSESQUARED")) falloff = GravityVolume.FalloffType.inverseSquared;
|
else if (config.Base.GravityFallOff.ToUpper().Equals("INVERSESQUARED")) falloff = GravityVolume.FalloffType.inverseSquared;
|
||||||
else Logger.LogError($"Couldn't set gravity type {config.Base.GravityFallOff}. Must be either \"linear\" or \"inverseSquared\". Defaulting to linear.");
|
else Logger.LogError($"Couldn't set gravity type {config.Base.GravityFallOff}. Must be either \"linear\" or \"inverseSquared\". Defaulting to linear.");
|
||||||
GV._falloffType = falloff;
|
gravityVolume._falloffType = falloff;
|
||||||
|
|
||||||
GV._alignmentRadius = config.Base.SurfaceGravity != 0 ? 1.5f * config.Base.SurfaceSize : 0f;
|
// Radius where your feet turn to the planet
|
||||||
GV._upperSurfaceRadius = config.Base.SurfaceSize;
|
var alignmentRadius = config.Atmosphere?.Clouds?.OuterCloudRadius ?? 1.5f * config.Base.SurfaceSize;
|
||||||
GV._lowerSurfaceRadius = 0;
|
if (config.Base.SurfaceGravity == 0) alignmentRadius = 0;
|
||||||
GV._layer = 3;
|
|
||||||
GV._priority = 0;
|
gravityVolume._alignmentRadius = alignmentRadius;
|
||||||
GV._alignmentPriority = 0;
|
gravityVolume._upperSurfaceRadius = config.Base.SurfaceSize;
|
||||||
GV._surfaceAcceleration = config.Base.SurfaceGravity;
|
gravityVolume._lowerSurfaceRadius = 0;
|
||||||
GV._inheritable = false;
|
gravityVolume._layer = 3;
|
||||||
GV._isPlanetGravityVolume = true;
|
gravityVolume._priority = 0;
|
||||||
GV._cutoffRadius = 0f;
|
gravityVolume._alignmentPriority = 0;
|
||||||
|
gravityVolume._surfaceAcceleration = config.Base.SurfaceGravity;
|
||||||
|
gravityVolume._inheritable = false;
|
||||||
|
gravityVolume._isPlanetGravityVolume = true;
|
||||||
|
gravityVolume._cutoffRadius = 0f;
|
||||||
|
|
||||||
gravityGO.SetActive(true);
|
gravityGO.SetActive(true);
|
||||||
|
|
||||||
ao._gravityVolume = GV;
|
ao._gravityVolume = gravityVolume;
|
||||||
|
|
||||||
return GV;
|
return gravityVolume;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,23 +1,24 @@
|
|||||||
using UnityEngine;
|
using NewHorizons.External.Configs;
|
||||||
|
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 owRigidBody, float sphereOfInfluence)
|
public static void Make(GameObject planetGO, OWRigidbody owRigidBody, float sphereOfInfluence)
|
||||||
{
|
{
|
||||||
GameObject rfGO = new GameObject("RFVolume");
|
var rfGO = new GameObject("RFVolume");
|
||||||
rfGO.transform.parent = planetGO.transform;
|
rfGO.transform.parent = planetGO.transform;
|
||||||
rfGO.transform.localPosition = Vector3.zero;
|
rfGO.transform.localPosition = Vector3.zero;
|
||||||
rfGO.layer = 19;
|
rfGO.layer = 19;
|
||||||
rfGO.SetActive(false);
|
rfGO.SetActive(false);
|
||||||
|
|
||||||
SphereCollider SC = rfGO.AddComponent<SphereCollider>();
|
var SC = rfGO.AddComponent<SphereCollider>();
|
||||||
SC.isTrigger = true;
|
SC.isTrigger = true;
|
||||||
SC.radius = sphereOfInfluence * 2;
|
SC.radius = sphereOfInfluence * 2;
|
||||||
|
|
||||||
ReferenceFrameVolume RFV = rfGO.AddComponent<ReferenceFrameVolume>();
|
var RFV = rfGO.AddComponent<ReferenceFrameVolume>();
|
||||||
|
|
||||||
ReferenceFrame RV = new ReferenceFrame(owRigidBody);
|
var RV = new ReferenceFrame(owRigidBody);
|
||||||
RV._minSuitTargetDistance = sphereOfInfluence;
|
RV._minSuitTargetDistance = sphereOfInfluence;
|
||||||
RV._maxTargetDistance = 0;
|
RV._maxTargetDistance = 0;
|
||||||
RV._autopilotArrivalDistance = 2.0f * sphereOfInfluence;
|
RV._autopilotArrivalDistance = 2.0f * sphereOfInfluence;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user