Exemplo n.º 1
0
        public static string GetFieldKeyTableText(StringBuilder builder, IFieldValueTable table)
        {
            if (table.IsNullTable())
            {
                return(string.Empty);
            }
            builder.Clear();
            ushort layer     = (ushort)(table.GetLayer() + 1);
            string tabString = GetTabString(layer);

            FieldValueTableInfo[] array = table.GetFieldValueTableInfo();
            for (int index = 0; index < array.Length; index++)
            {
                FieldValueTableInfo keyValue = array[index];
                object value = table.GetFieldValueTableValue(keyValue.key);
                if (keyValue.type != ValueType.Table)
                {
                    if (value != null)
                    {
                        SetBaseValueTableString(builder, keyValue, tabString, value);
                    }
                    continue;
                }
                ITable valueTable = value as ITable;
                if (!valueTable.IsNullTable())
                {
                    builder.Append(valueTable.ToString());
                }
            }
            return(GetTableText(table, builder.ToString()));
        }
Exemplo n.º 2
0
 private static void SetBaseValueTableString(StringBuilder builder, FieldValueTableInfo keyValue, string tabString, object value)
 {
     builder.Append(tabString);
     builder.Append(keyValue.key);
     builder.Append(LuaFormat.SpaceSymbol);
     builder.Append(LuaFormat.EqualSymbol);
     builder.Append(LuaFormat.SpaceSymbol);
     if (keyValue.type == ValueType.String)
     {
         builder.Append(LuaFormat.QuotationPair.start);
     }
     builder.Append(value);
     if (keyValue.type == ValueType.String)
     {
         builder.Append(LuaFormat.QuotationPair.end);
     }
     builder.Append(LuaFormat.CommaSymbol);
     builder.Append(LuaFormat.LineSymbol);
 }
Exemplo n.º 3
0
        private static void SetFixedFieldTableValue(string luaText, ref int valueIndex, FieldValueTableInfo keyValue, ref IFieldValueTable table)
        {
            object value = default;

            switch (keyValue.type)
            {
            case ValueType.Int:
                value = GetLuaTextInt(luaText, ref valueIndex);
                break;

            case ValueType.Number:
                value = GetLuaTextNumber(luaText, ref valueIndex);
                break;

            case ValueType.String:
                value = GetLuaTextString(luaText, ref valueIndex);
                break;

            case ValueType.Reference:
                value = GetLuaTextReferenceString(luaText, ref valueIndex);
                break;;

            case ValueType.Table:
                Type valueType = LuaTable.GetFieldValueTableValueType(table, keyValue.key);
                if (valueType == null)
                {
                    return;
                }
                SetTypeCache(valueType);
                MethodInfo readLuaFileTableMethod = m_readLuaFileTableMethod.MakeGenericMethod(GetTypeCache());
                SetThreeArgMethodArg(luaText, valueIndex);
                object[] args = GetThreeArgMethodArg();
                value      = readLuaFileTableMethod.Invoke(null, args);
                valueIndex = (int)args[1];
                break;
            }
            table.SetFieldValueTableValue(keyValue.key, value);
        }