Example #1
0
        private void LoadGameServer(IBridge gameBridge)
        {
            _game = new GameServer();

            var serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton(_logger);
            serviceCollection.AddSingleton <IServerEngine>(this);

            if (gameBridge != null)
            {
                serviceCollection.AddSingleton(gameBridge);
            }

            serviceCollection.AddSingleton(_engine.EngineTime);
            serviceCollection.AddSingleton <IEngineModels>(_serverModels);
            serviceCollection.AddSingleton <IServerModels>(_serverModels);

            _game.Initialize(serviceCollection);

            var serviceProvider = serviceCollection.BuildServiceProvider();

            _serverNetworking = serviceProvider.GetRequiredService <IServerNetworking>();

            _game.Startup(serviceProvider);

            //Listen servers have the client do this
            if (_engine.IsDedicatedServer)
            {
                _engine.ModelManager.SetLoaders(_game.GetModelLoaders());
            }
        }