From 1b1f5d1633172a4ecf52b001fb33511b0771f510 Mon Sep 17 00:00:00 2001 From: MrKBear Date: Tue, 5 Apr 2022 14:19:10 +0800 Subject: [PATCH 1/2] Behavior object parameters are controlled --- source/Behavior/BoundaryConstraint.ts | 13 +---- source/Context/Status.tsx | 11 ++++ source/Model/Behavior.ts | 2 +- source/Model/Model.ts | 64 ++++++++++++++++++++++- source/Page/SimulatorWeb/SimulatorWeb.tsx | 2 +- 5 files changed, 78 insertions(+), 14 deletions(-) diff --git a/source/Behavior/BoundaryConstraint.ts b/source/Behavior/BoundaryConstraint.ts index 4e36d70..bf1cb59 100644 --- a/source/Behavior/BoundaryConstraint.ts +++ b/source/Behavior/BoundaryConstraint.ts @@ -26,8 +26,7 @@ class BoundaryConstraint extends Behavior { - return obj instanceof Range - }) as any; - } + let rangeList: Range[] = this.parameter.range.objects; for (let i = 0; i < rangeList.length; i++) { let rx = rangeList[i].position[0] - individual.position[0]; diff --git a/source/Context/Status.tsx b/source/Context/Status.tsx index d7cefcb..838b3e3 100644 --- a/source/Context/Status.tsx +++ b/source/Context/Status.tsx @@ -136,6 +136,17 @@ class Status extends Emitter { this.model.on("individualChange", () => { this.emit("individualChange"); }); + + // 当模型中的标签和对象改变时,更新全部行为参数中的受控对象 + const updateBehaviorParameter = () => { + this.model.updateBehaviorParameter(); + } + this.on("objectChange", updateBehaviorParameter); + this.on("behaviorChange", updateBehaviorParameter); + this.on("labelChange", updateBehaviorParameter); + this.on("groupLabelChange", updateBehaviorParameter); + this.on("rangeLabelChange", updateBehaviorParameter); + this.on("behaviorAttrChange", updateBehaviorParameter); } public bindRenderer(renderer: AbstractRenderer) { diff --git a/source/Model/Behavior.ts b/source/Model/Behavior.ts index f25a612..b5f40bf 100644 --- a/source/Model/Behavior.ts +++ b/source/Model/Behavior.ts @@ -24,7 +24,7 @@ type IMapObjectParamTypeKeyToType = { "R": IObjectParamCacheType; "G": IObjectParamCacheType; "LR": IObjectParamCacheType