extend("fiskheroes:hero_basic");
loadTextures({
    "layer1": "tgheroes:sandman/sandman_layer1",
    "layer2": "tgheroes:sandman/sandman_layer2",
	"sand": "tgheroes:sandman/sand_overlay",
    "sand_mace": "tgheroes:sandman/sand"
});

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

function initEffects(renderer) {
	var model_mace = renderer.createResource("MODEL", "tgheroes:sand_mace");
    model_mace.texture.set("sand_mace");
    sand_mace = renderer.createEffect("fiskheroes:model").setModel(model_mace);
    sand_mace.anchor.set("rightArm");
    sand_mace.setScale(1);
	
	overlay = renderer.createEffect("fiskheroes:overlay");
    overlay.texture.set("sand");
	
	utils.setOpacityWithData(renderer, 0.0, 1.0, "fiskheroes:shadowform_timer");
    utils.bindCloud(renderer, "fiskheroes:particle_cloud", "tgheroes:sand_cloud").setCondition(entity => entity.getData("fiskheroes:shadowform"));
}

function render(entity, renderLayer, isFirstPersonArm) {
	if (entity.getData("fiskheroes:blade_timer") > 0.9) {
		var blade_anchor = sand_mace.anchor.set("rightArm");
		var blade_offSet = sand_mace.setOffset(3.2, 6.0, -2.2);
		var blade_rot = sand_mace.setRotation(0, 0, 0);
		sand_mace.anchor = blade_anchor, blade_offSet, blade_rot;
		sand_mace.render();
	}
	if (renderLayer == "HELMET" || renderLayer == "CHESTPLATE" || renderLayer == "LEGGINGS" || renderLayer == "BOOTS") {
        overlay.opacity = entity.getInterpolatedData("fiskheroes:dyn/giant_mode");
        overlay.render();
	}
}