From cf86e0de1dbdd47e9e875d7f49dfb812014e6f27 Mon Sep 17 00:00:00 2001 From: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> Date: Tue, 6 May 2025 06:49:43 -0700 Subject: [PATCH] Ghost friction fix (#37124) * commit * fix for real --- .../Components/FrictionContactsComponent.cs | 15 +++++++++------ .../Movement/Systems/FrictionContactsSystem.cs | 9 +++++++++ .../Movement/Systems/SharedMoverController.cs | 3 ++- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Content.Shared/Movement/Components/FrictionContactsComponent.cs b/Content.Shared/Movement/Components/FrictionContactsComponent.cs index 204e35a348..b6e1d533a2 100644 --- a/Content.Shared/Movement/Components/FrictionContactsComponent.cs +++ b/Content.Shared/Movement/Components/FrictionContactsComponent.cs @@ -8,24 +8,27 @@ namespace Content.Shared.Movement.Components; [Access(typeof(FrictionContactsSystem))] public sealed partial class FrictionContactsComponent : Component { + /// + /// Should this affect airborne mobs? + /// + [DataField, AutoNetworkedField] + public bool AffectAirborne; + /// /// Modified mob friction while on FrictionContactsComponent /// - [DataField, ViewVariables(VVAccess.ReadWrite)] - [AutoNetworkedField] + [DataField, AutoNetworkedField] public float MobFriction = 0.05f; /// /// Modified mob friction without input while on FrictionContactsComponent /// - [AutoNetworkedField] - [DataField, ViewVariables(VVAccess.ReadWrite)] + [DataField, AutoNetworkedField] public float? MobFrictionNoInput = 0.05f; /// /// Modified mob acceleration while on FrictionContactsComponent /// - [AutoNetworkedField] - [DataField, ViewVariables(VVAccess.ReadWrite)] + [DataField, AutoNetworkedField] public float MobAcceleration = 0.1f; } diff --git a/Content.Shared/Movement/Systems/FrictionContactsSystem.cs b/Content.Shared/Movement/Systems/FrictionContactsSystem.cs index 4dd679c37c..09d74bfb40 100644 --- a/Content.Shared/Movement/Systems/FrictionContactsSystem.cs +++ b/Content.Shared/Movement/Systems/FrictionContactsSystem.cs @@ -1,3 +1,4 @@ +using Content.Shared.Gravity; using Content.Shared.Movement.Components; using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Events; @@ -7,6 +8,7 @@ namespace Content.Shared.Movement.Systems; public sealed class FrictionContactsSystem : EntitySystem { + [Dependency] private readonly SharedGravitySystem _gravity = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly MovementSpeedModifierSystem _speedModifierSystem = default!; @@ -82,12 +84,19 @@ public sealed class FrictionContactsSystem : EntitySystem var frictionNoInput = 0.0f; var acceleration = 0.0f; + var isAirborne = physicsComponent.BodyStatus == BodyStatus.InAir || _gravity.IsWeightless(entity, physicsComponent); + var remove = true; var entries = 0; foreach (var ent in _physics.GetContactingEntities(entity, physicsComponent)) { if (!TryComp(ent, out var contacts)) continue; + + // Entities that are airborne should not be affected by contact slowdowns that are specified to not affect airborne entities. + if (isAirborne && !contacts.AffectAirborne) + continue; + friction += contacts.MobFriction; frictionNoInput += contacts.MobFrictionNoInput ?? contacts.MobFriction; acceleration += contacts.MobAcceleration; diff --git a/Content.Shared/Movement/Systems/SharedMoverController.cs b/Content.Shared/Movement/Systems/SharedMoverController.cs index d8aacb7480..d800234a6d 100644 --- a/Content.Shared/Movement/Systems/SharedMoverController.cs +++ b/Content.Shared/Movement/Systems/SharedMoverController.cs @@ -260,7 +260,8 @@ public abstract partial class SharedMoverController : VirtualController else { if (MapGridQuery.TryComp(xform.GridUid, out var gridComp) - && _mapSystem.TryGetTileRef(xform.GridUid.Value, gridComp, xform.Coordinates, out var tile)) + && _mapSystem.TryGetTileRef(xform.GridUid.Value, gridComp, xform.Coordinates, out var tile) + && physicsComponent.BodyStatus == BodyStatus.OnGround) tileDef = (ContentTileDefinition) _tileDefinitionManager[tile.Tile.TypeId]; var walkSpeed = moveSpeedComponent?.CurrentWalkSpeed ?? MovementSpeedModifierComponent.DefaultBaseWalkSpeed; -- 2.51.2