31 lines
459 B
JavaScript
31 lines
459 B
JavaScript
import {Actions} from './actions';
|
|
|
|
export class Routine {
|
|
|
|
constructor() {
|
|
this._context = undefined;
|
|
this.actions = new Actions();
|
|
}
|
|
|
|
set context(context) {
|
|
this._context = context;
|
|
}
|
|
|
|
fromJSON(json) {
|
|
this.actions.fromJSON(json.routine);
|
|
return this;
|
|
}
|
|
|
|
tick(elapsed) {
|
|
this.actions.tick(this._context, elapsed);
|
|
}
|
|
|
|
toJSON() {
|
|
return {
|
|
type: 'routine',
|
|
actions: this.actions.toJSON(),
|
|
}
|
|
}
|
|
|
|
}
|