]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
[HOTFIX] Movement Rewrite Hotfix Shuttles now respect their friction values (#37154)
authorPrincess Cheeseballs <66055347+Pronana@users.noreply.github.com>
Tue, 13 May 2025 12:14:18 +0000 (05:14 -0700)
committerGitHub <noreply@github.com>
Tue, 13 May 2025 12:14:18 +0000 (22:14 +1000)
* Shuttles now use their proper friction values

* Documentation

* Shuttles now use their proper friction values

* Documentation

* What the instrumentsystem doin

* what the instrumentsystem doing 2

Content.Server/Shuttles/Components/ShuttleComponent.cs
Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs
Content.Server/Shuttles/Systems/ShuttleSystem.cs
Content.Shared/Movement/Events/TileFrictionEvent.cs

index 949d8ea5bb240a59b56d60bf43fedccca197eae4..90ecb6129b9e6dab2941b16acd936a0e50667868 100644 (file)
@@ -57,12 +57,16 @@ namespace Content.Server.Shuttles.Components
         public DirectionFlag ThrustDirections = DirectionFlag.None;
 
         /// <summary>
-        /// Damping applied to the shuttle's physics component when not in FTL.
+        /// Base damping modifier applied to the shuttle's physics component when not in FTL.
         /// </summary>
-        [DataField("linearDamping"), ViewVariables(VVAccess.ReadWrite)]
-        public float LinearDamping = 0.05f;
+        [DataField]
+        public float BodyModifier = 0.25f;
 
-        [DataField("angularDamping"), ViewVariables(VVAccess.ReadWrite)]
-        public float AngularDamping = 0.05f;
+        /// <summary>
+        /// Final Damping Modifier for a shuttle.
+        /// This value is set to 0 during FTL. And to BodyModifier when not in FTL.
+        /// </summary>
+        [DataField]
+        public float DampingModifier;
     }
 }
index 40464e516f1ef601025b59d102e6c12d27fc2ab9..fd712142af7fd34e2ccbef750e4b705a9a9352f2 100644 (file)
@@ -421,8 +421,6 @@ public sealed partial class ShuttleSystem
         Enable(uid, component: body);
         _physics.SetLinearVelocity(uid, new Vector2(0f, 20f), body: body);
         _physics.SetAngularVelocity(uid, 0f, body: body);
-        _physics.SetLinearDamping(uid, body, 0f);
-        _physics.SetAngularDamping(uid, body, 0f);
 
         _dockSystem.SetDockBolts(uid, true);
         _console.RefreshShuttleConsoles(uid);
@@ -477,8 +475,6 @@ public sealed partial class ShuttleSystem
 
         _physics.SetLinearVelocity(uid, Vector2.Zero, body: body);
         _physics.SetAngularVelocity(uid, 0f, body: body);
-        _physics.SetLinearDamping(uid, body, entity.Comp2.LinearDamping);
-        _physics.SetAngularDamping(uid, body, entity.Comp2.AngularDamping);
 
         var target = entity.Comp1.TargetCoordinates;
 
index f2c58d103c918aac51ff6ee90a9a0c6ba4053121..dadadeb21109dca11a42eeffb694df273e59fdcf 100644 (file)
@@ -4,10 +4,12 @@ using Content.Server.Doors.Systems;
 using Content.Server.Parallax;
 using Content.Server.Procedural;
 using Content.Server.Shuttles.Components;
+using Content.Server.Shuttles.Events;
 using Content.Server.Station.Systems;
 using Content.Server.Stunnable;
 using Content.Shared.GameTicking;
 using Content.Shared.Mobs.Systems;
+using Content.Shared.Movement.Events;
 using Content.Shared.Salvage;
 using Content.Shared.Shuttles.Systems;
 using Content.Shared.Throwing;
@@ -78,6 +80,9 @@ public sealed partial class ShuttleSystem : SharedShuttleSystem
 
         SubscribeLocalEvent<ShuttleComponent, ComponentStartup>(OnShuttleStartup);
         SubscribeLocalEvent<ShuttleComponent, ComponentShutdown>(OnShuttleShutdown);
+        SubscribeLocalEvent<ShuttleComponent, TileFrictionEvent>(OnTileFriction);
+        SubscribeLocalEvent<ShuttleComponent, FTLStartedEvent>(OnFTLStarted);
+        SubscribeLocalEvent<ShuttleComponent, FTLCompletedEvent>(OnFTLCompleted);
 
         SubscribeLocalEvent<GridInitializeEvent>(OnGridInit);
         SubscribeLocalEvent<FixturesComponent, GridFixtureChangeEvent>(OnGridFixtureChange);
@@ -122,6 +127,8 @@ public sealed partial class ShuttleSystem : SharedShuttleSystem
         {
             Enable(uid, component: physicsComponent, shuttle: component);
         }
+
+        component.DampingModifier = component.BodyModifier;
     }
 
     public void Toggle(EntityUid uid, ShuttleComponent component)
@@ -149,8 +156,6 @@ public sealed partial class ShuttleSystem : SharedShuttleSystem
         _physics.SetBodyType(uid, BodyType.Dynamic, manager: manager, body: component);
         _physics.SetBodyStatus(uid, component, BodyStatus.InAir);
         _physics.SetFixedRotation(uid, false, manager: manager, body: component);
-        _physics.SetLinearDamping(uid, component, shuttle.LinearDamping);
-        _physics.SetAngularDamping(uid, component, shuttle.AngularDamping);
     }
 
     public void Disable(EntityUid uid, FixturesComponent? manager = null, PhysicsComponent? component = null)
@@ -171,4 +176,19 @@ public sealed partial class ShuttleSystem : SharedShuttleSystem
 
         Disable(uid);
     }
+
+    private void OnTileFriction(Entity<ShuttleComponent> ent, ref TileFrictionEvent args)
+    {
+        args.Modifier *= ent.Comp.DampingModifier;
+    }
+
+    private void OnFTLStarted(Entity<ShuttleComponent> ent, ref FTLStartedEvent args)
+    {
+        ent.Comp.DampingModifier = 0f;
+    }
+
+    private void OnFTLCompleted(Entity<ShuttleComponent> ent, ref FTLCompletedEvent args)
+    {
+        ent.Comp.DampingModifier = ent.Comp.BodyModifier;
+    }
 }
index e355f21f45e981ee63d5d90ba64696bb7f505737..3b6894c0d922816f68927fab7b40987200de1baa 100644 (file)
@@ -10,6 +10,7 @@ public struct TileFrictionEvent
 
     public TileFrictionEvent(float modifier)
     {
+        // TODO: If something ever uses different angular and linear modifiers, split this into two modifiers
         Modifier = modifier;
     }
 }