Files
wwdpublic/Content.Shared/Physics/FrictionRemoverSystem.cs
Mnemotechnican e092203d11 Frictionfull Space (#514)
# Description
Makes it so that the station and the ATS get a very tiny bit of friction
to prevent cargo tech pros from sending either of those out of this
galaxy cluster (which has actually happened multiple times on two
servers and required either admin intervention or early round ending).

# Technical details
Added a PassiveDampeningComponent which defines how much friction an
entity receives while in 0g. FrictionRemoverSystem was updated to try to
fetch this component from an entity before updating its dampening. A new
system was added to automatically add this component (if it's not
already defined) to all station grids.

# Media
See the #when-you-code-it channel for a preview. It's kinda hard to
demonstrate, but after a few minutes, stations and the ATS come to an
almost complete stop.

# Changelog
🆑
- tweak: Space stations now have a tiny bit of velocity dampening to
prevent them from being flunged into the void.
2024-07-05 12:53:25 -04:00

35 lines
981 B
C#

using Robust.Shared.Map.Components;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
namespace Content.Shared.Physics;
public sealed class FrictionRemoverSystem : EntitySystem
{
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<PhysicsComponent, PhysicsSleepEvent>(RemoveDampening);
}
private void RemoveDampening(EntityUid uid, PhysicsComponent component, PhysicsSleepEvent args)
{
var linear = 0f;
var angular = 0f;
if (TryComp<PassiveDampeningComponent>(uid, out var dampening) && dampening.Enabled)
{
linear = dampening.LinearDampening;
angular = dampening.AngularDampening;
}
_physics.SetAngularDamping(uid, component, angular, false);
_physics.SetLinearDamping(uid, component, linear);
}
}