Replace IBodyPartAdded and IBodyPartRemoved with ref events (#12572)
This commit is contained in:
@@ -1,29 +1,22 @@
|
||||
|
||||
using System.Linq;
|
||||
using Content.Server.CombatMode;
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Pulling;
|
||||
using Content.Server.Stack;
|
||||
using Content.Server.Storage.Components;
|
||||
using Content.Server.Storage.EntitySystems;
|
||||
using Content.Server.Strip;
|
||||
using Content.Server.Stunnable;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Body.Part;
|
||||
using Content.Shared.CombatMode;
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.Input;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Physics.Pull;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Pulling.Components;
|
||||
using Content.Shared.Stunnable;
|
||||
using Content.Shared.Throwing;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameStates;
|
||||
@@ -42,7 +35,6 @@ namespace Content.Server.Hands.Systems
|
||||
[Dependency] private readonly StackSystem _stackSystem = default!;
|
||||
[Dependency] private readonly HandVirtualItemSystem _virtualItemSystem = default!;
|
||||
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
|
||||
[Dependency] private readonly StrippableSystem _strippableSystem = default!;
|
||||
[Dependency] private readonly SharedHandVirtualItemSystem _virtualSystem = default!;
|
||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
||||
@@ -61,6 +53,9 @@ namespace Content.Server.Hands.Systems
|
||||
|
||||
SubscribeLocalEvent<HandsComponent, EntRemovedFromContainerMessage>(HandleEntityRemoved);
|
||||
|
||||
SubscribeLocalEvent<HandsComponent, BodyPartAddedEvent>(HandleBodyPartAdded);
|
||||
SubscribeLocalEvent<HandsComponent, BodyPartRemovedEvent>(HandleBodyPartRemoved);
|
||||
|
||||
SubscribeLocalEvent<HandsComponent, ComponentGetState>(GetComponentState);
|
||||
|
||||
CommandBinds.Builder
|
||||
@@ -97,7 +92,6 @@ namespace Content.Server.Hands.Systems
|
||||
args.Handled = true; // no shove/stun.
|
||||
}
|
||||
|
||||
#region EntityInsertRemove
|
||||
public override void PickupAnimation(EntityUid item, EntityCoordinates initialPosition, Vector2 finalPosition,
|
||||
EntityUid? exclude)
|
||||
{
|
||||
@@ -117,7 +111,32 @@ namespace Content.Server.Hands.Systems
|
||||
if (!Deleted(args.Entity) && TryComp(args.Entity, out HandVirtualItemComponent? @virtual))
|
||||
_virtualSystem.Delete(@virtual, uid);
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void HandleBodyPartAdded(EntityUid uid, HandsComponent component, ref BodyPartAddedEvent args)
|
||||
{
|
||||
if (args.Part.PartType != BodyPartType.Hand)
|
||||
return;
|
||||
|
||||
// If this annoys you, which it should.
|
||||
// Ping Smugleaf.
|
||||
var location = args.Part.Symmetry switch
|
||||
{
|
||||
BodyPartSymmetry.None => HandLocation.Middle,
|
||||
BodyPartSymmetry.Left => HandLocation.Left,
|
||||
BodyPartSymmetry.Right => HandLocation.Right,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(args.Part.Symmetry))
|
||||
};
|
||||
|
||||
AddHand(uid, args.Slot, location);
|
||||
}
|
||||
|
||||
private void HandleBodyPartRemoved(EntityUid uid, HandsComponent component, ref BodyPartRemovedEvent args)
|
||||
{
|
||||
if (args.Part.PartType != BodyPartType.Hand)
|
||||
return;
|
||||
|
||||
RemoveHand(uid, args.Slot);
|
||||
}
|
||||
|
||||
#region pulling
|
||||
private void HandlePullStarted(EntityUid uid, HandsComponent component, PullStartedMessage args)
|
||||
|
||||
Reference in New Issue
Block a user