Files
wwdpublic/Content.Server/_NF/Shuttles/Systems/ShuttleSystem.cs
neuPanda c2e063c3de Porting over My Cruise Control Code From Frontier (#1482)
porting over my cruise control code from frontier with some minor bug
fixes. also had to fuck with the passive dampening system because the
notsorobust toolbox has hurt its self in confusion

Description.

redid the port from frontier removing unnecessary complicated and
confusing content.
replaced hard coded values with cvars
patched issues with the passive dampener system causing dampener states
to reset
added regions to cvar file to make it easier to look threw
reverted text so that its more ship based, your not driving a car
this is my original work so re-licensed my work under my name rather
than frontier blanket who is licensed to use edit agpl3

🆑
- tweak: tweaked friction remover system
- fix: fixed inertia dampening system resetting or effecting the wrong
grid
- remove: Removed overcomplicated alterations

Co-authored-by: neuPanda <spainman0@yahoo.com>
(cherry picked from commit e389dffcdd74812cfc1c372aff8cbccd74dd24ee)
2025-01-14 02:12:04 +03:00

69 lines
3.1 KiB
C#

// NeuPanda - This file is licensed under AGPLv3
// Copyright (c) 2025 NeuPanda
// See AGPLv3.txt for details.
using Content.Server.Shuttles.Components;
using Content.Shared._NF.Shuttles.Events;
using Content.Shared.CCVar;
using Robust.Shared.Physics.Components;
namespace Content.Server.Shuttles.Systems;
public sealed partial class ShuttleSystem
{
private float _spaceFrictionStrength;
private float _anchorDampeningStrength;
private void NfInitialize()
{
SubscribeLocalEvent<ShuttleConsoleComponent, SetInertiaDampeningRequest>(OnSetInertiaDampening);
_spaceFrictionStrength = _cfg.GetCVar(CCVars.SpaceFrictionStrength);
_anchorDampeningStrength = _cfg.GetCVar(CCVars.AnchorDampeningStrength);
}
private void OnSetInertiaDampening(EntityUid uid, ShuttleConsoleComponent component, SetInertiaDampeningRequest args)
{
if (!EntityManager.TryGetComponent(GetEntity(args.ShuttleEntityUid), out TransformComponent? transform) ||
!transform.GridUid.HasValue ||
!EntityManager.TryGetComponent(transform.GridUid, out PhysicsComponent? physicsComponent) ||
!EntityManager.TryGetComponent(transform.GridUid, out ShuttleComponent? shuttleComponent))
{
return;
}
_console.RefreshShuttleConsoles(transform.GridUid.Value);
var linearDampeningStrength = args.Mode switch
{
InertiaDampeningMode.Off => _spaceFrictionStrength,
InertiaDampeningMode.Dampened => shuttleComponent.LinearDamping, // should i use Dampener Strength instead?
InertiaDampeningMode.Anchored => _anchorDampeningStrength,
_ => shuttleComponent.LinearDamping, // if some how we end up here... just keep calm and carry on with your bad self
};
var angularDampeningStrength = args.Mode switch
{
InertiaDampeningMode.Off => _spaceFrictionStrength,
InertiaDampeningMode.Dampened => shuttleComponent.AngularDamping,
InertiaDampeningMode.Anchored => _anchorDampeningStrength,
_ => shuttleComponent.AngularDamping, // if some how we end up here... just keep calm and carry on with your bad self
};
_physics.SetLinearDamping(transform.GridUid.Value, physicsComponent, linearDampeningStrength);
_physics.SetAngularDamping(transform.GridUid.Value, physicsComponent, angularDampeningStrength);
_console.RefreshShuttleConsoles(transform.GridUid.Value);
}
public InertiaDampeningMode NfGetInertiaDampeningMode(EntityUid entity)
{
if (!EntityManager.TryGetComponent<TransformComponent>(entity, out var xform) ||
!EntityManager.TryGetComponent(xform.GridUid, out PhysicsComponent? physicsComponent))
return InertiaDampeningMode.Dampened;
if (physicsComponent.LinearDamping == _anchorDampeningStrength)
return InertiaDampeningMode.Anchored;
else if (physicsComponent.LinearDamping == _spaceFrictionStrength)
return InertiaDampeningMode.Off;
else
return InertiaDampeningMode.Dampened;
}
}