Skip to content

Commit

Permalink
Cherry-picked commit d7484ae from space-wizards/space-station-14/master
Browse files Browse the repository at this point in the history
  • Loading branch information
SimpleStation14 authored and SlamBamActionman committed Mar 19, 2024
1 parent 3bf08c7 commit 5edf83f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
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);
11 changes: 10 additions & 1 deletion 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 @@ -11,7 +12,7 @@
using Content.Shared.Interaction;
using Content.Shared.Item;
using Content.Shared.Lock;
using Content.Shared.Nyanotrasen.Item.PseudoItem;
using Content.Shared.Materials;
using Content.Shared.Placeable;
using Content.Shared.Popups;
using Content.Shared.Stacks;
Expand Down Expand Up @@ -96,6 +97,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 +393,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

0 comments on commit 5edf83f

Please sign in to comment.