mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-07 14:02:48 +07:00
Changed all usages of GetTilesInDisttance to center around TileInfo, not TileMap
This commit is contained in:
parent
6fcf9ec93e
commit
23bd52fc66
@ -52,6 +52,9 @@ class UnCivGame : Game() {
|
||||
gameInfo.tileMap = TileMap(20)
|
||||
gameInfo.civilizations.add(CivilizationInfo("Babylon", Vector2.Zero, gameInfo)) // first one is player civ
|
||||
|
||||
val freeTiles = gameInfo.tileMap.values
|
||||
freeTiles.removeAll()
|
||||
|
||||
val barbarianCivilization = CivilizationInfo()
|
||||
gameInfo.civilizations.add(barbarianCivilization)// second is barbarian civ
|
||||
|
||||
|
@ -147,7 +147,7 @@ class Automation {
|
||||
// todo
|
||||
|
||||
// else, find the closest enemy unit that we know of within 5 spaces and advance towards it
|
||||
val closestUnit = unit.civInfo.gameInfo.tileMap.getTilesInDistance(unit.getTile().position, 5)
|
||||
val closestUnit = unit.getTile().getTilesInDistance(5)
|
||||
.firstOrNull { attackableTiles.contains(it) }
|
||||
|
||||
if (closestUnit != null) {
|
||||
@ -168,8 +168,8 @@ class Automation {
|
||||
val tileMap = unit.civInfo.gameInfo.tileMap
|
||||
|
||||
// find best city location within 5 tiles
|
||||
val bestCityLocation = tileMap.getTilesInDistance(unit.getTile().position, 7)
|
||||
.filterNot { tileMap.getTilesInDistance(it.position,2).any { tid -> tid.isCityCenter } }
|
||||
val bestCityLocation = unit.getTile().getTilesInDistance(7)
|
||||
.filterNot { it.getTilesInDistance(2).any { tid -> tid.isCityCenter } }
|
||||
.sortedByDescending { rankTileAsCityCenter(it, unit.civInfo) }
|
||||
.first()
|
||||
|
||||
|
@ -26,7 +26,7 @@ public class WorkerAutomation(){
|
||||
}
|
||||
|
||||
private fun findTileToWork(currentTile: TileInfo, civInfo: CivilizationInfo): TileInfo {
|
||||
val selectedTile = currentTile.tileMap.getTilesInDistance(currentTile.position, 4)
|
||||
val selectedTile = currentTile.getTilesInDistance(4)
|
||||
.filter {
|
||||
(it.unit == null || it == currentTile)
|
||||
&& it.improvement == null
|
||||
|
@ -8,9 +8,8 @@ class CityExpansionManager {
|
||||
lateinit var cityInfo: CityInfo
|
||||
var cultureStored: Int = 0
|
||||
|
||||
fun reset(){
|
||||
cityInfo.tiles = ArrayList(cityInfo.civInfo.gameInfo.tileMap
|
||||
.getTilesInDistance(cityInfo.location, 1).map { it.position })
|
||||
fun reset() {
|
||||
cityInfo.tiles = ArrayList(cityInfo.getCenterTile().getTilesInDistance(1).map { it.position })
|
||||
}
|
||||
|
||||
// This one has conflicting sources -
|
||||
@ -31,7 +30,7 @@ class CityExpansionManager {
|
||||
cultureStored -= getCultureToNextTile()
|
||||
|
||||
for (i in 2..3) {
|
||||
val tiles = cityInfo.civInfo.gameInfo.tileMap.getTilesInDistance(cityInfo.location, i).filter { it.getOwner() == null }
|
||||
val tiles = cityInfo.getCenterTile().getTilesInDistance(i).filter { it.getOwner() == null }
|
||||
if (tiles.isEmpty()) continue
|
||||
val chosenTile = tiles.maxBy { Automation().rankTile(it,cityInfo.civInfo) }
|
||||
cityInfo.tiles.add(chosenTile!!.position)
|
||||
|
@ -33,7 +33,7 @@ class CityInfo {
|
||||
fun getCenterTile(): TileInfo = tileMap[location]
|
||||
fun getTiles(): List<TileInfo> = tiles.map { tileMap[it] }
|
||||
|
||||
fun getTilesInRange(): List<TileInfo> = tileMap.getTilesInDistance(location, 3).filter { civInfo == it.getOwner() }
|
||||
fun getTilesInRange(): List<TileInfo> = getCenterTile().getTilesInDistance( 3).filter { civInfo == it.getOwner() }
|
||||
|
||||
|
||||
// Remove resources required by buildings
|
||||
|
@ -239,7 +239,7 @@ class CityStats {
|
||||
var tilesToCheck : List<TileInfo> = listOf(cityInfo.getCenterTile())
|
||||
while (tilesToCheck.isNotEmpty()) {
|
||||
val newTiles = tilesToCheck
|
||||
.flatMap { cityInfo.tileMap.getTilesInDistance(it.position, 1) }.distinct()
|
||||
.flatMap { it.neighbors }.distinct()
|
||||
.filter{ !tilesReached.contains(it) && !tilesToCheck.contains(it)
|
||||
&& (roadType !== RoadStatus.Road || it.roadStatus !== RoadStatus.None)
|
||||
&& (roadType !== RoadStatus.Railroad || it.roadStatus === roadType) }
|
||||
|
@ -61,7 +61,7 @@ class TechManager {
|
||||
for (tileInfo in civInfo.gameInfo.tileMap.values
|
||||
.filter { it.resource == revealedResource.name && civInfo == it.getOwner() }) {
|
||||
|
||||
val closestCityTile = civInfo.gameInfo.tileMap.getTilesInDistance(tileInfo.position, 4)
|
||||
val closestCityTile = tileInfo.getTilesInDistance(4)
|
||||
.firstOrNull { it.isCityCenter }
|
||||
if (closestCityTile != null) {
|
||||
civInfo.addNotification(
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.unciv.models.gamebasics
|
||||
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.logic.city.CityConstructions
|
||||
import com.unciv.logic.city.IConstruction
|
||||
import com.unciv.models.stats.NamedStats
|
||||
import com.unciv.models.stats.Stats
|
||||
import com.unciv.ui.ScienceVictoryScreen
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.ui.VictoryScreen
|
||||
import com.unciv.ui.pickerscreens.PolicyPickerScreen
|
||||
|
||||
@ -142,7 +142,7 @@ class Building : NamedStats(), IConstruction, ICivilopedia {
|
||||
if (requiredBuildingInAllCities != null && civInfo.cities.any { !it.cityConstructions.isBuilt(requiredBuildingInAllCities!!) })
|
||||
return false
|
||||
if (cannotBeBuiltWith != null && construction.isBuilt(cannotBeBuiltWith!!)) return false
|
||||
if ("MustBeNextToDesert" == unique && !civInfo.gameInfo.tileMap.getTilesInDistance(construction.cityInfo.location, 1).any { it.baseTerrain == "Desert" })
|
||||
if ("MustBeNextToDesert" == unique && !construction.cityInfo.getCenterTile().getTilesInDistance(1).any { it.baseTerrain == "Desert" })
|
||||
return false
|
||||
if (requiredResource != null && !civInfo.getCivResources().containsKey(GameBasics.TileResources[requiredResource!!]))
|
||||
return false
|
||||
|
@ -152,7 +152,7 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
|
||||
|
||||
val allTiles = Group()
|
||||
|
||||
for (tileInfo in game.gameInfo.tileMap.getTilesInDistance(cityInfo.location, 5)) {
|
||||
for (tileInfo in cityInfo.getCenterTile().getTilesInDistance(5)) {
|
||||
if (!city.civInfo.exploredTiles.contains(tileInfo.position)) continue // Don't even bother to display it.
|
||||
val group = CityTileGroup(cityInfo, tileInfo)
|
||||
group.addClickListener {
|
||||
|
@ -3,7 +3,6 @@ package com.unciv.ui.worldscreen
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.logic.battle.*
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.logic.map.UnitType
|
||||
@ -135,7 +134,7 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
|
||||
}
|
||||
|
||||
else { // ranged
|
||||
val tilesInRange = UnCivGame.Current.gameInfo.tileMap.getTilesInDistance(attacker.getTile().position, 2)
|
||||
val tilesInRange = attacker.getTile().getTilesInDistance(2)
|
||||
attackerCanReachDefender = tilesInRange.contains(defender.getTile())
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ class UnitActions {
|
||||
worldScreen.update()
|
||||
},
|
||||
unit.currentMovement != 0f &&
|
||||
!tileMapHolder.tileMap.getTilesInDistance(tile.position, 2).any { it.isCityCenter })
|
||||
!tile.getTilesInDistance(2).any { it.isCityCenter })
|
||||
}
|
||||
|
||||
if (unit.name == "Worker") {
|
||||
|
Loading…
Reference in New Issue
Block a user