Exemple #1
0
 public static T[] SanitizeTypeArray <T>(DataObjectArray array)
 {
     T[] returnArray = new T[array.Count];
     for (int i = 0; i < array.Count; i++)
     {
         returnArray[i] = SanitizeType <T>(array[i]);
     }
     return(returnArray);
 }
Exemple #2
0
        public static T[] ToArray <T>(this DataObjectArray array) where T : class, IData
        {
            T[] result = new T[array.Count];
            for (int i = 0; i < array.Count; i++)
            {
                result[i] = array[i] as T;
            }

            return(result);
        }
Exemple #3
0
        public static Vector4[] VectorArrayFromDataObjectArray(DataObjectArray array)
        {
            Vector4[] vectors = new Vector4[array.Count];
            for (int i = 0; i < array.Count; i++)
            {
                if (array[i] is DataObjectArray rawRow)
                {
                    DataObjectFlexible[] row = SanitizeTypeArray <DataObjectFlexible>(rawRow);
                    vectors[i] = new Vector4(row[0].GetAsFloat(), row[1].GetAsFloat(), row[2].GetAsFloat(), row[3].GetAsFloat());
                }
                else
                {
                    Debug.LogError("There was an incorrect element in the array");
                    vectors[i] = Vector4.zero;
                }
            }

            return(vectors);
        }
        public DataObjectArray Parse()
        {
            DataObjectArray array = new DataObjectArray();

            DiscardToken(TokenType.ArrayStart);

            Token next = _peekableStream.Peek();

            while (next.Type != TokenType.ArrayEnd)
            {
                if (next.Type == TokenType.ArrayStart)
                {
                    array.Add(Parse());
                }
                else
                {
                    Debug.Log(_peekableStream.Peek().Value);
                    array.Add(new DataObjectFlexible(_peekableStream.Pop().Value));
                }

                next = _peekableStream.Peek();

                if (next.Type != TokenType.ArrayEnd)
                {
                    DiscardToken(TokenType.SequenceSeperator);
                }
                else if (next.Type == TokenType.ArrayEnd)
                {
                    break;
                }

                next = _peekableStream.Peek();
            }

            DiscardToken(TokenType.ArrayEnd);
            return(array);
        }