Skip to content

Commit 75df8ad

Browse files
committed
Set dir:type map, set rivers/roads to adjacent rule
1 parent ee714b0 commit 75df8ad

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

src/model/tilemap/worldmap/world/basin/model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class BasinGridFill extends ConcurrentFill {
7878
}
7979

8080
getNeighbors(fill, parentPoint) {
81-
return Point.around(parentPoint)
81+
return Point.adjacents(parentPoint)
8282
}
8383

8484
_fillBasin(fill, fillPoint, parentPoint) {

src/model/tilemap/worldmap/world/civil/city.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class CitySpacesFill extends ConcurrentFill {
9595
if (isOrigin || world.surface.isBorder(parentPoint)) {
9696
return Point.adjacents(parentPoint)
9797
}
98-
return Point.around(parentPoint)
98+
return Point.adjacents(parentPoint)
9999
}
100100

101101
onInitFill(fill, fillPoint) {

src/model/tilemap/worldmap/zone/surface/model.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { buildRegionGridMap } from './region'
99

1010
const SURFACE_NOISE_RATIO = .6
1111
const SURFACE_GRID_CACHE = new FIFOCache(256)
12-
const REGION_WATER = 0
13-
const REGION_LAND = 1
12+
const REGION_WATER = false
13+
const REGION_LAND = true
1414

1515

1616
export function buildModel(context) {
@@ -20,33 +20,31 @@ export function buildModel(context) {
2020
return SURFACE_GRID_CACHE.get(hash)
2121
}
2222
const regionGridContext = buildRegionGridMap(context)
23-
const regionSurfaceMap = buildRegionSurfaceMap({...context, ...regionGridContext})
23+
const regionSurfaceMap = buildDirectionTypeMap(context)
2424
const landMaskGrid = buildLandMaskGrid({...context, ...regionGridContext, regionSurfaceMap})
2525
const model = {landMaskGrid, ...regionGridContext}
2626
SURFACE_GRID_CACHE.set(hash, model)
2727
return model
2828
}
2929

3030

31-
function buildRegionSurfaceMap(context) {
31+
function buildDirectionTypeMap(context) {
3232
const {world, worldPoint} = context
33-
const surfaceTypeMap = new Map()
33+
const directionTypeMap = new Map()
3434
const isWorldPointLand = world.surface.isLand(worldPoint)
3535

36-
Point.around(worldPoint, (sidePoint, direction) => {
36+
Point.adjacents(worldPoint, (sidePoint, direction) => {
37+
const isSideLand = world.surface.isLand(sidePoint)
3738
if (isWorldPointLand) {
38-
if (world.surface.isLand(sidePoint)) {
39-
if (isWaterChannel(context, direction)) {
40-
surfaceTypeMap.set(direction.id, REGION_WATER)
41-
} else {
42-
surfaceTypeMap.set(direction.id, REGION_LAND)
43-
}
39+
if (isSideLand) {
40+
const type = isWaterChannel(context, direction) ? REGION_WATER : REGION_LAND
41+
directionTypeMap.set(direction.id, type)
4442
}
45-
} else {
46-
surfaceTypeMap.set(direction.id, REGION_WATER)
43+
} else if (! isSideLand) {
44+
directionTypeMap.set(direction.id, REGION_WATER)
4745
}
4846
})
49-
return surfaceTypeMap
47+
return directionTypeMap
5048
}
5149

5250

0 commit comments

Comments
 (0)