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)); } }
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)); }
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)); }
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); }); } }
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(); }
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)); }
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)); }
public void Delay(float waitTime, Action action) { Logger.Log(string.Format("Delay method invoked! Will wait for {0} seconds...", waitTime)); StartCoroutine(DelayImpl(waitTime, action)); }