make explosions affect containers (#21625)
Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
@@ -406,6 +406,19 @@ public sealed partial class ExplosionSystem
|
||||
_damageableSystem.TryChangeDamage(uid, damage, ignoreResistances: true, damageable: damageable);
|
||||
}
|
||||
|
||||
// if it's a container, try to damage all its contents
|
||||
if (_containersQuery.TryGetComponent(uid, out var containers))
|
||||
{
|
||||
foreach (var container in containers.Containers.Values)
|
||||
{
|
||||
foreach (var ent in container.ContainedEntities)
|
||||
{
|
||||
// setting throw force to 0 to prevent offset items inside containers
|
||||
ProcessEntity(ent, epicenter, damage, 0f, id, _transformQuery.GetComponent(uid));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// throw
|
||||
if (xform != null // null implies anchored
|
||||
&& !xform.Anchored
|
||||
|
||||
@@ -21,6 +21,7 @@ using Robust.Server.GameStates;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Player;
|
||||
@@ -51,6 +52,7 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
|
||||
|
||||
private EntityQuery<TransformComponent> _transformQuery;
|
||||
private EntityQuery<ContainerManagerComponent> _containersQuery;
|
||||
private EntityQuery<DamageableComponent> _damageQuery;
|
||||
private EntityQuery<PhysicsComponent> _physicsQuery;
|
||||
private EntityQuery<ProjectileComponent> _projectileQuery;
|
||||
@@ -104,6 +106,7 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
InitVisuals();
|
||||
|
||||
_transformQuery = GetEntityQuery<TransformComponent>();
|
||||
_containersQuery = GetEntityQuery<ContainerManagerComponent>();
|
||||
_damageQuery = GetEntityQuery<DamageableComponent>();
|
||||
_physicsQuery = GetEntityQuery<PhysicsComponent>();
|
||||
_projectileQuery = GetEntityQuery<ProjectileComponent>();
|
||||
|
||||
Reference in New Issue
Block a user