public EntityControllerBase(int id, string username, Faction faction)
        {
            _logger = GameContext.Logger ?? throw new ArgumentNullException("invalid logger!");

            ID       = id;
            Username = username;
            Faction  = faction;

            CurrentClock = new OffsetStopwatch(TimeSpan.FromSeconds(10));
        }
Exemplo n.º 2
0
        public static void CreateTimer(string name)
        {
            if (_timers.ContainsKey(name))
            {
                RemoveTimer(name);
            }

            OffsetStopwatch timer = new OffsetStopwatch(TimeSpan.Zero);

            timer.Start();

            _timers.Add(name, timer);
        }
Exemplo n.º 3
0
        public void OffsetStopwatch_WithoutOffset_ElapsedTimeWithoutOffset()
        {
            // Arrange
            var stopwatch = new OffsetStopwatch();

            // Act

            stopwatch.Start();
            Thread.Sleep(2000);
            stopwatch.Stop();

            // Assert

            Assert.AreEqual(0, stopwatch.Elapsed.Hours);
            Assert.AreEqual(0, stopwatch.Elapsed.Minutes);
            Assert.AreEqual(2, stopwatch.Elapsed.Seconds);
        }
Exemplo n.º 4
0
        public void OffsetStopwatch_3HoursAdded_ElapsedTimeWith3Hours()
        {
            // Arrange
            var stopwatch = new OffsetStopwatch(TimeSpan.FromHours(3));

            // Act

            stopwatch.Start();
            Thread.Sleep(2000);
            stopwatch.Stop();

            // Assert

            Assert.AreEqual(3, stopwatch.Elapsed.Hours);
            Assert.AreEqual(0, stopwatch.Elapsed.Minutes);
            Assert.AreEqual(2, stopwatch.Elapsed.Seconds);
        }
Exemplo n.º 5
0
        public static void CreateTimer(string name)
        {
            OffsetStopwatch timer = new OffsetStopwatch(TimeSpan.Zero);

            _timers.AddOrUpdate(name, t => timer, (t, o) => timer);
        }