コード例 #1
0
        public GameEngineBase(ContentManager contentManager, IServiceRegistry services, GameSystemCollection gameSystems = null)
        {
            Logger = GlobalLogger.GetLogger(GetType().GetTypeInfo().Name);

            GameClockManager = new GameClockManager(PhysicsGameTime);
            _targetTimeDriftAdjustmentThreshold = GameClockManager.SimulationDeltaTime.Ticks / 10;     // 10% of a single sim step

            Services    = (ServiceRegistry)services;
            Content     = contentManager;
            GameSystems = gameSystems ?? new GameSystemCollection(Services);

            // Replacing existing IGameSystemCollection with our own
            var existingGameSystems = Services.GetService <IGameSystemCollection>();

            if (existingGameSystems != null)
            {
                Services.RemoveService <IGameSystemCollection>();
            }
            Services.AddOrOverwriteService <IGameSystemCollection>(GameSystems);

            var networkAssetDatabase = new NetworkAssetDatabase(Content, assetFolderUrls: new[] { "Prefabs", "Scenes" });

            Services.AddOrOverwriteService(networkAssetDatabase);

            Services.AddOrOverwriteService(GameClockManager);

            var gameSettingsService = services.GetSafeServiceAs <IGameSettingsService>();

            Settings = gameSettingsService.Settings;
        }