2 using Microsoft.Xna.Framework;
4 using System.Collections.Generic;
112 readonly record
struct EntityPositionHeader(
114 UInt32 PrefabUintIdentifier,
115 UInt16 EntityId) : INetSerializableStruct
117 public static EntityPositionHeader FromEntity(
Entity entity)
119 IsItem: entity is
Item,
121 EntityId: entity.ID);
132 PurchaseAndSwitchSub,
139 public enum ReadyCheckState
146 enum DisconnectReason
156 AuthenticationRequired,
157 AuthenticationFailed,
168 ExcessiveDesyncOldEvent,
169 ExcessiveDesyncRemovedEvent,
174 abstract partial class NetworkMember
176 public UInt16 LastClientListUpdateID
182 public abstract bool IsServer {
get; }
184 public abstract bool IsClient {
get; }
188 public abstract Voting Voting {
get; }
190 protected DateTime updateTimer;
192 public bool ShowNetStats;
194 public float SimulatedRandomLatency, SimulatedMinimumLatency;
195 public float SimulatedLoss;
196 public float SimulatedDuplicatesChance;
198 public KarmaManager KarmaManager
202 } =
new KarmaManager();
204 public bool GameStarted {
get;
protected set; }
206 public abstract IReadOnlyList<Client> ConnectedClients {
get; }
212 public TimeSpan UpdateInterval =>
new TimeSpan(0, 0, 0, 0, MathHelper.Clamp(1000 /
ServerSettings.
TickRate, 1, 500));
216 AddChatMessage(
ChatMessage.
Create(senderName, message, type, senderEntity, senderClient, changeType: changeType, textColor: textColor));
219 public abstract void AddChatMessage(
ChatMessage message);
221 public static string ClientLogName(
Client client,
string name =
null)
223 if (client ==
null) {
return name; }
225 if (client.
Karma < 40.0f)
227 retVal +=
"color:#ff9900;";
229 retVal +=
"metadata:" + (client.
AccountId.TryUnwrap(out var accountId) ? accountId.ToString() : client.
SessionId.ToString())
230 +
"‖" + (name ?? client.
Name).Replace(
"‖",
"") +
"‖end‖";
234 public abstract void KickPlayer(
string kickedName,
string reason);
236 public abstract void BanPlayer(
string kickedName,
string reason, TimeSpan? duration =
null);
238 public abstract void UnbanPlayer(
string playerName);
240 public abstract void UnbanPlayer(
Endpoint endpoint);
245 public static bool IsCompatible(Version myVersion, Version remoteVersion)
250 myVersion.Major == remoteVersion.Major &&
251 myVersion.Minor == remoteVersion.Minor &&
252 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
@ REQUEST_STARTGAMEFINALIZE
@ RESET_REWARD_DISTRIBUTION