diff --git a/Content.Client/MouseRotator/MouseRotatorSystem.cs b/Content.Client/MouseRotator/MouseRotatorSystem.cs index 18d60d9a7b9..2ee6e43368f 100644 --- a/Content.Client/MouseRotator/MouseRotatorSystem.cs +++ b/Content.Client/MouseRotator/MouseRotatorSystem.cs @@ -57,7 +57,8 @@ public sealed class MouseRotatorSystem : SharedMouseRotatorSystem rotation += 2 * Math.PI; RaisePredictiveEvent(new RequestMouseRotatorRotationEvent { - Rotation = rotation + Rotation = rotation, + User = GetNetEntity(player) }); return; @@ -77,7 +78,8 @@ public sealed class MouseRotatorSystem : SharedMouseRotatorSystem RaisePredictiveEvent(new RequestMouseRotatorRotationEvent { - Rotation = angle + Rotation = angle, + User = GetNetEntity(player) }); } } diff --git a/Content.Shared/MouseRotator/MouseRotatorComponent.cs b/Content.Shared/MouseRotator/MouseRotatorComponent.cs index 2844b3cb8b5..1f399b31f9c 100644 --- a/Content.Shared/MouseRotator/MouseRotatorComponent.cs +++ b/Content.Shared/MouseRotator/MouseRotatorComponent.cs @@ -48,4 +48,5 @@ public sealed partial class MouseRotatorComponent : Component public sealed class RequestMouseRotatorRotationEvent : EntityEventArgs { public Angle Rotation; + public NetEntity? User; } diff --git a/Content.Shared/MouseRotator/SharedMouseRotatorSystem.cs b/Content.Shared/MouseRotator/SharedMouseRotatorSystem.cs index 9663b3363d1..dadf59cea87 100644 --- a/Content.Shared/MouseRotator/SharedMouseRotatorSystem.cs +++ b/Content.Shared/MouseRotator/SharedMouseRotatorSystem.cs @@ -47,6 +47,11 @@ public abstract class SharedMouseRotatorSystem : EntitySystem private void OnRequestRotation(RequestMouseRotatorRotationEvent msg, EntitySessionEventArgs args) { + // Ignore the request if the requested entity is not the user's attached entity. + // This can happen when a player switches controlled entities while rotating. + if (args.SenderSession.AttachedEntity != GetEntity(msg.User)) + return; + if (args.SenderSession.AttachedEntity is not { } ent || !TryComp(ent, out var rotator)) {