Mirror icon indicating copy to clipboard operation
Mirror copied to clipboard

AllPlayersReady callback also when back to false

Open Chefty opened this issue 5 years ago • 0 comments

Please explain the suggested feature in detail. As mentioned in the summary above OnRoomServerPlayerReady() method: "By implementing this callback you can customize what happens when all the players in the room are ready, such as adding a countdown or a confirmation for a group leader." I'm actually adding a countdown to my room scene when all players are ready, but in case a player "unready" himself, there is no callback to stop any behaviour such as loading game scene. It's a one way callback without a turning back option.

How exactly does this keep you from releasing your game right now? I want to implement a "all players has to be ready to start countdown" in the room scene. Right now when all players are ready, the countdown start BUT If any of those players made a mistake (e.g. in his "character settings"): he cannot undo it, the game will start anyway.

Can you suggest a possible solution? Not sure it is the best option to implement this feature but it works: In the script NetworkRoomManager.cs I changed the following method:

internal void ReadyStatusChanged()
        {
            int CurrentPlayers = 0;
            int ReadyPlayers = 0;

            foreach (NetworkRoomPlayer item in roomSlots)
            {
                if (item != null)
                {
                    CurrentPlayers++;
                    if (item.readyToBegin)
                        ReadyPlayers++;
                }
            }

            if (CurrentPlayers == ReadyPlayers)
                CheckReadyToBegin();
            else if (CurrentPlayers - 1 == ReadyPlayers && allPlayersReady == true) // If previously all players were ready and one cancelled
            {
                allPlayersReady = false;
                OnRoomServerPlayersReady();
            }
            else
                allPlayersReady = false;
        }

I added an extra check in the end in case all players were previously ready but it happened to changed since then. I hope my feature request is not too irrelevant, I think it can be useful for some dev out there.

Chefty avatar May 14 '20 14:05 Chefty