* Use new Subs.CVar helper Removes manual config OnValueChanged calls, removes need to remember to manually unsubscribe. This both reduces boilerplate and fixes many issues where subscriptions weren't removed on entity system shutdown. * Fix a bunch of warnings * More warning fixes * Use new DateTime serializer to get rid of ISerializationHooks in changelog code. * Get rid of some more ISerializationHooks for enums * And a little more * Apply suggestions from code review Co-authored-by: 0x6273 <0x40@keemail.me> --------- Co-authored-by: 0x6273 <0x40@keemail.me>
59 lines
1.8 KiB
C#
59 lines
1.8 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;
|
|
|
|
if (!TryComp<JointComponent>(handUid, out var jointComp) ||
|
|
!jointComp.GetJoints.TryGetValue(GrapplingJoint, out var joint) ||
|
|
joint is not DistanceJoint distance)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (distance.MaxLength <= distance.MinLength)
|
|
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));
|
|
}
|
|
}
|