Add ore bag area pickups (#19358)
This commit is contained in:
@@ -9,11 +9,11 @@ namespace Content.Client.Animations
|
||||
{
|
||||
public static class ReusableAnimations
|
||||
{
|
||||
public static void AnimateEntityPickup(EntityUid entity, EntityCoordinates initialPosition, Vector2 finalPosition, Angle initialAngle, IEntityManager? entMan = null)
|
||||
public static void AnimateEntityPickup(EntityUid entity, EntityCoordinates initialCoords, Vector2 finalPosition, Angle initialAngle, IEntityManager? entMan = null)
|
||||
{
|
||||
IoCManager.Resolve(ref entMan);
|
||||
|
||||
if (entMan.Deleted(entity) || !initialPosition.IsValid(entMan))
|
||||
if (entMan.Deleted(entity) || !initialCoords.IsValid(entMan))
|
||||
return;
|
||||
|
||||
var metadata = entMan.GetComponent<MetaDataComponent>(entity);
|
||||
@@ -21,7 +21,7 @@ namespace Content.Client.Animations
|
||||
if (entMan.IsPaused(entity, metadata))
|
||||
return;
|
||||
|
||||
var animatableClone = entMan.SpawnEntity("clientsideclone", initialPosition);
|
||||
var animatableClone = entMan.SpawnEntity("clientsideclone", initialCoords);
|
||||
string val = entMan.GetComponent<MetaDataComponent>(entity).EntityName;
|
||||
entMan.System<MetaDataSystem>().SetEntityName(animatableClone, val);
|
||||
|
||||
@@ -35,7 +35,8 @@ namespace Content.Client.Animations
|
||||
sprite.Visible = true;
|
||||
|
||||
var animations = entMan.GetComponent<AnimationPlayerComponent>(animatableClone);
|
||||
animations.AnimationCompleted += (_) => {
|
||||
animations.AnimationCompleted += (_) =>
|
||||
{
|
||||
entMan.DeleteEntity(animatableClone);
|
||||
};
|
||||
|
||||
@@ -55,7 +56,7 @@ namespace Content.Client.Animations
|
||||
InterpolationMode = AnimationInterpolationMode.Linear,
|
||||
KeyFrames =
|
||||
{
|
||||
new AnimationTrackProperty.KeyFrame(initialPosition.Position, 0),
|
||||
new AnimationTrackProperty.KeyFrame(initialCoords.Position, 0),
|
||||
new AnimationTrackProperty.KeyFrame(finalPosition, 0.125f)
|
||||
}
|
||||
},
|
||||
|
||||
@@ -52,8 +52,6 @@ namespace Content.Client.Hands.Systems
|
||||
SubscribeLocalEvent<HandsComponent, ComponentHandleState>(HandleComponentState);
|
||||
SubscribeLocalEvent<HandsComponent, VisualsChangedEvent>(OnVisualsChanged);
|
||||
|
||||
SubscribeNetworkEvent<PickupAnimationEvent>(HandlePickupAnimation);
|
||||
|
||||
OnHandSetActive += OnHandActivated;
|
||||
}
|
||||
|
||||
@@ -121,30 +119,6 @@ namespace Content.Client.Hands.Systems
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region PickupAnimation
|
||||
private void HandlePickupAnimation(PickupAnimationEvent msg)
|
||||
{
|
||||
PickupAnimation(GetEntity(msg.ItemUid), GetCoordinates(msg.InitialPosition), msg.FinalPosition, msg.InitialAngle);
|
||||
}
|
||||
|
||||
public override void PickupAnimation(EntityUid item, EntityCoordinates initialPosition, Vector2 finalPosition, Angle initialAngle,
|
||||
EntityUid? exclude)
|
||||
{
|
||||
PickupAnimation(item, initialPosition, finalPosition, initialAngle);
|
||||
}
|
||||
|
||||
public void PickupAnimation(EntityUid item, EntityCoordinates initialPosition, Vector2 finalPosition, Angle initialAngle)
|
||||
{
|
||||
if (!_gameTiming.IsFirstTimePredicted)
|
||||
return;
|
||||
|
||||
if (finalPosition.EqualsApprox(initialPosition.Position, tolerance: 0.1f))
|
||||
return;
|
||||
|
||||
ReusableAnimations.AnimateEntityPickup(item, initialPosition, finalPosition, initialAngle);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public void ReloadHandButtons()
|
||||
{
|
||||
if (!TryGetPlayerHands(out var hands))
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using Content.Client.Animations;
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.Storage;
|
||||
using Content.Shared.Storage.EntitySystems;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Client.Storage.Systems;
|
||||
@@ -16,6 +18,7 @@ public sealed class StorageSystem : SharedStorageSystem
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeNetworkEvent<PickupAnimationEvent>(HandlePickupAnimation);
|
||||
SubscribeNetworkEvent<AnimateInsertingEntitiesEvent>(HandleAnimatingInsertingEntities);
|
||||
}
|
||||
|
||||
@@ -25,6 +28,38 @@ public sealed class StorageSystem : SharedStorageSystem
|
||||
StorageUpdated?.Invoke(uid, component);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void PlayPickupAnimation(EntityUid uid, EntityCoordinates initialCoordinates, EntityCoordinates finalCoordinates,
|
||||
Angle initialRotation, EntityUid? user = null)
|
||||
{
|
||||
if (!_timing.IsFirstTimePredicted)
|
||||
return;
|
||||
|
||||
PickupAnimation(uid, initialCoordinates, finalCoordinates, initialRotation);
|
||||
}
|
||||
|
||||
private void HandlePickupAnimation(PickupAnimationEvent msg)
|
||||
{
|
||||
PickupAnimation(GetEntity(msg.ItemUid), GetCoordinates(msg.InitialPosition), GetCoordinates(msg.FinalPosition), msg.InitialAngle);
|
||||
}
|
||||
|
||||
public void PickupAnimation(EntityUid item, EntityCoordinates initialCoords, EntityCoordinates finalCoords, Angle initialAngle)
|
||||
{
|
||||
if (!_timing.IsFirstTimePredicted)
|
||||
return;
|
||||
|
||||
if (finalCoords.InRange(EntityManager, _transform, initialCoords, 0.1f) ||
|
||||
!Exists(initialCoords.EntityId) || !Exists(finalCoords.EntityId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var finalMapPos = finalCoords.ToMapPos(EntityManager, _transform);
|
||||
var finalPos = _transform.GetInvWorldMatrix(initialCoords.EntityId).Transform(finalMapPos);
|
||||
|
||||
ReusableAnimations.AnimateEntityPickup(item, initialCoords, finalPos, initialAngle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Animate the newly stored entities in <paramref name="msg"/> flying towards this storage's position
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user