public void ReadData(byte[] data)
        {
            NetworkWriter writer = new NetworkWriter(data);

            Time = writer.ReadSingle();

            int count = writer.ReadInt16();

            for (int i = 0; i < count; i++)
            {
                InputTypeBase input  = (InputTypeBase)Activator.CreateInstance(m_ExpectedInputs[i]);
                int           bCount = writer.ReadInt16();
                input.Deserialize(writer.ReadBytes(bCount));
                Inputs.Add(input);
            }

            int simCount = writer.ReadInt16();

            for (int i = 0; i < simCount; i++)
            {
                float     time  = writer.ReadSingle();
                InputData input = new InputData(time)
                {
                    Inputs = this.Inputs
                };
                Similar.Add(input);
            }
        }
        private static void OnReceiveEntityState(NetworkWriter writer)
        {
            int             instanceID = writer.ReadInt16();
            NetworkIdentity identity   = NetworkIdentityManager.Instance.Get(instanceID);

            if (identity != null)
            {
                ServerEntity ent = identity.GetComponent <ServerEntity>();
                if (ent != null)
                {
                    ent.ReceiveState(writer);
                }
            }
        }
        /// <summary>
        /// Deserialize input data.
        /// </summary>
        /// <param name="data"></param>
        public void Deserialize(byte[] data)
        {
            if (m_ReadData == null)
            {
                m_ReadData = new Queue <InputData>();
            }

            Type[] expectedTypes = GetExpectedInputTypes();

            NetworkWriter writer = new NetworkWriter(data);

            int count = writer.ReadInt16();

            for (int i = 0; i < count; i++)
            {
                int bCount = writer.ReadInt16();

                byte[] inputData = writer.ReadBytes(bCount);

                InputData input = new InputData();

                input.SetExpected(expectedTypes);

                input.ReadData(inputData);

                m_ReadData.Enqueue(input);

                for (int j = 0; j < input.Similar.Count; j++)
                {
                    InputData similar = input.Similar[j];

                    m_ReadData.Enqueue(similar);
                }

                input.Similar.Clear();
            }
        }
        private static AuthoritativeInput <TInput, TOutput> GetInputComponentFromMessage(NetworkWriter writer, out byte[] data)
        {
            short conn = writer.ReadInt16();

            NetworkPlayerObject player = NetworkController.Instance.Scene.GetPlayer(conn);

            data = null;

            if (player == null)
            {
                return(null);
            }

            GameObject playerObj = player.GameObject;

            data = writer.ReadBytes();

            return(playerObj.GetComponent <AuthoritativeInput <TInput, TOutput> >());
        }
Example #5
0
        public override void OnDeserialize(byte[] data)
        {
            NetworkWriter writer = new NetworkWriter(data);

            Stack = writer.ReadInt16();
        }