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:
51
Content.Shared/Movement/Components/InputMoverComponent.cs
Normal file
51
Content.Shared/Movement/Components/InputMoverComponent.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Shared.Movement.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[NetworkedComponent]
|
||||
public sealed class InputMoverComponent : Component
|
||||
{
|
||||
// This class has to be able to handle server TPS being lower than client FPS.
|
||||
// While still having perfectly responsive movement client side.
|
||||
// We do this by keeping track of the exact sub-tick values that inputs are pressed on the client,
|
||||
// and then building a total movement vector based on those sub-tick steps.
|
||||
//
|
||||
// We keep track of the last sub-tick a movement input came in,
|
||||
// Then when a new input comes in, we calculate the fraction of the tick the LAST input was active for
|
||||
// (new sub-tick - last sub-tick)
|
||||
// and then add to the total-this-tick movement vector
|
||||
// by multiplying that fraction by the movement direction for the last input.
|
||||
// This allows us to incrementally build the movement vector for the current tick,
|
||||
// without having to keep track of some kind of list of inputs and calculating it later.
|
||||
//
|
||||
// We have to keep track of a separate movement vector for walking and sprinting,
|
||||
// since we don't actually know our current movement speed while processing inputs.
|
||||
// We change which vector we write into based on whether we were sprinting after the previous input.
|
||||
// (well maybe we do but the code is designed such that MoverSystem applies movement speed)
|
||||
// (and I'm not changing that)
|
||||
|
||||
/// <summary>
|
||||
/// Should our velocity be applied to our parent?
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("toParent")]
|
||||
public bool ToParent = false;
|
||||
|
||||
public GameTick LastInputTick;
|
||||
public ushort LastInputSubTick;
|
||||
|
||||
public Vector2 CurTickWalkMovement;
|
||||
public Vector2 CurTickSprintMovement;
|
||||
|
||||
public MoveButtons HeldMoveButtons = MoveButtons.None;
|
||||
|
||||
[ViewVariables]
|
||||
public Angle LastGridAngle { get; set; } = new(0);
|
||||
|
||||
public bool Sprinting => (HeldMoveButtons & MoveButtons.Walk) == 0x0;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool CanMove { get; set; } = true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user