@@ -58,29 +58,7 @@ private void initializeTileMap() {
5858 }
5959
6060 private void setTerrainTiles ( ) {
61- for ( int x = 0 ; x < width ; x ++ ) {
62- for ( int y = 0 ; y < height ; y ++ ) {
63- Vector2I cell = new Vector2I ( x , y ) ;
64- string left = terrain [ x , y ] ;
65- string right = terrain [ ( x + 1 ) % width , y ] ;
66- bool even = y % 2 == 0 ;
67- string top = "coast" ;
68- if ( y > 0 ) {
69- top = even ? terrain [ x , y - 1 ] : terrain [ ( x + 1 ) % width , y - 1 ] ;
70- }
71- string bottom = "coast" ;
72- if ( y < height - 1 ) {
73- bottom = even ? terrain [ x , y + 1 ] : terrain [ ( x + 1 ) % width , y + 1 ] ;
74- }
75- string [ ] corner = new string [ 4 ] { top , right , bottom , left } ;
76- TerrainPcx pcx = Civ3TerrainTileSet . GetPcxFor ( corner ) ;
77- Vector2I texCoords = pcx . getTextureCoords ( corner ) ;
78- setTerrainTile ( cell , pcx . atlas , texCoords ) ;
79- }
80- }
81- for ( int y = 0 ; y < height ; y ++ ) {
82- Vector2I cell = new Vector2I ( - 1 , y ) ;
83- int x = width - 1 ;
61+ string [ ] corners ( int x , int y ) {
8462 string left = terrain [ x , y ] ;
8563 string right = terrain [ ( x + 1 ) % width , y ] ;
8664 bool even = y % 2 == 0 ;
@@ -92,11 +70,23 @@ private void setTerrainTiles() {
9270 if ( y < height - 1 ) {
9371 bottom = even ? terrain [ x , y + 1 ] : terrain [ ( x + 1 ) % width , y + 1 ] ;
9472 }
95- string [ ] corner = new string [ 4 ] { top , right , bottom , left } ;
73+ return new string [ 4 ] { top , right , bottom , left } ;
74+ }
75+ void lookupAndSetTerrainTile ( int x , int y , int cellX , int cellY ) {
76+ Vector2I cell = new Vector2I ( cellX , cellY ) ;
77+ string [ ] corner = corners ( x , y ) ;
9678 TerrainPcx pcx = Civ3TerrainTileSet . GetPcxFor ( corner ) ;
9779 Vector2I texCoords = pcx . getTextureCoords ( corner ) ;
9880 setTerrainTile ( cell , pcx . atlas , texCoords ) ;
9981 }
82+ for ( int x = 0 ; x < width ; x ++ ) {
83+ for ( int y = 0 ; y < height ; y ++ ) {
84+ lookupAndSetTerrainTile ( x , y , x , y ) ;
85+ }
86+ }
87+ for ( int y = 0 ; y < height ; y ++ ) {
88+ lookupAndSetTerrainTile ( width - 1 , y , - 1 , y ) ;
89+ }
10090 }
10191
10292 void setTerrainTile ( Vector2I cell , int atlas , Vector2I texCoords ) {
0 commit comments