extend("fiskheroes:hero_basic");
loadTextures({
	"hair": "tgheroes:wonder_woman/wonder_hair",
	"suit": "tgheroes:wonder_woman/wonder_suit",
    "leggings": "tgheroes:wonder_woman/wonder_legs",
	"leggings_boots": "tgheroes:wonder_woman/wonder_legs_nb",
    "boots": "tgheroes:wonder_woman/wonder_boots",
	"suit_hair": "tgheroes:wonder_woman/wonder_suit_hair",
	"sword": "tgheroes:wonder_woman/wonder_sword"
});

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


function init(renderer) {
    parent.init(renderer);
    renderer.setTexture((entity, renderLayer) => {
        if (renderLayer == "CHESTPLATE") {
            return entity.getWornHelmet().suitType() == $SUIT_NAME ? "suit_hair" : "suit";
        }
	    else if (renderLayer == "LEGGINGS") {
            return entity.getWornBoots().suitType() == $SUIT_NAME ? "leggings" : "leggings_boots";
		}
        return renderLayer == "HELMET" ? "hair" : "boots" 
    });

    renderer.showModel("HELMET", "head", "headwear", "body");
    renderer.showModel("CHESTPLATE", "body", "rightArm", "leftArm");
    renderer.showModel("LEGGINGS", "body", "rightLeg", "leftLeg");
}

function initEffects(renderer) {	
    chest = renderer.createEffect("fiskheroes:chest");
    chest.setExtrude(1).setYOffset(1);
	
	var model_sword = renderer.createResource("MODEL", "tgheroes:wondersword");
    model_sword.texture.set("sword");
    model_sword.generateMirror();

    sword = renderer.createEffect("fiskheroes:model").setModel(model_sword);
    sword.anchor.set("rightArm");
    sword.setScale(1);

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

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

function initAnimations(renderer) {
    parent.initAnimations(renderer);
    utils.addFlightAnimation(renderer, "magic1.FLIGHT", "fiskheroes:flight/propelled_hands.anim.json");
    utils.addHoverAnimation(renderer, "magic1.HOVER", "fiskheroes:flight/idle/propelled_hands");

}

function render(entity, renderLayer, isFirstPersonArm) {
    if (!isFirstPersonArm && renderLayer == "CHESTPLATE") {
        chest.render();
    }
	if (renderLayer == "CHESTPLATE") {
        if (entity.getData("fiskheroes:blade_timer") > 0.3) {
            var blade_anchor = sword.anchor.set("rightArm");
            var blade_offSet = sword.setOffset(1.0, 9.0, -3.0);
            var blade_rot = sword.setRotation(90, 90, 0);
          
  
            sword.anchor = blade_anchor, blade_offSet, blade_rot;
            sword.render();
        }
        else {
            var back_anchor = back1.anchor.set("body");
            var back_offSet = back1.setOffset(4.0, -3.0, 2.5);
            var back_rot = back1.setRotation(0, 0, 140);
            back1.anchor = back_anchor, back_offSet, back_rot;
            back1.render();
        }

    }
}
