protected static void UpdateAttractionControllers(Household newHouse, Household oldHouse) { Dictionary <Relationship, bool> toDispose = new Dictionary <Relationship, bool>(); //if (Common.AssemblyCheck.IsInstalled("NRaasChemistry")) return; if (oldHouse != null) { foreach (SimDescription sim in Households.All(oldHouse)) { foreach (Relationship relation in Relationship.Get(sim)) { if (relation.AttractionNPCController != null) { if (!toDispose.ContainsKey(relation)) { toDispose.Add(relation, true); } } } } } if (newHouse != null) { foreach (SimDescription sim in Households.All(newHouse)) { foreach (Relationship relation in Relationship.Get(sim)) { if ((!SimTypes.IsSelectable(relation.SimDescriptionA)) && (!SimTypes.IsSelectable(relation.SimDescriptionB))) { continue; } // don't blow up when one Sim is selectable but out of world (boinked parents vacation, boarding school) if ((relation.SimDescriptionA.CreatedSim == null) && (relation.SimDescriptionB.CreatedSim == null)) { continue; } if (relation.AreAttracted) { if (TestEnableAttractionNPCController(relation)) { toDispose.Remove(relation); if (relation.AttractionNPCController == null) { relation.AttractionNPCController = new AttractionNPCBehaviorController(relation); } } } } } } foreach (Relationship relation in toDispose.Keys) { relation.AttractionNPCController.Dispose(); } }
public static string Perform(Household house, bool ignorePlaceholders) { if (house.LotHome == null) { return(null); } string msg = null; if (Households.NumSims(house) != Households.AllSims(house).Count) { List <SimDescription> sims = new List <SimDescription>(Households.All(house)); foreach (SimDescription description in sims) { bool flag = true; foreach (Sim sim in Households.AllSims(house)) { if (sim.SimDescription == description) { flag = false; break; } } if (flag) { FixInvisibleTask.Perform(description, false); msg += RecoverMissingSimTask.Perform(description, ignorePlaceholders); } } } return(msg); }
public CareerStore(Household house, SafeStore.Flag flags) { mSafeStore = new Dictionary <ulong, SafeStore>(); foreach (SimDescription sim in Households.All(house)) { mSafeStore[sim.SimDescriptionId] = new SafeStore(sim, flags); } }
private new bool DoHarvest() { Soil soil; Target.RemoveHarvestStateTimeoutAlarm(); StandardEntry(); BeginCommodityUpdates(); StateMachineClient stateMachine = Target.GetStateMachine(Actor, out soil); mDummyIk = soil; bool hasHarvested = true; if (Actor.IsInActiveHousehold) { hasHarvested = false; foreach (SimDescription description in Households.All(Actor.Household)) { Gardening skill = description.SkillManager.GetSkill <Gardening>(SkillNames.Gardening); if ((skill != null) && skill.HasHarvested()) { hasHarvested = true; break; } } } if (stateMachine != null) { stateMachine.RequestState("x", "Loop Harvest"); } Plant.StartStagesForTendableInteraction(this); while (!Actor.WaitForExitReason(Sim.kWaitForExitReasonDefaultTime, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached))) { if ((ActiveStage != null) && ActiveStage.IsComplete((InteractionInstance)this)) { Actor.AddExitReason(ExitReason.StageComplete); } } Plant.PauseTendGardenInteractionStage(Actor.CurrentInteraction); if (Actor.HasExitReason(ExitReason.StageComplete)) { DoHarvest(Target, Actor, hasHarvested, this.mBurglarSituation); } if (stateMachine != null) { stateMachine.RequestState("x", "Exit Standing"); } EndCommodityUpdates(true); StandardExit(); Plant.UpdateTendGardenTimeSpent(this, new Plant.UpdateTendGardenTimeSpentDelegate(HarvestPlant.Harvest.SetHarvestTimeSpent)); return(Actor.HasExitReason(ExitReason.StageComplete)); }
protected static void UpdateAttractionControllers(Household newHouse, Household oldHouse) { Dictionary <Relationship, bool> toDispose = new Dictionary <Relationship, bool>(); if (oldHouse != null) { foreach (SimDescription sim in Households.All(oldHouse)) { foreach (Relationship relation in Relationship.Get(sim)) { if (relation.AttractionNPCController != null) { if (!toDispose.ContainsKey(relation)) { toDispose.Add(relation, true); } } } } } if (newHouse != null) { foreach (SimDescription sim in Households.All(newHouse)) { foreach (Relationship relation in Relationship.Get(sim)) { if ((!SimTypes.IsSelectable(relation.SimDescriptionA)) && (!SimTypes.IsSelectable(relation.SimDescriptionB))) { continue; } if (relation.AreAttracted) { if (TestEnableAttractionNPCController(relation)) { toDispose.Remove(relation); if (relation.AttractionNPCController == null) { relation.AttractionNPCController = new AttractionNPCBehaviorController(relation); } } } } } } foreach (Relationship relation in toDispose.Keys) { relation.AttractionNPCController.Dispose(); } }
public static void StoreAll() { if (Household.ActiveHousehold == null) { return; } sSafeStore = new Dictionary <ulong, SafeStore>(); foreach (SimDescription sim in Households.All(Household.ActiveHousehold)) { sSafeStore[sim.SimDescriptionId] = new SafeStore(sim, SafeStore.Flag.OnlyAcademic | SafeStore.Flag.LoadFixup | SafeStore.Flag.Selectable | SafeStore.Flag.Unselectable); } }
protected static void CreateActors(Lot lot) { List <Sim> sims = new List <Sim>(); foreach (SimDescription description in Households.All(lot.Household)) { try { description.GetMiniSimForProtection().AddProtection(MiniSimDescription.ProtectionFlag.PartialFromPlayer); description.HomeWorld = GameUtils.GetCurrentWorld(); if (description.CreatedSim == null) { if (description.Weight < 0f) { description.ChangeBodyShape(0f, description.Fitness, -description.Weight); } else { description.ChangeBodyShape(description.Weight, description.Fitness, 0f); } FixInvisibleTask.Perform(description, false); Sim item = Instantiation.Perform(description, null); if (item != null) { sims.Add(item); } } else { sims.Add(description.CreatedSim); } } catch (Exception e) { Common.Exception(description, e); } } /* * if (lot != null) * { * BinCommon.PlaceSims(sims, lot); * }*/ }
protected override OptionResult Run(GameHitParameters <GameObject> parameters) { Common.StringBuilder msg = new Common.StringBuilder(); msg += Common.NewLine + "GameStates.IsOnVacation = " + GameStates.IsOnVacation; msg += Common.NewLine + "GameUtils.IsOnVacation = " + GameUtils.IsOnVacation(); msg += Common.NewLine + " CurrentWorldType = " + GameUtils.GetCurrentWorldType(); if (GameStates.sTravelData != null) { msg += Common.NewLine + "sTravelData"; msg += Common.NewLine + " mCurrentDayOfTrip = " + GameStates.sTravelData.mCurrentDayOfTrip; msg += Common.NewLine + " mHomeWorld = " + GameStates.sTravelData.mHomeWorld; msg += Common.NewLine + " mSaveName = " + GameStates.sTravelData.mSaveName; msg += Common.NewLine + " mTimeInHomeworld = " + GameStates.sTravelData.mTimeInHomeworld; if (GameStates.sTravelData.mTravelHouse != null) { msg += Common.NewLine + " mTravelHouse = " + GameStates.sTravelData.mTravelHouse.Name; foreach (SimDescription member in Households.All(GameStates.sTravelData.mTravelHouse)) { msg += Common.NewLine + " " + member.FullName; } } else { msg += Common.NewLine + " mTravelHouse = null"; } } else { msg += Common.NewLine + "sTravelData = null"; } msg += FileNameBooter.LookupToString(); msg += WorldData.GetWorldDataToString(); Common.Notify(msg); Common.WriteLog(msg); return(OptionResult.SuccessClose); }
public override void OnDelayedWorldLoadFinished() { Overwatch.Log("CleanupSimHousehold"); foreach (Household house in Household.sHouseholdList) { foreach (SimDescription sim in Households.All(house)) { if (sim.Household != house) { sim.mHousehold = house; Overwatch.Log(" Reattached: " + sim.FullName); } } } }
protected static void OnSelected(Event e) { if (GameStates.IsTravelling) { return; } if (GameStates.IsOnVacation) { SetVacationWorld(false, false); } else { Sim actor = e.Actor as Sim; if ((actor != null) && (actor.Household != mOldHouse)) { if (actor.Household != null) { foreach (SimDescription sim in Households.All(actor.Household)) { foreach (SimDescription other in Households.All(actor.Household)) { if (sim == other) { continue; } try { // A Relationship must be created between all travelers or the transition fails Relationship.Get(sim, other, true); } catch { } } } } mOldHouse = actor.Household; } } }
public override void UpdateInheritors(IGenericLevelOption option) { base.UpdateInheritors(option); if (House == null) { return; } foreach (SimDescription sim in Households.All(House)) { SimData data = StoryProgression.Main.GetData(sim); data.Uncache(option); if (!data.IsValidOption(option)) { data.RemoveOption(option); } } }
protected override OptionResult Run(GameHitParameters <GameObject> parameters) { string text = StringInputDialog.Show(Name, Common.Localize("CasteName:Prompt"), ""); if (string.IsNullOrEmpty(text)) { return(OptionResult.Failure); } bool created; CasteOptions options = StoryProgression.Main.Options.GetNewCasteOptions(null, text, out created); if (options == null) { return(OptionResult.Failure); } List <SimDescription> sims = new List <SimDescription>(); Sim sim = parameters.mTarget as Sim; if (sim != null) { StoryProgression.Main.AddValue <ManualCasteOption, CasteOptions>(sim.SimDescription, options); } else { Lot lot = parameters.mTarget as Lot; if (lot != null) { foreach (SimDescription member in Households.All(lot.Household)) { StoryProgression.Main.AddValue <ManualCasteOption, CasteOptions>(member, options); } } } return(OptionResult.SuccessRetain); }
public static bool SatisfiesLikingGate(Sim sim, Sim target) { if ((target.IsSelectable) && (GoHere.Settings.mDisallowActiveGoHome)) { return(true); } if (IsAlone(target)) { return(true); } foreach (SimDescription member in Households.All(sim.Household)) { if (target.SimDescription.TeenOrAbove) { if (member.ChildOrBelow) { continue; } } float liking = 0; Relationship relation = Relationship.Get(member, target.SimDescription, false); if (relation != null) { liking = relation.CurrentLTRLiking; } if (liking >= GoHere.Settings.mRudeGuestLikingGate) { return(true); } } return(false); }
public static bool HasFirstDayActiveStudents() { if (Household.ActiveHousehold == null) { return(false); } foreach (SimDescription sim in Households.All(Household.ActiveHousehold)) { AcademicController controller; if (!sControllers.TryGetValue(sim.SimDescriptionId, out controller)) { continue; } if (controller.IsFirstDay) { return(true); } } return(false); }
public override void Startup() { Common.StringBuilder msg = new Common.StringBuilder("LiveModeStateEx:Startup" + Common.NewLine); Traveler.InsanityWriteLog(msg); try { UIManager.BlackBackground(false); msg += "A1"; Traveler.InsanityWriteLog(msg); // StateMachineState:Startup() mBaseCallFlag |= BaseCallFlag.kStartup; // InWorldSubState:Startup() while (sDelayNextStateStartupCount > 0x0) { SpeedTrap.Sleep(); } msg += "A2"; Traveler.InsanityWriteLog(msg); EventTracker.SendEvent(new InWorldSubStateEvent(this, true)); //base.Startup(); msg += "A3"; Traveler.InsanityWriteLog(msg); ShowUI(true); if (CameraController.IsMapViewModeEnabled() && !TutorialModel.Singleton.IsTutorialRunning()) { CameraController.EnableCameraMapView(true); } msg += "B"; Traveler.InsanityWriteLog(msg); CASExitLoadScreen.Close(); bool traveling = false; if (GameStates.IsTravelling) { if (GameStates.sTravelData == null) { GameStates.ClearTravelStatics(); } else { traveling = true; GameStatesEx.OnArrivalAtVacationWorld(); } } msg += "C"; Traveler.InsanityWriteLog(msg); if (GameStates.sNextSimToSelect != null) { DreamCatcher.SelectNoLotCheckImmediate(GameStates.sNextSimToSelect, true, true); GameStates.sNextSimToSelect = null; } msg += "D"; Traveler.InsanityWriteLog(msg); bool flag2 = false; if (LoadingScreenController.Instance != null) { if ((GameStates.IsPerfTestRunning || (CommandLine.FindSwitch("campos") != null)) || (CommandLine.FindSwitch("camtarget") != null)) { msg += "D1"; Traveler.InsanityWriteLog(msg); GameUtils.EnableSceneDraw(true); LoadingScreenController.Unload(); } else if (traveling) { msg += "D2"; Traveler.InsanityWriteLog(msg); uint customFlyThroughIndex = CameraController.GetCustomFlyThroughIndex(); if (GameStates.IsNewGame && (customFlyThroughIndex != 0x0)) { msg += "D3"; Traveler.InsanityWriteLog(msg); WaitForLotLoad(true, false); ShowUI(false); ShowMaptags(false); msg += "D4"; Traveler.InsanityWriteLog(msg); AudioManager.MusicMode = MusicMode.Flyby; CameraController.OnCameraFlyThroughFinishedCallback += OnCameraFlyThroughFinishedEvent; CameraController.StartFlyThrough(customFlyThroughIndex, false); flag2 = true; msg += "D5"; Traveler.InsanityWriteLog(msg); GameUtils.EnableSceneDraw(true); LoadingScreenController.Unload(); while (LoadingScreenController.Instance != null) { Sleep(0.0); } } else { msg += "D6"; Traveler.InsanityWriteLog(msg); WaitForLotLoad(true, true); Camera.SetView(CameraView.SimView, true, true); } } else { msg += "D7"; Traveler.InsanityWriteLog(msg); Camera.RestorePersistedState(); msg += "D8"; Traveler.InsanityWriteLog(msg); WaitForLotLoad(false, true); } } else if (traveling) { msg += "D9"; Traveler.InsanityWriteLog(msg); WaitForLotLoad(!GameUtils.IsUniversityWorld(), true); Camera.SetView(CameraView.SimView, true, true); } msg += "E"; Traveler.InsanityWriteLog(msg); UserToolUtils.UserToolGeneric(0xc8, new ResourceKey(0x0L, 0x0, 0x0)); if (!flag2) { GameUtils.Unpause(); } if (AudioManager.MusicMode != MusicMode.Flyby) { AudioManager.MusicMode = MusicMode.None; } msg += "F"; Traveler.InsanityWriteLog(msg); InWorldSubState.EdgeScrollCheck(); InWorldSubState.OpportunityDialogCheck(); try { DreamsAndPromisesManager.ValidateLifetimeWishes(); } catch (Exception e) { Common.Exception(msg, e); } LifeEventManager.ValidatePendingLifeEvents(); if (GameUtils.IsInstalled(ProductVersion.EP9)) { Tutorialette.TriggerLesson(Lessons.Degrees, Sim.ActiveActor); } if (GameUtils.GetCurrentWorldType() == WorldType.Base) { Tutorialette.TriggerLesson(Lessons.Traveling, Sim.ActiveActor); } if (Sims3.Gameplay.ActiveCareer.ActiveCareer.ActiveCareerShowGeneralLesson) { Tutorialette.TriggerLesson(Lessons.Professions, Sim.ActiveActor); } msg += "G"; Traveler.InsanityWriteLog(msg); Tutorialette.TriggerLesson(Lessons.AgingStageLengths, Sim.ActiveActor); Sim selectedActor = PlumbBob.SelectedActor; if (selectedActor != null) { // Custom if (GameStates.sMovingWorldData != null) { WorldData.MergeFromCrossWorldData(); } if (selectedActor.LotHome != null) { if (selectedActor.LotHome.HasVirtualResidentialSlots) { Tutorialette.TriggerLesson(Lessons.ApartmentLiving, selectedActor); } } else { Lot lot = Helpers.TravelUtilEx.FindLot(); if (lot != null) { lot.MoveIn(selectedActor.Household); foreach (SimDescription sim in Households.All(selectedActor.Household)) { if (sim.CreatedSim == null) { FixInvisibleTask.Perform(sim, false); } else { bool replace = (sim.CreatedSim == selectedActor); ResetSimTask.Perform(sim.CreatedSim, false); if (replace) { selectedActor = sim.CreatedSim; } } } msg += "MoveIn"; } } if (selectedActor.Household != null) { foreach (SimDescription description in Households.Humans(selectedActor.Household)) { // Custom if (GameStates.sMovingWorldData != null) { CrossWorldControl.Restore(description); } if (description.Child || description.Teen) { Tutorialette.TriggerLesson(Lessons.Pranks, null); break; } } } if (selectedActor.BuffManager != null) { BuffMummysCurse.BuffInstanceMummysCurse element = selectedActor.BuffManager.GetElement(BuffNames.MummysCurse) as BuffMummysCurse.BuffInstanceMummysCurse; if (element != null) { BuffMummysCurse.SetCursedScreenFX(element.CurseStage, false); } } if (selectedActor.CareerManager != null) { selectedActor.CareerManager.UpdateCareerUI(); } if (Traveler.Settings.mAllowSpawnWeatherStone && GameUtils.IsInstalled(ProductVersion.EP7) && GameUtils.IsInstalled(ProductVersion.EP8)) { Sims3.Gameplay.UI.Responder.Instance.TrySpawnWeatherStone(); } } msg += "H"; Traveler.InsanityWriteLog(msg); // Custom if (GameStates.sMovingWorldData != null) { GameStatesEx.UpdateMiniSims(GameStatesEx.GetAllSims()); foreach (SimDescription sim in Households.All(Household.ActiveHousehold)) { MiniSimDescription miniSim = MiniSimDescription.Find(sim.SimDescriptionId); if (miniSim != null) { miniSim.Instantiated = true; if (miniSim.HomeWorld != GameUtils.GetCurrentWorld()) { miniSim.HomeWorld = GameUtils.GetCurrentWorld(); } } if (sim.HomeWorld != GameUtils.GetCurrentWorld()) { sim.HomeWorld = GameUtils.GetCurrentWorld(); } } } GameStates.SetupPostMoveData(); GameStates.ClearMovingData(); MovingWorldsWizardCheck(); // Custom Household.IsTravelImport = false; InWorldSubStateEx.PlaceLotWizardCheck(this); msg += "I"; Traveler.InsanityWriteLog(msg); foreach (Sim sim in LotManager.Actors) { try { if (sim.HasBeenDestroyed) { continue; } OccultManager occultManager = sim.OccultManager; if (occultManager != null) { occultManager.RestoreOccultIfNecessary(); } } catch (Exception e) { Common.Exception(sim, null, msg, e); } } msg += "J"; Traveler.InsanityWriteLog(msg); // Custom foreach (SimDescription description in SimListing.GetResidents(false).Values) { if (description.LotHome == null) { continue; } MiniSimDescription miniSimDescription = description.GetMiniSimDescription(); if (miniSimDescription != null) { miniSimDescription.LotHomeId = description.LotHome.LotId; } } msg += "K"; Traveler.InsanityWriteLog(msg); } catch (Exception e) { Traveler.InsanityException(msg, e); } finally { CASExitLoadScreen.Close(); } }
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 override bool Run() { try { StandardEntry(); try { if (!Target.StartComputing(this, SurfaceHeight.Table, true)) { return(false); } AnimateSim("GenericTyping"); string result = Common.Localize("InoculationReport:Title", Actor.IsFemale); int count = 0; bool foundAny = false; foreach (SimDescription sim in Households.All(Actor.Household)) { bool found = false, first = true; foreach (DiseaseVector vector in Vector.Settings.GetVectors(sim)) { if (!vector.IsIdentified) { continue; } if (vector.InoculationCost <= 0) { continue; } if (first) { first = false; result += Common.NewLine + Common.NewLine + Common.Localize("InoculationReport:Patient", sim.IsFemale, new object[] { sim }); } string incurable = null; if (!vector.CanInoculate) { incurable = "Incurable"; } result += Common.NewLine + Common.Localize("InoculationReport:Vector" + incurable, sim.IsFemale, new object[] { vector.GetLocalizedName(sim.IsFemale), Common.Localize("YesNo:" + vector.IsInoculated) }); if (vector.IsInoculated) { result += Common.Localize("InoculationReport:InoculationDuration", sim.IsFemale, new object[] { vector.InoculationStrain, Vector.Settings.GetCurrentStrain(vector.Data).Strain }); } found = true; count++; } if ((!found) && (!first)) { result += Common.NewLine + Common.Localize("InoculationReport:None", sim.IsFemale); } if (found) { foundAny = true; } if (count > 10) { Common.Notify(result); result = Common.Localize("InoculationReport:Title", Actor.IsFemale); count = 0; } } if (!foundAny) { result += Common.NewLine + Common.Localize("InoculationReport:None", Actor.IsFemale); count++; } if (count > 0) { Common.Notify(result); } Target.StopComputing(this, Computer.StopComputingAction.TurnOff, false); return(true); } finally { StandardExit(); } } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } }
private static void OneDayPassedUniversityUpdates(Household ths) { try { if (GameStates.CurrentDayOfTrip == GameStates.TripLength) { Household.ReportCardHelper helper = null; foreach (SimDescription description in Households.All(ths)) { if (description == null) { continue; } if (description.OccupationAsAcademicCareer == null) { continue; } if (helper == null) { helper = new Household.ReportCardHelper(); } helper.AddGPA(description.SimDescriptionId, description.OccupationAsAcademicCareer.GetGradeAsLetter()); } if (helper != null) { AlarmManager.Global.AddAlarm(SimClock.HoursUntil(Household.kWhenReportCardArrives), TimeUnit.Hours, helper.ReportCardArrives, "Report Card Arrives", AlarmType.AlwaysPersisted, ths); } // Correction for potential error in OnTermCompleted() Corrections.CleanupAcademics(null); foreach (Household household in Household.sHouseholdList) { if (household == null) { continue; } if (household.IsPreviousTravelerHousehold) { continue; } foreach (SimDescription sim in household.SimDescriptions) { if (sim == null) { continue; } try { AcademicCareer occupationAsAcademicCareer = sim.OccupationAsAcademicCareer; if (occupationAsAcademicCareer != null) { AcademicCareerEx.OnTermCompleted(occupationAsAcademicCareer); } } catch (Exception e) { Common.Exception(sim, e); } } } AlarmManager.Global.RemoveAlarm(ths.mLastDayAlarm); ths.mLastDayAlarm = AlarmManager.Global.AddAlarm(SimClock.HoursUntil(Household.kWhenOneHourLeftTNSAppears), TimeUnit.Hours, ths.OneHourLeft, "One Hour left TNS", AlarmType.AlwaysPersisted, ths); AlarmManager.Global.RemoveAlarm(ths.mTriggerUniversityReturnFlowAlarm); ths.mTriggerUniversityReturnFlowAlarm = AlarmManager.Global.AddAlarm(SimClock.HoursUntil(Household.kWhenSimsStartLeaving), TimeUnit.Hours, BeginReturnFromUniversityFlow, "Start University Return Home Flow Alarm", AlarmType.AlwaysPersisted, ths); } else if (GameStates.CurrentDayOfTrip > GameStates.TripLength) { bool denyTravel = false; if (!GameStates.IsTravelling) { foreach (Sim sim in ths.AllActors) { if ((sim != null) && sim.IsDying()) { denyTravel = true; } } } GameStates.StopSnappingPicturesIfNeccessary(); if (Sims3.Gameplay.UI.Responder.Instance.HudModel is HudModel) { Common.FunctionTask.Perform(ths.ShowTripOverDialog); } if (!denyTravel) { Traveler.SaveGame(); TravelUtil.PlayerMadeTravelRequest = true; // Custom GameStatesEx.UpdateTelemetryAndTriggerTravelBackToHomeWorld(); } } else if (GameStates.CurrentDayOfTrip <= 0x1) { AlarmManager.Global.RemoveAlarm(Household.mAtUnivTutorialAlarm); Household.mAtUnivTutorialAlarm = AlarmHandle.kInvalidHandle; AlarmManager.Global.RemoveAlarm(Household.mDormsTutorialAlarm); Household.mDormsTutorialAlarm = AlarmHandle.kInvalidHandle; Household.mAtUnivTutorialAlarm = AlarmManager.Global.AddAlarmDay(Household.kTimeAtUnivTutorial, ~DaysOfTheWeek.None, Household.TriggerAtUniversityTutorial, "At University Lesson", AlarmType.AlwaysPersisted, null); Household.mDormsTutorialAlarm = AlarmManager.Global.AddAlarmDay(Household.kTimeDormsTutorial, ~DaysOfTheWeek.None, Household.TriggerDormsTutorial, "Dorms Lesson", AlarmType.AlwaysPersisted, null); } else if (GameStates.CurrentDayOfTrip == (GameStates.TripLength - 0x1)) { float num2 = SimClock.HoursUntil(Household.kWhenOneDayLeftTNSAppears); ths.mLastDayAlarm = AlarmManager.Global.AddAlarm(num2, TimeUnit.Hours, ths.OneDayLeft, "One Day left TNS", AlarmType.AlwaysPersisted, ths); } } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(ths, e); } }
protected override OptionResult Run(GameHitParameters <GameObject> parameters) { Common.StringBuilder log = new Common.StringBuilder("Run"); try { Lot targetLot = Porter.GetLot(parameters.mTarget); if (targetLot == null) { return(OptionResult.Failure); } Dictionary <ulong, IMiniSimDescription> preExistingSims = SimListing.GetSims <IMiniSimDescription>(null, true); Household me = targetLot.Household; if (me == null) { me = GetImportSelection(targetLot); if (me == null) { return(OptionResult.Failure); } } Dictionary <ulong, IMiniSimDescription> allSims = SimListing.GetSims <IMiniSimDescription>(null, true); Dictionary <int, HouseData> houses = new Dictionary <int, HouseData>(); Dictionary <int, HouseData> doppleHouses = new Dictionary <int, HouseData>(); List <SimDescription> cleanUp = new List <SimDescription>(); List <SimDescription> fixUp = new List <SimDescription>(); List <Household> importedHouses = new List <Household>(); importedHouses.Add(me); List <SimDescription> checkSims = new List <SimDescription>(); log += Common.NewLine + "A"; List <SimDescription> sims = new List <SimDescription>(me.AllSimDescriptions); foreach (SimDescription sim in sims) { if (sim == null) { continue; } log += Common.NewLine + sim.FullName; Porter.AddExport(sim); string description = sim.mBio; if (string.IsNullOrEmpty(description)) { continue; } if (!description.Contains("NRaas.Porter:")) { continue; } description = description.Replace("NRaas.Porter:", ""); if (string.IsNullOrEmpty(description)) { continue; } HouseData lookup = new HouseData(description); lookup.Reconcile(sim); ValidateTask.Perform(sim); List <SimDescription> dependents = new List <SimDescription>(); if (HandleDoppleganger(sim, preExistingSims, allSims, dependents)) { if (!houses.ContainsKey(lookup.mID)) { if (!doppleHouses.ContainsKey(lookup.mID)) { doppleHouses.Add(lookup.mID, lookup); } } checkSims.AddRange(dependents); cleanUp.Add(sim); continue; } else { fixUp.Add(sim); } HouseData data; if (!houses.TryGetValue(lookup.mID, out data)) { data = lookup; houses.Add(data.mID, data); } doppleHouses.Remove(lookup.mID); data.mSims.Add(sim); } log += Common.NewLine + "B"; foreach (SimDescription sim in fixUp) { log += Common.NewLine + sim.FullName; new Relationships.RepairParents().Perform(sim, UnusedLog, allSims); new Relationships.RepairChildren().Perform(sim, UnusedLog, allSims); new Relationships.RepairSiblings().Perform(sim, UnusedLog, allSims); } log += Common.NewLine + "C"; foreach (SimDescription cleanup in cleanUp) { log += Common.NewLine + cleanup.FullName; try { if (cleanup.Household != null) { cleanup.Household.Remove(cleanup); } checkSims.Remove(cleanup); cleanup.Genealogy.ClearAllGenealogyInformation(); cleanup.Dispose(); } catch (Exception e) { Common.DebugException(log, e); } } log += Common.NewLine + "D"; if (houses.Count == 0) { SimpleMessageDialog.Show(Common.Localize("Title"), Common.Localize("Unpack:NotProper")); return(OptionResult.Failure); } else if (houses.Count == 1) { int funds = -1; foreach (HouseData data in houses.Values) { if (data.mID != 0) { funds = data.mFunds; } } if (funds >= 0) { me.SetFamilyFunds(funds); SimpleMessageDialog.Show(Common.Localize("Title"), Common.Localize("Unpack:Unneeded")); return(OptionResult.Failure); } } log += Common.NewLine + "E"; int unpacked = 0, failed = 0; List <HouseData> sorted = new List <HouseData>(houses.Values); sorted.Sort(new Comparison <HouseData>(HouseData.SortByCost)); foreach (HouseData data in sorted) { log += Common.NewLine + "House: " + data.mID; if (data.mID != 1) { Household house = null; if (data.mID != 0) { Lot lot = FindLot(data.mFunds, data.mSims); if (lot == null) { lot = FindLot(-1, null); if (lot == null) { failed++; continue; } } house = Household.Create(); importedHouses.Add(house); lot.MoveIn(house); house.Name = data.mName; int finalFunds = (data.mFunds - lot.Cost); if (finalFunds >= 0) { house.SetFamilyFunds(finalFunds); me.ModifyFamilyFunds(-data.mFunds); } else { house.SetFamilyFunds(0); me.ModifyFamilyFunds(-data.mFunds); me.ModifyFamilyFunds(finalFunds); } if (me.FamilyFunds < 0) { me.SetFamilyFunds(0); } if (house.FamilyFunds < 0) { house.SetFamilyFunds(0); } unpacked++; } foreach (SimDescription sim in data.mSims) { log += Common.NewLine + sim.FullName; if (house != null) { log += Common.NewLine + "Moved"; me.Remove(sim); house.Add(sim); Instantiation.Perform(sim, null); } else { log += Common.NewLine + "PlaceGrave"; Porter.PlaceGraveTask.Perform(sim); } } if (house != null) { string name = house.LotHome.Name; if (string.IsNullOrEmpty(name)) { name = house.LotHome.Address; } Porter.Notify(Common.Localize("Unpack:Success", false, new object[] { house.Name, name }), house.LotHome.ObjectId); } } else { unpacked++; } foreach (SimDescription sim in data.mSims) { sim.mBio = null; } } log += Common.NewLine + "F"; foreach (SimDescription checkSim in checkSims) { log += Common.NewLine + checkSim.FullName; if (checkSim.ChildOrBelow) { bool found = false; Household parentHousehold = null; foreach (SimDescription parent in Relationships.GetParents(checkSim)) { if ((checkSim.Household != null) && (parent.Household == checkSim.Household)) { found = true; break; } else { parentHousehold = parent.Household; } } if (!found) { if (parentHousehold == null) { if ((checkSim.Household != null) && (checkSim.Household.NumMembers == 1)) { foreach (Household house in Household.sHouseholdList) { foreach (SimDescription sim in Households.All(house)) { if (Relationships.IsCloselyRelated(checkSim, sim, false)) { parentHousehold = house; break; } } if (parentHousehold != null) { break; } } } } if (parentHousehold != null) { if (checkSim.Household != null) { checkSim.Household.Remove(checkSim); } parentHousehold.Add(checkSim); Instantiation.AttemptToPutInSafeLocation(checkSim.CreatedSim, false); } } } } log += Common.NewLine + "G"; foreach (Household house in importedHouses) { foreach (Sim sim in Households.AllSims(house)) { foreach (GameObject obj in Inventories.QuickFind <GameObject>(sim.Inventory)) { bool moveToFamily = false; if (!sim.Inventory.ValidForThisInventory(obj)) { moveToFamily = true; } else if (obj is IStageProp) { moveToFamily = true; } if (moveToFamily) { sim.Inventory.RemoveByForce(obj); Inventories.TryToMove(obj, house.SharedFamilyInventory.Inventory); } } } } log += Common.NewLine + "H"; int doppleFunds = 0; foreach (HouseData data in doppleHouses.Values) { doppleFunds += data.mFunds; } me.ModifyFamilyFunds(-doppleFunds); if (me.FamilyFunds < 0) { me.SetFamilyFunds(0); } SimpleMessageDialog.Show(Common.Localize("Title"), Common.Localize("Unpack:Completion", false, new object[] { unpacked, failed })); } catch (Exception e) { Common.Exception(log, e); } return(OptionResult.SuccessClose); }
public static PlaceResults LocateHomeAndPlaceSimsAtVacationWorld(Household household, ref Sim simToSelect) { PlaceResults results = PlaceResults.Failure; Common.StringBuilder msg = new Common.StringBuilder("LocateHomeAndPlaceSimsAtVacationWorld" + Common.NewLine); try { if (household != null) { msg += "A"; if (GameStates.DestinationTravelWorld == WorldName.University) { Dictionary <SimDescription, AcademicDegreeManager> managers = new Dictionary <SimDescription, AcademicDegreeManager>(); try { foreach (SimDescription sim in Households.All(household)) { if (sim.CareerManager == null) { continue; } managers[sim] = sim.CareerManager.DegreeManager; if ((sim.ChildOrBelow) || (sim.IsPet)) { sim.CareerManager.mDegreeManager = null; } else if ((sim.CareerManager.DegreeManager != null) && (sim.CareerManager.DegreeManager.EnrollmentCouseLoad == 0)) { sim.CareerManager.mDegreeManager = null; } } TravelUtil.MoveIntoUniversityHousehold(household); foreach (SimDescription sim in Households.All(household)) { CustomAcademicDegrees.AdjustCustomAcademics(sim); } } finally { foreach (SimDescription sim in Households.All(household)) { if (sim.CareerManager == null) { continue; } AcademicDegreeManager manager; if (!managers.TryGetValue(sim, out manager)) { continue; } sim.CareerManager.mDegreeManager = manager; } } results = PlaceResults.BaseCamp; } else { TravelUtil.ProcessDeedsAndMoveInHousehold(household); if (household.LotHome == null) { msg += "B"; bool manual = false; Lot choice = PromptForLot(); if (choice == null) { choice = FindLot(); } else { manual = true; } if (choice != null) { msg += "C"; msg += Common.NewLine + choice.Name + Common.NewLine; choice.MoveIn(household); Mailbox mailboxOnLot = Mailbox.GetMailboxOnLot(choice); if (mailboxOnLot != null) { mailboxOnLot.ListenToReturnFromWorld(); } if (household.LotHome != null) { msg += "D"; if (manual) { results = PlaceResults.BaseCamp; } else { results = PlaceResults.Residential; } } } } else { msg += "E"; results = PlaceResults.BaseCamp; } } if (household.LotHome != null) { msg += "F"; foreach (Service service in Services.AllServices) { if (service == null) { continue; } if (service.DefaultIsRequested()) { continue; } service.MakeServiceRequest(household.LotHome, false, ObjectGuid.InvalidObjectGuid); } TravelUtil.TriggerTutorial(household); TravelUtil.PlaceSimsOnSafeSpots(household, ref simToSelect); } } } catch (Exception e) { Traveler.InsanityException(msg, e); } finally { Traveler.InsanityWriteLog(msg); } return(results); }
public static void Perform() { Dictionary <ulong, bool> taxiDrivers = new Dictionary <ulong, bool>(); List <ulong> paps = new List <ulong>(); if ((CarNpcManager.Singleton != null) && (CarNpcManager.Singleton.NpcDriversManager != null)) { for (int i = 0; i < CarNpcManager.Singleton.NpcDriversManager.mDescPools.Length; i++) { Stack <SimDescription> stack = CarNpcManager.Singleton.NpcDriversManager.mDescPools[i]; if (stack == null) { continue; } NpcDriversManager.NpcDrivers type = (NpcDriversManager.NpcDrivers)(i + 0x95d01441); while (stack.Count > 10) { SimDescription sim = stack.Pop(); try { AttemptServiceDisposal(sim, false, "Too Many " + type); } catch (Exception e) { Common.Exception(sim, e); } } foreach (SimDescription sim in stack) { if (taxiDrivers.ContainsKey(sim.SimDescriptionId)) { continue; } taxiDrivers.Add(sim.SimDescriptionId, true); } } } Dictionary <ulong, bool> statueSims = new Dictionary <ulong, bool>(); CauseEffectService instance = CauseEffectService.GetInstance(); if (instance != null) { statueSims[instance.GetTimeTravelerSimID()] = true; List <ITimeStatueUiData> timeStatueData = instance.GetTimeAlmanacTimeStatueData(); if (timeStatueData != null) { foreach (ITimeStatueUiData data in timeStatueData) { TimeStatueRecordData record = data as TimeStatueRecordData; if (record == null) { continue; } statueSims[record.mRecordHolderId] = true; } } } foreach (SimDescription sim in new List <SimDescription> (Households.All(Household.NpcHousehold))) { try { if (SimTypes.IsDead(sim)) { continue; } if (taxiDrivers.ContainsKey(sim.SimDescriptionId)) { continue; } CommonCorrections(sim); if (SimTypes.InServicePool(sim, ServiceType.GrimReaper)) { continue; } if (statueSims.ContainsKey(sim.SimDescriptionId)) { continue; } uint spanLevel = 0; OptionsModel.GetOptionSetting("AgingInterval", out spanLevel); float averageElderAge = AgingManager.Singleton.GetAverageSimLifespanInDays((int)spanLevel); ServiceType type = ServiceType.None; if (sim.CreatedByService != null) { type = sim.CreatedByService.ServiceType; } if (AgingManager.Singleton.GetCurrentAgeInDays(sim) > averageElderAge) { if (sim.LotHome == null) { bool isRole = sim.AssignedRole != null; AttemptServiceDisposal(sim, true, "Too Old " + (!isRole ? type.ToString() : sim.AssignedRole.Type.ToString())); } } if (sim.AssignedRole != null && sim.AssignedRole is RolePaparazzi) { paps.Add(sim.SimDescriptionId); } if (sim.AssignedRole != null) { continue; } if (SimTypes.IsOccult(sim, OccultTypes.ImaginaryFriend)) { bool found = false; foreach (ImaginaryDoll doll in Sims3.Gameplay.Queries.GetObjects <ImaginaryDoll>()) { if (sim.SimDescriptionId == doll.mLiveStateSimDescId) { found = true; break; } } if (found) { continue; } AttemptServiceDisposal(sim, false, "Imaginary"); } else if (SimTypes.IsOccult(sim, OccultTypes.Genie)) { bool found = false; foreach (GenieLamp lamp in Sims3.Gameplay.Queries.GetObjects <GenieLamp>()) { if (sim == lamp.mGenieDescription) { found = true; break; } } if (found) { continue; } AttemptServiceDisposal(sim, false, "Genie"); } else if (sim.IsBonehilda) { bool found = false; foreach (BonehildaCoffin coffin in Sims3.Gameplay.Queries.GetObjects <BonehildaCoffin>()) { if (sim == coffin.mBonehilda) { found = true; break; } } if (found) { continue; } AttemptServiceDisposal(sim, false, "BoneHilda"); } else if ((sim.AssignedRole == null) && (!SimTypes.InServicePool(sim))) { AttemptServiceDisposal(sim, false, "No Purpose"); } else if ((type != ServiceType.None) && (sim.Age & ServiceNPCSpecifications.GetAppropriateAges(type.ToString())) == CASAgeGenderFlags.None) { AttemptServiceDisposal(sim, false, "Wrong Age " + type); } else if (!ServiceNPCSpecifications.ShouldUseServobot(type.ToString()) && sim.IsEP11Bot) { AttemptServiceDisposal(sim, false, "Not EP11 Bot " + type); } } catch (Exception e) { Common.Exception(sim, e); } } // kill extra paps if (paps.Count > Register.Settings.mMaximumPaparazzi) { int count = paps.Count; while (count > Register.Settings.mMaximumPaparazzi && count > 0) { SimDescription sim = SimDescription.Find(paps[0]); if (sim != null) { AttemptServiceDisposal(sim, false, "Too many Paparazzi"); } paps.Remove(paps[0]); count = count - 1; } } foreach (SimDescription sim in new List <SimDescription> (Households.All(Household.PetHousehold))) { try { if (SimTypes.IsDead(sim)) { continue; } CommonCorrections(sim); if ((sim.IsDeer) || (sim.IsRaccoon)) { if (sim.AssignedRole == null) { AttemptServiceDisposal(sim, false, "Roleless"); } else if (sim.Elder) { AttemptServiceDisposal(sim, true, "Elder"); } } else { bool noPool; PetPoolType pool = SimTypes.GetPetPool(sim, out noPool); if ((!noPool) && (pool == PetPoolType.None)) { AttemptServiceDisposal(sim, false, "Not Pooled"); } } } catch (Exception e) { Common.Exception(sim, e); } } }
protected void Perform(StoryProgressionObject manager, IScoringGenerator stats, string tag, List <SimDescription> movers, ChildrenMove children, bool ignoreHead) { if (movers.Count == 0) { return; } SimDescription focus = movers[0]; if (focus.Household == null) { stats.IncStat(tag + " Break: No Home"); mGoing.AddRange(movers); return; } else if (SimTypes.IsSpecial(focus)) { stats.IncStat(tag + " Break: Special"); mGoing.AddRange(movers); return; } else { bool adult = false; foreach (SimDescription sim in movers) { if (manager.Households.AllowGuardian(sim)) { adult = true; break; } } if (!adult) { stats.IncStat(tag + " Break: Child Transfer"); mStaying.AddRange(Households.All(focus.Household)); foreach (SimDescription sim in movers) { if (SimTypes.IsSelectable(sim)) { continue; } mStaying.Remove(sim); mGoing.Add(sim); } return; } List <SimDescription> going = new List <SimDescription>(); List <SimDescription> staying = new List <SimDescription>(); List <SimDescription> houseChildrenPetsPlumbots = new List <SimDescription>(); bool ancestral = manager.GetValue <IsAncestralOption, bool>(focus.Household); SimDescription head = null; if (!ignoreHead) { head = SimTypes.HeadOfFamily(focus.Household); } else if (ancestral) { stats.IncStat(tag + " Break: Ancestral Head Denied"); mStaying.AddRange(Households.All(focus.Household)); return; } foreach (SimDescription sim in Households.All(focus.Household)) { stats.IncStat(sim.FullName, Common.DebugLevel.Logging); SimDescription partner = null; if (SimTypes.IsSelectable(sim)) { stats.IncStat(tag + " Break: Active"); staying.Add(sim); } else if (!manager.Households.Allow(stats, sim, 0)) { stats.IncStat(tag + " Break: User Denied"); staying.Add(sim); } else if (IsPartner(sim, staying, out partner)) { stats.IncStat(tag + " Break: Partner Stay"); staying.Add(sim); } else if ((IsPartner(sim, movers, out partner)) || (IsPartner(sim, going, out partner))) { if ((head == sim) && (Households.NumHumans(focus.Household) != 1)) { stats.IncStat(tag + " Break: Partner Go Denied"); going.Remove(partner); staying.Add(sim); if (!staying.Contains(partner)) { staying.Add(partner); } } else { stats.IncStat(tag + " Break: Partner Go"); going.Add(sim); } } else if (movers.Contains(sim)) { if ((head == sim) && (Households.NumHumans(focus.Household) != 1)) { stats.IncStat(tag + " Break: Go Denied"); staying.Add(sim); } else { stats.IncStat(tag + " Break: Go"); going.Add(sim); } } else if (head == sim) { stats.IncStat(tag + " Break: Head Stay"); staying.Add(sim); } else if ((sim.YoungAdultOrAbove) && (!sim.IsPet) && (!sim.IsEP11Bot)) { stats.IncStat(tag + " Break: Stay"); staying.Add(sim); } else { houseChildrenPetsPlumbots.Add(sim); } } List <SimDescription> extraChildrenPets = new List <SimDescription>(); foreach (SimDescription child in houseChildrenPetsPlumbots) { bool bGoing = false; bool bMatch = false; if (child.IsPet) { int goingLiking = int.MinValue; foreach (SimDescription foci in going) { if (child.LastName == foci.LastName) { bMatch = true; int liking = ManagerSim.GetLTR(child, foci); if (goingLiking < liking) { goingLiking = liking; } } } int stayingLiking = int.MinValue; foreach (SimDescription foci in staying) { if (child.LastName == foci.LastName) { bMatch = true; int liking = ManagerSim.GetLTR(child, foci); if (stayingLiking < liking) { stayingLiking = liking; } } } if (goingLiking > stayingLiking) { bGoing = true; } } else { // this will handle plumbots that are related to the family (i.e. creation) if (children == ChildrenMove.RelatedStay) { foreach (SimDescription parent in Relationships.GetParents(child)) { if (staying.Contains(parent)) { bMatch = true; } } } else if (children == ChildrenMove.RelatedGo) { foreach (SimDescription parent in Relationships.GetParents(child)) { if (going.Contains(parent)) { bMatch = true; } } } else if (children != ChildrenMove.Stay) { foreach (SimDescription foci in going) { if (Relationships.GetChildren(foci).Contains(child)) { bMatch = true; if ((children != ChildrenMove.Scoring) || (ScoreChildMove(stats, tag, child, going))) { bGoing = true; break; } } } } } if (child.IsEP11Bot && !bGoing) { // test the liking for Plumbots without the HumanEmotion chip if (!manager.Households.AllowGuardian(child)) { bMatch = true; int goingLiking = int.MinValue; foreach (SimDescription foci in going) { int liking = ManagerSim.GetLTR(child, foci); if (goingLiking < liking) { goingLiking = liking; } } int stayingLiking = int.MinValue; foreach (SimDescription foci in staying) { int liking = ManagerSim.GetLTR(child, foci); if (stayingLiking < liking) { stayingLiking = liking; } } if (goingLiking > stayingLiking) { bGoing = true; } } } stats.IncStat(child.FullName, Common.DebugLevel.Logging); if ((!bMatch) && (manager.Households.AllowSoloMove(child))) { stats.IncStat(tag + " Break: Teen Stay"); staying.Add(child); } else if (bGoing) { if (children == ChildrenMove.Go) { stats.IncStat(tag + " Break: Child Go"); } else { stats.IncStat(tag + " Break: Child Scoring Go"); } going.Add(child); } else { if (children == ChildrenMove.Stay) { stats.IncStat(tag + " Break: Child Stay"); } else if (bMatch) { stats.IncStat(tag + " Break: Child Scoring Stay"); } extraChildrenPets.Add(child); } } bool foundAdult = false, foundBlood = false; foreach (SimDescription sim in staying) { if (manager.Deaths.IsDying(sim)) { continue; } if (!manager.Households.AllowGuardian(sim)) { continue; } if (ancestral) { if (Relationships.IsCloselyRelated(head, sim, false)) { foundBlood = true; } } foundAdult = true; } if ((!foundAdult) || ((ancestral) && (!foundBlood))) { stats.AddStat(tag + " Break: Extra", extraChildrenPets.Count); going.AddRange(extraChildrenPets); if (ancestral) { stats.IncStat(tag + " Break: Ancestral"); mStaying.AddRange(going); return; } } mStaying.AddRange(staying); foreach (SimDescription sim in mStaying) { going.Remove(sim); } mGoing.AddRange(going); } }
public override List <ICasteOption> GetOptions() { List <ICasteOption> results = new List <ICasteOption>(); results.Add(new AddCasteOption()); results.Add(new RemoveCasteOption()); Dictionary <CasteOptions, bool> casteOptions = new Dictionary <CasteOptions, bool>(); Sim sim = mTarget as Sim; if (sim != null) { IEnumerable <CasteOptions> castes = StoryProgression.Main.Options.GetSim(sim).Castes; if (castes != null) { foreach (CasteOptions option in castes) { casteOptions[option] = true; } SimDescription head = SimTypes.HeadOfFamily(sim.Household); if (head != null) { castes = StoryProgression.Main.Options.GetSim(head).Castes; if (castes != null) { foreach (CasteOptions option in castes) { if (option.GetValue <CasteApplyToHouseOption, bool>()) { casteOptions[option] = true; } } } } } } else { Lot lot = mTarget as Lot; if (lot != null) { if (lot.Household != null) { foreach (SimDescription desc in Households.All(lot.Household)) { IEnumerable <CasteOptions> castes = StoryProgression.Main.Options.GetSim(desc).Castes; if (castes != null) { foreach (CasteOptions option in castes) { casteOptions[option] = true; } } } } } else if (Common.IsRootMenuObject(mTarget)) { foreach (CasteOptions option in StoryProgression.Main.Options.AllCastes) { casteOptions[option] = true; } } } foreach (CasteOptions option in casteOptions.Keys) { results.Add(new ChangeCasteOptions(option)); } return(results); }
protected SimDescription GetSim(CASAgeGenderFlags gender, CASAgeGenderFlags species, SimDescription exclude) { if (RandomUtil.RandomChance(mBinChance)) { List <ExportBinContents> contents = new List <ExportBinContents>(); foreach (IExportBinContents iContent in BinModel.Singleton.ExportBinContents) { ExportBinContents content = iContent as ExportBinContents; if (content == null) { continue; } contents.Add(content); } Dictionary <UISimInfo, ExportBinContents> uiSims = new Dictionary <UISimInfo, ExportBinContents>(); if (Manager.GetValue <EqualBinChanceOption <TManager>, bool>()) { foreach (ExportBinContents content in contents) { if (!ValidContent(content)) { continue; } foreach (UISimInfo sim in content.HouseholdSims) { if (!ValidContent(sim, species, exclude)) { continue; } if (uiSims.ContainsKey(sim)) { continue; } uiSims.Add(sim, content); } } } else { RandomUtil.RandomizeListOfObjects(contents); foreach (ExportBinContents content in contents) { if (!ValidContent(content)) { continue; } foreach (UISimInfo sim in content.HouseholdSims) { if (!ValidContent(sim, species, exclude)) { continue; } uiSims.Add(sim, content); } if (uiSims.Count > 0) { break; } } } if (uiSims.Count > 0) { UISimInfo choice = RandomUtil.GetRandomObjectFromList(new List <UISimInfo>(uiSims.Keys)); ExportBinContents content = uiSims[choice]; if (!content.IsLoaded()) { Dictionary <string, List <News.NewsTuning.ArticleTuning> > namedArticles = News.sNewsTuning.mNamedArticles; bool fail = false; try { // Doing so stops Marriage notices of imported sims from appearing in the newspaper News.sNewsTuning.mNamedArticles = new Dictionary <string, List <News.NewsTuning.ArticleTuning> >(); ExportBinContentsEx.Import(content, false); mStats.AddStat("Import Size", content.HouseholdSims.Count); } catch (Exception e) { Common.DebugException(content.HouseholdName, e); fail = true; } finally { News.sNewsTuning.mNamedArticles = namedArticles; } mLoaded[content] = true; if (fail) { return(null); } } if ((content.Household != null) && (content.Household.AllSimDescriptions.Count > 0)) { List <SimDescription> choices = new List <SimDescription>(); foreach (SimDescription sim in Households.All(content.Household)) { if (SimTypes.IsSkinJob(sim)) { continue; } if (SimTypes.IsOccult(sim, OccultTypes.ImaginaryFriend)) { continue; } mStats.IncStat("Immigrant: Bin Sim"); if (sim.Species == choice.Species) { choices.Add(sim); if (sim.FullName == choice.SimName) { return(sim); } } } if (choices.Count > 0) { return(RandomUtil.GetRandomObjectFromList(choices)); } } } } if ((RandomUtil.RandomChance(mRandomChance)) || (Manager.Sims.All.Count <= 20)) { return(GetRandomSim(gender, species)); } List <SimDescription> sims = new List <SimDescription>(); bool allowAlien = Manager.GetValue <AllowAlienHouseholdOption <TManager>, bool>(); foreach (SimDescription sim in Manager.Sims.All) { if (SimTypes.InServicePool(sim, ServiceType.GrimReaper)) { continue; } if (sim.Species != species) { continue; } if (!allowAlien) { if (SimTypes.IsServiceAlien(sim)) { continue; } } if (exclude != null) { if (exclude == sim) { continue; } if (exclude.LastName == sim.LastName) { continue; } } sims.Add(sim); } if (sims.Count == 0) { return(null); } else { mStats.IncStat("Immigrant: Town Sim"); return(RandomUtil.GetRandomObjectFromList(sims)); } }
public override void OnDelayedWorldLoadFinished() { Overwatch.Log("RepairImaginaryFriends"); Trait trait; if (TraitManager.sDictionary.TryGetValue((ulong)TraitNames.ImaginaryFriendHiddenTrait, out trait)) { trait.mNonPersistableData.mCanBeLearnedRandomly = false; } foreach (ImaginaryDoll doll in Sims3.Gameplay.Queries.GetObjects<ImaginaryDoll>()) { if (doll.mLiveStateSimDescId == 0) continue; if (doll.GetLiveFormSimDescription() != null) continue; doll.CreateLiveStateForm(); Overwatch.Log("Missing Imaginary Doll Repaired"); } foreach (SimDescription sim in Households.All(Household.NpcHousehold)) { if (sim.OccultManager == null) continue; OccultImaginaryFriend occult = sim.OccultManager.GetOccultType(OccultTypes.ImaginaryFriend) as OccultImaginaryFriend; if (occult == null) continue; Overwatch.Log(sim.FullName); if (occult.IsReal) continue; SimDescription owner = SimDescription.Find(occult.OwnerSimDescriptionId); if (owner == null) continue; if (owner.LotHome == null) continue; IScriptProxy proxy = Simulator.GetProxy(occult.mDollId); if (proxy == null) { IGameObject obj = GlobalFunctions.CreateObjectOutOfWorld("ImaginaryFriendDoll", ProductVersion.EP4); if (obj != null) { ImaginaryDoll doll = obj as ImaginaryDoll; if (doll == null) { obj.Destroy(); } else { occult.UpdateDollGuid(obj.ObjectId); doll.SetOwner(owner); doll.mLiveStateSimDescId = sim.SimDescriptionId; doll.mIsFemale = sim.IsFemale; doll.mGenderSet = true; doll.EstablishState(ImaginaryDoll.OwnershipState.Live); Sim ownerSim = owner.CreatedSim; if (ownerSim != null) { if (Inventories.TryToMove(obj, ownerSim)) { Overwatch.Log("Imaginary Friend Doll Added To Sim Inventory"); } else { obj.Destroy(); } } else { if (Inventories.TryToMove(obj, ownerSim.Household.SharedFamilyInventory.Inventory)) { Overwatch.Log("Imaginary Friend Doll Added To Family Inventory"); } else { obj.Destroy(); } } } } } } }
public override bool Test(Sim a, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { if (!OccultTypeHelper.HasType(a, OccultTypes.Genie)) { return(false); } if (target.LotHome != null) { if (Households.All(target.Household).Count <= 1) { return(false); } } OccultGenie occultType = a.SimDescription.OccultManager.GetOccultType(OccultTypes.Genie) as OccultGenie; if (target.SimDescription.IsBonehilda) { return(false); } if (((target.Service != null) && (target.Service.ServiceType == ServiceType.GrimReaper)) || (target.Household == a.Household)) { return(false); } if (DaycareSituation.IsInDaycareSituationWith(target, a)) { return(false); } if ((target.BuffManager.HasElement(BuffNames.WeddingDay) || target.IsEngaged) || target.SimDescription.IsPregnant) { return(false); } if (GameUtils.IsOnVacation()) { return(false); } if (((isAutonomous || (occultType == null)) || (target.OccultManager.HasOccultType(OccultTypes.Genie) || target.BuffManager.HasElement(BuffNames.Ensorcelled))) || !a.SimDescription.ChildOrAbove) { return(false); } if (!occultType.MagicPoints.HasPoints()) { greyedOutTooltipCallback = delegate { return(Localization.LocalizeString(a.IsFemale, "Gameplay/Actors/Sim/GenieOutOfPoints:OutOfPoints", new object[] { a })); }; return(false); } /* * if (!a.Household.CanAddSpeciesToHousehold(CASAgeGenderFlags.Human)) * { * greyedOutTooltipCallback = delegate * { * return Localization.LocalizeString(a.IsFemale, "Gameplay/Actors/Sim/EnsorcelFail:HouseholdFull", new object[] { a }); * }; * return false; * } * * if (!a.Household.CanAddSpeciesToHousehold(target.SimDescription.Species, 0x1, true)) * { * greyedOutTooltipCallback = delegate { * return Localization.LocalizeString(a.IsFemale, "Gameplay/Actors/Sim/EnsorcelFail:UnableToJoinHousehold", new object[] { a }); * }; * return false; * } */ if (target.SimDescription.ToddlerOrBelow) { return(false); } if (target.Household.IsServiceNpcHousehold && (target.SimDescription.CreatedByService != null)) { greyedOutTooltipCallback = delegate { return(Localization.LocalizeString(a.IsFemale, "Gameplay/Actors/Sim/EnsorcelFail:UnableToJoinHousehold", new object[] { a })); }; return(false); } if (target.SimDescription.IsDead || ((target.SimDescription.Service != null) && (target.SimDescription.Service.ServiceType == ServiceType.GrimReaper))) { greyedOutTooltipCallback = delegate { return(Localization.LocalizeString(a.IsFemale, "Gameplay/Actors/Sim/EnsorcelFail:UnableToJoinHousehold", new object[] { a })); }; return(false); } /* * if (target.SimDescription.AssignedRole != null) * { * RoleData data = target.SimDescription.AssignedRole.Data; * if ((data != null) && !data.CanBeEnsorceled) * { * greyedOutTooltipCallback = delegate * { * return Localization.LocalizeString(a.IsFemale, "Gameplay/Actors/Sim/EnsorcelFail:UnableToJoinHousehold", new object[] { a }); * }; * return false; * } * } */ return(true); }
protected override void OnPerform() { if (mHouse == Household.ActiveHousehold) { return; } List <SimDescription> babies = new List <SimDescription>(); List <SimDescription> teens = new List <SimDescription>(); List <SimDescription> adults = new List <SimDescription>(); List <SimDescription> teensAndAdults = new List <SimDescription>(); foreach (SimDescription sim in Households.All(mHouse)) { if ((sim.IsPet) || (sim.ToddlerOrBelow)) { babies.Add(sim); } else if (sim.YoungAdultOrAbove) { adults.Add(sim); teensAndAdults.Add(sim); } else if (sim.Teen) { teens.Add(sim); teensAndAdults.Add(sim); } } if (adults.Count == 0) { adults = teens; } bool purchaseInoculation = false; foreach (SimDescription sim in adults) { if (ScoringLookup.GetScore("NRaasVectorPurchaseInoculation", sim) > 0) { purchaseInoculation = true; break; } } if (purchaseInoculation) { List <DiseaseVector> potentials = new List <DiseaseVector>(); foreach (SimDescription sim in babies) { GetInoculates(sim, potentials, false); } while (potentials.Count > 0) { DiseaseVector potential = RandomUtil.GetRandomObjectFromList(potentials); potentials.Remove(potential); DiseaseVector inoculate = null; List <SimDescription> potentialDonors = new List <SimDescription>(); foreach (SimDescription sim in teensAndAdults) { DiseaseVector vector = Vector.Settings.GetVector(sim, potential.Guid); if (vector == null) { continue; } if (!vector.IsInoculationUpToDate) { potentialDonors.Add(sim); } if (!vector.IsInoculated) { continue; } inoculate = vector; break; } if (inoculate == null) { if (mHouse.FamilyFunds < potential.InoculationCost) { continue; } inoculate = new DiseaseVector(potential.Data, Vector.Settings.GetCurrentStrain(potential.Data)); inoculate.Inoculate(potential.Data.InoculationStrain, true); if (potentialDonors.Count > 0) { SimDescription donor = RandomUtil.GetRandomObjectFromList(potentialDonors); VectorControl.Inoculate(donor, inoculate, true, false); } mHouse.ModifyFamilyFunds(-potential.InoculationCost); Common.DebugNotify("Donor Inoculate: " + mHouse.Name + Common.NewLine + "Cost: " + potential.InoculationCost + Common.NewLine + potential.GetUnlocalizedDescription()); } else { Common.DebugNotify("Existing Inoculate: " + mHouse.Name + Common.NewLine + "Cost: " + potential.InoculationCost + Common.NewLine + potential.GetUnlocalizedDescription()); } if (inoculate != null) { foreach (SimDescription child in babies) { VectorControl.Inoculate(child, inoculate, false, false); } return; } } potentials.Clear(); foreach (SimDescription sim in Households.All(mHouse)) { // Babies were handled earlier if (sim.ToddlerOrBelow) { continue; } GetInoculates(sim, potentials, true); } while (potentials.Count > 0) { DiseaseVector potential = RandomUtil.GetRandomObjectFromList(potentials); potentials.Remove(potential); if (mHouse.FamilyFunds < potential.InoculationCost) { continue; } potential.Inoculate(potential.Data.InoculationStrain, true); mHouse.ModifyFamilyFunds(-potential.InoculationCost); if (Common.kDebugging) { Common.DebugNotify("Inoculate: " + mHouse.Name + Common.NewLine + "Cost: " + potential.InoculationCost + Common.NewLine + potential.GetUnlocalizedDescription()); } return; } } List <SimDescription> choices = new List <SimDescription>(adults); while (choices.Count > 0) { SimDescription choice = RandomUtil.GetRandomObjectFromList(choices); choices.Remove(choice); if (ScoringLookup.GetScore("NRaasVectorPurchaseResistance", choice) > 0) { List <DiseaseVector> potentials = new List <DiseaseVector>(); GetResisters(choice, potentials); if (potentials.Count > 0) { DiseaseVector potential = RandomUtil.GetRandomObjectFromList(potentials); mHouse.ModifyFamilyFunds(-potential.ResistanceCost); potential.AlterResistance(Vector.Settings.mResistanceBoost); potential.SetToIdentified(); if (Common.kDebugging) { Common.DebugNotify("Boost: " + mHouse.Name + Common.NewLine + "Cost: " + potential.ResistanceCost + Common.NewLine + potential.GetUnlocalizedDescription()); } } } /* * if (ScoringLookup.GetScore("NRaasVectorPurchaseProtection", choice) > 0) * { * purchaseProtection = true; * } */ } }
protected override OptionResult Run(GameHitParameters <GameObject> parameters) { List <Item> choices = new List <Item>(); Sim sim = mTarget as Sim; if (sim != null) { IEnumerable <CasteOptions> castes = StoryProgression.Main.Options.GetSim(sim).Castes; if (castes != null) { foreach (CasteOptions option in castes) { choices.Add(new Item(option)); } } } else { Lot lot = mTarget as Lot; if (lot != null) { if (lot.Household != null) { Dictionary <CasteOptions, bool> lookup = new Dictionary <CasteOptions, bool>(); foreach (SimDescription desc in Households.All(lot.Household)) { IEnumerable <CasteOptions> castes = StoryProgression.Main.Options.GetSim(desc).Castes; if (castes != null) { foreach (CasteOptions option in castes) { if (lookup.ContainsKey(option)) { continue; } lookup.Add(option, true); choices.Add(new Item(option)); } } } } } else if (Common.IsRootMenuObject(mTarget)) { foreach (CasteOptions option in StoryProgression.Main.Options.AllCastes) { choices.Add(new Item(option)); } } } CommonSelection <Item> .Results selection = new CommonSelection <Item>(Name, choices).SelectMultiple(); if ((selection == null) || (selection.Count == 0)) { return(OptionResult.Failure); } if (sim != null) { SimData data = StoryProgression.Main.Options.GetSim(sim); foreach (Item item in selection) { data.RemoveValue <ManualCasteOption, CasteOptions>(item.Value); } } else { Lot lot = mTarget as Lot; if (lot != null) { if (lot.Household != null) { Dictionary <CasteOptions, bool> lookup = new Dictionary <CasteOptions, bool>(); foreach (SimDescription desc in Households.All(lot.Household)) { SimData data = StoryProgression.Main.Options.GetSim(desc); foreach (Item item in selection) { data.RemoveValue <ManualCasteOption, CasteOptions>(item.Value); } } } } else if (Common.IsRootMenuObject(mTarget)) { foreach (Item item in selection) { StoryProgression.Main.Options.RemoveCaste(item.Value); } } } return(OptionResult.SuccessRetain); }
public static PlaceResults LocateHomeAndPlaceSimsAtVacationWorld(Household household, ref Sim simToSelect) { PlaceResults results = PlaceResults.Failure; Common.StringBuilder msg = new Common.StringBuilder("LocateHomeAndPlaceSimsAtVacationWorld" + Common.NewLine); try { if (household != null) { msg += "A"; if (GameStates.DestinationTravelWorld == WorldName.University) { Dictionary <SimDescription, AcademicDegreeManager> managers = new Dictionary <SimDescription, AcademicDegreeManager>(); try { foreach (SimDescription sim in Households.All(household)) { if (sim.CareerManager == null) { continue; } managers[sim] = sim.CareerManager.DegreeManager; if ((sim.ChildOrBelow) || (sim.IsPet)) { sim.CareerManager.mDegreeManager = null; } else if ((sim.CareerManager.DegreeManager != null) && (sim.CareerManager.DegreeManager.EnrollmentCouseLoad == 0)) { sim.CareerManager.mDegreeManager = null; } } TravelUtil.MoveIntoUniversityHousehold(household); foreach (SimDescription sim in Households.All(household)) { CustomAcademicDegrees.AdjustCustomAcademics(sim); } } finally { foreach (SimDescription sim in Households.All(household)) { if (sim.CareerManager == null) { continue; } AcademicDegreeManager manager; if (!managers.TryGetValue(sim, out manager)) { continue; } sim.CareerManager.mDegreeManager = manager; } } results = PlaceResults.BaseCamp; } else { TravelUtil.ProcessDeedsAndMoveInHousehold(household); if (household.LotHome == null) { msg += "B"; bool manual = false; Lot choice = PromptForLot(); if (choice == null) { choice = FindLot(); } else { manual = true; } if (choice != null) { msg += "C"; msg += Common.NewLine + choice.Name + Common.NewLine; choice.MoveIn(household); Mailbox mailboxOnLot = Mailbox.GetMailboxOnLot(choice); if (mailboxOnLot != null) { mailboxOnLot.ListenToReturnFromWorld(); } if (household.LotHome != null) { msg += "D"; if (manual) { results = PlaceResults.BaseCamp; } else { results = PlaceResults.Residential; } } } } else { msg += "E"; results = PlaceResults.BaseCamp; } } if (household.LotHome != null) { msg += "F"; foreach (Service service in Services.AllServices) { if (service == null) { continue; } if (service.DefaultIsRequested()) { continue; } service.MakeServiceRequest(household.LotHome, false, ObjectGuid.InvalidObjectGuid); } TravelUtil.TriggerTutorial(household); TravelUtil.PlaceSimsOnSafeSpots(household, ref simToSelect); // core block in pusharriveinteraction on ITimePortal preventing teens who travel alone from getting the arrive interaction thus // appearing invisible bool flag = true; foreach (SimDescription desc in household.SimDescriptions) { if (desc.YoungAdultOrAbove) { flag = false; break; } } ITimePortal[] portalArray; if (flag && ArriveHomeBehaviorInVacationWorld.ShouldArriveByTimePortal(household.LotHome, out portalArray)) { new Common.AlarmTask(3f, TimeUnit.Minutes, PushArriveHomeInteractionEx); } } } } catch (Exception e) { Traveler.InsanityException(msg, e); } finally { Traveler.InsanityWriteLog(msg); } return(results); }