Add ore bag area pickups (#19358)
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Storage.EntitySystems;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
@@ -22,9 +24,10 @@ namespace Content.Shared.Stacks
|
||||
[Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
|
||||
[Dependency] protected readonly SharedHandsSystem Hands = default!;
|
||||
[Dependency] protected readonly SharedTransformSystem Xform = default!;
|
||||
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
[Dependency] protected readonly SharedPopupSystem Popup = default!;
|
||||
[Dependency] private readonly SharedStorageSystem _storage = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -56,6 +59,8 @@ namespace Content.Shared.Stacks
|
||||
if (!TryComp(args.Used, out StackComponent? recipientStack))
|
||||
return;
|
||||
|
||||
var localRotation = Transform(args.Used).LocalRotation;
|
||||
|
||||
if (!TryMergeStacks(uid, args.Used, out var transfered, stack, recipientStack))
|
||||
return;
|
||||
|
||||
@@ -67,10 +72,11 @@ namespace Content.Shared.Stacks
|
||||
return;
|
||||
|
||||
var popupPos = args.ClickLocation;
|
||||
var userCoords = Transform(args.User).Coordinates;
|
||||
|
||||
if (!popupPos.IsValid(EntityManager))
|
||||
{
|
||||
popupPos = Transform(args.User).Coordinates;
|
||||
popupPos = userCoords;
|
||||
}
|
||||
|
||||
switch (transfered)
|
||||
@@ -90,16 +96,18 @@ namespace Content.Shared.Stacks
|
||||
Popup.PopupCoordinates(Loc.GetString("comp-stack-already-full"), popupPos, Filter.Local(), false);
|
||||
break;
|
||||
}
|
||||
|
||||
_storage.PlayPickupAnimation(args.Used, popupPos, userCoords, localRotation, args.User);
|
||||
}
|
||||
|
||||
private bool TryMergeStacks(
|
||||
EntityUid donor,
|
||||
EntityUid recipient,
|
||||
out int transfered,
|
||||
out int transferred,
|
||||
StackComponent? donorStack = null,
|
||||
StackComponent? recipientStack = null)
|
||||
{
|
||||
transfered = 0;
|
||||
transferred = 0;
|
||||
if (donor == recipient)
|
||||
return false;
|
||||
|
||||
@@ -109,10 +117,10 @@ namespace Content.Shared.Stacks
|
||||
if (string.IsNullOrEmpty(recipientStack.StackTypeId) || !recipientStack.StackTypeId.Equals(donorStack.StackTypeId))
|
||||
return false;
|
||||
|
||||
transfered = Math.Min(donorStack.Count, GetAvailableSpace(recipientStack));
|
||||
SetCount(donor, donorStack.Count - transfered, donorStack);
|
||||
SetCount(recipient, recipientStack.Count + transfered, recipientStack);
|
||||
return true;
|
||||
transferred = Math.Min(donorStack.Count, GetAvailableSpace(recipientStack));
|
||||
SetCount(donor, donorStack.Count - transferred, donorStack);
|
||||
SetCount(recipient, recipientStack.Count + transferred, recipientStack);
|
||||
return transferred > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user