var boost = implement("diminpack:external/boost_space_travel");

function init(hero) {
    hero.setName("F.I.R.E.S.T.O.R.M/Blink/Diamond Man");
    hero.setAliases("flame");
    hero.setTier(5);

    
    hero.setChestplate("item.superhero_armor.piece.chestpiece");
    hero.setLeggings("item.superhero_armor.piece.pants");
    hero.setBoots("item.superhero_armor.piece.boots");
    hero.addAttribute("BASE_SPEED_LEVELS", 5,0);
    hero.addPowers("diminpack:firestorm_matrix");
    hero.addPowers("fiskheroes:speed_force");
    hero.addPowers("diminpack:space_travel");
    hero.addAttribute("PUNCH_DAMAGE", 6.0, 0);
    hero.addAttribute("SPRINT_SPEED", 0.15, 1);
    hero.addAttribute("JUMP_HEIGHT", 0.5, 0);
    hero.addAttribute("FALL_RESISTANCE", 0.8, 1);
    hero.addKeyBind("AIM", "key.shoot", 1);
    hero.addKeyBind("SUPER_SPEED", "key.superSpeed", 2);
    hero.addKeyBind("SLOW_MOTION", "key.slowMotion", 3);
    hero.addKeyBind("TELEPORT", "key.teleport", 5);
    hero.setModifierEnabled(isModifierEnabled);
    hero.setKeyBindEnabled(isKeyBindEnabled);
    hero.setHasProperty(hasProperty);
    hero.supplyFunction("canAim", canAim);

    hero.setDamageProfile(entity => (entity.getHeldItem().isEmpty() && !entity.getData("fiskheroes:mask_open"))? "FLAME_PUNCH" : null);
    hero.addDamageProfile("FLAME_PUNCH", {
        "types": {
            "BLUNT": 1.0,
            "FIRE": 0.4
        },
        "properties": {
            "HEAT_TRANSFER": 40,
            "IGNITE": 2
        }
    });

    hero.addSoundEvent("MASK_OPEN", "fiskheroes:flame_off");
    hero.addSoundEvent("MASK_CLOSE", "fiskheroes:flame_on");
}
function isKeyBindEnabled(entity, keyBind) {
    switch (keyBind) {
    case "AIM":
        return !entity.getData("fiskheroes:mask_open") ;
    case "TELEPORT":
        return !entity.getData("fiskheroes:mask_open");
    case "SUPER_SPEED":
        return !entity.getData("fiskheroes:flying");
    default:
        return true;  
    }
}
function hasProperty(entity, property) {
    return property == "MASK_TOGGLE" || property == "BREATHE_SPACE" && !entity.getData("fiskheroes:mask_open");
}

function isModifierEnabled(entity, modifier) {
    switch (modifier.name()) {
        case "fiskheroes:super_speed":
            return !entity.getData("fiskheroes:flying");
        case "fiskheroes:controlled_flight":
            return !entity.getData("fiskheroes:mask_open");
        case "fiskheroes:fireball":
            return !(entity.isSprinting() && entity.getData("fiskheroes:flying")) && !entity.getData("fiskheroes:mask_open");
        case "fiskheroes:flame_blast":
            return !(entity.isSprinting() && entity.getData("fiskheroes:flying"));
        default:
            return true;
    }
}

function canAim(entity) {
    return entity.getHeldItem().isEmpty() && !(entity.isSprinting() && entity.getData("fiskheroes:flying"));
}
