Skip to content

Commit

Permalink
Update ExplosionSystem.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
dvir001 committed Oct 6, 2023
1 parent 8e5acf7 commit 3b5180b
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions Content.Server/Explosion/EntitySystems/ExplosionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Content.Shared.GameTicking;
using Content.Shared.Inventory;
using Content.Shared.Throwing;
using Content.Shared.Tiles;
using Robust.Server.GameStates;
using Robust.Server.Player;
using Robust.Shared.Audio;
Expand All @@ -23,6 +24,8 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Utility;
using Content.Shared.Maps;
using Robust.Shared.Map.Components;

namespace Content.Server.Explosion.EntitySystems;

Expand All @@ -46,6 +49,8 @@ public sealed partial class ExplosionSystem : EntitySystem
[Dependency] private readonly PvsOverrideSystem _pvsSys = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;

[Dependency] private readonly IMapManager _mapMan = default!;

/// <summary>
/// "Tile-size" for space when there are no nearby grids to use as a reference.
/// </summary>
Expand Down Expand Up @@ -301,8 +306,6 @@ public void QueueExplosion(MapCoordinates epicenter,

var (area, iterationIntensity, spaceData, gridData, spaceMatrix) = results.Value;

var visualEnt = CreateExplosionVisualEntity(epicenter, type.ID, spaceMatrix, spaceData, gridData.Values, iterationIntensity);

// camera shake
CameraShake(iterationIntensity.Count * 2.5f, epicenter, totalIntensity);

Expand All @@ -314,6 +317,25 @@ public void QueueExplosion(MapCoordinates epicenter,
var filter = Filter.Pvs(epicenter).AddInRange(epicenter, audioRange);
SoundSystem.Play(type.Sound.GetSound(), filter, mapEntityCoords, _audioParams);

// Block explosions on safe zone
var location = mapEntityCoords;
var gridId = location.GetGridUid(EntityManager);
if (!HasComp<MapGridComponent>(gridId))
{
location = location.AlignWithClosestGridTile();
gridId = location.GetGridUid(EntityManager);
// Check if fixing it failed / get final grid ID
if (!HasComp<MapGridComponent>(gridId))
return null;
}
var mapGrid = _mapMan.GetGrid(gridId.Value);
var gridUid = mapGrid.Owner;
var ev = new FloorTileAttemptEvent();
if (HasComp<ProtectedGridComponent>(gridUid) || ev.Cancelled)
return null;

var visualEnt = CreateExplosionVisualEntity(epicenter, type.ID, spaceMatrix, spaceData, gridData.Values, iterationIntensity);

return new Explosion(this,
type,
spaceData,
Expand Down

0 comments on commit 3b5180b

Please sign in to comment.