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;
using Content.Shared.Interaction;
using Content.Shared.Timing;
using Content.Shared.Vapor;
-using Content.Shared.Chemistry.EntitySystems;
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;
[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()
{
SubscribeLocalEvent<SprayComponent, AfterInteractEvent>(OnAfterInteract);
SubscribeLocalEvent<SprayComponent, UserActivateInWorldEvent>(OnActivateInWorld);
+ Subs.CVar(_cfg, CCVars.GridImpulseMultiplier, UpdateGridMassMultiplier, true);
}
private void OnActivateInWorld(Entity<SprayComponent> entity, ref UserActivateInWorldEvent args)
Spray(entity, args.User, targetMapPos);
}
+ private void UpdateGridMassMultiplier(float value)
+ {
+ _gridImpulseMultiplier = value;
+ }
+
private void OnAfterInteract(Entity<SprayComponent> entity, ref AfterInteractEvent args)
{
if (args.Handled)
if (TryComp<PhysicsComponent>(user, out var body))
{
if (_gravity.IsWeightless(user, body))
- _physics.ApplyLinearImpulse(user, -impulseDirection.Normalized() * entity.Comp.PushbackAmount, body: body);
+ {
+ // push back the player
+ _physics.ApplyLinearImpulse(user, -impulseDirection * entity.Comp.PushbackAmount, body: body);
+ }
+ else
+ {
+ // push back the grid the player is standing on
+ var userTransform = Transform(user);
+ if (userTransform.GridUid == userTransform.ParentUid)
+ {
+ // apply both linear and angular momentum depending on the player position
+ // 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);
+ }
+ }
}
}
/// </summary>
public static readonly CVarDef<int> EmergencyShuttleAutoCallExtensionTime =
CVarDef.Create("shuttle.auto_call_extension_time", 45, CVar.SERVERONLY);
+
+ /// <summary>
+ /// 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.
+ /// </summary>
+ public static readonly CVarDef<float> GridImpulseMultiplier =
+ CVarDef.Create("shuttle.grid_impulse_multiplier", 0.01f, CVar.SERVERONLY);
}