Example #1
0
        protected override ICollection <SimDescription> GetTargets(SimDescription sim)
        {
            List <SimDescription> results = new List <SimDescription>();

            foreach (SimDescription parent in Relationships.GetParents(sim))
            {
                foreach (Relationship relation in Relationship.Get(parent))
                {
                    if (!relation.AreEnemies())
                    {
                        continue;
                    }

                    SimDescription other = relation.GetOtherSimDescription(parent);
                    if (other == null)
                    {
                        continue;
                    }

                    foreach (SimDescription child in Relationships.GetChildren(other))
                    {
                        results.Add(child);
                    }
                }
            }

            return(Flirts.FindAnyFor(this, sim, true, Force, results));
        }
Example #2
0
        protected override ICollection <SimDescription> GetTargets(SimDescription sim)
        {
            if (HasValue <LevelOption, FamilyLevel>(FamilyLevel.Other))
            {
                return(Sims.All);
            }

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

            if (HasValue <LevelOption, FamilyLevel>(FamilyLevel.Parents))
            {
                sims.AddRange(Relationships.GetParents(sim));
            }

            if (HasValue <LevelOption, FamilyLevel>(FamilyLevel.Siblings))
            {
                sims.AddRange(Relationships.GetSiblings(sim));
            }

            if (HasValue <LevelOption, FamilyLevel>(FamilyLevel.Grandparents))
            {
                foreach (SimDescription parent in Relationships.GetParents(sim))
                {
                    sims.AddRange(Relationships.GetParents(parent));
                }
            }

            return(sims);
        }
Example #3
0
        public static bool HandleForeigners(School school)
        {
            if (school == null)
            {
                return(false);
            }

            if (school.OwnerDescription == null)
            {
                return(false);
            }

            if (school.OwnerDescription.Genealogy == null)
            {
                return(false);
            }

            if (school.OwnerDescription.Genealogy.Parents.Count != Relationships.GetParents(school.OwnerDescription).Count)
            {
                if (school.Performance >= school.SchoolTuning.GradeThresholdB)
                {
                    school.mPerformance   = school.SchoolTuning.GradeThresholdA - 0.01f;
                    school.LastPerfChange = 0;
                    return(true);
                }
            }

            return(false);
        }
Example #4
0
        protected bool RenameDivorcee(SimDescription sim)
        {
            string parentNames = null;

            List <SimDescription> parents = Relationships.GetParents(sim);

            if (parents.Count > 0)
            {
                object[] objParents = null;
                if (parents.Count == 2)
                {
                    objParents = new object[] { parents[0], parents[1] };
                }
                else
                {
                    objParents = new object[] { parents[0] };
                }

                parentNames = Common.Localize("RenameDivorcee:PromptParents", sim.IsFemale, objParents);
            }

            List <object> parameters = Stories.AddGenderNouns(sim);

            string text = StringInputDialog.Show(Common.Localize("RenameDivorcee:MenuName"), Common.Localize("RenameDivorcee:Prompt", sim.IsFemale, parameters.ToArray()) + parentNames, sim.LastName);

            if (string.IsNullOrEmpty(text))
            {
                return(false);
            }

            sim.LastName = text;

            return(true);
        }
Example #5
0
        public static FuneralScenario Create(ManagerSituation manager, SimDescription deadSim)
        {
            SimDescription host = null;

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

            foreach (SimDescription parent in Relationships.GetParents(deadSim))
            {
                hosts.Add(parent);
            }

            foreach (SimDescription child in Relationships.GetChildren(deadSim))
            {
                hosts.Add(child);
            }

            foreach (SimDescription sibling in Relationships.GetSiblings(deadSim))
            {
                hosts.Add(sibling);
            }

            foreach (Relationship relation in Relationship.GetRelationships(deadSim))
            {
                if (relation.LTR.Liking <= 50)
                {
                    continue;
                }

                hosts.Add(relation.GetOtherSimDescription(deadSim));
            }

            foreach (SimDescription sim in hosts)
            {
                if (sim == null)
                {
                    continue;
                }

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

                if (manager.IsBusy(manager, sim, true))
                {
                    continue;
                }

                host = sim;
                break;
            }

            if (host == null)
            {
                return(null);
            }

            return(new FuneralScenario(host, deadSim));
        }
Example #6
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            SimDescription mom = null;
            SimDescription dad = null;

            Relationships.GetParents(Sim, out mom, out dad);

            return(PrivatePerform(mom, dad, mPriorBaby));
        }
Example #7
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            SimDescription mom = null, dad = null;

            Relationships.GetParents(me, out mom, out dad);

            Sims3.Gameplay.CAS.Genetics.AssignTraits(me, dad, mom, false, 0, new System.Random());

            return(true);
        }
Example #8
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);
            }
        }
Example #9
0
            protected static void OnTest(Sim target)
            {
                GeneticBlendScenario scenario = new GeneticBlendScenario(target.SimDescription, null);

                scenario.Manager = StoryProgression.Main.Pregnancies;

                for (int i = 0; i < 100; i++)
                {
                    scenario.BlendWings(Relationships.GetParents(target.SimDescription));
                }
            }
Example #10
0
        protected static void AlterSkinBlend(Common.IStatGenerator stats, SimDescription sim, List <SimDescription> immediateParents)
        {
            List <SimDescription> choices = new List <SimDescription>(immediateParents);

            foreach (SimDescription parent in immediateParents)
            {
                if (parent.IsAlien)
                {
                    return;
                }

                foreach (SimDescription grand in Relationships.GetParents(parent))
                {
                    if (!grand.IsAlien)
                    {
                        choices.Add(grand);
                    }
                }
            }

            stats.AddStat("Blend Choices", choices.Count);

            if (choices.Count >= 2)
            {
                sim.SkinToneKey = FixInvisibleTask.ValidateSkinTone(RandomUtil.GetRandomObjectFromList(choices).SkinToneKey);

                RandomUtil.RandomizeListOfObjects(choices);

                float num4 = choices[0].SkinToneIndex;
                float num5 = choices[1].SkinToneIndex;
                if (num4 > num5)
                {
                    float num6 = num5;
                    num5 = num4;
                    num4 = num6;
                }
                float num8 = num5 - num4;

                float newIndex = 0;

                float num7 = RandomUtil.GetFloat(Sims3.Gameplay.CAS.Genetics.kSkinColorMaxPercentTravel / 100f);
                if (RandomUtil.CoinFlip())
                {
                    newIndex = num4 + (num8 * num7);
                }
                else
                {
                    newIndex = num5 - (num8 * num7);
                }

                sim.SkinToneIndex = newIndex;
            }
        }
Example #11
0
        public static BirthdayScenario Create(ManagerSituation manager, SimDescription birthdaySim)
        {
            SimDescription host = null;

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

            if (!manager.Households.AllowGuardian(birthdaySim))
            {
                foreach (SimDescription parent in Relationships.GetParents(birthdaySim))
                {
                    hosts.Add(parent);
                }
            }
            else
            {
                hosts.Add(birthdaySim);
            }

            foreach (SimDescription sim in hosts)
            {
                if (sim == null)
                {
                    continue;
                }

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

                if (manager.IsBusy(manager, sim, true))
                {
                    continue;
                }

                host = sim;
                break;
            }

            if (host == null)
            {
                return(null);
            }

            return(new BirthdayScenario(host, birthdaySim));
        }
Example #12
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            Genealogy childGenealogy = Sim.Genealogy;

            if ((childGenealogy == null) || (childGenealogy.Parents.Count == 0))
            {
                return(false);
            }

            SimDescription mom = null, dad = null;

            Relationships.GetParents(Sim, out mom, out dad);

            return(PrivatePerform(this, mom, dad, false));
        }
Example #13
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            List <SimDescription> sims = new List <SimDescription>();

            bool okayed;
            List <IMiniSimDescription> miniSims = FilteredSelection.Selection(me, Common.Localize("FamilyTreeInteraction:Parent"), new ParentTest(me).OnTest, SelectionOption.List, 7, false, out okayed);

            if (miniSims != null)
            {
                foreach (IMiniSimDescription miniSim in miniSims)
                {
                    SimDescription sim = miniSim as SimDescription;
                    if (sim == null)
                    {
                        continue;
                    }

                    sims.Add(sim);
                }
            }

            if (sims.Count == 0)
            {
                sims.AddRange(Relationships.GetParents(me));
            }

            if (sims.Count < 2)
            {
                SimpleMessageDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":Failure"));
                return(false);
            }

            CASGeneticsEx.InitHousehold(sims);

            CASGeneticsEx.sChoice = me;

            if (CASGenetics.gSingleton == null)
            {
                CASGenetics.Load();
            }

            return(true);
        }
Example #14
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 #15
0
        protected override bool Allow(Household house)
        {
            if (!base.Allow(house))
            {
                return(false);
            }

            int totalFamily = GetTotalFamily(House);

            if (totalFamily >= GetValue <ThresholdOption, int>())
            {
                AddStat("Enough Family", totalFamily);
                return(false);
            }

            bool deadParent = false;

            foreach (SimDescription sim in HouseholdsEx.All(house))
            {
                foreach (SimDescription parent in Relationships.GetParents(sim))
                {
                    if (parent.IsDead)
                    {
                        deadParent = true;
                        break;
                    }
                }
            }

            if (!deadParent)
            {
                IncStat("No Ancestors");
                return(false);
            }


            return(true);
        }
Example #16
0
            protected static void OnRun(Scenario scenario, ScenarioFrame frame)
            {
                BirthScenario s = scenario as BirthScenario;

                if (s == null)
                {
                    return;
                }

                SimDescription mom = null;
                SimDescription dad = null;

                Relationships.GetParents(s.Babies[0], out mom, out dad);

                if ((mom != null) && (mom.Household == s.Babies[0].Household))
                {
                    scenario.Add(frame, new MaternityLeaveScenario(mom, s.Babies.Count), ScenarioResult.Start);
                }

                if ((scenario.GetValue <PaternityLeaveOption, bool>()) && (dad != null) && (dad.Household == s.Babies[0].Household))
                {
                    scenario.Add(frame, new MaternityLeaveScenario(dad, s.Babies.Count), ScenarioResult.Start);
                }
            }
Example #17
0
 protected override ICollection <SimDescription> GetTargets(SimDescription sim)
 {
     return(Relationships.GetParents(sim));
 }
Example #18
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 #19
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            bool changed = false;

            foreach (Trait trait in new List <Trait>(Sim.TraitManager.List))
            {
                bool remove = false;

                if ((Sim.IsEP11Bot) && (!trait.IsHidden) && (!ActionData.IsBotSpecificTrait(trait.Guid)))
                {
                    remove = true;
                }

                if (HasValue <DisallowTraitOption, TraitNames>(Sim, trait.Guid))
                {
                    remove = true;
                }

                if (remove)
                {
                    Sim.TraitManager.RemoveElement(trait.Guid);

                    IncStat("Disallowed Trait Removed");

                    changed = true;
                }
            }

            if (changed)
            {
                GetData(Sim).InvalidateCache();
            }

            if (Sim.IsEP11Bot)
            {
                IncStat("Plumbot");
                return(true);
            }

            int required = Sim.TraitManager.NumTraitsForAge() - Sim.TraitManager.CountVisibleTraits();

            AddStat("Required", required);

            if (required <= 0)
            {
                if (GetValue <RemoveTraitsOption, bool>())
                {
                    List <Trait> traits = new List <Trait>(Sim.TraitManager.List.Count);

                    for (int i = traits.Count - 1; i >= 0; i--)
                    {
                        if (Sim.TraitManager.CountVisibleTraits() <= Sim.TraitManager.NumTraitsForAge())
                        {
                            break;
                        }

                        if ((traits[i].IsHidden) || (traits[i].IsReward))
                        {
                            continue;
                        }

                        Sim.TraitManager.RemoveElement(traits[i].Guid);
                        changed = true;

                        IncStat("Removed Excess");
                    }

                    if (changed)
                    {
                        GetData(Sim).InvalidateCache();
                    }
                    return(true);
                }
                else
                {
                    IncStat("Remove Disabled");
                    return(false);
                }
            }

            AddStat("Add", required);

            SimDescription mom = null, dad = null;

            Relationships.GetParents(Sim, out mom, out dad);

            if (mom != null)
            {
                if ((!SimTypes.IsDead(mom)) &&
                    (mom.TraitManager != null) &&
                    (!mom.TraitManager.TraitsMaxed()))
                {
                    IncStat("Hold For Parent");
                    return(false);
                }
            }

            if (dad != null)
            {
                if ((!SimTypes.IsDead(dad)) &&
                    (dad.TraitManager != null) &&
                    (!dad.TraitManager.TraitsMaxed()))
                {
                    IncStat("Hold For Parent");
                    return(false);
                }
            }

            try
            {
                Sims3.Gameplay.CAS.Genetics.AssignTraits(Sim, dad, mom, false, 0, new System.Random());
                IncStat("Success");

                GetData(Sim).InvalidateCache();
                return(true);
            }
            catch (Exception e)
            {
                Common.DebugException(Sim, e);
            }

            return(false);
        }
Example #20
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            List <SimDescription> children = new List <SimDescription>();

            int chance = GetValue <AlimonyChanceOption, int>(Sim);

            foreach (SimDescription child in Relationships.GetChildren(Sim))
            {
                if (GetValue <ForTeensOption, bool>())
                {
                    if (child.YoungAdultOrAbove)
                    {
                        continue;
                    }
                }
                else
                {
                    if (child.TeenOrAbove)
                    {
                        continue;
                    }
                }

                if (SimTypes.IsDead(child))
                {
                    continue;
                }

                if (child.IsMarried)
                {
                    continue;
                }

                if (child.Household == Sim.Household)
                {
                    continue;
                }

                if (GetValue <NetWorthOption, int>(child.Household) >= GetValue <NetWorthOption, int>(Sim.Household))
                {
                    IncStat("Unnecessary");
                    continue;
                }

                if (!GetValue <ForAdoptedOption, bool>())
                {
                    List <SimDescription> parents = Relationships.GetParents(child);

                    bool found = false;
                    foreach (SimDescription member in CommonSpace.Helpers.Households.All(child.Household))
                    {
                        if (parents.Contains(member))
                        {
                            found = true;
                        }
                    }

                    if (!found)
                    {
                        IncStat("Child Adopted");
                        continue;
                    }
                }

                children.Add(child);
            }

            if (children.Count == 0)
            {
                return(false);
            }

            int perChildPayment = GetValue <PaymentOption, int>();

            if (GetValue <IsRichOption, bool>(Sim.Household))
            {
                perChildPayment *= GetValue <RichMultipleOption, int>();
            }

            if (AddScoring("CaresAboutChildren", chance, ScoringLookup.OptionType.Chance, Sim) <= 0)
            {
                foreach (SimDescription child in children)
                {
                    if (RandomUtil.RandomChance(GetValue <PropagationChanceOption, int>()))
                    {
                        Add(frame, new PropagateAlimonyFailScenario(child, Sim), ScenarioResult.Start);
                    }
                }

                AddValue <AlimonyLapsesOption, int>(Sim, 1);

                if ((GetValue <AlimonyJailOption, bool>()) && (RandomUtil.RandomChance(GetValue <AlimonyLapsesOption, int>(Sim) * 10)))
                {
                    Add(frame, new GoToJailScenario(Sim, "AlimonyJail", perChildPayment), ScenarioResult.Start);

                    SetValue <AlimonyLapsesOption, int>(Sim, 0);
                }

                Add(frame, new SuccessScenario(), ScenarioResult.Start);
                return(true);
            }
            else
            {
                SetValue <AlimonyLapsesOption, int>(Sim, 0);
            }

            foreach (SimDescription child in children)
            {
                if (!Money.Allow(this, child, Managers.Manager.AllowCheck.None))
                {
                    IncStat("Money Denied Child");
                    continue;
                }

                int payment = perChildPayment;
                if (Sim.FamilyFunds < payment)
                {
                    payment = Sim.FamilyFunds;
                }

                mTotalPayments += payment;

                if (payment == 0)
                {
                    IncStat("Insufficient");
                }
                else
                {
                    Money.AdjustFunds(Sim, "ChildSupport", -payment);

                    Money.AdjustFunds(child, "ChildSupport", payment);

                    AddStat("Paid", payment);
                }
            }

            return(mTotalPayments > 0);
        }
Example #21
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 #22
0
        public void HandleMarriageName(SimDescription a, SimDescription b, bool actorOnEither)
        {
            string lastName = null;

            bool wasEither = false;

            SimDescription left  = a;
            SimDescription right = b;

            if (a.Gender == b.Gender)
            {
                if (actorOnEither)
                {
                    switch (GetValue <SameSexMarriageNameOption, NameTakeType>(right))
                    {
                    case NameTakeType.User:
                    case NameTakeType.Either:
                        left  = b;
                        right = a;
                        break;
                    }
                }
                else
                {
                    if (GetValue <SameSexMarriageNameOption, NameTakeType>(right) == NameTakeType.User)
                    {
                        left  = b;
                        right = a;
                    }
                }

                lastName = GetData(left).HandleName <SameSexMarriageNameOption>(Sims, right, out wasEither);
            }
            else
            {
                if (actorOnEither)
                {
                    switch (GetValue <MarriageNameOption, NameTakeType>(right))
                    {
                    case NameTakeType.User:
                    case NameTakeType.Either:
                        left  = b;
                        right = a;
                        break;
                    }
                }
                else
                {
                    if (GetValue <MarriageNameOption, NameTakeType>(right) == NameTakeType.User)
                    {
                        left  = b;
                        right = a;
                    }
                }

                lastName = GetData(left).HandleName <MarriageNameOption>(Sims, right, out wasEither);
            }

            if ((actorOnEither) && (wasEither))
            {
                lastName = a.LastName;
            }

            if (!string.IsNullOrEmpty(lastName))
            {
                a.LastName = lastName;
                b.LastName = lastName;

                if (GetValue <MarriageScenario.RenameChildrenOption, bool>())
                {
                    bool onlyMutual = GetValue <MarriageScenario.RenameOnlyMutualOption, bool>();

                    foreach (SimDescription child in Relationships.GetChildren(a))
                    {
                        if (a.Household != child.Household)
                        {
                            continue;
                        }

                        if (Households.AllowGuardian(child))
                        {
                            continue;
                        }

                        if (onlyMutual)
                        {
                            if (!Relationships.GetParents(child).Contains(b))
                            {
                                continue;
                            }
                        }

                        child.LastName = a.LastName;
                    }

                    foreach (SimDescription child in Relationships.GetChildren(b))
                    {
                        if (b.Household != child.Household)
                        {
                            continue;
                        }

                        if (Households.AllowGuardian(child))
                        {
                            continue;
                        }

                        if (onlyMutual)
                        {
                            if (!Relationships.GetParents(child).Contains(a))
                            {
                                continue;
                            }
                        }

                        child.LastName = b.LastName;
                    }
                }
            }
        }
Example #23
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            if (mNewSim == null)
            {
                bool allowAnother = RandomUtil.RandomChance(GetValue <PetAdoptionBaseScenario.ChanceOfAnotherOptionV2, int>());

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

                foreach (SimDescription sim in Sims.All)
                {
                    if (sim.Species != Species)
                    {
                        continue;
                    }

                    if (!sim.ChildOrBelow)
                    {
                        continue;
                    }

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

                    // Don't take sims that are not living with their parents
                    bool found = false;
                    foreach (SimDescription parent in Relationships.GetParents(sim))
                    {
                        if (parent.Household == sim.Household)
                        {
                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        IncStat("Target Not With Parents");
                        continue;
                    }

                    if (!GetValue <AllowAdoptionOption, bool>(sim))
                    {
                        IncStat("Target Adoption Denied");
                        continue;
                    }

                    SimDescription head = SimTypes.HeadOfFamily(sim.Household);
                    if (head == null)
                    {
                        continue;
                    }

                    // Test whether the sim's existing household is too large and should shed an animal
                    if (!HouseholdsEx.IsFull(this, sim.Household, sim.Species, 0, true, true))
                    {
                        continue;
                    }

                    // Test whether the sim's new household is too small and can gain an animal
                    if (HouseholdsEx.IsFull(this, Sim.Household, sim.Species, 0, true, allowAnother))
                    {
                        continue;
                    }

                    choices.Add(sim);
                }

                if (choices.Count == 0)
                {
                    IncStat("No Choice");
                    return(false);
                }

                mNewSim = RandomUtil.GetRandomObjectFromList(choices);
            }

            return(base.PrivateUpdate(frame));
        }
Example #24
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            SimDescription mom = null, dad = null;

            Relationships.GetParents(Sim, out mom, out dad);

            bool   wasEither;
            string lastName = null;

            if (mom != null)
            {
                lastName = GetData(mom).HandleName <BabyLastNameOption>(Sims, dad, out wasEither);
            }
            else if (dad != null)
            {
                lastName = GetData(dad).HandleName <BabyLastNameOption>(Sims, mom, out wasEither);
            }

            if (lastName != null)
            {
                Sim.LastName = lastName;
            }
            else if (((dad != null) && (RandomUtil.CoinFlip())) || (mom == null))
            {
                Sim.LastName = dad.LastName;
            }
            else
            {
                Sim.LastName = mom.LastName;
            }

            if (GetValue <RenameNewbornOption, bool>(Sim))
            {
                CASAgeGenderFlags parentGender = CASAgeGenderFlags.None;

                List <object> parameters = Stories.AddGenderNouns(Sim);

                string key = null;
                if (mom != null)
                {
                    parentGender = mom.Gender;

                    parameters.AddRange(Stories.AddGenderNouns(mom));
                }

                if (dad != null)
                {
                    if (parentGender == CASAgeGenderFlags.None)
                    {
                        parentGender = dad.Gender;
                    }

                    parameters.AddRange(Stories.AddGenderNouns(dad));
                }

                if (mom != null)
                {
                    if (dad != null)
                    {
                        key = "DuoPrompt";
                    }
                    else
                    {
                        key = "SinglePrompt";
                    }
                }
                else if (dad != null)
                {
                    key = "SinglePrompt";
                }
                else
                {
                    key = "Prompt";
                }

                ManagerStory.AvailableStory story = new ManagerStory.AvailableStory(GetOption <Option>(), key, parameters.ToArray());

                string text = StringInputDialog.Show(GetOption <Option>().Name, story.Localize(GetOption <Option>(), Sim.Gender, parentGender, parameters.ToArray()), Sim.FirstName, 256, StringInputDialog.Validation.None);
                if (string.IsNullOrEmpty(text))
                {
                    return(false);
                }

                Sim.FirstName = text;
            }

            if ((!SimTypes.IsSelectable(Sim)) && (GetValue <PromptToMoveNewbornOption, bool>()))
            {
                foreach (SimDescription parent in Relationships.GetParents(Sim))
                {
                    if (SimTypes.IsSelectable(parent))
                    {
                        if (AcceptCancelDialog.Show(Common.Localize("PromptToMoveNewborn:Prompt", Sim.IsFemale, new object[] { Sim })))
                        {
                            Sim.Household.Remove(Sim);

                            parent.Household.Add(Sim);

                            if (Sim.CreatedSim == null)
                            {
                                Instantiation.EnsureInstantiate(Sim, parent.LotHome);
                            }
                        }
                    }
                }
            }

            return(true);
        }
Example #25
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            List <CASParts.PartPreset> parts = new List <CASParts.PartPreset>();

            foreach (SimDescription parent in Relationships.GetParents(Sim))
            {
                SimOutfit outfit = CASParts.GetOutfit(parent, new CASParts.Key(OutfitCategories.Everyday, 0), false);

                foreach (CASPart part in outfit.Parts)
                {
                    if (CASParts.GeneticBodyTypes.Contains(part.BodyType))
                    {
                        CASAgeGenderFlags ages = part.Age;

                        if ((ages & Sim.Age) == CASAgeGenderFlags.None)
                        {
                            continue;
                        }

                        IncStat("Found: " + part.BodyType);

                        bool found = false;
                        foreach (CASAgeGenderFlags priorAge in sAges)
                        {
                            if (priorAge >= Sim.Age)
                            {
                                break;
                            }

                            if ((ages & priorAge) == priorAge)
                            {
                                found = true;
                                break;
                            }
                        }

                        // This part would have been inherited in an earlier age-up
                        if (found)
                        {
                            continue;
                        }

                        parts.Add(new CASParts.PartPreset(part, outfit));
                    }
                }
            }

            AddStat("Choices", parts.Count);

            bool adjusted = false;

            using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(Sim, new CASParts.Key(OutfitCategories.Everyday, 0)))
            {
                foreach (CASParts.PartPreset part in parts)
                {
                    if (RandomUtil.RandomChance(GetValue <Option, int>()))
                    {
                        builder.ApplyPartPreset(part);
                        adjusted = true;

                        IncStat("Inherited: " + part.mPart.BodyType);
                    }
                }
            }

            if (adjusted)
            {
                SavedOutfit.Cache cache = new SavedOutfit.Cache(Sim);
                cache.PropagateGenetics(Sim, new CASParts.Key(OutfitCategories.Everyday, 0));
            }

            return(false);
        }
Example #26
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            Common.StringBuilder msg = new Common.StringBuilder("PrivateUpdate");

            try
            {
                bool fullList = !GetValue <CustomNamesOnlyOption <ManagerLot>, bool>();

                foreach (SimDescription baby in mBabies)
                {
                    msg += Common.NewLine + baby.FullName;

                    if (!SimTypes.IsSelectable(baby))
                    {
                        baby.FirstName = Sims.EnsureUniqueName(baby);
                    }

                    List <SimDescription> parents = Relationships.GetParents(baby);

                    parents.Remove(Sim);
                    if ((mDad == null) && (parents.Count > 0))
                    {
                        mDad = parents[0];
                    }

                    msg += Common.NewLine + "A";

                    List <OccultTypes> choices = OccultTypeHelper.CreateList(Sim.OccultManager.CurrentOccultTypes, true);

                    // Grandparent occult inheritance
                    foreach (SimDescription parent in Relationships.GetParents(Sim))
                    {
                        if (parent.OccultManager == null)
                        {
                            continue;
                        }

                        choices.AddRange(OccultTypeHelper.CreateList(parent.OccultManager.CurrentOccultTypes, true));
                    }

                    msg += Common.NewLine + "B";

                    if ((mDad != null) && (mDad.OccultManager != null))
                    {
                        choices.AddRange(OccultTypeHelper.CreateList(mDad.OccultManager.CurrentOccultTypes, true));

                        // Grandparent occult inheritance
                        foreach (SimDescription parent in Relationships.GetParents(mDad))
                        {
                            if (parent.OccultManager == null)
                            {
                                continue;
                            }

                            choices.AddRange(OccultTypeHelper.CreateList(parent.OccultManager.CurrentOccultTypes, true));
                        }
                    }

                    msg += Common.NewLine + "C";

                    Sims.ApplyOccultChance(this, baby, choices, GetValue <ChanceOfOccultBabyOptionV2, int>(), GetValue <MaximumNewbornOccultOption, int>());

                    msg += Common.NewLine + "D";

                    if ((SimTypes.IsServiceAlien(mDad)) || (SimTypes.IsServiceAlien(Sim)))
                    {
                        baby.SetAlienDNAPercentage(1f);
                    }
                    else
                    {
                        baby.SetAlienDNAPercentage(SimDescription.GetAlienDNAPercentage(mDad, Sim, true));
                    }
                }

                msg += Common.NewLine + "E";

                if (OnRenameNewbornsScenario != null)
                {
                    OnRenameNewbornsScenario(this, frame);
                }

                if (!SimTypes.IsSelectable(Sim))
                {
                    ManagerSim.IncrementLifetimeHappiness(Sim, Sims3.Gameplay.Rewards.LifeEventRewards.kLifetimeHappinessRewardForBaby);
                }

                SetElapsedTime <DayOfLastBabyOption>(Sim);

                msg += Common.NewLine + "F";

                if (mDad != null)
                {
                    if (!SimTypes.IsSelectable(mDad))
                    {
                        ManagerSim.IncrementLifetimeHappiness(mDad, Sims3.Gameplay.Rewards.LifeEventRewards.kLifetimeHappinessRewardForBaby);
                    }

                    SetElapsedTime <DayOfLastBabyOption>(mDad);
                }

                msg += Common.NewLine + "G";

                foreach (SimDescription baby in mBabies)
                {
                    Manager.AddAlarm(new NormalBabyAgingScenario(baby));
                }

                msg += Common.NewLine + "H";

                if (OnBirthScenario != null)
                {
                    OnBirthScenario(this, frame);
                }

                msg += Common.NewLine + "I";

                // Do this at the end once everything else has done its thing
                foreach (SimDescription baby in mBabies)
                {
                    msg += Common.NewLine + baby.FullName;

                    HouseholdOptions houseData = GetHouseOptions(baby.Household);
                    if (houseData != null)
                    {
                        int netWorth = houseData.GetValue <NetWorthOption, int>();

                        foreach (SimDescription parent in Relationships.GetParents(baby))
                        {
                            SimData parentData = GetData(parent);
                            if (parentData != null)
                            {
                                foreach (CasteOptions caste in parentData.Castes)
                                {
                                    if (!caste.GetValue <CasteInheritedOption, bool>())
                                    {
                                        continue;
                                    }

                                    if (!caste.Matches(baby, netWorth))
                                    {
                                        continue;
                                    }

                                    SimData babyData = GetData(baby);
                                    if (babyData != null)
                                    {
                                        babyData.AddValue <ManualCasteOption, CasteOptions>(caste);
                                    }
                                }
                            }
                        }
                    }
                }

                msg += Common.NewLine + "J";

                Add(frame, new SuccessScenario(), ScenarioResult.Start);
            }
            catch (Exception e)
            {
                Common.Exception(ToString() + Common.NewLine + msg.ToString(), e);
            }
            return(false);
        }
Example #27
0
        protected override Scenario Handle(Event e, ref ListenerAction result)
        {
            PregnancyEvent pe = e as PregnancyEvent;

            if (pe == null)
            {
                return(null);
            }

            if ((pe.Babies == null) || (pe.Babies.Count == 0))
            {
                return(null);
            }

            Sim mom = pe.Actor as Sim;

            if (mom == null)
            {
                return(null);
            }

            if (mom.SimDescription == null)
            {
                return(null);
            }

            List <SimDescription> parents = Relationships.GetParents(pe.Babies[0].SimDescription);

            if (parents.Count == 0)
            {
                return(null);
            }

            SimDescription actualMom = null;

            foreach (SimDescription parent in parents)
            {
                if (parent.Pregnancy == pe.Pregnancy)
                {
                    actualMom = parent;
                    break;
                }
            }

            if (actualMom == null)
            {
                actualMom = parents[0];
            }

            // Stops the second PregnancyEvent fired for the father from being picked up
            if (actualMom != mom.SimDescription)
            {
                return(null);
            }

            mBabies = new List <SimDescription>();
            foreach (Sim baby in pe.Babies)
            {
                mBabies.Add(baby.SimDescription);
            }

            Scenario scenario = base.Handle(e, ref result);

            if (scenario == null)
            {
                return(null);
            }

            return(scenario);
        }
Example #28
0
        protected void InheritFacialBlends(SimBuilder target, List <SimDescription> parentSims, Random rnd)
        {
            if (!GetValue <AdvancedGeneticsOption, bool>())
            {
                return;
            }

            if ((parentSims != null) && (parentSims.Count != 2))
            {
                List <SimOutfit> grandParents = new List <SimOutfit>();

                int grandParentChance = GetValue <GrandparentInheritanceOption, int>();
                if (grandParentChance > 0)
                {
                    foreach (SimDescription parent in parentSims)
                    {
                        foreach (SimDescription grandParent in Relationships.GetParents(parent))
                        {
                            SimOutfit outfit = grandParent.GetOutfit(OutfitCategories.Everyday, 0);
                            if (outfit != null)
                            {
                                grandParents.Add(outfit);
                            }
                        }
                    }
                }

                List <uint> grandParentList = new List <uint>();

                if (grandParents.Count > 0)
                {
                    foreach (uint num2 in Enum.GetValues(typeof(FacialBlend.FacialRegions)))
                    {
                        if (RandomUtil.RandomChance(grandParentChance))
                        {
                            SimOutfit outfit = RandomUtil.GetRandomObjectFromList(grandParents);

                            foreach (SimOutfit.BlendInfo grandBlend in outfit.Blends)
                            {
                                FacialBlend blend = new FacialBlend(grandBlend.key);

                                if (blend.GetRegionFlags() == num2)
                                {
                                    ApplyBlend(target, grandBlend);

                                    grandParentList.Add(num2);

                                    IncStat("Grandparent Blended");
                                }
                            }
                        }
                    }
                }

                SimOutfit parentOutfit1 = parentSims[0].GetOutfit(OutfitCategories.Everyday, 0);
                SimOutfit parentOutfit2 = parentSims[1].GetOutfit(OutfitCategories.Everyday, 0);
                if ((parentOutfit1 != null) && (parentOutfit2 != null))
                {
                    List <uint> list = new List <uint>();

                    foreach (uint num2 in Enum.GetValues(typeof(FacialBlend.FacialRegions)))
                    {
                        if (grandParentList.Contains(num2))
                        {
                            continue;
                        }

                        if (RandomUtil.CoinFlip())
                        {
                            list.Add(num2);
                        }
                    }

                    // Blend Parent 1
                    foreach (SimOutfit.BlendInfo parentBlend in parentOutfit1.Blends)
                    {
                        FacialBlend blend = new FacialBlend(parentBlend.key);

                        if (list.Contains(blend.GetRegionFlags()))
                        {
                            ApplyBlend(target, parentBlend);
                        }
                    }

                    // Blend Parent 2
                    foreach (SimOutfit.BlendInfo parentBlend in parentOutfit2.Blends)
                    {
                        FacialBlend blend = new FacialBlend(parentBlend.key);

                        if (!list.Contains(blend.GetRegionFlags()))
                        {
                            ApplyBlend(target, parentBlend);
                        }
                    }
                }
            }
        }
Example #29
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            List <SimDescription> parents = new List <SimDescription>();

            foreach (SimDescription parent in Relationships.GetParents(Sim))
            {
                if (SimTypes.IsDead(parent))
                {
                    continue;
                }

                if (!parent.Elder)
                {
                    continue;
                }

                if (parent.Household == Sim.Household)
                {
                    continue;
                }

                if (!ManagerFriendship.AreFriends(Sim, parent))
                {
                    continue;
                }

                if (GetValue <NetWorthOption, int>(parent.Household) >= GetValue <NetWorthOption, int>(Sim.Household))
                {
                    IncStat("Unnecessary");
                    continue;
                }

                parents.Add(parent);
            }

            if (parents.Count == 0)
            {
                return(false);
            }

            if (AddScoring("CaresAboutChildren", GetValue <AlimonyChanceOption, int>(Sim), ScoringLookup.OptionType.Chance, Sim) <= 0)
            {
                return(false);
            }

            int perParentPayment = GetValue <PaymentOption, int>();

            if (GetValue <IsRichOption, bool>(Sim.Household))
            {
                perParentPayment *= GetValue <AlimonyScenario.RichMultipleOption, int>();
            }

            foreach (SimDescription parent in parents)
            {
                if (!Money.Allow(this, parent, Managers.Manager.AllowCheck.None))
                {
                    IncStat("Money Denied Parent");
                    continue;
                }

                int payment = perParentPayment;
                if (Sim.FamilyFunds < payment)
                {
                    payment = Sim.FamilyFunds;
                }

                mTotalPayments += payment;

                if (payment == 0)
                {
                    IncStat("Insufficient");
                }
                else
                {
                    Money.AdjustFunds(Sim, "ElderSupport", -payment);

                    Money.AdjustFunds(parent, "ElderSupport", payment);

                    AddStat("Paid", payment);
                }
            }

            return(mTotalPayments > 0);
        }
Example #30
0
        protected bool PrivatePerform(SimDescription a, SimDescription b, SimDescription priorBaby)
        {
            if ((priorBaby != null) && (RandomUtil.RandomChance(GetValue <ChanceOfIdenticalTwinOption, int>())))
            {
                FacialBlends.CopyGenetics(priorBaby, Sim, false, false);

                new SavedOutfit.Cache(Sim).PropagateGenetics(Sim, CASParts.sPrimary);

                IncStat("Identical");
                return(true);
            }
            else
            {
                List <SimDescription> parents = new List <SimDescription>();

                List <WorldName> worlds = new List <WorldName>();
                if (a != null)
                {
                    SimDescription sim = Relationships.GetSim(a.Genealogy);
                    if (sim != null)
                    {
                        parents.Add(sim);

                        worlds.Add(a.HomeWorld);
                    }
                }

                if (b != null)
                {
                    SimDescription sim = Relationships.GetSim(b.Genealogy);
                    if (sim != null)
                    {
                        parents.Add(sim);

                        worlds.Add(b.HomeWorld);
                    }
                }

                if (GetValue <SkinOption, bool>())
                {
                    AlterSkinBlend(this, Sim, parents);
                }

                if (parents.Count == 2)
                {
                    List <SimDescription> allParents = new List <SimDescription>(parents);
                    foreach (SimDescription parent in parents)
                    {
                        foreach (SimDescription grandParent in Relationships.GetParents(parent))
                        {
                            allParents.Add(grandParent);
                        }
                    }

                    BlendWings(allParents);

                    using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(Sim, CASParts.sPrimary))
                    {
                        builder.Builder.Species        = CASAgeGenderFlags.Human;
                        builder.Builder.UseCompression = true;

                        if (!builder.OutfitValid)
                        {
                            IncStat("Skin Blend: Outfit Fail");
                            return(false);
                        }
                        else
                        {
                            InheritFacialBlends(builder.Builder, parents, new Random());

                            builder.Builder.SkinToneIndex = Sim.SkinToneIndex;
                            builder.Builder.SkinTone      = Sim.SkinToneKey;
                        }
                    }

                    new SavedOutfit.Cache(Sim).PropagateGenetics(Sim, CASParts.sPrimary);

                    IncStat("Blended");
                    return(true);
                }
                else
                {
                    IncStat("Not Two");
                    return(false);
                }
            }
        }