Mouse rotator system (#19267)

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
Kara
2023-09-22 22:45:13 -07:00
committed by GitHub
parent 69bcd69715
commit b8b4e918e2
10 changed files with 217 additions and 11 deletions

View File

@@ -54,6 +54,7 @@ namespace Content.Shared.Movement.Systems
protected EntityQuery<SharedPullableComponent> PullableQuery;
protected EntityQuery<TransformComponent> XformQuery;
protected EntityQuery<CanMoveInAirComponent> CanMoveInAirQuery;
protected EntityQuery<NoRotateOnMoveComponent> NoRotateQuery;
private const float StepSoundMoveDistanceRunning = 2;
private const float StepSoundMoveDistanceWalking = 1.5f;
@@ -84,6 +85,7 @@ namespace Content.Shared.Movement.Systems
RelayQuery = GetEntityQuery<RelayInputMoverComponent>();
PullableQuery = GetEntityQuery<SharedPullableComponent>();
XformQuery = GetEntityQuery<TransformComponent>();
NoRotateQuery = GetEntityQuery<NoRotateOnMoveComponent>();
CanMoveInAirQuery = GetEntityQuery<CanMoveInAirComponent>();
InitializeFootsteps();
@@ -246,10 +248,13 @@ namespace Content.Shared.Movement.Systems
if (worldTotal != Vector2.Zero)
{
var worldRot = _transform.GetWorldRotation(xform);
_transform.SetLocalRotation(xform, xform.LocalRotation + worldTotal.ToWorldAngle() - worldRot);
// TODO apparently this results in a duplicate move event because "This should have its event run during
// island solver"??. So maybe SetRotation needs an argument to avoid raising an event?
if (!NoRotateQuery.HasComponent(uid))
{
// TODO apparently this results in a duplicate move event because "This should have its event run during
// island solver"??. So maybe SetRotation needs an argument to avoid raising an event?
var worldRot = _transform.GetWorldRotation(xform);
_transform.SetLocalRotation(xform, xform.LocalRotation + worldTotal.ToWorldAngle() - worldRot);
}
if (!weightless && MobMoverQuery.TryGetComponent(uid, out var mobMover) &&
TryGetSound(weightless, uid, mover, mobMover, xform, out var sound, tileDef: tileDef))