Exemple #1
0
        internal static void Load()
        {
            ILEdits = new Dictionary <string, ILEdit>();
            Detours = new Dictionary <string, Detour>();

            Type[] types = JourneysBeginning.Instance.Code.GetTypes();

            foreach (Type type in types)
            {
                if (type.IsAbstract || type.GetConstructor(new Type[0]) == null)
                {
                    continue;
                }

                if (type.IsSubclassOf(typeof(ILEdit)))
                {
                    ILEdit ilEdit = Activator.CreateInstance(type) as ILEdit;

                    ILEdits.Add(ilEdit.DictKey, ilEdit);
                }

                if (type.IsSubclassOf(typeof(Detour)))
                {
                    Detour detour = Activator.CreateInstance(type) as Detour;

                    Detours.Add(detour.DictKey, detour);
                }
            }

            JourneysBeginning.ModLogger.Debug($"Found {ILEdits.Count} IL edits to load!");

            foreach (ILEdit ilEdit in ILEdits.Values)
            {
                ilEdit.Load();
            }

            JourneysBeginning.ModLogger.Debug($"Found {Detours.Count} detours to load!");

            foreach (Detour detour in Detours.Values)
            {
                detour.Load();
            }

            HasLoaded = true;
        }
Exemple #2
0
        public static void Load()
        {
            Detours = new Dictionary <string, Detour>();
            ILEdits = new Dictionary <string, ILEdit>();

            foreach (Type type in CataclysmMod.Instance.Code.GetTypes())
            {
                if (!type.IsAbstract && type.GetConstructor(new Type[] { }) != null)
                {
                    if (type.IsSubclassOf(typeof(Detour)))
                    {
                        Detour detour = Activator.CreateInstance(type) as Detour;

                        if (detour.Autoload())
                        {
                            Detours.Add(detour.DictKey, detour);
                        }
                    }

                    if (type.IsSubclassOf(typeof(ILEdit)))
                    {
                        ILEdit ilEdit = Activator.CreateInstance(type) as ILEdit;

                        if (ilEdit.Autoload())
                        {
                            ILEdits.Add(ilEdit.DictKey, ilEdit);
                        }
                    }
                }
            }

            foreach (Detour detour in Detours.Values)
            {
                detour.Load();
            }

            foreach (ILEdit ilEdit in ILEdits.Values)
            {
                ilEdit.Load();
            }
        }