using System.Collections.Generic; namespace Unity.Netcode { /// /// A NetworkClient /// public class NetworkClient { /// /// Returns true if the session instance is considered a server /// internal bool IsServer { get; set; } /// /// Returns true if the session instance is considered a client /// internal bool IsClient { get; set; } /// /// Returns true if the session instance is considered a host /// internal bool IsHost => IsClient && IsServer; /// /// When true, the client is connected, approved, and synchronized with /// the server. /// internal bool IsConnected { get; set; } /// /// Is true when the client has been approved. /// internal bool IsApproved { get; set; } /// /// The ClientId of the NetworkClient /// public ulong ClientId; /// /// The PlayerObject of the Client /// public NetworkObject PlayerObject; /// /// The list of NetworkObject's owned by this client instance /// public List OwnedObjects => IsConnected ? SpawnManager.GetClientOwnedObjects(ClientId) : new List(); internal NetworkSpawnManager SpawnManager { get; private set; } internal void SetRole(bool isServer, bool isClient, NetworkManager networkManager = null) { IsServer = isServer; IsClient = isClient; if (!IsServer && !isClient) { PlayerObject = null; ClientId = 0; IsConnected = false; IsApproved = false; } if (networkManager != null) { SpawnManager = networkManager.SpawnManager; } } internal void AssignPlayerObject(ref NetworkObject networkObject) { PlayerObject = networkObject; } } }