summaryrefslogtreecommitdiff
path: root/Bullet.cs
diff options
context:
space:
mode:
authoralex <[email protected]>2026-11-23 12:00:20 +0100
committeralex <[email protected]>2026-11-23 12:00:20 +0100
commit7f4bd1856869d7ae10fa8f07708fbd75c5bb7b1e (patch)
treee1fa2d87a79bc8bae87da9e62b19521fe27643e5 /Bullet.cs
parent45326f4f10ba2af92ff5d35f0f63e1dc35a4f8eb (diff)
downloadgodot-testing-7f4bd1856869d7ae10fa8f07708fbd75c5bb7b1e.tar.xz
godot-testing-7f4bd1856869d7ae10fa8f07708fbd75c5bb7b1e.zip
Diffstat (limited to 'Bullet.cs')
-rw-r--r--Bullet.cs11
1 files changed, 10 insertions, 1 deletions
diff --git a/Bullet.cs b/Bullet.cs
index 9202e3a..6df2903 100644
--- a/Bullet.cs
+++ b/Bullet.cs
@@ -6,6 +6,7 @@ public partial class Bullet : Area2D
[Export] public float Speed { get; set; } = 600.0f;
[Export] public float Damage { get; set; } = 10.0f;
public bool PierceEntity { get; set; } = false;
+ public int EntityPierceCount { get; set; } = 0;
public bool PierceTerrain { get; set; } = false;
public bool ricochet { get; set; } = true;
public int BounceLimit { get; set; } = 5;
@@ -62,11 +63,19 @@ public partial class Bullet : Area2D
if (collider is IDamageable target)
{
target.TakeDamage(Damage);
- if (!PierceEntity)
+
+ bool canPierceEntity = PierceEntity || EntityPierceCount > 0;
+ if (!canPierceEntity)
{
QueueFree();
return;
}
+
+ if (!PierceEntity && EntityPierceCount > 0)
+ {
+ EntityPierceCount--;
+ }
+
GlobalPosition = hitPos + Direction * 0.1f;
}
else