avocado-old/packages/behavior/item/routine.js

39 lines
568 B
JavaScript
Raw Normal View History

2019-03-17 23:45:48 -05:00
import {Actions} from './actions';
export class Routine {
2019-05-05 04:26:35 -05:00
static type() {
return 'routine';
}
2019-03-17 23:45:48 -05:00
constructor() {
2019-04-08 17:42:14 -05:00
this._context = undefined;
2019-03-17 23:45:48 -05:00
this.actions = new Actions();
}
2019-04-08 17:42:14 -05:00
set context(context) {
this._context = context;
}
2019-04-25 00:48:53 -05:00
clone(other) {
this.actions = other.actions.clone();
}
2019-03-17 23:45:48 -05:00
fromJSON(json) {
2019-04-19 15:39:28 -05:00
this.actions.fromJSON(json.routine);
2019-03-17 23:45:48 -05:00
return this;
}
2019-04-08 17:42:14 -05:00
tick(elapsed) {
this.actions.tick(this._context, elapsed);
2019-03-17 23:45:48 -05:00
}
toJSON() {
return {
type: 'routine',
actions: this.actions.toJSON(),
}
}
}