extend("fiskheroes:hero_basic");
loadTextures({
    "layer1": "skarlet:harley_quinn/harley_quinn_layer1",
    "layer2": "skarlet:harley_quinn/harley_quinn_layer2",
	"roller_skates": "skarlet:harley_quinn/roller_skates",
	"hair": "skarlet:harley_quinn/hair",
	"hood": "skarlet:harley_quinn/jester_hood"
});

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

var l_leg;
var r_leg;
var hair;
var hood;

function init(renderer) {
    parent.init(renderer);
}

function initEffects(renderer) {
	var model_hair = renderer.createResource("MODEL", "skarlet:hair");
	model_hair.texture.set("hair");
    hair = renderer.createEffect("fiskheroes:model").setModel(model_hair);
    hair.anchor.set("head");

	var model_hood = renderer.createResource("MODEL", "skarlet:jester_hood");
	model_hood.texture.set("hood");
    hood = renderer.createEffect("fiskheroes:model").setModel(model_hood);
    hood.anchor.set("head");
	
    var model_l_leg = renderer.createResource("MODEL", "skarlet:rollerskate_left");
    model_l_leg.texture.set("roller_skates");
    l_leg = renderer.createEffect("fiskheroes:model").setModel(model_l_leg);
    l_leg.anchor.set("leftLeg");

    var model_r_leg = renderer.createResource("MODEL", "skarlet:rollerskate_right");
    model_r_leg.texture.set("roller_skates");
    r_leg = renderer.createEffect("fiskheroes:model").setModel(model_r_leg);
    r_leg.anchor.set("rightLeg");
	
    chest = renderer.createEffect("fiskheroes:chest");
    chest.setExtrude(1.5).setYOffset(1);

    utils.bindTrail(renderer, "skarlet:harley_quinn");
}

function initAnimations(renderer) {
    parent.initAnimations(renderer);

    var anim_sprint = renderer.createResource("ANIMATION", "skarlet:skating");
    anim_sprint.setData((entity, data) => data.load(entity.getInterpolatedData("fiskheroes:dyn/speed_sprint_timer") && entity.isOnGround())).priority = -10;
    renderer.addCustomAnimation("harley.SPRINT", anim_sprint);
    
    addAnimation(renderer, "harley.IDLE", "skarlet:skates").setData((entity, data) => {
        data.load(1);
    })

    renderer.reprioritizeDefaultAnimation("PUNCH", 10);
}

function hasHair() {
    return true;
}

function render(entity, renderLayer, isFirstPersonArm) {
    if (!isFirstPersonArm) {
        if (renderLayer == "HELMET") {
            hasHair() ? hair.render() : hood.render(); 
	    }
        if (renderLayer == "CHESTPLATE") {
		chest.render();
        }
	    if (renderLayer == "BOOTS") {
			l_leg.render();
			r_leg.render();
        }
    }
}
