Exemplo n.º 1
0
 internal CoreMod()
 {
     this.configuration                = new ModConfiguration();
     this.configuration.assembly       = Assembly.GetExecutingAssembly();
     this.configuration.contentManager = ContentManagers.GetContentManager(typeof(DefaultContentManager));
     this.configuration.name           = "DuckGame";
     this.configuration.displayName    = "Core";
     this.configuration.description    = "The core mod for Duck Game content. This is no touchy. Bad. BAD duck. You will break your game, and I swear if you do I'm not picking that up. I just don't have the time these days to pick up after all of your goddamn mistakes. Seriously, just leave it alone. (it okay just do your best)";
     this.configuration.version        = new Version(DG.version);
     this.configuration.author         = "CORPTRON";
 }
Exemplo n.º 2
0
 private static Mod GetOrLoad(
     ModConfiguration modConfig,
     ref Stack <string> modLoadStack,
     ref Dictionary <string, ModConfiguration> loadableMods)
 {
     if (modLoadStack.Contains(modConfig.uniqueID))
     {
         throw new ModCircularDependencyException(modLoadStack);
     }
     modLoadStack.Push(modConfig.uniqueID);
     try
     {
         Mod mod1;
         if (ModLoader._loadedMods.TryGetValue(modConfig.uniqueID, out mod1))
         {
             return(mod1);
         }
         Mod mod2;
         if (modConfig.disabled)
         {
             mod2 = (Mod) new DisabledMod();
         }
         else
         {
             foreach (string hardDependency in modConfig.hardDependencies)
             {
                 ModConfiguration modConfig1;
                 if (!loadableMods.TryGetValue(hardDependency, out modConfig1))
                 {
                     throw new ModDependencyNotFoundException(modConfig.uniqueID, hardDependency);
                 }
                 if (modConfig1.disabled)
                 {
                     throw new ModDependencyNotFoundException(modConfig.uniqueID, hardDependency);
                 }
                 ModLoader.GetOrLoad(modConfig1, ref modLoadStack, ref loadableMods);
             }
             foreach (string softDependency in modConfig.softDependencies)
             {
                 ModConfiguration modConfig1;
                 if (loadableMods.TryGetValue(softDependency, out modConfig1) && !modConfig1.disabled)
                 {
                     ModLoader.GetOrLoad(modConfig1, ref modLoadStack, ref loadableMods);
                 }
             }
             modConfig.assembly = Assembly.Load(File.ReadAllBytes(modConfig.isDynamic ? modConfig.tempAssemblyPath : modConfig.assemblyPath));
             System.Type[] array1 = ((IEnumerable <System.Type>)modConfig.assembly.GetExportedTypes()).Where <System.Type>((Func <System.Type, bool>)(type => type.IsSubclassOf(typeof(IManageContent)) && type.IsPublic && type.IsClass && !type.IsAbstract)).ToArray <System.Type>();
             modConfig.contentManager = array1.Length <= 1 ? ContentManagers.GetContentManager(array1.Length == 1 ? array1[0] : (System.Type)null) : throw new ModTypeMissingException(modConfig.uniqueID + " has more than one content manager class");
             System.Type[] array2 = ((IEnumerable <System.Type>)modConfig.assembly.GetExportedTypes()).Where <System.Type>((Func <System.Type, bool>)(type => type.IsSubclassOf(typeof(Mod)) && !type.IsAbstract)).ToArray <System.Type>();
             if (array2.Length != 1)
             {
                 throw new ModTypeMissingException(modConfig.uniqueID + " is missing or has more than one Mod subclass");
             }
             if (MonoMain.preloadModContent && modConfig.preloadContent)
             {
                 modConfig.content.PreloadContent();
             }
             else
             {
                 modConfig.content.PreloadContentPaths();
             }
             mod2 = (Mod)Activator.CreateInstance(array2[0]);
         }
         mod2.configuration = modConfig;
         ModLoader.AddMod(mod2);
         return(mod2);
     }
     finally
     {
         modLoadStack.Pop();
     }
 }
Exemplo n.º 3
0
        internal static IManageContent GetContentManager(System.Type t)
        {
            if (t == (System.Type)null)
            {
                t = typeof(DefaultContentManager);
            }
            IManageContent manageContent;

            return(ContentManagers._contentManagers.TryGetValue(t, out manageContent) ? manageContent : ContentManagers.AddContentManager(t));
        }