Merge origin/master into damage-falloff
Conflicts: FusedRounds scenario brief and fixture comment, SmokeRoundsSteppedTests, and AetherDb's usage line keep both sides, with DeathCluster renamed Cluster Cannon. GameData/Aetheria.cc is master's blob; range-falloff is rerun on it in the next commit. This commit's catalog does not carry the falloff stats, so CatalogRole/falloff catalog tests do not pass here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
97b7566ee9
65 changed files with 3360 additions and 336 deletions
BIN
Assets/Resources/Settings.asset
(Stored with Git LFS)
BIN
Assets/Resources/Settings.asset
(Stored with Git LFS)
Binary file not shown.
302
Assets/Scripts/Editor/FlowFieldParityVerify.cs
Normal file
302
Assets/Scripts/Editor/FlowFieldParityVerify.cs
Normal file
|
|
@ -0,0 +1,302 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using GameCult.Caching;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Aetheria.EditorTools
|
||||
{
|
||||
/// <summary>
|
||||
/// Batchmode check for flow-shader-parity (campaign aetheria-fauna, cut fauna-flow-field): the HLSL globalFlow and
|
||||
/// slopeFlow of Assets/Shaders/Volumetric.cginc give the values of FlowField (ServerShared) for the same position,
|
||||
/// scroll, settings and gradient. It drives the real lowering: a Zone is stepped, VolumeSampling.LowerFlow sets the
|
||||
/// shader globals from the zone's Settings.Flow and FlowScroll, FlowParity.compute reads those globals, and the
|
||||
/// results are compared with FlowField. It also checks that Settings.asset carries the authored flow under
|
||||
/// PlanetSettings and that the shader got the zone's scroll (speed times zone time).
|
||||
///
|
||||
/// Dispatches a compute kernel, so it needs a graphics device: run WITHOUT -nographics (as ShieldPanelCut3Verify).
|
||||
/// Unity -batchmode -projectPath <repo> -executeMethod Aetheria.EditorTools.FlowFieldParityVerify.Run -logFile <path>
|
||||
/// Do not pass -quit: Run exits the Editor itself, 0 on success and 1 on any failure.
|
||||
/// </summary>
|
||||
public static class FlowFieldParityVerify
|
||||
{
|
||||
const string Tag = "[FlowFieldParityVerify]";
|
||||
// Measured disagreement between the HLSL and the C# on this tree (float32 on both sides, positions to 10000,
|
||||
// scrolls to 100, through the keyword-gated flow()): max 2.9e-5 of amplitude (the "max error" line this run
|
||||
// prints). The tolerance is 5x that noise, so constant errors of 0.05% (y factor .501, swirl or amplitude
|
||||
// x1.0005: 4e-4 to 8e-4) fail; a 0.01% error is at the noise floor and unresolvable.
|
||||
const float RelativeTolerance = 1.5e-4f;
|
||||
static float _maxError;
|
||||
static bool _ok = true;
|
||||
|
||||
static void OnLog(string message, string stack, LogType type)
|
||||
{
|
||||
if ((type == LogType.Error || type == LogType.Exception || type == LogType.Assert) && !message.StartsWith(Tag))
|
||||
Fail("logged-error", message.Split('\n')[0]);
|
||||
}
|
||||
|
||||
static void Fail(string check, string detail)
|
||||
{
|
||||
Debug.LogError($"{Tag} FAIL {check}: {detail}");
|
||||
_ok = false;
|
||||
}
|
||||
|
||||
public static void Run()
|
||||
{
|
||||
if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Null)
|
||||
{
|
||||
Debug.LogError($"{Tag} FAIL: no graphics device in this session; rerun batchmode without -nographics.");
|
||||
EditorApplication.Exit(1);
|
||||
return;
|
||||
}
|
||||
|
||||
// The flow's error lines (a shader keyword that does not exist, a missing property) fail the check.
|
||||
Application.logMessageReceived += OnLog;
|
||||
var work = Path.Combine(Path.GetTempPath(), "flow-parity-" + Guid.NewGuid().ToString("N"));
|
||||
Directory.CreateDirectory(work);
|
||||
try
|
||||
{
|
||||
var settings = AssetDatabase.LoadAssetAtPath<GameSettings>("Assets/Resources/Settings.asset")
|
||||
?? throw new InvalidOperationException("No Settings.asset.");
|
||||
var compute = AssetDatabase.LoadAssetAtPath<ComputeShader>("Assets/Shaders/Compute/FlowParity.compute")
|
||||
?? throw new InvalidOperationException("No FlowParity.compute.");
|
||||
|
||||
CheckAuthoredFlow(settings.PlanetSettings.Flow);
|
||||
|
||||
// The authored flow (global term only: its slope amplitudes are authored zero), then a flow with every
|
||||
// term live and a scroll speed that reaches scrolls up to 100.
|
||||
var authored = settings.PlanetSettings.Flow;
|
||||
CheckParity("authored", settings, work, compute, authored, new[] { 0.0, 3.1, 40.0, 100.0 });
|
||||
var wide = new FlowSettings
|
||||
{
|
||||
GlobalScale = authored.GlobalScale, GlobalAmplitude = authored.GlobalAmplitude, Period = authored.Period,
|
||||
GlobalScrollSpeed = 1f, SlopeAmplitude = 3f, SwirlAmplitude = 5f
|
||||
};
|
||||
CheckParity("wide", settings, work, compute, wide, new[] { 0.0, 1.0, 17.0, 60.0, 100.0 });
|
||||
CheckNoiseClock(compute);
|
||||
|
||||
Debug.Log($"{Tag} max error {_maxError:G4} of amplitude (tolerance {RelativeTolerance:G4})");
|
||||
Debug.Log(_ok ? $"{Tag} PASS" : $"{Tag} FAIL: see errors above");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"{Tag} FAIL exception: {e}");
|
||||
_ok = false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Application.logMessageReceived -= OnLog;
|
||||
try { Directory.Delete(work, true); } catch { }
|
||||
}
|
||||
EditorApplication.Exit(_ok ? 0 : 1);
|
||||
}
|
||||
|
||||
// Settings.asset carries the authored flow under PlanetSettings (it moved from DefaultEnvironment unchanged).
|
||||
static void CheckAuthoredFlow(FlowSettings flow)
|
||||
{
|
||||
if (flow == null) { Fail("authored-flow", "PlanetSettings.Flow is null"); return; }
|
||||
if (flow.GlobalScale != 512f || flow.GlobalAmplitude != 15f || flow.GlobalScrollSpeed != .025f ||
|
||||
flow.Period != 8f || flow.SlopeAmplitude != 0f || flow.SwirlAmplitude != 0f)
|
||||
Fail("authored-flow", $"PlanetSettings.Flow is {flow.GlobalScale}/{flow.GlobalAmplitude}/{flow.GlobalScrollSpeed}/" +
|
||||
$"{flow.Period}/{flow.SlopeAmplitude}/{flow.SwirlAmplitude}, authored 512/15/0.025/8/0/0");
|
||||
}
|
||||
|
||||
internal static Zone BuildZone(GameSettings settings, string work, FlowSettings flow, double time = 0)
|
||||
{
|
||||
var cache = AetheriaStores.Open(Path.Combine(work, Guid.NewGuid().ToString("N") + ".cc"), catalogWritable: true);
|
||||
cache.Upsert(new VerseGrammar { Revision = 1 });
|
||||
cache.FlushAsync().Wait();
|
||||
var items = new ItemManager(cache, new ProvenanceLedger(), settings.GameplaySettings, _ => { });
|
||||
return new Zone(items, new PlanetSettings { Flow = flow }, new ZonePack { Time = time }, new GalaxyZone { Name = "Parity", Owner = null }, null);
|
||||
}
|
||||
|
||||
static void CheckParity(string label, GameSettings settings, string work, ComputeShader compute, FlowSettings flow,
|
||||
double[] zoneTimes)
|
||||
{
|
||||
var zone = BuildZone(settings, work, flow);
|
||||
var kernel = compute.FindKernel("Evaluate");
|
||||
var rng = new System.Random(label.Length * 7919);
|
||||
const int positionCount = 256, gradientCount = 64;
|
||||
const int count = positionCount;
|
||||
|
||||
var positions = new Vector3[count];
|
||||
for (var i = 0; i < positionCount; i++)
|
||||
positions[i] = new Vector3((float) (rng.NextDouble() * 20000 - 10000), (float) (rng.NextDouble() * 200 - 100),
|
||||
(float) (rng.NextDouble() * 20000 - 10000));
|
||||
// Gradients of any direction and magnitude, plus one zero gradient.
|
||||
var gradients = new Vector2[count];
|
||||
for (var i = 1; i < gradientCount; i++)
|
||||
{
|
||||
var angle = rng.NextDouble() * Math.PI * 2;
|
||||
var magnitude = (float) Math.Exp(rng.NextDouble() * 8 - 4);
|
||||
gradients[i] = new Vector2((float) Math.Cos(angle) * magnitude, (float) Math.Sin(angle) * magnitude);
|
||||
}
|
||||
gradients[0] = Vector2.zero;
|
||||
|
||||
var positionBuffer = new ComputeBuffer(count, 12);
|
||||
var gradientBuffer = new ComputeBuffer(count, 8);
|
||||
var globalBuffer = new ComputeBuffer(count, 12);
|
||||
var slopeBuffer = new ComputeBuffer(count, 12);
|
||||
var gatedBuffer = new ComputeBuffer(count, 12);
|
||||
ComputeBuffer noiseBuffer = null;
|
||||
// flow() reads the nebula's gravity height under FLOW_SLOPE. A ramp rising along the texture's x gives every
|
||||
// position inside the grid the gradient direction (1, 0), so the slope term is live where a flat height
|
||||
// would zero it (and the FLOW_SLOPE keyword and its pragma would not matter).
|
||||
const int rampSize = 64;
|
||||
var height = new Texture2D(rampSize, rampSize, TextureFormat.RFloat, false)
|
||||
{ filterMode = FilterMode.Point, wrapMode = TextureWrapMode.Clamp };
|
||||
var ramp = new float[rampSize * rampSize];
|
||||
for (var i = 0; i < ramp.Length; i++) ramp[i] = (i % rampSize) / (float) (rampSize - 1);
|
||||
height.SetPixelData(ramp, 0);
|
||||
height.Apply();
|
||||
var rampGradient = new CultMath.float2(1f, 0f);
|
||||
try
|
||||
{
|
||||
positionBuffer.SetData(positions);
|
||||
gradientBuffer.SetData(gradients);
|
||||
compute.SetBuffer(kernel, "positions", positionBuffer);
|
||||
compute.SetBuffer(kernel, "gradients", gradientBuffer);
|
||||
compute.SetBuffer(kernel, "globalOut", globalBuffer);
|
||||
compute.SetBuffer(kernel, "slopeOut", slopeBuffer);
|
||||
compute.SetBuffer(kernel, "gatedOut", gatedBuffer);
|
||||
compute.SetTexture(kernel, "_NebulaSurfaceHeight", height);
|
||||
compute.SetVector("_NebulaSurfaceHeight_TexelSize", new Vector4(1f / rampSize, 1f / rampSize, rampSize, rampSize));
|
||||
// The grid spans 40000: every sampled position (|xz| to 10000) is inside the ramp's uv range.
|
||||
Shader.SetGlobalVector("_GridTransform", new Vector4(0f, 0f, 40000f, 0f));
|
||||
noiseBuffer = new ComputeBuffer(count, 4);
|
||||
compute.SetBuffer(kernel, "noiseOut", noiseBuffer);
|
||||
compute.SetInt("count", count);
|
||||
|
||||
var elapsed = 0.0;
|
||||
foreach (var target in zoneTimes)
|
||||
{
|
||||
// Step the zone to the target by an awkward step; the sum is the zone's time.
|
||||
while (elapsed < target - 1e-9)
|
||||
{
|
||||
var dt = (float) Math.Min(0.37, target - elapsed);
|
||||
zone.Update(dt);
|
||||
elapsed += dt;
|
||||
}
|
||||
VolumeSampling.LowerFlow(zone.Settings.Flow, zone.ExactTime);
|
||||
|
||||
// The shader got the zone's scroll and cycle: the same zone time Zone.Flow evaluates at.
|
||||
var zoneScroll = zone.FlowScroll;
|
||||
var lowered = Shader.GetGlobalVector("_FlowScroll");
|
||||
if (Math.Abs(lowered.x - zoneScroll.x) > 1e-6 || Math.Abs(lowered.y - zoneScroll.y) > 1e-6)
|
||||
Fail($"{label}-lowered-scroll", $"at zone time {elapsed:F3} the shader got _FlowScroll ({lowered.x}, {lowered.y}), the zone's is ({zoneScroll.x}, {zoneScroll.y})");
|
||||
if (Math.Abs(Shader.GetGlobalFloat("_FlowCycle") - zone.CyclePhase(flow.Period)) > 1e-6)
|
||||
Fail($"{label}-lowered-cycle", $"at zone time {elapsed:F3} the shader got _FlowCycle {Shader.GetGlobalFloat("_FlowCycle")}, the zone's phase is {zone.CyclePhase(flow.Period)}");
|
||||
if (Shader.GetGlobalFloat("_FlowScale") != flow.GlobalScale || Shader.GetGlobalFloat("_FlowAmplitude") != flow.GlobalAmplitude ||
|
||||
Shader.GetGlobalFloat("_FlowSlopeAmplitude") != flow.SlopeAmplitude ||
|
||||
Shader.GetGlobalFloat("_FlowSwirlAmplitude") != flow.SwirlAmplitude || Shader.GetGlobalFloat("_FlowPeriod") != flow.Period)
|
||||
Fail($"{label}-lowered-settings", "a flow uniform does not equal the zone's FlowSettings");
|
||||
|
||||
compute.Dispatch(kernel, (count + 63) / 64, 1, 1);
|
||||
var globalOut = new Vector3[count];
|
||||
var slopeOut = new Vector3[count];
|
||||
var gatedOut = new Vector3[count];
|
||||
globalBuffer.GetData(globalOut);
|
||||
slopeBuffer.GetData(slopeOut);
|
||||
gatedBuffer.GetData(gatedOut);
|
||||
|
||||
var at = $"{label} zone time {elapsed:F2} scroll {zoneScroll.x:F4}";
|
||||
for (var i = 0; i < positionCount; i++)
|
||||
{
|
||||
var p = positions[i];
|
||||
var expected = FlowField.Global(flow, new CultMath.float3(p.x, p.y, p.z), zoneScroll);
|
||||
Compare($"{label}-global", at, i, new Vector3(expected.x, expected.y, expected.z), globalOut[i], flow.GlobalAmplitude);
|
||||
}
|
||||
// flow() is the keyword-gated function the nebula and stardust call: the global term plus, under
|
||||
// FLOW_SLOPE, the slope term of the ramp's gradient. A flow that is live must not read zero.
|
||||
var live = 0;
|
||||
var gatedScale = Math.Max(Math.Abs(flow.GlobalAmplitude), Math.Max(Math.Abs(flow.SlopeAmplitude), Math.Abs(flow.SwirlAmplitude)));
|
||||
for (var i = 0; i < positionCount; i++)
|
||||
{
|
||||
var p = positions[i];
|
||||
var expected = FlowField.At(flow, new CultMath.float3(p.x, p.y, p.z), zoneScroll, rampGradient);
|
||||
var e = new Vector3(expected.x, expected.y, expected.z);
|
||||
if (e.magnitude > .1f * gatedScale) live++;
|
||||
Compare($"{label}-flow-keywords", at, i, e, gatedOut[i], gatedScale);
|
||||
}
|
||||
if (gatedScale != 0f && live < positionCount / 4)
|
||||
Fail($"{label}-flow-keywords", $"{at}: only {live} of {positionCount} zone flows are live; the check is vacuous");
|
||||
var slopeScale = Math.Max(Math.Abs(flow.SlopeAmplitude), Math.Abs(flow.SwirlAmplitude));
|
||||
for (var i = 0; i < gradientCount; i++)
|
||||
{
|
||||
var g = gradients[i];
|
||||
var expected = FlowField.Slope(flow, new CultMath.float2(g.x, g.y));
|
||||
Compare($"{label}-slope", at, i, new Vector3(expected.x, expected.y, expected.z), slopeOut[i], slopeScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
positionBuffer.Release(); gradientBuffer.Release(); globalBuffer.Release(); slopeBuffer.Release(); gatedBuffer.Release(); noiseBuffer?.Release(); UnityEngine.Object.DestroyImmediate(height);
|
||||
}
|
||||
}
|
||||
|
||||
// The nebula noise the flow advects evolves on the flow clock VolumeSampling lowers as _NebulaNoiseTime, never on
|
||||
// _Time: with the speed non-zero, the noise changes when _NebulaNoiseTime does and not otherwise (a frame clock
|
||||
// would not follow the global set here).
|
||||
static void CheckNoiseClock(ComputeShader compute)
|
||||
{
|
||||
const int count = 64;
|
||||
var kernel = compute.FindKernel("Evaluate");
|
||||
var rng = new System.Random(4217);
|
||||
var positions = new Vector3[count];
|
||||
for (var i = 0; i < count; i++)
|
||||
positions[i] = new Vector3((float) (rng.NextDouble() * 4000 - 2000), (float) (rng.NextDouble() * 100 - 50), (float) (rng.NextDouble() * 4000 - 2000));
|
||||
var buffers = new[] { new ComputeBuffer(count, 12), new ComputeBuffer(count, 8), new ComputeBuffer(count, 12), new ComputeBuffer(count, 12), new ComputeBuffer(count, 12), new ComputeBuffer(count, 4) };
|
||||
var height = new Texture2D(1, 1, TextureFormat.RFloat, false);
|
||||
try
|
||||
{
|
||||
buffers[0].SetData(positions);
|
||||
buffers[1].SetData(new Vector2[count]);
|
||||
compute.SetBuffer(kernel, "positions", buffers[0]);
|
||||
compute.SetBuffer(kernel, "gradients", buffers[1]);
|
||||
compute.SetBuffer(kernel, "globalOut", buffers[2]);
|
||||
compute.SetBuffer(kernel, "slopeOut", buffers[3]);
|
||||
compute.SetBuffer(kernel, "gatedOut", buffers[4]);
|
||||
compute.SetBuffer(kernel, "noiseOut", buffers[5]);
|
||||
compute.SetTexture(kernel, "_NebulaSurfaceHeight", height);
|
||||
compute.SetInt("count", count);
|
||||
Shader.SetGlobalFloat("_NebulaNoiseSpeed", 1f);
|
||||
float[] Noise(float noiseTime)
|
||||
{
|
||||
Shader.SetGlobalFloat("_NebulaNoiseTime", noiseTime);
|
||||
compute.Dispatch(kernel, 1, 1, 1);
|
||||
var result = new float[count];
|
||||
buffers[5].GetData(result);
|
||||
return result;
|
||||
}
|
||||
var a = Noise(0f);
|
||||
var b = Noise(3f);
|
||||
var again = Noise(3f);
|
||||
int moved = 0, repeated = 0;
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
if (Math.Abs(a[i] - b[i]) > 1e-4f) moved++;
|
||||
if (b[i] == again[i]) repeated++;
|
||||
}
|
||||
if (moved < count / 2) Fail("nebula-noise-clock", $"only {moved} of {count} noise samples follow _NebulaNoiseTime");
|
||||
if (repeated != count) Fail("nebula-noise-clock", $"{count - repeated} of {count} noise samples changed with _NebulaNoiseTime held");
|
||||
}
|
||||
finally
|
||||
{
|
||||
foreach (var buffer in buffers) buffer.Release();
|
||||
UnityEngine.Object.DestroyImmediate(height);
|
||||
}
|
||||
}
|
||||
|
||||
// Error is measured against the term's amplitude; a term with no amplitude must be exactly zero and never NaN.
|
||||
static void Compare(string check, string at, int index, Vector3 expected, Vector3 actual, float amplitude)
|
||||
{
|
||||
var error = (expected - actual).magnitude;
|
||||
if (float.IsNaN(error)) { Fail(check, $"{at} sample {index}: NaN (expected {expected}, shader {actual})"); return; }
|
||||
if (amplitude != 0f) _maxError = Math.Max(_maxError, error / Math.Abs(amplitude));
|
||||
var tolerance = RelativeTolerance * Math.Abs(amplitude);
|
||||
if (error > tolerance)
|
||||
Fail(check, $"{at} sample {index}: expected {expected}, shader {actual}, error {error:G4} > {tolerance:G4}");
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Editor/FlowFieldParityVerify.cs.meta
Normal file
2
Assets/Scripts/Editor/FlowFieldParityVerify.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8fae18f5f32f10f43ba892a097f18caa
|
||||
181
Assets/Scripts/Editor/FlowFieldSceneVerify.cs
Normal file
181
Assets/Scripts/Editor/FlowFieldSceneVerify.cs
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace Aetheria.EditorTools
|
||||
{
|
||||
/// <summary>
|
||||
/// Batchmode check for the flow as the scene runs it (campaign aetheria-fauna, cut fauna-flow-field; target
|
||||
/// invariants flow-one-owner and flow-shader-parity). FlowFieldParityVerify proves the HLSL against FlowField with
|
||||
/// no scene loaded; this opens ARPG.unity, lets VolumeSampling and Stardust initialise as the game does, drives
|
||||
/// their own Start and Update with a zone attached, and asserts what the presenters did:
|
||||
/// - nothing threw and nothing logged an error (a type that cannot initialise in a scene, as VolumeSampling once
|
||||
/// could when it created its keywords in a static field initializer, throws on its first use);
|
||||
/// - FLOW_GLOBAL and FLOW_SLOPE are enabled, _FlowAmplitude is the zone's, and the nebula noise clock is the zone's;
|
||||
/// - the stardust particle buffer changes with the flow and freezes when the zone pauses;
|
||||
/// - CloudShader pass 0 carries the FLOW_* keywords.
|
||||
/// The scene is opened before any Aetheria type is touched: run this method alone in its own Unity session, never
|
||||
/// after FlowFieldParityVerify (which would initialise VolumeSampling outside a MonoBehaviour constructor).
|
||||
/// Dispatches compute and renders, so it needs a graphics device: run WITHOUT -nographics.
|
||||
/// Unity -batchmode -projectPath <repo> -executeMethod Aetheria.EditorTools.FlowFieldSceneVerify.Run -logFile <path>
|
||||
/// Do not pass -quit: Run exits the Editor itself, 0 on success and 1 on any failure.
|
||||
/// </summary>
|
||||
public static class FlowFieldSceneVerify
|
||||
{
|
||||
const string Tag = "[FlowFieldSceneVerify]";
|
||||
static bool _ok = true;
|
||||
|
||||
static void OnLog(string message, string stack, LogType type)
|
||||
{
|
||||
if ((type == LogType.Error || type == LogType.Exception || type == LogType.Assert) && !message.StartsWith(Tag))
|
||||
Fail("logged-error", message.Split('\n')[0]);
|
||||
}
|
||||
|
||||
static void Fail(string check, string detail)
|
||||
{
|
||||
Debug.LogError($"{Tag} FAIL {check}: {detail}");
|
||||
_ok = false;
|
||||
}
|
||||
|
||||
public static void Run()
|
||||
{
|
||||
if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Null)
|
||||
{
|
||||
Debug.LogError($"{Tag} FAIL: no graphics device in this session; rerun batchmode without -nographics.");
|
||||
EditorApplication.Exit(1);
|
||||
return;
|
||||
}
|
||||
|
||||
Application.logMessageReceived += OnLog;
|
||||
try
|
||||
{
|
||||
// Before anything else touches the project's types: the scene constructs its MonoBehaviours here.
|
||||
EditorSceneManager.OpenScene("Assets/Scenes/ARPG.unity", OpenSceneMode.Single);
|
||||
Check();
|
||||
Debug.Log(_ok ? $"{Tag} PASS" : $"{Tag} FAIL: see errors above");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"{Tag} FAIL exception: {e}");
|
||||
_ok = false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Application.logMessageReceived -= OnLog;
|
||||
}
|
||||
EditorApplication.Exit(_ok ? 0 : 1);
|
||||
}
|
||||
|
||||
static void Check()
|
||||
{
|
||||
var settings = AssetDatabase.LoadAssetAtPath<GameSettings>("Assets/Resources/Settings.asset")
|
||||
?? throw new InvalidOperationException("No Settings.asset.");
|
||||
var agm = UnityEngine.Object.FindObjectsByType<ActionGameManager>(FindObjectsInactive.Include, FindObjectsSortMode.None).FirstOrDefault();
|
||||
var volume = UnityEngine.Object.FindObjectsByType<VolumeSampling>(FindObjectsInactive.Include, FindObjectsSortMode.None).FirstOrDefault();
|
||||
var dust = UnityEngine.Object.FindObjectsByType<Stardust>(FindObjectsInactive.Include, FindObjectsSortMode.None).FirstOrDefault();
|
||||
if (agm == null || volume == null || dust == null)
|
||||
{
|
||||
Fail("scene-objects", $"ARPG.unity has ActionGameManager={agm != null}, VolumeSampling={volume != null}, Stardust={dust != null}");
|
||||
return;
|
||||
}
|
||||
|
||||
// Every flow term live, so FLOW_SLOPE is on; and the same flow with every amplitude zero.
|
||||
var on = new FlowSettings
|
||||
{
|
||||
GlobalScale = 512f, GlobalAmplitude = 15f, GlobalScrollSpeed = .025f, Period = 8f, SlopeAmplitude = 3f, SwirlAmplitude = 5f
|
||||
};
|
||||
var off = new FlowSettings { GlobalScale = on.GlobalScale, GlobalScrollSpeed = on.GlobalScrollSpeed, Period = on.Period };
|
||||
var work = Path.Combine(Path.GetTempPath(), "flow-scene-" + Guid.NewGuid().ToString("N"));
|
||||
Directory.CreateDirectory(work);
|
||||
try
|
||||
{
|
||||
var zone = FlowFieldParityVerify.BuildZone(settings, work, on, 86400.0 * 3 + 12.3);
|
||||
typeof(ActionGameManager).GetProperty("Instance").GetSetMethod(true).Invoke(null, new object[] { agm });
|
||||
typeof(ActionGameManager).GetProperty("Zone").GetSetMethod(true).Invoke(agm, new object[] { zone });
|
||||
if (agm.Settings == null) agm.Settings = settings;
|
||||
|
||||
Call(volume, "Start");
|
||||
Call(volume, "Update");
|
||||
if (!Shader.IsKeywordEnabled("FLOW_GLOBAL")) Fail("scene-keywords", "FLOW_GLOBAL is not enabled after VolumeSampling.Update");
|
||||
if (!Shader.IsKeywordEnabled("FLOW_SLOPE")) Fail("scene-keywords", "FLOW_SLOPE is not enabled after VolumeSampling.Update");
|
||||
if (Shader.GetGlobalFloat("_FlowAmplitude") != on.GlobalAmplitude)
|
||||
Fail("scene-amplitude", $"_FlowAmplitude is {Shader.GetGlobalFloat("_FlowAmplitude")}, the zone's flow has {on.GlobalAmplitude}");
|
||||
var scroll = Shader.GetGlobalVector("_FlowScroll");
|
||||
if (scroll.x != zone.FlowScroll.x || scroll.y != zone.FlowScroll.y)
|
||||
Fail("scene-scroll", $"_FlowScroll ({scroll.x}, {scroll.y}) is not the zone's ({zone.FlowScroll.x}, {zone.FlowScroll.y})");
|
||||
var noiseTime = Shader.GetGlobalFloat("_NebulaNoiseTime");
|
||||
if (noiseTime != (float) zone.ExactTime)
|
||||
Fail("scene-noise-clock", $"_NebulaNoiseTime is {noiseTime}, the zone's time is {(float) zone.ExactTime}");
|
||||
|
||||
CheckCloudKeywords();
|
||||
|
||||
// Stardust follows the flow through its own dispatch: the particle buffer read back each frame.
|
||||
Call(dust, "Start");
|
||||
var bufferField = typeof(Stardust).GetField("_particlesBuffer", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
float[] Frame()
|
||||
{
|
||||
Call(dust, "Update");
|
||||
var buffer = (ComputeBuffer) bufferField.GetValue(dust);
|
||||
var data = new float[buffer.count * 7];
|
||||
buffer.GetData(data);
|
||||
return data;
|
||||
}
|
||||
var flowing = Frame();
|
||||
VolumeSampling.LowerFlow(off, VolumeSampling.FlowClock);
|
||||
var still = Frame();
|
||||
if (Differing(flowing, still) == 0) Fail("scene-stardust", "the particle buffer is the same with the zone's flow and with no flow");
|
||||
|
||||
// A paused zone freezes the particles and the nebula noise clock; a running one moves both.
|
||||
Call(volume, "Update");
|
||||
zone.Update(0f);
|
||||
Call(volume, "Update");
|
||||
if (Differing(flowing, Frame()) != 0) Fail("scene-stardust-pause", "the particle buffer moved while the zone was paused");
|
||||
if (Shader.GetGlobalFloat("_NebulaNoiseTime") != noiseTime) Fail("scene-noise-clock", "_NebulaNoiseTime moved while the zone was paused");
|
||||
zone.Update(.05f);
|
||||
Call(volume, "Update");
|
||||
if (Differing(flowing, Frame()) == 0) Fail("scene-stardust-run", "the particle buffer did not move while the zone ran");
|
||||
if (Shader.GetGlobalFloat("_NebulaNoiseTime") == noiseTime) Fail("scene-noise-clock", "_NebulaNoiseTime did not move while the zone ran");
|
||||
}
|
||||
finally
|
||||
{
|
||||
try { Directory.Delete(work, true); } catch { }
|
||||
}
|
||||
}
|
||||
|
||||
// CloudShader's pass 0 compiles with the flow keywords (it must #include_with_pragmas the shared include).
|
||||
static void CheckCloudKeywords()
|
||||
{
|
||||
var shader = AssetDatabase.LoadAssetAtPath<Shader>("Assets/Shaders/Raymarching/CloudShader.shader");
|
||||
if (shader == null) { Fail("scene-cloud-keywords", "No CloudShader.shader."); return; }
|
||||
var keywords = ShaderUtil.GetPassKeywords(shader, new PassIdentifier(0, 0), UnityEditor.Rendering.ShaderType.Fragment)
|
||||
.Select(keyword => keyword.name).ToArray();
|
||||
foreach (var name in new[] { "FLOW_GLOBAL", "FLOW_SLOPE" })
|
||||
if (!keywords.Contains(name)) Fail("scene-cloud-keywords", $"CloudShader pass 0 does not carry {name}");
|
||||
}
|
||||
|
||||
static int Differing(float[] a, float[] b)
|
||||
{
|
||||
var count = 0;
|
||||
for (var i = 0; i < a.Length; i++)
|
||||
if (Math.Abs(a[i] - b[i]) > 1e-4f) count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
// The presenters' own Start and Update, as the game calls them; an exception is a failure that names the type.
|
||||
static void Call(object target, string method)
|
||||
{
|
||||
var info = target.GetType().GetMethod(method, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
|
||||
if (info == null) { Fail("scene-presenter-exception", $"{target.GetType().Name}.{method} not found"); return; }
|
||||
try { info.Invoke(target, null); }
|
||||
catch (TargetInvocationException e)
|
||||
{
|
||||
Fail("scene-presenter-exception", $"{target.GetType().Name}.{method} threw {e.InnerException?.GetType().Name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Editor/FlowFieldSceneVerify.cs.meta
Normal file
2
Assets/Scripts/Editor/FlowFieldSceneVerify.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 25fbd79fca1de49498c3bebf9f63243b
|
||||
|
|
@ -191,6 +191,8 @@ public interface IPowerConsumer
|
|||
Union(47, typeof(MunitionFuelData)),
|
||||
Union(48, typeof(PickupData)),
|
||||
Union(49, typeof(LaunchSuppressorData)),
|
||||
Union(50, typeof(ListenerData)),
|
||||
Union(51, typeof(ScannerData)),
|
||||
JsonObject(MemberSerialization.OptIn)]
|
||||
public abstract class BehaviorData
|
||||
{
|
||||
|
|
|
|||
44
Assets/Scripts/ServerShared/Behaviors/Listener.cs
Normal file
44
Assets/Scripts/ServerShared/Behaviors/Listener.cs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/* 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 MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
// Passive listening gear (ruling sensor-stat-set): hears other ships' emissions at a multiple of their own range,
|
||||
// bearing only. It emits nothing; Entity.HearingMultiple asks each active listener at hearing time. Its power is the
|
||||
// design's EnergyDraw and its activity is the item's Active, as for sensors.
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
public class ListenerData : BehaviorData
|
||||
{
|
||||
// How many times an emitter's own reach this listener hears it at.
|
||||
[Inspectable, JsonProperty("multiple"), Key(1), RuntimeInspectable]
|
||||
public PerformanceStat Multiple = new PerformanceStat();
|
||||
|
||||
public override Behavior CreateInstance(EquippedItem item)
|
||||
{
|
||||
return new Listener(this, item);
|
||||
}
|
||||
public override Behavior CreateInstance(ConsumableItemEffect item)
|
||||
{
|
||||
return new Listener(this, item);
|
||||
}
|
||||
}
|
||||
|
||||
public class Listener : Behavior
|
||||
{
|
||||
private readonly ListenerData _data;
|
||||
|
||||
public Listener(ListenerData data, EquippedItem item) : base(data, item)
|
||||
{
|
||||
_data = data;
|
||||
}
|
||||
public Listener(ListenerData data, ConsumableItemEffect item) : base(data, item)
|
||||
{
|
||||
_data = data;
|
||||
}
|
||||
|
||||
public float Multiple => Evaluate(_data.Multiple);
|
||||
|
||||
public override bool Execute(float dt) => true;
|
||||
}
|
||||
11
Assets/Scripts/ServerShared/Behaviors/Listener.cs.meta
Normal file
11
Assets/Scripts/ServerShared/Behaviors/Listener.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5b0e1f6c2d7a4e39a8c4d1f27e6b3a90
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
98
Assets/Scripts/ServerShared/Behaviors/Scanner.cs
Normal file
98
Assets/Scripts/ServerShared/Behaviors/Scanner.cs
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
/* 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 MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
using static CultMath.math;
|
||||
|
||||
// Inspection (campaign aetheria-release, rulings quiet-gear-identifiable-hull-layout-known, scan-held-beam,
|
||||
// scan-is-an-act): a gear that, held on the ship's tracked target within Range for ScanTime, reveals everything fitted to
|
||||
// that target, quiet gear that never acts included. The scan is an emission like a lock: the target is painted and
|
||||
// third parties hear it at Range over the intercept factor.
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
public class ScannerData : BehaviorData
|
||||
{
|
||||
// The planar distance to the target within which a scan builds.
|
||||
[Inspectable, JsonProperty("range"), Key(1), RuntimeInspectable]
|
||||
public PerformanceStat Range = new PerformanceStat();
|
||||
|
||||
// Seconds a held scan takes to finish; a broken scan decays over the same span.
|
||||
[Inspectable, JsonProperty("scanTime"), Key(2), RuntimeInspectable]
|
||||
public PerformanceStat ScanTime = new PerformanceStat();
|
||||
|
||||
// The ratio of how far this scanner sees to how far others hear it (ruling sensor-stat-set); a design without it
|
||||
// reads as 1.
|
||||
[Inspectable, JsonProperty("interceptFactor"), Key(3)]
|
||||
public PerformanceStat InterceptFactor;
|
||||
|
||||
public override Behavior CreateInstance(EquippedItem item)
|
||||
{
|
||||
return new Scanner(this, item);
|
||||
}
|
||||
public override Behavior CreateInstance(ConsumableItemEffect item)
|
||||
{
|
||||
return new Scanner(this, item);
|
||||
}
|
||||
}
|
||||
|
||||
public class Scanner : Behavior, IProgressBehavior
|
||||
{
|
||||
private readonly ScannerData _data;
|
||||
private Entity _target;
|
||||
private float _built;
|
||||
private double _heldAt;
|
||||
|
||||
// The scan's progress now: what Execute last built, less ScanTime-relative decay over the time since a tick last held
|
||||
// it (ruling scan-held-beam: a broken scan decays over ScanTime, the item inactive or destroyed included). Derived from
|
||||
// the zone clock, never from tick order, so a scanner decays on the tick it breaks whether its host runs Execute
|
||||
// before the always-updated pass (EquippedItem) or after it (ConsumableItemEffect). The one decay site.
|
||||
public float Progress => Remaining(_heldAt);
|
||||
|
||||
public Scanner(ScannerData data, EquippedItem item) : base(data, item)
|
||||
{
|
||||
_data = data;
|
||||
}
|
||||
public Scanner(ScannerData data, ConsumableItemEffect item) : base(data, item)
|
||||
{
|
||||
_data = data;
|
||||
}
|
||||
|
||||
private float Remaining(double since)
|
||||
{
|
||||
if (_built <= 0f) return 0f;
|
||||
var now = Entity.Zone?.ExactTime ?? since;
|
||||
return saturate(_built - (float) (now - since) / Evaluate(_data.ScanTime));
|
||||
}
|
||||
|
||||
// Runs only while the item is Active. The scan builds while the ship's own Target is a tracked ship within Range, and
|
||||
// is painted and emitted on every tick it builds; at 1 the target's fitted items enter the book and the scan starts over.
|
||||
// A tick that does not hold the scan builds nothing, and the zone clock carries its decay (Progress).
|
||||
public override bool Execute(float dt)
|
||||
{
|
||||
var target = Entity.Target.Value.Entity;
|
||||
if (_target != target)
|
||||
{
|
||||
_built = 0f;
|
||||
_target = target;
|
||||
}
|
||||
|
||||
var range = Evaluate(_data.Range);
|
||||
if (target != null && Entity.VisibleEntities.Contains(target) && Entity.TargetRange <= range)
|
||||
{
|
||||
// Decay over the ticks since the last held one, not counting this tick, which holds.
|
||||
var progress = saturate(Remaining(_heldAt + dt) + dt / Evaluate(_data.ScanTime));
|
||||
_built = progress;
|
||||
_heldAt = Entity.Zone?.ExactTime ?? _heldAt;
|
||||
target.ReceivePaint(Entity, Item, PaintMode.Scan, progress);
|
||||
Entity.Emit(Item, range / (_data.InterceptFactor == null ? 1f : Evaluate(_data.InterceptFactor)));
|
||||
if (progress >= 1f)
|
||||
{
|
||||
Entity.RecordInspection(target);
|
||||
_built = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/ServerShared/Behaviors/Scanner.cs.meta
Normal file
11
Assets/Scripts/ServerShared/Behaviors/Scanner.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bf9e034c7a31410ea1c516f46b43825c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -247,7 +247,7 @@ public abstract class Entity
|
|||
// sensor-stat-set): written in Update, read by Sense in the same tick, cleared by the next PublishInbox.
|
||||
private readonly List<ActiveEmission> _emissions = new List<ActiveEmission>();
|
||||
// What this observer has seen each ship's items do (ruling visibility-per-capability-reveal), keyed (subject,
|
||||
// item). Written only by RecordReveal (an act enters) and EndReveals (an end the observer perceives, or a departed
|
||||
// item). Written only by RecordReveal (an act, or a scan through RecordInspection, enters) and EndReveals (an end the observer perceives, or a departed
|
||||
// subject's entries aged past BearingMemory), cleared by Deactivate (ruling reveal-ends-on-perception).
|
||||
private readonly Dictionary<Entity, Dictionary<EquippedItem, Reveal>> _reveals = new Dictionary<Entity, Dictionary<EquippedItem, Reveal>>();
|
||||
private readonly List<EquippedItem> _endedItems = new List<EquippedItem>();
|
||||
|
|
@ -714,8 +714,23 @@ public abstract class Entity
|
|||
}
|
||||
|
||||
// How much of an emission's reach this observer's instruments hear it at (ruling sensor-stat-set: listeners hear at
|
||||
// a multiple of an emitter's own range): 1 with an active sensor, 0 without. Listener gear extends it.
|
||||
private int HearingMultiple() => ActiveSensors().Count > 0 ? 1 : 0;
|
||||
// a multiple of an emitter's own range): the largest of 1 (any active sensor) and each active listener's Multiple,
|
||||
// 0 with neither. Catalog values come from AetherDb sensor-stat-set.
|
||||
private float HearingMultiple()
|
||||
{
|
||||
var multiple = ActiveSensors().Count > 0 ? 1f : 0f;
|
||||
for (var i = 0; i < Equipment.Count; i++)
|
||||
{
|
||||
var item = Equipment[i];
|
||||
if (!item.Active.Value) continue;
|
||||
foreach (var behavior in item.Behaviors)
|
||||
if (behavior is Listener listener) multiple = max(multiple, listener.Multiple);
|
||||
}
|
||||
foreach (var effect in _activeConsumables)
|
||||
foreach (var behavior in effect.Behaviors)
|
||||
if (behavior is Listener listener) multiple = max(multiple, listener.Multiple);
|
||||
return multiple;
|
||||
}
|
||||
|
||||
// Cut 12.3 (docs/fire-control-cut.md): "armour absorbs first" -- the per-cell armour phase, split out of
|
||||
// what used to be Absorb's own first half (moved verbatim from DamageSchematic's per-cell body, Cut 3) so
|
||||
|
|
@ -934,14 +949,14 @@ public abstract class Entity
|
|||
_paintInbox.Add(new PendingPaint(new PaintWarning(normalize((emitter.Position - Position).xz), emitter.ClaimOf(item), mode, strength), emitter, item));
|
||||
}
|
||||
|
||||
// The reveal book's one way in and its one membership gate (callers: Sense and PublishInbox, both in this file):
|
||||
// this observer saw `item` of `subject` act on `channel`, now, from this bearing. An item-less act (hull
|
||||
// The reveal book's one way in and its one membership gate (callers: Sense, PublishInbox and RecordInspection, all in
|
||||
// this file): this observer saw `item` of `subject` act on `channel`, now, from this bearing. An item-less act (hull
|
||||
// radiation, a consumable) reveals nothing, and neither does a subject that is not in the zone: a departed
|
||||
// subject's entries are never created or refreshed, from any caller, and neither does an item this observer
|
||||
// perceives destroyed (PerceivesDestroyed). A later act of the same item replaces the
|
||||
// earlier one. `claimed` is the class the carrier (signature, emission or paint) stamped: what this observer's
|
||||
// classifying readers will believe of the act; `item` stays the aim and book key.
|
||||
internal void RecordReveal(Entity subject, EquippedItem item, SignatureChannel channel, EquippableItemData claimed)
|
||||
internal void RecordReveal(Entity subject, EquippedItem item, SignatureChannel? channel, EquippableItemData claimed)
|
||||
{
|
||||
if (!_active || item == null || !Zone.Entities.Contains(subject) || PerceivesDestroyed(subject, item)) return;
|
||||
if (!_reveals.TryGetValue(subject, out var book))
|
||||
|
|
@ -949,6 +964,21 @@ public abstract class Entity
|
|||
book[item] = new Reveal(item, channel, normalize((subject.Position - Position).xz), Zone.Time, claimed);
|
||||
}
|
||||
|
||||
// A finished scan (Scanner.Execute; rulings scan-is-an-act, quiet-gear-identifiable-hull-layout-known: quiet gear
|
||||
// that never acts stays identifiable through special gear): this observer learns every fitted item of `subject`,
|
||||
// channel null. It records what the item claims, not what it is (ClaimOf, as every act's carrier stamps it: the
|
||||
// aetheria-ew one judge, classify-from-belief), skips the hull (its class is the track's to give) and a destroyed
|
||||
// item, and goes through RecordReveal's gate like any act. It calls no EndReveals: a scan ends nothing
|
||||
// (reveal-ends-on-perception).
|
||||
internal void RecordInspection(Entity subject)
|
||||
{
|
||||
foreach (var item in subject.Equipment)
|
||||
{
|
||||
if (item == subject.EquippedHull || item.EquippableItem.IsDestroyed) continue;
|
||||
RecordReveal(subject, item, null, subject.ClaimOf(item));
|
||||
}
|
||||
}
|
||||
|
||||
// This observer resolves `subject`'s gear (ContactOf's Identified gate) and `item` of it is destroyed: the one rule
|
||||
// for a destroyed item an observer perceives, read by the book's entry (RecordReveal) and its end (Sense).
|
||||
private bool PerceivesDestroyed(Entity subject, EquippedItem item) =>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ using float2 = CultMath.float2;
|
|||
public class ZoneEnvironment
|
||||
{
|
||||
[JsonProperty("nebula"), Key(0)] public NebulaSettings Nebula;
|
||||
[JsonProperty("flow"), Key(1)] public FlowSettings Flow;
|
||||
// Key 1 is retired (it held the flow, now PlanetSettings.Flow); never reuse it.
|
||||
[JsonProperty("noise"), Key(2)] public NoiseSettings Noise;
|
||||
[JsonProperty("lighting"), Key(3)] public AmbientLightingSettings Lighting;
|
||||
[JsonProperty("grid"), Key(4)] public GridSettings Grid;
|
||||
|
|
|
|||
78
Assets/Scripts/ServerShared/FlowField.cs
Normal file
78
Assets/Scripts/ServerShared/FlowField.cs
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
using CultMath;
|
||||
using static CultMath.math;
|
||||
using float2 = CultMath.float2;
|
||||
using float3 = CultMath.float3;
|
||||
|
||||
/// <summary>
|
||||
/// The global flow law: the one definition of the drift that stardust and nebula follow and that the sim knows.
|
||||
/// A pure function of the zone's FlowSettings, a position, a scroll and a downhill gradient; nothing here keeps
|
||||
/// a clock. Zone.Flow evaluates it at zone time. Assets/Shaders/Volumetric.cginc (globalFlow, slopeFlow) is its
|
||||
/// HLSL lowering, driven by VolumeSampling.LowerFlow and pinned to it by Aetheria.EditorTools.FlowFieldParityVerify.
|
||||
/// </summary>
|
||||
public static class FlowField
|
||||
{
|
||||
// The second octave of the noise samples at position * Golden (Volumetric.cginc Tri3D).
|
||||
const float Golden = 1.61803398875f;
|
||||
|
||||
// The scroll of the noise field, in field units: speed times zone time, for each of the two octaves, as a phase.
|
||||
// Every term of Tri3D reaches the scrolled axis through frac, so a phase is only meaningful modulo 1: the fold
|
||||
// happens here in double, where zone time is exact, and the float that reaches the shaders is in [0, 1) however
|
||||
// old the zone is. x is the first octave's phase, y the second's (the second octave's axis is scaled by Golden).
|
||||
public static float2 Scroll(FlowSettings settings, double zoneTime)
|
||||
{
|
||||
var scroll = (double) settings.GlobalScrollSpeed * zoneTime;
|
||||
return float2(Phase(scroll), Phase(scroll * Golden));
|
||||
}
|
||||
|
||||
// A phase in [0, 1) strictly: a double just below an integer rounds up to 1f in the cast, and 1 is 0 modulo 1.
|
||||
static float Phase(double value)
|
||||
{
|
||||
var phase = (float) frac(value);
|
||||
return phase < 1f ? phase : 0f;
|
||||
}
|
||||
|
||||
// The phase of a cycle of `period` seconds at zone time, in [0, 1). The nebula's flow-advected noise cycles and
|
||||
// Stardust's particle lifetimes take their phase from here, so drift follows sim time and stops with the sim.
|
||||
public static float Cycle(double zoneTime, float period) => period == 0f ? 0f : Phase(zoneTime / period);
|
||||
|
||||
// The procedural term (Volumetric.cginc globalFlow): a Tri3D field of position / scale, scrolled along y.
|
||||
// Skipped when its amplitude is zero, as the shader's FLOW_GLOBAL keyword skips it.
|
||||
public static float3 Global(FlowSettings settings, float3 position, float2 scroll)
|
||||
{
|
||||
if (settings.GlobalAmplitude == 0f) return float3.zero;
|
||||
var field = position / settings.GlobalScale;
|
||||
var sample = Tri3D(field - float3(0f, scroll.x, 0f), field * Golden - float3(0f, scroll.y, 0f)) * settings.GlobalAmplitude;
|
||||
sample.y *= .5f;
|
||||
return sample;
|
||||
}
|
||||
|
||||
// The slope term (Volumetric.cginc slopeFlow): swirl around and slide along the gravity gradient.
|
||||
// `downhill` is the DOWNHILL gradient, -grad(height) in world xz. The shader's texel gradient is that same
|
||||
// vector (getUV negates the world x and z axes), and Zone.GetNormal's xz is proportional to it.
|
||||
// Skipped when both amplitudes are zero (the FLOW_SLOPE keyword), and zero for a zero gradient.
|
||||
public static float3 Slope(FlowSettings settings, float2 downhill)
|
||||
{
|
||||
if (settings.SlopeAmplitude == 0f && settings.SwirlAmplitude == 0f) return float3.zero;
|
||||
if (dot(downhill, downhill) == 0f) return float3.zero;
|
||||
var direction = normalize(downhill);
|
||||
return float3(direction.y, 0f, -direction.x) * settings.SwirlAmplitude
|
||||
+ float3(direction.x, 0f, direction.y) * settings.SlopeAmplitude;
|
||||
}
|
||||
|
||||
public static float3 At(FlowSettings settings, float3 position, float2 scroll, float2 downhill) =>
|
||||
Global(settings, position, scroll) + Slope(settings, downhill);
|
||||
|
||||
// Volumetric.cginc tri / tri3 / Tri3D, term for term.
|
||||
static float Tri(float x) => abs(frac(x) - .5f);
|
||||
|
||||
static float3 Tri3(float3 p) =>
|
||||
float3(Tri(p.z + Tri(p.y)), Tri(p.z + Tri(p.x)), Tri(p.y + Tri(p.x)));
|
||||
|
||||
// The two octaves' positions are given already scrolled (see Scroll).
|
||||
static float3 Tri3D(float3 p, float3 pGolden)
|
||||
{
|
||||
var t1 = normalize(Tri3(p));
|
||||
var t2 = normalize(Tri3(pGolden));
|
||||
return cross(t1, t2);
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/ServerShared/FlowField.cs.meta
Normal file
2
Assets/Scripts/ServerShared/FlowField.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8105a45840c4552459aaf44e6c0e19ce
|
||||
|
|
@ -20,13 +20,13 @@ public sealed class AiFusedDiscipline : Scenario
|
|||
("Cockpit 2x2", int2(2, 6), None),
|
||||
("Large Drive", int2(1, 0), Reversed),
|
||||
("Large Drive", int2(3, 0), Reversed),
|
||||
("Talaria", int2(2, 14), CounterClockwise),
|
||||
("Talaria", int2(3, 14), Clockwise),
|
||||
("Core Power", int2(2, 4), None),
|
||||
("Rugged Drive", int2(2, 14), CounterClockwise),
|
||||
("Rugged Drive", int2(3, 14), Clockwise),
|
||||
("Compact Reactor", int2(2, 4), None),
|
||||
(weapon, int2(1, 8), None),
|
||||
("Iapyx", int2(2, 2), CounterClockwise),
|
||||
("Iapyx", int2(3, 2), Clockwise),
|
||||
("not if i see you first", int2(3, 10), None),
|
||||
("Radiator", int2(2, 2), CounterClockwise),
|
||||
("Radiator", int2(3, 2), Clockwise),
|
||||
("Compact Sensor", int2(3, 10), None),
|
||||
("Fire Control Array", int2(1, 6), Clockwise));
|
||||
|
||||
stage.Player(stage.Generated("Djinni"), float2(0, 0));
|
||||
|
|
|
|||
|
|
@ -27,27 +27,27 @@ public sealed class Arcs : Scenario
|
|||
("Cockpit 2x2", int2(4, 6), None),
|
||||
("Large Drive", int2(3, 0), Reversed),
|
||||
("Large Drive", int2(5, 0), Reversed),
|
||||
("Talaria", int2(4, 14), CounterClockwise),
|
||||
("Talaria", int2(5, 14), Clockwise),
|
||||
("Core Power", int2(4, 4), None),
|
||||
("GT 3K", int2(2, 5), None),
|
||||
("GT 3K", int2(7, 5), None),
|
||||
("FastBlast+-", int2(3, 8), None),
|
||||
("FastBlast+-", int2(6, 8), None),
|
||||
("Iapyx", int2(4, 2), CounterClockwise),
|
||||
("Iapyx", int2(5, 2), Clockwise),
|
||||
("not if i see you first", int2(5, 10), None),
|
||||
("Rugged Drive", int2(4, 14), CounterClockwise),
|
||||
("Rugged Drive", int2(5, 14), Clockwise),
|
||||
("Compact Reactor", int2(4, 4), None),
|
||||
("Guided Missile Launcher", int2(2, 5), None),
|
||||
("Guided Missile Launcher", int2(7, 5), None),
|
||||
("Cell Blaster", int2(3, 8), None),
|
||||
("Cell Blaster", int2(6, 8), None),
|
||||
("Radiator", int2(4, 2), CounterClockwise),
|
||||
("Radiator", int2(5, 2), Clockwise),
|
||||
("Compact Sensor", int2(5, 10), None),
|
||||
("Fire Control Array", int2(3, 6), Clockwise),
|
||||
("Autocannon", int2(8, 4), Clockwise),
|
||||
("ChargeBlast SG", int2(0, 4), CounterClockwise));
|
||||
("Charged Scatter Blaster", int2(0, 4), CounterClockwise));
|
||||
var turret = stage.Fit("Turret",
|
||||
("ClearPath", int2(1, 2), None),
|
||||
("ClearPath", int2(5, 2), None),
|
||||
("Skiron", int2(0, 2), CounterClockwise),
|
||||
("Skiron", int2(7, 2), Clockwise),
|
||||
("Core Power", int2(3, 3), None),
|
||||
("Light Machine Gun", int2(1, 2), None),
|
||||
("Light Machine Gun", int2(5, 2), None),
|
||||
("Long Radiator", int2(0, 2), CounterClockwise),
|
||||
("Long Radiator", int2(7, 2), Clockwise),
|
||||
("Compact Reactor", int2(3, 3), None),
|
||||
("Turret Control Module", int2(3, 5), None),
|
||||
("not if i see you first", int2(4, 5), None),
|
||||
("Compact Sensor", int2(4, 5), None),
|
||||
("Fire Control Array", int2(3, 6), None));
|
||||
|
||||
stage.Player(fighter, float2(0, 0), facing: float2(0, 1));
|
||||
|
|
|
|||
|
|
@ -23,16 +23,16 @@ public sealed class Belt : Scenario
|
|||
("Cockpit 2x2", int2(2, 6), None),
|
||||
("Large Drive", int2(1, 0), Reversed),
|
||||
("Large Drive", int2(3, 0), Reversed),
|
||||
("Talaria", int2(2, 14), CounterClockwise),
|
||||
("Talaria", int2(3, 14), Clockwise),
|
||||
("Core Power", int2(2, 4), None),
|
||||
("GT 3K", int2(0, 5), None),
|
||||
("GT 3K", int2(5, 5), None),
|
||||
("plight", int2(1, 8), None),
|
||||
("FastBlast+-", int2(4, 8), None),
|
||||
("Iapyx", int2(2, 2), CounterClockwise),
|
||||
("Iapyx", int2(3, 2), Clockwise),
|
||||
("not if i see you first", int2(3, 10), None),
|
||||
("Rugged Drive", int2(2, 14), CounterClockwise),
|
||||
("Rugged Drive", int2(3, 14), Clockwise),
|
||||
("Compact Reactor", int2(2, 4), None),
|
||||
("Guided Missile Launcher", int2(0, 5), None),
|
||||
("Guided Missile Launcher", int2(5, 5), None),
|
||||
("Lightning Projector", int2(1, 8), None),
|
||||
("Cell Blaster", int2(4, 8), None),
|
||||
("Radiator", int2(2, 2), CounterClockwise),
|
||||
("Radiator", int2(3, 2), Clockwise),
|
||||
("Compact Sensor", int2(3, 10), None),
|
||||
("Fire Control Array", int2(1, 6), Clockwise));
|
||||
|
||||
// The belt is a ring about its parent's position at the belt orbit's distance. The player stands 100 m outside
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ using static ItemRotation;
|
|||
public sealed class Crossing : Scenario
|
||||
{
|
||||
public override string Name => "Crossing";
|
||||
public override string Brief => "plight at the starboard gun and a FastBlast+- at the port gun, a fast Djinni crossing close ahead and an " +
|
||||
"unpiloted one waiting at range. The Djinni starts to port moving across the bow; the arena's gravity bends its run. Make the pass coasting: give no throttle until the Djinni has crossed the bow, then fly freely (thrusting from the start carries you past it). Verify: as the Djinni crosses close, FastBlast lands some and plight " +
|
||||
public override string Brief => "A Lightning Projector at the starboard gun and a Cell Blaster at the port gun, a fast Djinni crossing close ahead and an " +
|
||||
"unpiloted one waiting at range. The Djinni starts to port moving across the bow; the arena's gravity bends its run. Make the pass coasting: give no throttle until the Djinni has crossed the bow, then fly freely (thrusting from the start carries you past it). Verify: as the Djinni crosses close, FastBlast lands some and projector " +
|
||||
"almost none; against the Djinni at range both land. Fly it again without the Fire Control Array: " +
|
||||
"with it the small gun lands more.";
|
||||
public override uint Seed => 112;
|
||||
|
|
@ -13,11 +13,11 @@ public sealed class Crossing : Scenario
|
|||
|
||||
// Where the Djinni sit: the player is at the origin facing +z. The crosser starts ahead and to port, facing across
|
||||
// the bow and already moving at the Djinni's 50 m/s cap, so its run sweeps across the bow within seconds (the arena
|
||||
// pulls the player to port, which brings the two together). The waiting Djinni sits inside plight's arc at 80% of
|
||||
// pulls the player to port, which brings the two together). The waiting Djinni sits inside the Lightning Projector's arc at 80% of
|
||||
// its Range.
|
||||
public static readonly CultMath.float2 CrosserAt = float2(-150, 200), CrosserFacing = float2(1, 0), CrosserVelocity = float2(50, 0);
|
||||
public const float PlightRange = 1216f; // plight's Range in metres, 1216.4 as the fit stands settled at rest
|
||||
public static readonly CultMath.float2 Waiting = float2(0, PlightRange * .8f);
|
||||
public const float ProjectorRange = 1216f; // the Lightning Projector's Range in metres, 1216.4 as the fit stands settled at rest
|
||||
public static readonly CultMath.float2 Waiting = float2(0, ProjectorRange * .8f);
|
||||
|
||||
public override Galaxy Generate(GalaxyStage stage) => stage.Prelude(DemoTerminus.Cast);
|
||||
|
||||
|
|
@ -27,16 +27,16 @@ public sealed class Crossing : Scenario
|
|||
("Cockpit 2x2", int2(2, 6), None),
|
||||
("Large Drive", int2(1, 0), Reversed),
|
||||
("Large Drive", int2(3, 0), Reversed),
|
||||
("Talaria", int2(2, 14), CounterClockwise),
|
||||
("Talaria", int2(3, 14), Clockwise),
|
||||
("Core Power", int2(2, 4), None),
|
||||
("GT 3K", int2(0, 5), None),
|
||||
("GT 3K", int2(5, 5), None),
|
||||
("plight", int2(1, 8), None),
|
||||
("FastBlast+-", int2(4, 8), None),
|
||||
("Iapyx", int2(2, 2), CounterClockwise),
|
||||
("Iapyx", int2(3, 2), Clockwise),
|
||||
("not if i see you first", int2(3, 10), None),
|
||||
("Rugged Drive", int2(2, 14), CounterClockwise),
|
||||
("Rugged Drive", int2(3, 14), Clockwise),
|
||||
("Compact Reactor", int2(2, 4), None),
|
||||
("Guided Missile Launcher", int2(0, 5), None),
|
||||
("Guided Missile Launcher", int2(5, 5), None),
|
||||
("Lightning Projector", int2(1, 8), None),
|
||||
("Cell Blaster", int2(4, 8), None),
|
||||
("Radiator", int2(2, 2), CounterClockwise),
|
||||
("Radiator", int2(3, 2), Clockwise),
|
||||
("Compact Sensor", int2(3, 10), None),
|
||||
("Fire Control Array", int2(1, 6), Clockwise));
|
||||
|
||||
stage.Player(fighter, float2(0, 0), facing: float2(0, 1));
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ using static ItemRotation;
|
|||
public sealed class Duel : Scenario
|
||||
{
|
||||
public override string Name => "Duel";
|
||||
public override string Brief => "One piloted, hostile Longinus with slow GT 3K missiles and a Spectra in its hold. Verify: rolled " +
|
||||
public override string Brief => "One piloted, hostile Longinus with slow guided missiles and a Light Laser in its hold. Verify: rolled " +
|
||||
"hits and near-misses, subsystem aim, beam reads above bow, armour takes the missile, loot keeps its brand.";
|
||||
public override uint Seed => 104;
|
||||
public override bool Ambient => false;
|
||||
|
|
@ -17,22 +17,22 @@ public sealed class Duel : Scenario
|
|||
("Cockpit 2x2", int2(2, 6), None),
|
||||
("Large Drive", int2(1, 0), Reversed),
|
||||
("Large Drive", int2(3, 0), Reversed),
|
||||
("Talaria", int2(2, 14), CounterClockwise),
|
||||
("Talaria", int2(3, 14), Clockwise),
|
||||
("Core Power", int2(2, 4), None),
|
||||
("GT 3K", int2(0, 5), None),
|
||||
("GT 3K", int2(5, 5), None),
|
||||
("FastBlast+-", int2(1, 8), None),
|
||||
("FastBlast+-", int2(4, 8), None),
|
||||
("Iapyx", int2(2, 2), CounterClockwise),
|
||||
("Iapyx", int2(3, 2), Clockwise),
|
||||
("not if i see you first", int2(3, 10), None),
|
||||
("PotaT+-", int2(1, 5), None),
|
||||
("Rugged Drive", int2(2, 14), CounterClockwise),
|
||||
("Rugged Drive", int2(3, 14), Clockwise),
|
||||
("Compact Reactor", int2(2, 4), None),
|
||||
("Guided Missile Launcher", int2(0, 5), None),
|
||||
("Guided Missile Launcher", int2(5, 5), None),
|
||||
("Cell Blaster", int2(1, 8), None),
|
||||
("Cell Blaster", int2(4, 8), None),
|
||||
("Radiator", int2(2, 2), CounterClockwise),
|
||||
("Radiator", int2(3, 2), Clockwise),
|
||||
("Compact Sensor", int2(3, 10), None),
|
||||
("Capacitor", int2(1, 5), None),
|
||||
("Fire Control Array", int2(1, 6), Clockwise),
|
||||
("Store-All Plus", int2(2, 8), None));
|
||||
("Cargo Bay", int2(2, 8), None));
|
||||
|
||||
stage.Player(fighter, float2(0, 0));
|
||||
var rival = stage.Place(fighter, float2(0, 900), facing: float2(0, -1), stance: ScenarioStance.Hostile, piloted: true);
|
||||
stage.Cargo(rival, "Spectra");
|
||||
stage.Cargo(rival, "Light Laser");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,20 +4,20 @@ using static ItemRotation;
|
|||
public sealed class FusedRounds : Scenario
|
||||
{
|
||||
public override string Name => "Fused Rounds";
|
||||
public override string Brief => "The Smoke Test Hull with Smoke Proximity, Smoke Delayed and a DeathCluster; a hostile bare Longinus at mid range, a bare " +
|
||||
public override string Brief => "The Smoke Test Hull with Smoke Proximity, Smoke Delayed and a Cluster Cannon; a hostile bare Longinus at mid range, a bare " +
|
||||
"hull dead ahead, a fragile one to starboard, a close one inside the proximity blast radius, and one astern. " +
|
||||
"Verify with nothing selected: aim past every hull and the round bursts at max range along the aim; aim at the hull " +
|
||||
"ahead and it stops and bursts on it; fire the DeathCluster at the fragile hull and, once it is hurt, a Smoke " +
|
||||
"ahead and it stops and bursts on it; fire the Cluster Cannon at the fragile hull and, once it is hurt, a Smoke " +
|
||||
"Proximity round at it: the hull dies before the round lands, no burst. Select the astern hull: the round fires and bursts at its range along the arc edge. Select the " +
|
||||
"close hull: the burst is pushed out to the blast radius from your centre. A Smoke Proximity burst beside the " +
|
||||
"Longinus damages where the model shows the blast; a Smoke Delayed round into its nose bursts inside. The HUD " +
|
||||
"reads Direct, Burst at N m or Refused for the fused weapons and a percentage for the DeathCluster, and the " +
|
||||
"reads Direct, Burst at N m or Refused for the fused weapons and a percentage for the Cluster Cannon, and the " +
|
||||
"smoke weapons show no Manufacturer row.";
|
||||
public override uint Seed => 108;
|
||||
public override bool Ambient => false;
|
||||
|
||||
// Where everything sits: the player is at the origin facing +z. Ahead lies on the initial aim line, inside every forward
|
||||
// mount's arc. Fragile is a bare Longinus inside the DeathCluster's effective range (full damage; the scenario test reads the bound from the weapon); Close is inside Smoke Proximity's blast radius
|
||||
// mount's arc. Fragile is a bare Longinus inside the Cluster Cannon's effective range (full damage; the scenario test reads the bound from the weapon); Close is inside Smoke Proximity's blast radius
|
||||
// (8 m from the ship's centre) and beside the aim line, not across it; Stern is outside every mount's arc.
|
||||
public static readonly CultMath.float2 Mid = float2(-200, 600), Ahead = float2(0, 300), Fragile = float2(80, 240),
|
||||
Close = float2(6.4f, 4f), Stern = float2(0, -400);
|
||||
|
|
@ -30,15 +30,15 @@ public sealed class FusedRounds : Scenario
|
|||
("Cockpit 2x2", int2(4, 6), None),
|
||||
("Large Drive", int2(3, 0), Reversed),
|
||||
("Large Drive", int2(5, 0), Reversed),
|
||||
("Talaria", int2(4, 14), CounterClockwise),
|
||||
("Talaria", int2(5, 14), Clockwise),
|
||||
("Core Power", int2(4, 4), None),
|
||||
("Rugged Drive", int2(4, 14), CounterClockwise),
|
||||
("Rugged Drive", int2(5, 14), Clockwise),
|
||||
("Compact Reactor", int2(4, 4), None),
|
||||
("Smoke Proximity", int2(3, 8), None),
|
||||
("Smoke Delayed", int2(6, 8), None),
|
||||
("DeathCluster", int2(5, 17), None),
|
||||
("Iapyx", int2(4, 2), CounterClockwise),
|
||||
("Iapyx", int2(5, 2), Clockwise),
|
||||
("not if i see you first", int2(5, 10), None),
|
||||
("Cluster Cannon", int2(5, 17), None),
|
||||
("Radiator", int2(4, 2), CounterClockwise),
|
||||
("Radiator", int2(5, 2), Clockwise),
|
||||
("Compact Sensor", int2(5, 10), None),
|
||||
("Fire Control Array", int2(3, 6), Clockwise));
|
||||
|
||||
stage.Player(shooter, float2(0, 0), facing: float2(0, 1));
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ using static ItemRotation;
|
|||
public sealed class LauncherAngles : Scenario
|
||||
{
|
||||
public override string Name => "Launcher Angles";
|
||||
public override string Brief => "A GT 3K, a pswarm and two FastBlasts; a hostile bare Longinus broadside on, another beside it. " +
|
||||
"Verify: hits pulse only the facing edge; a pswarm round whose target dies fades unexploded.";
|
||||
public override string Brief => "A Guided Missile Launcher, a Swarm Rocket Pod and two Cell Blasters; a hostile bare Longinus broadside on, another beside it. " +
|
||||
"Verify: hits pulse only the facing edge; a Swarm Rocket Pod round whose target dies fades unexploded.";
|
||||
public override uint Seed => 105;
|
||||
public override bool Ambient => false;
|
||||
|
||||
|
|
@ -17,16 +17,16 @@ public sealed class LauncherAngles : Scenario
|
|||
("Cockpit 2x2", int2(2, 6), None),
|
||||
("Large Drive", int2(1, 0), Reversed),
|
||||
("Large Drive", int2(3, 0), Reversed),
|
||||
("Talaria", int2(2, 14), CounterClockwise),
|
||||
("Talaria", int2(3, 14), Clockwise),
|
||||
("Core Power", int2(2, 4), None),
|
||||
("GT 3K", int2(0, 5), None),
|
||||
("pswarm", int2(5, 5), None),
|
||||
("FastBlast+-", int2(1, 8), None),
|
||||
("FastBlast+-", int2(4, 8), None),
|
||||
("Iapyx", int2(2, 2), CounterClockwise),
|
||||
("Iapyx", int2(3, 2), Clockwise),
|
||||
("not if i see you first", int2(3, 10), None),
|
||||
("Rugged Drive", int2(2, 14), CounterClockwise),
|
||||
("Rugged Drive", int2(3, 14), Clockwise),
|
||||
("Compact Reactor", int2(2, 4), None),
|
||||
("Guided Missile Launcher", int2(0, 5), None),
|
||||
("Swarm Rocket Pod", int2(5, 5), None),
|
||||
("Cell Blaster", int2(1, 8), None),
|
||||
("Cell Blaster", int2(4, 8), None),
|
||||
("Radiator", int2(2, 2), CounterClockwise),
|
||||
("Radiator", int2(3, 2), Clockwise),
|
||||
("Compact Sensor", int2(3, 10), None),
|
||||
("Fire Control Array", int2(1, 6), Clockwise));
|
||||
|
||||
stage.Player(launcher, float2(0, 0));
|
||||
|
|
|
|||
|
|
@ -24,19 +24,19 @@ public sealed class LockOn : Scenario
|
|||
("Cockpit 2x2", int2(2, 6), None),
|
||||
("Large Drive", int2(1, 0), Reversed),
|
||||
("Large Drive", int2(3, 0), Reversed),
|
||||
("Talaria", int2(2, 14), CounterClockwise),
|
||||
("Talaria", int2(3, 14), Clockwise),
|
||||
("Core Power", int2(2, 4), None),
|
||||
("GT 3K", int2(0, 5), None),
|
||||
("GT 3K", int2(5, 5), None),
|
||||
("FastBlast+-", int2(1, 8), None),
|
||||
("FastBlast+-", int2(4, 8), None),
|
||||
("Iapyx", int2(2, 2), CounterClockwise),
|
||||
("Iapyx", int2(3, 2), Clockwise),
|
||||
("not if i see you first", int2(3, 10), None),
|
||||
("PotaT+-", int2(1, 5), None),
|
||||
("Rugged Drive", int2(2, 14), CounterClockwise),
|
||||
("Rugged Drive", int2(3, 14), Clockwise),
|
||||
("Compact Reactor", int2(2, 4), None),
|
||||
("Guided Missile Launcher", int2(0, 5), None),
|
||||
("Guided Missile Launcher", int2(5, 5), None),
|
||||
("Cell Blaster", int2(1, 8), None),
|
||||
("Cell Blaster", int2(4, 8), None),
|
||||
("Radiator", int2(2, 2), CounterClockwise),
|
||||
("Radiator", int2(3, 2), Clockwise),
|
||||
("Compact Sensor", int2(3, 10), None),
|
||||
("Capacitor", int2(1, 5), None),
|
||||
("Fire Control Array", int2(1, 6), Clockwise),
|
||||
("Store-All Plus", int2(2, 8), None));
|
||||
("Cargo Bay", int2(2, 8), None));
|
||||
|
||||
stage.Player(fighter, float2(0, 0), facing: float2(0, 1));
|
||||
stage.Place(fighter, HostileAt, facing: normalize(-HostileAt), stance: ScenarioStance.Hostile, piloted: true);
|
||||
|
|
|
|||
|
|
@ -23,35 +23,35 @@ public sealed class Pursuit : Scenario
|
|||
("Cockpit 2x2", int2(2, 6), None),
|
||||
("Large Drive", int2(1, 0), Reversed),
|
||||
("Large Drive", int2(3, 0), Reversed),
|
||||
("Talaria", int2(2, 14), CounterClockwise),
|
||||
("Talaria", int2(3, 14), Clockwise),
|
||||
("Core Power", int2(2, 4), None),
|
||||
("Rugged Drive", int2(2, 14), CounterClockwise),
|
||||
("Rugged Drive", int2(3, 14), Clockwise),
|
||||
("Compact Reactor", int2(2, 4), None),
|
||||
("Mine Launcher", int2(0, 5), None),
|
||||
("pswarm", int2(5, 5), None),
|
||||
("FastBlast+-", int2(1, 8), None),
|
||||
("FastBlast+-", int2(4, 8), None),
|
||||
("Iapyx", int2(2, 2), CounterClockwise),
|
||||
("Iapyx", int2(3, 2), Clockwise),
|
||||
("not if i see you first", int2(3, 10), None),
|
||||
("Swarm Rocket Pod", int2(5, 5), None),
|
||||
("Cell Blaster", int2(1, 8), None),
|
||||
("Cell Blaster", int2(4, 8), None),
|
||||
("Radiator", int2(2, 2), CounterClockwise),
|
||||
("Radiator", int2(3, 2), Clockwise),
|
||||
("Compact Sensor", int2(3, 10), None),
|
||||
("Fire Control Array", int2(1, 6), Clockwise),
|
||||
("Store-All Plus", int2(2, 8), None));
|
||||
("Cargo Bay", int2(2, 8), None));
|
||||
var pursuer = stage.Fit("Longinus",
|
||||
("Cockpit 2x2", int2(2, 6), None),
|
||||
("Large Drive", int2(1, 0), Reversed),
|
||||
("Large Drive", int2(3, 0), Reversed),
|
||||
("Talaria", int2(2, 14), CounterClockwise),
|
||||
("Talaria", int2(3, 14), Clockwise),
|
||||
("Core Power", int2(2, 4), None),
|
||||
("GT 3K", int2(0, 5), None),
|
||||
("GT 3K", int2(5, 5), None),
|
||||
("FastBlast+-", int2(1, 8), None),
|
||||
("FastBlast+-", int2(4, 8), None),
|
||||
("Iapyx", int2(2, 2), CounterClockwise),
|
||||
("Iapyx", int2(3, 2), Clockwise),
|
||||
("not if i see you first", int2(3, 10), None),
|
||||
("PotaT+-", int2(1, 5), None),
|
||||
("Rugged Drive", int2(2, 14), CounterClockwise),
|
||||
("Rugged Drive", int2(3, 14), Clockwise),
|
||||
("Compact Reactor", int2(2, 4), None),
|
||||
("Guided Missile Launcher", int2(0, 5), None),
|
||||
("Guided Missile Launcher", int2(5, 5), None),
|
||||
("Cell Blaster", int2(1, 8), None),
|
||||
("Cell Blaster", int2(4, 8), None),
|
||||
("Radiator", int2(2, 2), CounterClockwise),
|
||||
("Radiator", int2(3, 2), Clockwise),
|
||||
("Compact Sensor", int2(3, 10), None),
|
||||
("Capacitor", int2(1, 5), None),
|
||||
("Fire Control Array", int2(1, 6), Clockwise),
|
||||
("Store-All Plus", int2(2, 8), None));
|
||||
("Cargo Bay", int2(2, 8), None));
|
||||
|
||||
var player = stage.Player(layer, float2(0, 0), facing: float2(0, 1));
|
||||
stage.Cargo(player, "Coolant Vent", "Coolant Vent", "Coolant Vent", "Thruster Overdrive", "Thruster Overdrive");
|
||||
|
|
|
|||
|
|
@ -22,16 +22,16 @@ public sealed class RefusedRounds : Scenario
|
|||
("Cockpit 2x2", int2(4, 6), None),
|
||||
("Large Drive", int2(3, 0), Reversed),
|
||||
("Large Drive", int2(5, 0), Reversed),
|
||||
("Talaria", int2(4, 14), CounterClockwise),
|
||||
("Talaria", int2(5, 14), Clockwise),
|
||||
("Core Power", int2(4, 4), None),
|
||||
("Rugged Drive", int2(4, 14), CounterClockwise),
|
||||
("Rugged Drive", int2(5, 14), Clockwise),
|
||||
("Compact Reactor", int2(4, 4), None),
|
||||
("Smoke Refused", int2(3, 8), None),
|
||||
("Smoke Refused Beam", int2(6, 8), None),
|
||||
("Smoke Refused Charge", int2(3, 17), None),
|
||||
("Autocannon", int2(5, 17), None),
|
||||
("Iapyx", int2(4, 2), CounterClockwise),
|
||||
("Iapyx", int2(5, 2), Clockwise),
|
||||
("not if i see you first", int2(5, 10), None),
|
||||
("Radiator", int2(4, 2), CounterClockwise),
|
||||
("Radiator", int2(5, 2), Clockwise),
|
||||
("Compact Sensor", int2(5, 10), None),
|
||||
("Fire Control Array", int2(3, 6), Clockwise));
|
||||
|
||||
stage.Player(shooter, float2(0, 0), facing: float2(0, 1));
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ using static ItemRotation;
|
|||
public sealed class StarvedReactor : Scenario
|
||||
{
|
||||
public override string Name => "Starved Reactor";
|
||||
public override string Brief => "Two Spectras on a MoveOnPro, which can fall to a quarter of Core Power's charge, and a bare hull " +
|
||||
public override string Brief => "Two Light Lasers on a Muon Fusion Reactor, which can fall to a quarter of the Compact Reactor's charge, and a bare hull " +
|
||||
"to shoot. Verify: starvation reads as starvation, brownout degrades, refills stutter.";
|
||||
public override uint Seed => 102;
|
||||
public override bool Ambient => false;
|
||||
|
|
@ -17,14 +17,14 @@ public sealed class StarvedReactor : Scenario
|
|||
("Cockpit 2x2", int2(2, 6), None),
|
||||
("Large Drive", int2(1, 0), Reversed),
|
||||
("Large Drive", int2(3, 0), Reversed),
|
||||
("Talaria", int2(2, 14), CounterClockwise),
|
||||
("Talaria", int2(3, 14), Clockwise),
|
||||
("MoveOnPro", int2(2, 4), None),
|
||||
("Spectra", int2(1, 8), None),
|
||||
("Spectra", int2(4, 8), None),
|
||||
("Iapyx", int2(2, 2), CounterClockwise),
|
||||
("Iapyx", int2(3, 2), Clockwise),
|
||||
("not if i see you first", int2(3, 10), None),
|
||||
("Rugged Drive", int2(2, 14), CounterClockwise),
|
||||
("Rugged Drive", int2(3, 14), Clockwise),
|
||||
("Muon Fusion Reactor", int2(2, 4), None),
|
||||
("Light Laser", int2(1, 8), None),
|
||||
("Light Laser", int2(4, 8), None),
|
||||
("Radiator", int2(2, 2), CounterClockwise),
|
||||
("Radiator", int2(3, 2), Clockwise),
|
||||
("Compact Sensor", int2(3, 10), None),
|
||||
("Fire Control Array", int2(1, 6), Clockwise));
|
||||
stage.Player(starved, float2(0, 0));
|
||||
stage.Place(stage.Bare("Longinus"), float2(0, 400));
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ using static ItemRotation;
|
|||
public sealed class WeaponFeel : Scenario
|
||||
{
|
||||
public override string Name => "Weapon Feel";
|
||||
public override string Brief => "The Smoke Test Hull with a ChargeBlast SG, an Autocannon and a FastBlast+- burst weapon; a bare Longinus dead ahead. " +
|
||||
"Verify: ChargeBlast SG and Autocannon fire with effects, particles and action-bar icons; the burst weapon's " +
|
||||
"cadence is as before; a fast release-and-press on the ChargeBlast SG starts no second charge.";
|
||||
public override string Brief => "The Smoke Test Hull with a Charged Scatter Blaster, an Autocannon and a Cell Blaster burst weapon; a bare Longinus dead ahead. " +
|
||||
"Verify: Charged Scatter Blaster and Autocannon fire with effects, particles and action-bar icons; the burst weapon's " +
|
||||
"cadence is as before; a fast release-and-press on the Charged Scatter Blaster starts no second charge.";
|
||||
public override uint Seed => 107;
|
||||
public override bool Ambient => false;
|
||||
|
||||
|
|
@ -21,15 +21,15 @@ public sealed class WeaponFeel : Scenario
|
|||
("Cockpit 2x2", int2(4, 6), None),
|
||||
("Large Drive", int2(3, 0), Reversed),
|
||||
("Large Drive", int2(5, 0), Reversed),
|
||||
("Talaria", int2(4, 14), CounterClockwise),
|
||||
("Talaria", int2(5, 14), Clockwise),
|
||||
("Core Power", int2(4, 4), None),
|
||||
("ChargeBlast SG", int2(3, 17), None),
|
||||
("Rugged Drive", int2(4, 14), CounterClockwise),
|
||||
("Rugged Drive", int2(5, 14), Clockwise),
|
||||
("Compact Reactor", int2(4, 4), None),
|
||||
("Charged Scatter Blaster", int2(3, 17), None),
|
||||
("Autocannon", int2(5, 17), None),
|
||||
("FastBlast+-", int2(3, 8), None),
|
||||
("Iapyx", int2(4, 2), CounterClockwise),
|
||||
("Iapyx", int2(5, 2), Clockwise),
|
||||
("not if i see you first", int2(5, 10), None),
|
||||
("Cell Blaster", int2(3, 8), None),
|
||||
("Radiator", int2(4, 2), CounterClockwise),
|
||||
("Radiator", int2(5, 2), Clockwise),
|
||||
("Compact Sensor", int2(5, 10), None),
|
||||
("Fire Control Array", int2(3, 6), Clockwise));
|
||||
|
||||
stage.Player(shooter, float2(0, 0), facing: float2(0, 1));
|
||||
|
|
|
|||
|
|
@ -38,11 +38,13 @@ public readonly struct Signature
|
|||
|
||||
// What a painted ship learns of a beam on it (ruling sensor-stat-set item 4): a Search paint is a ping sweeping
|
||||
// it (Strength 0); a Track paint is a lock (Strength is the emitter's own lock progress, 0..1, ruling
|
||||
// lock-warning-strength). Never summed.
|
||||
// lock-warning-strength). A Scan paint is a held scanner: Strength is its scan progress 0..1 (ruling scan-is-an-act).
|
||||
// Never summed.
|
||||
public enum PaintMode
|
||||
{
|
||||
Search,
|
||||
Track
|
||||
Track,
|
||||
Scan
|
||||
}
|
||||
|
||||
// An ally's ping crossed `Subject` at `IlluminatedRange` through `IlluminatedObscuration`; `MaxRange` is that
|
||||
|
|
@ -100,16 +102,17 @@ public readonly struct PaintWarning
|
|||
// bearing at that act and the zone clock then. Held per (subject, item) in the observer's Entity; the latest act
|
||||
// replaces the earlier one. Position is never carried: only the track gives it. `Item` stays the true item: it is the
|
||||
// book's key and what aim reads. `Claimed` is the class the act claimed, and is what every classifying reader reads
|
||||
// (aetheria-ew, classify-from-belief).
|
||||
// (aetheria-ew, classify-from-belief). A null `Channel` is a reveal by the observer's own scan (Entity.RecordInspection),
|
||||
// whose `Claimed` is the subject's claim for the item.
|
||||
public readonly struct Reveal
|
||||
{
|
||||
public readonly EquippedItem Item;
|
||||
public readonly EquippableItemData Claimed;
|
||||
public readonly SignatureChannel Channel;
|
||||
public readonly SignatureChannel? Channel;
|
||||
public readonly float2 Bearing;
|
||||
public readonly float Time;
|
||||
|
||||
public Reveal(EquippedItem item, SignatureChannel channel, float2 bearing, float time, EquippableItemData claimed)
|
||||
public Reveal(EquippedItem item, SignatureChannel? channel, float2 bearing, float time, EquippableItemData claimed)
|
||||
{
|
||||
Item = item;
|
||||
Claimed = claimed;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@ public class PlanetSettings
|
|||
public float SecureAreaRadiusMultiplier = .45f;
|
||||
|
||||
public ExponentialCurve OrbitPeriod;
|
||||
|
||||
// The global flow stardust and nebula follow and the sim knows (FlowField). Zero flow by default.
|
||||
public FlowSettings Flow = new FlowSettings();
|
||||
}
|
||||
|
||||
[Serializable, MessagePackObject(keyAsPropertyName:true), JsonObject]
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ public class Zone
|
|||
}
|
||||
|
||||
// Zone time at full precision, for the index's orbital keys, which must agree with ChunkPose's own.
|
||||
internal double ExactTime => _time;
|
||||
public double ExactTime => _time;
|
||||
public ZonePack Pack { get; }
|
||||
public GalaxyZone GalaxyZone { get; }
|
||||
public Galaxy Galaxy { get; }
|
||||
|
|
@ -695,6 +695,20 @@ public class Zone
|
|||
return GravityAcceleration(new float2(normal.x, normal.z), Settings.GravityStrength);
|
||||
}
|
||||
|
||||
// The global flow velocity at `position` in zone time, in u/s (FlowField is the law). The slope term reads the
|
||||
// downhill gradient, which GetNormal's xz is proportional to.
|
||||
public float3 Flow(float3 position)
|
||||
{
|
||||
var normal = GetNormal(position.xz);
|
||||
return FlowField.At(Settings.Flow, position, FlowScroll, new float2(normal.x, normal.z));
|
||||
}
|
||||
|
||||
// The flow's noise scroll at zone time (Zone.Flow evaluates at exactly this); lowered to the shaders' _FlowScroll.
|
||||
public float2 FlowScroll => FlowField.Scroll(Settings.Flow, _time);
|
||||
|
||||
// The phase of a cycle of `period` seconds at zone time, for presenters that animate on the flow.
|
||||
public float CyclePhase(float period) => FlowField.Cycle(_time, period);
|
||||
|
||||
public static float PowerPulse(float x, float exponent)
|
||||
{
|
||||
x *= 2;
|
||||
|
|
|
|||
|
|
@ -27,16 +27,11 @@ public class VolumeSampling : MonoBehaviour
|
|||
public RenderTexture NebulaTint;
|
||||
|
||||
private MeshRenderer _gridMeshRenderer;
|
||||
private float _flowScroll;
|
||||
private Transform _gridTransform;
|
||||
private GlobalKeyword _keywordFlowGlobal;
|
||||
private GlobalKeyword _keywordFlowSlope;
|
||||
private GlobalKeyword _keywordNoiseSlope;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_keywordFlowGlobal = GlobalKeyword.Create("FLOW_GLOBAL");
|
||||
_keywordFlowSlope = GlobalKeyword.Create("FLOW_SLOPE");
|
||||
_keywordNoiseSlope = GlobalKeyword.Create("NOISE_SLOPE");
|
||||
|
||||
if (GridMesh != null)
|
||||
|
|
@ -52,6 +47,7 @@ public class VolumeSampling : MonoBehaviour
|
|||
Shader.SetGlobalVector("_GridTransform", new Vector4(_gridTransform.position.x,_gridTransform.position.z,GridCamera.orthographicSize*2));
|
||||
|
||||
var environment = ActionGameManager.Instance?.CurrentEnvironment ?? Settings.DefaultEnvironment;
|
||||
var clock = FlowClock;
|
||||
|
||||
if (GridMesh != null)
|
||||
{
|
||||
|
|
@ -91,18 +87,46 @@ public class VolumeSampling : MonoBehaviour
|
|||
Shader.SetGlobalFloat("_NebulaNoiseExponent", environment.Noise.Exponent);
|
||||
Shader.SetGlobalFloat("_NebulaNoiseAmplitude", environment.Noise.Amplitude);
|
||||
Shader.SetGlobalFloat("_NebulaNoiseSpeed", environment.Noise.Speed);
|
||||
// The noise the flow advects evolves on the flow's clock too: it pauses with the sim.
|
||||
Shader.SetGlobalFloat("_NebulaNoiseTime", (float) clock);
|
||||
Shader.SetGlobalFloat("_NebulaNoiseSlopeExponent", environment.Noise.SlopeExponent);
|
||||
|
||||
Shader.SetGlobalFloat("_FlowScale", environment.Flow.GlobalScale);
|
||||
Shader.SetGlobalFloat("_FlowAmplitude", environment.Flow.GlobalAmplitude);
|
||||
Shader.SetGlobalFloat("_FlowSlopeAmplitude", environment.Flow.SlopeAmplitude);
|
||||
Shader.SetGlobalFloat("_FlowSwirlAmplitude", environment.Flow.SwirlAmplitude);
|
||||
_flowScroll += environment.Flow.GlobalScrollSpeed * Time.deltaTime;
|
||||
Shader.SetGlobalFloat("_FlowScroll", _flowScroll);
|
||||
Shader.SetGlobalFloat("_FlowPeriod", environment.Flow.Period);
|
||||
|
||||
Shader.SetKeyword(_keywordFlowGlobal, environment.Flow.GlobalAmplitude != 0);
|
||||
Shader.SetKeyword(_keywordFlowSlope, environment.Flow.SlopeAmplitude != 0 || environment.Flow.SwirlAmplitude != 0);
|
||||
// The flow is the zone's: its settings and its time. Without a zone (menus) the same law runs on the presentation clock.
|
||||
LowerFlow(ActionGameManager.Instance?.Zone?.Settings.Flow ?? Settings.PlanetSettings.Flow, clock);
|
||||
Shader.SetKeyword(_keywordNoiseSlope, environment.Noise.SlopeExponent != 0);
|
||||
}
|
||||
|
||||
// GlobalKeyword's constructor only looks a keyword up; Create registers it. The shaders' pragmas and this owner
|
||||
// agree on the names. Unity refuses Create inside a MonoBehaviour's construction, and a scene constructing the
|
||||
// first VolumeSampling runs this type's static initializer there, so the keywords are created on first use, from
|
||||
// LowerFlow, never in a field initializer.
|
||||
static GlobalKeyword? _keywordFlowGlobal;
|
||||
static GlobalKeyword? _keywordFlowSlope;
|
||||
static GlobalKeyword KeywordFlowGlobal => _keywordFlowGlobal ??= GlobalKeyword.Create("FLOW_GLOBAL");
|
||||
static GlobalKeyword KeywordFlowSlope => _keywordFlowSlope ??= GlobalKeyword.Create("FLOW_SLOPE");
|
||||
|
||||
/// <summary>
|
||||
/// The time the flow runs on: the zone's own (so drift stops with the sim and follows sim speed), or on menus,
|
||||
/// where no zone exists, the presentation clock.
|
||||
/// </summary>
|
||||
public static double FlowClock => ActionGameManager.Instance?.Zone?.ExactTime ?? Time.timeSinceLevelLoad;
|
||||
|
||||
/// <summary>
|
||||
/// The one place that sets the flow uniforms and keywords: every shader flow term derives from FlowSettings and
|
||||
/// the flow clock through FlowField, so no presenter keeps its own flow clock.
|
||||
/// </summary>
|
||||
public static void LowerFlow(FlowSettings flow, double flowClock)
|
||||
{
|
||||
Shader.SetGlobalFloat("_FlowScale", flow.GlobalScale);
|
||||
Shader.SetGlobalFloat("_FlowAmplitude", flow.GlobalAmplitude);
|
||||
Shader.SetGlobalFloat("_FlowSlopeAmplitude", flow.SlopeAmplitude);
|
||||
Shader.SetGlobalFloat("_FlowSwirlAmplitude", flow.SwirlAmplitude);
|
||||
var scroll = FlowField.Scroll(flow, flowClock);
|
||||
Shader.SetGlobalVector("_FlowScroll", new Vector4(scroll.x, scroll.y));
|
||||
Shader.SetGlobalFloat("_FlowPeriod", flow.Period);
|
||||
Shader.SetGlobalFloat("_FlowCycle", FlowField.Cycle(flowClock, flow.Period));
|
||||
|
||||
Shader.SetKeyword(KeywordFlowGlobal, flow.GlobalAmplitude != 0);
|
||||
Shader.SetKeyword(KeywordFlowSlope, flow.SlopeAmplitude != 0 || flow.SwirlAmplitude != 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
27
Assets/Shaders/Compute/FlowParity.compute
Normal file
27
Assets/Shaders/Compute/FlowParity.compute
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// Evaluates the shader flow functions for a buffer of positions and gradients, so that
|
||||
// Aetheria.EditorTools.FlowFieldParityVerify can compare them with FlowField (ServerShared). Reads the same global
|
||||
// _Flow* uniforms the nebula and stardust read, set by VolumeSampling.LowerFlow.
|
||||
#pragma kernel Evaluate
|
||||
// A compute shader declares the global keywords itself (as Stardust.compute does); the flow() it calls is keyword-gated.
|
||||
#pragma multi_compile __ FLOW_GLOBAL
|
||||
#pragma multi_compile __ FLOW_SLOPE
|
||||
|
||||
#include "Assets/Shaders/Volumetric.cginc"
|
||||
|
||||
StructuredBuffer<float3> positions;
|
||||
StructuredBuffer<float2> gradients;
|
||||
RWStructuredBuffer<float3> globalOut;
|
||||
RWStructuredBuffer<float3> slopeOut;
|
||||
RWStructuredBuffer<float3> gatedOut; // flow(): the keyword-gated function the nebula and stardust call
|
||||
RWStructuredBuffer<float> noiseOut; // triNoise3d: the nebula noise the flow advects
|
||||
uint count;
|
||||
|
||||
[numthreads(64, 1, 1)]
|
||||
void Evaluate(uint3 id : SV_DispatchThreadID)
|
||||
{
|
||||
if (id.x >= count) return;
|
||||
globalOut[id.x] = globalFlow(positions[id.x]);
|
||||
slopeOut[id.x] = slopeFlow(gradients[id.x]);
|
||||
gatedOut[id.x] = flow(positions[id.x]);
|
||||
noiseOut[id.x] = triNoise3d(positions[id.x] / 512);
|
||||
}
|
||||
7
Assets/Shaders/Compute/FlowParity.compute.meta
Normal file
7
Assets/Shaders/Compute/FlowParity.compute.meta
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fd5f95c7d7c63b243aadd16f6e9dc702
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -25,7 +25,7 @@ Texture2D HueTexture;
|
|||
SamplerState samplerHueTexture;
|
||||
|
||||
float period;
|
||||
float time;
|
||||
float phase; // the cycle phase from zone time (FlowField.Cycle), in [0, 1)
|
||||
float spacing;
|
||||
float ceilingHeight;
|
||||
float floorHeight;
|
||||
|
|
@ -125,7 +125,7 @@ void UpdateParticles(uint3 id : SV_DispatchThreadID, int3 groupID : SV_GroupThre
|
|||
uint xp = x + xt + offset;
|
||||
uint yp = y + yt + offset;
|
||||
|
||||
const float lifetime = frac(time / period + RandomFirst(xp, yp));
|
||||
const float lifetime = frac(phase + RandomFirst(xp, yp));
|
||||
|
||||
particles[id.x].position = float3(
|
||||
x * spacing + xt * spacing + perlinNoise1D(RandomValue()*1024)*spacing, 0,
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ public class Stardust : MonoBehaviour
|
|||
//public Transform TargetTransform;
|
||||
public Camera GravityCamera;
|
||||
|
||||
private float _flowScroll;
|
||||
private const int GROUP_SIZE = 128;
|
||||
private int _updateParticlesKernel;
|
||||
#endregion
|
||||
|
|
@ -102,7 +101,8 @@ public class Stardust : MonoBehaviour
|
|||
//Bind resources to compute shader
|
||||
ParticleCalculation.SetBuffer(_updateParticlesKernel, "particles", _particlesBuffer);
|
||||
|
||||
ParticleCalculation.SetFloat("time", Time.time);
|
||||
// Particle lifetimes cycle on the flow clock (zone time), so the dust stops with the sim like everything the flow moves.
|
||||
ParticleCalculation.SetFloat("phase", FlowField.Cycle(VolumeSampling.FlowClock, Period));
|
||||
|
||||
var pos = GravityCamera.transform.position;
|
||||
ParticleCalculation.SetFloat("period", Period);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ uniform half _NebulaFillDensity,
|
|||
_NebulaNoiseSlopeExponent,
|
||||
_FlowScale,
|
||||
_FlowAmplitude,
|
||||
_FlowScroll,
|
||||
_FlowCycle,
|
||||
_FlowPeriod,
|
||||
_FlowSlopeAmplitude,
|
||||
_FlowSwirlAmplitude,
|
||||
|
|
@ -42,6 +42,9 @@ uniform half _NebulaFillDensity,
|
|||
_DynamicLodHigh,
|
||||
_DynamicIntensity,
|
||||
_DynamicSkyBoost;
|
||||
float2 _FlowScroll;
|
||||
// The flow clock (zone time, VolumeSampling.FlowClock): the nebula noise evolves on it, never on _Time.
|
||||
float _NebulaNoiseTime;
|
||||
|
||||
inline float tri(in float x){return abs(frac(x)-.5);}
|
||||
inline float3 tri3(in float3 p){return float3( tri(p.z+tri(p.y*1.)), tri(p.z+tri(p.x*1.)), tri(p.y+tri(p.x*1.)));}
|
||||
|
|
@ -54,7 +57,7 @@ float triNoise3d(in float3 p)
|
|||
for (float i=0.; i<=1.; i++ )
|
||||
{
|
||||
float3 dg = tri3(bp * 2.);
|
||||
p += dg + _Time.y * _NebulaNoiseSpeed;
|
||||
p += dg + _NebulaNoiseTime * _NebulaNoiseSpeed;
|
||||
|
||||
bp *= 1.8;
|
||||
z *= 1.5;
|
||||
|
|
@ -66,10 +69,11 @@ float triNoise3d(in float3 p)
|
|||
return rz;
|
||||
}
|
||||
|
||||
float3 Tri3D( float3 P )
|
||||
// The two octaves' positions arrive already scrolled (FlowField.Scroll folds each octave's phase in double).
|
||||
float3 Tri3D( float3 P, float3 PGolden )
|
||||
{
|
||||
float3 t1 = normalize(tri3(P));
|
||||
float3 t2 = normalize(tri3(P * 1.61803398875));
|
||||
float3 t2 = normalize(tri3(PGolden));
|
||||
return cross(t1,t2);
|
||||
}
|
||||
|
||||
|
|
@ -129,13 +133,15 @@ float3 gravNormal (float2 grad)
|
|||
|
||||
float3 globalFlow(float3 pos)
|
||||
{
|
||||
float3 flowSample = Tri3D( pos / _FlowScale - float3(0,_FlowScroll,0) ) * _FlowAmplitude;
|
||||
const float3 field = pos / _FlowScale;
|
||||
float3 flowSample = Tri3D( field - float3(0,_FlowScroll.x,0), field * 1.61803398875 - float3(0,_FlowScroll.y,0) ) * _FlowAmplitude;
|
||||
flowSample.y *= .5;
|
||||
return flowSample;
|
||||
}
|
||||
|
||||
float3 slopeFlow(float2 grad)
|
||||
{
|
||||
if (dot(grad, grad) == 0) return 0;
|
||||
float2 ngrad = normalize(grad);
|
||||
return float3(ngrad.y, 0, -ngrad.x) * _FlowSwirlAmplitude + float3(ngrad.x, 0, ngrad.y) * _FlowSlopeAmplitude;
|
||||
}
|
||||
|
|
@ -197,13 +203,13 @@ float density(float3 pos)
|
|||
#endif
|
||||
#endif
|
||||
|
||||
const float lerp1 = frac(_Time.y / _FlowPeriod);
|
||||
const float lerp2 = frac(_Time.y / _FlowPeriod + .5);
|
||||
const float lerp1 = frac(_FlowCycle);
|
||||
const float lerp2 = frac(_FlowCycle + .5);
|
||||
const float noise1 = pow(triNoise3d((pos+fl.xyz * (lerp1 - .5) * _FlowPeriod) / _NebulaNoiseScale),exponent) * tri2(lerp1);
|
||||
const float noise2 = pow(triNoise3d((pos+fl.xyz * (lerp2 - .5) * _FlowPeriod) / _NebulaNoiseScale),exponent) * tri2(lerp2);
|
||||
pos.y += (noise1 + noise2) * heightFade * _NebulaNoiseAmplitude;
|
||||
const float lerp3 = frac(_Time.y / _FlowPeriod * 2 + .25);
|
||||
const float lerp4 = frac(_Time.y / _FlowPeriod * 2 + .75);
|
||||
const float lerp3 = frac(_FlowCycle * 2 + .25);
|
||||
const float lerp4 = frac(_FlowCycle * 2 + .75);
|
||||
const float noise3 = pow(triNoise3d((pos+fl.xyz * (lerp3 - .5) * _FlowPeriod / 2) / _NebulaNoiseScale * 8), exponent) * tri2(lerp3);
|
||||
const float noise4 = pow(triNoise3d((pos+fl.xyz * (lerp4 - .5) * _FlowPeriod / 2) / _NebulaNoiseScale * 8), exponent) * tri2(lerp4);
|
||||
pos.y -= (noise3 + noise4) * heightFade * _NebulaNoiseAmplitude / 2;
|
||||
|
|
|
|||
BIN
GameData/Aetheria.cc
(Stored with Git LFS)
BIN
GameData/Aetheria.cc
(Stored with Git LFS)
Binary file not shown.
|
|
@ -54,7 +54,7 @@ Cuts without a `cut_spec`, withdrawn 2026-10-12 under map-only-what-runs: a spec
|
|||
- matrix-mines: Weapon matrix, Mine row: Mine Rack, Heavy Mine Layer and Minefield Projector beside the Mine Launcher, with warhead and. Waits on: roles-backfill (refresh needed; ruling catalog-breadth-now (superseded catalog-breadth-after-visibility 2026-10-13): runs now, refresh against master first).
|
||||
- product-lines-gear: Gear product lines: the twenty-two second-maker products of follow-up gear-product-lines, with role quality from maker. Waits on: generic-design-names, roles-backfill (blocked on generic-design-names; ruling catalog-breadth-now (superseded catalog-breadth-after-visibility 2026-10-13): runs now, refresh against master first).
|
||||
- product-lines-weapons: Weapon product lines (r2): r1's nineteen products plus a second maker for the Mine Launcher, authored after. Waits on: generic-design-names, lot-product, roles-backfill (blocked on generic-design-names; ruling catalog-breadth-now (superseded catalog-breadth-after-visibility 2026-10-13): runs now, refresh against master first).
|
||||
- boost-gear-combat: Stat boosters, combat, tiered by size: a modest 1x1 and a strong 2x2 each for Damage and Range on every gun through. Waits on: boost-gear-systems (blocked on boost-gear-systems; ruling catalog-breadth-now (superseded catalog-breadth-after-visibility 2026-10-13): runs now, refresh against master first).
|
||||
- boost-gear-combat: Stat boosters, combat, tiered by size: a modest 1x1 and a strong 2x2 each for Damage and Range on every gun through. Waits on: boost-gear-systems (blocked on boost-gear-systems; ruling catalog-breadth-now (superseded catalog-breadth-after-visibility 2026-10-13): runs now, refresh against master first). After damage-falloff: a Range Extender multiplies Range only, so it lengthens the falloff ramp and leaves EffectiveRange where it was; the cut decides whether it also targets EffectiveRange (section "Damage falloff at fire time", DF8).
|
||||
- boost-gear-systems: Stat boosters, systems, tiered by size: a modest 1x1 and a strong 2x2 each for Thrust, Signal, Emissivity and Reactor. Waits on: nothing in the mind (refresh needed; ruling catalog-breadth-now (superseded catalog-breadth-after-visibility 2026-10-13): runs now, refresh against master first).
|
||||
- ships-player: S3, agent side: a player built by AetheriaBuild composes and preloads mod ships with Aetheria materials only, radiators. Waits on: ships-mounts, ships-hull-material, player-build (blocked on ships-hull-material).
|
||||
- ships-addon-gizmos: Blender Ship Mounts tool (r6): gizmos select and drag mounts snapped to cells in Ship Root's frame; arc fans from the. Waits on: ships-addon-mesh-mounts (blocked on ships-addon-mesh-mounts).
|
||||
|
|
@ -73,7 +73,6 @@ Cuts without a `cut_spec`, withdrawn 2026-10-12 under map-only-what-runs: a spec
|
|||
- radiator-geonodes: a Geometry Nodes setup molds radiator panels over a region marked on the model under the radiator hardpoint's name, in the live hull stack. Waits on: Ruling: radiator-panels-molded-by-geonodes. HELD for the operator walkthrough on Starfire (ruling hardpoint-work-held-for-walkthrough). Schematic and model are separate spaces linked only by mount name (ruling schematic-and-model-are-separate-spaces).
|
||||
- floating-greeble-library: operator seed pieces, model-written parametric families, placements as hull-local data (never a GN scatter on the live mesh), merged into the ship mesh at export, kept out of socket clearance. Waits on: operator seed set. Research: GameCult.Geometry.Csg docs/research/greebles-prior-art.md (4877300).
|
||||
|
||||
- damage-curve-delete: delete WeaponData.DamageCurve (MessagePack key 7 tombstoned, never reused), the three Weapon RangeDamagePerSecond curve reads and the claims cut's rated copies, which become DamagePerSecond inside [MinRange, Range] and 0 outside; PropertiesPanel's "Damage Range" chart becomes the range numbers; catalog re-saved by AetherDb so the stored schema matches; fixtures that build a DamageCurve lose it. Waits on: the operator's answer on range falloff (section "Weapon damage over range"), and ew-claims-in-the-book merged (it rewrites the same formulas). Rulings: range-ramps-not-curve.
|
||||
- sensor-bearing-shape: SensorData.SensitivityCurve (gain over bearing angle / PI, read in the sim by Sensor.cs:229,262 and bounded by HullRange at :271) becomes authored scalars or is replaced by the beam width ruling sensor-stat-set already names. Waits on: the sensor-catalog chain; decide with it, not before.
|
||||
- consumable-effectiveness: ConsumableItemData.Effectiveness (a BezierCurve over progress through duration, read by Entity.cs:1921 ConsumableProgressFactor) is null on both shipped consumables, so any stat that declares a ConsumableProgress term throws; delete it or give it a validated shape. Waits on: nothing in the mind.
|
||||
## Body facts
|
||||
|
|
@ -8417,16 +8416,16 @@ Aimed across 8 test files; FireControlCut12Tests pins ResolveAimPoint's cell ave
|
|||
|---|---|---|---|
|
||||
| Signature channel (`SignatureChannel`: Thermal, Reflection, DrivePlume, LaunchFlash, Emission) | A closed enum, the five channels of ruling visibility-per-capability-reveal. Saved only as `VisibilityData.Channel` (catalog, by value; append-only, a value is never reused). | Fixed set; a new channel is a code change and a ruling. | The ruling. Code names each writer's channel; the catalog names a Visibility gear's. |
|
||||
| Light signature (`Signature {Channel, Strength, Item}` in `Entity.VisibilitySources`) | (emitting entity, source object). The source is the writing behaviour, or the entity for hull radiation; the key is a reference, so injective. `Item` is derived from the behaviour's `Item` (null for hull radiation and consumable effects). Channel Emission is never a light signature (after cut emissions-heard). | Written each tick its source acts (thermal, radiator, reflector, visibility gear continuously; weapon fire and plume when they act). Decayed by VisibilityDecay in the owner's Update and removed below 0.1. Runtime only, never saved. | One writer per entry: its source, through `Entity.SetSignature`. Entity.Update the only decayer. Forbidden: another entity, any presenter, a direct dictionary write. `Visibility` (the sum) stays the track input. |
|
||||
| Active emission (`ActiveEmission {Item, HearRange, Mode}` in `Entity.ActiveEmissions`) | (emitting entity, emitting item, tick). No persistent id. | Posted to the emitter's inbox each tick it emits (a ping wavefront in flight: Search; a lock paint inside LockAngle: Track); published in the zone's pre-phase with paints; lives exactly one tick. Never saved. | Sensor.Execute (search) and LockWeapon.Execute (track) through `Entity.Emit`; Entity publishes. HearRange = the emitter's range / its InterceptFactor, fixed at the emit. |
|
||||
| Paint warning (`PaintWarning {Bearing, EmitterClass, Mode, Strength}` in `Entity.IncomingPaints`; was LockWarning / IncomingLocks) | (painted entity, tick, painter beam). No id. | One tick after its last paint (unchanged from lock-warning). Search paints carry Strength 0. | LockWeapon.Execute (Track) and a ping wavefront crossing (Search, Sensor.Execute) call ReceivePaint; Entity publishes. Painted targets are always warned (sensor-stat-set 4). |
|
||||
| Active emission (`ActiveEmission {Item, HearRange, Claimed}` in the emitter's private `_emissions`) | (emitting entity, emitting item, tick). No persistent id. | Written by `Entity.Emit` during the emitter's Update each tick it emits (a ping wavefront in flight, a lock paint inside LockAngle, a held scan after inspection-scanner); read only by other entities' Sense in the same tick; cleared by the emitter's next PublishInbox and by Deactivate. No mode. Never saved. | Sensor.Execute, LockWeapon.Execute and (inspection-scanner) Scanner.Execute through `Entity.Emit`, which stamps `Claimed = ClaimOf(item)`. HearRange = the emitter's range / its InterceptFactor, fixed at the emit. (Body at b836af48: IS3.) |
|
||||
| Paint warning (`PaintWarning {Bearing, EmitterClass, Mode, Strength}` in `Entity.IncomingPaints`; was LockWarning / IncomingLocks) | (painted entity, tick, painter beam). No id. | One tick after its last paint (unchanged from lock-warning). Search paints carry Strength 0; Scan paints (inspection-scanner) carry the scan's progress. | LockWeapon.Execute (Track), a ping wavefront crossing (Search, Sensor.Execute) and a held scan (Scan, Scanner.Execute) call ReceivePaint; Entity publishes, and PublishInbox records the painter's item as an Emission reveal. Painted targets are always warned (sensor-stat-set 4, scan-is-an-act). |
|
||||
| Track (`EntityInfoGathered[subject]`) | (observer, subject entity). | Seeded 0 on zone entry, revised each tick by each active sensor (passive gain, decay), plus one monostatic gain on the tick its own ping crosses the subject and one bistatic gain per published ping return (R2); removed when the subject leaves; cleared on Deactivate. Runtime only. | Sensor.Execute only, reading the observer's own receivers and its own published returns. Forbidden: shared-track writes (ruling shared-track-bearing-only), presenters, other ships, any read of another ship's Sensor state. |
|
||||
| Ping sweep (`Sensor._reached`, per pinging sensor) | (pinging sensor, ping). The set of subjects the wavefront has reached this ping, in the beam or not. | Cleared at Ping(); a subject joins on the first sweeping tick it lies inside the radius, and that is its one crossing (credited and painted only if inside the beam then); nothing joins after the ping's last step; emptied when the sensor is idle. Runtime only. | The pinging Sensor.Execute alone decides "this ping crossed this subject, once". Forbidden: another sensor or ship reading its radii; an interval sample standing in for it. |
|
||||
| Ping return (`PingReturn {Subject, IlluminatedRange, IlluminatedObscuration, MaxRange}` in the ally's `PingReturns`) | (receiving entity, pinging sensor, subject, tick). No id. | Posted by the pinger to each ally's inbox on the crossing tick; published in the zone pre-phase with paints (`PublishInbox`); lives exactly one tick. Never saved. | The pinger posts (it owns the illuminated leg and its own range); the receiving Sensor credits from its own Sensitivity, PingBoost, distance and sight line (it owns the receive leg). Forbidden: the pinger writing the ally's track; the ally reading the pinger. |
|
||||
| Reveal (`Reveal {Item, Channel, Bearing, Time}` in the observer's reveal book, keyed (subject, item)) | (observer, subject entity, revealed item), by reference. Channel is null for a reveal by inspection (cut inspection-scanner). | Created on the first act the observer's instruments receive, or for every live item when the observer's scanner completes a scan; Channel, Bearing and Time refreshed by each later act; ended for an item when the observer perceives its destruction, and for all of a subject's items when the observer perceives the subject's death or departure (acts received through the observer's own Sense step, never a subscription to the subject); a subject leaving the zone does not by itself empty any book: its entries stay unrefreshed and are pruned once the freshest is older than BearingMemory; Contact never reads the subject's live equipment or Durability, and only the aiming read (IsRevealed, IsLocated) filters on the live item (Durability < .01 or off the subject) (Defaulted ruling reveal-ends-on-perception); RecordReveal and its one removal counterpart are the book's only writers and its one membership gate; cleared on Deactivate. Not decayed: memory of the sitting. Never saved. | `Entity.Sense` (once per Entity.Update) for light acts and heard emissions; `ReceivePaint` for paints; `Entity.RecordInspection` (called by the observer's own Scanner) for scans. Forbidden: Sensor's track loop, presenters, another ship, shared tracks. |
|
||||
| Reveal (`Reveal {Item, Channel, Bearing, Time}` in the observer's reveal book, keyed (subject, item)) | (observer, subject entity, revealed item), by reference. Channel is null for a reveal by inspection (cut inspection-scanner). | Created on the first act the observer's instruments receive, or for every fitted, non-destroyed, non-hull item when the observer's scanner completes a scan (Channel null, Claimed the subject's `ClaimOf(item)`, as any act records the claim it carries: aetheria-ew one-judge; a scan creates and refreshes entries and ends none); Channel, Bearing and Time refreshed by each later act; ended for an item when the observer perceives its destruction, and for all of a subject's items when the observer perceives the subject's death or departure (acts received through the observer's own Sense step, never a subscription to the subject); a subject leaving the zone does not by itself empty any book: its entries stay unrefreshed and are pruned once the freshest is older than BearingMemory; Contact never reads the subject's live equipment or Durability, and only the aiming read (IsRevealed, IsLocated) filters on the live item (Durability < .01 or off the subject) (Defaulted ruling reveal-ends-on-perception); RecordReveal and its one removal counterpart are the book's only writers and its one membership gate; cleared on Deactivate. Not decayed: memory of the sitting. Never saved. | `Entity.Sense` (once per Entity.Update) for light acts and heard emissions; `ReceivePaint` for paints; `Entity.RecordInspection` (called by the observer's own Scanner) for scans. Forbidden: Sensor's track loop, presenters, another ship, shared tracks. |
|
||||
| Hull layout knowledge (derived by `Entity.LayoutOf(subject)`) | (observer, subject hull class). The class is the subject's HullData; the layout is its Hardpoints (type, position, shape). | Derived on read: the subject's HullData.Hardpoints while ContactOf(subject).Identified, else empty. Stored nowhere; never says what is fitted. | `Entity.LayoutOf` is the one derivation (ruling quiet-gear-identifiable-hull-layout-known). Readers: IsLocated, the target schematic, the player's cycle. |
|
||||
| Contact (`Contact`, derived by `Entity.ContactOf(subject)`) | (observer, subject). | Derived on read from track, reveals, the zone clock and `BearingMemory`; stored nowhere. Flags: Detected (tracked, or a reveal younger than BearingMemory), Tracked (track > TargetDetectionInfoThreshold, which is VisibleEntities), Classified (detected and any reveal), Identified (track >= TargetGearInfoThreshold, name kept, now the identify threshold). Bearing: the true bearing while tracked, else the freshest reveal's. | `Entity.ContactOf` is the one derivation. HUD and AI read it; VisibleEntities stays the tracked set. |
|
||||
| Located item (`FireControl.IsLocated(observer, item)`) and aim point | (observer, subject item). | Derived on every read: revealed, or on a hardpoint of a layout the observer holds. The aim point is the item's own cells when revealed, else its hardpoint's cells; the choice is frozen into the shot with Aimed. | FireControl (R10). TrySelectTargetItem and ResolvedTargetItem gate on IsLocated; anything that reads an item's stats or class (AI weapon choice, schematic weapon rows) gates on IsRevealed. |
|
||||
| Scan (`Scanner` behaviour; progress per (scanner, target)) | (scanning item, the ship's Target). | Progress builds while the Target is tracked and within Range, at 1/ScanTime per second; falls at the same rate otherwise; reset on target change; at 1 the scan completes (RecordInspection) and progress restarts. Runtime only. | The Scanner behaviour; RecordInspection in Entity.cs writes the reveals. While scanning: a Scan paint (Strength = progress) on the target and an Emit(Item, Range / InterceptFactor, Scan) (question scanner-reveals-its-user, recommended). |
|
||||
| Scan (`Scanner` behaviour; progress per (scanner, target)) | (scanning item, the ship's Target entity). | Progress builds in Execute while the item is Active and its Target is tracked (VisibleEntities) and within Range (TargetRange), at 1/ScanTime per second; falls at the same rate in the behaviour's always-run Update on any tick it was not held (out of range, untracked, no target, or the item inactive: ruling scan-held-beam); reset on a target change; at 1 the scan completes (RecordInspection) and progress restarts. Runtime only. No hostility gate (a scan reads no true faction: classify-from-belief). | The Scanner behaviour owns progress; RecordInspection in Entity.cs writes the reveals through RecordReveal's gate. While held: a Scan paint (Strength = progress) on the target and Emit(Item, Range / InterceptFactor) (ruling scan-is-an-act). |
|
||||
| Sensor stats (SensorData Sensitivity key 3 = detection power, BeamWidth key 12, InterceptFactor key 13; LockWeaponData.InterceptFactor key 26; ListenerData.Multiple key 1; ScannerData Range 1, ScanTime 2, InterceptFactor 3) | Fields of a catalog design; brand flavour through product role quality. | Authored by AetherDb (cut sensor-catalog); resolved per item through StatResolver. PingVisibility (key 7) is retired, never reused. | The catalog. Readers: Sensor (BeamWidth, InterceptFactor), LockWeapon (InterceptFactor), Entity.HearingMultiple (ListenerData). |
|
||||
|
||||
No empty cell. Two decisions are defaults, not rulings: reveals never decay within a sitting (a ship
|
||||
|
|
@ -9481,3 +9480,168 @@ No weapon's falloff was ever authored: 26 weapons carry one copied template, and
|
|||
|
||||
Not for range: the deletion removes the only weapon use. Of the other BezierCurve uses, one is live in the sim (sensor bearing gain, on 2 records with the default template), one is null on every record (consumable effectiveness), and the launcher curves are `float4[]` Unity keyframes used only in presentation. A piecewise-linear keyframe type would be the same data with straight segments. Its real gains over BezierCurve are small: `HullRange` becomes exact (the extremes sit at the keys), and the mutable `_cachedIndices` search cache goes from shared sim data. That does not earn a new type or a CultMath change now: CultMath's `lerp` and `unlerp` already are the segment math, and CultMath holds no keyed or serialized curve. Decide it when the sensor line is mapped. R-heat's four scalars stay: they are the controls the operator asked for ("Same shape, more intuitive controls").
|
||||
|
||||
|
||||
# Inspection-scanner refresh at b836af48
|
||||
|
||||
Imagination imagination-aeth-inspection-scanner, session self-2026-10-14-ag, 2026-10-14. Pinned to Aetheria
|
||||
origin/master b836af48 (contact-hud, emissions-heard, reveals-replace-tiers, scenarios-lock-on, aetheria-ew
|
||||
ew-hide-launch and ew-claims-in-the-book, loot-3 merged). Refreshes cut_spec inspection-scanner (r2 -> r3) only;
|
||||
bearing-markers, layout-aim and scanner-catalog stay lines in the cut sequence. Paths under
|
||||
Assets/Scripts/ServerShared unless noted. Source reads at b836af48.
|
||||
|
||||
## Body facts
|
||||
|
||||
IS1. r2's anchors at b836af48 (context-pack): PaintMode moved to Sensing.cs:42-46 (comment 39-41); Reveal is
|
||||
Sensing.cs:104-120 (comment 99-103) and gained `Claimed` (ew-claims-in-the-book); RecordReveal is Entity.cs:944-950
|
||||
(comment 937-943) and takes `(subject, item, channel, claimed)`. `Reveal.Channel` is still a non-null
|
||||
`SignatureChannel`. The only `new Reveal(` is Entity.cs:949.
|
||||
|
||||
IS2. No production code reads `Reveal.Channel`: its readers are tests only (ContactRevealTests 321, 410, 413, 437,
|
||||
1000; EmissionTests 62, 103, 111; LaunchSuppressorTests 61), each `Assert.Equal(SignatureChannel.X, reveal.Channel)`,
|
||||
which infers `T = SignatureChannel?` once Channel is nullable and so needs no edit.
|
||||
|
||||
IS3. Claims (aetheria-ew ew-claims-in-the-book): `Entity.ClaimOf(item)` (Entity.cs:117-118) is the item's data
|
||||
unless claimed otherwise; `Claim` is the one write port, tests only until ew-masquerade (109-127). Every act stamps
|
||||
it: SetSignature (106), Emit (921-925: `ActiveEmission(item, hearRange, ClaimOf(item))`, two arguments, no mode),
|
||||
ReceivePaint (931-935: `PaintWarning(bearing, emitter.ClaimOf(item), mode, strength)`). PublishInbox (897-911)
|
||||
records each painter's item as an Emission reveal with the paint's EmitterClass. Classifying readers read
|
||||
`Reveal.Claimed` (RevealedWeapons 985-987, SchematicRows 1000-1003); ContactOf derives Profile from
|
||||
`subject.ClaimedHull` at Identified (1011-1030).
|
||||
|
||||
IS4. The hull is an equipped item: `EquippedHull` is added to `Equipment` (Entity.cs:1217-1218), and Claim refuses a
|
||||
hull class on any other item and any other class on the hull (123-124). A scan that walks Equipment must skip
|
||||
`subject.EquippedHull` explicitly.
|
||||
|
||||
IS5. Behaviour execution (EquippedItem.Update, Entity.cs:2299-2320): Execute runs per behaviour group only while
|
||||
`Active.Value` (Enabled && Online, 2126-2127); every `IAlwaysUpdatedBehavior.Update` runs after it on every tick,
|
||||
active or not. A behaviour whose Execute alone decays progress therefore freezes while its item is inactive.
|
||||
`TargetRange` is computed in Entity.Update (1704-1706) before the equipment updates.
|
||||
|
||||
IS6. Aim gate: `FireControl.IsRevealed(observer, item)` is book AND live (FireControl.cs:160-161);
|
||||
`TrySelectTargetItem` and `ResolvedTargetItem` read it (Entity.cs:410-432). A scan reveal therefore makes quiet gear
|
||||
selectable with no change to aim. `IsLocated` does not exist at b836af48 (layout-aim is unmapped).
|
||||
|
||||
IS7. BehaviorData union ends at `Union(49, LaunchSuppressorData)` (Behaviors/Behaviors.cs:193). Sensor-catalog's
|
||||
branch (eureka/aetheria-release-sensor-catalog-r2, head 068adf0d) takes 50 for ListenerData at the same place.
|
||||
ResourceScanner (Union 28, Behaviors/ResourceScanner.cs) is a parked mining behaviour with its own data keys; the
|
||||
new `ScannerData` is a separate type.
|
||||
|
||||
IS8. Paint readers: the incoming-lock indicator takes the strongest Track paint (Gameplay/ActionGameManager.cs:
|
||||
1478-1491), so a Scan paint never shows as a lock; the combat flag is `VisibleEnemies.Count > 0 ||
|
||||
IncomingPaints.Count > 0` (1270), so a ship being scanned enters the combat state, as it does when pinged.
|
||||
|
||||
IS9. Negative-check baselines: `Emit(` in Assets/Scripts/ServerShared appears in Entity.cs, Sensor.cs and
|
||||
LockWeapon.cs (Editor/ShipModPreview.cs is a particle Emit); `ReceivePaint(` in Entity.cs, Sensor.cs and
|
||||
LockWeapon.cs; `RecordReveal(` and `EndReveals(` only in Entity.cs.
|
||||
|
||||
IS10. Test fixture: ContactRevealTests is a partial class (EmissionTests, ClaimTests are partials); its constructor
|
||||
writes the fixture catalog (37-110), `Tool(name, behavior)` (236-241) makes a Tool gear, and `Add(position, mounts,
|
||||
tools)` (250-271) places tools by TryFindSpace on the five-by-five "Rack" hull.
|
||||
|
||||
## Shared sites with sensor-catalog (branch head 068adf0d)
|
||||
|
||||
Read as `git diff b836af48...068adf0d` (merge-base e99cfbed); line numbers below are b836af48's.
|
||||
|
||||
- Behaviors/Behaviors.cs union list: both insert after `Union(49, ...)` (193). Sensor-catalog takes 50; this cut
|
||||
takes 51 whichever merges first. A textual conflict only: keep both lines.
|
||||
- tests/Aetheria.Shared.Tests/ContactRevealTests.cs constructor: sensor-catalog inserts 18 lines after the Roar
|
||||
upsert (61) and edits `Make` (243-246). This cut inserts its scanner designs after `Locker("Hushed")` (98), a
|
||||
different hunk.
|
||||
- Entity.cs: sensor-catalog rewrites HearingMultiple (716-718 at b836af48), which this cut does not edit; every hunk of this cut
|
||||
in Entity.cs (SetSignature is untouched; RecordReveal 937-950) lies below it and shifts by +15 if sensor-catalog
|
||||
merges first. Semantics shared: a third party hears the scanner at HearRange times its HearingMultiple, which a
|
||||
listener raises above 1. This cut's hearing test uses a sensor-only observer, so it holds under either order.
|
||||
- No other shared file (sensor-catalog's Listener.cs, AetherDb, CatalogRoleTests, ListenerTests, EvasionTermTests
|
||||
and the catalog blob are untouched here).
|
||||
|
||||
Order: either; neither waits on the other. Running beside each other costs the two one-line merges above.
|
||||
|
||||
## Rationale
|
||||
|
||||
- A scan records the claim, not the truth. Every act stamps the class its ship claims (IS3), and the aetheria-ew
|
||||
target's one-judge invariant puts every see-through in one function (illumination-burns-through names paints
|
||||
among what burns through). A scan that recorded `item.Data` would be a second see-through path outside the judge,
|
||||
and would read the true item's data to classify (classify-from-belief). RecordInspection therefore records
|
||||
`subject.ClaimOf(item)`. While no production code writes a claim (IS3) this equals the truth, so ruling
|
||||
quiet-gear-identifiable-hull-layout-known is met today; whether a Scan paint burns through a lie is cut
|
||||
ew-burn-through's, which reads paints already.
|
||||
- Aim under a hull lie stays ew-masquerade's. Ruling ew-aim-under-hull-lie-ruled closes gear aim while a hull lie is
|
||||
believed. That gate will sit on the aim read (IsRevealed), which governs scan reveals and act reveals alike, so
|
||||
this cut adds nothing for it.
|
||||
- No hostility gate. LockWeapon requires `IsHostileTo` (LockWeapon.cs:98), which reads the true faction. A scanner
|
||||
inspects whatever its ship targets, and its gate reads only the track and range (ruling
|
||||
ew-hostility-from-belief-ruled moves allegiance to belief).
|
||||
- Decay in one place. r2 decayed in Execute, which freezes while the item is inactive (IS5), so a powered-down
|
||||
scanner held its progress: a broken beam that does not decay, against ruling scan-held-beam. r3 decays in the
|
||||
behaviour's IAlwaysUpdatedBehavior.Update on any tick Execute did not hold the scan, the one decay site for every
|
||||
way a scan breaks.
|
||||
- Channel stays `SignatureChannel?` (null = inspection), r2's design. A new SignatureChannel member would be a new
|
||||
channel, which the model page reserves for a ruling (row Signature channel), and nothing in production reads the
|
||||
channel (IS2).
|
||||
- The AI test is dropped. The Scanner reads only its ship's Target, so an AI ship scans through the same path by
|
||||
construction (ruling same-ship-same-inputs); a negative check that Scanner.cs reads no Agents or input type
|
||||
carries the claim instead of an agent fixture.
|
||||
- Size: 65/80 Hands calls, as r2; one pass.
|
||||
|
||||
## Cut order (amends 'Visibility refresh at efee2a2a')
|
||||
|
||||
emissions-heard, reveals-replace-tiers, contact-hud and ew-claims-in-the-book (all merged) -> inspection-scanner r3
|
||||
(runs now, beside sensor-catalog r2); inspection-scanner + sensor-catalog + bearing-markers -> scanner-catalog
|
||||
(unchanged line). bearing-markers and layout-aim are unchanged lines, mapped when they are about to run.
|
||||
|
||||
## Admitted (imagination-aeth-inspection-scanner, 2026-10-14)
|
||||
|
||||
- mind-commit-6e261b55...: cut-inspection-scanner.r3 (base b836af48), resolution cut_spec.cut-inspection-scanner.r2.n1
|
||||
(Superseded). context-pack on r3: all six anchors SAME. No question raised.
|
||||
|
||||
## Damage falloff at fire time (imagination-aeth-damage-falloff, 2026-10-14)
|
||||
|
||||
Operator ruling damage-curve-fate-ruled (make-falloff-real): "Simplify weapon range to minimum, effective and maximum, one lerp." The BezierCurve DamageCurve goes; hits, the AI and the panel read one function. Probes ran at origin/master b836af48 (worktree `C:\aeth-wt\map-damage-falloff`).
|
||||
|
||||
### Body facts
|
||||
|
||||
**DF1. The census at 1746e8bd still holds at b836af48.** `git log 1746e8bd..b836af48 -- GameData/Aetheria.cc` lists only launch-suppressor's two applies, which add gear, not weapons. Re-probed on Yggdrasil (scratch console over `AetheriaStores.Open`, job `imagination-aeth-damage-falloff/probe1.log`, 2026-10-14): 27 weapon designs carry a DamageCurve, 26 the copied default `(0,1,0,0) (1,0,-1.77,-1.77)`, Mine Launcher flat `(0,1) (1,1)`. By behaviour: Instant 2, Auto 13, Charged 5, Constant 1 (21 guns and beams, three of them the Smoke Refused rounds at Range 20); Guided 3 and Launcher 2 (5 missiles); MineLayer 1. No gear in the catalog carries a StatModifier on any Range stat.
|
||||
|
||||
**DF2. Range stats as authored.** MinRange is 0..0 on 25 weapons (terms `Heat:1`, inert at 0); LRMM72 500..500 and GT 3K 500..50 (follow-up gt3k-minrange-inverted). Range is quality-ranged on every weapon but the three Smoke Refused (20..20): for example Autocannon 800..1200 `[Heat:1, Quality:barrel:2]`, CShot RainbowLite 1000..3000 `[Heat:.5, Durability:.25, Quality:focusing array:2]`, Mine Launcher 1600..2400 `[Quality:dispenser:2]`. Each Range reads one declared role, so a stat with Range's terms copied reads the same role, and CB-R1 (`CatalogRoleTests.ShippedCatalogRolesAreLive`) holds.
|
||||
|
||||
**DF3. Where the curve is read at b836af48** (aetheria-ew ew-claims-in-the-book has merged, so the rated copies are live):
|
||||
- `WeaponData.DamageCurve` key 7 (`Weapon.cs:40-41`). The highest key in the WeaponData hierarchy is 34 (`LockWeapon.cs`); 35 and 36 are free.
|
||||
- Three shared formulas: `InstantWeaponData.RangeDamagePerSecond` (`InstantWeapon.cs:39-40`), `ConstantWeaponData` (`ConstantWeapon.cs:28-29`), `ChargedWeaponData` (`ChargedWeapon.cs:59-61`), each `curve.Evaluate(saturate(unlerp(minRange, range, at)))`. Each has a rated caller (`:42-43`, `:31-32`, `:63-65`) and a live caller (`:73-76`, `:57-60`, `:91-95`).
|
||||
- AI: `Combat.cs:48` (claimed design, rated), `:73` (own groups, live), `:157` (SampleDps, live).
|
||||
- Panel: `PropertiesPanel.cs:423-427` draws the curve through `CurveField.Show(string, BezierCurve, ...)` (`CurveField.cs:39-73`); that is CurveField's only caller, and its `showMax` path is unused.
|
||||
- Tools: AetherDb `smoke-rounds` copies it (`Program.cs:1741`), `mine-launcher` authors a flat one (`:1831`).
|
||||
- Tests: 30 fixture lines in 21 files set a curve, all flat but `ContactRevealTests.cs:170`, which sets `ClaimTests`' falling `Falloff()` (`ClaimTests.cs:22`) through `ContactRevealTests.Spanned` (`:165-175`); `FireControlTests.ClaimedDesign` takes a curve (`:289-299`) and `TheAIRanksClaimsAtTheTargetsDistance` passes a falling one (`:361-364`); `RunStartTests.EverySoldWeaponHasADamageCurve` (`:463-473`) requires one on every sold weapon.
|
||||
- Not readers: `BezierCurve` itself stays (SensorData.SensitivityCurve, `Sensor.cs`); the Unity weapon presenters read `Range` only.
|
||||
|
||||
**DF4. Who decides range today.** One gate, `FireControl.Designated` (`FireControl.cs:270-276`): planar range, inclusive `[MinRange, Range]`, read by PFire, Solve, the agents' trigger and Combat's group test (`Combat.cs:65`). `LockWeapon.CanFire` (`LockWeapon.cs:62`) keeps its own strict `(MinRange, Range)` test. The AI's distance is 3D (`Combat.cs:35`, `length(toTarget)`) while the gate is planar (FireControl R7). SampleDps (`Combat.cs:136-168`) samples only between the shortest and longest weapon **Range**, so a ship whose guns share one Range samples one point, its maximum: with falloff to zero there, that ship's optimum stays at its initial 0 and it closes to point blank.
|
||||
|
||||
**DF5. Where damage is decided at fire time.** `FireControl.Fire` freezes `Damage = damageOverride ?? weapon.Damage` into the PendingShot (`FireControl.cs:725`); a beam passes `Damage * interval` as the override (`ConstantWeapon.cs:188`), and a charged gun's Damage is already lerped by charge. Every resolution path reads the frozen `shot.Damage`. `Solve` already computes the distance the payload is delivered at: `BurstReach = length((burstPosition - origin).xz)` (`:654`), where `burstPosition` is the engaged target for a direct round, the armed burst point for a fused one (bomb fishing at Range included), and the origin (0) for an untargeted direct round. Its comments (`:587`, `:2040-2041`) say it is read for Burst only. Mines are laid by `Lay` (`:787`) with no range from the shooter.
|
||||
|
||||
**DF6. The AI's range bias.** `Settings.AgentRangeExponent` defaults to .25 (`Settings.cs:255`); SampleDps multiplies dps by `range^.25`. For a gun flat to E and ramping linearly to 0 at M, `d/dr ln(dps) = .25/r - 1/(M - r)` just past E is negative whenever E > M/5, so the optimum is E itself: the AI holds at its effective range.
|
||||
|
||||
**DF7. Prior art for the unruled numbers** (short search, 2026-10-14; community sources, not publisher documentation). MechWarrior Online: damage falls linearly from a weapon's optimal range to zero at its maximum, about 2x optimal for energy weapons and 3x for autocannons; LRMs instead ramp up below their minimum range ([MWO forum](https://mwomercs.com/forums/topic/155906-ac2-range-change-was-great-now-do-it-for-all-the-autocannons/), [MWO wiki, C-LRM 10](https://mwo.fandom.com/wiki/C-LRM_10)). Elite Dangerous: lasers fall off linearly from about 500 m to zero at their 3 km maximum; cannons and missiles do not fall off ([Steam discussion](https://steamcommunity.com/app/359320/discussions/0/2653115771069188807)). Shooters with a damage floor (Battlefield, Destiny) have no hard range gate to meet. Both games with a min/effective/max triple end at zero, and both exempt missiles.
|
||||
|
||||
**DF8. Range boosters.** A StatModifier targets one stat by reference (`StatModifier.cs:229`). The boost-gear-combat line's Range Extender (section "Catalog breadth", design tables) targets `WeaponData.Range`; after this cut it lengthens the ramp and leaves EffectiveRange. No shipped gear modifies a range today (DF1), so nothing changes now.
|
||||
|
||||
### The design
|
||||
|
||||
One function, `WeaponData.RangeFactor(min, effective, max, damageAtMax, at)`: 0 outside the gate's inclusive `[min, max]`; with `e = clamp(effective, min, max)`, 1 on `[min, e]`, then `lerp(1, damageAtMax, unlerp(e, max, at))` up to `max`; 1 everywhere inside the gate when `e >= max`. EffectiveRange is a PerformanceStat (key 35) defaulting to +infinity, as Tracking does (key 33), so an unauthored weapon is flat and every fixture keeps its damage. `DamageAtMaxRange` is a plain float (key 36, default 0): quality does not vary it, so it needs no role. Callers:
|
||||
- the hit: `Fire` multiplies the frozen Damage by the factor at `solution.BurstReach`;
|
||||
- the AI: the three DPS formulas take the factor in place of the curve (live through `Weapon.RangeFactor`, rated through `WeaponData.RatedRangeFactor` over each stat's Max); Combat reads planar range and samples from the shortest MinRange;
|
||||
- the panel: CurveField plots any `Func<float, float>`, and the panel passes the factor over `[min, max]`.
|
||||
|
||||
Missiles and mines get no EffectiveRange (flat): DF7's games exempt missiles, and a mine's damage happens where the mine is, not at a range from its layer.
|
||||
|
||||
### Model page rows
|
||||
|
||||
| Kind | Identity | Lifecycle | Authority |
|
||||
|---|---|---|---|
|
||||
| Weapon range shape (`WeaponData` MinRange key 5, Range key 6, EffectiveRange key 35, DamageAtMaxRange key 36; DamageCurve key 7 retired, never reused) | Fields of a catalog weapon design; ranges resolved per item through StatResolver. | Authored by AetherDb `range-falloff` (cut damage-falloff); an unauthored EffectiveRange means no falloff. | The catalog. One reader, `WeaponData.RangeFactor`: FireControl.Fire (the hit), the DPS formulas (Combat's choices) and PropertiesPanel (the chart). |
|
||||
|
||||
### Rationale
|
||||
|
||||
- BurstReach, not FireRange: FireRange is the target's distance or 0, so a fused round fished to Range would land at full damage. BurstReach is where the payload is delivered for every outcome, and Solve already computes it.
|
||||
- EffectiveRange is a stat, not a fraction of Range: the ruling names three authored ranges. A copied stat moves with quality, heat and wear as Range does (DF2); only a booster on Range alone moves one without the other (DF8).
|
||||
- +infinity as the unauthored value: it is Tracking's precedent, it keeps every fixture's damage, and "no falloff" becomes a value the function already handles rather than a flag.
|
||||
- Size: one Hands pass (about 110 calls, cap 150), with a declared stop point before the catalog apply.
|
||||
- The two numbers the operator has not ruled (the end multiplier and how effective ranges are authored) are authored data with defaults from DF7, so they do not block Hands; a different answer is a rerun of `range-falloff` with other arguments.
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ using static CultMath.math;
|
|||
// (to decide whether the pump can keep up this tick). Cut 7 asks for the brownout curve to live on exactly
|
||||
// the stats the behaviour actually curves (PumpedHeat), but F6 forbade a PowerSupply term on any
|
||||
// stat a request reads at all, on pain of the exact oscillation Soul measured against the shipped catalog's own
|
||||
// "OK Disperser" radiator (SOUL_RadiatorRequestDependsOnItsOwnGrantAndOscillates, docs/stats-and-power-cut.md).
|
||||
// "Heat Pump" radiator (SOUL_RadiatorRequestDependsOnItsOwnGrantAndOscillates, docs/stats-and-power-cut.md).
|
||||
// The six tests below that authored one were marked Skip rather than deleted or silently reworked to hide the
|
||||
// gap, naming the conflict as real, scoped work for a future pass rather than a fix a registry correction should
|
||||
// smuggle in.
|
||||
|
|
|
|||
|
|
@ -95,6 +95,106 @@ public sealed class CatalogRoleTests
|
|||
Assert.True(makerless.Length == 0, "products with no maker: " + string.Join(", ", makerless));
|
||||
}
|
||||
|
||||
// A design is named like a node on a tech tree and the brand lives in the product it sells (rulings
|
||||
// catalog-grows-generic-designs-branded-products, designs-are-tech-nodes): no design's product bears the design's name.
|
||||
[Fact]
|
||||
public void EveryProductCarriesABrand()
|
||||
{
|
||||
using var cache = RestoredHullsTests.OpenCatalog();
|
||||
var products = cache.GetAll<FactionProductData>().ToArray();
|
||||
var unbranded = cache.GetAll<EquippableItemData>().Where(design => design is not HullData)
|
||||
.Where(design => products.Any(p => p.Design.Key.Equals(cache.RefOf(design).Key) && p.Name == design.Name))
|
||||
.Select(design => design.Name).OrderBy(n => n, StringComparer.Ordinal).ToArray();
|
||||
Assert.True(unbranded.Length == 0, "designs sold under their own name: " + string.Join(", ", unbranded));
|
||||
}
|
||||
|
||||
// The Capacitor is the one Tool design with a role map by name; a key that falls out of step with the design's name leaves
|
||||
// roles-backfill finding no map for it.
|
||||
[Fact]
|
||||
public void TheCapacitorDesignCarriesItsRoleMap()
|
||||
{
|
||||
using var cache = RestoredHullsTests.OpenCatalog();
|
||||
var capacitor = cache.GetAll<EquippableItemData>().Single(design => design.Name == "Capacitor");
|
||||
Assert.True(Program.HasRoleMap(capacitor), "roles-backfill finds no role map for the Capacitor design");
|
||||
}
|
||||
|
||||
// A design is a tech node: its text may not name a product the catalog sells (the brand lives on the product).
|
||||
[Fact]
|
||||
public void NoDesignTextNamesAProduct()
|
||||
{
|
||||
using var cache = RestoredHullsTests.OpenCatalog();
|
||||
var productNames = cache.GetAll<FactionProductData>().Select(p => p.Name).Where(n => n.Length > 3).ToHashSet();
|
||||
var branded = cache.GetAll<EquippableItemData>().Where(design => design is not HullData && design.Description != null)
|
||||
.Where(design => productNames.Any(n => design.Description.Contains(n)))
|
||||
.Select(design => design.Name).OrderBy(n => n, StringComparer.Ordinal).ToArray();
|
||||
Assert.True(branded.Length == 0, "designs whose text names a product: " + string.Join(", ", branded));
|
||||
}
|
||||
|
||||
// Authoring notes are not player text, and every product of a design this cut renamed or branded speaks in its own
|
||||
// voice (Miss Terri's and the Pirates' records are other passes').
|
||||
[Fact]
|
||||
public void NoProductTextIsAnAuthoringNote()
|
||||
{
|
||||
using var cache = RestoredHullsTests.OpenCatalog();
|
||||
var products = cache.GetAll<FactionProductData>().ToArray();
|
||||
string[] notes = { Program.AuthoringNote.Trim(), "[TODO]", "subsidiary plight" };
|
||||
var noted = products.Where(p => p.Description != null && notes.Any(n => p.Description.Contains(n))).Select(p => p.Name).OrderBy(n => n, StringComparer.Ordinal).ToArray();
|
||||
Assert.True(noted.Length == 0, "products whose text is an authoring note: " + string.Join(", ", noted));
|
||||
|
||||
var touched = Program.Renames.Select(r => r.Generic).Concat(Program.Brands.Select(b => b.Design)).ToHashSet();
|
||||
var designs = cache.GetAll<EquippableItemData>().Where(d => touched.Contains(d.Name)).ToArray();
|
||||
Assert.Equal(touched.Count, designs.Length);
|
||||
var silent = products
|
||||
.Where(p => designs.Any(d => p.Design.Key.Equals(cache.RefOf(d).Key)))
|
||||
.Where(p => cache.Get(p.Manufacturer)?.ShortName is not ("Miss Terri's" or "Pirates"))
|
||||
.Where(p => string.IsNullOrWhiteSpace(p.Description))
|
||||
.Select(p => p.Name).OrderBy(n => n, StringComparer.Ordinal).ToArray();
|
||||
Assert.True(silent.Length == 0, "products with no text of their own: " + string.Join(", ", silent));
|
||||
}
|
||||
|
||||
// A rename changes Name and Description and nothing else: the design and its products keep their keys and makers, and the
|
||||
// flavour that moved lives on the product.
|
||||
[Fact]
|
||||
public void RenamedDesignsKeepTheirKeysAndProducts()
|
||||
{
|
||||
using var cache = RestoredHullsTests.OpenCatalog();
|
||||
var expected = new (string DesignKey, string Generic, (string Key, string Name, string Maker)[] Products)[]
|
||||
{
|
||||
("0271bb97-4ce8-4d64-97c3-8bfd3f76b2c6", "Light Machine Gun", new[] { ("7a1f63b0-68de-4976-a338-bc779db3386a", "ClearPath", "Lightsail") }),
|
||||
("3baa2c43-b389-4438-94cb-fbb04489cd77", "Heavy Reactor", new[] { ("1edd87f7-2592-4744-a9ba-618f403f91ce", "Manhattan", "Zhestokost") }),
|
||||
("49b4c15a-c10b-49c0-9dad-31dfb9b3a9b9", "Cargo Bay", new[] { ("4ecc97af-c1fa-4563-902e-72a094ad8322", "Store-All Plus", "Lightsail"), ("ed3c70eb23814d5181d99fa84f6194d4", null, "Pirates") }),
|
||||
("88e81a2b-45fd-49de-830f-c896adae8d5b", "Racing Drive", new[] { ("9ccc095374d64fde94dd8d04bdc97c2a", "Victoire", "Alakrita") }),
|
||||
("632420a6-4419-4647-a92b-5e22ea289025", "Lightning Projector", new[] { ("f0f8389f9dd64228b02a68392fcf4007", "DragOnBreath", "Lucent") }),
|
||||
};
|
||||
foreach (var (designKey, generic, sold) in expected)
|
||||
{
|
||||
var design = Assert.Single(cache.GetAll<EquippableItemData>(), d => cache.RefOf(d).Key.Value == designKey);
|
||||
Assert.Equal(generic, design.Name);
|
||||
Assert.Equal(Program.Renames.Single(r => r.Generic == generic).Functional, design.Description);
|
||||
var products = cache.GetAll<FactionProductData>().Where(p => p.Design.Key.Equals(cache.RefOf(design).Key)).ToArray();
|
||||
Assert.Equal(sold.Select(p => p.Key).OrderBy(k => k, StringComparer.Ordinal), products.Select(p => cache.RefOf(p).Key.Value).OrderBy(k => k, StringComparer.Ordinal));
|
||||
foreach (var (key, name, maker) in sold)
|
||||
{
|
||||
var product = products.Single(p => cache.RefOf(p).Key.Value == key);
|
||||
if (name != null) Assert.Equal(name, product.Name);
|
||||
Assert.Equal(maker, cache.Get(product.Manufacturer).ShortName);
|
||||
}
|
||||
}
|
||||
|
||||
// The text that moved: Victoire carries the racing drive's old line, DragOnBreath plight's old one.
|
||||
string TextOf(string productKey) => cache.GetAll<FactionProductData>().Single(p => cache.RefOf(p).Key.Value == productKey).Description;
|
||||
Assert.Equal("The most responsive thruster on the market, for the most irresponsible of racing pilots.", TextOf("9ccc095374d64fde94dd8d04bdc97c2a"));
|
||||
Assert.StartsWith("Chain lightning has your enemies chain smoking", TextOf("f0f8389f9dd64228b02a68392fcf4007"));
|
||||
|
||||
// The mine launcher: the design takes the functional line its product used to carry; the product is the brand.
|
||||
var mine = Assert.Single(cache.GetAll<EquippableItemData>(), d => cache.RefOf(d).Key.Value == "1b4a2bb358eb432eb1cfc0ccf3317303");
|
||||
Assert.Equal("Mine Launcher", mine.Name);
|
||||
Assert.Equal("Lays a drifting proximity mine that arms after two seconds.", mine.Description);
|
||||
var brand = Assert.Single(cache.GetAll<FactionProductData>(), p => p.Design.Key.Equals(cache.RefOf(mine).Key));
|
||||
Assert.Equal("parting gift", brand.Name);
|
||||
Assert.Equal("DME", cache.Get(brand.Manufacturer).ShortName);
|
||||
}
|
||||
|
||||
// A benefit rises with quality across 0.8x to 1.2x of its authored value (Max/Min 1.5), a cost falls across 1.2x to 0.8x
|
||||
// (Max/Min 2/3). The ratio and the role are pinned, not the value, so an operator retune of a design stays green.
|
||||
private static void AssertRange(EquippableItemData design, string field, bool cost, string role)
|
||||
|
|
@ -121,13 +221,13 @@ public sealed class CatalogRoleTests
|
|||
AssertRange(autocannon, "Range", false, "barrel");
|
||||
AssertRange(autocannon, "Penetration", false, "barrel");
|
||||
|
||||
var lrm = Design("LRMM72");
|
||||
var lrm = Design("Long-Range Missile Rack");
|
||||
Assert.Equal(new[] { "guidance system", "thruster", "warhead" }, Roles(lrm));
|
||||
AssertRange(lrm, "Damage", false, "warhead");
|
||||
AssertRange(lrm, "Cooldown", true, "guidance system");
|
||||
AssertRange(lrm, "LockAngle", false, "guidance system");
|
||||
|
||||
var srm = Design("SRMM72");
|
||||
var srm = Design("Short-Range Missile Rack");
|
||||
Assert.Equal(new[] { "guidance system", "thruster", "warhead" }, Roles(srm));
|
||||
AssertRange(srm, "Damage", false, "warhead");
|
||||
AssertRange(srm, "Cooldown", true, "guidance system");
|
||||
|
|
@ -152,12 +252,12 @@ public sealed class CatalogRoleTests
|
|||
AssertRange(Design("Small Drive"), "Thrust", false, "nozzle");
|
||||
|
||||
// Designs whose non-flat stats named no role are pointed at the role their kind's map gives them.
|
||||
AssertNamed(Design("DeathCluster"), "Count", "feed mechanism");
|
||||
AssertNamed(Design("Cluster Cannon"), "Count", "feed mechanism");
|
||||
AssertNamed(Design("Flak Gun"), "Count", "feed mechanism");
|
||||
AssertNamed(Design("GT 3K"), "MinRange", "guidance system");
|
||||
AssertNamed(Design("plight"), "DamageSpread", "focusing array");
|
||||
AssertNamed(Design("MoveOnPro"), "Modifier", "core");
|
||||
AssertNamed(Design("MoveOnPro Station Reactor"), "Modifier", "core");
|
||||
AssertNamed(Design("Guided Missile Launcher"), "MinRange", "guidance system");
|
||||
AssertNamed(Design("Lightning Projector"), "DamageSpread", "focusing array");
|
||||
AssertNamed(Design("Muon Fusion Reactor"), "Modifier", "core");
|
||||
AssertNamed(Design("Muon Fusion Station Reactor"), "Modifier", "core");
|
||||
|
||||
// Each seller's means come from its maker's profile; the Pirates are middling and inconsistent.
|
||||
var profiles = new Dictionary<string, (float Mean, float Dev)>
|
||||
|
|
@ -182,4 +282,92 @@ public sealed class CatalogRoleTests
|
|||
}
|
||||
Assert.Contains(cache.GetAll<FactionProductData>(), p => p.Design.Key.Equals(cache.RefOf(autocannon).Key) && cache.Get(p.Manufacturer).ShortName == "Pirates");
|
||||
}
|
||||
|
||||
// aetheria-release cut sensor-catalog (ruling sensor-stat-set): every sensor design's intercept factor varies with its
|
||||
// maker's emission-discipline quality, brand flavour is a product's quality (Lucent loud, Finch quiet), and the
|
||||
// Passive Array is a Tool listener with two products from makers other than Miss Terri's and the Pirates.
|
||||
[Fact]
|
||||
public void TheCatalogCarriesSensorStats()
|
||||
{
|
||||
using var cache = RestoredHullsTests.OpenCatalog();
|
||||
var products = cache.GetAll<FactionProductData>().ToArray();
|
||||
string MakerOf(FactionProductData p) => cache.Get(p.Manufacturer).ShortName;
|
||||
var sensors = cache.GetAll<EquippableItemData>().Where(d => d.Behaviors.OfType<SensorData>().Any()).ToArray();
|
||||
Assert.NotEmpty(sensors);
|
||||
foreach (var design in sensors)
|
||||
{
|
||||
var alpha = design.Behaviors.OfType<SensorData>().Single().InterceptFactor;
|
||||
Assert.NotNull(alpha);
|
||||
Assert.NotEqual(alpha.Min, alpha.Max);
|
||||
Assert.Equal(new[] { "emission-discipline" }, NamedQualityRoles(alpha));
|
||||
}
|
||||
|
||||
double[] Discipline(string maker) => products
|
||||
.Where(p => sensors.Any(s => cache.RefOf(s).Key.Equals(p.Design.Key)) && MakerOf(p) == maker)
|
||||
.Select(p => (double)p.Roles.Single(r => r.Role == "emission-discipline").Mean).ToArray();
|
||||
var lucent = Discipline("Lucent");
|
||||
var finch = Discipline("Finch");
|
||||
Assert.NotEmpty(lucent);
|
||||
Assert.NotEmpty(finch);
|
||||
Assert.True(lucent.Max() < finch.Min(), "a Lucent sensor must be louder than every Finch one");
|
||||
|
||||
var array = Assert.Single(cache.GetAll<EquippableItemData>(), d => d.Name == "Passive Array");
|
||||
Assert.Equal(HardpointType.Tool, array.HardpointType);
|
||||
Assert.True(array.Behaviors.OfType<ListenerData>().Single().Multiple.Min >= 2f);
|
||||
var makers = products.Where(p => p.Design.Key.Equals(cache.RefOf(array).Key)).Select(MakerOf).ToArray();
|
||||
Assert.Equal(2, makers.Distinct().Count());
|
||||
Assert.DoesNotContain(makers, m => m == "Pirates" || m == "Miss Terri's");
|
||||
}
|
||||
|
||||
// The intercept factor alpha is quality-derived (ruling sensor-stat-set): evaluated by the stat's own Evaluate over a
|
||||
// lot that fills only emission-discipline, so a design that read the lot's workmanship instead would read the decoy.
|
||||
private sealed class DisciplineContext : IStatContext
|
||||
{
|
||||
public DisciplineContext(float discipline) =>
|
||||
Lot = new Lot { Quality = .123f, Roles = new List<RoleFill> { new RoleFill { Role = "emission-discipline", Quality = discipline } } };
|
||||
public Lot Lot { get; }
|
||||
public float HeatFactor(float exponent) => 1f;
|
||||
public float DurabilityFactor(float exponent) => 1f;
|
||||
public float ConsumableProgressFactor(float exponent) => 1f;
|
||||
public float PowerSupplyFactor(float exponent) => 1f;
|
||||
public float ScaleModifier(PerformanceStat stat) => 1f;
|
||||
public float ConstantModifier(PerformanceStat stat) => 0f;
|
||||
}
|
||||
|
||||
// A sensor of middling discipline reads exactly 1 (it is heard where it sees), the worst discipline reads the loud end
|
||||
// .5 and the best the quiet end 2, and the exponent is the one that puts the midpoint on 1: lerp(.5, 2, .5^e) = 1.
|
||||
// Each product then reads alpha at its own authored discipline: Lucent below 1 (loud), Finch and Sol above (quiet),
|
||||
// every other maker at 1. The expectations come from that formula, not from numbers copied out of the catalog.
|
||||
[Fact]
|
||||
public void ASensorsInterceptFactorIsDerivedFromItsEmissionDiscipline()
|
||||
{
|
||||
using var cache = RestoredHullsTests.OpenCatalog();
|
||||
var sensors = cache.GetAll<EquippableItemData>().Where(d => d.Behaviors.OfType<SensorData>().Any()).ToArray();
|
||||
Assert.NotEmpty(sensors);
|
||||
float Alpha(EquippableItemData design, float discipline) =>
|
||||
design.Behaviors.OfType<SensorData>().Single().InterceptFactor.Evaluate(new DisciplineContext(discipline));
|
||||
foreach (var design in sensors)
|
||||
{
|
||||
Assert.Equal(1f, Alpha(design, .5f), 4);
|
||||
Assert.Equal(.5f, Alpha(design, 0f), 4);
|
||||
Assert.Equal(2f, Alpha(design, 1f), 4);
|
||||
var term = Assert.Single(design.Behaviors.OfType<SensorData>().Single().InterceptFactor.Terms);
|
||||
Assert.Equal(MathF.Log(3f) / MathF.Log(2f), term.Exponent, 4); // (2 - .5) / (1 - .5) = 3 = 2^e
|
||||
}
|
||||
|
||||
var products = cache.GetAll<FactionProductData>()
|
||||
.Where(p => sensors.Any(s => cache.RefOf(s).Key.Equals(p.Design.Key))).ToArray();
|
||||
Assert.NotEmpty(products);
|
||||
foreach (var product in products)
|
||||
{
|
||||
var design = sensors.Single(s => cache.RefOf(s).Key.Equals(product.Design.Key));
|
||||
var maker = cache.Get(product.Manufacturer).ShortName;
|
||||
var alpha = Alpha(design, product.Roles.Single(r => r.Role == "emission-discipline").Mean);
|
||||
if (maker == "Lucent") Assert.True(alpha < .8f, $"{product.Name}: a Lucent sensor must be loud, reads {alpha}");
|
||||
else if (maker == "Finch" || maker == "Sol") Assert.True(alpha > 1.25f, $"{product.Name}: a {maker} sensor must be quiet, reads {alpha}");
|
||||
else Assert.Equal(1f, alpha, 3);
|
||||
}
|
||||
Assert.Contains(products, p => cache.Get(p.Manufacturer).ShortName == "Lucent");
|
||||
Assert.Contains(products, p => cache.Get(p.Manufacturer).ShortName == "Finch");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,6 +59,24 @@ public sealed partial class ContactRevealTests : IDisposable
|
|||
// PingRange (300) over the intercept factor.
|
||||
cache.Upsert(Eye("Shout", sensitivity: 2f, interceptFactor: 2f, beamWidth: 10f));
|
||||
cache.Upsert(Eye("Roar", sensitivity: 2f, interceptFactor: .5f, beamWidth: 10f));
|
||||
// The catalog's sensor alpha (AetherDb sensor-stat-set): .5 to 2 over one Quality term on the equipped lot's
|
||||
// emission-discipline role, exponent log2(3) so a middling part (.5) reads 1.
|
||||
var disciplined = Eye("Disciplined", sensitivity: 2f);
|
||||
disciplined.Roles.Add(new ItemRole { Name = "emission-discipline" });
|
||||
disciplined.Behaviors.OfType<SensorData>().Single().InterceptFactor = new PerformanceStat
|
||||
{
|
||||
Min = .5f, Max = 2f,
|
||||
Terms = { new StatTerm { Source = StatSource.Quality, Exponent = MathF.Log(3f) / MathF.Log(2f), Role = "emission-discipline" } }
|
||||
};
|
||||
cache.Upsert(disciplined);
|
||||
cache.Upsert(Listener("Listener", 3f));
|
||||
cache.Upsert(new ConsumableItemData { Name = "Earpiece", Duration = 30f, Shape = new Shape(), Behaviors = { new ListenerData { Multiple = Const(3f) } } });
|
||||
cache.Upsert(Listener("Wide", 5f));
|
||||
cache.Upsert(Listener("Narrow", 1.5f));
|
||||
cache.Upsert(Listener("Hush", .5f));
|
||||
cache.Upsert(new ConsumableItemData { Name = "HushEarpiece", Duration = 30f, Shape = new Shape(), Behaviors = { new ListenerData { Multiple = Const(.5f) } } });
|
||||
cache.Upsert(new ConsumableItemData { Name = "WideEarpiece", Duration = 30f, Shape = new Shape(), Behaviors = { new ListenerData { Multiple = Const(5f) } } });
|
||||
cache.Upsert(new ConsumableItemData { Name = "NarrowEarpiece", Duration = 30f, Shape = new Shape(), Behaviors = { new ListenerData { Multiple = Const(1.5f) } } });
|
||||
cache.Upsert(Tool("Reactor", new ReactorData { Charge = Const(1000), Efficiency = Const(1), OverloadEfficiency = Const(1), ThrottlingFactor = Const(2) }));
|
||||
cache.Upsert(Tool("Targeting", new TargetingSystemData { Accuracy = Const(1), Resolution = Const(1000f), Precision = Const(1000f), Tracking = Const(1000000f) }));
|
||||
cache.Upsert(Tool("Thruster", new ThrusterData { Thrust = Const(100), Visibility = Const(10), Heat = Const(0), EnergyUsage = Const(10) }));
|
||||
|
|
@ -99,6 +117,14 @@ public sealed partial class ContactRevealTests : IDisposable
|
|||
cache.Upsert(SpannedWeapon("SpanBeam", Spanned(new ConstantWeaponData())));
|
||||
cache.Upsert(Locker("Locker", interceptFactor: null));
|
||||
cache.Upsert(Locker("Hushed", interceptFactor: 4f));
|
||||
// Scanners (cut inspection-scanner): range 200 and a two second scan; "QuietScanner" is heard at a quarter of it.
|
||||
cache.Upsert(Tool("Scanner", ScannerBehavior(range: 200f, scanTime: 2f)));
|
||||
cache.Upsert(Tool("QuietScanner", ScannerBehavior(range: 200f, scanTime: 2f, interceptFactor: 4f)));
|
||||
cache.Upsert(new ConsumableItemData
|
||||
{
|
||||
Name = "ScannerCharge", Duration = 30f, Shape = new Shape(),
|
||||
Behaviors = { ScannerBehavior(range: 200f, scanTime: 2f) }
|
||||
});
|
||||
cache.Upsert(new ConsumableItemData
|
||||
{
|
||||
Name = "Pinger", Duration = 30f, Shape = new Shape(),
|
||||
|
|
@ -241,9 +267,13 @@ public sealed partial class ContactRevealTests : IDisposable
|
|||
|
||||
private EquippableItem Make(string name) => new EquippableItem
|
||||
{
|
||||
Data = _items.ItemData.RefOf<ItemData>(_items.ItemData.GetByName<ItemData>(name)), Durability = 10, Lot = _nextLot++
|
||||
Data = _items.ItemData.RefOf<ItemData>(_items.ItemData.GetByName<ItemData>(name)), Durability = 10,
|
||||
Lot = _preparedLots.Remove(name, out var prepared) ? prepared : _nextLot++
|
||||
};
|
||||
|
||||
// Lots a test built through the ItemManager for the next mount of that name, ahead of Add (a ship takes no gear once deployed).
|
||||
private readonly Dictionary<string, int> _preparedLots = new Dictionary<string, int>();
|
||||
|
||||
// A ship at `position` with `mounts` on its sensor hardpoints in order, the tools on free cells and a thruster
|
||||
// on the centre column. A ship with a gun also gets the reactor and targeting a gun needs to fire.
|
||||
private Ship Add(float3 position, string[] mounts = null, string[] tools = null, bool thruster = false)
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ using float3 = CultMath.float3;
|
|||
// staging what its brief claims fails here.
|
||||
public sealed partial class RunStartTests
|
||||
{
|
||||
// Crossing: the demo's cast; plight and FastBlast+- fitted in separate weapon groups with the Fire Control Array
|
||||
// aboard; a piloted hostile Djinni that crosses the bow inside 400 m; and an unpiloted neutral one inside plight's
|
||||
// Crossing: the demo's cast; projector and Cell Blaster fitted in separate weapon groups with the Fire Control Array
|
||||
// aboard; a piloted hostile Djinni that crosses the bow inside 400 m; and an unpiloted neutral one inside the Lightning Projector's
|
||||
// arc, short of its Range and beyond three quarters of it.
|
||||
[Fact]
|
||||
public void CrossingConditions()
|
||||
|
|
@ -21,12 +21,12 @@ public sealed partial class RunStartTests
|
|||
Assert.Equal(4, galaxy.HomeZones.Count);
|
||||
|
||||
var player = staged.Player;
|
||||
var plight = player.Equipment.Single(item => item.Data.Name == "plight");
|
||||
var small = player.Equipment.Single(item => item.Data.Name == "FastBlast+-");
|
||||
var projector = player.Equipment.Single(item => item.Data.Name == "Lightning Projector");
|
||||
var small = player.Equipment.Single(item => item.Data.Name == "Cell Blaster");
|
||||
Assert.Contains(player.Equipment, item => item.Data.Name == "Fire Control Array");
|
||||
var groupOf = new System.Func<EquippedItem, int>(item => System.Array.FindIndex(player.WeaponGroups, group => group.items.Contains(item)));
|
||||
Assert.True(groupOf(plight) >= 0 && groupOf(small) >= 0, "both guns are in a weapon group");
|
||||
Assert.NotEqual(groupOf(plight), groupOf(small));
|
||||
Assert.True(groupOf(projector) >= 0 && groupOf(small) >= 0, "both guns are in a weapon group");
|
||||
Assert.NotEqual(groupOf(projector), groupOf(small));
|
||||
|
||||
Assert.Equal(2, staged.Entities.Count);
|
||||
var crosser = staged.Entities[0];
|
||||
|
|
@ -54,10 +54,10 @@ public sealed partial class RunStartTests
|
|||
Assert.Equal(0, AgentsOf(arena, waiting));
|
||||
var toWaiting = waiting.Position - player.Position;
|
||||
EvSettle(player); // a weapon's Range is read once the ship's stats have settled; the geometry above is as staged
|
||||
var range = plight.Behaviors.OfType<Weapon>().Single().Range;
|
||||
Assert.True(FireControl.InArc(plight, toWaiting), "the waiting Djinni is inside plight's arc");
|
||||
Assert.True(length(toWaiting) <= range, "the waiting Djinni is inside plight's Range");
|
||||
Assert.True(length(toWaiting) > .75f * range, "the waiting Djinni is beyond three quarters of plight's Range");
|
||||
var range = projector.Behaviors.OfType<Weapon>().Single().Range;
|
||||
Assert.True(FireControl.InArc(projector, toWaiting), "the waiting Djinni is inside the Lightning Projector's arc");
|
||||
Assert.True(length(toWaiting) <= range, "the waiting Djinni is inside the Lightning Projector's Range");
|
||||
Assert.True(length(toWaiting) > .75f * range, "the waiting Djinni is beyond three quarters of the Lightning Projector's Range");
|
||||
|
||||
// The crossing is what the sim does with that staging, read in the player's frame: the arena's gravity and the
|
||||
// crosser's pilot act from the first tick, so the t=0 facing proves nothing. Within CrossingSeconds the crosser's
|
||||
|
|
@ -79,8 +79,8 @@ public sealed partial class RunStartTests
|
|||
crossedMetres = length(after);
|
||||
Assert.True(after.z > 0, "the crosser passes the bow line ahead of the player, not astern");
|
||||
Assert.True(length(after) < CrossingMetres, "the crosser passes inside the stated distance");
|
||||
Assert.True(FireControl.InArc(small, after), "FastBlast+- bears on the crosser as it crosses");
|
||||
Assert.True(dot(FireControl.MountDirection(small), float3(player.Direction.x, 0, player.Direction.y)) > 0, "FastBlast+- mounts forward");
|
||||
Assert.True(FireControl.InArc(small, after), "Cell Blaster bears on the crosser as it crosses");
|
||||
Assert.True(dot(FireControl.MountDirection(small), float3(player.Direction.x, 0, player.Direction.y)) > 0, "Cell Blaster mounts forward");
|
||||
}
|
||||
}
|
||||
Assert.True(swept, $"the crosser's bearing never swept across the bow within {CrossingSeconds} s");
|
||||
|
|
|
|||
|
|
@ -314,4 +314,22 @@ public sealed partial class ContactRevealTests
|
|||
Assert.Equal(1f, locker.Equipment.SelectMany(i => i.Behaviors).OfType<LockWeapon>().Single().InterceptFactor);
|
||||
Assert.Equal(4f, hushed.Equipment.SelectMany(i => i.Behaviors).OfType<LockWeapon>().Single().InterceptFactor);
|
||||
}
|
||||
|
||||
// A catalog-style sensor reads its intercept factor through the lot the ship equips it from: the lot's
|
||||
// emission-discipline fill is the input (the workmanship is a decoy at .123), so a Sensor that read only the quiet or only
|
||||
// the loud end, or the workmanship, reads the wrong number. The expectations are lerp(.5, 2, q^log2(3)): a middling part
|
||||
// reads 1, the Lucent mean (.2) reads about .62 and the Finch mean (.8) about 1.55.
|
||||
[Theory]
|
||||
[InlineData(.5f, 1f)]
|
||||
[InlineData(.2f, .6168f)]
|
||||
[InlineData(.8f, 1.5534f)]
|
||||
public void ASensorReadsItsInterceptFactorFromItsLotsEmissionDiscipline(float discipline, float expected)
|
||||
{
|
||||
var lot = _items.CreateLot(_openCache.GetByName<EquippableItemData>("Disciplined"), _maker, .123f);
|
||||
_items.Lots[lot].Roles = new List<RoleFill> { new RoleFill { Role = "emission-discipline", Quality = discipline } };
|
||||
_preparedLots["Disciplined"] = lot;
|
||||
var ship = Add(float3(0, 0, 0), new[] { "Disciplined" });
|
||||
|
||||
Assert.Equal(expected, SensorOf(ship).InterceptFactor, 3);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,16 +22,24 @@ public sealed partial class RunStartTests
|
|||
{
|
||||
private const float EvDt = 1f / 60f;
|
||||
|
||||
// The Duel's guns on a Longinus: the generated Longinus's thrusters (two Large Drive forward, two Talaria on the
|
||||
// flanks) and power, its Targeting Computer, and the Duel's cockpit, guns, launchers and sensor.
|
||||
private static ScenarioFit EvLonginus(ScenarioStage stage, string gun = "FastBlast+-", string second = null) => stage.Fit("Longinus",
|
||||
("Cockpit 2x2", int2(2, 6), ItemRotation.None), ("Core Power", int2(2, 4), ItemRotation.None),
|
||||
// The Longinus's drive train, fitted by name: its cockpit and power and the generated Longinus's thrusters (two Large Drive
|
||||
// forward, two Rugged Drive on the flanks).
|
||||
private static readonly (string design, int2 cell, ItemRotation rotation)[] EvLonginusDrive =
|
||||
{
|
||||
("Cockpit 2x2", int2(2, 6), ItemRotation.None), ("Compact Reactor", int2(2, 4), ItemRotation.None),
|
||||
("Large Drive", int2(1, 0), ItemRotation.Reversed), ("Large Drive", int2(3, 0), ItemRotation.Reversed),
|
||||
("Talaria", int2(2, 14), ItemRotation.CounterClockwise), ("Talaria", int2(3, 14), ItemRotation.Clockwise),
|
||||
("GT 3K", int2(0, 5), ItemRotation.None), ("GT 3K", int2(5, 5), ItemRotation.None), (gun, int2(1, 8), ItemRotation.None),
|
||||
(second ?? gun, int2(4, 8), ItemRotation.None), ("Iapyx", int2(2, 2), ItemRotation.CounterClockwise), ("Iapyx", int2(3, 2), ItemRotation.Clockwise),
|
||||
("not if i see you first", int2(3, 10), ItemRotation.None), ("PotaT+-", int2(1, 6), ItemRotation.None),
|
||||
("Targeting Computer", int2(1, 7), ItemRotation.None), ("Store-All Plus", int2(2, 8), ItemRotation.None));
|
||||
("Rugged Drive", int2(2, 14), ItemRotation.CounterClockwise), ("Rugged Drive", int2(3, 14), ItemRotation.Clockwise),
|
||||
};
|
||||
|
||||
// The Duel's guns on a Longinus: the drive train above, its Targeting Computer, and the Duel's guns, launchers and sensor.
|
||||
private static ScenarioFit EvLonginus(ScenarioStage stage, string gun = "Cell Blaster", string second = null) => stage.Fit("Longinus",
|
||||
EvLonginusDrive.Concat(new (string design, int2 cell, ItemRotation rotation)[]
|
||||
{
|
||||
("Guided Missile Launcher", int2(0, 5), ItemRotation.None), ("Guided Missile Launcher", int2(5, 5), ItemRotation.None), (gun, int2(1, 8), ItemRotation.None),
|
||||
(second ?? gun, int2(4, 8), ItemRotation.None), ("Radiator", int2(2, 2), ItemRotation.CounterClockwise), ("Radiator", int2(3, 2), ItemRotation.Clockwise),
|
||||
("Compact Sensor", int2(3, 10), ItemRotation.None), ("Capacitor", int2(1, 6), ItemRotation.None),
|
||||
("Targeting Computer", int2(1, 7), ItemRotation.None), ("Cargo Bay", int2(2, 8), ItemRotation.None)
|
||||
}).ToArray());
|
||||
|
||||
// The catalog's two generated ships, far apart in the fixture arena, at the fixture seed.
|
||||
private (Zone arena, Ship longinus, Ship djinni) EvFleet()
|
||||
|
|
@ -52,6 +60,25 @@ public sealed partial class RunStartTests
|
|||
return (arena, longinus, djinni);
|
||||
}
|
||||
|
||||
// The two ships the flight tests measure, fitted by name and far apart in the fixture arena: EvDjinni's eight Talaria
|
||||
// and the Longinus's drive train (EvLonginusDrive: two Large Drives and two Talaria). Neither follows the catalog's census: the generator
|
||||
// draws from the run's item stream, so a catalog cut would change which gear a generated hull carried (sensor-catalog h1).
|
||||
private (Zone arena, Ship longinus, Ship djinni) EvFitted()
|
||||
{
|
||||
Ship longinus = null, djinni = null;
|
||||
var scenario = new Scripted(false, stage =>
|
||||
{
|
||||
stage.Player(stage.Bare("Djinni"), float2(-50000, -50000));
|
||||
djinni = stage.Place(EvDjinni(stage), float2(-10000, -30000), facing: float2(0, 1)) as Ship;
|
||||
longinus = stage.Place(stage.Fit("Longinus", EvLonginusDrive), float2(-30000, -30000), facing: float2(0, 1)) as Ship;
|
||||
});
|
||||
var (_, arena, _, failures) = Launch(scenario, Inputs(() => GalaxySeed));
|
||||
Assert.True(failures.Count == 0, string.Join("; ", failures));
|
||||
Assert.NotNull(longinus);
|
||||
Assert.NotNull(djinni);
|
||||
return (arena, longinus, djinni);
|
||||
}
|
||||
|
||||
// Idle long enough for stats and power to reach their idle state, then at rest, facing +y,
|
||||
// and, after three seconds of coasting, with nothing observed: the track forgets on its own.
|
||||
private static void EvSettle(Ship ship)
|
||||
|
|
@ -269,10 +296,15 @@ public sealed partial class RunStartTests
|
|||
return (Half(float2(1, 0)), Half(float2(0, 1)));
|
||||
}
|
||||
|
||||
// Each factor is fitted to its own ship's fleet fit: reach over measured motion. Djinni: 1.69 nose-on and 1.31 broadside at
|
||||
// the last measurement, each with about 4% to spare. Longinus broadside: 1.23 (reach 12.74 over measured 10.40) with
|
||||
// about 3.5% to spare, so an inflation of its envelope of 4% or more breaks its half.
|
||||
private const float DjinniNoseOnFactor = 1.75f, DjinniBroadsideFactor = 1.36f, LonginusBroadsideFactor = 1.27f;
|
||||
|
||||
[Fact]
|
||||
public void ReachIsWhatTheShipCanDo()
|
||||
{
|
||||
var (_, longinus, djinni) = EvFleet();
|
||||
var (_, longinus, djinni) = EvFitted();
|
||||
const float window = .5f;
|
||||
var results = new List<(string name, (float noseOn, float broadside) reach, (float noseOn, float broadside) allocated, (float noseOn, float broadside) measured)>();
|
||||
foreach (var (name, ship) in new[] { ("longinus", longinus), ("djinni", djinni) })
|
||||
|
|
@ -288,10 +320,12 @@ public sealed partial class RunStartTests
|
|||
}
|
||||
// The envelope's reach is the capability and the measured motion is the best of fifteen fixed control policies, so
|
||||
// the reach covers it: no more than 10% below it.
|
||||
// The Djinni's measured motion sits further below its reach (+38% nose-on, +26% broadside at the last measurement):
|
||||
// its strafers are off-axis and the envelope, summed from what each thruster can push, does not model that. Its
|
||||
// allocator holds the whole box (its allocated reach is the envelope's), so the allocated reach says nothing more
|
||||
// about it. The bound still pins that the reach covers what the ship does.
|
||||
// The Djinni's measured motion sits further below its reach (reach 1.69 times the measured nose-on and 1.31 times the broadside at the last measurement): its strafers are off-axis and the
|
||||
// envelope, summed from what each thruster can push, does not model that. Its allocator holds the whole box (its
|
||||
// allocated reach is within 8% of the envelope's), so the allocated reach moves with the reach and bounds nothing.
|
||||
// The ceiling is therefore the measured motion, which no function of Reach produces, times the factor the fitted
|
||||
// Djinni shows with about 4% to spare (DjinniNoseOnFactor, DjinniBroadsideFactor): a reach scaled by 1.1 or more
|
||||
// breaks it, however the allocated reach moves.
|
||||
// The Longinus's allocator holds the heading and pays for the drive torque out of the flank thrusters (ruling
|
||||
// allocator-divergence-accepted), so the envelope's box support overstates what a controlled flight spends. Its
|
||||
// measured motion is bounded by the reach of the push the allocator itself gives it on each half-axis, from the
|
||||
|
|
@ -300,8 +334,8 @@ public sealed partial class RunStartTests
|
|||
{
|
||||
if (name == "djinni")
|
||||
{
|
||||
Assert.InRange(reach.noseOn, measured.noseOn * .9f, measured.noseOn * 1.6f);
|
||||
Assert.InRange(reach.broadside, measured.broadside * .9f, measured.broadside * 1.6f);
|
||||
Assert.InRange(reach.noseOn, measured.noseOn * .9f, measured.noseOn * DjinniNoseOnFactor);
|
||||
Assert.InRange(reach.broadside, measured.broadside * .9f, measured.broadside * DjinniBroadsideFactor);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -311,7 +345,7 @@ public sealed partial class RunStartTests
|
|||
// with other rolls). The ceiling is that, from the columns
|
||||
// the allocator solves with, not an open bound: an envelope inflated by a factor (doubled: 2.7 and 2.3) breaks it.
|
||||
Assert.InRange(reach.noseOn, measured.noseOn * .9f, allocated.noseOn * 1.5f);
|
||||
Assert.InRange(reach.broadside, measured.broadside * .9f, allocated.broadside * 1.2f);
|
||||
Assert.InRange(reach.broadside, measured.broadside * .9f, measured.broadside * LonginusBroadsideFactor);
|
||||
Assert.InRange(measured.noseOn, allocated.noseOn * .9f, allocated.noseOn * 1.15f);
|
||||
Assert.InRange(measured.broadside, allocated.broadside * .85f, allocated.broadside * 1.15f);
|
||||
}
|
||||
|
|
@ -349,7 +383,7 @@ public sealed partial class RunStartTests
|
|||
var settings = _items.GameplaySettings;
|
||||
var thrusters = longinus.GetBehaviors<Thruster>().Where(t => t.Item.Active.Value).ToList();
|
||||
var largeDrives = thrusters.Where(t => t.Item.Data.Name == "Large Drive").ToList();
|
||||
var flanks = thrusters.Where(t => t.Item.Data.Name == "Talaria").ToList();
|
||||
var flanks = thrusters.Where(t => t.Item.Data.Name == "Rugged Drive").ToList();
|
||||
Assert.Equal(2, largeDrives.Count);
|
||||
Assert.Equal(2, flanks.Count);
|
||||
|
||||
|
|
@ -362,7 +396,7 @@ public sealed partial class RunStartTests
|
|||
var forward = largeDrives.Sum(t => t.Thrust) / mass;
|
||||
Assert.InRange(envelope.Forward, forward * .99f, forward * 1.01f);
|
||||
Assert.Equal(0f, envelope.Reverse);
|
||||
// One Talaria pushes each way, and each has its own lot's thrust: the sides are the two flanks' accelerations.
|
||||
// One Rugged Drive pushes each way, and each has its own lot's thrust: the sides are the two flanks' accelerations.
|
||||
var flankAccelerations = flanks.Select(t => t.Thrust / mass).OrderBy(a => a).ToArray();
|
||||
var sides = new[] { envelope.Left, envelope.Right }.OrderBy(a => a).ToArray();
|
||||
Assert.InRange(sides[0], flankAccelerations[0] * .99f, flankAccelerations[0] * 1.01f);
|
||||
|
|
@ -580,17 +614,17 @@ public sealed partial class RunStartTests
|
|||
public Weapon Gun, Laser, GunnerLaser;
|
||||
}
|
||||
|
||||
// The target's fit, written out: the Djinni's own hardpoints filled with the Talaria it is generated with, its
|
||||
// The target's fit, written out: the Djinni's own hardpoints filled with the Rugged Drive it is generated with, its
|
||||
// reactor, cockpit and radiators. What the evasion tests price is this ship's strafing, not whatever the generator
|
||||
// rolls for it from the galaxy.
|
||||
private static ScenarioFit EvDjinni(ScenarioStage stage) => stage.Fit("Djinni",
|
||||
("Cockpit 2x2", int2(6, 3), ItemRotation.None), ("Core Power", int2(6, 11), ItemRotation.None),
|
||||
("Talaria", int2(6, 0), ItemRotation.Reversed), ("Talaria", int2(5, 1), ItemRotation.Reversed), ("Talaria", int2(7, 1), ItemRotation.Reversed),
|
||||
("Talaria", int2(4, 4), ItemRotation.CounterClockwise), ("Talaria", int2(4, 11), ItemRotation.CounterClockwise),
|
||||
("Talaria", int2(9, 4), ItemRotation.Clockwise), ("Talaria", int2(9, 11), ItemRotation.Clockwise),
|
||||
("Talaria", int2(6, 14), ItemRotation.None),
|
||||
("Iapyx", int2(1, 4), ItemRotation.Reversed), ("Iapyx", int2(3, 1), ItemRotation.Reversed),
|
||||
("Iapyx", int2(9, 1), ItemRotation.Reversed), ("Iapyx", int2(11, 4), ItemRotation.Reversed));
|
||||
("Cockpit 2x2", int2(6, 3), ItemRotation.None), ("Compact Reactor", int2(6, 11), ItemRotation.None),
|
||||
("Rugged Drive", int2(6, 0), ItemRotation.Reversed), ("Rugged Drive", int2(5, 1), ItemRotation.Reversed), ("Rugged Drive", int2(7, 1), ItemRotation.Reversed),
|
||||
("Rugged Drive", int2(4, 4), ItemRotation.CounterClockwise), ("Rugged Drive", int2(4, 11), ItemRotation.CounterClockwise),
|
||||
("Rugged Drive", int2(9, 4), ItemRotation.Clockwise), ("Rugged Drive", int2(9, 11), ItemRotation.Clockwise),
|
||||
("Rugged Drive", int2(6, 14), ItemRotation.None),
|
||||
("Radiator", int2(1, 4), ItemRotation.Reversed), ("Radiator", int2(3, 1), ItemRotation.Reversed),
|
||||
("Radiator", int2(9, 1), ItemRotation.Reversed), ("Radiator", int2(11, 4), ItemRotation.Reversed));
|
||||
|
||||
private EvRange EvRangeLaunch()
|
||||
{
|
||||
|
|
@ -598,9 +632,9 @@ public sealed partial class RunStartTests
|
|||
var scenario = new Scripted(false, stage =>
|
||||
{
|
||||
stage.Player(stage.Bare("Djinni"), float2(-50000, -50000));
|
||||
gunner = stage.Place(EvLonginus(stage, "FastBlast+-", "ColdFire"), float2(0, 0), facing: float2(0, 1)) as Ship;
|
||||
gunner = stage.Place(EvLonginus(stage, "Cell Blaster", "Long Laser"), float2(0, 0), facing: float2(0, 1)) as Ship;
|
||||
target = stage.Place(EvDjinni(stage), float2(0, 200), facing: float2(0, 1)) as Ship;
|
||||
lasing = stage.Place(EvLonginus(stage, "ColdFire"), float2(0, 400), facing: float2(0, -1)) as Ship;
|
||||
lasing = stage.Place(EvLonginus(stage, "Long Laser"), float2(0, 400), facing: float2(0, -1)) as Ship;
|
||||
});
|
||||
var (_, arena, _, failures) = Launch(scenario, Inputs(() => GalaxySeed));
|
||||
Assert.True(failures.Count == 0, string.Join("; ", failures));
|
||||
|
|
@ -787,7 +821,7 @@ public sealed partial class RunStartTests
|
|||
[Fact]
|
||||
public void TheThrustersReadLiveThrust()
|
||||
{
|
||||
var (_, _, djinni) = EvFleet();
|
||||
var (_, _, djinni) = EvFitted();
|
||||
EvSettle(djinni);
|
||||
djinni.Update(EvDt);
|
||||
var thrusters = djinni.GetBehaviors<Thruster>().ToList();
|
||||
|
|
|
|||
|
|
@ -367,8 +367,8 @@ public sealed partial class RunStartTests
|
|||
{
|
||||
("Point Defense Gun", 40f, 80000, 60f, WeaponModifiers.RapidFire, (1.5f, 4f), (1f, 1f), (300f, 550f), (.06f, .025f), (1f, .3f),
|
||||
(1100f, 1600f), (.4f, .2f), (40f, 15f), (400f, 150f), true, 250, 3f),
|
||||
("Point Defense Laser", 30f, 110000, 30f, PdDesign("Spectra").WeaponModifiers, (5f, 12f), (1f, 1f), (400f, 750f), (.2f, .1f), (.05f, 0f),
|
||||
(0f, 0f), (6f, 10f), (300f, 150f), (300f, 100f), false, PdDesign("Spectra").Behaviors.OfType<InstantWeaponData>().Single().MagazineSize, PdDesign("Spectra").Behaviors.OfType<InstantWeaponData>().Single().ReloadTime),
|
||||
("Point Defense Laser", 30f, 110000, 30f, PdDesign("Light Laser").WeaponModifiers, (5f, 12f), (1f, 1f), (400f, 750f), (.2f, .1f), (.05f, 0f),
|
||||
(0f, 0f), (6f, 10f), (300f, 150f), (300f, 100f), false, PdDesign("Light Laser").Behaviors.OfType<InstantWeaponData>().Single().MagazineSize, PdDesign("Light Laser").Behaviors.OfType<InstantWeaponData>().Single().ReloadTime),
|
||||
("Flak Gun", 120f, 180000, 80f, WeaponModifiers.Cluster, (30f, 70f), (6f, 8f), (350f, 800f), (.6f, .35f), (4f, 2f),
|
||||
(900f, 1300f), (1f, .5f), (300f, 150f), (800f, 300f), true, 40, 4f),
|
||||
};
|
||||
|
|
@ -449,20 +449,20 @@ public sealed partial class RunStartTests
|
|||
return FireControl.TrackingRate(range.Gun, range.Gunner);
|
||||
}
|
||||
var pd = FireControl.PMount(omega, RateOf("Point Defense Gun"));
|
||||
var clearPath = FireControl.PMount(omega, RateOf("ClearPath"));
|
||||
var clearPath = FireControl.PMount(omega, RateOf("Light Machine Gun"));
|
||||
Assert.True(pd >= .75f, $"the PD gun follows a speed demon: {pd}");
|
||||
Assert.True(clearPath <= .25f, $"the machine gun does not: {clearPath}");
|
||||
}
|
||||
|
||||
// Data check, not a behaviour test: ruling plight-shape, plight is one wide, two high and fits a Longinus Energy hardpoint.
|
||||
// Data check, not a behaviour test: ruling plight-shape, the Lightning Projector is one wide, two high and fits a Longinus Energy hardpoint.
|
||||
[Fact]
|
||||
public void PlightHasItsRuledShape()
|
||||
{
|
||||
var plight = _cache.GetAll<WeaponItemData>().Single(w => w.Name == "plight");
|
||||
Assert.Equal(1, plight.Shape.Width);
|
||||
Assert.Equal(2, plight.Shape.Height);
|
||||
Assert.True(plight.Shape.Cells[0, 0] && plight.Shape.Cells[0, 1], "both cells are occupied");
|
||||
var projector = _cache.GetAll<WeaponItemData>().Single(w => w.Name == "Lightning Projector");
|
||||
Assert.Equal(1, projector.Shape.Width);
|
||||
Assert.Equal(2, projector.Shape.Height);
|
||||
Assert.True(projector.Shape.Cells[0, 0] && projector.Shape.Cells[0, 1], "both cells are occupied");
|
||||
var longinus = _cache.GetAll<HullData>().Single(h => h.Name == "Longinus");
|
||||
Assert.Contains(longinus.Hardpoints, hardpoint => hardpoint.Type == HardpointType.Energy && hardpoint.Takes(plight));
|
||||
Assert.Contains(longinus.Hardpoints, hardpoint => hardpoint.Type == HardpointType.Energy && hardpoint.Takes(projector));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
319
tests/Aetheria.Shared.Tests/FlowFieldTests.cs
Normal file
319
tests/Aetheria.Shared.Tests/FlowFieldTests.cs
Normal file
|
|
@ -0,0 +1,319 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using CultMath;
|
||||
using GameCult.Caching;
|
||||
using Xunit;
|
||||
using static CultMath.math;
|
||||
using float2 = CultMath.float2;
|
||||
using float3 = CultMath.float3;
|
||||
|
||||
// The global flow as a world fact (campaign aetheria-fauna, cut fauna-flow-field; ruling sim-knows-the-flow; target
|
||||
// invariants flow-one-owner and flow-step-free). Every test reads Zone.Flow / Zone.FlowScroll, the path a fauna
|
||||
// class will read, from zones built the way the other ServerShared tests build them.
|
||||
public sealed class FlowFieldTests : IDisposable
|
||||
{
|
||||
private readonly string _root = Path.Combine(Path.GetTempPath(), "aetheria-flow-" + Guid.NewGuid().ToString("N"));
|
||||
private readonly CultCache _cache;
|
||||
private readonly ItemManager _items;
|
||||
|
||||
public FlowFieldTests()
|
||||
{
|
||||
Directory.CreateDirectory(_root);
|
||||
_cache = AetheriaStores.Open(Path.Combine(_root, "flow.cc"), catalogWritable: true);
|
||||
_cache.Upsert(new VerseGrammar { Revision = 1 });
|
||||
_cache.FlushAsync().Wait();
|
||||
var settings = new GameplaySettings
|
||||
{
|
||||
DefaultEntitySettings = new EntitySettings(),
|
||||
Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } },
|
||||
QualityPriceModifier = new ExponentialLerp(),
|
||||
TargetDetectionInfoThreshold = .1f, TargetGearInfoThreshold = .8f,
|
||||
FiringArc = 170, CommitHorizon = .5f, SchematicCellSize = 2f
|
||||
};
|
||||
_items = new ItemManager(_cache, new ProvenanceLedger(), settings, _ => { });
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_cache.Dispose();
|
||||
Directory.Delete(_root, true);
|
||||
}
|
||||
|
||||
private static FlowSettings Flow(float amplitude = 15f, float slide = 0f, float swirl = 0f) => new FlowSettings
|
||||
{
|
||||
GlobalScale = 512f, GlobalAmplitude = amplitude, GlobalScrollSpeed = .025f, Period = 8f,
|
||||
SlopeAmplitude = slide, SwirlAmplitude = swirl
|
||||
};
|
||||
|
||||
// A zone at `time` (the pack's clock, as a saved zone restores it), flat unless `depth` digs the zone's own well.
|
||||
private Zone ZoneWith(FlowSettings flow, double time = 0, float depth = 0f) => new Zone(_items,
|
||||
new PlanetSettings { Flow = flow, ZoneDepth = depth, ZoneDepthExponent = 2f },
|
||||
new ZonePack { Time = time }, new GalaxyZone { Name = "Flow Zone", Owner = null }, null);
|
||||
|
||||
private static readonly float3[] Probes =
|
||||
{
|
||||
new float3(0, 0, 0), new float3(37.5f, 12f, -80.25f), new float3(-410f, -30f, 125f),
|
||||
new float3(1234f, 50f, 987f), new float3(-2501f, 7f, -3333f), new float3(9000f, 90f, -4000f)
|
||||
};
|
||||
|
||||
private static void AssertClose(float3 expected, float3 actual, float tolerance = 1e-3f)
|
||||
{
|
||||
Assert.True(abs(expected.x - actual.x) <= tolerance && abs(expected.y - actual.y) <= tolerance &&
|
||||
abs(expected.z - actual.z) <= tolerance, $"expected {expected} but flow was {actual}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ScrollIsSpeedTimesZoneTime()
|
||||
{
|
||||
// The flow at zone time t is the flow at time 0 of a field moved along y by -scale * speed * t, so the
|
||||
// noise scrolls by speed x zone time and nothing else (an odd t keeps the shift off a whole field period).
|
||||
const double t = 7.0;
|
||||
var flow = Flow();
|
||||
var later = ZoneWith(flow, t);
|
||||
var start = ZoneWith(flow, 0);
|
||||
var shift = flow.GlobalScale * flow.GlobalScrollSpeed * (float) t;
|
||||
foreach (var p in Probes)
|
||||
AssertClose(start.Flow(new float3(p.x, p.y - shift, p.z)), later.Flow(p));
|
||||
Assert.Equal(flow.GlobalScrollSpeed * t, later.FlowScroll.x, 6);
|
||||
Assert.Equal(float2(0f, 0f), start.FlowScroll);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FlowDoesNotDependOnStepSize()
|
||||
{
|
||||
var fine = ZoneWith(Flow());
|
||||
var coarse = ZoneWith(Flow());
|
||||
for (var i = 0; i < 60; i++) fine.Update(1f / 60f);
|
||||
for (var i = 0; i < 7; i++) coarse.Update(1f / 7f);
|
||||
Assert.Equal(1.0, fine.Time, 4);
|
||||
Assert.Equal(1.0, coarse.Time, 4);
|
||||
foreach (var p in Probes) AssertClose(fine.Flow(p), coarse.Flow(p));
|
||||
Assert.Equal(fine.FlowScroll.x, coarse.FlowScroll.x, 5);
|
||||
Assert.Equal(fine.FlowScroll.y, coarse.FlowScroll.y, 5);
|
||||
// The flow moved: a scroll of 0.025 per second is a different field from the start, somewhere.
|
||||
var start = ZoneWith(Flow());
|
||||
Assert.Contains(Probes, p => length(start.Flow(p) - fine.Flow(p)) > .05f);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ZeroAmplitudesGiveZeroFlowAndNoNaN()
|
||||
{
|
||||
// All amplitudes zero (and a zero scale a bad config could carry): no term runs, so nothing divides by zero.
|
||||
var none = ZoneWith(new FlowSettings());
|
||||
foreach (var p in Probes) Assert.Equal(float3.zero, none.Flow(p));
|
||||
|
||||
// A zone built from default PlanetSettings has no flow, the baseline every other ServerShared test relies on.
|
||||
var defaults = new Zone(_items, new PlanetSettings(), new ZonePack(), new GalaxyZone { Name = "Default", Owner = null }, null);
|
||||
foreach (var p in Probes) Assert.Equal(float3.zero, defaults.Flow(p));
|
||||
|
||||
// A term with zero amplitudes is skipped outright: not even a gradient that cannot be normalised reaches it.
|
||||
var unusable = float2(float.PositiveInfinity, float.NaN);
|
||||
Assert.Equal(float3.zero, FlowField.Slope(new FlowSettings(), unusable));
|
||||
|
||||
// A flat zone has a zero gradient; swirl and slide are zero there, never NaN.
|
||||
var flat = ZoneWith(Flow(amplitude: 0f, slide: 1f, swirl: 1f));
|
||||
foreach (var p in Probes)
|
||||
{
|
||||
var f = flat.Flow(p);
|
||||
Assert.False(float.IsNaN(f.x) || float.IsNaN(f.y) || float.IsNaN(f.z), "zero gradient gave NaN");
|
||||
Assert.Equal(float3.zero, f);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SlopeTermSwirlsAndSlidesOnTheGradient()
|
||||
{
|
||||
// The zone's own well is deepest at the origin: downhill at p is toward it.
|
||||
var at = new float3(500f, 3f, 300f);
|
||||
var downhill = normalize(float2(-at.x, -at.z));
|
||||
|
||||
var slide = ZoneWith(Flow(amplitude: 0f, slide: 1.5f), depth: 64f).Flow(at);
|
||||
Assert.Equal(0f, slide.y, 4);
|
||||
Assert.Equal(1.5f * downhill.x, slide.x, 2);
|
||||
Assert.Equal(1.5f * downhill.y, slide.z, 2);
|
||||
|
||||
// Swirl is perpendicular to downhill, and has a handedness: (down.y, -down.x).
|
||||
var swirl = ZoneWith(Flow(amplitude: 0f, swirl: 2f), depth: 64f).Flow(at);
|
||||
Assert.Equal(0f, swirl.y, 4);
|
||||
Assert.Equal(2f * downhill.y, swirl.x, 2);
|
||||
Assert.Equal(-2f * downhill.x, swirl.z, 2);
|
||||
Assert.Equal(0f, dot(float2(swirl.x, swirl.z), downhill), 2);
|
||||
Assert.Equal(2f, length(float2(swirl.x, swirl.z)), 2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ZoneFlowReadsItsPlanetSettings()
|
||||
{
|
||||
var one = ZoneWith(Flow(amplitude: 15f), 3.0);
|
||||
var two = ZoneWith(Flow(amplitude: 30f), 3.0);
|
||||
foreach (var p in Probes) AssertClose(one.Flow(p) * 2f, two.Flow(p));
|
||||
// The flow is live (the origin is a legitimate zero of the field, so it is not every probe).
|
||||
Assert.Contains(Probes, p => length(one.Flow(p)) > 1f);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ZoneFlowIsTheLawAtTheScrollTheShaderGets()
|
||||
{
|
||||
// Zone.Flow and the lowered scroll are one zone-time value: the flow at p is the law evaluated at the zone's
|
||||
// own FlowScroll, after any run of steps (a flow that ran ahead of or behind the shader's scroll differs here).
|
||||
var zone = ZoneWith(Flow(), 3.25);
|
||||
for (var step = 0; step < 90; step++)
|
||||
{
|
||||
zone.Update(1f / 60f);
|
||||
foreach (var p in Probes) AssertClose(FlowField.Global(Flow(), p, zone.FlowScroll), zone.Flow(p), 1e-4f);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PausedSimFreezesTheFlowPhases()
|
||||
{
|
||||
// Presenters take their cycle phase from zone time: a zone that does not advance does not move them, and a
|
||||
// zone that does moves them by dt / period (mod 1).
|
||||
const float period = 8f;
|
||||
var zone = ZoneWith(Flow(), 5.0);
|
||||
var before = zone.CyclePhase(period);
|
||||
var scroll = zone.FlowScroll;
|
||||
zone.Update(0f);
|
||||
Assert.Equal(before, zone.CyclePhase(period));
|
||||
Assert.Equal(scroll, zone.FlowScroll);
|
||||
zone.Update(2f);
|
||||
Assert.Equal(frac(before + 2f / period), zone.CyclePhase(period), 5);
|
||||
Assert.InRange(zone.CyclePhase(period), 0f, .9999999f);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(1)]
|
||||
[InlineData(10)]
|
||||
public void ScrollKeepsAdvancingAtDaysOfZoneTime(int days)
|
||||
{
|
||||
// Zone time persists and only grows. A float of speed x time stops resolving a 1/60 s step after days; the
|
||||
// phases the shader gets stay in [0, 1) and advance by speed x dt on every step.
|
||||
const double dt = 1.0 / 60.0;
|
||||
var flow = Flow();
|
||||
var zone = ZoneWith(flow, days * 86400.0 + .1);
|
||||
var previous = zone.FlowScroll;
|
||||
for (var step = 0; step < 30; step++)
|
||||
{
|
||||
zone.Update((float) dt);
|
||||
var now = zone.FlowScroll;
|
||||
Assert.InRange(now.x, 0f, .9999999f);
|
||||
Assert.InRange(now.y, 0f, .9999999f);
|
||||
var dx = now.x - previous.x;
|
||||
var dy = now.y - previous.y;
|
||||
if (dx < -.5f) dx += 1f;
|
||||
if (dy < -.5f) dy += 1f;
|
||||
var expected = flow.GlobalScrollSpeed * dt;
|
||||
Assert.InRange((double) dx, expected - 5e-7, expected + 5e-7);
|
||||
Assert.InRange((double) dy, expected * 1.61803398875 - 5e-7, expected * 1.61803398875 + 5e-7);
|
||||
previous = now;
|
||||
}
|
||||
}
|
||||
|
||||
// The law as Volumetric.cginc spelled it before the per-octave fold: Tri3D(p) with p * Golden for the second
|
||||
// octave and p = pos / scale - (0, speed * t, 0), in double with the unfolded scroll. The oracle the fold must
|
||||
// agree with; it shares no code with FlowField.
|
||||
// The origin is a degenerate point of the field (a zero cross product), where no law can be compared.
|
||||
private static readonly float3[] OffOrigin = Probes[1..];
|
||||
|
||||
private static double OTri(double x) => Math.Abs(x - Math.Floor(x) - .5);
|
||||
private static double[] OTri3(double x, double y, double z) => new[] { OTri(z + OTri(y)), OTri(z + OTri(x)), OTri(y + OTri(x)) };
|
||||
|
||||
private static double[] ONormalize(double[] v)
|
||||
{
|
||||
var l = Math.Sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
|
||||
return new[] { v[0] / l, v[1] / l, v[2] / l };
|
||||
}
|
||||
|
||||
private static double[] UnfoldedLaw(FlowSettings f, float3 p, double t)
|
||||
{
|
||||
double g = 1.61803398875f;
|
||||
var s = (double) f.GlobalScrollSpeed * t;
|
||||
double x = p.x / (double) f.GlobalScale, y = p.y / (double) f.GlobalScale - s, z = p.z / (double) f.GlobalScale;
|
||||
var t1 = ONormalize(OTri3(x, y, z));
|
||||
var t2 = ONormalize(OTri3(x * g, y * g, z * g));
|
||||
var c = new[] { t1[1] * t2[2] - t1[2] * t2[1], t1[2] * t2[0] - t1[0] * t2[2], t1[0] * t2[1] - t1[1] * t2[0] };
|
||||
return new[] { c[0] * f.GlobalAmplitude, c[1] * f.GlobalAmplitude * .5, c[2] * f.GlobalAmplitude };
|
||||
}
|
||||
|
||||
private static double Distance(float3 a, double[] b) =>
|
||||
Math.Sqrt((a.x - b[0]) * (a.x - b[0]) + (a.y - b[1]) * (a.y - b[1]) + (a.z - b[2]) * (a.z - b[2]));
|
||||
|
||||
[Fact]
|
||||
public void FoldedScrollIsTheUnfoldedLawAtAnyAge()
|
||||
{
|
||||
// fold-law: the phase each octave gets is the unfolded speed x time (second octave: x Golden), folded once in
|
||||
// double. Computing the second from the folded first (frac(frac(s) x Golden)) agrees below 40 s and nowhere after.
|
||||
var f = Flow();
|
||||
foreach (var t in new[] { 0.0, 3.1, 39.99, 40.0, 40.01, 86400.0, 864000.0 + .3, 8640000.0 + .7 })
|
||||
foreach (var p in OffOrigin)
|
||||
Assert.True(Distance(FlowField.Global(f, p, FlowField.Scroll(f, t)), UnfoldedLaw(f, p, t)) / f.GlobalAmplitude < 5e-5,
|
||||
$"t={t} p={p}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NoJumpWhereAPhaseWraps()
|
||||
{
|
||||
// Each octave's phase wraps at its own times (the first every 40 s of zone time at speed .025): across a wrap
|
||||
// the flow moves by what the unfolded law moves, so nothing jumps.
|
||||
var f = Flow();
|
||||
double speed = f.GlobalScrollSpeed, golden = 1.61803398875f;
|
||||
const double h = 1.0 / 120.0;
|
||||
foreach (var (octave, cycles) in new[] { (0, 1.0), (0, 21600.0), (1, 1.0), (1, 34950.0) })
|
||||
{
|
||||
var t = octave == 0 ? cycles / speed : cycles / (speed * golden);
|
||||
var before = FlowField.Scroll(f, t - h);
|
||||
var after = FlowField.Scroll(f, t + h);
|
||||
Assert.True(octave == 0 ? before.x > .9f && after.x < .1f : before.y > .9f && after.y < .1f,
|
||||
$"octave {octave} cycles {cycles}: the probe times do not straddle a wrap");
|
||||
foreach (var p in OffOrigin)
|
||||
{
|
||||
var folded = FlowField.Global(f, p, after) - FlowField.Global(f, p, before);
|
||||
var a = UnfoldedLaw(f, p, t + h);
|
||||
var b = UnfoldedLaw(f, p, t - h);
|
||||
Assert.True(Distance(folded, new[] { a[0] - b[0], a[1] - b[1], a[2] - b[2] }) / f.GlobalAmplitude < 1e-4,
|
||||
$"octave {octave} cycles {cycles} p={p}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(10)]
|
||||
[InlineData(100)]
|
||||
public void CycleKeepsAdvancingAtDays(int days)
|
||||
{
|
||||
// The cycle phase takes zone time in double: a float zone time at 10 days (8.6e5 s) resolves 0.06 s and at
|
||||
// 100 days 1 s, so a 1/60 s step would not move the phase.
|
||||
foreach (var period in new[] { 8f, .25f })
|
||||
{
|
||||
const double dt = 1.0 / 60.0;
|
||||
var time = days * 86400.0 + .1;
|
||||
var previous = FlowField.Cycle(time, period);
|
||||
for (var step = 0; step < 30; step++)
|
||||
{
|
||||
time += dt;
|
||||
var now = FlowField.Cycle(time, period);
|
||||
var advance = now - previous;
|
||||
if (advance < -.5f) advance += 1f;
|
||||
Assert.InRange((double) advance, dt / period - 1e-5, dt / period + 1e-5);
|
||||
previous = now;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PhasesAreStrictlyBelowOne()
|
||||
{
|
||||
// A phase just below an integer rounds to 1f in a float cast; the contract is [0, 1), so it reads 0 instead
|
||||
// (1 is 0 modulo 1: the flow there is the flow at 0).
|
||||
var f = Flow();
|
||||
double speed = f.GlobalScrollSpeed, golden = 1.61803398875f;
|
||||
foreach (var gap in new[] { 1e-9, 1e-12 })
|
||||
{
|
||||
var first = FlowField.Scroll(f, (1.0 - gap) / speed);
|
||||
var second = FlowField.Scroll(f, (2.0 - gap) / (speed * golden));
|
||||
Assert.InRange(first.x, 0f, .9999999f);
|
||||
Assert.InRange(second.y, 0f, .9999999f);
|
||||
Assert.InRange(FlowField.Cycle(8.0 * (1.0 - gap), 8f), 0f, .9999999f);
|
||||
}
|
||||
}
|
||||
}
|
||||
240
tests/Aetheria.Shared.Tests/GenericDesignsCommandTests.cs
Normal file
240
tests/Aetheria.Shared.Tests/GenericDesignsCommandTests.cs
Normal file
|
|
@ -0,0 +1,240 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using GameCult.Caching;
|
||||
using GameCult.Caching.MessagePack;
|
||||
using Xunit;
|
||||
|
||||
// AetherDb's generic-designs command (aetheria-release, cut generic-design-names), run on a scratch copy of the shipped
|
||||
// catalog, which already carries the applied result: each case first puts a few records back to their old shape.
|
||||
public sealed class GenericDesignsCommandTests : IDisposable
|
||||
{
|
||||
private readonly string _root = Path.Combine(Path.GetTempPath(), "generic-designs-command-" + Guid.NewGuid().ToString("N"));
|
||||
private string CatalogPath => Path.Combine(_root, "GameData", "Aetheria.cc");
|
||||
|
||||
public GenericDesignsCommandTests()
|
||||
{
|
||||
Directory.CreateDirectory(Path.Combine(_root, "GameData"));
|
||||
Directory.CreateDirectory(Path.Combine(_root, "Assets", "Resources"));
|
||||
var shipped = AetherDb.FindRoot();
|
||||
File.Copy(Path.Combine(shipped, "GameData", "Aetheria.cc"), CatalogPath);
|
||||
File.Copy(Path.Combine(shipped, "Assets", "Resources", "Settings.asset"), Path.Combine(_root, "Assets", "Resources", "Settings.asset"));
|
||||
}
|
||||
|
||||
public void Dispose() => Directory.Delete(_root, true);
|
||||
|
||||
private void Edit(Action<AetherDb> edit)
|
||||
{
|
||||
var db = AetherDb.Open(catalogWritable: true, root: _root);
|
||||
try { edit(db); }
|
||||
finally { db.Cache.Dispose(); }
|
||||
}
|
||||
|
||||
private T Read<T>(Func<AetherDb, T> read)
|
||||
{
|
||||
var db = AetherDb.Open(root: _root);
|
||||
try { return read(db); }
|
||||
finally { db.Cache.Dispose(); }
|
||||
}
|
||||
|
||||
private static void Save(AetherDb db, EquippableItemData design) =>
|
||||
db.Cache.Commit(batch => batch.Upsert(design.GetType(), design, db.Cache.RefOf(design).Key));
|
||||
|
||||
private static void Save(AetherDb db, FactionProductData product) =>
|
||||
db.Cache.Commit(batch => batch.Upsert(typeof(FactionProductData), product, db.Cache.RefOf(product).Key));
|
||||
|
||||
private static EquippableItemData DesignNamed(AetherDb db, string name) =>
|
||||
db.Cache.GetAll<EquippableItemData>().Single(d => d.Name == name);
|
||||
|
||||
private static FactionProductData ProductNamed(AetherDb db, string name) =>
|
||||
db.Cache.GetAll<FactionProductData>().Single(p => p.Name == name);
|
||||
|
||||
[Fact]
|
||||
public void An_applied_catalog_is_left_alone_by_a_dry_run_and_by_apply()
|
||||
{
|
||||
var before = File.ReadAllBytes(CatalogPath);
|
||||
Assert.Equal(0, Program.GenericDesigns(apply: false, root: _root));
|
||||
Assert.Equal(before, File.ReadAllBytes(CatalogPath));
|
||||
Assert.Equal(0, Program.GenericDesigns(apply: true, root: _root));
|
||||
Assert.Equal(before, File.ReadAllBytes(CatalogPath));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_dry_run_writes_nothing_and_apply_restores_both_records()
|
||||
{
|
||||
var (designText, productText, brandedDesignText, rowText) = Read(db => (DesignNamed(db, "Light Machine Gun").Description,
|
||||
ProductNamed(db, "Hammerfall").Description, DesignNamed(db, "Autocannon").Description, ProductNamed(db, "Skiron").Description));
|
||||
Edit(db =>
|
||||
{
|
||||
var design = DesignNamed(db, "Light Machine Gun");
|
||||
design.Name = "ClearPath";
|
||||
design.Description = "Defend your precious cargo.";
|
||||
Save(db, design);
|
||||
var product = ProductNamed(db, "Hammerfall");
|
||||
product.Name = "Autocannon";
|
||||
product.Description = "";
|
||||
Save(db, product);
|
||||
var branded = DesignNamed(db, "Autocannon");
|
||||
branded.Description = "";
|
||||
Save(db, branded);
|
||||
var row = ProductNamed(db, "Skiron");
|
||||
row.Description = "";
|
||||
Save(db, row);
|
||||
});
|
||||
var reverted = File.ReadAllBytes(CatalogPath);
|
||||
|
||||
Assert.Equal(0, Program.GenericDesigns(apply: false, root: _root));
|
||||
Assert.Equal(reverted, File.ReadAllBytes(CatalogPath));
|
||||
|
||||
Assert.Equal(0, Program.GenericDesigns(apply: true, root: _root));
|
||||
Read(db =>
|
||||
{
|
||||
Assert.Equal(designText, DesignNamed(db, "Light Machine Gun").Description);
|
||||
Assert.DoesNotContain(db.Cache.GetAll<EquippableItemData>(), d => d.Name == "ClearPath");
|
||||
Assert.Equal(productText, ProductNamed(db, "Hammerfall").Description);
|
||||
Assert.Equal(brandedDesignText, DesignNamed(db, "Autocannon").Description);
|
||||
Assert.Equal(rowText, ProductNamed(db, "Skiron").Description);
|
||||
Assert.DoesNotContain(db.Cache.GetAll<FactionProductData>(), p => p.Name == "Autocannon" && db.Cache.Get(p.Manufacturer)?.ShortName == "Zhestokost");
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
// Re-spell every record's payload in a longer, equally valid MessagePack form (an array16 header for the fixarray one). The
|
||||
// catalog then holds bytes no re-encode through the current types would reproduce, so a write that re-encodes records it did
|
||||
// not author shows as changed bytes; a write that lands onto the file as it is leaves them alone.
|
||||
private int WidenEveryPayload()
|
||||
{
|
||||
var snapshot = CultDocumentMessagePackSerialization.DeserializeSnapshot(File.ReadAllBytes(CatalogPath));
|
||||
var widened = 0;
|
||||
foreach (var record in snapshot.Records)
|
||||
{
|
||||
var payload = record.Payload;
|
||||
if (payload.Length == 0 || (payload[0] & 0xF0) != 0x90) continue;
|
||||
record.Payload = new byte[] { 0xDC, 0x00, (byte)(payload[0] & 0x0F) }.Concat(payload.Skip(1)).ToArray();
|
||||
widened++;
|
||||
}
|
||||
File.WriteAllBytes(CatalogPath, CultDocumentMessagePackSerialization.SerializeSnapshot(snapshot));
|
||||
return widened;
|
||||
}
|
||||
|
||||
private Dictionary<string, CultPersistedRecord> Records() =>
|
||||
CultDocumentMessagePackSerialization.DeserializeSnapshot(File.ReadAllBytes(CatalogPath)).Records.ToDictionary(r => r.Key, StringComparer.Ordinal);
|
||||
|
||||
[Fact]
|
||||
public void Apply_writes_only_the_records_it_authors_and_restores_the_rewritten_design_texts()
|
||||
{
|
||||
var (largeDriveText, tractorText, smokeText, tractorProductText) = Read(db => (DesignNamed(db, "Large Drive").Description, DesignNamed(db, "Tractor Beam").Description,
|
||||
DesignNamed(db, "Smoke Proximity").Description, ProductNamed(db, "Space Tractor").Description));
|
||||
Edit(db =>
|
||||
{
|
||||
var drive = DesignNamed(db, "Large Drive");
|
||||
drive.Description = "Keeps you going and going and going...";
|
||||
Save(db, drive);
|
||||
var smoke = DesignNamed(db, "Smoke Proximity");
|
||||
smoke.Description = "A Spectra that bursts by proximity, blast 8. For scenarios; no one builds it.";
|
||||
Save(db, smoke);
|
||||
var tractor = ProductNamed(db, "Space Tractor");
|
||||
tractor.Description = "It's a tractor. In space.";
|
||||
Save(db, tractor);
|
||||
});
|
||||
Assert.True(WidenEveryPayload() > 100, "the scratch catalog should hold many records in the widened spelling");
|
||||
var before = Records();
|
||||
|
||||
Assert.Equal(0, Program.GenericDesigns(apply: true, root: _root));
|
||||
|
||||
var after = Records();
|
||||
Assert.Equal(before.Count, after.Count);
|
||||
var changed = before.Keys.Where(key => !before[key].Payload.AsSpan().SequenceEqual(after[key].Payload)).ToArray();
|
||||
Assert.Equal(3, changed.Length);
|
||||
foreach (var (key, record) in before.Where(pair => !changed.Contains(pair.Key)))
|
||||
Assert.True(record.Payload.AsSpan().SequenceEqual(after[key].Payload), "a record the command did not author has changed bytes");
|
||||
Read(db =>
|
||||
{
|
||||
Assert.Equal(largeDriveText, DesignNamed(db, "Large Drive").Description);
|
||||
Assert.Equal(tractorText, DesignNamed(db, "Tractor Beam").Description);
|
||||
Assert.Equal(smokeText, DesignNamed(db, "Smoke Proximity").Description);
|
||||
Assert.Equal(tractorProductText, ProductNamed(db, "Space Tractor").Description);
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_generic_name_held_by_another_design_is_refused_and_nothing_is_written()
|
||||
{
|
||||
Edit(db =>
|
||||
{
|
||||
var cargo = DesignNamed(db, "Cargo Bay");
|
||||
cargo.Name = "Store-All Plus";
|
||||
Save(db, cargo);
|
||||
var flak = DesignNamed(db, "Flak Gun");
|
||||
flak.Name = "Cargo Bay";
|
||||
Save(db, flak);
|
||||
});
|
||||
var before = File.ReadAllBytes(CatalogPath);
|
||||
Assert.Throws<InvalidOperationException>(() => Program.GenericDesigns(apply: true, root: _root));
|
||||
Assert.Equal(before, File.ReadAllBytes(CatalogPath));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_brand_already_held_by_another_product_is_refused()
|
||||
{
|
||||
Edit(db =>
|
||||
{
|
||||
var product = ProductNamed(db, "Hammerfall");
|
||||
product.Name = "Autocannon";
|
||||
Save(db, product);
|
||||
var other = ProductNamed(db, "Wren");
|
||||
other.Name = "Hammerfall";
|
||||
Save(db, other);
|
||||
});
|
||||
var before = File.ReadAllBytes(CatalogPath);
|
||||
Assert.Throws<InvalidOperationException>(() => Program.GenericDesigns(apply: true, root: _root));
|
||||
Assert.Equal(before, File.ReadAllBytes(CatalogPath));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_row_whose_old_and_generic_names_are_both_absent_is_refused()
|
||||
{
|
||||
Edit(db =>
|
||||
{
|
||||
var gun = DesignNamed(db, "Light Machine Gun");
|
||||
gun.Name = "Neither Name";
|
||||
Save(db, gun);
|
||||
});
|
||||
var before = File.ReadAllBytes(CatalogPath);
|
||||
Assert.Throws<InvalidOperationException>(() => Program.GenericDesigns(apply: true, root: _root));
|
||||
Assert.Equal(before, File.ReadAllBytes(CatalogPath));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_brand_row_whose_maker_sells_no_product_of_the_design_under_either_name_is_refused()
|
||||
{
|
||||
Edit(db =>
|
||||
{
|
||||
var product = ProductNamed(db, "Hammerfall");
|
||||
product.Name = "Neither Name";
|
||||
Save(db, product);
|
||||
});
|
||||
var before = File.ReadAllBytes(CatalogPath);
|
||||
Assert.Throws<InvalidOperationException>(() => Program.GenericDesigns(apply: true, root: _root));
|
||||
Assert.Equal(before, File.ReadAllBytes(CatalogPath));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_shipped_authoring_note_is_stripped_from_a_product_the_tables_do_not_name()
|
||||
{
|
||||
Edit(db =>
|
||||
{
|
||||
var product = ProductNamed(db, "LockOn");
|
||||
product.Description += Program.AuthoringNote;
|
||||
Save(db, product);
|
||||
});
|
||||
Assert.Equal(0, Program.GenericDesigns(apply: true, root: _root));
|
||||
Read(db =>
|
||||
{
|
||||
Assert.EndsWith("target.", ProductNamed(db, "LockOn").Description);
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -17,7 +17,7 @@ public sealed class LaunchSuppressorCatalogTests
|
|||
internal const string MildName = "Launch Baffle";
|
||||
// The observer's sensor, named: the reveal readings below are this design's PassiveInfo, so a catalog that gains an earlier
|
||||
// sensor must not change which one the observer fits.
|
||||
private const string SensorName = "not if i see you first";
|
||||
private const string SensorName = "Compact Sensor";
|
||||
private const float Flash = 1000f;
|
||||
private const float Tick = .25f; // exact in floats: four ticks are one second
|
||||
|
||||
|
|
|
|||
211
tests/Aetheria.Shared.Tests/ListenerTests.cs
Normal file
211
tests/Aetheria.Shared.Tests/ListenerTests.cs
Normal file
|
|
@ -0,0 +1,211 @@
|
|||
using System.Linq;
|
||||
using CultMath;
|
||||
using GameCult.Caching.MessagePack;
|
||||
using MessagePack;
|
||||
using Xunit;
|
||||
using static CultMath.math;
|
||||
using float3 = CultMath.float3;
|
||||
|
||||
// Passive listening gear (ruling sensor-stat-set): an observer with a listener hears an emission at the emitter's own
|
||||
// range times the listener's Multiple, bearing only. The pinger is the fixture's "Eye" (PingRange 300, intercept
|
||||
// factor absent so 1), so a sensor hears it at 300 and the "Listener" (Multiple 3) at 900. Every fixture drives the
|
||||
// production path: Sensor.Execute posts through Entity.Emit and Sense hears, ticking inside Zone.Update.
|
||||
public sealed partial class ContactRevealTests
|
||||
{
|
||||
private static GearData Listener(string name, float multiple)
|
||||
{
|
||||
var cell = new Shape(1, 1);
|
||||
cell[new int2(0, 0)] = true;
|
||||
return new GearData
|
||||
{
|
||||
Name = name, Hardpoint = HardpointType.Tool, Shape = cell, Durability = 10,
|
||||
MinimumTemperature = -1000, MaximumTemperature = 1000, OptimalTemperature = 0, PlateauWidth = 2000,
|
||||
Behaviors = { new ListenerData { Multiple = Const(multiple) } }
|
||||
};
|
||||
}
|
||||
|
||||
// ---- AListenerHearsAtItsMultiple ----
|
||||
|
||||
[Theory]
|
||||
[InlineData(899f, true)]
|
||||
[InlineData(901f, false)]
|
||||
public void AListenerHearsAtItsMultiple(float distance, bool heard)
|
||||
{
|
||||
var p = Add(float3(0, 0, 0), new[] { "Eye" });
|
||||
var ear = Add(float3(distance, 0, 0), tools: new[] { "Listener" });
|
||||
|
||||
var at = PingAt(p);
|
||||
|
||||
if (!heard) { Assert.Empty(ear.RevealsOf(p)); return; }
|
||||
var reveal = Assert.Single(ear.RevealsOf(p));
|
||||
Assert.Equal(SignatureChannel.Emission, reveal.Channel);
|
||||
Assert.Equal(at, reveal.Time);
|
||||
AssertBearing(-1f, 0f, reveal.Bearing); // normalize((P - ear).xz)
|
||||
Assert.Equal(0f, Track(ear, p)); // bearing only: it builds no track
|
||||
}
|
||||
|
||||
// ---- AListenerAndASensorTakeTheLarger ----
|
||||
|
||||
[Theory]
|
||||
[InlineData(true, 899f, true)]
|
||||
[InlineData(true, 901f, false)]
|
||||
[InlineData(false, 299f, true)]
|
||||
[InlineData(false, 301f, false)]
|
||||
public void AListenerAndASensorTakeTheLarger(bool listenerActive, float distance, bool heard)
|
||||
{
|
||||
var p = Add(float3(0, 0, 0), new[] { "Eye" });
|
||||
var both = Add(float3(distance, 0, 0), new[] { "Eye" }, new[] { "Listener" }); // a sum would hear at 1200
|
||||
var listener = both.Equipment.Single(i => i.Behaviors.Any(b => b is Listener));
|
||||
listener.Enabled.Value = listenerActive;
|
||||
|
||||
PingAt(p);
|
||||
|
||||
Assert.Equal(heard ? 1 : 0, both.RevealsOf(p).Count());
|
||||
}
|
||||
|
||||
// ---- AnInactiveListenerHearsNothing ----
|
||||
|
||||
[Fact]
|
||||
public void AnInactiveListenerHearsNothing()
|
||||
{
|
||||
var p = Add(float3(0, 0, 0), new[] { "Eye" });
|
||||
var ear = Add(float3(100, 0, 0), tools: new[] { "Listener" });
|
||||
ear.Equipment.Single(i => i.Behaviors.Any(b => b is Listener)).Enabled.Value = false;
|
||||
|
||||
PingAt(p);
|
||||
|
||||
Assert.Empty(ear.RevealsOf(p));
|
||||
}
|
||||
|
||||
// ---- AConsumableListenerHearsAtItsMultiple ----
|
||||
|
||||
// The Earpiece is a consumable hosting a Listener (Multiple 3): an observer with it active hears the "Eye" at 900, the
|
||||
// same as with the gear; with it not yet activated it has no instrument at all.
|
||||
[Theory]
|
||||
[InlineData(true, 899f, true)]
|
||||
[InlineData(true, 901f, false)]
|
||||
[InlineData(false, 100f, false)]
|
||||
public void AConsumableListenerHearsAtItsMultiple(bool activated, float distance, bool heard)
|
||||
{
|
||||
var p = Add(float3(0, 0, 0), new[] { "Eye" });
|
||||
var ear = Add(float3(distance, 0, 0));
|
||||
if (activated)
|
||||
{
|
||||
var data = _openCache.GetByName<ConsumableItemData>("Earpiece");
|
||||
ear.ActivateConsumable(Assert.IsType<ConsumableItem>(_items.CreateInstance(_items.CreateLot(data, _maker, .5f))));
|
||||
Assert.Single(ear.FindActiveConsumable(data).Behaviors.OfType<Listener>()); // fixture: the consumable hosts it
|
||||
}
|
||||
|
||||
PingAt(p);
|
||||
|
||||
Assert.Equal(heard ? 1 : 0, ear.RevealsOf(p).Count());
|
||||
}
|
||||
|
||||
// ---- Stacking: HearingMultiple is the largest of 1 (an active sensor) and each ACTIVE listener's Multiple ----
|
||||
// The pinger's range is 300, so a hearer at 300 x M - 1 hears and one at 300 x M + 1 does not. The largest listener
|
||||
// is never first or last, so a sum, a first-wins and a last-wins each hear at the wrong distance.
|
||||
|
||||
private void Activate(Ship ship, string consumable)
|
||||
{
|
||||
var data = _openCache.GetByName<ConsumableItemData>(consumable);
|
||||
ship.ActivateConsumable(Assert.IsType<ConsumableItem>(_items.CreateInstance(_items.CreateLot(data, _maker, .5f))));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(1499f, true)]
|
||||
[InlineData(1501f, false)]
|
||||
public void GearListenersTakeTheLargestMultipleNotTheSumOrTheLast(float distance, bool heard)
|
||||
{
|
||||
var p = Add(float3(0, 0, 0), new[] { "Eye" });
|
||||
var ear = Add(float3(distance, 0, 0), tools: new[] { "Listener", "Wide", "Narrow" }); // 3, 5, 1.5: the largest is the middle one
|
||||
|
||||
PingAt(p);
|
||||
|
||||
Assert.Equal(heard ? 1 : 0, ear.RevealsOf(p).Count());
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(1499f, true)]
|
||||
[InlineData(1501f, false)]
|
||||
public void ConsumableListenersTakeTheLargestMultipleNotTheSumOrTheLast(float distance, bool heard)
|
||||
{
|
||||
var p = Add(float3(0, 0, 0), new[] { "Eye" });
|
||||
var ear = Add(float3(distance, 0, 0));
|
||||
Activate(ear, "Earpiece"); // 3
|
||||
Activate(ear, "WideEarpiece"); // 5
|
||||
Activate(ear, "NarrowEarpiece"); // 1.5
|
||||
|
||||
PingAt(p);
|
||||
|
||||
Assert.Equal(heard ? 1 : 0, ear.RevealsOf(p).Count());
|
||||
}
|
||||
|
||||
// A listener that is switched on but not online (destroyed) hears nothing: Active, not Enabled, gates it, so the
|
||||
// 5x array that is down does not lift the 3x one that is up.
|
||||
[Theory]
|
||||
[InlineData(899f, true)]
|
||||
[InlineData(901f, false)]
|
||||
public void ADestroyedListenerDoesNotLiftTheOnesThatAreUp(float distance, bool heard)
|
||||
{
|
||||
var p = Add(float3(0, 0, 0), new[] { "Eye" });
|
||||
var ear = Add(float3(distance, 0, 0), tools: new[] { "Listener", "Wide" });
|
||||
var wide = ear.Equipment.Single(i => i.Behaviors.Any(b => b is Listener l && l.Multiple == 5f));
|
||||
wide.EquippableItem.Durability = 0;
|
||||
Tick(.1f);
|
||||
Assert.True(wide.Enabled.Value); // fixture: switched on
|
||||
Assert.False(wide.Active.Value); // and not online
|
||||
|
||||
PingAt(p);
|
||||
|
||||
Assert.Equal(heard ? 1 : 0, ear.RevealsOf(p).Count());
|
||||
}
|
||||
|
||||
// The floor of 1 belongs to an active sensor, not to each listener: a listener-only ship with a Multiple of .5
|
||||
// hears at half the pinger's range, and the same listener beside a sensor hears at the sensor's full range.
|
||||
[Theory]
|
||||
[InlineData(false, 149f, true)]
|
||||
[InlineData(false, 151f, false)]
|
||||
[InlineData(true, 299f, true)]
|
||||
[InlineData(true, 301f, false)]
|
||||
public void AMultipleBelowOneIsFlooredBySensorsNotByTheListener(bool withSensor, float distance, bool heard)
|
||||
{
|
||||
var p = Add(float3(0, 0, 0), new[] { "Eye" });
|
||||
var ear = Add(float3(distance, 0, 0), withSensor ? new[] { "Eye" } : null, new[] { "Hush" });
|
||||
|
||||
PingAt(p);
|
||||
|
||||
Assert.Equal(heard ? 1 : 0, ear.RevealsOf(p).Count());
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(149f, true)]
|
||||
[InlineData(151f, false)]
|
||||
public void AConsumableMultipleBelowOneIsNotClampedUp(float distance, bool heard)
|
||||
{
|
||||
var p = Add(float3(0, 0, 0), new[] { "Eye" });
|
||||
var ear = Add(float3(distance, 0, 0));
|
||||
Activate(ear, "HushEarpiece");
|
||||
|
||||
PingAt(p);
|
||||
|
||||
Assert.Equal(heard ? 1 : 0, ear.RevealsOf(p).Count());
|
||||
}
|
||||
|
||||
// ---- ListenerDataRoundTripsAsUnionKey50 ----
|
||||
|
||||
[Fact]
|
||||
public void ListenerDataRoundTripsAsUnionKey50()
|
||||
{
|
||||
var options = CultDocumentMessagePackSerialization.OptionsFor(typeof(ZonePack).Assembly);
|
||||
var data = new ListenerData { Multiple = Const(2.5f) };
|
||||
|
||||
var bytes = MessagePackSerializer.Serialize<BehaviorData>(data, options);
|
||||
var reader = new MessagePackReader(bytes);
|
||||
Assert.Equal(2, reader.ReadArrayHeader());
|
||||
Assert.Equal(50, reader.ReadInt32());
|
||||
Assert.Equal(2, reader.ReadArrayHeader()); // Group is key 0, then Multiple
|
||||
|
||||
var back = Assert.IsType<ListenerData>(MessagePackSerializer.Deserialize<BehaviorData>(bytes, options));
|
||||
Assert.Equal(2.5f, back.Multiple.Min);
|
||||
}
|
||||
}
|
||||
|
|
@ -23,11 +23,11 @@ public sealed class MunitionPartsTests : IDisposable
|
|||
// both ranged stats. The column names are the retired fields'.
|
||||
private static readonly (string Design, float ThrustMin, float ThrustMax, float MissileVelocityMin, float MissileVelocityMax, float DodgeFrequency)[] Golden =
|
||||
{
|
||||
("GT 3K", 135, 325, 150, 300, 0.25f),
|
||||
("LRMM72", 400, 600, 200, 300, 0.25f),
|
||||
("SRMM72", 1600, 2400, 400, 600, 1f),
|
||||
("pswarm", 500, 2000, 400, 600, 1f),
|
||||
("scorched void policy", 500, 2000, 400, 600, 1f),
|
||||
("Guided Missile Launcher", 135, 325, 150, 300, 0.25f),
|
||||
("Long-Range Missile Rack", 400, 600, 200, 300, 0.25f),
|
||||
("Short-Range Missile Rack", 1600, 2400, 400, 600, 1f),
|
||||
("Swarm Rocket Pod", 500, 2000, 400, 600, 1f),
|
||||
("Incendiary Rocket Pod", 500, 2000, 400, 600, 1f),
|
||||
};
|
||||
|
||||
private static PerformanceStat Flat(float value) => new PerformanceStat { Min = value, Max = value };
|
||||
|
|
@ -208,13 +208,13 @@ public sealed class MunitionPartsTests : IDisposable
|
|||
[Fact]
|
||||
public void CatalogLoadRefusesAnIncompleteOrStrayMunitionPart()
|
||||
{
|
||||
using (AetheriaStores.Open(Forged<WeaponItemData>(d => d.Name == "GT 3K", _ => { }), registry: TestCatalog.Registry())) { }
|
||||
using (AetheriaStores.Open(Forged<WeaponItemData>(d => d.Name == "Guided Missile Launcher", _ => { }), registry: TestCatalog.Registry())) { }
|
||||
|
||||
foreach (var part in AllParts)
|
||||
{
|
||||
var path = Forged<WeaponItemData>(d => d.Name == "GT 3K", d => d.Behaviors.RemoveAll(b => b.GetType() == part));
|
||||
var path = Forged<WeaponItemData>(d => d.Name == "Guided Missile Launcher", d => d.Behaviors.RemoveAll(b => b.GetType() == part));
|
||||
var refusal = Assert.ThrowsAny<Exception>(() => AetheriaStores.Open(path, registry: TestCatalog.Registry()));
|
||||
Assert.Contains("GT 3K", refusal.ToString());
|
||||
Assert.Contains("Guided Missile Launcher", refusal.ToString());
|
||||
Assert.Contains(part.Name, refusal.ToString());
|
||||
}
|
||||
|
||||
|
|
@ -245,13 +245,13 @@ public sealed class MunitionPartsTests : IDisposable
|
|||
// The Longinus's own gear: two drives, a core, a cockpit and a sensor, so the ship has thrusters, a sensor and a plume
|
||||
// for any munition contribution to be seen against.
|
||||
private static readonly (string Name, int X, int Y)[] ShipGear =
|
||||
{ ("Large Drive", 1, 0), ("Large Drive", 3, 0), ("Core Power", 2, 4), ("Cockpit 2x2", 2, 6), ("not if i see you first", 3, 10) };
|
||||
{ ("Large Drive", 1, 0), ("Large Drive", 3, 0), ("Compact Reactor", 2, 4), ("Cockpit 2x2", 2, 6), ("Compact Sensor", 3, 10) };
|
||||
|
||||
// A GT 3K fitted to a Longinus launcher hardpoint beside that gear, its lot's thruster role at the given quality.
|
||||
// A Guided Missile Launcher fitted to a Longinus launcher hardpoint beside that gear, its lot's thruster role at the given quality.
|
||||
private static EquippedItem Fit(CultCache cache, float thrusterQuality, out Ship ship)
|
||||
{
|
||||
var hull = cache.GetByName<HullData>("Longinus");
|
||||
var gt = cache.GetByName<WeaponItemData>("GT 3K");
|
||||
var gt = cache.GetByName<WeaponItemData>("Guided Missile Launcher");
|
||||
var hardpoint = hull.Hardpoints.First(h => h.Type == HardpointType.Launcher && h.IsFilledBy(gt));
|
||||
var settings = RestoredHullsTests.Settings();
|
||||
var ledger = new ProvenanceLedger();
|
||||
|
|
@ -269,7 +269,7 @@ public sealed class MunitionPartsTests : IDisposable
|
|||
zone.Admit(ship, piloted: false);
|
||||
// Settle at the item's optimal temperature, as ConditionRatioTests does, so heat and wear read their identity and only
|
||||
// the role's quality moves a stat.
|
||||
var item = ship.Equipment.Single(e => e.Data.Name == "GT 3K");
|
||||
var item = ship.Equipment.Single(e => e.Data.Name == "Guided Missile Launcher");
|
||||
foreach (var cell in item.InsetShape.Coordinates) ship.Temperature[cell.x, cell.y] = gt.OptimalTemperature;
|
||||
item.UpdatePerformance();
|
||||
item.UpdatePerformance();
|
||||
|
|
@ -280,7 +280,7 @@ public sealed class MunitionPartsTests : IDisposable
|
|||
public void PartsReadThroughTheItem()
|
||||
{
|
||||
using var cache = RestoredHullsTests.OpenCatalog();
|
||||
var design = cache.GetByName<WeaponItemData>("GT 3K");
|
||||
var design = cache.GetByName<WeaponItemData>("Guided Missile Launcher");
|
||||
var poor = Fit(cache, .2f, out var poorShip);
|
||||
var good = Fit(cache, .9f, out _);
|
||||
|
||||
|
|
@ -324,7 +324,7 @@ public sealed class MunitionPartsTests : IDisposable
|
|||
public void ShipSumsIgnoreTheFittedMunitionParts()
|
||||
{
|
||||
using var cache = RestoredHullsTests.OpenCatalog();
|
||||
var design = cache.GetByName<WeaponItemData>("GT 3K");
|
||||
var design = cache.GetByName<WeaponItemData>("Guided Missile Launcher");
|
||||
var part = Part<MunitionThrusterData>(design);
|
||||
var item = Fit(cache, .5f, out var ship);
|
||||
for (var i = 0; i < 5; i++) ship.Update(.1f);
|
||||
|
|
|
|||
|
|
@ -79,13 +79,13 @@ public sealed class PiratesFactionCommandTests : IDisposable
|
|||
var expected = new (string Design, string Name, string Description)[]
|
||||
{
|
||||
("Autocannon", "🫳🔫", "Serial number filed off. Still shoots."),
|
||||
("Earp", "🪦🤠", "The previous owner had no further use for it."),
|
||||
("FastBlast+-", "🧾🚫", "Warranty void where prohibited, which is everywhere."),
|
||||
("6k Shooter", "🎨🙈", "The logo underneath is somebody else's problem."),
|
||||
("scorched void policy", "🔥", "Turns out we did start the fire after all."),
|
||||
("Long Slug Rifle", "🪦🤠", "The previous owner had no further use for it."),
|
||||
("Cell Blaster", "🧾🚫", "Warranty void where prohibited, which is everywhere."),
|
||||
("Slug Rifle", "🎨🙈", "The logo underneath is somebody else's problem."),
|
||||
("Incendiary Rocket Pod", "🔥", "Turns out we did start the fire after all."),
|
||||
("Targeting Computer", "👀🎯", "Somebody else's eyes. They still work."),
|
||||
("Small Drive", "🔑🏃💨", "Hotwired. Do not ask about the ignition."),
|
||||
("Store-All Plus", "📦🤫", "Contents not as declared."),
|
||||
("Cargo Bay", "📦🤫", "Contents not as declared."),
|
||||
};
|
||||
Assert.Equal(expected.Select(e => e.Name).OrderBy(n => n, StringComparer.Ordinal), products.Select(p => p.Name).OrderBy(n => n, StringComparer.Ordinal));
|
||||
foreach (var (designName, name, description) in expected)
|
||||
|
|
|
|||
|
|
@ -306,7 +306,7 @@ public sealed class PowerCurveTests : IDisposable
|
|||
|
||||
// --- F6 (docs/stats-and-power-cut.md, Soul pass 2026-09-19) named PumpedHeat as a Radiator request field
|
||||
// --- (PowerRequest's own early-out gate reads it, the exact shape Soul reproduced against the shipped
|
||||
// --- catalog's "OK Disperser": SOUL_RadiatorRequestDependsOnItsOwnGrantAndOscillates) and, at the time,
|
||||
// --- catalog's "Heat Pump": SOUL_RadiatorRequestDependsOnItsOwnGrantAndOscillates) and, at the time,
|
||||
// --- refused a PowerSupply term there for exactly that reason. The nominal-request ruling above is what
|
||||
// --- actually fixes the oscillation (the request no longer reads the live grant at all), so this shape is
|
||||
// --- accepted now -- the six shipped records this ruling exists to make legal again include exactly this
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ public sealed class RestoredHullsTests
|
|||
Assert.True(ship.TryEquip(gearItem, hardpoint.Position));
|
||||
}
|
||||
|
||||
// A reactor: Victoire (one of Cut 1's own restored thrusters, docs/locomotion-cut.md's own note on it)
|
||||
// A reactor: Racing Drive (one of Cut 1's own restored thrusters, docs/locomotion-cut.md's own note on it)
|
||||
// carries a real EnergyUsage draw unlike its four siblings, so an unpowered ship reads as though only
|
||||
// some fitting thrusters produce thrust -- an artifact of which design TryEquip's own hardpoint search
|
||||
// happens to land on, not of the restored content. Every hull here also has a Reactor hardpoint; a real
|
||||
|
|
@ -952,7 +952,7 @@ public sealed class RestoredHullsTests
|
|||
|
||||
// Every restored thruster's particle effect is Thruster 1.prefab, by the legacy record (soul-dump.txt).
|
||||
var thruster1Guid = GuidOf("Assets/Content/Prefabs/Thrusters/Thruster 1.prefab");
|
||||
var restoredThrusterNames = new[] { "deep space burnout", "Large Drive", "Victoire", "Small Drive", "Talaria", "RevvITup 2.0", "Medium Drive" };
|
||||
var restoredThrusterNames = new[] { "Burn Drive", "Large Drive", "Racing Drive", "Small Drive", "Rugged Drive", "High-Thrust Drive", "Medium Drive" };
|
||||
foreach (var name in restoredThrusterNames)
|
||||
{
|
||||
var design = cache.GetAll<GearData>().First(g => g.Name == name);
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ using Xunit;
|
|||
// oracle, since the command produced it.
|
||||
public sealed class RolesBackfillCommandTests : IDisposable
|
||||
{
|
||||
private static readonly string[] Flattened = { "Autocannon", "LRMM72", "SRMM72", "Mine Launcher", "Large Drive", "Small Drive" };
|
||||
private static readonly string[] Flattened = { "Autocannon", "Long-Range Missile Rack", "Short-Range Missile Rack", "Mine Launcher", "Large Drive", "Small Drive" };
|
||||
|
||||
// Designs that shipped with non-flat stats whose Quality term named no role; the field is the stat to unname.
|
||||
private static readonly (string Design, string Field)[] Unnamed =
|
||||
{
|
||||
("DeathCluster", "Count"), ("Flak Gun", "Count"), ("GT 3K", "MinRange"), ("plight", "DamageSpread"),
|
||||
("MoveOnPro", "Modifier"), ("MoveOnPro Station Reactor", "Modifier"),
|
||||
("Cluster Cannon", "Count"), ("Flak Gun", "Count"), ("Guided Missile Launcher", "MinRange"), ("Lightning Projector", "DamageSpread"),
|
||||
("Muon Fusion Reactor", "Modifier"), ("Muon Fusion Station Reactor", "Modifier"),
|
||||
};
|
||||
|
||||
private readonly string _root = Path.Combine(Path.GetTempPath(), "roles-backfill-" + Guid.NewGuid().ToString("N"));
|
||||
|
|
@ -165,7 +165,7 @@ public sealed class RolesBackfillCommandTests : IDisposable
|
|||
static Dictionary<string, float> Exponents(EquippableItemData d) => CatalogRoleTests.StatsOf(d)
|
||||
.SelectMany(s => s.Stat.Terms.Where(t => t.Source == StatSource.Quality && !string.IsNullOrEmpty(t.Role)).Select(t => (s.Name, t.Exponent)))
|
||||
.ToDictionary(x => x.Name, x => x.Exponent);
|
||||
var designs = new[] { "Autocannon", "LRMM72" };
|
||||
var designs = new[] { "Autocannon", "Long-Range Missile Rack" };
|
||||
Dictionary<string, Dictionary<string, float>> shipped;
|
||||
Dictionary<string, Dictionary<string, float>> Read(EquippableItemData[] all) => all.Where(d => designs.Contains(d.Name)).ToDictionary(d => d.Name, Exponents);
|
||||
using (var catalog = RestoredHullsTests.OpenCatalog()) shipped = Read(catalog.GetAll<EquippableItemData>().ToArray());
|
||||
|
|
|
|||
|
|
@ -445,7 +445,7 @@ public sealed partial class RunStartTests : IDisposable
|
|||
}
|
||||
|
||||
// The sold hardpoint gear the generator gives no home today: the production rule (LoadoutGenerator.HasHome over the hulls a
|
||||
// product sells). The Smoke Test Hull, which no product sells, gives ChargeBlast SG and ChargeBlast+- no home; authoring a
|
||||
// product sells). The Smoke Test Hull, which no product sells, gives Charged Scatter Blaster and Charged Blaster no home; authoring a
|
||||
// sold hull that takes one shows up here as a changed list.
|
||||
[Fact]
|
||||
public void TheSoldHardpointGearWithNoHomeToday()
|
||||
|
|
@ -456,7 +456,7 @@ public sealed partial class RunStartTests : IDisposable
|
|||
.Where(design => sold.Contains(_cache.RefOf(design).Key) && design.Price > 0)
|
||||
.Where(design => !LoadoutGenerator.HasHome(design, hulls))
|
||||
.Select(design => design.Name).OrderBy(name => name, StringComparer.Ordinal).ToArray();
|
||||
Assert.Equal(new[] { "CShot RainbowLite Lazer", "ChargeBlast SG", "ChargeBlast+-", "OK Disperser" }, homeless);
|
||||
Assert.Equal(new[] { "Charged Blaster", "Charged Scatter Blaster", "Heat Pump", "Heavy Beam Laser" }, homeless);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
433
tests/Aetheria.Shared.Tests/ScannerTests.cs
Normal file
433
tests/Aetheria.Shared.Tests/ScannerTests.cs
Normal file
|
|
@ -0,0 +1,433 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using CultMath;
|
||||
using GameCult.Caching.MessagePack;
|
||||
using MessagePack;
|
||||
using Xunit;
|
||||
using static CultMath.math;
|
||||
using float2 = CultMath.float2;
|
||||
using float3 = CultMath.float3;
|
||||
|
||||
// Inspection (rulings quiet-gear-identifiable-hull-layout-known, scan-held-beam, scan-is-an-act, reveal-ends-on-perception,
|
||||
// sensor-stat-set): a scanner held on its ship's tracked target within Range for ScanTime reveals everything fitted to it,
|
||||
// as claimed, and is itself an emission the target is warned of and a third party can hear. The fixtures are the
|
||||
// catalog's: "Scanner" has Range 200 and ScanTime 2, "QuietScanner" the same with intercept factor 4 (heard at 50). A tick
|
||||
// is 1/8 s, so a scan builds 1/16 a tick and finishes on the sixteenth with no float drift. The scanner's ship keeps
|
||||
// its track on the target at .5 each tick (above the detection gate, below the one at which gear is resolved, so
|
||||
// Sense neither loses the track nor perceives a destruction). Every fixture drives the production path, ticking inside
|
||||
// Zone.Update.
|
||||
public sealed partial class ContactRevealTests
|
||||
{
|
||||
private const float ScanStep = .125f;
|
||||
|
||||
private static ScannerData ScannerBehavior(float range, float scanTime, float? interceptFactor = null) => new ScannerData
|
||||
{
|
||||
Range = Const(range), ScanTime = Const(scanTime),
|
||||
InterceptFactor = interceptFactor.HasValue ? Const(interceptFactor.Value) : null
|
||||
};
|
||||
|
||||
private static Scanner ScannerOf(Entity e) => e.Equipment.SelectMany(i => i.Behaviors).OfType<Scanner>().Single();
|
||||
|
||||
private static EquippedItem ScannerItemOf(Entity e) => e.Equipment.Single(i => i.Behaviors.Any(b => b is Scanner));
|
||||
|
||||
// A scanner ship at the origin, with the named scanner and no sensor (an AI ship with a sensor pings once it loses its
|
||||
// track, which would paint the target beside the scan), tracking and targeting a ship `distance`
|
||||
// ahead that carries a reactor, a radiator and a suppressor, none of which ever acts.
|
||||
private (Ship scanner, Ship target) ScanOn(string scanner = "Scanner", float distance = 100f, float info = .5f)
|
||||
{
|
||||
var target = Add(float3(0, 0, distance), tools: new[] { "Reactor", "Radiator", "SuppressorCold" });
|
||||
var s = Add(float3(0, 0, 0), tools: new[] { scanner });
|
||||
s.EntityInfoGathered[target] = info;
|
||||
s.SetTarget(target);
|
||||
Assert.Same(target, s.Target.Value.Entity); // fixture
|
||||
return (s, target);
|
||||
}
|
||||
|
||||
// Ticks `ticks` steps, holding the observer's track on each of `tracked` at `info` before each.
|
||||
private void Hold(Entity observer, int ticks, float info, params Entity[] tracked)
|
||||
{
|
||||
for (var i = 0; i < ticks; i++)
|
||||
{
|
||||
foreach (var t in tracked) observer.EntityInfoGathered[t] = info;
|
||||
Tick(ScanStep);
|
||||
}
|
||||
}
|
||||
|
||||
private void Hold(Entity observer, int ticks, params Entity[] tracked) => Hold(observer, ticks, .5f, tracked);
|
||||
|
||||
private static EquippedItem[] FittedBesidesTheHull(Entity e) => e.Equipment.Where(i => i != e.EquippedHull).ToArray();
|
||||
|
||||
// ---- AScanRevealsQuietGear ----
|
||||
|
||||
[Fact]
|
||||
public void AScanRevealsQuietGear()
|
||||
{
|
||||
var (s, target) = ScanOn();
|
||||
var quiet = FittedBesidesTheHull(target);
|
||||
Assert.Equal(3, quiet.Length);
|
||||
Assert.Empty(s.RevealsOf(target)); // fixture: nothing acts
|
||||
|
||||
Hold(s, 15, target);
|
||||
|
||||
Assert.Empty(s.RevealsOf(target));
|
||||
Assert.Equal(15f / 16f, ScannerOf(s).Progress, 4);
|
||||
|
||||
Hold(s, 1, target);
|
||||
|
||||
foreach (var item in quiet)
|
||||
{
|
||||
var reveal = Assert.Single(s.RevealsOf(target), r => r.Item == item);
|
||||
Assert.Null(reveal.Channel);
|
||||
AssertBearing(0f, 1f, reveal.Bearing); // normalize((target - scanner).xz)
|
||||
Assert.Equal(_zone.Time, reveal.Time);
|
||||
}
|
||||
Assert.Equal(0f, ScannerOf(s).Progress); // a finished scan starts over
|
||||
}
|
||||
|
||||
// ---- AScanSkipsTheHull ----
|
||||
|
||||
[Fact]
|
||||
public void AScanSkipsTheHull()
|
||||
{
|
||||
var (s, target) = ScanOn();
|
||||
Assert.Contains(target.EquippedHull, target.Equipment); // fixture: the hull is an item of Equipment
|
||||
|
||||
Hold(s, 16, target);
|
||||
|
||||
Assert.Equal(3, s.RevealsOf(target).Count()); // fixture: the scan finished
|
||||
Assert.DoesNotContain(s.RevealsOf(target), r => r.Item == target.EquippedHull);
|
||||
}
|
||||
|
||||
// ---- AScanSkipsDestroyedGear ----
|
||||
|
||||
[Fact]
|
||||
public void AScanSkipsDestroyedGear()
|
||||
{
|
||||
var (s, target) = ScanOn();
|
||||
var items = FittedBesidesTheHull(target);
|
||||
items[0].EquippableItem.Durability = 0f;
|
||||
Assert.True(items[0].EquippableItem.IsDestroyed);
|
||||
|
||||
Hold(s, 16, target);
|
||||
|
||||
Assert.DoesNotContain(s.RevealsOf(target), r => r.Item == items[0]);
|
||||
Assert.Equal(2, s.RevealsOf(target).Count());
|
||||
}
|
||||
|
||||
// ---- AScanRecordsTheClaim ----
|
||||
|
||||
[Fact]
|
||||
public void AScanRecordsTheClaim()
|
||||
{
|
||||
var (s, target) = ScanOn();
|
||||
var reactor = target.Equipment.Single(i => i.Behaviors.Any(b => b is Reactor));
|
||||
var radiator = DataOf("Radiator");
|
||||
target.Claim(reactor, radiator);
|
||||
|
||||
Hold(s, 16, target);
|
||||
|
||||
var reveal = Assert.Single(s.RevealsOf(target), r => r.Item == reactor);
|
||||
Assert.Same(radiator, reveal.Claimed);
|
||||
Assert.NotSame(reactor.Data, reveal.Claimed);
|
||||
}
|
||||
|
||||
// ---- AScanNeedsATrackAndRange ----
|
||||
|
||||
[Theory]
|
||||
[InlineData(199f, true, true)]
|
||||
[InlineData(201f, true, false)]
|
||||
[InlineData(100f, false, false)]
|
||||
public void AScanNeedsATrackAndRange(float distance, bool tracked, bool builds)
|
||||
{
|
||||
var third = Add(float3(40, 0, 0), new[] { "Eye" }); // within 200 of the scanner: it hears an emission
|
||||
var info = tracked ? .5f : 0f;
|
||||
var (s, target) = ScanOn(distance: distance, info: info);
|
||||
Assert.Equal(tracked, s.VisibleEntities.Contains(target)); // fixture
|
||||
|
||||
Hold(s, 4, info, target);
|
||||
|
||||
Assert.Equal(builds, ScannerOf(s).Progress > 0f);
|
||||
Assert.Equal(builds, target.IncomingPaints.Count > 0);
|
||||
Assert.Equal(builds, target.RevealsOf(s).Any());
|
||||
Assert.Equal(builds, third.RevealsOf(s).Any());
|
||||
}
|
||||
|
||||
// ---- ABrokenScanDecays ----
|
||||
|
||||
// A scan at .5 broken for half of ScanTime (one second) falls to 0, a quarter in half of that: by range (Execute
|
||||
// runs and does not hold) and by the item switched off (Execute does not run at all).
|
||||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
public void ABrokenScanDecays(bool byRange)
|
||||
{
|
||||
var (s, target) = ScanOn();
|
||||
Hold(s, 8, target);
|
||||
Assert.Equal(.5f, ScannerOf(s).Progress, 4);
|
||||
if (byRange) target.Position = float3(0, 0, 400);
|
||||
else ScannerItemOf(s).Enabled.Value = false;
|
||||
|
||||
Hold(s, 4, target);
|
||||
Assert.Equal(.25f, ScannerOf(s).Progress, 4);
|
||||
|
||||
Hold(s, 4, target);
|
||||
Assert.Equal(0f, ScannerOf(s).Progress, 4);
|
||||
Hold(s, 2, target);
|
||||
Assert.Equal(0f, ScannerOf(s).Progress, 4); // never below 0
|
||||
}
|
||||
|
||||
// ---- ABrokenScanResumesFromWhatDecayed ----
|
||||
|
||||
// A scan at .5 loses a sixteenth for each tick it is broken, and a held tick after the gap builds on what is left (the
|
||||
// held tick itself is not a decay tick): .5, two broken ticks .375, two held ticks .5.
|
||||
[Fact]
|
||||
public void ABrokenScanResumesFromWhatDecayed()
|
||||
{
|
||||
var (s, target) = ScanOn();
|
||||
Hold(s, 8, target);
|
||||
Assert.Equal(.5f, ScannerOf(s).Progress, 4);
|
||||
target.Position = float3(0, 0, 400);
|
||||
|
||||
Hold(s, 2, target);
|
||||
Assert.Equal(.375f, ScannerOf(s).Progress, 4);
|
||||
|
||||
target.Position = float3(0, 0, 100);
|
||||
Hold(s, 2, target);
|
||||
Assert.Equal(.5f, ScannerOf(s).Progress, 4);
|
||||
}
|
||||
|
||||
// ---- ATargetChangeResetsTheScan ----
|
||||
|
||||
[Fact]
|
||||
public void ATargetChangeResetsTheScan()
|
||||
{
|
||||
var (s, first) = ScanOn();
|
||||
var second = Add(float3(100, 0, 0));
|
||||
Hold(s, 11, first, second);
|
||||
Assert.Equal(11f / 16f, ScannerOf(s).Progress, 4);
|
||||
|
||||
s.SetTarget(second);
|
||||
Hold(s, 1, first, second);
|
||||
|
||||
Assert.Equal(1f / 16f, ScannerOf(s).Progress, 4); // reset, then one tick on the new target
|
||||
Assert.Empty(s.RevealsOf(first));
|
||||
}
|
||||
|
||||
// ---- TheScannedShipIsWarned ----
|
||||
|
||||
// A paint made in a tick is published the next one, so after four ticks the target holds the third tick's paint.
|
||||
[Fact]
|
||||
public void TheScannedShipIsWarned()
|
||||
{
|
||||
var (s, target) = ScanOn();
|
||||
|
||||
Hold(s, 4, target);
|
||||
|
||||
var paint = Assert.Single(target.IncomingPaints);
|
||||
Assert.Equal(PaintMode.Scan, paint.Mode);
|
||||
Assert.Equal(3f / 16f, paint.Strength, 4);
|
||||
Assert.Same(DataOf("Scanner"), paint.EmitterClass);
|
||||
AssertBearing(0f, -1f, paint.Bearing); // normalize((scanner - target).xz)
|
||||
var warned = Assert.Single(target.RevealsOf(s));
|
||||
Assert.Same(ScannerItemOf(s), warned.Item);
|
||||
Assert.Equal(SignatureChannel.Emission, warned.Channel);
|
||||
}
|
||||
|
||||
// ---- AThirdPartyHearsTheScanner ----
|
||||
|
||||
[Theory]
|
||||
[InlineData("QuietScanner", 49f, true)]
|
||||
[InlineData("QuietScanner", 51f, false)]
|
||||
[InlineData("Scanner", 199f, true)]
|
||||
[InlineData("Scanner", 201f, false)]
|
||||
public void AThirdPartyHearsTheScanner(string scanner, float distance, bool heard)
|
||||
{
|
||||
var (s, target) = ScanOn(scanner);
|
||||
var third = Add(float3(-distance, 0, 0), new[] { "Eye" });
|
||||
|
||||
Hold(s, 3, target);
|
||||
|
||||
Assert.Empty(third.IncomingPaints); // fixture: only the target is painted
|
||||
if (!heard)
|
||||
{
|
||||
Assert.Empty(third.RevealsOf(s));
|
||||
return;
|
||||
}
|
||||
var reveal = Assert.Single(third.RevealsOf(s));
|
||||
Assert.Same(ScannerItemOf(s), reveal.Item);
|
||||
Assert.Equal(SignatureChannel.Emission, reveal.Channel);
|
||||
AssertBearing(1f, 0f, reveal.Bearing); // normalize((scanner - third).xz)
|
||||
}
|
||||
|
||||
// ---- AFinishedScanMakesTheReactorSelectable ----
|
||||
|
||||
[Fact]
|
||||
public void AFinishedScanMakesTheReactorSelectable()
|
||||
{
|
||||
var (s, target) = ScanOn();
|
||||
var reactor = target.Equipment.Single(i => i.Behaviors.Any(b => b is Reactor));
|
||||
Hold(s, 15, target);
|
||||
Assert.False(FireControl.IsRevealed(s, reactor));
|
||||
Assert.False(s.TrySelectTargetItem(reactor));
|
||||
|
||||
Hold(s, 1, target);
|
||||
|
||||
Assert.True(FireControl.IsRevealed(s, reactor));
|
||||
Assert.True(s.TrySelectTargetItem(reactor));
|
||||
}
|
||||
|
||||
// ---- AScanEndsNothing ----
|
||||
|
||||
// A gun revealed by firing and then destroyed, while the observer's track stays between the detection and gear
|
||||
// thresholds (so Sense perceives no destruction): a scan neither ends its reveal nor refreshes it.
|
||||
[Fact]
|
||||
public void AScanEndsNothing()
|
||||
{
|
||||
var target = Add(float3(0, 0, 100), new[] { "Gun" });
|
||||
var s = Add(float3(0, 0, 0), new[] { "Eye" }, new[] { "Scanner" });
|
||||
var gun = Guns(target)[0];
|
||||
var firedAt = Fire(target, gun);
|
||||
var before = Assert.Single(s.RevealsOf(target), r => r.Item == gun);
|
||||
Assert.Equal(firedAt, before.Time); // fixture: the gun is in the book
|
||||
gun.EquippableItem.Durability = 0f;
|
||||
s.EntityInfoGathered[target] = .5f;
|
||||
s.SetTarget(target);
|
||||
|
||||
Hold(s, 16, target);
|
||||
|
||||
var after = Assert.Single(s.RevealsOf(target), r => r.Item == gun);
|
||||
Assert.Equal(firedAt, after.Time);
|
||||
Assert.Equal(SignatureChannel.LaunchFlash, after.Channel);
|
||||
Assert.Contains(s.RevealsOf(target), r => r.Item != gun && r.Channel == null); // fixture: the scan finished
|
||||
}
|
||||
|
||||
// ---- AScanReadsNoHostility ----
|
||||
|
||||
// Ruling ew-hostility-from-belief-ruled: a scan is an act of perception and judges nothing, so it proceeds and records the
|
||||
// claim whatever the stance between the two ships, hostile or friendly, honest or lying. The stance is set both ways
|
||||
// through SetIff, which decides IsHostileTo, EntityHostility and VisibleEnemies alike.
|
||||
[Theory]
|
||||
[InlineData(true, false)]
|
||||
[InlineData(true, true)]
|
||||
[InlineData(false, false)]
|
||||
[InlineData(false, true)]
|
||||
public void AScanReadsNoHostility(bool hostile, bool lies)
|
||||
{
|
||||
var (s, target) = ScanOn();
|
||||
var reactor = target.Equipment.Single(i => i.Behaviors.Any(b => b is Reactor));
|
||||
var radiator = DataOf("Radiator");
|
||||
if (lies) target.Claim(reactor, radiator);
|
||||
s.SetIff(target, hostile);
|
||||
target.SetIff(s, hostile);
|
||||
Tick(ScanStep);
|
||||
Assert.Equal(hostile, s.IsHostileTo(target)); // fixture
|
||||
Assert.Equal(hostile, s.VisibleEnemies.Contains(target)); // fixture: the stance reached the readers a gate would use
|
||||
|
||||
Hold(s, 16, target);
|
||||
|
||||
Assert.Equal(3, s.RevealsOf(target).Count());
|
||||
var reveal = Assert.Single(s.RevealsOf(target), r => r.Item == reactor);
|
||||
Assert.Same(lies ? radiator : reactor.Data, reveal.Claimed);
|
||||
Assert.NotEmpty(target.IncomingPaints.Where(p => p.Mode == PaintMode.Scan));
|
||||
}
|
||||
|
||||
// ---- AScanTakesTheSamePathForAnyPilot ----
|
||||
|
||||
// Ruling same-ship-same-inputs: a ship with an AI agent and one with none (the player's) scan the same target through
|
||||
// the one Scanner and enter the same reveals in their books, claimed alike. Every reveal in a book comes from
|
||||
// RecordReveal, whose callers are Sense, PublishInbox and RecordInspection: a second scan path for either pilot would
|
||||
// leave the two books different (or one empty).
|
||||
[Fact]
|
||||
public void AScanTakesTheSamePathForAnyPilot()
|
||||
{
|
||||
var target = Add(float3(0, 0, 100), tools: new[] { "Reactor", "Radiator", "SuppressorCold" });
|
||||
var reactor = target.Equipment.Single(i => i.Behaviors.Any(b => b is Reactor));
|
||||
target.Claim(reactor, DataOf("Radiator"));
|
||||
var player = Add(float3(-20, 0, 0), tools: new[] { "Scanner" });
|
||||
var ai = Add(float3(20, 0, 0), tools: new[] { "Scanner" });
|
||||
_zone.Agents.Add(new Agent(ai)); // the AI pilot, ticked in Zone.Update beside the scan; a task-less agent needs no orbit to patrol
|
||||
Assert.Single(_zone.Agents); // fixture: only the second ship has an agent
|
||||
foreach (var scanner in new[] { player, ai })
|
||||
{
|
||||
scanner.EntityInfoGathered[target] = .5f;
|
||||
scanner.SetTarget(target);
|
||||
}
|
||||
|
||||
void Step(int ticks)
|
||||
{
|
||||
for (var i = 0; i < ticks; i++)
|
||||
{
|
||||
player.EntityInfoGathered[target] = .5f;
|
||||
ai.EntityInfoGathered[target] = .5f;
|
||||
Tick(ScanStep);
|
||||
}
|
||||
}
|
||||
Step(15);
|
||||
Assert.Empty(player.RevealsOf(target)); // neither pilot has a scan before ScanTime
|
||||
Assert.Empty(ai.RevealsOf(target));
|
||||
Step(1);
|
||||
|
||||
Assert.Equal(3, player.RevealsOf(target).Count());
|
||||
Func<Entity, string[]> book = o => o.RevealsOf(target)
|
||||
.Select(r => r.Item.Data.Name + "|" + r.Claimed.Name + "|" + (r.Channel?.ToString() ?? "scan")).OrderBy(x => x).ToArray();
|
||||
Assert.Equal(book(player), book(ai));
|
||||
}
|
||||
|
||||
// ---- AConsumableScannerDecaysOnTheSameTick ----
|
||||
|
||||
// The two hosts order Execute and the always-updated pass differently (ConsumableItemEffect.Update runs the pass first),
|
||||
// so the scan's decay must not depend on that order: a scan broken by range loses dt/ScanTime on the tick it breaks, and
|
||||
// .5 falls to .25 in four ticks, as ABrokenScanDecays has it for gear.
|
||||
[Fact]
|
||||
public void AConsumableScannerDecaysOnTheSameTick()
|
||||
{
|
||||
var data = _openCache.GetByName<ConsumableItemData>("ScannerCharge");
|
||||
var target = Add(float3(0, 0, 100), tools: new[] { "Reactor" });
|
||||
var s = Add(float3(0, 0, 0));
|
||||
s.ActivateConsumable(Assert.IsType<ConsumableItem>(_items.CreateInstance(_items.CreateLot(data, _maker, .5f))));
|
||||
var scanner = s.FindActiveConsumable(data).Behaviors.OfType<Scanner>().Single();
|
||||
s.EntityInfoGathered[target] = .5f;
|
||||
s.SetTarget(target);
|
||||
Hold(s, 8, target);
|
||||
Assert.Equal(.5f, scanner.Progress, 4); // fixture: the consumable scans like gear
|
||||
|
||||
target.Position = float3(0, 0, 400);
|
||||
Hold(s, 4, target);
|
||||
|
||||
Assert.Equal(.25f, scanner.Progress, 4);
|
||||
Hold(s, 4, target);
|
||||
Assert.Equal(0f, scanner.Progress, 4);
|
||||
}
|
||||
|
||||
// ---- ScannerDataRoundTripsAsUnionKey51 ----
|
||||
|
||||
[Fact]
|
||||
public void ScannerDataRoundTripsAsUnionKey51()
|
||||
{
|
||||
var options = CultDocumentMessagePackSerialization.OptionsFor(typeof(ZonePack).Assembly);
|
||||
var data = new ScannerData { Range = Const(200f), ScanTime = Const(2f), InterceptFactor = Const(4f) };
|
||||
|
||||
var bytes = MessagePackSerializer.Serialize<BehaviorData>(data, options);
|
||||
var reader = new MessagePackReader(bytes);
|
||||
Assert.Equal(2, reader.ReadArrayHeader());
|
||||
Assert.Equal(51, reader.ReadInt32()); // sensor-catalog holds 50; a key reused across branches would collide on the wire
|
||||
Assert.Equal(4, reader.ReadArrayHeader()); // Group is key 0, then the three stats
|
||||
reader.Skip();
|
||||
Assert.Equal(200f, MessagePackSerializer.Deserialize<PerformanceStat>(ref reader, options).Min); // key 1 Range
|
||||
Assert.Equal(2f, MessagePackSerializer.Deserialize<PerformanceStat>(ref reader, options).Min); // key 2 ScanTime
|
||||
Assert.Equal(4f, MessagePackSerializer.Deserialize<PerformanceStat>(ref reader, options).Min); // key 3 InterceptFactor
|
||||
|
||||
var back = Assert.IsType<ScannerData>(MessagePackSerializer.Deserialize<BehaviorData>(bytes, options));
|
||||
Assert.Equal(200f, back.Range.Min);
|
||||
Assert.Equal(2f, back.ScanTime.Min);
|
||||
Assert.Equal(4f, back.InterceptFactor.Min);
|
||||
var absent = Assert.IsType<ScannerData>(MessagePackSerializer.Deserialize<BehaviorData>(
|
||||
MessagePackSerializer.Serialize<BehaviorData>(new ScannerData { Range = Const(1f), ScanTime = Const(1f) }, options), options));
|
||||
Assert.Null(absent.InterceptFactor);
|
||||
|
||||
var unions = typeof(BehaviorData).GetCustomAttributes(typeof(UnionAttribute), false).Cast<UnionAttribute>().ToArray();
|
||||
Assert.Single(unions, u => u.Key == 51);
|
||||
Assert.Equal(unions.Length, unions.Select(u => u.Key).Distinct().Count());
|
||||
}
|
||||
}
|
||||
|
|
@ -537,7 +537,7 @@ public sealed partial class RunStartTests
|
|||
|
||||
runs.Add(Stage(Arena(false), new Scripted(false, stage =>
|
||||
{
|
||||
var ship = stage.Player(stage.Fit("Djinni", ("Census Fitted", int2(1, 6), ItemRotation.None), ("Store-All Plus", int2(3, 6), ItemRotation.None)), float2(0, 0));
|
||||
var ship = stage.Player(stage.Fit("Djinni", ("Census Fitted", int2(1, 6), ItemRotation.None), ("Cargo Bay", int2(3, 6), ItemRotation.None)), float2(0, 0));
|
||||
stage.Cargo(ship, "Census Carried");
|
||||
})));
|
||||
Assert.Empty(UnsoldAndUnplaced(runs));
|
||||
|
|
@ -580,4 +580,19 @@ public sealed partial class RunStartTests
|
|||
Assert.Equal("<Keyboard>/1", Assert.Single(settings.InputSettings.ActionBarInputs));
|
||||
Assert.Equal((Quality.High, true), (settings.GraphicsSettings.NebulaQuality, settings.GraphicsSettings.ShowAsteroidsInMinimap));
|
||||
}
|
||||
|
||||
// A scenario's Brief is player text (the menu shows it): it names gear by what the catalog sells today. A name a rename retired,
|
||||
// that no design or product carries any more, would send the player looking for gear that is gone.
|
||||
[Fact]
|
||||
public void NoScenarioBriefNamesRetiredGear()
|
||||
{
|
||||
var current = _cache.GetAll<EquippableItemData>().Select(design => design.Name)
|
||||
.Concat(_cache.GetAll<FactionProductData>().Select(product => product.Name)).ToHashSet(StringComparer.Ordinal);
|
||||
var stale = new List<string>();
|
||||
foreach (var scenario in EveryScenario)
|
||||
foreach (var retired in Program.Renames.Select(row => row.Old).Where(name => !current.Contains(name)))
|
||||
if (System.Text.RegularExpressions.Regex.IsMatch(scenario.Brief, @"(?<!\w)" + System.Text.RegularExpressions.Regex.Escape(retired) + @"s?(?!\w)"))
|
||||
stale.Add(scenario.Name + " names " + retired);
|
||||
Assert.True(stale.Count == 0, "scenario briefs naming gear the catalog no longer has: " + string.Join("; ", stale));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public sealed class SmokeHullCommandTests : IDisposable
|
|||
var hulls = db.Cache.GetAll<HullData>().Where(h => h.Name == HullName).ToArray();
|
||||
var keys = hulls.Select(h => db.Cache.RefOf(h).Key).ToArray();
|
||||
var products = db.Cache.GetAll<FactionProductData>().Count(p => keys.Any(k => p.Design.Key.Equals(k)));
|
||||
var fitted = new[] { "ChargeBlast SG", "Autocannon" }
|
||||
var fitted = new[] { "Charged Scatter Blaster", "Autocannon" }
|
||||
.Select(name => db.Cache.GetAll<EquippableItemData>().Single(d => d.Name == name)).ToArray();
|
||||
return (hulls, db.Cache.GetAll<HullData>().Single(h => h.Name == "Longinus"), fitted, products);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public sealed partial class RunStartTests
|
|||
private static List<EquippedItem> WeaponMounts(Entity ship) =>
|
||||
ship.Equipment.Where(item => item.Behaviors.OfType<Weapon>().Any()).ToList();
|
||||
|
||||
// Weapon Feel: the player flies the Smoke Test Hull with ChargeBlast SG on the 2x2 Energy hardpoint, Autocannon
|
||||
// Weapon Feel: the player flies the Smoke Test Hull with Charged Scatter Blaster on the 2x2 Energy hardpoint, Autocannon
|
||||
// on the 2x2 Ballistic hardpoint and a burst weapon; the bare hull ahead lies in every mount's arc.
|
||||
[Fact]
|
||||
public void WeaponFeelConditions()
|
||||
|
|
@ -23,7 +23,7 @@ public sealed partial class RunStartTests
|
|||
Assert.Equal("Smoke Test Hull", _items.GetData(player.EquippedHull.EquippableItem).Name);
|
||||
|
||||
EquippedItem Mount(string design) => Assert.Single(WeaponMounts(player), item => _items.GetData(item.EquippableItem).Name == design);
|
||||
var charge = Mount("ChargeBlast SG");
|
||||
var charge = Mount("Charged Scatter Blaster");
|
||||
var autocannon = Mount("Autocannon");
|
||||
Assert.Equal((HardpointType.Energy, 2, 2), (charge.Hardpoint.Type, charge.Hardpoint.Shape.Width, charge.Hardpoint.Shape.Height));
|
||||
Assert.Equal((HardpointType.Ballistic, 2, 2), (autocannon.Hardpoint.Type, autocannon.Hardpoint.Shape.Width, autocannon.Hardpoint.Shape.Height));
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public sealed class SmokeRoundsCommandTests : IDisposable
|
|||
|
||||
public void Dispose() => Directory.Delete(_root, true);
|
||||
|
||||
private (WeaponItemData[] Smoke, WeaponItemData Spectra, WeaponItemData ChargeBlast, int Products) Read()
|
||||
private (WeaponItemData[] Smoke, WeaponItemData LightLaser, WeaponItemData ChargedScatterBlaster, int Products) Read()
|
||||
{
|
||||
var db = AetherDb.Open(root: _root);
|
||||
try
|
||||
|
|
@ -51,7 +51,7 @@ public sealed class SmokeRoundsCommandTests : IDisposable
|
|||
var smoke = db.Cache.GetAll<WeaponItemData>().Where(w => Names.Contains(w.Name)).ToArray();
|
||||
var keys = smoke.Select(w => db.Cache.RefOf(w).Key).ToArray();
|
||||
var products = db.Cache.GetAll<FactionProductData>().Count(p => keys.Any(k => p.Design.Key.Equals(k)));
|
||||
return (smoke, db.Cache.GetAll<WeaponItemData>().Single(w => w.Name == "Spectra"), db.Cache.GetAll<WeaponItemData>().Single(w => w.Name == "ChargeBlast SG"), products);
|
||||
return (smoke, db.Cache.GetAll<WeaponItemData>().Single(w => w.Name == "Light Laser"), db.Cache.GetAll<WeaponItemData>().Single(w => w.Name == "Charged Scatter Blaster"), products);
|
||||
}
|
||||
finally { db.Cache.Dispose(); }
|
||||
}
|
||||
|
|
@ -85,7 +85,7 @@ public sealed class SmokeRoundsCommandTests : IDisposable
|
|||
Assert.Equal((WeaponFuse.Delayed, 4f, 2f, 2f), (Design("Smoke Delayed").Fuse.Value, Design("Smoke Delayed").BlastRadius.Value, Data("Smoke Delayed").Penetration.Min, Data("Smoke Delayed").Penetration.Max));
|
||||
Assert.Equal((WeaponFuse.Proximity, 30f, 20f, 20f), (Design("Smoke Refused").Fuse.Value, Design("Smoke Refused").BlastRadius.Value, Data("Smoke Refused").Range.Min, Data("Smoke Refused").Range.Max));
|
||||
|
||||
// Spectra clones are energy, 1x2, with the Spectra's own gear; the charged one is a ChargeBlast SG clone on its 2x2 energy mount.
|
||||
// Light Laser clones are energy, 1x2, with the Light Laser's own gear; the charged one is a Charged Scatter Blaster clone on its 2x2 energy mount.
|
||||
foreach (var name in new[] { "Smoke Proximity", "Smoke Delayed", "Smoke Refused", "Smoke Refused Beam" })
|
||||
Assert.Equal((spectra.Hardpoint, spectra.Shape.Width, spectra.Shape.Height, spectra.Mass), (Design(name).Hardpoint, Design(name).Shape.Width, Design(name).Shape.Height, Design(name).Mass));
|
||||
Assert.Equal((chargeBlast.Hardpoint, chargeBlast.Shape.Width, chargeBlast.Shape.Height), (Design("Smoke Refused Charge").Hardpoint, 2, 2));
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public sealed partial class RunStartTests
|
|||
|
||||
var proximity = Carried(player, "Smoke Proximity");
|
||||
var delayed = Carried(player, "Smoke Delayed");
|
||||
var direct = Carried(player, "DeathCluster");
|
||||
var direct = Carried(player, "Cluster Cannon");
|
||||
Assert.Null(player.Target.Value.Entity);
|
||||
|
||||
// The bare hull is on the initial aim line, ahead, and inside every weapon mount's arc.
|
||||
|
|
|
|||
|
|
@ -55,11 +55,11 @@ public sealed partial class RunStartTests
|
|||
Assert.True(taken > 0f, $"the hull ahead took no damage (selected {selected})");
|
||||
}
|
||||
|
||||
// Fused Rounds, nothing selected, the player aiming down the bare hull ahead. The DeathCluster is the control: it fires
|
||||
// Fused Rounds, nothing selected, the player aiming down the bare hull ahead. The Cluster Cannon is the control: it fires
|
||||
// in this arena, so a fused weapon that does not is not a harness that cannot fire. A fused round flies slowly enough
|
||||
// to be in the air when the direct weapon kills the fragile hull (check A.3) and bursts on the first hull on the aim line.
|
||||
[Theory]
|
||||
[InlineData("DeathCluster")]
|
||||
[InlineData("Cluster Cannon")]
|
||||
[InlineData("Smoke Proximity")]
|
||||
[InlineData("Smoke Delayed")]
|
||||
public void EveryWeaponAboardFiresInTheSteppedFusedRoundsArena(string design)
|
||||
|
|
@ -77,7 +77,7 @@ public sealed partial class RunStartTests
|
|||
for (var i = 0; i < 60; i++) arena.Update(SteppedDt);
|
||||
|
||||
Assert.True(fired.Count > 0, $"{design} fired nothing in 3 s; the ship's reactor is {(player.PowerBus.TotalGeneration > 0f ? "running" : "down")}");
|
||||
if (design == "DeathCluster") return;
|
||||
if (design == "Cluster Cannon") return;
|
||||
var (at, burst) = committed.First();
|
||||
Assert.Equal(ShotResult.Burst, burst.Result);
|
||||
Assert.True(burst.HasBurstPoint);
|
||||
|
|
@ -86,7 +86,7 @@ public sealed partial class RunStartTests
|
|||
Assert.InRange(at + burst.ArrivalIn - fired[0], 1f, 5f); // in the air for seconds: not resolved in its firing tick, not minutes of flight
|
||||
}
|
||||
|
||||
// Check A.3 flown: the fragile hull is selected and the DeathCluster, at full damage inside its effective range, starts
|
||||
// Check A.3 flown: the fragile hull is selected and the Cluster Cannon, at full damage inside its effective range, starts
|
||||
// killing it; once half its hull is gone a Smoke Proximity round is fired at it, and the hull dies before the round
|
||||
// lands, so the round never bursts.
|
||||
[Fact]
|
||||
|
|
@ -107,7 +107,7 @@ public sealed partial class RunStartTests
|
|||
});
|
||||
|
||||
var hullDurability = ((HullData) _items.GetData(fragile.Hull)).Durability;
|
||||
WeaponOf(Carried(player, "DeathCluster")).Activate();
|
||||
WeaponOf(Carried(player, "Cluster Cannon")).Activate();
|
||||
float? deadAt = null;
|
||||
var fired = false;
|
||||
for (var i = 0; i < 120 && landed == null; i++)
|
||||
|
|
@ -117,7 +117,7 @@ public sealed partial class RunStartTests
|
|||
if (deadAt == null && !arena.Entities.Contains(fragile)) deadAt = arena.Time;
|
||||
}
|
||||
|
||||
Assert.True(fired, "the DeathCluster never hurt the fragile hull");
|
||||
Assert.True(fired, "the Cluster Cannon never hurt the fragile hull");
|
||||
Assert.NotNull(deadAt);
|
||||
Assert.NotNull(landed);
|
||||
Assert.True(deadAt <= landed.Value.At, $"the round landed at {landed.Value.At:F2} s, before the fragile hull died at {deadAt:F2} s");
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ using float3 = CultMath.float3;
|
|||
|
||||
// Flight control allocates thrust (ruling flight-control-allocates-thrust): Ship.Update hands the intent and every
|
||||
// thruster's live column to one ThrustAllocator, and a ship flies on what that answers. These tests fly the Duel's
|
||||
// Longinus (two mismatched Large Drives forward, a Talaria on each flank) through the real Ship.Update; a test that reads
|
||||
// Longinus (two mismatched Large Drives forward, a Rugged Drive on each flank) through the real Ship.Update; a test that reads
|
||||
// velocity steps the arena, because the zone places the orbits that Ship.Update alone leaves stacked at the spawn.
|
||||
public sealed partial class RunStartTests
|
||||
{
|
||||
|
|
@ -307,7 +307,7 @@ public sealed partial class RunStartTests
|
|||
|
||||
// Rulings evasion-is-unpredictability and turn-authority-full: the Longinus's Large Drives count toward its turn,
|
||||
// because the envelope is summed over every live column. Its clockwise is the sum of the positive yaw of its columns
|
||||
// at live thrust, and exceeds the Talaria's own by the drives'.
|
||||
// at live thrust, and exceeds the Rugged Drive's own by the drives'.
|
||||
[Fact]
|
||||
public void TheEnvelopeCountsTheMains()
|
||||
{
|
||||
|
|
@ -317,7 +317,7 @@ public sealed partial class RunStartTests
|
|||
for (var tick = 0; tick < 10; tick++) player.Update(AllocDt);
|
||||
var thrusters = player.GetBehaviors<Thruster>().Where(t => t.Item.Active.Value).ToArray();
|
||||
var drives = thrusters.Where(t => t.Item.Data.Name == "Large Drive").ToArray();
|
||||
var flanks = thrusters.Where(t => t.Item.Data.Name == "Talaria").ToArray();
|
||||
var flanks = thrusters.Where(t => t.Item.Data.Name == "Rugged Drive").ToArray();
|
||||
Assert.Equal(2, drives.Length);
|
||||
Assert.Equal(2, flanks.Length);
|
||||
float Clockwise(IEnumerable<Thruster> of) => of.Sum(t => max(t.Column(t.Thrust).z, 0f));
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@ public class ThrustAllocatorTests
|
|||
|
||||
static float3 Col(float starboard, float forward, float yawDeg) => new(starboard, forward, yawDeg * Deg);
|
||||
|
||||
// TA3, the Duel Longinus: two mismatched drives (0, 1) and two Talarias (2 clockwise, 3 counter-clockwise).
|
||||
// TA3, the Duel Longinus: two mismatched drives (0, 1) and two Rugged Drives (2 clockwise, 3 counter-clockwise).
|
||||
static float3[] Duel() => new[]
|
||||
{
|
||||
Col(0, 53.94f, 49.24f), Col(0, 61.19f, -55.86f), Col(29.08f, 0, 166.26f), Col(-21.80f, 0, -124.63f),
|
||||
};
|
||||
|
||||
// The clockwise Talaria lost.
|
||||
// The clockwise Rugged Drive lost.
|
||||
static float3[] DamagedDuel() => new[]
|
||||
{
|
||||
Col(0, 53.94f, 49.24f), Col(0, 61.19f, -55.86f), default, Col(-21.80f, 0, -124.63f),
|
||||
|
|
@ -137,7 +137,7 @@ public class ThrustAllocatorTests
|
|||
[Fact]
|
||||
public void TheOnsetMovesWithTheColumns()
|
||||
{
|
||||
// Clockwise Talaria lost: the drive serves a clockwise turn from the first touch.
|
||||
// Clockwise Rugged Drive lost: the drive serves a clockwise turn from the first touch.
|
||||
var damaged = DamagedDuel();
|
||||
var small = Solve(damaged, 0, 0, .01f);
|
||||
Assert.True(small[0] > 0, $"drive {small[0]}");
|
||||
|
|
@ -145,7 +145,7 @@ public class ThrustAllocatorTests
|
|||
var full = Solve(damaged, 0, 0, 1f);
|
||||
Assert.True(MathF.Abs(YawDeg(damaged, full) - 49.24f) <= 49.24f * 1e-3f, $"yaw {YawDeg(damaged, full)}");
|
||||
|
||||
// Clockwise Talaria halved: the onset is its new share of the clockwise extreme.
|
||||
// Clockwise Rugged Drive halved: the onset is its new share of the clockwise extreme.
|
||||
var halved = Duel();
|
||||
halved[2] = halved[2] * .5f;
|
||||
var onset = halved[2].z / Extremes(halved, 2).plus;
|
||||
|
|
|
|||
124
tests/mutation_tests_flow_parity.py
Normal file
124
tests/mutation_tests_flow_parity.py
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Mutation tests for the flow-shader-parity rule (campaign aetheria-fauna, cut fauna-flow-field).
|
||||
|
||||
Assets/Scripts/Editor/FlowFieldSceneVerify.cs opens ARPG.unity and drives VolumeSampling and Stardust as the game
|
||||
does (the keywords, the stardust buffer, CloudShader's keywords); each mutant below names the check that must catch it.
|
||||
Assets/Scripts/Editor/FlowFieldParityVerify.cs evaluates the HLSL globalFlow and slopeFlow
|
||||
(Assets/Shaders/Volumetric.cginc, through FlowParity.compute) and FlowField (ServerShared) for the
|
||||
same positions, scrolls, settings and gradients, after VolumeSampling.LowerFlow has lowered a stepped
|
||||
Zone's flow into the shader globals. Tests.asmdef cannot see Assembly-CSharp and the check needs a GPU,
|
||||
so it runs here, in Unity batchmode WITHOUT -nographics (see ShieldPanelCut3Verify.cs).
|
||||
|
||||
A control run proves the unmutated tree passes. Then each mutant edits the real source in one way a
|
||||
rule of the cut forbids, runs the check, asserts it goes red naming the check that owns the rule, and
|
||||
restores the file byte for byte. A mutant that fails for the wrong reason (a broken harness) cannot
|
||||
hide behind the control.
|
||||
|
||||
Run from the repo root: py -3 tests/mutation_tests_flow_parity.py [--only <label>[,<label>]]
|
||||
Exit code 0 only if the control passed and every mutant was caught for its reason. Run one Unity at a
|
||||
time: never start this while another Unity process is running.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
UNITY_EXE = r"C:\Program Files\Unity\Hub\Editor\6000.3.24f1\Editor\Unity.exe"
|
||||
|
||||
PARITY = "Aetheria.EditorTools.FlowFieldParityVerify.Run"
|
||||
SCENE = "Aetheria.EditorTools.FlowFieldSceneVerify.Run"
|
||||
STARDUST_COMPUTE = "Assets/Shaders/Compute/Stardust/Stardust.compute"
|
||||
PARITY_COMPUTE = "Assets/Shaders/Compute/FlowParity.compute"
|
||||
CLOUD_SHADER = "Assets/Shaders/Raymarching/CloudShader.shader"
|
||||
CGINC = "Assets/Shaders/Volumetric.cginc"
|
||||
VOLUME_SAMPLING = "Assets/Scripts/Zone Display/VolumeSampling.cs"
|
||||
FLOW_FIELD = "Assets/Scripts/ServerShared/FlowField.cs"
|
||||
SETTINGS_ASSET = "Assets/Resources/Settings.asset"
|
||||
|
||||
# (label, file, before, after, the failing check the probe must name)
|
||||
MUTANTS = [
|
||||
("hlsl-y-halving", CGINC, "flowSample.y *= .5;", "flowSample.y *= .6;", "global"),
|
||||
("hlsl-y-factor-501", CGINC, "flowSample.y *= .5;", "flowSample.y *= .501;", "global"),
|
||||
("hlsl-amplitude-1.0005", CGINC, "- float3(0,_FlowScroll.y,0) ) * _FlowAmplitude;", "- float3(0,_FlowScroll.y,0) ) * _FlowAmplitude * 1.0005;", "global"),
|
||||
("hlsl-scroll-sign", CGINC, "field - float3(0,_FlowScroll.x,0)", "field + float3(0,_FlowScroll.x,0)", "global"),
|
||||
("hlsl-scroll2-dropped", CGINC, "field * 1.61803398875 - float3(0,_FlowScroll.y,0)", "field * 1.61803398875", "global"),
|
||||
("hlsl-swirl-flipped", CGINC, "float3(ngrad.y, 0, -ngrad.x)", "float3(-ngrad.y, 0, ngrad.x)", "slope"),
|
||||
("hlsl-swirl-1.0005", CGINC, "float3(ngrad.y, 0, -ngrad.x) * _FlowSwirlAmplitude", "float3(ngrad.y, 0, -ngrad.x) * _FlowSwirlAmplitude * 1.0005", "slope"),
|
||||
("hlsl-zero-gradient-guard", CGINC, " if (dot(grad, grad) == 0) return 0;\n", "", "slope"),
|
||||
("lower-scroll-doubled", VOLUME_SAMPLING, "new Vector4(scroll.x, scroll.y)", "new Vector4(scroll.x * 2f, scroll.y)", "lowered-scroll"),
|
||||
("lower-scale-halved", VOLUME_SAMPLING, 'Shader.SetGlobalFloat("_FlowScale", flow.GlobalScale);', 'Shader.SetGlobalFloat("_FlowScale", flow.GlobalScale * .5f);', "lowered-settings"),
|
||||
("lower-frame-clock", VOLUME_SAMPLING, "FlowField.Scroll(flow, flowClock)", "FlowField.Scroll(flow, flowClock + Time.realtimeSinceStartup)", "lowered-scroll"),
|
||||
("lower-cycle-frame-clock", VOLUME_SAMPLING, "FlowField.Cycle(flowClock, flow.Period)", "FlowField.Cycle(Time.realtimeSinceStartup, flow.Period)", "lowered-cycle"),
|
||||
("lower-keywords-lookup-only", VOLUME_SAMPLING, 'GlobalKeyword.Create("FLOW_GLOBAL")', 'new GlobalKeyword("FLOW_GLOBAL")', "flow-keywords"),
|
||||
("csharp-scale-doubled", FLOW_FIELD, "var field = position / settings.GlobalScale;", "var field = position / (settings.GlobalScale * 2f);", "global"),
|
||||
("asset-amplitude", SETTINGS_ASSET, " GlobalAmplitude: 15\n", " GlobalAmplitude: 14\n", "authored-flow"),
|
||||
("hlsl-noise-frame-clock", CGINC, "_NebulaNoiseTime * _NebulaNoiseSpeed", "_Time.y * _NebulaNoiseSpeed", "nebula-noise-clock"),
|
||||
("parity-slope-pragma-removed", PARITY_COMPUTE, "#pragma multi_compile __ FLOW_SLOPE", "", "flow-keywords"),
|
||||
("scene-stardust-pragma-removed", STARDUST_COMPUTE, "#pragma multi_compile __ FLOW_GLOBAL", "", "scene-stardust", SCENE),
|
||||
("scene-cloud-include-without-pragmas", CLOUD_SHADER, '#include_with_pragmas "Assets/Shaders/Volumetric.cginc"', '#include "Assets/Shaders/Volumetric.cginc"', "scene-cloud-keywords", SCENE),
|
||||
("scene-keyword-in-field-initializer", VOLUME_SAMPLING, "static GlobalKeyword? _keywordFlowGlobal;", 'static GlobalKeyword? _keywordFlowGlobal = GlobalKeyword.Create("FLOW_GLOBAL");', "scene-presenter-exception", SCENE),
|
||||
("scene-noise-time-frame-clock", VOLUME_SAMPLING, '"_NebulaNoiseTime", (float) clock', '"_NebulaNoiseTime", Time.realtimeSinceStartup', "scene-noise-clock", SCENE),
|
||||
]
|
||||
|
||||
|
||||
def run_probe(log: Path, entry: str = PARITY) -> tuple[int, str]:
|
||||
log.unlink(missing_ok=True)
|
||||
proc = subprocess.run(
|
||||
[UNITY_EXE, "-batchmode", "-projectPath", str(REPO_ROOT),
|
||||
"-executeMethod", entry, "-logFile", str(log)],
|
||||
timeout=1800,
|
||||
)
|
||||
return proc.returncode, log.read_text(encoding="utf-8", errors="replace")
|
||||
|
||||
|
||||
def main() -> int:
|
||||
only = set()
|
||||
if "--only" in sys.argv:
|
||||
only = set(sys.argv[sys.argv.index("--only") + 1].split(","))
|
||||
scratch = REPO_ROOT / "tests" / "_scratch_flow_parity"
|
||||
scratch.mkdir(parents=True, exist_ok=True)
|
||||
failures: list[str] = []
|
||||
|
||||
for entry, name in ((PARITY, "FlowFieldParityVerify"), (SCENE, "FlowFieldSceneVerify")):
|
||||
print(f"\n=== control: unmutated tree, {name} ===")
|
||||
code, text = run_probe(scratch / f"control-{name}.log", entry)
|
||||
if code != 0 or f"[{name}] PASS" not in text:
|
||||
print("control FAILED: expected exit 0 and PASS on the unmutated tree")
|
||||
return 1
|
||||
print("control OK: exit 0, PASS")
|
||||
|
||||
for label, rel, before, after, check, *rest in MUTANTS:
|
||||
entry = rest[0] if rest else PARITY
|
||||
if only and label not in only:
|
||||
continue
|
||||
path = REPO_ROOT / rel
|
||||
original = path.read_bytes()
|
||||
text_in = original.decode("utf-8")
|
||||
newline = "\r\n" if "\r\n" in text_in else "\n"
|
||||
b, a = before.replace("\n", newline), after.replace("\n", newline)
|
||||
if text_in.count(b) != 1:
|
||||
failures.append(f"{label}: anchor occurs {text_in.count(b)} times in {rel}, expected exactly once")
|
||||
continue
|
||||
print(f"\n=== mutant {label} ({rel}) ===")
|
||||
try:
|
||||
path.write_bytes(text_in.replace(b, a).encode("utf-8"))
|
||||
code, text = run_probe(scratch / f"{label}.log", entry)
|
||||
finally:
|
||||
path.write_bytes(original)
|
||||
named = f"FAIL {check}" in text or f"-{check}:" in text
|
||||
if code != 0 and named:
|
||||
print(f"OK: caught, the probe named {check}")
|
||||
elif code != 0:
|
||||
failures.append(f"{label}: red, but not for {check} (compile error or another check)")
|
||||
else:
|
||||
failures.append(f"{label}: SURVIVED")
|
||||
|
||||
for f in failures:
|
||||
print("FAIL:", f)
|
||||
return 1 if failures else 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
|
|
@ -52,8 +52,10 @@ public static class Program
|
|||
Console.OutputEncoding = new System.Text.UTF8Encoding(false);
|
||||
return PiratesFaction(args.Contains("apply"));
|
||||
case "verse-grammar": return VerseGrammarCommand.Run(args.Contains("apply"));
|
||||
case "sensor-stat-set": return SensorStatSet(args.Contains("apply"));
|
||||
case "generic-designs": return GenericDesigns(args.Contains("apply"));
|
||||
default:
|
||||
Console.WriteLine("commands: census, factions, station-fit, hardpoint-fit, loadout [seed], save, settings, settings-dump, dangling [clear <Type.Member>]... [apply], shield-migrate [apply], brownout-migrate [apply], roles-migrate [apply], firing-arc-migrate [apply], range-falloff [apply] [--effective <fraction>] [--end <multiplier>], targeting-catalog [apply], targeting-catalog-6c [apply], targeting-catalog-6d [apply], ship-authoring create|inspect|validate|compose, field-kinds [apply], mine-launcher [apply], smoke-hull [apply], smoke-rounds [apply], roles-backfill [apply], pd-gear [apply], consumables-first-set [apply], launch-suppressor [apply], pirates-faction [apply], verse-grammar [apply]");
|
||||
Console.WriteLine("commands: census, factions, station-fit, hardpoint-fit, loadout [seed], save, settings, settings-dump, dangling [clear <Type.Member>]... [apply], shield-migrate [apply], brownout-migrate [apply], roles-migrate [apply], firing-arc-migrate [apply], range-falloff [apply] [--effective <fraction>] [--end <multiplier>], targeting-catalog [apply], targeting-catalog-6c [apply], targeting-catalog-6d [apply], ship-authoring create|inspect|validate|compose, field-kinds [apply], mine-launcher [apply], smoke-hull [apply], smoke-rounds [apply], roles-backfill [apply], pd-gear [apply], consumables-first-set [apply], launch-suppressor [apply], pirates-faction [apply], verse-grammar [apply], generic-designs [apply], sensor-stat-set [apply]");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -209,7 +211,7 @@ public static class Program
|
|||
{
|
||||
["Sensitivity"] = "receiver",
|
||||
["PingBoost"] = "emitter", ["PingEnergy"] = "emitter", ["PingRange"] = "emitter",
|
||||
["PingCooldown"] = "emitter",
|
||||
["PingCooldown"] = "emitter", ["InterceptFactor"] = "emission-discipline",
|
||||
};
|
||||
|
||||
private static readonly Dictionary<string, string> ThrusterRoles = new Dictionary<string, string>
|
||||
|
|
@ -235,10 +237,11 @@ public static class Program
|
|||
{
|
||||
["EnergyDraw"] = "heating element", ["Heat"] = "heating element",
|
||||
},
|
||||
["PotaT+-"] = new Dictionary<string, string>
|
||||
["Capacitor"] = new Dictionary<string, string>
|
||||
{
|
||||
["Capacity"] = "storage cell", ["Efficiency"] = "converter",
|
||||
},
|
||||
["Passive Array"] = new Dictionary<string, string> { ["Multiple"] = "receiver" },
|
||||
};
|
||||
|
||||
// One Mean / StandardDeviation per maker, applied to every role of a design the maker sells (catalog-growth
|
||||
|
|
@ -407,7 +410,7 @@ public static class Program
|
|||
private static (float Mean, float Dev, string Basis) AuthorProductRole(AetherDb db, FactionProductData product, string designName, string role)
|
||||
{
|
||||
var maker = db.Cache.Get(product.Manufacturer)?.Name;
|
||||
if (designName == "Arctica" && maker == "Alakrita" && role == "fins")
|
||||
if (designName == "Adaptive Radiator" && maker == "Alakrita" && role == "fins")
|
||||
return (.78f, .07f, "lore: Alakrita brands on heat efficiency (item-provenance-target.md)");
|
||||
|
||||
var hash = StableHash($"{product.Name}|{role}");
|
||||
|
|
@ -1236,10 +1239,10 @@ public static class Program
|
|||
var newDesigns = new (GearData Design, string ProductName, Faction Maker, string ProductDescription, (string Role, float Mean, float Dev)[] Roles)[]
|
||||
{
|
||||
(targetingComputer, "LockOn", FactionByShortName("NiteLife"),
|
||||
"Keeps the lights on your target. (new text)",
|
||||
"Keeps the lights on your target.",
|
||||
new[] { ("processor", .55f, .15f), ("array", .5f, .16f) }),
|
||||
(fireControlArray, "LockOn Pro", FactionByShortName("NiteLife"),
|
||||
"Same promise, sharper lock. (new text)",
|
||||
"Same promise, sharper lock.",
|
||||
new[] { ("processor", .72f, .12f), ("array", .68f, .13f) }),
|
||||
};
|
||||
|
||||
|
|
@ -1252,17 +1255,17 @@ public static class Program
|
|||
// outside this cut's brief).
|
||||
var existingDesigns = new (string DesignName, string ProductName, Faction Maker, string ProductDescription, (string Role, float Mean, float Dev)[] Roles)[]
|
||||
{
|
||||
("plight", "DragOnBreath", FactionByShortName("Lucent"),
|
||||
"The subsidiary plight's own description already namechecks: DragOnBreath, a Lucent Media property.",
|
||||
("Lightning Projector", "DragOnBreath", FactionByShortName("Lucent"),
|
||||
"Chain lightning has your enemies chain smoking while you enjoy a relaxing DragOnBreath vapepop, now available in 17! flavours (manufactured by DragOnBreath, a subsidary of Lucent Media)",
|
||||
new[] { ("focusing array", .7f, .13f), ("power coupling", .55f, .15f) }),
|
||||
("pswarm", "Leonid", FactionByShortName("AU"),
|
||||
("Swarm Rocket Pod", "Leonid", FactionByShortName("AU"),
|
||||
"A rain of pain that falls mainly on space planes.",
|
||||
new[] { ("guidance system", .65f, .14f), ("thruster", .63f, .15f), ("warhead", .7f, .13f) }),
|
||||
("Core Power", "Steadfast", FactionByShortName("R&D"),
|
||||
"Rated for continuous operation. \"Continuous\" does not imply \"uninterrupted.\" (new text)",
|
||||
("Compact Reactor", "Steadfast", FactionByShortName("R&D"),
|
||||
"It gets the job done, but that's all. Rated for continuous operation. \"Continuous\" does not imply \"uninterrupted.\"",
|
||||
new[] { ("core", .5f, .12f), ("regulator", .5f, .12f) }),
|
||||
("Large Drive", "True North", FactionByShortName("Lightsail"),
|
||||
"Gets your cargo there. Getting you there is your problem. (new text)",
|
||||
"Gets your cargo there. Getting you there is your problem.",
|
||||
Array.Empty<(string, float, float)>()),
|
||||
};
|
||||
|
||||
|
|
@ -1374,16 +1377,16 @@ public static class Program
|
|||
var newProducts = new (GearData Design, string ProductName, Faction Maker, string ProductDescription, (string Role, float Mean, float Dev)[] Roles)[]
|
||||
{
|
||||
(targetingComputer, "Panopticon", FactionByShortName("Finch"),
|
||||
"Sees everything, judges nothing. Well, mostly nothing. (new text)",
|
||||
"Sees everything, judges nothing. Well, mostly nothing.",
|
||||
new[] { ("processor", .5f, .13f), ("array", .58f, .12f) }),
|
||||
(fireControlArray, "Panopticon Prime", FactionByShortName("Finch"),
|
||||
"The upgrade nobody at Finch will admit they needed until they had it. (new text)",
|
||||
"The upgrade nobody at Finch will admit they needed until they had it.",
|
||||
new[] { ("processor", .68f, .11f), ("array", .75f, .10f) }),
|
||||
(targetingComputer, "ClapBack", FactionByShortName("Lucent"),
|
||||
"Your target won't clock it until the killcam. (new text)",
|
||||
"Your target won't clock it until the killcam.",
|
||||
new[] { ("processor", .6f, .16f), ("array", .48f, .15f) }),
|
||||
(fireControlArray, "ClapBack Ultra", FactionByShortName("Lucent"),
|
||||
"Now with main-character energy built in. (new text)",
|
||||
"Now with main-character energy built in.",
|
||||
new[] { ("processor", .78f, .14f), ("array", .65f, .13f) }),
|
||||
};
|
||||
|
||||
|
|
@ -1589,7 +1592,7 @@ public static class Program
|
|||
static void Set(PerformanceStat stat, float min, float max) { stat.Min = min; stat.Max = max; }
|
||||
static void Track(WeaponData data, float rate) => data.Tracking = new PerformanceStat { Min = rate, Max = rate, Terms = new List<StatTerm>() };
|
||||
|
||||
var gun = Copy(Template("ClearPath"), designNames[0], "Close-in defence gun: a hose of light rounds.", 40f, 80000, 60f, 1, 1, WeaponModifiers.RapidFire);
|
||||
var gun = Copy(Template("Light Machine Gun"), designNames[0], "Close-in defence gun: a hose of light rounds.", 40f, 80000, 60f, 1, 1, WeaponModifiers.RapidFire);
|
||||
var gunData = gun.Behaviors.OfType<InstantWeaponData>().Single();
|
||||
Set(gunData.Damage, 1.5f, 4f); Set(gunData.Range, 300f, 550f); Set(gunData.MinRange, 0f, 0f);
|
||||
Set(gunData.Cooldown, .06f, .025f); Set(gunData.Count, 1f, 1f); Set(gunData.Spread, 1f, .3f);
|
||||
|
|
@ -1597,14 +1600,14 @@ public static class Program
|
|||
gunData.AmmoType = db.Cache.RefOf(ammunition); gunData.MagazineSize = 250; gunData.ReloadTime = 3f;
|
||||
Track(gunData, 40f);
|
||||
|
||||
var laser = Copy(Template("Spectra"), designNames[1], "Close-in defence beam: quick, light, instant.", 30f, 110000, 30f, 1, 1, Template("Spectra").WeaponModifiers);
|
||||
var laser = Copy(Template("Light Laser"), designNames[1], "Close-in defence beam: quick, light, instant.", 30f, 110000, 30f, 1, 1, Template("Light Laser").WeaponModifiers);
|
||||
var laserData = laser.Behaviors.OfType<InstantWeaponData>().Single();
|
||||
Set(laserData.Damage, 5f, 12f); Set(laserData.Range, 400f, 750f); Set(laserData.MinRange, 0f, 0f);
|
||||
Set(laserData.Cooldown, .2f, .1f); Set(laserData.Count, 1f, 1f); Set(laserData.Spread, .05f, 0f);
|
||||
Set(laserData.Velocity, 0f, 0f); Set(laserData.Energy, 6f, 10f); Set(laserData.Heat, 300f, 150f); Set(laserData.Visibility, 300f, 100f);
|
||||
Track(laserData, 40f);
|
||||
|
||||
var flak = Copy(Template("DeathCluster"), designNames[2], "Small flak gun: a short-range pellet volley.", 120f, 180000, 80f, 1, 2, WeaponModifiers.Cluster);
|
||||
var flak = Copy(Template("Cluster Cannon"), designNames[2], "Small flak gun: a short-range pellet volley.", 120f, 180000, 80f, 1, 2, WeaponModifiers.Cluster);
|
||||
var flakData = flak.Behaviors.OfType<InstantWeaponData>().Single();
|
||||
Set(flakData.Damage, 30f, 70f); Set(flakData.Count, 6f, 8f); Set(flakData.Range, 350f, 800f); Set(flakData.MinRange, 0f, 0f);
|
||||
Set(flakData.Cooldown, .6f, .35f); Set(flakData.Spread, 4f, 2f); Set(flakData.Velocity, 900f, 1300f);
|
||||
|
|
@ -1674,6 +1677,172 @@ public static class Program
|
|||
return 0;
|
||||
}
|
||||
|
||||
private const string EmissionDiscipline = "emission-discipline";
|
||||
|
||||
// The intercept factor alpha is how far others hear a sensor against how far it sees: a quality-ranged stat from
|
||||
// .5 (loud) to 2 (quiet) whose midpoint quality .5 reads 1, so lerp(Min, Max, q^e) with e = log2(3). Brand flavour
|
||||
// lives in the product's emission-discipline quality (ruling sensor-stat-set): Lucent is low, Finch and Sol high,
|
||||
// every other maker middling. A maker with no profile of its own (Miss Terri's, the Pirates) keeps the deviation its
|
||||
// product already authored for the emitter role.
|
||||
private static float DisciplineMean(Faction maker) =>
|
||||
maker.ShortName == "Lucent" ? .2f : maker.ShortName == "Finch" || maker.ShortName == "Sol" || maker.Name == "Sol" ? .8f : .5f;
|
||||
|
||||
private static float MakerDeviation(Faction maker, FactionProductData product) =>
|
||||
MakerProfiles.TryGetValue(maker.ShortName ?? "", out var profile) ? profile.Dev
|
||||
: product.Roles.FirstOrDefault(r => r.Role == "emitter")?.StandardDeviation ?? throw new InvalidOperationException($"Product \"{product.Name}\" has no emitter spread to take a deviation from.");
|
||||
|
||||
// aetheria-release cut sensor-catalog (rulings sensor-stat-set, catalog-grows-generic-designs-branded-products): every
|
||||
// SensorData design's InterceptFactor becomes a quality-ranged stat reading the emission-discipline role, every
|
||||
// product of such a design authors that role, and the Passive Array (a generic listener gear, ListenerData) is
|
||||
// authored with two products from the stealth makers. Prints the sensor census first. Dry run unless passed
|
||||
// "apply"; idempotent, so a second apply writes nothing and a catalog another cut changed is rerun, never merged.
|
||||
private static int SensorStatSet(bool apply)
|
||||
{
|
||||
var db = AetherDb.Open(catalogWritable: apply);
|
||||
var designs = db.Cache.GetAll<EquippableItemData>().ToArray();
|
||||
var products = db.Cache.GetAll<FactionProductData>().ToArray();
|
||||
Faction MakerOf(FactionProductData p) => db.Cache.Get(p.Manufacturer);
|
||||
Faction Maker(string shortName) =>
|
||||
db.Cache.GetAll<Faction>().FirstOrDefault(f => f.ShortName == shortName) ?? throw new InvalidOperationException($"No faction with short name \"{shortName}\".");
|
||||
|
||||
var sensors = designs.Where(d => d.Behaviors != null && d.Behaviors.OfType<SensorData>().Any()).OrderBy(d => d.Name, StringComparer.Ordinal).ToArray();
|
||||
var listeners = designs.Where(d => d.Behaviors != null && d.Behaviors.OfType<ListenerData>().Any()).OrderBy(d => d.Name, StringComparer.Ordinal).ToArray();
|
||||
Console.WriteLine($"Census: {sensors.Length} sensor designs, {listeners.Length} listener designs.");
|
||||
foreach (var design in sensors.Concat(listeners))
|
||||
{
|
||||
var key = db.Cache.RefOf(design).Key;
|
||||
Console.WriteLine($" {design.Name} [{design.HardpointType}] roles [{string.Join(", ", (design.Roles ?? new List<ItemRole>()).Select(r => r.Name))}]");
|
||||
foreach (var product in products.Where(p => p.Design.Key.Equals(key)).OrderBy(p => p.Name, StringComparer.Ordinal))
|
||||
Console.WriteLine($" {product.Name} by {MakerOf(product)?.ShortName ?? "(none)"}: " + string.Join(", ", (product.Roles ?? new List<ProductRole>()).Select(r => $"{r.Role} {r.Mean:0.00}±{r.StandardDeviation:0.00}")));
|
||||
}
|
||||
foreach (var consumable in db.Cache.GetAll<ConsumableItemData>().Where(c => c.Behaviors != null && c.Behaviors.OfType<SensorData>().Any()).OrderBy(c => c.Name, StringComparer.Ordinal))
|
||||
Console.WriteLine($" consumable {consumable.Name} carries SensorData; consumables are not catalog sensor designs and keep their alpha");
|
||||
|
||||
var changedDesigns = new List<(object Document, CultRecordKey Key)>();
|
||||
var changedProducts = new List<(object Document, CultRecordKey Key)>();
|
||||
var exponent = MathF.Log2(3f);
|
||||
foreach (var design in sensors)
|
||||
{
|
||||
var key = db.Cache.RefOf(design).Key;
|
||||
var designChanged = false;
|
||||
foreach (var sensor in design.Behaviors.OfType<SensorData>())
|
||||
{
|
||||
var stat = sensor.InterceptFactor;
|
||||
var current = stat != null && stat.Min == .5f && stat.Max == 2f && stat.Terms != null && stat.Terms.Count == 1
|
||||
&& stat.Terms[0].Source == StatSource.Quality && stat.Terms[0].Role == EmissionDiscipline && stat.Terms[0].Exponent == exponent;
|
||||
if (current) continue;
|
||||
sensor.InterceptFactor = new PerformanceStat { Min = .5f, Max = 2f, Terms = new List<StatTerm> { new StatTerm { Source = StatSource.Quality, Exponent = exponent, Role = EmissionDiscipline } } };
|
||||
designChanged = true;
|
||||
}
|
||||
design.Roles ??= new List<ItemRole>();
|
||||
if (!design.Roles.Any(r => r.Name == EmissionDiscipline)) { design.Roles.Add(new ItemRole { Name = EmissionDiscipline }); designChanged = true; }
|
||||
if (designChanged) changedDesigns.Add((design, key));
|
||||
foreach (var product in products.Where(p => p.Design.Key.Equals(key)))
|
||||
{
|
||||
var maker = MakerOf(product) ?? throw new InvalidOperationException($"Product \"{product.Name}\" has no maker.");
|
||||
product.Roles ??= new List<ProductRole>();
|
||||
var mean = DisciplineMean(maker);
|
||||
var dev = MakerDeviation(maker, product);
|
||||
var existing = product.Roles.FirstOrDefault(r => r.Role == EmissionDiscipline);
|
||||
if (existing != null && existing.Mean == mean && existing.StandardDeviation == dev) continue;
|
||||
if (existing != null) { existing.Mean = mean; existing.StandardDeviation = dev; }
|
||||
else product.Roles.Add(new ProductRole { Role = EmissionDiscipline, Mean = mean, StandardDeviation = dev });
|
||||
changedProducts.Add((product, db.Cache.RefOf(product).Key));
|
||||
}
|
||||
}
|
||||
|
||||
// The catalog sells two sensor designs, one branded by DME and one by Miss Terri's, and no Lucent or Finch sensor at all,
|
||||
// so the brand flavour has nothing to vary across: each design gains a loud Lucent and a quiet Finch product
|
||||
// (ruling catalog-grows-generic-designs-branded-products). Every role of the design is authored at the maker's profile,
|
||||
// emission-discipline at the maker's flavour.
|
||||
var sensorProducts = new (string Design, string Name, string Maker, string Description)[]
|
||||
{
|
||||
("Sensor Array", "Floodlight", "Lucent", "Sees everything and tells everything. Lucent never saw the point of subtle."),
|
||||
("Sensor Array", "Pinion", "Finch", "A listening ear with a whisper of a voice. Finch sensors are heard last and heard least."),
|
||||
("Compact Sensor", "Beacon", "Lucent", "If it can see you, you can see it. That is called fairness."),
|
||||
("Compact Sensor", "Kestrel", "Finch", "Hangs in the dark and looks down. The prey rarely notices."),
|
||||
};
|
||||
var newProducts = new List<(EquippableItemData Design, string Name, Faction Maker, string Description)>();
|
||||
foreach (var (designName, name, makerName, description) in sensorProducts)
|
||||
{
|
||||
if (products.Any(p => p.Name == name)) continue;
|
||||
var design = sensors.Single(s => s.Name == designName);
|
||||
newProducts.Add((design, name, Maker(makerName), description));
|
||||
}
|
||||
|
||||
// The Passive Array takes its thermal envelope and sound from a sensor gear, then becomes a Tool listener.
|
||||
GearData array = null;
|
||||
var arrayProducts = new List<(string Name, string Maker, string Description)>();
|
||||
if (listeners.Length == 0)
|
||||
{
|
||||
var template = sensors.OfType<GearData>().FirstOrDefault() ?? throw new InvalidOperationException("No sensor gear to take the Passive Array's thermal envelope from.");
|
||||
var options = CultDocumentMessagePackSerialization.OptionsFor(typeof(GearData).Assembly);
|
||||
array = MessagePackSerializer.Deserialize<GearData>(MessagePackSerializer.Serialize(template, options), options);
|
||||
array.Name = "Passive Array";
|
||||
array.Description = "Passive listening gear. Hears every emitter at a multiple of its own reach, giving a bearing only and no track. Emits nothing.";
|
||||
array.Hardpoint = HardpointType.Tool;
|
||||
array.Mass = 20f; array.Price = 60000; array.Durability = 30f;
|
||||
array.Shape = new Shape(1, 1);
|
||||
array.Shape.Cells[0, 0] = true;
|
||||
array.Behaviors = new List<BehaviorData>
|
||||
{
|
||||
new EnergyDrawData { EnergyDraw = new PerformanceStat { Min = 10f, Max = 10f, Terms = new List<StatTerm>() }, PerSecond = true },
|
||||
new ListenerData { Multiple = new PerformanceStat { Min = 2f, Max = 3f, Terms = new List<StatTerm> { new StatTerm { Source = StatSource.Quality, Exponent = 1f, Role = "receiver" } } } },
|
||||
};
|
||||
array.Roles = new List<ItemRole> { new ItemRole { Name = "receiver" } };
|
||||
arrayProducts.Add(("Murmur", "Finch", "Quiet as its name, and about as easy to notice. Hears a shout from the next sector over."));
|
||||
arrayProducts.Add(("Wallflower", "NiteLife", "Stands in the corner of your hull and takes notes on everyone's business."));
|
||||
foreach (var (name, maker, description) in arrayProducts) Maker(maker);
|
||||
Console.WriteLine($"\nNew design: Passive Array [Tool] 1x1, EnergyDraw 10/s, Multiple 2-3 reading receiver; products {string.Join(", ", arrayProducts.Select(p => $"{p.Name} by {p.Maker}"))}");
|
||||
}
|
||||
|
||||
Console.WriteLine($"\nIntercept factor: {changedDesigns.Count} designs and {changedProducts.Count} products to change, {newProducts.Count} sensor products to add; Passive Array {(array == null ? "already authored" : "to author")}.");
|
||||
if (changedDesigns.Count == 0 && changedProducts.Count == 0 && newProducts.Count == 0 && array == null)
|
||||
{
|
||||
Console.WriteLine("Sensor stats are already authored; nothing to do.");
|
||||
return 0;
|
||||
}
|
||||
if (!apply)
|
||||
{
|
||||
Console.WriteLine("Dry run. Pass \"apply\" to write them.");
|
||||
return 0;
|
||||
}
|
||||
if (array != null) CultRecordRefs.Validate(array);
|
||||
db.Cache.Commit(batch =>
|
||||
{
|
||||
foreach (var (document, key) in changedDesigns) batch.Upsert(document.GetType(), document, key);
|
||||
foreach (var (document, key) in changedProducts) batch.Upsert(document.GetType(), document, key);
|
||||
foreach (var (design, name, maker, description) in newProducts)
|
||||
{
|
||||
var (profileMean, profileDev) = MakerProfiles[maker.ShortName];
|
||||
batch.Upsert(typeof(FactionProductData), new FactionProductData
|
||||
{
|
||||
Name = name, Description = description,
|
||||
Design = new CultRecordRef<CraftedItemData>(db.Cache.RefOf(design).Key),
|
||||
Manufacturer = db.Cache.RefOf(maker),
|
||||
Roles = design.Roles.Select(r => r.Name == EmissionDiscipline
|
||||
? new ProductRole { Role = r.Name, Mean = DisciplineMean(maker), StandardDeviation = profileDev }
|
||||
: new ProductRole { Role = r.Name, Mean = profileMean, StandardDeviation = profileDev }).ToList(),
|
||||
});
|
||||
}
|
||||
if (array == null) return;
|
||||
var arrayKey = batch.Upsert(typeof(GearData), array);
|
||||
foreach (var (name, maker, description) in arrayProducts)
|
||||
{
|
||||
var (mean, dev) = MakerProfiles[maker];
|
||||
batch.Upsert(typeof(FactionProductData), new FactionProductData
|
||||
{
|
||||
Name = name, Description = description,
|
||||
Design = new CultRecordRef<CraftedItemData>(arrayKey),
|
||||
Manufacturer = db.Cache.RefOf(Maker(maker)),
|
||||
Roles = array.Roles.Select(r => new ProductRole { Role = r.Name, Mean = mean, StandardDeviation = dev }).ToList(),
|
||||
});
|
||||
}
|
||||
});
|
||||
Console.WriteLine($"Landed {changedDesigns.Count} designs, {changedProducts.Count} products changed and {newProducts.Count} added{(array == null ? "" : ", the Passive Array and its products")} in Aetheria.cc");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// aetheria-release cut scenarios-smoke (rulings weapon-feel-to-smoke-cut-test-hull, test-hull-both-flanks): the
|
||||
// Smoke Test Hull, a copy of the Longinus hull that no product sells, so no generated ship, station or shop offers
|
||||
// it and only a scenario fits it. It adds what no shipped ship hull has, where the Longinus runs out of cells: two
|
||||
|
|
@ -1781,11 +1950,11 @@ public static class Program
|
|||
weapon.Range = Fixed(20f);
|
||||
}
|
||||
|
||||
var proximity = Copy("Spectra", names[0], "A Spectra that bursts by proximity, blast 8. For scenarios; no one builds it.", WeaponFuse.Proximity, 8f);
|
||||
var delayed = Copy("Spectra", names[1], "A Spectra that bursts after two cells of metal, blast 4. For scenarios; no one builds it.", WeaponFuse.Delayed, 4f);
|
||||
var refused = Copy("Spectra", names[2], "A Spectra whose blast is wider than its reach, so it never fires. For scenarios; no one builds it.", WeaponFuse.Proximity, 30f);
|
||||
var charge = Copy("ChargeBlast SG", names[4], "A ChargeBlast SG whose blast is wider than its reach, so it never charges. For scenarios; no one builds it.", WeaponFuse.Proximity, 30f);
|
||||
var beam = Copy("Spectra", names[3], "A constant beam whose blast is wider than its reach, so it never starts. For scenarios; no one builds it.", WeaponFuse.Proximity, 30f);
|
||||
var proximity = Copy("Light Laser", names[0], "A Light Laser that bursts by proximity, blast 8. For scenarios; no one builds it.", WeaponFuse.Proximity, 8f);
|
||||
var delayed = Copy("Light Laser", names[1], "A Light Laser that bursts after two cells of metal, blast 4. For scenarios; no one builds it.", WeaponFuse.Delayed, 4f);
|
||||
var refused = Copy("Light Laser", names[2], "A Light Laser whose blast is wider than its reach, so it never fires. For scenarios; no one builds it.", WeaponFuse.Proximity, 30f);
|
||||
var charge = Copy("Charged Scatter Blaster", names[4], "A Charged Scatter Blaster whose blast is wider than its reach, so it never charges. For scenarios; no one builds it.", WeaponFuse.Proximity, 30f);
|
||||
var beam = Copy("Light Laser", names[3], "A constant beam whose blast is wider than its reach, so it never starts. For scenarios; no one builds it.", WeaponFuse.Proximity, 30f);
|
||||
|
||||
// The Smoke Test Hull carries one 2x2 reactor. A Spectra's 20-40 energy a shot at its cadence is more than that reactor makes,
|
||||
// so two of them overload it, it overheats and shuts down within a second, and nothing aboard fires again (Fused Rounds,
|
||||
|
|
@ -1954,8 +2123,8 @@ public static class Program
|
|||
// no non-flat stat reads; DeathCluster, Flak Gun, GT 3K, plight and the two MoveOnPros because each had a non-flat stat
|
||||
// whose Quality term named no role (CB-R1: each non-flat stat reads exactly one declared role). Idempotent: a design with
|
||||
// no flat mapped stat and no unnamed one is left alone, a product with a role is left alone. Dry run unless passed "apply".
|
||||
private static readonly string[] BackfillDesigns = { "Autocannon", "LRMM72", "SRMM72", "Mine Launcher", "Large Drive", "Small Drive",
|
||||
"DeathCluster", "Flak Gun", "GT 3K", "plight", "MoveOnPro", "MoveOnPro Station Reactor" };
|
||||
private static readonly string[] BackfillDesigns = { "Autocannon", "Long-Range Missile Rack", "Short-Range Missile Rack", "Mine Launcher", "Large Drive", "Small Drive",
|
||||
"Cluster Cannon", "Flak Gun", "Guided Missile Launcher", "Lightning Projector", "Muon Fusion Reactor", "Muon Fusion Station Reactor" };
|
||||
|
||||
// Stats the backfill names but never ranges: a shot count is whole, and which way a launcher's MinRange should fall is
|
||||
// each design's own call (GT 3K authors it as a cost already).
|
||||
|
|
@ -2119,13 +2288,13 @@ public static class Program
|
|||
var rebrands = new (string Design, string Name, string Description)[]
|
||||
{
|
||||
("Autocannon", "\U0001FAF3\U0001F52B", "Serial number filed off. Still shoots."),
|
||||
("Earp", "\U0001FAA6\U0001F920", "The previous owner had no further use for it."),
|
||||
("FastBlast+-", "\U0001F9FE\U0001F6AB", "Warranty void where prohibited, which is everywhere."),
|
||||
("6k Shooter", "\U0001F3A8\U0001F648", "The logo underneath is somebody else's problem."),
|
||||
("scorched void policy", "\U0001F525", "Turns out we did start the fire after all."),
|
||||
("Long Slug Rifle", "\U0001FAA6\U0001F920", "The previous owner had no further use for it."),
|
||||
("Cell Blaster", "\U0001F9FE\U0001F6AB", "Warranty void where prohibited, which is everywhere."),
|
||||
("Slug Rifle", "\U0001F3A8\U0001F648", "The logo underneath is somebody else's problem."),
|
||||
("Incendiary Rocket Pod", "\U0001F525", "Turns out we did start the fire after all."),
|
||||
("Targeting Computer", "\U0001F440\U0001F3AF", "Somebody else's eyes. They still work."),
|
||||
("Small Drive", "\U0001F511\U0001F3C3\U0001F4A8", "Hotwired. Do not ask about the ignition."),
|
||||
("Store-All Plus", "\U0001F4E6\U0001F92B", "Contents not as declared."),
|
||||
("Cargo Bay", "\U0001F4E6\U0001F92B", "Contents not as declared."),
|
||||
};
|
||||
|
||||
var products = rebrands.Select(r =>
|
||||
|
|
@ -2314,6 +2483,238 @@ public static class Program
|
|||
return 0;
|
||||
}
|
||||
|
||||
// generic-designs: the rename, brand and product-text tables (map: "Generic design names", "Content: brands, flavour and
|
||||
// functional text"). Public so the command test reads the same rows the command writes.
|
||||
public const string AuthoringNote = " (new text)";
|
||||
|
||||
public static readonly (string Old, string Generic, string Functional)[] Renames =
|
||||
{
|
||||
("ClearPath", "Light Machine Gun", "Light ballistic hose: many small rounds at short range."),
|
||||
("6k Shooter", "Slug Rifle", "Single heavy slugs, fired as fast as the trigger."),
|
||||
("Earp", "Long Slug Rifle", "A lighter slug rifle with the longest ballistic reach."),
|
||||
("DeathCluster", "Cluster Cannon", "Medium shotgun: a heavy volley of pellets."),
|
||||
("pretty pretty bang bang", "Charged Scattergun", "Ballistic shotgun that charges for a heavier volley."),
|
||||
("Spectra", "Light Laser", "The lightest beam: low damage, quick cycle, long reach."),
|
||||
("FastBlast+-", "Cell Blaster", "Rapid energy bursts fed by cells that cut its reactor draw."),
|
||||
("ColdFire", "Long Laser", "Heavy small beam: slow, hard-hitting, long reach."),
|
||||
("CShot RainbowLite Lazer", "Heavy Beam Laser", "The heaviest beam: nine cells, enormous damage and reach."),
|
||||
("ChargeBlast+-", "Charged Blaster", "One charged knockout shot."),
|
||||
("ChargeBlast SG", "Charged Scatter Blaster", "Charged energy shotgun."),
|
||||
("plight", "Lightning Projector", "Charged chain lightning."),
|
||||
("GT 3K", "Guided Missile Launcher", "Fires guided missiles."),
|
||||
("LRMM72", "Long-Range Missile Rack", "Large missile rack for long engagements."),
|
||||
("SRMM72", "Short-Range Missile Rack", "Extra-large rack of short-range missiles."),
|
||||
("pswarm", "Swarm Rocket Pod", "Dumbfire rockets in a swarm."),
|
||||
("scorched void policy", "Incendiary Rocket Pod", "Incendiary dumbfire rockets."),
|
||||
("Arctica", "Adaptive Radiator", "Radiator whose output scales widely with conditions."),
|
||||
("Iapyx", "Radiator", "Standard two-cell radiator."),
|
||||
("Skiron", "Long Radiator", "Four-cell radiator with a large surface."),
|
||||
("OK Disperser", "Heat Pump", "Moves heat to where it can be shed."),
|
||||
("cold like my heart", "Cryogenic Heat Pump", "Heavy heat pump that drives temperatures far down."),
|
||||
("Core Power", "Compact Reactor", "Small reactor."),
|
||||
("Manhattan", "Heavy Reactor", "Large three-by-three reactor."),
|
||||
("Notorious", "High-Yield Reactor", "Large reactor with a wide output range."),
|
||||
("Vulcan", "Ring Reactor", "Ring-shaped reactor, four by four."),
|
||||
("MoveOnPro", "Muon Fusion Reactor", "Compact fusion reactor that draws a reservoir."),
|
||||
("Core Power Station Reactor", "Station Reactor", "A reactor sized for a station's core."),
|
||||
("Manhattan Station Reactor", "Heavy Station Reactor", "A heavy reactor sized for a station's core."),
|
||||
("Notorious Station Reactor", "High-Yield Station Reactor", "A high-yield reactor sized for a station's core."),
|
||||
("Vulcan Station Reactor", "Ring Station Reactor", "A ring reactor sized for a station's core."),
|
||||
("MoveOnPro Station Reactor", "Muon Fusion Station Reactor", "A muon fusion reactor sized for a station's core."),
|
||||
("RevvITup 2.0", "High-Thrust Drive", "Large drive: huge thrust, little torque."),
|
||||
("deep space burnout", "Burn Drive", "Large drive that runs very hot."),
|
||||
("Talaria", "Rugged Drive", "Two-cell working drive."),
|
||||
("Victoire", "Racing Drive", "Feather-light two-cell drive with extreme response."),
|
||||
("The Bat", "Sensor Array", "Two-by-two long-range sensor array."),
|
||||
("not if i see you first", "Compact Sensor", "One-cell sensor."),
|
||||
("PotaT+-", "Capacitor", "Stores charge for burst draw."),
|
||||
("SafeStuff II", "Secure Cargo Bay", "Three-by-three secured hold."),
|
||||
("Store-All Enterprise Edition", "Large Cargo Bay", "Six-by-six hold."),
|
||||
("Store-All Plus", "Cargo Bay", "Two-by-two hold."),
|
||||
("Store-All Plus Mini", "Small Cargo Bay", "One-cell hold."),
|
||||
};
|
||||
|
||||
public static readonly (string Design, string Maker, string OldProduct, string Brand, string Text, string DesignText)[] Brands =
|
||||
{
|
||||
("Autocannon", "Zhestokost", "Autocannon", "Hammerfall",
|
||||
"The rounds fall steadily, and they do not stop until the work is done.",
|
||||
"Belt-fed cannon: a steady stream of rounds at long reach."),
|
||||
("Cockpit 2x2", "Lightsail", "Cockpit 2x2", "Wheelhouse",
|
||||
"Every Lightsail captain's favourite chair. The view comes standard.",
|
||||
"Two-by-two crew cockpit."),
|
||||
("Industrial Thermostatic Heater", "Lightsail", "Industrial Thermostatic Heater", "Hearth",
|
||||
"A warm hold, a warm crew, and a warm welcome at the cold end of the run.",
|
||||
"Turns reactor power into heat to keep the hull warm."),
|
||||
("Medium Drive", "Lightsail", "Medium Drive", "Steady Haul",
|
||||
"Keeps you going and going and going...",
|
||||
"Mid-sized working drive."),
|
||||
("Small Drive", "Lightsail", "Small Drive", "Short Hop",
|
||||
"Dock to dock, and not a metre further than the manifest says.",
|
||||
"Small working drive."),
|
||||
("Turret Control Module", "AU", "Turret Control Module", "Watchtower",
|
||||
"Point it at the dark and get back to work. It keeps watch.",
|
||||
"Control module for a station turret."),
|
||||
("Medium Docking Bay", "AU", "Medium Docking Bay", "Open Berth",
|
||||
"Room for a friend, a customer or a tug. We don't ask which.",
|
||||
"Docking bay for mid-sized ships."),
|
||||
("Mine Launcher", "DME", "Mine Launcher", "parting gift",
|
||||
"we were never here/ but we left you something/ it's waiting where we were",
|
||||
"Lays a drifting proximity mine that arms after two seconds."),
|
||||
};
|
||||
|
||||
public static readonly (string Product, string Maker, string Text)[] ProductTexts =
|
||||
{
|
||||
("Victoire", "Alakrita",
|
||||
"The most responsive thruster on the market, for the most irresponsible of racing pilots."),
|
||||
("DragOnBreath", "Lucent",
|
||||
"Chain lightning has your enemies chain smoking while you enjoy a relaxing DragOnBreath vapepop, now available in 17! flavours (manufactured by DragOnBreath, a subsidary of Lucent Media)"),
|
||||
("Steadfast", "R&D",
|
||||
"It gets the job done, but that's all. Rated for continuous operation. \"Continuous\" does not imply \"uninterrupted.\""),
|
||||
("Steadfast Station", "R&D",
|
||||
"Rated for continuous operation at station scale. The fine print scales too."),
|
||||
("Manhattan Station", "Zhestokost",
|
||||
"A fortress needs a furnace. This is the furnace."),
|
||||
("Notorious Station", "Lucent",
|
||||
"The biggest reaction in the system, and everyone docked here will hear about it."),
|
||||
("Vulcan Station", "AU",
|
||||
"Keeps the lights on and the forges hot."),
|
||||
("MoveOnPro Station", "NiteLife",
|
||||
"The club never closes. Neither does the reactor."),
|
||||
("LRMM72", "R&D",
|
||||
"Engages targets at up to seventy-two kilometres!* *In a vacuum, against a cooperative target."),
|
||||
("SRMM72", "DME",
|
||||
"seventy-two reasons/ to keep your distance/ all of them leaving at once"),
|
||||
("Iapyx", "AU",
|
||||
"Two cells of honest fin. Bolt it on and forget it's there."),
|
||||
("Skiron", "AU",
|
||||
"When the job runs hot, run a bigger fin."),
|
||||
("Talaria", "AU",
|
||||
"Takes a knock, keeps pushing. Built for crews who work for a living."),
|
||||
("RevvITup 2.0", "NiteLife",
|
||||
"Floor it. The bass drops when you do."),
|
||||
("PotaT+-", "NiteLife",
|
||||
"Holds the charge until the drop, then lets it all go at once."),
|
||||
("not if i see you first", "DME",
|
||||
"eyes in the dark/ you were seen before you looked/ say goodnight"),
|
||||
("Space Tractor", "Ewan Hart",
|
||||
"It's a tractor. In space. Trap your enemies in gravity wells. Haul thousands of tons of hay through space!"),
|
||||
};
|
||||
|
||||
// Designs whose text was flavour or named a brand, rewritten as tech-node text without a rename (ruling designs-are-tech-nodes).
|
||||
// The Large Drive's old line ships as Steady Haul's text; the Tractor Beam's moves to its product, Space Tractor (ProductTexts).
|
||||
public static readonly (string Design, string Text)[] DesignTexts =
|
||||
{
|
||||
("Large Drive", "Large working drive."),
|
||||
("Tractor Beam", "Holds a target in a gravity well and hauls it in."),
|
||||
("Smoke Proximity", "A Light Laser that bursts by proximity, blast 8. For scenarios; no one builds it."),
|
||||
("Smoke Delayed", "A Light Laser that bursts after two cells of metal, blast 4. For scenarios; no one builds it."),
|
||||
("Smoke Refused", "A Light Laser whose blast is wider than its reach, so it never fires. For scenarios; no one builds it."),
|
||||
("Smoke Refused Charge", "A Charged Scatter Blaster whose blast is wider than its reach, so it never charges. For scenarios; no one builds it."),
|
||||
};
|
||||
|
||||
// generic-designs: a design is named and described like a node on a tech tree, and the brand lives in the product it
|
||||
// sells (rulings catalog-grows-generic-designs-branded-products, kitchen-sink-content, designs-are-tech-nodes). A
|
||||
// Renames row renames the design found under its old name and gives it the functional text; a Brands row renames the
|
||||
// maker's same-named product and sets its text and the design's functional text; ProductTexts sets the rest; every
|
||||
// shipped product text ending in the authoring note loses it. Dry run unless passed "apply".
|
||||
public static int GenericDesigns(bool apply, string root = null)
|
||||
{
|
||||
var db = AetherDb.Open(catalogWritable: apply, root: root);
|
||||
var designs = db.Cache.GetAll<EquippableItemData>().ToArray();
|
||||
var products = db.Cache.GetAll<FactionProductData>().ToArray();
|
||||
string MakerOf(FactionProductData product) => db.Cache.Get(product.Manufacturer)?.ShortName;
|
||||
var changed = new List<(object Document, CultRecordKey Key)>();
|
||||
var report = new List<string>();
|
||||
|
||||
void Write(object document, string what, string before, string after)
|
||||
{
|
||||
if (!changed.Any(c => ReferenceEquals(c.Document, document))) changed.Add((document, db.Cache.RefOf(document).Key));
|
||||
report.Add($"{what}: \"{before}\" -> \"{after}\"");
|
||||
}
|
||||
|
||||
foreach (var (old, generic, functional) in Renames)
|
||||
{
|
||||
var found = designs.Where(d => d.Name == old).ToArray();
|
||||
var held = designs.Where(d => d.Name == generic).ToArray();
|
||||
if (found.Length == 0 && held.Length == 0) throw new InvalidOperationException($"Rename row \"{old}\" -> \"{generic}\": no design carries either name.");
|
||||
if (found.Length == 0) continue;
|
||||
if (held.Length != 0) throw new InvalidOperationException($"Rename row \"{old}\" -> \"{generic}\": the generic name is already held by another design.");
|
||||
if (found.Length != 1) throw new InvalidOperationException($"Rename row \"{old}\" -> \"{generic}\": {found.Length} designs carry the old name.");
|
||||
var design = found[0];
|
||||
Write(design, "design name", design.Name, generic);
|
||||
design.Name = generic;
|
||||
if (design.Description != functional) Write(design, $"design \"{generic}\" text", design.Description, functional);
|
||||
design.Description = functional;
|
||||
}
|
||||
|
||||
foreach (var (designName, maker, oldProduct, brand, text, designText) in Brands)
|
||||
{
|
||||
var found = designs.Where(d => d.Name == designName).ToArray();
|
||||
if (found.Length != 1) throw new InvalidOperationException($"Brand row \"{brand}\": {found.Length} designs are named \"{designName}\".");
|
||||
var design = found[0];
|
||||
var key = db.Cache.RefOf(design).Key;
|
||||
var sold = products.Where(p => p.Design.Key.Equals(key) && MakerOf(p) == maker).ToArray();
|
||||
var product = sold.FirstOrDefault(p => p.Name == brand) ?? sold.FirstOrDefault(p => p.Name == oldProduct);
|
||||
if (product == null) throw new InvalidOperationException($"Brand row \"{brand}\": {maker} sells no product of \"{designName}\" under either name.");
|
||||
if (product.Name == brand) continue;
|
||||
if (products.Any(p => !ReferenceEquals(p, product) && p.Name == brand)) throw new InvalidOperationException($"Brand row \"{brand}\": the brand is already held by another product.");
|
||||
Write(product, $"product of \"{designName}\" by {maker}", product.Name, brand);
|
||||
product.Name = brand;
|
||||
Write(product, $"product \"{brand}\" text", product.Description, text);
|
||||
product.Description = text;
|
||||
if (design.Description != designText) Write(design, $"design \"{designName}\" text", design.Description, designText);
|
||||
design.Description = designText;
|
||||
}
|
||||
|
||||
foreach (var (designName, text) in DesignTexts)
|
||||
{
|
||||
var found = designs.Where(d => d.Name == designName).ToArray();
|
||||
if (found.Length != 1) throw new InvalidOperationException($"Design text row \"{designName}\": {found.Length} designs carry the name.");
|
||||
if (found[0].Description == text) continue;
|
||||
Write(found[0], $"design \"{designName}\" text", found[0].Description, text);
|
||||
found[0].Description = text;
|
||||
}
|
||||
|
||||
foreach (var (name, maker, text) in ProductTexts)
|
||||
{
|
||||
var found = products.Where(p => p.Name == name && MakerOf(p) == maker).ToArray();
|
||||
if (found.Length != 1) throw new InvalidOperationException($"Product text row \"{name}\" by {maker}: {found.Length} products match.");
|
||||
if (found[0].Description == text) continue;
|
||||
Write(found[0], $"product \"{name}\" text", found[0].Description, text);
|
||||
found[0].Description = text;
|
||||
}
|
||||
|
||||
foreach (var product in products.Where(p => p.Description != null && p.Description.EndsWith(AuthoringNote, StringComparison.Ordinal)))
|
||||
{
|
||||
var stripped = product.Description.Substring(0, product.Description.Length - AuthoringNote.Length);
|
||||
Write(product, $"product \"{product.Name}\" authoring note stripped", product.Description, stripped);
|
||||
product.Description = stripped;
|
||||
}
|
||||
|
||||
if (changed.Count == 0)
|
||||
{
|
||||
Console.WriteLine("Already applied; nothing to do.");
|
||||
return 0;
|
||||
}
|
||||
foreach (var line in report) Console.WriteLine(line);
|
||||
if (!apply)
|
||||
{
|
||||
Console.WriteLine($"\nDry run. Pass \"apply\" to write {changed.Count} records.");
|
||||
return 0;
|
||||
}
|
||||
foreach (var (document, _) in changed) CultRecordRefs.Validate(document);
|
||||
// ExpectUnchanged lands the batch onto the file as it is: every record the command did not author keeps the bytes it has,
|
||||
// where a plain commit would re-encode the whole catalog through today's types.
|
||||
if (!db.Cache.Commit(batch =>
|
||||
{
|
||||
batch.ExpectUnchanged();
|
||||
foreach (var (document, key) in changed) batch.Upsert(document.GetType(), document, key);
|
||||
}))
|
||||
throw new InvalidOperationException("The catalog changed while the generic designs were being authored; nothing was written. Run it again.");
|
||||
Console.WriteLine($"\nWrote {changed.Count} records to Aetheria.cc");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// aetheria-ew cut ew-hide-launch-catalog (rulings ew-suppressor-strength-ruled, ew-suppressor-makers-ruled,
|
||||
// ew-mild-suppressor-makers-defaulted): two launch suppressors on the Tool hardpoint, one helper for both. The strong
|
||||
// Launch Suppressor hides a launch from its own target and gives out after an opening volley; the mild Launch Baffle
|
||||
|
|
|
|||
Loading…
Reference in a new issue