Beispiel #1
0
        protected static void BootMod(PreloadMod mod)
        {
            var startupAssembly = mod.Info.PreloadAssembly;
            var startupClass    = mod.Info.PreloadClass;

            if (startupAssembly.IsNullOrWhiteSpace() || startupClass.IsNullOrWhiteSpace())
            {
                _log.LogInfo($"Loaded {mod.Info.Name}");
                return;
            }

            var assembly = GetStartupAssembly(mod);

            if (assembly == null)
            {
                _log.LogInfo($"Couldn't find preload startup assembly for {mod.Info.Name}: {startupAssembly}");
                return;
            }

            var type = GetStartupClass(assembly, startupClass);

            if (type == null)
            {
                _log.LogInfo($"Couldn't find preload startup class for {mod.Info.Name} in assembly {startupAssembly}: {startupClass}");
                return;
            }

            InstantiateStartupClass(type, mod);
            _log.LogInfo($"Loaded {mod.Info.Name} {mod.Info.Version} by {mod.Info.Author}");
        }
Beispiel #2
0
        protected static Assembly GetStartupAssembly(PreloadMod mod)
        {
            var assemblyName = mod.Info.PreloadAssembly;
            var assemblyPath = Path.Combine(mod.InstallPath, "preload", $"{assemblyName}.dll");

            return(Assembly.LoadFrom(assemblyPath));
        }
Beispiel #3
0
        protected static void LoadMod(string modInfoPath)
        {
            var mod = new PreloadMod(modInfoPath);

            if (!mod.IsValid)
            {
                _log.LogWarning($"Failed to load {mod.Info.Name}");
                return;
            }

            BootMod(mod);
        }
Beispiel #4
0
 protected static void InstantiateStartupClass(Type type, PreloadMod mod)
 {
     Activator.CreateInstance(type, mod);
     _instances.Add(mod);
 }