Zone mine step: no empty-set fast path, one trigger scan; MineTests pin the turn with an oblique mount

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-07 20:17:47 +02:00
commit 0f568a018a
2 changed files with 6 additions and 8 deletions

View file

@ -243,19 +243,14 @@ public class Zone
// blast reads no faction; only the trigger does.
private void StepMines(float deltaTime)
{
if (Mines.Count == 0) return;
var settings = _itemManager.GameplaySettings;
foreach (var mine in Mines.ToArray())
{
mine.Body.Step(deltaTime, GetForce(mine.Body.Position), settings);
if (mine.TriggeredAt == null && mine.Armed(_time))
foreach (var entity in Entities.ToArray())
if (mine.Triggers(entity) && FireControl.Touches(entity, mine.Body.Position, mine.BlastRadius))
{
mine.TriggeredAt = _time;
break;
}
if (mine.TriggeredAt == null && mine.Armed(_time) &&
Entities.Any(entity => mine.Triggers(entity) && FireControl.Touches(entity, mine.Body.Position, mine.BlastRadius)))
mine.TriggeredAt = _time;
var fused = mine.TriggeredAt + mine.FuseDelay <= _time;
if (!fused && mine.LaidAt + mine.Lifetime > _time) continue;

View file

@ -581,6 +581,8 @@ public sealed class MineTests : IDisposable
var atLay = default(KinematicBody);
using var sub = lab.Zone.Mines.ObserveAdd().Subscribe(e => atLay = e.Value.Body);
lab.Layer.Velocity = float2(-2, 4);
// A mount along neither axis, so a wrong term in the turn cannot hide behind a zero component.
lab.Layer.Direction = normalize(float2(1, 2));
var mine = LayOne(lab);
@ -662,6 +664,7 @@ public sealed class MineTests : IDisposable
Assert.Empty(lab.Zone.Mines);
Assert.Single(log);
Assert.False(string.IsNullOrWhiteSpace(log[0]));
Assert.Empty(lab.Zone.PendingShots);
}
}