public static void SaveToPssg(PssgBinaryWriter writer) { // Update Ids to make sequential, and Unique int currentId = 0; int currentAttrId = 0; // Minimizing the attributes to unique names only seems to crash the game //Dictionary<string, int> unique = new Dictionary<string, int>(); foreach (KeyValuePair <string, Node> entry in entries) { if (entry.Value.Id > 0) { entry.Value.Id = ++currentId; writer.Write(entry.Value.Id); writer.WritePSSGString((string)entry.Key); int pos = (int)writer.BaseStream.Position; int attributeCount = 0; writer.Write(0); // attributeCount foreach (Attribute attrEntry in entry.Value.Attributes) { if (attrEntry.Id > 0) { attrEntry.Id = ++currentAttrId; writer.Write(attrEntry.Id); writer.WritePSSGString(attrEntry.Name); ++attributeCount; } } writer.Seek(pos, SeekOrigin.Begin); writer.Write(attributeCount); writer.Seek(0, SeekOrigin.End); } } }
public static void SaveToPssg(PssgBinaryWriter writer) { // Update Ids to make sequential, and Unique int currentId = 0; int currentAttrId = 0; // Minimizing the attributes to unique names only seems to crash the game //Dictionary<string, int> unique = new Dictionary<string, int>(); foreach (KeyValuePair<string, Node> entry in entries) { if (entry.Value.Id > 0) { entry.Value.Id = ++currentId; writer.Write(entry.Value.Id); writer.WritePSSGString((string)entry.Key); int pos = (int)writer.BaseStream.Position; int attributeCount = 0; writer.Write(0); // attributeCount foreach (Attribute attrEntry in entry.Value.Attributes) { if (attrEntry.Id > 0) { attrEntry.Id = ++currentAttrId; writer.Write(attrEntry.Id); writer.WritePSSGString(attrEntry.Name); ++attributeCount; } } writer.Seek(pos, SeekOrigin.Begin); writer.Write(attributeCount); writer.Seek(0, SeekOrigin.End); } } }