Esempio n. 1
0
        public static State GetStateFromBytes(Type type, ByteQueue bytes, int tick)
        {
            if (tick == 0)
            {
                return(bytes.GetIToBytes <State>(type));
            }

            var currentTick = 0;

            while (bytes.Count > 0)
            {
                if (bytes.StartsWith(DELIMITER))
                {
                    currentTick++;
                }

                if (currentTick == tick)
                {
                    bytes.GetBytes(DELIMITER.Length);
                    return(bytes.GetIToBytes <State>(type));
                }

                bytes.GetByte();
            }
            return(null);
        }
Esempio n. 2
0
        public static int GetCountFromBytes(ByteQueue bytes)
        {
            if (bytes.Count == 0)
            {
                return(0);
            }

            var count = 1;

            while (bytes.Count > 0)
            {
                if (bytes.StartsWith(DELIMITER))
                {
                    count++;
                }

                bytes.GetByte();
            }
            return(count);
        }