public void SetPause(bool paused, uint flags = 0x00000001) { var prev = this.pausedStates; if (paused) { this.pausedStates = BitFlag.Add(this.pausedStates, flags); if (0 == prev && 0 != this.pausedStates) { this.OnPause(true); } } else { this.pausedStates = BitFlag.Remove(this.pausedStates, flags); if (0 != prev && 0 == this.pausedStates) { this.OnPause(false); } } }