Fix raft docks not working on NH rafts

This commit is contained in:
xen-42 2025-01-28 23:02:44 -05:00
parent ffe41747fb
commit 06870db051
3 changed files with 39 additions and 0 deletions

View File

@ -459,6 +459,15 @@ namespace NewHorizons.Builder.Props
{ {
component.gameObject.AddComponent<NHRaftController>(); component.gameObject.AddComponent<NHRaftController>();
} }
else if (component is RaftDock dock)
{
// These flood toggles are to disable flooded docks on the Stranger
// Presumably the user isn't making one of those
foreach (var toggle in dock.GetComponents<FloodToggle>())
{
Component.DestroyImmediate(toggle);
}
}
} }
/// <summary> /// <summary>

View File

@ -66,6 +66,9 @@ namespace NewHorizons.Builder.Props
var waterVolume = planetGO.GetComponentInChildren<RadialFluidVolume>(); var waterVolume = planetGO.GetComponentInChildren<RadialFluidVolume>();
fluidDetector._alignmentFluid = waterVolume; fluidDetector._alignmentFluid = waterVolume;
fluidDetector._buoyancy.checkAgainstWaves = true; fluidDetector._buoyancy.checkAgainstWaves = true;
// Rafts were unable to trigger docks because these were disabled for some reason
fluidDetector.GetComponent<BoxShape>().enabled = true;
fluidDetector.GetComponent<OWCollider>().enabled = true;
// Light sensors // Light sensors
foreach (var lightSensor in raftObject.GetComponentsInChildren<SingleLightSensor>()) foreach (var lightSensor in raftObject.GetComponentsInChildren<SingleLightSensor>())

View File

@ -1,4 +1,5 @@
using HarmonyLib; using HarmonyLib;
using NewHorizons.Components.Props;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Patches.EchoesOfTheEyePatches namespace NewHorizons.Patches.EchoesOfTheEyePatches
@ -73,5 +74,31 @@ namespace NewHorizons.Patches.EchoesOfTheEyePatches
return false; return false;
} }
[HarmonyPostfix]
[HarmonyPatch(nameof(RaftController.UpdateMoveToTarget))]
public static void UpdateMoveToTarget(RaftController __instance)
{
// If it has a riverFluid volume then its a regular stranger one
if (__instance._movingToTarget && __instance._riverFluid == null)
{
OWRigidbody raftBody = __instance._raftBody;
OWRigidbody origParentBody = __instance._raftBody.GetOrigParentBody();
Transform transform = origParentBody.transform;
Vector3 vector = transform.TransformPoint(__instance._targetLocalPosition);
// Base game threshold has this at 1f (after doing smoothstep on it)
// For whatever reason it never hits that for NH planets (probably since they're moving so much compared to the steady velocity of the Stranger)
// Might break for somebody with a wacky spinning planet in which case we can adjust this or add some kind of fallback (i.e., wait x seconds and then just say its there)
// Fixes #1005
if (__instance.currentDistanceLerp > 0.999f)
{
raftBody.SetPosition(vector);
raftBody.SetRotation(transform.rotation * __instance._targetLocalRotation);
__instance.StopMovingToTarget();
__instance.OnArriveAtTarget.Invoke();
}
}
}
} }
} }