private Timer CreateTimer(double time, StoryEventType eventType, string key)
        {
            //if timeOffset goes past the time
            if (time <= 0)
            {
                return(null);
            }

            Timer timer = new Timer();

            timer.Elapsed += delegate
            {
                Log.Info($"Triggering event type {eventType} at time {time} with param {key}");
                playerManager.SendPacketToAllPlayers(new StoryEventSend(eventType, key));
            };
            timer.Interval  = time;
            timer.Enabled   = true;
            timer.AutoReset = false;
            if (!eventTimers.ContainsKey(key))
            {
                eventTimers.Add(key, timer);
            }
            return(timer);
        }
Beispiel #2
0
        public void SendCurrentTimePacket()
        {
            PlayerManager playerManager = NitroxServiceLocator.LocateService <PlayerManager>();

            playerManager.SendPacketToAllPlayers(new TimeChange(CurrentTime));
        }