/// <summary> /// Converts a PKM from one Generation 3 format to another. If it matches the destination format, the conversion will automatically return. /// </summary> /// <param name="pk">PKM to convert</param> /// <param name="PKMType">Format/Type to convert to</param> /// <param name="comment">Comments regarding the transfer's success/failure</param> /// <returns>Converted PKM</returns> public static PKM ConvertToType(PKM pk, Type PKMType, out string comment) { if (pk == null) { comment = $"Bad {nameof(pk)} input. Aborting."; return(null); } Type fromType = pk.GetType(); if (fromType == PKMType) { comment = "No need to convert, current format matches requested format."; return(pk); } var pkm = ConvertPKM(pk, PKMType, fromType, out comment); if (!AllowIncompatibleConversion || pkm != null) { return(pkm); } // Try Incompatible Conversion pkm = GetBlank(PKMType); TransferProperties(pk, pkm); if (!SaveUtil.IsPKMCompatibleWithModifications(pkm)) { return(null); } comment = "Converted via reflection."; return(pkm); }