public static HouseholdContentsProxy Import(string packageName) { ulong lotId = DownloadContent.ImportHouseholdContentsFromExportBin(packageName); if (lotId != 0x0L) { HouseholdContentsProxy householdContents = new HouseholdContentsProxy(); if (DownloadContent.ImportHouseholdContents(householdContents, lotId)) { householdContents.mContents.ContentId = lotId; return(householdContents); } } return(null); }
//public static string NExportHousehold(Bin ths, Household household, bool includeLotContents, bool isMovingPacked) //{ // return NExportHousehold(ths, household, includeLotContents, isMovingPacked, false); //} public static string NExportHousehold(Bin ths, Household household, bool includeLotContents, bool isMovingPacked, bool noReset, bool noThum) { if (ths == null) { throw new NullReferenceException(); } if (household == null) { throw new ArgumentNullException("household"); } try { string createdPackageFile = null; if (GameUtils.IsInstalled(ProductVersion.EP4)) { OccultImaginaryFriend.ForceHouseholdImaginaryFriendsBackToInventory(household); } if (!noReset) { foreach (Sim sim in household.AllActors) { sim.SetObjectToReset(); } } if (Simulator.CheckYieldingContext(false)) { Simulator.Sleep(0); } ThumbnailSizeMask sizeMask; if (includeLotContents) { Lot lotHome = household.LotHome; if (lotHome != null) { int householdFunds = household.FamilyFunds; int lotHomeLotWorth = World.GetEmptyLotWorth(lotHome.LotId) + ((int)World.GetLotAdditionalPropertyValue(lotHome.LotId)); household.SetFamilyFunds(householdFunds + lotHomeLotWorth, false); EditTownModel.SendObjectsToProperLot(lotHome); ulong contentID = DownloadContent.StoreLotContents(lotHome, lotHome.LotId); if (contentID != 0) { ThumbnailHelper.GenerateLotThumbnailSet(lotHome.LotId, contentID, ThumbnailSizeMask.ExtraLarge); ThumbnailHelper.GenerateLotThumbnail(lotHome.LotId, contentID, 0, ThumbnailSizeMask.Large | ThumbnailSizeMask.Medium); sizeMask = ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium; ThumbnailManager.GenerateHouseholdThumbnail(household.HouseholdId, contentID, sizeMask); if (!noThum && household.AllSimDescriptions.Count < 12) { ths.GenerateSimThumbnails(household, contentID, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge); } HouseholdContentsProxy contents = new HouseholdContentsProxy(household); if (DownloadContent.StoreHouseholdContents(contents, contentID)) { createdPackageFile = DownloadContent.ExportLotContentsToExportBin(contentID); } ThumbnailManager.InvalidateLotThumbnails(lotHome.LotId, contentID, ThumbnailSizeMask.ExtraLarge); ThumbnailManager.InvalidateLotThumbnailsForGroup(lotHome.LotId, contentID, ThumbnailSizeMask.Medium, 0); ThumbnailManager.InvalidateHouseholdThumbnail(household.HouseholdId, contentID, sizeMask); try { ths.InvalidateSimThumbnails(household, contentID); } catch (Exception) { if (IsOpenDGSInstalled) { return(null); } } } household.SetFamilyFunds(householdFunds, false); return(createdPackageFile); } //return createdPackageFile; } int familyFunds = household.FamilyFunds; int realEstateFunds = 0; if (household.RealEstateManager != null) { foreach (IPropertyData data in household.RealEstateManager.AllProperties) { realEstateFunds += data.TotalValue; } } if (household.LotHome != null) { int lotWorth = 0; if (isMovingPacked) { lotWorth = World.GetUnfurnishedLotWorth(household.LotHome.LotId) + realEstateFunds; } else { lotWorth = World.GetLotWorth(household.LotHome.LotId) + realEstateFunds; } household.SetFamilyFunds(household.FamilyFunds + lotWorth, false); } if (household.FamilyFunds < 20000) { household.SetFamilyFunds(20000, false); } ulong gGUID = DownloadContent.GenerateGUID(); HouseholdContentsProxy householdContents = new HouseholdContentsProxy(household); householdContents.Contents.ContentId = gGUID; sizeMask = ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium; if (!noThum && household.AllSimDescriptions.Count < 12) { ThumbnailManager.GenerateHouseholdThumbnail(household.HouseholdId, gGUID, sizeMask); ths.GenerateSimThumbnails(household, gGUID, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge); } if (DownloadContent.StoreHouseholdContents(householdContents, gGUID)) { createdPackageFile = DownloadContent.ExportLotContentsToExportBin(gGUID); } ThumbnailManager.InvalidateHouseholdThumbnail(household.HouseholdId, gGUID, sizeMask); try { ths.InvalidateSimThumbnails(household, gGUID); } catch (Exception) { if (IsOpenDGSInstalled) { return(null); } } household.SetFamilyFunds(familyFunds, false); return(createdPackageFile); } catch (Exception) { return(null); } }
public static Household _ImportHousehold(string packageFile, Lot moveinLot, bool full, bool askToCreateSim, out HouseholdContents contents) { contents = null; if (packageFile == null || packageFile.Length == 0) { return(null); } try { HouseholdContentsProxy hoc = HouseholdContentsProxy.Import(packageFile); if (hoc != null) { Household mhouse = hoc.Household; if (mhouse != null && mhouse.mMembers != null && mhouse.AllSimDescriptions != null && mhouse.AllSimDescriptions.Count != 0) { foreach (SimDescription item in mhouse.AllSimDescriptions.ToArray()) { item.mHousehold = mhouse; } try { mhouse.FixupGenealogy(); } catch (Exception) { } foreach (SimDescription item in mhouse.AllSimDescriptions.ToArray()) { try { item.Fixup(); } catch (Exception) { } } bool donelotofmovein = false; if (moveinLot != null && moveinLot.mHousehold == null) { donelotofmovein = true; try { moveinLot.MoveIn(mhouse); } catch (Exception) { moveinLot.mHousehold = mhouse; mhouse.mLotId = moveinLot.mLotId; mhouse.mLotHome = moveinLot; } } if (!full) { full = askToCreateSim && Simulator.CheckYieldingContext(false) && NiecMod.Nra.NFinalizeDeath.CheckAccept("Create Sim?"); } if (full) { //Sim sim = null; if (donelotofmovein) { try { foreach (SimDescription item in mhouse.AllSimDescriptions.ToArray()) { try { if (NiecMod.Nra.NFinalizeDeath.SimDesc_OutfitsIsValid(item)) { item.Instantiate(Service.GetPositionInRandomLot(moveinLot), false); } } catch (Exception) { } } } catch (Exception) { } } try { BinCommon.CreateInventories(mhouse, hoc.Contents, NiecMod.Nra.NFinalizeDeath.CreateIndexMap_(mhouse)); } catch (Exception) { } } contents = hoc.Contents; return(mhouse); } else { if (mhouse != null) { mhouse.Destroy(); } NiecMod.Nra.NiecException.PrintMessagePro("Check mhouse is invalid.\nSorry :(", false, 100); } } else { NiecMod.Nra.NiecException.PrintMessagePro("Could not find Package File" + "\n" + packageFile, false, 1000); } } catch (Exception) { } return(null); }