mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Zero Gravity Volume
This commit is contained in:
parent
75ce7349cf
commit
fa414929e3
@ -1,4 +1,4 @@
|
|||||||
using NewHorizons.External.Configs;
|
using NewHorizons.External.Configs;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
namespace NewHorizons.Builder.Atmosphere
|
namespace NewHorizons.Builder.Atmosphere
|
||||||
{
|
{
|
||||||
@ -6,7 +6,7 @@ namespace NewHorizons.Builder.Atmosphere
|
|||||||
{
|
{
|
||||||
private static readonly int FogColor = Shader.PropertyToID("_FogColor");
|
private static readonly int FogColor = Shader.PropertyToID("_FogColor");
|
||||||
|
|
||||||
public static void Make(GameObject planetGO, PlanetConfig config, float sphereOfInfluence)
|
public static void Make(GameObject planetGO, OWRigidbody owrb, PlanetConfig config, float sphereOfInfluence)
|
||||||
{
|
{
|
||||||
var innerRadius = config.Base.surfaceSize;
|
var innerRadius = config.Base.surfaceSize;
|
||||||
|
|
||||||
@ -48,6 +48,32 @@ namespace NewHorizons.Builder.Atmosphere
|
|||||||
}
|
}
|
||||||
ER._cloudMaterial = cloudMaterial;
|
ER._cloudMaterial = cloudMaterial;
|
||||||
|
|
||||||
|
if (config.Base.zeroGravityRadius != 0)
|
||||||
|
{
|
||||||
|
var zeroGObject = new GameObject("ZeroGVolume");
|
||||||
|
zeroGObject.transform.parent = volumesGO.transform;
|
||||||
|
zeroGObject.transform.localPosition = Vector3.zero;
|
||||||
|
zeroGObject.transform.localScale = Vector3.one * config.Base.zeroGravityRadius;
|
||||||
|
zeroGObject.layer = LayerMask.NameToLayer("BasicEffectVolume");
|
||||||
|
|
||||||
|
var sphereCollider = zeroGObject.AddComponent<SphereCollider>();
|
||||||
|
sphereCollider.radius = 1;
|
||||||
|
sphereCollider.isTrigger = true;
|
||||||
|
|
||||||
|
var owCollider = zeroGObject.AddComponent<OWCollider>();
|
||||||
|
owCollider._parentBody = owrb;
|
||||||
|
owCollider._collider = sphereCollider;
|
||||||
|
|
||||||
|
var triggerVolume = zeroGObject.AddComponent<OWTriggerVolume>();
|
||||||
|
triggerVolume._owCollider = owCollider;
|
||||||
|
|
||||||
|
var zeroGVolume = zeroGObject.AddComponent<ZeroGVolume>();
|
||||||
|
zeroGVolume._attachedBody = owrb;
|
||||||
|
zeroGVolume._triggerVolume = triggerVolume;
|
||||||
|
zeroGVolume._inheritable = true;
|
||||||
|
zeroGVolume._priority = 1;
|
||||||
|
}
|
||||||
|
|
||||||
volumesGO.transform.position = planetGO.transform.position;
|
volumesGO.transform.position = planetGO.transform.position;
|
||||||
rulesetGO.SetActive(true);
|
rulesetGO.SetActive(true);
|
||||||
volumesGO.SetActive(true);
|
volumesGO.SetActive(true);
|
||||||
|
|||||||
5
NewHorizons/External/Modules/BaseModule.cs
vendored
5
NewHorizons/External/Modules/BaseModule.cs
vendored
@ -81,6 +81,11 @@ namespace NewHorizons.External.Modules
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public float surfaceSize;
|
public float surfaceSize;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Radius of the zero gravity volume. This will make it so no gravity from any planet will affect you. Useful for satellites.
|
||||||
|
/// </summary>
|
||||||
|
public float zeroGravityRadius;
|
||||||
|
|
||||||
#region Obsolete
|
#region Obsolete
|
||||||
|
|
||||||
[Obsolete("IsSatellite is deprecated, please use ShowMinimap instead")]
|
[Obsolete("IsSatellite is deprecated, please use ShowMinimap instead")]
|
||||||
|
|||||||
@ -313,7 +313,7 @@ namespace NewHorizons.Handlers
|
|||||||
MarkerBuilder.Make(go, body.Config.name, body.Config);
|
MarkerBuilder.Make(go, body.Config.name, body.Config);
|
||||||
}
|
}
|
||||||
|
|
||||||
VolumesBuilder.Make(go, body.Config, sphereOfInfluence);
|
VolumesBuilder.Make(go, owRigidBody, body.Config, sphereOfInfluence);
|
||||||
|
|
||||||
if (body.Config.FocalPoint != null)
|
if (body.Config.FocalPoint != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -451,6 +451,11 @@
|
|||||||
"type": "number",
|
"type": "number",
|
||||||
"description": "A scale height used for a number of things. Should be the approximate radius of the body.",
|
"description": "A scale height used for a number of things. Should be the approximate radius of the body.",
|
||||||
"format": "float"
|
"format": "float"
|
||||||
|
},
|
||||||
|
"zeroGravityRadius": {
|
||||||
|
"type": "number",
|
||||||
|
"description": "Radius of the zero gravity sphere. This sphere will make gravity no longer affect you while you are inside it. Useful for satellites.",
|
||||||
|
"format": "float"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user