@@ -1101,7 +1101,7 @@ private static bool IsValidForLuxuryPlacement(GameMap m, Resource r, Tile t) {
11011101 minLuxurySpacing = Math . Max ( 2 , minLuxurySpacing ) ;
11021102 minLuxurySpacing = Math . Min ( minLuxurySpacing , 10 ) ;
11031103
1104- foreach ( Tile x in GetTilesWithinRankDistance ( t , minLuxurySpacing ) ) {
1104+ foreach ( Tile x in t . GetTilesWithinRankDistance ( minLuxurySpacing ) ) {
11051105 if ( x . Resource != null
11061106 && x . Resource != Resource . NONE
11071107 && x . Resource . Category == ResourceCategory . LUXURY
@@ -1122,7 +1122,7 @@ private static bool IsValidForLuxuryPlacement(GameMap m, Resource r, Tile t) {
11221122 private static bool HasSufficientLandNeighborsForResource ( Tile t ) {
11231123 int landTiles = 0 ;
11241124
1125- foreach ( Tile x in GetTilesWithinRankDistance ( t , 2 ) ) {
1125+ foreach ( Tile x in t . GetTilesWithinRankDistance ( 2 ) ) {
11261126 if ( x . IsLand ( ) ) {
11271127 ++ landTiles ;
11281128 }
@@ -1131,35 +1131,6 @@ private static bool HasSufficientLandNeighborsForResource(Tile t) {
11311131 return landTiles >= 1 ;
11321132 }
11331133
1134- private static HashSet < Tile > GetTilesWithinRankDistance ( Tile location , int rank ) {
1135- HashSet < Tile > result = new ( ) ;
1136- HashSet < Tile > knownTiles = new ( ) ;
1137-
1138- Stack < Tile > toCheck = new ( ) ;
1139- toCheck . Push ( location ) ;
1140- knownTiles . Add ( location ) ;
1141-
1142- while ( toCheck . Count > 0 ) {
1143- Tile t = toCheck . Pop ( ) ;
1144-
1145- // Skip tiles that are too far away.
1146- if ( location . rankDistanceTo ( t ) > rank ) {
1147- continue ;
1148- }
1149-
1150- // Otherwise this tile is close enough. Check its neighbors next.
1151- result . Add ( t ) ;
1152- foreach ( Tile neighbor in t . neighbors . Values ) {
1153- if ( ! knownTiles . Contains ( neighbor ) ) {
1154- toCheck . Push ( neighbor ) ;
1155- knownTiles . Add ( t ) ;
1156- }
1157- }
1158- }
1159-
1160- return result ;
1161- }
1162-
11631134 private static void PlaceStrategicResourceType ( Random rand , WorldCharacteristics wc , GameMap m , Resource r , List < int > tileIndicies ) {
11641135 int targetCount = GetAppearance ( wc , rand , r , minCount : 2 ) ;
11651136 int placed = 0 ;
@@ -1207,7 +1178,7 @@ private static bool IsValidForStrategicResourcePlacement(GameMap m, Resource r,
12071178 minSpacing = Math . Min ( minSpacing , 10 ) ;
12081179
12091180 // Ensure strategic resources of the same kind don't clump up.
1210- foreach ( Tile x in GetTilesWithinRankDistance ( t , minSpacing ) ) {
1181+ foreach ( Tile x in t . GetTilesWithinRankDistance ( minSpacing ) ) {
12111182 if ( x . Resource != null
12121183 && x . Resource != Resource . NONE
12131184 && x . Resource . Category == ResourceCategory . STRATEGIC
@@ -1359,7 +1330,7 @@ private static bool IsValidForBarbarianCamp(GameMap m, Tile t) {
13591330 }
13601331
13611332 // No barbarian camps within the big fat cross of another camp.
1362- foreach ( Tile n in GetTilesWithinRankDistance ( t , 2 ) ) {
1333+ foreach ( Tile n in t . GetTilesWithinRankDistance ( 2 ) ) {
13631334 if ( n . hasBarbarianCamp ) {
13641335 return false ;
13651336 }
@@ -1502,7 +1473,7 @@ private static int ScorePossibleCityLocation(WorldCharacteristics wc, Tile t) {
15021473
15031474 // Calculate the score for tiles in the immediate area.
15041475 int score = 0 ;
1505- foreach ( Tile n in GetTilesWithinRankDistance ( t , 1 ) ) {
1476+ foreach ( Tile n in t . GetTilesWithinRankDistance ( 1 ) ) {
15061477 score += CommercePoints * n . commerceYield ( player ) . yield ;
15071478 score += ShieldPoints * n . productionYield ( player ) . yield ;
15081479 score += FoodPoints * n . foodYield ( player ) . yield ;
@@ -1517,7 +1488,7 @@ private static int ScorePossibleCityLocation(WorldCharacteristics wc, Tile t) {
15171488
15181489 // Then do it again for the full big fat cross, effectively weighting
15191490 // the immediate neighbors at a 2x rate.
1520- foreach ( Tile n in GetTilesWithinRankDistance ( t , 2 ) ) {
1491+ foreach ( Tile n in t . GetTilesWithinRankDistance ( 2 ) ) {
15211492 score += CommercePoints * n . commerceYield ( player ) . yield ;
15221493 score += ShieldPoints * n . productionYield ( player ) . yield ;
15231494 score += FoodPoints * n . foodYield ( player ) . yield ;
@@ -1535,7 +1506,7 @@ private static int ScorePossibleCityLocation(WorldCharacteristics wc, Tile t) {
15351506 // Try to get a rough sense of the number of surrounding land tiles
15361507 // on the same continent, to avoid players getting stuck on a
15371508 // peninsula.
1538- foreach ( Tile n in GetTilesWithinRankDistance ( t , 4 ) ) {
1509+ foreach ( Tile n in t . GetTilesWithinRankDistance ( 4 ) ) {
15391510 if ( n . continent == t . continent ) {
15401511 score += LandTilePoints ;
15411512 }
0 commit comments