Advertisement
Guest User

Untitled

a guest
Aug 21st, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. class o2
  2. {
  3. BinaryReader reader;
  4. public List<mapObject> mapObjects;
  5. public o2(byte[] file)
  6. {
  7. reader = new BinaryReader(new MemoryStream(file));
  8. ParseO2File(reader);
  9. }
  10.  
  11. private void ParseO2File(BinaryReader reader)
  12. {
  13. reader.BaseStream.Position += 16; //Skip Header
  14. mapObjects = new List<mapObject>();
  15.  
  16. for (int i = 0; i < 142; i++)
  17. {
  18. short count = reader.ReadInt16();
  19. for (int x = 0; x < count; x++)
  20. {
  21. mapObject obj = new mapObject();
  22. obj.group = 1;
  23. obj.uID = reader.ReadInt32();
  24. obj.x = reader.ReadSingle();
  25. obj.y = reader.ReadSingle();
  26. obj.z = reader.ReadSingle();
  27. reader.ReadBytes(2);
  28. obj.angle = reader.ReadSingle();
  29. obj.ID = reader.ReadInt32();
  30. reader.ReadBytes(2);
  31. obj.xsec = reader.ReadByte();
  32. obj.ysec = reader.ReadByte();
  33. mapObjects.Add(obj);
  34. }
  35. }
  36.  
  37. }
  38.  
  39. public struct mapObject
  40. {
  41. public int group;
  42. public int uID;
  43. public float x;
  44. public float y;
  45. public float z;
  46. public float angle;
  47. public int ID;
  48. public byte xsec;
  49. public byte ysec;
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement