2 using Microsoft.Xna.Framework;
4 using System.Collections.Generic;
119 readonly record
struct EntityPositionHeader(
121 UInt32 PrefabUintIdentifier,
122 UInt16 EntityId) : INetSerializableStruct
124 public static EntityPositionHeader FromEntity(
Entity entity)
126 IsItem: entity is
Item,
128 EntityId: entity.ID);
139 PurchaseAndSwitchSub,
146 public enum ReadyCheckState
153 enum DisconnectReason
163 AuthenticationRequired,
164 AuthenticationFailed,
175 ExcessiveDesyncOldEvent,
176 ExcessiveDesyncRemovedEvent,
181 abstract partial class NetworkMember
183 public UInt16 LastClientListUpdateID
189 public abstract bool IsServer {
get; }
191 public abstract bool IsClient {
get; }
195 public abstract Voting Voting {
get; }
197 protected DateTime updateTimer;
199 public bool ShowNetStats;
201 public float SimulatedRandomLatency, SimulatedMinimumLatency;
202 public float SimulatedLoss;
203 public float SimulatedDuplicatesChance;
205 public KarmaManager KarmaManager
209 } =
new KarmaManager();
211 public bool GameStarted {
get;
protected set; }
213 public abstract IReadOnlyList<Client> ConnectedClients {
get; }
219 public TimeSpan UpdateInterval =>
new TimeSpan(0, 0, 0, 0, MathHelper.Clamp(1000 /
ServerSettings.
TickRate, 1, 500));
223 AddChatMessage(
ChatMessage.
Create(senderName, message, type, senderEntity, senderClient, changeType: changeType, textColor: textColor));
226 public abstract void AddChatMessage(
ChatMessage message);
228 public static string ClientLogName(
Client client,
string name =
null)
230 if (client ==
null) {
return name; }
232 if (client.
Karma < 40.0f)
234 retVal +=
"color:#ff9900;";
236 retVal +=
"metadata:" + (client.
AccountId.TryUnwrap(out var accountId) ? accountId.ToString() : client.
SessionId.ToString())
237 +
"‖" + (name ?? client.
Name).Replace(
"‖",
"") +
"‖end‖";
241 public abstract void KickPlayer(
string kickedName,
string reason);
243 public abstract void BanPlayer(
string kickedName,
string reason, TimeSpan? duration =
null);
245 public abstract void UnbanPlayer(
string playerName);
247 public abstract void UnbanPlayer(
Endpoint endpoint);
252 public static bool IsCompatible(Version myVersion, Version remoteVersion)
257 myVersion.Major == remoteVersion.Major &&
258 myVersion.Minor == remoteVersion.Minor &&
259 myVersion.Build == remoteVersion.Build;
readonly MapEntityPrefab Prefab
Marks fields and properties as to be serialized and deserialized by INetSerializableStruct....
static ChatMessage Create(string senderName, string text, ChatMessageType type, Entity sender, Client client=null, PlayerConnectionChangeType changeType=PlayerConnectionChangeType.None, Color? textColor=null)
Option< AccountId > AccountId
The ID of the account used to authenticate this session. This value can be used as a persistent value...
readonly byte SessionId
An ID for this client for the current session. THIS IS NOT A PERSISTENT VALUE. DO NOT STORE THIS LONG...
PlayerConnectionChangeType
@ RESPONSE_CANCEL_STARTGAME
@ REQUEST_STARTGAMEFINALIZE
@ RESET_REWARD_DISTRIBUTION