Zombie Rework & Polymorph Expansion (#8413)
Co-authored-by: Kara <lunarautomaton6@gmail.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -5,6 +5,7 @@ using Content.Server.Temperature.Systems;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Inventory.Events;
|
||||
using Robust.Shared.Containers;
|
||||
using InventoryComponent = Content.Shared.Inventory.InventoryComponent;
|
||||
|
||||
namespace Content.Server.Inventory
|
||||
@@ -42,5 +43,35 @@ namespace Content.Server.Inventory
|
||||
_storageSystem.OpenStorageUI(entityUid.Value, uid, storageComponent);
|
||||
}
|
||||
}
|
||||
|
||||
public void TransferEntityInventories(EntityUid uid, EntityUid target)
|
||||
{
|
||||
if (TryGetContainerSlotEnumerator(uid, out var enumerator))
|
||||
{
|
||||
Dictionary<string, EntityUid?> inventoryEntities = new();
|
||||
var slots = GetSlots(uid);
|
||||
while (enumerator.MoveNext(out var containerSlot))
|
||||
{
|
||||
//records all the entities stored in each of the target's slots
|
||||
foreach (var slot in slots)
|
||||
{
|
||||
if (TryGetSlotContainer(target, slot.Name, out var conslot, out var _) &&
|
||||
conslot.ID == containerSlot.ID)
|
||||
{
|
||||
inventoryEntities.Add(slot.Name, containerSlot.ContainedEntity);
|
||||
}
|
||||
}
|
||||
//drops everything in the target's inventory on the ground
|
||||
containerSlot.EmptyContainer();
|
||||
}
|
||||
/// This takes the objects we removed and stored earlier
|
||||
/// and actually equips all of it to the new entity
|
||||
foreach (var item in inventoryEntities)
|
||||
{
|
||||
if (item.Value != null)
|
||||
TryEquip(target, item.Value.Value, item.Key, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user