예제 #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);
        }
예제 #2
0
 public void FromBytes(ByteQueue bytes)
 {
     states.Clear();
     states.Add(bytes.GetIToBytes <T>(typeof(T)));
     while (bytes.StartsWith(DELIMITER))
     {
         bytes.GetBytes(DELIMITER.Length);
         states.Add(bytes.GetIToBytes <T>(typeof(T)));
     }
 }
예제 #3
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);
        }