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

function init(hero) {
    hero.setName("Vision");
    hero.setTier(10);
    
    hero.setHelmet("item.superhero_armor.piece.head");
    hero.setChestplate("item.superhero_armor.piece.torso");
    hero.setLeggings("item.superhero_armor.piece.legs");
    hero.setBoots("item.superhero_armor.piece.boots");
    
    hero.addPowers("fiskheroes:water_breathing", "fiskheroes:bullet_immunity", "fiskheroes:cellular_regeneration", "fiskheroes:superhuman_durability", "pack:flightdensity", "pack:density", "pack:mind_stone", "fiskheroes:fire_immunity", "fiskheroes:explosion_immunity");

	hero.addAttribute("WEAPON_DAMAGE", 24, 0);
    hero.addAttribute("PUNCH_DAMAGE", 29, 0);
    hero.addAttribute("FALL_RESISTANCE", 100.0, 0);
    hero.addAttribute("JUMP_HEIGHT", 0.75, 1);
    hero.addAttribute("SPRINT_SPEED", 0.2, 1);
    
    hero.addKeyBind("HEAT_VISION", "key.mindStoneBlast", 1);
    hero.addKeyBind("INTANGIBILITY", "key.intangibility", 2);
   hero.addKeyBind("STEEL_TRANSFORM", "Increase Density", 4); 
	
	
    hero.setHasProperty(hasProperty);
    hero.setDefaultScale(1.1);
	
    hero.addAttributeProfile("STEEL", steelProfile);
    hero.setAttributeProfile(getAttributeProfile);
    hero.setModifierEnabled(isModifierEnabled);
	
  hero.setTickHandler((entity, manager) => {
        utils.flightOnIntangibility(entity, manager);
    });
}
function steelProfile(profile) {
	profile.addAttribute("WEAPON_DAMAGE", 24, 0);
    profile.addAttribute("PUNCH_DAMAGE", 31, 0);
    profile.addAttribute("SPRINT_SPEED", -0.5, 1);
	
}

function getAttributeProfile(entity) {
    return entity.getData("fiskheroes:dyn/steeled") ? "STEEL" : null;
}

function isModifierEnabled(entity, modifier) {
    return modifier.name() == "fiskheroes:transformation" || modifier.name() == "fiskheroes:cooldown" || entity.getData("fiskheroes:dyn/steeled")|| modifier != "fiskheroes:superhuman_durability" && modifier != "fiskheroes:fire_immunity" && modifier != "fiskheroes:explosion_immunity" && modifier != "fiskheroes:metal_skin";
}

function hasProperty(entity, property) {
    return property == "BREATHE_SPACE";
}
