Mouse rotator system (#19267)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Interaction.Components;
|
||||
|
||||
/// <summary>
|
||||
/// This is used for entities which should not rotate on interactions (for instance those who use <see cref="MouseRotator"/> instead)
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed partial class NoRotateOnInteractComponent : Component
|
||||
{
|
||||
}
|
||||
@@ -44,7 +44,7 @@ namespace Content.Shared.Interaction
|
||||
if (Math.Abs(rotationDiff) > maxRotate)
|
||||
{
|
||||
var goalTheta = worldRot + Math.Sign(rotationDiff) * maxRotate;
|
||||
_transform.SetWorldRotation(xform, goalTheta);
|
||||
TryFaceAngle(uid, goalTheta, xform);
|
||||
rotationDiff = (goalRotation - goalTheta);
|
||||
|
||||
if (Math.Abs(rotationDiff) > tolerance)
|
||||
@@ -55,11 +55,11 @@ namespace Content.Shared.Interaction
|
||||
return true;
|
||||
}
|
||||
|
||||
_transform.SetWorldRotation(xform, goalRotation);
|
||||
TryFaceAngle(uid, goalRotation, xform);
|
||||
}
|
||||
else
|
||||
{
|
||||
_transform.SetWorldRotation(xform, goalRotation);
|
||||
TryFaceAngle(uid, goalRotation, xform);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -85,7 +85,7 @@ namespace Content.Shared.Interaction
|
||||
if (!Resolve(user, ref xform))
|
||||
return false;
|
||||
|
||||
xform.WorldRotation = diffAngle;
|
||||
_transform.SetWorldRotation(xform, diffAngle);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace Content.Shared.Interaction
|
||||
// (Since the user being buckled to it holds it down with their weight.)
|
||||
// This is logically equivalent to RotateWhileAnchored.
|
||||
// Barstools and office chairs have independent wheels, while regular chairs don't.
|
||||
Transform(rotatable.Owner).WorldRotation = diffAngle;
|
||||
_transform.SetWorldRotation(Transform(suid.Value), diffAngle);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -433,7 +433,8 @@ namespace Content.Shared.Interaction
|
||||
if (coordinates.GetMapId(EntityManager) != Transform(user).MapID)
|
||||
return false;
|
||||
|
||||
_rotateToFaceSystem.TryFaceCoordinates(user, coordinates.ToMapPos(EntityManager));
|
||||
if (!HasComp<NoRotateOnInteractComponent>(user))
|
||||
_rotateToFaceSystem.TryFaceCoordinates(user, coordinates.ToMapPos(EntityManager));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user