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 <metalgearsloth@gmail.com>
This commit is contained in:
metalgearsloth
2021-02-06 06:43:50 +11:00
committed by GitHub
parent b3869985e0
commit abde29ed5a
4 changed files with 13 additions and 7 deletions

View File

@@ -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<IPhysicsComponent>().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();
}

View File

@@ -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,

View File

@@ -24,7 +24,9 @@
- MobImpassable
- VaultImpassable
- SmallImpassable
- ExplosivePassable
- type: Tag
tags:
- ExplosivePassable
- type: Pullable
- type: Damageable
resistances: metallicResistances

View File

@@ -0,0 +1,2 @@
- type: Tag
id: ExplosivePassable