From e6759df44ffe0d112a3ce08e97f3d3cb353042a4 Mon Sep 17 00:00:00 2001 From: aarijimam <35100854+aarijimam@users.noreply.github.com> Date: Thu, 21 Nov 2024 00:00:24 +0500 Subject: [PATCH 01/12] fix: onquit build --- .../Examples/2d-platformer/scripts/GameManager2d.cs | 3 ++- .../scripts/GameManagerIsometric.cs | 6 ++++-- .../PlayroomKit/modules/Interfaces/IPlayerBase.cs | 1 + .../BrowserMode/BrowserMockPlayerService.cs | 5 +++++ .../modules/Player/LocalPlayerService.cs | 5 +++++ Assets/PlayroomKit/modules/Player/Player.cs | 6 ++++++ Assets/PlayroomKit/modules/Player/PlayerService.cs | 13 +++++++++++-- Assets/PlayroomKit/modules/PlayroomService.cs | 3 ++- ProjectSettings/EditorBuildSettings.asset | 4 ++-- 9 files changed, 38 insertions(+), 8 deletions(-) diff --git a/Assets/PlayroomKit/Examples/2d-platformer/scripts/GameManager2d.cs b/Assets/PlayroomKit/Examples/2d-platformer/scripts/GameManager2d.cs index 8da38b9..0598053 100644 --- a/Assets/PlayroomKit/Examples/2d-platformer/scripts/GameManager2d.cs +++ b/Assets/PlayroomKit/Examples/2d-platformer/scripts/GameManager2d.cs @@ -114,8 +114,9 @@ private void Update() for (var i = 0; i < players.Count; i++) { - if (players[i] != null) + if (players[i] != null && PlayerDict.TryGetValue(players[i].id, out GameObject playerObj)) { + Debug.Log("Getting state of: " + players[i].id); var pos = players[i].GetState("pos"); Debug.Log(pos); diff --git a/Assets/PlayroomKit/Examples/discord-activity/scripts/GameManagerIsometric.cs b/Assets/PlayroomKit/Examples/discord-activity/scripts/GameManagerIsometric.cs index bd60052..cf23648 100644 --- a/Assets/PlayroomKit/Examples/discord-activity/scripts/GameManagerIsometric.cs +++ b/Assets/PlayroomKit/Examples/discord-activity/scripts/GameManagerIsometric.cs @@ -32,7 +32,7 @@ private void Start() matchmaking = false, discord = true, gameId = "ii4pV1wfceCjjLvRoo3O", - roomCode = roomCode, + roomCode = "roomCode", }, () => { _playroomKit.OnPlayerJoin(AddPlayer); @@ -68,8 +68,9 @@ private void Update() for (var i = 0; i < players.Count; i++) { - if (players[i] != null) + if (players[i] != null && PlayerDict.TryGetValue(players[i].id, out GameObject playerObj)) { + Debug.Log("Getting state of: " + players[i].id); var pos = players[i].GetState("move"); var rotate = players[i].GetState("angle"); var color = players[i].GetState("color"); @@ -110,6 +111,7 @@ private static void RemovePlayer(string playerID) Debug.Log("Here?"); if (PlayerDict.TryGetValue(playerID, out var player)) { + Debug.Log("Deleting player" + playerID); PlayerDict.Remove(playerID); playerGameObjects.Remove(player); Destroy(player); diff --git a/Assets/PlayroomKit/modules/Interfaces/IPlayerBase.cs b/Assets/PlayroomKit/modules/Interfaces/IPlayerBase.cs index 9488b27..a25ca73 100644 --- a/Assets/PlayroomKit/modules/Interfaces/IPlayerBase.cs +++ b/Assets/PlayroomKit/modules/Interfaces/IPlayerBase.cs @@ -17,6 +17,7 @@ public interface IPlayerBase public T GetState(string key); public Profile GetProfile(); public Action OnQuit(Action callback); + public void InvokePlayerOnQuitCallback(string id); public void Kick(Action onKickCallBack = null); public void WaitForState(string stateKey, Action onStateSetCallback = null); diff --git a/Assets/PlayroomKit/modules/MockMode/BrowserMode/BrowserMockPlayerService.cs b/Assets/PlayroomKit/modules/MockMode/BrowserMode/BrowserMockPlayerService.cs index 37c8914..c706018 100644 --- a/Assets/PlayroomKit/modules/MockMode/BrowserMode/BrowserMockPlayerService.cs +++ b/Assets/PlayroomKit/modules/MockMode/BrowserMode/BrowserMockPlayerService.cs @@ -115,6 +115,11 @@ public Action OnQuit(Action callback) return default; } + public void InvokePlayerOnQuitCallback(string id) + { + throw new NotImplementedException(); + } + public void Kick(Action onKickCallBack = null) { _ubb.CallJs("Kick", null, null, true, _id); diff --git a/Assets/PlayroomKit/modules/Player/LocalPlayerService.cs b/Assets/PlayroomKit/modules/Player/LocalPlayerService.cs index 3060324..a5c9aff 100644 --- a/Assets/PlayroomKit/modules/Player/LocalPlayerService.cs +++ b/Assets/PlayroomKit/modules/Player/LocalPlayerService.cs @@ -101,6 +101,11 @@ public Action OnQuit(Action callback) return null; } + public void InvokePlayerOnQuitCallback(string id) + { + throw new NotImplementedException(); + } + public void Kick(Action onKickCallBack = null) { var player = GetPlayerById(_id); diff --git a/Assets/PlayroomKit/modules/Player/Player.cs b/Assets/PlayroomKit/modules/Player/Player.cs index ce43740..fb431d3 100644 --- a/Assets/PlayroomKit/modules/Player/Player.cs +++ b/Assets/PlayroomKit/modules/Player/Player.cs @@ -136,6 +136,12 @@ public void WaitForState(string StateKey, Action onStateSetCallback = nu _playerService.WaitForState(StateKey, onStateSetCallback); } + + public void InvokePlayerOnQuitCallback() + { + _playerService.InvokePlayerOnQuitCallback(id); + } + //DI END diff --git a/Assets/PlayroomKit/modules/Player/PlayerService.cs b/Assets/PlayroomKit/modules/Player/PlayerService.cs index 9f04196..93b5205 100644 --- a/Assets/PlayroomKit/modules/Player/PlayerService.cs +++ b/Assets/PlayroomKit/modules/Player/PlayerService.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.Runtime.CompilerServices; using UnityEngine; using System.Runtime.InteropServices; using AOT; @@ -139,6 +140,11 @@ void Unsubscribe() return Unsubscribe; } + public void InvokePlayerOnQuitCallback(string id) + { + OnQuitWrapperCallback(id); + } + public void Kick(Action onKickCallBack = null) { @@ -167,14 +173,15 @@ private static void InvokeKickCallBack() } [MonoPInvokeCallback(typeof(Action))] - private void OnQuitWrapperCallback(string id) + public void OnQuitWrapperCallback(string id) { + Debug.Log($"OnQuitWrapperCallback: {id}"); if (OnQuitCallbacks != null) foreach (var callback in OnQuitCallbacks) callback?.Invoke(id); } - void InvokeOnQuitWrapperCallback(string id) + public void InvokeOnQuitWrapperCallback(string id) { OnQuitWrapperCallback(id); } @@ -186,6 +193,8 @@ private bool GetPlayerStateBoolById(string key) stateValue == 0 ? false : throw new InvalidOperationException($"GetStateBool: {key} is not a bool"); } + + } } } diff --git a/Assets/PlayroomKit/modules/PlayroomService.cs b/Assets/PlayroomKit/modules/PlayroomService.cs index fecb767..f101c51 100644 --- a/Assets/PlayroomKit/modules/PlayroomService.cs +++ b/Assets/PlayroomKit/modules/PlayroomService.cs @@ -211,9 +211,10 @@ private static void InvokeInsertCoin(string key) [MonoPInvokeCallback(typeof(Action))] private static void __OnQuitInternalHandler(string playerId) { + Debug.Log("OnQuitInternalHandler from playeroom service called"); if (Players.TryGetValue(playerId, out Player player)) { - throw new NotImplementedException(); //implement OnQuitWrapperCallback; + player.InvokePlayerOnQuitCallback(); } else { diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index ab0bf7e..8e9f6cf 100644 --- a/ProjectSettings/EditorBuildSettings.asset +++ b/ProjectSettings/EditorBuildSettings.asset @@ -11,13 +11,13 @@ EditorBuildSettings: - enabled: 0 path: Assets/PlayroomKit/Examples/2d-platformer/2d-platformer.unity guid: cf82eec4c654cf44b89cec2a91afebd5 - - enabled: 0 + - enabled: 1 path: Assets/PlayroomKit/Examples/discord-activity/discord-activity.unity guid: bb7ef8e4a67f3fb46b78e5d95a6858a7 - enabled: 0 path: Assets/Scenes/topdown.unity guid: 490247da3cf48784ab657a183ba059d1 - - enabled: 1 + - enabled: 0 path: Assets/PlayroomKit/Examples/package-showcase/showcase.unity guid: 85c9af77ae006408ab24500b953a9035 m_configObjects: {} From dc8405acd843dda459db7b0024d1a1fd3f60d6ef Mon Sep 17 00:00:00 2001 From: aarijimam <35100854+aarijimam@users.noreply.github.com> Date: Thu, 21 Nov 2024 00:18:17 +0500 Subject: [PATCH 02/12] refactor: removed log --- .../Examples/discord-activity/scripts/GameManagerIsometric.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Assets/PlayroomKit/Examples/discord-activity/scripts/GameManagerIsometric.cs b/Assets/PlayroomKit/Examples/discord-activity/scripts/GameManagerIsometric.cs index cf23648..9b7689b 100644 --- a/Assets/PlayroomKit/Examples/discord-activity/scripts/GameManagerIsometric.cs +++ b/Assets/PlayroomKit/Examples/discord-activity/scripts/GameManagerIsometric.cs @@ -70,7 +70,6 @@ private void Update() { if (players[i] != null && PlayerDict.TryGetValue(players[i].id, out GameObject playerObj)) { - Debug.Log("Getting state of: " + players[i].id); var pos = players[i].GetState("move"); var rotate = players[i].GetState("angle"); var color = players[i].GetState("color"); From 7e140056ded359bf72cdb6e12d76b48c333575db Mon Sep 17 00:00:00 2001 From: aarijimam <35100854+aarijimam@users.noreply.github.com> Date: Thu, 21 Nov 2024 00:28:24 +0500 Subject: [PATCH 03/12] fix: remove MonoPInvoke from Remove Player --- .../Examples/discord-activity/scripts/GameManagerIsometric.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Assets/PlayroomKit/Examples/discord-activity/scripts/GameManagerIsometric.cs b/Assets/PlayroomKit/Examples/discord-activity/scripts/GameManagerIsometric.cs index 9b7689b..31255b6 100644 --- a/Assets/PlayroomKit/Examples/discord-activity/scripts/GameManagerIsometric.cs +++ b/Assets/PlayroomKit/Examples/discord-activity/scripts/GameManagerIsometric.cs @@ -104,7 +104,6 @@ private void AddPlayer(PlayroomKit.Player player) } // FIX: - [MonoPInvokeCallback(typeof(Action))] private static void RemovePlayer(string playerID) { Debug.Log("Here?"); From b197726c755a96ce93a98c900df2080d4c4bc728 Mon Sep 17 00:00:00 2001 From: aarijimam <35100854+aarijimam@users.noreply.github.com> Date: Thu, 21 Nov 2024 00:29:34 +0500 Subject: [PATCH 04/12] chore: remove comments --- .../discord-activity/scripts/GameManagerIsometric.cs | 5 +---- Assets/PlayroomKit/modules/Player/PlayerService.cs | 1 - Assets/PlayroomKit/modules/PlayroomService.cs | 1 - 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/Assets/PlayroomKit/Examples/discord-activity/scripts/GameManagerIsometric.cs b/Assets/PlayroomKit/Examples/discord-activity/scripts/GameManagerIsometric.cs index 31255b6..2937a0a 100644 --- a/Assets/PlayroomKit/Examples/discord-activity/scripts/GameManagerIsometric.cs +++ b/Assets/PlayroomKit/Examples/discord-activity/scripts/GameManagerIsometric.cs @@ -102,14 +102,11 @@ private void AddPlayer(PlayroomKit.Player player) playerJoined = true; player.OnQuit(RemovePlayer); } - - // FIX: + private static void RemovePlayer(string playerID) { - Debug.Log("Here?"); if (PlayerDict.TryGetValue(playerID, out var player)) { - Debug.Log("Deleting player" + playerID); PlayerDict.Remove(playerID); playerGameObjects.Remove(player); Destroy(player); diff --git a/Assets/PlayroomKit/modules/Player/PlayerService.cs b/Assets/PlayroomKit/modules/Player/PlayerService.cs index 93b5205..c511cd9 100644 --- a/Assets/PlayroomKit/modules/Player/PlayerService.cs +++ b/Assets/PlayroomKit/modules/Player/PlayerService.cs @@ -175,7 +175,6 @@ private static void InvokeKickCallBack() [MonoPInvokeCallback(typeof(Action))] public void OnQuitWrapperCallback(string id) { - Debug.Log($"OnQuitWrapperCallback: {id}"); if (OnQuitCallbacks != null) foreach (var callback in OnQuitCallbacks) callback?.Invoke(id); diff --git a/Assets/PlayroomKit/modules/PlayroomService.cs b/Assets/PlayroomKit/modules/PlayroomService.cs index f101c51..538e758 100644 --- a/Assets/PlayroomKit/modules/PlayroomService.cs +++ b/Assets/PlayroomKit/modules/PlayroomService.cs @@ -211,7 +211,6 @@ private static void InvokeInsertCoin(string key) [MonoPInvokeCallback(typeof(Action))] private static void __OnQuitInternalHandler(string playerId) { - Debug.Log("OnQuitInternalHandler from playeroom service called"); if (Players.TryGetValue(playerId, out Player player)) { player.InvokePlayerOnQuitCallback(); From 77c825fd30a4e4f7ebf1fee3dbb1292116dc5c33 Mon Sep 17 00:00:00 2001 From: aarijimam <35100854+aarijimam@users.noreply.github.com> Date: Thu, 21 Nov 2024 00:41:51 +0500 Subject: [PATCH 05/12] refactor: remove onquitcallbackwrapper from interface --- .../PlayroomKit/modules/Interfaces/IPlayerBase.cs | 1 - .../BrowserMode/BrowserMockPlayerService.cs | 5 ----- .../modules/Player/LocalPlayerService.cs | 6 +----- Assets/PlayroomKit/modules/Player/Player.cs | 13 ++++++++++++- Assets/PlayroomKit/modules/Player/PlayerService.cs | 2 +- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Assets/PlayroomKit/modules/Interfaces/IPlayerBase.cs b/Assets/PlayroomKit/modules/Interfaces/IPlayerBase.cs index a25ca73..9488b27 100644 --- a/Assets/PlayroomKit/modules/Interfaces/IPlayerBase.cs +++ b/Assets/PlayroomKit/modules/Interfaces/IPlayerBase.cs @@ -17,7 +17,6 @@ public interface IPlayerBase public T GetState(string key); public Profile GetProfile(); public Action OnQuit(Action callback); - public void InvokePlayerOnQuitCallback(string id); public void Kick(Action onKickCallBack = null); public void WaitForState(string stateKey, Action onStateSetCallback = null); diff --git a/Assets/PlayroomKit/modules/MockMode/BrowserMode/BrowserMockPlayerService.cs b/Assets/PlayroomKit/modules/MockMode/BrowserMode/BrowserMockPlayerService.cs index c706018..37c8914 100644 --- a/Assets/PlayroomKit/modules/MockMode/BrowserMode/BrowserMockPlayerService.cs +++ b/Assets/PlayroomKit/modules/MockMode/BrowserMode/BrowserMockPlayerService.cs @@ -115,11 +115,6 @@ public Action OnQuit(Action callback) return default; } - public void InvokePlayerOnQuitCallback(string id) - { - throw new NotImplementedException(); - } - public void Kick(Action onKickCallBack = null) { _ubb.CallJs("Kick", null, null, true, _id); diff --git a/Assets/PlayroomKit/modules/Player/LocalPlayerService.cs b/Assets/PlayroomKit/modules/Player/LocalPlayerService.cs index a5c9aff..b1820b7 100644 --- a/Assets/PlayroomKit/modules/Player/LocalPlayerService.cs +++ b/Assets/PlayroomKit/modules/Player/LocalPlayerService.cs @@ -100,11 +100,7 @@ public Action OnQuit(Action callback) Debug.Log($"OnQuit is not implemented for local"); return null; } - - public void InvokePlayerOnQuitCallback(string id) - { - throw new NotImplementedException(); - } + public void Kick(Action onKickCallBack = null) { diff --git a/Assets/PlayroomKit/modules/Player/Player.cs b/Assets/PlayroomKit/modules/Player/Player.cs index fb431d3..9aff8a1 100644 --- a/Assets/PlayroomKit/modules/Player/Player.cs +++ b/Assets/PlayroomKit/modules/Player/Player.cs @@ -139,7 +139,18 @@ public void WaitForState(string StateKey, Action onStateSetCallback = nu public void InvokePlayerOnQuitCallback() { - _playerService.InvokePlayerOnQuitCallback(id); + // Attempt the cast and throw an exception if it fails + if ((_playerService is PlayerService playerService)) + { + playerService.InvokePlayerOnQuitCallback(id); + } + else + { + Debug.LogWarning("InvokePlayerOnQuitCallback is only supported o build"); + } + + // Invoke the method on the casted object + } //DI END diff --git a/Assets/PlayroomKit/modules/Player/PlayerService.cs b/Assets/PlayroomKit/modules/Player/PlayerService.cs index c511cd9..0c3acca 100644 --- a/Assets/PlayroomKit/modules/Player/PlayerService.cs +++ b/Assets/PlayroomKit/modules/Player/PlayerService.cs @@ -140,7 +140,7 @@ void Unsubscribe() return Unsubscribe; } - public void InvokePlayerOnQuitCallback(string id) + internal void InvokePlayerOnQuitCallback(string id) { OnQuitWrapperCallback(id); } From 3f30db5e0efa0e2ed334bbc867925ff35c1f7137 Mon Sep 17 00:00:00 2001 From: momintlh <77355191+momintlh@users.noreply.github.com> Date: Thu, 21 Nov 2024 12:17:18 +0500 Subject: [PATCH 06/12] chore: removed unnecessary log --- Assets/PlayroomKit/modules/Helpers/CallbackManager.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Assets/PlayroomKit/modules/Helpers/CallbackManager.cs b/Assets/PlayroomKit/modules/Helpers/CallbackManager.cs index 019fa9d..bd6bf97 100644 --- a/Assets/PlayroomKit/modules/Helpers/CallbackManager.cs +++ b/Assets/PlayroomKit/modules/Helpers/CallbackManager.cs @@ -8,7 +8,7 @@ namespace Playroom public static class CallbackManager { private static Dictionary callbacks = new(); - + public static string RegisterCallback(Delegate callback, string key = null) { if (string.IsNullOrEmpty(key)) @@ -38,18 +38,13 @@ public static void InvokeCallback(string key, params string[] args) Debug.LogError( $"Callback with key {key} is of unsupported type or incorrect number of arguments: {args[0]}!"); } - else - { - Debug.LogWarning( - $"Callback with key {key} not found!, maybe register the callback or call the correct playroom function?"); - } } - + public static bool CheckCallback(string key) { return callbacks.TryGetValue(key, out Delegate callback); } - + private static string GenerateKey() { From 8a865e41cd9e94e48c81bf740a6592104e8c63e4 Mon Sep 17 00:00:00 2001 From: momintlh <77355191+momintlh@users.noreply.github.com> Date: Thu, 21 Nov 2024 12:17:54 +0500 Subject: [PATCH 07/12] chore: converted to switch-case forcing default mode to be local mode --- Assets/PlayroomKit/PlayroomKit.cs | 43 +++++++++++-------- .../modules/PlayroomkitDevManager.cs | 1 - 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/Assets/PlayroomKit/PlayroomKit.cs b/Assets/PlayroomKit/PlayroomKit.cs index 3421080..25dcd6c 100644 --- a/Assets/PlayroomKit/PlayroomKit.cs +++ b/Assets/PlayroomKit/PlayroomKit.cs @@ -29,18 +29,26 @@ public PlayroomKit() #if !UNITY_EDITOR _playroomService = new PlayroomBuildService(new PlayroomKitInterop()); _rpc = new RPC(this); - #elif UNITY_EDITOR - if (CurrentMockMode == MockModeSelector.Local) - { - _playroomService = new LocalMockPlayroomService(); - _rpc = new RPCLocal(); - } - else if (CurrentMockMode == MockModeSelector.Browser) + + switch (CurrentMockMode) { - _playroomService = new BrowserMockService(); - _rpc = new BrowserMockRPC(); + case MockModeSelector.Local: + Debug.Log("Starting playroom in Local Mock Mode"); + _playroomService = new LocalMockPlayroomService(); + _rpc = new RPCLocal(); + break; + + case MockModeSelector.Browser: + Debug.Log("Starting playroom in Browser Mock Mode"); + _playroomService = new BrowserMockService(); + _rpc = new BrowserMockRPC(); + break; + default: + _playroomService = new LocalMockPlayroomService(); + _rpc = new RPCLocal(); + break; } #endif } @@ -89,14 +97,15 @@ public Player GetPlayer(string playerId) else { #if UNITY_EDITOR - if (CurrentMockMode == MockModeSelector.Local) - { - player = new Player(playerId, new Player.LocalPlayerService(playerId)); - } - else if (CurrentMockMode == MockModeSelector.Browser) + switch (CurrentMockMode) { - player = new Player(playerId, - new BrowserMockPlayerService(UnityBrowserBridge.Instance, playerId)); + case MockModeSelector.Local: + player = new Player(playerId, new Player.LocalPlayerService(playerId)); + break; + case MockModeSelector.Browser: + player = new Player(playerId, + new BrowserMockPlayerService(UnityBrowserBridge.Instance, playerId)); + break; } #else player = new Player(playerId, new Player.PlayerService(playerId)); @@ -301,7 +310,5 @@ private void UnsubscribeOnQuit() { _playroomService.UnsubscribeOnQuit(); } - - // DI END } } \ No newline at end of file diff --git a/Assets/PlayroomKit/modules/PlayroomkitDevManager.cs b/Assets/PlayroomKit/modules/PlayroomkitDevManager.cs index e543f69..4750ae5 100644 --- a/Assets/PlayroomKit/modules/PlayroomkitDevManager.cs +++ b/Assets/PlayroomKit/modules/PlayroomkitDevManager.cs @@ -47,7 +47,6 @@ private void OnValidate() private void UpdateMockMode() { PlayroomKit.CurrentMockMode = mockMode; - } /// From ad1377c546681b81018444c8678ba1ea6b8950b5 Mon Sep 17 00:00:00 2001 From: momintlh <77355191+momintlh@users.noreply.github.com> Date: Thu, 21 Nov 2024 12:18:07 +0500 Subject: [PATCH 08/12] chore: updated log --- Assets/PlayroomKit/modules/Player/LocalPlayerService.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Assets/PlayroomKit/modules/Player/LocalPlayerService.cs b/Assets/PlayroomKit/modules/Player/LocalPlayerService.cs index b1820b7..6eb6108 100644 --- a/Assets/PlayroomKit/modules/Player/LocalPlayerService.cs +++ b/Assets/PlayroomKit/modules/Player/LocalPlayerService.cs @@ -97,10 +97,9 @@ public Profile GetProfile() public Action OnQuit(Action callback) { - Debug.Log($"OnQuit is not implemented for local"); + Debug.Log($"OnQuit is not supported in Local Mock Mode."); return null; } - public void Kick(Action onKickCallBack = null) { From aa608a43d414ae6cfd92cecc55ccad30e3525604 Mon Sep 17 00:00:00 2001 From: momintlh <77355191+momintlh@users.noreply.github.com> Date: Thu, 21 Nov 2024 12:29:07 +0500 Subject: [PATCH 09/12] chore: updated examples --- .../Examples/2d-platformer/2d-platformer.unity | 2 +- .../2d-platformer/scripts/GameManager2d.cs | 1 - .../scripts/GameManagerIsometric.cs | 14 +++++++++----- ProjectSettings/EditorBuildSettings.asset | 6 ------ 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Assets/PlayroomKit/Examples/2d-platformer/2d-platformer.unity b/Assets/PlayroomKit/Examples/2d-platformer/2d-platformer.unity index 34f52d2..160525e 100644 --- a/Assets/PlayroomKit/Examples/2d-platformer/2d-platformer.unity +++ b/Assets/PlayroomKit/Examples/2d-platformer/2d-platformer.unity @@ -313,7 +313,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 8987662522597341863, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3} propertyPath: mockMode - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 8987662522597341863, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3} propertyPath: insertCoinCaller diff --git a/Assets/PlayroomKit/Examples/2d-platformer/scripts/GameManager2d.cs b/Assets/PlayroomKit/Examples/2d-platformer/scripts/GameManager2d.cs index 0598053..a765c57 100644 --- a/Assets/PlayroomKit/Examples/2d-platformer/scripts/GameManager2d.cs +++ b/Assets/PlayroomKit/Examples/2d-platformer/scripts/GameManager2d.cs @@ -177,7 +177,6 @@ public void AddPlayer(PlayroomKit.Player player) /// /// Remove player from the game, called when the player leaves / closes the game. /// - [MonoPInvokeCallback(typeof(Action))] private static void RemovePlayer(string playerID) { if (PlayerDict.TryGetValue(playerID, out GameObject player)) diff --git a/Assets/PlayroomKit/Examples/discord-activity/scripts/GameManagerIsometric.cs b/Assets/PlayroomKit/Examples/discord-activity/scripts/GameManagerIsometric.cs index 2937a0a..5730087 100644 --- a/Assets/PlayroomKit/Examples/discord-activity/scripts/GameManagerIsometric.cs +++ b/Assets/PlayroomKit/Examples/discord-activity/scripts/GameManagerIsometric.cs @@ -38,11 +38,11 @@ private void Start() _playroomKit.OnPlayerJoin(AddPlayer); _playroomKit.RpcRegister("one", ((data, player) => { Debug.LogWarning("One Event Called"); })); - + _playroomKit.RpcRegister("two", ((data, player) => { Debug.LogWarning("two Event Called"); })); - - _playroomKit.RpcRegister("one", ((data, player) => { Debug.LogWarning("One Event Called With a diff callback"); })); - + + _playroomKit.RpcRegister("one", + ((data, player) => { Debug.LogWarning("One Event Called With a diff callback"); })); }, () => { Debug.Log("OnDisconnect callback"); }); } @@ -102,7 +102,7 @@ private void AddPlayer(PlayroomKit.Player player) playerJoined = true; player.OnQuit(RemovePlayer); } - + private static void RemovePlayer(string playerID) { if (PlayerDict.TryGetValue(playerID, out var player)) @@ -110,6 +110,10 @@ private static void RemovePlayer(string playerID) PlayerDict.Remove(playerID); playerGameObjects.Remove(player); Destroy(player); + + foreach (var (key, value) in PlayerDict) Debug.Log($"player {key} is still in the room"); + + Debug.Log(playerID + " has left the room!"); } else { diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index 8e9f6cf..d521744 100644 --- a/ProjectSettings/EditorBuildSettings.asset +++ b/ProjectSettings/EditorBuildSettings.asset @@ -5,18 +5,12 @@ EditorBuildSettings: m_ObjectHideFlags: 0 serializedVersion: 2 m_Scenes: - - enabled: 0 - path: Assets/Scenes/Lobby.unity - guid: 27215d4ccddeb6d49af03911dd97f9b1 - enabled: 0 path: Assets/PlayroomKit/Examples/2d-platformer/2d-platformer.unity guid: cf82eec4c654cf44b89cec2a91afebd5 - enabled: 1 path: Assets/PlayroomKit/Examples/discord-activity/discord-activity.unity guid: bb7ef8e4a67f3fb46b78e5d95a6858a7 - - enabled: 0 - path: Assets/Scenes/topdown.unity - guid: 490247da3cf48784ab657a183ba059d1 - enabled: 0 path: Assets/PlayroomKit/Examples/package-showcase/showcase.unity guid: 85c9af77ae006408ab24500b953a9035 From 7f6d0a1297c664b888822e7faef82f5a955bc7a2 Mon Sep 17 00:00:00 2001 From: aarijimam <35100854+aarijimam@users.noreply.github.com> Date: Thu, 21 Nov 2024 23:53:46 +0500 Subject: [PATCH 10/12] fix: remove check for rpc call --- .../Examples/package-showcase/scripts/GameManagerDemo.cs | 5 ++++- Assets/PlayroomKit/modules/RPC/RPC.cs | 8 +------- ProjectSettings/EditorBuildSettings.asset | 4 ++-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Assets/PlayroomKit/Examples/package-showcase/scripts/GameManagerDemo.cs b/Assets/PlayroomKit/Examples/package-showcase/scripts/GameManagerDemo.cs index bcc79ea..161fcf1 100644 --- a/Assets/PlayroomKit/Examples/package-showcase/scripts/GameManagerDemo.cs +++ b/Assets/PlayroomKit/Examples/package-showcase/scripts/GameManagerDemo.cs @@ -275,7 +275,10 @@ public void ShootLaser() var index = players.IndexOf(myPlayer); score = playerGameObjects[index].GetComponent().ShootLaser(score); _playroomKit.RpcCall("ShootLaser", score, PlayroomKit.RpcMode.ALL, - () => { logsText.text = "ShootLaser RPC Called"; }); + () => + { + Debug.Log("ShootLaser RPC Called"); + logsText.text = "ShootLaser RPC Called"; }); } public void GetRoomCode() diff --git a/Assets/PlayroomKit/modules/RPC/RPC.cs b/Assets/PlayroomKit/modules/RPC/RPC.cs index 051d43a..62dc2c3 100644 --- a/Assets/PlayroomKit/modules/RPC/RPC.cs +++ b/Assets/PlayroomKit/modules/RPC/RPC.cs @@ -42,8 +42,6 @@ public void RpcRegister(string name, Action rpcRegisterCallback, public void RpcCall(string name, object data, RpcMode mode, Action callbackOnResponse = null) { - if (CallbackManager.CheckCallback(name)) - { string jsonData = ConvertToJson(data); if (OnResponseCallbacks.ContainsKey(name)) @@ -74,11 +72,7 @@ public void RpcCall(string name, object data, RpcMode mode, Action callbackOnRes */ _playroomKit.SetState("rpcCalledEventName", jsonString, reliable: true); _interop.RpcCallWrapper(name, jsonData, mode, InvokeOnResponseCallback); - } - else - { - Debug.LogError("RPC is not registered!, register RPC first."); - } + } public void RpcCall(string name, object data, Action callbackOnResponse = null) diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index d521744..0273124 100644 --- a/ProjectSettings/EditorBuildSettings.asset +++ b/ProjectSettings/EditorBuildSettings.asset @@ -8,10 +8,10 @@ EditorBuildSettings: - enabled: 0 path: Assets/PlayroomKit/Examples/2d-platformer/2d-platformer.unity guid: cf82eec4c654cf44b89cec2a91afebd5 - - enabled: 1 + - enabled: 0 path: Assets/PlayroomKit/Examples/discord-activity/discord-activity.unity guid: bb7ef8e4a67f3fb46b78e5d95a6858a7 - - enabled: 0 + - enabled: 1 path: Assets/PlayroomKit/Examples/package-showcase/showcase.unity guid: 85c9af77ae006408ab24500b953a9035 m_configObjects: {} From 5c6ec3eff4cd0c4b456415a71a2c463fb928689e Mon Sep 17 00:00:00 2001 From: aarijimam <35100854+aarijimam@users.noreply.github.com> Date: Thu, 21 Nov 2024 23:54:42 +0500 Subject: [PATCH 11/12] refactor: remove unused check callback function --- Assets/PlayroomKit/modules/Helpers/CallbackManager.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Assets/PlayroomKit/modules/Helpers/CallbackManager.cs b/Assets/PlayroomKit/modules/Helpers/CallbackManager.cs index bd6bf97..2adebdc 100644 --- a/Assets/PlayroomKit/modules/Helpers/CallbackManager.cs +++ b/Assets/PlayroomKit/modules/Helpers/CallbackManager.cs @@ -40,12 +40,6 @@ public static void InvokeCallback(string key, params string[] args) } } - public static bool CheckCallback(string key) - { - return callbacks.TryGetValue(key, out Delegate callback); - } - - private static string GenerateKey() { return Guid.NewGuid().ToString(); From 522b61b4b94f9b1facb50a496640d1c91e06791c Mon Sep 17 00:00:00 2001 From: momintlh <77355191+momintlh@users.noreply.github.com> Date: Fri, 22 Nov 2024 12:51:09 +0500 Subject: [PATCH 12/12] feat: scene saved --- Assets/PlayroomKit/Examples/package-showcase/showcase.unity | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Assets/PlayroomKit/Examples/package-showcase/showcase.unity b/Assets/PlayroomKit/Examples/package-showcase/showcase.unity index c377cf5..8d67717 100644 --- a/Assets/PlayroomKit/Examples/package-showcase/showcase.unity +++ b/Assets/PlayroomKit/Examples/package-showcase/showcase.unity @@ -7767,6 +7767,10 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 8899696337967424923, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3} + propertyPath: httpServerPort + value: 6510 + objectReference: {fileID: 0} - target: {fileID: 8899696337967424923, guid: 1b30fa3a265114a45a7e23165a20aecc, type: 3} propertyPath: webDriverDirectory value: Assets\