Exemple #1
0
        private void LoadAssembly(string path)
        {
            try
            {
                Assembly assembly = Assembly.LoadFile(path);

                SpaceAddonAssembly[] attrbutes = assembly.GetCustomAttributes(typeof(SpaceAddonAssembly), false) as SpaceAddonAssembly[];

                if (attrbutes == null || attrbutes.Length == 0)
                {
                    Logger.Log(string.Format("This is not an adddon assembly! {0}", path));
                }
                else
                {
                    SpaceAddonAssembly    ea  = attrbutes[0];
                    List <Type>           mb  = GetAllSubclassesOf <Type, SpaceAddonMonoBehaviour, MonoBehaviour>(assembly);
                    AssemblyExternalTypes aet = new AssemblyExternalTypes(typeof(MonoBehaviour), mb);
                    AssemblyExternal      ae  = new AssemblyExternal(path, ea.Name, ea.Version, assembly, aet);

                    ExternalAssemblies.Add(ae);

                    TotalLoaded++;

                    FireHotPlugin(ae);
                }
            }
            catch (Exception ex)
            {
                Logger.Log(string.Format("LoadAssembly Exception: {0}", ex.Message));
            }
        }
Exemple #2
0
        private void FirePlugins(List <AssemblyExternal> ExternalAssemblies)
        {
            int counter = 0;

            foreach (AssemblyExternal assembly in ExternalAssemblies)
            {
                counter += assembly.Types.SelectMany(kvp => kvp.Value).Count(v => FirePlugin(v));
            }

            Logger.Log(string.Format("{0} plugins fired at scene №: {1}", counter, SceneManager.GetActiveScene().buildIndex));
        }
Exemple #3
0
        private void FirePlugins(List <AssemblyExternal> ExternalAssemblies, int level)
        {
            int counter = 0;

            foreach (AssemblyExternal assembly in ExternalAssemblies)
            {
                counter += assembly.Types.SelectMany(kvp => kvp.Value).Count(v => FirePlugin(v, level));
            }

            Logger.Log(string.Format("{0} plugins fired at scene №: {1}", counter, level));
        }
Exemple #4
0
        private void LoadDetectedAssemblies(List <string> allPaths)
        {
            if (allPaths == null)
            {
                DetectAssembies(out allPaths);
                Logger.Log("Something wrong with path's array! Detecting assemblies again!");
            }

            for (int i = 0; i < allPaths.Count; i++)
            {
                string path = allPaths[i];

                Delay(0.5f, () => { LoadAssembly(path); });
            }
        }
Exemple #5
0
        protected override void Pass()
        {
            Logger.Log(string.Format("AssemblyLoader Initiated at scene №: {0}", SceneManager.GetActiveScene().buildIndex));

            if (!Loaded)
            {
                DetectAndLoadAssemblies();
                Loaded = true;
            }

            if (SceneManager.GetActiveScene().buildIndex == 0 && Loaded)
            {
                Delay((TotalDetected + 1) * 2, () => { SceneManager.LoadScene(1); });
            }

            base.Pass();
        }
Exemple #6
0
        private void DetectAssembies(out List <string> allPaths)
        {
            string path = PathGlobals.GlobalModFolderPath;

            allPaths = new List <string>();

            try
            {
                allPaths.AddRange(Directory.GetFiles(path, "*.dll", SearchOption.AllDirectories));
            }
            catch (Exception ex)
            {
                Logger.Log(string.Format("DetectAssembies Exception: {0}", ex.Message));
            }

            TotalDetected = allPaths.Count;

            Logger.Log(string.Format("Assembies Detected: {0}", allPaths.Count));
        }
Exemple #7
0
        private void FireHotPlugin(AssemblyExternal Addon)
        {
            int counter = Addon.Types.SelectMany(kvp => kvp.Value).Count(v => FirePlugin(v, 0));

            Logger.Log(string.Format("{0} plugins fired at scene №: {1}", counter, SceneManager.GetActiveScene().buildIndex));
        }
Exemple #8
0
        public void Delay(float waitTime, Action action)
        {
            Logger.Log(string.Format("Delay method invoked! Will wait for {0} seconds...", waitTime));

            StartCoroutine(DelayImpl(waitTime, action));
        }