explosion minor rework + fix (#21718)

This commit is contained in:
deltanedas
2023-11-19 17:44:42 +00:00
committed by GitHub
parent db76d85f36
commit f25773ffec
10 changed files with 148 additions and 62 deletions

View File

@@ -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)