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; const direction = Direction.quantize(4); if (0 === direction) { x0 += 12 } if (1 === direction) { y0 += 12 } if (2 === direction) { x0 -= 12 } if (3 === direction) { y0 -= 12 } return {x0, x1: x0 + 15, y0, y1: y0 + 15}; } toJSON() { return {}; } } } static properties = { willInteractWith: {type: 'uint32'}, }; }