mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-17 18:40:33 +00:00
breaking: NetworkIdentity.isOwned renamed to isClientOwned to properly indicate that it's a client-side flag
This commit is contained in:
parent
13e07f5603
commit
36d955b146
@ -33,7 +33,7 @@ public class NetworkLerpRigidbody : NetworkBehaviour
|
||||
/// </summary>
|
||||
bool IgnoreSync => isServer || ClientWithAuthority;
|
||||
|
||||
bool ClientWithAuthority => clientAuthority && isOwned;
|
||||
bool ClientWithAuthority => clientAuthority && isClientOwned;
|
||||
|
||||
protected override void OnValidate()
|
||||
{
|
||||
|
@ -72,7 +72,7 @@ protected override void OnValidate()
|
||||
/// <returns></returns>
|
||||
bool IgnoreSync => isServer || ClientWithAuthority;
|
||||
|
||||
bool ClientWithAuthority => clientAuthority && isOwned;
|
||||
bool ClientWithAuthority => clientAuthority && isClientOwned;
|
||||
|
||||
void OnVelocityChanged(Vector3 _, Vector3 newValue)
|
||||
{
|
||||
@ -180,7 +180,7 @@ void SyncToClients()
|
||||
[Client]
|
||||
void SendToServer()
|
||||
{
|
||||
if (!isOwned)
|
||||
if (!isClientOwned)
|
||||
{
|
||||
Debug.LogWarning("SendToServer called without authority");
|
||||
return;
|
||||
|
@ -69,7 +69,7 @@ protected override void OnValidate()
|
||||
/// </summary>
|
||||
bool IgnoreSync => isServer || ClientWithAuthority;
|
||||
|
||||
bool ClientWithAuthority => clientAuthority && isOwned;
|
||||
bool ClientWithAuthority => clientAuthority && isClientOwned;
|
||||
|
||||
void OnVelocityChanged(Vector2 _, Vector2 newValue)
|
||||
{
|
||||
@ -177,7 +177,7 @@ void SyncToClients()
|
||||
[Client]
|
||||
void SendToServer()
|
||||
{
|
||||
if (!isOwned)
|
||||
if (!isClientOwned)
|
||||
{
|
||||
Debug.LogWarning("SendToServer called without authority");
|
||||
return;
|
||||
|
@ -67,7 +67,7 @@ bool SendMessagesAllowed
|
||||
return true;
|
||||
}
|
||||
|
||||
return (isOwned && clientAuthority);
|
||||
return (isClientOwned && clientAuthority);
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ void OnAnimatorSpeedChanged(float _, float value)
|
||||
{
|
||||
// skip if host or client with authority
|
||||
// they will have already set the speed so don't set again
|
||||
if (isServer || (isOwned && clientAuthority))
|
||||
if (isServer || (isClientOwned && clientAuthority))
|
||||
return;
|
||||
|
||||
animator.speed = value;
|
||||
@ -227,7 +227,7 @@ void SendAnimationParametersMessage(byte[] parameters)
|
||||
|
||||
void HandleAnimMsg(int stateHash, float normalizedTime, int layerId, float weight, NetworkReader reader)
|
||||
{
|
||||
if (isOwned && clientAuthority)
|
||||
if (isClientOwned && clientAuthority)
|
||||
return;
|
||||
|
||||
// usually transitions will be triggered by parameters, if not, play anims directly.
|
||||
@ -245,7 +245,7 @@ void HandleAnimMsg(int stateHash, float normalizedTime, int layerId, float weigh
|
||||
|
||||
void HandleAnimParamsMsg(NetworkReader reader)
|
||||
{
|
||||
if (isOwned && clientAuthority)
|
||||
if (isClientOwned && clientAuthority)
|
||||
return;
|
||||
|
||||
ReadParameters(reader);
|
||||
@ -428,7 +428,7 @@ public void SetTrigger(int hash)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isOwned)
|
||||
if (!isClientOwned)
|
||||
{
|
||||
Debug.LogWarning("Only the client with authority can set animations");
|
||||
return;
|
||||
@ -475,7 +475,7 @@ public void ResetTrigger(int hash)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isOwned)
|
||||
if (!isClientOwned)
|
||||
{
|
||||
Debug.LogWarning("Only the client with authority can reset animations");
|
||||
return;
|
||||
@ -543,7 +543,7 @@ void CmdOnAnimationTriggerServerMessage(int hash)
|
||||
|
||||
// handle and broadcast
|
||||
// host should have already the trigger
|
||||
bool isHostOwner = isClient && isOwned;
|
||||
bool isHostOwner = isClient && isClientOwned;
|
||||
if (!isHostOwner)
|
||||
{
|
||||
HandleAnimTriggerMsg(hash);
|
||||
@ -561,7 +561,7 @@ void CmdOnAnimationResetTriggerServerMessage(int hash)
|
||||
|
||||
// handle and broadcast
|
||||
// host should have already the trigger
|
||||
bool isHostOwner = isClient && isOwned;
|
||||
bool isHostOwner = isClient && isClientOwned;
|
||||
if (!isHostOwner)
|
||||
{
|
||||
HandleAnimResetTriggerMsg(hash);
|
||||
@ -600,7 +600,7 @@ void RpcOnAnimationParametersClientMessage(byte[] parameters)
|
||||
void RpcOnAnimationTriggerClientMessage(int hash)
|
||||
{
|
||||
// host/owner handles this before it is sent
|
||||
if (isServer || (clientAuthority && isOwned)) return;
|
||||
if (isServer || (clientAuthority && isClientOwned)) return;
|
||||
|
||||
HandleAnimTriggerMsg(hash);
|
||||
}
|
||||
@ -609,7 +609,7 @@ void RpcOnAnimationTriggerClientMessage(int hash)
|
||||
void RpcOnAnimationResetTriggerClientMessage(int hash)
|
||||
{
|
||||
// host/owner handles this before it is sent
|
||||
if (isServer || (clientAuthority && isOwned)) return;
|
||||
if (isServer || (clientAuthority && isClientOwned)) return;
|
||||
|
||||
HandleAnimResetTriggerMsg(hash);
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ protected virtual void UpdateServer()
|
||||
// https://github.com/MirrorNetworking/Mirror/issues/3329
|
||||
if (syncDirection == SyncDirection.ClientToServer &&
|
||||
connectionToClient != null &&
|
||||
!isOwned)
|
||||
!isClientOwned)
|
||||
{
|
||||
if (serverSnapshots.Count > 0)
|
||||
{
|
||||
|
@ -165,7 +165,7 @@ void UpdateServerInterpolation()
|
||||
// https://github.com/MirrorNetworking/Mirror/issues/3329
|
||||
if (syncDirection == SyncDirection.ClientToServer &&
|
||||
connectionToClient != null &&
|
||||
!isOwned)
|
||||
!isClientOwned)
|
||||
{
|
||||
if (serverSnapshots.Count == 0) return;
|
||||
|
||||
|
@ -65,11 +65,14 @@ public abstract class NetworkBehaviour : MonoBehaviour
|
||||
|
||||
/// <summary>isOwned is true on the client if this NetworkIdentity is one of the .owned entities of our connection on the server.</summary>
|
||||
// for example: main player & pets are owned. monsters & npcs aren't.
|
||||
public bool isOwned => netIdentity.isOwned;
|
||||
public bool isClientOwned => netIdentity.isClientOwned;
|
||||
|
||||
[Obsolete(".isOwned was renamed to .isClientOwned to reflect that it's a client-only flag.")]
|
||||
public bool isOwned => isClientOwned;
|
||||
|
||||
// Deprecated 2022-10-13
|
||||
[Obsolete(".hasAuthority was renamed to .isOwned. This is easier to understand and prepares for SyncDirection, where there is a difference betwen isOwned and authority.")]
|
||||
public bool hasAuthority => isOwned;
|
||||
[Obsolete(".hasAuthority was renamed to .isClientOwned. This is easier to understand and prepares for SyncDirection, where there is a difference betwen isOwned and authority.")]
|
||||
public bool hasAuthority => isClientOwned;
|
||||
|
||||
/// <summary>authority is true if we are allowed to modify this component's state. On server, it's true if SyncDirection is ServerToClient. On client, it's true if SyncDirection is ClientToServer and(!) if this object is owned by the client.</summary>
|
||||
// on the client: if owned and if clientAuthority sync direction
|
||||
@ -86,7 +89,7 @@ public abstract class NetworkBehaviour : MonoBehaviour
|
||||
// another component may not be client authoritative, etc.
|
||||
public bool authority =>
|
||||
isClient
|
||||
? syncDirection == SyncDirection.ClientToServer && isOwned
|
||||
? syncDirection == SyncDirection.ClientToServer && isClientOwned
|
||||
: syncDirection == SyncDirection.ServerToClient;
|
||||
|
||||
/// <summary>The unique network Id of this object (unique at runtime).</summary>
|
||||
@ -244,7 +247,7 @@ protected void InitSyncObject(SyncObject syncObject)
|
||||
|
||||
// host mode: any ServerToClient and any local client owned
|
||||
if (NetworkServer.active && NetworkClient.active)
|
||||
return syncDirection == SyncDirection.ServerToClient || isOwned;
|
||||
return syncDirection == SyncDirection.ServerToClient || isClientOwned;
|
||||
|
||||
// server only: any ServerToClient
|
||||
if (NetworkServer.active)
|
||||
@ -254,7 +257,7 @@ protected void InitSyncObject(SyncObject syncObject)
|
||||
if (NetworkClient.active)
|
||||
{
|
||||
// spawned: only ClientToServer and owned
|
||||
if (netId != 0) return syncDirection == SyncDirection.ClientToServer && isOwned;
|
||||
if (netId != 0) return syncDirection == SyncDirection.ClientToServer && isClientOwned;
|
||||
|
||||
// not spawned (character selection previews, etc.): always allow
|
||||
// fixes https://github.com/MirrorNetworking/Mirror/issues/3343
|
||||
@ -284,7 +287,7 @@ protected void InitSyncObject(SyncObject syncObject)
|
||||
if (isServer) return netIdentity.observers.Count > 0;
|
||||
|
||||
// client only: only ClientToServer and owned
|
||||
if (isClient) return syncDirection == SyncDirection.ClientToServer && isOwned;
|
||||
if (isClient) return syncDirection == SyncDirection.ClientToServer && isClientOwned;
|
||||
|
||||
// users may add to SyncLists before the object was spawned.
|
||||
// isServer / isClient would still be false.
|
||||
@ -340,7 +343,7 @@ protected void SendCommandInternal(string functionFullName, int functionHashCode
|
||||
|
||||
// local players can always send commands, regardless of authority,
|
||||
// other objects must have authority.
|
||||
if (!(!requiresAuthority || isLocalPlayer || isOwned))
|
||||
if (!(!requiresAuthority || isLocalPlayer || isClientOwned))
|
||||
{
|
||||
Debug.LogWarning($"Command {functionFullName} called on {name} without authority.", gameObject);
|
||||
return;
|
||||
|
@ -1044,7 +1044,7 @@ internal static void ApplySpawnPayload(NetworkIdentity identity, SpawnMessage me
|
||||
// the below DeserializeClient call invokes SyncVarHooks.
|
||||
// flags always need to be initialized before that.
|
||||
// fixes: https://github.com/MirrorNetworking/Mirror/issues/3259
|
||||
identity.isOwned = message.isOwner;
|
||||
identity.isClientOwned = message.isOwner;
|
||||
identity.netId = message.netId;
|
||||
|
||||
if (message.isLocalPlayer)
|
||||
@ -1069,7 +1069,7 @@ internal static void ApplySpawnPayload(NetworkIdentity identity, SpawnMessage me
|
||||
}
|
||||
|
||||
spawned[message.netId] = identity;
|
||||
if (identity.isOwned) connection?.owned.Add(identity);
|
||||
if (identity.isClientOwned) connection?.owned.Add(identity);
|
||||
|
||||
// the initial spawn with OnObjectSpawnStarted/Finished calls all
|
||||
// object's OnStartClient/OnStartLocalPlayer after they were all
|
||||
@ -1279,7 +1279,7 @@ internal static void OnHostClientSpawn(SpawnMessage message)
|
||||
if (aoi != null)
|
||||
aoi.SetHostVisibility(identity, true);
|
||||
|
||||
identity.isOwned = message.isOwner;
|
||||
identity.isClientOwned = message.isOwner;
|
||||
BootstrapIdentity(identity);
|
||||
}
|
||||
}
|
||||
@ -1357,10 +1357,10 @@ internal static void ChangeOwner(NetworkIdentity identity, ChangeOwnerMessage me
|
||||
}
|
||||
|
||||
// set ownership flag (aka authority)
|
||||
identity.isOwned = message.isOwner;
|
||||
identity.isClientOwned = message.isOwner;
|
||||
|
||||
// Add / Remove to client's connectionToServer.owned hashset.
|
||||
if (identity.isOwned)
|
||||
if (identity.isClientOwned)
|
||||
connection?.owned.Add(identity);
|
||||
else
|
||||
connection?.owned.Remove(identity);
|
||||
|
@ -91,11 +91,15 @@ public sealed class NetworkIdentity : MonoBehaviour
|
||||
|
||||
/// <summary>isOwned is true on the client if this NetworkIdentity is one of the .owned entities of our connection on the server.</summary>
|
||||
// for example: main player & pets are owned. monsters & npcs aren't.
|
||||
public bool isOwned { get; internal set; }
|
||||
// this flag is client-only, not for the server.
|
||||
public bool isClientOwned { get; internal set; }
|
||||
|
||||
[Obsolete(".isOwned was renamed to .isClientOwned to reflect that it's a client-only flag.")]
|
||||
public bool isOwned => isClientOwned;
|
||||
|
||||
// Deprecated 2022-10-13
|
||||
[Obsolete(".hasAuthority was renamed to .isOwned. This is easier to understand and prepares for SyncDirection, where there is a difference betwen isOwned and authority.")]
|
||||
public bool hasAuthority => isOwned;
|
||||
[Obsolete(".hasAuthority was renamed to .isClientOwned. This is easier to understand and prepares for SyncDirection, where there is a difference betwen isOwned and authority.")]
|
||||
public bool hasAuthority => isClientOwned;
|
||||
|
||||
/// <summary>The set of network connections (players) that can see this object.</summary>
|
||||
public readonly Dictionary<int, NetworkConnectionToClient> observers =
|
||||
@ -864,7 +868,7 @@ ulong ClientDirtyMask()
|
||||
|
||||
// on client, only consider owned components with SyncDirection to server
|
||||
NetworkBehaviour component = components[i];
|
||||
if (isOwned && component.syncDirection == SyncDirection.ClientToServer)
|
||||
if (isClientOwned && component.syncDirection == SyncDirection.ClientToServer)
|
||||
{
|
||||
// set the n-th bit if dirty
|
||||
// shifting from small to large numbers is varint-efficient.
|
||||
@ -1296,7 +1300,7 @@ internal void Reset()
|
||||
//isLocalPlayer = false; <- cleared AFTER ClearLocalPlayer below!
|
||||
|
||||
// remove authority flag. This object may be unspawned, not destroyed, on client.
|
||||
isOwned = false;
|
||||
isClientOwned = false;
|
||||
NotifyAuthority();
|
||||
|
||||
netId = 0;
|
||||
@ -1323,11 +1327,11 @@ internal void Reset()
|
||||
bool hadAuthority;
|
||||
internal void NotifyAuthority()
|
||||
{
|
||||
if (!hadAuthority && isOwned)
|
||||
if (!hadAuthority && isClientOwned)
|
||||
OnStartAuthority();
|
||||
if (hadAuthority && !isOwned)
|
||||
if (hadAuthority && !isClientOwned)
|
||||
OnStopAuthority();
|
||||
hadAuthority = isOwned;
|
||||
hadAuthority = isClientOwned;
|
||||
}
|
||||
|
||||
internal void OnStartAuthority()
|
||||
|
@ -940,7 +940,7 @@ public static bool AddPlayerForConnection(NetworkConnectionToClient conn, GameOb
|
||||
// special case, we are in host mode, set hasAuthority to true so that all overrides see it
|
||||
if (conn is LocalConnectionToClient)
|
||||
{
|
||||
identity.isOwned = true;
|
||||
identity.isClientOwned = true;
|
||||
NetworkClient.InternalAddPlayer(identity);
|
||||
}
|
||||
|
||||
@ -983,7 +983,7 @@ public static bool ReplacePlayerForConnection(NetworkConnectionToClient conn, Ga
|
||||
// special case, we are in host mode, set hasAuthority to true so that all overrides see it
|
||||
if (conn is LocalConnectionToClient)
|
||||
{
|
||||
identity.isOwned = true;
|
||||
identity.isClientOwned = true;
|
||||
NetworkClient.InternalAddPlayer(identity);
|
||||
}
|
||||
|
||||
@ -1397,7 +1397,7 @@ static void SpawnObject(GameObject obj, NetworkConnection ownerConnection)
|
||||
// special case to make sure hasAuthority is set
|
||||
// on start server in host mode
|
||||
if (ownerConnection is LocalConnectionToClient)
|
||||
identity.isOwned = true;
|
||||
identity.isClientOwned = true;
|
||||
|
||||
// only call OnStartServer if not spawned yet.
|
||||
// check used to be in NetworkIdentity. may not be necessary anymore.
|
||||
@ -1515,7 +1515,7 @@ static void DestroyObject(NetworkIdentity identity, DestroyMode mode)
|
||||
// The object may have been spawned with host client ownership,
|
||||
// e.g. a pet so we need to clear hasAuthority and call
|
||||
// NotifyAuthority which invokes OnStopAuthority if hasAuthority.
|
||||
identity.isOwned = false;
|
||||
identity.isClientOwned = false;
|
||||
identity.NotifyAuthority();
|
||||
|
||||
// remove from NetworkClient dictionary
|
||||
|
@ -252,7 +252,7 @@ IEnumerable<NetworkIdentityInfo> GetNetworkIdentityInfo(NetworkIdentity identity
|
||||
infos.Add(GetString("Network ID", identity.netId.ToString()));
|
||||
infos.Add(GetBoolean("Is Client", identity.isClient));
|
||||
infos.Add(GetBoolean("Is Server", identity.isServer));
|
||||
infos.Add(GetBoolean("Is Owned", identity.isOwned));
|
||||
infos.Add(GetBoolean("Is Owned", identity.isClientOwned));
|
||||
infos.Add(GetBoolean("Is Local Player", identity.isLocalPlayer));
|
||||
}
|
||||
return infos;
|
||||
|
@ -263,7 +263,7 @@ protected void CreateNetworkedAndSpawn(
|
||||
|
||||
// double check that we have authority if we passed an owner connection
|
||||
if (ownerConnection != null)
|
||||
Debug.Assert(clientIdentity.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(clientIdentity.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
|
||||
// make sure the client really spawned it.
|
||||
Assert.That(NetworkClient.spawned.ContainsKey(serverIdentity.netId));
|
||||
@ -286,7 +286,7 @@ protected void CreateNetworkedAndSpawn<T>(out GameObject go, out NetworkIdentity
|
||||
|
||||
// double check that we have authority if we passed an owner connection
|
||||
if (ownerConnection != null)
|
||||
Debug.Assert(component.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(component.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
}
|
||||
|
||||
// create GameObject + NetworkIdentity + NetworkBehaviour in children & SPAWN
|
||||
@ -306,7 +306,7 @@ protected void CreateNetworkedChildAndSpawn<T>(out GameObject parent, out GameOb
|
||||
|
||||
// double check that we have authority if we passed an owner connection
|
||||
if (ownerConnection != null)
|
||||
Debug.Assert(component.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(component.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
}
|
||||
|
||||
// create GameObject + NetworkIdentity + NetworkBehaviour & SPAWN
|
||||
@ -342,7 +342,7 @@ protected void CreateNetworkedAndSpawn<T>(
|
||||
|
||||
// double check that we have authority if we passed an owner connection
|
||||
if (ownerConnection != null)
|
||||
Debug.Assert(clientComponent.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(clientComponent.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
|
||||
// make sure the client really spawned it.
|
||||
Assert.That(NetworkClient.spawned.ContainsKey(serverIdentity.netId));
|
||||
@ -381,7 +381,7 @@ protected void CreateNetworkedChildAndSpawn<T>(
|
||||
|
||||
// double check that we have authority if we passed an owner connection
|
||||
if (ownerConnection != null)
|
||||
Debug.Assert(clientComponent.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(clientComponent.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
|
||||
// make sure the client really spawned it.
|
||||
Assert.That(NetworkClient.spawned.ContainsKey(serverIdentity.netId));
|
||||
@ -406,8 +406,8 @@ protected void CreateNetworkedAndSpawn<T, U>(out GameObject go, out NetworkIdent
|
||||
// double check that we have authority if we passed an owner connection
|
||||
if (ownerConnection != null)
|
||||
{
|
||||
Debug.Assert(componentA.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(componentB.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(componentA.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(componentB.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
}
|
||||
}
|
||||
|
||||
@ -430,8 +430,8 @@ protected void CreateNetworkedChildAndSpawn<T, U>(out GameObject parent, out Gam
|
||||
// double check that we have authority if we passed an owner connection
|
||||
if (ownerConnection != null)
|
||||
{
|
||||
Debug.Assert(componentA.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(componentB.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(componentA.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(componentB.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
}
|
||||
}
|
||||
|
||||
@ -470,8 +470,8 @@ protected void CreateNetworkedAndSpawn<T, U>(
|
||||
// double check that we have authority if we passed an owner connection
|
||||
if (ownerConnection != null)
|
||||
{
|
||||
Debug.Assert(clientComponentA.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(clientComponentB.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(clientComponentA.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(clientComponentB.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
}
|
||||
|
||||
// make sure the client really spawned it.
|
||||
@ -513,8 +513,8 @@ protected void CreateNetworkedChildAndSpawn<T, U>(
|
||||
// double check that we have authority if we passed an owner connection
|
||||
if (ownerConnection != null)
|
||||
{
|
||||
Debug.Assert(clientComponentA.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(clientComponentB.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(clientComponentA.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(clientComponentB.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
}
|
||||
|
||||
// make sure the client really spawned it.
|
||||
@ -541,9 +541,9 @@ protected void CreateNetworkedAndSpawn<T, U, V>(out GameObject go, out NetworkId
|
||||
// double check that we have authority if we passed an owner connection
|
||||
if (ownerConnection != null)
|
||||
{
|
||||
Debug.Assert(componentA.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(componentB.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(componentC.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(componentA.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(componentB.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(componentC.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
}
|
||||
}
|
||||
|
||||
@ -567,9 +567,9 @@ protected void CreateNetworkedChildAndSpawn<T, U, V>(out GameObject parent, out
|
||||
// double check that we have authority if we passed an owner connection
|
||||
if (ownerConnection != null)
|
||||
{
|
||||
Debug.Assert(componentA.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(componentB.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(componentC.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(componentA.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(componentB.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(componentC.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
}
|
||||
}
|
||||
|
||||
@ -609,9 +609,9 @@ protected void CreateNetworkedAndSpawn<T, U, V>(
|
||||
// double check that we have authority if we passed an owner connection
|
||||
if (ownerConnection != null)
|
||||
{
|
||||
Debug.Assert(clientComponentA.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(clientComponentB.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(clientComponentC.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(clientComponentA.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(clientComponentB.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(clientComponentC.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
}
|
||||
|
||||
// make sure the client really spawned it.
|
||||
@ -654,9 +654,9 @@ protected void CreateNetworkedChildAndSpawn<T, U, V>(
|
||||
// double check that we have authority if we passed an owner connection
|
||||
if (ownerConnection != null)
|
||||
{
|
||||
Debug.Assert(clientComponentA.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(clientComponentB.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(clientComponentC.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(clientComponentA.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(clientComponentB.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
Debug.Assert(clientComponentC.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results");
|
||||
}
|
||||
|
||||
// make sure the client really spawned it.
|
||||
|
@ -106,7 +106,7 @@ public void HasNoAuthorityByDefault()
|
||||
{
|
||||
// no authority by default
|
||||
CreateNetworked(out _, out _, out EmptyBehaviour emptyBehaviour);
|
||||
Assert.That(emptyBehaviour.isOwned, Is.False);
|
||||
Assert.That(emptyBehaviour.isClientOwned, Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -415,11 +415,11 @@ public void ApplyPayload_AppliesAuthority(bool isOwner)
|
||||
};
|
||||
|
||||
// set to opposite to make sure it is changed
|
||||
identity.isOwned = !isOwner;
|
||||
identity.isClientOwned = !isOwner;
|
||||
|
||||
NetworkClient.ApplySpawnPayload(identity, msg);
|
||||
|
||||
Assert.That(identity.isOwned, Is.EqualTo(isOwner));
|
||||
Assert.That(identity.isClientOwned, Is.EqualTo(isOwner));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -252,7 +252,7 @@ public void SerializeAndDeserialize_ClientToServer_NOT_OWNED()
|
||||
|
||||
// set to CLIENT with some unique values
|
||||
// and set connection to server to pretend we are the owner.
|
||||
identity.isOwned = false;
|
||||
identity.isClientOwned = false;
|
||||
identity.connectionToServer = null; // NOT OWNED
|
||||
comp1.syncDirection = SyncDirection.ServerToClient;
|
||||
comp1.value = 12345;
|
||||
|
@ -379,40 +379,40 @@ public void NotifyAuthorityCallsOnStartStopAuthority()
|
||||
CreateNetworked(out GameObject _, out NetworkIdentity identity, out NetworkBehaviourMock comp);
|
||||
|
||||
// set authority from false to true, which should call OnStartAuthority
|
||||
identity.isOwned = true;
|
||||
identity.isClientOwned = true;
|
||||
identity.NotifyAuthority();
|
||||
// shouldn't be touched
|
||||
Assert.That(identity.isOwned, Is.True);
|
||||
Assert.That(identity.isClientOwned, Is.True);
|
||||
// start should be called
|
||||
Assert.That(comp.onStartAuthorityCalled, Is.EqualTo(1));
|
||||
// stop shouldn't
|
||||
Assert.That(comp.onStopAuthorityCalled, Is.EqualTo(0));
|
||||
|
||||
// set it to true again, should do nothing because already true
|
||||
identity.isOwned = true;
|
||||
identity.isClientOwned = true;
|
||||
identity.NotifyAuthority();
|
||||
// shouldn't be touched
|
||||
Assert.That(identity.isOwned, Is.True);
|
||||
Assert.That(identity.isClientOwned, Is.True);
|
||||
// same as before
|
||||
Assert.That(comp.onStartAuthorityCalled, Is.EqualTo(1));
|
||||
// same as before
|
||||
Assert.That(comp.onStopAuthorityCalled, Is.EqualTo(0));
|
||||
|
||||
// set it to false, should call OnStopAuthority
|
||||
identity.isOwned = false;
|
||||
identity.isClientOwned = false;
|
||||
identity.NotifyAuthority();
|
||||
// should be changed
|
||||
Assert.That(identity.isOwned, Is.False);
|
||||
Assert.That(identity.isClientOwned, Is.False);
|
||||
// same as before
|
||||
Assert.That(comp.onStartAuthorityCalled, Is.EqualTo(1));
|
||||
// stop should be called
|
||||
Assert.That(comp.onStopAuthorityCalled, Is.EqualTo(1));
|
||||
|
||||
// set it to false again, should do nothing because already false
|
||||
identity.isOwned = false;
|
||||
identity.isClientOwned = false;
|
||||
identity.NotifyAuthority();
|
||||
// shouldn't be touched
|
||||
Assert.That(identity.isOwned, Is.False);
|
||||
Assert.That(identity.isClientOwned, Is.False);
|
||||
// same as before
|
||||
Assert.That(comp.onStartAuthorityCalled, Is.EqualTo(1));
|
||||
// same as before
|
||||
@ -676,7 +676,7 @@ public void Reset()
|
||||
Assert.That(identity.netId, Is.EqualTo(0));
|
||||
Assert.That(identity.connectionToClient, Is.Null);
|
||||
Assert.That(identity.connectionToServer, Is.Null);
|
||||
Assert.That(identity.isOwned, Is.False);
|
||||
Assert.That(identity.isClientOwned, Is.False);
|
||||
Assert.That(identity.observers, Is.Empty);
|
||||
}
|
||||
|
||||
|
@ -324,7 +324,7 @@ public void Destroy_HostMode_CallsOnStopAuthority()
|
||||
NetworkServer.localConnection);
|
||||
|
||||
// need to have authority for this test
|
||||
Assert.That(player.isOwned, Is.True);
|
||||
Assert.That(player.isClientOwned, Is.True);
|
||||
|
||||
// destroy and ignore 'Destroy called in Edit mode' error
|
||||
LogAssert.ignoreFailingMessages = true;
|
||||
@ -1070,11 +1070,11 @@ public void UnSpawnAndClearAuthority()
|
||||
go.SetActive(true);
|
||||
|
||||
// set authority from false to true, which should call OnStartAuthority
|
||||
identity.isOwned = true;
|
||||
identity.isClientOwned = true;
|
||||
identity.NotifyAuthority();
|
||||
|
||||
// shouldn't be touched
|
||||
Assert.That(identity.isOwned, Is.True);
|
||||
Assert.That(identity.isClientOwned, Is.True);
|
||||
// start should be called
|
||||
Assert.That(comp.onStartAuthorityCalled, Is.EqualTo(1));
|
||||
// stop shouldn't
|
||||
@ -1085,7 +1085,7 @@ public void UnSpawnAndClearAuthority()
|
||||
Assert.That(identity.netId, Is.Zero);
|
||||
|
||||
// should be changed
|
||||
Assert.That(identity.isOwned, Is.False);
|
||||
Assert.That(identity.isClientOwned, Is.False);
|
||||
// same as before
|
||||
Assert.That(comp.onStartAuthorityCalled, Is.EqualTo(1));
|
||||
// stop should be called
|
||||
|
Loading…
Reference in New Issue
Block a user