Cleans up some shield code, adds grid checks (#12621)
closes https://github.com/space-wizards/space-station-14/issues/11196
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
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;
|
||||||
using Content.Shared.Doors.Components;
|
using Content.Shared.Doors.Components;
|
||||||
using Content.Shared.Hands;
|
using Content.Shared.Hands;
|
||||||
using Content.Shared.Hands.EntitySystems;
|
using Content.Shared.Hands.EntitySystems;
|
||||||
@@ -33,6 +33,7 @@ public sealed class BlockingSystem : EntitySystem
|
|||||||
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
||||||
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
||||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||||
|
[Dependency] private readonly SharedBuckleSystem _buckleSystem = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -117,13 +118,14 @@ public sealed class BlockingSystem : EntitySystem
|
|||||||
/// Creates a new hard fixture to bodyblock
|
/// Creates a new hard fixture to bodyblock
|
||||||
/// Also makes the user static to prevent prediction issues
|
/// Also makes the user static to prevent prediction issues
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uid"> The entity with the blocking component</param>
|
/// <param name="item"> The entity with the blocking component</param>
|
||||||
/// <param name="component"> The <see cref="BlockingComponent"/></param>
|
/// <param name="component"> The <see cref="BlockingComponent"/></param>
|
||||||
/// <param name="user"> The entity who's using the item to block</param>
|
/// <param name="user"> The entity who's using the item to block</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool StartBlocking(EntityUid item, BlockingComponent component, EntityUid user)
|
public bool StartBlocking(EntityUid item, BlockingComponent component, EntityUid user)
|
||||||
{
|
{
|
||||||
if (component.IsBlocking) return false;
|
if (component.IsBlocking)
|
||||||
|
return false;
|
||||||
|
|
||||||
var xform = Transform(user);
|
var xform = Transform(user);
|
||||||
|
|
||||||
@@ -135,8 +137,8 @@ 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.
|
//Don't allow someone to block if they're not parented to a grid
|
||||||
if (_containerSystem.IsEntityInContainer(user) || !_mapManager.TryFindGridAt(xform.MapPosition, out var grid))
|
if (xform.GridUid != xform.ParentUid)
|
||||||
{
|
{
|
||||||
CantBlockError(user);
|
CantBlockError(user);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
using Content.Shared.Audio;
|
using Content.Shared.Damage;
|
||||||
using Content.Shared.Damage;
|
|
||||||
using Content.Shared.Damage.Prototypes;
|
using Content.Shared.Damage.Prototypes;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.Player;
|
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
namespace Content.Shared.Blocking;
|
namespace Content.Shared.Blocking;
|
||||||
@@ -30,18 +28,14 @@ public sealed class BlockingUserSystem : EntitySystem
|
|||||||
private void OnParentChanged(EntityUid uid, BlockingUserComponent component, ref EntParentChangedMessage args)
|
private void OnParentChanged(EntityUid uid, BlockingUserComponent component, ref EntParentChangedMessage args)
|
||||||
{
|
{
|
||||||
if (TryComp<BlockingComponent>(component.BlockingItem, out var blockComp) && blockComp.IsBlocking)
|
if (TryComp<BlockingComponent>(component.BlockingItem, out var blockComp) && blockComp.IsBlocking)
|
||||||
{
|
|
||||||
_blockingSystem.StopBlocking(component.BlockingItem.Value, blockComp, uid);
|
_blockingSystem.StopBlocking(component.BlockingItem.Value, blockComp, uid);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void OnInsertAttempt(EntityUid uid, BlockingUserComponent component, ContainerGettingInsertedAttemptEvent args)
|
private void OnInsertAttempt(EntityUid uid, BlockingUserComponent component, ContainerGettingInsertedAttemptEvent args)
|
||||||
{
|
{
|
||||||
if (TryComp<BlockingComponent>(component.BlockingItem, out var blockComp) && blockComp.IsBlocking)
|
if (TryComp<BlockingComponent>(component.BlockingItem, out var blockComp) && blockComp.IsBlocking)
|
||||||
{
|
|
||||||
_blockingSystem.StopBlocking(component.BlockingItem.Value, blockComp, uid);
|
_blockingSystem.StopBlocking(component.BlockingItem.Value, blockComp, uid);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void OnAnchorChanged(EntityUid uid, BlockingUserComponent component, ref AnchorStateChangedEvent args)
|
private void OnAnchorChanged(EntityUid uid, BlockingUserComponent component, ref AnchorStateChangedEvent args)
|
||||||
{
|
{
|
||||||
@@ -49,18 +43,14 @@ public sealed class BlockingUserSystem : EntitySystem
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (TryComp<BlockingComponent>(component.BlockingItem, out var blockComp) && blockComp.IsBlocking)
|
if (TryComp<BlockingComponent>(component.BlockingItem, out var blockComp) && blockComp.IsBlocking)
|
||||||
{
|
|
||||||
_blockingSystem.StopBlocking(component.BlockingItem.Value, blockComp, uid);
|
_blockingSystem.StopBlocking(component.BlockingItem.Value, blockComp, uid);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void OnDamageChanged(EntityUid uid, BlockingUserComponent component, DamageChangedEvent args)
|
private void OnDamageChanged(EntityUid uid, BlockingUserComponent component, DamageChangedEvent args)
|
||||||
{
|
{
|
||||||
if (args.DamageDelta != null && args.DamageIncreased)
|
if (args.DamageDelta != null && args.DamageIncreased)
|
||||||
{
|
|
||||||
_damageable.TryChangeDamage(component.BlockingItem, args.DamageDelta, origin: args.Origin);
|
_damageable.TryChangeDamage(component.BlockingItem, args.DamageDelta, origin: args.Origin);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void OnUserDamageModified(EntityUid uid, BlockingUserComponent component, DamageModifyEvent args)
|
private void OnUserDamageModified(EntityUid uid, BlockingUserComponent component, DamageModifyEvent args)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user