Cache CanMove (#7480)
This commit is contained in:
@@ -1,14 +1,10 @@
|
||||
using System;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.CCVar;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Shared.Movement.Components
|
||||
{
|
||||
@@ -63,6 +59,9 @@ namespace Content.Shared.Movement.Components
|
||||
|
||||
public bool Sprinting => !HasFlag(_heldMoveButtons, MoveButtons.Walk);
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool CanMove { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Calculated linear velocity direction of the entity.
|
||||
/// </summary>
|
||||
@@ -124,7 +123,7 @@ namespace Content.Shared.Movement.Components
|
||||
{
|
||||
base.Initialize();
|
||||
Owner.EnsureComponentWarn<PhysicsComponent>();
|
||||
LastGridAngle = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Parent?.WorldRotation ?? new Angle(0);
|
||||
LastGridAngle = _entityManager.GetComponent<TransformComponent>(Owner).Parent?.WorldRotation ?? new Angle(0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -200,12 +199,13 @@ namespace Content.Shared.Movement.Components
|
||||
_heldMoveButtons = state.Buttons;
|
||||
_lastInputTick = GameTick.Zero;
|
||||
_lastInputSubTick = 0;
|
||||
CanMove = state.CanMove;
|
||||
}
|
||||
}
|
||||
|
||||
public override ComponentState GetComponentState()
|
||||
{
|
||||
return new MoverComponentState(_heldMoveButtons);
|
||||
return new MoverComponentState(_heldMoveButtons, CanMove);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -244,10 +244,12 @@ namespace Content.Shared.Movement.Components
|
||||
private sealed class MoverComponentState : ComponentState
|
||||
{
|
||||
public MoveButtons Buttons { get; }
|
||||
public readonly bool CanMove;
|
||||
|
||||
public MoverComponentState(MoveButtons buttons)
|
||||
public MoverComponentState(MoveButtons buttons, bool canMove)
|
||||
{
|
||||
Buttons = buttons;
|
||||
CanMove = canMove;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user