public static Result Transfer <T>( object save, Stream srcSaveStream, Func <Stream, bool> isValid, Func <Stream, T> read, Dictionary <Type, Action <object, object, PropertyInfo> > mappings) where T : class { if (!(save is T)) { return(Result.GameNotSupported); } if (!isValid(srcSaveStream.SetPosition(0))) { return(Result.SourceNotCompatible); } var srcSave = read(srcSaveStream.SetPosition(0)); if (!(srcSave is T)) { return(Result.InternalError); } TransferServiceLL.CopySave <T>(save, srcSave, mappings); return(Result.Success); }
private static void CopySame(IDriveForm[] dst, IDriveForm[] src) { var length = Math.Min(dst.Length, src.Length); for (var i = 0; i < length; i++) { TransferServiceLL.CopySave <IDriveForm>(dst[i], src[i], TransferMappings); } }
private static void CopyFromFinalMix(IDriveForm[] dst, IDriveForm[] src) { TransferServiceLL.CopySave <IDriveForm>(dst[0], src[0], TransferMappings); TransferServiceLL.CopySave <IDriveForm>(dst[1], src[1], TransferMappings); TransferServiceLL.CopySave <IDriveForm>(dst[2], src[3], TransferMappings); TransferServiceLL.CopySave <IDriveForm>(dst[3], src[4], TransferMappings); TransferServiceLL.CopySave <IDriveForm>(dst[4], src[5], TransferMappings); TransferServiceLL.CopySave <IDriveForm>(dst[5], src[6], TransferMappings); TransferServiceLL.CopySave <IDriveForm>(dst[6], src[7], TransferMappings); TransferServiceLL.CopySave <IDriveForm>(dst[7], src[8], TransferMappings); TransferServiceLL.CopySave <IDriveForm>(dst[8], src[9], TransferMappings); }
private static void CopyFromVanilla(IDriveForm[] dst, IDriveForm[] src) { var limitDriveForm = new DriveFormFinalMix(); // creates a default Limit limitDriveForm.Level = 1; limitDriveForm.Abilities = new ushort[0x18]; limitDriveForm.Abilities[0] = 0x8234; limitDriveForm.Abilities[1] = 0x8239; limitDriveForm.Abilities[2] = 0x823A; limitDriveForm.Abilities[3] = 0x823B; limitDriveForm.Abilities[4] = 0x823C; limitDriveForm.Abilities[5] = 0x823D; limitDriveForm.Abilities[6] = 0x823E; limitDriveForm.Abilities[7] = 0x823F; limitDriveForm.Abilities[8] = 0x824B; limitDriveForm.Abilities[9] = 0x824C; limitDriveForm.Abilities[10] = 0x824D; limitDriveForm.Abilities[11] = 0x8052; limitDriveForm.Abilities[12] = 0x8106; limitDriveForm.Abilities[13] = 0x8108; limitDriveForm.Abilities[14] = 0x810D; limitDriveForm.Abilities[15] = 0x819C; limitDriveForm.Abilities[16] = 0x8195; limitDriveForm.Abilities[17] = 0x8197; limitDriveForm.Abilities[18] = 0x819D; dst[2] = limitDriveForm; TransferServiceLL.CopySave <IDriveForm>(dst[0], src[0], TransferMappings); TransferServiceLL.CopySave <IDriveForm>(dst[1], src[1], TransferMappings); TransferServiceLL.CopySave <IDriveForm>(dst[3], src[2], TransferMappings); TransferServiceLL.CopySave <IDriveForm>(dst[4], src[3], TransferMappings); TransferServiceLL.CopySave <IDriveForm>(dst[5], src[4], TransferMappings); TransferServiceLL.CopySave <IDriveForm>(dst[6], src[5], TransferMappings); TransferServiceLL.CopySave <IDriveForm>(dst[7], src[6], TransferMappings); TransferServiceLL.CopySave <IDriveForm>(dst[8], src[7], TransferMappings); TransferServiceLL.CopySave <IDriveForm>(dst[9], src[8], TransferMappings); }
public void TransferFrom_KH2FM_to_KH2EU() { var dst = new Lib2.SaveKh2.SaveEuropean() { InventoryCount = new byte[0x04], PlaceScripts = Enumerable.Range(0, 2).Select(x => new Lib2.Models.PlaceScriptVanilla()).ToArray(), Characters = new Lib2.Models.CharacterVanilla[] { new Lib2.Models.CharacterVanilla { Abilities = new ushort[1] { 123 } } }, DriveForms = new Lib2.Models.DriveFormVanilla[] { new Lib2.Models.DriveFormVanilla(), // Valor new Lib2.Models.DriveFormVanilla(), // Wisdom new Lib2.Models.DriveFormVanilla(), // Master new Lib2.Models.DriveFormVanilla(), // Final new Lib2.Models.DriveFormVanilla(), new Lib2.Models.DriveFormVanilla(), new Lib2.Models.DriveFormVanilla(), new Lib2.Models.DriveFormVanilla(), new Lib2.Models.DriveFormVanilla(), }, }; var src = new Lib2.SaveKh2.SaveFinalMix() { Difficulty = Lib2.Types.Difficulty.Critical, WorldId = Lib2.Types.WorldType.DisneyCastle, MunnyAmount = 12345, InventoryCount = new byte[6] { 0, 1, 2, 3, 4, 5 }, PlaceScripts = new Lib2.Models.PlaceScriptFinalMix[3] { new Lib2.Models.PlaceScriptFinalMix { Map = 1, Battle = 2, Event = 3 }, new Lib2.Models.PlaceScriptFinalMix { Map = 4, Battle = 5, Event = 6 }, new Lib2.Models.PlaceScriptFinalMix { Map = 7, Battle = 8, Event = 7 }, }, Characters = new Lib2.Models.CharacterFinalMix[] { new Lib2.Models.CharacterFinalMix { Abilities = new ushort[1] { 456 } } }, DriveForms = new Lib2.Models.DriveFormFinalMix[] { new Lib2.Models.DriveFormFinalMix // Valor { Experience = 1, }, new Lib2.Models.DriveFormFinalMix // Wisdom { Experience = 2, }, new Lib2.Models.DriveFormFinalMix // Limit { Experience = 3, }, new Lib2.Models.DriveFormFinalMix // Master { Experience = 4, }, new Lib2.Models.DriveFormFinalMix // Final { Experience = 5, }, new Lib2.Models.DriveFormFinalMix(), new Lib2.Models.DriveFormFinalMix(), new Lib2.Models.DriveFormFinalMix(), new Lib2.Models.DriveFormFinalMix(), new Lib2.Models.DriveFormFinalMix(), }, }; TransferServiceLL.CopySave <Lib2.ISaveKh2>(dst, src, Lib2.SaveKh2.TransferMappings); Assert.Equal(12345, dst.MunnyAmount); Assert.Equal(new byte[] { 0, 1, 2, 3 }, dst.InventoryCount); Assert.Equal(Lib2.Types.Difficulty.Proud, dst.Difficulty); Assert.Equal(Lib2.Types.WorldType.DisneyCastle, dst.WorldId); Assert.Equal(2, dst.PlaceScripts.Length); Assert.Equal(1, dst.PlaceScripts[0].Map); Assert.Equal(2, dst.PlaceScripts[0].Battle); Assert.Equal(3, dst.PlaceScripts[0].Event); Assert.Equal(4, dst.PlaceScripts[1].Map); Assert.Equal(5, dst.PlaceScripts[1].Battle); Assert.Equal(6, dst.PlaceScripts[1].Event); Assert.Equal(456, dst.Characters[0].Abilities[0]); Assert.Equal(1, dst.DriveForms[0].Experience); Assert.Equal(2, dst.DriveForms[1].Experience); Assert.Equal(4, dst.DriveForms[2].Experience); Assert.Equal(5, dst.DriveForms[3].Experience); }