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

@@ -1,42 +0,0 @@
using Content.Shared.FixedPoint;
using Content.Shared.Physics;
using Robust.Shared.GameStates;
namespace Content.Shared.Projectiles;
[RegisterComponent, NetworkedComponent]
public sealed partial class CanPenetrateComponent : Component
{
/// <summary>
/// Should the projectile keep the ability to deal damage after colliding.
/// </summary>
[DataField]
public bool DamageAfterCollide = true;
/// <summary>
/// The CollisionLayer, up to and including the one set, the projectile is allowed to penetrate.
/// </summary>
///<remarks>
/// Can penetrate everything if this value is not set.
/// </remarks>
[DataField]
public CollisionGroup? PenetrationLayer;
/// <summary>
/// How many times the projectile is allowed to deal damage.
/// </summary>
/// <remarks>
/// Can deal damage on every collision if this value is not set.
/// </remarks>
[DataField]
public float? PenetrationPower;
/// <summary>
/// Modifies the damage of a projectile after it has penetrated an entity.
/// </summary>
/// <remarks>
/// Won't modify the projectile's damage if this value is not set.
/// </remarks>
[DataField]
public FixedPoint2? DamageModifier;
}

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.

View File

@@ -12,8 +12,6 @@
damage:
types:
Blunt: 4
- type: CanPenetrate
penetrationLayer: MobLayer
- type: StaminaDamageOnCollide
damage: 55
- type: TimedDespawn
@@ -33,8 +31,6 @@
damage:
types:
Piercing: 45
- type: CanPenetrate
penetrationLayer: MobLayer
- type: TimedDespawn
lifetime: 0.25
@@ -53,8 +49,6 @@
types:
Blunt: 1
Heat: 2
- type: CanPenetrate
penetrationLayer: MobLayer
- type: IgniteOnCollide
fireStacks: 3
count: 10

View File

@@ -810,8 +810,6 @@
mask:
- Impassable
- BulletImpassable
- type: CanPenetrate
penetrationLayer: MobLayer
- type: Vapor
active: true
- type: Appearance

View File

@@ -19,7 +19,6 @@
damage:
types:
Radiation: 25
- type: CanPenetrate
- type: Physics
- type: Fixtures
fixtures: