From cbf19e8445e605fce848c2ea8cddff76b4e2bf54 Mon Sep 17 00:00:00 2001 From: Matt Walsh Date: Wed, 4 Aug 2021 15:53:45 -0700 Subject: [PATCH 1/3] oops --- .../Tests/Runtime/NetworkVariableTests.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/com.unity.multiplayer.mlapi/Tests/Runtime/NetworkVariableTests.cs b/com.unity.multiplayer.mlapi/Tests/Runtime/NetworkVariableTests.cs index dd3cde9001..e8e41853ec 100644 --- a/com.unity.multiplayer.mlapi/Tests/Runtime/NetworkVariableTests.cs +++ b/com.unity.multiplayer.mlapi/Tests/Runtime/NetworkVariableTests.cs @@ -101,6 +101,7 @@ public override IEnumerator Setup() // This is the *SERVER VERSION* of the *CLIENT PLAYER* var serverClientPlayerResult = new MultiInstanceHelpers.CoroutineResultWrapper(); + yield return MultiInstanceHelpers.Run(MultiInstanceHelpers.GetNetworkObjectByRepresentation( x => x.IsPlayerObject && x.OwnerClientId == m_ClientNetworkManagers[0].LocalClientId, m_ServerNetworkManager, serverClientPlayerResult)); @@ -178,8 +179,6 @@ public IEnumerator AllNetworkVariableTypes() [UnityTest] public IEnumerator NetworkListAdd() { - var waitResult = new MultiInstanceHelpers.CoroutineResultWrapper(); - yield return MultiInstanceHelpers.RunAndWaitForCondition( () => { From 27f303089386fe72973afb082528982f157c2b7f Mon Sep 17 00:00:00 2001 From: Matt Walsh Date: Wed, 4 Aug 2021 17:02:02 -0700 Subject: [PATCH 2/3] fixadded NetworkSet plainly-callable Add() method MTT-1005 --- .../NetworkVariable/Collections/NetworkSet.cs | 37 ++++++------------- .../Tests/Runtime/NetworkVariableTests.cs | 21 +++++------ 2 files changed, 22 insertions(+), 36 deletions(-) diff --git a/com.unity.multiplayer.mlapi/Runtime/NetworkVariable/Collections/NetworkSet.cs b/com.unity.multiplayer.mlapi/Runtime/NetworkVariable/Collections/NetworkSet.cs index 06dc63189f..9e0e58953f 100644 --- a/com.unity.multiplayer.mlapi/Runtime/NetworkVariable/Collections/NetworkSet.cs +++ b/com.unity.multiplayer.mlapi/Runtime/NetworkVariable/Collections/NetworkSet.cs @@ -331,29 +331,6 @@ IEnumerator IEnumerable.GetEnumerator() return m_Set.GetEnumerator(); } - /// - void ICollection.Add(T item) - { - EnsureInitialized(); - - if (m_NetworkBehaviour.NetworkManager.IsServer) - { - m_Set.Add(item); - } - - var setEvent = new NetworkSetEvent() - { - Type = NetworkSetEvent.EventType.Add, - Value = item - }; - m_DirtyEvents.Add(setEvent); - - if (m_NetworkBehaviour.NetworkManager.IsServer && OnSetChanged != null) - { - OnSetChanged(setEvent); - } - } - /// public void ExceptWith(IEnumerable other) { @@ -478,8 +455,7 @@ public void UnionWith(IEnumerable other) } } - /// - bool ISet.Add(T item) + public void Add(T item) { EnsureInitialized(); @@ -499,10 +475,21 @@ bool ISet.Add(T item) { OnSetChanged(setEvent); } + } + /// + bool ISet.Add(T item) + { + Add(item); return true; } + /// + void ICollection.Add(T item) + { + Add(item); + } + /// public void Clear() { diff --git a/com.unity.multiplayer.mlapi/Tests/Runtime/NetworkVariableTests.cs b/com.unity.multiplayer.mlapi/Tests/Runtime/NetworkVariableTests.cs index e8e41853ec..9be6a881a0 100644 --- a/com.unity.multiplayer.mlapi/Tests/Runtime/NetworkVariableTests.cs +++ b/com.unity.multiplayer.mlapi/Tests/Runtime/NetworkVariableTests.cs @@ -119,14 +119,16 @@ public override IEnumerator Setup() m_ClientComp = clientSideClientPlayer.GetComponent(); m_ServerComp.TheList.Clear(); + m_ServerComp.TheSet.Clear(); + m_ServerComp.TheDictionary.Clear(); - if (m_ServerComp.TheList.Count > 0) + if (m_ServerComp.TheList.Count > 0 || m_ServerComp.TheSet.Count > 0 || m_ServerComp.TheDictionary.Count > 0) { - throw new Exception("server network list not empty at start"); + throw new Exception("at least one server network container not empty at start"); } - if (m_ClientComp.TheList.Count > 0) + if (m_ClientComp.TheList.Count > 0 || m_ClientComp.TheSet.Count > 0 || m_ClientComp.TheDictionary.Count > 0) { - throw new Exception("client network list not empty at start"); + throw new Exception("at least one client network container not empty at start"); } } @@ -244,9 +246,8 @@ public IEnumerator NetworkSetAdd() yield return MultiInstanceHelpers.RunAndWaitForCondition( () => { - ISet iSet = m_ServerComp.TheSet; - iSet.Add(k_TestVal1); - iSet.Add(k_TestVal2); + m_ServerComp.TheSet.Add(k_TestVal1); + m_ServerComp.TheSet.Add(k_TestVal2); }, () => { @@ -271,8 +272,7 @@ public IEnumerator NetworkSetRemove() yield return MultiInstanceHelpers.RunAndWaitForCondition( () => { - ISet iSet = m_ServerComp.TheSet; - iSet.Remove(k_TestVal1); + m_ServerComp.TheSet.Remove(k_TestVal1); }, () => { @@ -295,8 +295,7 @@ public IEnumerator NetworkSetClear() yield return MultiInstanceHelpers.RunAndWaitForCondition( () => { - ISet iSet = m_ServerComp.TheSet; - iSet.Clear(); + m_ServerComp.TheSet.Clear(); }, () => { From f68626c9f852f50efa5e5543e8e664e9a2a23646 Mon Sep 17 00:00:00 2001 From: Matt Walsh Date: Wed, 4 Aug 2021 17:23:44 -0700 Subject: [PATCH 3/3] removed unneeded package --- .../Tests/Runtime/NetworkVariableTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/com.unity.multiplayer.mlapi/Tests/Runtime/NetworkVariableTests.cs b/com.unity.multiplayer.mlapi/Tests/Runtime/NetworkVariableTests.cs index 9be6a881a0..4b76e5645a 100644 --- a/com.unity.multiplayer.mlapi/Tests/Runtime/NetworkVariableTests.cs +++ b/com.unity.multiplayer.mlapi/Tests/Runtime/NetworkVariableTests.cs @@ -1,6 +1,5 @@ using System; using System.Collections; -using System.Collections.Generic; using UnityEngine; using UnityEngine.TestTools; using NUnit.Framework;