From abde29ed5a796d43e69527eb92be46d6b5331d14 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sat, 6 Feb 2021 06:43:50 +1100 Subject: [PATCH] Remove ExplosivePassable collision layer (#3084) * Remove ExplosivePassable collision layer Now we have tags which can do this cleaner. * Update typo * Vera's review Co-authored-by: Metal Gear Sloth --- Content.Server/Explosions/ExplosionHelper.cs | 12 +++++++----- Content.Shared/Physics/CollisionGroup.cs | 2 +- .../Entities/Constructible/Walls/girder.yml | 4 +++- Resources/Prototypes/tags.yml | 2 ++ 4 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 Resources/Prototypes/tags.yml diff --git a/Content.Server/Explosions/ExplosionHelper.cs b/Content.Server/Explosions/ExplosionHelper.cs index 60962b67ec..aa5a97e111 100644 --- a/Content.Server/Explosions/ExplosionHelper.cs +++ b/Content.Server/Explosions/ExplosionHelper.cs @@ -1,8 +1,10 @@ +#nullable enable using System; using System.Collections.Generic; using System.Linq; using Content.Server.GameObjects.Components.Explosion; using Content.Server.GameObjects.Components.Mobs; +using Content.Shared.GameObjects.Components.Tag; using Content.Shared.GameObjects.EntitySystems; using Content.Shared.Maps; using Content.Shared.Physics; @@ -39,7 +41,7 @@ namespace Content.Server.Explosions private static readonly float LightBreakChance = 0.3f; private static readonly float HeavyBreakChance = 0.8f; - private static bool IgnoreExplosivePassable(IEntity e) => (e.GetComponent().CollisionLayer & (int) CollisionGroup.ExplosivePassable) != 0; + private static bool IgnoreExplosivePassable(IEntity e) => e.HasTag("ExplosivePassable"); private static ExplosionSeverity CalculateSeverity(float distance, float devastationRange, float heaveyRange) { @@ -96,7 +98,7 @@ namespace Content.Server.Explosions continue; } - if (!entity.TryGetComponent(out IPhysicsComponent body) || body.PhysicsShapes.Count < 1) + if (!entity.TryGetComponent(out IPhysicsComponent? body) || body.PhysicsShapes.Count < 1) { continue; } @@ -117,7 +119,7 @@ namespace Content.Server.Explosions // Impassable entities are handled first. If they are damaged enough, they are destroyed and they may // be able to spawn a new entity. I.e Wall -> Girder. - // Girder has a layer ExplosivePassable, and the predicate make it so the entities with this layer are ignored + // Girder has a tag ExplosivePassable, and the predicate make it so the entities with this tag are ignored var epicenterMapPos = epicenter.ToMap(entityManager); foreach (var (entity, distance) in impassableEntities) { @@ -228,7 +230,7 @@ namespace Content.Server.Explosions var players = playerManager.GetPlayersInRange(epicenter, (int) Math.Ceiling(maxRange)); foreach (var player in players) { - if (player.AttachedEntity == null || !player.AttachedEntity.TryGetComponent(out CameraRecoilComponent recoil)) + if (player.AttachedEntity == null || !player.AttachedEntity.TryGetComponent(out CameraRecoilComponent? recoil)) { continue; } @@ -279,7 +281,7 @@ namespace Content.Server.Explosions int lightImpactRange = 0, int flashRange = 0) { // If you want to directly set off the explosive - if (!entity.Deleted && entity.TryGetComponent(out ExplosiveComponent explosive) && !explosive.Exploding) + if (!entity.Deleted && entity.TryGetComponent(out ExplosiveComponent? explosive) && !explosive.Exploding) { explosive.Explosion(); } diff --git a/Content.Shared/Physics/CollisionGroup.cs b/Content.Shared/Physics/CollisionGroup.cs index 5b676e8432..1916e72dea 100644 --- a/Content.Shared/Physics/CollisionGroup.cs +++ b/Content.Shared/Physics/CollisionGroup.cs @@ -1,3 +1,4 @@ +#nullable enable using System; using JetBrains.Annotations; using Robust.Shared.Map; @@ -23,7 +24,6 @@ namespace Content.Shared.Physics GhostImpassable = 1 << 6, // 64 Things impassible by ghosts/observers, ie blessed tiles or forcefields Underplating = 1 << 7, // 128 Things that are under plating Passable = 1 << 8, // 256 Things that are passable - ExplosivePassable = 1 << 9, // 512 Things that let the pressure of a explosion through MapGrid = MapGridHelpers.CollisionGroup, // Map grids, like shuttles. This is the actual grid itself, not the walls or other entities connected to the grid. MobMask = Impassable | MobImpassable | VaultImpassable | SmallImpassable, diff --git a/Resources/Prototypes/Entities/Constructible/Walls/girder.yml b/Resources/Prototypes/Entities/Constructible/Walls/girder.yml index 8895c3a02d..c1b1756643 100644 --- a/Resources/Prototypes/Entities/Constructible/Walls/girder.yml +++ b/Resources/Prototypes/Entities/Constructible/Walls/girder.yml @@ -24,7 +24,9 @@ - MobImpassable - VaultImpassable - SmallImpassable - - ExplosivePassable + - type: Tag + tags: + - ExplosivePassable - type: Pullable - type: Damageable resistances: metallicResistances diff --git a/Resources/Prototypes/tags.yml b/Resources/Prototypes/tags.yml new file mode 100644 index 0000000000..489d564aac --- /dev/null +++ b/Resources/Prototypes/tags.yml @@ -0,0 +1,2 @@ +- type: Tag + id: ExplosivePassable