extend("fiskheroes:hero_basic");
loadTextures({
	"layer1": "tgheroes:fantastic4/reed/reed_layer1",
    "layer2": "tgheroes:fantastic4/reed/reed_layer2",
	"arm": "tgheroes:fantastic4/reed/default_arm",
	"hammer_hand": "tgheroes:fantastic4/reed/default_hammer",
	"fist": "tgheroes:fantastic4/reed/default_fist"
});

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

function initEffects(renderer) {
  
	var arm = utils.createModel(renderer, "tgheroes:fantasticarm", "arm");
	var stretchfist = utils.createModel(renderer, "tgheroes:stretchfist", "fist");
	var tentacles = renderer.bindProperty("fiskheroes:tentacles").setTentacles([
        { "offset": [3.0, -3.0, 1.0], "direction": [13.0, 0.0, 0] },
        { "offset": [-3.0, -3.0, -1.0], "direction": [-13.0, 0.0, 0] }
    ]);
    tentacles.anchor.set("body");
    tentacles.setSegmentModel(arm);
	tentacles.setHeadModel(stretchfist);
    tentacles.segmentLength = 1.0;
    tentacles.segments = 30;

	var model_hammer_hand = renderer.createResource("MODEL", "tgheroes:fantastichammer");
    model_hammer_hand.texture.set("hammer_hand");


    hammer_hand = renderer.createEffect("fiskheroes:model").setModel(model_hammer_hand);
    hammer_hand.anchor.set("rightArm");
    hammer_hand.setScale(1);
}

function initAnimations(renderer) {
    parent.initAnimations(renderer);
    renderer.removeCustomAnimation("basic.ARMS");
    addAnimationWithData(renderer, "basic.ARMS", "tgheroes:long_arms", "fiskheroes:tentacles")
        .priority = -5;    
}

function render(entity, renderLayer, isFirstPersonArm) {
    if (renderLayer == "CHESTPLATE") {
        if (entity.getData("fiskheroes:blade_timer") > 0.9) {
            var blade_anchor = hammer_hand.anchor.set("rightArm");
            var blade_offSet = hammer_hand.setOffset(3.3, 13.0, 2.0);
            var blade_rot = hammer_hand.setRotation(180, 0, 0);
        			
            hammer_hand.anchor = blade_anchor, blade_offSet, blade_rot;
            hammer_hand.render();
        }
}
}