21 lines
943 B
JavaScript
21 lines
943 B
JavaScript
|
|
export function derivePatchSeed(worldSeed, terrainType, variant) {
|
||
|
|
let hash = (worldSeed >>> 0) ^ 0x9e3779b9;
|
||
|
|
hash = Math.imul(hash ^ (variant >>> 0), 668265263) >>> 0;
|
||
|
|
for (const char of String(terrainType || "auto")) hash = Math.imul(hash ^ char.charCodeAt(0), 16777619) >>> 0;
|
||
|
|
return hash >>> 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
export function buildMaximumProductionLasso(world, width = 470, height = 333) {
|
||
|
|
const x0 = Math.max(0, Math.min(world.width - width, world.originX + 238));
|
||
|
|
const y0 = Math.max(0, Math.min(world.height - height, world.originY));
|
||
|
|
const rect = { x0, y0, x1: x0 + width, y1: y0 + height, kind: "lasso" };
|
||
|
|
const insetX = Math.max(4, Math.floor(width * 0.16));
|
||
|
|
const insetY = Math.max(4, Math.floor(height * 0.16));
|
||
|
|
rect.polygon = [
|
||
|
|
{ x: rect.x0 + insetX, y: rect.y0 },
|
||
|
|
{ x: rect.x1 - 1, y: rect.y0 + insetY },
|
||
|
|
{ x: rect.x1 - insetX, y: rect.y1 - 1 },
|
||
|
|
{ x: rect.x0, y: rect.y1 - insetY },
|
||
|
|
];
|
||
|
|
return rect;
|
||
|
|
}
|