Make humans move based on their last grid's angle (#5122)

* Make humans move based on their last grid's angle

* Fix ghost movement, fix weightless grid parenting

* Make sure to init the last grid angle without needing to move
This commit is contained in:
Saphire Lattice
2021-11-02 20:35:02 +07:00
committed by GitHub
parent 5810fdb7ee
commit f5b4e461b3
5 changed files with 28 additions and 11 deletions

View File

@@ -22,6 +22,8 @@ namespace Content.Shared.Movement.Components
/// </summary>
bool Sprinting { get; }
Angle LastGridAngle { get; set; }
/// <summary>
/// Calculated linear velocity direction of the entity.
/// </summary>

View File

@@ -12,6 +12,8 @@ namespace Content.Shared.Movement.Components
public float CurrentWalkSpeed => 0f;
public float CurrentSprintSpeed => 0f;
public Angle LastGridAngle { get => Angle.Zero; set {} }
public bool Sprinting => false;
public (Vector2 walking, Vector2 sprinting) VelocityDir => (Vector2.Zero, Vector2.Zero);

View File

@@ -50,6 +50,8 @@ namespace Content.Shared.Movement.Components
private MoveButtons _heldMoveButtons = MoveButtons.None;
public Angle LastGridAngle { get; set; } = new(0);
public float CurrentWalkSpeed => _movementSpeed?.CurrentWalkSpeed ?? MovementSpeedModifierComponent.DefaultBaseWalkSpeed;
public float CurrentSprintSpeed => _movementSpeed?.CurrentSprintSpeed ?? MovementSpeedModifierComponent.DefaultBaseSprintSpeed;
@@ -117,6 +119,7 @@ namespace Content.Shared.Movement.Components
{
base.Initialize();
Owner.EnsureComponentWarn<PhysicsComponent>();
LastGridAngle = Owner.Transform.Parent?.WorldRotation ?? new Angle(0);
}
/// <summary>