Trashbag stuff (#18096)

This commit is contained in:
metalgearsloth
2023-07-18 21:44:00 +10:00
committed by GitHub
parent e0291500af
commit fcf01cc6ef
13 changed files with 55 additions and 44 deletions

View File

@@ -1,19 +1,15 @@
using System;
using System.Numerics;
using Content.Shared.Spawners.Components;
using Robust.Client.Animations;
using Robust.Client.GameObjects;
using Robust.Shared.Animations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Maths;
namespace Content.Client.Animations
{
public static class ReusableAnimations
{
public static void AnimateEntityPickup(EntityUid entity, EntityCoordinates initialPosition, Vector2 finalPosition, IEntityManager? entMan = null)
public static void AnimateEntityPickup(EntityUid entity, EntityCoordinates initialPosition, Vector2 finalPosition, Angle initialAngle, IEntityManager? entMan = null)
{
IoCManager.Resolve(ref entMan);
@@ -38,6 +34,10 @@ namespace Content.Client.Animations
entMan.DeleteEntity(animatableClone);
};
var despawn = entMan.EnsureComponent<TimedDespawnComponent>(animatableClone);
despawn.Lifetime = 0.25f;
entMan.System<SharedTransformSystem>().SetLocalRotationNoLerp(animatableClone, initialAngle);
animations.Play(new Animation
{
Length = TimeSpan.FromMilliseconds(125),
@@ -53,7 +53,7 @@ namespace Content.Client.Animations
new AnimationTrackProperty.KeyFrame(initialPosition.Position, 0),
new AnimationTrackProperty.KeyFrame(finalPosition, 0.125f)
}
}
},
}
}, "fancy_pickup_anim");
}

View File

@@ -3,6 +3,7 @@ using Content.Shared.Disposal.Components;
namespace Content.Client.Disposal;
[RegisterComponent]
[ComponentReference(typeof(SharedDisposalUnitComponent))]
public sealed class DisposalUnitComponent : SharedDisposalUnitComponent
{

View File

@@ -110,16 +110,16 @@ namespace Content.Client.Hands.Systems
#region PickupAnimation
private void HandlePickupAnimation(PickupAnimationEvent msg)
{
PickupAnimation(msg.ItemUid, msg.InitialPosition, msg.FinalPosition);
PickupAnimation(msg.ItemUid, msg.InitialPosition, msg.FinalPosition, msg.InitialAngle);
}
public override void PickupAnimation(EntityUid item, EntityCoordinates initialPosition, Vector2 finalPosition,
public override void PickupAnimation(EntityUid item, EntityCoordinates initialPosition, Vector2 finalPosition, Angle initialAngle,
EntityUid? exclude)
{
PickupAnimation(item, initialPosition, finalPosition);
PickupAnimation(item, initialPosition, finalPosition, initialAngle);
}
public void PickupAnimation(EntityUid item, EntityCoordinates initialPosition, Vector2 finalPosition)
public void PickupAnimation(EntityUid item, EntityCoordinates initialPosition, Vector2 finalPosition, Angle initialAngle)
{
if (!_gameTiming.IsFirstTimePredicted)
return;
@@ -127,7 +127,7 @@ namespace Content.Client.Hands.Systems
if (finalPosition.EqualsApprox(initialPosition.Position, tolerance: 0.1f))
return;
ReusableAnimations.AnimateEntityPickup(item, initialPosition, finalPosition);
ReusableAnimations.AnimateEntityPickup(item, initialPosition, finalPosition, initialAngle);
}
#endregion

View File

@@ -11,28 +11,9 @@ namespace Content.Client.Storage
[ComponentReference(typeof(SharedStorageComponent))]
public sealed class ClientStorageComponent : SharedStorageComponent
{
[Dependency] private readonly IEntityManager _entityManager = default!;
private List<EntityUid> _storedEntities = new();
public override IReadOnlyList<EntityUid> StoredEntities => _storedEntities;
/// <summary>
/// Animate the newly stored entities in <paramref name="msg"/> flying towards this storage's position
/// </summary>
/// <param name="msg"></param>
public void HandleAnimatingInsertingEntities(AnimateInsertingEntitiesEvent msg)
{
for (var i = 0; msg.StoredEntities.Count > i; i++)
{
var entity = msg.StoredEntities[i];
var initialPosition = msg.EntityPositions[i];
if (_entityManager.EntityExists(entity))
{
ReusableAnimations.AnimateEntityPickup(entity, initialPosition, _entityManager.GetComponent<TransformComponent>(Owner).LocalPosition, _entityManager);
}
}
}
public override bool Remove(EntityUid entity)
{
return false;

View File

@@ -30,7 +30,7 @@ public sealed class StorageSystem : EntitySystem
var initialPosition = msg.EntityPositions[i];
if (EntityManager.EntityExists(entity) && transformComp != null)
{
ReusableAnimations.AnimateEntityPickup(entity, initialPosition, transformComp.LocalPosition, EntityManager);
ReusableAnimations.AnimateEntityPickup(entity, initialPosition, transformComp.LocalPosition, msg.EntityAngles[i], EntityManager);
}
}
}