RUDPFramework/Assets/Scripts/Network/NetworkHost/ServerAuthoritativeMovement...

41 lines
1.4 KiB
C#

using System;
namespace Network.NetworkHost
{
public sealed class ServerAuthoritativeMovementConfiguration
{
public float MoveSpeed { get; set; } = 5f;
public float TurnSpeedDegreesPerSecond { get; set; } = 180f;
public TimeSpan SimulationInterval { get; set; } = TimeSpan.FromMilliseconds(50);
public TimeSpan BroadcastInterval { get; set; } = TimeSpan.FromMilliseconds(50);
public int DefaultHp { get; set; } = 100;
internal void Validate()
{
if (float.IsNaN(MoveSpeed) || float.IsInfinity(MoveSpeed) || MoveSpeed < 0f)
{
throw new ArgumentOutOfRangeException(nameof(MoveSpeed), "Move speed must be finite and non-negative.");
}
if (float.IsNaN(TurnSpeedDegreesPerSecond) || float.IsInfinity(TurnSpeedDegreesPerSecond) || TurnSpeedDegreesPerSecond < 0f)
{
throw new ArgumentOutOfRangeException(nameof(TurnSpeedDegreesPerSecond), "Turn speed must be finite and non-negative.");
}
if (SimulationInterval <= TimeSpan.Zero)
{
throw new ArgumentOutOfRangeException(nameof(SimulationInterval), "Simulation interval must be positive.");
}
if (BroadcastInterval <= TimeSpan.Zero)
{
throw new ArgumentOutOfRangeException(nameof(BroadcastInterval), "Broadcast interval must be positive.");
}
}
}
}