Files
SVSimServer/SVSim.BattleEngine/Patches/BattleManagerBase.ambient-isforecast-israndomdraw.patch
gamer147 92da7819f4 chore(engine-ambient): refresh BattleManagerBase manifest sha + add patch artifact
Hygiene fixup for the IsForecast/IsRandomDraw ambient conversion in 3b5f2e1.
The manifest sha was stale (pointed at the pre-ambient RNG-virtual-patched
contents) and the change had no companion .patch artifact alongside
BattleManagerBase.rng-virtual.patch. Follow established convention.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-06-07 21:16:57 -04:00

33 lines
1.5 KiB
Diff

Multi-instancing migration (Step 2): convert the two static `bool` fields IsForecast and
IsRandomDraw to static properties that resolve through BattleAmbient.Current when a scope is
active, falling back to a private static when not (preserves today's behavior for unwrapped
callers — solo SingleBattleMgr, in-process unit tests). This is the field-to-property pivot
that lets HeadlessBattleMgr (and any future per-session battle host) carry its own forecast /
random-draw flags inside an AsyncLocal scope without colliding with sibling battles
(design 2026-06-07-engine-multi-instancing, Task 2). ZERO logic change for unwrapped callers
(fallback storage holds the value); scoped callers get per-scope isolation.
--- Engine/BattleManagerBase.cs (~line 414)
- public static bool IsRandomDraw = false;
+ private static bool _isRandomDrawFallback = false;
+ public static bool IsRandomDraw {
+ get => SVSim.BattleEngine.Ambient.BattleAmbient.Current?.IsRandomDraw ?? _isRandomDrawFallback;
+ set {
+ var c = SVSim.BattleEngine.Ambient.BattleAmbient.Current;
+ if (c != null) c.IsRandomDraw = value;
+ else _isRandomDrawFallback = value;
+ }
+ }
--- Engine/BattleManagerBase.cs (~line 416)
- public static bool IsForecast = false;
+ private static bool _isForecastFallback = false;
+ public static bool IsForecast {
+ get => SVSim.BattleEngine.Ambient.BattleAmbient.Current?.IsForecast ?? _isForecastFallback;
+ set {
+ var c = SVSim.BattleEngine.Ambient.BattleAmbient.Current;
+ if (c != null) c.IsForecast = value;
+ else _isForecastFallback = value;
+ }
+ }