Skip to content

Commit 8f3b160

Browse files
committed
✨ 增加涂鸦对象的粘连式移动
1 parent abd2159 commit 8f3b160

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

app/src/core/stage/stageManager/concreteMethods/StageEntityMoveManager.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { RectanglePushInEffect } from "../../../service/feedbackService/effectEn
55
import { Stage } from "../../Stage";
66
import { ConnectableEntity } from "../../stageObject/abstract/ConnectableEntity";
77
import { Entity } from "../../stageObject/abstract/StageEntity";
8+
import { PenStroke } from "../../stageObject/entity/PenStroke";
89
import { GraphMethods } from "../basicMethods/GraphMethods";
910
import { SectionMethods } from "../basicMethods/SectionMethods";
1011
import { StageManager } from "../StageManager";
@@ -17,11 +18,11 @@ import { StageSectionInOutManager } from "./StageSectionInOutManager";
1718
* 以后还可能有自动布局的功能
1819
*/
1920
export namespace StageEntityMoveManager {
20-
export function moveEntityUtils(node: Entity, delta: Vector, isAutoAdjustSection: boolean = true) {
21+
export function moveEntityUtils(entity: Entity, delta: Vector, isAutoAdjustSection: boolean = true) {
2122
// 让自己移动
22-
node.move(delta);
23+
entity.move(delta);
2324

24-
const nodeUUID = node.uuid;
25+
const nodeUUID = entity.uuid;
2526

2627
// if (StageManager.isSectionByUUID(nodeUUID)) {
2728
// // 如果是Section,则需要带动孩子一起移动
@@ -39,6 +40,15 @@ export namespace StageEntityMoveManager {
3940
}
4041
}
4142
}
43+
// 如果是涂鸦,则连带所有可连接对象一起移动
44+
if (entity instanceof PenStroke) {
45+
for (const otherConnectableEntity of StageManager.getConnectableEntity()) {
46+
if (entity.collisionBox.isIntersectsWithRectangle(otherConnectableEntity.collisionBox.getRectangle())) {
47+
// 递归了
48+
moveEntityUtils(otherConnectableEntity, delta, false);
49+
}
50+
}
51+
}
4252
}
4353

4454
export function jumpMoveEntityUtils(entity: Entity, delta: Vector) {

0 commit comments

Comments
 (0)