]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fixed gloved weapons being able to attack when not equipped. (#26762)
authorbeck-thompson <107373427+beck-thompson@users.noreply.github.com>
Wed, 17 Apr 2024 10:10:03 +0000 (03:10 -0700)
committerGitHub <noreply@github.com>
Wed, 17 Apr 2024 10:10:03 +0000 (20:10 +1000)
* Initial commit. No evil hidden files this time :)

* Added newline because I forgot :(

* We <3 tags :)

* Fixed! Works now

* Update Content.Shared/Weapons/Melee/MeleeWeaponComponent.cs

---------

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Content.Shared/Weapons/Melee/MeleeWeaponComponent.cs
Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs
Resources/Prototypes/Entities/Clothing/Hands/gloves.yml

index 85d2e4675f7c59335f361f3d2f6e06706e895429..fa5e0b3a905b1d85101fc55a6cff6c8c2033b981 100644 (file)
@@ -140,6 +140,14 @@ public sealed partial class MeleeWeaponComponent : Component
     [ViewVariables(VVAccess.ReadWrite)]
     [DataField("soundNoDamage"), AutoNetworkedField]
     public SoundSpecifier NoDamageSound { get; set; } = new SoundCollectionSpecifier("WeakHit");
+
+    /// <summary>
+    /// If true, the weapon must be equipped for it to be used.
+    /// E.g boxing gloves must be equipped to your gloves,
+    /// not just held in your hand to be used.
+    /// </summary>
+    [DataField, AutoNetworkedField]
+    public bool MustBeEquippedToUse = false;
 }
 
 /// <summary>
index e59b4a13fedf57ecf159856747050a6b8c1a1dd3..6fa11f87d2a9fcd12c08666898eb659db6828cc9 100644 (file)
@@ -277,7 +277,10 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
         if (EntityManager.TryGetComponent(entity, out HandsComponent? hands) &&
             hands.ActiveHandEntity is { } held)
         {
-            if (EntityManager.TryGetComponent(held, out melee))
+            // Make sure the entity is a weapon AND it doesn't need
+            // to be equipped to be used (E.g boxing gloves).
+            if (EntityManager.TryGetComponent(held, out melee) &&
+                !melee.MustBeEquippedToUse)
             {
                 weaponUid = held;
                 return true;
index bf08db78f712fb47a7add4859b881d76ad6b02ce..96bdd61f94e013536999b3c7c1f3f3015e11860e 100644 (file)
@@ -20,6 +20,7 @@
     soundHit:
       collection: BoxingHit
     animation: WeaponArcFist
+    mustBeEquippedToUse: true
   - type: Fiber
     fiberMaterial: fibers-leather
     fiberColor: fibers-red
@@ -90,6 +91,7 @@
       types:
         Blunt: 8
     bluntStaminaDamageFactor: 0.0 # so blunt doesn't deal stamina damage at all
+    mustBeEquippedToUse: true
 
 - type: entity
   parent: ClothingHandsBase
     soundHit:
       collection: Punch
     animation: WeaponArcFist
+    mustBeEquippedToUse: true
   - type: Fiber
     fiberMaterial: fibers-leather
     fiberColor: fibers-blue