extend("ahhp:hero_with_models");

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

loadTextures({
    "model": "ahhp:kid_flash_yj_model"
});

function init(renderer) {
    parent.init(renderer);
    renderer.showModel("HELMET", "head", "headwear");
    renderer.showModel("LEGGINGS", "rightLeg", "leftLeg");
    renderer.showModel("CHESTPLATE", "body", "rightArm", "leftArm");
    renderer.fixHatLayer("HELMET");
    initEffects(renderer);
    initAnimations(renderer);
}

function initEffects(renderer) {
    models = models_stuff.noHelmetModels(renderer, "kid_flash_yj");
    var head = renderer.createResource("MODEL", "ahhp:kid_flash_yj_head");
    head.texture.set("model");
    head.bindAnimation("ahhp:kid_flash_yj_mask").setData((entity, data) => {
		data.load(entity.getInterpolatedData("fiskheroes:mask_open_timer2") - 0.25);
	});
    head_model = renderer.createEffect("fiskheroes:model").setModel(head);
    head_model.anchor.set("head");
    models_stuff.bindSpeedingTrail(renderer, "ahhp:kid_flash");
}

function initAnimations(renderer) {
    addAnimationWithData(renderer, "kid_flash.ARMS", "ahhp:kid_flash_jy_arms", "fiskheroes:mask_open_timer2");
}

function render(entity, renderLayer, isFirstPersonArm) {
    models.render(entity, renderLayer);
    head_model.render();
}
