private void OnPlayerJoinedEvent(int PeerId)
        {
            // Check if this is our own join message or if we are a client
            if (PeerId == MDStatics.GetPeerId() || MDStatics.IsClient())
            {
                return;
            }

            MDGameSynchPeerInfo PeerInfo = new MDGameSynchPeerInfo(this, PeerId);

            PeerSynchInfo.Add(PeerId, PeerInfo);

            if (IsPauseOnJoin())
            {
                PauseGame();
                foreach (int peerid in GameSession.GetAllPeerIds().Where(peerid => peerid != MDStatics.GetServerId() && PeerId != peerid))
                {
                    // Don't do this for the connecting peer or the server
                    RpcId(peerid, nameof(PauseGame));
                }
            }

            // Start synch check timer
            Timer timer = (Timer)GetNodeOrNull(ALL_PLAYERS_SYNCHED_TIMER_NAME);

            if (timer == null)
            {
                timer = this.CreateUnpausableTimer(ALL_PLAYERS_SYNCHED_TIMER_NAME, false, SYNCH_TIMER_CHECK_INTERVAL, true,
                                                   this, nameof(CheckAllClientsSynched));
                timer.Start();
            }
        }
        private void UnpauseAtTickMsec(uint UnpauseTime, uint GameTickToUnpauseAt)
        {
            float waitTime = (UnpauseTime - OS.GetTicksMsec()) / 1000f;

            MDLog.Trace(LOG_CAT, $"Unpausing game in {waitTime}");
            Timer timer = this.CreateUnpausableTimer(RESUME_TIMER_NAME, true, waitTime, true, this,
                                                     nameof(OnUnpauseTimerTimeout));

            timer.Start();
            OnSynchCompleteEvent(waitTime);
            if (GameClock != null && MDStatics.IsClient())
            {
                GameClock.SetCurrentTick(GameTickToUnpauseAt);
            }
        }
        private void OnPlayerInitializedEvent(int PeerId)
        {
            // Check if this is our own join message or if we are a client
            if (PeerId == MDStatics.GetPeerId() || MDStatics.IsClient())
            {
                return;
            }

            OnSynchStartedEvent(IsPauseOnJoin());
            foreach (int peerid in GameSession.GetAllPeerIds().Where(peerid => peerid != MDStatics.GetServerId()))
            {
                // Synch just started so set everyone to 0%
                OnPlayerSynchStatusUpdateEvent(peerid, 0f);
                RpcId(peerid, nameof(RpcReceiveNodeCount), NodeList.Count);
            }
        }
 ///<summary>Returns true if we are the client on a network</summary>
 public static bool IsClient(this Node Instance)
 {
     return(MDStatics.IsClient());
 }
 ///<summary>Returns the highest ping we got to any player</summary>
 public int GetMaxPlayerPing()
 {
     return(MDStatics.IsClient() ? MaxPing : PeerSynchInfo.Select(p => p.Value.Ping).Max());
 }