import * as mc from "@minecraft/server";
import { waitForTicks } from "../../utils/index";
import { Task } from "./task";
export class EmoteTask extends Task {
    async performTask() {
        this.shouldAbort();
        if (this.npc.Entity.isInWater) {
            return { outcome: "failed" };
        }
        this.npc.Entity.addEffect("slowness", this.options.emoteSeconds * 20, { showParticles: false, amplifier: 10 });
        this.npc.Entity.playAnimation(this.options.emoteAnimation, this.options.animOptions);
        if (this.options.emoteEvent)
            this.npc.broadcastEvent(this.options.emoteEvent);
        if (this.options.playSound)
            mc.world.playSound(this.options.playSound.sound, this.npc.Entity.location, { volume: this.options.playSound.volume });
        await waitForTicks(this.options.emoteSeconds * 20, this.id);
        return { outcome: "succeeded" };
    }
    async cleanupTask() {
        this.npc.Entity.removeEffect("slowness");
    }
}
