Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Perpetuum/Units/Unit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ protected virtual void OnRemovedFromZone(IZone zone) { }

protected virtual void OnBeforeRemovedFromZone(IZone zone) { }

public bool CannotTakeDamage => _damageProcessor?.CannotTakeDamage ?? true;

public void TakeDamage(DamageInfo damageInfo)
{
_damageProcessor.TakeDamage(damageInfo);
Expand Down
7 changes: 5 additions & 2 deletions src/Perpetuum/Zones/DamageProcessors/DamageProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ public void OnRequipUnit()
});
}

public bool CannotTakeDamage =>
!unit.InZone || unit.IsAttackable != ErrorCodes.NoError || unit.States.Dead || unit.IsInvulnerable;

public void TakeDamage(DamageInfo damageInfo)
{
if (!unit.InZone || unit.IsAttackable != ErrorCodes.NoError || unit.States.Dead || unit.IsInvulnerable)
if (CannotTakeDamage)
{
return;
}
Expand Down Expand Up @@ -84,7 +87,7 @@ private void ProcessFirstDamage(DamageInfo info)

private void ProcessDamage(DamageInfo damageInfo)
{
if (!unit.InZone || unit.IsAttackable != ErrorCodes.NoError || unit.States.Dead || unit.IsInvulnerable)
if (CannotTakeDamage)
{
return;
}
Expand Down
5 changes: 5 additions & 0 deletions src/Perpetuum/Zones/ZoneExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ public static void DoAoeDamage(this IZone zone, IBuilder<DamageInfo> damageBuild
continue;
}

if (unit.CannotTakeDamage)
{
continue;
}

LOSResult losResult = zone.IsInLineOfSight(damageInfo.attacker, unit, false);
if (losResult.hit)
{
Expand Down
Loading