예제 #1
0
        public static TimeSpan DelayFromPriority(TimerPriority p)
        {
            switch (p)
            {
            case TimerPriority.EveryTick:
                return(TimeSpan.FromMilliseconds(1));

            case TimerPriority.TenMS:
                return(TimeSpan.FromMilliseconds(10));

            case TimerPriority.TwentyFiveMS:
                return(TimeSpan.FromMilliseconds(25));

            case TimerPriority.FiftyMS:
                return(TimeSpan.FromMilliseconds(50));

            case TimerPriority.TwoFiftyMS:
                return(TimeSpan.FromMilliseconds(250));

            case TimerPriority.OneSecond:
                return(TimeSpan.FromSeconds(1));

            case TimerPriority.FiveSeconds:
                return(TimeSpan.FromSeconds(5));

            case TimerPriority.OneMinute:
                return(TimeSpan.FromMinutes(1));
            }

            //default:
            return(TimeSpan.FromMinutes(1));
        }
예제 #2
0
        public virtual void Deserialize(GenericReader reader)
        {
            int version = reader.GetVersion();

            switch (version)
            {
            case 0:
            {
                _Info = reader.ReadTypeCreate <ScheduleInfo>(reader) ?? new ScheduleInfo();

                _Enabled         = reader.ReadBool();
                _Name            = reader.ReadString();
                _DefaultPriority = reader.ReadFlag <TimerPriority>();

                if (reader.ReadBool())
                {
                    _LastGlobalTick = reader.ReadDateTime();
                }

                if (reader.ReadBool())
                {
                    _NextGlobalTick = reader.ReadDateTime();
                }

                Delay    = reader.ReadTimeSpan();
                Interval = reader.ReadTimeSpan();
            }
            break;
            }

            Start();
        }
예제 #3
0
		public static TimeSpan DelayFromPriority(TimerPriority p)
		{
			switch (p)
			{
				case TimerPriority.EveryTick:
					return TimeSpan.FromMilliseconds(1);
				case TimerPriority.TenMS:
					return TimeSpan.FromMilliseconds(10);
				case TimerPriority.TwentyFiveMS:
					return TimeSpan.FromMilliseconds(25);
				case TimerPriority.FiftyMS:
					return TimeSpan.FromMilliseconds(50);
				case TimerPriority.TwoFiftyMS:
					return TimeSpan.FromMilliseconds(250);
				case TimerPriority.OneSecond:
					return TimeSpan.FromSeconds(1);
				case TimerPriority.FiveSeconds:
					return TimeSpan.FromSeconds(5);
				case TimerPriority.OneMinute:
					return TimeSpan.FromMinutes(1);
			}

			//default:
			return TimeSpan.FromMinutes(1);
		}
예제 #4
0
        public void TimeSliceConstructorTest4()
        {
            TimerPriority processPriority = new TimerPriority(); // TODO: 初始化为适当的值
            TimeSpan      delayTimeSpan   = new TimeSpan();      // TODO: 初始化为适当的值
            TimeSlice     target          = new TimeSlice(processPriority, delayTimeSpan);

            Assert.Inconclusive("TODO: 实现用来验证目标的代码");
        }
예제 #5
0
        /// <summary>
        /// 创建一个新的时间片
        /// </summary>
        /// <param name="delayTimeSpan"></param>
        /// <param name="intervalTimeSpan"></param>
        /// <param name="iCount"></param>
        /// <param name="timerCallback"></param>
        /// <returns></returns>
        public static TimeSlice StartTimeSlice(TimerPriority processPriority, TimeSpan delayTimeSpan, TimeSpan intervalTimeSpan, long iCount, TimeSliceCallback timerCallback)
        {
            TimeSlice tTimer = new DelayCallTimer(processPriority, delayTimeSpan, intervalTimeSpan, iCount, timerCallback);

            tTimer.Start();

            return(tTimer);
        }
예제 #6
0
        /// <summary>
        /// 创建一个新的时间片
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="delayTimeSpan"></param>
        /// <param name="intervalTimeSpan"></param>
        /// <param name="count"></param>
        /// <param name="timerStateCallback"></param>
        /// <param name="tState"></param>
        /// <returns></returns>
        public static TimeSlice StartTimeSlice <T>(TimerPriority processPriority, TimeSpan delayTimeSpan, TimeSpan intervalTimeSpan, long iCount, TimeSliceStateCallback <T> timerStateCallback, T tState)
        {
            TimeSlice tTimer = new DelayStateCallTimer <T>(processPriority, delayTimeSpan, intervalTimeSpan, iCount, timerStateCallback, tState);

            tTimer.Start();

            return(tTimer);
        }
예제 #7
0
        public virtual void Deserialize(GenericReader reader)
        {
            var version = reader.GetVersion();

            if (version > 2)
            {
                UID = new CryptoHashCode(reader);
            }
            else
            {
                UID = new CryptoHashCode(CryptoHashType.MD5, TimeStamp.Now + "+" + Utility.RandomDouble());
            }

            switch (version)
            {
            case 3:
            case 2:
            case 1:
            case 0:
            {
                if (version < 2)
                {
                    _Info = reader.ReadTypeCreate <ScheduleInfo>(reader) ?? new ScheduleInfo();
                }
                else
                {
                    _Info = reader.ReadBlock(r => r.ReadTypeCreate <ScheduleInfo>(r)) ?? new ScheduleInfo();
                }

                _Enabled         = reader.ReadBool();
                _Name            = reader.ReadString();
                _DefaultPriority = reader.ReadFlag <TimerPriority>();

                if (reader.ReadBool())
                {
                    _LastGlobalTick = reader.ReadDateTime();
                }

                if (reader.ReadBool())
                {
                    _NextGlobalTick = reader.ReadDateTime();
                }

                Delay    = reader.ReadTimeSpan();
                Interval = reader.ReadTimeSpan();
            }
            break;
            }

            InvalidateNextTick();

            if (version > 0)
            {
                Running = reader.ReadBool();
            }
        }
예제 #8
0
        public void TimeSliceConstructorTest2()
        {
            TimerPriority processPriority  = new TimerPriority(); // TODO: 初始化为适当的值
            TimeSpan      delayTimeSpan    = new TimeSpan();      // TODO: 初始化为适当的值
            TimeSpan      intervalTimeSpan = new TimeSpan();      // TODO: 初始化为适当的值
            long          iCount           = 0;                   // TODO: 初始化为适当的值
            TimeSlice     target           = new TimeSlice(processPriority, delayTimeSpan, intervalTimeSpan, iCount);

            Assert.Inconclusive("TODO: 实现用来验证目标的代码");
        }
예제 #9
0
                public EffectTimer(CSpellTargetedTimer owner, TimeSpan duree, TimerPriority intervale)
                    : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0))
                {
                    m_End   = DateTime.Now + duree;
                    m_owner = owner;

                    Priority = intervale;

                    m_owner.OnStart();
                    Start();
                }
예제 #10
0
        public void PriorityTest()
        {
            TimeSpan      delayTimeSpan = new TimeSpan();               // TODO: 初始化为适当的值
            TimeSlice     target        = new TimeSlice(delayTimeSpan); // TODO: 初始化为适当的值
            TimerPriority expected      = new TimerPriority();          // TODO: 初始化为适当的值
            TimerPriority actual;

            target.Priority = expected;
            actual          = target.Priority;
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
예제 #11
0
        public void StartTimeSliceTest11()
        {
            TimerPriority     processPriority = new TimerPriority(); // TODO: 初始化为适当的值
            TimeSpan          delayTimeSpan   = new TimeSpan();      // TODO: 初始化为适当的值
            TimeSliceCallback timerCallback   = null;                // TODO: 初始化为适当的值
            TimeSlice         expected        = null;                // TODO: 初始化为适当的值
            TimeSlice         actual;

            actual = TimeSlice.StartTimeSlice(processPriority, delayTimeSpan, timerCallback);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
예제 #12
0
 public AoETimer(string Name, string Formule, short Cercle, int Action, int HandEffect, int ManaCost, SkillName SkillUtilise, int NiveauSkillReq, TimeSpan CastTime, bool TargetsDebutCast, bool ContinueCastDuringTimer, int Range, TimeSpan Duree, TimerPriority Intervale, params Type[] regs)
     : base(Name, Formule, Cercle, Action, HandEffect, ManaCost, SkillUtilise, NiveauSkillReq, CastTime, StyleSpell.AoETimer, regs)
 {
     m_targetsDebutCast        = TargetsDebutCast;
     m_continueCastDuringTimer = ContinueCastDuringTimer;
     if (range <= 20 && range >= 1)
     {
         m_Range = range;
     }
     m_duree     = Duree;
     m_intervale = Intervale;
 }
 public void CallbackTest()
 {
     TimerPriority processPriority = new TimerPriority(); // TODO: 初始化为适当的值
     TimeSpan delayTimeSpan = new TimeSpan(); // TODO: 初始化为适当的值
     TimeSpan intervalTimeSpan = new TimeSpan(); // TODO: 初始化为适当的值
     long iCount = 0; // TODO: 初始化为适当的值
     TimeSliceCallback timerCallback = null; // TODO: 初始化为适当的值
     DelayCallTimer target = new DelayCallTimer( processPriority, delayTimeSpan, intervalTimeSpan, iCount, timerCallback ); // TODO: 初始化为适当的值
     TimeSliceCallback actual;
     actual = target.Callback;
     Assert.Inconclusive( "验证此测试方法的正确性。" );
 }
예제 #14
0
        /// <summary>
        ///StartTimeSlice 的测试
        ///</summary>
        public void StartTimeSliceTest2Helper <T>()
        {
            TimerPriority processPriority = new TimerPriority();  // TODO: 初始化为适当的值
            TimeSpan      delayTimeSpan   = new TimeSpan();       // TODO: 初始化为适当的值
            TimeSliceStateCallback <T> timerStateCallback = null; // TODO: 初始化为适当的值
            T         tState   = default(T);                      // TODO: 初始化为适当的值
            TimeSlice expected = null;                            // TODO: 初始化为适当的值
            TimeSlice actual;

            actual = TimeSlice.StartTimeSlice <T>(processPriority, delayTimeSpan, timerStateCallback, tState);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
예제 #15
0
        public void CallbackTest()
        {
            TimerPriority     processPriority  = new TimerPriority();                                                                         // TODO: 初始化为适当的值
            TimeSpan          delayTimeSpan    = new TimeSpan();                                                                              // TODO: 初始化为适当的值
            TimeSpan          intervalTimeSpan = new TimeSpan();                                                                              // TODO: 初始化为适当的值
            long              iCount           = 0;                                                                                           // TODO: 初始化为适当的值
            TimeSliceCallback timerCallback    = null;                                                                                        // TODO: 初始化为适当的值
            DelayCallTimer    target           = new DelayCallTimer(processPriority, delayTimeSpan, intervalTimeSpan, iCount, timerCallback); // TODO: 初始化为适当的值
            TimeSliceCallback actual;

            actual = target.Callback;
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
예제 #16
0
        /// <summary>
        ///Callback 的测试
        ///</summary>
        public void CallbackTestHelper <T>()
        {
            TimerPriority processPriority  = new TimerPriority();                                                                                                  // TODO: 初始化为适当的值
            TimeSpan      delayTimeSpan    = new TimeSpan();                                                                                                       // TODO: 初始化为适当的值
            TimeSpan      intervalTimeSpan = new TimeSpan();                                                                                                       // TODO: 初始化为适当的值
            long          iCount           = 0;                                                                                                                    // TODO: 初始化为适当的值
            TimeSliceStateCallback <T> timerStateCallback = null;                                                                                                  // TODO: 初始化为适当的值
            T tState = default(T);                                                                                                                                 // TODO: 初始化为适当的值
            DelayStateCallTimer <T>    target = new DelayStateCallTimer <T>(processPriority, delayTimeSpan, intervalTimeSpan, iCount, timerStateCallback, tState); // TODO: 初始化为适当的值
            TimeSliceStateCallback <T> actual;

            actual = target.Callback;
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
예제 #17
0
 public TargetedTimer(string Name, string Formule, short Cercle, int Action, int HandEffect, int ManaCost, SkillName SkillUtilise, int NiveauSkillReq, TimeSpan CastTime, int NbTarget, bool unEffectParTarget, int Range, TimeSpan Duree, TimerPriority Intervale, params Type[] regs)
     : base(Name, Formule, Cercle, Action, HandEffect, ManaCost, SkillUtilise, NiveauSkillReq, CastTime, StyleSpell.TargetedTimer, regs)
 {
     if (NbTarget <= 3 && NbTarget >= 1)
     {
         m_NbTarget = NbTarget;
     }
     if (range <= 20 && range >= 1)
     {
         m_Range = Range;
     }
     m_duree     = Duree;
     m_intervale = Intervale;
 }
 public void ToStringTest()
 {
     TimerPriority processPriority = new TimerPriority(); // TODO: 初始化为适当的值
     TimeSpan delayTimeSpan = new TimeSpan(); // TODO: 初始化为适当的值
     TimeSpan intervalTimeSpan = new TimeSpan(); // TODO: 初始化为适当的值
     long iCount = 0; // TODO: 初始化为适当的值
     TimeSliceCallback timerCallback = null; // TODO: 初始化为适当的值
     DelayCallTimer target = new DelayCallTimer( processPriority, delayTimeSpan, intervalTimeSpan, iCount, timerCallback ); // TODO: 初始化为适当的值
     string expected = string.Empty; // TODO: 初始化为适当的值
     string actual;
     actual = target.ToString();
     Assert.AreEqual( expected, actual );
     Assert.Inconclusive( "验证此测试方法的正确性。" );
 }
예제 #19
0
        public void StartTimeSliceTest14()
        {
            TimerPriority          processPriority    = new TimerPriority(); // TODO: 初始化为适当的值
            TimeSpan               delayTimeSpan      = new TimeSpan();      // TODO: 初始化为适当的值
            TimeSpan               intervalTimeSpan   = new TimeSpan();      // TODO: 初始化为适当的值
            long                   iCount             = 0;                   // TODO: 初始化为适当的值
            TimeSliceStateCallback timerStateCallback = null;                // TODO: 初始化为适当的值
            object                 tState             = null;                // TODO: 初始化为适当的值
            TimeSlice              expected           = null;                // TODO: 初始化为适当的值
            TimeSlice              actual;

            actual = TimeSlice.StartTimeSlice(processPriority, delayTimeSpan, intervalTimeSpan, iCount, timerStateCallback, tState);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
예제 #20
0
        public void ToStringTest()
        {
            TimerPriority     processPriority  = new TimerPriority();                                                                         // TODO: 初始化为适当的值
            TimeSpan          delayTimeSpan    = new TimeSpan();                                                                              // TODO: 初始化为适当的值
            TimeSpan          intervalTimeSpan = new TimeSpan();                                                                              // TODO: 初始化为适当的值
            long              iCount           = 0;                                                                                           // TODO: 初始化为适当的值
            TimeSliceCallback timerCallback    = null;                                                                                        // TODO: 初始化为适当的值
            DelayCallTimer    target           = new DelayCallTimer(processPriority, delayTimeSpan, intervalTimeSpan, iCount, timerCallback); // TODO: 初始化为适当的值
            string            expected         = string.Empty;                                                                                // TODO: 初始化为适当的值
            string            actual;

            actual = target.ToString();
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
예제 #21
0
                public EffectTimer(CSpellSelfTimer owner, TimeSpan duree, TimerPriority intervale)
                    : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0))
                {
                    m_End   = DateTime.Now + duree;
                    m_owner = owner;

                    Priority = intervale;

                    m_owner.UniqueEffect();

                    m_owner.OnStart(m_owner.Caster);
                    Start();

                    m_owner.FinishSequence();
                }
예제 #22
0
        /// <summary>
        ///ToString 的测试
        ///</summary>
        public void ToStringTestHelper <T>()
        {
            TimerPriority processPriority  = new TimerPriority();                                                                                               // TODO: 初始化为适当的值
            TimeSpan      delayTimeSpan    = new TimeSpan();                                                                                                    // TODO: 初始化为适当的值
            TimeSpan      intervalTimeSpan = new TimeSpan();                                                                                                    // TODO: 初始化为适当的值
            long          iCount           = 0;                                                                                                                 // TODO: 初始化为适当的值
            TimeSliceStateCallback <T> timerStateCallback = null;                                                                                               // TODO: 初始化为适当的值
            T tState = default(T);                                                                                                                              // TODO: 初始化为适当的值
            DelayStateCallTimer <T> target = new DelayStateCallTimer <T>(processPriority, delayTimeSpan, intervalTimeSpan, iCount, timerStateCallback, tState); // TODO: 初始化为适当的值
            string expected = string.Empty;                                                                                                                     // TODO: 初始化为适当的值
            string actual;

            actual = target.ToString();
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
예제 #23
0
        public Timer(TimeSpan delay, TimeSpan interval, int count = 0)
        {
            m_Delay    = (long)delay.TotalMilliseconds;
            m_Interval = (long)interval.TotalMilliseconds;
            m_Count    = count;

            if (!m_PrioritySet)
            {
                m_Priority    = ComputePriority(count == 1 ? delay : interval);
                m_PrioritySet = true;
            }

            if (DefRegCreation)
            {
                RegCreation();
            }
        }
예제 #24
0
        /// <summary>
        /// 初始化时间片
        /// </summary>
        /// <param name="delayTimeSpan">延迟的时间</param>
        /// <param name="intervalTimeSpan">间隔的时间</param>
        /// <param name="iCount">调用的次数</param>
        public TimeSlice(TimerPriority processPriority, TimeSpan delayTimeSpan, TimeSpan intervalTimeSpan, long iCount)
        {
            m_Count           = iCount;
            m_DelayTime       = delayTimeSpan;
            m_IntervalTime    = intervalTimeSpan;
            m_ProcessPriority = processPriority;

            if (iCount == 1)
            {
                m_RunFrequency = ComputePriority(delayTimeSpan);
            }
            else
            {
                m_RunFrequency = ComputePriority(intervalTimeSpan);
            }

            RegCreation();
        }
예제 #25
0
        public virtual void Deserialize(GenericReader reader)
        {
            var version = reader.GetVersion();

            switch (version)
            {
            case 2:
            case 1:
            case 0:
            {
                if (version < 2)
                {
                    _Info = reader.ReadTypeCreate <ScheduleInfo>(reader) ?? new ScheduleInfo();
                }
                else
                {
                    reader.ReadBlock(r => _Info = r.ReadTypeCreate <ScheduleInfo>(r) ?? new ScheduleInfo());
                }

                _Enabled         = reader.ReadBool();
                _Name            = reader.ReadString();
                _DefaultPriority = reader.ReadFlag <TimerPriority>();

                if (reader.ReadBool())
                {
                    _LastGlobalTick = reader.ReadDateTime();
                }

                if (reader.ReadBool())
                {
                    _NextGlobalTick = reader.ReadDateTime();
                }

                Delay    = reader.ReadTimeSpan();
                Interval = reader.ReadTimeSpan();
            }
            break;
            }

            if (version > 0)
            {
                Running = reader.ReadBool();
            }
        }
예제 #26
0
        public Timer(TimeSpan delay, TimeSpan interval, int count)
        {
            m_Delay    = delay;
            m_Interval = interval;
            m_Count    = count;

            if (!m_PrioritySet)
            {
                if (count == 1)
                {
                    m_Priority = ComputePriority(delay);
                }
                else
                {
                    m_Priority = ComputePriority(interval);
                }
                m_PrioritySet = true;
            }
        }
예제 #27
0
                public EffectTimer(CSpellAoETimer owner, TimeSpan duree, TimerPriority intervale)
                    : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0))
                {
                    m_End   = DateTime.Now + duree;
                    m_owner = owner;

                    Priority = intervale;

                    m_owner.targetsList = m_owner.Caster.GetMobilesInRange(m_owner.info.range);

                    m_owner.UniqueEffect();

                    ChoixTarget(m_owner.OnStart);

                    Start();

                    if (!m_owner.info.continueCastDuringTimer)
                    {
                        m_owner.FinishSequence();
                    }
                }
예제 #28
0
        public Timer(TimeSpan delay, TimeSpan interval, int count)
        {
            this.m_Delay    = delay;
            this.m_Interval = interval;
            this.m_Count    = count;

            if (!this.m_PrioritySet)
            {
                if (count == 1)
                {
                    this.m_Priority = ComputePriority(delay);
                }
                else
                {
                    this.m_Priority = ComputePriority(interval);
                }
                this.m_PrioritySet = true;
            }

            if (this.DefRegCreation)
            {
                this.RegCreation();
            }
        }
예제 #29
0
 /// <summary>
 /// 初始化时间片
 /// </summary>
 /// <param name="delayTimeSpan">延迟的时间</param>
 /// <param name="intervalTimeSpan">间隔的时间</param>
 public TimeSlice(TimerPriority processPriority, TimeSpan delayTimeSpan, TimeSpan intervalTimeSpan)
     : this(processPriority, delayTimeSpan, intervalTimeSpan, 0 /*循环调用*/)
 {
 }
예제 #30
0
		public BucketTimer(Action action, TimerPriority prio)
		{
			m_Action = action;
            priority = prio;
		}
예제 #31
0
 /// <summary>
 /// 创建一个新的时间片
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="delayTimeSpan"></param>
 /// <param name="intervalTimeSpan"></param>
 /// <param name="timerStateCallback"></param>
 /// <param name="tState"></param>
 /// <returns></returns>
 public static TimeSlice StartTimeSlice <T>(TimerPriority processPriority, TimeSpan delayTimeSpan, TimeSpan intervalTimeSpan, TimeSliceStateCallback <T> timerStateCallback, T tState)
 {
     return(StartTimeSlice(processPriority, delayTimeSpan, intervalTimeSpan, 0, timerStateCallback, tState));
 }
예제 #32
0
 /// <summary>
 /// 延迟调用的时间
 /// </summary>
 /// <param name="delayTimeSpan">延迟的时间</param>
 /// <param name="intervalTimeSpan">间隔的时间</param>
 /// <param name="iCount">调用的次数</param>
 /// <param name="timerCallback">委托</param>
 public DelayCallTimer( TimerPriority processPriority, TimeSpan delayTimeSpan, TimeSpan intervalTimeSpan, long iCount, TimeSliceCallback timerCallback )
     : base( processPriority, delayTimeSpan, intervalTimeSpan, iCount )
 {
     m_Callback = timerCallback;
 }
예제 #33
0
파일: Schedule.cs 프로젝트: Ravenwolfe/Core
		public virtual void Deserialize(GenericReader reader)
		{
			var version = reader.GetVersion();

			switch (version)
			{
				case 2:
				case 1:
				case 0:
				{
					if (version < 2)
					{
						_Info = reader.ReadTypeCreate<ScheduleInfo>(reader) ?? new ScheduleInfo();
					}
					else
					{
						reader.ReadBlock(r => _Info = r.ReadTypeCreate<ScheduleInfo>(r) ?? new ScheduleInfo());
					}

					_Enabled = reader.ReadBool();
					_Name = reader.ReadString();
					_DefaultPriority = reader.ReadFlag<TimerPriority>();

					if (reader.ReadBool())
					{
						_LastGlobalTick = reader.ReadDateTime();
					}

					if (reader.ReadBool())
					{
						_NextGlobalTick = reader.ReadDateTime();
					}

					Delay = reader.ReadTimeSpan();
					Interval = reader.ReadTimeSpan();
				}
					break;
			}

			if (version > 0)
			{
				Running = reader.ReadBool();
			}
		}
예제 #34
0
		public TimerBucket(TimerPriority priority, float delay)
		{
			Priority = priority;
			Delay = delay;
			Timers = new HashSet<BucketTimer>();
		}
예제 #35
0
		public static void OnTick(TimerPriority p)
		{
			switch (p)
			{
				case TimerPriority.EveryTick:
					{
						if (EveryTick.Count > 0)
						{
							Trigger(EveryTick.ToArray(), TriggerName.onTick);
						}
					}
					break;
				case TimerPriority.TenMS:
					{
						if (EveryTenMS.Count > 0)
						{
							Trigger(EveryTenMS.ToArray(), TriggerName.onTenMS);
						}
					}
					break;
				case TimerPriority.TwentyFiveMS:
					{
						if (EveryTwentyFiveMS.Count > 0)
						{
							Trigger(EveryTwentyFiveMS.ToArray(), TriggerName.onTwentyFiveMS);
						}
					}
					break;
				case TimerPriority.FiftyMS:
					{
						if (EveryFiftyMS.Count > 0)
						{
							Trigger(EveryFiftyMS.ToArray(), TriggerName.onFiftyMS);
						}
					}
					break;
				case TimerPriority.TwoFiftyMS:
					{
						if (EveryTwoFiftyMS.Count > 0)
						{
							Trigger(EveryTwoFiftyMS.ToArray(), TriggerName.onTwoFiftyMS);
						}
					}
					break;
				case TimerPriority.OneSecond:
					{
						if (EveryOneSecond.Count > 0)
						{
							Trigger(EveryOneSecond.ToArray(), TriggerName.onOneSecond);
						}
					}
					break;
				case TimerPriority.FiveSeconds:
					{
						if (EveryFiveSeconds.Count > 0)
						{
							Trigger(EveryFiveSeconds.ToArray(), TriggerName.onFiveSeconds);
						}
					}
					break;
				case TimerPriority.OneMinute:
					{
						if (EveryOneMinute.Count > 0)
						{
							Trigger(EveryOneMinute.ToArray(), TriggerName.onOneMinute);
						}
					}
					break;
			}
		}
예제 #36
0
		void AddBucket(TimerPriority prio, float delay)
		{
			m_buckets[(int)prio] = new TimerBucket(prio, delay);
		}
예제 #37
0
		public TimerBucket this[TimerPriority priority]
		{
			get { return m_buckets[(int)priority]; }
		}
예제 #38
0
		public virtual void Deserialize(GenericReader reader)
		{
			int version = reader.GetVersion();

			switch (version)
			{
				case 1:
				case 0:
					{
						_Info = reader.ReadTypeCreate<ScheduleInfo>(reader) ?? new ScheduleInfo(reader);

						_Enabled = reader.ReadBool();
						_Name = reader.ReadString();
						_DefaultPriority = reader.ReadFlag<TimerPriority>();

						if (reader.ReadBool())
						{
							_LastGlobalTick = reader.ReadDateTime();
						}

						if (reader.ReadBool())
						{
							_NextGlobalTick = reader.ReadDateTime();
						}

						Delay = reader.ReadTimeSpan();
						Interval = reader.ReadTimeSpan();
					}
					break;
			}

			if (version < 1)
			{
				return;
			}

			if (reader.ReadBool() && _Enabled)
			{
				Running = true;
			}
		}
예제 #39
0
		public override void Deserialize(GenericReader reader)
		{
			base.Deserialize(reader);

			int version = reader.ReadInt();
			bool haveproximityrange = false;
			bool hasnewobjectinfo = false;
			int tmpSpawnListSize = 0;
			ArrayList tmpSubGroup = null;
			ArrayList tmpSequentialResetTime = null;
			ArrayList tmpSequentialResetTo = null;
			ArrayList tmpKillsNeeded = null;
			ArrayList tmpRequireSurface = null;
			ArrayList tmpRestrictKillsToSubgroup = null;
			ArrayList tmpClearOnAdvance = null;
			ArrayList tmpMinDelay = null;
			ArrayList tmpMaxDelay = null;
			ArrayList tmpNextSpawn = null;
			ArrayList tmpDisableSpawn = null;
			ArrayList tmpPackRange = null;
			ArrayList tmpSpawnsPer = null;

			switch (version)
			{
				case 31:
					{
						m_BasePriority = (TimerPriority)reader.ReadInt();
						goto case 30;
					}
				case 30:
					{
						m_AllowNPCTriggering = reader.ReadBool();
						goto case 29;
					}
				case 29:
					{
						tmpSpawnListSize = reader.ReadInt();
						tmpSpawnsPer = new ArrayList(tmpSpawnListSize);
						for (int i = 0; i < tmpSpawnListSize; ++i)
						{
							int spawnsper = reader.ReadInt();

							tmpSpawnsPer.Add(spawnsper);
						}
						goto case 28;
					}
				case 28:
					{
						if (version < 29)
						{
							tmpSpawnListSize = reader.ReadInt();
						}

						tmpPackRange = new ArrayList(tmpSpawnListSize);
						for (int i = 0; i < tmpSpawnListSize; ++i)
						{
							int packrange = reader.ReadInt();

							tmpPackRange.Add(packrange);
						}
						goto case 27;
					}
				case 27:
					{
						if (version < 28)
						{
							tmpSpawnListSize = reader.ReadInt();
						}

						tmpDisableSpawn = new ArrayList(tmpSpawnListSize);
						for (int i = 0; i < tmpSpawnListSize; ++i)
						{
							bool disablespawn = reader.ReadBool();

							tmpDisableSpawn.Add(disablespawn);
						}
						goto case 26;
					}
				case 26:
					{
						m_SpawnOnTrigger = reader.ReadBool();
						m_FirstModified = reader.ReadDateTime();
						m_LastModified = reader.ReadDateTime();
						goto case 25;
					}
				case 25:
					{
						goto case 24;
					}
				case 24:
					{
						if (version < 27)
						{
							tmpSpawnListSize = reader.ReadInt();
						}
						tmpRestrictKillsToSubgroup = new ArrayList(tmpSpawnListSize);
						tmpClearOnAdvance = new ArrayList(tmpSpawnListSize);
						tmpMinDelay = new ArrayList(tmpSpawnListSize);
						tmpMaxDelay = new ArrayList(tmpSpawnListSize);
						tmpNextSpawn = new ArrayList(tmpSpawnListSize);
						for (int i = 0; i < tmpSpawnListSize; ++i)
						{
							bool restrictkills = reader.ReadBool();
							bool clearadvance = reader.ReadBool();
							double mind = reader.ReadDouble();
							double maxd = reader.ReadDouble();
							DateTime nextspawn = reader.ReadDeltaTime();

							tmpRestrictKillsToSubgroup.Add(restrictkills);
							tmpClearOnAdvance.Add(clearadvance);
							tmpMinDelay.Add(mind);
							tmpMaxDelay.Add(maxd);
							tmpNextSpawn.Add(nextspawn);
						}

						bool hasitems = reader.ReadBool();

						if (hasitems)
						{
							m_ShowBoundsItems = reader.ReadItemList();
						}
						goto case 23;
					}
				case 23:
					{
						IsInactivated = reader.ReadBool();
						SmartSpawning = reader.ReadBool();

						goto case 22;
					}
				case 22:
					{
						SkillTrigger = reader.ReadString(); // note this will also register the skill
						m_skill_that_triggered = (SkillName)reader.ReadInt();
						m_FreeRun = reader.ReadBool();
						m_mob_who_triggered = reader.ReadMobile();
						goto case 21;
					}
				case 21:
					{
						m_DespawnTime = reader.ReadTimeSpan();
						goto case 20;
					}
				case 20:
					{
						if (version < 24)
						{
							tmpSpawnListSize = reader.ReadInt();
						}
						tmpRequireSurface = new ArrayList(tmpSpawnListSize);
						for (int i = 0; i < tmpSpawnListSize; ++i)
						{
							bool requiresurface = reader.ReadBool();
							tmpRequireSurface.Add(requiresurface);
						}
						goto case 19;
					}
				case 19:
					{
						m_ConfigFile = reader.ReadString();
						m_OnHold = reader.ReadBool();
						m_HoldSequence = reader.ReadBool();
						m_FirstModifiedBy = reader.ReadString();
						m_LastModifiedBy = reader.ReadString();
						// deserialize the keyword tag list
						int tagcount = reader.ReadInt();
						m_KeywordTagList = new ArrayList(tagcount);
						for (int i = 0; i < tagcount; i++)
						{
							BaseXmlSpawner.KeywordTag tag = new BaseXmlSpawner.KeywordTag(null, this);
							tag.Deserialize(reader);
						}
						goto case 18;
					}
				case 18:
					{
						m_AllowGhostTriggering = reader.ReadBool();
						goto case 17;
					}
				case 17:
					{
						if (version < 25)
						{
							// the textentrybooks are deleted on deserialization so no need to track them
							reader.ReadItem();
						}
						goto case 16;
					}
				case 16:
					{
						hasnewobjectinfo = true;
						m_SequentialSpawning = reader.ReadInt();
						TimeSpan seqdelay = reader.ReadTimeSpan();
						m_SeqEnd = DateTime.UtcNow + seqdelay;
						if (version < 20)
						{
							tmpSpawnListSize = reader.ReadInt();
						}
						tmpSubGroup = new ArrayList(tmpSpawnListSize);
						tmpSequentialResetTime = new ArrayList(tmpSpawnListSize);
						tmpSequentialResetTo = new ArrayList(tmpSpawnListSize);
						tmpKillsNeeded = new ArrayList(tmpSpawnListSize);
						for (int i = 0; i < tmpSpawnListSize; ++i)
						{
							int subgroup = reader.ReadInt();
							double resettime = reader.ReadDouble();
							int resetto = reader.ReadInt();
							int killsneeded = reader.ReadInt();
							tmpSubGroup.Add(subgroup);
							tmpSequentialResetTime.Add(resettime);
							tmpSequentialResetTo.Add(resetto);
							tmpKillsNeeded.Add(killsneeded);
						}
						m_RegionName = reader.ReadString(); // 2004.02.08 :: Omega Red
						goto case 15;
					}
				case 15:
					{
						m_ExternalTriggering = reader.ReadBool();
						m_ExternalTrigger = reader.ReadBool();
						goto case 14;
					}
				case 14:
					{
						m_NoItemTriggerName = reader.ReadString();
						goto case 13;
					}
				case 13:
					{
						m_GumpState = reader.ReadString();
						goto case 12;
					}
				case 12:
					{
						int todtype = reader.ReadInt();
						switch (todtype)
						{
							case (int)TODModeType.Gametime:
								m_TODMode = TODModeType.Gametime;
								break;
							case (int)TODModeType.Realtime:
								m_TODMode = TODModeType.Realtime;
								break;
						}
						goto case 11;
					}
				case 11:
					{
						m_KillReset = reader.ReadInt();
						m_skipped = reader.ReadBool();
						m_spawncheck = reader.ReadInt();
						goto case 10;
					}
				case 10:
					{
						m_SetPropertyItem = reader.ReadItem();
						goto case 9;
					}
				case 9:
					{
						m_TriggerProbability = reader.ReadDouble();
						goto case 8;
					}
				case 8:
					{
						m_MobPropertyName = reader.ReadString();
						m_MobTriggerName = reader.ReadString();
						m_PlayerPropertyName = reader.ReadString();
						goto case 7;
					}
				case 7:
					{
						m_SpeechTrigger = reader.ReadString();
						goto case 6;
					}
				case 6:
					{
						m_ItemTriggerName = reader.ReadString();
						goto case 5;
					}
				case 5:
					{
						m_ProximityTriggerMessage = reader.ReadString();
						m_ObjectPropertyItem = reader.ReadItem();
						m_ObjectPropertyName = reader.ReadString();
						m_killcount = reader.ReadInt();
						goto case 4;
					}
				case 4:
					{
						haveproximityrange = true;
						m_ProximityRange = reader.ReadInt();
						m_ProximityTriggerSound = reader.ReadInt();
						m_proximityActivated = reader.ReadBool();
						m_durActivated = reader.ReadBool();
						m_refractActivated = reader.ReadBool();
						m_StackAmount = reader.ReadInt();
						m_TODStart = reader.ReadTimeSpan();
						m_TODEnd = reader.ReadTimeSpan();
						m_MinRefractory = reader.ReadTimeSpan();
						m_MaxRefractory = reader.ReadTimeSpan();
						if (m_refractActivated)
						{
							TimeSpan delay = reader.ReadTimeSpan();
							DoTimer3(delay);
						}
						if (m_durActivated)
						{
							TimeSpan delay = reader.ReadTimeSpan();
							DoTimer2(delay);
						}
						goto case 3;
					}
				case 3:
					{
						m_ShowContainerStatic = reader.ReadItem() as Static;
						goto case 2;
					}
				case 2:
					{
						m_Duration = reader.ReadTimeSpan();
						goto case 1;
					}
				case 1:
					{
						m_UniqueId = reader.ReadString();
						m_HomeRangeIsRelative = reader.ReadBool();
						goto case 0;
					}
				case 0:
					{
						m_Name = reader.ReadString();
						// backward compatibility with old name storage
						if (m_Name != null && m_Name != String.Empty)
						{
							Name = m_Name;
						}
						m_X = reader.ReadInt();
						m_Y = reader.ReadInt();
						m_Width = reader.ReadInt();
						m_Height = reader.ReadInt();
						if (m_Width == m_Height)
						{
							m_SpawnRange = m_Width / 2;
						}
						else
						{
							m_SpawnRange = -1;
						}
						if (!haveproximityrange)
						{
							m_ProximityRange = -1;
						}
						m_WayPoint = reader.ReadItem() as WayPoint;
						m_Group = reader.ReadBool();
						m_MinDelay = reader.ReadTimeSpan();
						m_MaxDelay = reader.ReadTimeSpan();
						m_Count = reader.ReadInt();
						m_Team = reader.ReadInt();
						m_HomeRange = reader.ReadInt();
						m_Running = reader.ReadBool();

						if (m_Running)
						{
							TimeSpan delay = reader.ReadTimeSpan();
							DoTimer(delay);
						}

						// Read in the size of the spawn object list
						int SpawnListSize = reader.ReadInt();
						m_SpawnObjects = new ArrayList(SpawnListSize);
						for (int i = 0; i < SpawnListSize; ++i)
						{
							string TypeName = reader.ReadString();
							int TypeMaxCount = reader.ReadInt();

							SpawnObject TheSpawnObject = new SpawnObject(TypeName, TypeMaxCount);

							m_SpawnObjects.Add(TheSpawnObject);

							string typeName = BaseXmlSpawner.ParseObjectType(TypeName);
							// does it have a substitution that might change its validity?
							// if so then let it go

							if (typeName == null ||
								((SpawnerType.GetType(typeName) == null) &&
								 (!BaseXmlSpawner.IsTypeOrItemKeyword(typeName) && typeName.IndexOf('{') == -1 && !typeName.StartsWith("*") &&
								  !typeName.StartsWith("#"))))
							{
								if (m_WarnTimer == null)
								{
									m_WarnTimer = new WarnTimer2();
								}

								m_WarnTimer.Add(Location, Map, TypeName);

								status_str = "invalid type: " + typeName;
							}

							// Read in the number of spawns already
							int SpawnedCount = reader.ReadInt();

							TheSpawnObject.SpawnedObjects = new ArrayList(SpawnedCount);

							for (int x = 0; x < SpawnedCount; ++x)
							{
								int serial = reader.ReadInt();
								if (serial < -1)
								{
									// minusone is reserved for unknown types by default
									//  minustwo on is used for referencing keyword tags
									int tagserial = -1 * (serial + 2);
									// get the tag with that serial and add it
									BaseXmlSpawner.KeywordTag t = BaseXmlSpawner.GetFromTagList(this, tagserial);
									if (t != null)
									{
										TheSpawnObject.SpawnedObjects.Add(t);
									}
								}
								else
								{
									IEntity e = World.FindEntity(serial);

									if (e != null)
									{
										TheSpawnObject.SpawnedObjects.Add(e);
									}
								}
							}
						}
						// now have to reintegrate the later version spawnobject information into the earlier version desered objects
						if (hasnewobjectinfo && tmpSpawnListSize == SpawnListSize)
						{
							for (int i = 0; i < SpawnListSize; ++i)
							{
								SpawnObject so = (SpawnObject)m_SpawnObjects[i];

								so.SubGroup = (int)tmpSubGroup[i];
								so.SequentialResetTime = (double)tmpSequentialResetTime[i];
								so.SequentialResetTo = (int)tmpSequentialResetTo[i];
								so.KillsNeeded = (int)tmpKillsNeeded[i];
								if (version > 19)
								{
									so.RequireSurface = (bool)tmpRequireSurface[i];
								}
								bool restrictkills = false;
								bool clearadvance = true;
								double mind = -1;
								double maxd = -1;
								DateTime nextspawn = DateTime.MinValue;
								if (version > 23)
								{
									restrictkills = (bool)tmpRestrictKillsToSubgroup[i];
									clearadvance = (bool)tmpClearOnAdvance[i];
									mind = (double)tmpMinDelay[i];
									maxd = (double)tmpMaxDelay[i];
									nextspawn = (DateTime)tmpNextSpawn[i];
								}
								so.RestrictKillsToSubgroup = restrictkills;
								so.ClearOnAdvance = clearadvance;
								so.MinDelay = mind;
								so.MaxDelay = maxd;
								so.NextSpawn = nextspawn;

								bool disablespawn = false;
								if (version > 26)
								{
									disablespawn = (bool)tmpDisableSpawn[i];
								}
								so.Disabled = disablespawn;

								int packrange = -1;
								if (version > 27)
								{
									packrange = (int)tmpPackRange[i];
								}
								so.PackRange = packrange;

								int spawnsper = 1;
								if (version > 28)
								{
									spawnsper = (int)tmpSpawnsPer[i];
								}
								so.SpawnsPerTick = spawnsper;
							}
						}

						break;
					}
			}
		}
예제 #40
0
        public static void OnTick(TimerPriority p)
        {
            switch (p)
            {
            case TimerPriority.EveryTick:
            {
                if (EveryTick.Count > 0)
                {
                    Trigger(EveryTick.ToArray(), TriggerName.onTick);
                }
            }
            break;

            case TimerPriority.TenMS:
            {
                if (EveryTenMS.Count > 0)
                {
                    Trigger(EveryTenMS.ToArray(), TriggerName.onTenMS);
                }
            }
            break;

            case TimerPriority.TwentyFiveMS:
            {
                if (EveryTwentyFiveMS.Count > 0)
                {
                    Trigger(EveryTwentyFiveMS.ToArray(), TriggerName.onTwentyFiveMS);
                }
            }
            break;

            case TimerPriority.FiftyMS:
            {
                if (EveryFiftyMS.Count > 0)
                {
                    Trigger(EveryFiftyMS.ToArray(), TriggerName.onFiftyMS);
                }
            }
            break;

            case TimerPriority.TwoFiftyMS:
            {
                if (EveryTwoFiftyMS.Count > 0)
                {
                    Trigger(EveryTwoFiftyMS.ToArray(), TriggerName.onTwoFiftyMS);
                }
            }
            break;

            case TimerPriority.OneSecond:
            {
                if (EveryOneSecond.Count > 0)
                {
                    Trigger(EveryOneSecond.ToArray(), TriggerName.onOneSecond);
                }
            }
            break;

            case TimerPriority.FiveSeconds:
            {
                if (EveryFiveSeconds.Count > 0)
                {
                    Trigger(EveryFiveSeconds.ToArray(), TriggerName.onFiveSeconds);
                }
            }
            break;

            case TimerPriority.OneMinute:
            {
                if (EveryOneMinute.Count > 0)
                {
                    Trigger(EveryOneMinute.ToArray(), TriggerName.onOneMinute);
                }
            }
            break;
            }
        }
 /// <summary>
 /// 延迟调用的时间有状态类
 /// </summary>
 /// <param name="delayTimeSpan">延迟的时间</param>
 /// <param name="intervalTimeSpan">间隔的时间</param>
 /// <param name="iCount">调用的次数</param>
 /// <param name="timerStateCallback">委托</param>
 /// <param name="oState">回调的状态类</param>
 public DelayStateCallTimer( TimerPriority processPriority, TimeSpan delayTimeSpan, TimeSpan intervalTimeSpan, long iCount, TimeSliceStateCallback timerStateCallback, object oState )
     : base( processPriority, delayTimeSpan, intervalTimeSpan, iCount )
 {
     m_Callback = timerStateCallback;
     m_State = oState;
 }
예제 #42
0
 private UberScriptTimer(TimerPriority p)
     : base(DelayFromPriority(p), DelayFromPriority(p))
 {
     _InternalPriority = p;
 }
예제 #43
0
				public ConcussionTimer(TimerPriority priority, int range, IPoint2D point2D, Map map)
					: base(TimeSpan.Zero, TimeSpan.Zero)
				{
					Priority = priority;
					Point = point2D;
					Map = map;
					Range = range;
				}
예제 #44
0
 public BucketTimer(Action action, TimerPriority prio)
 {
     m_Action = action;
     priority = prio;
 }
예제 #45
0
		private UberScriptTimer(TimerPriority p)
			: base(DelayFromPriority(p), DelayFromPriority(p))
		{
			_InternalPriority = p;
		}