public PlayerTimersGroup(string persistentObjectId, TimersFeature timersFeature,
                          [NotNull] IWurmApi wurmApi, [NotNull] ILogger logger, [NotNull] ISoundManager soundManager,
                          [NotNull] ITrayPopups trayPopups, [NotNull] TimerDefinitions timerDefinitions,
                          [NotNull] TimerInstances timerInstances)
     : base(persistentObjectId)
 {
     if (wurmApi == null)
     {
         throw new ArgumentNullException("wurmApi");
     }
     if (logger == null)
     {
         throw new ArgumentNullException("logger");
     }
     if (soundManager == null)
     {
         throw new ArgumentNullException("soundManager");
     }
     if (trayPopups == null)
     {
         throw new ArgumentNullException("trayPopups");
     }
     if (timerDefinitions == null)
     {
         throw new ArgumentNullException("timerDefinitions");
     }
     if (timerInstances == null)
     {
         throw new ArgumentNullException("timerInstances");
     }
     this.Id               = Guid.Parse(persistentObjectId);
     this.timersFeature    = timersFeature;
     this.wurmApi          = wurmApi;
     this.logger           = logger;
     this.timerDefinitions = timerDefinitions;
     this.timerInstances   = timerInstances;
 }
Esempio n. 2
0
        public TimersFeature(
            [NotNull] ITimerFactory timerFactory,
            [NotNull] ILogger logger,
            [NotNull] IWurmApi wurmApi,
            [NotNull] ISoundManager soundManager,
            [NotNull] ITrayPopups trayPopups,
            [NotNull] TimerDefinitions timerDefinitions,
            [NotNull] IPersistentObjectResolver <PlayerTimersGroup> playerTimersGroupsResolver,
            [NotNull] TimerInstances timerInstances)
        {
            if (timerFactory == null)
            {
                throw new ArgumentNullException(nameof(timerFactory));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (wurmApi == null)
            {
                throw new ArgumentNullException(nameof(wurmApi));
            }
            if (soundManager == null)
            {
                throw new ArgumentNullException(nameof(soundManager));
            }
            if (trayPopups == null)
            {
                throw new ArgumentNullException(nameof(trayPopups));
            }
            if (timerDefinitions == null)
            {
                throw new ArgumentNullException(nameof(timerDefinitions));
            }
            if (playerTimersGroupsResolver == null)
            {
                throw new ArgumentNullException(nameof(playerTimersGroupsResolver));
            }
            if (timerInstances == null)
            {
                throw new ArgumentNullException(nameof(timerInstances));
            }
            this.logger                     = logger;
            this.wurmApi                    = wurmApi;
            this.soundManager               = soundManager;
            this.trayPopups                 = trayPopups;
            this.timerDefinitions           = timerDefinitions;
            this.playerTimersGroupsResolver = playerTimersGroupsResolver;
            this.timerInstances             = timerInstances;

            updateTimer = timerFactory.CreateUiThreadTimer();

            updateTimer.Interval = TimeSpan.FromMilliseconds(500);
            updateTimer.Tick    += (sender, args) =>
            {
                foreach (var timergroup in timerGroups)
                {
                    timergroup.Update();
                }
                ;
            };
        }