示例#1
0
        private void resolveGraphics()
        {
            if (nakedGraphic != null)
            {
                return;
            }

            nakedGraphic = GraphicGetter_NakedHumanlike.GetNakedBodyGraphic(
                bodyType, ShaderDatabase.CutoutSkin, skinColor);

            headGraphic = GraphicDatabaseHeadRecords.GetHeadNamed(
                headGraphicPath, skinColor);

            hairGraphic = GraphicDatabase.Get <Graphic_Multi>(
                hairDef.texPath, ShaderDatabase.Cutout, Vector2.one, hairColor);

            if (apparelDef != null)
            {
                Color color;
                if (Stuff != null)
                {
                    color = Stuff.stuffProps.color;
                }
                else
                {
                    color = Color.white;
                }

                apparelGraphic = new Graphic[apparelDef.Count];
                for (int i = 0; i < apparelDef.Count; i++)
                {
                    apparelGraphic[i] = TryGetGraphicApparel(apparelDef[i], bodyType, color);
                }
            }
        }
示例#2
0
        public static bool SetAncestorGraphics(Pawn pawn)
        {
            if (pawn.Drawer == null || pawn.Drawer.renderer == null || pawn.Drawer.renderer.graphics == null)
            {
                return(false);
            }

            if (!pawn.Drawer.renderer.graphics.AllResolved)
            {
                pawn.Drawer.renderer.graphics.ResolveAllGraphics();
            }

            if (pawn.Drawer.renderer.graphics.headGraphic == null ||
                pawn.Drawer.renderer.graphics.nakedGraphic == null ||
                pawn.Drawer.renderer.graphics.headGraphic.path == null ||
                pawn.Drawer.renderer.graphics.nakedGraphic.path == null)
            {
                return(false);
            }

            Graphic nakedBodyGraphic = GraphicGetter_NakedHumanlike.GetNakedBodyGraphic(pawn.story.BodyType, ShaderDatabase.CutoutSkin, AncestorUtils.spiritColor);
            Graphic headGraphic      = GraphicDatabase.Get <Graphic_Multi>(pawn.story.HeadGraphicPath, ShaderDatabase.CutoutSkin, Vector2.one, AncestorUtils.spiritColor);

            pawn.Drawer.renderer.graphics.headGraphic  = headGraphic;
            pawn.Drawer.renderer.graphics.nakedGraphic = nakedBodyGraphic;

            return(true);
        }
示例#3
0
 public void ResolveAllGraphicsAlien()
 {
     this.ClearCache();
     if (this.pawn.RaceProps.Humanlike)
     {
         this.nakedGraphic          = GraphicGetter_NakedAlien.GetNakedBodyGraphicAlien(this.pawn.story.BodyType, ShaderDatabase.CutoutSkin, this.pawn.story.SkinColor, ThingDef_AlienRace.);
         this.rottingGraphic        = GraphicGetter_NakedHumanlike.GetNakedBodyGraphic(this.pawn.story.BodyType, ShaderDatabase.CutoutSkin, PawnGraphicSet.RottingColor);
         this.dessicatedGraphic     = GraphicDatabase.Get <Graphic_Multi>("Things/Pawn/Humanlike/HumanoidDessicated", ShaderDatabase.Cutout);
         this.headGraphic           = GraphicDatabaseHeadRecords.GetHeadNamed(this.pawn.story.HeadGraphicPath, this.pawn.story.SkinColor);
         this.desiccatedHeadGraphic = GraphicDatabaseHeadRecords.GetHeadNamed(this.pawn.story.HeadGraphicPath, PawnGraphicSet.RottingColor);
         this.skullGraphic          = GraphicDatabaseHeadRecords.GetSkull();
         this.hairGraphic           = GraphicDatabase.Get <Graphic_Multi>(this.pawn.story.hairDef.texPath, ShaderDatabase.Cutout, Vector2.one, this.pawn.story.hairColor);
         this.ResolveApparelGraphics();
     }
     else
     {
         PawnKindLifeStage curKindLifeStage = this.pawn.ageTracker.CurKindLifeStage;
         if (this.pawn.gender != Gender.Female || curKindLifeStage.femaleGraphicData == null)
         {
             this.nakedGraphic = curKindLifeStage.bodyGraphicData.Graphic;
         }
         else
         {
             this.nakedGraphic = curKindLifeStage.femaleGraphicData.Graphic;
         }
         this.rottingGraphic = this.nakedGraphic.GetColoredVersion(ShaderDatabase.CutoutSkin, PawnGraphicSet.RottingColor, PawnGraphicSet.RottingColor);
         if (curKindLifeStage.dessicatedBodyGraphicData != null)
         {
             this.dessicatedGraphic = curKindLifeStage.dessicatedBodyGraphicData.GraphicColoredFor(this.pawn);
         }
     }
 }
示例#4
0
        protected void ResetBodyType()
        {
            BodyType bodyType        = pawn.story.BodyType;
            Graphic  bodyTypeGraphic = GraphicGetter_NakedHumanlike.GetNakedBodyGraphic(bodyType, ShaderDatabase.Cutout,
                                                                                        pawn.story.SkinColor);

            graphics[PawnLayers.BodyType] = bodyTypeGraphic;
            foreach (ThingDef def in selectedApparel)
            {
                if (def != null)
                {
                    int layer = PawnLayers.ToPawnLayerIndex(def.apparel);
                    if (layer != -1)
                    {
                        graphics[layer] = GraphicsCache.Instance.GetApparel(def, bodyType);
                    }
                }
            }
        }
示例#5
0
        //public static bool Zombify(ReanimatedPawn pawn)
        //{
        //    if (pawn.Drawer == null)
        //    {
        //        return false;
        //    }
        //    if (pawn.Drawer.renderer == null)
        //    {
        //        return false;
        //    }
        //    if (pawn.Drawer.renderer.graphics == null)
        //    {
        //        return false;
        //    }
        //    if (!pawn.Drawer.renderer.graphics.AllResolved)
        //    {
        //        pawn.Drawer.renderer.graphics.ResolveAllGraphics();
        //    }
        //    if (pawn.Drawer.renderer.graphics.headGraphic == null)
        //    {
        //        return false;
        //    }
        //    if (pawn.Drawer.renderer.graphics.nakedGraphic == null)
        //    {
        //        return false;
        //    }
        //    if (pawn.Drawer.renderer.graphics.headGraphic.path == null)
        //    {
        //        return false;
        //    }
        //    if (pawn.Drawer.renderer.graphics.nakedGraphic.path == null)
        //    {
        //        return false;
        //    }
        //    GiveZombieSkinEffect(pawn);
        //    return true;
        //}

        // Credit goes to Justin C for the Zombie Apocalypse code.
        // Taken from Verse.ZombieMod_Utility
        public static Pawn GenerateClonePawnFromSource(Pawn sourcePawn)
        {
            PawnKindDef pawnKindDef   = PawnKindDef.Named("ReanimatedCorpse");
            Faction     factionDirect = Find.FactionManager.FirstFactionOfDef(FactionDefOf.SpacerHostile);
            Pawn        pawn          = (Pawn)ThingMaker.MakeThing(pawnKindDef.race);

            pawn.kindDef = pawnKindDef;
            pawn.SetFactionDirect(factionDirect);
            pawn.pather     = new Pawn_PathFollower(pawn);
            pawn.ageTracker = new Pawn_AgeTracker(pawn);
            pawn.health     = new Pawn_HealthTracker(pawn);
            pawn.jobs       = new Pawn_JobTracker(pawn);
            pawn.mindState  = new Pawn_MindState(pawn);
            pawn.filth      = new Pawn_FilthTracker(pawn);
            pawn.needs      = new Pawn_NeedsTracker(pawn);
            pawn.stances    = new Pawn_StanceTracker(pawn);
            pawn.natives    = new Pawn_NativeVerbs(pawn);
            PawnComponentsUtility.CreateInitialComponents(pawn);
            if (pawn.RaceProps.ToolUser)
            {
                pawn.equipment    = new Pawn_EquipmentTracker(pawn);
                pawn.carryTracker = new Pawn_CarryTracker(pawn);
                pawn.apparel      = new Pawn_ApparelTracker(pawn);
                pawn.inventory    = new Pawn_InventoryTracker(pawn);
            }
            if (pawn.RaceProps.Humanlike)
            {
                pawn.ownership    = new Pawn_Ownership(pawn);
                pawn.skills       = new Pawn_SkillTracker(pawn);
                pawn.relations    = new Pawn_RelationsTracker(pawn);
                pawn.story        = new Pawn_StoryTracker(pawn);
                pawn.workSettings = new Pawn_WorkSettings(pawn);
            }
            if (pawn.RaceProps.intelligence <= Intelligence.ToolUser)
            {
                pawn.caller = new Pawn_CallTracker(pawn);
            }
            //pawn.gender = Gender.None;
            pawn.gender = sourcePawn.gender;
            //Cthulhu.Utility.GenerateRandomAge(pawn, pawn.Map);
            pawn.ageTracker.AgeBiologicalTicks = sourcePawn.ageTracker.AgeBiologicalTicks;
            pawn.ageTracker.BirthAbsTicks      = sourcePawn.ageTracker.BirthAbsTicks;

            pawn.needs.SetInitialLevels();
            if (pawn.RaceProps.Humanlike)
            {
                string headGraphicPath = sourcePawn.story.HeadGraphicPath;
                typeof(Pawn_StoryTracker).GetField("headGraphicPath", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(pawn.story, headGraphicPath);
                pawn.story.melanin   = sourcePawn.story.melanin;
                pawn.story.crownType = sourcePawn.story.crownType;
                pawn.story.hairColor = sourcePawn.story.hairColor;
                NameTriple name = sourcePawn.Name as NameTriple;
                pawn.Name            = name;
                pawn.story.childhood = sourcePawn.story.childhood;
                pawn.story.adulthood = sourcePawn.story.adulthood;
                pawn.story.hairDef   = sourcePawn.story.hairDef;
                foreach (Trait current in sourcePawn.story.traits.allTraits)
                {
                    pawn.story.traits.GainTrait(current);
                }
                //pawn.story.GenerateSkillsFromBackstory();
            }
            GenerateApparelFromSource(pawn, sourcePawn);
            PawnGenerationRequest con = new PawnGenerationRequest();

            PawnInventoryGenerator.GenerateInventoryFor(pawn, con);
            Graphic nakedBodyGraphic = GraphicGetter_NakedHumanlike.GetNakedBodyGraphic(sourcePawn.story.bodyType, ShaderDatabase.CutoutSkin, sourcePawn.story.SkinColor);
            Graphic headGraphic      = GraphicDatabase.Get <Graphic_Multi>(sourcePawn.story.HeadGraphicPath, ShaderDatabase.CutoutSkin, Vector2.one, sourcePawn.story.SkinColor);
            Graphic hairGraphic      = GraphicDatabase.Get <Graphic_Multi>(sourcePawn.story.hairDef.texPath, ShaderDatabase.Cutout, Vector2.one, sourcePawn.story.hairColor);

            pawn.Drawer.renderer.graphics.headGraphic  = headGraphic;
            pawn.Drawer.renderer.graphics.nakedGraphic = nakedBodyGraphic;
            pawn.Drawer.renderer.graphics.hairGraphic  = hairGraphic;
            return(pawn);
        }
        // [HarmonyAfter("net.pardeike.zombieland")]
        public static void ResolveAllGraphics_Postfix(PawnGraphicSet __instance)
        {
            Pawn pawn = __instance.pawn;

            if (pawn == null)
            {
                return;
            }

            pawn.CheckForAddedOrMissingParts();
            pawn.GetCompAnim()?.PawnBodyGraphic?.Initialize();

            // Check if race has face, else return
            if (!pawn.GetCompFace(out CompFace compFace))
            {
                return;
            }

            compFace.IsChild = pawn.ageTracker.AgeBiologicalYearsFloat < 14;

            // Return if child
            if (compFace.IsChild || compFace.Deactivated)
            {
                return;
            }

            __instance.ClearCache();
            pawn.GetComp <CompBodyAnimator>()?.ClearCache();

            GraphicDatabaseHeadRecordsModded.BuildDatabaseIfNecessary();

            // Need: get the traditional habitat of a faction => not suitable, as factions are scattered around the globe
            // if (!faceComp.IsSkinDNAoptimized)
            // {
            // faceComp.DefineSkinDNA();
            // }

            // Custom rotting color, mixed with skin tone
            Color rotColor = pawn.story.SkinColor * FaceTextures.SkinRottingMultiplyColor;

            if (!compFace.InitializeCompFace())
            {
                return;
            }

            __instance.nakedGraphic = GraphicGetter_NakedHumanlike.GetNakedBodyGraphic(
                pawn.story.bodyType,
                ShaderDatabase.CutoutSkin,
                pawn.story.SkinColor);

            if (compFace.Props.needsBlankHumanHead)
            {
                __instance.headGraphic =
                    GraphicDatabaseHeadRecordsModded.GetModdedHeadNamed(pawn,
                                                                        pawn.story.SkinColor);
                __instance.desiccatedHeadGraphic =
                    GraphicDatabaseHeadRecordsModded.GetModdedHeadNamed(pawn, rotColor);
                __instance.desiccatedHeadStumpGraphic = GraphicDatabaseHeadRecordsModded.GetStump(rotColor);
            }

            __instance.rottingGraphic =
                GraphicGetter_NakedHumanlike.GetNakedBodyGraphic(
                    pawn.story.bodyType,
                    ShaderDatabase.CutoutSkin,
                    rotColor);

            __instance.hairGraphic = GraphicDatabase.Get <Graphic_Multi_Four>(
                pawn.story.hairDef.texPath,
                ShaderDatabase.CutoutComplex,
                Vector2.one,
                pawn.story.hairColor);
            PortraitsCache.SetDirty(pawn);
        }
示例#7
0
        internal static void ResolveAgeGraphics(PawnGraphicSet graphics)
        {
            // Beards
            String beard = "";

            if (graphics.pawn.story.hairDef.hairTags.Contains("Beard"))
            {
                if (graphics.pawn.apparel.BodyPartGroupIsCovered(BodyPartGroupDefOf.UpperHead))
                {
                    beard = "_BeardOnly";
                }
                if (graphics.pawn.ageTracker.CurLifeStageIndex <= 3)
                {
                    graphics.hairGraphic = GraphicDatabase.Get <Graphic_Multi>(DefDatabase <HairDef> .GetNamed("Mop").texPath, ShaderDatabase.Cutout, Vector2.one, graphics.pawn.story.hairColor);
                }
                else
                {
                    graphics.hairGraphic = GraphicDatabase.Get <Graphic_Multi>(graphics.pawn.story.hairDef.texPath + beard, ShaderDatabase.Cutout, Vector2.one, graphics.pawn.story.hairColor);
                }
            }
            else
            {
                graphics.hairGraphic = GraphicDatabase.Get <Graphic_Multi>(graphics.pawn.story.hairDef.texPath, ShaderDatabase.Cutout, Vector2.one, graphics.pawn.story.hairColor);
            }

            // Reroute the graphics for children
            // For babies and toddlers
            if (graphics.pawn.ageTracker.CurLifeStageIndex <= 1)
            {
                string toddler_hair = "Boyish";
                if (graphics.pawn.gender == Gender.Female)
                {
                    toddler_hair = "Girlish";
                }
                graphics.hairGraphic = GraphicDatabase.Get <Graphic_Multi>("Things/Pawn/Humanlike/Children/Hairs/Child_" + toddler_hair, ShaderDatabase.Cutout, Vector2.one, graphics.pawn.story.hairColor);
                graphics.headGraphic = GraphicDatabase.Get <Graphic_Multi>("Things/Pawn/Humanlike/null", ShaderDatabase.Cutout, Vector2.one, Color.white);
            }
            // The pawn is a baby
            if (graphics.pawn.ageTracker.CurLifeStageIndex == 0)
            {
                graphics.nakedGraphic = GraphicDatabase.Get <Graphic_Single>("Things/Pawn/Humanlike/Children/Bodies/Newborn", ShaderDatabase.CutoutSkin, Vector2.one, graphics.pawn.story.SkinColor);
            }
            // The pawn is a toddler
            if (graphics.pawn.ageTracker.CurLifeStageIndex == 1)
            {
                string upright = "";
                if (graphics.pawn.ageTracker.AgeBiologicalYears >= 2)
                {
                    upright = "Upright";
                }
                graphics.nakedGraphic = GraphicDatabase.Get <Graphic_Multi>("Things/Pawn/Humanlike/Children/Bodies/Toddler" + upright, ShaderDatabase.CutoutSkin, Vector2.one, graphics.pawn.story.SkinColor);
            }
            // The pawn is a child
            else if (graphics.pawn.ageTracker.CurLifeStageIndex == 2)
            {
                //              graphics.nakedGraphic = ChildGraphics.GetChildBodyGraphics(graphics, ShaderDatabase.CutoutSkin, graphics.pawn.story.SkinColor);
                //              graphics.headGraphic = ChildGraphics.GetChildHeadGraphics(ShaderDatabase.CutoutSkin, graphics.pawn.story.SkinColor);
            }
            // Otherwise, just use the normal methods
            else if (graphics.pawn.ageTracker.CurLifeStageIndex >= 3)
            {
                graphics.nakedGraphic = GraphicGetter_NakedHumanlike.GetNakedBodyGraphic(graphics.pawn.story.bodyType, ShaderDatabase.CutoutSkin, graphics.pawn.story.SkinColor);
                graphics.headGraphic  = GraphicDatabaseHeadRecords.GetHeadNamed(graphics.pawn.story.HeadGraphicPath, graphics.pawn.story.SkinColor);
            }

            graphics.rottingGraphic        = GraphicGetter_NakedHumanlike.GetNakedBodyGraphic(graphics.pawn.story.bodyType, ShaderDatabase.CutoutSkin, PawnGraphicSet.RottingColor);
            graphics.dessicatedGraphic     = GraphicDatabase.Get <Graphic_Multi>("Things/Pawn/Humanlike/HumanoidDessicated", ShaderDatabase.Cutout);
            graphics.desiccatedHeadGraphic = GraphicDatabaseHeadRecords.GetHeadNamed(graphics.pawn.story.HeadGraphicPath, PawnGraphicSet.RottingColor);
            graphics.skullGraphic          = GraphicDatabaseHeadRecords.GetSkull();
        }
示例#8
0
        public void InitializeWithPawn(Pawn pawn)
        {
            this.pawn = this.CopyPawn(pawn);

            this.birthTicks = this.pawn.ageTracker.BirthAbsTicks % 3600000L;

            // Set the traits.
            this.traits.Clear();
            for (int i = 0; i < TraitCount; i++)
            {
                this.traits.Add(null);
            }
            List <Trait> pawnTraits = pawn.story.traits.allTraits;

            if (pawnTraits.Count > 0)
            {
                this.traits[0] = pawnTraits[0];
            }
            if (pawnTraits.Count > 1 && this.traits[0] != pawnTraits[1])
            {
                this.traits[1] = pawnTraits[1];
            }
            if (pawnTraits.Count > 2 && this.traits[0] != pawnTraits[2] && this.traits[1] != pawnTraits[2])
            {
                this.traits[2] = pawnTraits[2];
            }

            // Set the skills.
            InitializeSkillLevelsAndPassions();
            ComputeSkillLevelModifiers();

            graphics.Clear();
            colors.Clear();
            PawnGraphicSet pawnGraphics = pawn.Drawer.renderer.graphics;

            graphics.Add(GraphicGetter_NakedHumanlike.GetNakedBodyGraphic(pawn.story.BodyType, ShaderDatabase.CutoutSkin, pawn.story.SkinColor));
            colors.Add(pawn.story.SkinColor);

            graphics.Add(null);
            colors.Add(Color.white);
            graphics.Add(null);
            colors.Add(Color.white);
            graphics.Add(null);
            colors.Add(Color.white);
            graphics.Add(null);
            colors.Add(Color.white);

            graphics.Add(GraphicDatabaseHeadRecords.GetHeadNamed(pawn.story.HeadGraphicPath, pawn.story.SkinColor));
            colors.Add(pawn.story.SkinColor);
            ResetHead();

            graphics.Add(GraphicsCache.Instance.GetHair(pawn.story.hairDef));
            colors.Add(pawn.story.hairColor);

            graphics.Add(null);
            colors.Add(Color.white);
            graphics.Add(null);
            colors.Add(Color.white);

            for (int i = 0; i < PawnLayers.Count; i++)
            {
                selectedApparel.Add(null);
                acceptedApparel.Add(null);
                selectedStuff.Add(null);
            }
            foreach (Apparel current in this.pawn.apparel.WornApparel)
            {
                Graphic graphic = GraphicsCache.Instance.GetApparel(current.def, pawn.story.BodyType);
                Color   color   = current.DrawColor;
                int     layer   = PawnLayers.ToPawnLayerIndex(current.def.apparel);
                if (layer != -1)
                {
                    graphics[layer] = graphic;
                    SetSelectedApparel(layer, current.def);
                    acceptedApparel[layer] = current.def;
                    SetSelectedStuff(layer, current.Stuff);
                    if (ApparelIsTintedByDefault(current.def, current.Stuff))
                    {
                        SetColor(layer, color);
                    }
                }
            }

            ResetIncapableOf();
            pawn.health.capacities.Clear();
        }