Prevent projectiles from being affected by TryThrow() (#16185)
This commit is contained in:
@@ -8,7 +8,9 @@ using Content.Shared.Explosion;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Maps;
|
||||
using Content.Shared.Physics;
|
||||
using Content.Shared.Projectiles;
|
||||
using Content.Shared.Spawners.Components;
|
||||
using Content.Shared.Tag;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Physics;
|
||||
@@ -199,7 +201,8 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
EntityQuery<TransformComponent> xformQuery,
|
||||
EntityQuery<DamageableComponent> damageQuery,
|
||||
EntityQuery<PhysicsComponent> physicsQuery,
|
||||
LookupFlags flags)
|
||||
EntityQuery<TagComponent> tagQuery,
|
||||
EntityQuery<ProjectileComponent> projectileQuery)
|
||||
{
|
||||
var gridBox = new Box2(tile * grid.TileSize, (tile + 1) * grid.TileSize);
|
||||
|
||||
@@ -217,7 +220,7 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
// process those entities
|
||||
foreach (var xform in list)
|
||||
{
|
||||
ProcessEntity(xform.Owner, epicenter, damage, throwForce, id, damageQuery, physicsQuery, xform);
|
||||
ProcessEntity(xform.Owner, epicenter, damage, throwForce, id, xform, damageQuery, physicsQuery, xformQuery, tagQuery, projectileQuery);
|
||||
}
|
||||
|
||||
// process anchored entities
|
||||
@@ -226,7 +229,7 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
foreach (var entity in anchoredList)
|
||||
{
|
||||
processed.Add(entity);
|
||||
ProcessEntity(entity, epicenter, damage, throwForce, id, damageQuery, physicsQuery);
|
||||
ProcessEntity(entity, epicenter, damage, throwForce, id, null, damageQuery, physicsQuery, xformQuery, tagQuery, projectileQuery);
|
||||
}
|
||||
|
||||
// Walls and reinforced walls will break into girders. These girders will also be considered turf-blocking for
|
||||
@@ -260,7 +263,7 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
{
|
||||
// Here we only throw, no dealing damage. Containers n such might drop their entities after being destroyed, but
|
||||
// they should handle their own damage pass-through, with their own damage reduction calculation.
|
||||
ProcessEntity(xform.Owner, epicenter, null, throwForce, id, damageQuery, physicsQuery, xform);
|
||||
ProcessEntity(xform.Owner, epicenter, null, throwForce, id, xform, damageQuery, physicsQuery, xformQuery, tagQuery, projectileQuery);
|
||||
}
|
||||
|
||||
return !tileBlocked;
|
||||
@@ -299,7 +302,8 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
EntityQuery<TransformComponent> xformQuery,
|
||||
EntityQuery<DamageableComponent> damageQuery,
|
||||
EntityQuery<PhysicsComponent> physicsQuery,
|
||||
LookupFlags flags)
|
||||
EntityQuery<TagComponent> tagQuery,
|
||||
EntityQuery<ProjectileComponent> projectileQuery)
|
||||
{
|
||||
var gridBox = Box2.FromDimensions(tile * DefaultTileSize, (DefaultTileSize, DefaultTileSize));
|
||||
var worldBox = spaceMatrix.TransformBox(gridBox);
|
||||
@@ -315,7 +319,7 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
foreach (var xform in state.Item1)
|
||||
{
|
||||
processed.Add(xform.Owner);
|
||||
ProcessEntity(xform.Owner, epicenter, damage, throwForce, id, damageQuery, physicsQuery, xform);
|
||||
ProcessEntity(xform.Owner, epicenter, damage, throwForce, id, xform, damageQuery, physicsQuery, xformQuery, tagQuery, projectileQuery);
|
||||
}
|
||||
|
||||
if (throwForce <= 0)
|
||||
@@ -329,7 +333,7 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
|
||||
foreach (var xform in list)
|
||||
{
|
||||
ProcessEntity(xform.Owner, epicenter, null, throwForce, id, damageQuery, physicsQuery, xform);
|
||||
ProcessEntity(xform.Owner, epicenter, null, throwForce, id, xform, damageQuery, physicsQuery, xformQuery, tagQuery, projectileQuery);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,9 +379,12 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
DamageSpecifier? damage,
|
||||
float throwForce,
|
||||
string id,
|
||||
TransformComponent? xform,
|
||||
EntityQuery<DamageableComponent> damageQuery,
|
||||
EntityQuery<PhysicsComponent> physicsQuery,
|
||||
TransformComponent? xform = null)
|
||||
EntityQuery<TransformComponent> transformQuery,
|
||||
EntityQuery<TagComponent> tagQuery,
|
||||
EntityQuery<ProjectileComponent> projectileQuery)
|
||||
{
|
||||
// damage
|
||||
if (damage != null && damageQuery.TryGetComponent(uid, out var damageable))
|
||||
@@ -413,15 +420,22 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
}
|
||||
|
||||
// throw
|
||||
if (xform != null
|
||||
if (xform != null // null implies anchored
|
||||
&& !xform.Anchored
|
||||
&& throwForce > 0
|
||||
&& !EntityManager.IsQueuedForDeletion(uid)
|
||||
&& physicsQuery.TryGetComponent(uid, out var physics)
|
||||
&& physics.BodyType == BodyType.Dynamic)
|
||||
{
|
||||
// TODO purge throw helpers and pass in physics component
|
||||
_throwingSystem.TryThrow(uid, xform.WorldPosition - epicenter.Position, throwForce);
|
||||
var pos = _transformSystem.GetWorldPosition(xform, transformQuery);
|
||||
_throwingSystem.TryThrow(
|
||||
uid,
|
||||
pos - epicenter.Position,
|
||||
physics,
|
||||
xform,
|
||||
projectileQuery,
|
||||
tagQuery,
|
||||
throwForce);
|
||||
}
|
||||
|
||||
// TODO EXPLOSION puddle / flammable ignite?
|
||||
@@ -567,14 +581,14 @@ sealed class Explosion
|
||||
private readonly EntityQuery<TransformComponent> _xformQuery;
|
||||
private readonly EntityQuery<PhysicsComponent> _physicsQuery;
|
||||
private readonly EntityQuery<DamageableComponent> _damageQuery;
|
||||
private readonly EntityQuery<ProjectileComponent> _projectileQuery;
|
||||
private readonly EntityQuery<TagComponent> _tagQuery;
|
||||
|
||||
/// <summary>
|
||||
/// Total area that the explosion covers.
|
||||
/// </summary>
|
||||
public readonly int Area;
|
||||
|
||||
private readonly LookupFlags _flags = LookupFlags.None;
|
||||
|
||||
/// <summary>
|
||||
/// factor used to scale the tile break chances.
|
||||
/// </summary>
|
||||
@@ -625,14 +639,11 @@ sealed class Explosion
|
||||
_canCreateVacuum = canCreateVacuum;
|
||||
_entMan = entMan;
|
||||
|
||||
// yeah this should be a cvar, but this is only temporary anyways
|
||||
// see lookup todo
|
||||
if (Area > 100)
|
||||
_flags |= LookupFlags.Approximate;
|
||||
|
||||
_xformQuery = entMan.GetEntityQuery<TransformComponent>();
|
||||
_physicsQuery = entMan.GetEntityQuery<PhysicsComponent>();
|
||||
_damageQuery = entMan.GetEntityQuery<DamageableComponent>();
|
||||
_tagQuery = entMan.GetEntityQuery<TagComponent>();
|
||||
_projectileQuery = entMan.GetEntityQuery<ProjectileComponent>();
|
||||
|
||||
if (spaceData != null)
|
||||
{
|
||||
@@ -773,7 +784,8 @@ sealed class Explosion
|
||||
_xformQuery,
|
||||
_damageQuery,
|
||||
_physicsQuery,
|
||||
_flags);
|
||||
_tagQuery,
|
||||
_projectileQuery);
|
||||
|
||||
// If the floor is not blocked by some dense object, damage the floor tiles.
|
||||
if (canDamageFloor)
|
||||
@@ -794,7 +806,8 @@ sealed class Explosion
|
||||
_xformQuery,
|
||||
_damageQuery,
|
||||
_physicsQuery,
|
||||
_flags);
|
||||
_tagQuery,
|
||||
_projectileQuery);
|
||||
}
|
||||
|
||||
if (!MoveNext())
|
||||
|
||||
Reference in New Issue
Block a user