Mouse rotator system (#19267)

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
Kara
2023-09-22 22:45:13 -07:00
committed by GitHub
parent 69bcd69715
commit b8b4e918e2
10 changed files with 217 additions and 11 deletions

View File

@@ -0,0 +1,43 @@
using System.Numerics;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
namespace Content.Shared.MouseRotator;
/// <summary>
/// This component allows overriding an entities local rotation based on the client's mouse movement
/// </summary>
/// <see cref="SharedMouseRotatorSystem"/>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class MouseRotatorComponent : Component
{
/// <summary>
/// How much the desired angle needs to change before a predictive event is sent
/// </summary>
[DataField]
[ViewVariables(VVAccess.ReadWrite)]
public Angle AngleTolerance = Angle.FromDegrees(5.0);
/// <summary>
/// The angle that will be lerped to
/// </summary>
[AutoNetworkedField, DataField]
public Angle? GoalRotation;
/// <summary>
/// Max degrees the entity can rotate per second
/// </summary>
[DataField]
[ViewVariables(VVAccess.ReadWrite)]
public double RotationSpeed = float.MaxValue;
}
/// <summary>
/// Raised on an entity with <see cref="MouseRotatorComponent"/> as a predictive event on the client
/// when mouse rotation changes
/// </summary>
[Serializable, NetSerializable]
public sealed class RequestMouseRotatorRotationEvent : EntityEventArgs
{
public Angle Rotation;
}