Пример #1
0
        public void SyncState()
        {
            if (!hasAuthority)
            {
                return;
            }

            // Send update to all clients
            if (isServer)
            {
                UMsgSyncState msg = new UMsgSyncState(this);

                if (isClient)
                {
                    UNetworkManager.singleton.SendMessageToAllClientsExceptLocal(msg);
                }
                else
                {
                    UNetworkManager.singleton.SendMessageToAllClients(msg);
                }
            }

            if (isClient && !isServer)
            {
                UMsgSyncState msg = new UMsgSyncState(this);
                UNetworkManager.singleton.SendMessageToServer(msg);
            }
        }
Пример #2
0
        internal void HandleBehaviourSyncMessage(UMsgSyncState msg)
        {
            UNetworkBehaviour beh = cachedBehaviours[msg.netComponentId];

            NetBuffer reader = new NetBuffer();

            reader.Data = msg.data;

            beh.Deserialize(reader, false);
        }
Пример #3
0
        private void ClientHandleUMsgSyncState(Message m)
        {
            if (isServer)
            {
                return;
            }

            UMsgSyncState msg = m as UMsgSyncState;

            UNetworkIdentity iden = networkObjects[msg.targetNetID];

            iden.HandleBehaviourSyncMessage(msg);
        }
Пример #4
0
        private void ServerHandleUMsgSyncState(Message m)
        {
            UMsgSyncState msg = m as UMsgSyncState;

            UNetworkIdentity iden;

            if (networkObjects.TryGetValue(msg.targetNetID, out iden))
            {
                iden.HandleBehaviourSyncMessage(msg);

                // Resend this update to other clients except local if present
                serverObject.SendToAllExceptOneClient(msg.sourceClient, msg, NetDeliveryMethod.ReliableOrdered);
            }
        }
Пример #5
0
        public void ForceSyncServerStateToClients()
        {
            if (isServer)
            {
                UMsgSyncState msg = new UMsgSyncState(this);

                if (isClient)
                {
                    UNetworkManager.singleton.SendMessageToAllClientsExceptLocal(msg);
                }
                else
                {
                    UNetworkManager.singleton.SendMessageToAllClients(msg);
                }
            }
        }