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,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>

View File

@@ -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);
}
}
}

View File

@@ -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;
}
}