Exemple #1
0
        public TriggerBase([NotNull] TriggerEntity triggerEntity, [NotNull] ISoundManager soundManager, [NotNull] ITrayPopups trayPopups,
                           [NotNull] IWurmApi wurmApi, [NotNull] ILogger logger,
                           [NotNull] ITelemetry telemetry)
        {
            if (triggerEntity == null)
            {
                throw new ArgumentNullException("triggerEntity");
            }
            if (soundManager == null)
            {
                throw new ArgumentNullException("soundManager");
            }
            if (trayPopups == null)
            {
                throw new ArgumentNullException("trayPopups");
            }
            if (wurmApi == null)
            {
                throw new ArgumentNullException("wurmApi");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            this.TriggerEntity = triggerEntity;
            this.SoundManager  = soundManager;
            this.TrayPopups    = trayPopups;
            this.WurmApi       = wurmApi;
            this.Logger        = logger;
            this.telemetry     = telemetry ?? throw new ArgumentNullException(nameof(telemetry));

            MuteChecker = () => false;
            Active      = true;

            if (triggerEntity.HasSound)
            {
                Sound = new SoundNotifier(this, soundManager);
            }
            if (triggerEntity.HasPopup)
            {
                Popup = new PopupNotifier(this, trayPopups);
            }

            telemetry.TrackEvent($"Triggers: initialized trigger {this.GetType().Name}");
        }
Exemple #2
0
        public TriggerBase([NotNull] TriggerEntity triggerEntity, [NotNull] ISoundManager soundManager, [NotNull] ITrayPopups trayPopups,
                           [NotNull] IWurmApi wurmApi, [NotNull] ILogger logger)
        {
            if (triggerEntity == null)
            {
                throw new ArgumentNullException("triggerEntity");
            }
            if (soundManager == null)
            {
                throw new ArgumentNullException("soundManager");
            }
            if (trayPopups == null)
            {
                throw new ArgumentNullException("trayPopups");
            }
            if (wurmApi == null)
            {
                throw new ArgumentNullException("wurmApi");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            this.TriggerEntity = triggerEntity;
            this.SoundManager  = soundManager;
            this.TrayPopups    = trayPopups;
            this.WurmApi       = wurmApi;
            this.Logger        = logger;

            MuteChecker = () => false;
            Active      = true;

            if (triggerEntity.HasSound)
            {
                Sound = new SoundNotifier(this, soundManager);
            }
            if (triggerEntity.HasPopup)
            {
                Popup = new PopupNotifier(this, trayPopups);
            }
        }