Fix recycled containers deleting items inside them (#26045)

* Removes items from containers in reclaimers

* Made it into an event instead

* Sloth review comment

* Fix indentation and rename field
This commit is contained in:
SlamBamActionman
2024-03-19 03:36:21 +01:00
committed by GitHub
parent 6b966f6360
commit d7484ae9f5
2 changed files with 19 additions and 1 deletions

View File

@@ -1,7 +1,8 @@
using System.Linq; using System.Linq;
using Content.Shared.Administration.Logs; using Content.Shared.Administration.Logs;
using Content.Shared.Audio; using Content.Shared.Audio;
using Content.Shared.Body.Components; using Content.Shared.Body.Components;
using Content.Shared.Coordinates;
using Content.Shared.Database; using Content.Shared.Database;
using Content.Shared.Emag.Components; using Content.Shared.Emag.Components;
using Content.Shared.Emag.Systems; using Content.Shared.Emag.Systems;
@@ -11,6 +12,7 @@ using Content.Shared.Stacks;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems; using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.Map;
using Robust.Shared.Physics.Events; using Robust.Shared.Physics.Events;
using Robust.Shared.Timing; using Robust.Shared.Timing;
@@ -110,6 +112,9 @@ public abstract class SharedMaterialReclaimerSystem : EntitySystem
component.NextSound = Timing.CurTime + component.SoundCooldown; component.NextSound = Timing.CurTime + component.SoundCooldown;
} }
var reclaimedEvent = new GotReclaimedEvent(Transform(uid).Coordinates);
RaiseLocalEvent(item, ref reclaimedEvent);
var duration = GetReclaimingDuration(uid, item, component); var duration = GetReclaimingDuration(uid, item, component);
// if it's instant, don't bother with all the active comp stuff. // if it's instant, don't bother with all the active comp stuff.
if (duration == TimeSpan.Zero) if (duration == TimeSpan.Zero)
@@ -237,3 +242,6 @@ public abstract class SharedMaterialReclaimerSystem : EntitySystem
} }
} }
} }
[ByRefEvent]
public record struct GotReclaimedEvent(EntityCoordinates ReclaimerCoordinates);

View File

@@ -3,6 +3,7 @@ using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using Content.Shared.ActionBlocker; using Content.Shared.ActionBlocker;
using Content.Shared.Containers.ItemSlots; using Content.Shared.Containers.ItemSlots;
using Content.Shared.Coordinates;
using Content.Shared.Destructible; using Content.Shared.Destructible;
using Content.Shared.DoAfter; using Content.Shared.DoAfter;
using Content.Shared.Hands.Components; using Content.Shared.Hands.Components;
@@ -11,6 +12,7 @@ using Content.Shared.Implants.Components;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Item; using Content.Shared.Item;
using Content.Shared.Lock; using Content.Shared.Lock;
using Content.Shared.Materials;
using Content.Shared.Placeable; using Content.Shared.Placeable;
using Content.Shared.Popups; using Content.Shared.Popups;
using Content.Shared.Stacks; using Content.Shared.Stacks;
@@ -95,6 +97,9 @@ public abstract class SharedStorageSystem : EntitySystem
SubscribeAllEvent<StorageSetItemLocationEvent>(OnSetItemLocation); SubscribeAllEvent<StorageSetItemLocationEvent>(OnSetItemLocation);
SubscribeAllEvent<StorageInsertItemIntoLocationEvent>(OnInsertItemIntoLocation); SubscribeAllEvent<StorageInsertItemIntoLocationEvent>(OnInsertItemIntoLocation);
SubscribeAllEvent<StorageRemoveItemEvent>(OnRemoveItem); SubscribeAllEvent<StorageRemoveItemEvent>(OnRemoveItem);
SubscribeLocalEvent<StorageComponent, GotReclaimedEvent>(OnReclaimed);
UpdatePrototypeCache(); UpdatePrototypeCache();
} }
@@ -388,6 +393,11 @@ public abstract class SharedStorageSystem : EntitySystem
args.Handled = true; args.Handled = true;
} }
private void OnReclaimed(EntityUid uid, StorageComponent storageComp, GotReclaimedEvent args)
{
_containerSystem.EmptyContainer(storageComp.Container, destination: args.ReclaimerCoordinates);
}
private void OnDestroy(EntityUid uid, StorageComponent storageComp, DestructionEventArgs args) private void OnDestroy(EntityUid uid, StorageComponent storageComp, DestructionEventArgs args)
{ {
var coordinates = TransformSystem.GetMoverCoordinates(uid); var coordinates = TransformSystem.GetMoverCoordinates(uid);