explosion minor rework + fix (#21718)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Content.Server.Storage.EntitySystems;
|
||||
using Content.Shared.Clothing.Components;
|
||||
using Content.Shared.Explosion;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Inventory.Events;
|
||||
@@ -15,11 +16,26 @@ namespace Content.Server.Inventory
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<InventoryComponent, BeforeExplodeEvent>(OnExploded);
|
||||
|
||||
SubscribeLocalEvent<ClothingComponent, UseInHandEvent>(OnUseInHand);
|
||||
|
||||
SubscribeNetworkEvent<OpenSlotStorageNetworkMessage>(OnOpenSlotStorage);
|
||||
}
|
||||
|
||||
private void OnExploded(Entity<InventoryComponent> ent, ref BeforeExplodeEvent args)
|
||||
{
|
||||
if (!TryGetContainerSlotEnumerator(ent, out var slots, ent.Comp))
|
||||
return;
|
||||
|
||||
// explode each item in their inventory too
|
||||
while (slots.MoveNext(out var slot))
|
||||
{
|
||||
if (slot.ContainedEntity != null)
|
||||
args.Contents.Add(slot.ContainedEntity.Value);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnUseInHand(EntityUid uid, ClothingComponent component, UseInHandEvent args)
|
||||
{
|
||||
if (args.Handled || !component.QuickEquip)
|
||||
|
||||
Reference in New Issue
Block a user