32 lines
1001 B
Markdown
32 lines
1001 B
Markdown
# Darklord.js — addBloodSpreadFrontier() (satır 1340)
|
||
|
||
[← Darklord.js](index.md) · [← Master](../../wiki.md)
|
||
|
||
```javascript
|
||
function addBloodSpreadFrontier(pool, x, z)
|
||
{
|
||
if (!pool.frontier) pool.frontier = [];
|
||
if (!pool.frontierMap) pool.frontierMap = {};
|
||
if (!pool.visited) pool.visited = {};
|
||
|
||
x = Math.floor(Number(x || 0));
|
||
z = Math.floor(Number(z || 0));
|
||
var key = bloodSpreadVisitKey(x, z);
|
||
if (pool.visited[key] || pool.frontierMap[key]) return false;
|
||
|
||
pool.frontierMap[key] = true;
|
||
pool.frontier.push({ x: x, z: z });
|
||
|
||
while (pool.frontier.length > BLOOD_SPREAD_FRONTIER_LIMIT)
|
||
{
|
||
var cut = Math.floor(Math.random() * pool.frontier.length);
|
||
var removed = pool.frontier[cut];
|
||
pool.frontier[cut] = pool.frontier[pool.frontier.length - 1];
|
||
pool.frontier.pop();
|
||
if (removed) delete pool.frontierMap[bloodSpreadVisitKey(removed.x, removed.z)];
|
||
}
|
||
|
||
return true;
|
||
}
|
||
```
|