public static bool MustInitialize()
 {
     var tempData =  SaveData2.ReadData(Singleton<SimulationManager>.instance.m_metaData.m_gameInstanceIdentifier);
     if (tempData == null)
     {
         return true;
     }
     else
     {
         m_saveData = tempData;
         return false;
     }
 }
        public static void WriteData(SaveData2 data)
        {
            var found = false;
            for (var i = 0; i < saves.Count; i += 1)
            {
                if (saves[i].cityId == data.cityId){
                    saves[i] = data;
                    found = true;
                    break;
                }
            }
            if (!found){
                saves.Add(data);
            }

            System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List<SaveData2>));
            using(var file  = new StreamWriter(File.Create(fileName))){
                writer.Serialize(file, saves);
                file.Close();
            }
        }
        public static void LoadMod(SaveData2 sd)
        {
            var loaded = new HashSet<string>();

            if (sd.disastersEnabled)
            {
                modGameObject.AddComponent<Disasters2>();
            }

            var mapping = new Dictionary<Type, Type>
            {
                {typeof (ResidentialBuildingAI), typeof (WBBResidentialBuildingAI2)},
                {typeof (CommercialBuildingAI), typeof (WBCommercialBuildingAI2)},
                {typeof (IndustrialBuildingAI), typeof (WBIndustrialBuildingAI2)},
                {typeof (OfficeBuildingAI), typeof (WBOfficeBuildingAI2)},
                {typeof (IndustrialExtractorAI), typeof (WBIndustrialExtractorAI)},

            };

            for (uint i = 0; i < PrefabCollection<BuildingInfo>.PrefabCount(); i++)
            {
                var vi = PrefabCollection<BuildingInfo>.GetPrefab(i);
                AdjustBuildingAI(vi, mapping, loaded);
            }

            if (sd.DifficultyLevel == DifficultyLevel.Vanilla)
            {
                return;
            }

            if (sd.DifficultyLevel == DifficultyLevel.Hard && _mode == LoadMode.NewGame)
            {
                Singleton<EconomyManager>.instance.AddResource(EconomyManager.Resource.LoanAmount, 3000000, ItemClass.Service.Education, ItemClass.SubService.None, ItemClass.Level.None);
            }

            if (sd.DifficultyLevel == DifficultyLevel.DwarfFortress && _mode == LoadMode.NewGame)
            {
                Singleton<EconomyManager>.instance.AddResource(EconomyManager.Resource.LoanAmount, 4000000, ItemClass.Service.Education, ItemClass.SubService.None, ItemClass.Level.None);
            }

            mapping = new Dictionary<Type, Type>
            {
                {typeof (CargoTruckAI), typeof (WBCargoTruckAI)},
                {typeof (PassengerCarAI), typeof (WBPassengerCarAI)},
            };

            for (uint i = 0; i < PrefabCollection<VehicleInfo>.PrefabCount(); i++)
            {
                var vi = PrefabCollection<VehicleInfo>.GetPrefab(i);
                if (vi.m_vehicleAI.GetType().Equals(typeof(PassengerTrainAI)))
                {
                    ((PassengerTrainAI)vi.m_vehicleAI).m_passengerCapacity = 70;
                }
                else {
                    AdjustVehicleAI(vi, mapping, loaded);
                }
            }
            mapping = new Dictionary<Type, Type>
            {
                {typeof (ResidentAI), typeof (WBResidentAI6)},
            };

            for (uint i = 0; i < PrefabCollection<CitizenInfo>.PrefabCount(); i++)
            {
                var vi = PrefabCollection<CitizenInfo>.GetPrefab(i);
                AdjustResidentAI(vi, mapping, loaded);
            }

            //mapping = new Dictionary<Type, Type>
            //{
            //    {typeof (TransportLineAI), typeof (WBTransportLineAI2)},
            //};

            //for (uint i = 0; i < PrefabCollection<NetInfo>.PrefabCount(); i++)
            //{
            //    var vi = PrefabCollection<NetInfo>.GetPrefab(i);

            //    AdjustNetAI(vi, mapping);
            //}

            Singleton<UnlockManager>.instance.MilestonesUpdated();

            if (loaded.Count() < 8)
            {
                optionsWindow.ShowError();
            }
            //Debug.Log(loaded.Count().ToString());
            //Debug.Log(string.Join(",", loaded.ToArray()));
        }