Files
space-station-14/Content.Client/Weapons/Misc/GrapplingGunSystem.cs
deathride58 5d2988d5ff Grappling rework - Grappling hooks are now physics-driven (#42409)
* Grappling rework - Grappling hooks are now physics-based

* still have no idea wtf is going on with portals but fixed a few bugs + cleanup

* bonus fixes + prep for optional-but-recommended engine PR

* dropkicking a stray comment outta here

* makes the impulses actually take into account the fucking relays, makes reeling cancel if the rope's already too short, and tweaks values

* reviews + cleanup + makes ungrapple behavior a bit more consistent
joint removal was removed from ungrapple because it mispredicts either way, and breaks grappling hooks attached to the grappling gun (always good to leave possibilities like that open)

* adds a hack to work around grids not caring about waking cross-grid joints

* makes use of dirtyfield(), defenestrates magic number

* y'know it'd probably be better if we were like actually awake before we made commits

* null-coalesce instead of if statement

* two changes

* dont datafield and fix up for sound overrides

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
2026-01-22 22:15:01 +00:00

49 lines
1.5 KiB
C#

using System.Net;
using Content.Client.Hands.Systems;
using Content.Shared.CombatMode;
using Content.Shared.Weapons.Misc;
using Content.Shared.Weapons.Ranged.Components;
using Robust.Client.GameObjects;
using Robust.Client.Player;
using Robust.Shared.Input;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Dynamics.Joints;
namespace Content.Client.Weapons.Misc;
public sealed class GrapplingGunSystem : SharedGrapplingGunSystem
{
[Dependency] private readonly HandsSystem _hands = default!;
[Dependency] private readonly InputSystem _input = default!;
[Dependency] private readonly IPlayerManager _player = default!;
public override void Update(float frameTime)
{
base.Update(frameTime);
// Oh boy another input handler.
// If someone thinks of a better way to unify this please tell me.
if (!Timing.IsFirstTimePredicted)
return;
var local = _player.LocalEntity;
var handUid = _hands.GetActiveHandEntity();
if (!TryComp<GrapplingGunComponent>(handUid, out var grappling))
return;
var reelKey = _input.CmdStates.GetState(EngineKeyFunctions.UseSecondary) == BoundKeyState.Down;
if (!TryComp<CombatModeComponent>(local, out var combatMode) ||
!combatMode.IsInCombatMode)
{
reelKey = false;
}
if (grappling.Reeling == reelKey)
return;
RaisePredictiveEvent(new RequestGrapplingReelMessage(reelKey));
}
}