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-27 07:24:42 -05:00
|
|
|
this.entity.removeFromRoom();
|
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;
|
2019-05-27 07:24:42 -05:00
|
|
|
if (!room) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.entity.room = null;
|
2019-05-26 12:03:24 -05:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
}
|