private void PickSolution() { if (this.spawnsSolutions.Count == 0) { throw new TmxImportException(); } foreach (ImportTmxSpawnLayer.Spawn spawn in this.spawnsSolutions[0]) { base.Report(spawn.EmpireIndex + " - " + spawn.RegionId); } int index = this.randomGenerator.Next(this.spawnsSolutions.Count); base.Context.SpawnRegions = new short[this.spawnsSolutions[index].Length]; base.Context.SpawnPointsDefault = new HexPos[this.spawnsSolutions[index].Length]; base.Context.SpawnEmpirePreferences = new List <HexPos> [this.spawnsSolutions[index].Length]; for (int j = 0; j < this.spawnsSolutions[index].Length; j++) { ImportTmxSpawnLayer.Spawn spawn2 = this.spawnsSolutions[index][j]; base.Context.SpawnRegions[j] = spawn2.RegionId; base.Context.SpawnPointsDefault[j] = spawn2.Hexe; base.Context.SpawnEmpirePreferences[j] = new List <HexPos> { spawn2.Hexe }; if (base.Context.Configuration.Empires[(int)spawn2.EmpireIndex].Name == "AffinityFlames") { this.ImportTmxSpawnLayer_TryVolcanizeRegion(base.Context.Regions[spawn2.RegionId]); } } }
public Spawn(ImportTmxSpawnLayer.Spawn spawn) { this.EmpireIndex = spawn.EmpireIndex; this.RegionId = spawn.RegionId; this.Hexe = spawn.Hexe; }
private void GetSpawns() { for (int i = 0; i < base.Context.Grid.Columns; i++) { for (int j = 0; j < base.Context.Grid.Rows; j++) { int num = this.tmxSpawnLayer.Data[j, i]; if (num != 0) { short num2; if (!short.TryParse(base.Context.Settings.TmxMap.GetTileProperty(num, ImportTmxSpawnLayer.spawnNameProperty), out num2)) { base.ReportTmx(string.Concat(new object[] { "?MissingPropertyTile&$Coordinate=", i, ",", j - base.Context.Grid.Rows + 1, "&$MissingProperty=", ImportTmxSpawnLayer.spawnNameProperty })); } else if (num2 >= 0 && (num2 <= 14 || num2 == 42)) { short regionId = base.Context.RegionData[j, i]; HexPos hexPos = new HexPos(i, j); Terrain terrain = base.Context.GetTerrain(hexPos); if (terrain.IsWaterTile || terrain.Name.Contains("Waste")) { base.ReportTmx(string.Concat(new object[] { "?SpawnIncompatibleTerrain&$Coordinate=", i, ",", j - base.Context.Grid.Rows + 1 })); } else { bool flag = false; foreach (Ridge ridge in base.Context.Ridges) { foreach (HexPos rhs in ridge.Hexes) { if (hexPos == rhs) { flag = true; } } } if (flag) { base.ReportTmx(string.Concat(new object[] { "?SpawnIncompatibleTerrain&$Coordinate=", i, ",", j - base.Context.Grid.Rows + 1 })); } else { string tileProperty = base.Context.Settings.TmxMap.GetTileProperty(num, ImportTmxSpawnLayer.affinityNameProperty); if (string.IsNullOrEmpty(tileProperty)) { this.spawns.Add(new ImportTmxSpawnLayer.Spawn(num2, regionId, hexPos)); } else { if (!this.affinitySpawns.ContainsKey(tileProperty)) { this.affinitySpawns.Add(tileProperty, new List <ImportTmxSpawnLayer.Spawn>()); } this.affinitySpawns[tileProperty].Add(new ImportTmxSpawnLayer.Spawn(-1, regionId, hexPos)); } } } } } } } this.OverrideNumericSpawns(); this.ReserveUnusedAffinitySpawns(); ImportTmxSpawnLayer.Spawn[] array = new ImportTmxSpawnLayer.Spawn[base.Context.EmpiresCount]; if (!this.FindSpawnsSet(ref array, 0)) { base.ReportTmx("?NoSpawnCombination"); } }