async Task <T> ISaveSinglePlayerClass.RetrieveSinglePlayerGameAsync <T>()
        {
            if (_thisData.CanAutoSave == false)
            {
                throw new BasicBlankException("Should not have autosaved.  Should have first called CanOpenSavedSinglePlayerGameAsync To See");
            }


            //here, get the list.
            //_list = await fs.RetrieveSavedObjectAsync<LimitedList<IMappable>>(_gamePath); //hopefully no problem (?)

            LimitedList <T> temps = await fs.RetrieveSavedObjectAsync <LimitedList <T> >(_gamePath);

            _list = new LimitedList <IMappable>();
            _list.PopulateSavedList(temps);

            if (_data.GamePackageMode == EnumGamePackageMode.Production || RecentOne == 0)
            {
                _previousObject = _list.MostRecent.AutoMap <T>();
                return((T)_list.MostRecent !); //take a risk here too.
            }
            //in production, can add to history though.
            _previousObject = _list[RecentOne].AutoMap <T>();
            return((T)_list[RecentOne] !);

            //await Task.CompletedTask;
            //return fs.RetrieveSavedObject<T>(_gamePath);
            //return await fs.RetrieveSavedObjectAsync<T>(_gamePath);
        }
Пример #2
0
        async Task <string> IMultiplayerSaveState.SavedDataAsync <T>()
        {
            if (_game.CanAutoSave == false)
            {
                return("");
            }
            if (_test.SaveOption == EnumTestSaveCategory.NoSave)
            {
                return("");
            }

            string pathUsed = "";

            if (_data.MultiPlayer == false)
            {
                if (FileExists(_localPath) == false)
                {
                    return("");
                }
                pathUsed = _localPath;
                //return await AllTextAsync(_localPath); //they have to deseriaize it later.
            }

            if (_data.MultiPlayer == true && FileExists(_multiPath) == false)
            {
                return("");
            }
            if (_data.MultiPlayer)
            {
                pathUsed = _multiPath;
            }

            LimitedList <T> temps = await fs.RetrieveSavedObjectAsync <LimitedList <T> >(pathUsed);

            _list = new LimitedList <IMappable>();
            _list.PopulateSavedList(temps);
            //looks like i have to do generics after all.
            //if i did as string, then even if i could get it to work eventually, the problem is i can't easily debug anymore.
            //can't deserialize as string or even imappable.
            //if i made it more picky, then later causes other issues.


            if (_test.StatePosition == 0)
            {
                _previousObject = _list.MostRecent;
            }
            else
            {
                _previousObject = _list[_test.StatePosition];
            }
            return(JsonConvert.SerializeObject(_previousObject));
        }