Files

63 lines
1.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Darklord.js — buildDomainPlan() (satır 2233)
[← Darklord.js](index.md) · [← Master](../../wiki.md)
```javascript
function buildDomainPlan(cx, floorY, cz)
{
var plan = [];
var seen = {};
var r = DOMAIN_RADIUS;
var h = DOMAIN_HEIGHT;
var rSq = r * r;
var wallInner = (r - 2.2) * (r - 2.2);
var clearInner = (r - 1.2) * (r - 1.2);
for (var dx = -r; dx <= r; dx++)
{
for (var dz = -r; dz <= r; dz++)
{
var distSq = dx * dx + dz * dz;
if (distSq > rSq) continue;
var dist = Math.sqrt(distSq);
var x = cx + dx;
var z = cz + dz;
addDomainPlan(plan, seen, x, floorY, z, "block", dist * 1.15);
addDomainPlan(plan, seen, x, floorY + h, z, "block", 18 + (r - dist) * 0.95);
if (distSq >= wallInner)
{
for (var y = floorY + 1; y < floorY + h; y++)
{
var rise = y - floorY;
addDomainPlan(plan, seen, x, y, z, "block", 10 + rise * 0.85 + Math.abs(r - dist) * 1.6);
}
}
}
}
for (var cdx = -(r - 1); cdx <= r - 1; cdx++)
{
for (var cdz = -(r - 1); cdz <= r - 1; cdz++)
{
var cd = cdx * cdx + cdz * cdz;
if (cd > clearInner) continue;
var cdist = Math.sqrt(cd);
for (var cy = floorY + 1; cy < floorY + h; cy++)
{
addDomainPlan(plan, seen, cx + cdx, cy, cz + cdz, "air", 2 + cdist * 0.55 + Math.abs((floorY + h / 2) - cy) * 0.12);
}
}
}
plan.sort(function(a, b) {
return Number(a.p || 0) - Number(b.p || 0);
});
return plan;
}
```