public static float[] ReadFloatArray(byte[] data, ref int index) { int length = SerializableDataExtension.ReadInt32(data, ref index); float[] numArray = new float[length]; for (int index1 = 0; index1 < length; ++index1) { numArray[index1] = SerializableDataExtension.ReadFloat(data, ref index); } return(numArray); }
public static bool TryLoadData(out NodeData[] data) { data = new NodeData[32768]; byte[] data1 = SerializableDataExtension.instance.SerializableData.LoadData(NetManagerMod._dataID); if (data1 == null) { return(false); } int index1 = 0; string empty = string.Empty; try { Utils.Log((object)"Try to load net node data."); string str = SerializableDataExtension.ReadString(data1, ref index1); if (string.IsNullOrEmpty(str) || str.Length != 4) { Utils.LogWarning((object)"Unknown data found."); return(false); } Utils.Log((object)("Found net node data version: " + str)); while (index1 < data1.Length) { int index2 = SerializableDataExtension.ReadInt32(data1, ref index1); if (str == "v001") { double num = (double)SerializableDataExtension.ReadFloat(data1, ref index1); } data[index2].PassengersIn = SerializableDataExtension.ReadInt32(data1, ref index1); data[index2].PassengersOut = SerializableDataExtension.ReadInt32(data1, ref index1); data[index2].LastWeekPassengersIn = SerializableDataExtension.ReadInt32(data1, ref index1); data[index2].LastWeekPassengersOut = SerializableDataExtension.ReadInt32(data1, ref index1); data[index2].PassengerInData = SerializableDataExtension.ReadFloatArray(data1, ref index1); data[index2].PassengerOutData = SerializableDataExtension.ReadFloatArray(data1, ref index1); data[index2].Unbunching = str == "v001" || str == "v002" || SerializableDataExtension.ReadBool(data1, ref index1); } return(true); } catch (Exception ex) { Utils.LogWarning((object)("Could not load net node data. " + ex.Message)); data = new NodeData[32768]; return(false); } }