import * as utils from "../../utils/index";
import * as comp from "../components/index";
import { BotBase } from "../bot";
export const GUARD_MAX_FUEL = 99;
export const GUARD_FUEL_ITEM = "minecraft:arrow";
const DAMAGE = 10;
export class GuardBot extends BotBase {
    onConstructed() {
        const currentRotation = this.getRotation();
        super.onConstructed();
        this.addActorComponent(comp.BotFuelComponent, { fuelItem: GUARD_FUEL_ITEM, max: GUARD_MAX_FUEL });
        this.addActorComponent(comp.BlockSnapComponent, { angle: 90 });
        this.setRotation({ x: currentRotation.x, y: currentRotation.y + 180 });
        this.subscribe("start_attack", this.onShoot.bind(this));
    }
    onShoot() {
        this.Fuel -= 1;
    }
    onFuelExhausted() {
        this.removeActorComponent(comp.AttackComponent);
        this.dimension.playSound(utils.addName("entity.bot.power_down"), this.location);
    }
    onFuelRestored() {
        utils.waitForEvent(30, () => {
            this.addActorComponent(comp.AttackComponent, {
                type: "range",
                duration: { dmgTime: 0.0, endTime: 0.5 },
                cooldown: 2,
                projectileTypeId: "minecraft:arrow",
                projectileOptions: { power: 3.5, on_hit: { damage: 10, filters: { excludeFamilies: [utils.addName("utility_bot")] } },
                },
            });
        });
    }
}
utils.Actor.makeActors({ type: "ldz_240927:guard_bot" }, GuardBot);
