protected override bool Allow(Household house) { if (!Households.Allow(this, house, 0)) { IncStat("User Denied"); return(false); } else if (!GetValue <AllowAdoptionOption, bool>(SimTypes.HeadOfFamily(house))) { IncStat("Adoption Denied"); return(false); } else { SimDescription head = SimTypes.HeadOfFamily(house); if (AddScoring("Cooldown: Between Adoptions", TestElapsedTime <DayOfLastPetOption, PetAdoptionScenario.MinTimeBetweenAdoptionOption>(head)) < 0) { AddStat("Too Soon After Adoption", GetElapsedTime <DayOfLastPetOption>(head)); return(false); } } mPassedInspection = Lots.PassesHomeInspection(this, House.LotHome, HouseholdsEx.Pets(House), ManagerLot.FindLotFlags.InspectPets); if ((mPassedInspection) && (!HouseholdsEx.IsFull(this, House, CASAgeGenderFlags.Dog, GetValue <RoomToLeaveOption, int>(), false))) { IncStat("Score Fail"); return(false); } return(base.Allow(house)); }
protected override bool TargetAllow(SimDescription sim) { if (Sim.Household == Target.Household) { IncStat("Same"); return(false); } else if (sim.Household == null) { IncStat("No Home"); return(false); } else if (SimTypes.IsSpecial(sim)) { IncStat("Special"); return(false); } else if (HouseholdsEx.IsFull(sim.Household, sim.IsPet, GetValue <MaximumSizeOption, int>(sim.Household))) { IncStat("Full"); return(false); } return(base.TargetAllow(sim)); }
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(SimDescription sim) { if (!base.Allow(sim)) { return(false); } if (SimTypes.IsDead(sim)) { IncStat("Dead"); return(false); } else if (SimTypes.IsTourist(sim)) { IncStat("Tourist"); return(false); } else if ((sim.AgingState != null) && (sim.AgingState.IsAgingInProgress())) { IncStat("Aging"); return(false); } else if (sim.Household == null) { IncStat("No Household"); return(false); } else if (HouseholdHasAgelessBaby(sim.Household)) { IncStat("Unaging Baby"); return(false); } else if (HouseholdsEx.IsFull(this, sim.Household, sim.Species, 0, true, true)) { IncStat("House Full"); return(false); } else if ((sim.CreatedSim != null) && (sim.CreatedSim.BuffManager.HasTransformBuff())) { IncStat("Transformed"); return(false); } else if (!Pregnancies.AllowImpregnation(this, sim, Managers.Manager.AllowCheck.Active)) { IncStat("User Denied"); return(false); } return(true); }
protected override bool PrivateUpdate(ScenarioFrame frame) { List <Household> homeless = new List <Household>(); foreach (Household house in Household.sHouseholdList) { if (house.LotHome != null) { continue; } if (house == House) { continue; } homeless.Add(house); } if (homeless.Count == 0) { return(false); } int count = 0; do { count++; int total = RandomUtil.GetInt(2, 4); Dictionary <Household, bool> homes = new Dictionary <Household, bool>(); homes.Add(House, true); List <SimDescription> sims = new List <SimDescription>(); int humanCount = 0, petCount = 0; for (int i = 0; i < total; i++) { Household home = RandomUtil.GetRandomObjectFromList <Household>(homeless); if (homes.ContainsKey(home)) { continue; } if (HouseholdsEx.IsFull(this, home, CASAgeGenderFlags.Human, humanCount, false)) { continue; } if (HouseholdsEx.IsFull(this, home, CASAgeGenderFlags.Dog, petCount, false)) { continue; } HouseholdsEx.NumSimsIncludingPregnancy(home, ref humanCount, ref petCount); homes.Add(home, true); sims.AddRange(home.AllSimDescriptions); } Add(frame, new HomelessMoveInLotScenario(sims), ScenarioResult.Failure); }while (count < 10); return(false); }
protected override bool PrivateUpdate(ScenarioFrame frame) { if (mNewSim == null) { bool allowAnother = RandomUtil.RandomChance(GetValue <PetAdoptionBaseScenario.ChanceOfAnotherOptionV2, int>()); List <SimDescription> choices = new List <SimDescription>(); foreach (SimDescription sim in Sims.All) { if (sim.Species != Species) { continue; } if (!sim.ChildOrBelow) { continue; } if (SimTypes.IsSelectable(sim)) { continue; } // Don't take sims that are not living with their parents bool found = false; foreach (SimDescription parent in Relationships.GetParents(sim)) { if (parent.Household == sim.Household) { found = true; break; } } if (!found) { IncStat("Target Not With Parents"); continue; } if (!GetValue <AllowAdoptionOption, bool>(sim)) { IncStat("Target Adoption Denied"); continue; } SimDescription head = SimTypes.HeadOfFamily(sim.Household); if (head == null) { continue; } // Test whether the sim's existing household is too large and should shed an animal if (!HouseholdsEx.IsFull(this, sim.Household, sim.Species, 0, true, true)) { continue; } // Test whether the sim's new household is too small and can gain an animal if (HouseholdsEx.IsFull(this, Sim.Household, sim.Species, 0, true, allowAnother)) { continue; } choices.Add(sim); } if (choices.Count == 0) { IncStat("No Choice"); return(false); } mNewSim = RandomUtil.GetRandomObjectFromList(choices); } return(base.PrivateUpdate(frame)); }
protected override bool PrivateUpdate(ScenarioFrame frame) { if (mNewSim != null) { mSpecies = mNewSim.Species; } if (HouseholdsEx.IsFull(this, Sim.Household, mSpecies, 0, true, true)) { IncStat("Full"); return(false); } bool created = false; if (mNewSim == null) { using (SimFromBin <ManagerLot> simBin = new SimFromBin <ManagerLot>(this, Lots)) { CASAgeGenderFlags gender = BabyGenderScenario.GetGenderByFirstBorn(Manager, GetValue <ImmigrateScenario.GenderOption, BabyGenderScenario.FirstBornGender>(), false); mNewSim = simBin.CreateNewSim(Ages, gender, mSpecies); created = true; } } if (mNewSim != null) { if (Households.MoveSim(mNewSim, Sim.Household)) { mNewSim.LastName = Sim.LastName; mNewSim.WasAdopted = true; Relationship relation = ManagerSim.GetRelationship(Sim, mNewSim); if (relation != null) { relation.LTR.SetLiking(Delta); } Relationships.CheckAddHumanParentFlagOnAdoption(Sim, mNewSim); if (Sim.Partner != null) { Relationships.CheckAddHumanParentFlagOnAdoption(Sim.Partner, mNewSim); } if (SimTypes.IsEquivalentSpecies(mNewSim, Sim)) { Sim.Genealogy.AddChild(mNewSim.Genealogy); } UpdateDayOfLastOption(Sim); if ((Sim.Partner != null) && (Sim.IsMarried)) { if (SimTypes.IsEquivalentSpecies(mNewSim, Sim)) { Sim.Partner.Genealogy.AddChild(mNewSim.Genealogy); } UpdateDayOfLastOption(Sim.Partner); } return(true); } else if (created) { mNewSim.Dispose(); mNewSim = null; } } IncStat("No New Sim"); return(false); }