Trashbag stuff (#18096)
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Shared.Disposal.Components;
|
||||
namespace Content.Client.Disposal;
|
||||
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedDisposalUnitComponent))]
|
||||
public sealed class DisposalUnitComponent : SharedDisposalUnitComponent
|
||||
{
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace Content.Server.Disposal.Unit.Components;
|
||||
|
||||
// GasMixture life.
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedDisposalUnitComponent))]
|
||||
public sealed class DisposalUnitComponent : SharedDisposalUnitComponent
|
||||
{
|
||||
[DataField("air")]
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace Content.Server.Hands.Systems
|
||||
args.Handled = true; // no shove/stun.
|
||||
}
|
||||
|
||||
public override void PickupAnimation(EntityUid item, EntityCoordinates initialPosition, Vector2 finalPosition,
|
||||
public override void PickupAnimation(EntityUid item, EntityCoordinates initialPosition, Vector2 finalPosition, Angle initialAngle,
|
||||
EntityUid? exclude)
|
||||
{
|
||||
if (finalPosition.EqualsApprox(initialPosition.Position, tolerance: 0.1f))
|
||||
@@ -105,7 +105,7 @@ namespace Content.Server.Hands.Systems
|
||||
if (exclude != null)
|
||||
filter = filter.RemoveWhereAttachedEntity(entity => entity == exclude);
|
||||
|
||||
RaiseNetworkEvent(new PickupAnimationEvent(item, initialPosition, finalPosition), filter);
|
||||
RaiseNetworkEvent(new PickupAnimationEvent(item, initialPosition, finalPosition, initialAngle), filter);
|
||||
}
|
||||
|
||||
protected override void HandleEntityRemoved(EntityUid uid, HandsComponent hands, EntRemovedFromContainerMessage args)
|
||||
|
||||
@@ -275,7 +275,8 @@ namespace Content.Server.Storage.EntitySystems
|
||||
{
|
||||
RaiseNetworkEvent(new AnimateInsertingEntitiesEvent(uid,
|
||||
new List<EntityUid> { target },
|
||||
new List<EntityCoordinates> { position }));
|
||||
new List<EntityCoordinates> { position },
|
||||
new List<Angle> { transformOwner.LocalRotation }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -288,6 +289,7 @@ namespace Content.Server.Storage.EntitySystems
|
||||
|
||||
var successfullyInserted = new List<EntityUid>();
|
||||
var successfullyInsertedPositions = new List<EntityCoordinates>();
|
||||
var successfullyInsertedAngles = new List<Angle>();
|
||||
var itemQuery = GetEntityQuery<ItemComponent>();
|
||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||
xformQuery.TryGetComponent(uid, out var xform);
|
||||
@@ -313,10 +315,13 @@ namespace Content.Server.Storage.EntitySystems
|
||||
_transform
|
||||
);
|
||||
|
||||
var angle = targetXform.LocalRotation;
|
||||
|
||||
if (PlayerInsertEntityInWorld(uid, args.Args.User, entity, component))
|
||||
{
|
||||
successfullyInserted.Add(entity);
|
||||
successfullyInsertedPositions.Add(position);
|
||||
successfullyInsertedAngles.Add(angle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,7 +329,7 @@ namespace Content.Server.Storage.EntitySystems
|
||||
if (successfullyInserted.Count > 0)
|
||||
{
|
||||
_audio.PlayPvs(component.StorageInsertSound, uid);
|
||||
RaiseNetworkEvent(new AnimateInsertingEntitiesEvent(uid, successfullyInserted, successfullyInsertedPositions));
|
||||
RaiseNetworkEvent(new AnimateInsertingEntitiesEvent(uid, successfullyInserted, successfullyInsertedPositions, successfullyInsertedAngles));
|
||||
}
|
||||
|
||||
args.Handled = true;
|
||||
|
||||
@@ -109,14 +109,15 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
||||
{
|
||||
var xform = Transform(uid);
|
||||
var coordinateEntity = xform.ParentUid.IsValid() ? xform.ParentUid : uid;
|
||||
var itemPos = Transform(entity).MapPosition;
|
||||
var itemXform = Transform(entity);
|
||||
var itemPos = itemXform.MapPosition;
|
||||
|
||||
if (itemPos.MapId == xform.MapID
|
||||
&& (itemPos.Position - xform.MapPosition.Position).Length() <= MaxAnimationRange
|
||||
&& MetaData(entity).VisibilityMask == MetaData(uid).VisibilityMask) // Don't animate aghost pickups.
|
||||
{
|
||||
var initialPosition = EntityCoordinates.FromMap(coordinateEntity, itemPos, EntityManager);
|
||||
PickupAnimation(entity, initialPosition, xform.LocalPosition, animateUser ? null : uid);
|
||||
PickupAnimation(entity, initialPosition, xform.LocalPosition, itemXform.LocalRotation, animateUser ? null : uid);
|
||||
}
|
||||
}
|
||||
DoPickup(uid, hand, entity, handsComp);
|
||||
@@ -232,6 +233,6 @@ public abstract partial class SharedHandsSystem : EntitySystem
|
||||
RaiseLocalEvent(entity, new HandSelectedEvent(uid), false);
|
||||
}
|
||||
|
||||
public abstract void PickupAnimation(EntityUid item, EntityCoordinates initialPosition, Vector2 finalPosition,
|
||||
public abstract void PickupAnimation(EntityUid item, EntityCoordinates initialPosition, Vector2 finalPosition, Angle initialAngle,
|
||||
EntityUid? exclude);
|
||||
}
|
||||
|
||||
@@ -120,13 +120,15 @@ namespace Content.Shared.Hands
|
||||
public EntityUid ItemUid { get; }
|
||||
public EntityCoordinates InitialPosition { get; }
|
||||
public Vector2 FinalPosition { get; }
|
||||
public Angle InitialAngle { get; }
|
||||
|
||||
public PickupAnimationEvent(EntityUid itemUid, EntityCoordinates initialPosition,
|
||||
Vector2 finalPosition)
|
||||
Vector2 finalPosition, Angle initialAngle)
|
||||
{
|
||||
ItemUid = itemUid;
|
||||
FinalPosition = finalPosition;
|
||||
InitialPosition = initialPosition;
|
||||
InitialAngle = initialAngle;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.DoAfter;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
@@ -16,6 +17,9 @@ public sealed class DumpableDoAfterEvent : SimpleDoAfterEvent
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
public sealed partial class DumpableComponent : Component
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("soundDump"), AutoNetworkedField]
|
||||
public SoundSpecifier? DumpSound = new SoundCollectionSpecifier("storageRustle");
|
||||
|
||||
/// <summary>
|
||||
/// How long each item adds to the doafter.
|
||||
/// </summary>
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace Content.Shared.Storage.EntitySystems;
|
||||
public sealed class DumpableSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _container = default!;
|
||||
[Dependency] private readonly SharedDisposalUnitSystem _disposalUnitSystem = default!;
|
||||
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
|
||||
@@ -126,6 +127,9 @@ public sealed class DumpableSystem : EntitySystem
|
||||
dumpQueue.Enqueue(entity);
|
||||
}
|
||||
|
||||
if (dumpQueue.Count == 0)
|
||||
return;
|
||||
|
||||
foreach (var entity in dumpQueue)
|
||||
{
|
||||
var transform = Transform(entity);
|
||||
@@ -136,17 +140,21 @@ public sealed class DumpableSystem : EntitySystem
|
||||
if (args.Args.Target == null)
|
||||
return;
|
||||
|
||||
var dumped = false;
|
||||
|
||||
if (HasComp<SharedDisposalUnitComponent>(args.Args.Target.Value))
|
||||
{
|
||||
dumped = true;
|
||||
|
||||
foreach (var entity in dumpQueue)
|
||||
{
|
||||
_disposalUnitSystem.DoInsertDisposalUnit(args.Args.Target.Value, entity, args.Args.User);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (HasComp<PlaceableSurfaceComponent>(args.Args.Target.Value))
|
||||
else if (HasComp<PlaceableSurfaceComponent>(args.Args.Target.Value))
|
||||
{
|
||||
dumped = true;
|
||||
|
||||
var targetPos = _xformQuery.GetComponent(args.Args.Target.Value).LocalPosition;
|
||||
|
||||
foreach (var entity in dumpQueue)
|
||||
@@ -154,5 +162,11 @@ public sealed class DumpableSystem : EntitySystem
|
||||
_transformSystem.SetLocalPosition(entity, targetPos + _random.NextVector2Box() / 4);
|
||||
}
|
||||
}
|
||||
|
||||
if (dumped)
|
||||
{
|
||||
// TODO: Predicted when above predicted
|
||||
_audio.PlayPvs(component.DumpSound, uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,12 +62,14 @@ namespace Content.Shared.Storage
|
||||
public readonly EntityUid Storage;
|
||||
public readonly List<EntityUid> StoredEntities;
|
||||
public readonly List<EntityCoordinates> EntityPositions;
|
||||
public readonly List<Angle> EntityAngles;
|
||||
|
||||
public AnimateInsertingEntitiesEvent(EntityUid storage, List<EntityUid> storedEntities, List<EntityCoordinates> entityPositions)
|
||||
public AnimateInsertingEntitiesEvent(EntityUid storage, List<EntityUid> storedEntities, List<EntityCoordinates> entityPositions, List<Angle> entityAngles)
|
||||
{
|
||||
Storage = storage;
|
||||
StoredEntities = storedEntities;
|
||||
EntityPositions = entityPositions;
|
||||
EntityAngles = entityAngles;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user