Пример #1
0
 public static void use(Entity entity, String name) {
   Ability abilityComponent = EntityUtil.getComponent(entity, Ability.class);
   if (abilityComponent == null) {
     return;
   }
   AbilityInfo ability = abilityComponent.getAbility(name);
   if (ability == null) {
     return;
   }
   ability.getAbility().cast(entity);
   ability.setLastCast(TimeUtil.getGameTime());
 }
Пример #2
0
 public static boolean isAvailable(Entity entity, String name) {
   Ability abilityComponent = EntityUtil.getComponent(entity, Ability.class);
   if (abilityComponent == null) {
     return false;
   }
   AbilityInfo ability = abilityComponent.getAbility(name);
   if (ability == null) {
     return false;
   }
   long lastCast = ability.getLastCast();
   return lastCast == -1 || (TimeUtil.getGameTime() - lastCast > ability.getCooldown());
 }