private static void OnSaveData() { FastList <byte> data = new FastList <byte>(); try { SerializableDataExtension.WriteString(CachedNodeData._dataVersion, data); for (int index = 0; index < 32768; ++index) { if (!CachedNodeData.m_cachedNodeData[index].IsEmpty) { SerializableDataExtension.WriteInt32(index, data); SerializableDataExtension.WriteInt32(CachedNodeData.m_cachedNodeData[index].PassengersIn, data); SerializableDataExtension.WriteInt32(CachedNodeData.m_cachedNodeData[index].PassengersOut, data); SerializableDataExtension.WriteInt32(CachedNodeData.m_cachedNodeData[index].LastWeekPassengersIn, data); SerializableDataExtension.WriteInt32(CachedNodeData.m_cachedNodeData[index].LastWeekPassengersOut, data); SerializableDataExtension.WriteFloatArray(CachedNodeData.m_cachedNodeData[index].PassengerInData, data); SerializableDataExtension.WriteFloatArray(CachedNodeData.m_cachedNodeData[index].PassengerOutData, data); SerializableDataExtension.WriteBool(CachedNodeData.m_cachedNodeData[index].Unbunching, data); } } SerializableDataExtension.instance.SerializableData.SaveData(CachedNodeData._dataID, data.ToArray()); } catch (Exception ex) { Utils.LogError((object)("Error while saving net node data! " + ex.Message + " " + (object)ex.InnerException)); } }
private static void OnSaveData() { FastList <byte> data = new FastList <byte>(); try { SerializableDataExtension.WriteString(_dataVersion, data); for (ushort lineID = 0; (int)lineID < 256; ++lineID) { SerializableDataExtension.AddToData( BitConverter.GetBytes(GetTargetVehicleCount(lineID)), data); SerializableDataExtension.AddToData( BitConverter.GetBytes(Mathf.Max( GetNextSpawnTime(lineID) - SimHelper.SimulationTime, 0.0f)), data); SerializableDataExtension.AddToData( BitConverter.GetBytes(GetBudgetControlState(lineID)), data); SerializableDataExtension.AddToData(BitConverter.GetBytes(GetDepot(lineID)), data); int num = 0; HashSet <string> prefabs = GetPrefabs(lineID); if (prefabs != null) { num = prefabs.Count; } SerializableDataExtension.AddToData(BitConverter.GetBytes(num), data); if (num > 0) { foreach (string s in prefabs) { SerializableDataExtension.WriteString(s, data); } } string[] enqueuedVehicles = GetEnqueuedVehicles(lineID); SerializableDataExtension.AddToData(BitConverter.GetBytes(enqueuedVehicles.Length), data); if (enqueuedVehicles.Length != 0) { foreach (string s in enqueuedVehicles) { SerializableDataExtension.WriteString(s, data); } } SerializableDataExtension.WriteBool(GetUnbunchingState(lineID), data); } SerializableDataExtension.instance.SerializableData.SaveData(_dataID, data.ToArray()); } catch (Exception ex) { string msg = "Error while saving transport line data! " + ex.Message + " " + (object)ex.InnerException; Utils.LogError((object)msg); CODebugBase <LogChannel> .Log(LogChannel.Modding, msg, ErrorLevel.Error); } }