Skip to content

Commit

Permalink
Fixed cart pulling speed
Browse files Browse the repository at this point in the history
  • Loading branch information
DexlerXD committed Nov 2, 2023
1 parent bbd5449 commit ba2149a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Content.Shared/SS220/Cart/CartSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Shared.DoAfter;
using Content.Shared.DragDrop;
using Content.Shared.Foldable;
using Content.Shared.Friction;
using Content.Shared.Physics.Pull;
using Content.Shared.Pulling;
using Content.Shared.Pulling.Components;
Expand All @@ -15,6 +16,7 @@ public sealed class CartSystem : EntitySystem
{
[Dependency] private readonly SharedPullingSystem _pulling = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
[Dependency] private readonly TileFrictionController _tileFriction = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -105,6 +107,10 @@ private void OnAttachDoAfter(EntityUid uid, CartComponent component, CartAttachD
if (!_pulling.TryStartPull(args.AttachTarget, uid))
return;

// This is the simpliest way to change pulling speed I could've imagined.
var frictionModifierComp = EnsureComp<TileFrictionModifierComponent>(uid);
_tileFriction.SetModifier(uid, component.FrictionModifier, frictionModifierComp);

var ev = new CartAttachEvent(args.AttachTarget, uid);
RaiseLocalEvent(args.AttachTarget, ref ev);

Expand All @@ -124,6 +130,7 @@ private void OnDeattachDoAfter(EntityUid uid, CartComponent component, CartDeatt

_pulling.TryStopPull(pullable);
RemComp<SharedPullerComponent>(args.DeattachTarget);
RemComp<TileFrictionModifierComponent>(uid);

var ev = new CartDeattachEvent(args.DeattachTarget, uid);
RaiseLocalEvent(args.DeattachTarget, ref ev);
Expand Down
9 changes: 9 additions & 0 deletions Content.Shared/SS220/Cart/Components/CartComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,13 @@ public sealed partial class CartComponent : Component
[ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public float AttachRange = SharedInteractionSystem.InteractionRange / 1.4f; // Also stolen from BuckleComponent

/// <summary>
/// Friction modifier applied to the cart after attaching. It's used for increasing pulling speed, so they are not pointless...
/// TODO: write a normal way to modify pulling speed or wait for the space wizards to do it themselves.
/// </summary>
[DataField("frictionModifier")]
[ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public float FrictionModifier = .15f;
}

0 comments on commit ba2149a

Please sign in to comment.