namespace AcDream.App.Net; /// /// Tracks retail's stamina-exhaustion notification edge for one live-session /// generation. /// internal sealed class StaminaExhaustionEdgeTracker { private bool? _wasExhausted; /// /// Observes the current stamina value and returns /// only when a previously initialized state changes between exhausted and /// non-exhausted. /// public bool Observe(int currentStamina) { bool exhausted = currentStamina == 0; if (_wasExhausted == exhausted) return false; bool isEdge = _wasExhausted.HasValue; _wasExhausted = exhausted; return isEdge; } /// /// Forgets the retiring character/session sample. The first sample in the /// next generation establishes a baseline and must not synthesize an edge. /// public void Reset() => _wasExhausted = null; }