using UnityEngine;
namespace Arena.Combat
{
///
/// Everything a hit carries: amount, type, source and targeted team. Passed to IDamageable.TakeDamage.
///
public readonly struct DamageInfo
{
public readonly int Amount;
public readonly DamageType Type;
///
/// Object that dealt the damage: shooter, damage zone... Can be null.
///
public readonly GameObject Source;
///
/// Team hurt by this damage: Allied for enemy shots, Enemy for player shots, All for everyone.
///
public readonly Team Target;
public DamageInfo(int amount, DamageType type, GameObject source = null, Team target = Team.All)
{
Amount = amount;
Type = type;
Source = source;
Target = target;
}
///
/// True if this damage can hurt an IDamageable of the given team.
///
public bool CanHit(Team team)
{
return CanHit(Target, team);
}
///
/// True if a damage targeting a team can hurt an IDamageable of another team.
///
public static bool CanHit(Team target, Team team)
{
return target == Team.All || team == Team.All || team == target;
}
}
}