extend("fiskheroes:hero_basic");
loadTextures({
    "layer1": "skarredheroes:super/superman_christmas_layer1",
    "layer2": "skarredheroes:super/superman_christmas_layer2",
	"boots": "skarredheroes:super/superman_christmas_boots",
	"jacket": "skarredheroes:super/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, "skarredheroes:superman_christmas");
    utils.bindTrail(renderer, "skarredheroes:superman_boost_christmas").setCondition(entity => entity.getData("fiskheroes:dyn/flight_super_boost") > 0);

    utils.bindParticles(renderer, "skarredheroes:freeze_breath").setCondition(entity => entity.getData("fiskheroes:beam_charging") && entity.getData("fiskheroes:beam_charge") < 1 || entity.getData("fiskheroes:beam_shooting") > 0);
    utils.bindParticles(renderer, "skarredheroes: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", "skarredheroes: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", "skarredheroes:impact_freeze_breath"));
}

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