Don't let someone block if they're too close or if they're in a doorway. (#9890)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -1,9 +1,12 @@
|
|||||||
using Content.Shared.Actions;
|
using Content.Shared.Actions;
|
||||||
using Content.Shared.Actions.ActionTypes;
|
using Content.Shared.Actions.ActionTypes;
|
||||||
using Content.Shared.Buckle.Components;
|
using Content.Shared.Buckle.Components;
|
||||||
|
using Content.Shared.Doors.Components;
|
||||||
using Content.Shared.Hands;
|
using Content.Shared.Hands;
|
||||||
using Content.Shared.Hands.EntitySystems;
|
using Content.Shared.Hands.EntitySystems;
|
||||||
using Content.Shared.IdentityManagement;
|
using Content.Shared.IdentityManagement;
|
||||||
|
using Content.Shared.Maps;
|
||||||
|
using Content.Shared.MobState.Components;
|
||||||
using Content.Shared.Physics;
|
using Content.Shared.Physics;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using Content.Shared.Toggleable;
|
using Content.Shared.Toggleable;
|
||||||
@@ -26,6 +29,7 @@ public sealed class BlockingSystem : EntitySystem
|
|||||||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
||||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||||
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
||||||
|
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -128,12 +132,33 @@ public sealed class BlockingSystem : EntitySystem
|
|||||||
|
|
||||||
if (component.BlockingToggleAction != null)
|
if (component.BlockingToggleAction != null)
|
||||||
{
|
{
|
||||||
|
//Don't allow someone to block if they're in a container.
|
||||||
if (_containerSystem.IsEntityInContainer(user) || !_mapManager.TryFindGridAt(xform.MapPosition, out var grid))
|
if (_containerSystem.IsEntityInContainer(user) || !_mapManager.TryFindGridAt(xform.MapPosition, out var grid))
|
||||||
{
|
{
|
||||||
CantBlockError(user);
|
CantBlockError(user);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Don't allow someone to block if someone else is on the same tile or if they're inside of a doorway
|
||||||
|
var playerTileRef = xform.Coordinates.GetTileRef();
|
||||||
|
if (playerTileRef != null)
|
||||||
|
{
|
||||||
|
var intersecting = _lookup.GetEntitiesIntersecting(playerTileRef.Value);
|
||||||
|
var mobQuery = GetEntityQuery<MobStateComponent>();
|
||||||
|
var doorQuery = GetEntityQuery<DoorComponent>();
|
||||||
|
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||||
|
|
||||||
|
foreach (var uid in intersecting)
|
||||||
|
{
|
||||||
|
if (uid != user && mobQuery.HasComponent(uid) || xformQuery.GetComponent(uid).Anchored && doorQuery.HasComponent(uid))
|
||||||
|
{
|
||||||
|
TooCloseError(user);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Don't allow someone to block if they're somehow not anchored.
|
||||||
_transformSystem.AnchorEntity(xform);
|
_transformSystem.AnchorEntity(xform);
|
||||||
if (!xform.Anchored)
|
if (!xform.Anchored)
|
||||||
{
|
{
|
||||||
@@ -168,6 +193,12 @@ public sealed class BlockingSystem : EntitySystem
|
|||||||
_popupSystem.PopupEntity(msgError, user, Filter.Entities(user));
|
_popupSystem.PopupEntity(msgError, user, Filter.Entities(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void TooCloseError(EntityUid user)
|
||||||
|
{
|
||||||
|
var msgError = Loc.GetString("action-popup-blocking-user-too-close");
|
||||||
|
_popupSystem.PopupEntity(msgError, user, Filter.Entities(user));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called where you want the user to stop blocking.
|
/// Called where you want the user to stop blocking.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -8,3 +8,5 @@ action-popup-blocking-other = {CAPITALIZE(THE($blockerName))} raises {POSS-ADJ($
|
|||||||
action-popup-blocking-disabling-other = {CAPITALIZE(THE($blockerName))} lowers {POSS-ADJ($blockerName)} {$shield}!
|
action-popup-blocking-disabling-other = {CAPITALIZE(THE($blockerName))} lowers {POSS-ADJ($blockerName)} {$shield}!
|
||||||
|
|
||||||
action-popup-blocking-user-cant-block = You tried to raise your shield, but it was no use.
|
action-popup-blocking-user-cant-block = You tried to raise your shield, but it was no use.
|
||||||
|
action-popup-blocking-user-too-close = There's no room here to block. Try moving a bit!
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user