Add ore bag area pickups (#19358)

This commit is contained in:
metalgearsloth
2023-09-12 22:34:04 +10:00
committed by GitHub
parent 7d9550bc55
commit 7064f262b4
18 changed files with 256 additions and 83 deletions

View File

@@ -58,7 +58,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
if (hand == null)
return false;
return TryPickup(uid, entity, hand, checkActionBlocker, animateUser, animate, handsComp, item);
return TryPickup(uid, entity, hand, checkActionBlocker, animate, handsComp, item);
}
/// <summary>
@@ -83,7 +83,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
if (!TryGetEmptyHand(uid, out var hand, handsComp))
return false;
return TryPickup(uid, entity, hand, checkActionBlocker, animateUser, animate, handsComp, item);
return TryPickup(uid, entity, hand, checkActionBlocker, animate, handsComp, item);
}
public bool TryPickup(
@@ -91,7 +91,6 @@ public abstract partial class SharedHandsSystem : EntitySystem
EntityUid entity,
Hand hand,
bool checkActionBlocker = true,
bool animateUser = false,
bool animate = true,
HandsComponent? handsComp = null,
ItemComponent? item = null)
@@ -117,7 +116,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
&& MetaData(entity).VisibilityMask == MetaData(uid).VisibilityMask) // Don't animate aghost pickups.
{
var initialPosition = EntityCoordinates.FromMap(coordinateEntity, itemPos, EntityManager);
PickupAnimation(entity, initialPosition, xform.LocalPosition, itemXform.LocalRotation, animateUser ? null : uid);
_storage.PlayPickupAnimation(entity, initialPosition, xform.Coordinates, itemXform.LocalRotation, uid);
}
}
DoPickup(uid, hand, entity, handsComp);
@@ -199,7 +198,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
if (uid == null
|| !Resolve(uid.Value, ref handsComp, false)
|| !TryGetEmptyHand(uid.Value, out var hand, handsComp)
|| !TryPickup(uid.Value, entity, hand, checkActionBlocker, animateUser, animate, handsComp, item))
|| !TryPickup(uid.Value, entity, hand, checkActionBlocker, animate, handsComp, item))
{
// TODO make this check upwards for any container, and parent to that.
// Currently this just checks the direct parent, so items can still teleport through containers.
@@ -227,12 +226,9 @@ public abstract partial class SharedHandsSystem : EntitySystem
_adminLogger.Add(LogType.Pickup, LogImpact.Low, $"{ToPrettyString(uid):user} picked up {ToPrettyString(entity):entity}");
Dirty(hands);
Dirty(uid, hands);
if (hand == hands.ActiveHand)
RaiseLocalEvent(entity, new HandSelectedEvent(uid), false);
}
public abstract void PickupAnimation(EntityUid item, EntityCoordinates initialPosition, Vector2 finalPosition, Angle initialAngle,
EntityUid? exclude);
}

View File

@@ -5,6 +5,7 @@ using Content.Shared.Administration.Logs;
using Content.Shared.Hands.Components;
using Content.Shared.Interaction;
using Content.Shared.Item;
using Content.Shared.Storage.EntitySystems;
using Robust.Shared.Containers;
using Robust.Shared.Input.Binding;
@@ -17,6 +18,8 @@ public abstract partial class SharedHandsSystem : EntitySystem
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly SharedItemSystem _items = default!;
[Dependency] private readonly SharedStorageSystem _storage = default!;
[Dependency] protected readonly SharedTransformSystem TransformSystem = default!;
protected event Action<HandsComponent?>? OnHandSetActive;

View File

@@ -114,16 +114,24 @@ namespace Content.Shared.Hands
}
}
/// <summary>
/// Plays a clientside pickup animation by copying the specified entity.
/// </summary>
[Serializable, NetSerializable]
public sealed class PickupAnimationEvent : EntityEventArgs
{
public NetEntity ItemUid { get; }
public NetCoordinates InitialPosition { get; }
public Vector2 FinalPosition { get; }
public Angle InitialAngle { get; }
/// <summary>
/// Entity to be copied for the clientside animation.
/// </summary>
public readonly NetEntity ItemUid;
public readonly NetCoordinates InitialPosition;
public readonly NetCoordinates FinalPosition;
public readonly Angle InitialAngle;
public PickupAnimationEvent(NetEntity itemUid, NetCoordinates initialPosition,
Vector2 finalPosition, Angle initialAngle)
public PickupAnimationEvent(NetEntity itemUid,
NetCoordinates initialPosition,
NetCoordinates finalPosition,
Angle initialAngle)
{
ItemUid = itemUid;
FinalPosition = finalPosition;