Optimise mob moverment a little bit (#12136)

This commit is contained in:
metalgearsloth
2022-10-23 08:50:25 +11:00
committed by GitHub
parent 016900b18a
commit 15029b8410
2 changed files with 18 additions and 4 deletions

View File

@@ -2,7 +2,6 @@ using Content.Shared.CCVar;
using Content.Shared.Input;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Events;
using Robust.Shared.Configuration;
using Robust.Shared.GameStates;
using Robust.Shared.Input;
using Robust.Shared.Input.Binding;
@@ -52,6 +51,7 @@ namespace Content.Shared.Movement.Systems
SubscribeLocalEvent<InputMoverComponent, EntParentChangedMessage>(OnInputParentChange);
_configManager.OnValueChanged(CCVars.CameraRotationLocked, SetCameraRotationLocked, true);
_configManager.OnValueChanged(CCVars.GameDiagonalMovement, SetDiagonalMovement, true);
}
private void SetCameraRotationLocked(bool obj)
@@ -97,9 +97,12 @@ namespace Content.Shared.Movement.Systems
{
CommandBinds.Unregister<SharedMoverController>();
_configManager.UnsubValueChanged(CCVars.CameraRotationLocked, SetCameraRotationLocked);
_configManager.UnsubValueChanged(CCVars.GameDiagonalMovement, SetDiagonalMovement);
}
public bool DiagonalMovementEnabled => _configManager.GetCVar(CCVars.GameDiagonalMovement);
public bool DiagonalMovementEnabled { get; private set; }
private void SetDiagonalMovement(bool value) => DiagonalMovementEnabled = value;
protected virtual void HandleShuttleInput(EntityUid uid, ShuttleButtons button, ushort subTick, bool state) {}
@@ -121,6 +124,16 @@ namespace Content.Shared.Movement.Systems
Dirty(mover);
}
public Angle GetParentGridAngle(InputMoverComponent mover, EntityQuery<TransformComponent> xformQuery)
{
var rotation = mover.RelativeRotation;
if (xformQuery.TryGetComponent(mover.RelativeEntity, out var relativeXform))
return (_transform.GetWorldRotation(relativeXform, xformQuery) + rotation);
return rotation;
}
public Angle GetParentGridAngle(InputMoverComponent mover)
{
var rotation = mover.RelativeRotation;