protected ICollection <SimDescription> FindPotentialMothers(int additionalBabyCount)
        {
            List <SimDescription> choices = new List <SimDescription>();

            foreach (SimDescription sim in Sims.All)
            {
                using (Common.TestSpan span = new Common.TestSpan(Scenarios, "FindPotentialMothers"))
                {
                    if (!AllowSpecies(sim))
                    {
                        continue;
                    }

                    IncStat(sim.FullName, Common.DebugLevel.Logging);

                    if ((sim.IsHuman) && (sim.Partner == null))
                    {
                        IncStat("Unpartnered");
                    }
                    else if (sim.IsPregnant)
                    {
                        IncStat("Already Pregnant");
                    }
                    else if (!Pregnancies.Allow(this, sim, sim.Partner, Managers.Manager.AllowCheck.Active))
                    {
                        //IncStat("Allow Fail");
                        continue;
                    }
                    else if (!TestPreferredBaby(this, sim, additionalBabyCount))
                    {
                        //IncStat("Preferred Fail");
                        continue;
                    }
                    else if (!Pregnancies.TestCooldown(this, sim))
                    {
                        //IncStat("Cooldown Fail");
                        continue;
                    }
                    else
                    {
                        choices.Add(sim);
                    }
                }
            }

            AddStat("Fertile Choices", choices.Count);

            return(new SimScoringList(this, "PotentialMother", choices, false).GetBestByMinScore(0));
        }
Exemplo n.º 2
0
        protected override bool Allow(SimDescription sim)
        {
            if (!base.Allow(sim))
            {
                return(false);
            }

            if (sim.Elder)
            {
                if (!ManagerPregnancy.TestNearElderLimit(this, sim, GetValue <NearDeathLimitOption, int>()))
                {
                    IncStat("Near Death Denied");
                    return(false);
                }
                else if (ExpectedPregnancyBaseScenario.GetNumLiveChildren(sim) > 0)
                {
                    IncStat("Has Children");
                    return(false);
                }
                else if (AddScoring("PreferredBabyCount", sim) <= 0)
                {
                    IncStat("Score Fail");
                    return(false);
                }
                else if (sim.Partner != null)
                {
                    if (Pregnancies.Allow(this, sim, sim.Partner, Managers.Manager.AllowCheck.Active))
                    {
                        IncStat("Partner Too Young");
                        return(false);
                    }
                    else if (!GetValue <AllowAdoptionOption, bool>(sim.Partner))
                    {
                        IncStat("Partner Adoption Denied");
                        return(false);
                    }
                    else if (AddScoring("Partner", ScoringLookup.GetScore("PreferredBabyCount", sim.Partner)) <= 0)
                    {
                        IncStat("Partner Score Fail");
                        return(false);
                    }
                }

                foreach (SimDescription other in HouseholdsEx.Humans(sim.Household))
                {
                    if (other.ChildOrBelow)
                    {
                        IncStat("Child in Home");
                        return(false);
                    }
                }
            }
            else if ((sim.Partner != null) && (sim.Gender == sim.Partner.Gender))
            {
                // If the sims can have children normally, then don't allow adoption
                if (Pregnancies.Allow(this, sim, sim.Partner, Managers.Manager.AllowCheck.Active))
                {
                    return(false);
                }
                else if (!GetValue <AllowAdoptionOption, bool>(sim.Partner))
                {
                    IncStat("Partner Adoption Denied");
                    return(false);
                }
                else if (!ExpectedPregnancyBaseScenario.TestPreferredBaby(this, sim, 0))
                {
                    IncStat("Preferred Fail");
                    return(false);
                }
                else if (!Pregnancies.TestCooldown(this, sim))
                {
                    IncStat("Cooldown Fail");
                    return(false);
                }
            }
            else
            {
                IncStat("Too Young");
                return(false);
            }

            return(true);
        }