Exemple #1
0
        public static Thing MakeGenomeSequence(Pawn pawn, ThingDef genomeDef)
        {
            Thing          genomeThing    = ThingMaker.MakeThing(genomeDef);
            GenomeSequence genomeSequence = genomeThing as GenomeSequence;

            if (genomeSequence != null)
            {
                //Standard.
                genomeSequence.sourceName = pawn?.Name?.ToStringFull ?? null;
                if (genomeSequence.sourceName == null)
                {
                    genomeSequence.sourceName = pawn.def.LabelCap;
                }
                genomeSequence.pawnKindDef = pawn.kindDef;
                genomeSequence.gender      = pawn.gender;

                if (pawn?.health?.hediffSet?.hediffs != null)
                {
                    List <Hediff> pawnHediffs = pawn.health.hediffSet.hediffs;
                    if (pawnHediffs.Count > 0)
                    {
                        foreach (Hediff h in pawnHediffs)
                        {
                            if (GeneralCompatibility.includedGenomeTemplateHediffs.Any(hediffDef => h.def.defName == hediffDef.defName))
                            {
                                QEEMod.TryLog("Hediff " + h.def.defName + " will be added to genome template");

                                genomeSequence.hediffInfos.Add(new HediffInfo(h));
                            }
                        }
                    }
                }

                //Humanoid only.
                Pawn_StoryTracker story = pawn.story;
                if (story != null)
                {
                    genomeSequence.bodyType        = story.bodyType;
                    genomeSequence.crownType       = story.crownType;
                    genomeSequence.hairColor       = story.hairColor;
                    genomeSequence.skinMelanin     = story.melanin;
                    genomeSequence.hair            = story.hairDef;
                    genomeSequence.headGraphicPath = story.HeadGraphicPath;

                    foreach (Trait trait in story.traits.allTraits)
                    {
                        genomeSequence.traits.Add(new ExposedTraitEntry(trait));
                    }
                }

                //Alien Races compatibility.
                if (CompatibilityTracker.AlienRacesActive)
                {
                    AlienRaceCompat.GetFieldsFromAlienComp(pawn, genomeSequence);
                }
            }

            return(genomeThing);
        }
        public static Thing MakeGenomeSequence(Pawn pawn, ThingDef genomeDef)
        {
            Thing          genomeThing    = ThingMaker.MakeThing(genomeDef);
            GenomeSequence genomeSequence = genomeThing as GenomeSequence;

            if (genomeSequence != null)
            {
                //Standard.
                genomeSequence.sourceName = pawn?.Name?.ToStringFull ?? null;
                if (genomeSequence.sourceName == null)
                {
                    genomeSequence.sourceName = pawn.def.LabelCap;
                }
                genomeSequence.pawnKindDef = pawn.kindDef;
                genomeSequence.gender      = pawn.gender;

                //Humanoid only.
                Pawn_StoryTracker story = pawn.story;
                if (story != null)
                {
                    genomeSequence.bodyType        = story.bodyType;
                    genomeSequence.crownType       = story.crownType;
                    genomeSequence.hairColor       = story.hairColor;
                    genomeSequence.skinMelanin     = story.melanin;
                    genomeSequence.hair            = story.hairDef;
                    genomeSequence.headGraphicPath = story.HeadGraphicPath;

                    foreach (Trait trait in story.traits.allTraits)
                    {
                        genomeSequence.traits.Add(new ExposedTraitEntry(trait));
                    }
                }

                //Alien Races compatibility.
                if (CompatibilityTracker.AlienRacesActive)
                {
                    AlienRaceCompat.GetFieldsFromAlienComp(pawn, genomeSequence);
                }
            }

            return(genomeThing);
        }