avocado-old/packages/topdown/traits/roomed.trait.js

33 lines
576 B
JavaScript
Raw Normal View History

2019-04-14 20:21:52 -05:00
import {Trait} from '@avocado/entity';
2019-03-27 01:03:05 -05:00
export class Roomed extends Trait {
2019-05-05 04:26:35 -05:00
static type() {
return 'roomed';
}
2019-03-27 01:03:05 -05:00
destroy() {
2019-05-17 05:47:40 -05:00
const room = this.entity.room;
this.entity.room = null;
2019-04-05 11:25:26 -05:00
this.entity.emit('removedFromRoom', room);
2019-03-27 01:03:05 -05:00
}
2019-05-17 05:47:40 -05:00
methods() {
return {
2019-05-26 12:03:24 -05:00
removeFromRoom: () => {
const room = this.entity.room;
this.entity.room = undefined;
this.entity.emit('removedFromRoom', room);
},
setIntoRoom: (room) => {
2019-05-17 05:47:40 -05:00
this.entity.room = room;
this.entity.emit('addedToRoom');
},
2019-03-27 01:03:05 -05:00
2019-05-17 05:47:40 -05:00
};
2019-03-27 01:03:05 -05:00
}
}