1.9
This commit is contained in:
parent
fc7c94bd69
commit
2cc2f003df
71 changed files with 3359 additions and 1027 deletions
59
js/render.js
59
js/render.js
|
|
@ -175,6 +175,44 @@ function strokeWorldObstacleRect(ctx, rect) {
|
|||
return true;
|
||||
}
|
||||
|
||||
function drawWireConnectableHighlights(ctx, world) {
|
||||
if (!world || !["wire", "insulated_wire"].includes(String(world.tool || ""))) return;
|
||||
const signal = globalThis.TarinaiSignalSystem;
|
||||
const circuit = globalThis.TarinaiCircuitBoardSystem;
|
||||
if (!signal?.isSignalConnectable) return;
|
||||
const pulse = 0.72 + Math.sin((world.time || 0) * 7.5) * 0.13;
|
||||
const pointer = world.pointer || {};
|
||||
ctx.save();
|
||||
ctx.setLineDash([7, 5]);
|
||||
const blockedTypes = new Set(["rope", "rod", "spring", "wire", "insulated_wire"]);
|
||||
for (const item of world.items || []) {
|
||||
if (!item || item.dead || item.type === "splat" || blockedTypes.has(item.type)) continue;
|
||||
const signalCapable = signal.isSignalConnectable(item);
|
||||
if (item.type === "circuit_board") {
|
||||
for (const port of circuit?.ports?.(item) || []) {
|
||||
const point = circuit.portWorld(item, port);
|
||||
if (!point) continue;
|
||||
const hovered = pointer.inside && Math.hypot(pointer.x - point.x, pointer.y - point.y) <= 17;
|
||||
const selected = world.pendingLinkEndpoint?.id === item.id && world.pendingLinkEndpoint?.portId === port.portId;
|
||||
ctx.globalAlpha = selected ? 1 : (hovered ? 0.98 : 0.72);
|
||||
ctx.fillStyle = port.direction === "input" ? "rgba(74,177,255,0.22)" : "rgba(255,132,65,0.22)";
|
||||
ctx.strokeStyle = selected ? "rgba(255,235,92,1)" : (port.direction === "input" ? "rgba(74,177,255,0.98)" : "rgba(255,132,65,0.98)");
|
||||
ctx.lineWidth = selected || hovered ? 3.8 : 2.5;
|
||||
ctx.beginPath(); ctx.arc(point.x, point.y, (selected || hovered ? 12 : 9) * pulse, 0, Math.PI * 2); ctx.fill(); ctx.stroke();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
const selected = world.pendingLinkEndpoint?.id === item.id;
|
||||
const radius = Math.max(18, Number(item.r || 22) * 1.22 + 7);
|
||||
ctx.globalAlpha = selected ? 1 : (signalCapable ? 0.66 : 0.30);
|
||||
ctx.strokeStyle = selected ? "rgba(255,235,92,1)" : (signalCapable ? "rgba(90,207,255,0.94)" : "rgba(224,232,238,0.72)");
|
||||
ctx.lineWidth = selected ? 4 : (signalCapable ? 2.4 : 1.6);
|
||||
ctx.beginPath(); ctx.ellipse(item.x, item.y, radius, radius * 0.78, 0, 0, Math.PI * 2); ctx.stroke();
|
||||
}
|
||||
ctx.setLineDash([]);
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
function drawToolTargetHoverHighlight(ctx, world) {
|
||||
if (!world) return;
|
||||
const tool = String(world.tool || "");
|
||||
|
|
@ -495,7 +533,6 @@ function drawPlacementPreview(ctx, world) {
|
|||
const preview = placementPreviewFor(world);
|
||||
if (!preview) return;
|
||||
const { type, x, y, r, rect, rects, overlay, influence, blocked } = preview;
|
||||
const pulse = 0.55 + Math.sin((world.time || 0) * 7.0) * 0.10;
|
||||
ctx.save();
|
||||
ctx.globalAlpha = blocked ? 0.44 : 0.72;
|
||||
ctx.lineWidth = blocked ? 2.2 : 2.0;
|
||||
|
|
@ -519,9 +556,9 @@ function drawPlacementPreview(ctx, world) {
|
|||
ctx.stroke();
|
||||
}
|
||||
};
|
||||
if (overlay?.shape === "ellipse") {
|
||||
if (overlay?.shape === "circle") {
|
||||
ctx.beginPath();
|
||||
ctx.ellipse(overlay.centerX, overlay.centerY, Math.max(1, overlay.radiusX), Math.max(1, overlay.radiusY), 0, 0, Math.PI * 2);
|
||||
ctx.arc(overlay.centerX, overlay.centerY, Math.max(1, overlay.radius), 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
} else if (overlay?.shape === "roundedRect") {
|
||||
|
|
@ -542,14 +579,9 @@ function drawPlacementPreview(ctx, world) {
|
|||
ctx.strokeRect(part.left, part.top, part.right - part.left, part.bottom - part.top);
|
||||
}
|
||||
}
|
||||
} else if (type === "stone" || type === "ball" || type === "balloon" || type === "fan" || type === "pipe" || type === "firecracker" || isPinType(type) || type === "zunchi" || type.includes("mochi") || type === "sweet" || type === "sleep_drug") {
|
||||
ctx.beginPath();
|
||||
ctx.arc(x, y, Math.max(8, r * (1.18 + pulse * 0.04)), 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
} else {
|
||||
ctx.beginPath();
|
||||
ctx.ellipse(x, y, Math.max(9, r * 1.55), Math.max(6, r * 0.86), 0, 0, Math.PI * 2);
|
||||
ctx.arc(x, y, Math.max(8, r), 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
}
|
||||
|
|
@ -585,8 +617,8 @@ function drawPlacementPreview(ctx, world) {
|
|||
ctx.fill();
|
||||
ctx.restore();
|
||||
}
|
||||
const markerX = (overlay?.shape === "ellipse" || overlay?.shape === "roundedRect") ? overlay.centerX : x;
|
||||
const markerY = (overlay?.shape === "ellipse" || overlay?.shape === "roundedRect") ? overlay.centerY : y;
|
||||
const markerX = (overlay?.shape === "circle" || overlay?.shape === "roundedRect") ? overlay.centerX : x;
|
||||
const markerY = (overlay?.shape === "circle" || overlay?.shape === "roundedRect") ? overlay.centerY : y;
|
||||
ctx.globalAlpha = blocked ? 0.52 : 0.70;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(markerX - 8, markerY);
|
||||
|
|
@ -711,7 +743,7 @@ function drawOperationToolPreview(ctx, world) {
|
|||
}
|
||||
} else {
|
||||
const r = Math.max(10, item.r || itemRadiusFor?.(type, 16) || 16);
|
||||
ctx.beginPath(); ctx.ellipse(p.x, p.y, r * 1.45, r * 0.95, 0, 0, Math.PI * 2); ctx.fill(); ctx.stroke();
|
||||
ctx.beginPath(); ctx.arc(item.x, item.y, r, 0, Math.PI * 2); ctx.fill(); ctx.stroke();
|
||||
}
|
||||
ctx.setLineDash([]);
|
||||
const markerX = (previewOverlay?.shape === "ellipse" || previewOverlay?.shape === "roundedRect") ? previewOverlay.centerX : item.x;
|
||||
|
|
@ -901,7 +933,7 @@ function linkIntersectsVisibleRect(it, worldRef, rect, margin = 18) {
|
|||
}
|
||||
|
||||
function isBehindSpriteLayerItem(it) {
|
||||
return Boolean(it && !it.dead && (isLinkRenderItem(it) || it.type === "bed" || it.type === "grass_bed" || it.type === "toilet"));
|
||||
return Boolean(it && !it.dead && (isLinkRenderItem(it) || it.type === "bed" || it.type === "grass_bed" || it.type === "toilet" || it.type === "seesaw"));
|
||||
}
|
||||
|
||||
function renderLayerSortY(entity) {
|
||||
|
|
@ -1764,6 +1796,7 @@ function render() {
|
|||
}
|
||||
renderPerfEnd(endAttachments);
|
||||
|
||||
drawWireConnectableHighlights(ctx, world);
|
||||
drawToolTargetHoverHighlight(ctx, world);
|
||||
|
||||
const endEffects = renderPerfBegin("render.draw.effects");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue