// Save tracked data to files public static void Save() { if (m_trackedPhysObjects == null) { return; } foreach (KeyValuePair <MyEntity, MyTrailerSaveObjectHolder> kvp in m_trackedPhysObjects) { var path = Path.Combine(MyFileSystemUtils.GetApplicationUserDataFolder(), "Trailer"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } // Name is unique, that's preserved by Add() method using (FileStream fs = File.Create(Path.Combine(path, kvp.Value.Name + ".tracked"))) { using (BinaryWriter bw = new BinaryWriter(fs)) { foreach (KeyValuePair <int, MyPhysObjectTrackedTickData> kvpTicks in kvp.Value.Ticks) { MyUtils.BinaryWrite(bw, ref kvpTicks.Value.Position); MyUtils.BinaryWrite(bw, ref kvpTicks.Value.Orientation); bw.Write(kvpTicks.Value.ReflectorLevel); bw.Write(kvpTicks.Value.EngineLevel); if (kvpTicks.Value.GunShot == null) { bw.Write((int)-1); } else { bw.Write((int)kvpTicks.Value.GunShot.Value); } } } } } }