From 2566c95551ac2e69f053ba9e123d913f977546fe Mon Sep 17 00:00:00 2001 From: slarticodefast <161409025+slarticodefast@users.noreply.github.com> Date: Mon, 23 Sep 2024 02:10:36 +0200 Subject: [PATCH] add cvar and reduce pushback --- .../Fluids/Components/SprayComponent.cs | 10 +--------- .../Fluids/EntitySystems/SpraySystem.cs | 16 +++++++++++++++- Content.Shared/CCVar/CCVars.cs | 12 ++++++++++++ .../Entities/Objects/Misc/fire_extinguisher.yml | 1 - 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/Content.Server/Fluids/Components/SprayComponent.cs b/Content.Server/Fluids/Components/SprayComponent.cs index 9cba7236b9cd6e..128fdecfa7f50d 100644 --- a/Content.Server/Fluids/Components/SprayComponent.cs +++ b/Content.Server/Fluids/Components/SprayComponent.cs @@ -33,15 +33,7 @@ public sealed partial class SprayComponent : Component /// How much the player is pushed back for each spray. /// [DataField] - public float PushbackAmount = 2f; - - /// - /// How much the grid the player is standing on is pushed back for each spray when gravity or magboots are on. - /// We need to make this separate because the mass of a grid is completely unrealistic at the moment. - /// The Dev map weights only 700kg for example. - /// - [DataField] - public float GridPushbackAmount = 1; + public float PushbackAmount = 5f; [DataField(required: true)] [Access(typeof(SpraySystem), Other = AccessPermissions.ReadExecute)] // FIXME Friends diff --git a/Content.Server/Fluids/EntitySystems/SpraySystem.cs b/Content.Server/Fluids/EntitySystems/SpraySystem.cs index a29acd81d3416e..e3541b624127af 100644 --- a/Content.Server/Fluids/EntitySystems/SpraySystem.cs +++ b/Content.Server/Fluids/EntitySystems/SpraySystem.cs @@ -3,6 +3,7 @@ using Content.Server.Fluids.Components; using Content.Server.Gravity; using Content.Server.Popups; +using Content.Shared.CCVar; using Content.Shared.Chemistry.EntitySystems; using Content.Shared.FixedPoint; using Content.Shared.Fluids; @@ -11,6 +12,7 @@ using Content.Shared.Vapor; using Robust.Server.GameObjects; using Robust.Shared.Audio.Systems; +using Robust.Shared.Configuration; using Robust.Shared.Physics.Components; using Robust.Shared.Prototypes; using System.Numerics; @@ -29,12 +31,21 @@ public sealed class SpraySystem : EntitySystem [Dependency] private readonly VaporSystem _vapor = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; + [Dependency] private readonly IConfigurationManager _cfg = default!; + + private float _gridImpulseMultiplier; public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnAfterInteract); + Subs.CVar(_cfg, CCVars.GridImpulseMultiplier, UpdateGridMassMultiplier, true); + } + + private void UpdateGridMassMultiplier(float value) + { + _gridImpulseMultiplier = value; } private void OnAfterInteract(Entity entity, ref AfterInteractEvent args) @@ -147,8 +158,11 @@ private void OnAfterInteract(Entity entity, ref AfterInteractEve // push back the grid the player is standing on var userTransform = Transform(args.User); if (userTransform.GridUid != null) + { // apply both linear and angular momentum depending on the player position - _physics.ApplyLinearImpulse(userTransform.GridUid.Value, -impulseDirection * entity.Comp.GridPushbackAmount, userTransform.LocalPosition); + // multiply by a cvar because grid mass is currently extremely small compared to all other masses + _physics.ApplyLinearImpulse(userTransform.GridUid.Value, -impulseDirection * _gridImpulseMultiplier * entity.Comp.PushbackAmount, userTransform.LocalPosition); + } } } } diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index 95fb7bd692c597..1638dc848b9fdf 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -1491,6 +1491,18 @@ public static readonly CVarDef public static readonly CVarDef HideSplitGridsUnder = CVarDef.Create("shuttle.hide_split_grids_under", 30, CVar.SERVERONLY); + /// + /// Impulse multiplier for player interactions that move grids (other than shuttle thrusters, gyroscopes and grid collisons). + /// At the moment this only affects the pushback in SpraySystem. + /// A higher value means grids have a lower effective mass and therefore will get pushed stronger. + /// A value of 0 will disable pushback. + /// The default has been chosen such that a one tile grid roughly equals 2/3 Urist masses. + /// TODO: Make grid mass a sane number so we can get rid of this. + /// At the moment they have a very low mass of roughly 0.48 kg per tile independent of any walls or anchored objects on them. + /// + public static readonly CVarDef GridImpulseMultiplier = + CVarDef.Create("shuttle.grid_impulse_multiplier", 0.01f, CVar.SERVERONLY); + /// /// Whether to automatically spawn escape shuttles. /// diff --git a/Resources/Prototypes/Entities/Objects/Misc/fire_extinguisher.yml b/Resources/Prototypes/Entities/Objects/Misc/fire_extinguisher.yml index 9d041e03fcc366..0389db27ea0365 100644 --- a/Resources/Prototypes/Entities/Objects/Misc/fire_extinguisher.yml +++ b/Resources/Prototypes/Entities/Objects/Misc/fire_extinguisher.yml @@ -30,7 +30,6 @@ - type: Spray transferAmount: 10 pushbackAmount: 60 - gridPushbackAmount: 2 spraySound: path: /Audio/Effects/extinguish.ogg sprayedPrototype: ExtinguisherSpray