NEO-93: Reset LastAdvancedUtc on dev fixture runtime clear.

Fixture reset cleared NPC rows but left a stale lazy-tick marker, causing
catch-up bursts after re-acquire. Reset to MinValue with prototype rows.

Co-authored-by: Cursor <cursoragent@cursor.com>
pull/131/head
VinPropane 2026-05-27 23:26:17 -04:00
parent 9fa0fbef4b
commit 83d1bb13e4
3 changed files with 23 additions and 0 deletions

View File

@ -78,6 +78,8 @@ public sealed class InMemoryNpcRuntimeStateStoreTests
Assert.Equal(NpcBehaviorState.Idle, snapshot.BehaviorState); Assert.Equal(NpcBehaviorState.Idle, snapshot.BehaviorState);
Assert.Null(snapshot.ActiveTelegraph); Assert.Null(snapshot.ActiveTelegraph);
} }
Assert.Equal(DateTimeOffset.MinValue, store.LastAdvancedUtc);
} }
[Fact] [Fact]

View File

@ -258,4 +258,23 @@ public sealed class NpcRuntimeOperationsTests
Assert.Equal(NpcBehaviorState.Recover, snapshot.BehaviorState); Assert.Equal(NpcBehaviorState.Recover, snapshot.BehaviorState);
Assert.Equal(T0.AddSeconds(9), snapshot.PhaseStartedUtc); Assert.Equal(T0.AddSeconds(9), snapshot.PhaseStartedUtc);
} }
[Fact]
public void ResetAllPrototypeRows_ShouldClearLastAdvancedUtc_ForFreshAdvanceBaseline()
{
// Arrange
var (runtime, threat, behavior) = CreateFixture();
SetHolder(threat, PrototypeNpcRegistry.PrototypeNpcMeleeId);
Advance(T0, runtime, threat, behavior);
runtime.LastAdvancedUtc = T0.AddHours(1);
NpcRuntimeOperations.ResetAllPrototypeRows(runtime);
SetHolder(threat, PrototypeNpcRegistry.PrototypeNpcMeleeId);
// Act
Advance(T0.AddHours(1).AddSeconds(10), runtime, threat, behavior, maxDeltaSeconds: 5);
// Assert
runtime.TryGet(PrototypeNpcRegistry.PrototypeNpcMeleeId, out var snapshot);
Assert.Equal(NpcBehaviorState.Aggro, snapshot.BehaviorState);
Assert.Equal(T0.AddHours(1).AddSeconds(10), snapshot.PhaseStartedUtc);
Assert.Equal(T0.AddHours(1).AddSeconds(10), runtime.LastAdvancedUtc);
}
} }

View File

@ -69,6 +69,8 @@ public sealed class InMemoryNpcRuntimeStateStore : INpcRuntimeStateStore
{ {
_ = TryResetPrototypeRow(npcInstanceId); _ = TryResetPrototypeRow(npcInstanceId);
} }
LastAdvancedUtc = DateTimeOffset.MinValue;
} }
private static string NormalizeNpcInstanceId(string? npcInstanceId) => private static string NormalizeNpcInstanceId(string? npcInstanceId) =>