// this was done because the scoring causes the stack depth to be exceeded when a value in the PrivateAllow // function calls SimData so I check the value in the scoring instead public bool Allow(IScoringGenerator stats, SimDescription sim, bool fromScoring) { AllowCheck check = AllowCheck.None; check &= AllowCheck.Scoring; return(PrivateAllow(stats, sim, check)); }
public static void PushBuffetInteractions(IScoringGenerator stats, SimDescription sim, Lot lot) { foreach (BuffetTable table in lot.GetObjects <BuffetTable>()) { NRaas.StoryProgression.Main.Situations.PushInteraction(stats, sim, table, BuffetTable.Serve.Singleton); } }
protected override bool PrivateAllow(IScoringGenerator stats, SimDescription sim, SimData settings, AllowCheck check) { if (SimTypes.IsSpecial(sim)) { stats.IncStat("Allow: Special"); return(false); } if (Household.RoommateManager != null) { if (Household.RoommateManager.IsNPCRoommate(sim)) { stats.IncStat("Allow: Roomie"); return(false); } } if (((check & AllowCheck.Scoring) != AllowCheck.Scoring) && !settings.GetValue <AllowMoneyOption, bool>()) { stats.IncStat("Allow: Money Denied"); return(false); } return(true); }
public List <SimDescription> FindAnyFor(IScoringGenerator stats, SimDescription sim, bool allowAffair, bool force, ICollection <SimDescription> pool) { if ((sim == null) || (sim.Household == null)) { stats.IncStat("Invalid Sim"); return(new List <SimDescription>()); } stats.AddStat("Pool", pool.Count); SimScoringList scoring = new SimScoringList("NewFlirt"); foreach (SimDescription potential in pool) { stats.IncStat("FindAnyFor " + potential.FullName, Common.DebugLevel.Logging); if (IsValidLover(stats, sim, potential, allowAffair, force)) { scoring.Add(stats, "Single", potential, sim); } Main.Sleep("ManagerFlirt:FindAnyFor"); } if (force) { return(scoring.GetBestByPercent(50f)); } else { return(scoring.GetBestByMinScore(0)); } }
protected static bool Test(IScoringGenerator stats, SimData actorData, SimData targetData, Managers.Manager.AllowCheck check) { SimDescription actor = actorData.SimDescription; SimDescription target = targetData.SimDescription; if (actor.Partner != null) { int chance = actorData.GetValue <ChanceOfAdulteryOption, int>(); if (chance == 0) { stats.IncStat("Adultery Denied"); return(false); } else if (stats.AddScoring("FlirtyPartner", chance, ScoringLookup.OptionType.Chance, actor) <= 0) { stats.IncStat("Adultery Scoring Fail"); return(false); } chance = targetData.GetValue <ChanceOfLiaisonOption, int>(); if (chance == 0) { stats.IncStat("Liaison Denied"); return(false); } if (stats.AddScoring("FlirtyPartner", chance, ScoringLookup.OptionType.Chance, target) <= 0) { stats.IncStat("Liaison Scoring Fail"); return(false); } } return(true); }
public bool AllowAffair(IScoringGenerator stats, SimDescription actor, SimDescription target, AllowCheck check) { if (!IsAffair(actor, target)) { return(true); } if (OnAllowAffair == null) { return(false); } SimData actorData = GetData(actor); SimData targetData = GetData(target); foreach (OnDualAllowFunc del in OnAllowAffair.GetInvocationList()) { if (!del(stats, actorData, targetData, check)) { return(false); } } return(true); }
protected override bool PrivateAllow(IScoringGenerator stats, SimDescription sim, SimData settings, AllowCheck check) { if (sim.Household != null) { if (SimTypes.IsTourist(sim)) { stats.IncStat("Allow: Tourist"); return(false); } if (sim.Household.IsTravelHousehold) { stats.IncStat("Allow: Travel Household"); return(false); } } if (!settings.GetValue <AllowMoveFamilyOption, bool>()) { stats.IncStat("Allow: Move Denied"); return(false); } return(true); }
public bool Allow(IScoringGenerator stats, SimDescription actor, SimDescription target, AllowCheck check) { if ((check & AllowCheck.UserDirected) == AllowCheck.None) { if (Personalities.IsOpposing(stats, actor, target, true)) { stats.IncStat("Opposing Clan"); return(false); } } SimData actorData = GetData(actor); SimData targetData = GetData(target); if (!actorData.Allowed <AllowCasteMoveOption>(targetData, true)) { stats.IncStat("Caste Denied"); return(false); } else if (actorData.Disallowed <DisallowCasteMoveOption>(targetData, true)) { stats.IncStat("Caste Denied"); return(false); } else if (!DualAllow(stats, actorData, targetData, check)) { return(false); } return(true); }
public bool AllowPartner(IScoringGenerator stats, SimDescription actor, SimDescription target, AllowCheck check) { if (!Allow(stats, actor, check)) { return(false); } if (!Allow(stats, target, check)) { return(false); } SimData actorData = GetData(actor); SimData targetData = GetData(target); if (!actorData.Allowed <AllowCasteRomanceOption>(targetData, true)) { stats.IncStat("Caste Romance Denied"); return(false); } else if (actorData.Disallowed <DisallowCasteRomanceOption>(targetData, true)) { stats.IncStat("Caste Romance Denied"); return(false); } else if (!DualAllow(stats, actorData, targetData, check)) { return(false); } return(true); }
public HouseholdBreakdown(StoryProgressionObject manager, IScoringGenerator stats, string tag, SimDescription a, SimDescription b, ChildrenMove children, bool ignoreHead) { if (a != null) { mSims.Add(a); } if (b != null) { mSims.Add(b); } if ((mSims.Count > 1) && (a.Household != b.Household)) { List <SimDescription> sims = new List <SimDescription>(); sims.Add(a); Perform(manager, stats, tag, sims, children, ignoreHead); sims = new List <SimDescription>(); sims.Add(b); Perform(manager, stats, tag, sims, children, ignoreHead); } else { Perform(manager, stats, tag, mSims, children, ignoreHead); } Tally(stats, tag, ignoreHead); }
protected override bool PrivateAllow(IScoringGenerator stats, SimDescription sim, SimData settings, AllowCheck check) { if (!base.PrivateAllow(stats, sim, settings, check)) { return(false); } if (sim.IsEP11Bot) { if (!sim.HasTrait(TraitNames.AbilityToLearnChip)) { stats.IncStat("Chip Denied"); return(false); } } IHasSkill option = stats as IHasSkill; if (option != null) { foreach (SkillNames skill in option.CheckSkills) { if (!AllowSkill(stats, sim, settings, skill)) { return(false); } } } return(true); }
protected void Tally(IScoringGenerator stats, string tag, bool ignoreHead) { if (!Common.kDebugging) { return; } string prefix = tag + " Break"; if (ignoreHead) { prefix += " Ignore"; } int humans = 0, pets = 0, plumbots = 0; stats.AddStat(prefix + ": Sims", mSims.Count); stats.AddStat(prefix + ": Going", GetGoingCount(ref humans, ref pets, ref plumbots)); stats.AddStat(prefix + ": Going Human", humans); stats.AddStat(prefix + ": Going Pets", pets); stats.AddStat(prefix + ": Going Plumbots", plumbots); stats.AddStat(prefix + ": Staying", GetStayingCount(ref humans, ref pets, ref plumbots)); stats.AddStat(prefix + ": Staying Human", humans); stats.AddStat(prefix + ": Staying Pets", pets); stats.AddStat(prefix + ": Staying Plumbots", plumbots); if (SimGoing) { stats.IncStat(prefix + ": SimGoing"); } }
public bool AllowRent(IScoringGenerator stats, SimDescription sim) { if (OnAllowRent == null) { return(true); } return(OnAllowRent(stats, GetData(sim), Managers.Manager.AllowCheck.None)); }
protected override bool PrivateAllow(IScoringGenerator stats, SimDescription sim, AllowCheck check) { if (sim == null) { return(false); } return(PrivateAllow(stats, sim, GetData(sim), check)); }
protected bool PrivateAllow(IScoringGenerator stats, Sim sim, AllowCheck check) { if (sim == null) { return(false); } return(PrivateAllow(stats, sim.SimDescription, check)); }
public bool AllowImpregnation(IScoringGenerator stats, SimDescription sim, AllowCheck check) { if (!Allow(stats, sim, check)) { return(false); } if (SimTypes.IsTourist(sim)) { stats.IncStat("Allow: Tourist"); return(false); } if ((check & AllowCheck.Active) == AllowCheck.Active) { if (sim.Household.IsTravelHousehold) { stats.IncStat("Allow: Travel Household"); return(false); } } if (sim.LotHome == null) { if (!GetValue <NewcomerGoneScenario.AllowHomelessMoveInOptionV2, bool>()) { stats.IncStat("Allow: Homeless Move In Denied"); return(false); } } if (SimTypes.IsServiceOrRole(sim, false)) { if (SimTypes.IsOccult(sim, Sims3.UI.Hud.OccultTypes.ImaginaryFriend)) { stats.IncStat("Allow: Service Imaginary Denied"); return(false); } } if (!GetValue <AllowCanBePregnantOption, bool>(sim)) { stats.IncStat("Allow: Can Be Pregnant Denied"); return(false); } if ((sim.IsHuman) && ((check & AllowCheck.UserDirected) == AllowCheck.None)) { if (!TestNearElderLimit(stats, sim, GetValue <NearElderLimitOption, int>())) { return(false); } } return(true); }
protected override bool PrivateAllow(IScoringGenerator stats, SimDescription sim, SimData settings, AllowCheck check) { if (!settings.GetValue <AllowCasteOption, bool>()) { stats.IncStat("Allow: Caste Denied"); return(false); } return(true); }
protected bool IsValidLover(IScoringGenerator stats, SimDescription sim, SimDescription potential, bool allowAffair, bool force) { if (sim == potential) { //stats.IncStat("Myself"); return(false); } else if (!GetValue <AllowRomanceOption, bool>(potential)) { stats.IncStat("User Denied"); return(false); } else if ((!allowAffair) && (potential.Partner != null)) { stats.IncStat("Affair Denied"); return(false); } else if (sim.Partner == potential) { stats.IncStat("Partner"); return(false); } else if ((!GetValue <AllowOldLoverOption, bool>()) && (WasOldLover(sim, potential))) { stats.IncStat("Old Lover"); return(false); } else if (!Allow(stats, sim, potential)) { //stats.IncStat("Mixed Aged Denied"); return(false); } else if (potential.Household == null) { stats.IncStat("Invalid House"); return(false); } else if ((SimTypes.IsSpecial(sim)) && (SimTypes.IsSpecial(potential))) { stats.IncStat("Both Special"); return(false); } else if (Situations.IsBusy(stats, potential, true)) { stats.IncStat("Other Busy"); return(false); } else if (IsActiveInvolved(potential)) { stats.IncStat("Other Active Involved"); return(false); } return(true); }
protected bool ScoreChildMove(IScoringGenerator stats, string tag, SimDescription child, List <SimDescription> movingSims) { if (child.Genealogy.Parents.Count == 0) { stats.IncStat(tag + " ChildMove: No Parents"); return(false); } int firstScore = 0; bool firstMoving = false; SimDescription mom = null, dad = null; Relationships.GetParents(child, out mom, out dad); if (mom != null) { firstMoving = movingSims.Contains(mom); if ((firstMoving) || (mom.Household == child.Household)) { firstScore = stats.AddScoring(tag + " ChildMove", ScoringLookup.GetScore("ParentChild", child, mom)); } else { return(true); } } int secondScore = 0; bool secondMoving = false; if (dad != null) { secondMoving = movingSims.Contains(dad); if ((secondMoving) || (dad.Household == child.Household)) { secondScore = stats.AddScoring(tag + " ChildMove", ScoringLookup.GetScore("ParentChild", child, dad)); } else { return(true); } } if (firstScore > secondScore) { return(firstMoving); } else { return(secondMoving); } }
public HouseholdBreakdown(StoryProgressionObject manager, IScoringGenerator stats, string tag, SimDescription me, ChildrenMove children, bool ignoreHead) { if (me != null) { mSims.Add(me); } Perform(manager, stats, tag, mSims, children, ignoreHead); Tally(stats, tag, ignoreHead); }
protected virtual bool PrivateAllow(IScoringGenerator stats, SimDescription sim, AllowCheck check) { if (sim == null) { return(false); } if (SimTypes.IsPassporter(sim)) { stats.IncStat("Allow: Simport"); return(false); } if ((check & AllowCheck.Active) == AllowCheck.Active) { if (SimTypes.IsDead(sim)) { stats.IncStat("Allow: Dead"); return(false); } else if ((SimTypes.IsService(sim)) && (SimTypes.IsOccult(sim, OccultTypes.ImaginaryFriend))) { stats.IncStat("Allow: Imaginary Friend"); return(false); } string reason = IsOnActiveLot(sim, true); if (!string.IsNullOrEmpty(reason)) { stats.IncStat("Allow: " + reason); return(false); } if (GetValue <ManagerSim.ProgressActiveNPCOption, bool>()) { if (SimTypes.IsSelectable(sim)) { stats.IncStat("Allow: Selectable"); return(false); } } else { if (sim.Household == Household.ActiveHousehold) { stats.IncStat("Allow: Active Family"); return(false); } } } return(PrivateAllow(stats, sim, GetData(sim), check)); }
protected override bool PrivateAllow(IScoringGenerator stats, SimDescription sim, AllowCheck check) { if (Household.RoommateManager.IsNPCRoommate(sim)) { IncStat("Roommate"); return(false); } check &= ~AllowCheck.Active; return(base.PrivateAllow(stats, sim, check)); }
public static bool PushForRepairman(IScoringGenerator stats, StoryProgressionObject manager, Household house) { List <SimDescription> choices = manager.Situations.GetFree(stats, new SimScoringList(stats, "Handiness", manager.Sims.TeensAndAdults, false).GetBestByMinScore(1), true); Dictionary <Household, List <GameObject> > repairs = new Dictionary <Household, List <GameObject> >(); foreach (Lot lot in ManagerLot.GetOwnedLots(house)) { GetRepairs(manager, lot.GetObjects <GameObject>(), repairs); } stats.AddStat("Residents", choices.Count); while (choices.Count > 0) { SimDescription choice = RandomUtil.GetRandomObjectFromList(choices); choices.Remove(choice); if (choice.CreatedSim == null) { continue; } List <GameObject> repairWork = null; if (repairs.TryGetValue(house, out repairWork)) { if (PushInteractions(manager, choice, repairWork)) { stats.IncStat("Resident Repairman"); return(true); } else { stats.IncStat("Push Fail"); } } else { stats.IncStat("No Repairs Fonud"); } } stats.IncStat("Service Repairman"); Repairman instance = Repairman.Instance; if (instance != null) { instance.MakeServiceRequest(house.LotHome, true, ObjectGuid.InvalidObjectGuid); } return(true); }
public bool AllowMarriage(IScoringGenerator stats, SimDescription actor, SimDescription target, AllowCheck check) { if (!AllowMarriage(stats, actor, check)) { return(false); } if (!AllowMarriage(stats, target, check)) { return(false); } return(AllowPartner(stats, actor, target, check)); }
public List <SimDescription> FindNemesisFor(IScoringGenerator stats, SimDescription sim, bool ignoreBusy) { List <SimDescription> choices = new List <SimDescription>(); List <Relationship> relations = new List <Relationship>(Relationship.GetRelationships(sim)); if (relations.Count == 0) { stats.IncStat("Nemesis: None"); return(choices); } stats.AddStat("Nemesis: Relations", relations.Count); foreach (Relationship relation in relations) { SimDescription other = relation.GetOtherSimDescription(sim); if (other == null) { stats.IncStat("Nemesis: Bad Link"); continue; } stats.IncStat(other.FullName, Common.DebugLevel.Logging); if (!relation.HasInteractionBitSet(LongTermRelationship.InteractionBits.MakeEnemy)) { stats.IncStat("Nemesis: Not"); } else if (SimTypes.IsDead(other)) { stats.IncStat("Nemesis: Dead"); } else if ((!ignoreBusy) && (Situations.IsBusy(stats, other, true))) { stats.IncStat("Nemesis: Busy"); } else if (!Allow(stats, other)) { stats.IncStat("Nemesis: User Denied"); } else { choices.Add(other); } Main.Sleep("ManagerFriendship:FindNemesisFor"); } return(choices); }
public List <SimDescription> FindExistingFriendFor(IScoringGenerator stats, SimDescription sim, int minLiking, bool ignoreBusy) { List <SimDescription> choices = new List <SimDescription>(); List <Relationship> relations = new List <Relationship>(Relationship.GetRelationships(sim)); if (relations.Count == 0) { stats.IncStat("Friend: None"); return(choices); } stats.AddStat("Friend: Relations", relations.Count); foreach (Relationship relation in relations) { SimDescription other = relation.GetOtherSimDescription(sim); if (other == null) { stats.IncStat("Friend: Bad Link"); continue; } stats.IncStat(other.FullName, Common.DebugLevel.Logging); if (relation.LTR.Liking <= minLiking) { stats.IncStat("Friend: Unliked"); } else if (SimTypes.IsDead(other)) { stats.IncStat("Friend: Dead"); } else if ((!ignoreBusy) && (Situations.IsBusy(stats, other, true))) { stats.IncStat("Friend: Busy"); } else if (!Allow(stats, other)) { stats.IncStat("Friend: User Denied"); } else { choices.Add(other); } Main.Sleep("ManagerFriendship:FindExistingFriendFor"); } return(choices); }
public bool Allow(IScoringGenerator stats, SimDescription actor, SimDescription target, AllowCheck check) { if (Personalities.IsOpposing(stats, actor, target, true)) { stats.IncStat("Opposing Clan"); return(false); } else if (!Flirts.CanHaveAutonomousRomance(stats, actor, target, ((check & AllowCheck.Active) == AllowCheck.Active))) { return(false); } return(AllowPartner(stats, actor, target, check)); }
protected static bool OnAllowAffair(IScoringGenerator stats, SimData actorData, SimData targetData, Managers.Manager.AllowCheck check) { if (!Test(stats, actorData, targetData, check)) { return(false); } if (!Test(stats, targetData, actorData, check)) { return(false); } return(true); }
protected override bool PrivateAllow(IScoringGenerator stats, SimDescription sim, SimData settings, AllowCheck check) { bool testRomance = true; if ((sim.Household != null) && ((check & AllowCheck.UserDirected) == AllowCheck.None)) { if (SimTypes.InServicePool(sim, ServiceType.GrimReaper)) { stats.IncStat("Allow: Reaper"); return(false); } if (sim.LotHome == null) { if (!GetValue <NewcomerGoneScenario.AllowHomelessMoveInOptionV2, bool>()) { stats.IncStat("Allow: Homeless Move In Denied"); return(false); } } } else { if (SimTypes.IsService(sim)) { testRomance = false; } } if (sim.IsEP11Bot) { if (!sim.TraitManager.HasAnyElement(sFlirtChips)) { stats.IncStat("Allow: Missing Chips"); return(false); } } if (testRomance) { if (!settings.GetValue <AllowRomanceOption, bool>()) { stats.IncStat("Allow: Romance Denied"); return(false); } } return(true); }
public bool AllowMarriage(IScoringGenerator stats, SimDescription sim, AllowCheck check) { if (!Allow(stats, sim, check)) { return(false); } if (!GetValue <AllowMarriageOption, bool>(sim)) { stats.IncStat("Allow: Marriage Denied"); return(false); } return(true); }
public static bool TestPreferredBaby(IScoringGenerator stats, SimDescription sim, int additionalBabyCount) { int simPreferredBabies = stats.AddScoring("PreferredBabyCount", sim); if (sim.Genealogy == null) { stats.IncStat("No Genealogy"); return false; } else if ((simPreferredBabies + additionalBabyCount) <= GetNumLiveChildren(sim)) { stats.AddStat("Additional Children", additionalBabyCount); stats.AddStat("Preferred Children", (simPreferredBabies + additionalBabyCount)); stats.AddStat("Actual Children", GetNumLiveChildren(sim)); stats.AddStat("Enough Children", GetNumLiveChildren(sim) - simPreferredBabies); return false; } if (sim.Partner == null) { return (!sim.IsHuman); } else { int partnerPreferredBabies = stats.AddScoring("PreferredBabyCount", sim.Partner); if (sim.Partner.Genealogy == null) { stats.IncStat("No Genealogy"); return false; } if ((partnerPreferredBabies + additionalBabyCount) <= GetNumLiveChildren(sim.Partner)) { stats.AddStat("Additional Children", additionalBabyCount); stats.AddStat("Prefered Children", (partnerPreferredBabies + additionalBabyCount)); stats.AddStat("Actual Children", GetNumLiveChildren(sim.Partner)); stats.AddStat("Enough Children", GetNumLiveChildren(sim.Partner) - partnerPreferredBabies); return false; } } return true; }
protected void Tally(IScoringGenerator stats, string tag, bool ignoreHead) { if (!Common.kDebugging) return; string prefix = tag + " Break"; if (ignoreHead) { prefix += " Ignore"; } int humans = 0, pets = 0, plumbots = 0; stats.AddStat(prefix + ": Sims", mSims.Count); stats.AddStat(prefix + ": Going", GetGoingCount(ref humans, ref pets, ref plumbots)); stats.AddStat(prefix + ": Going Human", humans); stats.AddStat(prefix + ": Going Pets", pets); stats.AddStat(prefix + ": Going Plumbots", plumbots); stats.AddStat(prefix + ": Staying", GetStayingCount(ref humans, ref pets, ref plumbots)); stats.AddStat(prefix + ": Staying Human", humans); stats.AddStat(prefix + ": Staying Pets", pets); stats.AddStat(prefix + ": Staying Plumbots", plumbots); if (SimGoing) { stats.IncStat(prefix + ": SimGoing"); } }
public HouseholdBreakdown(StoryProgressionObject manager, IScoringGenerator stats, string tag, SimDescription a, SimDescription b, ChildrenMove children, bool ignoreHead) { if (a != null) { mSims.Add(a); } if (b != null) { mSims.Add(b); } if ((mSims.Count > 1) && (a.Household != b.Household)) { List<SimDescription> sims = new List<SimDescription>(); sims.Add(a); Perform(manager, stats, tag, sims, children, ignoreHead); sims = new List<SimDescription>(); sims.Add(b); Perform(manager, stats, tag, sims, children, ignoreHead); } else { Perform(manager, stats, tag, mSims, children, ignoreHead); } Tally(stats, tag, ignoreHead); }
protected void Perform(StoryProgressionObject manager, IScoringGenerator stats, string tag, List<SimDescription> movers, ChildrenMove children, bool ignoreHead) { if (movers.Count == 0) return; SimDescription focus = movers[0]; if (focus.Household == null) { stats.IncStat(tag + " Break: No Home"); mGoing.AddRange(movers); return; } else if (SimTypes.IsSpecial(focus)) { stats.IncStat(tag + " Break: Special"); mGoing.AddRange(movers); return; } else { bool adult = false; foreach (SimDescription sim in movers) { if (manager.Households.AllowGuardian(sim)) { adult = true; break; } } if (!adult) { stats.IncStat(tag + " Break: Child Transfer"); mStaying.AddRange(Households.All(focus.Household)); foreach (SimDescription sim in movers) { if (SimTypes.IsSelectable(sim)) continue; mStaying.Remove(sim); mGoing.Add(sim); } return; } List<SimDescription> going = new List<SimDescription>(); List<SimDescription> staying = new List<SimDescription>(); List<SimDescription> houseChildrenPetsPlumbots = new List<SimDescription>(); bool ancestral = manager.GetValue<IsAncestralOption, bool>(focus.Household); SimDescription head = null; if (!ignoreHead) { head = SimTypes.HeadOfFamily(focus.Household); } else if (ancestral) { stats.IncStat(tag + " Break: Ancestral Head Denied"); mStaying.AddRange(Households.All(focus.Household)); return; } foreach (SimDescription sim in Households.All(focus.Household)) { stats.IncStat(sim.FullName, Common.DebugLevel.Logging); SimDescription partner = null; if (SimTypes.IsSelectable(sim)) { stats.IncStat(tag + " Break: Active"); staying.Add(sim); } else if (!manager.Households.Allow(stats, sim, 0)) { stats.IncStat(tag + " Break: User Denied"); staying.Add(sim); } else if (IsPartner(sim, staying, out partner)) { stats.IncStat(tag + " Break: Partner Stay"); staying.Add(sim); } else if ((IsPartner(sim, movers, out partner)) || (IsPartner(sim, going, out partner))) { if ((head == sim) && (Households.NumHumans(focus.Household) != 1)) { stats.IncStat(tag + " Break: Partner Go Denied"); going.Remove(partner); staying.Add(sim); if (!staying.Contains(partner)) { staying.Add(partner); } } else { stats.IncStat(tag + " Break: Partner Go"); going.Add(sim); } } else if (movers.Contains(sim)) { if ((head == sim) && (Households.NumHumans(focus.Household) != 1)) { stats.IncStat(tag + " Break: Go Denied"); staying.Add(sim); } else { stats.IncStat(tag + " Break: Go"); going.Add(sim); } } else if (head == sim) { stats.IncStat(tag + " Break: Head Stay"); staying.Add(sim); } else if ((sim.YoungAdultOrAbove) && (!sim.IsPet) && (!sim.IsEP11Bot)) { stats.IncStat(tag + " Break: Stay"); staying.Add(sim); } else { houseChildrenPetsPlumbots.Add(sim); } } List<SimDescription> extraChildrenPets = new List<SimDescription>(); foreach (SimDescription child in houseChildrenPetsPlumbots) { bool bGoing = false; bool bMatch = false; if (child.IsPet) { int goingLiking = int.MinValue; foreach (SimDescription foci in going) { if (child.LastName == foci.LastName) { bMatch = true; int liking = ManagerSim.GetLTR(child, foci); if (goingLiking < liking) { goingLiking = liking; } } } int stayingLiking = int.MinValue; foreach (SimDescription foci in staying) { if (child.LastName == foci.LastName) { bMatch = true; int liking = ManagerSim.GetLTR(child, foci); if (stayingLiking < liking) { stayingLiking = liking; } } } if (goingLiking > stayingLiking) { bGoing = true; } } else { // this will handle plumbots that are related to the family (i.e. creation) if (children == ChildrenMove.RelatedStay) { foreach (SimDescription parent in Relationships.GetParents(child)) { if (staying.Contains(parent)) { bMatch = true; } } } else if (children == ChildrenMove.RelatedGo) { foreach (SimDescription parent in Relationships.GetParents(child)) { if (going.Contains(parent)) { bMatch = true; } } } else if (children != ChildrenMove.Stay) { foreach (SimDescription foci in going) { if (Relationships.GetChildren(foci).Contains(child)) { bMatch = true; if ((children != ChildrenMove.Scoring) || (ScoreChildMove(stats, tag, child, going))) { bGoing = true; break; } } } } } if (child.IsEP11Bot && !bGoing) { // test the liking for Plumbots without the HumanEmotion chip if (!manager.Households.AllowGuardian(child)) { bMatch = true; int goingLiking = int.MinValue; foreach (SimDescription foci in going) { int liking = ManagerSim.GetLTR(child, foci); if (goingLiking < liking) { goingLiking = liking; } } int stayingLiking = int.MinValue; foreach (SimDescription foci in staying) { int liking = ManagerSim.GetLTR(child, foci); if (stayingLiking < liking) { stayingLiking = liking; } } if (goingLiking > stayingLiking) { bGoing = true; } } } stats.IncStat(child.FullName, Common.DebugLevel.Logging); if ((!bMatch) && (manager.Households.AllowSoloMove(child))) { stats.IncStat(tag + " Break: Teen Stay"); staying.Add(child); } else if (bGoing) { if (children == ChildrenMove.Go) { stats.IncStat(tag + " Break: Child Go"); } else { stats.IncStat(tag + " Break: Child Scoring Go"); } going.Add(child); } else { if (children == ChildrenMove.Stay) { stats.IncStat(tag + " Break: Child Stay"); } else if (bMatch) { stats.IncStat(tag + " Break: Child Scoring Stay"); } extraChildrenPets.Add(child); } } bool foundAdult = false, foundBlood = false; foreach (SimDescription sim in staying) { if (manager.Deaths.IsDying(sim)) continue; if (!manager.Households.AllowGuardian(sim)) continue; if (ancestral) { if (Relationships.IsCloselyRelated(head, sim, false)) { foundBlood = true; } } foundAdult = true; } if ((!foundAdult) || ((ancestral) && (!foundBlood))) { stats.AddStat(tag + " Break: Extra", extraChildrenPets.Count); going.AddRange(extraChildrenPets); if (ancestral) { stats.IncStat(tag + " Break: Ancestral"); mStaying.AddRange(going); return; } } mStaying.AddRange(staying); foreach (SimDescription sim in mStaying) { going.Remove(sim); } mGoing.AddRange(going); } }
protected bool ScoreChildMove(IScoringGenerator stats, string tag, SimDescription child, List<SimDescription> movingSims) { if (child.Genealogy.Parents.Count == 0) { stats.IncStat(tag + " ChildMove: No Parents"); return false; } int firstScore = 0; bool firstMoving = false; SimDescription mom = null, dad = null; Relationships.GetParents(child, out mom, out dad); if (mom != null) { firstMoving = movingSims.Contains(mom); if ((firstMoving) || (mom.Household == child.Household)) { firstScore = stats.AddScoring(tag + " ChildMove", ScoringLookup.GetScore("ParentChild", child, mom)); } else { return true; } } int secondScore = 0; bool secondMoving = false; if (dad != null) { secondMoving = movingSims.Contains(dad); if ((secondMoving) || (dad.Household == child.Household)) { secondScore = stats.AddScoring(tag + " ChildMove", ScoringLookup.GetScore("ParentChild", child, dad)); } else { return true; } } if (firstScore > secondScore) { return firstMoving; } else { return secondMoving; } }