protected override bool Allow(SimDescription sim) { if (!Households.Allow(this, sim)) { IncStat("User Denied"); return(false); } else if (sim.Household == null) { return(false); } else if (SimTypes.IsSpecial(sim)) { IncStat("Special"); return(false); } else if (sim.LotHome == null) { IncStat("Homeless"); return(false); } else if (SimTypes.HeadOfFamily(sim.Household) == sim) { IncStat("Head"); return(false); } else if (!Households.AllowSoloMove(sim)) { IncStat("Too Young"); return(false); } return(base.Allow(sim)); }
protected override bool PrivateUpdate(ScenarioFrame frame) { HouseholdBreakdown breakdown = new HouseholdBreakdown(Manager, this, UnlocalizedName, Sim, ChildMove, false); if (!breakdown.SimGoing) { IncStat("Staying"); return(false); } else if ((breakdown.NoneStaying) && (Sim.LotHome != null)) { IncStat("None Staying"); return(false); } else if (breakdown.NoneGoing) { IncStat("None Going"); return(false); } else if ((mStay != null) && (breakdown.Going.Contains(mStay))) { IncStat("Both Going"); return(false); } if (Households.AllowSoloMove(Sim)) { Add(frame, GetMoveInLotScenario(breakdown.Going), ScenarioResult.Failure); } Add(frame, GetMoveInScenario(breakdown.Going), ScenarioResult.Failure); return(false); }
protected override bool TargetAllow(SimDescription sim) { if ((!Households.AllowSoloMove(Sim)) && (!Households.AllowSoloMove(Target))) { IncStat("Teen Denied"); return(false); } else if (!Households.Allow(this, Sim, Target, Managers.Manager.AllowCheck.None)) { return(false); } return(base.TargetAllow(sim)); }
protected override bool PrivateUpdate(ScenarioFrame frame) { ScoringList <SimDescription> scoring = new ScoringList <SimDescription>(); SimDescription head = SimTypes.HeadOfFamily(House); foreach (SimDescription sim in HouseholdsEx.All(House)) { if (!Households.AllowSoloMove(sim)) { continue; } if (head != null) { if (head == sim) { continue; } if (head.Partner == sim) { continue; } } scoring.Add(sim, AddScoring("FindOwnHome", sim, sim.Partner)); } List <SimDescription> best = scoring.GetBestByMinScore(1); if ((best == null) || (best.Count == 0)) { IncStat("No Choices"); return(false); } else { foreach (SimDescription sim in best) { HouseholdBreakdown breakdown = new HouseholdBreakdown(Manager, this, UnlocalizedName, sim, HouseholdBreakdown.ChildrenMove.Scoring, false); Add(frame, new StandardMoveInLotScenario(breakdown, 0), ScenarioResult.Failure); Add(frame, new PostScenario(sim, mPassedInspection), ScenarioResult.Success); } } return(false); }
protected override bool Sort(List <Household> houses) { Dictionary <Household, int> candidates = new Dictionary <Household, int>(); AddStat("Potentials", houses.Count); SimDescription oldestSim = Sim; foreach (SimDescription sim in Movers) { if ((oldestSim == null) || (SimTypes.IsOlderThan(sim, oldestSim))) { oldestSim = sim; } } foreach (Household house in houses) { bool olderFound = false; foreach (SimDescription other in HouseholdsEx.All(house)) { if (Deaths.IsDying(other)) { continue; } if (SimTypes.IsOlderThan(other, oldestSim)) { olderFound = true; } int count = 0; if (Flirts.IsCloselyRelated(Sim, other)) { if (Sim.Genealogy.Parents.Contains(other.Genealogy)) { count += 10; } else { count++; } } else if (OnlyFamilyMoveIn) { continue; } bool checkRel = false; if (other.YoungAdultOrAbove) { checkRel = true; } else if ((Households.AllowSoloMove(Sim)) && (other.TeenOrAbove)) { checkRel = true; } if (checkRel) { int rel = 0; Relationship relation = Relationship.Get(Sim, other, false); if (relation != null) { rel = (int)(relation.LTR.Liking / 25); if ((relation.AreRomantic()) && (rel > 0)) { rel += 5; } count += rel; } if (Households.AllowSoloMove(Sim)) { if (rel < 3) { continue; } } } if (Sim.Partner == other) { count += 10; } if (!candidates.ContainsKey(house)) { candidates.Add(house, count); } else { candidates[house] += count; } } if (!olderFound) { candidates.Remove(house); } } houses.Clear(); if (candidates.Count > 0) { ScoringList <Household> scoring = new ScoringList <Household>(); foreach (KeyValuePair <Household, int> candidate in candidates) { AddScoring("", candidate.Value); scoring.Add(candidate.Key, candidate.Value); } houses.AddRange(scoring.GetBestByMinScore(1)); } else { IncStat("No Candidates"); } return(true); }
protected override bool PrivateUpdate(ScenarioFrame frame) { ScoringList <SimDescription> scoring = new ScoringList <SimDescription>(); SimDescription head = SimTypes.HeadOfFamily(House); foreach (SimDescription sim in House.AllSimDescriptions) { if ((sim == head) || (sim.Partner == head)) { continue; } // Don't move sims that can't move out if (!Households.AllowSoloMove(sim)) { continue; } // Don't move sims related to the head of family if (Flirts.IsCloselyRelated(sim, head)) { continue; } // Don't move sims that don't have partners if (sim.Partner == null) { continue; } if (!House.AllSimDescriptions.Contains(sim.Partner)) { continue; } if (Flirts.IsCloselyRelated(sim.Partner, head)) { continue; } scoring.Add(sim, AddScoring("FindOwnHome", sim.Partner, sim)); } ICollection <SimDescription> best = scoring.GetBestByPercent(100); if ((best == null) || (best.Count == 0)) { IncStat("No Choices"); return(false); } else { foreach (SimDescription sim in best) { HouseholdBreakdown breakdown = new HouseholdBreakdown(Manager, this, UnlocalizedName, sim, HouseholdBreakdown.ChildrenMove.Scoring, false); Add(frame, new StandardMoveInLotScenario(breakdown, 0), ScenarioResult.Failure); Add(frame, new PostScenario(sim), ScenarioResult.Success); } } return(false); }