extend("fiskheroes:hero_basic");
loadTextures({
	"hair": "tgheroes:medusa/medusa_wig",
	"suit": "tgheroes:medusa/medusa_suit",
	"suit_hair": "tgheroes:medusa/medusa_suit_hair",
	"boots_hair": "tgheroes:medusa/medusa_boots_hair",
    "legs": "tgheroes:medusa/medusa_legs",
    "legs_hair": "tgheroes:medusa/medusa_legs_hair",
    "boots": "tgheroes:medusa/medusa_boots", 
    "segment": "tgheroes:medusa/medusahair"
});

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

var chest;

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.getWornHelmet().suitType() == $SUIT_NAME ? "legs_hair" : "legs";
		}
		else if (renderLayer == "BOOTS") {
            return entity.getWornHelmet().suitType() == $SUIT_NAME ? "boots_hair" : "boots";
		}
		else if (renderLayer == "HELMET") {
            return entity.getWornHelmet().suitType() == $SUIT_NAME ? "hair" : "hair";
		}
    });

    renderer.showModel("HELMET", "head", "headwear", "body", "rightLeg", "leftLeg");
    renderer.showModel("CHESTPLATE", "body", "rightArm", "leftArm", "rightLeg", "leftLeg");
}
function initEffects(renderer) {
  
   var medusa_hair = utils.createModel(renderer, "tgheroes:medusa_hair", "segment");

    var tentacles = renderer.bindProperty("fiskheroes:tentacles").setTentacles([
        { "offset": [2.5, 1.0, -5.0], "direction": [0.0, 0.0, -5.0] },
        { "offset": [-2.5, 1.0, -5.0], "direction": [0.0, 0.0, -5.0] },
        { "offset": [1.0, 1.0, -5.0], "direction": [0.0, 0.0, -5.0] },
        { "offset": [-1.0, 1.0, -5.0], "direction": [0.0, 0.0, -5.0] },
        { "offset": [2.5, 2.0, -5.0], "direction": [0.0, 0.0, -5.0] },
        { "offset": [-2.5, 2.0, -5.0], "direction": [0.0, 0.0, -5.0] },
        { "offset": [1.0, 2.0, -5.0], "direction": [0.0, 0.0, -5.0] },
        { "offset": [-1.0, 2.0, -5.0], "direction": [0.0, 0.0, -5.0] },
        { "offset": [2.5, 3.0, -5.0], "direction": [0.0, 0.0, -5.0] },
        { "offset": [-2.5, 3.0, -5.0], "direction": [0.0, 0.0, -5.0] },
        { "offset": [1.0, 3.0, -5.0], "direction": [0.0, 0.0, -5.0] },
        { "offset": [-1.0, 3.0, -5.0], "direction": [0.0, 0.0, -5.0] },
        { "offset": [2.5, 4.0, -5.0], "direction": [0.0, 0.0, -5.0] },
        { "offset": [-2.5, 4.0, -5.0], "direction": [0.0, 0.0, -5.0] },
        { "offset": [1.0, 4.0, -5.0], "direction": [0.0, 0.0, -5.0] },
        { "offset": [-1.0, 4.0, -5.0], "direction": [0.0, 0.0, -5.0] },
        { "offset": [2.5, 5.0, -5.0], "direction": [0.0, 0.0, -5.0] },
        { "offset": [-2.5, 5.0, -5.0], "direction": [0.0, 0.0, -5.0] },
        { "offset": [1.0, 5.0, -5.0], "direction": [0.0, 0.0, -5.0] },
        { "offset": [-1.0, 5.0, -5.0], "direction": [0.0, 0.0, -5.0] },
        { "offset": [2.5, 6.0, -5.0], "direction": [0.0, 0.0, -5.0] },
        { "offset": [-2.5, 6.0, -5.0], "direction": [0.0, 0.0, -5.0] },
        { "offset": [1.0, 6.0, -5.0], "direction": [0.0, 0.0, -5.0] },
        { "offset": [-1.0, 6.0, -5.0], "direction": [0.0, 0.0, -5.0] },
			{ "offset": [-1.0, 4.0, 0.0], "direction": [7.0, 1.0, -1.0] },
			{ "offset": [-1.0, 5.0, 0.0], "direction": [7.0, 1.0, -1.0] },
			{ "offset": [-1.0, 6.0, 0.0], "direction": [7.0, 1.0, -1.0] },
			{ "offset": [1.0, 4.0, 0.0], "direction": [7.0, 1.0, -1.0] },
			{ "offset": [1.0, 5.0, 0.0], "direction": [7.0, 1.0, -1.0] },
			{ "offset": [1.0, 6.0, 0.0], "direction": [7.0, 1.0, -1.0] },
			{ "offset": [-1.0, 4.0, 0.0], "direction": [-7.0, 1.0, -1.0] },
			{ "offset": [-1.0, 5.0, 0.0], "direction": [-7.0, 1.0, -1.0] },
			{ "offset": [-1.0, 6.0, 0.0], "direction": [-7.0, 1.0, -1.0] },
			{ "offset": [1.0, 4.0, 0.0], "direction": [-7.0, 1.0, -1.0] },
			{ "offset": [1.0, 5.0, 0.0], "direction": [-7.0, 1.0, -1.0] },
			{ "offset": [1.0, 6.0, 0.0], "direction": [-7.0, 1.0, -1.0] }

    ]);
    tentacles.anchor.set("head");
    tentacles.setSegmentModel(medusa_hair);
    tentacles.segmentLength = 1.8;
    tentacles.segments = 16;
	
    chest = renderer.createEffect("fiskheroes:chest");
    chest.setExtrude(1).setYOffset(1); 
}

function render(entity, renderLayer, isFirstPersonArm) {
    if (!isFirstPersonArm && renderLayer == "CHESTPLATE") {
        chest.render();
    }
}