From bff39805cf2dbf1c5f054ffb9ec3100f9fbbdf7a Mon Sep 17 00:00:00 2001 From: soul Date: Wed, 25 Nov 2026 23:29:12 +0100 Subject: [PATCH] Wormhole warp: centre follows the wormhole the ship is at in each half The presenter stored the entered wormhole's position once, so the exit half pulled toward a point in the old zone. The ship already holds the wormhole position for the current half; expose it as Ship.WormholePosition and read it each frame, dropping the presenter's copy. Co-Authored-By: Claude Sonnet 5.5 --- Assets/Scripts/Gameplay/ActionGameManager.cs | 2 +- Assets/Scripts/ServerShared/Ship.cs | 4 ++++ Assets/Scripts/Zone Display/WormholeWarp.cs | 8 +++---- tests/Aetheria.Shared.Tests/SimClockTests.cs | 23 ++++++++++++++++++++ 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index 5b39a8ca7..51894dbbc 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -701,7 +701,7 @@ public class ActionGameManager : MonoBehaviour { if (!(CurrentEntity is Ship ship) || ship.WormholeAnimationInProgress) return; ship.EnterWormhole(wormhole.Position); - WormholeWarpPresenter.Begin(ship, wormhole.Position, DeathPost.gameObject.layer, + WormholeWarpPresenter.Begin(ship, DeathPost.gameObject.layer, Mathf.Max(DeathPost.priority, HeatstrokePost.priority, HypothermiaPost.priority, SevereHeatstrokePost.priority, SevereHypothermiaPost.priority) + 1); ship.OnEnteredWormhole += () => diff --git a/Assets/Scripts/ServerShared/Ship.cs b/Assets/Scripts/ServerShared/Ship.cs index 77d1c885d..922ab91b5 100644 --- a/Assets/Scripts/ServerShared/Ship.cs +++ b/Assets/Scripts/ServerShared/Ship.cs @@ -54,6 +54,10 @@ public class Ship : Entity : _exitingWormhole ? 1 - _wormholeAnimationProgress : 0; + // The wormhole the ship is at in the current half: the one it dives into, then the one it emerges from. Presenters + // read it (the screen warp centres on it); it is the sim's own position, so it needs no copy elsewhere. + public float2 WormholePosition => _wormholePosition; + public event Action OnExitedWormhole; public event Action OnEnteredWormhole; diff --git a/Assets/Scripts/Zone Display/WormholeWarp.cs b/Assets/Scripts/Zone Display/WormholeWarp.cs index 59ecbddc2..7646c1dfe 100644 --- a/Assets/Scripts/Zone Display/WormholeWarp.cs +++ b/Assets/Scripts/Zone Display/WormholeWarp.cs @@ -51,16 +51,14 @@ internal sealed class WormholeWarpRenderer : PostProcessEffectRenderer(); presenter._ship = ship; - presenter._wormhole = new Vector3(wormholePosition.x, 0, wormholePosition.y); presenter._settings = ScriptableObject.CreateInstance(); presenter._settings.enabled.Override(true); presenter._volume = PostProcessManager.instance.QuickVolume(layer, priority, presenter._settings); @@ -76,7 +74,9 @@ public sealed class WormholeWarpPresenter : MonoBehaviour _seenAnimation = true; var camera = Camera.main; if (camera == null) return; - var viewport = camera.WorldToViewportPoint(_wormhole); + // The wormhole the ship is at in this half, read from the ship each frame. + var wormhole = _ship.WormholePosition; + var viewport = camera.WorldToViewportPoint(new Vector3(wormhole.x, 0, wormhole.y)); _settings.Center.value = new Vector2(viewport.x, viewport.y); _settings.Strength.value = _ship.WormholeWarp; } diff --git a/tests/Aetheria.Shared.Tests/SimClockTests.cs b/tests/Aetheria.Shared.Tests/SimClockTests.cs index 9582c48f2..e053dc703 100644 --- a/tests/Aetheria.Shared.Tests/SimClockTests.cs +++ b/tests/Aetheria.Shared.Tests/SimClockTests.cs @@ -322,6 +322,29 @@ public sealed partial class RunStartTests Assert.Equal(0f, player.WormholeWarp); } + // The warp centres on the wormhole the ship is at in each half: the one it dives into, then the one it emerges from, + // which is a different place in the new zone. + [Fact] + public void ShipWormholePositionFollowsTheHalf() + { + var (arena, player) = LaunchDuel(); + var entered = player.Position.xz + float2(50, 0); + var emerging = player.Position.xz + float2(-300, 120); + var exiting = false; + var arrived = false; + player.OnEnteredWormhole += () => { player.ExitWormhole(emerging, float2(0, 40)); exiting = true; }; + player.OnExitedWormhole += () => arrived = true; + player.EnterWormhole(entered); + Assert.Equal(entered, player.WormholePosition); + for (var step = 0; step < 2000 && !arrived; step++) + { + arena.Update(ClockFrame); + if (arrived) break; + Assert.Equal(exiting ? emerging : entered, player.WormholePosition); + } + Assert.True(arrived && exiting, "the ship dives and emerges"); + } + // The turn a presenter draws ahead is the turn the next step makes: a ship held in a steady turn, drawn one whole // step ahead of the pose it was last given, is where the sim puts that pose next. [Fact]