예제 #1
0
        internal void BeginSafety(PlayerMobile player)
        {
            if (player == null || player.AccessLevel != AccessLevel.Player)
            {
                return;
            }

            TimeSpan delay = TimeSpan.FromSeconds(SafeResConfig.SafeForSeconds);
            DateTime when  = DateTime.UtcNow.Add(delay);

            player.SafeResContext = SafeResContext.Instance;
            BlessPlayer(player);

            lock (Resurrections.SyncRoot)
            {
                // Push both queues
                Resurrections.Enqueue(player);
                DateTimes.Enqueue(when);

                if (!Running)
                {
                    Delay = delay;
                    Start();
                }
            }
        }
예제 #2
0
        protected override void OnTick()
        {
            lock (Resurrections.SyncRoot)
            {
                Stop();

                DateTime onTickTime = DateTime.UtcNow;

                while (Resurrections.Count > 0)
                {
                    DateTime nextDateTime = (DateTime)DateTimes.Peek();

                    if (DateTime.Compare(nextDateTime, onTickTime) <= 0)
                    {
                        // Handle any that have expired at this time
                        EndSafety(Resurrections.Peek() as PlayerMobile);
                    }
                    else
                    {
                        // No more concurrent expiries - schedule the next one
                        Delay = nextDateTime.Subtract(DateTime.UtcNow);
                        Start();
                        break;
                    }
                }
            }
        }
예제 #3
0
        internal Array ToArray()
        {
            Array array;

            lock (Resurrections.SyncRoot)
                array = Resurrections.ToArray();

            return(array);
        }
예제 #4
0
        private void EndSafety(PlayerMobile player)
        {
            if (player == null || player.AccessLevel != AccessLevel.Player)
            {
                return;
            }

            lock (Resurrections.SyncRoot)
            {
                // Pop both queues
                Resurrections.Dequeue();
                DateTimes.Dequeue();
            }

            UnblessPlayer(player);
        }