protected override bool CommonAllow(SimDescription sim) { if (Sims.HasEnough(this, sim)) { IncStat("Maximum Reached"); return(false); } else if (sim.IsPregnant) { IncStat("Couple Pregnant"); return(false); } else if (!Pregnancies.Allow(this, sim)) { IncStat("User Denied"); return(false); } if (GetValue <MaximumNumberOfChildrenOption, int>(sim) > 0) { if (AddScoring("PreferredBabyCount", sim) <= Relationships.GetChildren(sim).Count) { IncStat("Enough"); return(false); } } return(base.CommonAllow(sim)); }
protected override bool CommonAllow(SimDescription sim) { if (Sims.HasEnough(this, sim)) { IncStat("Maximum Reached"); return(false); } else if (sim.IsPregnant) { IncStat("Couple Pregnant"); return(false); } else if (SimTypes.InServicePool(sim, ServiceType.GrimReaper)) { IncStat("Reaper"); return(false); } else if (sim.IsMummy) { IncStat("Mummy"); return(false); } return(base.CommonAllow(sim)); }
protected override bool PrivateUpdate(ScenarioFrame frame) { List <Manager> managers = new List <Manager>(); string body = null; int previousPressure = 0; foreach (KeyValuePair <Manager, int> value in Lots.ImmigrationPressure) { if (value.Value == 0) { continue; } AddStat("Pressure: " + value.Key.UnlocalizedName, value.Value); body += Localize("PressureElement", false, new object[] { value.Key.GetLocalizedName(), value.Value }); managers.Add(value.Key); previousPressure += value.Value; } AddStat("Total", previousPressure); Lots.PreviousPressure = previousPressure; if (ImmigrationGauge <= 0) { return(false); } mStory = Localize("PressureSummary", false, new object[] { body, previousPressure }); if (previousPressure <= ImmigrationGauge) { mStory += Localize("PressureInsufficient", false, new object[] { ImmigrationGauge }); return(true); } if (Sims.HasEnough(this, CASAgeGenderFlags.Human)) { mStory += Localize("PressureMaxResidents"); return(true); } foreach (Manager manager in managers) { Add(frame, manager.GetImmigrantRequirement(mRequirement), ScenarioResult.Start); } mStory = null; mRequirement.mRequired = true; return(false); }
protected CASAgeGenderFlags GetSpecies(SimDescription sim) { List <CASAgeGenderFlags> species = new List <CASAgeGenderFlags>(); if (mSpecies != CASAgeGenderFlags.None) { species.Add(mSpecies); } else { GetPossibleSpecies(sim.Household, species); } AddStat("Choices", species.Count); bool allowAnother = RandomUtil.RandomChance(GetValue <PetAdoptionBaseScenario.ChanceOfAnotherOptionV2, int>()); for (int i = species.Count - 1; i >= 0; i--) { CASAgeGenderFlags choice = species[i]; if (Sims.HasEnough(this, choice)) { IncStat("Maximum " + species); species.RemoveAt(i); } else if (HouseholdsEx.IsFull(this, sim.Household, choice, 0, true, allowAnother)) { species.RemoveAt(i); } } if (species.Count > 0) { if (mNewSim != null) { if (!species.Contains(mNewSim.Species)) { IncStat("House Wrong Species"); return(CASAgeGenderFlags.None); } else { return(mNewSim.Species); } } return(RandomUtil.GetRandomObjectFromList(species)); } else { return(CASAgeGenderFlags.None); } }
protected override bool Allow(Household house) { if (house.LotHome != null) { IncStat("Resident"); return(false); } else if (Sims.HasEnough(house.SimDescriptions)) { IncStat("Town Full"); return(false); } return(base.Allow(house)); }
protected override bool Allow() { if (!GetValue <NewcomerGoneScenario.AllowHomelessMoveInOptionV2, bool>()) { IncStat("Move In Denied"); return(false); } else if (Sims.HasEnough(Movers)) { IncStat("Town Full"); return(false); } return(base.Allow()); }
protected override bool Allow() { if (GetValue <ThresholdOption, int>() <= 0) { return(false); } if (!Sims.HasEnough(this, CASAgeGenderFlags.Human)) { IncStat("Not Full"); return(false); } return(base.Allow()); }
protected override bool Allow() { if (Sims.HasEnough(this, CASAgeGenderFlags.Human)) { IncStat("Town Full"); return(false); } else if (!TestEmptyHomes(this)) { IncStat("Too Few Empty"); return(false); } else if (Lots.FindLot(this, null, 0, ManagerLot.FindLotFlags.Inspect | ManagerLot.FindLotFlags.CheapestHome, OnLotPriceCheck) == null) { IncStat("No Empty"); return(false); } return(base.Allow()); }
protected override bool Allow(SimDescription sim) { if (sim.LotHome != null) { IncStat("Resident"); return(false); } else if (!Households.Allow(this, sim, 0)) { IncStat("User Denied"); return(false); } else if (Sims.HasEnough(this, sim)) { IncStat("Maximum Reached"); return(false); } return(base.Allow(sim)); }
protected override bool CommonAllow(SimDescription sim) { if (Sims.HasEnough(this, sim)) { IncStat("Maximum Reached"); return(false); } else if (sim.IsPregnant) { IncStat("Couple Pregnant"); return(false); } else if (!Pregnancies.Allow(this, sim)) { IncStat("User Denied"); return(false); } return(base.CommonAllow(sim)); }
protected override bool PrivateUpdate(ScenarioFrame frame) { if (mCheckRequired) { if (!mRequirement.mRequired) { return(false); } } List <CASAgeGenderFlags> ageGenderRequirements = new List <CASAgeGenderFlags>(); if ((!mRequirement.mNeedMale) && (!mRequirement.mNeedFemale)) { if (BabyGenderScenario.GetGenderByFirstBorn(Manager, GetValue <GenderOption, BabyGenderScenario.FirstBornGender>(), false) == CASAgeGenderFlags.Male) { mRequirement.mNeedMale = true; } else { mRequirement.mNeedFemale = true; } } bool teenMoveIn = false; if (mRequirement.mMate == null) { if (RandomUtil.RandomChance(GetValue <TeenChanceOption, int>())) { teenMoveIn = true; } } else if (mRequirement.mMate.Teen) { teenMoveIn = true; } if (mRequirement.mNeedMale) { CASAgeGenderFlags age = CASAgeGenderFlags.Male | CASAgeGenderFlags.Human; if (teenMoveIn) { age |= CASAgeGenderFlags.Teen; } else //if ((mRequirement.CareerLevel != null) && (mRequirement.CareerLevel.Level > 5)) { age |= CASAgeGenderFlags.YoungAdult; age |= CASAgeGenderFlags.Adult; } ageGenderRequirements.Add(age); } if (mRequirement.mNeedFemale) { CASAgeGenderFlags age = CASAgeGenderFlags.Female | CASAgeGenderFlags.Human; if (teenMoveIn) { age |= CASAgeGenderFlags.Teen; } else if (mRequirement.mFertile) { age |= CASAgeGenderFlags.YoungAdult; } else //((mRequirement.CareerLevel != null) && (mRequirement.CareerLevel.Level > 5) && ) { age |= CASAgeGenderFlags.YoungAdult; age |= CASAgeGenderFlags.Adult; } ageGenderRequirements.Add(age); } bool singleParent = false; Lot familyLot = null; if (((mRequirement.mMate == null) || (!mCheckRequired)) && (GetValue <WholeFamilyOption, int>() > 0) && (!RandomUtil.RandomChance(GetValue <SingleSimOption, int>()))) { IncStat("WholeFamily"); familyLot = Lots.FindLot(this, null, 0, ManagerLot.FindLotFlags.CheapestHome | ManagerLot.FindLotFlags.Inspect, OnLotPriceCheck); if (familyLot == null) { return(false); } if (RandomUtil.RandomChance(GetValue <ChanceOfSingleOption, int>())) { IncStat("Single Parent"); singleParent = true; } else if (familyLot.CountObjects <IBedDouble>() == 0) { if (familyLot.CountObjects <IBedSingle>() > 1) { IncStat("Single Parent"); singleParent = true; } else { IncStat("No Double Bed"); familyLot = null; } } } using (SimFromBin <ManagerLot> simBin = new SimFromBin <ManagerLot>(this, Lots)) { List <SimDescription> sims = new List <SimDescription>(); CASAgeGenderFlags genders = CASAgeGenderFlags.Male | CASAgeGenderFlags.Female; if (familyLot != null) { BabyGenderScenario.FirstBornGender genderPref = GetValue <GenderOption, BabyGenderScenario.FirstBornGender>(); bool bothGenders = true; if ((genderPref == BabyGenderScenario.FirstBornGender.Male) || (genderPref == BabyGenderScenario.FirstBornGender.Female)) { bothGenders = false; } else if (RandomUtil.RandomChance(GetValue <ManagerFlirt.ChanceOfGaySim, int>())) { bothGenders = false; } if (ageGenderRequirements.Count == 1) { if (bothGenders) { if ((ageGenderRequirements[0] & CASAgeGenderFlags.Male) == CASAgeGenderFlags.Male) { ageGenderRequirements.Add(CASAgeGenderFlags.Female | (ageGenderRequirements[0] & CASAgeGenderFlags.AgeMask)); } else { ageGenderRequirements.Add(CASAgeGenderFlags.Male | (ageGenderRequirements[0] & CASAgeGenderFlags.AgeMask)); } } else { genders = ageGenderRequirements[0] & CASAgeGenderFlags.GenderMask; ageGenderRequirements.Add(ageGenderRequirements[0]); } } } foreach (CASAgeGenderFlags ageGender in ageGenderRequirements) { SimDescription sim = simBin.CreateNewSim(ageGender & CASAgeGenderFlags.AgeMask, ageGender & CASAgeGenderFlags.GenderMask, CASAgeGenderFlags.Human); if (sim == null) { IncStat("Creation Failure"); } else { sims.Add(sim); } } if (familyLot == null) { if (sims.Count > 0) { Add(frame, new ImmigrantMailOrderScenario(mRequirement, sims), ScenarioResult.Start); } } else { bool createChildren = true; SimDescription otherParent = null; List <SimDescription> parents = new List <SimDescription>(sims); if (parents.Count > 1) { otherParent = parents[1]; if (parents[1].IsMale) { parents[0].InternalIncreaseGenderPreferenceMale(); } else { parents[0].InternalIncreaseGenderPreferenceFemale(); } if (parents[0].IsMale) { parents[1].InternalIncreaseGenderPreferenceMale(); } else { parents[1].InternalIncreaseGenderPreferenceFemale(); } Relationship relation = Relationship.Get(parents[0], parents[1], true); if (relation != null) { relation.MakeAcquaintances(); } if (GameUtils.IsUniversityWorld()) { createChildren = true; IncStat("Immigrant Friends"); } else if (!RandomUtil.RandomChance(GetValue <ChanceOfFriendsOption, int>())) { Dictionary <string, List <News.NewsTuning.ArticleTuning> > namedArticles = News.sNewsTuning.mNamedArticles; try { // Doing so stops Marriage notices of imported sims from appearing in the newspaper News.sNewsTuning.mNamedArticles = new Dictionary <string, List <News.NewsTuning.ArticleTuning> >(); if (RandomUtil.RandomChance(GetValue <ChanceOfPartnerOption, int>())) { IncStat("Immigrant Partners"); while (relation.CurrentLTR != LongTermRelationshipTypes.Partner) { if (!Romances.BumpToHigherState(this, parents[0], parents[1])) { break; } } } else { if (!Romances.BumpToHighestState(this, parents[0], parents[1])) { IncStat("Unmarriable"); createChildren = false; } else { parents[1].LastName = parents[0].LastName; } } } finally { News.sNewsTuning.mNamedArticles = namedArticles; } } else { createChildren = false; IncStat("Immigrant Friends"); } } if (createChildren) { Lot.LotMetrics metrics = new Lot.LotMetrics(); familyLot.GetLotMetrics(ref metrics); int totalChildren = GetValue <WholeFamilyOption, int>(); if (totalChildren > Options.GetValue <MaximumSizeOption, int>()) { totalChildren = Options.GetValue <MaximumSizeOption, int>(); } totalChildren -= parents.Count; totalChildren = RandomUtil.GetInt(totalChildren - 1) + 1; AddStat("Allowed Children", totalChildren); int totalBeds = metrics.BedCount - parents.Count; if (totalBeds > totalChildren) { totalBeds = totalChildren; } AddStat("Available Beds", totalBeds); if (!GameUtils.IsUniversityWorld()) { int numCribs = RandomUtil.GetInt((int)familyLot.CountObjects <Sims3.Gameplay.Objects.Beds.Crib>()); // Create the children if (numCribs > 2) { numCribs = 2; } if (numCribs > totalChildren) { numCribs = totalChildren; } AddStat("Available Cribs", numCribs); for (int i = 0; i < numCribs; i++) { SimDescription sim = simBin.CreateNewSim(parents[0], otherParent, CASAgeGenderFlags.Toddler, genders, parents[0].Species, true); if (sim == null) { IncStat("Creation Failure"); } else { sims.Add(sim); totalBeds--; } } if ((!parents[0].Teen) && ((otherParent == null) || (!otherParent.Teen))) { for (int i = 0; i < totalBeds; i++) { SimDescription sim = simBin.CreateNewSim(parents[0], otherParent, CASAgeGenderFlags.Child | CASAgeGenderFlags.Teen, genders, parents[0].Species, true); if (sim == null) { IncStat("Creation Failure"); } else { sims.Add(sim); } } } } else { for (int i = 0; i < totalBeds; i++) { SimDescription sim = simBin.CreateNewSim(CASAgeGenderFlags.YoungAdult | CASAgeGenderFlags.Adult, genders, parents[0].Species); if (sim == null) { IncStat("Creation Failure"); } else { sims.Add(sim); } } } if ((singleParent) && (otherParent != null)) { sims.Remove(otherParent); parents.Remove(otherParent); if (otherParent.Partner != null) { otherParent.Partner.Partner = null; otherParent.Partner = null; } otherParent.Dispose(true, false, true); } } } if ((GameUtils.IsInstalled(ProductVersion.EP5)) && (RandomUtil.RandomChance(GetValue <PetChanceOption, int>()))) { List <CASAgeGenderFlags> choices = new List <CASAgeGenderFlags>(); foreach (SimDescription sim in sims) { PetAdoptionBaseScenario.GetPossibleSpecies(this, familyLot, sim, false, choices); } AddStat("Pet Choices", choices.Count); if (choices.Count > 0) { int numberPets = RandomUtil.GetInt(1, GetValue <MaximumPetsOption, int>() - 1); AddStat("Pet Immigrants", numberPets); for (int i = 0; i < numberPets; i++) { CASAgeGenderFlags species = RandomUtil.GetRandomObjectFromList(choices); if (Sims.HasEnough(this, species)) { continue; } SimDescription pet = simBin.CreateNewSim(CASAgeGenderFlags.Child | CASAgeGenderFlags.Adult | CASAgeGenderFlags.Elder, CASAgeGenderFlags.Male | CASAgeGenderFlags.Female, species); if (pet != null) { pet.LastName = sims[0].LastName; sims.Add(pet); } else { IncStat("Pet Creation Fail"); } } } } Add(frame, new ImmigrantMoveInScenario(sims), ScenarioResult.Start); Add(frame, new NewImmigrantScenario(sims, mRequirement), ScenarioResult.Success); } return(true); }