]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
make syndie bag and rigs explosion resistant (#22088)
authordeltanedas <39013340+deltanedas@users.noreply.github.com>
Mon, 11 Dec 2023 09:43:00 +0000 (09:43 +0000)
committerGitHub <noreply@github.com>
Mon, 11 Dec 2023 09:43:00 +0000 (02:43 -0700)
* remove empty file real

* support explosion resistance for non-worn things

* remove redundant entitystorage resistance

* port entitystorage optimisation to apply for everything with 100% resistance

* add explosion resistance for bag contents

* make thing reusable

* add resistance to chest rig too

* medical chest rig too

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
Content.Server/Explosion/Components/ExplosionResistanceComponent.cs
Content.Server/Explosion/EntitySystems/ExplosionSystem.Processing.cs
Content.Server/Explosion/EntitySystems/ExplosionSystem.cs
Content.Server/Storage/EntitySystems/EntityStorageSystem.cs
Content.Shared/Storage/Components/SharedEntityStorageComponent.cs
Content.Shared/Storage/SharedStorageComponent.cs [deleted file]
Resources/Locale/en-US/explosions/explosion-resistance.ftl
Resources/Prototypes/Entities/Clothing/Back/backpacks.yml
Resources/Prototypes/Entities/Clothing/Back/duffel.yml
Resources/Prototypes/Entities/Clothing/Belt/belts.yml
Resources/Prototypes/Entities/Clothing/base_clothing.yml

index a65764c41333eabba0082faca4ac1ae4f526f7f6..d4a93c2b5699b535f106e96221846a9bd76364b5 100644 (file)
@@ -5,7 +5,9 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
 namespace Content.Server.Explosion.Components;
 
 /// <summary>
-///     Component that provides entities with explosion resistance.
+/// Component that provides entities with explosion resistance.
+/// By default this is applied when worn, but to solely protect the entity itself and
+/// not the wearer use <c>worn: false</c>.
 /// </summary>
 /// <remarks>
 ///     This is desirable over just using damage modifier sets, given that equipment like bomb-suits need to
@@ -21,6 +23,20 @@ public sealed partial class ExplosionResistanceComponent : Component
     [DataField("damageCoefficient")]
     public float DamageCoefficient = 1;
 
+    /// <summary>
+    /// When true, resistances will be applied to the entity wearing this item.
+    /// When false, only this entity will get th resistance.
+    /// </summary>
+    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    public bool Worn = true;
+
+    /// <summary>
+    /// Examine string for explosion resistance.
+    /// Passed <c>value</c> from 0 to 100.
+    /// </summary>
+    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    public LocId Examine = "explosion-resistance-coefficient-value";
+
     /// <summary>
     ///     Modifiers specific to each explosion type for more customizability.
     /// </summary>
index 1941ff9d163fb671dc585d17c2245fccf086798a..e48d9f145ebbb62dcc1f0f8f433119a89540557d 100644 (file)
@@ -389,7 +389,13 @@ public sealed partial class ExplosionSystem
     private void GetEntitiesToDamage(EntityUid uid, DamageSpecifier originalDamage, string prototype)
     {
         _toDamage.Clear();
-        _toDamage.Add((uid, GetDamage(uid, prototype, originalDamage)));
+
+        // don't raise BeforeExplodeEvent if the entity is completely immune to explosions
+        var thisDamage = GetDamage(uid, prototype, originalDamage);
+        if (!thisDamage.Any())
+            return;
+
+        _toDamage.Add((uid, thisDamage));
 
         for (var i = 0; i < _toDamage.Count; i++)
         {
index a246b940859aebc0be688564749503652b295ec5..9df735ff6acf9e1dee2b7a600e7e3323c4a9751f 100644 (file)
@@ -132,7 +132,8 @@ public sealed partial class ExplosionSystem : EntitySystem
     private void RelayedResistance(EntityUid uid, ExplosionResistanceComponent component,
         InventoryRelayedEvent<GetExplosionResistanceEvent> args)
     {
-        OnGetResistance(uid, component, ref args.Args);
+        if (component.Worn)
+            OnGetResistance(uid, component, ref args.Args);
     }
 
     private void OnGetResistance(EntityUid uid, ExplosionResistanceComponent component, ref GetExplosionResistanceEvent args)
@@ -378,9 +379,9 @@ public sealed partial class ExplosionSystem : EntitySystem
 
     private void OnArmorExamine(EntityUid uid, ExplosionResistanceComponent component, ref ArmorExamineEvent args)
     {
+        var value = MathF.Round((1f - component.DamageCoefficient) * 100, 1);
+
         args.Msg.PushNewline();
-        args.Msg.AddMarkup(Loc.GetString("explosion-resistance-coefficient-value",
-            ("value", MathF.Round((1f - component.DamageCoefficient) * 100, 1))
-            ));
+        args.Msg.AddMarkup(Loc.GetString(component.Examine, ("value", value)));
     }
 }
index efb3734962d3f686a0d34e5bba444efdd05cf9b1..9bc49165eede411fbb939a2aa630616aa885f525 100644 (file)
@@ -102,11 +102,7 @@ public sealed class EntityStorageSystem : SharedEntityStorageSystem
 
     private void OnExploded(Entity<EntityStorageComponent> ent, ref BeforeExplodeEvent args)
     {
-        if (ent.Comp.ExplosionDamageCoefficient <= 0)
-            return;
-
         args.Contents.AddRange(ent.Comp.Contents.ContainedEntities);
-        args.DamageCoefficient *= ent.Comp.ExplosionDamageCoefficient;
     }
 
     protected override void TakeGas(EntityUid uid, SharedEntityStorageComponent component)
index e70c59c9d67199f5ecd8750dfa9ab6cdaf5821ea..b4cd18f4d5c62c7eba05b48b1c2b623c9ee9b563 100644 (file)
@@ -124,12 +124,6 @@ public abstract partial class SharedEntityStorageComponent : Component
     /// </summary>
     [ViewVariables]
     public Container Contents = default!;
-
-    /// <summary>
-    /// Multiplier for explosion damage that gets applied to contained entities.
-    /// </summary>
-    [DataField]
-    public float ExplosionDamageCoefficient = 1;
 }
 
 [Serializable, NetSerializable]
diff --git a/Content.Shared/Storage/SharedStorageComponent.cs b/Content.Shared/Storage/SharedStorageComponent.cs
deleted file mode 100644 (file)
index e69de29..0000000
index 26fb74346d10cd99732916f424da6c2fef9ce2ba..6ebb406b9a9c7537548a1bafdcf1ebd4cd2fc4a4 100644 (file)
@@ -1 +1,2 @@
 explosion-resistance-coefficient-value = - [color=orange]Explosion[/color] damage reduced by [color=lightblue]{$value}%[/color].
+explosion-resistance-contents-coefficient-value = - [color=orange]Explosion[/color] damage [color=white]to contents[/color] reduced by [color=lightblue]{$value}%[/color].
index b8792211a279c6e02ff73a850d9b2e71e9fc0d90..867bbc107697e4c850c0354e3af766b908fe45f5 100644 (file)
@@ -1,5 +1,5 @@
 - type: entity
-  parent: Clothing
+  parent: [Clothing, ContentsExplosionResistanceBase]
   id: ClothingBackpack
   name: backpack
   description: You wear this on your back and put items into it.
@@ -28,6 +28,8 @@
   # to prevent bag open/honk spam
   - type: UseDelay
     delay: 0.5
+  - type: ExplosionResistance
+    damageCoefficient: 0.9
 
 - type: entity
   parent: ClothingBackpack
index ca1281eb9d66c4ed268db0e6a95d263074169180..2ac53effe631102cb73d4e77d777fceeeea1b77f 100644 (file)
   components:
   - type: Sprite
     sprite: Clothing/Back/Duffels/syndicate.rsi
+  - type: ExplosionResistance
+    damageCoefficient: 0.1
 
 - type: entity
   parent: ClothingBackpackDuffelSyndicate
index fb27fc676c2e8610ce71dc5d37d8c6c50d1513e3..0375980d649a49a9269f5781caa1f06c819e73ba 100644 (file)
     sprite: Clothing/Belt/salvagewebbing.rsi
 
 - type: entity
-  parent: ClothingBeltStorageBase
+  parent: [ClothingBeltStorageBase, ContentsExplosionResistanceBase]
   id: ClothingBeltMilitaryWebbing
   name: chest rig
   description: A set of tactical webbing worn by Syndicate boarding parties.
     sprite: Clothing/Belt/militarywebbing.rsi
   - type: Clothing
     sprite: Clothing/Belt/militarywebbing.rsi
+  - type: ExplosionResistance
+    damageCoefficient: 0.5
 
 - type: entity
-  parent: ClothingBeltStorageBase
+  parent: ClothingBeltMilitaryWebbing
   id: ClothingBeltMilitaryWebbingMed
   name: medical chest rig
   description: A set of tactical webbing worn by Gorlex Marauder medic operatives.
index df22b9b40d373976190d684e327b50987c25f2ec..04609381cbf5971c33818dadbf307421620ed42d 100644 (file)
   - type: ContainerContainer
     containers:
       item: !type:ContainerSlot
+
+# a piece of clothing that has explosion resistance *for its contents*, not the wearer
+- type: entity
+  abstract: true
+  id: ContentsExplosionResistanceBase
+  components:
+  - type: ExplosionResistance
+    worn: true # only apply to the clothing itself and items inside, not the wearer
+    examine: explosion-resistance-contents-coefficient-value
+  # to show explosion resistance examine
+  - type: GroupExamine
+  - type: Armor
+    modifiers: {}