@esengine/blueprint 4.1.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +200 -82
- package/dist/index.js +2168 -1443
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -64,7 +64,19 @@ function getNodeCategoryColor(category) {
|
|
|
64
64
|
__name(getNodeCategoryColor, "getNodeCategoryColor");
|
|
65
65
|
|
|
66
66
|
// src/types/blueprint.ts
|
|
67
|
-
function createEmptyBlueprint(name) {
|
|
67
|
+
function createEmptyBlueprint(name, includeBeginPlay = true) {
|
|
68
|
+
const nodes = [];
|
|
69
|
+
if (includeBeginPlay) {
|
|
70
|
+
nodes.push({
|
|
71
|
+
id: "node_beginplay_1",
|
|
72
|
+
type: "EventBeginPlay",
|
|
73
|
+
position: {
|
|
74
|
+
x: 100,
|
|
75
|
+
y: 200
|
|
76
|
+
},
|
|
77
|
+
data: {}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
68
80
|
return {
|
|
69
81
|
version: 1,
|
|
70
82
|
type: "blueprint",
|
|
@@ -74,7 +86,7 @@ function createEmptyBlueprint(name) {
|
|
|
74
86
|
modifiedAt: Date.now()
|
|
75
87
|
},
|
|
76
88
|
variables: [],
|
|
77
|
-
nodes
|
|
89
|
+
nodes,
|
|
78
90
|
connections: []
|
|
79
91
|
};
|
|
80
92
|
}
|
|
@@ -86,6 +98,109 @@ function validateBlueprintAsset(asset) {
|
|
|
86
98
|
}
|
|
87
99
|
__name(validateBlueprintAsset, "validateBlueprintAsset");
|
|
88
100
|
|
|
101
|
+
// src/registry/BlueprintDecorators.ts
|
|
102
|
+
var registeredComponents = /* @__PURE__ */ new Map();
|
|
103
|
+
function getRegisteredBlueprintComponents() {
|
|
104
|
+
return registeredComponents;
|
|
105
|
+
}
|
|
106
|
+
__name(getRegisteredBlueprintComponents, "getRegisteredBlueprintComponents");
|
|
107
|
+
function getBlueprintMetadata(componentClass) {
|
|
108
|
+
return registeredComponents.get(componentClass);
|
|
109
|
+
}
|
|
110
|
+
__name(getBlueprintMetadata, "getBlueprintMetadata");
|
|
111
|
+
function clearRegisteredComponents() {
|
|
112
|
+
registeredComponents.clear();
|
|
113
|
+
}
|
|
114
|
+
__name(clearRegisteredComponents, "clearRegisteredComponents");
|
|
115
|
+
function getOrCreateMetadata(constructor) {
|
|
116
|
+
let metadata = registeredComponents.get(constructor);
|
|
117
|
+
if (!metadata) {
|
|
118
|
+
metadata = {
|
|
119
|
+
componentName: constructor.__componentName__ ?? constructor.name,
|
|
120
|
+
properties: [],
|
|
121
|
+
methods: []
|
|
122
|
+
};
|
|
123
|
+
registeredComponents.set(constructor, metadata);
|
|
124
|
+
}
|
|
125
|
+
return metadata;
|
|
126
|
+
}
|
|
127
|
+
__name(getOrCreateMetadata, "getOrCreateMetadata");
|
|
128
|
+
function BlueprintExpose(options = {}) {
|
|
129
|
+
return function(target) {
|
|
130
|
+
const metadata = getOrCreateMetadata(target);
|
|
131
|
+
Object.assign(metadata, options);
|
|
132
|
+
metadata.componentName = target.__componentName__ ?? target.name;
|
|
133
|
+
return target;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
__name(BlueprintExpose, "BlueprintExpose");
|
|
137
|
+
function BlueprintProperty(options = {}) {
|
|
138
|
+
return function(target, propertyKey) {
|
|
139
|
+
const key = String(propertyKey);
|
|
140
|
+
const metadata = getOrCreateMetadata(target.constructor);
|
|
141
|
+
const propMeta = {
|
|
142
|
+
propertyKey: key,
|
|
143
|
+
displayName: options.displayName ?? key,
|
|
144
|
+
description: options.description,
|
|
145
|
+
pinType: options.type ?? "any",
|
|
146
|
+
readonly: options.readonly ?? false,
|
|
147
|
+
defaultValue: options.defaultValue
|
|
148
|
+
};
|
|
149
|
+
const existingIndex = metadata.properties.findIndex((p) => p.propertyKey === key);
|
|
150
|
+
if (existingIndex >= 0) {
|
|
151
|
+
metadata.properties[existingIndex] = propMeta;
|
|
152
|
+
} else {
|
|
153
|
+
metadata.properties.push(propMeta);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
__name(BlueprintProperty, "BlueprintProperty");
|
|
158
|
+
function BlueprintMethod(options = {}) {
|
|
159
|
+
return function(target, propertyKey, descriptor) {
|
|
160
|
+
const key = String(propertyKey);
|
|
161
|
+
const metadata = getOrCreateMetadata(target.constructor);
|
|
162
|
+
const methodMeta = {
|
|
163
|
+
methodKey: key,
|
|
164
|
+
displayName: options.displayName ?? key,
|
|
165
|
+
description: options.description,
|
|
166
|
+
isPure: options.isPure ?? false,
|
|
167
|
+
params: options.params ?? [],
|
|
168
|
+
returnType: options.returnType ?? "any"
|
|
169
|
+
};
|
|
170
|
+
const existingIndex = metadata.methods.findIndex((m) => m.methodKey === key);
|
|
171
|
+
if (existingIndex >= 0) {
|
|
172
|
+
metadata.methods[existingIndex] = methodMeta;
|
|
173
|
+
} else {
|
|
174
|
+
metadata.methods.push(methodMeta);
|
|
175
|
+
}
|
|
176
|
+
return descriptor;
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
__name(BlueprintMethod, "BlueprintMethod");
|
|
180
|
+
function inferPinType(typeName) {
|
|
181
|
+
const typeMap = {
|
|
182
|
+
"number": "float",
|
|
183
|
+
"Number": "float",
|
|
184
|
+
"string": "string",
|
|
185
|
+
"String": "string",
|
|
186
|
+
"boolean": "bool",
|
|
187
|
+
"Boolean": "bool",
|
|
188
|
+
"Entity": "entity",
|
|
189
|
+
"Component": "component",
|
|
190
|
+
"Vector2": "vector2",
|
|
191
|
+
"Vec2": "vector2",
|
|
192
|
+
"Vector3": "vector3",
|
|
193
|
+
"Vec3": "vector3",
|
|
194
|
+
"Color": "color",
|
|
195
|
+
"Array": "array",
|
|
196
|
+
"Object": "object",
|
|
197
|
+
"void": "exec",
|
|
198
|
+
"undefined": "exec"
|
|
199
|
+
};
|
|
200
|
+
return typeMap[typeName] ?? "any";
|
|
201
|
+
}
|
|
202
|
+
__name(inferPinType, "inferPinType");
|
|
203
|
+
|
|
89
204
|
// src/runtime/ExecutionContext.ts
|
|
90
205
|
var _ExecutionContext = class _ExecutionContext {
|
|
91
206
|
constructor(blueprint, entity, scene) {
|
|
@@ -253,10 +368,49 @@ var _ExecutionContext = class _ExecutionContext {
|
|
|
253
368
|
static clearGlobalVariables() {
|
|
254
369
|
_ExecutionContext._globalVariables.clear();
|
|
255
370
|
}
|
|
371
|
+
/**
|
|
372
|
+
* Get a component class by name
|
|
373
|
+
* 通过名称获取组件类
|
|
374
|
+
*
|
|
375
|
+
* @zh 首先检查 @BlueprintExpose 装饰的组件,然后检查手动注册的组件
|
|
376
|
+
* @en First checks @BlueprintExpose decorated components, then manually registered ones
|
|
377
|
+
*/
|
|
378
|
+
getComponentClass(typeName) {
|
|
379
|
+
const blueprintComponents = getRegisteredBlueprintComponents();
|
|
380
|
+
for (const [componentClass, metadata] of blueprintComponents) {
|
|
381
|
+
if (metadata.componentName === typeName || componentClass.name === typeName) {
|
|
382
|
+
return componentClass;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return _ExecutionContext._componentRegistry.get(typeName);
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Register a component class for dynamic creation
|
|
389
|
+
* 注册组件类以支持动态创建
|
|
390
|
+
*/
|
|
391
|
+
static registerComponentClass(typeName, componentClass) {
|
|
392
|
+
_ExecutionContext._componentRegistry.set(typeName, componentClass);
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Unregister a component class
|
|
396
|
+
* 取消注册组件类
|
|
397
|
+
*/
|
|
398
|
+
static unregisterComponentClass(typeName) {
|
|
399
|
+
_ExecutionContext._componentRegistry.delete(typeName);
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Get all registered component classes
|
|
403
|
+
* 获取所有已注册的组件类
|
|
404
|
+
*/
|
|
405
|
+
static getRegisteredComponentClasses() {
|
|
406
|
+
return new Map(_ExecutionContext._componentRegistry);
|
|
407
|
+
}
|
|
256
408
|
};
|
|
257
409
|
__name(_ExecutionContext, "ExecutionContext");
|
|
258
410
|
/** Global variables (shared) (全局变量,共享) */
|
|
259
411
|
__publicField(_ExecutionContext, "_globalVariables", /* @__PURE__ */ new Map());
|
|
412
|
+
/** Component class registry (组件类注册表) */
|
|
413
|
+
__publicField(_ExecutionContext, "_componentRegistry", /* @__PURE__ */ new Map());
|
|
260
414
|
var ExecutionContext = _ExecutionContext;
|
|
261
415
|
|
|
262
416
|
// src/runtime/NodeRegistry.ts
|
|
@@ -576,104 +730,622 @@ __name(_BlueprintVM, "BlueprintVM");
|
|
|
576
730
|
var BlueprintVM = _BlueprintVM;
|
|
577
731
|
|
|
578
732
|
// src/runtime/BlueprintComponent.ts
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
debug: false,
|
|
586
|
-
vm: null,
|
|
587
|
-
isStarted: false
|
|
588
|
-
};
|
|
733
|
+
import { Component, ECSComponent } from "@esengine/ecs-framework";
|
|
734
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
735
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
736
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
737
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
738
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
589
739
|
}
|
|
590
|
-
__name(
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
740
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
741
|
+
var _BlueprintComponent = class _BlueprintComponent extends Component {
|
|
742
|
+
constructor() {
|
|
743
|
+
super(...arguments);
|
|
744
|
+
/**
|
|
745
|
+
* @zh 蓝图资产引用
|
|
746
|
+
* @en Blueprint asset reference
|
|
747
|
+
*/
|
|
748
|
+
__publicField(this, "blueprintAsset", null);
|
|
749
|
+
/**
|
|
750
|
+
* @zh 用于序列化的蓝图资产路径
|
|
751
|
+
* @en Blueprint asset path for serialization
|
|
752
|
+
*/
|
|
753
|
+
__publicField(this, "blueprintPath", "");
|
|
754
|
+
/**
|
|
755
|
+
* @zh 实体创建时自动开始执行
|
|
756
|
+
* @en Auto-start execution when entity is created
|
|
757
|
+
*/
|
|
758
|
+
__publicField(this, "autoStart", true);
|
|
759
|
+
/**
|
|
760
|
+
* @zh 启用 VM 调试模式
|
|
761
|
+
* @en Enable debug mode for VM
|
|
762
|
+
*/
|
|
763
|
+
__publicField(this, "debug", false);
|
|
764
|
+
/**
|
|
765
|
+
* @zh 运行时 VM 实例
|
|
766
|
+
* @en Runtime VM instance
|
|
767
|
+
*/
|
|
768
|
+
__publicField(this, "vm", null);
|
|
769
|
+
/**
|
|
770
|
+
* @zh 蓝图是否已启动
|
|
771
|
+
* @en Whether the blueprint has started
|
|
772
|
+
*/
|
|
773
|
+
__publicField(this, "isStarted", false);
|
|
594
774
|
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
775
|
+
/**
|
|
776
|
+
* @zh 初始化蓝图 VM
|
|
777
|
+
* @en Initialize blueprint VM
|
|
778
|
+
*/
|
|
779
|
+
initialize(entity, scene) {
|
|
780
|
+
if (!this.blueprintAsset) return;
|
|
781
|
+
this.vm = new BlueprintVM(this.blueprintAsset, entity, scene);
|
|
782
|
+
this.vm.debug = this.debug;
|
|
603
783
|
}
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
784
|
+
/**
|
|
785
|
+
* @zh 开始执行蓝图
|
|
786
|
+
* @en Start blueprint execution
|
|
787
|
+
*/
|
|
788
|
+
start() {
|
|
789
|
+
if (this.vm && !this.isStarted) {
|
|
790
|
+
this.vm.start();
|
|
791
|
+
this.isStarted = true;
|
|
792
|
+
}
|
|
610
793
|
}
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
794
|
+
/**
|
|
795
|
+
* @zh 停止执行蓝图
|
|
796
|
+
* @en Stop blueprint execution
|
|
797
|
+
*/
|
|
798
|
+
stop() {
|
|
799
|
+
if (this.vm && this.isStarted) {
|
|
800
|
+
this.vm.stop();
|
|
801
|
+
this.isStarted = false;
|
|
802
|
+
}
|
|
616
803
|
}
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
804
|
+
/**
|
|
805
|
+
* @zh 更新蓝图
|
|
806
|
+
* @en Update blueprint
|
|
807
|
+
*/
|
|
808
|
+
tick(deltaTime) {
|
|
809
|
+
if (this.vm && this.isStarted) {
|
|
810
|
+
this.vm.tick(deltaTime);
|
|
623
811
|
}
|
|
624
|
-
component.vm = null;
|
|
625
|
-
component.isStarted = false;
|
|
626
812
|
}
|
|
627
|
-
|
|
628
|
-
|
|
813
|
+
/**
|
|
814
|
+
* @zh 清理蓝图资源
|
|
815
|
+
* @en Cleanup blueprint resources
|
|
816
|
+
*/
|
|
817
|
+
cleanup() {
|
|
818
|
+
if (this.vm) {
|
|
819
|
+
if (this.isStarted) {
|
|
820
|
+
this.vm.stop();
|
|
821
|
+
}
|
|
822
|
+
this.vm = null;
|
|
823
|
+
this.isStarted = false;
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
};
|
|
827
|
+
__name(_BlueprintComponent, "BlueprintComponent");
|
|
828
|
+
var BlueprintComponent = _BlueprintComponent;
|
|
829
|
+
BlueprintComponent = _ts_decorate([
|
|
830
|
+
ECSComponent("Blueprint")
|
|
831
|
+
], BlueprintComponent);
|
|
629
832
|
|
|
630
833
|
// src/runtime/BlueprintSystem.ts
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
834
|
+
import { EntitySystem, Matcher, ECSSystem, Time } from "@esengine/ecs-framework";
|
|
835
|
+
|
|
836
|
+
// src/registry/ComponentNodeGenerator.ts
|
|
837
|
+
function generateComponentNodes(componentClass, metadata) {
|
|
838
|
+
const { componentName, properties, methods } = metadata;
|
|
839
|
+
const category = metadata.category ?? "component";
|
|
840
|
+
const color = metadata.color ?? "#1e8b8b";
|
|
841
|
+
generateAddComponentNode(componentClass, componentName, metadata, color);
|
|
842
|
+
generateGetComponentNode(componentClass, componentName, metadata, color);
|
|
843
|
+
for (const prop of properties) {
|
|
844
|
+
generatePropertyGetNode(componentName, prop, category, color);
|
|
845
|
+
if (!prop.readonly) {
|
|
846
|
+
generatePropertySetNode(componentName, prop, category, color);
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
for (const method of methods) {
|
|
850
|
+
generateMethodCallNode(componentName, method, category, color);
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
__name(generateComponentNodes, "generateComponentNodes");
|
|
854
|
+
function generateAddComponentNode(componentClass, componentName, metadata, color) {
|
|
855
|
+
const nodeType = `Add_${componentName}`;
|
|
856
|
+
const displayName = metadata.displayName ?? componentName;
|
|
857
|
+
const propertyInputs = [];
|
|
858
|
+
const propertyDefaults = {};
|
|
859
|
+
for (const prop of metadata.properties) {
|
|
860
|
+
if (!prop.readonly) {
|
|
861
|
+
propertyInputs.push({
|
|
862
|
+
name: prop.propertyKey,
|
|
863
|
+
type: prop.pinType,
|
|
864
|
+
displayName: prop.displayName,
|
|
865
|
+
defaultValue: prop.defaultValue
|
|
866
|
+
});
|
|
867
|
+
propertyDefaults[prop.propertyKey] = prop.defaultValue;
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
const template = {
|
|
871
|
+
type: nodeType,
|
|
872
|
+
title: `Add ${displayName}`,
|
|
873
|
+
category: "component",
|
|
874
|
+
color,
|
|
875
|
+
description: `Adds ${displayName} component to entity (\u4E3A\u5B9E\u4F53\u6DFB\u52A0 ${displayName} \u7EC4\u4EF6)`,
|
|
876
|
+
keywords: [
|
|
877
|
+
"add",
|
|
878
|
+
"component",
|
|
879
|
+
"create",
|
|
880
|
+
componentName.toLowerCase()
|
|
881
|
+
],
|
|
882
|
+
menuPath: [
|
|
883
|
+
"Components",
|
|
884
|
+
displayName,
|
|
885
|
+
`Add ${displayName}`
|
|
886
|
+
],
|
|
887
|
+
inputs: [
|
|
888
|
+
{
|
|
889
|
+
name: "exec",
|
|
890
|
+
type: "exec",
|
|
891
|
+
displayName: ""
|
|
892
|
+
},
|
|
893
|
+
{
|
|
894
|
+
name: "entity",
|
|
895
|
+
type: "entity",
|
|
896
|
+
displayName: "Entity"
|
|
897
|
+
},
|
|
898
|
+
...propertyInputs
|
|
899
|
+
],
|
|
900
|
+
outputs: [
|
|
901
|
+
{
|
|
902
|
+
name: "exec",
|
|
903
|
+
type: "exec",
|
|
904
|
+
displayName: ""
|
|
905
|
+
},
|
|
906
|
+
{
|
|
907
|
+
name: "component",
|
|
908
|
+
type: "component",
|
|
909
|
+
displayName
|
|
910
|
+
},
|
|
911
|
+
{
|
|
912
|
+
name: "success",
|
|
913
|
+
type: "bool",
|
|
914
|
+
displayName: "Success"
|
|
646
915
|
}
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
916
|
+
]
|
|
917
|
+
};
|
|
918
|
+
const propertyKeys = metadata.properties.filter((p) => !p.readonly).map((p) => p.propertyKey);
|
|
919
|
+
const executor = {
|
|
920
|
+
execute(node, context) {
|
|
921
|
+
const entity = context.evaluateInput(node.id, "entity", context.entity);
|
|
922
|
+
if (!entity || entity.isDestroyed) {
|
|
923
|
+
return {
|
|
924
|
+
outputs: {
|
|
925
|
+
component: null,
|
|
926
|
+
success: false
|
|
927
|
+
},
|
|
928
|
+
nextExec: "exec"
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
const existing = entity.components.find((c) => c.constructor === componentClass || c.constructor.name === componentName || c.constructor.__componentName__ === componentName);
|
|
932
|
+
if (existing) {
|
|
933
|
+
return {
|
|
934
|
+
outputs: {
|
|
935
|
+
component: existing,
|
|
936
|
+
success: false
|
|
937
|
+
},
|
|
938
|
+
nextExec: "exec"
|
|
939
|
+
};
|
|
940
|
+
}
|
|
941
|
+
try {
|
|
942
|
+
const component = new componentClass();
|
|
943
|
+
for (const key of propertyKeys) {
|
|
944
|
+
const value = context.evaluateInput(node.id, key, propertyDefaults[key]);
|
|
945
|
+
if (value !== void 0) {
|
|
946
|
+
component[key] = value;
|
|
947
|
+
}
|
|
654
948
|
}
|
|
949
|
+
entity.addComponent(component);
|
|
950
|
+
return {
|
|
951
|
+
outputs: {
|
|
952
|
+
component,
|
|
953
|
+
success: true
|
|
954
|
+
},
|
|
955
|
+
nextExec: "exec"
|
|
956
|
+
};
|
|
957
|
+
} catch (error) {
|
|
958
|
+
console.error(`[Blueprint] Failed to add ${componentName}:`, error);
|
|
959
|
+
return {
|
|
960
|
+
outputs: {
|
|
961
|
+
component: null,
|
|
962
|
+
success: false
|
|
963
|
+
},
|
|
964
|
+
nextExec: "exec"
|
|
965
|
+
};
|
|
655
966
|
}
|
|
656
|
-
},
|
|
657
|
-
onEntityRemoved(entity) {
|
|
658
|
-
cleanupBlueprint(entity.blueprintComponent);
|
|
659
967
|
}
|
|
660
968
|
};
|
|
969
|
+
NodeRegistry.instance.register(template, executor);
|
|
661
970
|
}
|
|
662
|
-
__name(
|
|
663
|
-
function
|
|
664
|
-
const
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
971
|
+
__name(generateAddComponentNode, "generateAddComponentNode");
|
|
972
|
+
function generateGetComponentNode(componentClass, componentName, metadata, color) {
|
|
973
|
+
const nodeType = `Get_${componentName}`;
|
|
974
|
+
const displayName = metadata.displayName ?? componentName;
|
|
975
|
+
const template = {
|
|
976
|
+
type: nodeType,
|
|
977
|
+
title: `Get ${displayName}`,
|
|
978
|
+
category: "component",
|
|
979
|
+
color,
|
|
980
|
+
isPure: true,
|
|
981
|
+
description: `Gets ${displayName} component from entity (\u4ECE\u5B9E\u4F53\u83B7\u53D6 ${displayName} \u7EC4\u4EF6)`,
|
|
982
|
+
keywords: [
|
|
983
|
+
"get",
|
|
984
|
+
"component",
|
|
985
|
+
componentName.toLowerCase()
|
|
986
|
+
],
|
|
987
|
+
menuPath: [
|
|
988
|
+
"Components",
|
|
989
|
+
displayName,
|
|
990
|
+
`Get ${displayName}`
|
|
991
|
+
],
|
|
992
|
+
inputs: [
|
|
993
|
+
{
|
|
994
|
+
name: "entity",
|
|
995
|
+
type: "entity",
|
|
996
|
+
displayName: "Entity"
|
|
997
|
+
}
|
|
998
|
+
],
|
|
999
|
+
outputs: [
|
|
1000
|
+
{
|
|
1001
|
+
name: "component",
|
|
1002
|
+
type: "component",
|
|
1003
|
+
displayName
|
|
1004
|
+
},
|
|
1005
|
+
{
|
|
1006
|
+
name: "found",
|
|
1007
|
+
type: "bool",
|
|
1008
|
+
displayName: "Found"
|
|
1009
|
+
}
|
|
1010
|
+
]
|
|
1011
|
+
};
|
|
1012
|
+
const executor = {
|
|
1013
|
+
execute(node, context) {
|
|
1014
|
+
const entity = context.evaluateInput(node.id, "entity", context.entity);
|
|
1015
|
+
if (!entity || entity.isDestroyed) {
|
|
1016
|
+
return {
|
|
1017
|
+
outputs: {
|
|
1018
|
+
component: null,
|
|
1019
|
+
found: false
|
|
1020
|
+
}
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
1023
|
+
const component = entity.components.find((c) => c.constructor === componentClass || c.constructor.name === componentName || c.constructor.__componentName__ === componentName);
|
|
1024
|
+
return {
|
|
1025
|
+
outputs: {
|
|
1026
|
+
component: component ?? null,
|
|
1027
|
+
found: component != null
|
|
1028
|
+
}
|
|
1029
|
+
};
|
|
1030
|
+
}
|
|
1031
|
+
};
|
|
1032
|
+
NodeRegistry.instance.register(template, executor);
|
|
1033
|
+
}
|
|
1034
|
+
__name(generateGetComponentNode, "generateGetComponentNode");
|
|
1035
|
+
function generatePropertyGetNode(componentName, prop, category, color) {
|
|
1036
|
+
const nodeType = `Get_${componentName}_${prop.propertyKey}`;
|
|
1037
|
+
const { displayName, pinType } = prop;
|
|
1038
|
+
const template = {
|
|
1039
|
+
type: nodeType,
|
|
1040
|
+
title: `Get ${displayName}`,
|
|
1041
|
+
subtitle: componentName,
|
|
1042
|
+
category,
|
|
1043
|
+
color,
|
|
1044
|
+
isPure: true,
|
|
1045
|
+
description: prop.description ?? `Gets ${displayName} from ${componentName} (\u4ECE ${componentName} \u83B7\u53D6 ${displayName})`,
|
|
1046
|
+
keywords: [
|
|
1047
|
+
"get",
|
|
1048
|
+
"property",
|
|
1049
|
+
componentName.toLowerCase(),
|
|
1050
|
+
prop.propertyKey.toLowerCase()
|
|
1051
|
+
],
|
|
1052
|
+
menuPath: [
|
|
1053
|
+
"Components",
|
|
1054
|
+
componentName,
|
|
1055
|
+
`Get ${displayName}`
|
|
1056
|
+
],
|
|
1057
|
+
inputs: [
|
|
1058
|
+
{
|
|
1059
|
+
name: "component",
|
|
1060
|
+
type: "component",
|
|
1061
|
+
displayName: componentName
|
|
1062
|
+
}
|
|
1063
|
+
],
|
|
1064
|
+
outputs: [
|
|
1065
|
+
{
|
|
1066
|
+
name: "value",
|
|
1067
|
+
type: pinType,
|
|
1068
|
+
displayName
|
|
1069
|
+
}
|
|
1070
|
+
]
|
|
1071
|
+
};
|
|
1072
|
+
const propertyKey = prop.propertyKey;
|
|
1073
|
+
const defaultValue = prop.defaultValue;
|
|
1074
|
+
const executor = {
|
|
1075
|
+
execute(node, context) {
|
|
1076
|
+
const component = context.evaluateInput(node.id, "component", null);
|
|
1077
|
+
if (!component) {
|
|
1078
|
+
return {
|
|
1079
|
+
outputs: {
|
|
1080
|
+
value: defaultValue ?? null
|
|
1081
|
+
}
|
|
1082
|
+
};
|
|
1083
|
+
}
|
|
1084
|
+
const value = component[propertyKey];
|
|
1085
|
+
return {
|
|
1086
|
+
outputs: {
|
|
1087
|
+
value
|
|
1088
|
+
}
|
|
1089
|
+
};
|
|
1090
|
+
}
|
|
1091
|
+
};
|
|
1092
|
+
NodeRegistry.instance.register(template, executor);
|
|
1093
|
+
}
|
|
1094
|
+
__name(generatePropertyGetNode, "generatePropertyGetNode");
|
|
1095
|
+
function generatePropertySetNode(componentName, prop, category, color) {
|
|
1096
|
+
const nodeType = `Set_${componentName}_${prop.propertyKey}`;
|
|
1097
|
+
const { displayName, pinType, defaultValue } = prop;
|
|
1098
|
+
const template = {
|
|
1099
|
+
type: nodeType,
|
|
1100
|
+
title: `Set ${displayName}`,
|
|
1101
|
+
subtitle: componentName,
|
|
1102
|
+
category,
|
|
1103
|
+
color,
|
|
1104
|
+
description: prop.description ?? `Sets ${displayName} on ${componentName} (\u8BBE\u7F6E ${componentName} \u7684 ${displayName})`,
|
|
1105
|
+
keywords: [
|
|
1106
|
+
"set",
|
|
1107
|
+
"property",
|
|
1108
|
+
componentName.toLowerCase(),
|
|
1109
|
+
prop.propertyKey.toLowerCase()
|
|
1110
|
+
],
|
|
1111
|
+
menuPath: [
|
|
1112
|
+
"Components",
|
|
1113
|
+
componentName,
|
|
1114
|
+
`Set ${displayName}`
|
|
1115
|
+
],
|
|
1116
|
+
inputs: [
|
|
1117
|
+
{
|
|
1118
|
+
name: "exec",
|
|
1119
|
+
type: "exec",
|
|
1120
|
+
displayName: ""
|
|
1121
|
+
},
|
|
1122
|
+
{
|
|
1123
|
+
name: "component",
|
|
1124
|
+
type: "component",
|
|
1125
|
+
displayName: componentName
|
|
1126
|
+
},
|
|
1127
|
+
{
|
|
1128
|
+
name: "value",
|
|
1129
|
+
type: pinType,
|
|
1130
|
+
displayName,
|
|
1131
|
+
defaultValue
|
|
1132
|
+
}
|
|
1133
|
+
],
|
|
1134
|
+
outputs: [
|
|
1135
|
+
{
|
|
1136
|
+
name: "exec",
|
|
1137
|
+
type: "exec",
|
|
1138
|
+
displayName: ""
|
|
1139
|
+
}
|
|
1140
|
+
]
|
|
1141
|
+
};
|
|
1142
|
+
const propertyKey = prop.propertyKey;
|
|
1143
|
+
const executor = {
|
|
1144
|
+
execute(node, context) {
|
|
1145
|
+
const component = context.evaluateInput(node.id, "component", null);
|
|
1146
|
+
const value = context.evaluateInput(node.id, "value", defaultValue);
|
|
1147
|
+
if (component) {
|
|
1148
|
+
component[propertyKey] = value;
|
|
1149
|
+
}
|
|
1150
|
+
return {
|
|
1151
|
+
nextExec: "exec"
|
|
1152
|
+
};
|
|
1153
|
+
}
|
|
1154
|
+
};
|
|
1155
|
+
NodeRegistry.instance.register(template, executor);
|
|
1156
|
+
}
|
|
1157
|
+
__name(generatePropertySetNode, "generatePropertySetNode");
|
|
1158
|
+
function generateMethodCallNode(componentName, method, category, color) {
|
|
1159
|
+
const nodeType = `Call_${componentName}_${method.methodKey}`;
|
|
1160
|
+
const { displayName, isPure, params, returnType } = method;
|
|
1161
|
+
const inputs = [];
|
|
1162
|
+
if (!isPure) {
|
|
1163
|
+
inputs.push({
|
|
1164
|
+
name: "exec",
|
|
1165
|
+
type: "exec",
|
|
1166
|
+
displayName: ""
|
|
1167
|
+
});
|
|
1168
|
+
}
|
|
1169
|
+
inputs.push({
|
|
1170
|
+
name: "component",
|
|
1171
|
+
type: "component",
|
|
1172
|
+
displayName: componentName
|
|
1173
|
+
});
|
|
1174
|
+
const paramNames = [];
|
|
1175
|
+
for (const param of params) {
|
|
1176
|
+
inputs.push({
|
|
1177
|
+
name: param.name,
|
|
1178
|
+
type: param.type ?? "any",
|
|
1179
|
+
displayName: param.displayName ?? param.name,
|
|
1180
|
+
defaultValue: param.defaultValue
|
|
1181
|
+
});
|
|
1182
|
+
paramNames.push(param.name);
|
|
1183
|
+
}
|
|
1184
|
+
const outputs = [];
|
|
1185
|
+
if (!isPure) {
|
|
1186
|
+
outputs.push({
|
|
1187
|
+
name: "exec",
|
|
1188
|
+
type: "exec",
|
|
1189
|
+
displayName: ""
|
|
1190
|
+
});
|
|
1191
|
+
}
|
|
1192
|
+
if (returnType !== "exec" && returnType !== "any") {
|
|
1193
|
+
outputs.push({
|
|
1194
|
+
name: "result",
|
|
1195
|
+
type: returnType,
|
|
1196
|
+
displayName: "Result"
|
|
1197
|
+
});
|
|
1198
|
+
}
|
|
1199
|
+
const template = {
|
|
1200
|
+
type: nodeType,
|
|
1201
|
+
title: displayName,
|
|
1202
|
+
subtitle: componentName,
|
|
1203
|
+
category,
|
|
1204
|
+
color,
|
|
1205
|
+
isPure,
|
|
1206
|
+
description: method.description ?? `Calls ${displayName} on ${componentName} (\u8C03\u7528 ${componentName} \u7684 ${displayName})`,
|
|
1207
|
+
keywords: [
|
|
1208
|
+
"call",
|
|
1209
|
+
"method",
|
|
1210
|
+
componentName.toLowerCase(),
|
|
1211
|
+
method.methodKey.toLowerCase()
|
|
1212
|
+
],
|
|
1213
|
+
menuPath: [
|
|
1214
|
+
"Components",
|
|
1215
|
+
componentName,
|
|
1216
|
+
displayName
|
|
1217
|
+
],
|
|
1218
|
+
inputs,
|
|
1219
|
+
outputs
|
|
1220
|
+
};
|
|
1221
|
+
const methodKey = method.methodKey;
|
|
1222
|
+
const executor = {
|
|
1223
|
+
execute(node, context) {
|
|
1224
|
+
const component = context.evaluateInput(node.id, "component", null);
|
|
1225
|
+
if (!component) {
|
|
1226
|
+
return isPure ? {
|
|
1227
|
+
outputs: {
|
|
1228
|
+
result: null
|
|
1229
|
+
}
|
|
1230
|
+
} : {
|
|
1231
|
+
nextExec: "exec"
|
|
1232
|
+
};
|
|
1233
|
+
}
|
|
1234
|
+
const args = paramNames.map((name) => context.evaluateInput(node.id, name, void 0));
|
|
1235
|
+
const fn = component[methodKey];
|
|
1236
|
+
if (typeof fn !== "function") {
|
|
1237
|
+
console.warn(`Method ${methodKey} not found on component ${componentName}`);
|
|
1238
|
+
return isPure ? {
|
|
1239
|
+
outputs: {
|
|
1240
|
+
result: null
|
|
1241
|
+
}
|
|
1242
|
+
} : {
|
|
1243
|
+
nextExec: "exec"
|
|
1244
|
+
};
|
|
1245
|
+
}
|
|
1246
|
+
const result = fn.apply(component, args);
|
|
1247
|
+
return isPure ? {
|
|
1248
|
+
outputs: {
|
|
1249
|
+
result
|
|
1250
|
+
}
|
|
1251
|
+
} : {
|
|
1252
|
+
outputs: {
|
|
1253
|
+
result
|
|
1254
|
+
},
|
|
1255
|
+
nextExec: "exec"
|
|
1256
|
+
};
|
|
1257
|
+
}
|
|
1258
|
+
};
|
|
1259
|
+
NodeRegistry.instance.register(template, executor);
|
|
1260
|
+
}
|
|
1261
|
+
__name(generateMethodCallNode, "generateMethodCallNode");
|
|
1262
|
+
function registerAllComponentNodes() {
|
|
1263
|
+
const components = getRegisteredBlueprintComponents();
|
|
1264
|
+
for (const [componentClass, metadata] of components) {
|
|
1265
|
+
try {
|
|
1266
|
+
generateComponentNodes(componentClass, metadata);
|
|
1267
|
+
console.log(`[Blueprint] Registered component: ${metadata.componentName} (${metadata.properties.length} properties, ${metadata.methods.length} methods)`);
|
|
1268
|
+
} catch (error) {
|
|
1269
|
+
console.error(`[Blueprint] Failed to register component ${metadata.componentName}:`, error);
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
console.log(`[Blueprint] Registered ${components.size} component(s)`);
|
|
1273
|
+
}
|
|
1274
|
+
__name(registerAllComponentNodes, "registerAllComponentNodes");
|
|
1275
|
+
function registerComponentNodes(componentClass) {
|
|
1276
|
+
const components = getRegisteredBlueprintComponents();
|
|
1277
|
+
const metadata = components.get(componentClass);
|
|
1278
|
+
if (!metadata) {
|
|
1279
|
+
console.warn(`[Blueprint] Component ${componentClass.name} is not marked with @BlueprintExpose`);
|
|
1280
|
+
return;
|
|
1281
|
+
}
|
|
1282
|
+
generateComponentNodes(componentClass, metadata);
|
|
1283
|
+
}
|
|
1284
|
+
__name(registerComponentNodes, "registerComponentNodes");
|
|
1285
|
+
|
|
1286
|
+
// src/runtime/BlueprintSystem.ts
|
|
1287
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
1288
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1289
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1290
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1291
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1292
|
+
}
|
|
1293
|
+
__name(_ts_decorate2, "_ts_decorate");
|
|
1294
|
+
function _ts_metadata(k, v) {
|
|
1295
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1296
|
+
}
|
|
1297
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
1298
|
+
var _BlueprintSystem = class _BlueprintSystem extends EntitySystem {
|
|
1299
|
+
constructor() {
|
|
1300
|
+
super(Matcher.all(BlueprintComponent));
|
|
1301
|
+
__publicField(this, "_componentsRegistered", false);
|
|
1302
|
+
}
|
|
1303
|
+
/**
|
|
1304
|
+
* @zh 系统初始化时注册所有组件节点
|
|
1305
|
+
* @en Register all component nodes when system initializes
|
|
1306
|
+
*/
|
|
1307
|
+
onInitialize() {
|
|
1308
|
+
if (!this._componentsRegistered) {
|
|
1309
|
+
registerAllComponentNodes();
|
|
1310
|
+
this._componentsRegistered = true;
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
/**
|
|
1314
|
+
* @zh 处理所有带有蓝图组件的实体
|
|
1315
|
+
* @en Process all entities with blueprint components
|
|
1316
|
+
*/
|
|
1317
|
+
process(entities) {
|
|
1318
|
+
const dt = Time.deltaTime;
|
|
1319
|
+
for (const entity of entities) {
|
|
1320
|
+
const blueprint = entity.getComponent(BlueprintComponent);
|
|
1321
|
+
if (!blueprint?.blueprintAsset) continue;
|
|
1322
|
+
if (!blueprint.vm) {
|
|
1323
|
+
blueprint.initialize(entity, this.scene);
|
|
1324
|
+
}
|
|
1325
|
+
if (blueprint.autoStart && !blueprint.isStarted) {
|
|
1326
|
+
blueprint.start();
|
|
1327
|
+
}
|
|
1328
|
+
blueprint.tick(dt);
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
/**
|
|
1332
|
+
* @zh 实体移除时清理蓝图资源
|
|
1333
|
+
* @en Cleanup blueprint resources when entity is removed
|
|
1334
|
+
*/
|
|
1335
|
+
onRemoved(entity) {
|
|
1336
|
+
const blueprint = entity.getComponent(BlueprintComponent);
|
|
1337
|
+
if (blueprint) {
|
|
1338
|
+
blueprint.cleanup();
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
};
|
|
1342
|
+
__name(_BlueprintSystem, "BlueprintSystem");
|
|
1343
|
+
var BlueprintSystem = _BlueprintSystem;
|
|
1344
|
+
BlueprintSystem = _ts_decorate2([
|
|
1345
|
+
ECSSystem("BlueprintSystem"),
|
|
1346
|
+
_ts_metadata("design:type", Function),
|
|
1347
|
+
_ts_metadata("design:paramtypes", [])
|
|
1348
|
+
], BlueprintSystem);
|
|
677
1349
|
|
|
678
1350
|
// src/triggers/TriggerTypes.ts
|
|
679
1351
|
var TriggerTypes = {
|
|
@@ -1035,1419 +1707,985 @@ var _ConditionBuilder = class _ConditionBuilder {
|
|
|
1035
1707
|
}
|
|
1036
1708
|
/**
|
|
1037
1709
|
* @zh 添加消息条件
|
|
1038
|
-
* @en Add message condition
|
|
1039
|
-
*/
|
|
1040
|
-
onMessage(messageName) {
|
|
1041
|
-
this._conditions.push(new MessageNameCondition(messageName));
|
|
1042
|
-
return this;
|
|
1043
|
-
}
|
|
1044
|
-
/**
|
|
1045
|
-
* @zh 添加状态条件
|
|
1046
|
-
* @en Add state condition
|
|
1047
|
-
*/
|
|
1048
|
-
onState(stateName, checkCurrent = true) {
|
|
1049
|
-
this._conditions.push(new StateNameCondition(stateName, checkCurrent));
|
|
1050
|
-
return this;
|
|
1051
|
-
}
|
|
1052
|
-
/**
|
|
1053
|
-
* @zh 添加定时器条件
|
|
1054
|
-
* @en Add timer condition
|
|
1055
|
-
*/
|
|
1056
|
-
onTimer(timerId) {
|
|
1057
|
-
this._conditions.push(new TimerIdCondition(timerId));
|
|
1058
|
-
return this;
|
|
1059
|
-
}
|
|
1060
|
-
/**
|
|
1061
|
-
* @zh 添加碰撞条件
|
|
1062
|
-
* @en Add collision condition
|
|
1063
|
-
*/
|
|
1064
|
-
onCollision(options) {
|
|
1065
|
-
this._conditions.push(new CollisionEntityCondition(options?.entityId, options?.isEnter, options?.isExit));
|
|
1066
|
-
return this;
|
|
1067
|
-
}
|
|
1068
|
-
/**
|
|
1069
|
-
* @zh 添加自定义事件条件
|
|
1070
|
-
* @en Add custom event condition
|
|
1071
|
-
*/
|
|
1072
|
-
onCustomEvent(eventName) {
|
|
1073
|
-
this._conditions.push(new CustomEventCondition(eventName));
|
|
1074
|
-
return this;
|
|
1075
|
-
}
|
|
1076
|
-
/**
|
|
1077
|
-
* @zh 添加自定义函数条件
|
|
1078
|
-
* @en Add custom function condition
|
|
1079
|
-
*/
|
|
1080
|
-
where(predicate) {
|
|
1081
|
-
this._conditions.push(new FunctionCondition(predicate));
|
|
1082
|
-
return this;
|
|
1083
|
-
}
|
|
1084
|
-
/**
|
|
1085
|
-
* @zh 添加取反条件
|
|
1086
|
-
* @en Add negated condition
|
|
1087
|
-
*/
|
|
1088
|
-
not(condition2) {
|
|
1089
|
-
this._conditions.push(new NotCondition(condition2));
|
|
1090
|
-
return this;
|
|
1091
|
-
}
|
|
1092
|
-
/**
|
|
1093
|
-
* @zh 构建条件
|
|
1094
|
-
* @en Build condition
|
|
1095
|
-
*/
|
|
1096
|
-
build() {
|
|
1097
|
-
if (this._conditions.length === 0) {
|
|
1098
|
-
return new AlwaysTrueCondition();
|
|
1099
|
-
}
|
|
1100
|
-
if (this._conditions.length === 1) {
|
|
1101
|
-
return this._conditions[0];
|
|
1102
|
-
}
|
|
1103
|
-
return new CompositeCondition(this._conditions, this._logic);
|
|
1104
|
-
}
|
|
1105
|
-
};
|
|
1106
|
-
__name(_ConditionBuilder, "ConditionBuilder");
|
|
1107
|
-
var ConditionBuilder = _ConditionBuilder;
|
|
1108
|
-
function condition() {
|
|
1109
|
-
return new ConditionBuilder();
|
|
1110
|
-
}
|
|
1111
|
-
__name(condition, "condition");
|
|
1112
|
-
|
|
1113
|
-
// src/triggers/BlueprintTrigger.ts
|
|
1114
|
-
var _triggerId = 0;
|
|
1115
|
-
function generateTriggerId() {
|
|
1116
|
-
return `trigger_${++_triggerId}`;
|
|
1117
|
-
}
|
|
1118
|
-
__name(generateTriggerId, "generateTriggerId");
|
|
1119
|
-
var _BlueprintTrigger = class _BlueprintTrigger {
|
|
1120
|
-
constructor(config) {
|
|
1121
|
-
__publicField(this, "id");
|
|
1122
|
-
__publicField(this, "type");
|
|
1123
|
-
__publicField(this, "condition");
|
|
1124
|
-
__publicField(this, "priority");
|
|
1125
|
-
__publicField(this, "enabled");
|
|
1126
|
-
__publicField(this, "_callback");
|
|
1127
|
-
__publicField(this, "_callbacks", /* @__PURE__ */ new Set());
|
|
1128
|
-
this.id = config.id ?? generateTriggerId();
|
|
1129
|
-
this.type = config.type;
|
|
1130
|
-
this.condition = config.condition ?? new AlwaysTrueCondition();
|
|
1131
|
-
this.priority = config.priority ?? 0;
|
|
1132
|
-
this.enabled = config.enabled ?? true;
|
|
1133
|
-
this._callback = config.callback;
|
|
1134
|
-
}
|
|
1135
|
-
/**
|
|
1136
|
-
* @zh 检查是否应该触发
|
|
1137
|
-
* @en Check if should fire
|
|
1138
|
-
*/
|
|
1139
|
-
shouldFire(context) {
|
|
1140
|
-
if (!this.enabled) {
|
|
1141
|
-
return false;
|
|
1142
|
-
}
|
|
1143
|
-
if (context.type !== this.type && this.type !== "custom") {
|
|
1144
|
-
return false;
|
|
1145
|
-
}
|
|
1146
|
-
return this.condition.evaluate(context);
|
|
1147
|
-
}
|
|
1148
|
-
/**
|
|
1149
|
-
* @zh 执行触发器
|
|
1150
|
-
* @en Execute trigger
|
|
1151
|
-
*/
|
|
1152
|
-
fire(context) {
|
|
1153
|
-
if (this._callback) {
|
|
1154
|
-
this._callback(context);
|
|
1155
|
-
}
|
|
1156
|
-
for (const callback of this._callbacks) {
|
|
1157
|
-
callback(context);
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
/**
|
|
1161
|
-
* @zh 添加回调
|
|
1162
|
-
* @en Add callback
|
|
1163
|
-
*/
|
|
1164
|
-
addCallback(callback) {
|
|
1165
|
-
this._callbacks.add(callback);
|
|
1166
|
-
}
|
|
1167
|
-
/**
|
|
1168
|
-
* @zh 移除回调
|
|
1169
|
-
* @en Remove callback
|
|
1170
|
-
*/
|
|
1171
|
-
removeCallback(callback) {
|
|
1172
|
-
this._callbacks.delete(callback);
|
|
1173
|
-
}
|
|
1174
|
-
/**
|
|
1175
|
-
* @zh 清除所有回调
|
|
1176
|
-
* @en Clear all callbacks
|
|
1177
|
-
*/
|
|
1178
|
-
clearCallbacks() {
|
|
1179
|
-
this._callbacks.clear();
|
|
1180
|
-
}
|
|
1181
|
-
};
|
|
1182
|
-
__name(_BlueprintTrigger, "BlueprintTrigger");
|
|
1183
|
-
var BlueprintTrigger = _BlueprintTrigger;
|
|
1184
|
-
var _TriggerRegistry = class _TriggerRegistry {
|
|
1185
|
-
constructor() {
|
|
1186
|
-
__publicField(this, "_triggers", /* @__PURE__ */ new Map());
|
|
1187
|
-
__publicField(this, "_triggersByType", /* @__PURE__ */ new Map());
|
|
1188
|
-
}
|
|
1189
|
-
/**
|
|
1190
|
-
* @zh 注册触发器
|
|
1191
|
-
* @en Register trigger
|
|
1192
|
-
*/
|
|
1193
|
-
register(trigger) {
|
|
1194
|
-
if (this._triggers.has(trigger.id)) {
|
|
1195
|
-
console.warn(`Trigger ${trigger.id} already registered, overwriting`);
|
|
1196
|
-
}
|
|
1197
|
-
this._triggers.set(trigger.id, trigger);
|
|
1198
|
-
if (!this._triggersByType.has(trigger.type)) {
|
|
1199
|
-
this._triggersByType.set(trigger.type, /* @__PURE__ */ new Set());
|
|
1200
|
-
}
|
|
1201
|
-
this._triggersByType.get(trigger.type).add(trigger.id);
|
|
1202
|
-
}
|
|
1203
|
-
/**
|
|
1204
|
-
* @zh 注销触发器
|
|
1205
|
-
* @en Unregister trigger
|
|
1206
|
-
*/
|
|
1207
|
-
unregister(triggerId) {
|
|
1208
|
-
const trigger = this._triggers.get(triggerId);
|
|
1209
|
-
if (!trigger) {
|
|
1210
|
-
return false;
|
|
1211
|
-
}
|
|
1212
|
-
this._triggers.delete(triggerId);
|
|
1213
|
-
const typeSet = this._triggersByType.get(trigger.type);
|
|
1214
|
-
if (typeSet) {
|
|
1215
|
-
typeSet.delete(triggerId);
|
|
1216
|
-
}
|
|
1217
|
-
return true;
|
|
1710
|
+
* @en Add message condition
|
|
1711
|
+
*/
|
|
1712
|
+
onMessage(messageName) {
|
|
1713
|
+
this._conditions.push(new MessageNameCondition(messageName));
|
|
1714
|
+
return this;
|
|
1218
1715
|
}
|
|
1219
1716
|
/**
|
|
1220
|
-
* @zh
|
|
1221
|
-
* @en
|
|
1717
|
+
* @zh 添加状态条件
|
|
1718
|
+
* @en Add state condition
|
|
1222
1719
|
*/
|
|
1223
|
-
|
|
1224
|
-
|
|
1720
|
+
onState(stateName, checkCurrent = true) {
|
|
1721
|
+
this._conditions.push(new StateNameCondition(stateName, checkCurrent));
|
|
1722
|
+
return this;
|
|
1225
1723
|
}
|
|
1226
1724
|
/**
|
|
1227
|
-
* @zh
|
|
1228
|
-
* @en
|
|
1725
|
+
* @zh 添加定时器条件
|
|
1726
|
+
* @en Add timer condition
|
|
1229
1727
|
*/
|
|
1230
|
-
|
|
1231
|
-
|
|
1728
|
+
onTimer(timerId) {
|
|
1729
|
+
this._conditions.push(new TimerIdCondition(timerId));
|
|
1730
|
+
return this;
|
|
1232
1731
|
}
|
|
1233
1732
|
/**
|
|
1234
|
-
* @zh
|
|
1235
|
-
* @en
|
|
1733
|
+
* @zh 添加碰撞条件
|
|
1734
|
+
* @en Add collision condition
|
|
1236
1735
|
*/
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
return [];
|
|
1241
|
-
}
|
|
1242
|
-
const triggers = [];
|
|
1243
|
-
for (const id of typeSet) {
|
|
1244
|
-
const trigger = this._triggers.get(id);
|
|
1245
|
-
if (trigger) {
|
|
1246
|
-
triggers.push(trigger);
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
return triggers.sort((a, b) => b.priority - a.priority);
|
|
1736
|
+
onCollision(options) {
|
|
1737
|
+
this._conditions.push(new CollisionEntityCondition(options?.entityId, options?.isEnter, options?.isExit));
|
|
1738
|
+
return this;
|
|
1250
1739
|
}
|
|
1251
1740
|
/**
|
|
1252
|
-
* @zh
|
|
1253
|
-
* @en
|
|
1741
|
+
* @zh 添加自定义事件条件
|
|
1742
|
+
* @en Add custom event condition
|
|
1254
1743
|
*/
|
|
1255
|
-
|
|
1256
|
-
this.
|
|
1257
|
-
this
|
|
1744
|
+
onCustomEvent(eventName) {
|
|
1745
|
+
this._conditions.push(new CustomEventCondition(eventName));
|
|
1746
|
+
return this;
|
|
1258
1747
|
}
|
|
1259
1748
|
/**
|
|
1260
|
-
* @zh
|
|
1261
|
-
* @en
|
|
1749
|
+
* @zh 添加自定义函数条件
|
|
1750
|
+
* @en Add custom function condition
|
|
1262
1751
|
*/
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
};
|
|
1267
|
-
__name(_TriggerRegistry, "TriggerRegistry");
|
|
1268
|
-
var TriggerRegistry = _TriggerRegistry;
|
|
1269
|
-
function createTrigger(config) {
|
|
1270
|
-
return new BlueprintTrigger(config);
|
|
1271
|
-
}
|
|
1272
|
-
__name(createTrigger, "createTrigger");
|
|
1273
|
-
function createTickTrigger(callback, options) {
|
|
1274
|
-
return new BlueprintTrigger({
|
|
1275
|
-
id: options?.id,
|
|
1276
|
-
type: "tick",
|
|
1277
|
-
condition: options?.condition,
|
|
1278
|
-
priority: options?.priority,
|
|
1279
|
-
callback
|
|
1280
|
-
});
|
|
1281
|
-
}
|
|
1282
|
-
__name(createTickTrigger, "createTickTrigger");
|
|
1283
|
-
function createInputTrigger(callback, options) {
|
|
1284
|
-
return new BlueprintTrigger({
|
|
1285
|
-
id: options?.id,
|
|
1286
|
-
type: "input",
|
|
1287
|
-
condition: options?.condition,
|
|
1288
|
-
priority: options?.priority,
|
|
1289
|
-
callback
|
|
1290
|
-
});
|
|
1291
|
-
}
|
|
1292
|
-
__name(createInputTrigger, "createInputTrigger");
|
|
1293
|
-
function createCollisionTrigger(callback, options) {
|
|
1294
|
-
return new BlueprintTrigger({
|
|
1295
|
-
id: options?.id,
|
|
1296
|
-
type: "collision",
|
|
1297
|
-
condition: options?.condition,
|
|
1298
|
-
priority: options?.priority,
|
|
1299
|
-
callback
|
|
1300
|
-
});
|
|
1301
|
-
}
|
|
1302
|
-
__name(createCollisionTrigger, "createCollisionTrigger");
|
|
1303
|
-
function createMessageTrigger(callback, options) {
|
|
1304
|
-
return new BlueprintTrigger({
|
|
1305
|
-
id: options?.id,
|
|
1306
|
-
type: "message",
|
|
1307
|
-
condition: options?.condition,
|
|
1308
|
-
priority: options?.priority,
|
|
1309
|
-
callback
|
|
1310
|
-
});
|
|
1311
|
-
}
|
|
1312
|
-
__name(createMessageTrigger, "createMessageTrigger");
|
|
1313
|
-
function createTimerTrigger(callback, options) {
|
|
1314
|
-
return new BlueprintTrigger({
|
|
1315
|
-
id: options?.id,
|
|
1316
|
-
type: "timer",
|
|
1317
|
-
condition: options?.condition,
|
|
1318
|
-
priority: options?.priority,
|
|
1319
|
-
callback
|
|
1320
|
-
});
|
|
1321
|
-
}
|
|
1322
|
-
__name(createTimerTrigger, "createTimerTrigger");
|
|
1323
|
-
function createStateEnterTrigger(callback, options) {
|
|
1324
|
-
return new BlueprintTrigger({
|
|
1325
|
-
id: options?.id,
|
|
1326
|
-
type: "stateEnter",
|
|
1327
|
-
condition: options?.condition,
|
|
1328
|
-
priority: options?.priority,
|
|
1329
|
-
callback
|
|
1330
|
-
});
|
|
1331
|
-
}
|
|
1332
|
-
__name(createStateEnterTrigger, "createStateEnterTrigger");
|
|
1333
|
-
function createStateExitTrigger(callback, options) {
|
|
1334
|
-
return new BlueprintTrigger({
|
|
1335
|
-
id: options?.id,
|
|
1336
|
-
type: "stateExit",
|
|
1337
|
-
condition: options?.condition,
|
|
1338
|
-
priority: options?.priority,
|
|
1339
|
-
callback
|
|
1340
|
-
});
|
|
1341
|
-
}
|
|
1342
|
-
__name(createStateExitTrigger, "createStateExitTrigger");
|
|
1343
|
-
function createCustomTrigger(callback, options) {
|
|
1344
|
-
return new BlueprintTrigger({
|
|
1345
|
-
id: options?.id,
|
|
1346
|
-
type: "custom",
|
|
1347
|
-
condition: options?.condition,
|
|
1348
|
-
priority: options?.priority,
|
|
1349
|
-
callback
|
|
1350
|
-
});
|
|
1351
|
-
}
|
|
1352
|
-
__name(createCustomTrigger, "createCustomTrigger");
|
|
1353
|
-
|
|
1354
|
-
// src/triggers/TriggerDispatcher.ts
|
|
1355
|
-
var _TriggerDispatcher = class _TriggerDispatcher {
|
|
1356
|
-
constructor(registry) {
|
|
1357
|
-
__publicField(this, "_registry");
|
|
1358
|
-
__publicField(this, "_typeSubscribers", /* @__PURE__ */ new Map());
|
|
1359
|
-
__publicField(this, "_globalSubscribers", /* @__PURE__ */ new Set());
|
|
1360
|
-
__publicField(this, "_isDispatching", false);
|
|
1361
|
-
__publicField(this, "_pendingContexts", []);
|
|
1362
|
-
this._registry = registry ?? new TriggerRegistry();
|
|
1363
|
-
}
|
|
1364
|
-
get registry() {
|
|
1365
|
-
return this._registry;
|
|
1752
|
+
where(predicate) {
|
|
1753
|
+
this._conditions.push(new FunctionCondition(predicate));
|
|
1754
|
+
return this;
|
|
1366
1755
|
}
|
|
1367
1756
|
/**
|
|
1368
|
-
* @zh
|
|
1369
|
-
* @en
|
|
1757
|
+
* @zh 添加取反条件
|
|
1758
|
+
* @en Add negated condition
|
|
1370
1759
|
*/
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
return {
|
|
1375
|
-
context,
|
|
1376
|
-
triggeredCount: 0,
|
|
1377
|
-
results: []
|
|
1378
|
-
};
|
|
1379
|
-
}
|
|
1380
|
-
this._isDispatching = true;
|
|
1381
|
-
try {
|
|
1382
|
-
const result = this._doDispatch(context);
|
|
1383
|
-
while (this._pendingContexts.length > 0) {
|
|
1384
|
-
const pendingContext = this._pendingContexts.shift();
|
|
1385
|
-
this._doDispatch(pendingContext);
|
|
1386
|
-
}
|
|
1387
|
-
return result;
|
|
1388
|
-
} finally {
|
|
1389
|
-
this._isDispatching = false;
|
|
1390
|
-
}
|
|
1760
|
+
not(condition2) {
|
|
1761
|
+
this._conditions.push(new NotCondition(condition2));
|
|
1762
|
+
return this;
|
|
1391
1763
|
}
|
|
1392
1764
|
/**
|
|
1393
|
-
* @zh
|
|
1394
|
-
* @en
|
|
1765
|
+
* @zh 构建条件
|
|
1766
|
+
* @en Build condition
|
|
1395
1767
|
*/
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
const triggers = this._registry.getByType(context.type);
|
|
1400
|
-
for (const trigger of triggers) {
|
|
1401
|
-
if (trigger.shouldFire(context)) {
|
|
1402
|
-
try {
|
|
1403
|
-
trigger.fire(context);
|
|
1404
|
-
triggeredCount++;
|
|
1405
|
-
results.push({
|
|
1406
|
-
triggerId: trigger.id,
|
|
1407
|
-
success: true
|
|
1408
|
-
});
|
|
1409
|
-
} catch (error) {
|
|
1410
|
-
results.push({
|
|
1411
|
-
triggerId: trigger.id,
|
|
1412
|
-
success: false,
|
|
1413
|
-
error: error instanceof Error ? error.message : String(error)
|
|
1414
|
-
});
|
|
1415
|
-
}
|
|
1416
|
-
}
|
|
1768
|
+
build() {
|
|
1769
|
+
if (this._conditions.length === 0) {
|
|
1770
|
+
return new AlwaysTrueCondition();
|
|
1417
1771
|
}
|
|
1418
|
-
this.
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1772
|
+
if (this._conditions.length === 1) {
|
|
1773
|
+
return this._conditions[0];
|
|
1774
|
+
}
|
|
1775
|
+
return new CompositeCondition(this._conditions, this._logic);
|
|
1776
|
+
}
|
|
1777
|
+
};
|
|
1778
|
+
__name(_ConditionBuilder, "ConditionBuilder");
|
|
1779
|
+
var ConditionBuilder = _ConditionBuilder;
|
|
1780
|
+
function condition() {
|
|
1781
|
+
return new ConditionBuilder();
|
|
1782
|
+
}
|
|
1783
|
+
__name(condition, "condition");
|
|
1784
|
+
|
|
1785
|
+
// src/triggers/BlueprintTrigger.ts
|
|
1786
|
+
var _triggerId = 0;
|
|
1787
|
+
function generateTriggerId() {
|
|
1788
|
+
return `trigger_${++_triggerId}`;
|
|
1789
|
+
}
|
|
1790
|
+
__name(generateTriggerId, "generateTriggerId");
|
|
1791
|
+
var _BlueprintTrigger = class _BlueprintTrigger {
|
|
1792
|
+
constructor(config) {
|
|
1793
|
+
__publicField(this, "id");
|
|
1794
|
+
__publicField(this, "type");
|
|
1795
|
+
__publicField(this, "condition");
|
|
1796
|
+
__publicField(this, "priority");
|
|
1797
|
+
__publicField(this, "enabled");
|
|
1798
|
+
__publicField(this, "_callback");
|
|
1799
|
+
__publicField(this, "_callbacks", /* @__PURE__ */ new Set());
|
|
1800
|
+
this.id = config.id ?? generateTriggerId();
|
|
1801
|
+
this.type = config.type;
|
|
1802
|
+
this.condition = config.condition ?? new AlwaysTrueCondition();
|
|
1803
|
+
this.priority = config.priority ?? 0;
|
|
1804
|
+
this.enabled = config.enabled ?? true;
|
|
1805
|
+
this._callback = config.callback;
|
|
1424
1806
|
}
|
|
1425
1807
|
/**
|
|
1426
|
-
* @zh
|
|
1427
|
-
* @en
|
|
1808
|
+
* @zh 检查是否应该触发
|
|
1809
|
+
* @en Check if should fire
|
|
1428
1810
|
*/
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
for (const callback of typeSubscribers) {
|
|
1433
|
-
try {
|
|
1434
|
-
callback(context);
|
|
1435
|
-
} catch (error) {
|
|
1436
|
-
console.error(`Trigger subscriber error: ${error}`);
|
|
1437
|
-
}
|
|
1438
|
-
}
|
|
1811
|
+
shouldFire(context) {
|
|
1812
|
+
if (!this.enabled) {
|
|
1813
|
+
return false;
|
|
1439
1814
|
}
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
callback(context);
|
|
1443
|
-
} catch (error) {
|
|
1444
|
-
console.error(`Global trigger subscriber error: ${error}`);
|
|
1445
|
-
}
|
|
1815
|
+
if (context.type !== this.type && this.type !== "custom") {
|
|
1816
|
+
return false;
|
|
1446
1817
|
}
|
|
1818
|
+
return this.condition.evaluate(context);
|
|
1447
1819
|
}
|
|
1448
1820
|
/**
|
|
1449
|
-
* @zh
|
|
1450
|
-
* @en
|
|
1451
|
-
*/
|
|
1452
|
-
async dispatchAsync(context) {
|
|
1453
|
-
return new Promise((resolve) => {
|
|
1454
|
-
queueMicrotask(() => {
|
|
1455
|
-
resolve(this.dispatch(context));
|
|
1456
|
-
});
|
|
1457
|
-
});
|
|
1458
|
-
}
|
|
1459
|
-
/**
|
|
1460
|
-
* @zh 订阅触发器类型
|
|
1461
|
-
* @en Subscribe to trigger type
|
|
1821
|
+
* @zh 执行触发器
|
|
1822
|
+
* @en Execute trigger
|
|
1462
1823
|
*/
|
|
1463
|
-
|
|
1464
|
-
if (
|
|
1465
|
-
this.
|
|
1824
|
+
fire(context) {
|
|
1825
|
+
if (this._callback) {
|
|
1826
|
+
this._callback(context);
|
|
1466
1827
|
}
|
|
1467
|
-
this.
|
|
1468
|
-
|
|
1469
|
-
}
|
|
1470
|
-
/**
|
|
1471
|
-
* @zh 取消订阅
|
|
1472
|
-
* @en Unsubscribe
|
|
1473
|
-
*/
|
|
1474
|
-
unsubscribe(type, callback) {
|
|
1475
|
-
const subscribers = this._typeSubscribers.get(type);
|
|
1476
|
-
if (subscribers) {
|
|
1477
|
-
subscribers.delete(callback);
|
|
1828
|
+
for (const callback of this._callbacks) {
|
|
1829
|
+
callback(context);
|
|
1478
1830
|
}
|
|
1479
1831
|
}
|
|
1480
1832
|
/**
|
|
1481
|
-
* @zh
|
|
1482
|
-
* @en
|
|
1833
|
+
* @zh 添加回调
|
|
1834
|
+
* @en Add callback
|
|
1483
1835
|
*/
|
|
1484
|
-
|
|
1485
|
-
this.
|
|
1486
|
-
return () => this.unsubscribeAll(callback);
|
|
1836
|
+
addCallback(callback) {
|
|
1837
|
+
this._callbacks.add(callback);
|
|
1487
1838
|
}
|
|
1488
1839
|
/**
|
|
1489
|
-
* @zh
|
|
1490
|
-
* @en
|
|
1840
|
+
* @zh 移除回调
|
|
1841
|
+
* @en Remove callback
|
|
1491
1842
|
*/
|
|
1492
|
-
|
|
1493
|
-
this.
|
|
1843
|
+
removeCallback(callback) {
|
|
1844
|
+
this._callbacks.delete(callback);
|
|
1494
1845
|
}
|
|
1495
1846
|
/**
|
|
1496
|
-
* @zh
|
|
1497
|
-
* @en Clear all
|
|
1847
|
+
* @zh 清除所有回调
|
|
1848
|
+
* @en Clear all callbacks
|
|
1498
1849
|
*/
|
|
1499
|
-
|
|
1500
|
-
this.
|
|
1501
|
-
this._globalSubscribers.clear();
|
|
1850
|
+
clearCallbacks() {
|
|
1851
|
+
this._callbacks.clear();
|
|
1502
1852
|
}
|
|
1503
1853
|
};
|
|
1504
|
-
__name(
|
|
1505
|
-
var
|
|
1506
|
-
var
|
|
1507
|
-
constructor(
|
|
1508
|
-
__publicField(this, "
|
|
1509
|
-
__publicField(this, "
|
|
1510
|
-
this._dispatcher = dispatcher ?? new TriggerDispatcher();
|
|
1511
|
-
}
|
|
1512
|
-
get dispatcher() {
|
|
1513
|
-
return this._dispatcher;
|
|
1854
|
+
__name(_BlueprintTrigger, "BlueprintTrigger");
|
|
1855
|
+
var BlueprintTrigger = _BlueprintTrigger;
|
|
1856
|
+
var _TriggerRegistry = class _TriggerRegistry {
|
|
1857
|
+
constructor() {
|
|
1858
|
+
__publicField(this, "_triggers", /* @__PURE__ */ new Map());
|
|
1859
|
+
__publicField(this, "_triggersByType", /* @__PURE__ */ new Map());
|
|
1514
1860
|
}
|
|
1515
1861
|
/**
|
|
1516
|
-
* @zh
|
|
1517
|
-
* @en Register trigger
|
|
1862
|
+
* @zh 注册触发器
|
|
1863
|
+
* @en Register trigger
|
|
1518
1864
|
*/
|
|
1519
|
-
|
|
1520
|
-
this.
|
|
1521
|
-
|
|
1522
|
-
this._entityTriggers.set(entityId, /* @__PURE__ */ new Set());
|
|
1865
|
+
register(trigger) {
|
|
1866
|
+
if (this._triggers.has(trigger.id)) {
|
|
1867
|
+
console.warn(`Trigger ${trigger.id} already registered, overwriting`);
|
|
1523
1868
|
}
|
|
1524
|
-
this.
|
|
1869
|
+
this._triggers.set(trigger.id, trigger);
|
|
1870
|
+
if (!this._triggersByType.has(trigger.type)) {
|
|
1871
|
+
this._triggersByType.set(trigger.type, /* @__PURE__ */ new Set());
|
|
1872
|
+
}
|
|
1873
|
+
this._triggersByType.get(trigger.type).add(trigger.id);
|
|
1525
1874
|
}
|
|
1526
1875
|
/**
|
|
1527
|
-
* @zh
|
|
1528
|
-
* @en Unregister trigger
|
|
1876
|
+
* @zh 注销触发器
|
|
1877
|
+
* @en Unregister trigger
|
|
1529
1878
|
*/
|
|
1530
|
-
|
|
1531
|
-
const
|
|
1532
|
-
if (!
|
|
1879
|
+
unregister(triggerId) {
|
|
1880
|
+
const trigger = this._triggers.get(triggerId);
|
|
1881
|
+
if (!trigger) {
|
|
1533
1882
|
return false;
|
|
1534
1883
|
}
|
|
1535
|
-
|
|
1536
|
-
|
|
1884
|
+
this._triggers.delete(triggerId);
|
|
1885
|
+
const typeSet = this._triggersByType.get(trigger.type);
|
|
1886
|
+
if (typeSet) {
|
|
1887
|
+
typeSet.delete(triggerId);
|
|
1537
1888
|
}
|
|
1538
|
-
|
|
1539
|
-
return this._dispatcher.registry.unregister(triggerId);
|
|
1889
|
+
return true;
|
|
1540
1890
|
}
|
|
1541
1891
|
/**
|
|
1542
|
-
* @zh
|
|
1543
|
-
* @en Get
|
|
1892
|
+
* @zh 获取触发器
|
|
1893
|
+
* @en Get trigger
|
|
1544
1894
|
*/
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
if (!entitySet) {
|
|
1548
|
-
return [];
|
|
1549
|
-
}
|
|
1550
|
-
const triggers = [];
|
|
1551
|
-
for (const triggerId of entitySet) {
|
|
1552
|
-
const trigger = this._dispatcher.registry.get(triggerId);
|
|
1553
|
-
if (trigger) {
|
|
1554
|
-
triggers.push(trigger);
|
|
1555
|
-
}
|
|
1556
|
-
}
|
|
1557
|
-
return triggers;
|
|
1895
|
+
get(triggerId) {
|
|
1896
|
+
return this._triggers.get(triggerId);
|
|
1558
1897
|
}
|
|
1559
1898
|
/**
|
|
1560
|
-
* @zh
|
|
1561
|
-
* @en
|
|
1899
|
+
* @zh 获取所有触发器
|
|
1900
|
+
* @en Get all triggers
|
|
1562
1901
|
*/
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
if (!entitySet) {
|
|
1566
|
-
return;
|
|
1567
|
-
}
|
|
1568
|
-
for (const triggerId of entitySet) {
|
|
1569
|
-
this._dispatcher.registry.unregister(triggerId);
|
|
1570
|
-
}
|
|
1571
|
-
this._entityTriggers.delete(entityId);
|
|
1902
|
+
getAll() {
|
|
1903
|
+
return Array.from(this._triggers.values());
|
|
1572
1904
|
}
|
|
1573
1905
|
/**
|
|
1574
|
-
* @zh
|
|
1575
|
-
* @en
|
|
1906
|
+
* @zh 按类型获取触发器
|
|
1907
|
+
* @en Get triggers by type
|
|
1576
1908
|
*/
|
|
1577
|
-
|
|
1578
|
-
const
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
for (const trigger of entityTriggers) {
|
|
1582
|
-
if (trigger.shouldFire(context)) {
|
|
1583
|
-
try {
|
|
1584
|
-
trigger.fire(context);
|
|
1585
|
-
triggeredCount++;
|
|
1586
|
-
results.push({
|
|
1587
|
-
triggerId: trigger.id,
|
|
1588
|
-
success: true
|
|
1589
|
-
});
|
|
1590
|
-
} catch (error) {
|
|
1591
|
-
results.push({
|
|
1592
|
-
triggerId: trigger.id,
|
|
1593
|
-
success: false,
|
|
1594
|
-
error: error instanceof Error ? error.message : String(error)
|
|
1595
|
-
});
|
|
1596
|
-
}
|
|
1597
|
-
}
|
|
1909
|
+
getByType(type) {
|
|
1910
|
+
const typeSet = this._triggersByType.get(type);
|
|
1911
|
+
if (!typeSet) {
|
|
1912
|
+
return [];
|
|
1598
1913
|
}
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
}
|
|
1606
|
-
|
|
1607
|
-
var EntityTriggerManager = _EntityTriggerManager;
|
|
1608
|
-
function createTriggerDispatcher(registry) {
|
|
1609
|
-
return new TriggerDispatcher(registry);
|
|
1610
|
-
}
|
|
1611
|
-
__name(createTriggerDispatcher, "createTriggerDispatcher");
|
|
1612
|
-
function createEntityTriggerManager(dispatcher) {
|
|
1613
|
-
return new EntityTriggerManager(dispatcher);
|
|
1614
|
-
}
|
|
1615
|
-
__name(createEntityTriggerManager, "createEntityTriggerManager");
|
|
1616
|
-
|
|
1617
|
-
// src/composition/BlueprintFragment.ts
|
|
1618
|
-
var _BlueprintFragment = class _BlueprintFragment {
|
|
1619
|
-
constructor(config) {
|
|
1620
|
-
__publicField(this, "id");
|
|
1621
|
-
__publicField(this, "name");
|
|
1622
|
-
__publicField(this, "description");
|
|
1623
|
-
__publicField(this, "category");
|
|
1624
|
-
__publicField(this, "tags");
|
|
1625
|
-
__publicField(this, "inputs");
|
|
1626
|
-
__publicField(this, "outputs");
|
|
1627
|
-
__publicField(this, "graph");
|
|
1628
|
-
__publicField(this, "version");
|
|
1629
|
-
__publicField(this, "icon");
|
|
1630
|
-
__publicField(this, "color");
|
|
1631
|
-
this.id = config.id;
|
|
1632
|
-
this.name = config.name;
|
|
1633
|
-
this.description = config.description;
|
|
1634
|
-
this.category = config.category;
|
|
1635
|
-
this.tags = config.tags;
|
|
1636
|
-
this.inputs = config.inputs ?? [];
|
|
1637
|
-
this.outputs = config.outputs ?? [];
|
|
1638
|
-
this.graph = config.graph;
|
|
1639
|
-
this.version = config.version;
|
|
1640
|
-
this.icon = config.icon;
|
|
1641
|
-
this.color = config.color;
|
|
1642
|
-
}
|
|
1643
|
-
/**
|
|
1644
|
-
* @zh 获取所有暴露引脚
|
|
1645
|
-
* @en Get all exposed pins
|
|
1646
|
-
*/
|
|
1647
|
-
getAllExposedPins() {
|
|
1648
|
-
return [
|
|
1649
|
-
...this.inputs,
|
|
1650
|
-
...this.outputs
|
|
1651
|
-
];
|
|
1914
|
+
const triggers = [];
|
|
1915
|
+
for (const id of typeSet) {
|
|
1916
|
+
const trigger = this._triggers.get(id);
|
|
1917
|
+
if (trigger) {
|
|
1918
|
+
triggers.push(trigger);
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
return triggers.sort((a, b) => b.priority - a.priority);
|
|
1652
1922
|
}
|
|
1653
1923
|
/**
|
|
1654
|
-
* @zh
|
|
1655
|
-
* @en
|
|
1924
|
+
* @zh 清除所有触发器
|
|
1925
|
+
* @en Clear all triggers
|
|
1656
1926
|
*/
|
|
1657
|
-
|
|
1658
|
-
|
|
1927
|
+
clear() {
|
|
1928
|
+
this._triggers.clear();
|
|
1929
|
+
this._triggersByType.clear();
|
|
1659
1930
|
}
|
|
1660
1931
|
/**
|
|
1661
|
-
* @zh
|
|
1662
|
-
* @en
|
|
1932
|
+
* @zh 获取触发器数量
|
|
1933
|
+
* @en Get trigger count
|
|
1663
1934
|
*/
|
|
1664
|
-
|
|
1665
|
-
return this.
|
|
1935
|
+
get count() {
|
|
1936
|
+
return this._triggers.size;
|
|
1666
1937
|
}
|
|
1667
1938
|
};
|
|
1668
|
-
__name(
|
|
1669
|
-
var
|
|
1670
|
-
function
|
|
1671
|
-
return
|
|
1672
|
-
name,
|
|
1673
|
-
displayName: options?.displayName ?? name,
|
|
1674
|
-
type,
|
|
1675
|
-
direction,
|
|
1676
|
-
description: options?.description,
|
|
1677
|
-
defaultValue: options?.defaultValue,
|
|
1678
|
-
internalNodeId,
|
|
1679
|
-
internalPinName
|
|
1680
|
-
};
|
|
1939
|
+
__name(_TriggerRegistry, "TriggerRegistry");
|
|
1940
|
+
var TriggerRegistry = _TriggerRegistry;
|
|
1941
|
+
function createTrigger(config) {
|
|
1942
|
+
return new BlueprintTrigger(config);
|
|
1681
1943
|
}
|
|
1682
|
-
__name(
|
|
1683
|
-
function
|
|
1684
|
-
return new
|
|
1944
|
+
__name(createTrigger, "createTrigger");
|
|
1945
|
+
function createTickTrigger(callback, options) {
|
|
1946
|
+
return new BlueprintTrigger({
|
|
1947
|
+
id: options?.id,
|
|
1948
|
+
type: "tick",
|
|
1949
|
+
condition: options?.condition,
|
|
1950
|
+
priority: options?.priority,
|
|
1951
|
+
callback
|
|
1952
|
+
});
|
|
1685
1953
|
}
|
|
1686
|
-
__name(
|
|
1687
|
-
function
|
|
1688
|
-
return new
|
|
1689
|
-
|
|
1690
|
-
|
|
1954
|
+
__name(createTickTrigger, "createTickTrigger");
|
|
1955
|
+
function createInputTrigger(callback, options) {
|
|
1956
|
+
return new BlueprintTrigger({
|
|
1957
|
+
id: options?.id,
|
|
1958
|
+
type: "input",
|
|
1959
|
+
condition: options?.condition,
|
|
1960
|
+
priority: options?.priority,
|
|
1961
|
+
callback
|
|
1691
1962
|
});
|
|
1692
1963
|
}
|
|
1693
|
-
__name(
|
|
1694
|
-
function
|
|
1695
|
-
return {
|
|
1696
|
-
|
|
1697
|
-
type: "
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
category: fragment.category,
|
|
1703
|
-
tags: fragment.tags,
|
|
1704
|
-
inputs: fragment.inputs,
|
|
1705
|
-
outputs: fragment.outputs,
|
|
1706
|
-
version: fragment.version,
|
|
1707
|
-
icon: fragment.icon,
|
|
1708
|
-
color: fragment.color
|
|
1709
|
-
},
|
|
1710
|
-
graph: fragment.graph
|
|
1711
|
-
};
|
|
1964
|
+
__name(createInputTrigger, "createInputTrigger");
|
|
1965
|
+
function createCollisionTrigger(callback, options) {
|
|
1966
|
+
return new BlueprintTrigger({
|
|
1967
|
+
id: options?.id,
|
|
1968
|
+
type: "collision",
|
|
1969
|
+
condition: options?.condition,
|
|
1970
|
+
priority: options?.priority,
|
|
1971
|
+
callback
|
|
1972
|
+
});
|
|
1712
1973
|
}
|
|
1713
|
-
__name(
|
|
1974
|
+
__name(createCollisionTrigger, "createCollisionTrigger");
|
|
1975
|
+
function createMessageTrigger(callback, options) {
|
|
1976
|
+
return new BlueprintTrigger({
|
|
1977
|
+
id: options?.id,
|
|
1978
|
+
type: "message",
|
|
1979
|
+
condition: options?.condition,
|
|
1980
|
+
priority: options?.priority,
|
|
1981
|
+
callback
|
|
1982
|
+
});
|
|
1983
|
+
}
|
|
1984
|
+
__name(createMessageTrigger, "createMessageTrigger");
|
|
1985
|
+
function createTimerTrigger(callback, options) {
|
|
1986
|
+
return new BlueprintTrigger({
|
|
1987
|
+
id: options?.id,
|
|
1988
|
+
type: "timer",
|
|
1989
|
+
condition: options?.condition,
|
|
1990
|
+
priority: options?.priority,
|
|
1991
|
+
callback
|
|
1992
|
+
});
|
|
1993
|
+
}
|
|
1994
|
+
__name(createTimerTrigger, "createTimerTrigger");
|
|
1995
|
+
function createStateEnterTrigger(callback, options) {
|
|
1996
|
+
return new BlueprintTrigger({
|
|
1997
|
+
id: options?.id,
|
|
1998
|
+
type: "stateEnter",
|
|
1999
|
+
condition: options?.condition,
|
|
2000
|
+
priority: options?.priority,
|
|
2001
|
+
callback
|
|
2002
|
+
});
|
|
2003
|
+
}
|
|
2004
|
+
__name(createStateEnterTrigger, "createStateEnterTrigger");
|
|
2005
|
+
function createStateExitTrigger(callback, options) {
|
|
2006
|
+
return new BlueprintTrigger({
|
|
2007
|
+
id: options?.id,
|
|
2008
|
+
type: "stateExit",
|
|
2009
|
+
condition: options?.condition,
|
|
2010
|
+
priority: options?.priority,
|
|
2011
|
+
callback
|
|
2012
|
+
});
|
|
2013
|
+
}
|
|
2014
|
+
__name(createStateExitTrigger, "createStateExitTrigger");
|
|
2015
|
+
function createCustomTrigger(callback, options) {
|
|
2016
|
+
return new BlueprintTrigger({
|
|
2017
|
+
id: options?.id,
|
|
2018
|
+
type: "custom",
|
|
2019
|
+
condition: options?.condition,
|
|
2020
|
+
priority: options?.priority,
|
|
2021
|
+
callback
|
|
2022
|
+
});
|
|
2023
|
+
}
|
|
2024
|
+
__name(createCustomTrigger, "createCustomTrigger");
|
|
1714
2025
|
|
|
1715
|
-
// src/
|
|
1716
|
-
var
|
|
1717
|
-
constructor(
|
|
1718
|
-
__publicField(this, "
|
|
1719
|
-
__publicField(this, "
|
|
1720
|
-
__publicField(this, "
|
|
1721
|
-
__publicField(this, "
|
|
1722
|
-
this
|
|
1723
|
-
|
|
1724
|
-
getSlots() {
|
|
1725
|
-
return Array.from(this.slots.values());
|
|
1726
|
-
}
|
|
1727
|
-
getConnections() {
|
|
1728
|
-
return Array.from(this.connections.values());
|
|
1729
|
-
}
|
|
1730
|
-
addFragment(fragment, slotId, options) {
|
|
1731
|
-
if (this.slots.has(slotId)) {
|
|
1732
|
-
throw new Error(`Slot '${slotId}' already exists`);
|
|
1733
|
-
}
|
|
1734
|
-
const slot = {
|
|
1735
|
-
id: slotId,
|
|
1736
|
-
name: options?.name ?? fragment.name,
|
|
1737
|
-
fragment,
|
|
1738
|
-
position: options?.position ?? {
|
|
1739
|
-
x: 0,
|
|
1740
|
-
y: 0
|
|
1741
|
-
}
|
|
1742
|
-
};
|
|
1743
|
-
this.slots.set(slotId, slot);
|
|
1744
|
-
}
|
|
1745
|
-
removeSlot(slotId) {
|
|
1746
|
-
if (!this.slots.has(slotId)) {
|
|
1747
|
-
return;
|
|
1748
|
-
}
|
|
1749
|
-
const toRemove = [];
|
|
1750
|
-
for (const [id, conn] of this.connections) {
|
|
1751
|
-
if (conn.fromSlotId === slotId || conn.toSlotId === slotId) {
|
|
1752
|
-
toRemove.push(id);
|
|
1753
|
-
}
|
|
1754
|
-
}
|
|
1755
|
-
for (const id of toRemove) {
|
|
1756
|
-
this.connections.delete(id);
|
|
1757
|
-
}
|
|
1758
|
-
this.slots.delete(slotId);
|
|
1759
|
-
}
|
|
1760
|
-
connect(fromSlotId, fromPin, toSlotId, toPin) {
|
|
1761
|
-
const fromSlot = this.slots.get(fromSlotId);
|
|
1762
|
-
const toSlot = this.slots.get(toSlotId);
|
|
1763
|
-
if (!fromSlot) {
|
|
1764
|
-
throw new Error(`Source slot '${fromSlotId}' not found`);
|
|
1765
|
-
}
|
|
1766
|
-
if (!toSlot) {
|
|
1767
|
-
throw new Error(`Target slot '${toSlotId}' not found`);
|
|
1768
|
-
}
|
|
1769
|
-
const fromPinDef = fromSlot.fragment.outputs.find((p) => p.name === fromPin);
|
|
1770
|
-
const toPinDef = toSlot.fragment.inputs.find((p) => p.name === toPin);
|
|
1771
|
-
if (!fromPinDef) {
|
|
1772
|
-
throw new Error(`Output pin '${fromPin}' not found in slot '${fromSlotId}'`);
|
|
1773
|
-
}
|
|
1774
|
-
if (!toPinDef) {
|
|
1775
|
-
throw new Error(`Input pin '${toPin}' not found in slot '${toSlotId}'`);
|
|
1776
|
-
}
|
|
1777
|
-
const connectionId = `conn_${++this.connectionIdCounter}`;
|
|
1778
|
-
const connection = {
|
|
1779
|
-
id: connectionId,
|
|
1780
|
-
fromSlotId,
|
|
1781
|
-
fromPin,
|
|
1782
|
-
toSlotId,
|
|
1783
|
-
toPin
|
|
1784
|
-
};
|
|
1785
|
-
this.connections.set(connectionId, connection);
|
|
1786
|
-
}
|
|
1787
|
-
disconnect(connectionId) {
|
|
1788
|
-
this.connections.delete(connectionId);
|
|
2026
|
+
// src/triggers/TriggerDispatcher.ts
|
|
2027
|
+
var _TriggerDispatcher = class _TriggerDispatcher {
|
|
2028
|
+
constructor(registry) {
|
|
2029
|
+
__publicField(this, "_registry");
|
|
2030
|
+
__publicField(this, "_typeSubscribers", /* @__PURE__ */ new Map());
|
|
2031
|
+
__publicField(this, "_globalSubscribers", /* @__PURE__ */ new Set());
|
|
2032
|
+
__publicField(this, "_isDispatching", false);
|
|
2033
|
+
__publicField(this, "_pendingContexts", []);
|
|
2034
|
+
this._registry = registry ?? new TriggerRegistry();
|
|
1789
2035
|
}
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
}
|
|
1805
|
-
for (const output of slot.fragment.outputs) {
|
|
1806
|
-
const hasConnection = Array.from(this.connections.values()).some((c) => c.fromSlotId === slot.id && c.fromPin === output.name);
|
|
1807
|
-
if (!hasConnection) {
|
|
1808
|
-
warnings.push({
|
|
1809
|
-
type: "unused-output",
|
|
1810
|
-
message: `Output '${output.name}' in slot '${slot.id}' is not connected`,
|
|
1811
|
-
slotId: slot.id,
|
|
1812
|
-
pinName: output.name
|
|
1813
|
-
});
|
|
1814
|
-
}
|
|
1815
|
-
}
|
|
2036
|
+
get registry() {
|
|
2037
|
+
return this._registry;
|
|
2038
|
+
}
|
|
2039
|
+
/**
|
|
2040
|
+
* @zh 调度触发器
|
|
2041
|
+
* @en Dispatch trigger
|
|
2042
|
+
*/
|
|
2043
|
+
dispatch(context) {
|
|
2044
|
+
if (this._isDispatching) {
|
|
2045
|
+
this._pendingContexts.push(context);
|
|
2046
|
+
return {
|
|
2047
|
+
context,
|
|
2048
|
+
triggeredCount: 0,
|
|
2049
|
+
results: []
|
|
2050
|
+
};
|
|
1816
2051
|
}
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
const
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
message: `Invalid slot reference in connection '${conn.id}'`
|
|
1824
|
-
});
|
|
1825
|
-
continue;
|
|
2052
|
+
this._isDispatching = true;
|
|
2053
|
+
try {
|
|
2054
|
+
const result = this._doDispatch(context);
|
|
2055
|
+
while (this._pendingContexts.length > 0) {
|
|
2056
|
+
const pendingContext = this._pendingContexts.shift();
|
|
2057
|
+
this._doDispatch(pendingContext);
|
|
1826
2058
|
}
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
2059
|
+
return result;
|
|
2060
|
+
} finally {
|
|
2061
|
+
this._isDispatching = false;
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
/**
|
|
2065
|
+
* @zh 执行调度
|
|
2066
|
+
* @en Do dispatch
|
|
2067
|
+
*/
|
|
2068
|
+
_doDispatch(context) {
|
|
2069
|
+
const results = [];
|
|
2070
|
+
let triggeredCount = 0;
|
|
2071
|
+
const triggers = this._registry.getByType(context.type);
|
|
2072
|
+
for (const trigger of triggers) {
|
|
2073
|
+
if (trigger.shouldFire(context)) {
|
|
2074
|
+
try {
|
|
2075
|
+
trigger.fire(context);
|
|
2076
|
+
triggeredCount++;
|
|
2077
|
+
results.push({
|
|
2078
|
+
triggerId: trigger.id,
|
|
2079
|
+
success: true
|
|
2080
|
+
});
|
|
2081
|
+
} catch (error) {
|
|
2082
|
+
results.push({
|
|
2083
|
+
triggerId: trigger.id,
|
|
2084
|
+
success: false,
|
|
2085
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1834
2086
|
});
|
|
1835
2087
|
}
|
|
1836
2088
|
}
|
|
1837
2089
|
}
|
|
2090
|
+
this._notifySubscribers(context);
|
|
1838
2091
|
return {
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
2092
|
+
context,
|
|
2093
|
+
triggeredCount,
|
|
2094
|
+
results
|
|
1842
2095
|
};
|
|
1843
2096
|
}
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
const
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
nodes.push({
|
|
1857
|
-
...node,
|
|
1858
|
-
id: newNodeId,
|
|
1859
|
-
position: {
|
|
1860
|
-
x: node.position.x + slot.position.x,
|
|
1861
|
-
y: node.position.y + slot.position.y
|
|
1862
|
-
}
|
|
1863
|
-
});
|
|
1864
|
-
}
|
|
1865
|
-
for (const conn of slot.fragment.graph.connections) {
|
|
1866
|
-
const newFromId = slotNodeMap.get(conn.fromNodeId);
|
|
1867
|
-
const newToId = slotNodeMap.get(conn.toNodeId);
|
|
1868
|
-
if (newFromId && newToId) {
|
|
1869
|
-
connections.push({
|
|
1870
|
-
...conn,
|
|
1871
|
-
id: `conn_internal_${connections.length}`,
|
|
1872
|
-
fromNodeId: newFromId,
|
|
1873
|
-
toNodeId: newToId
|
|
1874
|
-
});
|
|
2097
|
+
/**
|
|
2098
|
+
* @zh 通知订阅者
|
|
2099
|
+
* @en Notify subscribers
|
|
2100
|
+
*/
|
|
2101
|
+
_notifySubscribers(context) {
|
|
2102
|
+
const typeSubscribers = this._typeSubscribers.get(context.type);
|
|
2103
|
+
if (typeSubscribers) {
|
|
2104
|
+
for (const callback of typeSubscribers) {
|
|
2105
|
+
try {
|
|
2106
|
+
callback(context);
|
|
2107
|
+
} catch (error) {
|
|
2108
|
+
console.error(`Trigger subscriber error: ${error}`);
|
|
1875
2109
|
}
|
|
1876
2110
|
}
|
|
1877
|
-
for (const variable of slot.fragment.graph.variables) {
|
|
1878
|
-
variables.push({
|
|
1879
|
-
...variable,
|
|
1880
|
-
name: `${slot.id}_${variable.name}`
|
|
1881
|
-
});
|
|
1882
|
-
}
|
|
1883
2111
|
}
|
|
1884
|
-
for (const
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
const toPinDef = toSlot.fragment.inputs.find((p) => p.name === slotConn.toPin);
|
|
1890
|
-
if (!fromPinDef || !toPinDef) continue;
|
|
1891
|
-
const fromNodeMap = nodeIdMap.get(slotConn.fromSlotId);
|
|
1892
|
-
const toNodeMap = nodeIdMap.get(slotConn.toSlotId);
|
|
1893
|
-
if (!fromNodeMap || !toNodeMap) continue;
|
|
1894
|
-
const fromNodeId = fromNodeMap.get(fromPinDef.internalNodeId);
|
|
1895
|
-
const toNodeId = toNodeMap.get(toPinDef.internalNodeId);
|
|
1896
|
-
if (fromNodeId && toNodeId) {
|
|
1897
|
-
connections.push({
|
|
1898
|
-
id: `conn_slot_${connections.length}`,
|
|
1899
|
-
fromNodeId,
|
|
1900
|
-
fromPin: fromPinDef.internalPinName,
|
|
1901
|
-
toNodeId,
|
|
1902
|
-
toPin: toPinDef.internalPinName
|
|
1903
|
-
});
|
|
2112
|
+
for (const callback of this._globalSubscribers) {
|
|
2113
|
+
try {
|
|
2114
|
+
callback(context);
|
|
2115
|
+
} catch (error) {
|
|
2116
|
+
console.error(`Global trigger subscriber error: ${error}`);
|
|
1904
2117
|
}
|
|
1905
2118
|
}
|
|
1906
|
-
return {
|
|
1907
|
-
version: 1,
|
|
1908
|
-
type: "blueprint",
|
|
1909
|
-
metadata: {
|
|
1910
|
-
name: this.name,
|
|
1911
|
-
description: `Composed from ${this.slots.size} fragments`,
|
|
1912
|
-
createdAt: Date.now(),
|
|
1913
|
-
modifiedAt: Date.now()
|
|
1914
|
-
},
|
|
1915
|
-
variables,
|
|
1916
|
-
nodes,
|
|
1917
|
-
connections
|
|
1918
|
-
};
|
|
1919
2119
|
}
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
2120
|
+
/**
|
|
2121
|
+
* @zh 异步调度触发器
|
|
2122
|
+
* @en Async dispatch trigger
|
|
2123
|
+
*/
|
|
2124
|
+
async dispatchAsync(context) {
|
|
2125
|
+
return new Promise((resolve) => {
|
|
2126
|
+
queueMicrotask(() => {
|
|
2127
|
+
resolve(this.dispatch(context));
|
|
2128
|
+
});
|
|
2129
|
+
});
|
|
1924
2130
|
}
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
constructor() {
|
|
1936
|
-
__publicField(this, "fragments", /* @__PURE__ */ new Map());
|
|
2131
|
+
/**
|
|
2132
|
+
* @zh 订阅触发器类型
|
|
2133
|
+
* @en Subscribe to trigger type
|
|
2134
|
+
*/
|
|
2135
|
+
subscribe(type, callback) {
|
|
2136
|
+
if (!this._typeSubscribers.has(type)) {
|
|
2137
|
+
this._typeSubscribers.set(type, /* @__PURE__ */ new Set());
|
|
2138
|
+
}
|
|
2139
|
+
this._typeSubscribers.get(type).add(callback);
|
|
2140
|
+
return () => this.unsubscribe(type, callback);
|
|
1937
2141
|
}
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
2142
|
+
/**
|
|
2143
|
+
* @zh 取消订阅
|
|
2144
|
+
* @en Unsubscribe
|
|
2145
|
+
*/
|
|
2146
|
+
unsubscribe(type, callback) {
|
|
2147
|
+
const subscribers = this._typeSubscribers.get(type);
|
|
2148
|
+
if (subscribers) {
|
|
2149
|
+
subscribers.delete(callback);
|
|
1941
2150
|
}
|
|
1942
|
-
this.fragments.set(fragment.id, fragment);
|
|
1943
2151
|
}
|
|
1944
|
-
|
|
1945
|
-
|
|
2152
|
+
/**
|
|
2153
|
+
* @zh 订阅所有触发器
|
|
2154
|
+
* @en Subscribe to all triggers
|
|
2155
|
+
*/
|
|
2156
|
+
subscribeAll(callback) {
|
|
2157
|
+
this._globalSubscribers.add(callback);
|
|
2158
|
+
return () => this.unsubscribeAll(callback);
|
|
1946
2159
|
}
|
|
1947
|
-
|
|
1948
|
-
|
|
2160
|
+
/**
|
|
2161
|
+
* @zh 取消订阅所有
|
|
2162
|
+
* @en Unsubscribe from all
|
|
2163
|
+
*/
|
|
2164
|
+
unsubscribeAll(callback) {
|
|
2165
|
+
this._globalSubscribers.delete(callback);
|
|
1949
2166
|
}
|
|
1950
|
-
|
|
1951
|
-
|
|
2167
|
+
/**
|
|
2168
|
+
* @zh 清除所有订阅
|
|
2169
|
+
* @en Clear all subscriptions
|
|
2170
|
+
*/
|
|
2171
|
+
clearSubscriptions() {
|
|
2172
|
+
this._typeSubscribers.clear();
|
|
2173
|
+
this._globalSubscribers.clear();
|
|
1952
2174
|
}
|
|
1953
|
-
|
|
1954
|
-
|
|
2175
|
+
};
|
|
2176
|
+
__name(_TriggerDispatcher, "TriggerDispatcher");
|
|
2177
|
+
var TriggerDispatcher = _TriggerDispatcher;
|
|
2178
|
+
var _EntityTriggerManager = class _EntityTriggerManager {
|
|
2179
|
+
constructor(dispatcher) {
|
|
2180
|
+
__publicField(this, "_dispatcher");
|
|
2181
|
+
__publicField(this, "_entityTriggers", /* @__PURE__ */ new Map());
|
|
2182
|
+
this._dispatcher = dispatcher ?? new TriggerDispatcher();
|
|
1955
2183
|
}
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
2184
|
+
get dispatcher() {
|
|
2185
|
+
return this._dispatcher;
|
|
2186
|
+
}
|
|
2187
|
+
/**
|
|
2188
|
+
* @zh 为实体注册触发器
|
|
2189
|
+
* @en Register trigger for entity
|
|
2190
|
+
*/
|
|
2191
|
+
registerForEntity(entityId, trigger) {
|
|
2192
|
+
this._dispatcher.registry.register(trigger);
|
|
2193
|
+
if (!this._entityTriggers.has(entityId)) {
|
|
2194
|
+
this._entityTriggers.set(entityId, /* @__PURE__ */ new Set());
|
|
1960
2195
|
}
|
|
1961
|
-
|
|
1962
|
-
|
|
2196
|
+
this._entityTriggers.get(entityId).add(trigger.id);
|
|
2197
|
+
}
|
|
2198
|
+
/**
|
|
2199
|
+
* @zh 注销实体的触发器
|
|
2200
|
+
* @en Unregister trigger from entity
|
|
2201
|
+
*/
|
|
2202
|
+
unregisterFromEntity(entityId, triggerId) {
|
|
2203
|
+
const entitySet = this._entityTriggers.get(entityId);
|
|
2204
|
+
if (!entitySet) {
|
|
2205
|
+
return false;
|
|
1963
2206
|
}
|
|
1964
|
-
if (
|
|
1965
|
-
|
|
1966
|
-
results = results.filter((f) => f.name.toLowerCase().includes(searchLower) || f.description?.toLowerCase().includes(searchLower));
|
|
2207
|
+
if (!entitySet.has(triggerId)) {
|
|
2208
|
+
return false;
|
|
1967
2209
|
}
|
|
1968
|
-
|
|
2210
|
+
entitySet.delete(triggerId);
|
|
2211
|
+
return this._dispatcher.registry.unregister(triggerId);
|
|
1969
2212
|
}
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
2213
|
+
/**
|
|
2214
|
+
* @zh 获取实体的所有触发器
|
|
2215
|
+
* @en Get all triggers for entity
|
|
2216
|
+
*/
|
|
2217
|
+
getEntityTriggers(entityId) {
|
|
2218
|
+
const entitySet = this._entityTriggers.get(entityId);
|
|
2219
|
+
if (!entitySet) {
|
|
2220
|
+
return [];
|
|
1976
2221
|
}
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
if (fragment.tags) {
|
|
1983
|
-
for (const tag of fragment.tags) {
|
|
1984
|
-
tags.add(tag);
|
|
1985
|
-
}
|
|
2222
|
+
const triggers = [];
|
|
2223
|
+
for (const triggerId of entitySet) {
|
|
2224
|
+
const trigger = this._dispatcher.registry.get(triggerId);
|
|
2225
|
+
if (trigger) {
|
|
2226
|
+
triggers.push(trigger);
|
|
1986
2227
|
}
|
|
1987
2228
|
}
|
|
1988
|
-
return
|
|
2229
|
+
return triggers;
|
|
1989
2230
|
}
|
|
1990
|
-
|
|
1991
|
-
|
|
2231
|
+
/**
|
|
2232
|
+
* @zh 清除实体的所有触发器
|
|
2233
|
+
* @en Clear all triggers for entity
|
|
2234
|
+
*/
|
|
2235
|
+
clearEntityTriggers(entityId) {
|
|
2236
|
+
const entitySet = this._entityTriggers.get(entityId);
|
|
2237
|
+
if (!entitySet) {
|
|
2238
|
+
return;
|
|
2239
|
+
}
|
|
2240
|
+
for (const triggerId of entitySet) {
|
|
2241
|
+
this._dispatcher.registry.unregister(triggerId);
|
|
2242
|
+
}
|
|
2243
|
+
this._entityTriggers.delete(entityId);
|
|
1992
2244
|
}
|
|
1993
2245
|
/**
|
|
1994
|
-
* @zh
|
|
1995
|
-
* @en
|
|
2246
|
+
* @zh 调度触发器到实体
|
|
2247
|
+
* @en Dispatch trigger to entity
|
|
1996
2248
|
*/
|
|
1997
|
-
|
|
1998
|
-
|
|
2249
|
+
dispatchToEntity(entityId, context) {
|
|
2250
|
+
const entityTriggers = this.getEntityTriggers(entityId);
|
|
2251
|
+
const results = [];
|
|
2252
|
+
let triggeredCount = 0;
|
|
2253
|
+
for (const trigger of entityTriggers) {
|
|
2254
|
+
if (trigger.shouldFire(context)) {
|
|
2255
|
+
try {
|
|
2256
|
+
trigger.fire(context);
|
|
2257
|
+
triggeredCount++;
|
|
2258
|
+
results.push({
|
|
2259
|
+
triggerId: trigger.id,
|
|
2260
|
+
success: true
|
|
2261
|
+
});
|
|
2262
|
+
} catch (error) {
|
|
2263
|
+
results.push({
|
|
2264
|
+
triggerId: trigger.id,
|
|
2265
|
+
success: false,
|
|
2266
|
+
error: error instanceof Error ? error.message : String(error)
|
|
2267
|
+
});
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
return {
|
|
2272
|
+
context,
|
|
2273
|
+
triggeredCount,
|
|
2274
|
+
results
|
|
2275
|
+
};
|
|
1999
2276
|
}
|
|
2000
2277
|
};
|
|
2001
|
-
__name(
|
|
2002
|
-
var
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
return new FragmentRegistry();
|
|
2006
|
-
}
|
|
2007
|
-
__name(createFragmentRegistry, "createFragmentRegistry");
|
|
2008
|
-
|
|
2009
|
-
// src/registry/BlueprintDecorators.ts
|
|
2010
|
-
var registeredComponents = /* @__PURE__ */ new Map();
|
|
2011
|
-
function getRegisteredBlueprintComponents() {
|
|
2012
|
-
return registeredComponents;
|
|
2013
|
-
}
|
|
2014
|
-
__name(getRegisteredBlueprintComponents, "getRegisteredBlueprintComponents");
|
|
2015
|
-
function getBlueprintMetadata(componentClass) {
|
|
2016
|
-
return registeredComponents.get(componentClass);
|
|
2278
|
+
__name(_EntityTriggerManager, "EntityTriggerManager");
|
|
2279
|
+
var EntityTriggerManager = _EntityTriggerManager;
|
|
2280
|
+
function createTriggerDispatcher(registry) {
|
|
2281
|
+
return new TriggerDispatcher(registry);
|
|
2017
2282
|
}
|
|
2018
|
-
__name(
|
|
2019
|
-
function
|
|
2020
|
-
|
|
2283
|
+
__name(createTriggerDispatcher, "createTriggerDispatcher");
|
|
2284
|
+
function createEntityTriggerManager(dispatcher) {
|
|
2285
|
+
return new EntityTriggerManager(dispatcher);
|
|
2021
2286
|
}
|
|
2022
|
-
__name(
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2287
|
+
__name(createEntityTriggerManager, "createEntityTriggerManager");
|
|
2288
|
+
|
|
2289
|
+
// src/composition/BlueprintFragment.ts
|
|
2290
|
+
var _BlueprintFragment = class _BlueprintFragment {
|
|
2291
|
+
constructor(config) {
|
|
2292
|
+
__publicField(this, "id");
|
|
2293
|
+
__publicField(this, "name");
|
|
2294
|
+
__publicField(this, "description");
|
|
2295
|
+
__publicField(this, "category");
|
|
2296
|
+
__publicField(this, "tags");
|
|
2297
|
+
__publicField(this, "inputs");
|
|
2298
|
+
__publicField(this, "outputs");
|
|
2299
|
+
__publicField(this, "graph");
|
|
2300
|
+
__publicField(this, "version");
|
|
2301
|
+
__publicField(this, "icon");
|
|
2302
|
+
__publicField(this, "color");
|
|
2303
|
+
this.id = config.id;
|
|
2304
|
+
this.name = config.name;
|
|
2305
|
+
this.description = config.description;
|
|
2306
|
+
this.category = config.category;
|
|
2307
|
+
this.tags = config.tags;
|
|
2308
|
+
this.inputs = config.inputs ?? [];
|
|
2309
|
+
this.outputs = config.outputs ?? [];
|
|
2310
|
+
this.graph = config.graph;
|
|
2311
|
+
this.version = config.version;
|
|
2312
|
+
this.icon = config.icon;
|
|
2313
|
+
this.color = config.color;
|
|
2032
2314
|
}
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2315
|
+
/**
|
|
2316
|
+
* @zh 获取所有暴露引脚
|
|
2317
|
+
* @en Get all exposed pins
|
|
2318
|
+
*/
|
|
2319
|
+
getAllExposedPins() {
|
|
2320
|
+
return [
|
|
2321
|
+
...this.inputs,
|
|
2322
|
+
...this.outputs
|
|
2323
|
+
];
|
|
2324
|
+
}
|
|
2325
|
+
/**
|
|
2326
|
+
* @zh 通过名称查找输入引脚
|
|
2327
|
+
* @en Find input pin by name
|
|
2328
|
+
*/
|
|
2329
|
+
findInput(name) {
|
|
2330
|
+
return this.inputs.find((p) => p.name === name);
|
|
2331
|
+
}
|
|
2332
|
+
/**
|
|
2333
|
+
* @zh 通过名称查找输出引脚
|
|
2334
|
+
* @en Find output pin by name
|
|
2335
|
+
*/
|
|
2336
|
+
findOutput(name) {
|
|
2337
|
+
return this.outputs.find((p) => p.name === name);
|
|
2338
|
+
}
|
|
2339
|
+
};
|
|
2340
|
+
__name(_BlueprintFragment, "BlueprintFragment");
|
|
2341
|
+
var BlueprintFragment = _BlueprintFragment;
|
|
2342
|
+
function createExposedPin(name, type, direction, internalNodeId, internalPinName, options) {
|
|
2343
|
+
return {
|
|
2344
|
+
name,
|
|
2345
|
+
displayName: options?.displayName ?? name,
|
|
2346
|
+
type,
|
|
2347
|
+
direction,
|
|
2348
|
+
description: options?.description,
|
|
2349
|
+
defaultValue: options?.defaultValue,
|
|
2350
|
+
internalNodeId,
|
|
2351
|
+
internalPinName
|
|
2042
2352
|
};
|
|
2043
2353
|
}
|
|
2044
|
-
__name(
|
|
2045
|
-
function
|
|
2046
|
-
return
|
|
2047
|
-
const key = String(propertyKey);
|
|
2048
|
-
const metadata = getOrCreateMetadata(target.constructor);
|
|
2049
|
-
const propMeta = {
|
|
2050
|
-
propertyKey: key,
|
|
2051
|
-
displayName: options.displayName ?? key,
|
|
2052
|
-
description: options.description,
|
|
2053
|
-
pinType: options.type ?? "any",
|
|
2054
|
-
readonly: options.readonly ?? false,
|
|
2055
|
-
defaultValue: options.defaultValue
|
|
2056
|
-
};
|
|
2057
|
-
const existingIndex = metadata.properties.findIndex((p) => p.propertyKey === key);
|
|
2058
|
-
if (existingIndex >= 0) {
|
|
2059
|
-
metadata.properties[existingIndex] = propMeta;
|
|
2060
|
-
} else {
|
|
2061
|
-
metadata.properties.push(propMeta);
|
|
2062
|
-
}
|
|
2063
|
-
};
|
|
2354
|
+
__name(createExposedPin, "createExposedPin");
|
|
2355
|
+
function createFragment(config) {
|
|
2356
|
+
return new BlueprintFragment(config);
|
|
2064
2357
|
}
|
|
2065
|
-
__name(
|
|
2066
|
-
function
|
|
2067
|
-
return
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
methodKey: key,
|
|
2072
|
-
displayName: options.displayName ?? key,
|
|
2073
|
-
description: options.description,
|
|
2074
|
-
isPure: options.isPure ?? false,
|
|
2075
|
-
params: options.params ?? [],
|
|
2076
|
-
returnType: options.returnType ?? "any"
|
|
2077
|
-
};
|
|
2078
|
-
const existingIndex = metadata.methods.findIndex((m) => m.methodKey === key);
|
|
2079
|
-
if (existingIndex >= 0) {
|
|
2080
|
-
metadata.methods[existingIndex] = methodMeta;
|
|
2081
|
-
} else {
|
|
2082
|
-
metadata.methods.push(methodMeta);
|
|
2083
|
-
}
|
|
2084
|
-
return descriptor;
|
|
2085
|
-
};
|
|
2358
|
+
__name(createFragment, "createFragment");
|
|
2359
|
+
function fragmentFromAsset(asset) {
|
|
2360
|
+
return new BlueprintFragment({
|
|
2361
|
+
...asset.fragment,
|
|
2362
|
+
graph: asset.graph
|
|
2363
|
+
});
|
|
2086
2364
|
}
|
|
2087
|
-
__name(
|
|
2088
|
-
function
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
"void": "exec",
|
|
2106
|
-
"undefined": "exec"
|
|
2365
|
+
__name(fragmentFromAsset, "fragmentFromAsset");
|
|
2366
|
+
function fragmentToAsset(fragment) {
|
|
2367
|
+
return {
|
|
2368
|
+
version: 1,
|
|
2369
|
+
type: "blueprint-fragment",
|
|
2370
|
+
fragment: {
|
|
2371
|
+
id: fragment.id,
|
|
2372
|
+
name: fragment.name,
|
|
2373
|
+
description: fragment.description,
|
|
2374
|
+
category: fragment.category,
|
|
2375
|
+
tags: fragment.tags,
|
|
2376
|
+
inputs: fragment.inputs,
|
|
2377
|
+
outputs: fragment.outputs,
|
|
2378
|
+
version: fragment.version,
|
|
2379
|
+
icon: fragment.icon,
|
|
2380
|
+
color: fragment.color
|
|
2381
|
+
},
|
|
2382
|
+
graph: fragment.graph
|
|
2107
2383
|
};
|
|
2108
|
-
return typeMap[typeName] ?? "any";
|
|
2109
2384
|
}
|
|
2110
|
-
__name(
|
|
2385
|
+
__name(fragmentToAsset, "fragmentToAsset");
|
|
2111
2386
|
|
|
2112
|
-
// src/
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
if (!prop.readonly) {
|
|
2121
|
-
generatePropertySetNode(componentName, prop, category, color);
|
|
2122
|
-
}
|
|
2387
|
+
// src/composition/BlueprintComposer.ts
|
|
2388
|
+
var _BlueprintComposer = class _BlueprintComposer {
|
|
2389
|
+
constructor(name) {
|
|
2390
|
+
__publicField(this, "name");
|
|
2391
|
+
__publicField(this, "slots", /* @__PURE__ */ new Map());
|
|
2392
|
+
__publicField(this, "connections", /* @__PURE__ */ new Map());
|
|
2393
|
+
__publicField(this, "connectionIdCounter", 0);
|
|
2394
|
+
this.name = name;
|
|
2123
2395
|
}
|
|
2124
|
-
|
|
2125
|
-
|
|
2396
|
+
getSlots() {
|
|
2397
|
+
return Array.from(this.slots.values());
|
|
2126
2398
|
}
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
"component",
|
|
2142
|
-
componentName.toLowerCase()
|
|
2143
|
-
],
|
|
2144
|
-
menuPath: [
|
|
2145
|
-
"Components",
|
|
2146
|
-
displayName,
|
|
2147
|
-
`Get ${displayName}`
|
|
2148
|
-
],
|
|
2149
|
-
inputs: [
|
|
2150
|
-
{
|
|
2151
|
-
name: "entity",
|
|
2152
|
-
type: "entity",
|
|
2153
|
-
displayName: "Entity"
|
|
2399
|
+
getConnections() {
|
|
2400
|
+
return Array.from(this.connections.values());
|
|
2401
|
+
}
|
|
2402
|
+
addFragment(fragment, slotId, options) {
|
|
2403
|
+
if (this.slots.has(slotId)) {
|
|
2404
|
+
throw new Error(`Slot '${slotId}' already exists`);
|
|
2405
|
+
}
|
|
2406
|
+
const slot = {
|
|
2407
|
+
id: slotId,
|
|
2408
|
+
name: options?.name ?? fragment.name,
|
|
2409
|
+
fragment,
|
|
2410
|
+
position: options?.position ?? {
|
|
2411
|
+
x: 0,
|
|
2412
|
+
y: 0
|
|
2154
2413
|
}
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2414
|
+
};
|
|
2415
|
+
this.slots.set(slotId, slot);
|
|
2416
|
+
}
|
|
2417
|
+
removeSlot(slotId) {
|
|
2418
|
+
if (!this.slots.has(slotId)) {
|
|
2419
|
+
return;
|
|
2420
|
+
}
|
|
2421
|
+
const toRemove = [];
|
|
2422
|
+
for (const [id, conn] of this.connections) {
|
|
2423
|
+
if (conn.fromSlotId === slotId || conn.toSlotId === slotId) {
|
|
2424
|
+
toRemove.push(id);
|
|
2166
2425
|
}
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2426
|
+
}
|
|
2427
|
+
for (const id of toRemove) {
|
|
2428
|
+
this.connections.delete(id);
|
|
2429
|
+
}
|
|
2430
|
+
this.slots.delete(slotId);
|
|
2431
|
+
}
|
|
2432
|
+
connect(fromSlotId, fromPin, toSlotId, toPin) {
|
|
2433
|
+
const fromSlot = this.slots.get(fromSlotId);
|
|
2434
|
+
const toSlot = this.slots.get(toSlotId);
|
|
2435
|
+
if (!fromSlot) {
|
|
2436
|
+
throw new Error(`Source slot '${fromSlotId}' not found`);
|
|
2437
|
+
}
|
|
2438
|
+
if (!toSlot) {
|
|
2439
|
+
throw new Error(`Target slot '${toSlotId}' not found`);
|
|
2440
|
+
}
|
|
2441
|
+
const fromPinDef = fromSlot.fragment.outputs.find((p) => p.name === fromPin);
|
|
2442
|
+
const toPinDef = toSlot.fragment.inputs.find((p) => p.name === toPin);
|
|
2443
|
+
if (!fromPinDef) {
|
|
2444
|
+
throw new Error(`Output pin '${fromPin}' not found in slot '${fromSlotId}'`);
|
|
2445
|
+
}
|
|
2446
|
+
if (!toPinDef) {
|
|
2447
|
+
throw new Error(`Input pin '${toPin}' not found in slot '${toSlotId}'`);
|
|
2448
|
+
}
|
|
2449
|
+
const connectionId = `conn_${++this.connectionIdCounter}`;
|
|
2450
|
+
const connection = {
|
|
2451
|
+
id: connectionId,
|
|
2452
|
+
fromSlotId,
|
|
2453
|
+
fromPin,
|
|
2454
|
+
toSlotId,
|
|
2455
|
+
toPin
|
|
2456
|
+
};
|
|
2457
|
+
this.connections.set(connectionId, connection);
|
|
2458
|
+
}
|
|
2459
|
+
disconnect(connectionId) {
|
|
2460
|
+
this.connections.delete(connectionId);
|
|
2461
|
+
}
|
|
2462
|
+
validate() {
|
|
2463
|
+
const errors = [];
|
|
2464
|
+
const warnings = [];
|
|
2465
|
+
for (const slot of this.slots.values()) {
|
|
2466
|
+
for (const input of slot.fragment.inputs) {
|
|
2467
|
+
const hasConnection = Array.from(this.connections.values()).some((c) => c.toSlotId === slot.id && c.toPin === input.name);
|
|
2468
|
+
if (!hasConnection && input.defaultValue === void 0) {
|
|
2469
|
+
warnings.push({
|
|
2470
|
+
type: "unconnected-input",
|
|
2471
|
+
message: `Input '${input.name}' in slot '${slot.id}' is not connected`,
|
|
2472
|
+
slotId: slot.id,
|
|
2473
|
+
pinName: input.name
|
|
2474
|
+
});
|
|
2475
|
+
}
|
|
2179
2476
|
}
|
|
2180
|
-
const
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2477
|
+
for (const output of slot.fragment.outputs) {
|
|
2478
|
+
const hasConnection = Array.from(this.connections.values()).some((c) => c.fromSlotId === slot.id && c.fromPin === output.name);
|
|
2479
|
+
if (!hasConnection) {
|
|
2480
|
+
warnings.push({
|
|
2481
|
+
type: "unused-output",
|
|
2482
|
+
message: `Output '${output.name}' in slot '${slot.id}' is not connected`,
|
|
2483
|
+
slotId: slot.id,
|
|
2484
|
+
pinName: output.name
|
|
2485
|
+
});
|
|
2185
2486
|
}
|
|
2186
|
-
}
|
|
2487
|
+
}
|
|
2187
2488
|
}
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
title: `Get ${displayName}`,
|
|
2198
|
-
subtitle: componentName,
|
|
2199
|
-
category,
|
|
2200
|
-
color,
|
|
2201
|
-
isPure: true,
|
|
2202
|
-
description: prop.description ?? `Gets ${displayName} from ${componentName} (\u4ECE ${componentName} \u83B7\u53D6 ${displayName})`,
|
|
2203
|
-
keywords: [
|
|
2204
|
-
"get",
|
|
2205
|
-
"property",
|
|
2206
|
-
componentName.toLowerCase(),
|
|
2207
|
-
prop.propertyKey.toLowerCase()
|
|
2208
|
-
],
|
|
2209
|
-
menuPath: [
|
|
2210
|
-
"Components",
|
|
2211
|
-
componentName,
|
|
2212
|
-
`Get ${displayName}`
|
|
2213
|
-
],
|
|
2214
|
-
inputs: [
|
|
2215
|
-
{
|
|
2216
|
-
name: "component",
|
|
2217
|
-
type: "component",
|
|
2218
|
-
displayName: componentName
|
|
2489
|
+
for (const conn of this.connections.values()) {
|
|
2490
|
+
const fromSlot = this.slots.get(conn.fromSlotId);
|
|
2491
|
+
const toSlot = this.slots.get(conn.toSlotId);
|
|
2492
|
+
if (!fromSlot || !toSlot) {
|
|
2493
|
+
errors.push({
|
|
2494
|
+
type: "invalid-slot",
|
|
2495
|
+
message: `Invalid slot reference in connection '${conn.id}'`
|
|
2496
|
+
});
|
|
2497
|
+
continue;
|
|
2219
2498
|
}
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
{
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2499
|
+
const fromPinDef = fromSlot.fragment.outputs.find((p) => p.name === conn.fromPin);
|
|
2500
|
+
const toPinDef = toSlot.fragment.inputs.find((p) => p.name === conn.toPin);
|
|
2501
|
+
if (fromPinDef && toPinDef && fromPinDef.type !== toPinDef.type) {
|
|
2502
|
+
if (fromPinDef.type !== "any" && toPinDef.type !== "any") {
|
|
2503
|
+
errors.push({
|
|
2504
|
+
type: "type-mismatch",
|
|
2505
|
+
message: `Type mismatch: '${fromPinDef.type}' -> '${toPinDef.type}' in connection '${conn.id}'`
|
|
2506
|
+
});
|
|
2507
|
+
}
|
|
2226
2508
|
}
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2509
|
+
}
|
|
2510
|
+
return {
|
|
2511
|
+
isValid: errors.length === 0,
|
|
2512
|
+
errors,
|
|
2513
|
+
warnings
|
|
2514
|
+
};
|
|
2515
|
+
}
|
|
2516
|
+
compile() {
|
|
2517
|
+
const nodes = [];
|
|
2518
|
+
const connections = [];
|
|
2519
|
+
const variables = [];
|
|
2520
|
+
const nodeIdMap = /* @__PURE__ */ new Map();
|
|
2521
|
+
let nodeIdCounter = 0;
|
|
2522
|
+
for (const slot of this.slots.values()) {
|
|
2523
|
+
const slotNodeMap = /* @__PURE__ */ new Map();
|
|
2524
|
+
nodeIdMap.set(slot.id, slotNodeMap);
|
|
2525
|
+
for (const node of slot.fragment.graph.nodes) {
|
|
2526
|
+
const newNodeId = `node_${++nodeIdCounter}`;
|
|
2527
|
+
slotNodeMap.set(node.id, newNodeId);
|
|
2528
|
+
nodes.push({
|
|
2529
|
+
...node,
|
|
2530
|
+
id: newNodeId,
|
|
2531
|
+
position: {
|
|
2532
|
+
x: node.position.x + slot.position.x,
|
|
2533
|
+
y: node.position.y + slot.position.y
|
|
2238
2534
|
}
|
|
2239
|
-
};
|
|
2535
|
+
});
|
|
2240
2536
|
}
|
|
2241
|
-
const
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2537
|
+
for (const conn of slot.fragment.graph.connections) {
|
|
2538
|
+
const newFromId = slotNodeMap.get(conn.fromNodeId);
|
|
2539
|
+
const newToId = slotNodeMap.get(conn.toNodeId);
|
|
2540
|
+
if (newFromId && newToId) {
|
|
2541
|
+
connections.push({
|
|
2542
|
+
...conn,
|
|
2543
|
+
id: `conn_internal_${connections.length}`,
|
|
2544
|
+
fromNodeId: newFromId,
|
|
2545
|
+
toNodeId: newToId
|
|
2546
|
+
});
|
|
2245
2547
|
}
|
|
2246
|
-
};
|
|
2247
|
-
}
|
|
2248
|
-
};
|
|
2249
|
-
NodeRegistry.instance.register(template, executor);
|
|
2250
|
-
}
|
|
2251
|
-
__name(generatePropertyGetNode, "generatePropertyGetNode");
|
|
2252
|
-
function generatePropertySetNode(componentName, prop, category, color) {
|
|
2253
|
-
const nodeType = `Set_${componentName}_${prop.propertyKey}`;
|
|
2254
|
-
const { displayName, pinType, defaultValue } = prop;
|
|
2255
|
-
const template = {
|
|
2256
|
-
type: nodeType,
|
|
2257
|
-
title: `Set ${displayName}`,
|
|
2258
|
-
subtitle: componentName,
|
|
2259
|
-
category,
|
|
2260
|
-
color,
|
|
2261
|
-
description: prop.description ?? `Sets ${displayName} on ${componentName} (\u8BBE\u7F6E ${componentName} \u7684 ${displayName})`,
|
|
2262
|
-
keywords: [
|
|
2263
|
-
"set",
|
|
2264
|
-
"property",
|
|
2265
|
-
componentName.toLowerCase(),
|
|
2266
|
-
prop.propertyKey.toLowerCase()
|
|
2267
|
-
],
|
|
2268
|
-
menuPath: [
|
|
2269
|
-
"Components",
|
|
2270
|
-
componentName,
|
|
2271
|
-
`Set ${displayName}`
|
|
2272
|
-
],
|
|
2273
|
-
inputs: [
|
|
2274
|
-
{
|
|
2275
|
-
name: "exec",
|
|
2276
|
-
type: "exec",
|
|
2277
|
-
displayName: ""
|
|
2278
|
-
},
|
|
2279
|
-
{
|
|
2280
|
-
name: "component",
|
|
2281
|
-
type: "component",
|
|
2282
|
-
displayName: componentName
|
|
2283
|
-
},
|
|
2284
|
-
{
|
|
2285
|
-
name: "value",
|
|
2286
|
-
type: pinType,
|
|
2287
|
-
displayName,
|
|
2288
|
-
defaultValue
|
|
2289
2548
|
}
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
displayName: ""
|
|
2549
|
+
for (const variable of slot.fragment.graph.variables) {
|
|
2550
|
+
variables.push({
|
|
2551
|
+
...variable,
|
|
2552
|
+
name: `${slot.id}_${variable.name}`
|
|
2553
|
+
});
|
|
2296
2554
|
}
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
const
|
|
2303
|
-
const
|
|
2304
|
-
if (
|
|
2305
|
-
|
|
2555
|
+
}
|
|
2556
|
+
for (const slotConn of this.connections.values()) {
|
|
2557
|
+
const fromSlot = this.slots.get(slotConn.fromSlotId);
|
|
2558
|
+
const toSlot = this.slots.get(slotConn.toSlotId);
|
|
2559
|
+
if (!fromSlot || !toSlot) continue;
|
|
2560
|
+
const fromPinDef = fromSlot.fragment.outputs.find((p) => p.name === slotConn.fromPin);
|
|
2561
|
+
const toPinDef = toSlot.fragment.inputs.find((p) => p.name === slotConn.toPin);
|
|
2562
|
+
if (!fromPinDef || !toPinDef) continue;
|
|
2563
|
+
const fromNodeMap = nodeIdMap.get(slotConn.fromSlotId);
|
|
2564
|
+
const toNodeMap = nodeIdMap.get(slotConn.toSlotId);
|
|
2565
|
+
if (!fromNodeMap || !toNodeMap) continue;
|
|
2566
|
+
const fromNodeId = fromNodeMap.get(fromPinDef.internalNodeId);
|
|
2567
|
+
const toNodeId = toNodeMap.get(toPinDef.internalNodeId);
|
|
2568
|
+
if (fromNodeId && toNodeId) {
|
|
2569
|
+
connections.push({
|
|
2570
|
+
id: `conn_slot_${connections.length}`,
|
|
2571
|
+
fromNodeId,
|
|
2572
|
+
fromPin: fromPinDef.internalPinName,
|
|
2573
|
+
toNodeId,
|
|
2574
|
+
toPin: toPinDef.internalPinName
|
|
2575
|
+
});
|
|
2306
2576
|
}
|
|
2307
|
-
return {
|
|
2308
|
-
nextExec: "exec"
|
|
2309
|
-
};
|
|
2310
2577
|
}
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
});
|
|
2325
|
-
}
|
|
2326
|
-
inputs.push({
|
|
2327
|
-
name: "component",
|
|
2328
|
-
type: "component",
|
|
2329
|
-
displayName: componentName
|
|
2330
|
-
});
|
|
2331
|
-
const paramNames = [];
|
|
2332
|
-
for (const param of params) {
|
|
2333
|
-
inputs.push({
|
|
2334
|
-
name: param.name,
|
|
2335
|
-
type: param.type ?? "any",
|
|
2336
|
-
displayName: param.displayName ?? param.name,
|
|
2337
|
-
defaultValue: param.defaultValue
|
|
2338
|
-
});
|
|
2339
|
-
paramNames.push(param.name);
|
|
2340
|
-
}
|
|
2341
|
-
const outputs = [];
|
|
2342
|
-
if (!isPure) {
|
|
2343
|
-
outputs.push({
|
|
2344
|
-
name: "exec",
|
|
2345
|
-
type: "exec",
|
|
2346
|
-
displayName: ""
|
|
2347
|
-
});
|
|
2578
|
+
return {
|
|
2579
|
+
version: 1,
|
|
2580
|
+
type: "blueprint",
|
|
2581
|
+
metadata: {
|
|
2582
|
+
name: this.name,
|
|
2583
|
+
description: `Composed from ${this.slots.size} fragments`,
|
|
2584
|
+
createdAt: Date.now(),
|
|
2585
|
+
modifiedAt: Date.now()
|
|
2586
|
+
},
|
|
2587
|
+
variables,
|
|
2588
|
+
nodes,
|
|
2589
|
+
connections
|
|
2590
|
+
};
|
|
2348
2591
|
}
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
displayName: "Result"
|
|
2354
|
-
});
|
|
2592
|
+
clear() {
|
|
2593
|
+
this.slots.clear();
|
|
2594
|
+
this.connections.clear();
|
|
2595
|
+
this.connectionIdCounter = 0;
|
|
2355
2596
|
}
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
}
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2597
|
+
};
|
|
2598
|
+
__name(_BlueprintComposer, "BlueprintComposer");
|
|
2599
|
+
var BlueprintComposer = _BlueprintComposer;
|
|
2600
|
+
function createComposer(name) {
|
|
2601
|
+
return new BlueprintComposer(name);
|
|
2602
|
+
}
|
|
2603
|
+
__name(createComposer, "createComposer");
|
|
2604
|
+
|
|
2605
|
+
// src/composition/FragmentRegistry.ts
|
|
2606
|
+
var _FragmentRegistry = class _FragmentRegistry {
|
|
2607
|
+
constructor() {
|
|
2608
|
+
__publicField(this, "fragments", /* @__PURE__ */ new Map());
|
|
2609
|
+
}
|
|
2610
|
+
register(fragment) {
|
|
2611
|
+
if (this.fragments.has(fragment.id)) {
|
|
2612
|
+
console.warn(`Fragment '${fragment.id}' already registered, overwriting`);
|
|
2613
|
+
}
|
|
2614
|
+
this.fragments.set(fragment.id, fragment);
|
|
2615
|
+
}
|
|
2616
|
+
unregister(id) {
|
|
2617
|
+
this.fragments.delete(id);
|
|
2618
|
+
}
|
|
2619
|
+
get(id) {
|
|
2620
|
+
return this.fragments.get(id);
|
|
2621
|
+
}
|
|
2622
|
+
has(id) {
|
|
2623
|
+
return this.fragments.has(id);
|
|
2624
|
+
}
|
|
2625
|
+
getAll() {
|
|
2626
|
+
return Array.from(this.fragments.values());
|
|
2627
|
+
}
|
|
2628
|
+
filter(filter) {
|
|
2629
|
+
let results = this.getAll();
|
|
2630
|
+
if (filter.category) {
|
|
2631
|
+
results = results.filter((f) => f.category === filter.category);
|
|
2632
|
+
}
|
|
2633
|
+
if (filter.tags && filter.tags.length > 0) {
|
|
2634
|
+
results = results.filter((f) => f.tags && filter.tags.some((t) => f.tags.includes(t)));
|
|
2635
|
+
}
|
|
2636
|
+
if (filter.search) {
|
|
2637
|
+
const searchLower = filter.search.toLowerCase();
|
|
2638
|
+
results = results.filter((f) => f.name.toLowerCase().includes(searchLower) || f.description?.toLowerCase().includes(searchLower));
|
|
2639
|
+
}
|
|
2640
|
+
return results;
|
|
2641
|
+
}
|
|
2642
|
+
getCategories() {
|
|
2643
|
+
const categories = /* @__PURE__ */ new Set();
|
|
2644
|
+
for (const fragment of this.fragments.values()) {
|
|
2645
|
+
if (fragment.category) {
|
|
2646
|
+
categories.add(fragment.category);
|
|
2402
2647
|
}
|
|
2403
|
-
const result = fn.apply(component, args);
|
|
2404
|
-
return isPure ? {
|
|
2405
|
-
outputs: {
|
|
2406
|
-
result
|
|
2407
|
-
}
|
|
2408
|
-
} : {
|
|
2409
|
-
outputs: {
|
|
2410
|
-
result
|
|
2411
|
-
},
|
|
2412
|
-
nextExec: "exec"
|
|
2413
|
-
};
|
|
2414
2648
|
}
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
} catch (error) {
|
|
2426
|
-
console.error(`[Blueprint] Failed to register component ${metadata.componentName}:`, error);
|
|
2649
|
+
return Array.from(categories).sort();
|
|
2650
|
+
}
|
|
2651
|
+
getTags() {
|
|
2652
|
+
const tags = /* @__PURE__ */ new Set();
|
|
2653
|
+
for (const fragment of this.fragments.values()) {
|
|
2654
|
+
if (fragment.tags) {
|
|
2655
|
+
for (const tag of fragment.tags) {
|
|
2656
|
+
tags.add(tag);
|
|
2657
|
+
}
|
|
2658
|
+
}
|
|
2427
2659
|
}
|
|
2660
|
+
return Array.from(tags).sort();
|
|
2428
2661
|
}
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
__name(registerAllComponentNodes, "registerAllComponentNodes");
|
|
2432
|
-
function registerComponentNodes(componentClass) {
|
|
2433
|
-
const components = getRegisteredBlueprintComponents();
|
|
2434
|
-
const metadata = components.get(componentClass);
|
|
2435
|
-
if (!metadata) {
|
|
2436
|
-
console.warn(`[Blueprint] Component ${componentClass.name} is not marked with @BlueprintExpose`);
|
|
2437
|
-
return;
|
|
2662
|
+
clear() {
|
|
2663
|
+
this.fragments.clear();
|
|
2438
2664
|
}
|
|
2439
|
-
|
|
2665
|
+
/**
|
|
2666
|
+
* @zh 获取片段数量
|
|
2667
|
+
* @en Get fragment count
|
|
2668
|
+
*/
|
|
2669
|
+
get size() {
|
|
2670
|
+
return this.fragments.size;
|
|
2671
|
+
}
|
|
2672
|
+
};
|
|
2673
|
+
__name(_FragmentRegistry, "FragmentRegistry");
|
|
2674
|
+
var FragmentRegistry = _FragmentRegistry;
|
|
2675
|
+
var defaultFragmentRegistry = new FragmentRegistry();
|
|
2676
|
+
function createFragmentRegistry() {
|
|
2677
|
+
return new FragmentRegistry();
|
|
2440
2678
|
}
|
|
2441
|
-
__name(
|
|
2679
|
+
__name(createFragmentRegistry, "createFragmentRegistry");
|
|
2442
2680
|
|
|
2443
2681
|
// src/nodes/events/EventBeginPlay.ts
|
|
2444
|
-
function
|
|
2682
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
2445
2683
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2446
2684
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2447
2685
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2448
2686
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2449
2687
|
}
|
|
2450
|
-
__name(
|
|
2688
|
+
__name(_ts_decorate3, "_ts_decorate");
|
|
2451
2689
|
var EventBeginPlayTemplate = {
|
|
2452
2690
|
type: "EventBeginPlay",
|
|
2453
2691
|
title: "Event Begin Play",
|
|
@@ -2458,7 +2696,12 @@ var EventBeginPlayTemplate = {
|
|
|
2458
2696
|
"start",
|
|
2459
2697
|
"begin",
|
|
2460
2698
|
"init",
|
|
2461
|
-
"event"
|
|
2699
|
+
"event",
|
|
2700
|
+
"self"
|
|
2701
|
+
],
|
|
2702
|
+
menuPath: [
|
|
2703
|
+
"Events",
|
|
2704
|
+
"Begin Play"
|
|
2462
2705
|
],
|
|
2463
2706
|
inputs: [],
|
|
2464
2707
|
outputs: [
|
|
@@ -2466,30 +2709,38 @@ var EventBeginPlayTemplate = {
|
|
|
2466
2709
|
name: "exec",
|
|
2467
2710
|
type: "exec",
|
|
2468
2711
|
displayName: ""
|
|
2712
|
+
},
|
|
2713
|
+
{
|
|
2714
|
+
name: "self",
|
|
2715
|
+
type: "entity",
|
|
2716
|
+
displayName: "Self"
|
|
2469
2717
|
}
|
|
2470
2718
|
]
|
|
2471
2719
|
};
|
|
2472
2720
|
var _EventBeginPlayExecutor = class _EventBeginPlayExecutor {
|
|
2473
|
-
execute(_node,
|
|
2721
|
+
execute(_node, context) {
|
|
2474
2722
|
return {
|
|
2475
|
-
nextExec: "exec"
|
|
2723
|
+
nextExec: "exec",
|
|
2724
|
+
outputs: {
|
|
2725
|
+
self: context.entity
|
|
2726
|
+
}
|
|
2476
2727
|
};
|
|
2477
2728
|
}
|
|
2478
2729
|
};
|
|
2479
2730
|
__name(_EventBeginPlayExecutor, "EventBeginPlayExecutor");
|
|
2480
2731
|
var EventBeginPlayExecutor = _EventBeginPlayExecutor;
|
|
2481
|
-
EventBeginPlayExecutor =
|
|
2732
|
+
EventBeginPlayExecutor = _ts_decorate3([
|
|
2482
2733
|
RegisterNode(EventBeginPlayTemplate)
|
|
2483
2734
|
], EventBeginPlayExecutor);
|
|
2484
2735
|
|
|
2485
2736
|
// src/nodes/events/EventTick.ts
|
|
2486
|
-
function
|
|
2737
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
2487
2738
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2488
2739
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2489
2740
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2490
2741
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2491
2742
|
}
|
|
2492
|
-
__name(
|
|
2743
|
+
__name(_ts_decorate4, "_ts_decorate");
|
|
2493
2744
|
var EventTickTemplate = {
|
|
2494
2745
|
type: "EventTick",
|
|
2495
2746
|
title: "Event Tick",
|
|
@@ -2500,7 +2751,12 @@ var EventTickTemplate = {
|
|
|
2500
2751
|
"update",
|
|
2501
2752
|
"frame",
|
|
2502
2753
|
"tick",
|
|
2503
|
-
"event"
|
|
2754
|
+
"event",
|
|
2755
|
+
"self"
|
|
2756
|
+
],
|
|
2757
|
+
menuPath: [
|
|
2758
|
+
"Events",
|
|
2759
|
+
"Tick"
|
|
2504
2760
|
],
|
|
2505
2761
|
inputs: [],
|
|
2506
2762
|
outputs: [
|
|
@@ -2509,6 +2765,11 @@ var EventTickTemplate = {
|
|
|
2509
2765
|
type: "exec",
|
|
2510
2766
|
displayName: ""
|
|
2511
2767
|
},
|
|
2768
|
+
{
|
|
2769
|
+
name: "self",
|
|
2770
|
+
type: "entity",
|
|
2771
|
+
displayName: "Self"
|
|
2772
|
+
},
|
|
2512
2773
|
{
|
|
2513
2774
|
name: "deltaTime",
|
|
2514
2775
|
type: "float",
|
|
@@ -2521,6 +2782,7 @@ var _EventTickExecutor = class _EventTickExecutor {
|
|
|
2521
2782
|
return {
|
|
2522
2783
|
nextExec: "exec",
|
|
2523
2784
|
outputs: {
|
|
2785
|
+
self: context.entity,
|
|
2524
2786
|
deltaTime: context.deltaTime
|
|
2525
2787
|
}
|
|
2526
2788
|
};
|
|
@@ -2528,18 +2790,18 @@ var _EventTickExecutor = class _EventTickExecutor {
|
|
|
2528
2790
|
};
|
|
2529
2791
|
__name(_EventTickExecutor, "EventTickExecutor");
|
|
2530
2792
|
var EventTickExecutor = _EventTickExecutor;
|
|
2531
|
-
EventTickExecutor =
|
|
2793
|
+
EventTickExecutor = _ts_decorate4([
|
|
2532
2794
|
RegisterNode(EventTickTemplate)
|
|
2533
2795
|
], EventTickExecutor);
|
|
2534
2796
|
|
|
2535
2797
|
// src/nodes/events/EventEndPlay.ts
|
|
2536
|
-
function
|
|
2798
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
2537
2799
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2538
2800
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2539
2801
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2540
2802
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2541
2803
|
}
|
|
2542
|
-
__name(
|
|
2804
|
+
__name(_ts_decorate5, "_ts_decorate");
|
|
2543
2805
|
var EventEndPlayTemplate = {
|
|
2544
2806
|
type: "EventEndPlay",
|
|
2545
2807
|
title: "Event End Play",
|
|
@@ -2550,7 +2812,12 @@ var EventEndPlayTemplate = {
|
|
|
2550
2812
|
"stop",
|
|
2551
2813
|
"end",
|
|
2552
2814
|
"destroy",
|
|
2553
|
-
"event"
|
|
2815
|
+
"event",
|
|
2816
|
+
"self"
|
|
2817
|
+
],
|
|
2818
|
+
menuPath: [
|
|
2819
|
+
"Events",
|
|
2820
|
+
"End Play"
|
|
2554
2821
|
],
|
|
2555
2822
|
inputs: [],
|
|
2556
2823
|
outputs: [
|
|
@@ -2558,30 +2825,38 @@ var EventEndPlayTemplate = {
|
|
|
2558
2825
|
name: "exec",
|
|
2559
2826
|
type: "exec",
|
|
2560
2827
|
displayName: ""
|
|
2828
|
+
},
|
|
2829
|
+
{
|
|
2830
|
+
name: "self",
|
|
2831
|
+
type: "entity",
|
|
2832
|
+
displayName: "Self"
|
|
2561
2833
|
}
|
|
2562
2834
|
]
|
|
2563
2835
|
};
|
|
2564
2836
|
var _EventEndPlayExecutor = class _EventEndPlayExecutor {
|
|
2565
|
-
execute(_node,
|
|
2837
|
+
execute(_node, context) {
|
|
2566
2838
|
return {
|
|
2567
|
-
nextExec: "exec"
|
|
2839
|
+
nextExec: "exec",
|
|
2840
|
+
outputs: {
|
|
2841
|
+
self: context.entity
|
|
2842
|
+
}
|
|
2568
2843
|
};
|
|
2569
2844
|
}
|
|
2570
2845
|
};
|
|
2571
2846
|
__name(_EventEndPlayExecutor, "EventEndPlayExecutor");
|
|
2572
2847
|
var EventEndPlayExecutor = _EventEndPlayExecutor;
|
|
2573
|
-
EventEndPlayExecutor =
|
|
2848
|
+
EventEndPlayExecutor = _ts_decorate5([
|
|
2574
2849
|
RegisterNode(EventEndPlayTemplate)
|
|
2575
2850
|
], EventEndPlayExecutor);
|
|
2576
2851
|
|
|
2577
2852
|
// src/nodes/ecs/EntityNodes.ts
|
|
2578
|
-
function
|
|
2853
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
2579
2854
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2580
2855
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2581
2856
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2582
2857
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2583
2858
|
}
|
|
2584
|
-
__name(
|
|
2859
|
+
__name(_ts_decorate6, "_ts_decorate");
|
|
2585
2860
|
var GetSelfTemplate = {
|
|
2586
2861
|
type: "ECS_GetSelf",
|
|
2587
2862
|
title: "Get Self",
|
|
@@ -2621,7 +2896,7 @@ var _GetSelfExecutor = class _GetSelfExecutor {
|
|
|
2621
2896
|
};
|
|
2622
2897
|
__name(_GetSelfExecutor, "GetSelfExecutor");
|
|
2623
2898
|
var GetSelfExecutor = _GetSelfExecutor;
|
|
2624
|
-
GetSelfExecutor =
|
|
2899
|
+
GetSelfExecutor = _ts_decorate6([
|
|
2625
2900
|
RegisterNode(GetSelfTemplate)
|
|
2626
2901
|
], GetSelfExecutor);
|
|
2627
2902
|
var CreateEntityTemplate = {
|
|
@@ -2682,7 +2957,7 @@ var _CreateEntityExecutor = class _CreateEntityExecutor {
|
|
|
2682
2957
|
};
|
|
2683
2958
|
__name(_CreateEntityExecutor, "CreateEntityExecutor");
|
|
2684
2959
|
var CreateEntityExecutor = _CreateEntityExecutor;
|
|
2685
|
-
CreateEntityExecutor =
|
|
2960
|
+
CreateEntityExecutor = _ts_decorate6([
|
|
2686
2961
|
RegisterNode(CreateEntityTemplate)
|
|
2687
2962
|
], CreateEntityExecutor);
|
|
2688
2963
|
var DestroyEntityTemplate = {
|
|
@@ -2736,7 +3011,7 @@ var _DestroyEntityExecutor = class _DestroyEntityExecutor {
|
|
|
2736
3011
|
};
|
|
2737
3012
|
__name(_DestroyEntityExecutor, "DestroyEntityExecutor");
|
|
2738
3013
|
var DestroyEntityExecutor = _DestroyEntityExecutor;
|
|
2739
|
-
DestroyEntityExecutor =
|
|
3014
|
+
DestroyEntityExecutor = _ts_decorate6([
|
|
2740
3015
|
RegisterNode(DestroyEntityTemplate)
|
|
2741
3016
|
], DestroyEntityExecutor);
|
|
2742
3017
|
var DestroySelfTemplate = {
|
|
@@ -2778,7 +3053,7 @@ var _DestroySelfExecutor = class _DestroySelfExecutor {
|
|
|
2778
3053
|
};
|
|
2779
3054
|
__name(_DestroySelfExecutor, "DestroySelfExecutor");
|
|
2780
3055
|
var DestroySelfExecutor = _DestroySelfExecutor;
|
|
2781
|
-
DestroySelfExecutor =
|
|
3056
|
+
DestroySelfExecutor = _ts_decorate6([
|
|
2782
3057
|
RegisterNode(DestroySelfTemplate)
|
|
2783
3058
|
], DestroySelfExecutor);
|
|
2784
3059
|
var IsValidTemplate = {
|
|
@@ -2829,7 +3104,7 @@ var _IsValidExecutor = class _IsValidExecutor {
|
|
|
2829
3104
|
};
|
|
2830
3105
|
__name(_IsValidExecutor, "IsValidExecutor");
|
|
2831
3106
|
var IsValidExecutor = _IsValidExecutor;
|
|
2832
|
-
IsValidExecutor =
|
|
3107
|
+
IsValidExecutor = _ts_decorate6([
|
|
2833
3108
|
RegisterNode(IsValidTemplate)
|
|
2834
3109
|
], IsValidExecutor);
|
|
2835
3110
|
var GetEntityNameTemplate = {
|
|
@@ -2877,7 +3152,7 @@ var _GetEntityNameExecutor = class _GetEntityNameExecutor {
|
|
|
2877
3152
|
};
|
|
2878
3153
|
__name(_GetEntityNameExecutor, "GetEntityNameExecutor");
|
|
2879
3154
|
var GetEntityNameExecutor = _GetEntityNameExecutor;
|
|
2880
|
-
GetEntityNameExecutor =
|
|
3155
|
+
GetEntityNameExecutor = _ts_decorate6([
|
|
2881
3156
|
RegisterNode(GetEntityNameTemplate)
|
|
2882
3157
|
], GetEntityNameExecutor);
|
|
2883
3158
|
var SetEntityNameTemplate = {
|
|
@@ -2937,7 +3212,7 @@ var _SetEntityNameExecutor = class _SetEntityNameExecutor {
|
|
|
2937
3212
|
};
|
|
2938
3213
|
__name(_SetEntityNameExecutor, "SetEntityNameExecutor");
|
|
2939
3214
|
var SetEntityNameExecutor = _SetEntityNameExecutor;
|
|
2940
|
-
SetEntityNameExecutor =
|
|
3215
|
+
SetEntityNameExecutor = _ts_decorate6([
|
|
2941
3216
|
RegisterNode(SetEntityNameTemplate)
|
|
2942
3217
|
], SetEntityNameExecutor);
|
|
2943
3218
|
var GetEntityTagTemplate = {
|
|
@@ -2985,7 +3260,7 @@ var _GetEntityTagExecutor = class _GetEntityTagExecutor {
|
|
|
2985
3260
|
};
|
|
2986
3261
|
__name(_GetEntityTagExecutor, "GetEntityTagExecutor");
|
|
2987
3262
|
var GetEntityTagExecutor = _GetEntityTagExecutor;
|
|
2988
|
-
GetEntityTagExecutor =
|
|
3263
|
+
GetEntityTagExecutor = _ts_decorate6([
|
|
2989
3264
|
RegisterNode(GetEntityTagTemplate)
|
|
2990
3265
|
], GetEntityTagExecutor);
|
|
2991
3266
|
var SetEntityTagTemplate = {
|
|
@@ -3045,7 +3320,7 @@ var _SetEntityTagExecutor = class _SetEntityTagExecutor {
|
|
|
3045
3320
|
};
|
|
3046
3321
|
__name(_SetEntityTagExecutor, "SetEntityTagExecutor");
|
|
3047
3322
|
var SetEntityTagExecutor = _SetEntityTagExecutor;
|
|
3048
|
-
SetEntityTagExecutor =
|
|
3323
|
+
SetEntityTagExecutor = _ts_decorate6([
|
|
3049
3324
|
RegisterNode(SetEntityTagTemplate)
|
|
3050
3325
|
], SetEntityTagExecutor);
|
|
3051
3326
|
var SetEntityActiveTemplate = {
|
|
@@ -3106,7 +3381,7 @@ var _SetEntityActiveExecutor = class _SetEntityActiveExecutor {
|
|
|
3106
3381
|
};
|
|
3107
3382
|
__name(_SetEntityActiveExecutor, "SetEntityActiveExecutor");
|
|
3108
3383
|
var SetEntityActiveExecutor = _SetEntityActiveExecutor;
|
|
3109
|
-
SetEntityActiveExecutor =
|
|
3384
|
+
SetEntityActiveExecutor = _ts_decorate6([
|
|
3110
3385
|
RegisterNode(SetEntityActiveTemplate)
|
|
3111
3386
|
], SetEntityActiveExecutor);
|
|
3112
3387
|
var IsEntityActiveTemplate = {
|
|
@@ -3154,7 +3429,7 @@ var _IsEntityActiveExecutor = class _IsEntityActiveExecutor {
|
|
|
3154
3429
|
};
|
|
3155
3430
|
__name(_IsEntityActiveExecutor, "IsEntityActiveExecutor");
|
|
3156
3431
|
var IsEntityActiveExecutor = _IsEntityActiveExecutor;
|
|
3157
|
-
IsEntityActiveExecutor =
|
|
3432
|
+
IsEntityActiveExecutor = _ts_decorate6([
|
|
3158
3433
|
RegisterNode(IsEntityActiveTemplate)
|
|
3159
3434
|
], IsEntityActiveExecutor);
|
|
3160
3435
|
var FindEntityByNameTemplate = {
|
|
@@ -3212,7 +3487,7 @@ var _FindEntityByNameExecutor = class _FindEntityByNameExecutor {
|
|
|
3212
3487
|
};
|
|
3213
3488
|
__name(_FindEntityByNameExecutor, "FindEntityByNameExecutor");
|
|
3214
3489
|
var FindEntityByNameExecutor = _FindEntityByNameExecutor;
|
|
3215
|
-
FindEntityByNameExecutor =
|
|
3490
|
+
FindEntityByNameExecutor = _ts_decorate6([
|
|
3216
3491
|
RegisterNode(FindEntityByNameTemplate)
|
|
3217
3492
|
], FindEntityByNameExecutor);
|
|
3218
3493
|
var FindEntitiesByTagTemplate = {
|
|
@@ -3271,7 +3546,7 @@ var _FindEntitiesByTagExecutor = class _FindEntitiesByTagExecutor {
|
|
|
3271
3546
|
};
|
|
3272
3547
|
__name(_FindEntitiesByTagExecutor, "FindEntitiesByTagExecutor");
|
|
3273
3548
|
var FindEntitiesByTagExecutor = _FindEntitiesByTagExecutor;
|
|
3274
|
-
FindEntitiesByTagExecutor =
|
|
3549
|
+
FindEntitiesByTagExecutor = _ts_decorate6([
|
|
3275
3550
|
RegisterNode(FindEntitiesByTagTemplate)
|
|
3276
3551
|
], FindEntitiesByTagExecutor);
|
|
3277
3552
|
var GetEntityIdTemplate = {
|
|
@@ -3319,7 +3594,7 @@ var _GetEntityIdExecutor = class _GetEntityIdExecutor {
|
|
|
3319
3594
|
};
|
|
3320
3595
|
__name(_GetEntityIdExecutor, "GetEntityIdExecutor");
|
|
3321
3596
|
var GetEntityIdExecutor = _GetEntityIdExecutor;
|
|
3322
|
-
GetEntityIdExecutor =
|
|
3597
|
+
GetEntityIdExecutor = _ts_decorate6([
|
|
3323
3598
|
RegisterNode(GetEntityIdTemplate)
|
|
3324
3599
|
], GetEntityIdExecutor);
|
|
3325
3600
|
var FindEntityByIdTemplate = {
|
|
@@ -3359,34 +3634,148 @@ var FindEntityByIdTemplate = {
|
|
|
3359
3634
|
type: "bool",
|
|
3360
3635
|
displayName: "Found"
|
|
3361
3636
|
}
|
|
3362
|
-
]
|
|
3363
|
-
};
|
|
3364
|
-
var _FindEntityByIdExecutor = class _FindEntityByIdExecutor {
|
|
3365
|
-
execute(node, context) {
|
|
3366
|
-
const id = context.evaluateInput(node.id, "id", 0);
|
|
3367
|
-
const entity = context.scene.findEntityById(id);
|
|
3368
|
-
return {
|
|
3369
|
-
outputs: {
|
|
3370
|
-
entity: entity ?? null,
|
|
3371
|
-
found: entity != null
|
|
3372
|
-
}
|
|
3373
|
-
};
|
|
3637
|
+
]
|
|
3638
|
+
};
|
|
3639
|
+
var _FindEntityByIdExecutor = class _FindEntityByIdExecutor {
|
|
3640
|
+
execute(node, context) {
|
|
3641
|
+
const id = context.evaluateInput(node.id, "id", 0);
|
|
3642
|
+
const entity = context.scene.findEntityById(id);
|
|
3643
|
+
return {
|
|
3644
|
+
outputs: {
|
|
3645
|
+
entity: entity ?? null,
|
|
3646
|
+
found: entity != null
|
|
3647
|
+
}
|
|
3648
|
+
};
|
|
3649
|
+
}
|
|
3650
|
+
};
|
|
3651
|
+
__name(_FindEntityByIdExecutor, "FindEntityByIdExecutor");
|
|
3652
|
+
var FindEntityByIdExecutor = _FindEntityByIdExecutor;
|
|
3653
|
+
FindEntityByIdExecutor = _ts_decorate6([
|
|
3654
|
+
RegisterNode(FindEntityByIdTemplate)
|
|
3655
|
+
], FindEntityByIdExecutor);
|
|
3656
|
+
|
|
3657
|
+
// src/nodes/ecs/ComponentNodes.ts
|
|
3658
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
3659
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3660
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3661
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3662
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3663
|
+
}
|
|
3664
|
+
__name(_ts_decorate7, "_ts_decorate");
|
|
3665
|
+
var AddComponentTemplate = {
|
|
3666
|
+
type: "ECS_AddComponent",
|
|
3667
|
+
title: "Add Component",
|
|
3668
|
+
category: "component",
|
|
3669
|
+
color: "#1e8b8b",
|
|
3670
|
+
description: "Adds a component to an entity by type name (\u6309\u7C7B\u578B\u540D\u79F0\u4E3A\u5B9E\u4F53\u6DFB\u52A0\u7EC4\u4EF6)",
|
|
3671
|
+
keywords: [
|
|
3672
|
+
"component",
|
|
3673
|
+
"add",
|
|
3674
|
+
"create",
|
|
3675
|
+
"attach"
|
|
3676
|
+
],
|
|
3677
|
+
menuPath: [
|
|
3678
|
+
"ECS",
|
|
3679
|
+
"Component",
|
|
3680
|
+
"Add Component"
|
|
3681
|
+
],
|
|
3682
|
+
inputs: [
|
|
3683
|
+
{
|
|
3684
|
+
name: "exec",
|
|
3685
|
+
type: "exec",
|
|
3686
|
+
displayName: ""
|
|
3687
|
+
},
|
|
3688
|
+
{
|
|
3689
|
+
name: "entity",
|
|
3690
|
+
type: "entity",
|
|
3691
|
+
displayName: "Entity"
|
|
3692
|
+
},
|
|
3693
|
+
{
|
|
3694
|
+
name: "componentType",
|
|
3695
|
+
type: "string",
|
|
3696
|
+
displayName: "Component Type",
|
|
3697
|
+
defaultValue: ""
|
|
3698
|
+
}
|
|
3699
|
+
],
|
|
3700
|
+
outputs: [
|
|
3701
|
+
{
|
|
3702
|
+
name: "exec",
|
|
3703
|
+
type: "exec",
|
|
3704
|
+
displayName: ""
|
|
3705
|
+
},
|
|
3706
|
+
{
|
|
3707
|
+
name: "component",
|
|
3708
|
+
type: "component",
|
|
3709
|
+
displayName: "Component"
|
|
3710
|
+
},
|
|
3711
|
+
{
|
|
3712
|
+
name: "success",
|
|
3713
|
+
type: "bool",
|
|
3714
|
+
displayName: "Success"
|
|
3715
|
+
}
|
|
3716
|
+
]
|
|
3717
|
+
};
|
|
3718
|
+
var _AddComponentExecutor = class _AddComponentExecutor {
|
|
3719
|
+
execute(node, context) {
|
|
3720
|
+
const entity = context.evaluateInput(node.id, "entity", context.entity);
|
|
3721
|
+
const componentType = context.evaluateInput(node.id, "componentType", "");
|
|
3722
|
+
if (!entity || entity.isDestroyed || !componentType) {
|
|
3723
|
+
return {
|
|
3724
|
+
outputs: {
|
|
3725
|
+
component: null,
|
|
3726
|
+
success: false
|
|
3727
|
+
},
|
|
3728
|
+
nextExec: "exec"
|
|
3729
|
+
};
|
|
3730
|
+
}
|
|
3731
|
+
const existing = entity.components.find((c) => c.constructor.name === componentType || c.constructor.__componentName__ === componentType);
|
|
3732
|
+
if (existing) {
|
|
3733
|
+
return {
|
|
3734
|
+
outputs: {
|
|
3735
|
+
component: existing,
|
|
3736
|
+
success: false
|
|
3737
|
+
},
|
|
3738
|
+
nextExec: "exec"
|
|
3739
|
+
};
|
|
3740
|
+
}
|
|
3741
|
+
const ComponentClass = context.getComponentClass?.(componentType);
|
|
3742
|
+
if (!ComponentClass) {
|
|
3743
|
+
console.warn(`[Blueprint] Component type not found: ${componentType}`);
|
|
3744
|
+
return {
|
|
3745
|
+
outputs: {
|
|
3746
|
+
component: null,
|
|
3747
|
+
success: false
|
|
3748
|
+
},
|
|
3749
|
+
nextExec: "exec"
|
|
3750
|
+
};
|
|
3751
|
+
}
|
|
3752
|
+
try {
|
|
3753
|
+
const component = new ComponentClass();
|
|
3754
|
+
entity.addComponent(component);
|
|
3755
|
+
return {
|
|
3756
|
+
outputs: {
|
|
3757
|
+
component,
|
|
3758
|
+
success: true
|
|
3759
|
+
},
|
|
3760
|
+
nextExec: "exec"
|
|
3761
|
+
};
|
|
3762
|
+
} catch (error) {
|
|
3763
|
+
console.error(`[Blueprint] Failed to add component ${componentType}:`, error);
|
|
3764
|
+
return {
|
|
3765
|
+
outputs: {
|
|
3766
|
+
component: null,
|
|
3767
|
+
success: false
|
|
3768
|
+
},
|
|
3769
|
+
nextExec: "exec"
|
|
3770
|
+
};
|
|
3771
|
+
}
|
|
3374
3772
|
}
|
|
3375
3773
|
};
|
|
3376
|
-
__name(
|
|
3377
|
-
var
|
|
3378
|
-
|
|
3379
|
-
RegisterNode(
|
|
3380
|
-
],
|
|
3381
|
-
|
|
3382
|
-
// src/nodes/ecs/ComponentNodes.ts
|
|
3383
|
-
function _ts_decorate5(decorators, target, key, desc) {
|
|
3384
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3385
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3386
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3387
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3388
|
-
}
|
|
3389
|
-
__name(_ts_decorate5, "_ts_decorate");
|
|
3774
|
+
__name(_AddComponentExecutor, "AddComponentExecutor");
|
|
3775
|
+
var AddComponentExecutor = _AddComponentExecutor;
|
|
3776
|
+
AddComponentExecutor = _ts_decorate7([
|
|
3777
|
+
RegisterNode(AddComponentTemplate)
|
|
3778
|
+
], AddComponentExecutor);
|
|
3390
3779
|
var HasComponentTemplate = {
|
|
3391
3780
|
type: "ECS_HasComponent",
|
|
3392
3781
|
title: "Has Component",
|
|
@@ -3448,7 +3837,7 @@ var _HasComponentExecutor = class _HasComponentExecutor {
|
|
|
3448
3837
|
};
|
|
3449
3838
|
__name(_HasComponentExecutor, "HasComponentExecutor");
|
|
3450
3839
|
var HasComponentExecutor = _HasComponentExecutor;
|
|
3451
|
-
HasComponentExecutor =
|
|
3840
|
+
HasComponentExecutor = _ts_decorate7([
|
|
3452
3841
|
RegisterNode(HasComponentTemplate)
|
|
3453
3842
|
], HasComponentExecutor);
|
|
3454
3843
|
var GetComponentTemplate = {
|
|
@@ -3518,7 +3907,7 @@ var _GetComponentExecutor = class _GetComponentExecutor {
|
|
|
3518
3907
|
};
|
|
3519
3908
|
__name(_GetComponentExecutor, "GetComponentExecutor");
|
|
3520
3909
|
var GetComponentExecutor = _GetComponentExecutor;
|
|
3521
|
-
GetComponentExecutor =
|
|
3910
|
+
GetComponentExecutor = _ts_decorate7([
|
|
3522
3911
|
RegisterNode(GetComponentTemplate)
|
|
3523
3912
|
], GetComponentExecutor);
|
|
3524
3913
|
var GetAllComponentsTemplate = {
|
|
@@ -3584,7 +3973,7 @@ var _GetAllComponentsExecutor = class _GetAllComponentsExecutor {
|
|
|
3584
3973
|
};
|
|
3585
3974
|
__name(_GetAllComponentsExecutor, "GetAllComponentsExecutor");
|
|
3586
3975
|
var GetAllComponentsExecutor = _GetAllComponentsExecutor;
|
|
3587
|
-
GetAllComponentsExecutor =
|
|
3976
|
+
GetAllComponentsExecutor = _ts_decorate7([
|
|
3588
3977
|
RegisterNode(GetAllComponentsTemplate)
|
|
3589
3978
|
], GetAllComponentsExecutor);
|
|
3590
3979
|
var RemoveComponentTemplate = {
|
|
@@ -3667,7 +4056,7 @@ var _RemoveComponentExecutor = class _RemoveComponentExecutor {
|
|
|
3667
4056
|
};
|
|
3668
4057
|
__name(_RemoveComponentExecutor, "RemoveComponentExecutor");
|
|
3669
4058
|
var RemoveComponentExecutor = _RemoveComponentExecutor;
|
|
3670
|
-
RemoveComponentExecutor =
|
|
4059
|
+
RemoveComponentExecutor = _ts_decorate7([
|
|
3671
4060
|
RegisterNode(RemoveComponentTemplate)
|
|
3672
4061
|
], RemoveComponentExecutor);
|
|
3673
4062
|
var GetComponentPropertyTemplate = {
|
|
@@ -3745,7 +4134,7 @@ var _GetComponentPropertyExecutor = class _GetComponentPropertyExecutor {
|
|
|
3745
4134
|
};
|
|
3746
4135
|
__name(_GetComponentPropertyExecutor, "GetComponentPropertyExecutor");
|
|
3747
4136
|
var GetComponentPropertyExecutor = _GetComponentPropertyExecutor;
|
|
3748
|
-
GetComponentPropertyExecutor =
|
|
4137
|
+
GetComponentPropertyExecutor = _ts_decorate7([
|
|
3749
4138
|
RegisterNode(GetComponentPropertyTemplate)
|
|
3750
4139
|
], GetComponentPropertyExecutor);
|
|
3751
4140
|
var SetComponentPropertyTemplate = {
|
|
@@ -3835,7 +4224,7 @@ var _SetComponentPropertyExecutor = class _SetComponentPropertyExecutor {
|
|
|
3835
4224
|
};
|
|
3836
4225
|
__name(_SetComponentPropertyExecutor, "SetComponentPropertyExecutor");
|
|
3837
4226
|
var SetComponentPropertyExecutor = _SetComponentPropertyExecutor;
|
|
3838
|
-
SetComponentPropertyExecutor =
|
|
4227
|
+
SetComponentPropertyExecutor = _ts_decorate7([
|
|
3839
4228
|
RegisterNode(SetComponentPropertyTemplate)
|
|
3840
4229
|
], SetComponentPropertyExecutor);
|
|
3841
4230
|
var GetComponentTypeNameTemplate = {
|
|
@@ -3891,7 +4280,7 @@ var _GetComponentTypeNameExecutor = class _GetComponentTypeNameExecutor {
|
|
|
3891
4280
|
};
|
|
3892
4281
|
__name(_GetComponentTypeNameExecutor, "GetComponentTypeNameExecutor");
|
|
3893
4282
|
var GetComponentTypeNameExecutor = _GetComponentTypeNameExecutor;
|
|
3894
|
-
GetComponentTypeNameExecutor =
|
|
4283
|
+
GetComponentTypeNameExecutor = _ts_decorate7([
|
|
3895
4284
|
RegisterNode(GetComponentTypeNameTemplate)
|
|
3896
4285
|
], GetComponentTypeNameExecutor);
|
|
3897
4286
|
var GetEntityFromComponentTemplate = {
|
|
@@ -3954,18 +4343,18 @@ var _GetEntityFromComponentExecutor = class _GetEntityFromComponentExecutor {
|
|
|
3954
4343
|
};
|
|
3955
4344
|
__name(_GetEntityFromComponentExecutor, "GetEntityFromComponentExecutor");
|
|
3956
4345
|
var GetEntityFromComponentExecutor = _GetEntityFromComponentExecutor;
|
|
3957
|
-
GetEntityFromComponentExecutor =
|
|
4346
|
+
GetEntityFromComponentExecutor = _ts_decorate7([
|
|
3958
4347
|
RegisterNode(GetEntityFromComponentTemplate)
|
|
3959
4348
|
], GetEntityFromComponentExecutor);
|
|
3960
4349
|
|
|
3961
4350
|
// src/nodes/ecs/FlowNodes.ts
|
|
3962
|
-
function
|
|
4351
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
3963
4352
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3964
4353
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3965
4354
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3966
4355
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3967
4356
|
}
|
|
3968
|
-
__name(
|
|
4357
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
3969
4358
|
var BranchTemplate = {
|
|
3970
4359
|
type: "Flow_Branch",
|
|
3971
4360
|
title: "Branch",
|
|
@@ -4019,7 +4408,7 @@ var _BranchExecutor = class _BranchExecutor {
|
|
|
4019
4408
|
};
|
|
4020
4409
|
__name(_BranchExecutor, "BranchExecutor");
|
|
4021
4410
|
var BranchExecutor = _BranchExecutor;
|
|
4022
|
-
BranchExecutor =
|
|
4411
|
+
BranchExecutor = _ts_decorate8([
|
|
4023
4412
|
RegisterNode(BranchTemplate)
|
|
4024
4413
|
], BranchExecutor);
|
|
4025
4414
|
var SequenceTemplate = {
|
|
@@ -4093,7 +4482,7 @@ var _SequenceExecutor = class _SequenceExecutor {
|
|
|
4093
4482
|
};
|
|
4094
4483
|
__name(_SequenceExecutor, "SequenceExecutor");
|
|
4095
4484
|
var SequenceExecutor = _SequenceExecutor;
|
|
4096
|
-
SequenceExecutor =
|
|
4485
|
+
SequenceExecutor = _ts_decorate8([
|
|
4097
4486
|
RegisterNode(SequenceTemplate)
|
|
4098
4487
|
], SequenceExecutor);
|
|
4099
4488
|
var DoOnceTemplate = {
|
|
@@ -4157,7 +4546,7 @@ var _DoOnceExecutor = class _DoOnceExecutor {
|
|
|
4157
4546
|
};
|
|
4158
4547
|
__name(_DoOnceExecutor, "DoOnceExecutor");
|
|
4159
4548
|
var DoOnceExecutor = _DoOnceExecutor;
|
|
4160
|
-
DoOnceExecutor =
|
|
4549
|
+
DoOnceExecutor = _ts_decorate8([
|
|
4161
4550
|
RegisterNode(DoOnceTemplate)
|
|
4162
4551
|
], DoOnceExecutor);
|
|
4163
4552
|
var FlipFlopTemplate = {
|
|
@@ -4219,7 +4608,7 @@ var _FlipFlopExecutor = class _FlipFlopExecutor {
|
|
|
4219
4608
|
};
|
|
4220
4609
|
__name(_FlipFlopExecutor, "FlipFlopExecutor");
|
|
4221
4610
|
var FlipFlopExecutor = _FlipFlopExecutor;
|
|
4222
|
-
FlipFlopExecutor =
|
|
4611
|
+
FlipFlopExecutor = _ts_decorate8([
|
|
4223
4612
|
RegisterNode(FlipFlopTemplate)
|
|
4224
4613
|
], FlipFlopExecutor);
|
|
4225
4614
|
var GateTemplate = {
|
|
@@ -4309,7 +4698,7 @@ var _GateExecutor = class _GateExecutor {
|
|
|
4309
4698
|
};
|
|
4310
4699
|
__name(_GateExecutor, "GateExecutor");
|
|
4311
4700
|
var GateExecutor = _GateExecutor;
|
|
4312
|
-
GateExecutor =
|
|
4701
|
+
GateExecutor = _ts_decorate8([
|
|
4313
4702
|
RegisterNode(GateTemplate)
|
|
4314
4703
|
], GateExecutor);
|
|
4315
4704
|
var ForLoopTemplate = {
|
|
@@ -4399,7 +4788,7 @@ var _ForLoopExecutor = class _ForLoopExecutor {
|
|
|
4399
4788
|
};
|
|
4400
4789
|
__name(_ForLoopExecutor, "ForLoopExecutor");
|
|
4401
4790
|
var ForLoopExecutor = _ForLoopExecutor;
|
|
4402
|
-
ForLoopExecutor =
|
|
4791
|
+
ForLoopExecutor = _ts_decorate8([
|
|
4403
4792
|
RegisterNode(ForLoopTemplate)
|
|
4404
4793
|
], ForLoopExecutor);
|
|
4405
4794
|
var WhileLoopTemplate = {
|
|
@@ -4459,18 +4848,354 @@ var _WhileLoopExecutor = class _WhileLoopExecutor {
|
|
|
4459
4848
|
};
|
|
4460
4849
|
__name(_WhileLoopExecutor, "WhileLoopExecutor");
|
|
4461
4850
|
var WhileLoopExecutor = _WhileLoopExecutor;
|
|
4462
|
-
WhileLoopExecutor =
|
|
4851
|
+
WhileLoopExecutor = _ts_decorate8([
|
|
4463
4852
|
RegisterNode(WhileLoopTemplate)
|
|
4464
4853
|
], WhileLoopExecutor);
|
|
4465
4854
|
|
|
4855
|
+
// src/nodes/variables/VariableNodes.ts
|
|
4856
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
4857
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4858
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4859
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4860
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4861
|
+
}
|
|
4862
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
4863
|
+
var GetVariableTemplate = {
|
|
4864
|
+
type: "GetVariable",
|
|
4865
|
+
title: "Get Variable",
|
|
4866
|
+
category: "variable",
|
|
4867
|
+
color: "#4a9c6d",
|
|
4868
|
+
isPure: true,
|
|
4869
|
+
description: "Gets the value of a variable (\u83B7\u53D6\u53D8\u91CF\u7684\u503C)",
|
|
4870
|
+
keywords: [
|
|
4871
|
+
"variable",
|
|
4872
|
+
"get",
|
|
4873
|
+
"read",
|
|
4874
|
+
"value"
|
|
4875
|
+
],
|
|
4876
|
+
menuPath: [
|
|
4877
|
+
"Variable",
|
|
4878
|
+
"Get Variable"
|
|
4879
|
+
],
|
|
4880
|
+
inputs: [
|
|
4881
|
+
{
|
|
4882
|
+
name: "variableName",
|
|
4883
|
+
type: "string",
|
|
4884
|
+
displayName: "Variable Name",
|
|
4885
|
+
defaultValue: ""
|
|
4886
|
+
}
|
|
4887
|
+
],
|
|
4888
|
+
outputs: [
|
|
4889
|
+
{
|
|
4890
|
+
name: "value",
|
|
4891
|
+
type: "any",
|
|
4892
|
+
displayName: "Value"
|
|
4893
|
+
}
|
|
4894
|
+
]
|
|
4895
|
+
};
|
|
4896
|
+
var _GetVariableExecutor = class _GetVariableExecutor {
|
|
4897
|
+
execute(node, context) {
|
|
4898
|
+
const variableName = context.evaluateInput(node.id, "variableName", "");
|
|
4899
|
+
if (!variableName) {
|
|
4900
|
+
return {
|
|
4901
|
+
outputs: {
|
|
4902
|
+
value: null
|
|
4903
|
+
}
|
|
4904
|
+
};
|
|
4905
|
+
}
|
|
4906
|
+
const value = context.getVariable(variableName);
|
|
4907
|
+
return {
|
|
4908
|
+
outputs: {
|
|
4909
|
+
value
|
|
4910
|
+
}
|
|
4911
|
+
};
|
|
4912
|
+
}
|
|
4913
|
+
};
|
|
4914
|
+
__name(_GetVariableExecutor, "GetVariableExecutor");
|
|
4915
|
+
var GetVariableExecutor = _GetVariableExecutor;
|
|
4916
|
+
GetVariableExecutor = _ts_decorate9([
|
|
4917
|
+
RegisterNode(GetVariableTemplate)
|
|
4918
|
+
], GetVariableExecutor);
|
|
4919
|
+
var SetVariableTemplate = {
|
|
4920
|
+
type: "SetVariable",
|
|
4921
|
+
title: "Set Variable",
|
|
4922
|
+
category: "variable",
|
|
4923
|
+
color: "#4a9c6d",
|
|
4924
|
+
description: "Sets the value of a variable (\u8BBE\u7F6E\u53D8\u91CF\u7684\u503C)",
|
|
4925
|
+
keywords: [
|
|
4926
|
+
"variable",
|
|
4927
|
+
"set",
|
|
4928
|
+
"write",
|
|
4929
|
+
"assign",
|
|
4930
|
+
"value"
|
|
4931
|
+
],
|
|
4932
|
+
menuPath: [
|
|
4933
|
+
"Variable",
|
|
4934
|
+
"Set Variable"
|
|
4935
|
+
],
|
|
4936
|
+
inputs: [
|
|
4937
|
+
{
|
|
4938
|
+
name: "exec",
|
|
4939
|
+
type: "exec",
|
|
4940
|
+
displayName: ""
|
|
4941
|
+
},
|
|
4942
|
+
{
|
|
4943
|
+
name: "variableName",
|
|
4944
|
+
type: "string",
|
|
4945
|
+
displayName: "Variable Name",
|
|
4946
|
+
defaultValue: ""
|
|
4947
|
+
},
|
|
4948
|
+
{
|
|
4949
|
+
name: "value",
|
|
4950
|
+
type: "any",
|
|
4951
|
+
displayName: "Value"
|
|
4952
|
+
}
|
|
4953
|
+
],
|
|
4954
|
+
outputs: [
|
|
4955
|
+
{
|
|
4956
|
+
name: "exec",
|
|
4957
|
+
type: "exec",
|
|
4958
|
+
displayName: ""
|
|
4959
|
+
},
|
|
4960
|
+
{
|
|
4961
|
+
name: "value",
|
|
4962
|
+
type: "any",
|
|
4963
|
+
displayName: "Value"
|
|
4964
|
+
}
|
|
4965
|
+
]
|
|
4966
|
+
};
|
|
4967
|
+
var _SetVariableExecutor = class _SetVariableExecutor {
|
|
4968
|
+
execute(node, context) {
|
|
4969
|
+
const variableName = context.evaluateInput(node.id, "variableName", "");
|
|
4970
|
+
const value = context.evaluateInput(node.id, "value", null);
|
|
4971
|
+
if (!variableName) {
|
|
4972
|
+
return {
|
|
4973
|
+
outputs: {
|
|
4974
|
+
value: null
|
|
4975
|
+
},
|
|
4976
|
+
nextExec: "exec"
|
|
4977
|
+
};
|
|
4978
|
+
}
|
|
4979
|
+
context.setVariable(variableName, value);
|
|
4980
|
+
return {
|
|
4981
|
+
outputs: {
|
|
4982
|
+
value
|
|
4983
|
+
},
|
|
4984
|
+
nextExec: "exec"
|
|
4985
|
+
};
|
|
4986
|
+
}
|
|
4987
|
+
};
|
|
4988
|
+
__name(_SetVariableExecutor, "SetVariableExecutor");
|
|
4989
|
+
var SetVariableExecutor = _SetVariableExecutor;
|
|
4990
|
+
SetVariableExecutor = _ts_decorate9([
|
|
4991
|
+
RegisterNode(SetVariableTemplate)
|
|
4992
|
+
], SetVariableExecutor);
|
|
4993
|
+
var GetBoolVariableTemplate = {
|
|
4994
|
+
type: "GetBoolVariable",
|
|
4995
|
+
title: "Get Bool",
|
|
4996
|
+
category: "variable",
|
|
4997
|
+
color: "#8b1e3f",
|
|
4998
|
+
isPure: true,
|
|
4999
|
+
description: "Gets a boolean variable (\u83B7\u53D6\u5E03\u5C14\u53D8\u91CF)",
|
|
5000
|
+
keywords: [
|
|
5001
|
+
"variable",
|
|
5002
|
+
"get",
|
|
5003
|
+
"bool",
|
|
5004
|
+
"boolean"
|
|
5005
|
+
],
|
|
5006
|
+
menuPath: [
|
|
5007
|
+
"Variable",
|
|
5008
|
+
"Get Bool"
|
|
5009
|
+
],
|
|
5010
|
+
inputs: [
|
|
5011
|
+
{
|
|
5012
|
+
name: "variableName",
|
|
5013
|
+
type: "string",
|
|
5014
|
+
displayName: "Variable Name",
|
|
5015
|
+
defaultValue: ""
|
|
5016
|
+
}
|
|
5017
|
+
],
|
|
5018
|
+
outputs: [
|
|
5019
|
+
{
|
|
5020
|
+
name: "value",
|
|
5021
|
+
type: "bool",
|
|
5022
|
+
displayName: "Value"
|
|
5023
|
+
}
|
|
5024
|
+
]
|
|
5025
|
+
};
|
|
5026
|
+
var _GetBoolVariableExecutor = class _GetBoolVariableExecutor {
|
|
5027
|
+
execute(node, context) {
|
|
5028
|
+
const variableName = context.evaluateInput(node.id, "variableName", "");
|
|
5029
|
+
const value = context.getVariable(variableName);
|
|
5030
|
+
return {
|
|
5031
|
+
outputs: {
|
|
5032
|
+
value: Boolean(value)
|
|
5033
|
+
}
|
|
5034
|
+
};
|
|
5035
|
+
}
|
|
5036
|
+
};
|
|
5037
|
+
__name(_GetBoolVariableExecutor, "GetBoolVariableExecutor");
|
|
5038
|
+
var GetBoolVariableExecutor = _GetBoolVariableExecutor;
|
|
5039
|
+
GetBoolVariableExecutor = _ts_decorate9([
|
|
5040
|
+
RegisterNode(GetBoolVariableTemplate)
|
|
5041
|
+
], GetBoolVariableExecutor);
|
|
5042
|
+
var GetFloatVariableTemplate = {
|
|
5043
|
+
type: "GetFloatVariable",
|
|
5044
|
+
title: "Get Float",
|
|
5045
|
+
category: "variable",
|
|
5046
|
+
color: "#39c5bb",
|
|
5047
|
+
isPure: true,
|
|
5048
|
+
description: "Gets a float variable (\u83B7\u53D6\u6D6E\u70B9\u53D8\u91CF)",
|
|
5049
|
+
keywords: [
|
|
5050
|
+
"variable",
|
|
5051
|
+
"get",
|
|
5052
|
+
"float",
|
|
5053
|
+
"number"
|
|
5054
|
+
],
|
|
5055
|
+
menuPath: [
|
|
5056
|
+
"Variable",
|
|
5057
|
+
"Get Float"
|
|
5058
|
+
],
|
|
5059
|
+
inputs: [
|
|
5060
|
+
{
|
|
5061
|
+
name: "variableName",
|
|
5062
|
+
type: "string",
|
|
5063
|
+
displayName: "Variable Name",
|
|
5064
|
+
defaultValue: ""
|
|
5065
|
+
}
|
|
5066
|
+
],
|
|
5067
|
+
outputs: [
|
|
5068
|
+
{
|
|
5069
|
+
name: "value",
|
|
5070
|
+
type: "float",
|
|
5071
|
+
displayName: "Value"
|
|
5072
|
+
}
|
|
5073
|
+
]
|
|
5074
|
+
};
|
|
5075
|
+
var _GetFloatVariableExecutor = class _GetFloatVariableExecutor {
|
|
5076
|
+
execute(node, context) {
|
|
5077
|
+
const variableName = context.evaluateInput(node.id, "variableName", "");
|
|
5078
|
+
const value = context.getVariable(variableName);
|
|
5079
|
+
return {
|
|
5080
|
+
outputs: {
|
|
5081
|
+
value: Number(value) || 0
|
|
5082
|
+
}
|
|
5083
|
+
};
|
|
5084
|
+
}
|
|
5085
|
+
};
|
|
5086
|
+
__name(_GetFloatVariableExecutor, "GetFloatVariableExecutor");
|
|
5087
|
+
var GetFloatVariableExecutor = _GetFloatVariableExecutor;
|
|
5088
|
+
GetFloatVariableExecutor = _ts_decorate9([
|
|
5089
|
+
RegisterNode(GetFloatVariableTemplate)
|
|
5090
|
+
], GetFloatVariableExecutor);
|
|
5091
|
+
var GetIntVariableTemplate = {
|
|
5092
|
+
type: "GetIntVariable",
|
|
5093
|
+
title: "Get Int",
|
|
5094
|
+
category: "variable",
|
|
5095
|
+
color: "#1c8b8b",
|
|
5096
|
+
isPure: true,
|
|
5097
|
+
description: "Gets an integer variable (\u83B7\u53D6\u6574\u6570\u53D8\u91CF)",
|
|
5098
|
+
keywords: [
|
|
5099
|
+
"variable",
|
|
5100
|
+
"get",
|
|
5101
|
+
"int",
|
|
5102
|
+
"integer",
|
|
5103
|
+
"number"
|
|
5104
|
+
],
|
|
5105
|
+
menuPath: [
|
|
5106
|
+
"Variable",
|
|
5107
|
+
"Get Int"
|
|
5108
|
+
],
|
|
5109
|
+
inputs: [
|
|
5110
|
+
{
|
|
5111
|
+
name: "variableName",
|
|
5112
|
+
type: "string",
|
|
5113
|
+
displayName: "Variable Name",
|
|
5114
|
+
defaultValue: ""
|
|
5115
|
+
}
|
|
5116
|
+
],
|
|
5117
|
+
outputs: [
|
|
5118
|
+
{
|
|
5119
|
+
name: "value",
|
|
5120
|
+
type: "int",
|
|
5121
|
+
displayName: "Value"
|
|
5122
|
+
}
|
|
5123
|
+
]
|
|
5124
|
+
};
|
|
5125
|
+
var _GetIntVariableExecutor = class _GetIntVariableExecutor {
|
|
5126
|
+
execute(node, context) {
|
|
5127
|
+
const variableName = context.evaluateInput(node.id, "variableName", "");
|
|
5128
|
+
const value = context.getVariable(variableName);
|
|
5129
|
+
return {
|
|
5130
|
+
outputs: {
|
|
5131
|
+
value: Math.floor(Number(value) || 0)
|
|
5132
|
+
}
|
|
5133
|
+
};
|
|
5134
|
+
}
|
|
5135
|
+
};
|
|
5136
|
+
__name(_GetIntVariableExecutor, "GetIntVariableExecutor");
|
|
5137
|
+
var GetIntVariableExecutor = _GetIntVariableExecutor;
|
|
5138
|
+
GetIntVariableExecutor = _ts_decorate9([
|
|
5139
|
+
RegisterNode(GetIntVariableTemplate)
|
|
5140
|
+
], GetIntVariableExecutor);
|
|
5141
|
+
var GetStringVariableTemplate = {
|
|
5142
|
+
type: "GetStringVariable",
|
|
5143
|
+
title: "Get String",
|
|
5144
|
+
category: "variable",
|
|
5145
|
+
color: "#e91e8c",
|
|
5146
|
+
isPure: true,
|
|
5147
|
+
description: "Gets a string variable (\u83B7\u53D6\u5B57\u7B26\u4E32\u53D8\u91CF)",
|
|
5148
|
+
keywords: [
|
|
5149
|
+
"variable",
|
|
5150
|
+
"get",
|
|
5151
|
+
"string",
|
|
5152
|
+
"text"
|
|
5153
|
+
],
|
|
5154
|
+
menuPath: [
|
|
5155
|
+
"Variable",
|
|
5156
|
+
"Get String"
|
|
5157
|
+
],
|
|
5158
|
+
inputs: [
|
|
5159
|
+
{
|
|
5160
|
+
name: "variableName",
|
|
5161
|
+
type: "string",
|
|
5162
|
+
displayName: "Variable Name",
|
|
5163
|
+
defaultValue: ""
|
|
5164
|
+
}
|
|
5165
|
+
],
|
|
5166
|
+
outputs: [
|
|
5167
|
+
{
|
|
5168
|
+
name: "value",
|
|
5169
|
+
type: "string",
|
|
5170
|
+
displayName: "Value"
|
|
5171
|
+
}
|
|
5172
|
+
]
|
|
5173
|
+
};
|
|
5174
|
+
var _GetStringVariableExecutor = class _GetStringVariableExecutor {
|
|
5175
|
+
execute(node, context) {
|
|
5176
|
+
const variableName = context.evaluateInput(node.id, "variableName", "");
|
|
5177
|
+
const value = context.getVariable(variableName);
|
|
5178
|
+
return {
|
|
5179
|
+
outputs: {
|
|
5180
|
+
value: String(value ?? "")
|
|
5181
|
+
}
|
|
5182
|
+
};
|
|
5183
|
+
}
|
|
5184
|
+
};
|
|
5185
|
+
__name(_GetStringVariableExecutor, "GetStringVariableExecutor");
|
|
5186
|
+
var GetStringVariableExecutor = _GetStringVariableExecutor;
|
|
5187
|
+
GetStringVariableExecutor = _ts_decorate9([
|
|
5188
|
+
RegisterNode(GetStringVariableTemplate)
|
|
5189
|
+
], GetStringVariableExecutor);
|
|
5190
|
+
|
|
4466
5191
|
// src/nodes/math/MathOperations.ts
|
|
4467
|
-
function
|
|
5192
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
4468
5193
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4469
5194
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4470
5195
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4471
5196
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4472
5197
|
}
|
|
4473
|
-
__name(
|
|
5198
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
4474
5199
|
var AddTemplate = {
|
|
4475
5200
|
type: "Add",
|
|
4476
5201
|
title: "Add",
|
|
@@ -4520,7 +5245,7 @@ var _AddExecutor = class _AddExecutor {
|
|
|
4520
5245
|
};
|
|
4521
5246
|
__name(_AddExecutor, "AddExecutor");
|
|
4522
5247
|
var AddExecutor = _AddExecutor;
|
|
4523
|
-
AddExecutor =
|
|
5248
|
+
AddExecutor = _ts_decorate10([
|
|
4524
5249
|
RegisterNode(AddTemplate)
|
|
4525
5250
|
], AddExecutor);
|
|
4526
5251
|
var SubtractTemplate = {
|
|
@@ -4571,7 +5296,7 @@ var _SubtractExecutor = class _SubtractExecutor {
|
|
|
4571
5296
|
};
|
|
4572
5297
|
__name(_SubtractExecutor, "SubtractExecutor");
|
|
4573
5298
|
var SubtractExecutor = _SubtractExecutor;
|
|
4574
|
-
SubtractExecutor =
|
|
5299
|
+
SubtractExecutor = _ts_decorate10([
|
|
4575
5300
|
RegisterNode(SubtractTemplate)
|
|
4576
5301
|
], SubtractExecutor);
|
|
4577
5302
|
var MultiplyTemplate = {
|
|
@@ -4622,7 +5347,7 @@ var _MultiplyExecutor = class _MultiplyExecutor {
|
|
|
4622
5347
|
};
|
|
4623
5348
|
__name(_MultiplyExecutor, "MultiplyExecutor");
|
|
4624
5349
|
var MultiplyExecutor = _MultiplyExecutor;
|
|
4625
|
-
MultiplyExecutor =
|
|
5350
|
+
MultiplyExecutor = _ts_decorate10([
|
|
4626
5351
|
RegisterNode(MultiplyTemplate)
|
|
4627
5352
|
], MultiplyExecutor);
|
|
4628
5353
|
var DivideTemplate = {
|
|
@@ -4679,18 +5404,18 @@ var _DivideExecutor = class _DivideExecutor {
|
|
|
4679
5404
|
};
|
|
4680
5405
|
__name(_DivideExecutor, "DivideExecutor");
|
|
4681
5406
|
var DivideExecutor = _DivideExecutor;
|
|
4682
|
-
DivideExecutor =
|
|
5407
|
+
DivideExecutor = _ts_decorate10([
|
|
4683
5408
|
RegisterNode(DivideTemplate)
|
|
4684
5409
|
], DivideExecutor);
|
|
4685
5410
|
|
|
4686
5411
|
// src/nodes/time/GetDeltaTime.ts
|
|
4687
|
-
function
|
|
5412
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
4688
5413
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4689
5414
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4690
5415
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4691
5416
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4692
5417
|
}
|
|
4693
|
-
__name(
|
|
5418
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
4694
5419
|
var GetDeltaTimeTemplate = {
|
|
4695
5420
|
type: "GetDeltaTime",
|
|
4696
5421
|
title: "Get Delta Time",
|
|
@@ -4724,18 +5449,18 @@ var _GetDeltaTimeExecutor = class _GetDeltaTimeExecutor {
|
|
|
4724
5449
|
};
|
|
4725
5450
|
__name(_GetDeltaTimeExecutor, "GetDeltaTimeExecutor");
|
|
4726
5451
|
var GetDeltaTimeExecutor = _GetDeltaTimeExecutor;
|
|
4727
|
-
GetDeltaTimeExecutor =
|
|
5452
|
+
GetDeltaTimeExecutor = _ts_decorate11([
|
|
4728
5453
|
RegisterNode(GetDeltaTimeTemplate)
|
|
4729
5454
|
], GetDeltaTimeExecutor);
|
|
4730
5455
|
|
|
4731
5456
|
// src/nodes/time/GetTime.ts
|
|
4732
|
-
function
|
|
5457
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
4733
5458
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4734
5459
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4735
5460
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4736
5461
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4737
5462
|
}
|
|
4738
|
-
__name(
|
|
5463
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
4739
5464
|
var GetTimeTemplate = {
|
|
4740
5465
|
type: "GetTime",
|
|
4741
5466
|
title: "Get Game Time",
|
|
@@ -4769,18 +5494,18 @@ var _GetTimeExecutor = class _GetTimeExecutor {
|
|
|
4769
5494
|
};
|
|
4770
5495
|
__name(_GetTimeExecutor, "GetTimeExecutor");
|
|
4771
5496
|
var GetTimeExecutor = _GetTimeExecutor;
|
|
4772
|
-
GetTimeExecutor =
|
|
5497
|
+
GetTimeExecutor = _ts_decorate12([
|
|
4773
5498
|
RegisterNode(GetTimeTemplate)
|
|
4774
5499
|
], GetTimeExecutor);
|
|
4775
5500
|
|
|
4776
5501
|
// src/nodes/time/Delay.ts
|
|
4777
|
-
function
|
|
5502
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
4778
5503
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4779
5504
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4780
5505
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4781
5506
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4782
5507
|
}
|
|
4783
|
-
__name(
|
|
5508
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
4784
5509
|
var DelayTemplate = {
|
|
4785
5510
|
type: "Delay",
|
|
4786
5511
|
title: "Delay",
|
|
@@ -4826,18 +5551,18 @@ var _DelayExecutor = class _DelayExecutor {
|
|
|
4826
5551
|
};
|
|
4827
5552
|
__name(_DelayExecutor, "DelayExecutor");
|
|
4828
5553
|
var DelayExecutor = _DelayExecutor;
|
|
4829
|
-
DelayExecutor =
|
|
5554
|
+
DelayExecutor = _ts_decorate13([
|
|
4830
5555
|
RegisterNode(DelayTemplate)
|
|
4831
5556
|
], DelayExecutor);
|
|
4832
5557
|
|
|
4833
5558
|
// src/nodes/debug/Print.ts
|
|
4834
|
-
function
|
|
5559
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
4835
5560
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4836
5561
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4837
5562
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4838
5563
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4839
5564
|
}
|
|
4840
|
-
__name(
|
|
5565
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
4841
5566
|
var PrintTemplate = {
|
|
4842
5567
|
type: "Print",
|
|
4843
5568
|
title: "Print String",
|
|
@@ -4910,17 +5635,25 @@ var _PrintExecutor = class _PrintExecutor {
|
|
|
4910
5635
|
};
|
|
4911
5636
|
__name(_PrintExecutor, "PrintExecutor");
|
|
4912
5637
|
var PrintExecutor = _PrintExecutor;
|
|
4913
|
-
PrintExecutor =
|
|
5638
|
+
PrintExecutor = _ts_decorate14([
|
|
4914
5639
|
RegisterNode(PrintTemplate)
|
|
4915
5640
|
], PrintExecutor);
|
|
5641
|
+
|
|
5642
|
+
// src/index.ts
|
|
5643
|
+
function registerComponentClass(typeName, componentClass) {
|
|
5644
|
+
ExecutionContext.registerComponentClass(typeName, componentClass);
|
|
5645
|
+
}
|
|
5646
|
+
__name(registerComponentClass, "registerComponentClass");
|
|
4916
5647
|
export {
|
|
4917
5648
|
AlwaysFalseCondition,
|
|
4918
5649
|
AlwaysTrueCondition,
|
|
5650
|
+
BlueprintComponent,
|
|
4919
5651
|
BlueprintComposer,
|
|
4920
5652
|
BlueprintExpose,
|
|
4921
5653
|
BlueprintFragment,
|
|
4922
5654
|
BlueprintMethod,
|
|
4923
5655
|
BlueprintProperty,
|
|
5656
|
+
BlueprintSystem,
|
|
4924
5657
|
BlueprintTrigger,
|
|
4925
5658
|
BlueprintVM,
|
|
4926
5659
|
CollisionEntityCondition,
|
|
@@ -4944,11 +5677,8 @@ export {
|
|
|
4944
5677
|
TriggerTypeCondition,
|
|
4945
5678
|
TriggerTypes,
|
|
4946
5679
|
arePinTypesCompatible,
|
|
4947
|
-
cleanupBlueprint,
|
|
4948
5680
|
clearRegisteredComponents,
|
|
4949
5681
|
condition,
|
|
4950
|
-
createBlueprintComponentData,
|
|
4951
|
-
createBlueprintSystem,
|
|
4952
5682
|
createCollisionContext,
|
|
4953
5683
|
createCollisionTrigger,
|
|
4954
5684
|
createComposer,
|
|
@@ -4981,14 +5711,9 @@ export {
|
|
|
4981
5711
|
getPinTypeColor,
|
|
4982
5712
|
getRegisteredBlueprintComponents,
|
|
4983
5713
|
inferPinType,
|
|
4984
|
-
initializeBlueprintVM,
|
|
4985
5714
|
registerAllComponentNodes,
|
|
5715
|
+
registerComponentClass,
|
|
4986
5716
|
registerComponentNodes,
|
|
4987
|
-
startBlueprint,
|
|
4988
|
-
stopBlueprint,
|
|
4989
|
-
tickBlueprint,
|
|
4990
|
-
triggerBlueprintEvent,
|
|
4991
|
-
triggerCustomBlueprintEvent,
|
|
4992
5717
|
validateBlueprintAsset
|
|
4993
5718
|
};
|
|
4994
5719
|
//# sourceMappingURL=index.js.map
|