The real movement refactor (#9645)

* The real movement refactor

* ref events

* Jetpack cleanup

* a

* Vehicles partially working

* Balance tweaks

* Restore some shitcode

* AAAAAAAA

* Even more prediction

* ECS compstate trying to fix this

* yml

* vehicles kill me

* Don't lock keys

* a

* Fix problem

* Fix sounds

* shuttle inputs

* Shuttle controls

* space brakes

* Keybinds

* Fix merge

* Handle shutdown

* Fix keys

* Bump friction

* fix buckle offset

* Fix relay and friction

* Fix jetpack turning

* contexts amirite
This commit is contained in:
metalgearsloth
2022-07-16 13:51:52 +10:00
committed by GitHub
parent e0b7b48cae
commit b9e876ca92
109 changed files with 1752 additions and 1584 deletions

View File

@@ -1,34 +1,62 @@
using Content.Client.Buckle.Strap;
using Content.Shared.Vehicle;
using Robust.Client.Graphics;
using Content.Shared.Vehicle.Components;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.GameStates;
namespace Content.Client.Vehicle
{
public sealed class VehicleSystem : EntitySystem
public sealed class VehicleSystem : SharedVehicleSystem
{
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
public override void Initialize()
{
base.Initialize();
SubscribeNetworkEvent<BuckledToVehicleEvent>(OnBuckle);
SubscribeLocalEvent<RiderComponent, ComponentShutdown>(OnRiderShutdown);
SubscribeLocalEvent<RiderComponent, ComponentHandleState>(OnRiderHandleState);
SubscribeLocalEvent<RiderComponent, PlayerAttachedEvent>(OnRiderAttached);
SubscribeLocalEvent<RiderComponent, PlayerDetachedEvent>(OnRiderDetached);
}
private void OnBuckle(BuckledToVehicleEvent args)
private void OnRiderShutdown(EntityUid uid, RiderComponent component, ComponentShutdown args)
{
// Use the vehicle's eye if we get buckled
if (args.Buckling)
{
if (!TryComp<EyeComponent>(args.Vehicle, out var vehicleEye) || vehicleEye.Eye == null)
return;
_eyeManager.CurrentEye = vehicleEye.Eye;
return;
}
// Reset if we get unbuckled.
if (!TryComp<EyeComponent>(args.Rider, out var component) || component.Eye == null)
return; // This probably will never happen but in this strange new world we probably want to maintain our old vision
_eyeManager.CurrentEye = component.Eye;
component.Vehicle = null;
UpdateEye(component);
}
private void OnRiderAttached(EntityUid uid, RiderComponent component, PlayerAttachedEvent args)
{
UpdateEye(component);
}
private void OnRiderDetached(EntityUid uid, RiderComponent component, PlayerDetachedEvent args)
{
UpdateEye(component);
}
private void UpdateEye(RiderComponent component)
{
if (!TryComp(component.Vehicle, out EyeComponent? eyeComponent))
{
TryComp(_playerManager.LocalPlayer?.ControlledEntity, out eyeComponent);
}
if (eyeComponent?.Eye == null) return;
_eyeManager.CurrentEye = eyeComponent.Eye;
}
private void OnRiderHandleState(EntityUid uid, RiderComponent component, ref ComponentHandleState args)
{
// Server should only be sending states for our entity.
if (args.Current is not RiderComponentState state) return;
component.Vehicle = state.Entity;
UpdateEye(component);
}
}
}