Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mirror: Fix Recycled Containers Deleting Items Inside Them #267

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Content.Shared/Materials/SharedMaterialReclaimerSystem.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System.Linq;
using System.Linq;
using Content.Shared.Administration.Logs;
using Content.Shared.Audio;
using Content.Shared.Body.Components;
using Content.Shared.Coordinates;
using Content.Shared.Database;
using Content.Shared.Emag.Components;
using Content.Shared.Emag.Systems;
Expand All @@ -11,6 +12,7 @@
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
using Robust.Shared.Map;
using Robust.Shared.Physics.Events;
using Robust.Shared.Timing;

Expand Down Expand Up @@ -110,6 +112,9 @@ public bool TryStartProcessItem(EntityUid uid, EntityUid item, MaterialReclaimer
component.NextSound = Timing.CurTime + component.SoundCooldown;
}

var reclaimedEvent = new GotReclaimedEvent(Transform(uid).Coordinates);
RaiseLocalEvent(item, ref reclaimedEvent);

var duration = GetReclaimingDuration(uid, item, component);
// if it's instant, don't bother with all the active comp stuff.
if (duration == TimeSpan.Zero)
Expand Down Expand Up @@ -238,3 +243,6 @@ public override void Update(float frameTime)
}
}
}

[ByRefEvent]
public record struct GotReclaimedEvent(EntityCoordinates ReclaimerCoordinates);
10 changes: 10 additions & 0 deletions Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using Content.Shared.ActionBlocker;
using Content.Shared.Containers.ItemSlots;
using Content.Shared.Coordinates;
using Content.Shared.Destructible;
using Content.Shared.DoAfter;
using Content.Shared.Hands.Components;
Expand All @@ -12,6 +13,7 @@
using Content.Shared.Item;
using Content.Shared.Lock;
using Content.Shared.Nyanotrasen.Item.PseudoItem;
using Content.Shared.Materials;
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
using Content.Shared.Placeable;
using Content.Shared.Popups;
using Content.Shared.Stacks;
Expand Down Expand Up @@ -96,6 +98,9 @@ public override void Initialize()
SubscribeAllEvent<StorageSetItemLocationEvent>(OnSetItemLocation);
SubscribeAllEvent<StorageInsertItemIntoLocationEvent>(OnInsertItemIntoLocation);
SubscribeAllEvent<StorageRemoveItemEvent>(OnRemoveItem);

SubscribeLocalEvent<StorageComponent, GotReclaimedEvent>(OnReclaimed);

UpdatePrototypeCache();
}

Expand Down Expand Up @@ -389,6 +394,11 @@ private void OnDoAfter(EntityUid uid, StorageComponent component, AreaPickupDoAf
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)
{
var coordinates = TransformSystem.GetMoverCoordinates(uid);
Expand Down
Loading