diff --git a/Content.Client/MouseRotator/MouseRotatorSystem.cs b/Content.Client/MouseRotator/MouseRotatorSystem.cs index 4894c17c4c0..363c8248c96 100644 --- a/Content.Client/MouseRotator/MouseRotatorSystem.cs +++ b/Content.Client/MouseRotator/MouseRotatorSystem.cs @@ -45,13 +45,19 @@ public override void Update(float frameTime) // only raise event if the cardinal direction has changed if (rotator.Simple4DirMode) { - var angleDir = angle.GetCardinalDir(); - if (angleDir == curRot.GetCardinalDir()) + var eyeRot = _eye.CurrentEye.Rotation; // camera rotation + var angleDir = (angle + eyeRot).GetCardinalDir(); // apply GetCardinalDir in the camera frame, not in the world frame + if (angleDir == (curRot + eyeRot).GetCardinalDir()) return; - RaisePredictiveEvent(new RequestMouseRotatorRotationSimpleEvent() + var rotation = angleDir.ToAngle() - eyeRot; // convert back to world frame + if (rotation >= Math.PI) // convert to [-PI, +PI) + rotation -= 2 * Math.PI; + else if (rotation < -Math.PI) + rotation += 2 * Math.PI; + RaisePredictiveEvent(new RequestMouseRotatorRotationEvent { - Direction = angleDir, + Rotation = rotation }); return; diff --git a/Content.Shared/MouseRotator/MouseRotatorComponent.cs b/Content.Shared/MouseRotator/MouseRotatorComponent.cs index a35dfe0a288..2844b3cb8b5 100644 --- a/Content.Shared/MouseRotator/MouseRotatorComponent.cs +++ b/Content.Shared/MouseRotator/MouseRotatorComponent.cs @@ -30,8 +30,7 @@ public sealed partial class MouseRotatorComponent : Component public double RotationSpeed = float.MaxValue; /// - /// This one is important. If this is true, does not apply, and the system will - /// use instead. In this mode, the client will only send + /// This one is important. If this is true, does not apply. In this mode, the client will only send /// events when an entity should snap to a different cardinal direction, rather than for every angle change. /// /// This is useful for cases like humans, where what really matters is the visual sprite direction, as opposed to something @@ -50,13 +49,3 @@ public sealed class RequestMouseRotatorRotationEvent : EntityEventArgs { public Angle Rotation; } - -/// -/// Simpler version of for implementations -/// that only require snapping to 4-dir and not full angle rotation. -/// -[Serializable, NetSerializable] -public sealed class RequestMouseRotatorRotationSimpleEvent : EntityEventArgs -{ - public Direction Direction; -} diff --git a/Content.Shared/MouseRotator/SharedMouseRotatorSystem.cs b/Content.Shared/MouseRotator/SharedMouseRotatorSystem.cs index c57d477bd2f..9663b3363d1 100644 --- a/Content.Shared/MouseRotator/SharedMouseRotatorSystem.cs +++ b/Content.Shared/MouseRotator/SharedMouseRotatorSystem.cs @@ -1,5 +1,4 @@ using Content.Shared.Interaction; -using Robust.Shared.Timing; namespace Content.Shared.MouseRotator; @@ -16,7 +15,6 @@ public override void Initialize() base.Initialize(); SubscribeAllEvent(OnRequestRotation); - SubscribeAllEvent(OnRequestSimpleRotation); } public override void Update(float frameTime) @@ -50,7 +48,7 @@ public override void Update(float frameTime) private void OnRequestRotation(RequestMouseRotatorRotationEvent msg, EntitySessionEventArgs args) { if (args.SenderSession.AttachedEntity is not { } ent - || !TryComp(ent, out var rotator) || rotator.Simple4DirMode) + || !TryComp(ent, out var rotator)) { Log.Error($"User {args.SenderSession.Name} ({args.SenderSession.UserId}) tried setting local rotation directly without a valid mouse rotator component attached!"); return; @@ -59,17 +57,4 @@ private void OnRequestRotation(RequestMouseRotatorRotationEvent msg, EntitySessi rotator.GoalRotation = msg.Rotation; Dirty(ent, rotator); } - - private void OnRequestSimpleRotation(RequestMouseRotatorRotationSimpleEvent ev, EntitySessionEventArgs args) - { - if (args.SenderSession.AttachedEntity is not { } ent - || !TryComp(ent, out var rotator) || !rotator.Simple4DirMode) - { - Log.Error($"User {args.SenderSession.Name} ({args.SenderSession.UserId}) tried setting 4-dir rotation directly without a valid mouse rotator component attached!"); - return; - } - - rotator.GoalRotation = ev.Direction.ToAngle(); - Dirty(ent, rotator); - } }