mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
Fix items deletion on recycling for entities with ItemSlotsComponent (#44486)
* Fix items deletion on recycling for entities with `ItemSlotsComponent` * Make it to be dependent on `DestructionEvent` instead * Revert testing changes * Actual proto fix * Fix some other recyclable prototypes with ItemSlots
This commit is contained in:
parent
bea946d516
commit
bc9a9207c5
6 changed files with 30 additions and 11 deletions
|
|
@ -169,6 +169,8 @@ public sealed partial class MaterialReclaimerSystem : SharedMaterialReclaimerSys
|
|||
SpawnChemicalsFromComposition(uid, item, completion, true, component, xform);
|
||||
}
|
||||
|
||||
var eventArgs = new DestructionEventArgs();
|
||||
RaiseLocalEvent(item, eventArgs);
|
||||
QueueDel(item);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using Content.Shared.Hands.Components;
|
|||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Materials;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Verbs;
|
||||
using Content.Shared.Whitelist;
|
||||
|
|
@ -621,6 +622,29 @@ namespace Content.Shared.Containers.ItemSlots
|
|||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unlocks all slots and ejects items from them on the floor.
|
||||
/// </summary>
|
||||
public void EjectFromAllSlots(Entity<ItemSlotsComponent> entity)
|
||||
{
|
||||
EjectFromAllSlots(entity, _ => true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unlocks all slots and ejects items from them on the floor. Works only while <paramref name="shouldEject"/> returns true.
|
||||
/// </summary>
|
||||
private void EjectFromAllSlots(Entity<ItemSlotsComponent> entity, Func<ItemSlot, bool> shouldEject)
|
||||
{
|
||||
foreach (var slot in entity.Comp.Slots.Values)
|
||||
{
|
||||
if (slot.HasItem && shouldEject(slot))
|
||||
{
|
||||
SetLock(entity.Owner, slot, false, entity.Comp);
|
||||
TryEject(entity.Owner, slot, null, out _);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Verbs
|
||||
|
|
@ -826,14 +850,7 @@ namespace Content.Shared.Containers.ItemSlots
|
|||
/// </summary>
|
||||
private void OnBreak(EntityUid uid, ItemSlotsComponent component, EntityEventArgs args)
|
||||
{
|
||||
foreach (var slot in component.Slots.Values)
|
||||
{
|
||||
if (slot.EjectOnBreak && slot.HasItem)
|
||||
{
|
||||
SetLock(uid, slot, false, component);
|
||||
TryEject(uid, slot, null, out var _);
|
||||
}
|
||||
}
|
||||
EjectFromAllSlots((uid, component), slot => slot.EjectOnBreak);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
ejectVerbText: sheath-eject-verb
|
||||
insertSound: /Audio/Items/sheath.ogg
|
||||
ejectSound: /Audio/Items/unsheath.ogg
|
||||
ejectOnBreak: true
|
||||
whitelist:
|
||||
tags:
|
||||
- CaptainSabre
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@
|
|||
item:
|
||||
name: clothing-boots-sidearm
|
||||
priority: 4
|
||||
ejectOnBreak: true
|
||||
whitelist:
|
||||
tags:
|
||||
- Knife
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
slots:
|
||||
item:
|
||||
name: clothing-boots-sidearm
|
||||
ejectOnBreak: true
|
||||
whitelist:
|
||||
tags:
|
||||
- ToyKnife
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@
|
|||
name: id-card-console-privileged-id
|
||||
ejectSound: /Audio/Machines/id_swipe.ogg
|
||||
insertSound: /Audio/Weapons/Guns/MagIn/batrifle_magin.ogg
|
||||
ejectOnBreak: true
|
||||
swap: false
|
||||
whitelist:
|
||||
components:
|
||||
|
|
@ -136,7 +135,6 @@
|
|||
startingItem: UniversalIDCard
|
||||
ejectSound: /Audio/Machines/id_swipe.ogg
|
||||
insertSound: /Audio/Weapons/Guns/MagIn/batrifle_magin.ogg
|
||||
ejectOnBreak: true
|
||||
swap: false
|
||||
whitelist:
|
||||
components:
|
||||
|
|
@ -164,7 +162,6 @@
|
|||
startingItem: XenoborgIDCard
|
||||
ejectSound: /Audio/Machines/id_swipe.ogg
|
||||
insertSound: /Audio/Weapons/Guns/MagIn/batrifle_magin.ogg
|
||||
ejectOnBreak: true
|
||||
disableEject: true
|
||||
swap: false
|
||||
whitelist:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue