예제 #1
0
        /// <summary>
        /// Register all object builders types from game assemblies. This function must be called after links to assemblies in MyPlugins are set!
        /// Returns false if assembly links are not set. Only MyPlugins.UserAssembly can be null.
        /// </summary>
        public static bool RegisterAssemblies()
        {
            if (m_typeById.Count > 0)
            {
                UnregisterAssemblies();
            }

            MyObjectBuilderType.RegisterFromAssembly(Assembly.GetExecutingAssembly(), registerLegacyNames: true);
            //MyObjectBuilderType.RegisterLegacyName(typeof(MyObjectBuilder_GlobalEventDefinition), "EventDefinition");
            //MyObjectBuilderType.RegisterLegacyName(typeof(MyObjectBuilder_FactionCollection), "Factions");
            if (MyPlugins.SandboxAssemblyReady)
            {
                MyObjectBuilderType.RegisterFromAssembly(MyPlugins.SandboxAssembly, registerLegacyNames: true); //TODO: Will be removed
            }
            if (MyPlugins.GameAssemblyReady)
            {
                MyObjectBuilderType.RegisterFromAssembly(MyPlugins.GameAssembly, registerLegacyNames: true);
            }
            if (MyPlugins.GameObjectBuildersAssemblyReady)
            {
                MyObjectBuilderType.RegisterFromAssembly(MyPlugins.GameObjectBuildersAssembly, registerLegacyNames: true);
            }
            if (MyPlugins.UserAssemblyReady)
            {
                MyObjectBuilderType.RegisterFromAssembly(MyPlugins.UserAssembly, registerLegacyNames: true);
            }

            return(Assembly.GetExecutingAssembly() != null && MyPlugins.SandboxAssembly != null &&
                   MyPlugins.GameAssembly != null && MyPlugins.GameObjectBuildersAssembly != null);
        }
예제 #2
0
        static MyObjectBuilderType()
        {
            m_typeByName       = new Dictionary <string, MyObjectBuilderType>(200);
            m_typeByLegacyName = new Dictionary <string, MyObjectBuilderType>(200);
            m_typeById         = new Dictionary <MyRuntimeObjectBuilderId, MyObjectBuilderType>(200, MyRuntimeObjectBuilderId.Comparer);
            m_idByType         = new Dictionary <MyObjectBuilderType, MyRuntimeObjectBuilderId>(200, MyObjectBuilderType.Comparer);

            MyObjectBuilderType.RegisterFromAssembly(Assembly.GetExecutingAssembly(), registerLegacyNames: true);

            //MyObjectBuilderType.RegisterLegacyName(typeof(MyObjectBuilder_GlobalEventDefinition), "EventDefinition");
            //MyObjectBuilderType.RegisterLegacyName(typeof(MyObjectBuilder_FactionCollection), "Factions");

            MyObjectBuilderType.RegisterFromAssembly(MyPlugins.GameAssembly, true);
            MyObjectBuilderType.RegisterFromAssembly(MyPlugins.SandboxAssembly, true); //TODO: Will be removed
            MyObjectBuilderType.RegisterFromAssembly(MyPlugins.UserAssembly, true);
        }