1 using Microsoft.Xna.Framework;
8 public const int DefaultPort = 27015;
9 public const int DefaultQueryPort = 27016;
11 public static int MaxPlayers = 256;
13 public static int ServerNameMaxLength = 60;
14 public static int ServerMessageMaxLength = 2000;
16 public const float MaxPhysicsBodyVelocity = 64.0f;
17 public const float MaxPhysicsBodyAngularVelocity = 16.0f;
19 public static float MaxHealthUpdateInterval = 2.0f;
20 public static float MaxHealthUpdateIntervalDead = 10.0f;
22 public static float HighPrioCharacterPositionUpdateDistance = 1000.0f;
23 public static float LowPrioCharacterPositionUpdateDistance = 10000.0f;
24 public static float HighPrioCharacterPositionUpdateInterval = 0.0f;
25 public static float LowPrioCharacterPositionUpdateInterval = 1.0f;
29 public static float FreezeCharacterIfPositionDataMissingDelay = 2.0f;
30 public static float DisableCharacterIfPositionDataMissingDelay = 3.5f;
32 public static float DeleteDisconnectedTime = 20.0f;
34 public static float ItemConditionUpdateInterval = 0.15f;
35 public static float LevelObjectUpdateInterval = 0.5f;
36 public static float HullUpdateInterval = 0.5f;
37 public static float SparseHullUpdateInterval = 5.0f;
38 public static float HullUpdateDistance = 20000.0f;
40 public static int MaxEventPacketsPerUpdate = 4;
45 public static float RoundStartSyncDuration = 60.0f;
50 public static float EventRemovalTime = 15.0f;
55 public static float OldReceivedEventKickTime = 10.0f;
60 public static float OldEventKickTime = 30.0f;
65 public static Vector2 InterpolateSimPositionError(Vector2 simPositionError,
float? smoothingFactor =
null)
67 float lengthSqr = simPositionError.LengthSquared();
69 if (lengthSqr > 100.0f) {
return Vector2.Zero; }
70 float positionSmoothingFactor = smoothingFactor ?? MathHelper.Lerp(0.95f, 0.8f, MathHelper.Clamp(lengthSqr, 0.0f, 1.0f));
71 return simPositionError *= positionSmoothingFactor;
77 public static float InterpolateRotationError(
float rotationError)
80 if (rotationError > MathHelper.TwoPi) {
return 0.0f; }
81 float rotationSmoothingFactor = MathHelper.Lerp(0.95f, 0.8f, Math.Min(Math.Abs(rotationError), 1.0f));
82 return rotationError *= rotationSmoothingFactor;
88 public static Vector2 InterpolateCursorPositionError(Vector2 cursorPositionError)
90 float lengthSqr = cursorPositionError.LengthSquared();
92 if (lengthSqr > 1000.0f) {
return Vector2.Zero; }
93 return cursorPositionError *= 0.7f;
96 public static Vector2 Quantize(Vector2 value,
float min,
float max,
int numberOfBits)
99 Quantize(value.X, min, max, numberOfBits),
100 Quantize(value.Y, min, max, numberOfBits));
103 public static float Quantize(
float value,
float min,
float max,
int numberOfBits)
105 float step = (max - min) / (1 << (numberOfBits + 1));
106 if (Math.Abs(value) < step + 0.00001f)
111 return MathUtils.RoundTowardsClosest(MathHelper.Clamp(value, min, max), step);