Example #1
0
        protected int GetScore(SimDescription sim)
        {
            if (sim.LotHome == null)
            {
                return(-1000);
            }

            int score = (GetValue <MaximumSizeOption, int>(sim.Household) - HouseholdsEx.NumHumansIncludingPregnancy(sim.Household)) * 2;

            foreach (SimDescription member in HouseholdsEx.Humans(sim.Household))
            {
                if (Relationships.IsCloselyRelated(member, sim, false))
                {
                    score++;
                }

                if (member.Elder)
                {
                    score++;
                }
                else if (member.ToddlerOrBelow)
                {
                    score--;
                }
            }

            return(score);
        }
Example #2
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            if (sim.SimDescription.IsPregnant)
            {
                return;
            }

            if (mClone)
            {
                Pregnancies.Start(sim, sim.SimDescription, mHandlePlantSim);
            }
            else if (vector.Infector != 0)
            {
                SimDescription other = SimDescription.Find(vector.Infector);
                if (other != null)
                {
                    if (!mAllowCloseRelations)
                    {
                        if (Relationships.IsCloselyRelated(sim.SimDescription, other, false))
                        {
                            return;
                        }
                    }

                    Pregnancies.Start(sim, other, mHandlePlantSim);
                }
            }
        }
Example #3
0
        public static bool HasActiveRelation(Household home)
        {
            if (Household.ActiveHousehold == null)
            {
                return(false);
            }

            foreach (SimDescription sim in HouseholdsEx.All(home))
            {
                foreach (SimDescription active in HouseholdsEx.All(Household.ActiveHousehold))
                {
                    if (Relationships.IsCloselyRelated(sim, active, false))
                    {
                        return(true);
                    }

                    Relationship relation = Relationship.Get(sim, active, false);
                    if (relation == null)
                    {
                        continue;
                    }

                    if (relation.AreFriendsOrRomantic())
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #4
0
        protected override bool TargetAllow(SimDescription target)
        {
            if ((!IsFriendly) && (Sim.ToddlerOrBelow))
            {
                IncStat("Too Young");
                return(false);
            }
            else if ((IsRomantic) && (Sim.TeenOrAbove != target.TeenOrAbove))
            {
                IncStat("Wrong Age");
                return(false);
            }
            else if ((IsFriendly) && (TestRelationship) && (ManagerSim.GetLTR(Sim, Target) >= 100))
            {
                IncStat("Max Liking");
                return(false);
            }
            else if (Delta < 0)
            {
                if (target.ToddlerOrBelow)
                {
                    IncStat("Too Young");
                    return(false);
                }
                else if ((TestRelationship) && (ManagerSim.GetLTR(Sim, Target) <= -100))
                {
                    IncStat("Min Liking");
                    return(false);
                }
                else if (!Friends.AllowEnemy(this, Sim, Target, Managers.Manager.AllowCheck.None))
                {
                    return(false);
                }
                else if ((!GetValue <AllowEnemyFamilyOption, bool>()) &&
                         ((Sim.Partner == Target) || (Relationships.IsCloselyRelated(Sim, Target, false))))
                {
                    IncStat("Closely Related Denied");
                    return(false);
                }
            }
            else if (Delta > 0)
            {
                if ((TestRelationship) && (target.CreatedSim != null) && (SnubManager.IsSnubbing(target.CreatedSim, target)))
                {
                    IncStat("Snubbing");
                    return(false);
                }
                else if (!Friends.AllowFriend(this, Sim, Target, Managers.Manager.AllowCheck.None))
                {
                    return(false);
                }
                else if ((IsRomantic) && (!Flirts.Allow(this, Sim, Target)))
                {
                    return(false);
                }
            }

            return(base.TargetAllow(target));
        }
Example #5
0
        private SimDescription FindPartner(SimDescription parent, List <SimDescription> dyingSims)
        {
            SimDescription description = null;
            float          liking      = -100f;

            List <SimDescription> list = new List <SimDescription>();

            foreach (Relationship relationship in Relationship.GetRelationships(parent))
            {
                SimDescription otherSimDescription = relationship.GetOtherSimDescription(parent);
                if (otherSimDescription.Household == null)
                {
                    continue;
                }

                if (otherSimDescription.Household.IsPreviousTravelerHousehold)
                {
                    continue;
                }

                if (otherSimDescription.Household.IsTravelHousehold)
                {
                    continue;
                }

                if (((parent.Gender != otherSimDescription.Gender) && (otherSimDescription.Partner == null)) && !otherSimDescription.IsMummy)
                {
                    if (relationship.AreRomantic())
                    {
                        list.Add(otherSimDescription);
                    }
                    else if ((!Relationships.IsCloselyRelated(parent, otherSimDescription, false) && parent.CheckAutonomousGenderPreference(otherSimDescription)) && (otherSimDescription.CheckAutonomousGenderPreference(parent) && (relationship.LTR.Liking > liking)))
                    {
                        liking      = relationship.LTR.Liking;
                        description = otherSimDescription;
                    }
                }
            }

            if (list.Count > 0x0)
            {
                return(list[RandomUtil.GetInt(list.Count - 0x1)]);
            }

            foreach (SimDescription description3 in dyingSims)
            {
                if ((((parent.Gender != description3.Gender) && (description3.Partner == null)) && (!description3.IsMummy && !Relationships.IsCloselyRelated(parent, description3, false))) && (parent.CheckAutonomousGenderPreference(description3) && description3.CheckAutonomousGenderPreference(parent)))
                {
                    list.Add(description3);
                }
            }

            if (list.Count > 0x0)
            {
                return(list[RandomUtil.GetInt(list.Count - 0x1)]);
            }

            return(description);
        }
Example #6
0
        protected override bool TargetAllow(SimDescription sim)
        {
            if ((!Relationships.IsCloselyRelated(mDeadSim, Target, false)) || (ManagerSim.GetLTR(mDeadSim, Target) < 50))
            {
                IncStat("Low LTR");
                return(false);
            }

            return(base.TargetAllow(sim));
        }
Example #7
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            if (ManagerSim.HasTrait(Target, TraitNames.Evil))
            {
                Target.CreatedSim.BuffManager.AddElement(BuffNames.FiendishlyDelighted, Origin);
            }
            else
            {
                float multiple = 0;

                if (Relationships.IsBloodRelated(Sim.Genealogy, Target.Genealogy, false))
                {
                    multiple++;
                }
                else if (Relationships.IsCloselyRelated(Sim, Target, false))
                {
                    multiple += 0.5f;
                }

                int ltr = ManagerSim.GetLTR(Sim, Target);
                if (ltr > 75)
                {
                    multiple += 1.5f;
                }
                else if (ltr > 50)
                {
                    multiple++;
                }
                else if (ltr > 25)
                {
                    multiple += 0.5f;
                }

                mTimeoutLength = multiple * 24 * 60;

                base.PrivateUpdate(frame);

                BuffMourning.BuffInstanceMourning mourning = Target.CreatedSim.BuffManager.GetElement(BuffNames.Mourning) as BuffMourning.BuffInstanceMourning;
                if (mourning != null)
                {
                    mourning.MissedSim = Sim;
                }
            }

            return(true);
        }
Example #8
0
        protected override bool TargetAllow(SimDescription target)
        {
            if (HasValue <LevelOption, FamilyLevel>(FamilyLevel.Other))
            {
                if (!Relationships.IsCloselyRelated(Sim, target, false))
                {
                    IncStat("Not Related");
                    return(false);
                }
            }

            foreach (SimDescription parent in Relationships.GetParents(Sim))
            {
                if (ManagerSim.GetLTR(Sim, Target) < 0)
                {
                    IncStat("Parent Relation Fail");
                    return(false);
                }
            }

            return(base.TargetAllow(target));
        }
Example #9
0
            public override ObjectPicker.ColumnInfo GetValue(SimDescription sim)
            {
                string result = "";

                switch (sim.Age)
                {
                case CASAgeGenderFlags.Teen:
                case CASAgeGenderFlags.YoungAdult:
                case CASAgeGenderFlags.Adult:
                case CASAgeGenderFlags.Elder:
                    result += Common.Localize("Matchmaker:" + sim.Age.ToString(), sim.IsFemale);
                    break;
                }


                if (SimTypes.InServicePool(sim))
                {
                    result += Common.Localize("Matchmaker:Service", sim.IsFemale);
                }

                if (sim.AssignedRole != null)
                {
                    result += Common.Localize("Matchmaker:Role", sim.IsFemale);
                }

                if (sim.LotHome == null)
                {
                    result += Common.Localize("Matchmaker:Homeless", sim.IsFemale);
                }

                if (Relationships.IsCloselyRelated(mSelection.Me, sim, false))
                {
                    result += Common.Localize("Matchmaker:Related", sim.IsFemale);
                }

                return(new ObjectPicker.TextColumn(result));
            }
Example #10
0
        public static List <Sim> GetChoices(Sim actor, Sim target)
        {
            List <Sim> results = new List <Sim>();

            if (actor == null || target == null || actor.LotHome == null || target.LotHome == null)
            {
                return(results);
            }

            foreach (SimDescription sim2 in actor.Household.SimDescriptions)
            {
                if (sim2.CreatedSim == null)
                {
                    continue;
                }

                if (sim2.TeenOrAbove)
                {
                    continue;
                }

                if (sim2.CreatedSim.IsAtWork)
                {
                    continue;
                }

                if (!Relationships.IsCloselyRelated(actor.SimDescription, sim2, false))
                {
                    continue;
                }

                results.Add(sim2.CreatedSim);
            }

            return(results);
        }
Example #11
0
        protected int GetTotalFamily(Household house)
        {
            int total = 0;

            foreach (Household other in Household.GetHouseholdsLivingInWorld())
            {
                if (other == house)
                {
                    continue;
                }

                foreach (SimDescription otherSim in HouseholdsEx.All(other))
                {
                    bool found = false;
                    foreach (SimDescription sim in HouseholdsEx.All(house))
                    {
                        if (Relationships.IsCloselyRelated(sim, otherSim, false))
                        {
                            total++;
                            found = true;
                            //break;
                        }
                    }
                    if (found)
                    {
                        if (other == Household.ActiveHousehold)
                        {
                            return(int.MaxValue);
                        }
                        break;
                    }
                }
            }

            return(total);
        }
Example #12
0
        private static SimDescription GetPotentialInLaw(SimDescription me, SimDescription partner, List <SimDescription> testAgainst, bool testRelation)
        {
            List <SimDescription> choices = new List <SimDescription>();

            foreach (List <SimDescription> sims in SimListing.GetFullResidents(false).Values)
            {
                foreach (SimDescription sim in sims)
                {
                    if (sim.LotHome == null)
                    {
                        continue;
                    }

                    if (testRelation)
                    {
                        if (sim.Partner != null)
                        {
                            continue;
                        }
                    }

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

                    if (!SimTypes.IsEquivalentSpecies(me, sim))
                    {
                        continue;
                    }

                    if (me.Genealogy == null || me.Genealogy.SimDescription == null)
                    {
                        continue;
                    }

                    if (me.SkinToneKey == ResourceKey.kInvalidResourceKey || me.Genealogy.SimDescription.SkinToneKey == ResourceKey.kInvalidResourceKey)
                    {
                        continue;
                    }

                    choices.Add(sim);
                }
            }

            RandomUtil.RandomizeListOfObjects(choices);

            foreach (SimDescription sim in choices)
            {
                if (sim == me)
                {
                    continue;
                }

                if (sim == partner)
                {
                    continue;
                }

                if (testRelation)
                {
                    bool found = false;
                    foreach (SimDescription test in testAgainst)
                    {
                        if (Relationships.IsCloselyRelated(test, sim, false))
                        {
                            found = true;
                            break;
                        }
                    }
                    if (found)
                    {
                        continue;
                    }
                }

                return(sim);
            }

            return(null);
        }
Example #13
0
 public bool IsCloselyRelated(SimDescription a, SimDescription b)
 {
     return(Relationships.IsCloselyRelated(a, b, GetValue <CompleteAncestorCheckOption, bool>()));
 }
Example #14
0
        protected override bool Allow(SimDescription sim)
        {
            if (!sim.Elder)
            {
                IncStat("Too Young");
                return(false);
            }
            else if (sim.Household == null)
            {
                IncStat("No Home");
                return(false);
            }
            else if (!Households.Allow(this, sim))
            {
                IncStat("Move Denied");
                return(false);
            }
            else if ((sim.Partner != null) && (!SimTypes.IsDead(sim.Partner)) && (Pregnancies.Allow(this, sim, sim.Partner, Managers.Manager.AllowCheck.Active)))
            {
                IncStat("Fertile Partnered");
                return(false);
            }
            else if (!GetValue <EmigrationOption, bool>(sim))
            {
                IncStat("Emigrate Denied");
                return(false);
            }
            else if (HouseholdsEx.NumHumansIncludingPregnancy(sim.Household) < GetValue <MaximumSizeOption, int>(sim.Household))
            {
                IncStat("House Empty");
                return(false);
            }
            else
            {
                bool found = false;
                foreach (SimDescription other in HouseholdsEx.Humans(sim.Household))
                {
                    if (other == sim)
                    {
                        continue;
                    }

                    if (other == sim.Partner)
                    {
                        continue;
                    }

                    if (other.Partner == null)
                    {
                        continue;
                    }

                    if (!Pregnancies.Allow(this, other))
                    {
                        continue;
                    }

                    if (ExpectedPregnancyBaseScenario.GetNumLiveChildren(other) > 0)
                    {
                        continue;
                    }

                    if (AddScoring("PreferredBabyCount", other) <= 0)
                    {
                        continue;
                    }

                    if ((!Relationships.IsCloselyRelated(other, sim, false)) ||
                        (!Relationships.IsCloselyRelated(other, sim.Partner, false)))
                    {
                        continue;
                    }

                    found = true;
                }

                if (!found)
                {
                    IncStat("Not Necessary");
                    return(false);
                }
            }

            return(base.Allow(sim));
        }
Example #15
0
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            Common.StringBuilder log = new Common.StringBuilder("Run");

            try
            {
                Lot targetLot = Porter.GetLot(parameters.mTarget);
                if (targetLot == null)
                {
                    return(OptionResult.Failure);
                }

                Dictionary <ulong, IMiniSimDescription> preExistingSims = SimListing.GetSims <IMiniSimDescription>(null, true);

                Household me = targetLot.Household;
                if (me == null)
                {
                    me = GetImportSelection(targetLot);

                    if (me == null)
                    {
                        return(OptionResult.Failure);
                    }
                }

                Dictionary <ulong, IMiniSimDescription> allSims = SimListing.GetSims <IMiniSimDescription>(null, true);

                Dictionary <int, HouseData> houses       = new Dictionary <int, HouseData>();
                Dictionary <int, HouseData> doppleHouses = new Dictionary <int, HouseData>();

                List <SimDescription> cleanUp = new List <SimDescription>();
                List <SimDescription> fixUp   = new List <SimDescription>();

                List <Household> importedHouses = new List <Household>();
                importedHouses.Add(me);

                List <SimDescription> checkSims = new List <SimDescription>();

                log += Common.NewLine + "A";

                List <SimDescription> sims = new List <SimDescription>(me.AllSimDescriptions);
                foreach (SimDescription sim in sims)
                {
                    if (sim == null)
                    {
                        continue;
                    }

                    log += Common.NewLine + sim.FullName;

                    Porter.AddExport(sim);

                    string description = sim.mBio;
                    if (string.IsNullOrEmpty(description))
                    {
                        continue;
                    }

                    if (!description.Contains("NRaas.Porter:"))
                    {
                        continue;
                    }

                    description = description.Replace("NRaas.Porter:", "");
                    if (string.IsNullOrEmpty(description))
                    {
                        continue;
                    }

                    HouseData lookup = new HouseData(description);

                    lookup.Reconcile(sim);

                    ValidateTask.Perform(sim);

                    List <SimDescription> dependents = new List <SimDescription>();
                    if (HandleDoppleganger(sim, preExistingSims, allSims, dependents))
                    {
                        if (!houses.ContainsKey(lookup.mID))
                        {
                            if (!doppleHouses.ContainsKey(lookup.mID))
                            {
                                doppleHouses.Add(lookup.mID, lookup);
                            }
                        }

                        checkSims.AddRange(dependents);

                        cleanUp.Add(sim);
                        continue;
                    }
                    else
                    {
                        fixUp.Add(sim);
                    }

                    HouseData data;
                    if (!houses.TryGetValue(lookup.mID, out data))
                    {
                        data = lookup;
                        houses.Add(data.mID, data);
                    }

                    doppleHouses.Remove(lookup.mID);

                    data.mSims.Add(sim);
                }

                log += Common.NewLine + "B";

                foreach (SimDescription sim in fixUp)
                {
                    log += Common.NewLine + sim.FullName;

                    new Relationships.RepairParents().Perform(sim, UnusedLog, allSims);
                    new Relationships.RepairChildren().Perform(sim, UnusedLog, allSims);
                    new Relationships.RepairSiblings().Perform(sim, UnusedLog, allSims);
                }

                log += Common.NewLine + "C";

                foreach (SimDescription cleanup in cleanUp)
                {
                    log += Common.NewLine + cleanup.FullName;

                    try
                    {
                        if (cleanup.Household != null)
                        {
                            cleanup.Household.Remove(cleanup);
                        }

                        checkSims.Remove(cleanup);

                        cleanup.Genealogy.ClearAllGenealogyInformation();
                        cleanup.Dispose();
                    }
                    catch (Exception e)
                    {
                        Common.DebugException(log, e);
                    }
                }

                log += Common.NewLine + "D";

                if (houses.Count == 0)
                {
                    SimpleMessageDialog.Show(Common.Localize("Title"), Common.Localize("Unpack:NotProper"));
                    return(OptionResult.Failure);
                }
                else if (houses.Count == 1)
                {
                    int funds = -1;
                    foreach (HouseData data in houses.Values)
                    {
                        if (data.mID != 0)
                        {
                            funds = data.mFunds;
                        }
                    }

                    if (funds >= 0)
                    {
                        me.SetFamilyFunds(funds);

                        SimpleMessageDialog.Show(Common.Localize("Title"), Common.Localize("Unpack:Unneeded"));
                        return(OptionResult.Failure);
                    }
                }

                log += Common.NewLine + "E";

                int unpacked = 0, failed = 0;

                List <HouseData> sorted = new List <HouseData>(houses.Values);
                sorted.Sort(new Comparison <HouseData>(HouseData.SortByCost));

                foreach (HouseData data in sorted)
                {
                    log += Common.NewLine + "House: " + data.mID;

                    if (data.mID != 1)
                    {
                        Household house = null;

                        if (data.mID != 0)
                        {
                            Lot lot = FindLot(data.mFunds, data.mSims);
                            if (lot == null)
                            {
                                lot = FindLot(-1, null);
                                if (lot == null)
                                {
                                    failed++;
                                    continue;
                                }
                            }

                            house = Household.Create();

                            importedHouses.Add(house);

                            lot.MoveIn(house);

                            house.Name = data.mName;

                            int finalFunds = (data.mFunds - lot.Cost);
                            if (finalFunds >= 0)
                            {
                                house.SetFamilyFunds(finalFunds);

                                me.ModifyFamilyFunds(-data.mFunds);
                            }
                            else
                            {
                                house.SetFamilyFunds(0);

                                me.ModifyFamilyFunds(-data.mFunds);
                                me.ModifyFamilyFunds(finalFunds);
                            }

                            if (me.FamilyFunds < 0)
                            {
                                me.SetFamilyFunds(0);
                            }

                            if (house.FamilyFunds < 0)
                            {
                                house.SetFamilyFunds(0);
                            }

                            unpacked++;
                        }

                        foreach (SimDescription sim in data.mSims)
                        {
                            log += Common.NewLine + sim.FullName;

                            if (house != null)
                            {
                                log += Common.NewLine + "Moved";

                                me.Remove(sim);
                                house.Add(sim);

                                Instantiation.Perform(sim, null);
                            }
                            else
                            {
                                log += Common.NewLine + "PlaceGrave";

                                Porter.PlaceGraveTask.Perform(sim);
                            }
                        }

                        if (house != null)
                        {
                            string name = house.LotHome.Name;
                            if (string.IsNullOrEmpty(name))
                            {
                                name = house.LotHome.Address;
                            }

                            Porter.Notify(Common.Localize("Unpack:Success", false, new object[] { house.Name, name }), house.LotHome.ObjectId);
                        }
                    }
                    else
                    {
                        unpacked++;
                    }

                    foreach (SimDescription sim in data.mSims)
                    {
                        sim.mBio = null;
                    }
                }

                log += Common.NewLine + "F";

                foreach (SimDescription checkSim in checkSims)
                {
                    log += Common.NewLine + checkSim.FullName;

                    if (checkSim.ChildOrBelow)
                    {
                        bool found = false;

                        Household parentHousehold = null;
                        foreach (SimDescription parent in Relationships.GetParents(checkSim))
                        {
                            if ((checkSim.Household != null) && (parent.Household == checkSim.Household))
                            {
                                found = true;
                                break;
                            }
                            else
                            {
                                parentHousehold = parent.Household;
                            }
                        }

                        if (!found)
                        {
                            if (parentHousehold == null)
                            {
                                if ((checkSim.Household != null) && (checkSim.Household.NumMembers == 1))
                                {
                                    foreach (Household house in Household.sHouseholdList)
                                    {
                                        foreach (SimDescription sim in Households.All(house))
                                        {
                                            if (Relationships.IsCloselyRelated(checkSim, sim, false))
                                            {
                                                parentHousehold = house;
                                                break;
                                            }
                                        }

                                        if (parentHousehold != null)
                                        {
                                            break;
                                        }
                                    }
                                }
                            }

                            if (parentHousehold != null)
                            {
                                if (checkSim.Household != null)
                                {
                                    checkSim.Household.Remove(checkSim);
                                }

                                parentHousehold.Add(checkSim);

                                Instantiation.AttemptToPutInSafeLocation(checkSim.CreatedSim, false);
                            }
                        }
                    }
                }

                log += Common.NewLine + "G";

                foreach (Household house in importedHouses)
                {
                    foreach (Sim sim in Households.AllSims(house))
                    {
                        foreach (GameObject obj in Inventories.QuickFind <GameObject>(sim.Inventory))
                        {
                            bool moveToFamily = false;

                            if (!sim.Inventory.ValidForThisInventory(obj))
                            {
                                moveToFamily = true;
                            }
                            else if (obj is IStageProp)
                            {
                                moveToFamily = true;
                            }

                            if (moveToFamily)
                            {
                                sim.Inventory.RemoveByForce(obj);

                                Inventories.TryToMove(obj, house.SharedFamilyInventory.Inventory);
                            }
                        }
                    }
                }

                log += Common.NewLine + "H";

                int doppleFunds = 0;
                foreach (HouseData data in doppleHouses.Values)
                {
                    doppleFunds += data.mFunds;
                }

                me.ModifyFamilyFunds(-doppleFunds);

                if (me.FamilyFunds < 0)
                {
                    me.SetFamilyFunds(0);
                }

                SimpleMessageDialog.Show(Common.Localize("Title"), Common.Localize("Unpack:Completion", false, new object[] { unpacked, failed }));
            }
            catch (Exception e)
            {
                Common.Exception(log, e);
            }

            return(OptionResult.SuccessClose);
        }
Example #16
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);
            }
        }
Example #17
0
        private static SimDescription GetPotentialMate(SimDescription me, List <SimDescription> testAgainst, bool testRelation)
        {
            List <SimDescription> choices = new List <SimDescription>();

            foreach (List <SimDescription> sims in SimListing.GetFullResidents(false).Values)
            {
                foreach (SimDescription sim in sims)
                {
                    if (sim.LotHome == null)
                    {
                        continue;
                    }

                    if (testRelation)
                    {
                        if (sim.Partner != null)
                        {
                            continue;
                        }
                    }

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

                    if (!SimTypes.IsEquivalentSpecies(me, sim))
                    {
                        continue;
                    }

                    if (me.Genealogy == null || me.Genealogy.SimDescription == null)
                    {
                        continue;
                    }

                    if (me.SkinToneKey == ResourceKey.kInvalidResourceKey || me.Genealogy.SimDescription.SkinToneKey == ResourceKey.kInvalidResourceKey)
                    {
                        continue;
                    }

                    choices.Add(sim);
                }
            }

            RandomUtil.RandomizeListOfObjects(choices);

            foreach (SimDescription sim in choices)
            {
                if (!sim.CheckAutonomousGenderPreference(me))
                {
                    continue;
                }

                if (!Relationships.CanHaveRomanceWith(null, sim, me, false, true, testRelation, false))
                {
                    continue;
                }

                if (testRelation)
                {
                    Relationship relation = Relationship.Get(me, sim, false);
                    if ((relation != null) && (relation.CurrentLTRLiking < 0))
                    {
                        continue;
                    }

                    bool found = false;
                    foreach (SimDescription test in testAgainst)
                    {
                        if (Relationships.IsCloselyRelated(test, sim, false))
                        {
                            found = true;
                            break;
                        }
                    }
                    if (found)
                    {
                        continue;
                    }
                }

                return(sim);
            }

            return(null);
        }
Example #18
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            bool wasMarried = Sim.IsMarried;

            if (!Romances.BumpToLowerState(this, Sim, Target, false))
            {
                IncStat("Bump Fail");
                return(false);
            }

            if (wasMarried)
            {
                if (GetValue <RenameDivorceeOption, bool>())
                {
                    RenameDivorcee(Sim);
                    RenameDivorcee(Target);
                }
            }

            if (Sim.Household == Target.Household)
            {
                SimDescription go   = Sim;
                SimDescription stay = Target;

                SimDescription head = SimTypes.HeadOfFamily(Sim.Household);
                if (head != null)
                {
                    if (Relationships.IsCloselyRelated(Target, head, false))
                    {
                        stay = Target;
                        go   = Sim;
                    }
                    else if (Relationships.IsCloselyRelated(Sim, head, false))
                    {
                        stay = Sim;
                        go   = Target;
                    }
                    else if (RandomUtil.CoinFlip())
                    {
                        stay = Sim;
                        go   = Target;
                    }
                }

                HouseholdBreakdown.ChildrenMove goScore   = HouseholdBreakdown.ChildrenMove.Scoring;
                HouseholdBreakdown.ChildrenMove stayScore = HouseholdBreakdown.ChildrenMove.Scoring;
                if (mAffair)
                {
                    // Sim is cheater, so keep children with other parent
                    if (go == Sim)
                    {
                        if (mRelatedStay)
                        {
                            goScore   = HouseholdBreakdown.ChildrenMove.RelatedStay;
                            stayScore = HouseholdBreakdown.ChildrenMove.RelatedGo;
                        }
                        else
                        {
                            goScore   = HouseholdBreakdown.ChildrenMove.Stay;
                            stayScore = HouseholdBreakdown.ChildrenMove.Go;
                        }
                    }
                    else
                    {
                        if (mRelatedStay)
                        {
                            goScore   = HouseholdBreakdown.ChildrenMove.RelatedGo;
                            stayScore = HouseholdBreakdown.ChildrenMove.RelatedStay;
                        }
                        else
                        {
                            goScore   = HouseholdBreakdown.ChildrenMove.Go;
                            stayScore = HouseholdBreakdown.ChildrenMove.Stay;
                        }
                    }
                }

                Add(frame, new BreakupMoveOutScenario(go, stay, goScore), ScenarioResult.Failure);
                Add(frame, new BreakupMoveOutScenario(stay, go, stayScore), ScenarioResult.Failure);
            }

            return(true);
        }
Example #19
0
            public bool Matches(SimDescription sim)
            {
                if (Value == AlertLevel.None)
                {
                    return(false);
                }
                else if (((Value & AlertLevel.OnlyResidents) == AlertLevel.OnlyResidents) && (sim.LotHome == null))
                {
                    return(false);
                }
                else if ((Value == AlertLevel.OnlyResidents) || ((Value & AlertLevel.All) == AlertLevel.All) || (sim.Household == Household.ActiveHousehold))
                {
                    return(true);
                }
                else if (((Value & AlertLevel.PersonalityLeaders) == AlertLevel.PersonalityLeaders) && (Manager.Personalities.GetClanLeadership(sim).Count > 0))
                {
                    return(true);
                }
                else if (((Value & AlertLevel.PersonalityMembers) == AlertLevel.PersonalityMembers) && (Manager.Personalities.GetClanMembership(sim, false).Count > 0))
                {
                    return(true);
                }
                else if (((Value & AlertLevel.PortraitPanel) == AlertLevel.PortraitPanel) && (sIsSimListed.Invoke <bool>(new object[] { sim })))
                {
                    return(true);
                }
                else
                {
                    Household house = Household.ActiveHousehold;
                    if (house != null)
                    {
                        foreach (SimDescription active in HouseholdsEx.All(house))
                        {
                            if (!SimTypes.IsSelectable(active))
                            {
                                continue;
                            }

                            if ((Value & AlertLevel.Blood) == AlertLevel.Blood)
                            {
                                if (Relationships.IsCloselyRelated(active, sim, false))
                                {
                                    return(true);
                                }
                            }

                            if (Matches(Relationship.Get(active, sim, false)))
                            {
                                return(true);
                            }

                            if (((Value & AlertLevel.Spouses) == AlertLevel.Spouses) && (sim.Partner != null))
                            {
                                if (Matches(Relationship.Get(active, sim.Partner, false)))
                                {
                                    return(true);
                                }
                            }
                        }
                    }

                    return(false);
                }
            }