import {System} from '@/ecs/index.js'; import {distance} from '@/util/math.js'; export default class InventoryCloser extends System { static queries() { return { default: ['Player'], }; } tick() { for (const {Player, Position} of this.select('default')) { const {openInventory} = Player; if (openInventory) { const {Position: inventoryPosition} = this.ecs.get(openInventory.entity); if (distance(Position, inventoryPosition) > 64) { Player.closeInventory(); } } } } }