HOTFIX Fix pickup effects occurring with verb creation (#38705)
* fix: don't run pickup effects on verb creation * review * redundant --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
@@ -37,12 +37,17 @@ public sealed class MultiHandedItemSystem : EntitySystem
|
||||
|
||||
private void OnAttemptPickup(Entity<MultiHandedItemComponent> ent, ref GettingPickedUpAttemptEvent args)
|
||||
{
|
||||
if (_hands.CountFreeHands(args.User) >= ent.Comp.HandsNeeded)
|
||||
if (args.Cancelled || _hands.CountFreeHands(args.User) >= ent.Comp.HandsNeeded)
|
||||
return;
|
||||
|
||||
args.Cancel();
|
||||
_popup.PopupPredictedCursor(Loc.GetString("multi-handed-item-pick-up-fail",
|
||||
("number", ent.Comp.HandsNeeded - 1), ("item", ent.Owner)), args.User);
|
||||
|
||||
if (args.ShowPopup)
|
||||
_popup.PopupPredictedCursor(
|
||||
Loc.GetString("multi-handed-item-pick-up-fail",
|
||||
("number", ent.Comp.HandsNeeded - 1),
|
||||
("item", ent.Owner)),
|
||||
args.User);
|
||||
}
|
||||
|
||||
private void OnVirtualItemDeleted(Entity<MultiHandedItemComponent> ent, ref VirtualItemDeletedEvent args)
|
||||
|
||||
@@ -1,30 +1,47 @@
|
||||
namespace Content.Shared.Item;
|
||||
|
||||
/// <summary>
|
||||
/// Raised on a *mob* when it tries to pickup something
|
||||
/// Raised on a *mob* when it tries to pickup something.
|
||||
/// IMPORTANT: Attempt event subscriptions should not be doing any state changes like throwing items, opening UIs, playing sounds etc!
|
||||
/// </summary>
|
||||
public sealed class PickupAttemptEvent : BasePickupAttemptEvent
|
||||
{
|
||||
public PickupAttemptEvent(EntityUid user, EntityUid item) : base(user, item) { }
|
||||
public PickupAttemptEvent(EntityUid user, EntityUid item, bool showPopup) : base(user, item, showPopup) { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raised directed at entity being picked up when someone tries to pick it up
|
||||
/// Raised directed at entity being picked up when someone tries to pick it up.
|
||||
/// IMPORTANT: Attempt event subscriptions should not be doing any state changes like throwing items, opening UIs, playing sounds etc!
|
||||
/// </summary>
|
||||
public sealed class GettingPickedUpAttemptEvent : BasePickupAttemptEvent
|
||||
{
|
||||
public GettingPickedUpAttemptEvent(EntityUid user, EntityUid item) : base(user, item) { }
|
||||
public GettingPickedUpAttemptEvent(EntityUid user, EntityUid item, bool showPopup) : base(user, item, showPopup) { }
|
||||
}
|
||||
|
||||
[Virtual]
|
||||
public class BasePickupAttemptEvent : CancellableEntityEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// The mob that is picking up the item.
|
||||
/// </summary>
|
||||
public readonly EntityUid User;
|
||||
/// <summary>
|
||||
/// The item being picked up.
|
||||
/// </summary>
|
||||
|
||||
public readonly EntityUid Item;
|
||||
|
||||
public BasePickupAttemptEvent(EntityUid user, EntityUid item)
|
||||
/// <summary>
|
||||
/// Whether or not to show a popup message to the player telling them why the attempt was cancelled.
|
||||
/// This should be true when this event is raised during interactions, and false when it is raised
|
||||
/// for disabling verbs or similar that do not do the actual pickup.
|
||||
/// </summary>
|
||||
public bool ShowPopup;
|
||||
|
||||
public BasePickupAttemptEvent(EntityUid user, EntityUid item, bool showPopup)
|
||||
{
|
||||
User = user;
|
||||
Item = item;
|
||||
ShowPopup = showPopup;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user