]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Make crawl speed depend on your free hand count (#41458)
authorslarticodefast <161409025+slarticodefast@users.noreply.github.com>
Sun, 16 Nov 2025 23:48:25 +0000 (00:48 +0100)
committerGitHub <noreply@github.com>
Sun, 16 Nov 2025 23:48:25 +0000 (23:48 +0000)
* crawl speed

* I can't spell

Content.Shared/Hands/EntitySystems/SharedHandsSystem.EventListeners.cs
Content.Shared/Stunnable/SharedStunSystem.Knockdown.cs

index af0ed1c1aab31dad13d88cdb6f6f9793989752fd..ea2502331e972a27941ade84fc51a6a30d2f3034 100644 (file)
@@ -11,6 +11,7 @@ public abstract partial class SharedHandsSystem
     private void InitializeEventListeners()
     {
         SubscribeLocalEvent<HandsComponent, GetStandUpTimeEvent>(OnStandupArgs);
+        SubscribeLocalEvent<HandsComponent, KnockedDownRefreshEvent>(OnKnockedDownRefresh);
     }
 
     /// <summary>
@@ -28,4 +29,17 @@ public abstract partial class SharedHandsSystem
 
         time.DoAfterTime *= (float)ent.Comp.Count / (hands + ent.Comp.Count);
     }
+
+    private void OnKnockedDownRefresh(Entity<HandsComponent> ent, ref KnockedDownRefreshEvent args)
+    {
+        var freeHands = CountFreeHands(ent.AsNullable());
+        var totalHands = GetHandCount(ent.AsNullable());
+
+        // Can't crawl around without any hands.
+        // Entities without the HandsComponent will always have full crawling speed.
+        if (totalHands == 0)
+            args.SpeedModifier = 0f;
+        else
+            args.SpeedModifier *= (float)freeHands / totalHands;
+    }
 }
index fc2b01c649aec2647d7026a8029c58d96066400e..58f38c9db85f44cf9792e7b94f45d1d3d2347e65 100644 (file)
@@ -1,12 +1,12 @@
 using Content.Shared.Alert;
 using Content.Shared.Buckle.Components;
 using Content.Shared.CCVar;
-using Content.Shared.Damage;
 using Content.Shared.Damage.Components;
 using Content.Shared.Damage.Systems;
 using Content.Shared.Database;
 using Content.Shared.DoAfter;
 using Content.Shared.Gravity;
+using Content.Shared.Hands;
 using Content.Shared.Hands.EntitySystems;
 using Content.Shared.Input;
 using Content.Shared.Movement.Events;
@@ -54,7 +54,7 @@ public abstract partial class SharedStunSystem
         SubscribeLocalEvent<KnockedDownComponent, BuckleAttemptEvent>(OnBuckleAttempt);
         SubscribeLocalEvent<KnockedDownComponent, StandAttemptEvent>(OnStandAttempt);
 
-        // Updating movement a friction
+        // Updating movement and friction
         SubscribeLocalEvent<KnockedDownComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshKnockedSpeed);
         SubscribeLocalEvent<KnockedDownComponent, RefreshFrictionModifiersEvent>(OnRefreshFriction);
         SubscribeLocalEvent<KnockedDownComponent, TileFrictionEvent>(OnKnockedTileFriction);
@@ -66,6 +66,9 @@ public abstract partial class SharedStunSystem
         SubscribeLocalEvent<CrawlerComponent, KnockedDownRefreshEvent>(OnKnockdownRefresh);
         SubscribeLocalEvent<CrawlerComponent, DamageChangedEvent>(OnDamaged);
         SubscribeLocalEvent<KnockedDownComponent, WeightlessnessChangedEvent>(OnWeightlessnessChanged);
+        SubscribeLocalEvent<KnockedDownComponent, DidEquipHandEvent>(OnHandEquipped);
+        SubscribeLocalEvent<KnockedDownComponent, DidUnequipHandEvent>(OnHandUnequipped);
+        SubscribeLocalEvent<KnockedDownComponent, HandCountChangedEvent>(OnHandCountChanged);
         SubscribeLocalEvent<GravityAffectedComponent, KnockDownAttemptEvent>(OnKnockdownAttempt);
         SubscribeLocalEvent<GravityAffectedComponent, GetStandUpTimeEvent>(OnGetStandUpTime);
 
@@ -380,7 +383,7 @@ public abstract partial class SharedStunSystem
 
     private void OnForceStandup(ForceStandUpEvent msg, EntitySessionEventArgs args)
     {
-        if (args.SenderSession.AttachedEntity is not {} user)
+        if (args.SenderSession.AttachedEntity is not { } user)
             return;
 
         ForceStandUp(user);
@@ -522,6 +525,30 @@ public abstract partial class SharedStunSystem
         RemCompDeferred<KnockedDownComponent>(entity);
     }
 
+    private void OnHandEquipped(Entity<KnockedDownComponent> entity, ref DidEquipHandEvent args)
+    {
+        if (GameTiming.ApplyingState)
+            return; // The result of the change is already networked separately in the same game state
+
+        RefreshKnockedMovement(entity);
+    }
+
+    private void OnHandUnequipped(Entity<KnockedDownComponent> entity, ref DidUnequipHandEvent args)
+    {
+        if (GameTiming.ApplyingState)
+            return; // The result of the change is already networked separately in the same game state
+
+        RefreshKnockedMovement(entity);
+    }
+
+    private void OnHandCountChanged(Entity<KnockedDownComponent> entity, ref HandCountChangedEvent args)
+    {
+        if (GameTiming.ApplyingState)
+            return; // The result of the change is already networked separately in the same game state
+
+        RefreshKnockedMovement(entity);
+    }
+
     private void OnKnockdownAttempt(Entity<GravityAffectedComponent> entity, ref KnockDownAttemptEvent args)
     {
         // Directed, targeted moth attack.
@@ -582,6 +609,7 @@ public abstract partial class SharedStunSystem
 
         ent.Comp.SpeedModifier = ev.SpeedModifier;
         ent.Comp.FrictionModifier = ev.FrictionModifier;
+        Dirty(ent);
 
         _movementSpeedModifier.RefreshMovementSpeedModifiers(ent);
         _movementSpeedModifier.RefreshFrictionModifiers(ent);