feat(rng-seam): SeededRandomSource mirrors the engine's two System.Random streams

This commit is contained in:
gamer147
2026-06-06 10:18:19 -04:00
parent c77d789558
commit 2fd42c10cf
2 changed files with 40 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
using System;
namespace SVSim.BattleEngine.Rng
{
// Default source. Faithfully reproduces the engine's own RNG: BattleManagerBase seeds two separate
// System.Random(RandomSeed) instances (_stableRandom synced, _stableRandomOnlySelf self-only) at
// BattleManagerBase.cs:721-722. The authoritative server uses this; tests use ScriptedRandomSource.
public sealed class SeededRandomSource : IRandomSource
{
private readonly Random _synced;
private readonly Random _self;
public SeededRandomSource(int seed)
{
_synced = new Random(seed);
_self = new Random(seed);
}
public double NextUnit() => _synced.NextDouble();
public int NextSelf(int max) => _self.Next(max);
}
}