The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Additional documentation and release notes are available at [Multiplayer Documentation](https://docs-multiplayer.unity3d.com). ## [1.5.2] - 2023-07-24 ### Added ### Fixed - Fixed issue where `NetworkClient.OwnedObjects` was not returning any owned objects due to the `NetworkClient.IsConnected` not being properly set. (#2631) - Fixed a crash when calling TrySetParent with a null Transform (#2625) - Fixed issue where a `NetworkTransform` using full precision state updates was losing transform state updates when interpolation was enabled. (#2624) - Fixed issue where `NetworkObject.SpawnWithObservers` was not being honored for late joining clients. (#2623) - Fixed issue where invoking `NetworkManager.Shutdown` multiple times, depending upon the timing, could cause an exception. (#2622) - Fixed issue where removing ownership would not notify the server that it gained ownership. This also resolves the issue where an owner authoritative NetworkTransform would not properly initialize upon removing ownership from a remote client. (#2618) - Fixed ILPP issues when using CoreCLR and for certain dedicated server builds. (#2614) - Fixed an ILPP compile error when creating a generic NetworkBehaviour singleton with a static T instance. (#2603) ### Changed
77 lines
2.2 KiB
C#
77 lines
2.2 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace Unity.Netcode
|
|
{
|
|
/// <summary>
|
|
/// A NetworkClient
|
|
/// </summary>
|
|
public class NetworkClient
|
|
{
|
|
/// <summary>
|
|
/// Returns true if the session instance is considered a server
|
|
/// </summary>
|
|
internal bool IsServer { get; set; }
|
|
|
|
/// <summary>
|
|
/// Returns true if the session instance is considered a client
|
|
/// </summary>
|
|
internal bool IsClient { get; set; }
|
|
|
|
/// <summary>
|
|
/// Returns true if the session instance is considered a host
|
|
/// </summary>
|
|
internal bool IsHost => IsClient && IsServer;
|
|
|
|
/// <summary>
|
|
/// When true, the client is connected, approved, and synchronized with
|
|
/// the server.
|
|
/// </summary>
|
|
internal bool IsConnected { get; set; }
|
|
|
|
/// <summary>
|
|
/// Is true when the client has been approved.
|
|
/// </summary>
|
|
internal bool IsApproved { get; set; }
|
|
|
|
/// <summary>
|
|
/// The ClientId of the NetworkClient
|
|
/// </summary>
|
|
public ulong ClientId;
|
|
|
|
/// <summary>
|
|
/// The PlayerObject of the Client
|
|
/// </summary>
|
|
public NetworkObject PlayerObject;
|
|
|
|
/// <summary>
|
|
/// The list of NetworkObject's owned by this client instance
|
|
/// </summary>
|
|
public List<NetworkObject> OwnedObjects => IsConnected ? SpawnManager.GetClientOwnedObjects(ClientId) : new List<NetworkObject>();
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|