import { Assets, Container, utils } from "pixi.js";
import { HitSprite } from "../interactions/HitSprite";
export class AvatarLayer extends Container {
    constructor(avatar, configuration) {
        super();
        this._avatar = avatar;
        this._type = configuration.type;
        this._part = configuration.part;
        this._gesture = configuration.gesture;
        this._tint = configuration.tint;
        this._z = configuration.z;
        this._flip = configuration.flip;
        this._direction = configuration.direction;
        this._frame = configuration.frame;
        this._alpha = configuration.alpha;
        this._draw();
    }
    _draw() {
        let tempDirection = this._direction;
        if (this._flip && [4, 5, 6].includes(tempDirection))
            this.scale.x = -1;
        if (this._flip && [4, 5, 6].includes(tempDirection))
            this.x = 64;
        if ([4, 5, 6].includes(tempDirection) && this._flip) {
            tempDirection = 6 - tempDirection;
        }
        const avatarActions = Assets.get("figures/actions");
        //if(this._type === "ls" || this._type === "lh" || this._type === "lc") console.log(2, this._part.lib.id + "_h_" + this._gesture + "_" + this._type + "_" + this._part.id + "_" + tempDirection + "_" + this._frame);
        const sprite = new HitSprite(Assets.get("figures/" + this._part.lib.id).textures[this._part.lib.id + "_h_" + this._gesture + "_" + this._type + "_" + this._part.id + "_" + tempDirection + "_" + this._frame]);
        if (this._tint !== undefined)
            sprite.tint = utils.premultiplyTint(this._tint, 0.999);
        if (this._z !== undefined)
            this.zIndex = this._z;
        if (this._alpha !== undefined)
            sprite.alpha = this._alpha;
        //sprite.animationSpeed = 0.167;
        //sprite.play();
        sprite.interactive = true;
        sprite.on("pointerdown", (event) => this._avatar.interactionManager.handlePointerDown({ mouseEvent: event }));
        sprite.on("pointerup", (event) => this._avatar.interactionManager.handlePointerUp({ mouseEvent: event }));
        sprite.on("pointermove", (event) => this._avatar.interactionManager.handlePointerMove({ mouseEvent: event }));
        sprite.on("pointerout", (event) => this._avatar.interactionManager.handlePointerOut({ mouseEvent: event }));
        sprite.on("pointerover", (event) => this._avatar.interactionManager.handlePointerOver({ mouseEvent: event }));
        this.addChild(sprite);
    }
    get avatar() {
        return this._avatar;
    }
}
//# sourceMappingURL=AvatarLayer.js.map