From ce94e62e6244ed3e5178781adbef32ae93e9f0fc Mon Sep 17 00:00:00 2001 From: John Detter Date: Thu, 31 Oct 2024 21:22:14 +0000 Subject: [PATCH 1/3] More tests! --- .../client/Assets/PlayModeTests/PlayModeExampleTest.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/demo/Blackholio/client/Assets/PlayModeTests/PlayModeExampleTest.cs b/demo/Blackholio/client/Assets/PlayModeTests/PlayModeExampleTest.cs index ba7a28a984f..5f22fd062db 100644 --- a/demo/Blackholio/client/Assets/PlayModeTests/PlayModeExampleTest.cs +++ b/demo/Blackholio/client/Assets/PlayModeTests/PlayModeExampleTest.cs @@ -16,7 +16,7 @@ public class PlayModeExampleTest { - // [UnityTest] - This won't work until we have reconnections + [UnityTest] public IEnumerator SimpleConnectionTest() { PlayerPrefs.DeleteAll(); @@ -138,7 +138,7 @@ public IEnumerator CreatePlayerAndTestDecay() Debug.Assert(massEnd < massStart, "Mass should have decayed"); } - // [UnityTest] - This won't work until we have reconnections + [UnityTest] public IEnumerator OneOffTest1() { var connected = false; @@ -183,7 +183,7 @@ public IEnumerator OneOffTest1() Debug.Log($"id: {players[0].PlayerId} Username: {players[0].Name}"); } - // [UnityTest] - This won't work until we have reconnections + [UnityTest] public IEnumerator OneOffTest2() { var connected = false; @@ -227,7 +227,7 @@ public IEnumerator OneOffTest2() Debug.Log($"id: {players[0].PlayerId} Username: {players[0].Name}"); } - //[UnityTest] + [UnityTest] public IEnumerator ReconnectionViaReloadingScene() { var connected = false; From c899eab1ce0dadf8ac6c903540a30fa2069411ab Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Sat, 9 Aug 2025 00:28:46 +0800 Subject: [PATCH 2/3] Fix reconnections --- demo/Blackholio/client-unity/Assets/Scripts/GameManager.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/demo/Blackholio/client-unity/Assets/Scripts/GameManager.cs b/demo/Blackholio/client-unity/Assets/Scripts/GameManager.cs index 82d33882c06..a3584e81c70 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/GameManager.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/GameManager.cs @@ -29,6 +29,9 @@ public class GameManager : MonoBehaviour private void Start() { + // Clear game state in case we've disconnected and reconnected + Entities.Clear(); + Players.Clear(); Instance = this; Application.targetFrameRate = 60; From af3e281812401512525210dd6703299abca008c7 Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Sat, 9 Aug 2025 01:23:03 +0800 Subject: [PATCH 3/3] Make testsuite more reliable --- .../Assets/PlayModeTests/PlayModeExampleTest.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/demo/Blackholio/client-unity/Assets/PlayModeTests/PlayModeExampleTest.cs b/demo/Blackholio/client-unity/Assets/PlayModeTests/PlayModeExampleTest.cs index 2542c777f73..09d5622dd99 100644 --- a/demo/Blackholio/client-unity/Assets/PlayModeTests/PlayModeExampleTest.cs +++ b/demo/Blackholio/client-unity/Assets/PlayModeTests/PlayModeExampleTest.cs @@ -84,7 +84,7 @@ public IEnumerator CreatePlayerAndTestDecay() // Standing still should decay a bit PlayerController.Local.EnableTestInput(); - while (foodEaten < 200) + while (foodEaten < 50) { Debug.Assert(circle != null, nameof(circle) + " != null"); var ourEntity = GameManager.Conn.Db.Entity.EntityId.Find(circle.EntityId); @@ -116,6 +116,11 @@ public IEnumerator CreatePlayerAndTestDecay() Debug.Assert(foodEntity != null, nameof(foodEntity) + " != null"); Debug.Assert(ourNewEntity != null, nameof(ourNewEntity) + " != null"); var toThisFood = (Vector2)foodEntity.Position - (Vector2)ourNewEntity.Position; + // We have to go slow for the first few pieces of food otherwise we can "hop" over it + if (foodEaten < 10) + { + toThisFood = toThisFood.normalized * 0.5f; + } PlayerController.Local.SetTestInput(toThisFood); }