This commit is contained in:
Leon Friedrich
2022-03-17 20:13:31 +13:00
committed by GitHub
parent 7b84362901
commit bfd95c493b
94 changed files with 1454 additions and 2185 deletions

View File

@@ -1,27 +1,30 @@
using Robust.Shared.GameObjects;
namespace Content.Shared.Item;
namespace Content.Shared.Item
/// <summary>
/// Raised on a *mob* when it tries to pickup something
/// </summary>
public sealed class PickupAttemptEvent : BasePickupAttemptEvent
{
/// <summary>
/// Raised on a *mob* when it tries to pickup something
/// </summary>
public sealed class PickupAttemptEvent : CancellableEntityEventArgs
{
public PickupAttemptEvent(EntityUid uid)
{
Uid = uid;
}
public PickupAttemptEvent(EntityUid user, EntityUid item) : base(user, item) { }
}
public EntityUid Uid { get; }
}
/// <summary>
/// Raised directed at entity being picked up when someone tries to pick it up
/// </summary>
public sealed class GettingPickedUpAttemptEvent : BasePickupAttemptEvent
{
public GettingPickedUpAttemptEvent(EntityUid user, EntityUid item) : base(user, item) { }
}
/// <summary>
/// Raised on the *item* when tried to be picked up
/// </summary>
/// <remarks>
/// Doesn't just handle "items" but calling it "PickedUpAttempt" is too close to "Pickup" for the sleep deprived brain.
/// </remarks>
public sealed class AttemptItemPickupEvent : CancellableEntityEventArgs
[Virtual]
public class BasePickupAttemptEvent : CancellableEntityEventArgs
{
public readonly EntityUid User;
public readonly EntityUid Item;
public BasePickupAttemptEvent(EntityUid user, EntityUid item)
{
User = user;
Item = item;
}
}

View File

@@ -1,17 +1,17 @@
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction;
using Content.Shared.Inventory.Events;
using Content.Shared.Verbs;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.Localization;
using System;
namespace Content.Shared.Item
{
public abstract class SharedItemSystem : EntitySystem
{
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
public override void Initialize()
{
base.Initialize();
@@ -30,13 +30,7 @@ namespace Content.Shared.Item
if (args.Handled)
return;
if (!TryComp(args.User, out SharedHandsComponent? hands))
return;
if (hands.ActiveHand == null)
return;
args.Handled = hands.TryPickupEntity(hands.ActiveHand, uid, false, animateUser: false);
args.Handled = _handsSystem.TryPickup(args.User, uid, animateUser: false);
}
private void OnHandleState(EntityUid uid, SharedItemComponent component, ref ComponentHandleState args)
@@ -74,11 +68,11 @@ namespace Content.Shared.Item
args.Using != null ||
!args.CanAccess ||
!args.CanInteract ||
!args.Hands.CanPickupEntityToActiveHand(args.Target))
!_handsSystem.CanPickupAnyHand(args.User, args.Target, handsComp: args.Hands, item: component))
return;
InteractionVerb verb = new();
verb.Act = () => args.Hands.TryPickupEntityToActiveHand(args.Target);
verb.Act = () => _handsSystem.TryPickupAnyHand(args.User, args.Target, checkActionBlocker: false, handsComp: args.Hands, item: component);
verb.IconTexture = "/Textures/Interface/VerbIcons/pickup.svg.192dpi.png";
// if the item already in a container (that is not the same as the user's), then change the text.