Trashbag stuff (#18096)
This commit is contained in:
@@ -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