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:
@@ -1,9 +1,26 @@
|
||||
using Content.Client.Buckle.Strap;
|
||||
using Content.Shared.Buckle;
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Client.Buckle
|
||||
{
|
||||
internal sealed class BuckleSystem : SharedBuckleSystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<StrapComponent, ComponentHandleState>(OnStrapHandleState);
|
||||
}
|
||||
|
||||
private void OnStrapHandleState(EntityUid uid, StrapComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not StrapComponentState state) return;
|
||||
component.Position = state.Position;
|
||||
component.BuckleOffsetUnclamped = state.BuckleOffsetClamped;
|
||||
component.BuckledEntities.Clear();
|
||||
component.BuckledEntities.UnionWith(state.BuckledEntities);
|
||||
component.MaxBuckleDistance = state.MaxBuckleDistance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Content.Shared.DragDrop;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.Buckle.Strap
|
||||
{
|
||||
|
||||
@@ -172,6 +172,15 @@ namespace Content.Client.EscapeMenu.UI.Tabs
|
||||
AddButton(ContentKeyFunctions.Loadout8);
|
||||
AddButton(ContentKeyFunctions.Loadout9);
|
||||
|
||||
AddHeader("ui-options-header-shuttle");
|
||||
AddButton(ContentKeyFunctions.ShuttleStrafeUp);
|
||||
AddButton(ContentKeyFunctions.ShuttleStrafeRight);
|
||||
AddButton(ContentKeyFunctions.ShuttleStrafeLeft);
|
||||
AddButton(ContentKeyFunctions.ShuttleStrafeDown);
|
||||
AddButton(ContentKeyFunctions.ShuttleRotateLeft);
|
||||
AddButton(ContentKeyFunctions.ShuttleRotateRight);
|
||||
AddButton(ContentKeyFunctions.ShuttleBrake);
|
||||
|
||||
AddHeader("ui-options-header-map-editor");
|
||||
AddButton(EngineKeyFunctions.EditorPlaceObject);
|
||||
AddButton(EngineKeyFunctions.EditorCancelPlace);
|
||||
|
||||
@@ -94,7 +94,7 @@ public sealed class EyeLerpingSystem : EntitySystem
|
||||
return;
|
||||
|
||||
// We can't lerp if the mob can't move!
|
||||
if (!TryComp(mob, out IMoverComponent? mover))
|
||||
if (!TryComp(mob, out InputMoverComponent? mover))
|
||||
return;
|
||||
|
||||
LerpEye(_eyeManager.CurrentEye, frameTime, mover.LastGridAngle, _playerActiveEye);
|
||||
|
||||
@@ -33,6 +33,11 @@ namespace Content.Client.Input
|
||||
common.AddFunction(ContentKeyFunctions.EditorCopyObject);
|
||||
|
||||
var human = contexts.GetContext("human");
|
||||
human.AddFunction(EngineKeyFunctions.MoveUp);
|
||||
human.AddFunction(EngineKeyFunctions.MoveDown);
|
||||
human.AddFunction(EngineKeyFunctions.MoveLeft);
|
||||
human.AddFunction(EngineKeyFunctions.MoveRight);
|
||||
human.AddFunction(EngineKeyFunctions.Walk);
|
||||
human.AddFunction(ContentKeyFunctions.SwapHands);
|
||||
human.AddFunction(ContentKeyFunctions.Drop);
|
||||
human.AddFunction(ContentKeyFunctions.UseItemInHand);
|
||||
@@ -89,7 +94,7 @@ namespace Content.Client.Input
|
||||
aghost.AddFunction(ContentKeyFunctions.Drop);
|
||||
aghost.AddFunction(ContentKeyFunctions.ThrowItemInHand);
|
||||
|
||||
var ghost = contexts.New("ghost", "common");
|
||||
var ghost = contexts.New("ghost", "human");
|
||||
ghost.AddFunction(EngineKeyFunctions.MoveUp);
|
||||
ghost.AddFunction(EngineKeyFunctions.MoveDown);
|
||||
ghost.AddFunction(EngineKeyFunctions.MoveLeft);
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Shared.Movement;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Movement.Systems;
|
||||
using Content.Shared.Pulling.Components;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Timing;
|
||||
@@ -20,10 +17,32 @@ namespace Content.Client.Physics.Controllers
|
||||
{
|
||||
base.UpdateBeforeSolve(prediction, frameTime);
|
||||
|
||||
if (_playerManager.LocalPlayer?.ControlledEntity is not {Valid: true} player ||
|
||||
!TryComp(player, out IMoverComponent? mover) ||
|
||||
!TryComp(player, out PhysicsComponent? body) ||
|
||||
!TryComp(player, out TransformComponent? xform))
|
||||
if (_playerManager.LocalPlayer?.ControlledEntity is not {Valid: true} player)
|
||||
return;
|
||||
|
||||
if (TryComp<RelayInputMoverComponent>(player, out var relayMover))
|
||||
{
|
||||
if (relayMover.RelayEntity != null)
|
||||
HandleClientsideMovement(relayMover.RelayEntity.Value, frameTime);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
HandleClientsideMovement(player, frameTime);
|
||||
}
|
||||
|
||||
private void HandleClientsideMovement(EntityUid player, float frameTime)
|
||||
{
|
||||
if (!TryComp(player, out InputMoverComponent? mover) ||
|
||||
!TryComp(player, out TransformComponent? xform)) return;
|
||||
|
||||
PhysicsComponent? body = null;
|
||||
|
||||
if (mover.ToParent && HasComp<RelayInputMoverComponent>(xform.ParentUid))
|
||||
{
|
||||
if (!TryComp(xform.ParentUid, out body)) return;
|
||||
}
|
||||
else if (!TryComp(player, out body))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -65,13 +84,7 @@ namespace Content.Client.Physics.Controllers
|
||||
}
|
||||
|
||||
// Server-side should just be handled on its own so we'll just do this shizznit
|
||||
if (TryComp(player, out IMobMoverComponent? mobMover))
|
||||
{
|
||||
HandleMobMovement(mover, body, mobMover, xform, frameTime);
|
||||
return;
|
||||
}
|
||||
|
||||
HandleKinematicMovement(mover, body);
|
||||
HandleMobMovement(mover, body, xform, frameTime);
|
||||
}
|
||||
|
||||
protected override Filter GetSoundPlayers(EntityUid mover)
|
||||
|
||||
@@ -18,7 +18,6 @@ public sealed class ShuttleConsoleBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
base.Open();
|
||||
_window = new ShuttleConsoleWindow();
|
||||
_window.ShuttleModePressed += OnShuttleModePressed;
|
||||
_window.UndockPressed += OnUndockPressed;
|
||||
_window.StartAutodockPressed += OnAutodockPressed;
|
||||
_window.StopAutodockPressed += OnStopAutodockPressed;
|
||||
@@ -65,11 +64,6 @@ public sealed class ShuttleConsoleBoundUserInterface : BoundUserInterface
|
||||
SendMessage(new UndockRequestMessage() {DockEntity = obj});
|
||||
}
|
||||
|
||||
private void OnShuttleModePressed(ShuttleMode obj)
|
||||
{
|
||||
SendMessage(new ShuttleModeRequestMessage() {Mode = obj});
|
||||
}
|
||||
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
{
|
||||
base.UpdateState(state);
|
||||
|
||||
@@ -1,16 +1,43 @@
|
||||
using Content.Shared.Input;
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using Content.Shared.Shuttles.Events;
|
||||
using Content.Shared.Shuttles.Systems;
|
||||
using Robust.Client.Input;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Client.Shuttles.Systems
|
||||
{
|
||||
public sealed class ShuttleConsoleSystem : SharedShuttleConsoleSystem
|
||||
{
|
||||
[Dependency] private readonly IInputManager _input = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<PilotComponent, ComponentHandleState>(OnHandleState);
|
||||
var shuttle = _input.Contexts.New("shuttle", "common");
|
||||
shuttle.AddFunction(ContentKeyFunctions.ShuttleStrafeUp);
|
||||
shuttle.AddFunction(ContentKeyFunctions.ShuttleStrafeDown);
|
||||
shuttle.AddFunction(ContentKeyFunctions.ShuttleStrafeLeft);
|
||||
shuttle.AddFunction(ContentKeyFunctions.ShuttleStrafeRight);
|
||||
shuttle.AddFunction(ContentKeyFunctions.ShuttleRotateLeft);
|
||||
shuttle.AddFunction(ContentKeyFunctions.ShuttleRotateRight);
|
||||
shuttle.AddFunction(ContentKeyFunctions.ShuttleBrake);
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
_input.Contexts.Remove("shuttle");
|
||||
}
|
||||
|
||||
protected override void HandlePilotShutdown(EntityUid uid, PilotComponent component, ComponentShutdown args)
|
||||
{
|
||||
base.HandlePilotShutdown(uid, component, args);
|
||||
if (_playerManager.LocalPlayer?.ControlledEntity != uid) return;
|
||||
|
||||
_input.Contexts.SetActiveContext("human");
|
||||
}
|
||||
|
||||
private void OnHandleState(EntityUid uid, PilotComponent component, ref ComponentHandleState args)
|
||||
@@ -21,6 +48,7 @@ namespace Content.Client.Shuttles.Systems
|
||||
if (!console.IsValid())
|
||||
{
|
||||
component.Console = null;
|
||||
_input.Contexts.SetActiveContext("human");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -32,6 +60,7 @@ namespace Content.Client.Shuttles.Systems
|
||||
|
||||
component.Console = shuttleConsoleComponent;
|
||||
ActionBlockerSystem.UpdateCanMove(uid);
|
||||
_input.Contexts.SetActiveContext("shuttle");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,10 +83,6 @@
|
||||
Align="Right"/>
|
||||
</GridContainer>
|
||||
</BoxContainer>
|
||||
<Button Name="ShuttleModeDisplay"
|
||||
Text="{Loc 'shuttle-console-strafing'}"
|
||||
TextAlign="Center"
|
||||
ToggleMode="True"/>
|
||||
<Button Name="IFFToggle"
|
||||
Text="{Loc 'shuttle-console-iff-toggle'}"
|
||||
TextAlign="Center"
|
||||
|
||||
@@ -40,7 +40,6 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow,
|
||||
/// </summary>
|
||||
public TimeSpan FTLTime;
|
||||
|
||||
public Action<ShuttleMode>? ShuttleModePressed;
|
||||
public Action<EntityUid>? UndockPressed;
|
||||
public Action<EntityUid>? StartAutodockPressed;
|
||||
public Action<EntityUid>? StopAutodockPressed;
|
||||
@@ -61,8 +60,6 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow,
|
||||
DockToggle.OnToggled += OnDockTogglePressed;
|
||||
DockToggle.Pressed = RadarScreen.ShowDocks;
|
||||
|
||||
ShuttleModeDisplay.OnToggled += OnShuttleModePressed;
|
||||
|
||||
UndockButton.OnPressed += OnUndockPressed;
|
||||
}
|
||||
|
||||
@@ -71,11 +68,6 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow,
|
||||
RadarRange.Text = $"{value:0}";
|
||||
}
|
||||
|
||||
private void OnShuttleModePressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
ShuttleModePressed?.Invoke(obj.Button.Pressed ? ShuttleMode.Strafing : ShuttleMode.Cruise);
|
||||
}
|
||||
|
||||
private void OnIFFTogglePressed(BaseButton.ButtonEventArgs args)
|
||||
{
|
||||
RadarScreen.ShowIFF ^= true;
|
||||
@@ -106,7 +98,6 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow,
|
||||
UpdateFTL(scc.Destinations, scc.FTLState, scc.FTLTime);
|
||||
RadarScreen.UpdateState(scc);
|
||||
MaxRadarRange.Text = $"{scc.MaxRange:0}";
|
||||
ShuttleModeDisplay.Pressed = scc.Mode == ShuttleMode.Strafing;
|
||||
}
|
||||
|
||||
private void UpdateFTL(List<(EntityUid Entity, string Destination, bool Enabled)> destinations, FTLState state, TimeSpan time)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,12 +14,13 @@ namespace Content.Client.Vehicle
|
||||
if (args.Sprite == null)
|
||||
return;
|
||||
|
||||
/// First check is for the sprite itself
|
||||
// First check is for the sprite itself
|
||||
if (args.Component.TryGetData(VehicleVisuals.DrawDepth, out int drawDepth))
|
||||
{
|
||||
args.Sprite.DrawDepth = drawDepth;
|
||||
}
|
||||
/// Set vehicle layer to animated or not (i.e. are the wheels turning or not)
|
||||
|
||||
// Set vehicle layer to animated or not (i.e. are the wheels turning or not)
|
||||
if (args.Component.TryGetData(VehicleVisuals.AutoAnimate, out bool autoAnimate))
|
||||
{
|
||||
args.Sprite.LayerSetAutoAnimated(VehicleVisualLayers.AutoAnimate, autoAnimate);
|
||||
|
||||
Reference in New Issue
Block a user