Ejemplo n.º 1
0
 /// <summary>
 /// Activate the mod loader.
 /// Activation is only preformed the first time this is called.
 /// </summary>
 public static void Activate()
 {
     if (!activated)
     {
         ModLoader.Initialize();
         activated = true;
     }
 }
Ejemplo n.º 2
0
        public Manager()
        {
            InitializeSettings();

            if (!Settings.GetItem <bool>(Resources.EnableCentrifugeSettingsKey))
            {
                Log.Info("Centrifuge was disabled via reactor.json. No mods will be loaded. Goodbye.");
                return;
            }

            UnityLog    = new UnityLog();
            HarmonyXLog = new HarmonyXLog();

            Hotkeys   = new HotkeyManager();
            Messenger = new Messenger();

            GameSupportLoader = new GameSupportLoader(this);

            ModRegistry = new ModRegistry();
            ModLoader   = new ModLoader(this, GetModRepositoryPath(), ModRegistry);

            GameSupportLoader.Initialize();
            ModLoader.Initialize();
        }
Ejemplo n.º 3
0
 public static void InitiatePatching()
 {
     ModLoader.Initialize();
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes the engine.
        /// </summary>
        protected sealed override void Initialize()
        {
            FileMarshal.Setup();

            Content.RootDirectory = "Data";
            LoadEngineContent();
            LoadAssets();

            IsMouseVisible = true;
            GraphicsDeviceManager.SynchronizeWithVerticalRetrace = false;
            IsFixedTimeStep   = Screen.IsFullHeadless;
            TargetElapsedTime = TimeSpan.FromSeconds(1.0f / 60);
            InactiveSleepTime = IsEditor ? TimeSpan.FromSeconds(1.0f / 2000) : TimeSpan.FromSeconds(1.0f / 60); // Alt-tabbed update rate.

            // If the engine ISN'T initialized (i.e, in editor mode)...
            if (!isInitialized)
            {
                ThreadPool.SetMinThreads(Environment.ProcessorCount, 8);

                Config.Initialize();
                InputManager.Initialize(this);
                Reflection.Initialize();
                ModLoader.Initialize();
                GameLoop = new GameLoop();

                ParticleEngine.AllocationMode = Config.Performance.UseArrayPoolParticles
                    ? ParticleAllocationMode.ArrayPool
                    : ParticleAllocationMode.Array;
                ParticleEngine.Initialize();

                UIManager.Initialize();
                if (!Screen.IsFullHeadless)
                {
                    Core.Lighting.Initialize();
                }

                SpatialPartitionManager.Initialize(192, 192 * 8);
                Core.Physics.Initialize();

                Network.OnLogInfo    += (msg, important) => Console.LogInfo(msg, important, LogSource.Network);
                Network.OnLogWarning += (msg, exception) => {
                    if (!string.IsNullOrEmpty(msg))
                    {
                        Console.LogWarning(msg, LogSource.Network);
                    }
                    else
                    {
                        Console.LogWarning(exception, LogSource.Network);
                    }
                };
                Network.OnLogError += (msg, exception) => {
                    if (!string.IsNullOrEmpty(msg))
                    {
                        Console.LogError(msg, LogSource.Network);
                    }
                    else
                    {
                        Console.LogError(exception, LogSource.Network);
                    }
                };

                SetCurrentScene("_MAIN\\empty");
                if (!Screen.IsFullHeadless)
                {
                    Core.Rendering.Initialize(GraphicsDeviceManager, GraphicsDevice);
                    Console.InitializeStats(Core.Rendering.SpriteBatch);
                }

                // After core initialization. Console will work here.
                Console.Initialize();
                Console.LogInfo("Core engine loaded.", true);
                Console.LogInfo("Game loop loaded:", true);
                Console.LogInfo(GameLoop.ToString());

                Network.Initialize();
                Screen.Reset();
                Initalized?.Invoke();

                Console.LogInfo("Finished initialization.", true);
            }

            if (IsEditor)
            {
                Editor.ChangeInstance(this);
                Editor.OnInitialize(this);
            }

            OnInitialize();
            isInitialized = true;
        }