34 lines
823 B
JavaScript
34 lines
823 B
JavaScript
import Component from '@/ecs/component.js';
|
|
|
|
export default class Interacts extends Component {
|
|
instanceFromSchema() {
|
|
const {ecs} = this;
|
|
return class ControlledInstance extends super.instanceFromSchema() {
|
|
aabb() {
|
|
const {Direction, Position} = ecs.get(this.entity);
|
|
let x0 = Position.x - 8;
|
|
let y0 = Position.y - 8;
|
|
if (0 === Direction.direction) {
|
|
y0 -= 16
|
|
}
|
|
if (1 === Direction.direction) {
|
|
x0 += 16
|
|
}
|
|
if (2 === Direction.direction) {
|
|
y0 += 16
|
|
}
|
|
if (3 === Direction.direction) {
|
|
x0 -= 16
|
|
}
|
|
return {x0, x1: x0 + 15, y0, y1: y0 + 15};
|
|
}
|
|
toJSON() {
|
|
return {};
|
|
}
|
|
}
|
|
}
|
|
static properties = {
|
|
willInteractWith: {type: 'uint32'},
|
|
};
|
|
}
|