checkCanReceiveDamage method

bool checkCanReceiveDamage(
  1. AttackOriginEnum attacker
)

This method is used to check if this component can receive damage from any attacker.

Implementation

bool checkCanReceiveDamage(AttackOriginEnum attacker) {
  if (isDead || isRemoving) return false;
  switch (receivesAttackFrom) {
    case AcceptableAttackOriginEnum.ALL:
      return true;
    case AcceptableAttackOriginEnum.ENEMY:
      if (attacker == AttackOriginEnum.ENEMY ||
          attacker == AttackOriginEnum.WORLD) {
        return true;
      }
      break;
    case AcceptableAttackOriginEnum.PLAYER_AND_ALLY:
      if (attacker == AttackOriginEnum.PLAYER_OR_ALLY ||
          attacker == AttackOriginEnum.WORLD) {
        return true;
      }
      break;
    case AcceptableAttackOriginEnum.NONE:
      return false;
  }

  return false;
}