private void FindModLoaders(StateManager.StateTypes state, Type type, List <SetupOptions> modLoaders) { foreach (MethodInfo mi in type.GetMethods()) { if (!mi.IsPublic || !mi.IsStatic) { continue; } else if (mi.ContainsGenericParameters) { continue; } Invoke initAttribute = (Invoke)Attribute.GetCustomAttribute(mi, typeof(Invoke)); if (initAttribute == null) { continue; } else if (initAttribute.StartState != state) { continue; } ParameterInfo[] pi = mi.GetParameters(); if (pi.Length != 1) { continue; } else if (pi[0].ParameterType != typeof(InitParams)) { continue; } SetupOptions options = new SetupOptions(initAttribute.Priority, this, mi); #if DEBUG Debug.Log(string.Format("found new loader: {0} for mod: {1}", options.mi.Name, this.Title)); #endif modLoaders.Add(options); } }
public List <SetupOptions> FindModLoaders(StateManager.StateTypes state) { if (Assemblies == null || Assemblies.Count < 1) { return(null); } List <SetupOptions> modLoaders = new List <SetupOptions>(1); for (int i = 0; i < Assemblies.Count; i++) { try { Type[] types = Assemblies[i].GetTypes(); foreach (Type t in types) { if (!t.IsClass) { continue; } foreach (MethodInfo mi in t.GetMethods()) { if (!mi.IsPublic || !mi.IsStatic) { continue; } else if (mi.ContainsGenericParameters) { continue; } Invoke initAttribute = (Invoke)Attribute.GetCustomAttribute(mi, typeof(Invoke)); if (initAttribute == null) { continue; } else if (initAttribute.startState != state) { continue; } ParameterInfo[] pi = mi.GetParameters(); if (pi.Length != 1) { continue; } else if (pi[0].ParameterType != typeof(InitParams)) { continue; } SetupOptions options = new SetupOptions(initAttribute.priority, this, mi); #if DEBUG Debug.Log(string.Format("found new loader: {0} for mod: {1}", options.mi.Name, this.Name)); #endif modLoaders.Add(options); } } } catch (Exception ex) { Debug.LogError(ex.Message); continue; } } modLoaders.Sort(); return(modLoaders); }