diff --git a/binaries/data/mods/public/maps/random/new_rms_test.js b/binaries/data/mods/public/maps/random/new_rms_test.js
index b9d04b9..da1506d 100644
a
|
b
|
Engine.LoadLibrary("rmgen-common");
|
3 | 3 | |
4 | 4 | var g_Map = new RandomMap(0, "grass1_spring"); |
5 | 5 | |
6 | | placePlayerBases({ |
7 | | "PlayerPlacement": playerPlacementCircle(fractionToTiles(0.39)) |
8 | | }); |
| 6 | var clTerrain = g_Map.createTileClass(); |
9 | 7 | |
10 | | placePlayersNomad(g_Map.createTileClass()); |
| 8 | clTerrain.add(g_Map.getCenter()); |
| 9 | |
| 10 | for (let i = 0; i < 2; ++i) |
| 11 | createArea( |
| 12 | new MapBoundsPlacer(), |
| 13 | new TerrainPainter(i == 0 ? "blue" : "red"), |
| 14 | new NearTileClassConstraint(clTerrain, 10, i == 0)); |
| 15 | |
| 16 | g_Camera = { |
| 17 | "Position": |
| 18 | { |
| 19 | "x": g_Map.getCenter().x * 4, |
| 20 | "y": 0, |
| 21 | "z": g_Map.getCenter().y * 4 |
| 22 | }, |
| 23 | "Rotation": 0, |
| 24 | "Declination": 0.5 |
| 25 | }; |
11 | 26 | |
12 | 27 | g_Map.ExportMap(); |
diff --git a/binaries/data/mods/public/maps/random/rmgen/Constraint.js b/binaries/data/mods/public/maps/random/rmgen/Constraint.js
index 46c7cef..66b4d92 100644
a
|
b
|
StayInTileClassConstraint.prototype.allows = function(position)
|
128 | 128 | /** |
129 | 129 | * The NearTileClassConstraint is met if at least one tile within the given radius of the tile is marked with the given TileClass. |
130 | 130 | */ |
131 | | function NearTileClassConstraint(tileClass, distance) |
| 131 | function NearTileClassConstraint(tileClass, distance, useRangeOp) |
132 | 132 | { |
133 | 133 | this.tileClass = tileClass; |
134 | 134 | this.distance = distance; |
| 135 | this.useRangeOp = useRangeOp; |
135 | 136 | } |
136 | 137 | |
137 | 138 | NearTileClassConstraint.prototype.allows = function(position) |
138 | 139 | { |
139 | | return this.tileClass.countMembersInRadius(position, this.distance) > 0; |
| 140 | return this.tileClass.countMembersInRadius(position, this.distance, this.useRangeOp) > 0; |
140 | 141 | }; |
141 | 142 | |
142 | 143 | /** |
diff --git a/binaries/data/mods/public/maps/random/rmgen/TileClass.js b/binaries/data/mods/public/maps/random/rmgen/TileClass.js
index b211e36..51c2b7f 100644
a
|
b
|
TileClass.prototype.remove = function(position)
|
97 | 97 | this.rangeCount[position.y].add(position.x, -1); |
98 | 98 | }; |
99 | 99 | |
100 | | TileClass.prototype.countInRadius = function(position, radius, returnMembers) |
| 100 | TileClass.prototype.countInRadius = function(position, radius, returnMembers, useRangeOp) |
101 | 101 | { |
102 | 102 | let members = 0; |
103 | 103 | let nonMembers = 0; |
… |
… |
TileClass.prototype.countInRadius = function(position, radius, returnMembers)
|
106 | 106 | for (let y = position.y - radius; y <= position.y + radius; ++y) |
107 | 107 | { |
108 | 108 | let iy = Math.floor(y); |
109 | | if (radius >= 27) // Switchover point before RangeOp actually performs better than a straight algorithm |
| 109 | if (useRangeOp) |
110 | 110 | { |
111 | 111 | if (iy >= 0 && iy < this.size) |
112 | 112 | { |
… |
… |
TileClass.prototype.countInRadius = function(position, radius, returnMembers)
|
148 | 148 | return nonMembers; |
149 | 149 | }; |
150 | 150 | |
151 | | TileClass.prototype.countMembersInRadius = function(position, radius) |
| 151 | TileClass.prototype.countMembersInRadius = function(position, radius, useRangeOp) |
152 | 152 | { |
153 | | return this.countInRadius(position, radius, true); |
| 153 | return this.countInRadius(position, radius, true, useRangeOp); |
154 | 154 | }; |
155 | 155 | |
156 | 156 | TileClass.prototype.countNonMembersInRadius = function(position, radius) |
157 | 157 | { |
158 | | return this.countInRadius(position, radius, false); |
| 158 | return this.countInRadius(position, radius, false, useRangeOp); |
159 | 159 | }; |