Esempio n. 1
0
        // Objects are despawned when a runner is shutdown <<-- 왜 안되지
        public void OnShutdown(NetworkRunner runner, ShutdownReason shutdownReason)
        {
            Util.Log($"OnShutDown {shutdownReason}");
            SetConnectionStatus(Enum.ConnectionStatus.Disconnected);

            (string status, string msg) = ShutdownReasonToHuman(shutdownReason);
            //TODO : UI에 뿌려줄거라면! status와 msg 이용하면 됨.

            for (int i = RoomPlayer.Players.Count - 1; i >= 0; i--)
            {
                RoomPlayer player = RoomPlayer.Players[i];
                StartCoroutine(player.Co_RemovePlayer());
            }
            for (int i = PlayerModel.Players.Count - 1; i >= 0; i--)
            {
                PlayerModel player = PlayerModel.Players[i];
                if (!player || !player.Object || player.Object.InputAuthority)
                {
                    continue;
                }
                StartCoroutine(player.Co_RemovePlayer());
            }

            if (_runner)
            {
                Destroy(_runner.gameObject);
            }

            _pool.ClearPools();

            _runner = null;
        }