Clean up some parts of ExplosionSystem (#40485)

* Clean up some parts of ExplosionSystem

* Update Content.Shared/Damage/DamageSpecifier.cs

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

* Review

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
Leon Friedrich
2025-09-29 05:23:40 +13:00
committed by GitHub
parent fd5f9d7f60
commit f2d4317258
10 changed files with 109 additions and 54 deletions

View File

@@ -27,8 +27,6 @@ namespace Content.Server.Explosion.EntitySystems;
public sealed partial class ExplosionSystem
{
[Dependency] private readonly FlammableSystem _flammableSystem = default!;
/// <summary>
/// Used to limit explosion processing time. See <see cref="MaxProcessingTime"/>.
/// </summary>
@@ -446,7 +444,7 @@ public sealed partial class ExplosionSystem
GetEntitiesToDamage(uid, originalDamage, id);
foreach (var (entity, damage) in _toDamage)
{
if (damage.GetTotal() > 0 && TryComp<ActorComponent>(entity, out var actorComponent))
if (_actorQuery.HasComp(entity))
{
// Log damage to player entities only, cause this will create a massive amount of log spam otherwise.
if (cause != null)
@@ -461,7 +459,7 @@ public sealed partial class ExplosionSystem
}
// TODO EXPLOSIONS turn explosions into entities, and pass the the entity in as the damage origin.
_damageableSystem.TryChangeDamage(entity, damage * _damageableSystem.UniversalExplosionDamageModifier, ignoreResistances: true);
_damageableSystem.TryChangeDamage(entity, damage, ignoreResistances: true, ignoreGlobalModifiers: true);
}
}
@@ -668,6 +666,7 @@ sealed class Explosion
private readonly IEntityManager _entMan;
private readonly ExplosionSystem _system;
private readonly SharedMapSystem _mapSystem;
private readonly DamageableSystem _damageable;
public readonly EntityUid VisualEnt;
@@ -688,10 +687,10 @@ sealed class Explosion
int maxTileBreak,
bool canCreateVacuum,
IEntityManager entMan,
IMapManager mapMan,
EntityUid visualEnt,
EntityUid? cause,
SharedMapSystem mapSystem)
SharedMapSystem mapSystem,
DamageableSystem damageable)
{
VisualEnt = visualEnt;
Cause = cause;
@@ -706,6 +705,7 @@ sealed class Explosion
_maxTileBreak = maxTileBreak;
_canCreateVacuum = canCreateVacuum;
_entMan = entMan;
_damageable = damageable;
_xformQuery = entMan.GetEntityQuery<TransformComponent>();
_physicsQuery = entMan.GetEntityQuery<PhysicsComponent>();
@@ -760,8 +760,10 @@ sealed class Explosion
_expectedDamage = ExplosionType.DamagePerIntensity * _currentIntensity;
}
#endif
_currentDamage = ExplosionType.DamagePerIntensity * _currentIntensity;
var modifier = _currentIntensity
* _damageable.UniversalExplosionDamageModifier
* _damageable.UniversalAllDamageModifier;
_currentDamage = ExplosionType.DamagePerIntensity * modifier;
// only throw if either the explosion is small, or if this is the outer ring of a large explosion.
var doThrow = Area < _system.ThrowLimit || CurrentIteration > _tileSetIntensity.Count - 6;