Fix disposals bins not automatically flushing after an object is inserted (#25233)

Fix disposals bins not automatically flushing after an object is inserted.

Because of Spaghetti Code™️, AfterInsert() in DisposalUnitSystem still handles insertion itself. Except in all cases except drag/drop insert, the object is already inserted so this check fails and the remaining logic doesn't happen anymore. Fixed now.

(cherry picked from commit 571d4f735888343ca3ba90eaea0908257095cdb9)
This commit is contained in:
Pieter-Jan Briers 2024-02-15 21:52:52 +01:00 committed by Debug
parent a37bd5b2a7
commit 8cdd3d1cb7
No known key found for this signature in database
GPG Key ID: 271270A74EF9C350
1 changed files with 4 additions and 4 deletions

View File

@ -198,7 +198,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
if (args.Handled || args.Cancelled || args.Args.Target == null || args.Args.Used == null) if (args.Handled || args.Cancelled || args.Args.Target == null || args.Args.Used == null)
return; return;
AfterInsert(uid, component, args.Args.Target.Value, args.Args.User); AfterInsert(uid, component, args.Args.Target.Value, args.Args.User, doInsert: true);
args.Handled = true; args.Handled = true;
} }
@ -512,7 +512,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
if (delay <= 0 || userId == null) if (delay <= 0 || userId == null)
{ {
AfterInsert(unitId, unit, toInsertId, userId); AfterInsert(unitId, unit, toInsertId, userId, doInsert: true);
return true; return true;
} }
@ -796,11 +796,11 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
Dirty(component); Dirty(component);
} }
public void AfterInsert(EntityUid uid, SharedDisposalUnitComponent component, EntityUid inserted, EntityUid? user = null) public void AfterInsert(EntityUid uid, SharedDisposalUnitComponent component, EntityUid inserted, EntityUid? user = null, bool doInsert = false)
{ {
_audioSystem.PlayPvs(component.InsertSound, uid); _audioSystem.PlayPvs(component.InsertSound, uid);
if (!_containerSystem.Insert(inserted, component.Container)) if (doInsert && !_containerSystem.Insert(inserted, component.Container))
return; return;
if (user != inserted && user != null) if (user != inserted && user != null)