using System; using System.Collections.Generic; using System.Net; using System.Threading.Tasks; using Godot; using RustToDust.Core; using RustToDust.Net; using RustToDust.Ymir; namespace RustToDust.Client.Tests; /// /// Headless & Vulkan Forward+ Godot smoke test: instantiates Main, drives 60 frames with throttle + fire + crater stamp, /// verifies terrain tile baking and Ymir physics integration, and exits with code 0 on pass. /// godot --headless --path client res://tests/Smoke.tscn /// public partial class Smoke : Node { private const double WatchdogSeconds = 90.0; private readonly List _failures = new(); private Main _main = null!; private bool _done; public override void _Ready() => _ = RunAsync(); public override void _Process(double delta) { if (!_done && Time.GetTicksMsec() > WatchdogSeconds * 1000.0) { Check(false, $"Smoke watchdog timed out after {WatchdogSeconds}s"); Finish(); } } private async Task RunAsync() { try { _main = GD.Load("res://Main.tscn").Instantiate
(); _main.InitialMapKindOverride = ArenaMapKind.Desert; _main.InitialSkipDropOverride = true; AddChild(_main); if (_main.Failure is { } failure) { Check(false, "Main failed to initialize IClientArenaSession: " + failure); } else { await RunScenarioAsync(); } } catch (Exception ex) { Check(false, ex.ToString()); } Finish(); } private async Task RunScenarioAsync() { Check(Engine.PhysicsTicksPerSecond == 60, $"Expected 60 physics ticks/sec, got {Engine.PhysicsTicksPerSecond}"); Check((string)ProjectSettings.GetSetting("physics/3d/physics_engine") == "Dummy", "Godot 3D physics_engine is not Dummy"); Check(!_main.GetWorld3D().Space.IsValid, "Godot should have no active 3D physics space"); Check(_main.Terrain.BakedTileCount == 64, $"Expected 64 baked terrain tiles, got {_main.Terrain.BakedTileCount}"); var player = _main.Session.ViewState.Contenders[0]; float startX = player.X; float startZ = player.Z; _main.SetScriptedInput(new PlayerInput( Throttle: 1f, Steer: 0.25f, AimWorldX: startX + 35f, AimWorldZ: startZ + 10f, Fire: true, InteractPickup: false, Brake: false)); for (int i = 0; i < 60; i++) { await ToSignal(GetTree(), SceneTree.SignalName.PhysicsFrame); if (_main.Failure is { } f) { Check(false, "Session failure during physics loop: " + f); return; } } float dx = player.X - startX; float dz = player.Z - startZ; float displacement = MathF.Sqrt(dx * dx + dz * dz); Check(displacement > 3f, $"Expected player displacement > 3m after 60 frames, got {displacement:F2}m"); Check(!float.IsNaN(player.X) && !float.IsNaN(player.Y) && !float.IsNaN(player.Z), "Player position became NaN"); // Pause physics during the isolated crater check so AI contender track stamps in other tiles do not race it. _main.SetScriptedInput(null); _main.SetPhysicsProcess(false); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); bool isHeadless = DisplayServer.GetName() == "headless"; int rebakesBefore = _main.Terrain.DirtyRebakes; float cpuBefore = _main.Session.ViewState.Terrain.SampleHeight(-96f, -96f); float gpuBefore = 0f; if (!isHeadless) { if (_main.Terrain.TryGetHeightImageFormat(out var imgFormat)) { GD.Print($"SMOKE INFO: HeightViewport format={imgFormat}"); } bool hasGpuBefore = _main.Terrain.TrySampleBakedHeight(-96f, -96f, out gpuBefore); Check(hasGpuBefore, "Expected GPU HeightViewport readback to succeed before crater"); if (hasGpuBefore) { float beforeErr = MathF.Abs(gpuBefore - cpuBefore); GD.Print($"SMOKE INFO: Crater-site pre-stamp cpu={cpuBefore:F4}m gpu={gpuBefore:F4}m err={beforeErr:F4}m"); Check(beforeErr <= 0.20f, $"Expected baked GPU height ({gpuBefore:F4}m) to match CPU height ({cpuBefore:F4}m) before crater within 0.20m"); } // Verify brushed terrain relief (tallest Mesa/DuneRidge center) so a flat-map bug can never pass TerrainBrush? reliefBrush = null; float bestHillCpu = 0f; foreach (var b in _main.Session.ViewState.Terrain.Brushes) { if (b.Kind == TerrainBrushKind.Mesa || (b.Kind == TerrainBrushKind.DuneRidge && b.HeightDelta > 0f)) { float h = _main.Session.ViewState.Terrain.SampleHeight(b.X, b.Z); if (h > bestHillCpu) { bestHillCpu = h; reliefBrush = b; } } } Check(reliefBrush.HasValue && bestHillCpu > 10f, "Expected brushed terrain relief > 10m in generated arena"); if (reliefBrush.HasValue) { var rb = reliefBrush.Value; bool hasGpuHill = _main.Terrain.TrySampleBakedHeight(rb.X, rb.Z, out float gpuHill); Check(hasGpuHill, "Expected GPU HeightViewport readback to succeed on brushed relief hill/mesa"); if (hasGpuHill) { float hillErr = MathF.Abs(gpuHill - bestHillCpu); GD.Print($"SMOKE INFO: Relief {rb.Kind} at ({rb.X:F1},{rb.Z:F1}) cpu={bestHillCpu:F4}m gpu={gpuHill:F4}m err={hillErr:F4}m"); Check(gpuHill > 10f, $"Expected GPU baked hill height > 10m, got {gpuHill:F4}m"); Check(hillErr <= 0.20f, $"Expected GPU hill height ({gpuHill:F4}m) to match CPU ({bestHillCpu:F4}m) within 0.20m"); } } // Verify tile seam continuity across interior tile boundaries (< 0.01m) float maxSeamErr = 0f; float[] boundaries = { -192f, 0f, 192f }; float[] offsets = { -280f, -96f, 96f, 280f }; foreach (float bCoord in boundaries) { foreach (float ortho in offsets) { if (_main.Terrain.TrySampleBakedHeight(bCoord - 0.0001f, ortho, out float hL) && _main.Terrain.TrySampleBakedHeight(bCoord + 0.0001f, ortho, out float hR)) { maxSeamErr = MathF.Max(maxSeamErr, MathF.Abs(hL - hR)); } if (_main.Terrain.TrySampleBakedHeight(ortho, bCoord - 0.0001f, out float hD) && _main.Terrain.TrySampleBakedHeight(ortho, bCoord + 0.0001f, out float hU)) { maxSeamErr = MathF.Max(maxSeamErr, MathF.Abs(hD - hU)); } } } GD.Print($"SMOKE INFO: Max tile seam error={maxSeamErr:F5}m"); Check(maxSeamErr < 0.01f, $"Expected tile seam error < 0.01m, got {maxSeamErr:F5}m"); } _main.Session.ViewState.Terrain.StampCrater(-96f, -96f, radius: 5f, depth: 1.4f); _main.Terrain.Sync(_main.Session.ViewState.Terrain); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); float cpuAfter = _main.Session.ViewState.Terrain.SampleHeight(-96f, -96f); Check(cpuAfter < cpuBefore - 0.8f, $"Expected CPU terrain height to drop after crater stamp (before {cpuBefore:F2}m, after {cpuAfter:F2}m)"); Check(_main.Terrain.DirtyRebakes == rebakesBefore + 1, $"Expected 1 dirty tile rebake from isolated crater stamp, got {_main.Terrain.DirtyRebakes - rebakesBefore}"); if (!isHeadless) { bool hasGpuAfter = _main.Terrain.TrySampleBakedHeight(-96f, -96f, out float gpuAfter); Check(hasGpuAfter, "Expected GPU HeightViewport readback to succeed after crater"); if (hasGpuAfter) { float afterErr = MathF.Abs(gpuAfter - cpuAfter); GD.Print($"SMOKE INFO: Crater-site post-stamp cpu={cpuAfter:F4}m gpu={gpuAfter:F4}m err={afterErr:F4}m"); Check(afterErr <= 0.20f, $"Expected baked GPU height ({gpuAfter:F4}m) to match CPU height ({cpuAfter:F4}m) after crater within 0.20m"); Check(gpuAfter < gpuBefore - 0.8f, $"Expected baked GPU height to drop after crater (before {gpuBefore:F4}m, after {gpuAfter:F4}m)"); } } // Regression check (Finding 4): 4-tile boundary crater at (0, 0) bakes all 4 tiles on Sync#1 (<= 0.20m error on all 4 quadrants) // and passive Track throttling preserves DirtyTileMask until all tiles are baked without skipping via _rebakeCursor. { // Flush any lingering track rebakes first so baseline is clean for (int flush = 0; flush < 32 && _main.Session.ViewState.Terrain.DirtyTileMask != 0UL; flush++) { _main.Terrain.Sync(_main.Session.ViewState.Terrain); } await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); (float Qx, float Qz)[] quadrants = { (-1f, -1f), (1f, -1f), (-1f, 1f), (1f, 1f) }; float[] qGpuBefore = new float[4]; if (!isHeadless) { for (int q = 0; q < 4; q++) { Check(_main.Terrain.TrySampleBakedHeight(quadrants[q].Qx, quadrants[q].Qz, out qGpuBefore[q]), $"Expected GPU readback before 4-tile boundary crater at quadrant {q}"); } } int rebakes4Before = _main.Terrain.DirtyRebakes; _main.Session.ViewState.Terrain.StampCrater(0f, 0f, radius: 6f, depth: 1.4f); _main.Terrain.Sync(_main.Session.ViewState.Terrain); // Sync#1 Check(_main.Terrain.DirtyRebakes == rebakes4Before + 4, $"Expected 4-tile boundary crater at (0,0) to bake all 4 tiles on Sync#1, got {_main.Terrain.DirtyRebakes - rebakes4Before}"); Check(_main.Session.ViewState.Terrain.StructuralDirtyTileMask == 0UL, "Expected StructuralDirtyTileMask == 0 after Sync#1 on 4-tile boundary crater"); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); if (!isHeadless) { for (int q = 0; q < 4; q++) { float qCpu = _main.Session.ViewState.Terrain.SampleHeight(quadrants[q].Qx, quadrants[q].Qz); bool ok = _main.Terrain.TrySampleBakedHeight(quadrants[q].Qx, quadrants[q].Qz, out float qGpu); Check(ok, $"Expected GPU readback on quadrant {q} after 4-tile boundary crater"); if (ok) { float qErr = MathF.Abs(qGpu - qCpu); GD.Print($"SMOKE INFO: 4-tile crater Q{q} ({quadrants[q].Qx},{quadrants[q].Qz}) cpu={qCpu:F4}m gpu={qGpu:F4}m err={qErr:F4}m"); Check(qErr <= 0.20f, $"4-tile crater quadrant {q} GPU error {qErr:F4}m > 0.20m"); Check(qGpu < qGpuBefore[q] - 0.35f, $"4-tile crater quadrant {q} did not depress on Sync#1 (before={qGpuBefore[q]:F4}, after={qGpu:F4})"); } } } // Stamp 3 passive tracks in adjacent tiles so _rebakeCursor must advance across Sync#1 and Sync#2 without skipping int rebakesTrackBefore = _main.Terrain.DirtyRebakes; _main.Session.ViewState.Terrain.StampTrack(-480f, -480f, 0f, 2f, 3f); _main.Session.ViewState.Terrain.StampTrack(-288f, -480f, 0f, 2f, 3f); _main.Session.ViewState.Terrain.StampTrack(-96f, -480f, 0f, 2f, 3f); _main.Terrain.Sync(_main.Session.ViewState.Terrain); Check(_main.Terrain.DirtyRebakes == rebakesTrackBefore + 2, $"Expected Sync#1 to throttle 3 passive tracks to 2 rebakes, got {_main.Terrain.DirtyRebakes - rebakesTrackBefore}"); Check(_main.Session.ViewState.Terrain.DirtyTileMask != 0UL, "Expected DirtyTileMask to stay non-zero while 1 passive track tile remains dirty"); _main.Terrain.Sync(_main.Session.ViewState.Terrain); Check(_main.Terrain.DirtyRebakes == rebakesTrackBefore + 3, $"Expected Sync#2 to bake remaining 3rd passive track tile without _rebakeCursor skip, got {_main.Terrain.DirtyRebakes - rebakesTrackBefore}"); Check(_main.Session.ViewState.Terrain.DirtyTileMask == 0UL, "Expected DirtyTileMask == 0 after all passive track tiles baked"); } _main.SetPhysicsProcess(true); await VerifyHudAndShadersAsync(isHeadless); await VerifyCut3bVehiclesAndMechanismsAsync(); await MaybeCapturePreviewAsync(isHeadless); await VerifyMaxLoadPaladinGarageAsync(); await VerifySionMapAsync(); await VerifyOrbitalDropSequenceAsync(); await VerifyCut7bModularOrdnanceAsync(); VerifyForwardPlusAtmosphere(); } private async Task VerifyHudAndShadersAsync(bool isHeadless) { var invShader = _main.Hud.Schematic.ShaderMaterial.Shader; Check(invShader is not null && !string.IsNullOrWhiteSpace(invShader.Code), "inventory_grid.gdshader failed to load"); int chromeCount = 0; foreach (var mat in _main.Hud.GetChromeMaterials()) { chromeCount++; Check(mat.Shader is not null && !string.IsNullOrWhiteSpace(mat.Shader.Code), $"panel_chrome.gdshader failed to load on HUD panel #{chromeCount}"); } Check(chromeCount == 6, $"Expected 6 ChromePanel materials on HUD, got {chromeCount}"); // Pack a real Ironclad chassis with mounted modules, thermal gradient, stripped cell, and active hit-pulse var testGrid = new ChassisGrid(Catalog.Ironclad); Check(testGrid.TryMount(Catalog.Recoilless, "hp.weapon.main"), "Expected Recoilless to mount on hp.weapon.main"); Check(testGrid.TryMount(Catalog.Mg762, "hp.weapon.coax"), "Expected Mg762 to mount on hp.weapon.coax"); Check(testGrid.TryMount(Catalog.TurboCore, "hp.engine.rear"), "Expected TurboCore to mount on hp.engine.rear"); Check(testGrid.TryMount(Catalog.CopperRad, "hp.radiator.l"), "Expected CopperRad to mount on hp.radiator.l"); Check(testGrid.TryMount(Catalog.WeldedPlate, "hp.armor.front"), "Expected WeldedPlate to mount on hp.armor.front"); testGrid.InjectHardpointHeat("hp.engine.rear", 1800f); testGrid.InjectHardpointHeat("hp.weapon.main", 900f); testGrid.StepHeat(0.25f); testGrid.Armor[0, 0] = 0f; // stripped armor cell var schematic = _main.Hud.Schematic; schematic.SetGrid(testGrid); schematic.TriggerHitPulse(1, 1, 1f); // Hit-testing verification: center of cell (1, 1) must map to (1, 1) and hardpoint "hp.weapon.main" schematic.ComputeCellLayout(out float cellSize, out Vector2 origin); Check(cellSize > 10f, $"Expected InventoryGridControl cellSize > 10px, got {cellSize:F2}"); Vector2 probePos = origin + new Vector2(1.5f * cellSize, 1.5f * cellSize); bool hitCell = schematic.TryGetCellAt(probePos, out var mappedCell); Check(hitCell && mappedCell == new Vector2I(1, 1), $"Expected TryGetCellAt to map center of (1,1) to (1,1), got hit={hitCell} cell={mappedCell}"); var mappedHp = schematic.GetHardpointAt(1, 1); Check(mappedHp is { Id: "hp.weapon.main" }, $"Expected GetHardpointAt(1,1) to return hp.weapon.main, got {mappedHp?.Id ?? "null"}"); // Regression check (Finding 3): same-dimension SwapChassis updates _hardpointLookup and clears hover state schematic._GuiInput(new InputEventMouseMotion { Position = probePos }); Check(schematic.HoveredCell == new Vector2I(1, 1) && schematic.HoveredHardpoint is { Id: "hp.weapon.main" }, $"Expected hover on (1,1)/hp.weapon.main before SwapChassis, got cell={schematic.HoveredCell} hp={schematic.HoveredHardpoint?.Id ?? "null"}"); bool hoverResetEmitted = false; void OnSwapHoverChanged(Vector2I? cell, HardpointSpec? hp) { if (cell is null && hp is null) { hoverResetEmitted = true; } } schematic.HoverChanged += OnSwapHoverChanged; var altTankSpec = Catalog.Ironclad with { Id = "ironclad_alt", Hardpoints = new[] { new HardpointSpec("wpn_swapped", HardpointKind.Weapon, 1, 1, 2, 2, 18f) } }; testGrid.SwapChassis(altTankSpec); schematic.SetGrid(testGrid); schematic.HoverChanged -= OnSwapHoverChanged; Check(schematic.GetHardpointAt(1, 1) is { Id: "wpn_swapped" }, $"Expected GetHardpointAt(1,1) to update to wpn_swapped after same-dimension SwapChassis, got {schematic.GetHardpointAt(1, 1)?.Id ?? "null"}"); Check(schematic.GetHardpointAt(0, 1) is null, $"Expected old hardpoint hp.weapon.coax at (0,1) to clear after SwapChassis, got {schematic.GetHardpointAt(0, 1)?.Id ?? "null"}"); Check(schematic.HoveredCell is null && schematic.HoveredHardpoint is null && hoverResetEmitted, $"Expected SwapChassis to clear hover and emit HoverChanged(null, null), cell={schematic.HoveredCell} emitted={hoverResetEmitted}"); // Re-seed Ironclad grid for GPU tests below testGrid = new ChassisGrid(Catalog.Ironclad); Check(testGrid.TryMount(Catalog.Recoilless, "hp.weapon.main"), "Expected Recoilless to remount on hp.weapon.main"); Check(testGrid.TryMount(Catalog.Mg762, "hp.weapon.coax"), "Expected Mg762 to remount on hp.weapon.coax"); Check(testGrid.TryMount(Catalog.TurboCore, "hp.engine.rear"), "Expected TurboCore to remount on hp.engine.rear"); Check(testGrid.TryMount(Catalog.CopperRad, "hp.radiator.l"), "Expected CopperRad to remount on hp.radiator.l"); Check(testGrid.TryMount(Catalog.WeldedPlate, "hp.armor.front"), "Expected WeldedPlate to remount on hp.armor.front"); testGrid.InjectHardpointHeat("hp.engine.rear", 1800f); testGrid.InjectHardpointHeat("hp.weapon.main", 900f); testGrid.StepHeat(0.25f); testGrid.Armor[0, 0] = 0f; // Restore live player grid to HUD and verify layout has no overlaps or clipping _main.Hud.Sync(_main.Session); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); Vector2 vpSize = GetViewport().GetVisibleRect().Size; Check(!_main.Hud.HasPanelOverlapOrClip(vpSize), $"Compact HUD panels overlapped or clipped at {vpSize}"); _main.Hud.ToggleGarage(); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); Check(!_main.Hud.HasPanelOverlapOrClip(vpSize), $"Garage HUD panels overlapped or clipped at {vpSize}"); _main.Hud.ToggleGarage(); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); _main.Hud.ToggleNetworkPanel(); _main.Hud.Sync(_main.Session); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); Check(!_main.Hud.HasPanelOverlapOrClip(vpSize), $"F9 Network HUD panel overlapped or clipped at {vpSize}"); _main.Hud.ToggleNetworkPanel(); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); if (isHeadless) { return; } // GPU verification on Forward+ Vulkan: render isolated InventoryGridControl (ambient vs live bilinear heat) & panel_chrome.gdshader var gridVp = new SubViewport { Size = new Vector2I(240, 240), TransparentBg = true, RenderTargetUpdateMode = SubViewport.UpdateMode.Always }; var vpGrid = new InventoryGridControl { Size = new Vector2(240f, 240f), CustomMinimumSize = new Vector2(240f, 240f) }; gridVp.AddChild(vpGrid); AddChild(gridVp); var coolGrid = new ChassisGrid(Catalog.Ironclad); coolGrid.TryMount(Catalog.Recoilless, "hp.weapon.main"); coolGrid.TryMount(Catalog.Mg762, "hp.weapon.coax"); coolGrid.TryMount(Catalog.TurboCore, "hp.engine.rear"); coolGrid.TryMount(Catalog.CopperRad, "hp.radiator.l"); coolGrid.TryMount(Catalog.WeldedPlate, "hp.armor.front"); coolGrid.Armor[0, 0] = 0f; vpGrid.SetGrid(coolGrid); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); var coolImg = gridVp.GetTexture().GetImage(); int coolOpaque = CountNonZeroAlphaPixels(coolImg, 0.08f); GD.Print($"SMOKE INFO: InventoryGrid GPU cool opaque pixels={coolOpaque}"); Check(coolOpaque > 4000, $"Expected > 4000 rendered pixels from InventoryGrid shader, got {coolOpaque}"); vpGrid.SetGrid(testGrid); vpGrid.TriggerHitPulse(1, 1, 1f); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); var hotImg = gridVp.GetTexture().GetImage(); int hotOpaque = CountNonZeroAlphaPixels(hotImg, 0.08f); int heatDiff = CountDifferentPixels(coolImg, hotImg, 0.05f); GD.Print($"SMOKE INFO: InventoryGrid GPU hot opaque={hotOpaque}, diff vs cool={heatDiff}"); Check(hotOpaque > 4000, $"Expected > 4000 rendered pixels from heated InventoryGrid shader, got {hotOpaque}"); Check(heatDiff > 400, $"Expected always-active temp_tex + hit pulse to visibly change > 400 pixels, got {heatDiff}"); // Finding 2 GPU check: overheated (350C..550C+) must obey blend_premul_alpha (out_rgb <= out_a) testGrid.InjectHardpointHeat("hp.engine.rear", 45000f); testGrid.InjectHardpointHeat("hp.weapon.main", 25000f); testGrid.StepHeat(0.05f); float hotTemp = testGrid.Temperature[1, 3]; Check(hotTemp >= 350f, $"Expected overheated cell >= 350C for premul test, got {hotTemp:F1}C"); vpGrid.SetGrid(testGrid); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); var overheatImg = gridVp.GetTexture().GetImage(); int premulViolations = CountPremulViolations(overheatImg, 0.01f); GD.Print($"SMOKE INFO: InventoryGrid GPU overheat ({hotTemp:F1}C) premul violations={premulViolations}"); Check(premulViolations == 0, $"Expected 0 blend_premul_alpha violations (max(RGB) > A + 0.01) on overheated grid, got {premulViolations}"); // Finding 1 GPU check: asymmetric heated Raptor chassis must leave 0 lit pixels in inactive cell holes var raptorGrid = new ChassisGrid(Catalog.Raptor); Check(raptorGrid.TryMount(Catalog.CopperRad, "hp.radiator.sh_l"), "Expected CopperRad on Raptor hp.radiator.sh_l"); Check(raptorGrid.TryMount(Catalog.CopperRad, "hp.radiator.sh_r"), "Expected CopperRad on Raptor hp.radiator.sh_r"); Check(raptorGrid.TryMount(Catalog.Autocannon, "hp.weapon.arm_l"), "Expected Autocannon on Raptor hp.weapon.arm_l"); Check(raptorGrid.TryMount(Catalog.TurboCore, "hp.engine.chest"), "Expected TurboCore on Raptor hp.engine.chest"); Check(raptorGrid.TryMount(Catalog.Autocannon, "hp.weapon.arm_r"), "Expected Autocannon on Raptor hp.weapon.arm_r"); raptorGrid.InjectHardpointHeat("hp.engine.chest", 1800f); raptorGrid.StepHeat(0.25f); vpGrid.SetGrid(raptorGrid); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); var raptorImg = gridVp.GetTexture().GetImage(); int raptorHoleScanned = 0; int raptorHoleLit = 0; int rw = raptorImg.GetWidth(); int rh = raptorImg.GetHeight(); for (int py = 0; py < rh; py++) { for (int px = 0; px < rw; px++) { if (vpGrid.TryGetCellAt(new Vector2(px + 0.5f, py + 0.5f), out var cell) && !Catalog.Raptor.IsActive(cell.X, cell.Y)) { raptorHoleScanned++; Color c = raptorImg.GetPixel(px, py); if (MathF.Max(MathF.Max(c.R, c.G), MathF.Max(c.B, c.A)) > 0.001f) { raptorHoleLit++; } } } } GD.Print($"SMOKE INFO: Asymmetric Raptor hole lit pixels={raptorHoleLit} (scanned {raptorHoleScanned} hole px)"); Check(raptorHoleScanned > 1000, $"Expected > 1000 inactive hole pixels scanned on Raptor, got {raptorHoleScanned}"); Check(raptorHoleLit == 0, $"Expected 0 lit/opaque pixels in inactive Raptor cell holes, got {raptorHoleLit}"); // Finding 5 GPU check: LabelsOverlay redraws on temp-only change & compatibility highlights update when Cargo[0] swaps at unchanged index 0 { raptorGrid.Cargo.Clear(); Check(raptorGrid.TryAddCargo(Catalog.Autocannon), "Expected Autocannon in Raptor Cargo[0]"); vpGrid.SetGrid(raptorGrid, selectedCargoIndex: 0); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); int drawCountBeforeTemp = vpGrid.LabelsDrawCount; string? tagBeforeTemp = vpGrid.GetLastDrawnLabel("hp.engine.chest"); var cargoImgWeapon = gridVp.GetTexture().GetImage(); // Temp-only change (no armor hit, no mount change) raptorGrid.InjectHardpointHeat("hp.engine.chest", 4200f); raptorGrid.StepHeat(0.1f); vpGrid.SetGrid(raptorGrid, selectedCargoIndex: 0); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); int drawCountAfterTemp = vpGrid.LabelsDrawCount; string? tagAfterTemp = vpGrid.GetLastDrawnLabel("hp.engine.chest"); Check(drawCountAfterTemp > drawCountBeforeTemp, $"Expected LabelsOverlay to redraw on temp-only change ({drawCountBeforeTemp} -> {drawCountAfterTemp})"); Check(!string.Equals(tagBeforeTemp, tagAfterTemp, StringComparison.Ordinal), $"Expected engine temp label text to update on temp-only change ('{tagBeforeTemp}' -> '{tagAfterTemp}')"); // Cargo[0] replacement at unchanged selectedCargoIndex == 0 (Weapon -> Radiator) raptorGrid.Cargo[0] = Catalog.CopperRad; vpGrid.SetGrid(raptorGrid, selectedCargoIndex: 0); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); var cargoImgRad = gridVp.GetTexture().GetImage(); int cargoDiff = CountDifferentPixels(cargoImgWeapon, cargoImgRad, 0.05f); GD.Print($"SMOKE INFO: InventoryGrid Cargo[0] swap diff pixels={cargoDiff}, label '{tagBeforeTemp}'->'{tagAfterTemp}'"); Check(cargoDiff > 50, $"Expected Cargo[0] replacement at unchanged index 0 to update compatibility highlight pixels (>50), got {cargoDiff}"); } gridVp.QueueFree(); // GPU verification for panel_chrome.gdshader var chromeVp = new SubViewport { Size = new Vector2I(240, 120), TransparentBg = true, RenderTargetUpdateMode = SubViewport.UpdateMode.Always }; var chromeShader = GD.Load("res://panel_chrome.gdshader"); var chromeMat = new ShaderMaterial { Shader = chromeShader }; chromeMat.SetShaderParameter("rect_size", new Vector2(240f, 120f)); chromeMat.SetShaderParameter("accent_color", Color.FromHtml("#e08a4a")); var chromeImgTex = Image.CreateEmpty(1, 1, false, Image.Format.Rgba8); chromeImgTex.SetPixel(0, 0, Colors.White); var chromeRect = new TextureRect { Texture = ImageTexture.CreateFromImage(chromeImgTex), Size = new Vector2(240f, 120f), ExpandMode = TextureRect.ExpandModeEnum.IgnoreSize, StretchMode = TextureRect.StretchModeEnum.Scale, Material = chromeMat }; chromeVp.AddChild(chromeRect); AddChild(chromeVp); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); var chromeImg = chromeVp.GetTexture().GetImage(); int chromeOpaque = CountNonZeroAlphaPixels(chromeImg, 0.08f); Color cornerPx = chromeImg.GetPixel(2, 2); Color centerPx = chromeImg.GetPixel(120, 60); GD.Print($"SMOKE INFO: panel_chrome GPU opaque={chromeOpaque}, corner={cornerPx}, center={centerPx}"); Check(chromeOpaque > 10000, $"Expected > 10000 rendered pixels from panel_chrome.gdshader, got {chromeOpaque}"); Check(cornerPx.R > centerPx.R + 0.25f, $"Expected L-bracket corner pixel ({cornerPx}) to be accented brighter than panel center ({centerPx})"); chromeVp.QueueFree(); } private async Task MaybeCapturePreviewAsync(bool isHeadless) { if (isHeadless) return; string? previewPath = null; foreach (string arg in OS.GetCmdlineUserArgs()) { const string prefix = "--capture-preview="; if (arg.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) { previewPath = arg[prefix.Length..]; break; } } if (string.IsNullOrWhiteSpace(previewPath)) { return; } if (!_main.Hud.GarageExpanded) { _main.Hud.ToggleGarage(); } // Seed realistic combat telemetry so the preview clearly showcases armor stripping, hit-flash, cargo rack, and thermal heat var player = _main.Session.ViewState.Contenders[0]; var grid = player.Grid; grid.TryAddCargo(Catalog.TouringPlasma); grid.TryAddCargo(Catalog.GoldRadiator); grid.InjectHardpointHeat("hp.engine.rear", 1100f); grid.InjectHardpointHeat("hp.weapon.roof", 750f); grid.StepHeat(0.15f); grid.Armor[0, 0] = 0f; // Place two nearby rival contenders cleanly in the desert ahead of the player so the preview shows multiple Brokkr GLBs grounded on terrain float fwdX = MathF.Sin(_main.CameraYaw); float fwdZ = MathF.Cos(_main.CameraYaw); float rightX = -fwdZ; float rightZ = fwdX; if (_main.Session is LocalArenaSession localPreview && localPreview.Inner.State.Contenders.Count > 2) { var r1 = localPreview.Inner.State.Contenders[1]; if (r1.Alive) { localPreview.Inner.SetContenderPose(r1.Id, player.X + fwdX * 19f - rightX * 5.5f, player.Z + fwdZ * 19f - rightZ * 5.5f, _main.CameraYaw + MathF.PI * 0.82f); } var r2 = localPreview.Inner.State.Contenders[2]; if (r2.Alive) { localPreview.Inner.SetContenderPose(r2.Id, player.X + fwdX * 26f + rightX * 8.5f, player.Z + fwdZ * 26f + rightZ * 8.5f, _main.CameraYaw - MathF.PI * 0.72f); } } _main.Arena.Sync(_main.Session, 1.5f, 1f / 60f); _main.Hud.Sync(_main.Session); _main.Hud.Schematic.TriggerHitPulse(1, 0, 0.9f); if (_main.Arena.GetContenderVisual(player.Id) is { } pVis) { Vector3 vehFwd = pVis.Root.GlobalTransform.Basis.Z.Normalized(); if (pVis.GetMountedGearNode("hp.weapon.roof") is { } roofGun) { Vector3 gunFwd = roofGun.GlobalTransform.Basis.Z.Normalized(); GD.Print($"SMOKE INFO: Preview Jackal yaw={player.Yaw:F3} vehFwd={vehFwd} roofGunFwd={gunFwd} dot={vehFwd.Dot(gunFwd):F3}"); } } await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); var frameImg = GetViewport().GetTexture().GetImage(); var err = frameImg.SavePng(previewPath); GD.Print($"SMOKE INFO: Saved preview screenshot ({frameImg.GetWidth()}x{frameImg.GetHeight()}) to {previewPath} (err={err})"); Check(err == Error.Ok, $"Failed to save preview screenshot to {previewPath}: {err}"); } private async Task VerifyCut3bVehiclesAndMechanismsAsync() { var cache = _main.Arena.AssetCache; cache.PreloadAll(); Check(cache.Vehicles.Count == 15, $"Expected 15 cached vehicle GLBs, got {cache.Vehicles.Count}"); Check(cache.Gear.Count == 6, $"Expected 6 cached gear GLBs, got {cache.Gear.Count}"); // 1. All 15 vehicles bind 100% of hardpoint AnchorIds and attach/unmount gear cleanly foreach (var spec in Catalog.AllChassis) { var pkg = Catalog.TryGetPackage(spec.Id); Check(pkg is not null, $"Missing VehiclePackage for '{spec.Id}'"); if (pkg is null) continue; var vis = VehicleVisualInstance.Create(cache, spec.Id, VehicleVisualRole.Player); Check(CountMeshInstances(vis.Root) == 0, $"Expected zero MeshInstance3D children on MultiMesh rig '{spec.Id}', got {CountMeshInstances(vis.Root)}"); Check(vis.BoundHardpointCount == spec.Hardpoints.Length, $"Expected {spec.Hardpoints.Length} bound hardpoints on '{spec.Id}', got {vis.BoundHardpointCount}"); Check(vis.Joints.Count == pkg.Joints.Count, $"Expected {pkg.Joints.Count} bound joints on '{spec.Id}', got {vis.Joints.Count}"); Check(MathF.Abs(vis.Template.MinY) < 0.05f, $"Expected grounded GLB MinY ~ 0 on '{spec.Id}', got {vis.Template.MinY:F4}"); var grid = Catalog.CreateWithDefaultLoadout(spec); vis.SyncMountedGear(grid); int mountedMeshes = 0; foreach (var m in grid.Mounted) { var gNode = vis.GetMountedGearNode(m.HardpointId); if (gNode is not null) { mountedMeshes++; if (m.Spec.Kind == HardpointKind.Weapon) { (string frontPart, string rearPart) = m.Spec.Id switch { "mg_762" or "pd_flak" => ("barrel_inner", "receiver"), "autocannon" or "flak" => ("muzzle_brake_L", "gun_housing"), "recoilless" => ("sight_tube", "breech_band"), _ => ("condenser_ring_2", "ivory_cowl") }; bool hasCentroids = vis.TryGetMountedWeaponCentroidsInModel( m.HardpointId, frontPart, rearPart, out Vector3 frontC, out Vector3 rearC); Check(hasCentroids, $"Missing weapon submeshes '{frontPart}'/'{rearPart}' on '{spec.Id}.{m.HardpointId}' ({m.Spec.Id})"); if (hasCentroids) { Vector3 muzzleDir = (frontC - rearC).Normalized(); if (m.Spec.Id == "recoilless") { GD.Print($"SMOKE INFO: recoilless {spec.Id}.{m.HardpointId} sight_tube={frontC} breech={rearC} dir={muzzleDir}"); Check(frontC.Z > rearC.Z + 0.20f, $"Expected recoilless sight_tube (+Z) ahead of breech_band on '{spec.Id}.{m.HardpointId}', got sight={frontC}, breech={rearC}"); } Check(muzzleDir.Z > 0.75f, $"Expected weapon '{m.Spec.Id}' on '{spec.Id}.{m.HardpointId}' mesh geometry to point forward (+Z), got dir={muzzleDir}"); } } } } Check(mountedMeshes == grid.Mounted.Count && mountedMeshes > 0, $"Expected all {grid.Mounted.Count} default modules on '{spec.Id}' to attach visible gear meshes, got {mountedMeshes}"); // Unmount first module and confirm gear node is removed cleanly if (grid.Mounted.Count > 0) { string removedHp = grid.Mounted[0].HardpointId; grid.Mounted.RemoveAt(0); vis.SyncMountedGear(grid); Check(vis.GetMountedGearNode(removedHp) is null, $"Expected gear node on '{spec.Id}.{removedHp}' to be removed after unmount"); } vis.Root.QueueFree(); } // 2. Rig animator produces real non-zero transforms (> 0.001 rad) with zero NaNs across all mobility archetypes VerifyRigMotion(cache, "jackal", "joint.wheel_fl", new VehicleRigDriveInput(new Vector3(0f, 0f, 14f), 0f, 0f, 0f, -1f, 1f, 0f, 1f, 1f / 60f), minRotRad: 0.001f); VerifyRigMotion(cache, "hornet", "joint.rotor_l", new VehicleRigDriveInput(new Vector3(0f, 0f, 10f), 0f, 0f, 0f, 0f, 1f, 1f, 1f, 1f / 60f), minRotRad: 0.001f); VerifyRigMotion(cache, "anvil", "joint.turret_yaw", new VehicleRigDriveInput(Vector3.Zero, 0f, 0.85f, 0f, 0f, 0f, 0f, 1f, 1f / 60f), minRotRad: 0.001f); VerifyRigMotion(cache, "manticore", "joint.tail_yaw", new VehicleRigDriveInput(new Vector3(0f, 0f, 6f), 0f, 0.70f, 18f, 0f, 0.8f, 0f, 1f, 1f / 60f), minRotRad: 0.001f); // Breaker: verify oleo strut slide + scissor torque links + recess ram aiming driven by Newtonian GRF load { var breakerVis = VehicleVisualInstance.Create(cache, "breaker", VehicleVisualRole.Player); Node3D? oleo = breakerVis.GetNamedNode("LegL.Oleo"); Node3D? scissorUp = breakerVis.GetNamedNode("LegL.TorqueUp"); Node3D? ram0 = breakerVis.GetNamedNode("LegL.RecessRam0"); Check(oleo is not null && scissorUp is not null && ram0 is not null, "Expected Breaker LegL.Oleo, LegL.TorqueUp, and LegL.RecessRam0 nodes to resolve"); if (oleo is not null && scissorUp is not null && ram0 is not null) { Transform3D oleo0 = oleo.Transform; Transform3D sc0 = scissorUp.Transform; Transform3D ramRest = ram0.Transform; Node3D? footL = breakerVis.GetNamedNode("LegL.Foot"); if (footL is not null) { footL.Transform = new Transform3D(new Basis(Vector3.Right, 0.28f) * footL.Transform.Basis, footL.Transform.Origin); } for (int s = 0; s < 10; s++) VehicleRigAnimator.StepBreakerLinkages(breakerVis, leftLoadG: 1.85f, rightLoadG: 0.25f, dt: 1f / 60f); for (int s = 0; s < 10; s++) VehicleRigAnimator.StepBreakerLinkages(breakerVis, leftLoadG: 0.25f, rightLoadG: 1.85f, dt: 1f / 60f); float oleoDelta = (oleo.Transform.Origin - oleo0.Origin).Length(); float scDelta = sc0.Basis.GetRotationQuaternion().AngleTo(scissorUp.Transform.Basis.GetRotationQuaternion()); float ramDelta = ramRest.Basis.GetRotationQuaternion().AngleTo(ram0.Transform.Basis.GetRotationQuaternion()); GD.Print($"SMOKE INFO: Breaker mech deltas oleo={oleoDelta:F4}m scissor={scDelta:F4}rad ram={ramDelta:F4}rad"); Check(oleoDelta > 0.0005f && !HasNaN(oleo.Transform), $"Expected Breaker LegL.Oleo motion > 0.0005m, got {oleoDelta:F5}"); Check(scDelta > 0.001f && !HasNaN(scissorUp.Transform), $"Expected Breaker LegL.TorqueUp scissor rotation > 0.001rad, got {scDelta:F5}"); Check(ramDelta > 0.001f && !HasNaN(ram0.Transform), $"Expected Breaker LegL.RecessRam0 aim rotation > 0.001rad, got {ramDelta:F5}"); } breakerVis.Root.QueueFree(); } // 3. Part-by-cell armor detachment + hardpoint gear shear into DebrisSystem { var debris = new DebrisSystem { Name = "SmokeDebrisTest" }; AddChild(debris); var anvilGrid = Catalog.CreateWithDefaultLoadout(Catalog.Anvil); var anvilVis = VehicleVisualInstance.Create(cache, "anvil", VehicleVisualRole.Player); AddChild(anvilVis.Root); anvilVis.SyncMountedGear(anvilGrid); anvilVis.SyncDamageAndHeat(anvilGrid, debris, Vector3.Zero); Check(debris.ActiveCount == 0, $"Expected 0 debris before armor strip, got {debris.ActiveCount}"); // Pick a cell that has detachable armor/shroud plates int targetCx = -1, targetCy = -1; for (int cy = 0; cy < anvilGrid.Spec.Height && targetCx < 0; cy++) { for (int cx = 0; cx < anvilGrid.Spec.Width; cx++) { if (anvilVis.CountDetachablePartsForCell(cx, cy) > 0) { targetCx = cx; targetCy = cy; break; } } } Check(targetCx >= 0, "Expected Anvil to have >= 1 cell with detachable armor/shroud parts"); // Strip that armor cell AND strip weapon hardpoint hp.weapon.siege_l if (targetCx >= 0) { anvilGrid.Armor[targetCx, targetCy] = 0f; } var siegeHp = anvilGrid.FindHardpoint("hp.weapon.siege_l")!; for (int dy = 0; dy < siegeHp.Height; dy++) { for (int dx = 0; dx < siegeHp.Width; dx++) { anvilGrid.Armor[siegeHp.X + dx, siegeHp.Y + dy] = 0f; } } anvilVis.SyncDamageAndHeat(anvilGrid, debris, new Vector3(2f, 0f, 4f)); Check(debris.ActiveCount >= 2, $"Expected >= 2 debris pieces (armor plate + sheared weapon gear), got {debris.ActiveCount}"); Check(anvilVis.GetMountedGearNode("hp.weapon.siege_l") is null, "Expected hp.weapon.siege_l gear to shear off when hardpoint becomes non-operational"); if (debris.TryGetPiecePosition(0, out Vector3 p0)) { for (int s = 0; s < 25; s++) { debris.Step(1f / 60f, _main.Session.ViewState.Terrain); } debris.TryGetPiecePosition(0, out Vector3 p1); float moved = p1.DistanceTo(p0); Check(moved > 0.1f && p1.IsFinite(), $"Expected debris piece to travel/fall > 0.1m under blast + gravity, got {moved:F3}m"); } anvilVis.Root.QueueFree(); debris.QueueFree(); } // 4. Full Paladin hull + gear strip detaches every merged cell armor chunk + mounted gear under 256 cap { var debris = new DebrisSystem { Name = "SmokePaladinDebrisTest" }; AddChild(debris); var palGrid = Catalog.CreateWithDefaultLoadout(Catalog.Paladin); var palVis = VehicleVisualInstance.Create(cache, "paladin", VehicleVisualRole.Player); AddChild(palVis.Root); palVis.SyncMountedGear(palGrid); int activeCellCount = 0; int expectedCellChunks = 0; for (int cy = 0; cy < palGrid.Spec.Height; cy++) { for (int cx = 0; cx < palGrid.Spec.Width; cx++) { if (palGrid.Spec.IsActive(cx, cy)) { activeCellCount++; expectedCellChunks += palVis.CountDetachablePartsForCell(cx, cy); } palGrid.Armor[cx, cy] = 0f; } } int expectedTotal = expectedCellChunks + palGrid.Mounted.Count; palVis.SyncDamageAndHeat(palGrid, debris, new Vector3(1f, 0f, 3f)); GD.Print($"SMOKE INFO: Full Paladin strip debris.ActiveCount={debris.ActiveCount} (activeCells={activeCellCount}, cellChunks={expectedCellChunks}, mounted={palGrid.Mounted.Count})"); Check(debris.ActiveCount >= activeCellCount && debris.ActiveCount == expectedTotal && debris.ActiveCount <= 256, $"Expected full Paladin strip to detach {expectedTotal} (>= {activeCellCount} active cells) pieces under 256 cap, got {debris.ActiveCount}"); palVis.Root.QueueFree(); debris.QueueFree(); } // 5. All 15 ChassisDrop salvage wrecks ground within 0.05m of terrain & PickedUp frees drops cleanly { var drops = _main.Session.ViewState.GroundDrops; int baseCount = drops.Count; _main.Arena.Sync(_main.Session, 1.0f, 1f / 60f); int trackedBefore = _main.Arena.ActiveDropVisualCount; int nextId = 90000; var added = new List(Catalog.AllChassis.Count); float maxGroundErr = 0f; for (int i = 0; i < Catalog.AllChassis.Count; i++) { var spec = Catalog.AllChassis[i]; float dx = -80f + i * 11f; float dz = -40f; var d = new GroundDrop(nextId++, dx, dz, spec, null); drops.Add(d); added.Add(d); } _main.Arena.Sync(_main.Session, 1.0f, 1f / 60f); Check(_main.Arena.ActiveDropVisualCount == trackedBefore + added.Count, $"Expected {trackedBefore + added.Count} tracked drop visuals, got {_main.Arena.ActiveDropVisualCount}"); for (int i = 0; i < added.Count; i++) { var d = added[i]; bool hasDrop = _main.Arena.TryGetChassisDropVisual(d.Id, out var dropVis, out _); Check(hasDrop && dropVis is not null, $"Missing ChassisDrop visual for Drop_{d.Id} ('{d.Chassis!.Id}')"); if (hasDrop && dropVis is not null) { dropVis.SetLodState(useStaticLod: false, castShadows: false); float minWorldY = dropVis.ComputeMinVertexY(); float terrainY = _main.Session.ViewState.Terrain.SampleHeight(d.X, d.Z); float err = MathF.Abs(minWorldY - terrainY); if (err > maxGroundErr) maxGroundErr = err; Check(err <= 0.05f, $"ChassisDrop '{d.Chassis!.Id}' buried/floating: minWorldY={minWorldY:F4}m terrainY={terrainY:F4}m err={err:F4}m"); } } GD.Print($"SMOKE INFO: ChassisDrop max ground err={maxGroundErr:F4}m across {added.Count} chassis"); // Also verify far LOD (SingleSurfaceLodFarMesh) ChassisDrop grounding stays <= 0.05m across all 15 chassis float maxFarGroundErr = 0f; for (int i = 0; i < added.Count; i++) { var d = added[i]; if (_main.Arena.TryGetChassisDropVisual(d.Id, out var dropVis, out _) && dropVis is not null) { dropVis.SetLodState(useStaticLod: true, castShadows: false); float minFarWorldY = dropVis.ComputeMinVertexY(); float terrainY = _main.Session.ViewState.Terrain.SampleHeight(d.X, d.Z); float err = MathF.Abs(minFarWorldY - terrainY); if (err > maxFarGroundErr) maxFarGroundErr = err; Check(err <= 0.05f, $"Far LOD ChassisDrop '{d.Chassis!.Id}' buried/floating: minFarWorldY={minFarWorldY:F4}m terrainY={terrainY:F4}m err={err:F4}m"); } } GD.Print($"SMOKE INFO: Far LOD ChassisDrop max ground err={maxFarGroundErr:F4}m across {added.Count} chassis"); for (int i = 0; i < added.Count; i++) { added[i].PickedUp = true; } _main.Arena.Sync(_main.Session, 1.1f, 1f / 60f); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); Check(_main.Arena.ActiveDropVisualCount == trackedBefore, $"Expected picked-up drops removed from _dropVisuals ({trackedBefore}), got {_main.Arena.ActiveDropVisualCount}"); drops.RemoveRange(baseCount, added.Count); } // 6. All 7 walkers (including Kestrel) walk through IClientArenaSession (LocalArenaSession) + Hybrid B FK snapshot cleanly { using var localWalk = new LocalArenaSession(seed: 42, mapKind: ArenaMapKind.Desert); IClientArenaSession walkIface = localWalk; var walkSession = localWalk.Inner; for (int cIdx = 1; cIdx < walkSession.State.Contenders.Count; cIdx++) { walkSession.SetContenderPose(cIdx, 450f + cIdx * 18f, 450f); } var walkerChecks = new (string Id, string FootNode, string PelvisNode)[] { ("raptor", "FootL", "Pelvis"), ("spectre", "LegL.Ankle", "Pelvis"), ("manticore", "FootFL", "Hull"), ("bastion", "Ankle.fl", "Trunk"), ("breaker", "LegL.Foot", "Pelvis"), ("paladin", "LegL.Ankle", "Pelvis"), ("kestrel", "LegL.Foot", "Pelvis"), }; foreach (var (wId, footNodeName, pelvisNodeName) in walkerChecks) { var wSpec = Catalog.ChassisById[wId]; walkSession.SetContenderPose(0, 0f, 0f, 0f); if (walkIface.LocalContender.Grid.Spec.Id != wId) { walkIface.ViewState.SpawnChassisDrop(0f, 0f, wSpec); Check(walkSession.TrySwapNearbyChassis(0), $"Failed to swap walkSession player to '{wId}'"); } var vis = VehicleVisualInstance.Create(cache, wId, VehicleVisualRole.Player); float worstRelMinY = float.PositiveInfinity; float minFootZ = float.PositiveInfinity, maxFootZ = float.NegativeInfinity; float minFootX = float.PositiveInfinity, maxFootX = float.NegativeInfinity; Node3D? footNode = vis.GetNamedNode(footNodeName); Node3D? pelvisNode = vis.GetNamedNode(pelvisNodeName); Check(footNode is not null && pelvisNode is not null, $"Missing FK nodes '{footNodeName}'/'{pelvisNodeName}' on walker '{wId}'"); var player = walkIface.LocalContender; for (int step = 0; step < 60; step++) { walkIface.SubmitLocalInput(new PlayerInput( Throttle: 1f, Steer: 0f, AimWorldX: player.X, AimWorldZ: player.Z + 50f, Fire: false, InteractPickup: false, Brake: false), isPhysicsTick: true); bool hasSnap = walkIface.TrySampleInterpolatedWalkerPose(true, player.Id, 1f, out var walkerSnap); Check(hasSnap, $"Missing WalkerVisualSnapshot for '{wId}' at step {step}"); if (!hasSnap) break; var (interpPos, interpRot, interpVel) = walkIface.GetInterpolatedContenderPose(player.Id, 1f); var q = new Quaternion(interpRot.X, interpRot.Y, interpRot.Z, interpRot.W); vis.Root.Transform = new Transform3D(new Basis(q), new Vector3(interpPos.X, interpPos.Y, interpPos.Z)); VehicleRigAnimator.Update( vis, player, new Vector3(interpVel.X, interpVel.Y, interpVel.Z), vis.Root.Basis, 1f / 60f, in walkerSnap); float curMinWorldY = vis.ComputeMinVertexY(relativeToModelRoot: false); Check(!float.IsNaN(curMinWorldY), $"NaN vertex Y on walker '{wId}' step {step}"); if (footNode is not null && pelvisNode is not null) { Vector3 fPos = TransformPointToAncestor(footNode, pelvisNode, Vector3.Zero); if (fPos.Z < minFootZ) minFootZ = fPos.Z; if (fPos.Z > maxFootZ) maxFootZ = fPos.Z; if (fPos.X < minFootX) minFootX = fPos.X; if (fPos.X > maxFootX) maxFootX = fPos.X; Vector3 fInModel = TransformPointToAncestor(footNode, vis.ModelRoot, Vector3.Zero); Vector3 fWorld = vis.Root.Transform * (vis.ModelRoot.Transform * fInModel); float groundUnderFoot = walkIface.ViewState.Terrain.SampleHeight(fWorld.X, fWorld.Z); float relMinY = curMinWorldY - groundUnderFoot; if (relMinY < worstRelMinY) worstRelMinY = relMinY; } } float zSpan = footNode is not null ? maxFootZ - minFootZ : 0f; float xSpan = footNode is not null ? maxFootX - minFootX : 0f; GD.Print($"SMOKE INFO: HybridB Walker {wId} minWorldFootRelY={worstRelMinY:F4}m zSpan={zSpan:F3}m xSpan={xSpan:F3}m"); Check(worstRelMinY >= -0.25f, $"Walker '{wId}' plunged below terrain: minRelY={worstRelMinY:F4}m"); if (footNode is not null) { Check(zSpan > 0.12f, $"Expected walker '{wId}' foot '{footNodeName}' to stride along Z > 0.12m through Hybrid B FK, got {zSpan:F3}m"); } vis.Root.QueueFree(); } } // 7. VehicleRigAnimator.Update with dt == 0 is a strict no-op unless snap == true { var anvilVis = VehicleVisualInstance.Create(cache, "anvil", VehicleVisualRole.Player); var driveInp = new VehicleRigDriveInput( new Vector3(0f, 0f, 6f), 0f, 0.2f, 5f, 0.2f, 0.5f, 0f, 1f, 1f / 60f); for (int s = 0; s < 10; s++) { VehicleRigAnimator.Update(anvilVis, in driveInp, Basis.Identity); } var beforeTransforms = new Dictionary(); foreach (var (jid, j) in anvilVis.Joints) { beforeTransforms[jid] = j.Node.Transform; } var zeroDtInp = new VehicleRigDriveInput( new Vector3(0f, 0f, 12f), 0f, 1.9f, 35f, -1f, 1f, 0f, 1f, 0f); VehicleRigAnimator.Update(anvilVis, in zeroDtInp, Basis.Identity); float maxDelta = 0f; foreach (var (jid, before) in beforeTransforms) { Transform3D after = anvilVis.Joints[jid].Node.Transform; float dOrigin = (after.Origin - before.Origin).Length(); float dRot = before.Basis.GetRotationQuaternion().AngleTo(after.Basis.GetRotationQuaternion()); maxDelta = MathF.Max(maxDelta, MathF.Max(dOrigin, dRot)); } VehicleRigAnimator.Update(anvilVis, in zeroDtInp, Basis.Identity, snap: true); Transform3D snapped = anvilVis.Joints["joint.turret_yaw"].Node.Transform; float snapDelta = beforeTransforms["joint.turret_yaw"].Basis.GetRotationQuaternion() .AngleTo(snapped.Basis.GetRotationQuaternion()); GD.Print($"SMOKE INFO: Rig dt=0 maxDelta={maxDelta:F6} snapDelta={snapDelta:F4}rad"); Check(maxDelta < 1e-6f, $"Expected dt == 0 Update (snap=false) to be a strict no-op, got maxDelta={maxDelta:F6}"); Check(snapDelta > 0.5f, $"Expected dt == 0 Update (snap=true) to snap turret cleanly, got snapDelta={snapDelta:F4}rad"); anvilVis.Root.QueueFree(); } // 8. Spectator halo sits >= 0.75m above mounted dorsal gear (including Patron with turbo_core) { _main.Arena.Sync(_main.Session, 1.5f, 1f / 60f); bool sawPatron = false; foreach (var s in _main.Session.ViewState.Spectators.Spectators) { if (!s.Alive) continue; var vis = _main.Arena.GetSpectatorVisual(s.Id); float? haloY = _main.Arena.GetSpectatorHaloLocalY(s.Id); Check(vis is not null && haloY.HasValue, $"Missing spectator visual/halo for spectator #{s.Id}"); if (vis is not null && haloY.HasValue) { float topY = vis.ComputeMountedMaxY(); float clearance = haloY.Value - topY; if (s.Tier == SpectatorTier.Patron) { sawPatron = true; GD.Print($"SMOKE INFO: Spectator #{s.Id} ({s.Tier}/{s.Grid.Spec.Id}) mountedMaxY={topY:F3}m haloY={haloY.Value:F3}m clearance={clearance:F3}m"); } Check(clearance >= 0.74f, $"Spectator #{s.Id} ({s.Tier}/{s.Grid.Spec.Id}) halo clearance < 0.74m: topY={topY:F3}m haloY={haloY.Value:F3}m clearance={clearance:F3}m"); } } Check(sawPatron, "Expected at least one alive Patron spectator in arena"); } // 9. Finding 3: Stripped distant rig (180m) detaches debris immediately without popping armor back on at far LOD { var debris = new DebrisSystem { Name = "SmokeDistantStripTest" }; AddChild(debris); var specGrid = Catalog.CreateWithDefaultLoadout(Catalog.Anvil); var specVis = VehicleVisualInstance.Create(cache, "anvil", VehicleVisualRole.SpectatorPatron); specVis.Root.Position = new Vector3(0f, 0f, 180f); AddChild(specVis.Root); specVis.SyncMountedGear(specGrid); specVis.SetLodState(useStaticLod: true, castShadows: false); Check(specVis.IsStaticLod && !specVis.ModelRoot.Visible, "Expected intact distant rig at 180m to start in static far LOD"); int stripCx = -1, stripCy = -1; for (int cy = 0; cy < specGrid.Spec.Height && stripCx < 0; cy++) { for (int cx = 0; cx < specGrid.Spec.Width; cx++) { if (specVis.CountDetachablePartsForCell(cx, cy) > 0) { stripCx = cx; stripCy = cy; break; } } } Check(stripCx >= 0, "Expected Anvil distant rig to have detachable cell parts"); if (stripCx >= 0) { specGrid.Armor[stripCx, stripCy] = 0f; } specVis.SyncDamageAndHeat(specGrid, debris, Vector3.Zero); specVis.SetLodState(useStaticLod: true, castShadows: false); Check(debris.ActiveCount >= 1, $"Expected distant stripped rig at 180m to detach debris immediately, got {debris.ActiveCount}"); Check(specVis.HasAnyStrippedCell && !specVis.IsStaticLod && specVis.ModelRoot.Visible, "Expected distant stripped rig to keep ModelRoot visible without popping armor back on at far LOD"); specVis.Root.QueueFree(); debris.QueueFree(); } // 10. MultiMeshPartPool & PomDecalPool sanity: live arena submits into MultiMeshPartPool and PomDecalPool stamps impacts cleanly { var localC = _main.Session.LocalContender; _main.Arena.PomDecals.StampTestDecal( new Vector3(localC.X + 2f, _main.Session.ViewState.Terrain.SampleHeight(localC.X + 2f, localC.Z) + 0.03f, localC.Z), Vector3.Up, 1.2f, tileIndex: 14); _main.Arena.Sync(_main.Session, 1.6f, 1f / 60f); Check(_main.Arena.PartPool.TotalSubmittedInstances > 0, $"Expected MultiMeshPartPool to submit active instances, got {_main.Arena.PartPool.TotalSubmittedInstances}"); Check(_main.Arena.PomDecals.ActiveCount >= 1, $"Expected PomDecalPool to hold >= 1 active decal, got {_main.Arena.PomDecals.ActiveCount}"); _main.Hud.PushTestHitArc(localC.X + 20f, localC.Z + 10f, WeaponVisualClass.Explosive); Check(_main.Hud.ActiveHitArcCount >= 1, "Expected CrosshairOverlay to accept incoming hit arc"); } // 11. Finding 1: Merged MultiMeshPartPool meshes preserve real non-white material albedos and intact COLOR_0.R AO { foreach (string vid in new[] { "paladin", "jackal" }) { var tpl = cache.Vehicles[vid]; var meshesToCheck = new List { tpl.SingleSurfaceStaticMesh }; for (int i = 0; i < tpl.StaticRigidParts.Count; i++) meshesToCheck.Add(tpl.StaticRigidParts[i].Mesh); for (int i = 0; i < tpl.DetachableRigidParts.Count; i++) meshesToCheck.Add(tpl.DetachableRigidParts[i].Mesh); float minAo = 1f; float maxAo = 0f; int whiteNeutralVerts = 0; int darkNeutralVerts = 0; int armorBandVerts = 0; int totalVerts = 0; for (int m = 0; m < meshesToCheck.Count; m++) { ArrayMesh am = meshesToCheck[m]; for (int s = 0; s < am.GetSurfaceCount(); s++) { var arr = am.SurfaceGetArrays(s); if (arr.Count <= (int)Mesh.ArrayType.Color || arr[(int)Mesh.ArrayType.Color].VariantType != Variant.Type.PackedColorArray || arr[(int)Mesh.ArrayType.TexUV].VariantType != Variant.Type.PackedVector2Array || arr[(int)Mesh.ArrayType.TexUV2].VariantType != Variant.Type.PackedVector2Array) { Check(false, $"Merged MultiMesh '{vid}' missing Color/UV/UV2 arrays"); continue; } Color[] cols = arr[(int)Mesh.ArrayType.Color].AsColorArray(); Vector2[] uv0 = arr[(int)Mesh.ArrayType.TexUV].AsVector2Array(); Vector2[] uv1 = arr[(int)Mesh.ArrayType.TexUV2].AsVector2Array(); for (int v = 0; v < cols.Length; v++) { totalVerts++; float ao = cols[v].R; if (ao < minAo) minAo = ao; if (ao > maxAo) maxAo = ao; int band = (int)MathF.Floor((uv1[v].Y + 0.5f) * 0.5f); float r = uv0[v].X; float g = uv0[v].Y; float b = uv1[v].X; if (band < 3) { if (r > 0.95f && g > 0.95f && b > 0.95f) whiteNeutralVerts++; if (MathF.Max(r, MathF.Max(g, b)) < 0.15f) darkNeutralVerts++; } else if (band == 3) { armorBandVerts++; } } } } GD.Print($"SMOKE INFO: MechPaint '{vid}' verts={totalVerts} COLOR_0.R=[{minAo:F4}, {maxAo:F4}] whiteNeutral={whiteNeutralVerts} darkNeutral={darkNeutralVerts} armorBand={armorBandVerts}"); Check(totalVerts > 0 && minAo >= 0.03f && maxAo > 0.90f, $"Expected '{vid}' COLOR_0.R AO intact (min >= 0.03, max > 0.90), got [{minAo:F4}, {maxAo:F4}]"); Check(whiteNeutralVerts == 0, $"Expected zero white-washed band 0..2 vertices on '{vid}', got {whiteNeutralVerts}"); Check(darkNeutralVerts > 0 && armorBandVerts > 0, $"Expected both dark non-white rubber/gunmetal ({darkNeutralVerts}) and olive armor ({armorBandVerts}) vertices on '{vid}'"); } Check(VehicleVisualInstance.PerfMaterialDupCount == 0, $"Expected zero StandardMaterial3D duplicates, got {VehicleVisualInstance.PerfMaterialDupCount}"); } // 12. Cut 5d-2: Unified SimEvent -> ParticlePool idempotency + OmniLight3D[4] cap + CameraJuice zero-idle-jitter + Hud X-flash & vignette { var particles = _main.Arena.Particles; particles.ClearAll(); int beforeCount = particles.ActiveParticleCount; int tracerId = _main.Session.ViewState.AllocateTracerId(); var localC = _main.Session.LocalContender; Vector3 pPos = new(localC.X, localC.Y, localC.Z); var shotEvent = new ShotFiredEvent { TracerId = tracerId, IsSpectatorShooter = false, ShooterId = _main.Session.LocalContenderId, StartX = pPos.X, StartY = pPos.Y + 1f, StartZ = pPos.Z, EndX = pPos.X + 20f, EndY = pPos.Y + 1f, EndZ = pPos.Z, ColorRgba = 0xFFEEDDAAu, Ttl = 0.03f, WeaponClass = (byte)WeaponVisualClass.Explosive, WeaponId = "recoilless" }; var simBatch = new List { shotEvent }; var emptyFootsteps = new List(); _main.Arena.ConsumeEvents(_main.Session, simBatch, emptyFootsteps, 0f, _main.SampleCurrentMapGroundTint); int afterFirst = particles.ActiveParticleCount; Check(afterFirst == beforeCount + 5, $"Expected recoilless ShotFiredEvent #{tracerId} to spawn 1 muzzle starburst + 4 smoke puffs (+5 particles), got +{afterFirst - beforeCount}"); // Re-consume with dt=0: idempotent TracerId dedupe must NOT double-emit _main.Arena.ConsumeEvents(_main.Session, simBatch, emptyFootsteps, 0f, _main.SampleCurrentMapGroundTint); _main.Arena.ConsumeEvents(_main.Session, simBatch, emptyFootsteps, 0f, _main.SampleCurrentMapGroundTint); Check(particles.ActiveParticleCount == afterFirst, $"Expected duplicate ShotFiredEvent #{tracerId} across dt=0 frames to spawn once, got {afterFirst} -> {particles.ActiveParticleCount}"); // OmniLight3D[2] pool strictly capped at <= 2 active lights even under 12 simultaneous flashes particles.ClearAll(); for (int f = 0; f < 12; f++) { particles.TriggerFlashLightForTest( pPos + new Vector3(f * 2f, 1.5f, 0f), new Color(1f, 0.7f, 0.3f), 3.0f, 12f, 0.15f, priority: f); } particles.AdvanceAndCommit(0f); Check(particles.FlashLightPoolSize == 2 && particles.ActiveFlashLightCount <= 2 && particles.PeakFlashLightCount <= 2, $"Expected OmniLight3D pool capped at <= 2, got active={particles.ActiveFlashLightCount} peak={particles.PeakFlashLightCount}"); // Far walker footstep pulse (>70m static LOD, <=110m) still emits terrain-tinted dust in ParticlePool particles.ClearAll(); var farStep = new FootstepPulse( IsContender: true, EntityId: 99, LegIndex: 0, ChassisId: "bastion", MassKg: 4600f, LoadG: 1.25f, WorldPos: new System.Numerics.Vector3(pPos.X + 85f, pPos.Y, pPos.Z)); _main.Arena.ConsumeEvents(_main.Session, Array.Empty(), new[] { farStep }, 0f, _main.SampleCurrentMapGroundTint); Check(particles.ActiveParticleCount >= 3, $"Expected far walker (85m > 70m static LOD) footstep to emit dust puffs, got {particles.ActiveParticleCount}"); particles.ClearAll(); // CameraJuiceState zero-idle-jitter & ComputeCenterScreenAim invariance under trauma var juice = _main.CameraJuice; juice.Reset(); Check(juice.IsIdle, "Expected CameraJuiceState idle after Reset"); var (aimIdleX, aimIdleY, aimIdleZ) = _main.ProbeCenterScreenAim(); juice.ConsumeEvents(simBatch, _main.Session.LocalContenderId, new System.Numerics.Vector3(pPos.X, pPos.Y, pPos.Z), _main.Session); juice.Update(0.016f, 0f, false); Check(!juice.IsIdle && juice.RecoilPitchRad > 0f, "Expected CameraJuiceState recoil after local recoilless shot"); var (aimJuiceX, aimJuiceY, aimJuiceZ) = _main.ProbeCenterScreenAim(); Check(MathF.Abs(aimIdleX - aimJuiceX) < 1e-4f && MathF.Abs(aimIdleY - aimJuiceY) < 1e-4f && MathF.Abs(aimIdleZ - aimJuiceZ) < 1e-4f, "Expected ComputeCenterScreenAim to remain strictly invariant during camera recoil/trauma"); juice.Reset(); // Hud reticle hit-marker X-flash + hud_vignette.gdshader falsification _main.Hud.ResetFeedback(); Check(!_main.Hud.HasActiveHitMarker && !_main.Hud.IsVignetteVisible, "Expected HUD hit-marker & vignette inactive when cool and unhit"); // Non-local shooter must produce ZERO reticle hit-marker flash var aiHit = new HitImpactEvent { EventId = 8801, ShooterId = _main.Session.LocalContenderId + 1, IsContenderShooter = true, TargetKind = (byte)HitTargetKind.Contender, TargetId = _main.Session.LocalContenderId + 2, ArmorDamage = 18f, CoreDamage = 0f, Killed = false }; _main.Hud.ConsumeEvents(new ISimEvent[] { aiHit }, _main.Session.LocalContenderId, 1.0f, 0.2f); Check(!_main.Hud.HasActiveHitMarker, "Expected AI/other shooter hit NOT to trigger local reticle hit-marker"); // Local shooter hitting Terrain / StaticCover / Airburst must produce ZERO reticle hit-marker flash var missTerrainHit = new HitImpactEvent { EventId = 8810, ShooterId = _main.Session.LocalContenderId, IsContenderShooter = true, TargetKind = (byte)HitTargetKind.Terrain, TargetId = -1, ArmorDamage = 0f, CoreDamage = 0f, Killed = false }; var missCoverHit = new HitImpactEvent { EventId = 8811, ShooterId = _main.Session.LocalContenderId, IsContenderShooter = true, TargetKind = (byte)HitTargetKind.StaticCover, TargetId = 0, ArmorDamage = 0f, CoreDamage = 0f, Killed = false }; var missAirburstHit = new HitImpactEvent { EventId = 8812, ShooterId = _main.Session.LocalContenderId, IsContenderShooter = true, TargetKind = (byte)HitTargetKind.StaticCover, TargetId = -1, IsAirburst = true, ArmorDamage = 0f, CoreDamage = 0f, Killed = false }; _main.Hud.ConsumeEvents(new ISimEvent[] { missTerrainHit, missCoverHit, missAirburstHit }, _main.Session.LocalContenderId, 1.0f, 0.2f); Check(!_main.Hud.HasActiveHitMarker, "Expected Terrain/StaticCover/Airburst miss NOT to trigger local reticle hit-marker"); // Local armor hit -> Armor X-flash var localArmorHit = new HitImpactEvent { EventId = 8802, ShooterId = _main.Session.LocalContenderId, IsContenderShooter = true, TargetKind = (byte)HitTargetKind.Contender, TargetId = _main.Session.LocalContenderId + 1, ArmorDamage = 22f, CoreDamage = 0f, Killed = false }; _main.Hud.ConsumeEvents(new ISimEvent[] { localArmorHit }, _main.Session.LocalContenderId, 1.0f, 0.2f); Check(_main.Hud.HasActiveHitMarker && _main.Hud.ActiveHitMarkerKind == HitMarkerKind.Armor, $"Expected Armor hit-marker, got {_main.Hud.ActiveHitMarkerKind}"); // Local core hit -> Core X-flash var localCoreHit = new HitImpactEvent { EventId = 8803, ShooterId = _main.Session.LocalContenderId, IsContenderShooter = true, TargetKind = (byte)HitTargetKind.Contender, TargetId = _main.Session.LocalContenderId + 1, ArmorDamage = 10f, CoreDamage = 14f, Killed = false }; _main.Hud.ConsumeEvents(new ISimEvent[] { localCoreHit }, _main.Session.LocalContenderId, 1.0f, 0.2f); Check(_main.Hud.HasActiveHitMarker && _main.Hud.ActiveHitMarkerKind == HitMarkerKind.Core, $"Expected Core hit-marker, got {_main.Hud.ActiveHitMarkerKind}"); // Local kill + overheat -> Kill double-X + vignette active var localKillHit = new HitImpactEvent { EventId = 8804, ShooterId = _main.Session.LocalContenderId, IsContenderShooter = true, TargetKind = (byte)HitTargetKind.Contender, TargetId = _main.Session.LocalContenderId + 1, ArmorDamage = 0f, CoreDamage = 35f, Killed = true }; _main.Hud.ConsumeEvents(new ISimEvent[] { localKillHit }, _main.Session.LocalContenderId, 1.0f, 0.92f); Check(_main.Hud.HasActiveHitMarker && _main.Hud.ActiveHitMarkerKind == HitMarkerKind.Kill && _main.Hud.IsVignetteVisible, $"Expected Kill hit-marker & overheat vignette active, got kind={_main.Hud.ActiveHitMarkerKind} vig={_main.Hud.IsVignetteVisible}"); _main.Hud.ResetFeedback(); } // 13. Loopback IClientArenaSession check: ServerMatchHost + RemoteArenaSession join + snapshot sync { using var host = new ServerMatchHost(IPAddress.Loopback, port: 0, seed: 42, mapKind: ArenaMapKind.Desert); using var remote = new RemoteArenaSession(new IPEndPoint(IPAddress.Loopback, host.BoundPort), "SmokeClient"); IClientArenaSession remoteIface = remote; long nowMs = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); for (int t = 0; t < 15 && !remote.IsJoined; t++) { host.StepOnce(nowMs + t * 16); remoteIface.BeginRenderFrame(1.0 / 60.0, 1.0f); } Check(remote.IsJoined && remoteIface.ConnectionStatus.Connected, $"Expected RemoteArenaSession loopback connect inside Smoke, label='{remoteIface.ConnectionStatus.StateLabel}'"); for (int t = 0; t < 6; t++) { remoteIface.SubmitLocalInput(new PlayerInput(0.5f, 0f, 10f, 10f, false, false, false), isPhysicsTick: true); host.StepOnce(nowMs + 300 + t * 16); remoteIface.BeginRenderFrame(1.0 / 60.0, 1.0f); } Check(remote.LastSnapshotSeq > 0, $"Expected loopback RemoteArenaSession to receive snapshots, got seq={remote.LastSnapshotSeq}"); Check(remoteIface.LocalContender.Alive, "Expected loopback RemoteArenaSession LocalContender alive"); } // 14. Cut 5d-1: Headless AudioBank, voice-cap/priority/dedupe, and mass-scaled GRF footstep pitch falsification { var audio = _main.Audio; audio.EnsureInitialized(); Check(audio.Bank.HavenClipCount == 25, $"Expected 25 curated Haven clips in ProceduralAudioBank, got {audio.Bank.HavenClipCount}"); Check(audio.Bank.ProceduralClipCount == RustToDust.Core.Audio.PcmSynth.CueRegistry.Count, $"Expected {RustToDust.Core.Audio.PcmSynth.CueRegistry.Count} procedural clips in ProceduralAudioBank, got {audio.Bank.ProceduralClipCount}"); audio.ClearAll(); audio.ResetStatsForTest(); var localC = _main.Session.LocalContender; Vector3 listener = new(localC.X, localC.Y, localC.Z); var burstEvents = new List(); // Local player shot first (priority 10) burstEvents.Add(new ShotFiredEvent { TracerId = 90001, IsSpectatorShooter = false, ShooterId = _main.Session.LocalContenderId, StartX = listener.X, StartY = listener.Y + 1f, StartZ = listener.Z, EndX = listener.X + 40f, EndY = listener.Y + 1f, EndZ = listener.Z, WeaponClass = (byte)WeaponVisualClass.KineticLight, WeaponId = "mg_762" }); // 5-pellet flak salvo from contender 1 -> must dedupe to 1 audio voice for (int p = 0; p < 5; p++) { burstEvents.Add(new ShotFiredEvent { TracerId = 90010 + p, IsSpectatorShooter = false, ShooterId = 1, StartX = listener.X + 18f, StartY = listener.Y + 1f, StartZ = listener.Z, EndX = listener.X, EndY = listener.Y + 1f, EndZ = listener.Z, WeaponClass = (byte)WeaponVisualClass.Explosive, WeaponId = "flak" }); } // 30 simultaneous distant AI shots (>150m, <240m) trying to saturate all 19 one-shot voices for (int a = 2; a < 32; a++) { burstEvents.Add(new ShotFiredEvent { TracerId = 90100 + a, IsSpectatorShooter = false, ShooterId = a, StartX = listener.X + 175f, StartY = listener.Y + 1f, StartZ = listener.Z + (a % 5), EndX = listener.X, EndY = listener.Y + 1f, EndZ = listener.Z, WeaponClass = (byte)WeaponVisualClass.Autocannon, WeaponId = "autocannon" }); } // 1 event beyond MaxAudioDistance (260m) -> must be culled (0 voices) burstEvents.Add(new ShotFiredEvent { TracerId = 90999, IsSpectatorShooter = false, ShooterId = 99, StartX = listener.X + 320f, StartY = listener.Y + 1f, StartZ = listener.Z, EndX = listener.X, EndY = listener.Y + 1f, EndZ = listener.Z, WeaponClass = (byte)WeaponVisualClass.Explosive, WeaponId = "recoilless" }); audio.ConsumeSimEvents(_main.Session, burstEvents, listener); Check(audio.Active3DVoiceCount <= ArenaAudioSystem.Total3DVoiceCount, $"Active 3D voices exceeded 24 cap: {audio.Active3DVoiceCount}"); Check(audio.ActiveOneShotVoiceCount == ArenaAudioSystem.OneShotVoiceCount, $"Expected 19 saturated one-shot voices, got {audio.ActiveOneShotVoiceCount}"); Check(audio.DedupedCount == 4, $"Expected 5-pellet flak salvo to dedupe 4 pellets, got DedupedCount={audio.DedupedCount}"); Check(audio.RejectedDistanceCount == 1, $"Expected >260m event to be distance-culled, got RejectedDistanceCount={audio.RejectedDistanceCount}"); Check(audio.HasActiveVoiceForSource(isLocalSource: true, sourceEntityId: _main.Session.LocalContenderId), "Expected local player priority-10 voice never to be stolen by distant AI shots"); // Footstep mass-scaled pitch verification: Bastion (4600 kg) pitch < Kestrel (1650 kg) pitch audio.ClearAll(); var kestrelPulse = new FootstepPulse(true, 0, 0, "kestrel", Catalog.Kestrel.MassKg, 1.0f, new System.Numerics.Vector3(listener.X, listener.Y, listener.Z)); audio.ConsumeFootsteps(new[] { kestrelPulse }, _main.Session.LocalContenderId, listener); float? kestrelPitch = audio.GetLastPitchForClipPrefix("footstep_"); var bastionPulse = new FootstepPulse(true, 1, 0, "bastion", Catalog.Bastion.MassKg, 1.0f, new System.Numerics.Vector3(listener.X + 10f, listener.Y, listener.Z)); audio.ConsumeFootsteps(new[] { bastionPulse }, _main.Session.LocalContenderId, listener); float? bastionPitch = audio.GetLastPitchForClipPrefix("footstep_heavy_"); Check(kestrelPitch.HasValue && bastionPitch.HasValue && bastionPitch.Value < kestrelPitch.Value, $"Expected Bastion pitch ({bastionPitch}) < Kestrel pitch ({kestrelPitch})"); // Finding 4: TerrainStampEvent(Crater) + ContenderEliminatedEvent in same batch plays impact_explosion EXACTLY ONCE audio.ClearAll(); var victim = _main.Session.ViewState.Contenders[1]; var killEvents = new ISimEvent[] { new TerrainStampEvent { Kind = (byte)TerrainStampKind.Crater, X = victim.X, Z = victim.Z, Radius = 4.2f, Depth = 0.3f }, new ContenderEliminatedEvent { VictimId = victim.Id, KillerId = _main.Session.LocalContenderId, IsSpectatorKiller = false } }; audio.ConsumeSimEvents(_main.Session, killEvents, listener); int expCount = audio.CountActiveVoicesForClip("impact_explosion"); int ejectCount = audio.CountActiveVoicesForClip("mech_eject"); Check(expCount == 1 && ejectCount == 1, $"Expected kill crater+eliminated batch to play impact_explosion=1 & mech_eject=1, got exp={expCount} eject={ejectCount}"); // Finding 5: ResetForSession seeds loadout baselines so first equip (1 -> 2) plays mech_quick_bolt audio.ResetForSession(_main.Session); var equipEv = new ContenderLoadoutEvent { ContenderId = localC.Id, ChassisId = localC.Grid.Spec.Id, LoadoutVersion = localC.LoadoutVersion + 1 }; audio.ConsumeSimEvents(_main.Session, new ISimEvent[] { equipEv }, listener); Check(audio.CountActiveUiVoicesForClip("mech_quick_bolt") == 1, $"Expected first ContenderLoadoutEvent (1 -> 2) after ResetForSession to play mech_quick_bolt, got {audio.CountActiveUiVoicesForClip("mech_quick_bolt")}"); // Finding 3: Out-of-PVS deaths spawn zero phantom particles, lights, or audio audio.ResetForSession(_main.Session); var particles3 = _main.Arena.Particles; particles3.ClearAll(); var hiddenSession = new HiddenRemoteDeathsSession(_main.Session); var spec0 = _main.Session.ViewState.Spectators.Spectators[0]; var hiddenDeaths = new ISimEvent[] { new ContenderEliminatedEvent { VictimId = victim.Id, KillerId = localC.Id, IsSpectatorKiller = false }, new SpectatorDestroyedEvent { SpectatorId = spec0.Id, KillerContenderId = localC.Id } }; particles3.ConsumeEvents(hiddenSession, hiddenDeaths, listener, hasCam: true, _main.SampleCurrentMapGroundTint); particles3.AdvanceAndCommit(0f); audio.ConsumeSimEvents(hiddenSession, hiddenDeaths, listener); Check(particles3.ActiveParticleCount == 0 && particles3.ActiveFlashLightCount == 0 && audio.ActiveOneShotVoiceCount == 0, $"Expected out-of-PVS deaths to spawn 0 VFX/SFX, got particles={particles3.ActiveParticleCount} lights={particles3.ActiveFlashLightCount} voices={audio.ActiveOneShotVoiceCount}"); particles3.ClearAll(); GD.Print($"SMOKE INFO: Audio verified (haven={audio.Bank.HavenClipCount}, proc={audio.Bank.ProceduralClipCount}, dummy={audio.IsDummyAudio}, kestrelPitch={kestrelPitch:F3}, bastionPitch={bastionPitch:F3})"); } await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); } private void VerifyRigMotion( VehicleAssetCache cache, string vehicleId, string jointId, VehicleRigDriveInput input, float minRotRad) { var vis = VehicleVisualInstance.Create(cache, vehicleId, VehicleVisualRole.Player); Check(vis.Joints.TryGetValue(jointId, out var j), $"Missing joint '{jointId}' on '{vehicleId}'"); if (j is not null) { Transform3D before = j.Node.Transform; for (int s = 0; s < 20; s++) { VehicleRigAnimator.Update(vis, in input, Basis.Identity); } Transform3D after = j.Node.Transform; float deltaRad = before.Basis.GetRotationQuaternion().AngleTo(after.Basis.GetRotationQuaternion()); GD.Print($"SMOKE INFO: Rig {vehicleId}.{jointId} delta={deltaRad:F4}rad"); Check(deltaRad > minRotRad && !HasNaN(after), $"Expected {vehicleId}.{jointId} rotation delta > {minRotRad:F4}rad with zero NaNs, got {deltaRad:F5}"); } vis.Root.QueueFree(); } private static int CountMeshInstances(Node cur) { int count = cur is MeshInstance3D ? 1 : 0; for (int i = 0; i < cur.GetChildCount(); i++) { count += CountMeshInstances(cur.GetChild(i)); } return count; } private static Vector3 TransformPointToAncestor(Node3D node, Node3D ancestor, Vector3 localPt) { Transform3D xf = Transform3D.Identity; for (Node? cur = node; cur is Node3D n3d && cur != ancestor; cur = cur.GetParent()) { xf = n3d.Transform * xf; } return xf * localPt; } private static Vector3? ComputeSubtreeVertexCentroidInAncestor(Node3D subRoot, Node3D ancestor, string partName) { Vector3 sum = Vector3.Zero; int count = 0; AccumulatePartCentroidRecursive(subRoot, ancestor, partName, ref sum, ref count); return count > 0 ? sum / count : null; } private static void AccumulatePartCentroidRecursive( Node cur, Node3D ancestor, string partName, ref Vector3 sum, ref int count) { if (cur is MeshInstance3D mi && mi.Mesh is { } mesh && mi.Name.ToString().Equals(partName, StringComparison.OrdinalIgnoreCase)) { Transform3D toAnc = Transform3D.Identity; for (Node? p = mi; p is Node3D n3d && p != ancestor; p = p.GetParent()) { toAnc = n3d.Transform * toAnc; } int surfCount = mesh.GetSurfaceCount(); for (int s = 0; s < surfCount; s++) { var arrays = mesh.SurfaceGetArrays(s); if (arrays.Count <= (int)Mesh.ArrayType.Vertex || arrays[(int)Mesh.ArrayType.Vertex].VariantType != Variant.Type.PackedVector3Array) { continue; } Vector3[] verts = arrays[(int)Mesh.ArrayType.Vertex].AsVector3Array(); for (int v = 0; v < verts.Length; v++) { sum += toAnc * verts[v]; count++; } } } for (int i = 0; i < cur.GetChildCount(); i++) { AccumulatePartCentroidRecursive(cur.GetChild(i), ancestor, partName, ref sum, ref count); } } private static float ComputeSubtreeMinWorldY(Node3D root, float baseWorldY, bool relativeToModelRoot = false) { float minY = float.PositiveInfinity; if (relativeToModelRoot) { Transform3D id = Transform3D.Identity; for (int i = 0; i < root.GetChildCount(); i++) { AccumulateMinYRecursive(root.GetChild(i), id, ref minY); } } else { AccumulateMinYRecursive(root, new Transform3D(Basis.Identity, new Vector3(0f, baseWorldY, 0f)), ref minY); } return minY; } private static void AccumulateMinYRecursive(Node cur, Transform3D parentXf, ref float minY) { Transform3D xf = cur is Node3D n3d ? parentXf * n3d.Transform : parentXf; if (cur is MeshInstance3D mi && mi.Mesh is { } mesh) { int surfCount = mesh.GetSurfaceCount(); for (int s = 0; s < surfCount; s++) { var arrays = mesh.SurfaceGetArrays(s); if (arrays.Count <= (int)Mesh.ArrayType.Vertex || arrays[(int)Mesh.ArrayType.Vertex].VariantType != Variant.Type.PackedVector3Array) { continue; } Vector3[] verts = arrays[(int)Mesh.ArrayType.Vertex].AsVector3Array(); for (int v = 0; v < verts.Length; v++) { float wy = (xf * verts[v]).Y; if (wy < minY) { minY = wy; } } } } for (int i = 0; i < cur.GetChildCount(); i++) { AccumulateMinYRecursive(cur.GetChild(i), xf, ref minY); } } private static bool HasNaN(Transform3D t) { return !t.Origin.IsFinite() || !t.Basis.X.IsFinite() || !t.Basis.Y.IsFinite() || !t.Basis.Z.IsFinite(); } private async Task VerifyMaxLoadPaladinGarageAsync() { var grid = _main.Session.LocalContender.Grid; grid.SwapChassis(Catalog.Paladin); Check(grid.TryMount(Catalog.TouringPlasma, "hp.weapon.sh_l"), "Expected TouringPlasma on Paladin hp.weapon.sh_l"); Check(grid.TryMount(Catalog.WeldedPlate, "hp.armor.torso"), "Expected WeldedPlate on Paladin hp.armor.torso"); Check(grid.TryMount(Catalog.TouringPlasma, "hp.weapon.sh_r"), "Expected TouringPlasma on Paladin hp.weapon.sh_r"); Check(grid.TryMount(Catalog.GildedLance, "hp.weapon.arm_l"), "Expected GildedLance on Paladin hp.weapon.arm_l"); Check(grid.TryMount(Catalog.NobleCore, "hp.engine.chest"), "Expected NobleCore on Paladin hp.engine.chest"); Check(grid.TryMount(Catalog.GildedLance, "hp.weapon.arm_r"), "Expected GildedLance on Paladin hp.weapon.arm_r"); Check(grid.TryMount(Catalog.GoldRadiator, "hp.radiator.back_l"), "Expected GoldRadiator on Paladin hp.radiator.back_l"); Check(grid.TryMount(Catalog.WeldedPlate, "hp.armor.legs"), "Expected WeldedPlate on Paladin hp.armor.legs"); Check(grid.TryMount(Catalog.GoldRadiator, "hp.radiator.back_r"), "Expected GoldRadiator on Paladin hp.radiator.back_r"); grid.Cargo.Clear(); var cargoSpecs = new[] { Catalog.TouringPlasma, Catalog.GoldRadiator, Catalog.GildedLance, Catalog.NobleCore, Catalog.Recoilless, Catalog.Autocannon, Catalog.TurboCore, Catalog.CopperRad, Catalog.WeldedPlate }; for (int i = 0; i < cargoSpecs.Length; i++) { Check(grid.TryAddCargo(cargoSpecs[i]), $"Expected cargo slot #{i} ({cargoSpecs[i].Name}) to fit on Paladin"); } if (!_main.Hud.GarageExpanded) { _main.Hud.ToggleGarage(); } _main.Hud.Sync(_main.Session); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); Vector2 vpSize = GetViewport().GetVisibleRect().Size; Rect2 blRect = _main.Hud.BottomLeftPanelRect; Rect2 chyronRect = _main.Hud.ChyronPanelRect; float chyronGap = chyronRect.Position.X - blRect.End.X; GD.Print($"SMOKE INFO: Max-load Paladin Garage rect={blRect}, chyron gap={chyronGap:F1}px at {vpSize}"); Check(!_main.Hud.HasPanelOverlapOrClip(vpSize), $"Max-load Paladin Garage panels overlapped or clipped at {vpSize}"); Check(blRect.End.X <= 610f, $"Expected max-load Paladin Garage End.X <= 610px, got {blRect.End.X:F1}"); Check(!blRect.HasPoint(vpSize * 0.5f), $"Expected max-load Paladin Garage not to cover viewport center {vpSize * 0.5f}, rect={blRect}"); Check(chyronGap > 80f, $"Expected > 80px breathing room between Garage and Chyron, got {chyronGap:F1}px"); _main.Hud.ToggleGarage(); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); } private async Task VerifySionMapAsync() { _main.Reset(42, ArenaMapKind.Sion, skipInitialDrop: true); Check(_main.Failure is null, $"Sion Reset failed: {_main.Failure}"); if (_main.Failure is not null) { return; } await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); var sionState = _main.Session.ViewState; Check(_main.MapKind == ArenaMapKind.Sion && sionState.MapKind == ArenaMapKind.Sion, "Expected Sion map kind after Reset"); Check(_main.SionMap.Visible && !_main.Terrain.Visible, "Expected SionMapRenderer visible and Desert TerrainRenderer hidden"); Check(_main.SionMap.IsBuilt, "Expected SionMapRenderer.IsBuilt == true"); Check(_main.SionMap.TerrainChunkCount == 36, $"Expected 36 Sion terrain chunks, got {_main.SionMap.TerrainChunkCount}"); Check(_main.SionMap.BuildingTileCount == 36, $"Expected 36 Sion building tiles, got {_main.SionMap.BuildingTileCount}"); Check(_main.SionMap.ActiveLod1TileCount > 0, $"Expected > 0 LOD1 tiles near Sion spawn, got {_main.SionMap.ActiveLod1TileCount}"); Check(_main.SionMap.ActiveLod2TileCount > 0, $"Expected > 0 LOD2 tiles in Sion valley, got {_main.SionMap.ActiveLod2TileCount}"); var cam = _main.GetViewport().GetCamera3D(); Check(cam is not null && cam.Far >= 3600f, $"Expected Camera3D.Far >= 3600m on Sion, got {cam?.Far ?? 0f}"); var sionMap = sionState.SionMap!; foreach (var c in sionState.Contenders) { Check(!sionMap.IsInsideAnyBuildingXz(c.X, c.Z, 0f), $"Contender {c.Id} spawned inside building at ({c.X:F1}, {c.Z:F1})"); } foreach (var d in sionState.GroundDrops) { Check(!sionMap.IsInsideAnyBuildingXz(d.X, d.Z, 0f), $"GroundDrop {d.Id} spawned inside building at ({d.X:F1}, {d.Z:F1})"); } Vector2 vpSize = GetViewport().GetVisibleRect().Size; Check(!_main.Hud.HasPanelOverlapOrClip(vpSize), $"Sion HUD panels overlapped or clipped at {vpSize}"); var player = sionState.Contenders[0]; float startX = player.X; float startZ = player.Z; _main.SetScriptedInput(new PlayerInput( Throttle: 1f, Steer: 0f, AimWorldX: startX + MathF.Sin(player.Yaw) * 50f, AimWorldZ: startZ + MathF.Cos(player.Yaw) * 50f, Fire: false, InteractPickup: false, Brake: false)); for (int i = 0; i < 30; i++) { await ToSignal(GetTree(), SceneTree.SignalName.PhysicsFrame); Check(float.IsFinite(player.X) && float.IsFinite(player.Y) && float.IsFinite(player.Z), $"Sion player pose non-finite at frame {i}"); float gh = sionState.Terrain.SampleHeight(player.X, player.Z); Check(player.Y - player.Grid.Spec.HalfHeight >= gh - 0.8f, $"Sion player fell below terrain at frame {i}: bottom={player.Y - player.Grid.Spec.HalfHeight:F2}m < ground={gh:F2}m"); } _main.SetScriptedInput(null); float disp = MathF.Sqrt((player.X - startX) * (player.X - startX) + (player.Z - startZ) * (player.Z - startZ)); Check(disp > 1.5f, $"Expected player displacement > 1.5m on Sion after 30 frames, got {disp:F2}m"); Color inBoundsTint = _main.SionMap.SampleGroundTint(player.X, player.Z); Color outBoundsTint = _main.SionMap.SampleGroundTint(9999f, 9999f); Check(float.IsFinite(inBoundsTint.R) && float.IsFinite(inBoundsTint.G) && float.IsFinite(inBoundsTint.B) && inBoundsTint.R > 0.1f, $"Expected valid Sion SampleGroundTint at player pos, got {inBoundsTint}"); Check(MathF.Abs(outBoundsTint.R - 0.56f) < 0.01f && MathF.Abs(outBoundsTint.G - 0.53f) < 0.01f, $"Expected neutral alpine fallback tint outside Sion bounds, got {outBoundsTint}"); GD.Print($"SMOKE INFO: Sion verified (chunks={_main.SionMap.TerrainChunkCount}, tiles={_main.SionMap.BuildingTileCount}, lod1={_main.SionMap.ActiveLod1TileCount}, lod2={_main.SionMap.ActiveLod2TileCount}, disp={disp:F2}m, tint=({inBoundsTint.R:F2},{inBoundsTint.G:F2},{inBoundsTint.B:F2}))"); } private async Task VerifyOrbitalDropSequenceAsync() { var podTpl = _main.Arena.AssetCache.GetOrLoadDropPod(); Check(podTpl.CoreMesh.GetSurfaceCount() == 1, $"Expected single-surface DropPod CoreMesh, got {podTpl.CoreMesh.GetSurfaceCount()}"); Check(podTpl.PetalMesh.GetSurfaceCount() == 1, $"Expected single-surface DropPod PetalMesh, got {podTpl.PetalMesh.GetSurfaceCount()}"); Check(podTpl.PetalLocalTransforms.Length == 4, $"Expected 4 DropPod petal transforms, got {podTpl.PetalLocalTransforms.Length}"); Check(podTpl.Size.Y >= 4.0f && podTpl.Size.Y <= 5.2f, $"Unexpected DropPod height {podTpl.Size.Y:F2}m"); // Verify COLOR_0 weathering exists on both CoreMesh and PetalMesh var coreArr = podTpl.CoreMesh.SurfaceGetArrays(0); var petalArr = podTpl.PetalMesh.SurfaceGetArrays(0); Check(coreArr.Count > (int)Mesh.ArrayType.Color && coreArr[(int)Mesh.ArrayType.Color].VariantType == Variant.Type.PackedColorArray, "DropPod CoreMesh missing COLOR_0 weathering array"); Check(petalArr.Count > (int)Mesh.ArrayType.Color && petalArr[(int)Mesh.ArrayType.Color].VariantType == Variant.Type.PackedColorArray, "DropPod PetalMesh missing COLOR_0 weathering array"); int bucketsBefore = _main.Arena.PartPool.BucketCount; _main.Reset(42, ArenaMapKind.Sion, skipInitialDrop: false); Check(_main.Failure is null, $"Sion Orbital Reset failed: {_main.Failure}"); if (_main.Failure is not null) { return; } _main.SetPhysicsProcess(false); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); var session = _main.Session; var player = session.LocalContender; Check(player.Lifecycle == ContenderLifecycle.Deploying && player.IsInDropPod, $"Expected player to start Deploying in DropPod, got {player.Lifecycle}"); Check(!player.IsGroundedActive, "Expected player IsGroundedActive == false while inside DropPod"); Check(session.ActivePods.Count >= 50, $"Expected >= 50 Wave 0 active pods (40 gear + 12 contenders), got {session.ActivePods.Count}"); var pVisDeploying = _main.Arena.GetContenderVisual(player.Id); Check(pVisDeploying is null || !pVisDeploying.Root.Visible, "Expected ground vehicle visual hidden while inside DropPod"); _main.Arena.Sync(session, 0.1f, 1f / 60f, 1f); int bucketsDuringDrop = _main.Arena.PartPool.BucketCount; Check(bucketsDuringDrop <= bucketsBefore + 2, $"Expected DropPod to add <= 2 MultiMeshPartPool buckets (Core + Petal), delta={bucketsDuringDrop - bucketsBefore}"); bool sawRetroBurn = false; bool sawGearEarlyTouchdown = false; int touchdownTick = -1; int debrisAtTouchdown = 0; _main.SetScriptedInput(new PlayerInput( Throttle: 1f, Steer: 0f, AimWorldX: player.X, AimWorldZ: player.Z + 120f, Fire: false, InteractPickup: false, Brake: false)); for (int tick = 0; tick < 620; tick++) { var tickInp = _main.Session.LocalContender.IsInDropPod ? new PlayerInput(1f, 0f, player.X, player.Z + 120f, false, false, false) : new PlayerInput(1f, 0f, player.X, player.Z + 60f, false, false, false); session.SubmitLocalInput(in tickInp, isPhysicsTick: true); _main.Arena.Sync(session, (tick + 1) / 60f, 1f / 60f, 1f); var evs = new List(32); session.DrainSimEvents(evs); _main.Arena.ConsumeEvents(session, evs, Array.Empty(), 1f / 60f, _main.SampleCurrentMapGroundTint); _main.CameraJuice.ConsumeEvents(evs, session.LocalContenderId, new System.Numerics.Vector3(player.X, player.Y, player.Z), session); _main.Audio.UpdateFrame(session, evs, Array.Empty(), _main.Camera.GlobalPosition, 1f / 60f, 1f); _main.Hud.Sync(session); if (tick == 270) // t = 4.5s: gear pods should have landed while player is still falling { sawGearEarlyTouchdown = session.ViewState.GroundDrops.Count >= 35 && player.IsInDropPod; } if (player.IsInDropPod) { foreach (var pod in session.ActivePods) { if (pod.PodKind == OrbitalPodKind.Contender && pod.ContenderId == player.Id && pod.Phase == OrbitalPodPhase.RetroBurn) { sawRetroBurn = true; break; } } } else if (touchdownTick < 0 && player.IsGroundedActive) { touchdownTick = tick; debrisAtTouchdown = _main.Arena.Debris.ActiveCount; break; } } Check(sawGearEarlyTouchdown, $"Expected >= 35 Wave 0 gear drops on ground at t=4.5s while player still in pod (drops={session.ViewState.GroundDrops.Count}, inPod={player.IsInDropPod})"); Check(sawRetroBurn, "Expected local player pod to enter RetroBurn phase"); Check(touchdownTick > 240 && touchdownTick < 620, $"Expected player pod touchdown in (240, 620) ticks, got {touchdownTick}"); Check(debrisAtTouchdown >= 4, $"Expected >= 4 blown-off petals in DebrisSystem on touchdown, got {debrisAtTouchdown}"); Check(VehicleVisualInstance.PerfMaterialDupCount == 0, $"Expected 0 material duplicates during orbital drop, got {VehicleVisualInstance.PerfMaterialDupCount}"); var pVisLanded = _main.Arena.GetContenderVisual(player.Id); Check(pVisLanded is not null && pVisLanded.Root.Visible, "Expected player ground chassis visual visible immediately on touchdown"); // Verify post-touchdown ground driving works cleanly float landX = player.X; float landZ = player.Z; for (int t = 0; t < 30; t++) { var driveInp = new PlayerInput(1f, 0f, player.X, player.Z + 60f, false, false, false); session.SubmitLocalInput(in driveInp, isPhysicsTick: true); } float postDisp = MathF.Sqrt((player.X - landX) * (player.X - landX) + (player.Z - landZ) * (player.Z - landZ)); Check(postDisp > 1.5f, $"Expected post-touchdown driving displacement > 1.5m over 30 ticks, got {postDisp:F2}m"); _main.SetScriptedInput(null); _main.SetPhysicsProcess(true); GD.Print($"SMOKE INFO: Cut 6b OrbitalDrop verified (touchdownTick={touchdownTick}, debris={debrisAtTouchdown}, postDisp={postDisp:F2}m, bucketsDelta={bucketsDuringDrop - bucketsBefore}, matDups={VehicleVisualInstance.PerfMaterialDupCount})"); } private async Task VerifyCut7bModularOrdnanceAsync() { var cache = _main.Arena.AssetCache; var partPool = _main.Arena.PartPool; // 1. All 16 modular weapon sub-parts loaded with single-surface COLOR_0 meshes and required sockets Check(cache.WeaponParts.Count == 16, $"Expected 16 cached modular weapon parts, got {cache.WeaponParts.Count}"); foreach (string pid in VehicleAssetCache.ExpectedWeaponPartIds) { var wp = cache.GetOrLoadWeaponPart(pid); Check(wp.SingleSurfaceMesh.GetSurfaceCount() == 1, $"Expected 1 surface on modular part '{pid}', got {wp.SingleSurfaceMesh.GetSurfaceCount()}"); var arr = wp.SingleSurfaceMesh.SurfaceGetArrays(0); Check(arr.Count > (int)Mesh.ArrayType.Color && arr[(int)Mesh.ArrayType.Color].VariantType == Variant.Type.PackedColorArray, $"Modular part '{pid}' missing COLOR_0 attribute"); if (wp.Slot == "receiver") { Check(wp.SocketsLocal.ContainsKey("barrel") && wp.SocketsLocal.ContainsKey("feed"), $"Receiver '{pid}' missing barrel/feed sockets"); } else if (wp.Slot == "barrel") { Check(wp.SocketsLocal.ContainsKey("muzzle"), $"Barrel '{pid}' missing muzzle socket"); } else if (wp.Slot == "muzzle") { Check(wp.SocketsLocal.ContainsKey("muzzle_tip"), $"Muzzle '{pid}' missing muzzle_tip socket"); } } // 2. Mount 50 distinct procedural weapons across all 5 manufacturers & 20 archetypes -> <= 16 new PartPool buckets, 0 matDups VehicleVisualInstance.PerfMaterialDupCount = 0; var testVis = VehicleVisualInstance.Create(cache, "anvil", VehicleVisualRole.Player); AddChild(testVis.Root); var testGrid = Catalog.CreateWithDefaultLoadout(Catalog.Anvil); string? weaponHpId = null; for (int i = 0; i < testGrid.Spec.Hardpoints.Length; i++) { if (testGrid.Spec.Hardpoints[i].Kind == HardpointKind.Weapon && testGrid.Spec.Hardpoints[i].Height >= 2) { weaponHpId = testGrid.Spec.Hardpoints[i].Id; break; } } Check(weaponHpId is not null, "Expected Anvil to have a 1x2 weapon hardpoint for modular assembly test"); // Pre-warm baseline Anvil chassis/cell buckets in PartPool so bucketDelta measures ONLY modular weapon parts if (weaponHpId is not null) { testGrid.Mounted.RemoveAll(m => m.HardpointId == weaponHpId); } testVis.SyncMountedGear(testGrid); partPool.BeginFrame(null); testVis.SubmitToPool(partPool); partPool.EndFrame(); int bucketsBefore = partPool.BucketCount; partPool.BeginFrame(null); if (weaponHpId is not null) { for (int w = 0; w < 50; w++) { byte mfg = (byte)(w % 5); byte arch = (byte)(mfg * 4 + (w % 4)); var pSpec = ProceduralWeaponGenerator.Generate(new ProceduralWeaponKey((ulong)(0xA100 + w), mfg, arch, (byte)(w & 3), 0)); testGrid.Mounted.RemoveAll(m => m.HardpointId == weaponHpId); Check(testGrid.TryMount(pSpec.Module, weaponHpId), $"Failed to mount procedural weapon '{pSpec.DisplayName}' on '{weaponHpId}'"); testVis.SyncMountedGear(testGrid); testVis.SubmitToPool(partPool); if (w < 5) { bool hasAim = testVis.TryGetMountedWeaponCentroidsInModel(weaponHpId, "muzzle", "receiver", out Vector3 frontC, out Vector3 rearC); Check(hasAim && (frontC.Z > rearC.Z + 0.35f), $"Expected modular weapon '{pSpec.DisplayName}' muzzle ({frontC}) forward of receiver ({rearC})"); } } } partPool.EndFrame(); int bucketDelta = partPool.BucketCount - bucketsBefore; Check(bucketDelta <= 16, $"Expected 50 procedural weapons to add <= 16 PartPool buckets, added {bucketDelta}"); Check(VehicleVisualInstance.PerfMaterialDupCount == 0, $"Expected 0 material duplications, got {VehicleVisualInstance.PerfMaterialDupCount}"); Check(CountMeshInstances(testVis.Root) == 0, $"Expected 0 MeshInstance3D children on modular vehicle rig, got {CountMeshInstances(testVis.Root)}"); // Verify shearing a modular weapon hardpoint spawns all 4 sub-parts into DebrisSystem if (weaponHpId is not null) { var testDebris = new DebrisSystem { Name = "SmokeModularShearDebris" }; AddChild(testDebris); var hp = testGrid.FindHardpoint(weaponHpId)!; for (int dy = 0; dy < hp.Height; dy++) { for (int dx = 0; dx < hp.Width; dx++) { testGrid.Armor[hp.X + dx, hp.Y + dy] = 0f; } } testVis.SyncDamageAndHeat(testGrid, testDebris, Vector3.Zero); Check(testDebris.ActiveCount >= 4, $"Expected >= 4 sheared modular sub-parts in DebrisSystem, got {testDebris.ActiveCount}"); testDebris.QueueFree(); } testVis.Root.QueueFree(); // 3. Procedural weapon GroundDrops render with modular parts & clean up on pickup _main.Reset(77, ArenaMapKind.Desert, skipInitialDrop: true); _main.SetPhysicsProcess(false); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); var state = _main.Session.ViewState; var player = _main.Session.LocalContender; int dropsBefore = state.GroundDrops.Count; _main.Arena.Sync(_main.Session, 1.0f, 1f / 60f, 1f); int trackedBefore = _main.Arena.ActiveDropVisualCount; var procDrops = new List(5); for (int m = 0; m < 5; m++) { var pSpec = ProceduralWeaponGenerator.RollForManufacturer((ManufacturerId)m, tier: 2, seed: (ulong)(0x7700 + m)); var gd = new GroundDrop(95000 + m, player.X + 4f + m * 6f, player.Z + 8f, null, pSpec.Module); state.GroundDrops.Add(gd); procDrops.Add(gd); } _main.Arena.Sync(_main.Session, 1.1f, 1f / 60f, 1f); Check(_main.Arena.ActiveDropVisualCount == trackedBefore + 5, $"Expected {trackedBefore + 5} tracked drops after adding 5 mfg drops, got {_main.Arena.ActiveDropVisualCount}"); // 4. HUD 6 chrome panels, 2-line Borderlands tooltips (Garage + Hover + Pickup Prompt), zero overlap at 1280x720 var sabotDream = ProceduralWeaponGenerator.CreateDreamSabotSled(); var droneDream = ProceduralWeaponGenerator.CreateDreamLoiteringDrone(); var mirvDream = ProceduralWeaponGenerator.CreateDreamMirvMineBlanket(); var pGrid = player.Grid; string? pWeaponHp = null; HardpointSpec? pWeaponHpSpec = null; for (int i = 0; i < pGrid.Spec.Hardpoints.Length; i++) { if (pGrid.Spec.Hardpoints[i].Kind == HardpointKind.Weapon && pGrid.Spec.Hardpoints[i].Height >= 2) { pWeaponHp = pGrid.Spec.Hardpoints[i].Id; pWeaponHpSpec = pGrid.Spec.Hardpoints[i]; break; } } if (pWeaponHp is not null && pWeaponHpSpec is not null) { pGrid.Mounted.RemoveAll(m => m.HardpointId == pWeaponHp); Check(pGrid.TryMount(sabotDream.Module, pWeaponHp), "Expected Dream Sabot Sled to mount on player"); if (!_main.Hud.GarageExpanded) _main.Hud.ToggleGarage(); _main.Hud.Sync(_main.Session); _main.Hud.SimulateCellHover(new Vector2I(pWeaponHpSpec.X, pWeaponHpSpec.Y), pWeaponHpSpec); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); int chromeCount = 0; foreach (var _ in _main.Hud.GetChromeMaterials()) chromeCount++; Check(chromeCount == 6, $"Expected 6 HUD chrome panels, got {chromeCount}"); Check(_main.Hud.HoverLabelText.Contains(sabotDream.ManufacturerLabel) && _main.Hud.HoverLabelText.Contains('\n'), $"Expected 2-line Borderlands hover tooltip with manufacturer badge, got: {_main.Hud.HoverLabelText}"); Check(_main.Hud.GarageDetailsText.Contains(sabotDream.SummaryLine1) && _main.Hud.GarageDetailsText.Contains(sabotDream.SummaryLine2), $"Expected Garage details to contain SummaryLine1 & SummaryLine2, got: {_main.Hud.GarageDetailsText}"); // Check nearby pickup prompt 2-line display var nearbyDrop = new GroundDrop(95999, player.X + 1.0f, player.Z + 1.0f, null, droneDream.Module); state.GroundDrops.Add(nearbyDrop); _main.Hud.Sync(_main.Session); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); Check(_main.Hud.PromptLabelText.Contains(droneDream.ManufacturerLabel) && _main.Hud.PromptLabelText.Contains('\n'), $"Expected 2-line pickup prompt with manufacturer & summary, got: {_main.Hud.PromptLabelText}"); Vector2 vpSize = GetViewport().GetVisibleRect().Size; Check(!_main.Hud.HasPanelOverlapOrClip(vpSize), $"HUD overlapped or clipped with procedural tooltip at {vpSize}"); nearbyDrop.PickedUp = true; state.GroundDrops.Remove(nearbyDrop); if (_main.Hud.GarageExpanded) _main.Hud.ToggleGarage(); } for (int i = 0; i < procDrops.Count; i++) procDrops[i].PickedUp = true; _main.Arena.Sync(_main.Session, 1.2f, 1f / 60f, 1f); state.GroundDrops.RemoveRange(dropsBefore, procDrops.Count); // 5. ClientOrdnanceMirror + Haven MWO Audio Hooks across Sabot, Loitering Drone, and MIRV Mines var localSession = (_main.Session as LocalArenaSession)!; var sim = localSession.Inner; for (int cIdx = 1; cIdx < sim.State.Contenders.Count; cIdx++) { sim.SetContenderPose(cIdx, 480f + cIdx * 12f, 480f); } sim.SetContenderPose(0, 0f, 0f, 0f); sim.SetContenderPose(1, 0f, 125f, MathF.PI); // target Anvil/rival 125m ahead int audioShotsBefore = _main.Audio.Total3DPlaysRequested; bool sawMirrorRocket = false; bool sawSabotTransition = false; bool sawMirrorDrone = false; bool sawMirrorMines = false; // 5a: Sabot Rocket Sled if (pWeaponHp is not null) { pGrid.Mounted.RemoveAll(m => m.HardpointId == pWeaponHp); pGrid.TryMount(sabotDream.Module, pWeaponHp); for (int t = 0; t < 35; t++) { var inp = new PlayerInput(0f, 0f, 0f, 125f, Fire: t == 0, InteractPickup: false, Brake: true); _main.Session.SubmitLocalInput(in inp, isPhysicsTick: true); var evs = new List(16); _main.Session.DrainSimEvents(evs); for (int e = 0; e < evs.Count; e++) { if (evs[e] is OrdnanceNodeEvent oe && (OrdnanceEventKind)oe.Kind == OrdnanceEventKind.StageTransition) { sawSabotTransition = true; } } _main.Arena.Sync(_main.Session, 2.0f + t / 60f, 1f / 60f, 1f); _main.Arena.ConsumeEvents(_main.Session, evs, Array.Empty(), 1f / 60f, _main.SampleCurrentMapGroundTint); _main.Audio.UpdateFrame(_main.Session, evs, Array.Empty(), _main.Camera.GlobalPosition, 1f / 60f, 1f); if (_main.Arena.OrdnanceMirror.ActiveCount > 0) sawMirrorRocket = true; } // 5b: Loitering Laser Drone pGrid.Mounted.RemoveAll(m => m.HardpointId == pWeaponHp); pGrid.TryMount(droneDream.Module, pWeaponHp); for (int t = 0; t < 95; t++) { var inp = new PlayerInput(0f, 0f, 0f, 125f, Fire: t == 0, InteractPickup: false, Brake: true); _main.Session.SubmitLocalInput(in inp, isPhysicsTick: true); var evs = new List(16); _main.Session.DrainSimEvents(evs); _main.Arena.Sync(_main.Session, 3.0f + t / 60f, 1f / 60f, 1f); _main.Arena.ConsumeEvents(_main.Session, evs, Array.Empty(), 1f / 60f, _main.SampleCurrentMapGroundTint); _main.Audio.UpdateFrame(_main.Session, evs, Array.Empty(), _main.Camera.GlobalPosition, 1f / 60f, 1f); if (t > 70 && _main.Arena.OrdnanceMirror.ActiveCount > 0) sawMirrorDrone = true; } // 5c: MIRV Minefield Blanket pGrid.Mounted.RemoveAll(m => m.HardpointId == pWeaponHp); pGrid.TryMount(mirvDream.Module, pWeaponHp); for (int t = 0; t < 160; t++) { var inp = new PlayerInput(0f, 0f, 0f, 85f, Fire: t == 0, InteractPickup: false, Brake: true); _main.Session.SubmitLocalInput(in inp, isPhysicsTick: true); var evs = new List(32); _main.Session.DrainSimEvents(evs); _main.Arena.Sync(_main.Session, 5.0f + t / 60f, 1f / 60f, 1f); _main.Arena.ConsumeEvents(_main.Session, evs, Array.Empty(), 1f / 60f, _main.SampleCurrentMapGroundTint); _main.Audio.UpdateFrame(_main.Session, evs, Array.Empty(), _main.Camera.GlobalPosition, 1f / 60f, 1f); if (_main.Arena.OrdnanceMirror.ActiveCount >= 6) sawMirrorMines = true; } } Check(sawMirrorRocket && sawSabotTransition, $"Expected ClientOrdnanceMirror to track Sabot rocket & StageTransition (rocket={sawMirrorRocket}, trans={sawSabotTransition})"); Check(sawMirrorDrone, "Expected ClientOrdnanceMirror to maintain active Loitering Laser Drone after climb"); Check(sawMirrorMines, "Expected ClientOrdnanceMirror to mirror >= 6 MIRV mines after Split"); Check(_main.Audio.Total3DPlaysRequested > audioShotsBefore, $"Expected ArenaAudioSystem Haven MWO ordnance cues to trigger (before={audioShotsBefore}, after={_main.Audio.Total3DPlaysRequested})"); // Verify MatchResetEvent clears ClientOrdnanceMirror cleanly _main.Arena.ConsumeEvents(_main.Session, new ISimEvent[] { new MatchResetEvent() }, Array.Empty(), 1f / 60f, _main.SampleCurrentMapGroundTint); Check(_main.Arena.OrdnanceMirror.ActiveCount == 0, $"Expected MatchResetEvent to clear ClientOrdnanceMirror, got {_main.Arena.OrdnanceMirror.ActiveCount}"); _main.SetPhysicsProcess(true); GD.Print($"SMOKE INFO: Cut 7b verified (16 parts, bucketDelta={bucketDelta}, matDups={VehicleVisualInstance.PerfMaterialDupCount}, audioPlays={_main.Audio.Total3DPlaysRequested - audioShotsBefore})"); } private void VerifyForwardPlusAtmosphere() { string method = RenderingServer.GetCurrentRenderingMethod(); var cmdArgs = System.Environment.GetCommandLineArgs(); bool requestedDummy = false; for (int i = 0; i < cmdArgs.Length; i++) { if (cmdArgs[i] == "--rendering-driver=dummy" || (cmdArgs[i] == "--rendering-driver" && i + 1 < cmdArgs.Length && cmdArgs[i + 1] == "dummy")) { requestedDummy = true; break; } } bool isHeadlessDummy = DisplayServer.GetName() == "headless" && requestedDummy; Check(method == "forward_plus" || (isHeadlessDummy && method == "dummy"), $"Expected RenderingMethod 'forward_plus' (or 'dummy' with --rendering-driver dummy), got '{method}'"); var sionBaked = AtmosphereLutBaker.GetOrBake(ArenaMapKind.Sion); var desertBaked = AtmosphereLutBaker.GetOrBake(ArenaMapKind.Desert); CheckFinitePositiveLut("Sion.Transmittance", sionBaked.TransmittanceImage, AtmosphereLutBaker.TransmittanceWidth, AtmosphereLutBaker.TransmittanceHeight); CheckFinitePositiveLut("Sion.MultiScattering", sionBaked.MultiScatteringImage, AtmosphereLutBaker.MultiScatteringSize, AtmosphereLutBaker.MultiScatteringSize); CheckFinitePositiveLut("Sion.SkyView", sionBaked.SkyViewImage, AtmosphereLutBaker.SkyViewWidth, AtmosphereLutBaker.SkyViewHeight); CheckFinitePositiveLut("Desert.Transmittance", desertBaked.TransmittanceImage, AtmosphereLutBaker.TransmittanceWidth, AtmosphereLutBaker.TransmittanceHeight); CheckFinitePositiveLut("Desert.MultiScattering", desertBaked.MultiScatteringImage, AtmosphereLutBaker.MultiScatteringSize, AtmosphereLutBaker.MultiScatteringSize); CheckFinitePositiveLut("Desert.SkyView", desertBaked.SkyViewImage, AtmosphereLutBaker.SkyViewWidth, AtmosphereLutBaker.SkyViewHeight); Check(sionBaked.ZenithTransmittanceMean > desertBaked.ZenithTransmittanceMean, $"Expected Sion zenith transmittance ({sionBaked.ZenithTransmittanceMean:F4}) > Desert ({desertBaked.ZenithTransmittanceMean:F4})"); Check(desertBaked.HazeColor.R > desertBaked.HazeColor.G && desertBaked.HazeColor.G > desertBaked.HazeColor.B, $"Expected warm golden Desert haze chromaticity R > G > B, got ({desertBaked.HazeColor.R:F3}, {desertBaked.HazeColor.G:F3}, {desertBaked.HazeColor.B:F3})"); Check(sionBaked.HazeColor.B > sionBaked.HazeColor.R, $"Expected cool alpine Sion haze chromaticity B > R, got ({sionBaked.HazeColor.R:F3}, {sionBaked.HazeColor.G:F3}, {sionBaked.HazeColor.B:F3})"); CheckSkyViewHorizonContinuity("Sion", sionBaked.SkyViewImage); CheckSkyViewHorizonContinuity("Desert", desertBaked.SkyViewImage); var atmo = _main.Atmosphere; var env = atmo.Environment; Check(env.TonemapMode == Godot.Environment.ToneMapper.Agx, $"Expected ToneMapper.Agx, got {env.TonemapMode}"); Check(env.GlowEnabled && env.GlowNormalized, $"Expected GlowEnabled && GlowNormalized, got enabled={env.GlowEnabled} norm={env.GlowNormalized}"); Check(env.GlowBlendMode == Godot.Environment.GlowBlendModeEnum.Additive, $"Expected GlowBlendModeEnum.Additive, got {env.GlowBlendMode}"); Check(env.SsrEnabled, "Expected SsrEnabled == true"); Check(env.SsaoEnabled, "Expected SsaoEnabled == true"); Check(env.VolumetricFogEnabled && env.VolumetricFogTemporalReprojectionEnabled, $"Expected VolumetricFogEnabled && TemporalReprojection, got vf={env.VolumetricFogEnabled} tr={env.VolumetricFogTemporalReprojectionEnabled}"); Check(env.FogEnabled && env.FogAerialPerspective >= 0.20f, $"Expected FogEnabled && FogAerialPerspective >= 0.20f, got fog={env.FogEnabled} ap={env.FogAerialPerspective:F2}"); Check(sionBaked.Preset.DepthFogAerialPerspective > 0.7f, $"Expected Sion DepthFogAerialPerspective > 0.7f, got {sionBaked.Preset.DepthFogAerialPerspective:F2}"); var sun = atmo.Sun; Check(sun.DirectionalShadowMode == DirectionalLight3D.ShadowMode.Parallel4Splits && sun.DirectionalShadowMaxDistance >= 280f, $"Expected Parallel4Splits & maxDist >= 280m, got {sun.DirectionalShadowMode} maxDist={sun.DirectionalShadowMaxDistance:F1}"); Check(GetViewport().UseTaa, "Expected GetViewport().UseTaa == true"); int checkedLights = 0; foreach (Node ch in _main.Arena.Particles.GetChildren()) { if (ch is OmniLight3D omni) { checkedLights++; Check(omni.LightVolumetricFogEnergy == 0f, $"Expected {omni.Name}.LightVolumetricFogEnergy == 0f to prevent temporal fog ghosting, got {omni.LightVolumetricFogEnergy}"); } } Check(checkedLights == ParticlePool.MaxFlashLights, $"Expected {ParticlePool.MaxFlashLights} ParticlePool OmniLight3D nodes, found {checkedLights}"); Check(atmo.FilmGrainLayer.Layer == 5 && atmo.FilmGrainLayer.Layer < _main.Hud.Layer, $"Expected FilmGrainLayer.Layer == 5 < Hud.Layer ({_main.Hud.Layer}), got {atmo.FilmGrainLayer.Layer}"); GD.Print($"SMOKE INFO: Cut 8 Forward+ verified (method={method}, sionZenithT={sionBaked.ZenithTransmittanceMean:F4}, desertZenithT={desertBaked.ZenithTransmittanceMean:F4}, desertHaze=({desertBaked.HazeColor.R:F3},{desertBaked.HazeColor.G:F3},{desertBaked.HazeColor.B:F3}), sionHaze=({sionBaked.HazeColor.R:F3},{sionBaked.HazeColor.G:F3},{sionBaked.HazeColor.B:F3}), grainLayer={atmo.FilmGrainLayer.Layer})"); } private void CheckFinitePositiveLut(string label, Image img, int expectedW, int expectedH) { Check(img.GetFormat() == Image.Format.Rgbah, $"Expected {label} format Rgbah, got {img.GetFormat()}"); Check(img.GetWidth() == expectedW && img.GetHeight() == expectedH, $"Expected {label} size {expectedW}x{expectedH}, got {img.GetWidth()}x{img.GetHeight()}"); bool allValid = true; float maxSum = 0f; int w = img.GetWidth(); int h = img.GetHeight(); for (int y = 0; y < h; y += Math.Max(1, h / 8)) { for (int x = 0; x < w; x += Math.Max(1, w / 8)) { Color c = img.GetPixel(x, y); if (!float.IsFinite(c.R) || !float.IsFinite(c.G) || !float.IsFinite(c.B) || c.R < 0f || c.G < 0f || c.B < 0f) { allValid = false; } maxSum = MathF.Max(maxSum, c.R + c.G + c.B); } } Check(allValid && maxSum > 0f, $"Expected finite positive values in {label} LUT (valid={allValid}, maxSum={maxSum:F4})"); } private void CheckSkyViewHorizonContinuity(string label, Image skyView) { int yBelow = AtmosphereLutBaker.SkyViewHeight / 2 - 1; int yAbove = AtmosphereLutBaker.SkyViewHeight / 2; float worstRelJump = 0f; for (int x = 0; x < skyView.GetWidth(); x += 8) { Color cBelow = skyView.GetPixel(x, yBelow); Color cAbove = skyView.GetPixel(x, yAbove); float lBelow = cBelow.R * 0.2126f + cBelow.G * 0.7152f + cBelow.B * 0.0722f; float lAbove = cAbove.R * 0.2126f + cAbove.G * 0.7152f + cAbove.B * 0.0722f; float rel = MathF.Abs(lAbove - lBelow) / MathF.Max(1e-4f, lAbove); if (rel > worstRelJump) worstRelJump = rel; } Check(worstRelJump <= 0.05f, $"Expected smooth below-horizon SkyView seam <= 5% on {label} (y={yBelow}->y={yAbove}), got {worstRelJump * 100f:F2}%"); } private static int CountPremulViolations(Image img, float tolerance) { int count = 0; int w = img.GetWidth(); int h = img.GetHeight(); for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { Color c = img.GetPixel(x, y); float maxRgb = MathF.Max(c.R, MathF.Max(c.G, c.B)); if (maxRgb > c.A + tolerance) { count++; } } } return count; } private static int CountNonZeroAlphaPixels(Image img, float minAlpha) { int count = 0; int w = img.GetWidth(); int h = img.GetHeight(); for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { if (img.GetPixel(x, y).A > minAlpha) count++; } } return count; } private static int CountDifferentPixels(Image a, Image b, float threshold) { int count = 0; int w = Math.Min(a.GetWidth(), b.GetWidth()); int h = Math.Min(a.GetHeight(), b.GetHeight()); for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { Color ca = a.GetPixel(x, y); Color cb = b.GetPixel(x, y); float diff = MathF.Abs(ca.R - cb.R) + MathF.Abs(ca.G - cb.G) + MathF.Abs(ca.B - cb.B) + MathF.Abs(ca.A - cb.A); if (diff > threshold) count++; } } return count; } private void Check(bool condition, string message) { if (!condition) { _failures.Add(message); } } private void Finish() { if (_done) return; _done = true; foreach (var f in _failures) { GD.PrintErr("SMOKE FAIL: " + f); } GD.Print(_failures.Count == 0 ? "SMOKE PASS" : $"SMOKE FAILED ({_failures.Count})"); GetTree().Quit(_failures.Count == 0 ? 0 : 1); } private sealed class HiddenRemoteDeathsSession : IClientArenaSession { private readonly IClientArenaSession _inner; public HiddenRemoteDeathsSession(IClientArenaSession inner) => _inner = inner; public MatchState ViewState => _inner.ViewState; public int LocalContenderId => _inner.LocalContenderId; public ContenderState LocalContender => _inner.LocalContender; public ClientMatchOutcome LocalOutcome => _inner.LocalOutcome; public int LocalDetectedByCount => _inner.LocalDetectedByCount; public IReadOnlyDictionary LocalContenderContacts => _inner.LocalContenderContacts; public IReadOnlyDictionary LocalSpectatorContacts => _inner.LocalSpectatorContacts; public NetworkStatusSnapshot ConnectionStatus => _inner.ConnectionStatus; public IReadOnlyList ActivePods => _inner.ActivePods; public DropWaveState DropWaveState => _inner.DropWaveState; public IReadOnlyList PodEvents => _inner.PodEvents; public bool IsContenderVisible(int contenderId) => contenderId == _inner.LocalContenderId; public bool IsSpectatorVisible(int spectatorId) => false; public void BeginRenderFrame(double dt, float physicsAlpha) => _inner.BeginRenderFrame(dt, physicsAlpha); public void SubmitLocalInput(in PlayerInput input, bool isPhysicsTick) => _inner.SubmitLocalInput(in input, isPhysicsTick); public void DrainSimEvents(List dest) => _inner.DrainSimEvents(dest); public bool RequestEquipCargo(int cargoIndex, string hardpointId) => _inner.RequestEquipCargo(cargoIndex, hardpointId); public void RequestNewMatch(int seed, ArenaMapKind mapKind) => _inner.RequestNewMatch(seed, mapKind); public (System.Numerics.Vector3 Pos, System.Numerics.Quaternion Rot, System.Numerics.Vector3 Vel) GetInterpolatedContenderPose(int contenderId, float alpha) => _inner.GetInterpolatedContenderPose(contenderId, alpha); public (System.Numerics.Vector3 Pos, System.Numerics.Quaternion Rot, System.Numerics.Vector3 Vel) GetInterpolatedSpectatorPose(int spectatorId, float alpha) => _inner.GetInterpolatedSpectatorPose(spectatorId, alpha); public bool TrySampleInterpolatedWalkerPose(bool isContender, int id, float alpha, out WalkerVisualSnapshot snap) => _inner.TrySampleInterpolatedWalkerPose(isContender, id, alpha, out snap); public ClientRayHit CastWorldRayClosest(System.Numerics.Vector3 origin, System.Numerics.Vector3 translation) => _inner.CastWorldRayClosest(origin, translation); public void Dispose() { } } }