extend("fiskheroes:hero_basic");
loadTextures({
    "layer1": "skarlet:superman/superman_christmas_layer1",
    "layer2": "skarlet:superman/superman_christmas_layer2",
	"boots": "skarlet:superman/superman_christmas_boots",
	"jacket": "skarlet:superman/superman_christmas_jacket"
});

var utils = implement("fiskheroes:external/utils");

function init(renderer) {
    parent.init(renderer);
    renderer.fixHatLayer("CHESTPLATE");
    renderer.showModel("CHESTPLATE", "head", "headwear", "body", "rightArm", "leftArm", "rightLeg", "leftLeg");
    renderer.setTexture((entity, renderLayer) => {
        if (renderLayer == "CHESTPLATE") {
            return entity.getWornLeggings().suitType() == $SUIT_NAME ? "layer1" : "jacket";
        }
        else if (renderLayer == "LEGGINGS") {
            return entity.getWornChestplate().suitType() == $SUIT_NAME ? "layer1" : "layer2";
        }
        return "boots";
    });
}

function initEffects(renderer) {
    utils.addCameraShake(renderer, 0.1, 1.5, "fiskheroes:dyn/superhero_landing_timer");
	
    utils.bindTrail(renderer, "skarlet:superman_christmas");
    utils.bindTrail(renderer, "skarlet:superman_boost_christmas").setCondition(entity => entity.getData("fiskheroes:dyn/flight_super_boost") > 0);

    utils.bindParticles(renderer, "skarlet:freeze_breath").setCondition(entity => entity.getData("fiskheroes:beam_charging") && entity.getData("fiskheroes:beam_charge") < 1 || entity.getData("fiskheroes:beam_shooting") > 0);
    utils.bindParticles(renderer, "skarlet:freeze_breath_fp").setCondition(entity => entity.getData("fiskheroes:beam_charging") && entity.getData("fiskheroes:beam_charge") < 1 || entity.getData("fiskheroes:beam_shooting") > 0);
	
    utils.bindBeam(renderer, "fiskheroes:heat_vision", "fiskheroes:heat_vision", "head", 0xFF0000, [
        { "firstPerson": [2.2, 0.0, 2.0], "offset": [2.2, -3.3, -4.0], "size": [1.0, 0.5] },
        { "firstPerson": [-2.2, 0.0, 2.0], "offset": [-2.2, -3.3, -4.0], "size": [1.0, 0.5] }
    ]).setParticles(renderer.createResource("PARTICLE_EMITTER", "fiskheroes:impact_heat_vision"));

    utils.bindBeam(renderer, "fiskheroes:charged_beam", "skarlet:freeze_breath", "head", 0x4CB5FF, [
        { "firstPerson": [0.0, 3.15, 0.0], "offset": [0.0, -1.15, -4.0], "size": [1.0, 0.5] }
    ]).setParticles(renderer.createResource("PARTICLE_EMITTER", "skarlet:impact_freeze_breath"));
}

function initAnimations(renderer) {
    parent.initAnimations(renderer);
    utils.addFlightAnimationWithLanding(renderer, "superman.FLIGHT", "skarlet:flight/superman.anim.json");
    utils.addHoverAnimation(renderer, "superman.HOVER", "fiskheroes:flight/idle/default");
    addAnimationWithData(renderer, "superman.LAND", "skarlet:superman_landing", "fiskheroes:dyn/superhero_landing_timer")
        .priority = -8;
}