private void doDamage(
     EntityRef entity,
     int damageAmount,
     Prefab damageType,
     EntityRef instigator,
     EntityRef directCause) {
   HealthComponent health = entity.getComponent(HealthComponent.class);
   CharacterMovementComponent characterMovementComponent =
       entity.getComponent(CharacterMovementComponent.class);
   boolean ghost = false;
   if (characterMovementComponent != null) {
     ghost = (characterMovementComponent.mode == MovementMode.GHOSTING);
   }
   if ((health != null) && !ghost) {
     int damagedAmount = health.currentHealth - Math.max(health.currentHealth - damageAmount, 0);
     health.currentHealth -= damagedAmount;
     health.nextRegenTick =
         time.getGameTimeInMs() + TeraMath.floorToInt(health.waitBeforeRegen * 1000);
     entity.saveComponent(health);
     entity.send(new OnDamagedEvent(damageAmount, damagedAmount, damageType, instigator));
     if (health.currentHealth == 0 && health.destroyEntityOnNoHealth) {
       entity.send(new DestroyEvent(instigator, directCause, damageType));
     }
   }
 }
 private void doHeal(EntityRef entity, int healAmount, EntityRef instigator) {
   HealthComponent health = entity.getComponent(HealthComponent.class);
   if (health != null) {
     int healedAmount =
         Math.min(health.currentHealth + healAmount, health.maxHealth) - health.currentHealth;
     health.currentHealth += healedAmount;
     entity.saveComponent(health);
     entity.send(new OnHealedEvent(healAmount, healedAmount, instigator));
     if (health.currentHealth == health.maxHealth) {
       entity.send(new FullHealthEvent(instigator));
     }
   }
 }