extend("ahhp:hero_with_models");

var utils = implement("fiskheroes:external/utils");
var models_stuff = implement("ahhp:external/model_stuff");
var capes = implement("fiskheroes:external/capes");

loadTextures({
    "cape": "ahhp:omni_man_cape",
    "model": "ahhp:omni_man_model"
});

function init(renderer) {
    parent.init(renderer);
    renderer.fixHatLayer("CHESTPLATE");
    renderer.showModel("CHESTPLATE", "body", "rightArm", "leftArm");
    renderer.showModel("LEGGINGS", "rightLeg", "leftLeg");
    initEffects(renderer);
}
function initAnimations(renderer) {
    parent.initAnimations(renderer);
    utils.addFlightAnimationWithLanding(renderer, "omniman.FLIGHT", "fiskheroes:flight/default_arms_forward.anim.json");
    utils.addHoverAnimation(renderer, "omniman.HOVER", "fiskheroes:flight/idle/neutral");
    addAnimationWithData(renderer, "omniman.LAND", "fiskheroes:superhero_landing", "fiskheroes:dyn/superhero_landing_timer")
        .priority = -8;
    addAnimationWithData(renderer, "omniman.ROLL", "fiskheroes:flight/barrel_roll", "fiskheroes:barrel_roll_timer")
        .priority = 10;
}

function initEffects(renderer) {
    models = models_stuff.noHelmetModels(renderer, "omni_man");
    models_stuff.bindSpeedingTrail(renderer, "ahhp:omni_man");
    var physics = renderer.createResource("CAPE_PHYSICS", null);
    physics.maxFlare = 0.4;
    cape = capes.createDefault(renderer, 24, "fiskheroes:cape_default.mesh.json", physics);
    cape.effect.texture.set("cape");
    cape.effect.width = 14;

}

function render(entity, renderLayer, isFirstPersonArm) {
    models.render(entity, renderLayer);
    if (!isFirstPersonArm && renderLayer == "CHESTPLATE") {
        cape.render(entity);
    }
}
