using Content.Shared.Popups;
using Content.Shared.Throwing;
using Content.Shared.Verbs;
+using Robust.Server.Audio;
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
[Dependency] private readonly AppearanceSystem _appearance = default!;
[Dependency] private readonly AtmosphereSystem _atmosSystem = default!;
+ [Dependency] private readonly AudioSystem _audioSystem = default!;
[Dependency] private readonly DisposalTubeSystem _disposalTubeSystem = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
/// </summary>
private void OnThrowCollide(EntityUid uid, SharedDisposalUnitComponent component, ThrowHitByEvent args)
{
- if (!CanInsert(uid, component, args.Thrown) ||
- _robustRandom.NextDouble() > 0.75 ||
- !component.Container.Insert(args.Thrown))
+ var canInsert = CanInsert(uid, component, args.Thrown);
+ var randDouble = _robustRandom.NextDouble();
+
+ if (!canInsert || randDouble > 0.75)
{
+ _audioSystem.PlayPvs(component.MissSound, uid);
+
_popupSystem.PopupEntity(Loc.GetString("disposal-unit-thrown-missed"), uid);
return;
}
+ var inserted = _containerSystem.Insert(args.Thrown, component.Container);
+
+ if (!inserted)
+ {
+ throw new InvalidOperationException("Container insertion failed but CanInsert returned true");
+ }
+
if (args.Component.Thrower != null)
_adminLogger.Add(LogType.Landed, LogImpact.Low, $"{ToPrettyString(args.Thrown)} thrown by {ToPrettyString(args.Component.Thrower.Value):player} landed in {ToPrettyString(uid)}");
public void AfterInsert(EntityUid uid, SharedDisposalUnitComponent component, EntityUid inserted, EntityUid? user = null)
{
+ _audioSystem.PlayPvs(component.InsertSound, uid);
+
if (!component.Container.Insert(inserted))
return;
[ViewVariables(VVAccess.ReadWrite), DataField("soundFlush")]
public SoundSpecifier? FlushSound = new SoundPathSpecifier("/Audio/Machines/disposalflush.ogg");
+ /// <summary>
+ /// Sound played when an object is inserted into the disposal unit.
+ /// </summary>
+ [ViewVariables(VVAccess.ReadWrite), DataField("soundInsert")]
+ public SoundSpecifier? InsertSound = new SoundPathSpecifier("/Audio/Effects/trashbag1.ogg");
+
+ /// <summary>
+ /// Sound played when an item is thrown and misses the disposal unit.
+ /// </summary>
+ [ViewVariables(VVAccess.ReadWrite), DataField("soundMiss")]
+ public SoundSpecifier? MissSound = new SoundPathSpecifier("/Audio/Effects/thudswoosh.ogg");
+
+
/// <summary>
/// State for this disposals unit.
/// </summary>