Esempio n. 1
0
        private void LoadSaveable(ISaveable saveable)
        {
            string fileName = GetSaveableFilePath(saveable);

            if (System.IO.File.Exists(fileName))
            {
                using (BinaryReader reader = new BinaryReader(File.Open(fileName, FileMode.Open))) {
                    string saveString = reader.ReadString();
                    if (!string.IsNullOrEmpty(saveString))
                    {
                        saveable.Load(saveString);
                        saveable.OnLoaded();
                        RavenhillEvents.OnSaveableLoaded(saveable);
                    }
                    else
                    {
                        saveable.InitSave();
                        saveable.OnLoaded();
                        RavenhillEvents.OnSaveableLoaded(saveable);
                    }
                }
            }
            else
            {
                saveable.InitSave();
                saveable.OnLoaded();
                RavenhillEvents.OnSaveableLoaded(saveable);
            }
        }