コード例 #1
0
 private void NotifyAllNodesSynched()
 {
     // Called from client the first time they complete their node synch
     MDLog.Trace(LOG_CAT, $"Peer [{Multiplayer.GetRpcSenderId()}] has completed node synchronization");
     if (!PeerSynchInfo.ContainsKey(Multiplayer.GetRpcSenderId()))
     {
         PeerSynchInfo[Multiplayer.GetRpcSenderId()].CompletedNodeSynch = true;
     }
 }
コード例 #2
0
        private void ClientSynchStatus(int SynchedNodes)
        {
            // Synch in progress
            MDLog.Debug(LOG_CAT,
                        $"Peer [{Multiplayer.GetRpcSenderId()}] has synched {SynchedNodes} out of {NodeList.Count} nodes");

            // Send status update to all players so they can update UI
            UpdateSynchStatusOnAllClients(Multiplayer.GetRpcSenderId(), (float)SynchedNodes / NodeList.Count);

            // Update our own UI
            OnPlayerSynchStatusUpdateEvent(Multiplayer.GetRpcSenderId(), (float)SynchedNodes / NodeList.Count);
        }
コード例 #3
0
    public void NetRequestRespawn()
    {
        if (!Self.Multiplayer.IsNetworkServer())
        {
            return;
        }

        if (DeathmatchMode)
        {
            ChooseSpawnPointAndDoSpawn(Multiplayer.GetRpcSenderId());
        }
    }
コード例 #4
0
        private void ClientSynchDone()
        {
            // Great this client is done
            MDLog.Debug(LOG_CAT, $"Peer [{Multiplayer.GetRpcSenderId()}] completed synch");
            if (PeerSynchInfo.ContainsKey(Multiplayer.GetRpcSenderId()))
            {
                PeerSynchInfo[Multiplayer.GetRpcSenderId()].CompletedSynch = true;
            }

            // Send status update to all players so they can update UI
            UpdateSynchStatusOnAllClients(Multiplayer.GetRpcSenderId(), 1f);

            // Update our own UI
            OnPlayerSynchStatusUpdateEvent(Multiplayer.GetRpcSenderId(), 1f);
        }
コード例 #5
0
    public void RegisterNickname(string ClientNick)
    {
        char[] NickArray = ClientNick.ToCharArray();
        NickArray  = Array.FindAll(NickArray, car => char.IsLetter(car) || car == '_');
        ClientNick = new string(NickArray);

        if (ClientNick.Length == 0)
        {
            ((NetworkedMultiplayerENet)Multiplayer.NetworkPeer).DisconnectPeer(Multiplayer.GetRpcSenderId());
        }

        string Identifier = $"{ClientNick}#{Multiplayer.GetRpcSenderId()}";

        Nicknames.Add(Multiplayer.GetRpcSenderId(), Identifier);
        Log("Registered player ", Identifier);
    }
コード例 #6
0
        private void ClockedCall(uint Tick, ClockedRemoteCall.TypeOfCall Type, string NodePath, string Method,
                                 MDRemoteMode Mode, params object[] Parameters)
        {
            Node Target = GetNodeOrNull(NodePath);

            if (Target == null)
            {
                MDLog.Warn(LOG_CAT, $"Could not find target [{NodePath}] for ClockedRpcCall.");
                return;
            }
            MDLog.Trace(LOG_CAT, $"Got clocked call {Method} on {NodePath} with parameters ({MDStatics.GetParametersAsString(Parameters)})");
            ClockedRemoteCall RemoteCall = new ClockedRemoteCall(Tick, Type, WeakRef(Target), Method, Mode, Multiplayer.GetRpcSenderId(), Parameters);

            // Check if we should already invoke this (if the time has already passed)
            if (!RemoteCall.Invoke(GameClock.GetRemoteTick()))
            {
                ClockedRemoteCallList.Add(RemoteCall);
            }
        }
コード例 #7
0
 public void NetDamage(int Damage)
 {
     Health -= Damage;
     CheckDie(Multiplayer.GetRpcSenderId());
 }
コード例 #8
0
 private void ResponseTicksMsec(uint ClientTicksMsec, uint ServerTimeOfRequest, int RequestNumber)
 {
     MDLog.Debug(LOG_CAT,
                 $"Msec response number {RequestNumber} from peer [{Multiplayer.GetRpcSenderId()}] is {ClientTicksMsec} local Msec is {OS.GetTicksMsec()}");
     PeerSynchInfo[Multiplayer.GetRpcSenderId()].ProcessMSecResponse(ClientTicksMsec, ServerTimeOfRequest, RequestNumber);
 }
コード例 #9
0
        private void PingResponse(uint ServerTimeOfRequest)
        {
            int ping = (int)(OS.GetTicksMsec() - ServerTimeOfRequest);

            PeerSynchInfo[Multiplayer.GetRpcSenderId()].PushPlayerPingToQueue(ping);
        }
コード例 #10
0
 private void RequestPing(uint ServerTimeOfRequest)
 {
     // Respond
     RpcId(Multiplayer.GetRpcSenderId(), nameof(PingResponse), ServerTimeOfRequest);
     MDLog.Trace(LOG_CAT, "Responded to server request for ping");
 }