Пример #1
0
        // ModLoader Injection
        public static void InitMod()
        {
            var caller = Assembly.GetEntryAssembly()?.GetName().Name;
            var server = caller != null && caller.Equals("TerrariaServer");

            if (caller == null || server)
            {
                return;
            }

            var config  = new NLog.Config.LoggingConfiguration();
            var logfile = new NLog.Targets.FileTarget("logfile")
            {
                FileName                = $"{AssemblyDirectory}/logs/client.log",
                MaxArchiveFiles         = 10,
                Layout                  = Layout.FromString("${longdate}|${level:uppercase=true}|${logger}|${threadid}|${message}|${exception:format=tostring}"),
                ArchiveOldFileOnStartup = true
            };

            config.AddRule(LogLevel.Trace, LogLevel.Fatal, logfile);
            LogManager.Configuration = config;

            try
            {
                Main.OnEnginePreload += () =>
                {
                    var myMod = new MyMod(LogManager.GetLogger("StreamIntegration"));
                };
            }
            catch (Exception e)
            {
                var logger = LogManager.GetCurrentClassLogger();
                logger.Error(e, "Error loading mod");
            }
        }
Пример #2
0
 internal void Unload()
 {
     if (_integrationManager != null && Utils.IsClient())
     {
         _integrationManager.Close();
     }
     Instance            = null;
     _integrationManager = null;
     ActionManager       = null;
 }
Пример #3
0
        private MyMod(Logger logger)
        {
            Instance = this;
            DeathCounter.FileName = AssemblyDirectory + DeathCounter.FileName;
            DeathCounter          = new DeathCounter();
            _logger = logger;
            _logger.Info("Starting patching");
            var harmony = HarmonyInstance.Create("se.gory_moon.terraria.stream_integration");

            harmony.PatchAll(Assembly.GetExecutingAssembly());
            _logger.Info("Done patching");
        }