Fix mouse rotator error spam (#39071)

Ignore mouse rotation requests when the player is switching controlled entity
This commit is contained in:
Tayrtahn
2025-07-19 19:16:40 -04:00
committed by GitHub
parent 50302a531b
commit cfb0a95035
3 changed files with 10 additions and 2 deletions

View File

@@ -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)
});
}
}

View File

@@ -48,4 +48,5 @@ public sealed partial class MouseRotatorComponent : Component
public sealed class RequestMouseRotatorRotationEvent : EntityEventArgs
{
public Angle Rotation;
public NetEntity? User;
}

View File

@@ -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<MouseRotatorComponent>(ent, out var rotator))
{