private static void Write(Script script, ScorpioWriter writer, ScriptTable table, string tableName) { ScriptArray layout = (ScriptArray)script.GetValue(tableName); int sign = 0; for (int i = 0; i < layout.Count(); ++i) { ScriptObject config = layout.GetValue(i); if (table != null && table.HasValue(config.GetValue(Name).ObjectValue)) { sign = ScorpioUtil.AddSign(sign, ScorpioUtil.ToInt32(config.GetValue(Index).ObjectValue)); } } writer.WriteInt32(sign); for (int i = 0; i < layout.Count(); ++i) { ScriptObject config = layout.GetValue(i); string name = (string)config.GetValue(Name).ObjectValue; if (table != null && table.HasValue(name)) { string type = (string)config.GetValue(Type).ObjectValue; bool array = (bool)config.GetValue(Array).ObjectValue; if (array) { ScriptArray arr = table.GetValue(name) as ScriptArray; writer.WriteInt32(arr.Count()); for (int j = 0; j < arr.Count(); ++j) { WriteObject(script, writer, type, arr.GetValue(j)); } } else { WriteObject(script, writer, type, table.GetValue(name)); } } } }