Ejemplo n.º 1
0
        public SirenToken BeginSignalSiren()
        {
            if (_currentToken != null)
            {
                return(_currentToken);
            }
            if (_activeSensors == null)
            {
                _activeSensors = new HashSet <AudibleSensor>();
            }

            _currentToken = new SirenToken(this);
            (this as IUpdateable).Update();
            GameLoopEntry.RegisterNextUpdate(this);
            return(_currentToken);
        }
Ejemplo n.º 2
0
        public void EndSiren()
        {
            GameLoopEntry.UpdatePump.Remove(this);
            var token = _currentToken;

            _currentToken = null;

            if (_activeSensors != null && _activeSensors.Count > 0)
            {
                using (var lst = TempCollection.GetList(_activeSensors))
                {
                    _activeSensors.Clear();
                    for (int i = 0; i < lst.Count; i++)
                    {
                        lst[i].SignalExitSiren(this);
                    }
                }
            }

            if (token != null && !token.IsComplete)
            {
                token.SignalComplete();
            }
        }