import Actor_Manager from "../../../Actor/Actor_Manager";
export const command_interact = {
    id: "bgs:interact",
    permission: 1,
    async run(command) {
        const argument = command.message.split(" ");
        const entity = command.sourceEntity;
        const players = entity.dimension.getPlayers({ location: entity.location });
        for (let i = 0; i < players.length; i++) {
            const ray = players[i].getEntitiesFromViewDirection()[0];
            if (players[i].getEntitiesFromViewDirection()[0] == undefined)
                continue;
            if (players[i].getEntitiesFromViewDirection()[0].entity.id != entity.id)
                continue;
            if (entity.typeId == "bgs:actor") {
                const actor = Actor_Manager.get(entity.id);
                if (actor == undefined)
                    break;
                Actor_Manager.interact(players[i], actor);
            }
            else {
                let texture = entity.getProperty("bgs:texture");
                if (players[i].isSneaking == false) {
                    entity.setProperty("bgs:texture", ++texture);
                    entity.playAnimation("animation.guide_book.turn");
                    players[i].playSound("item.book.page_turn");
                }
                else {
                    entity.setProperty("bgs:texture", --texture);
                    entity.playAnimation("animation.guide_book.turn");
                    players[i].playSound("item.book.page_turn");
                }
            }
            break;
        }
    },
};
