/// <summary> /// Создаёт экземпляр сектора подземелий с указанными параметрами. /// </summary> /// <param name="sectorNode"> Схема генерации сектора. </param> /// <returns> Возвращает экземпляр сектора. </returns> public async Task <ISector> GenerateAsync(ISectorNode sectorNode) { if (sectorNode is null) { throw new ArgumentNullException(nameof(sectorNode)); } var mapFactory = _mapFactorySelector.GetMapFactory(sectorNode); var transitions = MapFactoryHelper.CreateTransitions(sectorNode); var mapGeneratorOptions = sectorNode.SectorScheme.MapGeneratorOptions; if (mapGeneratorOptions is null) { throw new InvalidOperationException(); } var sectorFactoryOptions = new SectorMapFactoryOptions(mapGeneratorOptions, transitions); var map = await mapFactory.CreateAsync(sectorFactoryOptions).ConfigureAwait(false); var locationScheme = sectorNode.Biome.LocationScheme; var sector = _sectorFactory.Create(map, locationScheme); DefineDiseases(sector); var gameObjectRegions = map.Regions.Where(x => !x.IsStart).ToArray(); var sectorScheme = sectorNode.SectorScheme; await GenerateStaticObjectsAsync(sector, sectorScheme, sectorNode).ConfigureAwait(false); var monsterRegions = gameObjectRegions.ToArray(); _monsterGenerator.CreateMonsters(sector, monsterRegions, sectorScheme); return(sector); }
/// <summary> /// Создаёт экземпляр сектора подземелий с указанными параметрами. /// </summary> /// <param name="sectorNode"> Схема генерации сектора. </param> /// <returns> Возвращает экземпляр сектора. </returns> public async Task <ISector> GenerateAsync(ISectorNode sectorNode) { if (sectorNode is null) { throw new ArgumentNullException(nameof(sectorNode)); } var mapFactory = _mapFactorySelector.GetMapFactory(sectorNode); var transitions = MapFactoryHelper.CreateTransitions(sectorNode); var sectorFactoryOptions = new SectorMapFactoryOptions(sectorNode.SectorScheme.MapGeneratorOptions, transitions); var map = await mapFactory.CreateAsync(sectorFactoryOptions).ConfigureAwait(false); var locationScheme = sectorNode.Biome.LocationScheme; var sector = _sectorFactory.Create(map, locationScheme); DefineDiseases(sector); var gameObjectRegions = map.Regions.Where(x => !x.IsStart).ToArray(); var sectorScheme = sectorNode.SectorScheme; var resourceDepositData = _resourceMaterializationMap.GetDepositData(sectorNode); var staticObjectgenerationContext = new StaticObjectGenerationContext(sector, sectorScheme, resourceDepositData); await _staticObstaclesGenerator.CreateAsync(staticObjectgenerationContext).ConfigureAwait(false); var monsterRegions = gameObjectRegions.ToArray(); _monsterGenerator.CreateMonsters(sector, _botPlayer, monsterRegions, sectorScheme); return(sector); }