Esempio n. 1
0
        internal static void OnServerObjectState(QNetMessage message, QNetMessageReader reader, ref bool disallowRecycle)
        {
            if (!QNetWorldSerializer.WorldIsSerialized)
            {
                return; // system can't receive query data while initializing,
            }
            var objectIdentity = reader.ReadInt16();
            var qNetObject     = QNetObjectBehaviour.GetObject(objectIdentity);

            if (qNetObject == null)
            {
                if (QNetManager.PrintNetworkWarnings)
                {
                    JEMLogger.LogWarning($"Local machine received QNetEntity state update message but object of identity {objectIdentity} not exists in local world.");
                }
                return;
            }

            qNetObject.DeSerializeServerState(reader);
        }
Esempio n. 2
0
        public static void OnClientEntityQuery(QNetMessage message, QNetMessageReader reader, ref bool disallowRecycle)
        {
            if (!QNetWorldSerializer.WorldIsSerialized)
            {
                return; // system can't receive entity query data while initializing,
            }
            var objectIdentity = reader.ReadInt16();
            var qNetObject     = QNetObjectBehaviour.GetObject(objectIdentity);

            if (qNetObject == null)
            {
                if (QNetManager.PrintNetworkWarnings)
                {
                    JEMLogger.LogWarning(
                        $"Local machine received QNetEntity query message but object of identity {objectIdentity} not exists in local world.");
                }
                return;
            }

            var entity = qNetObject.GetComponent <QNetEntity>();

            if (entity == null)
            {
                throw new NullReferenceException(
                          $"QNetEntity query target exists but does not have {nameof(QNetEntity)} based script.");
            }

            if (message.IsClientMessage)
            {
                QNetSimulation.ReceivedServerFrame = reader.ReadUInt32();
                QNetSimulation.AdjustServerFrames  = QNetSimulation.ReceivedServerFrame > QNetTime.ServerFrame;
            }

            var index = reader.ReadByte();

            entity.InvokeNetworkMessage(index, reader);
        }