public override void Init(ITorchBase torch)
        {
            base.Init(torch);
            this.ListenOnGameLoaded(OnGameLoaded);
            this.ListenOnGameUnloading(OnGameUnloading);

            _cancellationTokenSource = new CancellationTokenSource();

            var configPath = this.MakeConfigFilePath();

            _config = Persistent <DotTraceConnectorConfig> .Load(configPath);

            _fileLoggingConfigurator = new FileLoggingConfigurator(
                "TorchDotTraceConnector",
                new[] { "TorchDotTraceConnector.*" },
                Config.LogFilePath);

            _fileLoggingConfigurator.Initialize();
            _fileLoggingConfigurator.Configure(Config);

            _connector       = new DotTraceConnector(Config);
            _simDropObserver = new SimDropObserver(10);

            Config.PropertyChanged += (sender, args) =>
            {
                _fileLoggingConfigurator.Configure(Config);
            };
        }
        async void OnConfigPropertyChanged(object sender, PropertyChangedEventArgs args)
        {
            try
            {
                _fileLoggingConfigurator.Configure(Config);

                if (Config.Enable)
                {
                    if (args.PropertyName == nameof(Config.Enable) ||
                        args.PropertyName == nameof(Config.Token))
                    {
                        await TorchAlert.InitializeDiscordAsync();
                    }

                    if (args.PropertyName == nameof(Config.EnableGameText) ||
                        args.PropertyName == nameof(Config.GameText))
                    {
                        await TorchAlert.UpdateGameTextAsync();
                    }
                }
            }
            catch (Exception e)
            {
                Log.Warn(e, "failed applying config changes");
            }
        }
        public override void Init(ITorchBase torch)
        {
            base.Init(torch);
            this.ListenOnGameLoaded(OnGameLoaded);
            this.ListenOnGameUnloading(OnGameUnloading);

            _cancellationTokenSource = new CancellationTokenSource();

            var configPath = this.MakeConfigFilePath();

            _config = Persistent <TorchAlertConfig> .Load(configPath);

            Config.PropertyChanged += OnConfigPropertyChanged;

            _fileLoggingConfigurator = new FileLoggingConfigurator(nameof(TorchAlert), new[] { "TorchAlert.*", "Discord.Net.*" }, Config.LogFilePath);
            _fileLoggingConfigurator.Initialize();
            _fileLoggingConfigurator.Configure(Config);

            var linkDbPath  = this.MakeFilePath($"{nameof(DiscordIdentityLinker)}.csv");
            var splitLookup = new ParentsLookupTree <long>();

            TorchAlert = new Core.TorchAlert(Config, linkDbPath, splitLookup);
            MyCubeGridPatch.SplitLookup = splitLookup;

            Log.Info("initialized");
        }
Exemple #4
0
        public override void Init(ITorchBase torch)
        {
            base.Init(torch);
            this.ListenOnGameLoaded(OnGameLoaded);
            this.ListenOnGameUnloading(OnGameUnloading);

            var configFilePath = this.MakeConfigFilePath();

            _config = Persistent <AutoModeratorConfig> .Load(configFilePath);

            _config.Data.Initialize();
            Config.PropertyChanged += OnConfigChanged;

            _fileLoggingConfigurator = new FileLoggingConfigurator(
                "AutoModerator",
                new[] { "AutoModerator.*", "Utils.TorchEntityGps.*", "Utils.TimeSerieses.*" },
                AutoModeratorConfig.DefaultLogFilePath);

            _fileLoggingConfigurator.Initialize();
            _fileLoggingConfigurator.Configure(Config);

            // Local Gps Mod
            ModAdditionPatch.AddModForServerAndClient(2781829620);
        }
Exemple #5
0
 void OnConfigChanged(object _, PropertyChangedEventArgs args)
 {
     _fileLoggingConfigurator.Configure(Config);
     Log.Info("config changed");
 }