extend("fiskheroes:hero_basic");
loadTextures({
	"layer1": "tgheroes:guardians/drax_layer1",
    "layer2": "tgheroes:guardians/drax_layer2",
	"knife": "tgheroes:guardians/knife"
});

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

function initEffects(renderer) {

	
    var model_knife = renderer.createResource("MODEL", "tgheroes:draxknife");
    model_knife.texture.set("knife");
    model_knife.generateMirror();

    knife = renderer.createEffect("fiskheroes:model").setModel(model_knife);
    knife.anchor.set("rightArm");
    knife.setScale(0.5);
    knife.mirror = true;

	var model_back1 = renderer.createResource("MODEL", "tgheroes:draxknife");
    model_back1.texture.set("knife");

    back1 = renderer.createEffect("fiskheroes:model").setModel(model_back1);
    back1.setScale(0.5);	
	
	var model_back2 = renderer.createResource("MODEL", "tgheroes:draxknife");
    model_back2.texture.set("knife");

    back2 = renderer.createEffect("fiskheroes:model").setModel(model_back2);
    back2.setScale(0.5);	
}


function render(entity, renderLayer, isFirstPersonArm) {
    if (renderLayer == "CHESTPLATE") {
        if (entity.getData("fiskheroes:blade_timer") > 0.3) {
            var blade_anchor = knife.anchor.set("rightArm");
            var blade_offSet = knife.setOffset(1.0, 9.0, -8.5);
            var blade_rot = knife.setRotation(0, -90, 0);
          
  
            knife.anchor = blade_anchor, blade_offSet, blade_rot;
            knife.render();
        }
        else {
            var back_anchor = back1.anchor.set("body");
            var back_offSet = back1.setOffset(0.0, 7.0, 2.5);
            var back_rot = back1.setRotation(0, 0, -20);
            var back_anchor = back2.anchor.set("body");
            var back_offSet = back2.setOffset(0.0, 3.0, 2.5);
            var back_rot = back2.setRotation(0, 0, -40);

            back2.anchor = back_anchor, back_offSet, back_rot;
            back2.render();
            back1.anchor = back_anchor, back_offSet, back_rot;
            back1.render();
        }
    }
}
