Пример #1
0
        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));
            }
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
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);
            }
Пример #7
0
        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);
        }
Пример #8
0
        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);
        }
Пример #9
0
        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);
        }
Пример #10
0
        protected override bool PrivateAllow(IScoringGenerator stats, SimDescription sim, SimData settings, AllowCheck check)
        {
            if (sim.Household == null)
            {
                stats.IncStat("Allow: No Home");
                return(false);
            }

            if (!settings.GetValue <AllowPregnancyParticipationOption, bool>())
            {
                stats.IncStat("Allow: Participation Denied");
                return(false);
            }

            return(true);
        }
Пример #11
0
        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");
            }
        }
Пример #12
0
        protected override bool PrivateAllow(IScoringGenerator stats, SimDescription sim, SimData settings, AllowCheck check)
        {
            if (SimTypes.InServicePool(sim, ServiceType.GrimReaper))
            {
                stats.IncStat("Allow: Reaper");
                return(false);
            }

            if (!settings.GetValue <AllowFriendshipOption, bool>())
            {
                stats.IncStat("Allow: Friendship Denied");
                return(false);
            }

            return(true);
        }
Пример #13
0
        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);
        }
Пример #14
0
        public bool Allow(IScoringGenerator stats, SimDescription actor, SimDescription target, AllowCheck check)
        {
            if (!Allow(stats, actor, check))
            {
                return(false);
            }

            if (!Allow(stats, target, check))
            {
                return(false);
            }

            if (!Flirts.CanHaveAutonomousRomance(stats, actor, target, ((check & AllowCheck.Active) == AllowCheck.Active)))
            {
                return(false);
            }

            SimData actorData  = GetData(actor);
            SimData targetData = GetData(target);

            if (!actorData.Allowed <AllowCasteCanBePregnantOption>(targetData, false))
            {
                stats.IncStat("Can Be Caste Denied");
                return(false);
            }
            else if (actorData.Disallowed <DisallowCasteCanBePregnantOption>(targetData, false))
            {
                stats.IncStat("Can Be Caste Denied");
                return(false);
            }
            else if (!actorData.Allowed <AllowCastePregnancyOption>(targetData, true))
            {
                stats.IncStat("Participation Caste Denied");
                return(false);
            }
            else if (actorData.Disallowed <DisallowCastePregnancyOption>(targetData, true))
            {
                stats.IncStat("Participation Caste Denied");
                return(false);
            }
            else if (!DualAllow(stats, actorData, targetData, check))
            {
                return(false);
            }

            return(true);
        }
Пример #15
0
        protected override bool PrivateAllow(IScoringGenerator stats, SimDescription sim, SimData settings, AllowCheck check)
        {
            if (sim.LotHome == null)
            {
                stats.IncStat("Allow: Homeless");
                return(false);
            }

            if (!settings.GetValue <AllowPersonalityOption, bool>())
            {
                stats.IncStat("Allow: User Denied");
                return(false);
            }

            SimPersonality personality = stats as SimPersonality;

            if (personality == null)
            {
                IHasPersonality hasPersonality = stats as IHasPersonality;
                if (hasPersonality != null)
                {
                    personality = hasPersonality.Personality;
                }
                else
                {
                    Scenario scenario = stats as Scenario;
                    if (scenario != null)
                    {
                        personality = scenario.Manager as SimPersonality;
                    }
                }
            }

            if (personality == null)
            {
                Common.DebugStackLog(stats.GetType().ToString());
                //stats.IncStat("Allow: Incorrect Manager");
                //return false;
            }
            else if (settings.HasValue <DisallowPersonalityOption, SimPersonality>(personality))
            {
                stats.IncStat("Allow: Personality Denied");
                return(false);
            }

            return(true);
        }
Пример #16
0
        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);
        }
Пример #17
0
        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);
        }
Пример #18
0
        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);
        }
Пример #19
0
        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);
            }
        }
Пример #20
0
        protected override bool PrivateAllow(IScoringGenerator stats, SimDescription sim, SimData settings, AllowCheck check)
        {
            if (!base.PrivateAllow(stats, sim, settings, check))
            {
                return(false);
            }

            if (SimTypes.IsDead(sim))
            {
                stats.IncStat("Allow: Dead");
                return(false);
            }

            if (sim.ChildOrBelow)
            {
                stats.IncStat("Allow: Too Young");
                return(false);
            }

            if (sim.IsPregnant)
            {
                stats.IncStat("Allow: Pregnant");
                return(false);
            }

            if (!sim.AgingEnabled)
            {
                stats.IncStat("Allow: Aging Disabled");
                return(false);
            }

            if (settings.GetValue <PushDeathChanceOption, int>() <= 0)
            {
                stats.IncStat("Allow: Sim Push Death Denied");
                return(false);
            }

            return(true);
        }
Пример #21
0
        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));
        }
Пример #22
0
        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);
        }
Пример #23
0
        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);
        }
Пример #24
0
        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);
        }
Пример #25
0
        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));
        }
        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;
        }
Пример #27
0
        public bool AllowCelebrity(IScoringGenerator stats, SimDescription sim)
        {
            if (!sim.CanBeCelebrity)
            {
                return(false);
            }

            if (!Allow(stats, sim, AllowCheck.None))
            {
                return(false);
            }

            if (!GetValue <AllowCelebrityOption, bool>(sim))
            {
                stats.IncStat("Allow: Celebrity Denied");
                return(false);
            }

            return(true);
        }
Пример #28
0
        public bool Allow(IScoringGenerator stats, SimDescription sim, int moveCooldown)
        {
            if (!Allow(stats, sim, AllowCheck.Active))
            {
                return(false);
            }

            if (sim.LotHome == null)
            {
                return(true);
            }

            if (stats.AddScoring("Allow: Move Cooldown", GetElapsedTime <DayOfLastMoveOption>(sim) - moveCooldown) < 0)
            {
                stats.IncStat("Allow: Cooldown Denied");
                return(false);
            }

            return(true);
        }
Пример #29
0
        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);
            }
        }
Пример #30
0
        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");
            }
        }
Пример #31
0
        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;
            }
        }
Пример #32
0
        public Lot FindLot(IScoringGenerator stats, ICollection <SimDescription> sims, int maximumLoan, FindLotFlags flags, LotPriceCheck inPriceRange)
        {
            stats.IncStat("FindLot");

            Dictionary <SimDescription, bool> lookup = new Dictionary <SimDescription, bool> ();

            Dictionary <Household, bool> homes = new Dictionary <Household, bool>();

            Dictionary <ulong, int> castes = new Dictionary <ulong, int>();
            int simCount = 0;

            bool allowRentable = true;

            if (sims != null)
            {
                foreach (SimDescription sim in sims)
                {
                    if (lookup.ContainsKey(sim))
                    {
                        continue;
                    }
                    lookup.Add(sim, true);

                    if (!Money.AllowRent(stats, sim))
                    {
                        allowRentable = false;
                    }

                    simCount++;

                    foreach (CasteOptions caste in GetData(sim).Castes)
                    {
                        int count;
                        if (castes.TryGetValue(caste.ID, out count))
                        {
                            castes[caste.ID] = count + 1;
                        }
                        else
                        {
                            castes[caste.ID] = 1;
                        }
                    }

                    if (SimTypes.IsSpecial(sim))
                    {
                        continue;
                    }

                    if (sim.Household == null)
                    {
                        continue;
                    }

                    homes[sim.Household] = true;
                }
            }

            int currentLotCost = 0;

            int availableFunds = maximumLoan;

            foreach (Household home in homes.Keys)
            {
                bool allMoving = true;
                foreach (SimDescription sim in home.AllSimDescriptions)
                {
                    if (!lookup.ContainsKey(sim))
                    {
                        allMoving = false;
                        break;
                    }
                }

                if (allMoving)
                {
                    if (home.LotHome == null)
                    {
                        availableFunds += home.NetWorth();
                    }
                    else if (GetValue <IsAncestralOption, bool>(home))
                    {
                        stats.IncStat("FindLot: Ancestral Fail");
                        return(null);
                    }
                    else
                    {
                        currentLotCost += GetLotCost(home.LotHome);

                        availableFunds += home.FamilyFunds + GetLotCost(home.LotHome);

                        availableFunds -= CalculateVehicleCost(home.LotHome);
                    }
                }
                else
                {
                    availableFunds += home.FamilyFunds;
                }
            }

            flags |= FindLotFlags.InspectCareerItems;

            stats.AddStat("Available Funds", availableFunds);

            List <Lot> choices = new List <Lot>();

            foreach (Lot lot in LotManager.AllLots)
            {
                string reason = HouseholdsEx.IsValidResidentialLot(lot);
                if (!string.IsNullOrEmpty(reason))
                {
                    stats.IncStat("Find Lot: " + reason);
                }
                else if (!Allow(stats, lot, sims, flags, allowRentable))
                {
                    continue;
                }
                else
                {
                    stats.AddStat("Lot Cost", GetLotCost(lot));

                    if ((inPriceRange == null) || (inPriceRange(stats, lot, currentLotCost, availableFunds) != CheckResult.Failure))
                    {
                        choices.Add(lot);
                    }
                }
            }

            if (choices.Count == 0)
            {
                stats.IncStat("Find Lot: Failure");
                return(null);
            }
            else if ((flags & FindLotFlags.CheapestHome) == FindLotFlags.CheapestHome)
            {
                choices.Sort(new Comparison <Lot>(HouseholdsEx.SortByCost));

                return(choices[0]);
            }
            else
            {
                return(RandomUtil.GetRandomObjectFromList(choices));
            }
        }
Пример #33
0
        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);
            }
        }
Пример #34
0
        protected static bool IsWitnessed(ManagerProgressionBase manager, IScoringGenerator stats, SimDescription sim, int baseChance)
        {
            if (sim.CreatedSim == null)
            {
                stats.IncStat("Hibernating");
                return(false);
            }

            Lot lot = sim.CreatedSim.LotCurrent;

            if (lot == null)
            {
                return(false);
            }

            if (lot.IsWorldLot)
            {
                return(false);
            }

            if (lot.CanSimTreatAsHome(sim.CreatedSim))
            {
                stats.IncStat("At Home");
                return(false);
            }

            /*
             * if (lot.IsResidentialLot)
             * {
             *  stats.IncStat("Residential");
             *  return false;
             * }
             */

            foreach (Sim witness in lot.GetAllActors())
            {
                if (!witness.IsHuman)
                {
                    continue;
                }

                if (witness.SimDescription.ChildOrBelow)
                {
                    continue;
                }

                if (stats.AddScoring("IgnoreCurfew", witness.SimDescription) > 0)
                {
                    continue;
                }

                if (!RandomUtil.RandomChance(stats.AddScoring("CurfewWitness", witness.SimDescription) + baseChance))
                {
                    continue;
                }

                bool forceCurfew;
                if (IsUnderCurfew(manager, stats, witness.SimDescription, out forceCurfew))
                {
                    continue;
                }

                stats.IncStat("Witnessed");
                return(true);
            }

            return(false);
        }