]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Added several variables to make ClumsyComponent more modular for developers. (#33715)
authorbeck <163376292+widgetbeck@users.noreply.github.com>
Fri, 6 Dec 2024 15:31:31 +0000 (10:31 -0500)
committerGitHub <noreply@github.com>
Fri, 6 Dec 2024 15:31:31 +0000 (16:31 +0100)
Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
Content.Shared/Clumsy/ClumsyComponent.cs
Content.Shared/Clumsy/ClumsySystem.cs

index c71f5d0008ae90aba6ef284375fb09a05269ddc7..6b013a5c2f14900e659db5b02736151ad69aa152 100644 (file)
@@ -58,4 +58,46 @@ public sealed partial class ClumsyComponent : Component
     /// </summary>
     [DataField]
     public SoundSpecifier GunShootFailSound = new SoundPathSpecifier("/Audio/Weapons/Guns/Gunshots/bang.ogg");
+
+    /// <summary>
+    ///      Whether or not to apply Clumsy to hyposprays.
+    /// </summary>
+    [DataField, AutoNetworkedField]
+    public bool ClumsyHypo = true;
+
+    /// <summary>
+    ///      Whether or not to apply Clumsy to defibs.
+    /// </summary>
+    [DataField, AutoNetworkedField]
+    public bool ClumsyDefib = true;
+
+    /// <summary>
+    ///      Whether or not to apply Clumsy to guns.
+    /// </summary>
+    [DataField, AutoNetworkedField]
+    public bool ClumsyGuns = true;
+
+    /// <summary>
+    ///      Whether or not to apply Clumsy to vaulting.
+    /// </summary>
+    [DataField, AutoNetworkedField]
+    public bool ClumsyVaulting = true;
+
+    /// <summary>
+    ///      Lets you define a new "failed" message for each event.
+    /// </summary>
+    [DataField]
+    public LocId HypoFailedMessage = "hypospray-component-inject-self-clumsy-message";
+
+    [DataField]
+    public LocId GunFailedMessage = "gun-clumsy";
+
+    [DataField]
+    public LocId VaulingFailedMessageSelf = "bonkable-success-message-user";
+
+    [DataField]
+    public LocId VaulingFailedMessageOthers = "bonkable-success-message-others";
+
+    [DataField]
+    public LocId VaulingFailedMessageForced = "forced-bonkable-success-message";
 }
index e034458197fdf2018ec24f05cd97f93dfd422ad6..4804b6b723433cf09ee616162b74d134dd183b94 100644 (file)
@@ -38,6 +38,11 @@ public sealed class ClumsySystem : EntitySystem
     private void BeforeHyposprayEvent(Entity<ClumsyComponent> ent, ref SelfBeforeHyposprayInjectsEvent args)
     {
         // Clumsy people sometimes inject themselves! Apparently syringes are clumsy proof...
+    
+        // checks if ClumsyHypo is false, if so, skips.
+        if (!ent.Comp.ClumsyHypo)
+            return;
+
         if (!_random.Prob(ent.Comp.ClumsyDefaultCheck))
             return;
 
@@ -49,6 +54,11 @@ public sealed class ClumsySystem : EntitySystem
     private void BeforeDefibrillatorZapsEvent(Entity<ClumsyComponent> ent, ref SelfBeforeDefibrillatorZapsEvent args)
     {
         // Clumsy people sometimes defib themselves!
+        
+        // checks if ClumsyDefib is false, if so, skips.
+        if (!ent.Comp.ClumsyDefib)
+            return;
+
         if (!_random.Prob(ent.Comp.ClumsyDefaultCheck))
             return;
 
@@ -61,6 +71,10 @@ public sealed class ClumsySystem : EntitySystem
     {
         // Clumsy people sometimes can't shoot :(
 
+        // checks if ClumsyGuns is false, if so, skips.
+        if (!ent.Comp.ClumsyGuns)
+            return;
+
         if (args.Gun.Comp.ClumsyProof)
             return;
 
@@ -82,6 +96,10 @@ public sealed class ClumsySystem : EntitySystem
 
     private void OnBeforeClimbEvent(Entity<ClumsyComponent> ent, ref SelfBeforeClimbEvent args)
     {
+        // checks if ClumsyVaulting is false, if so, skips.
+        if (!ent.Comp.ClumsyVaulting)
+            return;
+
         // This event is called in shared, thats why it has all the extra prediction stuff.
         var rand = new System.Random((int)_timing.CurTick.Value);
 
@@ -102,8 +120,8 @@ public sealed class ClumsySystem : EntitySystem
         {
             // You are slamming yourself onto the table.
             _popup.PopupPredicted(
-                Loc.GetString("bonkable-success-message-user", ("bonkable", args.BeingClimbedOn)),
-                Loc.GetString("bonkable-success-message-others", ("victim", gettingPutOnTableName), ("bonkable", args.BeingClimbedOn)),
+                Loc.GetString(ent.Comp.VaulingFailedMessageSelf, ("bonkable", args.BeingClimbedOn)),
+                Loc.GetString(ent.Comp.VaulingFailedMessageOthers, ("victim", gettingPutOnTableName), ("bonkable", args.BeingClimbedOn)),
                 ent,
                 ent);
         }
@@ -112,7 +130,7 @@ public sealed class ClumsySystem : EntitySystem
             // Someone else slamed you onto the table.
             // This is only run in server so you need to use popup entity.
             _popup.PopupPredicted(
-                Loc.GetString("forced-bonkable-success-message",
+                Loc.GetString(ent.Comp.VaulingFailedMessageForced,
                     ("bonker", puttingOnTableName),
                     ("victim", gettingPutOnTableName),
                     ("bonkable", args.BeingClimbedOn)),