From e8da04ec81656aeea22f753bdc36cde82a122b23 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A1rk=C3=B6zi=20Gergely=20J=C3=A1nos?=
 <cycss7@inf.elte.hu>
Date: Mon, 21 Mar 2022 12:02:10 +0000
Subject: [PATCH] Destroy unit even if destination castle is destroyed (closes
 #61)

---
 Assets/Scripts/Logic/System/UnitDamagesCastleSystem.cs | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Assets/Scripts/Logic/System/UnitDamagesCastleSystem.cs b/Assets/Scripts/Logic/System/UnitDamagesCastleSystem.cs
index ea5d8fb..da27ed3 100644
--- a/Assets/Scripts/Logic/System/UnitDamagesCastleSystem.cs
+++ b/Assets/Scripts/Logic/System/UnitDamagesCastleSystem.cs
@@ -12,10 +12,12 @@ public class UnitDamagesCastleSystem : BaseSystem {
 	private void On(UnitMovedTileEvent e) {
 		Unit unit = e.Unit;
 		Castle enemyCastle = unit.World.Overview.GetEnemyTeam(unit.Owner).Castle;
-		if (enemyCastle.Health <= 0) return;
 
 		if (unit.TilePosition.Equals(enemyCastle.Position)) {
-			enemyCastle.Damage(unit, unit.Type.Damage);
+			if (!enemyCastle.IsDestroyed) {
+				enemyCastle.Damage(unit, unit.Type.Damage);
+			}
+
 			unit.World.DestroyUnit(unit);
 		}
 	}
-- 
GitLab