Skip to content

Commit 24bca5b

Browse files
committed
component animation position differences resolved
clone mode / unabstraction mode
1 parent 660e0b1 commit 24bca5b

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

static/component.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ function getXYBySize(size) {
868868
}
869869

870870
function makeBlueprintString(component, signal) {
871-
return ["integrated_blueprint", [component.x, component.y], signal, component.integrationId, component.direction];
871+
return ["integrated_blueprint", [component.targetX, component.targetY], signal, component.integrationId, component.direction];
872872
}
873873

874874
class SwitchComponent extends Component {

static/work_mode.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -218,17 +218,19 @@ function tickUnabstractionMode() {
218218
floatingComponent.components.forEach(component => {
219219
components.push(component);
220220

221-
deltaX += component.x;
222-
deltaY += component.y;
221+
deltaX += component.targetX;
222+
deltaY += component.targetY;
223223
});
224224
wires.push(...floatingComponent.wires);
225225

226-
deltaX = floatingComponent.x - Math.round(deltaX / floatingComponent.components.length);
227-
deltaY = floatingComponent.y - Math.round(deltaY / floatingComponent.components.length);
226+
deltaX = floatingComponent.targetX - Math.round(deltaX / floatingComponent.components.length);
227+
deltaY = floatingComponent.targetY - Math.round(deltaY / floatingComponent.components.length);
228228

229229
floatingComponent.components.forEach(component => {
230-
component.x += deltaX;
231-
component.y += deltaY;
230+
component.x = floatingComponent.x + floatingComponent.size / 2;
231+
component.y = floatingComponent.y + floatingComponent.size / 2;
232+
component.targetX += deltaX;
233+
component.targetY += deltaY;
232234
component.reposition();
233235
});
234236
}
@@ -337,8 +339,9 @@ function tickCloneMode() {
337339
let clonedComponents = [];
338340
clonedStrings.forEach(strings => {
339341
let component = structify(strings, camera);
340-
component.x = component.x - x1 - halfWidth + inGameX;
341-
component.y = component.y - y1 - halfHeight + inGameY;
342+
component.setPos(component.targetX - x1 - halfWidth + inGameX, component.targetY - y1 - halfHeight + inGameY);
343+
component.x = component.targetX;
344+
component.y = component.targetY;
342345
component.reposition();
343346
component.calculate();
344347
clonedComponents.push(component);

0 commit comments

Comments
 (0)