Tactical view, first cut: scroll zooms the flight camera out to a 3D zone schematic, sim time slows

TacticalView owns the zoom; blend, time rate, fade and schematic derive from camera
distance each frame. SimClock.Rate dilates real seconds fed, never Step.
Rulings tactical-view-is-zoom-out, tactical-view-in-runs-slow-time.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
soul 2026-11-25 23:00:47 +01:00
commit 0df1642d66
14 changed files with 409 additions and 5 deletions

View file

@ -36,6 +36,16 @@
"initialStateCheck": false,
"priority": 0
},
{
"name": "Zoom",
"type": "Value",
"id": "47ee174a-e711-4dd1-885c-f1cfbdd3681e",
"expectedControlType": "Axis",
"processors": "",
"interactions": "",
"initialStateCheck": true,
"priority": 0
},
{
"name": "Target Reticle",
"type": "Button",
@ -353,6 +363,17 @@
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "c2b6406d-0c48-47e1-ad45-9f05fc7b7017",
"path": "<Mouse>/scroll/y",
"interactions": "",
"processors": "",
"groups": "Keyboard&Mouse",
"action": "Zoom",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "5211a58c-428b-4ee6-820d-2f67789806d6",

View file

@ -122,6 +122,16 @@ public partial class @AetheriaInput: IInputActionCollection2, IDisposable
""initialStateCheck"": false,
""priority"": 0
},
{
""name"": ""Zoom"",
""type"": ""Value"",
""id"": ""47ee174a-e711-4dd1-885c-f1cfbdd3681e"",
""expectedControlType"": ""Axis"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": true,
""priority"": 0
},
{
""name"": ""Target Reticle"",
""type"": ""Button"",
@ -439,6 +449,17 @@ public partial class @AetheriaInput: IInputActionCollection2, IDisposable
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""c2b6406d-0c48-47e1-ad45-9f05fc7b7017"",
""path"": ""<Mouse>/scroll/y"",
""interactions"": """",
""processors"": """",
""groups"": ""Keyboard&Mouse"",
""action"": ""Zoom"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""5211a58c-428b-4ee6-820d-2f67789806d6"",
@ -1303,6 +1324,7 @@ public partial class @AetheriaInput: IInputActionCollection2, IDisposable
m_Player_Move = m_Player.FindAction("Move", throwIfNotFound: true);
m_Player_Look = m_Player.FindAction("Look", throwIfNotFound: true);
m_Player_MinimapZoom = m_Player.FindAction("Minimap Zoom", throwIfNotFound: true);
m_Player_Zoom = m_Player.FindAction("Zoom", throwIfNotFound: true);
m_Player_TargetReticle = m_Player.FindAction("Target Reticle", throwIfNotFound: true);
m_Player_TargetPrevious = m_Player.FindAction("Target Previous", throwIfNotFound: true);
m_Player_TargetNext = m_Player.FindAction("Target Next", throwIfNotFound: true);
@ -1422,6 +1444,7 @@ public partial class @AetheriaInput: IInputActionCollection2, IDisposable
private readonly InputAction m_Player_Move;
private readonly InputAction m_Player_Look;
private readonly InputAction m_Player_MinimapZoom;
private readonly InputAction m_Player_Zoom;
private readonly InputAction m_Player_TargetReticle;
private readonly InputAction m_Player_TargetPrevious;
private readonly InputAction m_Player_TargetNext;
@ -1461,6 +1484,10 @@ public partial class @AetheriaInput: IInputActionCollection2, IDisposable
/// </summary>
public InputAction @MinimapZoom => m_Wrapper.m_Player_MinimapZoom;
/// <summary>
/// Provides access to the underlying input action "Player/Zoom".
/// </summary>
public InputAction @Zoom => m_Wrapper.m_Player_Zoom;
/// <summary>
/// Provides access to the underlying input action "Player/TargetReticle".
/// </summary>
public InputAction @TargetReticle => m_Wrapper.m_Player_TargetReticle;
@ -1555,6 +1582,9 @@ public partial class @AetheriaInput: IInputActionCollection2, IDisposable
@MinimapZoom.started += instance.OnMinimapZoom;
@MinimapZoom.performed += instance.OnMinimapZoom;
@MinimapZoom.canceled += instance.OnMinimapZoom;
@Zoom.started += instance.OnZoom;
@Zoom.performed += instance.OnZoom;
@Zoom.canceled += instance.OnZoom;
@TargetReticle.started += instance.OnTargetReticle;
@TargetReticle.performed += instance.OnTargetReticle;
@TargetReticle.canceled += instance.OnTargetReticle;
@ -1620,6 +1650,9 @@ public partial class @AetheriaInput: IInputActionCollection2, IDisposable
@MinimapZoom.started -= instance.OnMinimapZoom;
@MinimapZoom.performed -= instance.OnMinimapZoom;
@MinimapZoom.canceled -= instance.OnMinimapZoom;
@Zoom.started -= instance.OnZoom;
@Zoom.performed -= instance.OnZoom;
@Zoom.canceled -= instance.OnZoom;
@TargetReticle.started -= instance.OnTargetReticle;
@TargetReticle.performed -= instance.OnTargetReticle;
@TargetReticle.canceled -= instance.OnTargetReticle;
@ -2101,6 +2134,13 @@ public partial class @AetheriaInput: IInputActionCollection2, IDisposable
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
void OnMinimapZoom(InputAction.CallbackContext context);
/// <summary>
/// Method invoked when associated input action "Zoom" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
/// </summary>
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
void OnZoom(InputAction.CallbackContext context);
/// <summary>
/// Method invoked when associated input action "Target Reticle" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
/// </summary>
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />

View file

@ -340,6 +340,30 @@ public class ActionGameManager : MonoBehaviour
ZoneRenderer.MinimapDistance = Settings.MinimapZoomLevels[_zoomLevelIndex];
};
// The tactical view is the camera pulled far out (ruling tactical-view-is-zoom-out): the wheel is the only input,
// and TacticalView the one owner of how far.
_tactical = new TacticalView(Settings.TacticalZoomStep, Settings.TacticalBlendStart, Settings.TacticalBlendEnd,
Settings.TacticalTimeScale, Settings.TacticalFitPerRadius);
_tacticalFade = ScriptableObject.CreateInstance<TacticalFade>();
_tacticalFade.enabled.Override(true);
_tacticalFade.Background.Override(Settings.TacticalBackground);
_tacticalVolume = PostProcessManager.instance.QuickVolume(DeathPost.gameObject.layer, 100f, _tacticalFade);
_tacticalVolume.weight = 0;
var schematic = new GameObject("Tactical Schematic Camera");
schematic.transform.SetParent(ZoneRenderer.MainCamera.transform, false);
_schematicCamera = schematic.AddComponent<Camera>();
_schematicCamera.clearFlags = CameraClearFlags.Depth;
_schematicCamera.depth = ZoneRenderer.MainCamera.depth + 1;
_schematicCamera.cullingMask = 1 << LayerMask.NameToLayer("Minimap");
_schematicCamera.enabled = false;
Input.Player.Zoom.performed += context =>
{
var scroll = context.ReadValue<float>();
if (scroll == 0 || !Flying) return;
_tactical.Step(-Mathf.Sign(scroll), BaseFollowDistance(CurrentEntity));
ApplyFraming(CurrentEntity);
};
Input.Global.ZoneMap.performed += context =>
{
ToggleMenuTab(MenuTab.Map);
@ -1080,6 +1104,7 @@ public class ActionGameManager : MonoBehaviour
}
CurrentEntity = entity;
_tactical.Reset(entity.Zone.Pack.Radius);
DeathPost.weight = 0;
ZoneRenderer.PerspectiveEntity = CurrentEntity;
@ -1217,6 +1242,14 @@ public class ActionGameManager : MonoBehaviour
}
private CinemachineFramingTransposer _framingTransposer;
private TacticalView _tactical;
private TacticalFade _tacticalFade;
private PostProcessVolume _tacticalVolume;
private Camera _schematicCamera;
private float _authoredFarClip;
// Flying: a ship under the player's hand, not docked. Everything tactical reads 0 otherwise.
private bool Flying => RunLive && CurrentEntity != null && DockedEntity == null;
// The one writer of the follow camera's Follow, LookAt and distance for an entity: the distance is
// the hull's reach (from its centre of mass, where Follow sits) times the authored ratio.
@ -1225,9 +1258,35 @@ public class ActionGameManager : MonoBehaviour
var instance = ZoneRenderer.EntityInstances[entity];
FollowCamera.LookAt = instance.LookAtPoint;
FollowCamera.Follow = instance.transform;
ApplyFraming(entity);
}
private float BaseFollowDistance(Entity entity) => Settings.FollowCameraDistancePerReach * Contacts.Radius(entity);
// The one writer of the follow camera's distance and far clip: the hull's framed distance times the tactical zoom,
// far enough to see the whole zone from there.
private void ApplyFraming(Entity entity)
{
if (_framingTransposer == null)
_framingTransposer = FollowCamera.GetCinemachineComponent<CinemachineFramingTransposer>();
_framingTransposer.m_CameraDistance = Settings.FollowCameraDistancePerReach * Contacts.Radius(entity);
if (_authoredFarClip == 0) _authoredFarClip = FollowCamera.m_Lens.FarClipPlane;
var distance = _tactical.Distance(BaseFollowDistance(entity));
_framingTransposer.m_CameraDistance = distance;
FollowCamera.m_Lens.FarClipPlane = Mathf.Max(_authoredFarClip, distance + 2 * entity.Zone.Pack.Radius);
}
// Everything the tactical view shows is read off the camera distance: the fade, the schematic, the map icons' size
// and the minimap cameras. Time is the Update line that feeds the clock.
private float TacticalBlend() => Flying && _framingTransposer != null
? _tactical.Blend(_framingTransposer.m_CameraDistance)
: 0f;
private void ShowTactical(float blend)
{
_tacticalVolume.weight = blend;
_schematicCamera.enabled = blend > 0;
ZoneRenderer.Map.SetTacticalScale(blend > 0 ? _framingTransposer.m_CameraDistance * Settings.TacticalIconSize : 0);
foreach (var camera in ZoneRenderer.MinimapCameras) camera.enabled = blend == 0;
}
private void UpdatePlayerPanel()
@ -1370,6 +1429,8 @@ public class ActionGameManager : MonoBehaviour
void Update()
{
var blend = TacticalBlend();
ShowTactical(blend);
if (!RunLive) return;
if(!_paused)
{
@ -1433,6 +1494,7 @@ public class ActionGameManager : MonoBehaviour
void EnterNewZone() { if (_zoneEntered) { Clock.Reset(); _zoneEntered = false; } }
EnterNewZone();
var steppedZone = Zone;
Clock.Rate = _tactical.TimeRate(blend);
Clock.Advance(_paused ? 0f : Time.deltaTime, delta =>
{
if (Zone != steppedZone) return;
@ -1522,6 +1584,11 @@ public class ActionGameManager : MonoBehaviour
private void LateUpdate()
{
// The schematic camera is the game camera's pose and lens, seeing only the map's layer.
var output = ZoneRenderer.MainCamera;
_schematicCamera.fieldOfView = output.fieldOfView;
_schematicCamera.nearClipPlane = output.nearClipPlane;
_schematicCamera.farClipPlane = output.farClipPlane;
UpdateTargetIndicators();
}

View file

@ -24,6 +24,20 @@ public class GameSettings : ScriptableObject
public int AsteroidMeshCount = 5;
public float MinimapAsteroidSize = 3;
public float MinimapIconSize = 1f / 32;
// Tactical view (rulings tactical-view-is-zoom-out, tactical-view-in-runs-slow-time): one wheel notch multiplies the
// follow camera distance by this.
public float TacticalZoomStep = 1.25f;
// The camera distance (m) where the scene starts to fade to the schematic, and where it is fully faded.
public float TacticalBlendStart = 250;
public float TacticalBlendEnd = 1000;
// Sim seconds per real second at full fade (about 100x slower).
public float TacticalTimeScale = .01f;
// The farthest zoom, as a multiple of the zone radius.
public float TacticalFitPerRadius = 2;
// Schematic icon size as a fraction of the camera distance.
public float TacticalIconSize = 1f / 40;
// The colour the scene fades toward.
public Color TacticalBackground = new Color(.02f, .03f, .05f, 1);
public float PlanetRotationSpeed = 1;
public SectorBackgroundSettings CastBackgroundSettings;
public SectorBackgroundSettings SectorBackgroundSettings;

View file

@ -53,11 +53,22 @@ public sealed class SimClock
_accumulator = 0;
}
private float _rate = 1f;
// Real-time dilation: how much sim time a real second buys, in (0, 1]. It scales the real seconds fed and never
// changes Step, so every step and trajectory is the same and only the wall-clock pace differs. Its one writer is
// ActionGameManager, from TacticalView.TimeRate.
public float Rate
{
get => _rate;
set => _rate = Math.Min(Math.Max(value, float.Epsilon), 1f);
}
// Feeds real seconds (negative counts as none, one frame counts at most MaxFrameSeconds) and runs the whole
// steps they pay for. Returns how many ran.
public int Advance(float realSeconds, Action<float> step)
{
_accumulator += Math.Min(Math.Max(realSeconds, 0f), MaxFrameSeconds);
_accumulator += Math.Min(Math.Max(realSeconds, 0f), MaxFrameSeconds) * (double) Rate;
var ran = 0;
_advancing = true;
try

View file

@ -0,0 +1,56 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using static CultMath.math;
// The one owner of the flight camera's zoom (rulings tactical-view-is-zoom-out, tactical-view-in-runs-slow-time).
// Nothing stores an "in tactical" state: the tactical view is how far out the camera is. Zoom is the only state;
// distance, blend and the time rate are derived from it, each frame, by whoever draws or steps.
public sealed class TacticalView
{
private readonly float _zoomStep, _blendStart, _blendEnd, _timeScale, _fitPerRadius;
private float _zoneRadius;
public TacticalView(float zoomStep, float blendStart, float blendEnd, float timeScale, float fitPerRadius)
{
_zoomStep = zoomStep;
_blendStart = blendStart;
_blendEnd = blendEnd;
_timeScale = timeScale;
_fitPerRadius = fitPerRadius;
}
// The multiple of the framed distance the camera sits at, >= 1.
public float Zoom { get; private set; } = 1;
// The farthest the camera goes: the whole zone in view.
public float MaxDistance => _zoneRadius * _fitPerRadius;
// Each notch multiplies Zoom by ZoomStep (negative notches zoom in). Never inside the hull's framing, never past
// the whole zone.
public void Step(float notches, float baseDistance)
{
var ceiling = MaxDistance > baseDistance && baseDistance > 0 ? MaxDistance / baseDistance : 1f;
Zoom = clamp(Zoom * pow(_zoomStep, notches), 1f, ceiling);
}
// Back to the hull's own framing, in the zone the camera is now in.
public void Reset(float zoneRadius)
{
_zoneRadius = zoneRadius;
Zoom = 1;
}
public float Distance(float baseDistance) => min(baseDistance * Zoom, max(MaxDistance, baseDistance));
// 0 at or below the band's near edge, 1 at or above its far edge, smooth in the logarithm of distance between.
public float Blend(float distance)
{
var t = saturate((log(max(distance, 1e-6f)) - log(_blendStart)) / (log(_blendEnd) - log(_blendStart)));
return t * t * (3 - 2 * t);
}
// Real seconds feed the sim clock at this rate: 1 in flight, TacticalTimeScale fully zoomed out.
public float TimeRate(float blend) => pow(_timeScale, saturate(blend));
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c994fb45f71d4a7fa9ed80a9ab8b034d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -48,7 +48,7 @@ public class MapPresenter
private readonly Dictionary<Entity, Icon> _entityIcons = new Dictionary<Entity, Icon>();
private readonly Material[] _gravityMaterials;
private readonly int _layer = LayerMask.NameToLayer("Minimap");
private float _minimapScale = 1, _mapScreenScale;
private float _minimapScale = 1, _mapScreenScale, _tacticalScale;
private bool _mapScreenOpen;
private readonly Material _asteroidMaterial;
private readonly Vector4 _spriteSheet;
@ -63,8 +63,10 @@ public class MapPresenter
_asteroidSize = asteroidSize;
}
// The icon size: the map screen's scale while it is open, else the minimap's zoom.
public float IconSize => _mapScreenOpen ? _mapScreenScale : _minimapScale;
// The icon size: the map screen's scale while it is open, else the tactical scale while the schematic shows, else
// the minimap's zoom.
public float IconSize => _mapScreenOpen ? _mapScreenScale : _tacticalScale > 0 ? _tacticalScale : _minimapScale;
public void SetTacticalScale(float scale) => _tacticalScale = scale;
public void SetMinimapScale(float scale) => _minimapScale = scale;
public void OpenMapScreen(bool open) => _mapScreenOpen = open;

View file

@ -0,0 +1,32 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
// The tactical view's fade (ruling tactical-view-is-zoom-out): after the post stack the scene colour lerps toward the
// background by Strength. The volume's weight is the tactical blend, so Strength stays 1 and the fade is derived from
// camera distance like everything else about the view.
[Serializable]
[PostProcess(typeof(TacticalFadeRenderer), PostProcessEvent.AfterStack, "Aetheria/Tactical Fade", false)]
public sealed class TacticalFade : PostProcessEffectSettings
{
[Range(0, 1)] public FloatParameter Strength = new FloatParameter { value = 1 };
public ColorParameter Background = new ColorParameter { value = Color.black };
}
public sealed class TacticalFadeRenderer : PostProcessEffectRenderer<TacticalFade>
{
private static readonly int StrengthId = Shader.PropertyToID("_Strength");
private static readonly int BackgroundId = Shader.PropertyToID("_Background");
public override void Render(PostProcessRenderContext context)
{
var sheet = context.propertySheets.Get(Shader.Find("Aetheria/PostProcessing/TacticalFade"));
sheet.properties.SetFloat(StrengthId, settings.Strength);
sheet.properties.SetColor(BackgroundId, settings.Background);
context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, 0);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: edb50c44dcb243aeacbc04ec22a8d013
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,28 @@
Shader "Aetheria/PostProcessing/TacticalFade"
{
// Lerps the scene colour toward a flat background by Strength: the scene fades out as the tactical view comes in.
// The schematic camera renders after the post stack, so this never dims it.
SubShader
{
Cull Off ZWrite Off ZTest Always
Pass
{
HLSLPROGRAM
#pragma vertex VertDefault
#pragma fragment Frag
#include "Packages/com.unity.postprocessing/PostProcessing/Shaders/StdLib.hlsl"
TEXTURE2D_SAMPLER2D(_MainTex, sampler_MainTex);
float _Strength;
float4 _Background;
float4 Frag(VaryingsDefault i) : SV_Target
{
float4 scene = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoordStereo);
return float4(lerp(scene.rgb, _Background.rgb, saturate(_Strength)), scene.a);
}
ENDHLSL
}
}
}

View file

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 20fc266aaa8644d392ec11bfaf7fc4f3
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:

View file

@ -410,4 +410,31 @@ public sealed partial class RunStartTests
Assert.True(all(Close(Axis(turned, float3(0, 1, 0)), upBefore) < tolerance), "the pose's up does not move");
Assert.True(all(Close(Axis(turned, float3(0, 0, 1)), rodrigues) < tolerance), "the forward axis swings about it by the angle");
}
// Rate dilates the real seconds fed, never the step: sixteen frames of one period's real time at Rate 1/16 (all exact in
// binary) buy exactly one step, and that step is the same Step.
[Fact]
public void RateDilatesRealTimeWithoutChangingStep()
{
var clock = new SimClock(1f / 32, 32) { Rate = 1f / 16 };
var passed = new List<float>();
for (var frame = 0; frame < 15; frame++) clock.Advance(1f / 32, dt => passed.Add(dt));
Assert.Empty(passed);
clock.Advance(1f / 32, dt => passed.Add(dt));
Assert.Equal(new[] { 1f / 32 }, passed);
Assert.Equal(1f / 32, clock.Step);
// The frame clamp comes first: a hitch at Rate .5 pays MaxFrameSeconds x .5, not the hitch.
var hitch = new SimClock(1f / 32, 32) { Rate = .5f };
Assert.Equal((int) (SimClock.MaxFrameSeconds * .5f * 32), hitch.Advance(10f, _ => { }));
// The game's own rate over ten real seconds at Rate .01: a tenth of a sim second of steps, every one GameStep.
var game = SimClock.ForGame();
game.Rate = .01f;
var deltas = new List<float>();
for (var frame = 0; frame < 600; frame++) game.Advance(1f / 60, dt => deltas.Add(dt));
Assert.InRange(deltas.Count, 2, 4);
Assert.All(deltas, dt => Assert.Equal(SimClock.GameStep, dt));
Assert.Equal(1f, new SimClock(1f / 60, 60).Rate);
}
}

View file

@ -0,0 +1,74 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using Xunit;
// TacticalView owns the flight camera's zoom; blend and time rate are derived from the distance, never stored.
public sealed class TacticalViewTests
{
private const float Radius = 20000, Fit = 2, Start = 250, End = 1000, Scale = .01f, BaseDistance = 30;
private static TacticalView Make()
{
var view = new TacticalView(1.25f, Start, End, Scale, Fit);
view.Reset(Radius);
return view;
}
[Fact]
public void ZoomIsClampedToFlightAndTheWholeZone()
{
var view = Make();
view.Step(-5, BaseDistance);
Assert.Equal(1f, view.Zoom);
Assert.Equal(BaseDistance, view.Distance(BaseDistance));
for (var i = 0; i < 200; i++) view.Step(1, BaseDistance);
Assert.Equal(Radius * Fit, view.Distance(BaseDistance));
Assert.True(view.Zoom <= Radius * Fit / BaseDistance + 1e-3f);
view.Step(1, BaseDistance);
Assert.Equal(Radius * Fit, view.Distance(BaseDistance));
view.Step(-2, BaseDistance);
Assert.True(view.Distance(BaseDistance) < Radius * Fit);
view.Reset(Radius);
Assert.Equal(BaseDistance, view.Distance(BaseDistance));
// A hull framed wider than the zone's fit still never sits closer than its own framing.
Assert.Equal(Radius * Fit * 2, view.Distance(Radius * Fit * 2));
}
[Fact]
public void BlendRisesMonotonicallyAcrossTheBand()
{
var view = Make();
Assert.Equal(0f, view.Blend(BaseDistance));
Assert.Equal(0f, view.Blend(Start));
Assert.Equal(1f, view.Blend(End));
Assert.Equal(1f, view.Blend(Radius * Fit));
var last = 0f;
for (var distance = Start; distance <= End; distance += 5)
{
var blend = view.Blend(distance);
Assert.InRange(blend, last, 1f);
last = blend;
}
Assert.InRange(view.Blend(Start * 1.01f), 0f, .05f);
Assert.InRange(view.Blend(End / 1.01f), .95f, 1f);
}
[Fact]
public void TimeRateIsOneInFlightAndTheScaleInTactical()
{
var view = Make();
Assert.Equal(1f, view.TimeRate(0));
Assert.Equal(Scale, view.TimeRate(1), 6);
var last = 1f;
for (var blend = 0f; blend <= 1f; blend += .05f)
{
var rate = view.TimeRate(blend);
Assert.InRange(rate, Scale - 1e-6f, last);
last = rate;
}
// Flying never sees it: every distance at or under the near edge runs at full speed.
Assert.Equal(1f, view.TimeRate(view.Blend(Start)));
}
}