From 0e92a0c88c3857a393899e661f25479f6573fc81 Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Sun, 21 Jun 2020 21:57:22 +0200 Subject: [PATCH] Add backpack bombing (#1156) * Change exploding storages to explode their contents as well * Change storages to only trigger content explosions when the severity is heavy or destruction * Make inventories explode their contents as well * Change InventoryComponent IExAct into an explicit implementation * Change chain explosions to only trigger for explosion severities larger than or equal to heavy --- .../Components/GUI/InventoryComponent.cs | 22 ++++++++++++++++++- .../Items/Storage/ServerStorageComponent.cs | 20 ++++++++++++++++- .../GameObjects/EntitySystems/ActSystem.cs | 4 ++-- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs b/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs index cc48a4604c..0c698f434d 100644 --- a/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs +++ b/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs @@ -22,7 +22,7 @@ using static Content.Shared.GameObjects.SharedInventoryComponent.ClientInventory namespace Content.Server.GameObjects { [RegisterComponent] - public class InventoryComponent : SharedInventoryComponent + public class InventoryComponent : SharedInventoryComponent, IExAct { #pragma warning disable 649 [Dependency] private readonly IEntitySystemManager _entitySystemManager; @@ -396,5 +396,25 @@ namespace Content.Server.GameObjects } return new InventoryComponentState(list); } + + void IExAct.OnExplosion(ExplosionEventArgs eventArgs) + { + if (eventArgs.Severity < ExplosionSeverity.Heavy) + { + return; + } + + foreach (var slot in SlotContainers.Values.ToList()) + { + foreach (var entity in slot.ContainedEntities) + { + var exActs = entity.GetAllComponents(); + foreach (var exAct in exActs) + { + exAct.OnExplosion(eventArgs); + } + } + } + } } } diff --git a/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs index 27bbc2c942..efff79896e 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs @@ -32,7 +32,7 @@ namespace Content.Server.GameObjects [RegisterComponent] [ComponentReference(typeof(IActivate))] [ComponentReference(typeof(IStorageComponent))] - public class ServerStorageComponent : SharedStorageComponent, IInteractUsing, IUse, IActivate, IStorageComponent, IDestroyAct + public class ServerStorageComponent : SharedStorageComponent, IInteractUsing, IUse, IActivate, IStorageComponent, IDestroyAct, IExAct { #pragma warning disable 649 [Dependency] private readonly IMapManager _mapManager; @@ -364,6 +364,24 @@ namespace Content.Server.GameObjects } } + void IExAct.OnExplosion(ExplosionEventArgs eventArgs) + { + if (eventArgs.Severity < ExplosionSeverity.Heavy) + { + return; + } + + var storedEntities = storage.ContainedEntities.ToList(); + foreach (var entity in storedEntities) + { + var exActs = entity.GetAllComponents(); + foreach (var exAct in exActs) + { + exAct.OnExplosion(eventArgs); + } + } + } + /// /// Inserts an entity into the storage component from the players active hand. /// diff --git a/Content.Server/GameObjects/EntitySystems/ActSystem.cs b/Content.Server/GameObjects/EntitySystems/ActSystem.cs index 035cac5218..56be8389ea 100644 --- a/Content.Server/GameObjects/EntitySystems/ActSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/ActSystem.cs @@ -102,8 +102,8 @@ namespace Content.Server.GameObjects.EntitySystems } public enum ExplosionSeverity { - Destruction, - Heavy, Light, + Heavy, + Destruction, } }