extend("fiskheroes:spider_man_base");
loadTextures({
    "layer1": "pack:spiderman_whatif_layer1",
    "layer2": "pack:spiderman_whatif_layer2",
    "web_wings": "fiskheroes:spider_man_wings",
    "mask": "pack:spiderman_whatif_mask.tx.json"
});

var web_wings;

function init(renderer) {
    parent.init(renderer);
	 renderer.setTexture((entity, renderLayer) => renderLayer == "LEGGINGS" ? "layer2" : renderLayer == "HELMET" && entity.getData("fiskheroes:mask_open_timer") > 0 ? "mask" : "layer1");

}

function initEffects(renderer) {
    web_wings = renderer.createEffect("fiskheroes:wingsuit");
    web_wings.texture.set("web_wings");
    web_wings.opacity = 0.99;

    renderer.bindProperty("fiskheroes:equipment_wheel").color.set(0x00DAFF);
}


function initAnimations(renderer) {
    parent.initAnimations(renderer);
    utils.addAnimationEvent(renderer, "WEBSWING_TRICK_RIGHT", [
        "fiskheroes:swing_rotate_right", "fiskheroes:swing_rotate_right1"
    ]);
    utils.addAnimationEvent(renderer, "WEBSWING_TRICK_LEFT", [
        "fiskheroes:swing_rotate_left", "fiskheroes:swing_rotate_left1"
    ]);
}

function render(entity, renderLayer, isFirstPersonArm) {
    if (!isFirstPersonArm && renderLayer == "CHESTPLATE") {
        web_wings.unfold = entity.getInterpolatedData("fiskheroes:wing_animation_timer");
        web_wings.render();
    }
}
