Selectively revert gun penetration (#25551)

The collision layer check doesn't work and I don't have time to fix it.
This commit is contained in:
metalgearsloth
2024-02-25 21:58:08 +11:00
committed by GitHub
parent e52ebe0ebd
commit ec5edc3626
5 changed files with 1 additions and 79 deletions

View File

@@ -169,33 +169,6 @@ public abstract partial class SharedProjectileSystem : EntitySystem
/// </summary>
private void AfterProjectileHit(EntityUid uid, ProjectileComponent component, ref AfterProjectileHitEvent args)
{
if (!TryComp<CanPenetrateComponent>(uid, out var damageAfterCollide))
return;
//Delete the projectile if it hits an entity with a CollisionLayer that has a higher value than it's PenetrationLayer.
//This allows a projectile to only penetrate a specific set of entities.
if (damageAfterCollide.PenetrationLayer != null)
{
if (args.Fixture.CollisionLayer > (int) damageAfterCollide.PenetrationLayer ||
damageAfterCollide.PenetrationPower == 0)
{
QueueDel(uid);
return;
}
}
//Allow the projectile to deal damage again.
if(damageAfterCollide.DamageAfterCollide)
component.DamagedEntity = false;
//If the projectile has a limit on the amount of penetrations, reduce it.
if (damageAfterCollide.PenetrationPower != null)
damageAfterCollide.PenetrationPower -= 1;
//Apply the penetration damage modifier if the projectile has one.
if (damageAfterCollide.DamageModifier != null)
component.Damage *= damageAfterCollide.DamageModifier.Value;
//Overrides the original DeleteOnCollide if the projectile passes all penetration checks.
//This is to prevent having to set DeleteOnCollide to false on every prototype
//you want to give the ability to penetrate entities.