private void LoadFromBinaryReader(BinaryReader reader) { Ticks = new List <DemoTick>(); //Read header string demoVersion = reader.ReadString(); Assert.IsTrue(demoVersion == DEMO_VERSION_STRING); PlayerName = reader.ReadString(); MapID = reader.ReadInt32(); TotalTickTime = reader.ReadInt64(); RunValid = reader.ReadBoolean(); //Read ticks until end of file while (reader.BaseStream.Position < reader.BaseStream.Length) { long time = reader.ReadInt64(); float xPos = reader.ReadSingle(); float yPos = reader.ReadSingle(); float zPos = reader.ReadSingle(); float xRot = reader.ReadSingle(); float yRot = reader.ReadSingle(); bool crouched = reader.ReadBoolean(); Vector3 pos = new Vector3(xPos, yPos, zPos); Quaternion rot = Quaternion.Euler(xRot, yRot, 0f); DemoTick tick = new DemoTick(time, pos, rot, crouched); Ticks.Add(tick); } }
private void LoadFromBinaryReader(BinaryReader reader) { Ticks = new List <DemoTick>(); //Read header string demoVersion = reader.ReadString(); if (demoVersion != DEMO_VERSION_STRING) { throw new ArgumentException("Demo version mismatch! File: " + demoVersion + ", current: " + DEMO_VERSION_STRING); } PlayerName = reader.ReadString(); LevelName = reader.ReadString(); TotalTickTime = reader.ReadInt64(); RunVaild = reader.ReadBoolean(); //Read ticks until end of file while (reader.BaseStream.Position < reader.BaseStream.Length) { long time = reader.ReadInt64(); float xPos = reader.ReadSingle(); float yPos = reader.ReadSingle(); float zPos = reader.ReadSingle(); Vector3 pos = new Vector3(xPos, yPos, zPos); float xRot = reader.ReadSingle(); float yRot = reader.ReadSingle(); Quaternion rot = Quaternion.Euler(xRot, yRot, 0f); DemoTick tick = new DemoTick(time, pos, rot); Ticks.Add(tick); } }