Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove double-iteration from the mime wall code #31420

Merged
merged 3 commits into from
Aug 27, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions Content.Server/Abilities/Mime/MimePowersSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Content.Shared.Alert;
using Content.Shared.Coordinates.Helpers;
using Content.Shared.Maps;
using Content.Shared.Mobs.Components;
using Content.Shared.Physics;
using Robust.Shared.Containers;
using Robust.Shared.Map;
Expand All @@ -19,7 +18,6 @@ public sealed class MimePowersSystem : EntitySystem
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
[Dependency] private readonly EntityLookupSystem _lookupSystem = default!;
[Dependency] private readonly TurfSystem _turf = default!;
[Dependency] private readonly IMapManager _mapMan = default!;
[Dependency] private readonly SharedContainerSystem _container = default!;
Expand Down Expand Up @@ -80,22 +78,13 @@ private void OnInvisibleWall(EntityUid uid, MimePowersComponent component, Invis
if (tile == null)
return;

// Check there are no walls there
if (_turf.IsTileBlocked(tile.Value, CollisionGroup.Impassable))
// Check if the tile is blocked by a wall or mob, and don't create the wall if so
if (_turf.IsTileBlocked(tile.Value, CollisionGroup.MobLayer | CollisionGroup.WallLayer))
{
_popupSystem.PopupEntity(Loc.GetString("mime-invisible-wall-failed"), uid, uid);
return;
}

// Check there are no mobs there
foreach (var entity in _lookupSystem.GetLocalEntitiesIntersecting(tile.Value, 0f))
{
if (HasComp<MobStateComponent>(entity) && entity != uid)
{
_popupSystem.PopupEntity(Loc.GetString("mime-invisible-wall-failed"), uid, uid);
return;
}
}
_popupSystem.PopupEntity(Loc.GetString("mime-invisible-wall-popup", ("mime", uid)), uid);
// Make sure we set the invisible wall to despawn properly
Spawn(component.WallPrototype, _turf.GetTileCenter(tile.Value));
Expand Down
Loading