Prove released authoritative aim and camera channels

This commit is contained in:
Meta Vens 2026-07-15 06:14:49 +01:00
commit 68aba5f67b
5 changed files with 66 additions and 26 deletions

View file

@ -188,6 +188,7 @@ namespace GameCult.EveUnity.GenericClient.PlayModeTests
EveUnityPlayableWorldClientHost host = null; EveUnityPlayableWorldClientHost host = null;
EveUnityPlayableWorldRuntime runtime = null; EveUnityPlayableWorldRuntime runtime = null;
WitnessReceipt movementReceipt = null; WitnessReceipt movementReceipt = null;
WitnessReceipt lookReceipt = null;
WitnessReceipt focusReceipt = null; WitnessReceipt focusReceipt = null;
WitnessReceipt actionReceipt = null; WitnessReceipt actionReceipt = null;
EveUnityShotReceipt observedShot = null; EveUnityShotReceipt observedShot = null;
@ -196,6 +197,7 @@ namespace GameCult.EveUnity.GenericClient.PlayModeTests
float hullRatioBefore = 0f; float hullRatioBefore = 0f;
long initialVersion = 0; long initialVersion = 0;
float movementDistance = 0f; float movementDistance = 0f;
float aimDotDistance = 0f;
try try
{ {
@ -344,18 +346,24 @@ namespace GameCult.EveUnity.GenericClient.PlayModeTests
aim.y = 0; aim.y = 0;
Assert.That(aim.sqrMagnitude, Is.GreaterThan(0.0001f)); Assert.That(aim.sqrMagnitude, Is.GreaterThan(0.0001f));
aim.Normalize(); aim.Normalize();
var steerVersion = runtime.ActiveVersion; var lookVersion = runtime.ActiveVersion;
var steer = runtime.SubmitMoveVectorIntent(playerId, aim.x, aim.z, 0.25f); var look = runtime.SubmitLookDirectionIntent(playerId, aim.x, 0f, aim.z);
var steerDeadline = Time.realtimeSinceStartup + 12f; var lookDeadline = Time.realtimeSinceStartup + 12f;
while (Time.realtimeSinceStartup < steerDeadline && while (Time.realtimeSinceStartup < lookDeadline &&
(runtime.LastReceipt == null || runtime.LastReceipt.CommandId != steer.CommandId || (runtime.LastReceipt == null || runtime.LastReceipt.CommandId != look.CommandId ||
!string.Equals(runtime.LastReceipt.State, "reconciled", StringComparison.OrdinalIgnoreCase))) !string.Equals(runtime.LastReceipt.State, "reconciled", StringComparison.OrdinalIgnoreCase) ||
runtime.ActiveVersion < runtime.LastReceipt.SourceVersion ||
Vector3.Dot(FindMarker(root, playerId).transform.forward, aim) < 0.99f))
{ {
yield return new WaitForSecondsRealtime(0.1f); yield return new WaitForSecondsRealtime(0.1f);
runtime.Refresh(); runtime.Refresh();
} }
AssertReconciledProviderReceipt(runtime.LastReceipt, steer.CommandId, AssertReconciledProviderReceipt(runtime.LastReceipt, look.CommandId,
provider.Selection.ProviderId, provider.Selection.SurfaceId, steerVersion); provider.Selection.ProviderId, provider.Selection.SurfaceId, lookVersion);
Assert.That(Vector3.Dot(FindMarker(root, playerId).transform.forward, aim), Is.GreaterThan(0.99f));
lookReceipt = WitnessReceipt.From("look", runtime.LastReceipt);
var aimRenderer = root.GetComponent<EveUnityAimPresentationRenderer>();
Assert.That(aimRenderer, Is.Not.Null);
var focusVersion = runtime.ActiveVersion; var focusVersion = runtime.ActiveVersion;
var inputDriver = root.GetComponent<EveUnityPlayableWorldInputDriver>() ?? var inputDriver = root.GetComponent<EveUnityPlayableWorldInputDriver>() ??
@ -448,6 +456,10 @@ namespace GameCult.EveUnity.GenericClient.PlayModeTests
cameraRig.CameraTransform = camera.transform; cameraRig.CameraTransform = camera.transform;
cameraRig.RenderPolicySource = provider; cameraRig.RenderPolicySource = provider;
Assert.That(cameraRig.ApplyRig(0f), Is.True); Assert.That(cameraRig.ApplyRig(0f), Is.True);
aimRenderer.RefreshNow();
Assert.That(aimRenderer.ViewDotVisible, Is.True);
aimDotDistance = Vector3.Distance(playerMarker.transform.position, aimRenderer.ViewDotPosition);
Assert.That(aimDotDistance, Is.GreaterThanOrEqualTo(49.9f));
Assert.That(camera.cullingMask & (1 << mapLayer), Is.Zero); Assert.That(camera.cullingMask & (1 << mapLayer), Is.Zero);
Assert.That(camera.fieldOfView, Is.EqualTo(60f).Within(0.001f)); Assert.That(camera.fieldOfView, Is.EqualTo(60f).Within(0.001f));
var playerViewport = camera.WorldToViewportPoint(playerMarker.transform.position); var playerViewport = camera.WorldToViewportPoint(playerMarker.transform.position);
@ -504,6 +516,7 @@ namespace GameCult.EveUnity.GenericClient.PlayModeTests
(camera.cullingMask & (1 << mapLayer)) == 0, (camera.cullingMask & (1 << mapLayer)) == 0,
(mapCamera.cullingMask & (1 << mapLayer)) != 0, (mapCamera.cullingMask & (1 << mapLayer)) != 0,
movementReceipt, movementReceipt,
lookReceipt,
focusReceipt, focusReceipt,
actionReceipt, actionReceipt,
observedShot, observedShot,
@ -511,7 +524,8 @@ namespace GameCult.EveUnity.GenericClient.PlayModeTests
observedCombat?.ShieldRatio ?? shieldRatioBefore, observedCombat?.ShieldRatio ?? shieldRatioBefore,
hullRatioBefore, hullRatioBefore,
observedCombat?.HullRatio ?? hullRatioBefore, observedCombat?.HullRatio ?? hullRatioBefore,
(float)observedShot.LockQuality); (float)observedShot.LockQuality,
aimDotDistance);
} }
finally finally
{ {
@ -541,6 +555,7 @@ namespace GameCult.EveUnity.GenericClient.PlayModeTests
bool pilotCameraExcludesMapChannel, bool pilotCameraExcludesMapChannel,
bool mapCameraIncludesMapChannel, bool mapCameraIncludesMapChannel,
WitnessReceipt movement, WitnessReceipt movement,
WitnessReceipt look,
WitnessReceipt targeting, WitnessReceipt targeting,
WitnessReceipt action, WitnessReceipt action,
EveUnityShotReceipt shot, EveUnityShotReceipt shot,
@ -548,7 +563,8 @@ namespace GameCult.EveUnity.GenericClient.PlayModeTests
float shieldRatioAfter, float shieldRatioAfter,
float hullRatioBefore, float hullRatioBefore,
float hullRatioAfter, float hullRatioAfter,
float lockProgress) float lockProgress,
float aimDotDistance)
{ {
var path = Environment.GetEnvironmentVariable("EVEUNITY_WITNESS_FACTS_PATH"); var path = Environment.GetEnvironmentVariable("EVEUNITY_WITNESS_FACTS_PATH");
if (string.IsNullOrWhiteSpace(path)) return; if (string.IsNullOrWhiteSpace(path)) return;
@ -557,6 +573,7 @@ namespace GameCult.EveUnity.GenericClient.PlayModeTests
providerAdvertisement = true, providerAdvertisement = true,
providerAssets = true, providerAssets = true,
movement = movement != null, movement = movement != null,
aimPresentation = look != null && aimDotDistance >= 49.9f,
targeting = targeting != null, targeting = targeting != null,
action = action != null, action = action != null,
combatPresentation = shot != null, combatPresentation = shot != null,
@ -573,13 +590,14 @@ namespace GameCult.EveUnity.GenericClient.PlayModeTests
initialVersion = initialVersion, initialVersion = initialVersion,
finalVersion = finalVersion, finalVersion = finalVersion,
movementDistance = movementDistance, movementDistance = movementDistance,
aimDotDistance = aimDotDistance,
playerRendererCount = playerRendererCount, playerRendererCount = playerRendererCount,
pilotChangedPixels = pilotChangedPixels, pilotChangedPixels = pilotChangedPixels,
mapChannelRendererCount = mapChannelRendererCount, mapChannelRendererCount = mapChannelRendererCount,
mapChangedPixels = mapChangedPixels, mapChangedPixels = mapChangedPixels,
pilotCameraExcludesMapChannel = pilotCameraExcludesMapChannel, pilotCameraExcludesMapChannel = pilotCameraExcludesMapChannel,
mapCameraIncludesMapChannel = mapCameraIncludesMapChannel, mapCameraIncludesMapChannel = mapCameraIncludesMapChannel,
receipts = new[] { movement, targeting, action } receipts = new[] { movement, look, targeting, action }
}; };
Directory.CreateDirectory(Path.GetDirectoryName(Path.GetFullPath(path))); Directory.CreateDirectory(Path.GetDirectoryName(Path.GetFullPath(path)));
File.WriteAllText(path, JsonUtility.ToJson(document, true)); File.WriteAllText(path, JsonUtility.ToJson(document, true));
@ -591,6 +609,7 @@ namespace GameCult.EveUnity.GenericClient.PlayModeTests
public bool providerAdvertisement; public bool providerAdvertisement;
public bool providerAssets; public bool providerAssets;
public bool movement; public bool movement;
public bool aimPresentation;
public bool targeting; public bool targeting;
public bool action; public bool action;
public bool combatPresentation; public bool combatPresentation;
@ -607,6 +626,7 @@ namespace GameCult.EveUnity.GenericClient.PlayModeTests
public long initialVersion; public long initialVersion;
public long finalVersion; public long finalVersion;
public float movementDistance; public float movementDistance;
public float aimDotDistance;
public int playerRendererCount; public int playerRendererCount;
public int pilotChangedPixels; public int pilotChangedPixels;
public int mapChannelRendererCount; public int mapChannelRendererCount;

View file

@ -9,7 +9,7 @@
"org.gamecult.cultlib": "https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib-unity-v1.0.13", "org.gamecult.cultlib": "https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib-unity-v1.0.13",
"org.gamecult.eve.plugin-fields": "https://github.com/GameCult/EvePlugins.git?path=/plugins/eve-plugin-fields/unity/org.gamecult.eve.plugin-fields#eve-plugin-fields-unity-v0.1.1", "org.gamecult.eve.plugin-fields": "https://github.com/GameCult/EvePlugins.git?path=/plugins/eve-plugin-fields/unity/org.gamecult.eve.plugin-fields#eve-plugin-fields-unity-v0.1.1",
"org.gamecult.eve.surface": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.surface#eveunity-surface-v0.2.1", "org.gamecult.eve.surface": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.surface#eveunity-surface-v0.2.1",
"org.gamecult.eve.unity-scene": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.24", "org.gamecult.eve.unity-scene": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.25",
"org.gamecult.eve.unity-uitoolkit": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-uitoolkit#eveunity-uitoolkit-v0.1.0" "org.gamecult.eve.unity-uitoolkit": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-uitoolkit#eveunity-uitoolkit-v0.1.0"
}, },
"testables": [ "testables": [

View file

@ -142,7 +142,7 @@
"hash": "d0aa50d31f3b6da96bffc194fdc3aa358f37e332" "hash": "d0aa50d31f3b6da96bffc194fdc3aa358f37e332"
}, },
"org.gamecult.eve.unity-scene": { "org.gamecult.eve.unity-scene": {
"version": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.24", "version": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.25",
"depth": 0, "depth": 0,
"source": "git", "source": "git",
"dependencies": { "dependencies": {
@ -151,7 +151,7 @@
"org.gamecult.eve.surface": "0.2.1", "org.gamecult.eve.surface": "0.2.1",
"com.unity.mathematics": "1.3.2" "com.unity.mathematics": "1.3.2"
}, },
"hash": "e43f2d74557dcbf2cc408893c7b7d7ac708a44a8" "hash": "58d87c628a261751439584263c18e93a7d8d8708"
}, },
"org.gamecult.eve.unity-uitoolkit": { "org.gamecult.eve.unity-uitoolkit": {
"version": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-uitoolkit#eveunity-uitoolkit-v0.1.0", "version": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-uitoolkit#eveunity-uitoolkit-v0.1.0",

View file

@ -188,6 +188,7 @@ namespace GameCult.EveUnity.GenericClient.PlayModeTests
EveUnityPlayableWorldClientHost host = null; EveUnityPlayableWorldClientHost host = null;
EveUnityPlayableWorldRuntime runtime = null; EveUnityPlayableWorldRuntime runtime = null;
WitnessReceipt movementReceipt = null; WitnessReceipt movementReceipt = null;
WitnessReceipt lookReceipt = null;
WitnessReceipt focusReceipt = null; WitnessReceipt focusReceipt = null;
WitnessReceipt actionReceipt = null; WitnessReceipt actionReceipt = null;
EveUnityShotReceipt observedShot = null; EveUnityShotReceipt observedShot = null;
@ -196,6 +197,7 @@ namespace GameCult.EveUnity.GenericClient.PlayModeTests
float hullRatioBefore = 0f; float hullRatioBefore = 0f;
long initialVersion = 0; long initialVersion = 0;
float movementDistance = 0f; float movementDistance = 0f;
float aimDotDistance = 0f;
try try
{ {
@ -344,18 +346,24 @@ namespace GameCult.EveUnity.GenericClient.PlayModeTests
aim.y = 0; aim.y = 0;
Assert.That(aim.sqrMagnitude, Is.GreaterThan(0.0001f)); Assert.That(aim.sqrMagnitude, Is.GreaterThan(0.0001f));
aim.Normalize(); aim.Normalize();
var steerVersion = runtime.ActiveVersion; var lookVersion = runtime.ActiveVersion;
var steer = runtime.SubmitMoveVectorIntent(playerId, aim.x, aim.z, 0.25f); var look = runtime.SubmitLookDirectionIntent(playerId, aim.x, 0f, aim.z);
var steerDeadline = Time.realtimeSinceStartup + 12f; var lookDeadline = Time.realtimeSinceStartup + 12f;
while (Time.realtimeSinceStartup < steerDeadline && while (Time.realtimeSinceStartup < lookDeadline &&
(runtime.LastReceipt == null || runtime.LastReceipt.CommandId != steer.CommandId || (runtime.LastReceipt == null || runtime.LastReceipt.CommandId != look.CommandId ||
!string.Equals(runtime.LastReceipt.State, "reconciled", StringComparison.OrdinalIgnoreCase))) !string.Equals(runtime.LastReceipt.State, "reconciled", StringComparison.OrdinalIgnoreCase) ||
runtime.ActiveVersion < runtime.LastReceipt.SourceVersion ||
Vector3.Dot(FindMarker(root, playerId).transform.forward, aim) < 0.99f))
{ {
yield return new WaitForSecondsRealtime(0.1f); yield return new WaitForSecondsRealtime(0.1f);
runtime.Refresh(); runtime.Refresh();
} }
AssertReconciledProviderReceipt(runtime.LastReceipt, steer.CommandId, AssertReconciledProviderReceipt(runtime.LastReceipt, look.CommandId,
provider.Selection.ProviderId, provider.Selection.SurfaceId, steerVersion); provider.Selection.ProviderId, provider.Selection.SurfaceId, lookVersion);
Assert.That(Vector3.Dot(FindMarker(root, playerId).transform.forward, aim), Is.GreaterThan(0.99f));
lookReceipt = WitnessReceipt.From("look", runtime.LastReceipt);
var aimRenderer = root.GetComponent<EveUnityAimPresentationRenderer>();
Assert.That(aimRenderer, Is.Not.Null);
var focusVersion = runtime.ActiveVersion; var focusVersion = runtime.ActiveVersion;
var inputDriver = root.GetComponent<EveUnityPlayableWorldInputDriver>() ?? var inputDriver = root.GetComponent<EveUnityPlayableWorldInputDriver>() ??
@ -448,6 +456,10 @@ namespace GameCult.EveUnity.GenericClient.PlayModeTests
cameraRig.CameraTransform = camera.transform; cameraRig.CameraTransform = camera.transform;
cameraRig.RenderPolicySource = provider; cameraRig.RenderPolicySource = provider;
Assert.That(cameraRig.ApplyRig(0f), Is.True); Assert.That(cameraRig.ApplyRig(0f), Is.True);
aimRenderer.RefreshNow();
Assert.That(aimRenderer.ViewDotVisible, Is.True);
aimDotDistance = Vector3.Distance(playerMarker.transform.position, aimRenderer.ViewDotPosition);
Assert.That(aimDotDistance, Is.GreaterThanOrEqualTo(49.9f));
Assert.That(camera.cullingMask & (1 << mapLayer), Is.Zero); Assert.That(camera.cullingMask & (1 << mapLayer), Is.Zero);
Assert.That(camera.fieldOfView, Is.EqualTo(60f).Within(0.001f)); Assert.That(camera.fieldOfView, Is.EqualTo(60f).Within(0.001f));
var playerViewport = camera.WorldToViewportPoint(playerMarker.transform.position); var playerViewport = camera.WorldToViewportPoint(playerMarker.transform.position);
@ -504,6 +516,7 @@ namespace GameCult.EveUnity.GenericClient.PlayModeTests
(camera.cullingMask & (1 << mapLayer)) == 0, (camera.cullingMask & (1 << mapLayer)) == 0,
(mapCamera.cullingMask & (1 << mapLayer)) != 0, (mapCamera.cullingMask & (1 << mapLayer)) != 0,
movementReceipt, movementReceipt,
lookReceipt,
focusReceipt, focusReceipt,
actionReceipt, actionReceipt,
observedShot, observedShot,
@ -511,7 +524,8 @@ namespace GameCult.EveUnity.GenericClient.PlayModeTests
observedCombat?.ShieldRatio ?? shieldRatioBefore, observedCombat?.ShieldRatio ?? shieldRatioBefore,
hullRatioBefore, hullRatioBefore,
observedCombat?.HullRatio ?? hullRatioBefore, observedCombat?.HullRatio ?? hullRatioBefore,
(float)observedShot.LockQuality); (float)observedShot.LockQuality,
aimDotDistance);
} }
finally finally
{ {
@ -541,6 +555,7 @@ namespace GameCult.EveUnity.GenericClient.PlayModeTests
bool pilotCameraExcludesMapChannel, bool pilotCameraExcludesMapChannel,
bool mapCameraIncludesMapChannel, bool mapCameraIncludesMapChannel,
WitnessReceipt movement, WitnessReceipt movement,
WitnessReceipt look,
WitnessReceipt targeting, WitnessReceipt targeting,
WitnessReceipt action, WitnessReceipt action,
EveUnityShotReceipt shot, EveUnityShotReceipt shot,
@ -548,7 +563,8 @@ namespace GameCult.EveUnity.GenericClient.PlayModeTests
float shieldRatioAfter, float shieldRatioAfter,
float hullRatioBefore, float hullRatioBefore,
float hullRatioAfter, float hullRatioAfter,
float lockProgress) float lockProgress,
float aimDotDistance)
{ {
var path = Environment.GetEnvironmentVariable("EVEUNITY_WITNESS_FACTS_PATH"); var path = Environment.GetEnvironmentVariable("EVEUNITY_WITNESS_FACTS_PATH");
if (string.IsNullOrWhiteSpace(path)) return; if (string.IsNullOrWhiteSpace(path)) return;
@ -557,6 +573,7 @@ namespace GameCult.EveUnity.GenericClient.PlayModeTests
providerAdvertisement = true, providerAdvertisement = true,
providerAssets = true, providerAssets = true,
movement = movement != null, movement = movement != null,
aimPresentation = look != null && aimDotDistance >= 49.9f,
targeting = targeting != null, targeting = targeting != null,
action = action != null, action = action != null,
combatPresentation = shot != null, combatPresentation = shot != null,
@ -573,13 +590,14 @@ namespace GameCult.EveUnity.GenericClient.PlayModeTests
initialVersion = initialVersion, initialVersion = initialVersion,
finalVersion = finalVersion, finalVersion = finalVersion,
movementDistance = movementDistance, movementDistance = movementDistance,
aimDotDistance = aimDotDistance,
playerRendererCount = playerRendererCount, playerRendererCount = playerRendererCount,
pilotChangedPixels = pilotChangedPixels, pilotChangedPixels = pilotChangedPixels,
mapChannelRendererCount = mapChannelRendererCount, mapChannelRendererCount = mapChannelRendererCount,
mapChangedPixels = mapChangedPixels, mapChangedPixels = mapChangedPixels,
pilotCameraExcludesMapChannel = pilotCameraExcludesMapChannel, pilotCameraExcludesMapChannel = pilotCameraExcludesMapChannel,
mapCameraIncludesMapChannel = mapCameraIncludesMapChannel, mapCameraIncludesMapChannel = mapCameraIncludesMapChannel,
receipts = new[] { movement, targeting, action } receipts = new[] { movement, look, targeting, action }
}; };
Directory.CreateDirectory(Path.GetDirectoryName(Path.GetFullPath(path))); Directory.CreateDirectory(Path.GetDirectoryName(Path.GetFullPath(path)));
File.WriteAllText(path, JsonUtility.ToJson(document, true)); File.WriteAllText(path, JsonUtility.ToJson(document, true));
@ -591,6 +609,7 @@ namespace GameCult.EveUnity.GenericClient.PlayModeTests
public bool providerAdvertisement; public bool providerAdvertisement;
public bool providerAssets; public bool providerAssets;
public bool movement; public bool movement;
public bool aimPresentation;
public bool targeting; public bool targeting;
public bool action; public bool action;
public bool combatPresentation; public bool combatPresentation;
@ -607,6 +626,7 @@ namespace GameCult.EveUnity.GenericClient.PlayModeTests
public long initialVersion; public long initialVersion;
public long finalVersion; public long finalVersion;
public float movementDistance; public float movementDistance;
public float aimDotDistance;
public int playerRendererCount; public int playerRendererCount;
public int pilotChangedPixels; public int pilotChangedPixels;
public int mapChannelRendererCount; public int mapChannelRendererCount;

View file

@ -13,7 +13,7 @@ param(
) )
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
$expectedEveUnityCommit = "e43f2d74557dcbf2cc408893c7b7d7ac708a44a8" $expectedEveUnityCommit = "58d87c628a261751439584263c18e93a7d8d8708"
$expectedCultLibCommit = "feb5c71513e71d681699f462fe3682b3168c6f73" $expectedCultLibCommit = "feb5c71513e71d681699f462fe3682b3168c6f73"
$repoRoot = Split-Path -Parent $PSScriptRoot $repoRoot = Split-Path -Parent $PSScriptRoot
$projectRoot = $ClientProject $projectRoot = $ClientProject