mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Allow rafts to be added to Giant's Deep and add acceleration option (#415)

This commit is contained in:
commit
01f719dee4
@ -3,7 +3,6 @@ using NewHorizons.Utility;
|
||||
using UnityEngine;
|
||||
using NewHorizons.External.Modules.VariableSize;
|
||||
using Tessellation;
|
||||
using NewHorizons.Components.Volumes;
|
||||
|
||||
namespace NewHorizons.Builder.Body
|
||||
{
|
||||
@ -80,7 +79,7 @@ namespace NewHorizons.Builder.Body
|
||||
var buoyancyTriggerVolume = buoyancyObject.AddComponent<OWTriggerVolume>();
|
||||
buoyancyTriggerVolume._owCollider = owCollider;
|
||||
|
||||
var fluidVolume = buoyancyObject.AddComponent<NHFluidVolume>();
|
||||
var fluidVolume = buoyancyObject.AddComponent<RadialFluidVolume>();
|
||||
fluidVolume._fluidType = FluidVolume.Type.WATER;
|
||||
fluidVolume._attachedBody = rb;
|
||||
fluidVolume._triggerVolume = buoyancyTriggerVolume;
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using NewHorizons.Components.Volumes;
|
||||
using NewHorizons.External.Modules;
|
||||
using NewHorizons.External.Modules;
|
||||
using NewHorizons.Handlers;
|
||||
using NewHorizons.Utility;
|
||||
using UnityEngine;
|
||||
@ -38,13 +37,15 @@ namespace NewHorizons.Builder.Props
|
||||
raftController._riverFluid = null;
|
||||
|
||||
raftController._sector = sector;
|
||||
raftController._acceleration = info.acceleration;
|
||||
sector.OnOccupantEnterSector += raftController.OnOccupantEnterSector;
|
||||
sector.OnOccupantExitSector += raftController.OnOccupantExitSector;
|
||||
|
||||
// Detectors
|
||||
var fluidDetector = raftObject.transform.Find("Detector_Raft").GetComponent<RaftFluidDetector>();
|
||||
var waterVolume = planetGO.GetComponentInChildren<NHFluidVolume>();
|
||||
var waterVolume = planetGO.GetComponentInChildren<RadialFluidVolume>();
|
||||
fluidDetector._alignmentFluid = waterVolume;
|
||||
fluidDetector._buoyancy.checkAgainstWaves = true;
|
||||
|
||||
// Light sensors
|
||||
foreach (var lightSensor in raftObject.GetComponentsInChildren<SingleLightSensor>())
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
using UnityEngine;
|
||||
namespace NewHorizons.Components.Volumes
|
||||
{
|
||||
public class NHFluidVolume : RadialFluidVolume
|
||||
{
|
||||
public override float GetDepthAtPosition(Vector3 worldPosition)
|
||||
{
|
||||
Vector3 vector = transform.InverseTransformPoint(worldPosition);
|
||||
float dist = Mathf.Sqrt(vector.x * vector.x + vector.z * vector.z + vector.y * vector.y);
|
||||
return dist - _radius;
|
||||
}
|
||||
}
|
||||
}
|
||||
5
NewHorizons/External/Modules/PropModule.cs
vendored
5
NewHorizons/External/Modules/PropModule.cs
vendored
@ -233,6 +233,11 @@ namespace NewHorizons.External.Modules
|
||||
/// Position of the raft
|
||||
/// </summary>
|
||||
public MVector3 position;
|
||||
|
||||
/// <summary>
|
||||
/// Acceleration of the raft. Default acceleration is 5.
|
||||
/// </summary>
|
||||
[DefaultValue(5f)] public float acceleration = 5f;
|
||||
}
|
||||
|
||||
[JsonObject]
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using HarmonyLib;
|
||||
using NewHorizons.Components.Volumes;
|
||||
using UnityEngine;
|
||||
namespace NewHorizons.Patches
|
||||
{
|
||||
@ -74,17 +73,17 @@ namespace NewHorizons.Patches
|
||||
}
|
||||
|
||||
[HarmonyReversePatch]
|
||||
[HarmonyPatch(typeof(AsymmetricFluidDetector), "ManagedFixedUpdate")]
|
||||
[HarmonyPatch(typeof(AsymmetricFluidDetector), nameof(AsymmetricFluidDetector.ManagedFixedUpdate))]
|
||||
public static void AsymmetricFluidDetector_ManagedFixedUpdate(AsymmetricFluidDetector __instance)
|
||||
{
|
||||
// This is like doing base.FixedUpdate
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(AlignToSurfaceFluidDetector), "ManagedFixedUpdate")]
|
||||
[HarmonyPatch(typeof(AlignToSurfaceFluidDetector), nameof(AlignToSurfaceFluidDetector.ManagedFixedUpdate))]
|
||||
public static bool AlignToSurfaceFluidDetector_ManagedFixedUpdate(AlignToSurfaceFluidDetector __instance)
|
||||
{
|
||||
if (!(__instance._alignmentFluid is NHFluidVolume)) return true;
|
||||
if (__instance._alignmentFluid is not RadialFluidVolume) return true;
|
||||
|
||||
// Mostly copy pasting from the AlignWithDirection class
|
||||
AsymmetricFluidDetector_ManagedFixedUpdate(__instance);
|
||||
@ -104,5 +103,16 @@ namespace NewHorizons.Patches
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(FluidVolume), nameof(FluidVolume.GetDepthAtPosition))]
|
||||
public static bool FluidVolume_GetDepthAtPosition(FluidVolume __instance, ref float __result, Vector3 worldPosition)
|
||||
{
|
||||
if (__instance is not RadialFluidVolume radialFluidVolume) return true;
|
||||
|
||||
Vector3 vector = radialFluidVolume.transform.InverseTransformPoint(worldPosition);
|
||||
__result = Mathf.Sqrt(vector.x * vector.x + vector.z * vector.z + vector.y * vector.y) - radialFluidVolume._radius;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1339,6 +1339,12 @@
|
||||
"position": {
|
||||
"description": "Position of the raft",
|
||||
"$ref": "#/definitions/MVector3"
|
||||
},
|
||||
"acceleration": {
|
||||
"type": "number",
|
||||
"description": "Acceleration of the raft. Default acceleration is 5.",
|
||||
"format": "float",
|
||||
"default": 5.0
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user