コード例 #1
0
        static void TimerCallback([NotNull] SchedulerTask task)
        {
            if (task == null)
            {
                throw new ArgumentNullException("task");
            }
            ChatTimer timer = (ChatTimer)task.UserState;

            if (task.MaxRepeats == 1)
            {
                if (string.IsNullOrEmpty(timer.Message))
                {
                    Chat.SendSay(Player.Console, "(Timer Up)", MessageType.Chat);
                }
                else
                {
                    Chat.SendSay(Player.Console, "(Timer Up) " + timer.Message, MessageType.Chat);
                }
                timer.Stop();
            }
            else if (timer.announceIntervalIndex >= 0)
            {
                if (timer.lastHourAnnounced != (int)timer.TimeLeft.TotalHours)
                {
                    timer.lastHourAnnounced = (int)timer.TimeLeft.TotalHours;
                    timer.Announce(TimeSpan.FromHours(Math.Ceiling(timer.TimeLeft.TotalHours)));
                }
                if (timer.TimeLeft <= AnnounceIntervals[timer.announceIntervalIndex])
                {
                    timer.Announce(AnnounceIntervals[timer.announceIntervalIndex]);
                    timer.announceIntervalIndex--;
                }
            }
        }
コード例 #2
0
 static void RemoveTimerFromList([NotNull] ChatTimer timer)
 {
     if (timer == null)
     {
         throw new ArgumentNullException("timer");
     }
     lock ( TimerListLock ) {
         Timers.Remove(timer.Id);
     }
 }
コード例 #3
0
 static void AddTimerToList([NotNull] ChatTimer timer)
 {
     if (timer == null)
     {
         throw new ArgumentNullException("timer");
     }
     lock ( TimerListLock ) {
         Timers.Add(timer.Id, timer);
     }
 }