import {compose} from '@avocado/core'; import {simpleState, Trait} from '../trait'; const decorate = compose( simpleState('name'), ); class ExistentBase extends Trait { static defaultParams() { return { isTicking: true, }; } static defaultState() { return { name: 'Untitled entity', }; } initialize() { this._isTicking = this.params.get('isTicking'); } get isTicking() { return this._isTicking; } set isTicking(isTicking) { this._isTicking = isTicking; } actions() { return { destroy: () => { this.isTicking = false; this.entity.emit('destroy'); this.entity.emit('destroyed'); }, tick: (elapsed) => { if (!this.isTicking) { return; } this.entity.emit('tick', elapsed); }, }; } } export class Existent extends decorate(ExistentBase) {}