Files
tbd-station-14/Content.Shared/Movement/Systems/SharedJumpAbilitySystem.cs
Голубь 114ec579f5 JumpBoots Attempt №2 (#36862)
Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
Co-authored-by: unknown <wainzor1337@gmail.com>
Co-authored-by: ScarKy0 <scarky0@onet.eu>
2025-07-07 21:19:28 +02:00

36 lines
1.2 KiB
C#

using Content.Shared.Gravity;
using Content.Shared.Movement.Components;
using Content.Shared.Throwing;
using Robust.Shared.Audio.Systems;
namespace Content.Shared.Movement.Systems;
public sealed partial class SharedJumpAbilitySystem : EntitySystem
{
[Dependency] private readonly ThrowingSystem _throwing = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedGravitySystem _gravity = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<JumpAbilityComponent, GravityJumpEvent>(OnGravityJump);
}
private void OnGravityJump(Entity<JumpAbilityComponent> entity, ref GravityJumpEvent args)
{
if (_gravity.IsWeightless(args.Performer))
return;
var xform = Transform(args.Performer);
var throwing = xform.LocalRotation.ToWorldVec() * entity.Comp.JumpDistance;
var direction = xform.Coordinates.Offset(throwing); // to make the character jump in the direction he's looking
_throwing.TryThrow(args.Performer, direction, entity.Comp.JumpThrowSpeed);
_audio.PlayPredicted(entity.Comp.JumpSound, args.Performer, args.Performer);
args.Handled = true;
}
}