public static bool PayForLot(EditTownModel ths, UIBinInfo info, ulong lotId) { Lot lot = LotManager.GetLot(lotId); if (lot != null) { ExportBinContents contents = ths.FindExportBinContents(info.ContentId); if (contents != null) { bool flag = contents.IsLoaded(); if (!flag) { ExportBinContentsEx.Import(contents, true); } Household household = contents.Household; if (household != null) { return(BinCommonEx.PayForLot(household, lot, true, Mover.GetLotCost)); } if (!flag) { ExportBinContentsEx.Flush(contents); } } else if (info.LotId != ulong.MaxValue) { LotContents contents2 = Bin.Singleton.FindLot(info.LotId); if ((contents2 != null) && (contents2.Household != null)) { Household household2 = contents2.Household.Household; if (household2 != null) { return(BinCommonEx.PayForLot(household2, lot, true, Mover.GetLotCost)); } } } else if (info.HouseholdId != ulong.MaxValue) { Household household3 = Household.Find(info.HouseholdId); if (household3 != null) { return(BinCommonEx.PayForLot(household3, lot, true, Mover.GetLotCost)); } } } return(false); }
public static bool PayForLot(EditTownModel ths, UIBinInfo info, ulong lotId) { Lot lot = LotManager.GetLot(lotId); if (lot != null) { ExportBinContents contents = ths.FindExportBinContents(info.ContentId); if (contents != null) { bool flag = contents.IsLoaded(); if (!flag) { ExportBinContentsEx.Import(contents, true); } Household household = contents.Household; if (household != null) { return BinCommonEx.PayForLot(household, lot, true, Mover.GetLotCost); } if (!flag) { ExportBinContentsEx.Flush(contents); } } else if (info.LotId != ulong.MaxValue) { LotContents contents2 = Bin.Singleton.FindLot(info.LotId); if ((contents2 != null) && (contents2.Household != null)) { Household household2 = contents2.Household.Household; if (household2 != null) { return BinCommonEx.PayForLot(household2, lot, true, Mover.GetLotCost); } } } else if (info.HouseholdId != ulong.MaxValue) { Household household3 = Household.Find(info.HouseholdId); if (household3 != null) { return BinCommonEx.PayForLot(household3, lot, true, Mover.GetLotCost); } } } return false; }
public static PlaceResult PlaceFromGameBin(EditTownModel ths, UIBinInfo info, ulong lotId, PlaceAction action) { PlaceResult contentFailure = PlaceResult.ContentFailure; Lot lot = LotManager.GetLot(lotId); if (lot == null) { return(PlaceResult.InvalidLot); } else if (lot.Household != null) { return(PlaceResult.HouseholdPresent); } ths.GetInWorldHouseholdBinInfoList(); contentFailure = PlaceResult.ContentFailure; if (info.HouseholdId != ulong.MaxValue) { BinCommon.KickSimsOffLot(lot, true); if (info.LotId != ulong.MaxValue) { contentFailure = BinCommonEx.PlaceHouseholdAndContentsFromGameBin(info.ContentId, lot, action, Mover.GetLotCost); } else { contentFailure = BinCommonEx.PlaceHouseholdFromGameBin(info.ContentId, lot, action, Mover.GetLotCost); } if (contentFailure != PlaceResult.Success) { return(contentFailure); } ths.mGameBin.Remove(info); if (ths.GameBinChanged != null) { ths.GameBinChanged(ths, null); } info = BinCommon.CreateInWorldBinInfo(lot.Household, lot); if (info != null) { ths.mInWorldHouseholdBin.Add(info); } } return(contentFailure); }
public static PlaceResult PlaceFromGameBin(EditTownModel ths, UIBinInfo info, ulong lotId, PlaceAction action) { PlaceResult contentFailure = PlaceResult.ContentFailure; Lot lot = LotManager.GetLot(lotId); if (lot == null) { return PlaceResult.InvalidLot; } else if (lot.Household != null) { return PlaceResult.HouseholdPresent; } ths.GetInWorldHouseholdBinInfoList(); contentFailure = PlaceResult.ContentFailure; if (info.HouseholdId != ulong.MaxValue) { BinCommon.KickSimsOffLot(lot, true); if (info.LotId != ulong.MaxValue) { contentFailure = BinCommonEx.PlaceHouseholdAndContentsFromGameBin(info.ContentId, lot, action, Mover.GetLotCost); } else { contentFailure = BinCommonEx.PlaceHouseholdFromGameBin(info.ContentId, lot, action, Mover.GetLotCost); } if (contentFailure != PlaceResult.Success) { return contentFailure; } ths.mGameBin.Remove(info); if (ths.GameBinChanged != null) { ths.GameBinChanged(ths, null); } info = BinCommon.CreateInWorldBinInfo(lot.Household, lot); if (info != null) { ths.mInWorldHouseholdBin.Add(info); } } return contentFailure; }
public static PlaceResult PlaceFromExportBin(EditTownModel ths, UIBinInfo info, ulong lotId, PlaceAction action, bool showConfirmDialog) { try { PlaceResult contentFailure = PlaceResult.ContentFailure; Lot lot = LotManager.GetLot(lotId); if (lot == null) { return(PlaceResult.InvalidLot); } ExportBinContents exportBinItem = ths.FindExportBinContents(info.ContentId); if (exportBinItem != null) { ths.GetInWorldHouseholdBinInfoList(); ths.GetInWorldLotBinInfoList(); Sim newActiveSim = null; if (lot.Household != null) { return(BinCommonEx.MergeHouseholdFromExportBin(exportBinItem, lot, showConfirmDialog, Mover.Settings.mAllowGreaterThanEight)); } BinCommon.KickSimsOffLot(lot, true); ProgressDialog.Show(Localization.LocalizeString("Ui/Caption/Global:Processing", new object[0x0])); try { try { contentFailure = BinCommonEx.PlaceFromExportBin(exportBinItem, lot, action, true, Mover.GetLotCost, ref newActiveSim); ExportBinContentsEx.Flush(exportBinItem); UIBinInfo item = BinCommon.CreateInWorldBinInfo(lot.Household, lot); if (item != null) { if (info.HouseholdId != ulong.MaxValue) { ths.mInWorldHouseholdBin.Add(item); } else { ths.mInWorldLotBin.Add(item); } } } finally { ProgressDialog.Close(); } } catch (ExecutionEngineException) { } } return(contentFailure); } catch (Exception e) { Common.Exception("PlaceFromExportBin", e); return(PlaceResult.ContentFailure); } }
public static PlaceResult PlaceFromExportBin(EditTownModel ths, UIBinInfo info, ulong lotId, PlaceAction action) { return(PlaceFromExportBin(ths, info, lotId, action, true)); }
private static bool ChangeLotTypeHelper(Lot lot, bool deleteInvalidObjects, LotType newType, CommercialLotSubType commercialSubType, ResidentialLotSubType residentialSubType) { List <GameObject> objects = null; if (newType == LotType.Commercial) { // Custom //objects = lot.GetObjects<GameObject>(new Predicate<GameObject>(EditTownModel.IsNotValidCommunityLotObject)); if (commercialSubType == CommercialLotSubType.kEP10_Resort) { foreach (RabbitHole hole in lot.GetObjects <RabbitHole>(new Predicate <RabbitHole>(EditTownModel.IsInvestable))) { objects.Add(hole); } if (lot.ResortManager == null) { lot.ResortManager = new ResortManager(lot); } } } else { // Custom //objects = lot.GetObjects<GameObject>(new Predicate<GameObject>(EditTownModel.IsNotValidResidentialLotObject)); } if ((objects != null) && (objects.Count > 0)) { if (!deleteInvalidObjects) { return(false); } foreach (GameObject obj2 in objects) { int num = 0; bool flag = false; while (obj2.ActorsUsingMe.Count > num) { Sim sim = obj2.ActorsUsingMe[num]; if (sim != null) { sim.SetObjectToReset(); sim.InteractionQueue.PurgeInteractions(obj2); flag = true; } num++; } if (flag) { SpeedTrap.Sleep(0); } lot.RemoveObjectFromLot(obj2.ObjectId, true); obj2.Destroy(); } ThumbnailKey key = new ThumbnailKey(new ResourceKey(lot.LotId, 0x436fee4c, 0), ThumbnailSize.Large); ThumbnailManager.InvalidateThumbnail(key); EditTownModel.UpdateDirtyLotThumbnailsTask(true); } if (lot.CommercialLotSubType == CommercialLotSubType.kEP10_Resort) { foreach (IResortBuffetTable table in lot.GetObjects <IResortBuffetTable>()) { table.ClearTable(); } } if (GameStates.IsEditTownState) { BinCommon.KickSimsOffLot(lot, true); } return(true); }
public static bool ChangeLotType(ulong lotId, bool deleteInvalidObjects, LotType newType, CommercialLotSubType commercialSubType, ResidentialLotSubType residentialSubType) { EditTownModel ths = EditTownController.Instance.mModel as EditTownModel; Lot lot = LotManager.GetLot(lotId); if (lot == null) { return(false); } if (newType == LotType.Residential) { commercialSubType = CommercialLotSubType.kCommercialUndefined; } else { residentialSubType = ResidentialLotSubType.kResidentialUndefined; } if ((newType != LotType.Residential) && (commercialSubType == CommercialLotSubType.kCommercialUndefined)) { return(false); } if (!ChangeLotTypeHelper(lot, deleteInvalidObjects, newType, commercialSubType, residentialSubType)) { return(false); } ths.GetInWorldCommunityLotBinInfoList(); ths.GetInWorldLotBinInfoList(); lot.LotType = newType; lot.CommercialLotSubType = commercialSubType; lot.ResidentialLotSubType = residentialSubType; if (lot.IsCommunityLot) { UIBinInfo item = ths.FindLotBinInfo(lotId); bool flag2 = true; if (item == null) { flag2 = false; item = ths.FindCommunityLotBinInfo(lotId); } if (item != null) { item.LotTypeFilter = 0x8; item.LotType = newType; item.CommercialLotSubType = commercialSubType; item.ResidentialLotSubType = residentialSubType; if (flag2) { ths.mInWorldLotBin.Remove(item); ths.mInWorldCommunityLotBin.Add(item); } } } else { UIBinInfo info2 = ths.FindCommunityLotBinInfo(lotId); bool flag3 = true; if (info2 == null) { flag3 = false; info2 = ths.FindLotBinInfo(lotId); } if (info2 != null) { if (World.LotIsEmpty(lotId) && lot.IsLotEmptyFromObjects()) { info2.LotTypeFilter = 0x2; } else { info2.LotTypeFilter = 0x4; } info2.LotType = newType; info2.CommercialLotSubType = commercialSubType; info2.ResidentialLotSubType = residentialSubType; if (flag3) { ths.mInWorldCommunityLotBin.Remove(info2); ths.mInWorldLotBin.Add(info2); } } } SpeedTrap.Sleep(); lot.EnsureLotObjects(); try { Sims3.Gameplay.Services.Services.ClearServicesForLot(lot); } catch (Exception e) { Common.Exception(lot, e); } Occupation.ValidateJobConsistencyWithLotType(lot); lot.UpdateCachedValues(); return(true); }
public static string ExportHousehold(Bin ths, Household household, bool includeLotContents, bool isMovingPacked) { try { string str = null; if (GameUtils.IsInstalled(ProductVersion.EP4)) { OccultImaginaryFriend.ForceHouseholdImaginaryFriendsBackToInventory(household); } foreach (Sim sim in household.AllActors) { sim.SetObjectToReset(); } Common.Sleep(); if (includeLotContents) { Lot lotHome = household.LotHome; if (lotHome != null) { int num = household.FamilyFunds; int num2 = World.GetEmptyLotWorth(lotHome.LotId) + ((int)World.GetLotAdditionalPropertyValue(lotHome.LotId)); household.SetFamilyFunds(household.FamilyFunds + num2, false); EditTownModel.SendObjectsToProperLot(lotHome); ulong contentId = DownloadContent.StoreLotContents(lotHome, lotHome.LotId); if (contentId != 0x0L) { ThumbnailHelper.GenerateLotThumbnailSet(lotHome.LotId, contentId, ThumbnailSizeMask.ExtraLarge); ThumbnailHelper.GenerateLotThumbnail(lotHome.LotId, contentId, 0x0, ThumbnailSizeMask.Large | ThumbnailSizeMask.Medium); ThumbnailSizeMask mask = ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium; ThumbnailManager.GenerateHouseholdThumbnail(household.HouseholdId, contentId, mask); ths.GenerateSimThumbnails(household, contentId, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge); HouseholdContentsProxy contents = new HouseholdContentsProxy(household); if (DownloadContent.StoreHouseholdContents(contents, contentId)) { str = DownloadContent.ExportLotContentsToExportBin(contentId); } ThumbnailManager.InvalidateLotThumbnails(lotHome.LotId, contentId, ThumbnailSizeMask.ExtraLarge); ThumbnailManager.InvalidateLotThumbnailsForGroup(lotHome.LotId, contentId, ThumbnailSizeMask.Medium, 0x0); ThumbnailManager.InvalidateHouseholdThumbnail(household.HouseholdId, contentId, mask); ths.InvalidateSimThumbnails(household, contentId); } household.SetFamilyFunds(num, false); } return(str); } 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 < 0x4e20) { household.SetFamilyFunds(0x4e20, false); } ulong cacheId = DownloadContent.GenerateGUID(); HouseholdContentsProxy householdContents = new HouseholdContentsProxy(household); householdContents.Contents.ContentId = cacheId; ThumbnailSizeMask sizeMask = ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium; ThumbnailManager.GenerateHouseholdThumbnail(household.HouseholdId, cacheId, sizeMask); ths.GenerateSimThumbnails(household, cacheId, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge); if (DownloadContent.StoreHouseholdContents(householdContents, cacheId)) { str = DownloadContent.ExportLotContentsToExportBin(cacheId); } ThumbnailManager.InvalidateHouseholdThumbnail(household.HouseholdId, cacheId, sizeMask); ths.InvalidateSimThumbnails(household, cacheId); household.SetFamilyFunds(familyFunds, false); return(str); } catch (Exception e) { Common.Exception("ExportHousehold", e); 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 void PlaceLotWizardCheck(InWorldSubState ths) { try { if ((GameStates.IsNewGame) && (GameStates.HasTravelData) && (!WorldData.IsPreviousWorld())) { WorldData.SetPreviousWorld(); WorldName currentWorld = GameUtils.GetCurrentWorld(); switch (currentWorld) { case WorldName.China: case WorldName.Egypt: case WorldName.France: break; default: if ((GameStates.sSingleton != null) && (GameStates.sSingleton.mInWorldState != null) && (GameStates.sSingleton.mInWorldState.mSubStates[0xb] != null)) { bool isChangingWorlds = GameStates.sIsChangingWorlds; WorldType currentWorldType = GameUtils.GetCurrentWorldType(); try { GameUtils.WorldNameToType.Remove(currentWorld); GameUtils.WorldNameToType.Add(currentWorld, WorldType.Base); GameStates.sIsChangingWorlds = false; BinModel.Singleton.PopulateExportBin(); EditTownModel.ClearPlaceLotsWizardFlags(); Dictionary <CommercialLotSubType, string> lotTypesToPrompt = EditTownModel.LotTypesToPrompt; if (lotTypesToPrompt.Count != 0x0) { if (BinModel.Singleton.IsClear()) { BinModel.Singleton.PopulateExportBin(); } string promptText = Common.LocalizeEAString("Ui/Caption/GameEntry/PlaceEPLotsWizard:EnterPrompt") + '\n'; try { InWorldSubState.AutoVenuPlacementData.Parse(); foreach (KeyValuePair <CommercialLotSubType, string> pair in lotTypesToPrompt) { promptText = promptText + '\n' + pair.Value; if (InWorldSubState.AutoVenuPlacementData.HasPlacementDataForWorldName(World.GetWorldFileName())) { UIBinInfo lotToPlaceInfo = null; UIBinInfo targetLotInfo = null; LotRotationAngle kLotRotateAuto = LotRotationAngle.kLotRotateAuto; List <IExportBinContents> exportBinContents = BinModel.Singleton.ExportBinContents; if (ths.FindRequiredEPVenuePlacementInfo(pair.Key, exportBinContents, out lotToPlaceInfo, out targetLotInfo, out kLotRotateAuto)) { EditTownModel.AddForcedLocationLotToPlace(pair.Key, lotToPlaceInfo, targetLotInfo, kLotRotateAuto); } } } } finally { InWorldSubState.AutoVenuPlacementData.Shutdown(); } if (TwoButtonDialog.Show(promptText, Common.LocalizeEAString("Ui/Caption/GameEntry/PlaceEPLotsWizard:Accept"), Common.LocalizeEAString("Ui/Caption/GameEntry/PlaceEPLotsWizard:Decline"))) { GameStates.sSingleton.mInWorldState.mSubStates[0xb].PlaceRequiredEPVenues(); } } } finally { GameStates.sIsChangingWorlds = isChangingWorlds; GameUtils.WorldNameToType.Remove(currentWorld); GameUtils.WorldNameToType.Add(currentWorld, currentWorldType); } } break; } } else { ths.PlaceLotWizardCheck(); } } catch (Exception e) { Common.Exception("PlaceLotWizardCheck", e); } }
public override void Startup() { Common.StringBuilder msg = new Common.StringBuilder("InWorldStateEx:Startup"); Traveler.InsanityWriteLog(msg); try { // StateMachineState:Startup() mBaseCallFlag |= BaseCallFlag.kStartup; //base.Startup(); msg += Common.NewLine + "A"; Traveler.InsanityWriteLog(msg); Sims3.Gameplay.UI.Responder.GameStartup(); mEnteredFromTravelling = GameStates.IsTravelling; bool flag = false; try { ModalDialog.EnableModalDialogs = false; if (World.IsEditInGameFromWBMode()) { Sims3.Gameplay.Autonomy.Autonomy.DisableMoodContributors = true; } msg += Common.NewLine + "B"; Traveler.InsanityWriteLog(msg); mStateMachine = StateMachine.Create(0x1, "InWorld"); mSubStates[0] = new LiveModeStateEx(GameStates.IsMovingWorlds); // Custom mSubStates[1] = new BuildModeState(); mSubStates[2] = new BuyModeState(); mSubStates[12] = new ShoppingModeState(); mSubStates[3] = new CASFullModeState(); mSubStates[4] = new CASDresserModeState(); mSubStates[5] = new CASMirrorModeState(); mSubStates[6] = new CASTattooModeState(); mSubStates[7] = new CASStylistModeState(); mSubStates[8] = new CASTackModeState(); mSubStates[9] = new CASCollarModeState(); mSubStates[10] = new CASSurgeryFaceModeState(); mSubStates[11] = new CASSurgeryBodyModeState(); mSubStates[15] = new PlayFlowStateEx(); // Custom mSubStates[14] = new EditTownStateEx(); // Custom mSubStates[16] = new BlueprintModeState(); mSubStates[17] = new CASMermaidModeState(); mSubStates[0x12] = new CABModeState(); mSubStates[0x13] = new CABModeEditState(); foreach (InWorldSubState state in mSubStates) { mStateMachine.AddState(state); } msg += Common.NewLine + "C"; Traveler.InsanityWriteLog(msg); StateMachineManager.AddMachine(mStateMachine); if (GameStates.IsTravelling || GameStates.IsEditingOtherTown) { try { Sims3.Gameplay.WorldBuilderUtil.CharacterImportOnGameLoad.RemapSimDescriptionIds(); } catch (Exception e) { Common.DebugException("RemapSimDescriptionIds", e); } } else { CrossWorldControl.sRetention.RestoreHouseholds(); } msg += Common.NewLine + "D"; Traveler.InsanityWriteLog(msg); if (GameStates.IsTravelling) { msg += Common.NewLine + "E1"; Traveler.InsanityWriteLog(msg); bool fail = false; if (!GameStatesEx.ImportTravellingHousehold()) { msg += Common.NewLine + "E3"; fail = true; } if ((GameStates.TravelHousehold == null) && (GameStates.sTravelData.mState == GameStates.TravelData.TravelState.StartVacation)) { msg += Common.NewLine + "E4"; fail = true; } if (fail) { msg += Common.NewLine + "E5"; Traveler.InsanityWriteLog(msg); GameStates.sStartupState = SubState.EditTown; GameStates.ClearTravelStatics(); WorldData.SetVacationWorld(true, true); } } else if ((!GameStates.IsEditingOtherTown) && (GameStates.HasTravelData) && (GameStates.TravelHousehold == null)) { switch (GameUtils.GetCurrentWorldType()) { case WorldType.Base: case WorldType.Downtown: msg += Common.NewLine + "E2"; Traveler.InsanityWriteLog(msg); GameStates.ClearTravelStatics(); break; } } // Custom if (GameStates.sMovingWorldData != null) { Household.IsTravelImport = true; } msg += Common.NewLine + "F1"; Traveler.InsanityWriteLog(msg); List <Household> households = new List <Household>(Household.sHouseholdList); foreach (Household a in households) { if ((a.LotHome != null) && (a.LotHome.Household == null)) { a.LotHome.mHousehold = a; } foreach (SimDescription simA in Households.All(a)) { // Must be validated prior to SimDescription:PostLoadFixup() if (simA.GameObjectRelationships != null) { for (int index = simA.GameObjectRelationships.Count - 1; index >= 0; index--) { if ((simA.GameObjectRelationships[index] == null) || (simA.GameObjectRelationships[index].GameObjectDescription == null) || (simA.GameObjectRelationships[index].GameObjectDescription.GameObject == null) || (!Objects.IsValid(simA.GameObjectRelationships[index].GameObjectDescription.GameObject.ObjectId))) { simA.GameObjectRelationships.RemoveAt(index); } } } foreach (Household b in households) { if (a == b) { continue; } if (!b.Contains(simA)) { continue; } if (b.NumMembers == 1) { continue; } try { b.Remove(simA, false); msg += Common.NewLine + "Duplicate: " + simA.FullName; } catch (Exception e) { Common.Exception(simA, e); } } } } msg += Common.NewLine + "F2"; Traveler.InsanityWriteLog(msg); // Required to ensure that all homeworld specific data is fixed up properly (specifically careers) using (BaseWorldReversion reversion = new BaseWorldReversion()) { // Reset this, to allow the Seasons Manager to activate properly SeasonsManager.sSeasonsValidForWorld = SeasonsManager.Validity.Undetermined; try { mPostWorldInitializers = new Initializers("PostWorldInitializers", this); using (CareerStore store = new CareerStore()) { //InitializersEx.Initialize(mPostWorldInitializers); mPostWorldInitializers.Initialize(); } } catch (Exception e) { Traveler.InsanityException(msg, e); } } msg += Common.NewLine + "G1"; Traveler.InsanityWriteLog(msg); try { if (GameStates.TravelHousehold != null) { LinkToTravelHousehold(); WorldName worldName = GameUtils.GetCurrentWorld(); switch (worldName) { case WorldName.China: case WorldName.Egypt: case WorldName.France: break; default: foreach (SimDescription sim in Households.All(GameStates.TravelHousehold)) { if (sim.VisaManager == null) { continue; } WorldData.OnLoadFixup(sim.VisaManager); sim.VisaManager.SetVisaLevel(worldName, 3); } break; } } } catch (Exception e) { Traveler.InsanityException(msg, e); } msg += Common.NewLine + "G2"; Traveler.InsanityWriteLog(msg); List <SimDescription> dyingSims = null; if (GameStates.IsTravelling) { dyingSims = GameStatesEx.PostTravelingFixUp(); } msg += Common.NewLine + "H"; Traveler.InsanityWriteLog(msg); if (GameStates.IsEditingOtherTown) { GameStates.PostLoadEditTownFixup(); } msg += Common.NewLine + "I"; Traveler.InsanityWriteLog(msg); // We must stop the travel actions from running if the homeworld is an EA vacation world WorldData.SetVacationWorld(true, false); GameStates.NullEditTownDataDataIfEditingOriginalStartingWorld(); try { if (GameUtils.IsAnyTravelBasedWorld()) { if ((dyingSims != null) && (AgingManager.NumberAgingYearsElapsed != -1f)) { float yearsGone = GameStates.NumberAgingYearsElapsed - AgingManager.NumberAgingYearsElapsed; // Custom function FixUpAfterTravel(yearsGone, dyingSims); } AgingManager.NumberAgingYearsElapsed = GameStates.NumberAgingYearsElapsed; } } catch (Exception e) { Traveler.InsanityException(msg, e); } msg += Common.NewLine + "J"; Traveler.InsanityWriteLog(msg); Sims3.Gameplay.Gameflow.GameSpeed pause = Sims3.Gameplay.Gameflow.GameSpeed.Pause; if (GameStates.StartupState == SubState.LiveMode) { flag = !GameStates.IsEditingOtherTown && (((GameStates.ForceStateChange || !PlayFlowModel.Singleton.GameEntryLive) || (PlumbBob.SelectedActor != null)) || GameStates.IsTravelling); if (flag) { if (Sims3.Gameplay.Gameflow.sGameLoadedFromWorldFile) { pause = Sims3.SimIFace.Gameflow.GameSpeed.Normal; } else { pause = Sims3.Gameplay.Gameflow.sPersistedGameSpeed; } } } msg += Common.NewLine + "K"; Traveler.InsanityWriteLog(msg); Sims3.Gameplay.Gameflow.sGameLoadedFromWorldFile = false; string s = CommandLine.FindSwitch("speed"); if (s != null) { int num2; if (int.TryParse(s, out num2)) { pause = (Sims3.Gameplay.Gameflow.GameSpeed)num2; } else { ParserFunctions.TryParseEnum <Sims3.Gameplay.Gameflow.GameSpeed>(s, out pause, Sims3.Gameplay.Gameflow.GameSpeed.Normal); } } msg += Common.NewLine + "L"; Traveler.InsanityWriteLog(msg); Sims3.Gameplay.Gameflow.SetGameSpeed(pause, Sims3.Gameplay.Gameflow.SetGameSpeedContext.GameStates); NotificationManager.Load(); MainMenu.TriggerPendingFsiWorldNotifications(); } finally { ModalDialog.EnableModalDialogs = true; } if (SocialFeatures.Accounts.IsLoggedIn()) { Notify(0, 0, 0L); } switch (GameStates.StartupState) { case SubState.EditTown: msg += Common.NewLine + "StartupState: EditTown"; GameUtils.EnableSceneDraw(true); LoadingScreenController.Unload(); GotoEditTown(); break; case SubState.PlayFlow: if (World.IsEditInGameFromWBMode()) { msg += Common.NewLine + "StartupState: PlayFlow (A)"; GameUtils.EnableSceneDraw(true); LoadingScreenController.Unload(); GotoLiveMode(); } else if (!PlayFlowModel.PlayFlowEnabled || !PlayFlowModel.Singleton.GameEntryLive) { msg += Common.NewLine + "StartupState: PlayFlow (B)"; GameUtils.EnableSceneDraw(true); LoadingScreenController.Unload(); GotoLiveMode(); } else { msg += Common.NewLine + "StartupState: PlayFlow (C)"; GotoPlayFlow(); } break; case SubState.LiveMode: // Custom if (((!GameUtils.IsOnVacation() && !GameUtils.IsFutureWorld()) || EditTownModel.IsAnyLotBaseCampStatic() || EditTownModelEx.IsAnyUnoccupiedLotStatic()) && flag) { bool directToGame = false; if (!GameStates.IsTravelling) { // Entering an existing save directToGame = true; } else if (EditTownModel.IsAnyLotBaseCampStatic()) { // Normal transition to base camp directToGame = true; } else if (!GameUtils.IsInstalled(ProductVersion.EP9)) { // Use custom household selection directToGame = true; } // Custom if ((flag) && (directToGame)) { msg += Common.NewLine + "StartupState: LiveMode (A)"; GotoLiveMode(); break; } else { msg += Common.NewLine + "StartupState: LiveMode (C)"; GameUtils.EnableSceneDraw(true); LoadingScreenController.Unload(); GotoPlayFlow(); break; } } msg += Common.NewLine + "StartupState: LiveMode (B)"; GameUtils.EnableSceneDraw(true); LoadingScreenController.Unload(); GotoEditTown(); break; } msg += Common.NewLine + "M"; Traveler.InsanityWriteLog(msg); if (Sims3.Gameplay.Gameflow.sShowObjectReplacedWarning) { SimpleMessageDialog.Show(Common.LocalizeEAString("Ui/Warning/LoadGame:Warning"), Common.LocalizeEAString("Ui/Warning/LoadGame:ReplacedObjects"), ModalDialog.PauseMode.PauseSimulator); Sims3.Gameplay.Gameflow.sShowObjectReplacedWarning = false; } } catch (Exception e) { Traveler.InsanityException(msg, e); } finally { //Common.WriteLog(msg); } }
public static PlaceResult PlaceFromExportBin(EditTownModel ths, UIBinInfo info, ulong lotId, PlaceAction action, bool showConfirmDialog) { try { PlaceResult contentFailure = PlaceResult.ContentFailure; Lot lot = LotManager.GetLot(lotId); if (lot == null) { return PlaceResult.InvalidLot; } ExportBinContents exportBinItem = ths.FindExportBinContents(info.ContentId); if (exportBinItem != null) { ths.GetInWorldHouseholdBinInfoList(); ths.GetInWorldLotBinInfoList(); Sim newActiveSim = null; if (lot.Household != null) { return BinCommonEx.MergeHouseholdFromExportBin(exportBinItem, lot, showConfirmDialog, Mover.Settings.mAllowGreaterThanEight); } BinCommon.KickSimsOffLot(lot, true); ProgressDialog.Show(Localization.LocalizeString("Ui/Caption/Global:Processing", new object[0x0])); try { try { contentFailure = BinCommonEx.PlaceFromExportBin(exportBinItem, lot, action, true, Mover.GetLotCost, ref newActiveSim); ExportBinContentsEx.Flush(exportBinItem); UIBinInfo item = BinCommon.CreateInWorldBinInfo(lot.Household, lot); if (item != null) { if (info.HouseholdId != ulong.MaxValue) { ths.mInWorldHouseholdBin.Add(item); } else { ths.mInWorldLotBin.Add(item); } } } finally { ProgressDialog.Close(); } } catch (ExecutionEngineException) { } } return contentFailure; } catch (Exception e) { Common.Exception("PlaceFromExportBin", e); return PlaceResult.ContentFailure; } }
public static PlaceResult PlaceFromExportBin(EditTownModel ths, UIBinInfo info, ulong lotId, PlaceAction action) { return PlaceFromExportBin(ths, info, lotId, action, true); }