]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Hardsuits, EVA suits, Firesuits, and others now protect your feet from Glass Shards...
authorPlykiya <58439124+Plykiya@users.noreply.github.com>
Sun, 28 Apr 2024 07:11:46 +0000 (00:11 -0700)
committerGitHub <noreply@github.com>
Sun, 28 Apr 2024 07:11:46 +0000 (17:11 +1000)
* Hardsuits and softsuits count as having shoes for step triggers

* Add softsuit tag prototype

* Change to suitEVA tag

* Get rid of softsuit tag, found suitEVA tag

* Full pass of ShoesRequiredStepTriggerImmune

* Adds check to outerClothing for ShoesRequiredStepTriggerImmune

* return

* fuck Dionas

* Convert to comp, space dragons immune as well

* Merge conflict

* Merge conflict

* fix leftover tags

* empty spaces

* turns out the dragon didn't need it

* minor optimization

* Add access for system, add comp to baseShoes, check slotflags for every slot besides pockets

* fix

* fuck it we ball

---------

Co-authored-by: Plykiya <plykiya@protonmail.com>
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
22 files changed:
Content.Shared/Inventory/InventorySystem.Relay.cs
Content.Shared/Inventory/InventorySystem.Slots.cs
Content.Shared/Inventory/SlotFlags.cs
Content.Shared/StepTrigger/Components/ClothingRequiredStepTriggerComponent.cs [new file with mode: 0644]
Content.Shared/StepTrigger/Components/ClothingRequiredStepTriggerImmuneComponent.cs [new file with mode: 0644]
Content.Shared/StepTrigger/Components/ShoesRequiredStepTriggerComponent.cs [deleted file]
Content.Shared/StepTrigger/Components/StepTriggerImmuneComponent.cs [new file with mode: 0644]
Content.Shared/StepTrigger/Systems/ShoesRequiredStepTriggerSystem.cs [deleted file]
Content.Shared/StepTrigger/Systems/StepTriggerImmuneSystem.cs [new file with mode: 0644]
Content.Shared/Weapons/Reflect/ReflectSystem.cs
Resources/Locale/en-US/step-trigger/shoes-required.ftl
Resources/Prototypes/Entities/Clothing/OuterClothing/armor.yml
Resources/Prototypes/Entities/Clothing/OuterClothing/base_clothingouter.yml
Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml
Resources/Prototypes/Entities/Clothing/Shoes/base_clothingshoes.yml
Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml
Resources/Prototypes/Entities/Mobs/NPCs/elemental.yml
Resources/Prototypes/Entities/Mobs/NPCs/silicon.yml
Resources/Prototypes/Entities/Objects/Devices/mousetrap.yml
Resources/Prototypes/Entities/Objects/Fun/dice.yml
Resources/Prototypes/Entities/Objects/Materials/shards.yml
Resources/Prototypes/tags.yml

index b418a1d41624987d75ff5d6ebbd783a7cf2f0dea..6bd65622f17214c5f114a437f46c55954b0119a0 100644 (file)
@@ -123,6 +123,11 @@ public sealed class InventoryRelayedEvent<TEvent> : EntityEventArgs
     }
 }
 
+public interface IClothingSlots
+{
+    SlotFlags Slots { get; }
+}
+
 /// <summary>
 ///     Events that should be relayed to inventory slots should implement this interface.
 /// </summary>
index c634b68e041b02de449efad0a22026d1b9a77315..1da44155b9566656de711a94b55921bb8454aa23 100644 (file)
@@ -27,6 +27,31 @@ public partial class InventorySystem : EntitySystem
             .RemoveHandler(HandleViewVariablesSlots, ListViewVariablesSlots);
     }
 
+    /// <summary>
+    /// Tries to find an entity in the specified slot with the specified component.
+    /// </summary>
+    public bool TryGetInventoryEntity<T>(Entity<InventoryComponent?> entity, out EntityUid targetUid)
+        where T : IComponent, IClothingSlots
+    {
+        if (TryGetContainerSlotEnumerator(entity.Owner, out var containerSlotEnumerator))
+        {
+            while (containerSlotEnumerator.NextItem(out var item, out var slot))
+            {
+                if (!TryComp<T>(item, out var required))
+                    continue;
+
+                if ((((IClothingSlots) required).Slots & slot.SlotFlags) == 0x0)
+                    continue;
+
+                targetUid = item;
+                return true;
+            }
+        }
+
+        targetUid = EntityUid.Invalid;
+        return false;
+    }
+
     protected virtual void OnInit(EntityUid uid, InventoryComponent component, ComponentInit args)
     {
         if (!_prototypeManager.TryIndex(component.TemplateId, out InventoryTemplatePrototype? invTemplate))
index 8d5e33e34863831f14fe3f4547e035da7688e497..90971d1670bca700d7737da7abfb659a1b4d2526 100644 (file)
@@ -27,4 +27,6 @@ public enum SlotFlags
     FEET = 1 << 14,
     SUITSTORAGE = 1 << 15,
     All = ~NONE,
+
+    WITHOUT_POCKET = All & ~POCKET
 }
diff --git a/Content.Shared/StepTrigger/Components/ClothingRequiredStepTriggerComponent.cs b/Content.Shared/StepTrigger/Components/ClothingRequiredStepTriggerComponent.cs
new file mode 100644 (file)
index 0000000..9efd78d
--- /dev/null
@@ -0,0 +1,10 @@
+using Content.Shared.Inventory;
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.StepTrigger.Components;
+
+/// <summary>
+/// This is used for marking step trigger events that require the user to wear shoes, such as for glass shards.
+/// </summary>
+[RegisterComponent, NetworkedComponent]
+public sealed partial class ClothingRequiredStepTriggerComponent : Component;
diff --git a/Content.Shared/StepTrigger/Components/ClothingRequiredStepTriggerImmuneComponent.cs b/Content.Shared/StepTrigger/Components/ClothingRequiredStepTriggerImmuneComponent.cs
new file mode 100644 (file)
index 0000000..dc76207
--- /dev/null
@@ -0,0 +1,16 @@
+using Content.Shared.Inventory;
+using Content.Shared.StepTrigger.Systems;
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.StepTrigger.Components;
+
+/// <summary>
+/// This is used for cancelling step trigger events if the user is wearing clothing in a valid slot.
+/// </summary>
+[RegisterComponent, NetworkedComponent]
+[Access(typeof(StepTriggerImmuneSystem))]
+public sealed partial class ClothingRequiredStepTriggerImmuneComponent : Component, IClothingSlots
+{
+    [DataField]
+    public SlotFlags Slots { get; set; } = SlotFlags.FEET;
+}
diff --git a/Content.Shared/StepTrigger/Components/ShoesRequiredStepTriggerComponent.cs b/Content.Shared/StepTrigger/Components/ShoesRequiredStepTriggerComponent.cs
deleted file mode 100644 (file)
index dd95b94..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-using Robust.Shared.GameStates;
-
-namespace Content.Shared.StepTrigger.Components;
-
-/// <summary>
-/// This is used for cancelling step trigger events if the user is wearing shoes, such as for glass shards.
-/// </summary>
-[RegisterComponent, NetworkedComponent]
-public sealed partial class ShoesRequiredStepTriggerComponent : Component
-{
-}
diff --git a/Content.Shared/StepTrigger/Components/StepTriggerImmuneComponent.cs b/Content.Shared/StepTrigger/Components/StepTriggerImmuneComponent.cs
new file mode 100644 (file)
index 0000000..74e10ba
--- /dev/null
@@ -0,0 +1,9 @@
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.StepTrigger.Components;
+
+/// <summary>
+/// Grants the attached entity to step triggers.
+/// </summary>
+[RegisterComponent, NetworkedComponent]
+public sealed partial class StepTriggerImmuneComponent : Component;
diff --git a/Content.Shared/StepTrigger/Systems/ShoesRequiredStepTriggerSystem.cs b/Content.Shared/StepTrigger/Systems/ShoesRequiredStepTriggerSystem.cs
deleted file mode 100644 (file)
index 5fc9140..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-using Content.Shared.Examine;
-using Content.Shared.Inventory;
-using Content.Shared.StepTrigger.Components;
-using Content.Shared.Tag;
-
-namespace Content.Shared.StepTrigger.Systems;
-
-public sealed class ShoesRequiredStepTriggerSystem : EntitySystem
-{
-    [Dependency] private readonly InventorySystem _inventory = default!;
-    [Dependency] private readonly TagSystem _tagSystem = default!;
-
-    /// <inheritdoc/>
-    public override void Initialize()
-    {
-        SubscribeLocalEvent<ShoesRequiredStepTriggerComponent, StepTriggerAttemptEvent>(OnStepTriggerAttempt);
-        SubscribeLocalEvent<ShoesRequiredStepTriggerComponent, ExaminedEvent>(OnExamined);
-    }
-
-    private void OnStepTriggerAttempt(EntityUid uid, ShoesRequiredStepTriggerComponent component, ref StepTriggerAttemptEvent args)
-    {
-        if (_tagSystem.HasTag(args.Tripper, "ShoesRequiredStepTriggerImmune"))
-        {
-            args.Cancelled = true;
-            return;
-        }
-
-        if (!TryComp<InventoryComponent>(args.Tripper, out var inventory))
-            return;
-
-        if (_inventory.TryGetSlotEntity(args.Tripper, "shoes", out _, inventory))
-        {
-            args.Cancelled = true;
-        }
-    }
-
-    private void OnExamined(EntityUid uid, ShoesRequiredStepTriggerComponent component, ExaminedEvent args)
-    {
-        args.PushMarkup(Loc.GetString("shoes-required-step-trigger-examine"));
-    }
-}
diff --git a/Content.Shared/StepTrigger/Systems/StepTriggerImmuneSystem.cs b/Content.Shared/StepTrigger/Systems/StepTriggerImmuneSystem.cs
new file mode 100644 (file)
index 0000000..ca72a20
--- /dev/null
@@ -0,0 +1,37 @@
+using Content.Shared.Examine;
+using Content.Shared.Inventory;
+using Content.Shared.StepTrigger.Components;
+using Content.Shared.Tag;
+
+namespace Content.Shared.StepTrigger.Systems;
+
+public sealed class StepTriggerImmuneSystem : EntitySystem
+{
+    [Dependency] private readonly InventorySystem _inventory = default!;
+
+    /// <inheritdoc/>
+    public override void Initialize()
+    {
+        SubscribeLocalEvent<StepTriggerImmuneComponent, StepTriggerAttemptEvent>(OnStepTriggerAttempt);
+        SubscribeLocalEvent<ClothingRequiredStepTriggerComponent, StepTriggerAttemptEvent>(OnStepTriggerClothingAttempt);
+        SubscribeLocalEvent<ClothingRequiredStepTriggerComponent, ExaminedEvent>(OnExamined);
+    }
+
+    private void OnStepTriggerAttempt(Entity<StepTriggerImmuneComponent> ent, ref StepTriggerAttemptEvent args)
+    {
+        args.Cancelled = true;
+    }
+
+    private void OnStepTriggerClothingAttempt(EntityUid uid, ClothingRequiredStepTriggerComponent component, ref StepTriggerAttemptEvent args)
+    {
+        if (_inventory.TryGetInventoryEntity<ClothingRequiredStepTriggerImmuneComponent>(args.Tripper, out _))
+        {
+            args.Cancelled = true;
+        }
+    }
+
+    private void OnExamined(EntityUid uid, ClothingRequiredStepTriggerComponent component, ExaminedEvent args)
+    {
+        args.PushMarkup(Loc.GetString("clothing-required-step-trigger-examine"));
+    }
+}
index 4a7c2f6b6a7b736365a5b0c48e030e72ee2cc17c..014b3cfe1ff37b9bae10f0db28c3092463630d07 100644 (file)
@@ -57,7 +57,7 @@ public sealed class ReflectSystem : EntitySystem
         if (args.Reflected)
             return;
 
-        foreach (var ent in _inventorySystem.GetHandOrInventoryEntities(uid, SlotFlags.All & ~SlotFlags.POCKET))
+        foreach (var ent in _inventorySystem.GetHandOrInventoryEntities(uid, SlotFlags.WITHOUT_POCKET))
         {
             if (!TryReflectHitscan(uid, ent, args.Shooter, args.SourceItem, args.Direction, out var dir))
                 continue;
@@ -70,7 +70,7 @@ public sealed class ReflectSystem : EntitySystem
 
     private void OnReflectUserCollide(EntityUid uid, ReflectUserComponent component, ref ProjectileReflectAttemptEvent args)
     {
-        foreach (var ent in _inventorySystem.GetHandOrInventoryEntities(uid, SlotFlags.All & ~SlotFlags.POCKET))
+        foreach (var ent in _inventorySystem.GetHandOrInventoryEntities(uid, SlotFlags.WITHOUT_POCKET))
         {
             if (!TryReflectProjectile(uid, ent, args.ProjUid))
                 continue;
@@ -222,7 +222,7 @@ public sealed class ReflectSystem : EntitySystem
     /// </summary>
     private void RefreshReflectUser(EntityUid user)
     {
-        foreach (var ent in _inventorySystem.GetHandOrInventoryEntities(user, SlotFlags.All & ~SlotFlags.POCKET))
+        foreach (var ent in _inventorySystem.GetHandOrInventoryEntities(user, SlotFlags.WITHOUT_POCKET))
         {
             if (!HasComp<ReflectComponent>(ent))
                 continue;
index 8c1369a49f4919b9b556868e9c0a2fbc03d37684..07a4b8a84f8b27c6bffb49056bb3ce284ce0e073 100644 (file)
@@ -1 +1 @@
-shoes-required-step-trigger-examine = You probably shouldn't step on this barefoot.
+clothing-required-step-trigger-examine = You probably shouldn't step on this barefoot.
index 9a1f14274024255f784d42a6416539d053ecff94..ecc4156affaa3261dc39b9e4276181ebf5bc721a 100644 (file)
         Radiation: 0
         Caustic: 0.75
   - type: GroupExamine
+  - type: ClothingRequiredStepTriggerImmune
+    slots: WITHOUT_POCKET
 
 - type: entity
   parent: ClothingOuterArmorHeavy
   - type: ExplosionResistance
     damageCoefficient: 0.5
   - type: GroupExamine
+  - type: ClothingRequiredStepTriggerImmune
+    slots: WITHOUT_POCKET
 
 - type: entity
   parent: ClothingOuterBaseLarge
   - type: Construction
     graph: BoneArmor
     node: armor
+  - type: ClothingRequiredStepTriggerImmune
+    slots: WITHOUT_POCKET
 
 - type: entity
   parent: ClothingOuterBaseLarge
         Piercing: 0.6
         Heat: 0.5
   - type: GroupExamine
+  - type: ClothingRequiredStepTriggerImmune
+    slots: WITHOUT_POCKET
+
index e5067e84c516008d964d7faa5762a52047e34187..16b287917b5f2733031b8766ebb29832cf32b733 100644 (file)
     tags:
     - Hardsuit
     - WhitelistChameleon
+  - type: ClothingRequiredStepTriggerImmune
+    slots: WITHOUT_POCKET
 
 - type: entity
   abstract: true
   - type: HeldSpeedModifier
   - type: Item
     size: Huge
+  - type: ClothingRequiredStepTriggerImmune
+    slots: WITHOUT_POCKET
 
 - type: entity
   parent: ClothingOuterBase
index 5e82959c4e2282616c2d3fc01d1eb4f42baec3e8..cc6f0131adf59cb84c5fc7377e04aa5a07d3fa02 100644 (file)
@@ -25,6 +25,8 @@
     tags:
     - Hardsuit
     - WhitelistChameleon
+  - type: ClothingRequiredStepTriggerImmune
+    slots: WITHOUT_POCKET
 
 - type: entity
   parent: ClothingOuterSuitBomb
@@ -63,6 +65,8 @@
     sprintModifier: 0.7
   - type: HeldSpeedModifier
   - type: GroupExamine
+  - type: ClothingRequiredStepTriggerImmune
+    slots: WITHOUT_POCKET
 
 - type: entity
   parent: ClothingOuterBaseLarge
   name: atmos fire suit
   description: An expensive firesuit that protects against even the most deadly of station fires. Designed to protect even if the wearer is set aflame.
   components:
-    - type: Sprite
-      sprite: Clothing/OuterClothing/Suits/atmos_firesuit.rsi
-    - type: Clothing
-      sprite: Clothing/OuterClothing/Suits/atmos_firesuit.rsi
-    - type: PressureProtection
-      highPressureMultiplier: 0.02
-      lowPressureMultiplier: 1000
-    - type: TemperatureProtection
-      coefficient: 0.001
-    - type: Armor
-      modifiers:
-        coefficients:
-          Slash: 0.9
-          Heat: 0.3
-          Cold: 0.2
-    - type: ClothingSpeedModifier
-      walkModifier: 0.8
-      sprintModifier: 0.8
-    - type: HeldSpeedModifier
-    - type: GroupExamine
+  - type: Sprite
+    sprite: Clothing/OuterClothing/Suits/atmos_firesuit.rsi
+  - type: Clothing
+    sprite: Clothing/OuterClothing/Suits/atmos_firesuit.rsi
+  - type: PressureProtection
+    highPressureMultiplier: 0.02
+    lowPressureMultiplier: 1000
+  - type: TemperatureProtection
+    coefficient: 0.001
+  - type: Armor
+    modifiers:
+      coefficients:
+        Slash: 0.9
+        Heat: 0.3
+        Cold: 0.2
+  - type: ClothingSpeedModifier
+    walkModifier: 0.8
+    sprintModifier: 0.8
+  - type: HeldSpeedModifier
+  - type: GroupExamine
+  - type: ClothingRequiredStepTriggerImmune
+    slots: WITHOUT_POCKET
 
 - type: entity
   parent: [ClothingOuterBaseLarge, GeigerCounterClothing]
   - type: ContainerContainer
     containers:
       toggleable-clothing: !type:ContainerSlot {}
-      
+  - type: ClothingRequiredStepTriggerImmune
+    slots: WITHOUT_POCKET
+
 - type: entity
   parent: ClothingOuterBaseLarge
   id: ClothingOuterSuitSpaceNinja
     sprite: Clothing/OuterClothing/Suits/chicken.rsi
   - type: Clothing
     sprite: Clothing/OuterClothing/Suits/chicken.rsi
+  - type: ClothingRequiredStepTriggerImmune
+    slots: WITHOUT_POCKET
 
 - type: entity
   parent: ClothingOuterBase
   - type: ContainerContainer
     containers:
       toggleable-clothing: !type:ContainerSlot {}
+  - type: ClothingRequiredStepTriggerImmune
+    slots: WITHOUT_POCKET
 
 - type: entity
   parent: ClothingOuterBase
   - type: Construction
     graph: ClothingOuterSuitIan
     node: suit
+  - type: ClothingRequiredStepTriggerImmune
+    slots: WITHOUT_POCKET
 
 - type: entity
   parent: ClothingOuterBase
index 1119d5cda74b292078359ef17103dc5f8532e242..a0f56966bb5903231ac291064a2440dd651fd027 100644 (file)
@@ -23,6 +23,7 @@
     tags:
     - ClothMade
     - WhitelistChameleon
+  - type: ClothingRequiredStepTriggerImmune
 
 - type: entity
   abstract: true
index 27a19ab8994032216f9b1c253c924baac213bad3..cb846c7ddec519294a754db8d8c915c726bd1714 100644 (file)
   - type: StandingState
   - type: Tag
     tags:
-    - ShoesRequiredStepTriggerImmune
     - DoorBumpOpener
     - CanPilot
   - type: Emoting
   - type: GuideHelp
     guides:
       - Cyborgs
+  - type: StepTriggerImmune
 
 - type: entity
   id: BaseBorgChassisNT
index c2380c40278cffdf1331ca7def3aa07514810926..58d30ccfc06a605bb2deb24a79ec2724692fa14d 100644 (file)
@@ -44,7 +44,6 @@
   - type: Tag
     tags:
     - DoorBumpOpener
-    - ShoesRequiredStepTriggerImmune
   - type: MobState
     allowedStates:
       - Alive
@@ -73,6 +72,8 @@
   - type: InputMover
   - type: MobMover
   - type: ZombieImmune
+  - type: ClothingRequiredStepTriggerImmune
+    slots: All
 
 - type: entity
   abstract: true
index c808ed2d210e3851047339a36efec91520dc57fe..7a36046a0fd598d38791d8c90d5b6c43c98e21f8 100644 (file)
@@ -66,7 +66,6 @@
   - type: Tag
     tags:
     - DoorBumpOpener
-    - ShoesRequiredStepTriggerImmune
   - type: MobState
     allowedStates:
       - Alive
   - type: TypingIndicator
     proto: robot
   - type: ZombieImmune
+  - type: StepTriggerImmune
 
 - type: entity
   parent: MobSiliconBase
index c3bd74dd75121a50763872fc25dbc7b552224c96..d97cae2e6d674802deb987d07c2e978d31f436f5 100644 (file)
@@ -15,7 +15,7 @@
       requiredTriggeredSpeed: 0
     - type: Mousetrap
     - type: TriggerOnStepTrigger
-    - type: ShoesRequiredStepTrigger
+    - type: ClothingRequiredStepTrigger
     - type: DamageUserOnTrigger
       damage:
         types:
index 852a1c2699c9d8ec30a1eae789a9193997052268..0b534f087989f3e0ea019168ea5ed4ea901f13e5 100644 (file)
   - type: StepTrigger
     intersectRatio: 0.2
   - type: TriggerOnStepTrigger
-  - type: ShoesRequiredStepTrigger
+  - type: ClothingRequiredStepTrigger
   - type: Slippery
     slipSound:
       path: /Audio/Effects/glass_step.ogg
index 834a2e7ff0a093f9cbcbd3539dc5c93fdb01333b..dfd02b6fccf7faadaca0304cb3e7564af699432f 100644 (file)
@@ -63,7 +63,7 @@
         acts: [ "Destruction" ]
   - type: StepTrigger
     intersectRatio: 0.2
-  - type: ShoesRequiredStepTrigger
+  - type: ClothingRequiredStepTrigger
   - type: Slippery
     slipSound:
       path: /Audio/Effects/glass_step.ogg
index 8238bc2d536ec0eba85a908e9a3df4d7cc128e5f..f4477a8c85de5c39c4bd05d4d11c78973231eac7 100644 (file)
 - type: Tag
   id: Shiv
 
-- type: Tag
-  id: ShoesRequiredStepTriggerImmune
-
 - type: Tag
   id: Shovel