Outer-Wilds-New-Horizons / new-horizons

A tool for modifying or creating new planets, dialogue, ship logs, and more for Outer Wilds.
https://nh.outerwildsmods.com/
MIT License
42 stars 15 forks source link

Rafts Broken in Custom Water Volumes #846

Closed Hawkbat closed 1 month ago

Hawkbat commented 2 months ago

What Happened?

Currently rafts spawned using the dedicated rafts prop module always assume that the primary water fluid volume used to align the raft upward will be the planet's spherical water volume (set using the Water planet module). If the raft enters a custom RadialFluidVolume made using the fluidVolumes volume module or in Unity, it will use the planet's water volume for alignment instead of the custom volume. This usually causes the raft to consider itself never submerged, tumble wildly, and be uncontrollable.

If the planet has no planetary water volume at all, the raft instead throws a NullReferenceException error every FixedUpdate() because __instance._fluidDetector._alignmentFluid is null, and exhibits similar weird physics behavior.

What was supposed to happen?

The raft should not throw errors or behave strangely when entering a non-planet-sphere water volume.

Platform

Steam

Mods

Common Camera Utility, Custom Ship Log Modes, Menu Framework, Mod Data Tools, New Horizons, No Alt Tab Pause, Screenshot Tool, Ship Light Toggle, Sound Test, Unity Explorer, Vanilla Fix, WrongWarp

Logs

No response

Hawkbat commented 2 months ago

For Wrong Warp, we've fixed this by dynamically reassigning the raft's alignment fluid with the following patch:

[HarmonyPrefix, HarmonyPatch(typeof(AlignToSurfaceFluidDetector), nameof(AlignToSurfaceFluidDetector.OnVolumeActivated))]
public static void AlignToSurfaceFluidDetector_OnVolumeActivated(AlignToSurfaceFluidDetector __instance, PriorityVolume volume)
{
    if (!WrongWarpMod.Instance.IsInWrongWarpSystem) return;
    if (__instance is not RaftFluidDetector) return;
    if (volume is FluidVolume fluidVolume)
    {
        __instance._alignmentFluid = fluidVolume;
    }
}

But I haven't tested extensively to see if this would negatively impact the existing rafts in the Stranger or Dream World.