feat: Enemies
This commit is contained in:
@@ -3,7 +3,7 @@ using UnityEngine;
|
||||
namespace Arena.Combat
|
||||
{
|
||||
/// <summary>
|
||||
/// Everything a hit carries: amount, type and source. Passed to IDamageable.TakeDamage.
|
||||
/// Everything a hit carries: amount, type, source and targeted team. Passed to IDamageable.TakeDamage.
|
||||
/// </summary>
|
||||
public readonly struct DamageInfo
|
||||
{
|
||||
@@ -16,11 +16,33 @@ namespace Arena.Combat
|
||||
/// </summary>
|
||||
public readonly GameObject Source;
|
||||
|
||||
public DamageInfo(int amount, DamageType type, GameObject source = null)
|
||||
/// <summary>
|
||||
/// Team hurt by this damage: Allied for enemy shots, Enemy for player shots, All for everyone.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if this damage can hurt an IDamageable of the given team.
|
||||
/// </summary>
|
||||
public bool CanHit(Team team)
|
||||
{
|
||||
return CanHit(Target, team);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if a damage targeting a team can hurt an IDamageable of another team.
|
||||
/// </summary>
|
||||
public static bool CanHit(Team target, Team team)
|
||||
{
|
||||
return target == Team.All || team == Team.All || team == target;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user