Пример #1
0
        public static SimDescription GenerateOffspring(List <SimDescription> potentialParents, out bool noParents)
        {
            SimDescription choiceMom;
            SimDescription choiceDad;

            SimUtils.SimCreationSpec.ChooseParents(potentialParents, out choiceDad, out choiceMom);

            noParents = ((choiceMom == null) || (choiceDad == null) || (choiceMom == choiceDad));

            if (noParents)
            {
                return(null);
            }

            CASAgeGenderFlags age = CASAgeGenderFlags.Teen | CASAgeGenderFlags.Child;

            if ((choiceMom.AdultOrAbove) && (choiceDad.AdultOrAbove))
            {
                age |= CASAgeGenderFlags.YoungAdult;
            }

            float weight, fitness;

            WeightAndFitness(choiceMom, choiceDad, out weight, out fitness);

            SimUtils.SimCreationSpec spec3 = new SimUtils.SimCreationSpec();
            spec3.Age = age;

            spec3.Weight  = weight;
            spec3.Fitness = fitness;

            spec3.Normalize();

            SimDescription child = spec3.Instantiate(choiceDad, choiceMom, true);

            if (child != null)
            {
                child.TraitManager.AddHiddenElement(TraitNames.DescendantHiddenTrait);
                if ((choiceMom != null) && (choiceDad != null))
                {
                    SimUtils.HouseholdCreationSpec.InitializeRomance(choiceMom, choiceDad, child, choiceMom.LastName);
                }
                else if (choiceMom != null)
                {
                    child.LastName = choiceMom.LastName;
                }
                else if (choiceDad != null)
                {
                    child.LastName = choiceDad.LastName;
                }
            }

            return(child);
        }
Пример #2
0
        protected SimDescription GetRandomSim(CASAgeGenderFlags gender, CASAgeGenderFlags species)
        {
            SimDescription result = null;

            if (species == CASAgeGenderFlags.Human)
            {
                SimUtils.SimCreationSpec sim = new SimUtils.SimCreationSpec();

                Vector2 fatRange = Manager.GetValue <FatRangeOption <TManager>, Vector2>();
                Vector2 fitRange = Manager.GetValue <FitRangeOption <TManager>, Vector2>();

                WorldName worldName = GetGeneticWorld();

                sim.Gender      = gender;
                sim.Age         = CASAgeGenderFlags.Adult;
                sim.Species     = species;
                sim.Weight      = RandomUtil.GetFloat(fatRange.x, fatRange.y);
                sim.Fitness     = RandomUtil.GetFloat(fitRange.x, fitRange.y);
                sim.Description = "";
                sim.GivenName   = SimUtils.GetRandomFamilyName(worldName);

                result = sim.Instantiate(worldName, uint.MaxValue);

                result.VoiceVariation     = (VoiceVariationType)RandomUtil.GetInt(0, 2);
                result.VoicePitchModifier = RandomUtil.GetFloat(0, 1f);

                Vector2 skintToneRange = Manager.GetValue <SkinToneRangeOption <TManager>, Vector2>();

                result.SkinToneIndex = RandomUtil.GetFloat(skintToneRange.x, skintToneRange.y);
            }
            else
            {
                result = GeneticsPet.MakeRandomPet(CASAgeGenderFlags.Adult, gender, species, 1f);
            }

            SetBustMuscleSliders(result);

            FacialBlends.RandomizeBlends(mStats.AddStat, result, Manager.GetValue <MutationSetRangeOption <TManager>, Vector2>(), true, Manager.GetValue <MutationSetRangeOption <TManager>, Vector2>(), false, Manager.GetValue <AllowAlienHouseholdOption <TManager>, bool>());

            mDispose.Add(result);

            mStats.IncStat("Immigrant: Random Sim");

            return(result);
        }
Пример #3
0
        public GenerateOffspringEx(SimDescription forcedParent, List <SimDescription> dyingSims, float daysGone)
        {
            CASAgeGenderFlags daysGoneAges = GetDaysGoneAges(daysGone);

            bool university = false;

            if (GameUtils.IsUniversityWorld())
            {
                university = true;
                if ((daysGoneAges & CASAgeGenderFlags.Teen) == CASAgeGenderFlags.None)
                {
                    return;
                }
            }

            SimDescription parent  = null;
            SimDescription partner = null;

            if (forcedParent.IsMale)
            {
                partner = forcedParent;
            }
            else
            {
                parent = forcedParent;
            }

            Household household = forcedParent.Household;

            if (household != null)
            {
                mHouseholdId = household.HouseholdId;
                mSim         = new SimUtils.SimCreationSpec();
                if ((parent == null) && (partner != null))
                {
                    if ((partner.Partner != null) && (partner.Gender != partner.Partner.Gender))
                    {
                        parent = partner.Partner;
                    }
                    else if (partner.Partner == null)
                    {
                        parent = FindPartner(partner, dyingSims);
                    }
                }
                if ((partner == null) && (parent != null))
                {
                    if ((parent.Partner != null) && (parent.Gender != parent.Partner.Gender))
                    {
                        partner = parent.Partner;
                    }
                    else if (parent.Partner == null)
                    {
                        partner = FindPartner(parent, dyingSims);
                    }
                }
                if (((parent != null) && !parent.IsMummy) && ((partner != null) && !partner.IsMummy))
                {
                    numDyingSims = 0;
                    int  numPetsRemoved = 0;
                    bool flag           = false;
                    foreach (SimDescription description3 in household.AllSimDescriptions)
                    {
                        if (dyingSims.Contains(description3))
                        {
                            if (description3.IsHuman)
                            {
                                numDyingSims++;
                            }
                            else
                            {
                                numPetsRemoved++;
                            }
                        }
                        else if (description3.TeenOrAbove)
                        {
                            flag = true;
                        }
                    }

                    if (household.CanSimBeAddedIfXSimAndYPetsRemoved(numDyingSims, numPetsRemoved))
                    {
                        if (university)
                        {
                            mSim.Age  = CASAgeGenderFlags.YoungAdult;
                            mSim.Age |= daysGoneAges;
                            mSim.Age &= ~CASAgeGenderFlags.Child;
                        }
                        else
                        {
                            if (!flag)
                            {
                                mSim.Age = CASAgeGenderFlags.Teen;
                            }
                            else
                            {
                                mSim.Age = CASAgeGenderFlags.Child;
                            }

                            mSim.Age |= daysGoneAges;
                        }

                        mSim.Normalize();

                        if (parent != null)
                        {
                            mMom = parent.SimDescriptionId;
                        }
                        if (partner != null)
                        {
                            mDad = partner.SimDescriptionId;
                        }
                    }
                }
            }
        }
Пример #4
0
        protected static SimDescription CreateDescendant(ulong momID, ulong dadID, Household household, CASAgeGenderFlags age, CASAgeGenderFlags gender)
        {
            bool           momUnpacked;
            SimDescription mom = CreateProgenitor(momID, out momUnpacked);

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

            bool           dadUnpacked;
            SimDescription dad = CreateProgenitor(dadID, out dadUnpacked);

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

            float weight, fitness;

            WeightAndFitness(mom, dad, out weight, out fitness);

            SimDescription sim = null;

            try
            {
                SimUtils.SimCreationSpec spec = new SimUtils.SimCreationSpec();
                spec.Weight  = weight;
                spec.Fitness = fitness;
                spec.Age     = age;
                spec.Gender  = gender;
                spec.Normalize();
                sim = spec.Instantiate(mom, dad, false, WorldName.FutureWorld);
            }
            catch (Exception e)
            {
                Common.Exception("CreateDescendant", e);
            }

            /*
             * if (dadUnpacked && (dad != null))
             * {
             *  dad.PackUpToMiniSimDescription();
             * }
             *
             * if (momUnpacked && (mom != null))
             * {
             *  mom.PackUpToMiniSimDescription();
             * }
             * */

            if (sim != null)
            {
                sim.TraitManager.AddHiddenElement(TraitNames.DescendantHiddenTrait);
                household.Add(sim);

                return(sim);
            }
            else
            {
                return(null);
            }
        }
Пример #5
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            if (!ApplyAll)
            {
                mAdoptionParams = AdoptionDialog.Show(Common.Localize(GetTitlePrefix() + ":Prompt", me.IsFemale, new object[] { me }));
                if (mAdoptionParams.mCancelled) return false;
            }

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

            foreach (SimDescription sim in SimListing.GetResidents(true).Values)
            {
                if (!sim.IsHuman) continue;

                residents.Add(sim);
            }

            SimDescription dad = RandomUtil.GetRandomObjectFromList(residents);
            SimDescription mom = RandomUtil.GetRandomObjectFromList(residents);

            SimDescription newKid = null;

            if ((dad != null) && (mom != null))
            {
                if (dad.CelebrityManager == null)
                {
                    dad.Fixup();
                }

                if (mom.CelebrityManager == null)
                {
                    mom.Fixup();
                }

                newKid = Genetics.MakeDescendant(dad, mom, mAdoptionParams.mAge, mAdoptionParams.mIsFemale ? CASAgeGenderFlags.Female : CASAgeGenderFlags.Male, 100, new Random(), false, false, true);
            }
            else
            {
                SimUtils.SimCreationSpec spec = new SimUtils.SimCreationSpec();
                spec.Gender = mAdoptionParams.mIsFemale ? CASAgeGenderFlags.Female : CASAgeGenderFlags.Male;
                spec.Age = mAdoptionParams.mAge;
                spec.Normalize();
                newKid = spec.Instantiate();
            }

            if (newKid == null)
            {
                Common.Notify(Common.Localize(GetTitlePrefix() + ":Failure"));
                return false;
            }

            string genderName = null;
            if (newKid.IsFemale)
            {
                genderName = Common.Localize("BabyGender:Female");
            }
            else
            {
                genderName = Common.Localize("BabyGender:Male");
            }

            string name = StringInputDialog.Show(Name, Common.Localize("InstaBaby:NamePrompt", newKid.IsFemale, new object[0]), newKid.FirstName);
            if (!string.IsNullOrEmpty(name))
            {
                newKid.FirstName = name;
            }

            newKid.LastName = me.LastName;

            me.Household.Add(newKid);

            newKid.WasAdopted = true;

            Sim adoptedChild = Instantiation.Perform(newKid, null);
            if (adoptedChild != null)
            {
                ResetSimTask.UpdateInterface(adoptedChild);

                SocialWorkerAdoptionSituation.InstantiateNewKid instantiateNewKid = new SocialWorkerAdoptionSituation.InstantiateNewKid();

                instantiateNewKid.AssignTraits(adoptedChild);

                instantiateNewKid.GiveImaginaryFriendDoll(newKid);

                me.Genealogy.AddChild(newKid.Genealogy);

                if (me.CreatedSim != null)
                {
                    ActiveTopic.AddToSim(me.CreatedSim, "Recently Had Baby");

                    EventTracker.SendEvent(EventTypeId.kAdoptedChild, me.CreatedSim, adoptedChild);
                    EventTracker.SendEvent(EventTypeId.kNewOffspring, me.CreatedSim, adoptedChild);
                    EventTracker.SendEvent(EventTypeId.kParentAdded, adoptedChild, me.CreatedSim);
                }

                MidlifeCrisisManager.OnHadChild(me);

                Genealogy spouse = me.Genealogy.Spouse;
                if (spouse != null)
                {
                    spouse.AddChild(newKid.Genealogy);

                    SimDescription spouseDesc = spouse.SimDescription;
                    if (spouseDesc != null)
                    {
                        MidlifeCrisisManager.OnHadChild(spouseDesc);

                        if (spouseDesc.CreatedSim != null)
                        {
                            ActiveTopic.AddToSim(spouseDesc.CreatedSim, "Recently Had Baby");

                            EventTracker.SendEvent(EventTypeId.kAdoptedChild, spouseDesc.CreatedSim, adoptedChild);
                            EventTracker.SendEvent(EventTypeId.kNewOffspring, spouseDesc.CreatedSim, adoptedChild);
                            EventTracker.SendEvent(EventTypeId.kParentAdded, adoptedChild, spouseDesc.CreatedSim);
                        }
                    }
                }

                EventTracker.SendEvent(EventTypeId.kChildBornOrAdopted, null, adoptedChild);
            }

            return true;
        }
Пример #6
0
        public GenerateOffspringEx(SimDescription forcedParent, List<SimDescription> dyingSims, float daysGone)
        {
            CASAgeGenderFlags daysGoneAges = GetDaysGoneAges(daysGone);
            
            bool university = false;
            if (GameUtils.IsUniversityWorld())
            {
                university = true;
                if ((daysGoneAges & CASAgeGenderFlags.Teen) == CASAgeGenderFlags.None)
                {
                    return;
                }
            }

            SimDescription parent = null;
            SimDescription partner = null;
            if (forcedParent.IsMale)
            {
                partner = forcedParent;
            }
            else
            {
                parent = forcedParent;
            }

            Household household = forcedParent.Household;
            if (household != null)
            {
                mHouseholdId = household.HouseholdId;
                mSim = new SimUtils.SimCreationSpec();
                if ((parent == null) && (partner != null))
                {
                    if ((partner.Partner != null) && (partner.Gender != partner.Partner.Gender))
                    {
                        parent = partner.Partner;
                    }
                    else if (partner.Partner == null)
                    {
                        parent = FindPartner(partner, dyingSims);
                    }
                }
                if ((partner == null) && (parent != null))
                {
                    if ((parent.Partner != null) && (parent.Gender != parent.Partner.Gender))
                    {
                        partner = parent.Partner;
                    }
                    else if (parent.Partner == null)
                    {
                        partner = FindPartner(parent, dyingSims);
                    }
                }
                if (((parent != null) && !parent.IsMummy) && ((partner != null) && !partner.IsMummy))
                {
                    numDyingSims = 0;
                    int numPetsRemoved = 0;
                    bool flag = false;
                    foreach (SimDescription description3 in household.AllSimDescriptions)
                    {
                        if (dyingSims.Contains(description3))
                        {
                            if (description3.IsHuman)
                            {
                                numDyingSims++;
                            }
                            else
                            {
                                numPetsRemoved++;
                            }
                        }
                        else if (description3.TeenOrAbove)
                        {
                            flag = true;
                        }
                    }

                    if (household.CanSimBeAddedIfXSimAndYPetsRemoved(numDyingSims, numPetsRemoved))
                    {
                        if (university)
                        {
                            mSim.Age = CASAgeGenderFlags.YoungAdult;
                            mSim.Age |= daysGoneAges;
                            mSim.Age &= ~CASAgeGenderFlags.Child;
                        }
                        else
                        {
                            if (!flag)
                            {
                                mSim.Age = CASAgeGenderFlags.Teen;
                            }
                            else
                            {
                                mSim.Age = CASAgeGenderFlags.Child;
                            }

                            mSim.Age |= daysGoneAges;
                        }

                        mSim.Normalize();

                        if (parent != null)
                        {
                            mMom = parent.SimDescriptionId;
                        }
                        if (partner != null)
                        {
                            mDad = partner.SimDescriptionId;
                        }
                    }
                }
            }
        }
Пример #7
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            if (!ApplyAll)
            {
                mAdoptionParams = AdoptionDialog.Show(Common.Localize(GetTitlePrefix() + ":Prompt", me.IsFemale, new object[] { me }));
                if (mAdoptionParams.mCancelled)
                {
                    return(false);
                }
            }

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

            foreach (SimDescription sim in SimListing.GetResidents(true).Values)
            {
                if (!sim.IsHuman)
                {
                    continue;
                }

                residents.Add(sim);
            }

            SimDescription dad = RandomUtil.GetRandomObjectFromList(residents);
            SimDescription mom = RandomUtil.GetRandomObjectFromList(residents);

            SimDescription newKid = null;

            if ((dad != null) && (mom != null))
            {
                if (dad.CelebrityManager == null)
                {
                    dad.Fixup();
                }

                if (mom.CelebrityManager == null)
                {
                    mom.Fixup();
                }

                newKid = Genetics.MakeDescendant(dad, mom, mAdoptionParams.mAge, mAdoptionParams.mIsFemale ? CASAgeGenderFlags.Female : CASAgeGenderFlags.Male, 100, new Random(), false, false, true);
            }
            else
            {
                SimUtils.SimCreationSpec spec = new SimUtils.SimCreationSpec();
                spec.Gender = mAdoptionParams.mIsFemale ? CASAgeGenderFlags.Female : CASAgeGenderFlags.Male;
                spec.Age    = mAdoptionParams.mAge;
                spec.Normalize();
                newKid = spec.Instantiate();
            }

            if (newKid == null)
            {
                Common.Notify(Common.Localize(GetTitlePrefix() + ":Failure"));
                return(false);
            }

            string genderName = null;

            if (newKid.IsFemale)
            {
                genderName = Common.Localize("BabyGender:Female");
            }
            else
            {
                genderName = Common.Localize("BabyGender:Male");
            }

            string name = StringInputDialog.Show(Name, Common.Localize("InstaBaby:NamePrompt", newKid.IsFemale, new object[0]), newKid.FirstName);

            if (!string.IsNullOrEmpty(name))
            {
                newKid.FirstName = name;
            }

            newKid.LastName = me.LastName;

            me.Household.Add(newKid);

            newKid.WasAdopted = true;

            Sim adoptedChild = Instantiation.Perform(newKid, null);

            if (adoptedChild != null)
            {
                ResetSimTask.UpdateInterface(adoptedChild);

                SocialWorkerAdoptionSituation.InstantiateNewKid instantiateNewKid = new SocialWorkerAdoptionSituation.InstantiateNewKid();

                instantiateNewKid.AssignTraits(adoptedChild);

                instantiateNewKid.GiveImaginaryFriendDoll(newKid);

                me.Genealogy.AddChild(newKid.Genealogy);

                if (me.CreatedSim != null)
                {
                    ActiveTopic.AddToSim(me.CreatedSim, "Recently Had Baby");

                    EventTracker.SendEvent(EventTypeId.kAdoptedChild, me.CreatedSim, adoptedChild);
                    EventTracker.SendEvent(EventTypeId.kNewOffspring, me.CreatedSim, adoptedChild);
                    EventTracker.SendEvent(EventTypeId.kParentAdded, adoptedChild, me.CreatedSim);
                }

                MidlifeCrisisManager.OnHadChild(me);

                Genealogy spouse = me.Genealogy.Spouse;
                if (spouse != null)
                {
                    spouse.AddChild(newKid.Genealogy);

                    SimDescription spouseDesc = spouse.SimDescription;
                    if (spouseDesc != null)
                    {
                        MidlifeCrisisManager.OnHadChild(spouseDesc);

                        if (spouseDesc.CreatedSim != null)
                        {
                            ActiveTopic.AddToSim(spouseDesc.CreatedSim, "Recently Had Baby");

                            EventTracker.SendEvent(EventTypeId.kAdoptedChild, spouseDesc.CreatedSim, adoptedChild);
                            EventTracker.SendEvent(EventTypeId.kNewOffspring, spouseDesc.CreatedSim, adoptedChild);
                            EventTracker.SendEvent(EventTypeId.kParentAdded, adoptedChild, spouseDesc.CreatedSim);
                        }
                    }
                }

                EventTracker.SendEvent(EventTypeId.kChildBornOrAdopted, null, adoptedChild);
            }

            return(true);
        }
        public static SimDescription GenerateOffspring(List<SimDescription> potentialParents, out bool noParents)
        {
            SimDescription choiceMom;
            SimDescription choiceDad;
            SimUtils.SimCreationSpec.ChooseParents(potentialParents, out choiceDad, out choiceMom);

            noParents = ((choiceMom == null) || (choiceDad == null) || (choiceMom == choiceDad));

            if (noParents)
            {
                return null;
            }

            CASAgeGenderFlags age = CASAgeGenderFlags.Teen | CASAgeGenderFlags.Child;
            if ((choiceMom.AdultOrAbove) && (choiceDad.AdultOrAbove))
            {
                age |= CASAgeGenderFlags.YoungAdult;
            }

            float weight, fitness;
            WeightAndFitness(choiceMom, choiceDad, out weight, out fitness);

            SimUtils.SimCreationSpec spec3 = new SimUtils.SimCreationSpec();
            spec3.Age = age;

            spec3.Weight = weight;
            spec3.Fitness = fitness;

            spec3.Normalize();

            SimDescription child = spec3.Instantiate(choiceDad, choiceMom, true);
            if (child != null)
            {
                child.TraitManager.AddHiddenElement(TraitNames.DescendantHiddenTrait);
                if ((choiceMom != null) && (choiceDad != null))
                {
                    SimUtils.HouseholdCreationSpec.InitializeRomance(choiceMom, choiceDad, child, choiceMom.LastName);
                }
                else if (choiceMom != null)
                {
                    child.LastName = choiceMom.LastName;
                }
                else if (choiceDad != null)
                {
                    child.LastName = choiceDad.LastName;
                }                
            }            

            return child;
        }
        protected static SimDescription CreateDescendant(ulong momID, ulong dadID, Household household, CASAgeGenderFlags age, CASAgeGenderFlags gender)
        {           
            bool momUnpacked;
            SimDescription mom = CreateProgenitor(momID, out momUnpacked);
            if (mom == null) return null;            

            bool dadUnpacked;
            SimDescription dad = CreateProgenitor(dadID, out dadUnpacked);
            if (dad == null) return null;            

            float weight, fitness;
            WeightAndFitness(mom, dad, out weight, out fitness);

            SimDescription sim = null;

            try
            {                
                SimUtils.SimCreationSpec spec = new SimUtils.SimCreationSpec();
                spec.Weight = weight;
                spec.Fitness = fitness;
                spec.Age = age;
                spec.Gender = gender;
                spec.Normalize();
                sim = spec.Instantiate(mom, dad, false, WorldName.FutureWorld);                
            }
            catch (Exception e)
            {
                Common.Exception("CreateDescendant", e);
            }  
          
            /*
            if (dadUnpacked && (dad != null))
            {                
                dad.PackUpToMiniSimDescription();
            }

            if (momUnpacked && (mom != null))
            {                
                mom.PackUpToMiniSimDescription();
            }
             * */

            if (sim != null)
            {
                sim.TraitManager.AddHiddenElement(TraitNames.DescendantHiddenTrait);
                household.Add(sim);

                return sim;
            }
            else
            {
                return null;
            }
        }