using Core.Health; using UnityEngine; namespace ActionGameFramework.Health { /// /// Damage zone - an area that receives damage and gives it to the damageable behaviour /// Abstract base class because the actual damage mechanic can be based on Collisions or Triggers or some other mechanism /// [RequireComponent(typeof(Collider))] public abstract class DamageZone : MonoBehaviour { /// /// Allow the user to define the damageable behaviour that this zone corresponds to. /// This allows multiple damage zones to reference one damageable behaviour /// allowing locational damage. e.g. headshots. /// [Tooltip("If this is empty, DamageZone will try to use a DamageableBehaviour on the same object.")] public DamageableBehaviour damageableBehaviour; /// /// Allow scaling of the damage. This allows different zones to take different damage from same Damager. e.g. headshots /// public float damageScale = 1f; /// /// Scales the damage. /// /// The damage. /// Damage. protected float ScaleDamage(float damage) { return damageScale * damage; } /// /// Looks for the damageableBehaviour if it is not already assigned /// It may be assigned in editor or from a previous LazyLoad() call /// protected void LazyLoad() { if (damageableBehaviour != null) { return; } damageableBehaviour = GetComponent(); } } }