import * as utils from "../utils/index";
export class WornHat {
    constructor(wearer) {
        this.hatTypeId = "";
        this.hatWearer = wearer;
        this.cancelCategory = this.constructor.name + wearer.Entity.id;
    }
}
WornHat.LoreTable = {};
WornHat.HatTable = {};
export class WornHatEffect extends WornHat {
    constructor() {
        super(...arguments);
        this.effectData = [];
    }
    async onEquip() {
        utils.waitForLoopEvent(20, () => {
            this.effectData.forEach(data => {
                if (!data.condition || data.condition(this.hatWearer.Entity)) {
                    this.hatWearer.Entity.addEffect(data.type, 1200, { amplifier: data.amplifier, showParticles: false });
                }
                else {
                    this.hatWearer.Entity.removeEffect(data.type);
                }
            });
            return !this.hatWearer.Entity.isValid();
        }, this.cancelCategory);
    }
    async onUnequip() {
        utils.abortEvents(this.cancelCategory);
        if (this.hatWearer.Entity.isValid()) {
            this.effectData.forEach(data => this.hatWearer.Entity.removeEffect(data.type));
        }
    }
}
