feat: tool setup
This commit is contained in:
parent
0221a525b4
commit
2164a43bfd
|
@ -12,12 +12,16 @@ export class Tool extends decorate(Trait) {
|
||||||
|
|
||||||
static defaultParams() {
|
static defaultParams() {
|
||||||
return {
|
return {
|
||||||
|
actions: {
|
||||||
|
type: 'actions',
|
||||||
|
traversals: [],
|
||||||
|
},
|
||||||
condition: {
|
condition: {
|
||||||
type: 'condition',
|
type: 'condition',
|
||||||
operator: 'or',
|
operator: 'or',
|
||||||
operands: [],
|
operands: [],
|
||||||
},
|
},
|
||||||
actions: {
|
setup: {
|
||||||
type: 'actions',
|
type: 'actions',
|
||||||
traversals: [],
|
traversals: [],
|
||||||
},
|
},
|
||||||
|
@ -46,8 +50,9 @@ export class Tool extends decorate(Trait) {
|
||||||
throw new Error("Tool::params.target.width must be odd!");
|
throw new Error("Tool::params.target.width must be odd!");
|
||||||
}
|
}
|
||||||
this.targets = [];
|
this.targets = [];
|
||||||
this.toolCondition = behaviorItemFromJSON(this.params.condition);
|
|
||||||
this.toolActions = behaviorItemFromJSON(this.params.actions);
|
this.toolActions = behaviorItemFromJSON(this.params.actions);
|
||||||
|
this.toolCondition = behaviorItemFromJSON(this.params.condition);
|
||||||
|
this.toolSetup = behaviorItemFromJSON(this.params.setup);
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateTargetStart() {
|
calculateTargetStart() {
|
||||||
|
@ -239,6 +244,8 @@ export class Tool extends decorate(Trait) {
|
||||||
for (let i = 0; i < this.targets.length; ++i) {
|
for (let i = 0; i < this.targets.length; ++i) {
|
||||||
const target = this.targets[i];
|
const target = this.targets[i];
|
||||||
const context = this.createTargetContext(target);
|
const context = this.createTargetContext(target);
|
||||||
|
// Initial setup.
|
||||||
|
this.toolSetup.tick(context, 0);
|
||||||
// Each target checks condition.
|
// Each target checks condition.
|
||||||
if (!this.toolCondition.get(context)) {
|
if (!this.toolCondition.get(context)) {
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user