public GMObject(ProjectReader reader, GMProject proj) { Name = reader.ReadString(); LastChanged = reader.ReadDate(); Version = reader.ReadInt32(); if (Version != 430) { throw new InvalidDataException("Invalid Object version, got " + Version); } Sprite = null; int spr = reader.ReadInt32(); if (spr > -1) { Sprite = proj.Sprites[spr]; } Solid = reader.ReadBoolean(); Visible = reader.ReadBoolean(); Depth = reader.ReadInt32(); Persistent = reader.ReadBoolean(); Parent = null; _ParentInd = reader.ReadInt32(); Mask = null; int mask = reader.ReadInt32(); if (mask > -1) { Mask = proj.Sprites[mask]; } int ev_count = reader.ReadInt32(); Events = new List <List <GMEvent> >(ev_count + 1); for (int i = 0; i <= ev_count; i++) { var l = new List <GMEvent>(); bool done = false; while (!done) { int first = reader.ReadInt32(); if (first != -1) { var ev = new GMEvent(reader); ev.Key = first; l.Add(ev); } else { done = true; } } Events.Add(l); } reader.Dispose(); }
public TimelineMoment(ProjectReader reader) { Point = reader.ReadInt32(); Event = new GMEvent(reader); }
/// <summary> /// Reads objects from GM file /// </summary> private GMList<GMObject> ReadObjects() { // Get version. int version = ReadInt(); // Check version. if (version != 400 && version != 800) throw new Exception("Unsupported Pre-Object object version."); // The number of objects. GMList<GMObject> objects = new GMList<GMObject>(); // Amount of object ids. int num = ReadInt(); // Iterate through objects for (int i = 0; i < num; i++) { // If version is 8.0, start inflate. if (version == 800) Decompress(); // If the object at index does not exists, continue. if (ReadBool() == false) { objects.LastId++; EndDecompress(); continue; } // Create a new script object. GMObject obj = new GMObject(); // Set script id. obj.Id = i; // Read script data. obj.Name = ReadString(); // If version is 8.0, get last changed. if (version == 800) obj.LastChanged = ReadDouble(); // Get version. int version2 = ReadInt(); // Check version. if (version2 != 430) throw new Exception("Unsupported Object object version."); // Read object data. obj.SpriteId = ReadInt(); obj.Solid = ReadBool(); obj.Visible = ReadBool(); obj.Depth = ReadInt(); obj.Persistent = ReadBool(); obj.Parent = ReadInt(); obj.Mask = ReadInt(); // Skip data. ReadBytes(4); // The amount of main event types. int amount = 11; // If version 8.0, there are 12 main event types. if (version == 800) amount = 12; // Iterate through events. for (int j = 0; j < amount; j++) { // Not done processing. bool done = false; // While not done processing events. while (!done) { // Check for event int eventNum = ReadInt(); // If the event exists if (eventNum != -1) { // Create new event. GMEvent ev = new GMEvent(); // Set type of event. ev.MainType = (EventType)(j); // If a collision type of event set other object id. if (ev.MainType == EventType.Collision) ev.OtherId = eventNum; else ev.SubType = eventNum; // Read event actions. ev.Actions = ReadActions(); // Add new event. obj.Events[j].Add(ev); } else done = true; } } // End object inflate. EndDecompress(); // Add object to list. objects.Add(obj); } // Return objects. return objects; }