Exemplo n.º 1
0
        public static void LoadBasicEvents(TickCount currentTick)
        {
            TimeSpan time = new TimeSpan(0, 0, 0, 0, Core.GetTickCount().Tick);
            int      hour = (int)time.TotalHours % 12;

            DayCycleTimedEvent dayCycleEvent = new DayCycleTimedEvent("DayCycle");

            if (hour < 4)
            {
                Server.Globals.ServerTime = Enums.Time.Day;
                int tickDiff = (int)(time.TotalMilliseconds - new TimeSpan((int)time.TotalHours - hour, 0, 0).TotalMilliseconds);
                dayCycleEvent.SetInterval(currentTick, (int)new TimeSpan(4, 0, 0).TotalMilliseconds - tickDiff);
            }
            else if (hour < 6)
            {
                Server.Globals.ServerTime = Enums.Time.Dusk;
                int tickDiff = (int)(time.TotalMilliseconds - new TimeSpan((int)time.TotalHours - hour + 4, 0, 0).TotalMilliseconds);
                dayCycleEvent.SetInterval(currentTick, (int)new TimeSpan(2, 0, 0).TotalMilliseconds - tickDiff);
            }
            else if (hour < 10)
            {
                Server.Globals.ServerTime = Enums.Time.Night;
                int tickDiff = (int)(time.TotalMilliseconds - new TimeSpan((int)time.TotalHours - hour + 6, 0, 0).TotalMilliseconds);
                dayCycleEvent.SetInterval(currentTick, (int)new TimeSpan(4, 0, 0).TotalMilliseconds - tickDiff);
            }
            else
            {
                Server.Globals.ServerTime = Enums.Time.Dawn;
                int tickDiff = (int)(time.TotalMilliseconds - new TimeSpan((int)time.TotalHours - hour + 10, 0, 0).TotalMilliseconds);
                dayCycleEvent.SetInterval(currentTick, (int)new TimeSpan(2, 0, 0).TotalMilliseconds - tickDiff);
            }

            timedEvents.Add(dayCycleEvent);

            StatisticSaverTimedEvent statisticSaverEvent = new StatisticSaverTimedEvent("StatisticSaver");

            statisticSaverEvent.SetInterval(currentTick, 3600000);

            timedEvents.Add(statisticSaverEvent);

            ClientKeepAliveTimedEvent clientKeepAliveEvent = new ClientKeepAliveTimedEvent("ClientKeepAlive");

            clientKeepAliveEvent.SetInterval(currentTick, 600000);

            timedEvents.Add(clientKeepAliveEvent);
        }
Exemplo n.º 2
0
        public static void LoadBasicEvents(TickCount currentTick)
        {
            TimeSpan time = new TimeSpan(0, 0, 0, 0, Core.GetTickCount().Tick);
            int hour = (int)time.TotalHours % 12;

            DayCycleTimedEvent dayCycleEvent = new DayCycleTimedEvent("DayCycle");

            if (hour < 4) {
                Server.Globals.ServerTime = Enums.Time.Day;
                int tickDiff = (int)(time.TotalMilliseconds - new TimeSpan((int)time.TotalHours - hour, 0, 0).TotalMilliseconds);
                dayCycleEvent.SetInterval(currentTick, (int)new TimeSpan(4, 0, 0).TotalMilliseconds - tickDiff);
            } else if (hour < 6) {
                Server.Globals.ServerTime = Enums.Time.Dusk;
                int tickDiff = (int)(time.TotalMilliseconds - new TimeSpan((int)time.TotalHours - hour + 4, 0, 0).TotalMilliseconds);
                dayCycleEvent.SetInterval(currentTick, (int)new TimeSpan(2, 0, 0).TotalMilliseconds - tickDiff);
            } else if (hour < 10) {
                Server.Globals.ServerTime = Enums.Time.Night;
                int tickDiff = (int)(time.TotalMilliseconds - new TimeSpan((int)time.TotalHours - hour + 6, 0, 0).TotalMilliseconds);
                dayCycleEvent.SetInterval(currentTick, (int)new TimeSpan(4, 0, 0).TotalMilliseconds - tickDiff);
            } else {
                Server.Globals.ServerTime = Enums.Time.Dawn;
                int tickDiff = (int)(time.TotalMilliseconds - new TimeSpan((int)time.TotalHours - hour + 10, 0, 0).TotalMilliseconds);
                dayCycleEvent.SetInterval(currentTick, (int)new TimeSpan(2, 0, 0).TotalMilliseconds - tickDiff);
            }

            timedEvents.Add(dayCycleEvent);

            StatisticSaverTimedEvent statisticSaverEvent = new StatisticSaverTimedEvent("StatisticSaver");
            statisticSaverEvent.SetInterval(currentTick, 3600000);

            timedEvents.Add(statisticSaverEvent);

            ClientKeepAliveTimedEvent clientKeepAliveEvent = new ClientKeepAliveTimedEvent("ClientKeepAlive");
            clientKeepAliveEvent.SetInterval(currentTick, 600000);

            timedEvents.Add(clientKeepAliveEvent);
        }