]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
offgrid mob friction (#29383)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Fri, 9 Aug 2024 04:52:25 +0000 (00:52 -0400)
committerGitHub <noreply@github.com>
Fri, 9 Aug 2024 04:52:25 +0000 (14:52 +1000)
* offgrid mob friction

* save the world...

Content.Shared/Movement/Components/MovementSpeedModifierComponent.cs
Content.Shared/Movement/Systems/SharedMoverController.cs

index a0feab7052c44cd7fc27f61359260a35d843613e..02a85385314dbd59d2f5bb943d33dc7230a00592 100644 (file)
@@ -15,6 +15,7 @@ namespace Content.Shared.Movement.Components
         public const float DefaultMinimumFrictionSpeed = 0.005f;
         public const float DefaultWeightlessFriction = 1f;
         public const float DefaultWeightlessFrictionNoInput = 0.2f;
+        public const float DefaultOffGridFriction = 0.05f;
         public const float DefaultWeightlessModifier = 0.7f;
         public const float DefaultWeightlessAcceleration = 1f;
 
@@ -72,6 +73,12 @@ namespace Content.Shared.Movement.Components
         [ViewVariables(VVAccess.ReadWrite), DataField]
         public float WeightlessFrictionNoInput = DefaultWeightlessFrictionNoInput;
 
+        /// <summary>
+        /// The negative velocity applied for friction when weightless and not standing on a grid or mapgrid
+        /// </summary>
+        [ViewVariables(VVAccess.ReadWrite), DataField]
+        public float OffGridFriction = DefaultOffGridFriction;
+
         /// <summary>
         /// The movement speed modifier applied to a mob's total input velocity when weightless.
         /// </summary>
index 1f647178239880235539ef9c1a1305993c835402..c41db21b01eb94c47891d09535cf71102d546e58 100644 (file)
@@ -214,7 +214,9 @@ namespace Content.Shared.Movement.Systems
 
             if (weightless)
             {
-                if (worldTotal != Vector2.Zero && touching)
+                if (gridComp == null && !MapGridQuery.HasComp(xform.GridUid))
+                    friction = moveSpeedComponent?.OffGridFriction ?? MovementSpeedModifierComponent.DefaultOffGridFriction;
+                else if (worldTotal != Vector2.Zero && touching)
                     friction = moveSpeedComponent?.WeightlessFriction ?? MovementSpeedModifierComponent.DefaultWeightlessFriction;
                 else
                     friction = moveSpeedComponent?.WeightlessFrictionNoInput ?? MovementSpeedModifierComponent.DefaultWeightlessFrictionNoInput;