using Content.Shared.Explosion; using Content.Shared.Inventory; namespace Content.Server.Inventory { public sealed class ServerInventorySystem : InventorySystem { public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnExploded); } private void OnExploded(Entity ent, ref BeforeExplodeEvent args) { // explode each item in their inventory too var slots = new InventorySlotEnumerator(ent); while (slots.MoveNext(out var slot)) { if (slot.ContainedEntity != null) args.Contents.Add(slot.ContainedEntity.Value); } } public void TransferEntityInventories(Entity source, Entity target) { if (!Resolve(source.Owner, ref source.Comp) || !Resolve(target.Owner, ref target.Comp)) return; var enumerator = new InventorySlotEnumerator(source.Comp); while (enumerator.NextItem(out var item, out var slot)) { if (TryUnequip(source, slot.Name, true, true, inventory: source.Comp)) TryEquip(target, item, slot.Name , true, true, inventory: target.Comp); } } } }