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(); } } }
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; } } } }
internal Array ToArray() { Array array; lock (Resurrections.SyncRoot) array = Resurrections.ToArray(); return(array); }
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); }