using System.Numerics;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
namespace Content.Shared.MouseRotator;
///
/// This component allows overriding an entities local rotation based on the client's mouse movement
///
///
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class MouseRotatorComponent : Component
{
///
/// How much the desired angle needs to change before a predictive event is sent
///
[DataField, AutoNetworkedField]
public Angle AngleTolerance = Angle.FromDegrees(20.0);
///
/// The angle that will be lerped to
///
[DataField, AutoNetworkedField]
public Angle? GoalRotation;
///
/// Max degrees the entity can rotate per second
///
[DataField, AutoNetworkedField]
public double RotationSpeed = float.MaxValue;
///
/// This one is important. If this is true, does not apply, and the system will
/// use instead. In this mode, the client will only send
/// events when an entity should snap to a different cardinal direction, rather than for every angle change.
///
/// This is useful for cases like humans, where what really matters is the visual sprite direction, as opposed to something
/// like turrets or ship guns, which have finer range of movement.
///
[DataField, AutoNetworkedField]
public bool Simple4DirMode = true;
}
///
/// Raised on an entity with as a predictive event on the client
/// when mouse rotation changes
///
[Serializable, NetSerializable]
public sealed class RequestMouseRotatorRotationEvent : EntityEventArgs
{
public Angle Rotation;
}
///
/// Simpler version of for implementations
/// that only require snapping to 4-dir and not full angle rotation.
///
[Serializable, NetSerializable]
public sealed class RequestMouseRotatorRotationSimpleEvent : EntityEventArgs
{
public Direction Direction;
}