Fix MouseRotator on rotated grids (#29663)
* fix harm mode rotation * cleanup * -pi to pi
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Input;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.Replays.Loading;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
@@ -46,13 +45,19 @@ public sealed class MouseRotatorSystem : SharedMouseRotatorSystem
|
||||
// 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;
|
||||
|
||||
Reference in New Issue
Block a user