예제 #1
0
        protected void GetInheritors(List <Genealogy> possibles, float defFraction, Dictionary <SimDescription, float> inheritors)
        {
            List <Genealogy> children = new List <Genealogy>(possibles);

            Dictionary <SimDescription, float> fractions = new Dictionary <SimDescription, float>();

            int index = 0;

            while (index < children.Count)
            {
                Genealogy childGene = children[index];
                index++;

                SimDescription child = Relationships.GetSim(childGene);

                if (child == null)
                {
                    continue;
                }

                float fFraction;
                if (!fractions.TryGetValue(child, out fFraction))
                {
                    fFraction = defFraction;
                }

                // No inheritance for dead children
                if (child.DeathStyle != SimDescription.DeathType.None)
                {
                    foreach (Genealogy grandchildGene in childGene.Children)
                    {
                        SimDescription grandchild = Relationships.GetSim(grandchildGene);
                        if (grandchild == null)
                        {
                            continue;
                        }

                        children.Add(grandchildGene);

                        if (!fractions.ContainsKey(grandchild))
                        {
                            fractions.Add(grandchild, fFraction / childGene.Children.Count);
                        }
                    }
                }
                else if (!inheritors.ContainsKey(child))
                {
                    inheritors.Add(child, fFraction);
                }
            }
        }
예제 #2
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);
                }
            }
        }
예제 #3
0
        protected static void RepairSpouse(IMiniSimDescription simA, Dictionary <ulong, IMiniSimDescription> lookup)
        {
            SimDescription trueSimA = simA as SimDescription;

            IMiniSimDescription simB = null;

            Genealogy genealogy = simA.CASGenealogy as Genealogy;

            if (genealogy.Spouse != null)
            {
                simB = Relationships.GetSim(genealogy.Spouse, lookup);
            }

            if (trueSimA != null)
            {
                if ((simB == null) && (simA.IsMarried))
                {
                    simB = trueSimA.Partner;
                }

                if (simB == null)
                {
                    List <Relationship> relations = new List <Relationship>(Relationship.GetRelationships(trueSimA));
                    foreach (Relationship relation in relations)
                    {
                        if (relation.LTR.CurrentLTR == LongTermRelationshipTypes.Spouse)
                        {
                            simB = relation.GetOtherSimDescription(trueSimA);
                            if (simB != null)
                            {
                                simB = Relationships.Find(simB.SimDescriptionId, lookup);
                            }

                            if (simB is SimDescription)
                            {
                                break;
                            }
                        }
                    }
                }
            }

            SimDescription trueSimB = simB as SimDescription;

            if ((simA != null) && (simB != null))
            {
                Genealogy geneA = simA.CASGenealogy as Genealogy;
                Genealogy geneB = simB.CASGenealogy as Genealogy;

                if ((geneA != null) && (geneB != null))
                {
                    if (!object.ReferenceEquals(geneA.Spouse, geneB))
                    {
                        geneA.mSpouse = geneB;

                        Overwatch.Log("Missing Spouse Link Attached A");
                        Overwatch.Log("  " + Relationships.GetFullName(geneA) + " - " + Relationships.GetFullName(geneB));
                    }

                    if (!object.ReferenceEquals(geneB.Spouse, geneA))
                    {
                        geneB.mSpouse = geneA;

                        Overwatch.Log("Missing Spouse Link Attached B");
                        Overwatch.Log("  " + Relationships.GetFullName(geneB) + " - " + Relationships.GetFullName(geneA));
                    }
                }
            }

            if ((trueSimA != null) && (trueSimB != null))
            {
                if (!object.ReferenceEquals(trueSimA.Partner, trueSimB))
                {
                    // Don't call Partner, it requires genealogy
                    trueSimA.mPartner = trueSimB;

                    Overwatch.Log("Missing Partner Link Attached A");
                    Overwatch.Log("  " + Relationships.GetFullName(simA) + " - " + Relationships.GetFullName(simB));
                }

                if (!object.ReferenceEquals(trueSimB.Partner, trueSimA))
                {
                    // Don't call Partner, it requires genealogy
                    trueSimB.mPartner = trueSimA;

                    Overwatch.Log("Missing Partner Link Attached B");
                    Overwatch.Log("  " + Relationships.GetFullName(simB) + " - " + Relationships.GetFullName(simA));
                }
            }
        }