public void ExportData(WillowTwoPlayerSaveGame saveGame)
        {
            saveGame.PlayerClass = this.PlayerClass;

            var playerClass = InfoManager.PlayerClasses.Items.FirstOrDefault(p => p.Key == this.PlayerClass).Value;

            if (playerClass != null && playerClass.DLC != null)
            {
                saveGame.IsDLCPlayerClass        = true;
                saveGame.DLCPlayerClassPackageId = playerClass.DLC.Package.Id;
            }
            else
            {
                saveGame.IsDLCPlayerClass        = false;
                saveGame.DLCPlayerClassPackageId = 0;
            }

            saveGame.ExpLevel  = this.ExpLevel;
            saveGame.ExpPoints = this.ExpPoints;
            saveGame.NumOverpowerLevelsUnlocked  = this.OverpowerLevel <= 0 ? (int?)null : this.OverpowerLevel;
            saveGame.GeneralSkillPoints          = this.GeneralSkillPoints;
            saveGame.SpecialistSkillPoints       = this.SpecialistSkillPoints;
            saveGame.UIPreferences.CharacterName = Encoding.UTF8.GetBytes(this.CharacterName);

            while (saveGame.AppliedCustomizations.Count < 5)
            {
                saveGame.AppliedCustomizations.Add("");
            }

            saveGame.AppliedCustomizations[0] = this.SelectedHead;
            saveGame.AppliedCustomizations[4] = this.SelectedSkin;
        }
        public void ExportData(WillowTwoPlayerSaveGame saveGame, Platform platform)
        {
            saveGame.BankSlots.Clear();

            foreach (var viewModel in this.Slots)
            {
                var slot = viewModel.BaseSlot;

                if (slot is BaseWeapon weapon)
                {
                    var data = BaseDataHelper.Encode(weapon, platform);
                    saveGame.BankSlots.Add(new BankSlot()
                    {
                        InventorySerialNumber = data,
                    });
                }
                else if (slot is BaseItem item)
                {
                    var data = BaseDataHelper.Encode(item, platform);
                    saveGame.BankSlots.Add(new BankSlot()
                    {
                        InventorySerialNumber = data,
                    });
                }
                else
                {
                    throw new NotSupportedException();
                }
            }

            this._BrokenSlots.ForEach(kv => saveGame.BankSlots.Add(kv.Key));
        }
        public void ExportData(WillowTwoPlayerSaveGame saveGame)
        {
            ExportTarget(
                "GD_Globals.VehicleSpawnStation.VehicleFamily_Runner",
                saveGame.ChosenVehicleCustomizations,
                this.SelectedRunner1,
                this.SelectedRunner2,
                this.ExtraRunner);
            ExportTarget(
                "GD_Globals.VehicleSpawnStation.VehicleFamily_BanditTechnical",
                saveGame.ChosenVehicleCustomizations,
                this.SelectedBanditTech1,
                this.SelectedBanditTech2,
                this.ExtraBanditTech);

            ExportTarget(
                "GD_OrchidPackageDef.Vehicles.VehicleFamily_Hovercraft",
                saveGame.ChosenVehicleCustomizations,
                this.SelectedHovercraft1,
                this.SelectedHovercraft2,
                this.ExtraHovercraft);

            ExportTarget(
                "GD_SagePackageDef.Vehicles.VehicleFamily_FanBoat",
                saveGame.ChosenVehicleCustomizations,
                this.SelectedFanBoat1,
                this.SelectedFanBoat2,
                this.ExtraFanBoat);
        }
        public void ImportData(WillowTwoPlayerSaveGame saveGame)
        {
            this.PlayerClass = saveGame.PlayerClass;

            var expLevel  = saveGame.ExpLevel;
            var expPoints = saveGame.ExpPoints;

            if (expPoints < 0)
            {
                expPoints = 0;
            }

            if (expLevel <= 0)
            {
                expLevel = Math.Max(1, Experience.GetLevelForPoints(expPoints));
            }

            this.ExpLevel       = expLevel;
            this.ExpPoints      = expPoints;
            this.OverpowerLevel = saveGame.NumOverpowerLevelsUnlocked.HasValue == false
                                      ? 0
                                      : saveGame.NumOverpowerLevelsUnlocked.Value;
            this.GeneralSkillPoints    = saveGame.GeneralSkillPoints;
            this.SpecialistSkillPoints = saveGame.SpecialistSkillPoints;
            this.CharacterName         = Encoding.UTF8.GetString(saveGame.UIPreferences.CharacterName);
            this.SelectedHead          = saveGame.AppliedCustomizations.Count > 0 ? saveGame.AppliedCustomizations[0] : "None";
            this.SelectedSkin          = saveGame.AppliedCustomizations.Count > 4 ? saveGame.AppliedCustomizations[4] : "None";
            this.BuildCustomizationAssets();
        }
Esempio n. 5
0
        public void ExportData(WillowTwoPlayerSaveGame saveGame)
        {
            saveGame.BankSlots.Clear();

            foreach (var viewModel in this.Slots)
            {
                var slot = viewModel.BaseSlot;

                if (slot is BaseWeapon)
                {
                    var weapon = (BaseWeapon)slot;
                    var data   = BaseDataHelper.Encode(weapon);

                    saveGame.BankSlots.Add(new BankSlot()
                    {
                        Data = data,
                    });
                }
                else if (slot is BaseItem)
                {
                    var item = (BaseItem)slot;
                    var data = BaseDataHelper.Encode(item);

                    saveGame.BankSlots.Add(new BankSlot()
                    {
                        Data = data,
                    });
                }
                else
                {
                    throw new NotSupportedException();
                }
            }
        }
        public void ImportData(WillowTwoPlayerSaveGame saveGame)
        {
            this.ExtraRunner.Clear();
            ImportTarget(
                "GD_Globals.VehicleSpawnStation.VehicleFamily_Runner",
                saveGame.ChosenVehicleCustomizations,
                s => this.SelectedRunner1 = s,
                s => this.SelectedRunner2 = s,
                s => this.ExtraRunner.Add(s));

            this.ExtraBanditTech.Clear();
            ImportTarget(
                "GD_Globals.VehicleSpawnStation.VehicleFamily_BanditTechnical",
                saveGame.ChosenVehicleCustomizations,
                s => this.SelectedBanditTech1 = s,
                s => this.SelectedBanditTech2 = s,
                s => this.ExtraBanditTech.Add(s));

            this.ExtraHovercraft.Clear();
            ImportTarget(
                "GD_OrchidPackageDef.Vehicles.VehicleFamily_Hovercraft",
                saveGame.ChosenVehicleCustomizations,
                s => this.SelectedHovercraft1 = s,
                s => this.SelectedHovercraft2 = s,
                s => this.ExtraHovercraft.Add(s));

            this.ExtraFanBoat.Clear();
            ImportTarget(
                "GD_SagePackageDef.Vehicles.VehicleFamily_FanBoat",
                saveGame.ChosenVehicleCustomizations,
                s => this.SelectedFanBoat1 = s,
                s => this.SelectedFanBoat2 = s,
                s => this.ExtraFanBoat.Add(s));
        }
        public void ImportData(WillowTwoPlayerSaveGame saveGame, Platform platform)
        {
            this.Slots.Clear();
            this._BrokenSlots.Clear();
            foreach (var bankSlot in saveGame.BankSlots)
            {
                IPackableSlot slot;
                try
                {
                    slot = BaseDataHelper.Decode(bankSlot.InventorySerialNumber, platform);
                }
                catch (Exception e)
                {
                    this._BrokenSlots.Add(new KeyValuePair <BankSlot, Exception>(bankSlot, e));
                    continue;
                }

                var test = BaseDataHelper.Encode(slot, platform);
                if (bankSlot.InventorySerialNumber.SequenceEqual(test) == false)
                {
                    throw new FormatException("bank slot reencode mismatch");
                }

                if (slot is BaseWeapon)
                {
                    var viewModel = new BaseWeaponViewModel((BaseWeapon)slot);
                    this.Slots.Add(viewModel);
                }
                else if (slot is BaseItem)
                {
                    var viewModel = new BaseItemViewModel((BaseItem)slot);
                    this.Slots.Add(viewModel);
                }
            }
        }
Esempio n. 8
0
        public void ImportData(WillowTwoPlayerSaveGame saveGame)
        {
            this.Slots.Clear();

            foreach (var bankSlot in saveGame.BankSlots)
            {
                var slot = BaseDataHelper.Decode(bankSlot.Data);
                var test = BaseDataHelper.Encode(slot);
                if (bankSlot.Data.SequenceEqual(test) == false)
                {
                    throw new FormatException("bank slot reencode mismatch");
                }

                if (slot is BaseWeapon)
                {
                    var viewModel = new BaseWeaponViewModel((BaseWeapon)slot);
                    this.Slots.Add(viewModel);
                }
                else if (slot is BaseItem)
                {
                    var viewModel = new BaseItemViewModel((BaseItem)slot);
                    this.Slots.Add(viewModel);
                }
            }
        }
Esempio n. 9
0
        ///////////////////////////////////////////
        //SPITFIRE1337 MODS
        ///////////////////////////////////////////
        public void ImportData(WillowTwoPlayerSaveGame saveGame, Endian endian, string myprofileid, string mydeviceid, string myconsoleid)
        {
            this.Endian      = endian;
            this.SaveGameId  = saveGame.SaveGameId;
            this.PlayerClass = saveGame.PlayerClass;

            var expLevel  = saveGame.ExpLevel;
            var expPoints = saveGame.ExpPoints;

            if (expPoints < 0)
            {
                expPoints = 0;
            }

            if (expLevel <= 0)
            {
                expLevel = Math.Max(1, Experience.GetLevelForPoints(expPoints));
            }

            this.ExpLevel              = expLevel;
            this.ExpPoints             = expPoints;
            this.GeneralSkillPoints    = saveGame.GeneralSkillPoints;
            this.SpecialistSkillPoints = saveGame.SpecialistSkillPoints;
            this.CharacterName         = Encoding.UTF8.GetString(saveGame.UIPreferences.CharacterName);
            this.SelectedHead          = saveGame.AppliedCustomizations[0];
            this.SelectedSkin          = saveGame.AppliedCustomizations[4];
            this.BuildCustomizationAssets();

            string vOut = myprofileid.ToString();

            this.Profileid   = vOut;
            this.ProfileName = checkProfile(myprofileid);
        }
 private static void AddExpansionSavedataToUnloadableItemData(this WillowTwoPlayerSaveGame saveGame,
                                                              byte id,
                                                              int value1)
 {
     // ReSharper disable IntroduceOptionalParameters.Local
     AddExpansionSavedataToUnloadableItemData(saveGame, id, value1, 0);
     // ReSharper restore IntroduceOptionalParameters.Local
 }
Esempio n. 11
0
        public void ExportData(WillowTwoPlayerSaveGame saveGame)
        {
            var count = Math.Min(this.Playthroughs.Count, saveGame.MissionPlaythroughs.Count);

            for (int i = 0; i < count; i++)
            {
                var viewModel          = this.Playthroughs[i];
                var missionPlaythrough = saveGame.MissionPlaythroughs[i];
                viewModel.ExportData(missionPlaythrough);
            }
        }
Esempio n. 12
0
 public void ExportData(WillowTwoPlayerSaveGame saveGame)
 {
     saveGame.LastVisitedTeleporter = this.LastVisitedTeleporter;
     saveGame.VisitedTeleporters.Clear();
     foreach (var travelStation in this.VisitedTeleporters)
     {
         if (travelStation.Visited == true)
         {
             saveGame.VisitedTeleporters.Add(travelStation.ResourceName);
         }
     }
 }
Esempio n. 13
0
 private static void AddExpansionSavedataToUnloadableItemData(this WillowTwoPlayerSaveGame saveGame,
                                                              byte id,
                                                              int value1,
                                                              int value2)
 {
     saveGame.PackedItemData.Add(new PackedItemData()
     {
         InventorySerialNumber = (byte[])_HackInventorySerialNumber.Clone(),
         Quantity = -(id | (Math.Max(0, Math.Min(value1, 0x7FFFFF)) << 8)),
         Mark     = value2,
     });
 }
Esempio n. 14
0
 ///////////////////////////////////////////
 //END SPITFIRE1337 MODS
 ///////////////////////////////////////////
 public void ExportData(WillowTwoPlayerSaveGame saveGame, out Endian endian)
 {
     endian = this.Endian;
     saveGame.SaveGameId                  = this.SaveGameId;
     saveGame.PlayerClass                 = this.PlayerClass;
     saveGame.ExpLevel                    = this.ExpLevel;
     saveGame.ExpPoints                   = this.ExpPoints;
     saveGame.GeneralSkillPoints          = this.GeneralSkillPoints;
     saveGame.SpecialistSkillPoints       = this.SpecialistSkillPoints;
     saveGame.UIPreferences.CharacterName = Encoding.UTF8.GetBytes(this.CharacterName);
     saveGame.AppliedCustomizations[0]    = this.SelectedHead;
     saveGame.AppliedCustomizations[4]    = this.SelectedSkin;
 }
Esempio n. 15
0
        public void ImportData(WillowTwoPlayerSaveGame saveGame)
        {
            this.Playthroughs.Clear();
            int index = 0;

            foreach (var missionPlaythrough in saveGame.MissionPlaythroughs)
            {
                var viewModel = new FastTravelPlaythroughViewModel($"Playthrough #{index + 1}", this);
                viewModel.ImportData(missionPlaythrough);
                this.Playthroughs.Add(viewModel);
                index++;
            }
        }
        public static void ExtractExpansionSavedataFromUnloadableItemData(WillowTwoPlayerSaveGame saveGame)
        {
            if (saveGame == null)
            {
                throw new ArgumentNullException("saveGame");
            }

            if (saveGame.PackedItemData != null)
            {
                var hacks = saveGame.PackedItemData.Where(pid => pid.Quantity < 0).ToArray();
                foreach (var hack in hacks)
                {
                    byte id;
                    int  value1, value2;
                    ExtractExpansionSavedataFromUnloadableItemData(hack, out id, out value1, out value2);

                    if (id == 1)
                    {
                        if (saveGame.CurrencyOnHand.Count >= 1)
                        {
                            saveGame.CurrencyOnHand[1] += value1;
                        }
                        saveGame.PackedItemData.Remove(hack);
                    }
                    else if (id == 2)
                    {
                        saveGame.LastPlaythroughNumber += value1;
                        saveGame.PlaythroughsCompleted += (byte)value2;
                        saveGame.PackedItemData.Remove(hack);
                    }
                    else if (id == 3)
                    {
                        saveGame.PlayerHasPlayedInPlaythroughThree = value1;
                        saveGame.PackedItemData.Remove(hack);
                    }
                    else if (id == 4)
                    {
                        saveGame.NumOverpowerLevelsUnlocked = value1;
                        saveGame.PackedItemData.Remove(hack);
                    }

                    /*
                     * else if (id == 5)
                     * {
                     *  saveGame.LastOverpowerChoice = value1;
                     *  saveGame.PackedItemData.Remove(hack);
                     * }
                     */
                }
            }
        }
        public void ImportData(WillowTwoPlayerSaveGame saveGame)
        {
            foreach (var teleporter in this.AvailableTeleporters.Where(t => t.Custom == true).ToList())
            {
                this.AvailableTeleporters.Remove(teleporter);
            }

            if (this.AvailableTeleporters.Any(t => t.Path == saveGame.LastVisitedTeleporter) == false)
            {
                this.AvailableTeleporters.Add(new AssetDisplay(
                                                  saveGame.LastVisitedTeleporter,
                                                  saveGame.LastVisitedTeleporter,
                                                  "Unknown",
                                                  true));
            }

            this.LastVisitedTeleporter = saveGame.LastVisitedTeleporter;

            var visitedStations = saveGame.VisitedTeleporters.ToList();

            foreach (var station in this.VisitedTeleporters.ToArray())
            {
                if (visitedStations.Contains(station.ResourceName) == true)
                {
                    station.Visited = true;
                    visitedStations.Remove(station.ResourceName);
                }
                else if (station.Custom == true)
                {
                    this.VisitedTeleporters.Remove(station);
                }
                else
                {
                    station.Visited = false;
                }
            }

            foreach (var station in visitedStations)
            {
                this.VisitedTeleporters.Add(new VisitedTeleporterDisplay()
                {
                    DisplayName  = station,
                    ResourceName = station,
                    Visited      = true,
                    Custom       = true,
                    Group        = "Unknown",
                });
            }
        }
Esempio n. 18
0
        public void ExportData(WillowTwoPlayerSaveGame saveGame, Platform platform)
        {
            saveGame.PackedWeaponData.Clear();
            saveGame.PackedItemData.Clear();

            foreach (var viewModel in this.Slots)
            {
                var slot = viewModel.BackpackSlot;

                if (slot is BackpackWeapon)
                {
                    var weapon = (BackpackWeapon)slot;
                    var data   = BackpackDataHelper.Encode(weapon, platform);

                    saveGame.PackedWeaponData.Add(new PackedWeaponData()
                    {
                        InventorySerialNumber = data,
                        QuickSlot             = weapon.QuickSlot,
                        Mark = weapon.Mark,
                    });
                }
                else if (slot is BackpackItem)
                {
                    var item = (BackpackItem)slot;
                    var data = BackpackDataHelper.Encode(item, platform);

                    saveGame.PackedItemData.Add(new PackedItemData()
                    {
                        InventorySerialNumber = data,
                        Quantity = item.Quantity,
                        Equipped = item.Equipped,
                        Mark     = (int)item.Mark,
                    });
                }
                else
                {
                    throw new NotSupportedException();
                }
            }

            this._BrokenWeapons.ForEach(kv => saveGame.PackedWeaponData.Add(kv.Key));
            this._BrokenItems.ForEach(kv => saveGame.PackedItemData.Add(kv.Key));

            // TODO: STUPID STUPID STUPID STUPID WHY GEARBOX WHY?????????????????????
            foreach (var packedItem in this._ExpansionItems)
            {
                saveGame.PackedItemData.Add(packedItem);
            }
        }
Esempio n. 19
0
 public void ExportData(WillowTwoPlayerSaveGame saveGame)
 {
     ExportTarget("GD_Globals.VehicleSpawnStation.VehicleFamily_MoonBuggy",
                  saveGame.ChosenVehicleCustomizations,
                  this.ExtraMoonBuggy,
                  this.SelectedMoonBuggy1,
                  this.SelectedMoonBuggy2);
     ExportTarget("GD_Globals.VehicleSpawnStation.VehicleFamily_StingRay",
                  saveGame.ChosenVehicleCustomizations,
                  this.ExtraStingRay,
                  this.SelectedStingRay1,
                  this.SelectedStingRay2,
                  this.SelectedStingRay3,
                  this.SelectedStingRay4);
 }
 public void ImportData(WillowTwoPlayerSaveGame saveGame)
 {
     this.Credits        = saveGame.CurrencyOnHand != null && saveGame.CurrencyOnHand.Count > 0 ? saveGame.CurrencyOnHand[0] : 0;
     this.Eridium        = saveGame.CurrencyOnHand != null && saveGame.CurrencyOnHand.Count > 1 ? saveGame.CurrencyOnHand[1] : 0;
     this.SeraphCrystals = saveGame.CurrencyOnHand != null && saveGame.CurrencyOnHand.Count > 2 ? saveGame.CurrencyOnHand[2] : 0;
     this.ReservedA      = saveGame.CurrencyOnHand != null && saveGame.CurrencyOnHand.Count > 3 ? saveGame.CurrencyOnHand[3] : 0;
     this.ReservedB      = saveGame.CurrencyOnHand != null && saveGame.CurrencyOnHand.Count > 4 ? saveGame.CurrencyOnHand[4] : 0;
     this.ReservedC      = saveGame.CurrencyOnHand != null && saveGame.CurrencyOnHand.Count > 5 ? saveGame.CurrencyOnHand[5] : 0;
     this.ReservedD      = saveGame.CurrencyOnHand != null && saveGame.CurrencyOnHand.Count > 6 ? saveGame.CurrencyOnHand[6] : 0;
     this.ReservedE      = saveGame.CurrencyOnHand != null && saveGame.CurrencyOnHand.Count > 7 ? saveGame.CurrencyOnHand[7] : 0;
     this.ReservedF      = saveGame.CurrencyOnHand != null && saveGame.CurrencyOnHand.Count > 8 ? saveGame.CurrencyOnHand[8] : 0;
     this.ReservedG      = saveGame.CurrencyOnHand != null && saveGame.CurrencyOnHand.Count > 9 ? saveGame.CurrencyOnHand[9] : 0;
     this.ReservedH      = saveGame.CurrencyOnHand != null && saveGame.CurrencyOnHand.Count > 10 ? saveGame.CurrencyOnHand[10] : 0;
     this.ReservedI      = saveGame.CurrencyOnHand != null && saveGame.CurrencyOnHand.Count > 11 ? saveGame.CurrencyOnHand[11] : 0;
     this.ReservedJ      = saveGame.CurrencyOnHand != null && saveGame.CurrencyOnHand.Count > 12 ? saveGame.CurrencyOnHand[12] : 0;
 }
Esempio n. 21
0
 public void ExportData(WillowTwoPlayerSaveGame saveGame)
 {
     saveGame.CurrencyOnHand.Clear();
     saveGame.CurrencyOnHand.Add(this.Credits);
     saveGame.CurrencyOnHand.Add(this.Eridium);
     saveGame.CurrencyOnHand.Add(this.SeraphCrystals);
     saveGame.CurrencyOnHand.Add(this.ReservedA);
     saveGame.CurrencyOnHand.Add(this.TorgueTokens);
     saveGame.CurrencyOnHand.Add(this.ReservedC);
     saveGame.CurrencyOnHand.Add(this.ReservedD);
     saveGame.CurrencyOnHand.Add(this.ReservedE);
     saveGame.CurrencyOnHand.Add(this.ReservedF);
     saveGame.CurrencyOnHand.Add(this.ReservedG);
     saveGame.CurrencyOnHand.Add(this.ReservedH);
     saveGame.CurrencyOnHand.Add(this.ReservedI);
     saveGame.CurrencyOnHand.Add(this.ReservedJ);
 }
Esempio n. 22
0
        public void ImportData(WillowTwoPlayerSaveGame saveGame)
        {
            this.ExtraMoonBuggy.Clear();
            ImportTarget("GD_Globals.VehicleSpawnStation.VehicleFamily_MoonBuggy",
                         saveGame.ChosenVehicleCustomizations,
                         s => this.ExtraMoonBuggy.Add(s),
                         s => this.SelectedMoonBuggy1 = s,
                         s => this.SelectedMoonBuggy2 = s);

            this.ExtraStingRay.Clear();
            ImportTarget("GD_Globals.VehicleSpawnStation.VehicleFamily_StingRay",
                         saveGame.ChosenVehicleCustomizations,
                         s => this.ExtraStingRay.Add(s),
                         s => this.SelectedStingRay1 = s,
                         s => this.SelectedStingRay2 = s,
                         s => this.SelectedStingRay3 = s,
                         s => this.SelectedStingRay4 = s);
        }
        public void ExportData(WillowTwoPlayerSaveGame saveGame)
        {
            saveGame.PackedWeaponData.Clear();
            saveGame.PackedItemData.Clear();

            foreach (var viewModel in this.Slots)
            {
                var slot = viewModel.BackpackSlot;

                if (slot is BackpackWeapon)
                {
                    var weapon = (BackpackWeapon)slot;
                    var data   = BackpackDataHelper.Encode(weapon);

                    saveGame.PackedWeaponData.Add(new PackedWeaponData()
                    {
                        Data      = data,
                        QuickSlot = weapon.QuickSlot,
                        Mark      = weapon.Mark,
                    });
                }
                else if (slot is BackpackItem)
                {
                    var item = (BackpackItem)slot;
                    var data = BackpackDataHelper.Encode(item);

                    saveGame.PackedItemData.Add(new PackedItemData()
                    {
                        Data     = data,
                        Quantity = item.Quantity,
                        Equipped = item.Equipped,
                        Mark     = item.Mark,
                    });
                }
                else
                {
                    throw new NotSupportedException();
                }
            }
        }
        public void ImportData(WillowTwoPlayerSaveGame saveGame)
        {
            this.Slots.Clear();

            foreach (var packedWeapon in saveGame.PackedWeaponData)
            {
                var weapon = (BackpackWeapon)BackpackDataHelper.Decode(packedWeapon.Data);
                var test   = BackpackDataHelper.Encode(weapon);
                if (packedWeapon.Data.SequenceEqual(test) == false)
                {
                    throw new FormatException("backpack weapon reencode mismatch");
                }

                weapon.QuickSlot = packedWeapon.QuickSlot;
                weapon.Mark      = packedWeapon.Mark;

                var viewModel = new BackpackWeaponViewModel(weapon);
                this.Slots.Add(viewModel);
            }

            foreach (var packedItem in saveGame.PackedItemData)
            {
                var item = (BackpackItem)BackpackDataHelper.Decode(packedItem.Data);
                var test = BackpackDataHelper.Encode(item);
                if (packedItem.Data.SequenceEqual(test) == false)
                {
                    throw new FormatException("backpack item reencode mismatch");
                }

                item.Quantity = packedItem.Quantity;
                item.Equipped = packedItem.Equipped;
                item.Mark     = packedItem.Mark;

                var viewModel = new BackpackItemViewModel(item);
                this.Slots.Add(viewModel);
            }
        }
Esempio n. 25
0
        public void ImportData(WillowTwoPlayerSaveGame saveGame, Platform platform)
        {
            this.Slots.Clear();

            this._BrokenWeapons.Clear();
            foreach (var packedWeapon in saveGame.PackedWeaponData)
            {
                BackpackWeapon weapon;
                try
                {
                    weapon = (BackpackWeapon)BackpackDataHelper.Decode(packedWeapon.InventorySerialNumber, platform);
                }
                catch (Exception e)
                {
                    this._BrokenWeapons.Add(new KeyValuePair <PackedWeaponData, Exception>(packedWeapon, e));
                    continue;
                }

                var test = BackpackDataHelper.Encode(weapon, platform);
                if (packedWeapon.InventorySerialNumber.SequenceEqual(test) == false)
                {
                    throw new FormatException("backpack weapon reencode mismatch");
                }

                weapon.QuickSlot = packedWeapon.QuickSlot;
                weapon.Mark      = packedWeapon.Mark;

                var viewModel = new BackpackWeaponViewModel(weapon);
                this.Slots.Add(viewModel);
            }

            this._ExpansionItems.Clear();
            this._BrokenItems.Clear();
            foreach (var packedItem in saveGame.PackedItemData)
            {
                if (packedItem.Quantity < 0)
                {
                    this._ExpansionItems.Add(packedItem);
                    continue;
                }

                BackpackItem item;
                try
                {
                    item = (BackpackItem)BackpackDataHelper.Decode(packedItem.InventorySerialNumber, platform);
                }
                catch (Exception e)
                {
                    this._BrokenItems.Add(new KeyValuePair <PackedItemData, Exception>(packedItem, e));
                    continue;
                }

                var test = BackpackDataHelper.Encode(item, platform);
                if (packedItem.InventorySerialNumber.SequenceEqual(test) == false)
                {
                    throw new FormatException("backpack item reencode mismatch");
                }

                item.Quantity = packedItem.Quantity;
                item.Equipped = packedItem.Equipped;
                item.Mark     = (PlayerMark)packedItem.Mark;

                // required since protobuf is no longer doing the validation for us
                if (item.Mark != PlayerMark.Trash &&
                    item.Mark != PlayerMark.Standard &&
                    item.Mark != PlayerMark.Favorite)
                {
                    throw new FormatException("invalid PlayerMark value");
                }

                var viewModel = new BackpackItemViewModel(item);
                this.Slots.Add(viewModel);
            }
        }
Esempio n. 26
0
 public void ExportData(WillowTwoPlayerSaveGame saveGame, out Platform platform)
 {
     platform            = this.Platform;
     saveGame.SaveGuid   = (GameGuid)this.SaveGuid;
     saveGame.SaveGameId = this.SaveGameId;
 }
Esempio n. 27
0
 public void ImportData(WillowTwoPlayerSaveGame saveGame, Platform platform)
 {
     this.Platform   = platform;
     this.SaveGuid   = (SystemGuid)saveGame.SaveGuid;
     this.SaveGameId = saveGame.SaveGameId;
 }
Esempio n. 28
0
        public static void AddExpansionSavedataToUnloadableItemData(WillowTwoPlayerSaveGame saveGame)
        {
            if (saveGame == null)
            {
                throw new ArgumentNullException("saveGame");
            }

            if (saveGame.PackedItemData == null)
            {
                saveGame.PackedItemData = new List <PackedItemData>();
            }
            else
            {
                var oldHacks = saveGame.PackedItemData.Where(pid => pid.Quantity < 0).ToArray();
                foreach (var hack in oldHacks)
                {
                    var type = (-hack.Quantity) & 0xFF;
                    if (type >= 1 && type <= 5)
                    {
                        saveGame.PackedItemData.Remove(hack);
                    }
                }
            }

            if (saveGame.CurrencyOnHand.Count >= 1 &&
                saveGame.CurrencyOnHand[1] > 99)
            {
                var extraEridium = saveGame.CurrencyOnHand[1] - 99;
                saveGame.AddExpansionSavedataToUnloadableItemData(1, extraEridium);
                saveGame.CurrencyOnHand[1] = 99;
            }

            if (saveGame.PlaythroughsCompleted > 1 &&
                saveGame.LastPlaythroughNumber >= 1 && saveGame.LastPlaythroughNumber <= 0x800000)
            {
                var extraLastPlaythroughNumber = saveGame.LastPlaythroughNumber - 1;
                var extraPlaythroughsCompleted = (byte)(saveGame.PlaythroughsCompleted - 1);
                saveGame.AddExpansionSavedataToUnloadableItemData(2,
                                                                  extraLastPlaythroughNumber,
                                                                  extraPlaythroughsCompleted);
                saveGame.LastPlaythroughNumber = saveGame.LastPlaythroughNumber >= 1 ? 1 : 0;
                saveGame.PlaythroughsCompleted = 1;
            }

            if (saveGame.PlayerHasPlayedInPlaythroughThree.HasValue == true)
            {
                var value = saveGame.PlayerHasPlayedInPlaythroughThree.Value;
                saveGame.AddExpansionSavedataToUnloadableItemData(3, value);
            }

            if (saveGame.NumOverpowerLevelsUnlocked.HasValue == true)
            {
                var value = saveGame.NumOverpowerLevelsUnlocked.Value;
                saveGame.AddExpansionSavedataToUnloadableItemData(4, value);
            }

            if (saveGame.LastOverpowerChoice.HasValue == true)
            {
                var value = saveGame.LastOverpowerChoice.Value;
                saveGame.AddExpansionSavedataToUnloadableItemData(5, value);
            }
        }
Esempio n. 29
0
 private static void AddExpansionSavedataToUnloadableItemData(this WillowTwoPlayerSaveGame saveGame,
                                                              byte id,
                                                              int value1)
 {
     AddExpansionSavedataToUnloadableItemData(saveGame, id, value1, 0);
 }