private static void SpawnAlarmCallBack() { try { if (Household.ActiveHousehold == null) return; UnicornPool.sSpawnAlarm = AlarmHandle.kInvalidHandle; if (RandomUtil.RandomChance01(UnicornPool.kChanceOfSpawningUnicorn)) { using (BaseWorldReversion reversion = new BaseWorldReversion()) { UnicornPool.SpawnNPCUnicorn(false); } } } catch (Exception e) { Common.Exception("SpawnAlarmCallBack", e); } }
private static void HerdBehaviorCallback() { try { using (BaseWorldReversion reversion = new BaseWorldReversion()) { PetPool pool; if (!PetPoolManager.TryGetPetPool(PetPoolType.WildHorse, out pool)) return; WildHorsePool ths = pool as WildHorsePool; ths.HerdBehaviorCallback(); } } catch (ResetException) { throw; } catch (Exception e) { Common.Exception("HerdBehaviorCallback", e); } }
public static bool ImportTravellingHousehold() { Common.StringBuilder msg = new Common.StringBuilder("ImportTravellingHousehold" + Common.NewLine); Traveler.InsanityWriteLog(msg); try { // Store in persistence CrossWorldControl.sRetention.OnImportHousehold(); // Must be set prior to selecting a lot for the traveling family WorldData.SetVacationWorld(true, true); GameStates.sTravelData.mDeadSims = new List<ulong>(GameStates.sTravelData.mTravelerIds); msg += Common.NewLine + "A"; Traveler.InsanityWriteLog(msg); sAllTravelIds.Clear(); Dictionary<ulong, SimDescription> travelers = new Dictionary<ulong, SimDescription>(); Household travelHouse = null; HouseholdContents contents = null; if (GameStates.sTravelData.mTravelerIds.Count > 0) { try { Household.IsTravelImport = true; // Faking a Base world game ensures that all the data is imported (careers specifically) using (BaseWorldReversion reversion = new BaseWorldReversion()) { contents = BinEx.ImportHouseholdForTravel(); } } finally { Household.IsTravelImport = false; } msg += Common.NewLine + "B"; Traveler.InsanityWriteLog(msg); if (contents == null) { msg += Common.NewLine + "contents == null"; } travelHouse = contents.Household; if (travelHouse == null) { msg += Common.NewLine + "travelHouse = null"; } else if (travelHouse.AllSimDescriptions == null) { msg += Common.NewLine + "travelHouse.AllSimDescriptions = null"; } for (int i = travelHouse.AllSimDescriptions.Count - 1; i >= 0; i--) { SimDescription sim = travelHouse.AllSimDescriptions[i]; msg += Common.NewLine + sim.FullName; CrossWorldControl.Restore(sim); if (sim == null) { travelHouse.CurrentMembers.RemoveAt(i); } else { MiniSimDescription miniSim = MiniSimDescription.Find(sim.SimDescriptionId); if (miniSim != null) { miniSim.Instantiated = true; miniSim.mHomeWorld = sim.HomeWorld; } travelers[sim.SimDescriptionId] = sim; if ((Traveler.Settings.mSetAsUnselectable) && (GameStates.sTravelData.mState == GameStates.TravelData.TravelState.StartVacation)) { if (!CrossWorldControl.sRetention.mTrueActives.ContainsKey(sim.SimDescriptionId)) { sim.SetFlags(SimDescription.FlagField.IsNeverSelectable, true); } } } sAllTravelIds[sim.SimDescriptionId] = true; } CrossWorldControl.Clear(); } msg += Common.NewLine + "C1"; Traveler.InsanityWriteLog(msg); Household.CreatePreviousTravelerHousehold(); msg += Common.NewLine + "C2"; Traveler.InsanityWriteLog(msg); if ((!GameStates.IsNewGame) && (GameStates.sTravelData.mState == GameStates.TravelData.TravelState.StartVacation)) { List<SimDescription> list = new List<SimDescription>(); WorldName currentWorld = GameUtils.GetCurrentWorld(); foreach (SimDescription sim in Household.EverySimDescription()) { try { SimDescription traveler = null; if (travelers.TryGetValue(sim.SimDescriptionId, out traveler)) { if (object.ReferenceEquals(traveler, sim)) continue; list.Add(sim); } else { MiniSimDescription miniSim = MiniSimDescription.Find(sim.SimDescriptionId); if (miniSim != null) { if (WorldData.IsFromDifferentWorld(sim.SimDescriptionId)) { list.Add(sim); } if (!GameStates.IsIdTravelling(sim.SimDescriptionId)) { miniSim.Instantiated = true; } } } } catch (Exception e) { Common.Exception(sim, null, msg, e); } } msg += Common.NewLine + "C3"; Traveler.InsanityWriteLog(msg); foreach (Urnstone urnstone in Sims3.Gameplay.Queries.GetObjects<Urnstone>()) { urnstone.UpdateInstantiatedField(); } msg += Common.NewLine + "C4"; Traveler.InsanityWriteLog(msg); foreach (SimDescription sim in list) { try { msg += Common.NewLine + sim.FullName; if (sim.CreatedSim != null) { msg += Common.NewLine + "Destroy"; sim.CreatedSim.Destroy(); SpeedTrap.Sleep(); } if (Household.PreviousTravelerHousehold != sim.Household) { msg += Common.NewLine + "Remove"; sim.Household.Remove(sim, !sim.Household.IsSpecialHousehold); Household.PreviousTravelerHousehold.AddTemporary(sim); } } catch (Exception e) { Common.Exception(sim, null, msg, e); } } } WorldData.MergeFromCrossWorldData(); GameStates.TravelData.TravelState travelState = GameStates.sTravelData.mState; if (travelHouse != null) { switch (travelState) { case GameStates.TravelData.TravelState.StartVacation: GameStates.sTravelData.mTravelHouse = travelHouse; msg += Common.NewLine + "Start D"; Traveler.InsanityWriteLog(msg); List<SimDescription> list2 = new List<SimDescription>(); uint familyIndex = (uint)travelHouse.AllSimDescriptions.Count; for (int travelIndex = travelHouse.AllSimDescriptions.Count - 1; travelIndex >= 0; travelIndex--) { SimDescription travelSim = travelHouse.AllSimDescriptions[travelIndex]; msg += Common.NewLine + "Try: " + travelSim.FullName; try { if (!GameStates.IsIdTravelling(travelSim.SimDescriptionId)) { // Sim did not make the trip if (travelSim.IsHuman) { GameStates.sTravelData.mNumLeftBehindPlusPregnancy++; if (travelSim.Pregnancy != null) { GameStates.sTravelData.mNumLeftBehindPlusPregnancy++; } } else { GameStates.sTravelData.mNumPetsLeftBehindPlusPregnancy++; if (travelSim.Pregnancy != null) { GameStates.sTravelData.mNumPetsLeftBehindPlusPregnancy++; } } travelHouse.CurrentMembers.RemoveAt(travelIndex); msg += Common.NewLine + "Dispose"; travelSim.Dispose(); } else { ulong inventoryIndex = contents.Inventories[travelIndex]; SimDescription existingSim = Household.PreviousTravelerHousehold.FindMember(travelSim.SimDescriptionId); if (existingSim != null) { existingSim.Fixup(); // Existing sim located in town msg += Common.NewLine + "Found: " + existingSim.FullName; Traveler.InsanityWriteLog(msg); if (BinEx.ImportSim(existingSim, Vector3.OutOfWorld, inventoryIndex)) { // Moved, as Imaginary Friends require that the sim be Created before altering occult SimDescriptionEx.MergeTravelInformation(existingSim, travelSim, false); msg += Common.NewLine + " Imported"; Traveler.InsanityWriteLog(msg); if ((existingSim.CreatedSim != null) && (existingSim.CreatedSim.BuffManager != null)) { existingSim.CreatedSim.BuffManager.LoadBuffsFromTravel(travelSim); } existingSim.MergePregnancyInformation(travelSim); travelHouse.CurrentMembers.RemoveAt(travelIndex); travelSim.DisposeTravelImportedSimDesc(); list2.Add(existingSim); GameStates.GhostSetup(existingSim); } } else { // Brand new sim in town msg += Common.NewLine + "New: " + travelSim.FullName; Traveler.InsanityWriteLog(msg); if (BinEx.ImportSim(travelSim, Vector3.OutOfWorld, inventoryIndex)) { msg += Common.NewLine + " Imported"; Traveler.InsanityWriteLog(msg); GameStates.GhostSetup(travelSim); } } } } catch (Exception e) { Common.Exception(travelSim, null, msg, e); } } msg += Common.NewLine + "E"; Traveler.InsanityWriteLog(msg); Bin.ImportHouseholdInventories(contents, travelHouse, familyIndex, false); foreach (SimDescription sim in list2) { try { Household.PreviousTravelerHousehold.RemoveSimKeepHousehold(sim); travelHouse.AddSilent(sim); sim.OnHouseholdChanged(travelHouse, false); } catch (Exception e) { Common.Exception(sim, null, msg, e); } } msg += Common.NewLine + "F"; Traveler.InsanityWriteLog(msg); // Calls custom version VacationArrival(travelHouse); msg += Common.NewLine + "G"; Traveler.InsanityWriteLog(msg); break; case GameStates.TravelData.TravelState.EndVacation: msg += Common.NewLine + "End D"; Traveler.InsanityWriteLog(msg); // Custom function WorldData.ResetWorldType(); List<SimDescription> carTravelers = new List<SimDescription>(); List<SimDescription> earlyDepartureSims = null; SimDescription restoreSim = null; int index = -1; foreach (SimDescription travelSim in Households.All(travelHouse)) { msg += Common.NewLine + travelSim.FullName; Traveler.InsanityWriteLog(msg); try { GameStates.sTravelData.mDeadSims.Remove(travelSim.SimDescriptionId); index++; SimDescription item = SimDescription.Find(travelSim.SimDescriptionId); bool ageChanged = travelSim.AgeGenderSpecies != item.AgeGenderSpecies; Sim createdSim = item.CreatedSim; if (createdSim == null) { msg += Common.NewLine + "D1"; Traveler.InsanityWriteLog(msg); if (GameStates.sTravelData.mSimDescriptionNeedPostFixUp == null) { GameStates.sTravelData.mSimDescriptionNeedPostFixUp = new List<SimDescription>(); } GameStates.sTravelData.mSimDescriptionNeedPostFixUp.Add(item); createdSim = Instantiation.Perform(item, Vector3.OutOfWorld, null, null); } else { msg += Common.NewLine + "D2"; Traveler.InsanityWriteLog(msg); if (ageChanged) { if (GameStates.sTravelData.mSimDescriptionAgedUpFixUp == null) { GameStates.sTravelData.mSimDescriptionAgedUpFixUp = new List<GameStates.SimRefreshData>(); } GameStates.sTravelData.mSimDescriptionAgedUpFixUp.Add(new GameStates.SimRefreshData(item, travelSim, contents.Inventories[index], createdSim.Position, Sim.ActiveActor == createdSim)); createdSim.Destroy(); createdSim = null; item.CreatedSim = null; } else if (createdSim.Household.IsTouristHousehold) { if (GameStates.sTravelData.mSimDescriptionNeedPostFixUp == null) { GameStates.sTravelData.mSimDescriptionNeedPostFixUp = new List<SimDescription>(); } GameStates.sTravelData.mSimDescriptionNeedPostFixUp.Add(item); } msg += Common.NewLine + "D3"; Traveler.InsanityWriteLog(msg); SimDescriptionEx.MergeTravelInformation(item, travelSim, true); msg += Common.NewLine + "D4"; Traveler.InsanityWriteLog(msg); if (createdSim != null) { createdSim.BuffManager.LoadBuffsFromTravel(travelSim); } msg += Common.NewLine + "D5"; Traveler.InsanityWriteLog(msg); item.MergePregnancyInformation(travelSim); if ((createdSim != null) && (GameStates.ReturningFromWorld == WorldType.Vacation)) { createdSim.BuffManager.AddElement(BuffNames.WentToLocation, Origin.FromVisitingLocation); BuffWentToLocation.BuffInstanceWentToLocation element = createdSim.BuffManager.GetElement(BuffNames.WentToLocation) as BuffWentToLocation.BuffInstanceWentToLocation; if (element != null) { element.SetVacationWorldName(GameStates.sTravelData.mDestWorld); } } } msg += Common.NewLine + "ImportSim"; Traveler.InsanityWriteLog(msg); if (createdSim != null) { BinEx.ImportSim(item, Vector3.OutOfWorld, contents.Inventories[index]); } if (!CrossWorldControl.sRetention.IsRestoree(item)) { restoreSim = item; } if ((GameStates.sTravelData.mEarlyDepartureIds != null) && GameStates.sTravelData.mEarlyDepartureIds.Contains(item.SimDescriptionId)) { if (earlyDepartureSims == null) { earlyDepartureSims = new List<SimDescription>(); } earlyDepartureSims.Add(item); } else { carTravelers.Add(item); } if ((GameStates.ReturningFromWorld == WorldType.University) && (item.CareerManager != null)) { AcademicDegreeManager degreeManager = item.CareerManager.DegreeManager; if (degreeManager != null) { degreeManager.LastTimeAtUniversity = SimClock.ElapsedCalendarDays(); } } } catch (Exception e) { Common.Exception(travelSim, null, msg, e); } } SpeedTrap.Sleep(); msg += Common.NewLine + "E"; Traveler.InsanityWriteLog(msg); travelHouse.RealEstateManager = GameStates.sTravelData.mRealEstateManager; ReturnHomeBehaviorInHomeWorld.SetupReturnHomeBehavior(carTravelers, earlyDepartureSims); if (GameStates.sTravelData.mSimDescriptionNeedPostFixUp != null) { Household activeHousehold = Household.ActiveHousehold; foreach (SimDescription sim in GameStates.sTravelData.mSimDescriptionNeedPostFixUp) { msg += Common.NewLine + sim.FullName; sim.Household.RemoveSimKeepHousehold(sim); activeHousehold.AddTemporary(sim); } } msg += Common.NewLine + "F"; Traveler.InsanityWriteLog(msg); index++; if (restoreSim != null) { Household household = restoreSim.Household; if (household != null) { household.SharedFamilyInventory.Inventory.DestroyItems(); SpeedTrap.Sleep(); Bin.ImportHouseholdInventories(contents, household, (uint)index, false); household.MergeTravelData(travelHouse); GameStates.sNextSimToSelect = household.AllActors[0]; } } msg += Common.NewLine + "G1"; Traveler.InsanityWriteLog(msg); for (int i = travelHouse.AllSimDescriptions.Count - 1; i >= 0; i--) { SimDescription sim = travelHouse.AllSimDescriptions[i]; msg += Common.NewLine + sim.FullName; try { sim.Dispose(false); } catch (Exception e) { Common.Exception(sim, null, msg, e); } } msg += Common.NewLine + "G2"; Traveler.InsanityWriteLog(msg); travelHouse.Destroy(); GameStates.ReturningFromWorld = WorldType.Undefined; break; } } // Must be performed whether there is a traveling household or not switch (travelState) { case GameStates.TravelData.TravelState.StartVacation: List<SimDescription> list3 = new List<SimDescription>(Households.All(Household.PreviousTravelerHousehold)); foreach (SimDescription sim in list3) { try { msg += Common.NewLine + "Disposed: " + sim.FullName + " (" + sim.SimDescriptionId + ")"; Household.PreviousTravelerHousehold.RemoveSimKeepHousehold(sim); sim.Dispose(false, false, false); } catch (Exception e) { Common.Exception(sim, null, msg, e); } } break; } msg += Common.NewLine + "H"; Traveler.InsanityWriteLog(msg); if ((GameStates.sTravelData.mState == GameStates.TravelData.TravelState.EndVacation) && GameStates.sTravelData.mbItemsAddedToInventory) { Sim activeActor = Sim.ActiveActor; if (activeActor != null) { activeActor.AddAlarm(2f, TimeUnit.Minutes, activeActor.ShowItemsAddFromTravelTNS, "Display TNS of Added Items", AlarmType.AlwaysPersisted); } } msg += Common.NewLine + "I"; Traveler.InsanityWriteLog(msg); PersistStatic.MainMenuLoading = true; Tutorialette.ResetTutorialetteCoolDownTimer(); if (GameStates.TravelHousehold != null) { ThumbnailManager.GenerateHouseholdThumbnail(GameStates.TravelHousehold.HouseholdId, GameStates.TravelHousehold.HouseholdId, ThumbnailSizeMask.Large); } return true; } catch (Exception e) { Traveler.InsanityException(msg, e); return false; } }
protected override bool OnPerform() { if ((HudController.Instance != null) && (GameUtils.IsOnVacation())) { HudModel model = HudController.Instance.mHudModel as HudModel; if (model != null) { if (model.MinuteChanged != null) { foreach (Delegate del in model.MinuteChanged.GetInvocationList()) { TimeControl control = del.Target as TimeControl; if (control != null) { TimeControlEx.sThs = control; model.MinuteChanged -= TimeControlEx.sThs.OnMinuteChanged; model.MinuteChanged -= TimeControlEx.OnMinuteChanged; model.MinuteChanged += TimeControlEx.OnMinuteChanged; break; } } } } } InventoryPanel inventory = InventoryPanel.sInstance; if ((inventory != null) && (inventory.Visible)) { if (inventory.mTimeAlmanacButton != null) { if (GameUtils.IsFutureWorld()) { inventory.mTimeAlmanacButton.Visible = (GameStates.TravelHousehold == Household.ActiveHousehold); } if (inventory.mTimeAlmanacButton.Visible) { inventory.mTimeAlmanacButton.Click -= inventory.OnClickTimeAlmanac; inventory.mTimeAlmanacButton.Click -= FutureDescendantServiceEx.OnClickTimeAlmanac; inventory.mTimeAlmanacButton.Click += FutureDescendantServiceEx.OnClickTimeAlmanac; } } } EditTownPuck puck = EditTownPuck.Instance; if (puck != null) { if (puck.mReturnToLiveButton != null) { puck.mReturnToLiveButton.Click -= puck.OnReturnToLive; puck.mReturnToLiveButton.Click -= OnReturnToLive; puck.mReturnToLiveButton.Click += OnReturnToLive; } } EditTownInfoPanel panel = EditTownInfoPanel.Instance; if (panel != null) { if ((panel.mActionButtons != null) && (panel.mActionButtons.Length > 8) && (panel.mActionButtons[0x8] != null)) { panel.mActionButtons[0x8].Click -= panel.OnChangeTypeClick; panel.mActionButtons[0x8].Click -= OnChangeTypeClick; panel.mActionButtons[0x8].Click += OnChangeTypeClick; } } OptionsDialog options = OptionsDialog.sDialog; if (options != null) { if (GameUtils.IsInstalled(ProductVersion.EP8)) { Button testButton = options.mSeasonWindow.GetChildByID(0xdf085c3, true) as Button; if ((testButton != null) && (!testButton.Enabled)) { using (BaseWorldReversion reversion = new BaseWorldReversion()) { foreach (Button weather in options.mEnabledWeatherButtons.Values) { weather.Enabled = true; } if (options.mFahrenheitRadio != null) { options.mFahrenheitRadio.Enabled = true; } if (options.mCelciusRadio != null) { options.mCelciusRadio.Enabled = true; } options.SetupSeasonControls(false, ref options.mOldSeasonData); } } } } FutureDescendantService instance = FutureDescendantServiceEx.GetInstance(); if (Sims3.UI.Responder.Instance.InLiveMode && Traveler.Settings.mDisableDescendants && instance.mEventListeners.Count > 0) { instance.CleanUpEventListeners(); } return true; }
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 void Dispose() { try { mSim.AssignedRole = mRole; mSim.IsNeverSelectable = mNeverSelectable; if (mSim.CelebrityManager != null) { mSim.CelebrityManager.ScheduleOpportunityCallIfNecessary(); } if (mOpportunities != null) { mOpportunities.Dispose(); } if ((mSchool != null) && (mSim.CareerManager != null)) { mSim.CareerManager.mSchool = mSchool; } if ((mCareer != null) && (mSim.CareerManager != null) && (mSim.Occupation == null)) { mSim.CareerManager.mJob = mCareer; if (mSim.Occupation != null) { using (BaseWorldReversion reversion = new BaseWorldReversion()) { if ((mFlags & Flag.LoadFixup) == Flag.LoadFixup) { mSim.Occupation.OnLoadFixup(false); } if (((mFlags & Flag.Selectable) == Flag.Selectable) && (SimTypes.IsSelectable(mSim))) { using (StoryProgressionServiceEx.SuppressCreateHousehold suppress = new StoryProgressionServiceEx.SuppressCreateHousehold()) { bool careerLoc = true; if (mSim.Occupation is Career) { careerLoc = (mSim.Occupation.CareerLoc != null); } if (careerLoc) { Corrections.FixCareer(mSim.Occupation, false, null); mSim.Occupation.OnOwnerBecameSelectable(); } } } else if ((mFlags & Flag.Unselectable) == Flag.Unselectable) { using (StoryProgressionServiceEx.SuppressCreateHousehold suppress = new StoryProgressionServiceEx.SuppressCreateHousehold()) { mSim.Occupation.OnOwnerBecameUnselectable(); } } } mSim.CareerManager.UpdateCareerUI(); } } } catch (Exception e) { Common.Exception(mSim, e); } }