Example #1
0
        public IGame Build(IGameOptions gameOptions = null)
        {
            LoadAreas();
            LoadCommands();
            _startup.ConfigureCommands(this);

            _serviceCollection.AddSingleton <IGame, Game>(services => new Game(services.GetService <ICommander>(), GameServices, _commands, _globalCommands, _areas, gameOptions ?? new GameOptions()));

            GameServices = _serviceCollection.BuildServiceProvider();

            var game = GameServices.GetService <IGame>();

            _startup.ConfigureGame(game);
            GameServices.GetRequiredService <ICommander>().OnGameCreated(game);

            return(game);
        }