public static bool IsLunarCycleZombie(Household home) { if (LunarCycleManager.sFullMoonZombies == null) { return(false); } if (LunarCycleManager.sFullMoonZombies.Count == 0) { return(false); } foreach (SimDescription sim in Households.All(home)) { if (sim.IsZombie) { if (LunarCycleManager.sFullMoonZombies.Contains(sim)) { return(true); } } } return(false); }
public static bool ExportHouseholdForTravel(Household household) { try { foreach (Sim sim in Households.AllSims(household)) { sim.SetObjectToReset(); DreamCatcher.PruneDreamManager(sim); } Common.Sleep(); ulong id = DownloadContent.GenerateGUID(); HouseholdContentsProxy householdContents = new HouseholdContentsProxy(household); householdContents.Contents.ContentId = id; if (DownloadContent.StoreHouseholdContents(householdContents, id)) { DownloadContent.ExportLotContentsToTravelBin(id); return(true); } } catch (Exception e) { Common.Exception("ExportHouseholdForTravel", e); } return(false); }
public static bool IsActiveDaycare(Household home) { if (Household.ActiveHousehold == null) { return(false); } foreach (SimDescription actor in Households.All(Household.ActiveHousehold)) { Daycare dayCare = actor.Occupation as Daycare; if (dayCare == null) { continue; } foreach (SimDescription sim in Households.All(home)) { if (dayCare.IsDaycareChild(sim)) { return(true); } } } return(false); }
public static bool IsActiveCoworker(Household home) { if (Household.ActiveHousehold == null) { return(false); } foreach (SimDescription sim in Households.All(home)) { foreach (SimDescription active in Households.All(Household.ActiveHousehold)) { Occupation occupation = active.Occupation; if (occupation == null) { continue; } if (occupation.Coworkers != null) { if (occupation.Coworkers.Contains(sim)) { return(true); } } } } return(false); }
public static bool IsPassport(Household home) { foreach (SimDescription sim in Households.All(home)) { if (Passport.IsHostedPassportSim(sim.CreatedSim)) { return(true); } } return(false); }
public static bool IsRole(Household home) { foreach (SimDescription sim in Households.All(home)) { if (sim.AssignedRole != null) { return(true); } } return(false); }
public static void Cleanse(Household house) { try { foreach (SimDescription sim in new List <SimDescription>(Households.All(house))) { Cleanse(sim); } house.Destroy(); house.Dispose(); } catch (Exception e) { Common.Exception(house.Name, e); } }
public static Dictionary<SimDescription, string> GetTravelChoices(Sim travelInitiator, Type filter, bool forUniversity) { Dictionary<SimDescription, string> results = new Dictionary<SimDescription, string>(); foreach (Sim sim in LotManager.Actors) { if (sim.Household != travelInitiator.Household) { if (GameStates.sTravelData != null) continue; } if ((sim.Household != travelInitiator.Household) || (!SimTypes.IsSelectable(sim))) { bool allow = false; if ((filter & Type.Friends) != Type.None) { foreach (Sim member in Households.AllSims(travelInitiator.Household)) { if (member == sim) continue; Relationship relation = Relationship.Get(sim, travelInitiator, false); if (relation == null) continue; if (relation.AreFriendsOrRomantic()) { allow = true; break; } } } if (!allow) continue; } results[sim.SimDescription] = TravelUtilEx.CheckForReasonsToFailTravel(sim.SimDescription, filter, forUniversity ? WorldName.University : WorldName.Undefined, false, false); } return results; }
public HouseholdStore(IEnumerable <SimDescription> newSims, bool catchDreams) { if (newSims != null) { mNewSims = new List <SimDescription>(newSims); } mOldHouse = PlumbBob.sCurrentNonNullHousehold; if ((mOldHouse != null) && (catchDreams)) { foreach (Sim member in Households.AllSims(mOldHouse)) { DreamStore element = new DreamStore(member, false, true); mDreamStore.Add(member, element); } } if (mNewSims != null) { foreach (SimDescription member in mNewSims) { Corrections.CleanupBrokenSkills(member, null); mSafeStore.Add(member, new SafeStore(member, SafeStore.Flag.Selectable | SafeStore.Flag.Unselectable | SafeStore.Flag.StoreOpportunities)); if ((member.CreatedSim != null) && (member.CreatedSim.Autonomy != null)) { Motives motives = member.CreatedSim.Autonomy.Motives; if ((motives == null) || (motives.GetMotive(CommodityKind.Hunger) == null)) { member.CreatedSim.Autonomy.RecreateAllMotives(); } } } } }
public HouseholdStore(Household newHouse, bool catchDreams) : this(Households.All(newHouse), catchDreams) { }
public static bool ImportContent(Household me, ResKeyTable resKeyTable, ObjectIdTable objIdTable, IPropertyStreamReader reader) { ulong num2; int num3; ulong[] numArray; ulong[] numArray2; ulong num8; reader.ReadString(0x50e3d25c, out me.mName, ""); reader.ReadInt32(0x33b96433, out me.mFamilyFunds, 0x0); reader.ReadString(0xd96b03f8, out me.mBioText, ""); reader.ReadInt32(0x8af84d8, out me.mUnpaidBills, 0x0); reader.ReadInt32(0xc6fdb12d, out me.mLotHomeWorth, 0x0); long num = DateTime.Now.ToBinary(); reader.ReadInt64(0x6384bbe4, out num, DateTime.Now.ToBinary()); me.mExportTime = DateTime.FromBinary(num); reader.ReadBool(0x2213ca71, out me.mbLifetimeHappinessNotificationShown, false); IPropertyStreamReader child = reader.GetChild(0x91fa3ace); if (child != null) { me.mMembers.ImportContent(resKeyTable, objIdTable, child); // Custom to handle import of custom careers HouseholdMemberEx.ImportContent(me.mMembers, resKeyTable, objIdTable, child); } foreach (SimDescription description in Households.All(me)) { try { // Custom if (Household.sOldIdToNewSimDescriptionMap != null) { if ((description.mOldSimDescriptionId != 0) && (!Household.sOldIdToNewSimDescriptionMap.ContainsKey(description.mOldSimDescriptionId))) { Household.sOldIdToNewSimDescriptionMap.Add(description.mOldSimDescriptionId, description); } if (!Household.sOldIdToNewSimDescriptionMap.ContainsKey(description.mSimDescriptionId)) { Household.sOldIdToNewSimDescriptionMap.Add(description.mSimDescriptionId, description); } } description.OnHouseholdChanged(me, true); description.CareerManager.OnLoadFixup(); Occupation occupation = description.CareerManager.Occupation; if (occupation != null) { occupation.RepairLocation(); } } catch (Exception e) { Common.Exception(description, e); } } foreach (SimDescription description2 in Households.All(me)) { try { if (description2.Pregnancy != null) { SimDescription description3; if ((Household.sOldIdToNewSimDescriptionMap != null) && Household.sOldIdToNewSimDescriptionMap.TryGetValue(description2.Pregnancy.DadDescriptionId, out description3)) { description2.Pregnancy.DadDescriptionId = description3.SimDescriptionId; } else if (!Household.IsTravelImport && (me.mMembers.GetSimDescriptionFromId(description2.Pregnancy.DadDescriptionId) == null)) { description2.Pregnancy.DadDescriptionId = 0x0L; } } } catch (Exception e) { Common.Exception(description2, e); } } child = reader.GetChild(0xa14ee9b6); if (child != null) { // Custom Function ImportRelationships(me, resKeyTable, objIdTable, child); } reader.ReadInt32(0x872a7c9, out me.mAncientCoinCount, 0x0); reader.ReadUint64(0x4723b840, out num2, 0x0L); me.UniqueObjectsObtained = (UniqueObjectKey)num2; me.mKeystonePanelsUsed = new PairedListDictionary <WorldName, List <string> >(); reader.ReadInt32(0x7bcd11d, out num3, 0x0); for (uint i = 0x0; i < num3; i++) { int num5; string[] strArray; reader.ReadInt32(0x8bc9c54 + i, out num5, -1); WorldName name = (WorldName)num5; reader.ReadString(0x9bcd0e7 + i, out strArray); me.mKeystonePanelsUsed[name] = new List <string>(strArray); } me.mCompletedHouseholdOpportunities.Clear(); reader.ReadUint64(0x8eae351, out numArray); foreach (ulong num6 in numArray) { me.mCompletedHouseholdOpportunities.Add(num6, true); } reader.ReadUint32(0x8eae352, out me.mMoneySaved); reader.ReadUint64(0x92b562c, out numArray2); foreach (ulong num7 in numArray2) { me.mWardrobeCasParts.Add(num7); } reader.ReadUint64(0x95175f0, out num8, 0x0L); me.AddServiceUniforms((ServiceType)((int)num8)); return(true); }
public static void AddSims(Household ths, List <Sim> sims, Household oldHousehold, bool bDeleteHouseholdIfEmpty, bool willBeActive, bool dreamCatcher) { bool isActive = ths.IsActive || willBeActive; List <SimDescription> existing = new List <SimDescription>(Households.All(ths)); foreach (Sim sim in sims) { try { SimDescription simDescription = sim.SimDescription; if (simDescription.ServiceHistory != ServiceType.None) { ths.AddServiceUniform(simDescription.ServiceHistory); } if (isActive) { /* * if (((!simDescription.IsMummy && !simDescription.IsFrankenstein) && (!simDescription.IsImaginaryFriend && !sim.IsActiveFirefighter)) && simDescription.ReplaceHiddenCasParts()) * { * sim.PushSwitchToOutfitInteraction(Sim.ClothesChangeReason.Force, OutfitCategories.Everyday); * } */ if (simDescription.CreatedByService != null) { simDescription.CreatedByService.OnMoveInActiveHousehold(sim); } } if (oldHousehold != null) { oldHousehold.RemoveSim(sim, false, bDeleteHouseholdIfEmpty); } if (sim.Household != ths) { ths.Add(simDescription); } } catch (Exception e) { Common.Exception(sim, e); } } if ((ths.LotHome != null) && (ths.LotHome.IsApartmentLot)) { if (isActive) { foreach (SimDescription member in existing) { Household.RoommateManager.AddRoommate(member, ths); } Household.RoommateManager.StartAcceptingRoommates(8, ths); } else { Household.RoommateManager.MakeAllRoommatesSelectable(ths); } } ths.AddWardrobeToWardrobe(oldHousehold.Wardrobe); ths.AddServiceUniforms(oldHousehold.mServiceUniforms); foreach (Sim sim2 in sims) { DreamCatcher.AdjustSelectable(sim2.SimDescription, isActive, dreamCatcher); } }
public AddSims(Household house, IEnumerable <IMiniSimDescription> miniSims, bool overStuff, bool transferFunds, bool dreamCatcher) { mOldMembers = new List <SimDescription>(CommonSpace.Helpers.Households.All(house)); foreach (IMiniSimDescription iMiniSim in new List <IMiniSimDescription>(miniSims)) { if (overStuff) { if (iMiniSim.IsHuman) { if (CommonSpace.Helpers.Households.NumHumansIncludingPregnancy(house) >= 8) { continue; } } else { if (CommonSpace.Helpers.Households.NumPetsIncludingPregnancy(house) >= 6) { continue; } } } MiniSimDescription miniSim = null; bool lastActiveSim = false; SimDescription sim = iMiniSim as SimDescription; if (sim == null) { miniSim = iMiniSim as MiniSimDescription; if (miniSim == null) { continue; } sim = MiniSims.UnpackSimAndUpdateRel(miniSim); if (sim == null) { continue; } } else if (sim.CreatedSim == Sim.ActiveActor) { if (Households.NumSims(sim.Household) == 1) { lastActiveSim = true; } else { LotManager.SelectNextSim(); } } Household oldHouse = sim.Household; if (oldHouse != null) { if (oldHouse == Household.ActiveHousehold) { Household.RoommateManager.RemoveRoommateInternal(sim); } if ((transferFunds) && (oldHouse.NumMembers == 1)) { int funds = oldHouse.FamilyFunds; if (oldHouse.LotHome != null) { funds += oldHouse.LotHome.Cost; } house.ModifyFamilyFunds(funds); Households.TransferData(house, oldHouse); } house.AddWardrobeToWardrobe(oldHouse.Wardrobe); house.AddServiceUniforms(oldHouse.mServiceUniforms); oldHouse.Remove(sim, !oldHouse.IsSpecialHousehold); if (PetAdoption.sNeighborAdoption != null) { PetAdoption.sNeighborAdoption.mPetsToAdopt.Remove(sim); } if (sim.CreatedSim != null) { oldHouse.GetCaregiverRoutingMonitor(sim.CreatedSim.LotCurrent, true); } } if ((oldHouse != null) && (!mOldHouses.ContainsKey(oldHouse))) { mOldHouses.Add(oldHouse, true); } mNewMembers.Add(sim); if (house.Name == null) { house.Name = sim.LastName; } if ((sim.IsDead) && (!sim.IsPlayableGhost)) { Urnstone grave = Urnstones.CreateGrave(sim, false); if (grave != null) { Urnstones.GhostToPlayableGhost(grave, house, house.LotHome.EntryPoint()); } } else { // Must be performed or the Household:Add() will bounce if (!sim.IsValidDescription) { sim.Fixup(); } MiniSims.ProtectedAddHousehold(house, sim); if (sim.IsPet) { foreach (PetPoolType type in Enum.GetValues(typeof(PetPoolType))) { if (PetPoolManager.IsPetInPoolType(sim, type)) { PetPoolManager.RemovePet(type, sim, true); } } } if ((CarNpcManager.Singleton != null) && (CarNpcManager.Singleton.NpcDriversManager != null)) { if (CarNpcManager.Singleton.NpcDriversManager.mDescPools != null) { for (int i = 0; i < CarNpcManager.Singleton.NpcDriversManager.mDescPools.Length; i++) { Stack <SimDescription> stack = CarNpcManager.Singleton.NpcDriversManager.mDescPools[i]; if (stack == null) { continue; } List <SimDescription> list = new List <SimDescription>(); foreach (SimDescription stackSim in stack) { if (stackSim == sim) { while (stack.Count > 0) { list.Add(stack.Pop()); } list.Remove(sim); for (int j = list.Count - 1; j >= 0; j--) { stack.Push(list[j]); } } } } } if ((sim.CreatedSim != null) && (CarNpcManager.Singleton.NpcDriversManager.mNpcDrivers != null)) { CarNpcManager.Singleton.NpcDriversManager.mNpcDrivers.Remove(sim.CreatedSim); } } } if (house.LotHome != null) { Instantiation.EnsureInstantiate(sim, house.LotHome); } if (miniSim != null) { (Sims3.Gameplay.UI.Responder.Instance.HudModel as HudModel).OnSimCurrentWorldChanged(true, miniSim); AgingManager.Singleton.AddSimDescription(sim); sim.AgingState.MergeTravelInformation(miniSim); sim.SetFlags(SimDescription.FlagField.AgingEnabled, true); } try { if (sim.Service != null) { sim.Service.EndService(sim); } if (sim.CreatedSim != null) { sim.CreatedSim.BuffManager.RemoveElement(BuffNames.StrayPet); DreamCatcher.AdjustSelectable(sim, sim.Household == Household.ActiveHousehold, dreamCatcher); sim.CreatedSim.SetObjectToReset(); sim.CreatedSim.Motives.RecreateMotives(sim.CreatedSim); Sim.MakeSimGoHome(sim.CreatedSim, false); if (lastActiveSim) { PlumbBob.DoSelectActor(sim.CreatedSim, false); } } } catch (Exception e) { Common.DebugException(sim, e); } } }
public static string CheckForReasonsToFailTravel(SimDescription simDescription, Type filter, WorldName worldName, bool isWorldMove, bool testMoveRequested) { try { if (simDescription == null) return null; if (testMoveRequested) { if ((TravelUtil.PlayerMadeTravelRequest) || (GameStates.WorldMoveRequested)) { return TravelUtil.LocalizeString(simDescription.IsFemale, "AnotherTravelRequested", new object[] { simDescription }); } } bool playerMadeTravelRequest = TravelUtil.PlayerMadeTravelRequest; try { TravelUtil.PlayerMadeTravelRequest = false; string failReason = null; if (!InWorldSubState.IsEditTownValid(simDescription.LotHome, ref failReason)) { if (!string.IsNullOrEmpty(failReason) && Localization.HasLocalizationString("Gameplay/Visa/TravelUtil:EditTownInvalid" + failReason)) { return TravelUtil.LocalizeString(simDescription.IsFemale, "EditTownInvalid" + failReason, new object[] { simDescription }); } return TravelUtil.LocalizeString(simDescription.IsFemale, "EditTownInvalid", new object[] { simDescription }); } } finally { TravelUtil.PlayerMadeTravelRequest = playerMadeTravelRequest; } foreach (Sim sim in Households.AllSims(simDescription.Household)) { try { if (sim.IsDying()) { return TravelUtil.LocalizeString(sim.IsFemale, "FamilyMemberIsDying", new object[] { sim }); } else if (sim.Autonomy.SituationComponent.InSituationOfType(typeof(ParentsLeavingTownSituation))) { return TravelUtil.LocalizeString(sim.IsFemale, "ParentsOutOfTown", new object[] { sim }); } else if (sim.InteractionQueue.HasInteractionOfType(AgeDown.Singleton)) { return TravelUtil.LocalizeString(sim.IsFemale, "SomeoneIsAgingDown", new object[] { sim }); } else if ((sim != simDescription.CreatedSim) && sim.InteractionQueue.HasInteractionOfType(typeof(IAmMovingInteraction))) { return TravelUtil.LocalizeString(sim.IsFemale, "AnotherTravelRequested", new object[] { sim }); } } catch (Exception e) { Common.Exception(sim, e); return "(Error)"; } } if (!isWorldMove) { if ((worldName != WorldName.FutureWorld) && (simDescription.ToddlerOrBelow)) { if ((filter & Type.Toddlers) == Type.None) { return TravelUtil.LocalizeString(simDescription.IsFemale, "TooYoungToTravel", new object[] { simDescription }); } } if ((worldName == WorldName.University) && (simDescription.Teen)) { if ((filter & Type.Teens) == Type.None) { return TravelUtil.LocalizeString(simDescription.IsFemale, "TooYoungToTravel", new object[] { simDescription }); } } if ((worldName == WorldName.University) && (simDescription.ChildOrBelow)) { if ((filter & Type.Children) == Type.None) { return TravelUtil.LocalizeString(simDescription.IsFemale, "TooYoungToTravel", new object[] { simDescription }); } } if (simDescription.IsPet) { if ((filter & Type.Pets) == Type.None) { return Common.Localize("Travel:PetDeny", simDescription.IsFemale, new object[] { simDescription }); } } if ((worldName != WorldName.University) && (worldName != WorldName.FutureWorld) && (simDescription.CreatedSim != null) && simDescription.CreatedSim.BuffManager.HasElement(BuffNames.WentToLocation)) { if ((filter & Type.Recovering) == Type.None) { return TravelUtil.LocalizeString(simDescription.IsFemale, "RecoveringFromVacation", new object[] { simDescription }); } } } if (Sims3.Gameplay.Passport.Passport.IsHouseholdSimAwayInPassport(simDescription.Household)) { return TravelUtil.LocalizeString(simDescription.IsFemale, "SimInPassport", new object[] { simDescription }); } if ((simDescription.CreatedSim != null) && simDescription.CreatedSim.BuffManager.HasElement(BuffNames.VampireBite)) { return TravelUtil.LocalizeString(simDescription.IsFemale, "VampireBite", new object[] { simDescription }); } if (simDescription.IsVisuallyPregnant) { if ((filter & Type.Pregnant) == Type.None) { return TravelUtil.LocalizeString(simDescription.IsFemale, "IsPregnant", new object[] { simDescription }); } } Sim createdSim = simDescription.CreatedSim; if ((createdSim != null) && createdSim.BuffManager.HasElement(BuffNames.MalePregnancy)) { if ((filter & Type.Pregnant) == Type.None) { return TravelUtil.LocalizeString(simDescription.IsFemale, "ConditionPreventsTravel", new object[] { simDescription }); } } if ((createdSim != null) && createdSim.IsDying()) { return TravelUtil.LocalizeString(simDescription.IsFemale, "IsDying", new object[] { simDescription }); } if ((createdSim != null) && (createdSim.CurrentInteraction is IGoToJail)) { return TravelUtil.LocalizeString(simDescription.IsFemale, "IsInJail", new object[] { simDescription }); } if (simDescription.IsEnrolledInBoardingSchool()) { return TravelUtil.LocalizeString(simDescription.IsFemale, "IsInBoardingSchool", new object[] { simDescription }); } if ((ParentsLeavingTownSituation.Adults != null) && ParentsLeavingTownSituation.Adults.Contains(simDescription.SimDescriptionId)) { return TravelUtil.LocalizeString(simDescription.IsFemale, "ParentsOutOfTown", new object[] { simDescription }); } if (simDescription.mCurrentPassportChallengeID != PassportChallenges.ChallengeIds.InvalidChallenge) { return TravelUtil.LocalizeString(simDescription.IsFemale, "AwayInPassport", new object[] { simDescription }); } if ((createdSim != null) && createdSim.BuffManager.HasElement(BuffNames.Ensorcelled)) { return TravelUtil.LocalizeString(simDescription.IsFemale, "Ensorcelled", new object[] { simDescription }); } if (filter == Type.None) { if ((createdSim != null) && (TravelUtil.HasBlockingTransformBuff(createdSim, worldName == WorldName.FutureWorld))) { return TravelUtil.LocalizeString(simDescription.IsFemale, "NoTravelWhileTransformed", new object[0]); } } return null; } catch (Exception e) { Common.Exception(simDescription, e); return "(Error)"; } }