Example #1
0
        public override void PostAdd(DamageInfo?dinfo)
        {
            base.PostAdd(dinfo);
            List <Hediff> hediffs = this.pawn.health.hediffSet.hediffs;
            Vector2       vector  = pawn.ageTracker.CurKindLifeStage.bodyGraphicData.drawSize;

            initialHediffCount = hediffs.Count;
            Pawn_DrawTracker drawtracker = ((Pawn_DrawTracker)typeof(Pawn).GetField("drawer", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(pawn));

            if (drawtracker != null)
            {
                this.pawn_renderer = drawtracker.renderer;
            }
            LongEventHandler.ExecuteWhenFinished(delegate
            {
                if (this.pawn_renderer != null)
                {
                    try
                    {
                        Graphic_Multi nakedGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>("Things/Pawn/Animal/AA_ArcticLion/AA_ArcticLion_Invisible", ShaderDatabase.Cutout, vector, Color.white);
                        this.pawn_renderer.graphics.ResolveAllGraphics();
                        this.pawn_renderer.graphics.nakedGraphic = nakedGraphic;
                        (this.pawn_renderer.graphics.nakedGraphic.data = new GraphicData()).shadowData = pawn.ageTracker.CurKindLifeStage.bodyGraphicData.shadowData;
                    }
                    catch (NullReferenceException) { }
                }
            });
        }
        public override void CompPostMake()
        {
            Pawn             pawn        = this.parent.pawn as Pawn;
            Pawn_DrawTracker drawtracker = ((Pawn_DrawTracker)typeof(Pawn).GetField("drawer", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(pawn));

            if (drawtracker != null)
            {
                this.pawn_renderer = drawtracker.renderer;
            }
            Vector2 vector = pawn.ageTracker.CurKindLifeStage.bodyGraphicData.drawSize * 3;

            LongEventHandler.ExecuteWhenFinished(delegate
            {
                if (this.pawn_renderer != null)
                {
                    try
                    {
                        Graphic_Multi nakedGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(pawn.ageTracker.CurKindLifeStage.bodyGraphicData.texPath + "_Enlarged", ShaderDatabase.Cutout, vector, Color.white);
                        this.pawn_renderer.graphics.ResolveAllGraphics();
                        this.pawn_renderer.graphics.nakedGraphic = nakedGraphic;
                        (this.pawn_renderer.graphics.nakedGraphic.data = new GraphicData()).shadowData = pawn.ageTracker.CurKindLifeStage.bodyGraphicData.shadowData;
                    }
                    catch (NullReferenceException) { }
                }
            });
        }
Example #3
0
 public void ExposeData()
 {
     Scribe_Values.Look(ref id, "blueprintID");
     Scribe_Values.Look(ref Label, "label");
     Scribe_Values.Look(ref VersionNumber, "versionNum");
     Scribe_Values.Look(ref chassisType, "chassisType");
     Scribe_Collections.Look(ref aiPackages, "aiPackages");
     Scribe_Collections.Look(ref skills, "skills", LookMode.Deep);
     Scribe_Values.Look(ref CapableOfViolence, "capableOfViolence");
     Scribe_Values.Look(ref bptype, "bpType");
     Scribe_Defs.Look(ref headGraphicDef, "headGraphicDef");
     Scribe_Defs.Look(ref bodyGraphicDef, "bodyGraphicDef");
     //Scribe_Values.Look(ref color, "color");
     if (Scribe.mode == LoadSaveMode.Saving)
     {
         partsCondensed = CondenseParts();
         Scribe_Collections.Look(ref partsCondensed, "partsCondensed", LookMode.Deep);
     }
     else
     {
         Scribe_Collections.Look(ref partsCondensed, "partsCondensed", LookMode.Deep);
         LoadDictionary();
         headGraphic = headGraphicDef.GetGraphic();
         bodyGraphic = bodyGraphicDef.GetGraphic();
     }
 }
Example #4
0
 public Graphic_Multi GetGraphic()
 {
     if (_graphic == null)
     {
         _graphic = (Graphic_Multi)GraphicDatabase.Get(typeof(Graphic_Multi), GetPath(), ShaderDatabase.Cutout, new Vector2(1.5f, 1.5f), Color.white, Color.white);
     }
     return(_graphic);
 }
Example #5
0
        // ==================================

        private void UpdateGraphics()
        {
            graphic_Wheel       = new Graphic_Multi();
            graphic_Wheel       = GraphicDatabase.Get <Graphic_Multi>("Things/Pawn/Vehicle/Cart_Wheel", def.graphic.Shader, def.graphic.drawSize, def.graphic.color, def.graphic.colorTwo) as Graphic_Multi;
            graphic_Handle      = new Graphic_Multi();
            graphic_Handle      = GraphicDatabase.Get <Graphic_Multi>("Things/Pawn/Vehicle/Cart_Handle", def.graphic.Shader, def.graphic.drawSize, def.graphic.color, def.graphic.colorTwo) as Graphic_Multi;
            graphic_FullStorage = new Graphic_Multi();
            graphic_FullStorage = GraphicDatabase.Get <Graphic_Multi>("Things/Pawn/Vehicle/Cart_FullStorage", def.graphic.Shader, def.graphic.drawSize, def.graphic.color, def.graphic.colorTwo) as Graphic_Multi;
        }
Example #6
0
        // My own methods
        internal static Graphic GetChildHeadGraphics(Shader shader, Color skinColor)
        {
            Graphic_Multi graphic = null;
            string        str     = "Male_Child";
            string        path    = "Things/Pawn/Humanlike/Children/Heads/" + str;

            graphic = GraphicDatabase.Get <Graphic_Multi> (path, shader, Vector2.one, skinColor) as Graphic_Multi;
            return(graphic);
        }
        /// <summary>
        /// Import the graphics
        /// </summary>
        private void UpdateGraphics()
        {
            graphic_Body   = new Graphic_Multi();
            graphic_Handle = new Graphic_Multi();
            graphic_Wheel  = new Graphic_Multi();

            graphic_Wheel  = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>("Things/Pawn/Vehicle/Cargo_Wheel", def.shader, def.DrawSize, def.defaultColor, def.defaultColorTwo);
            graphic_Body   = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>("Things/Pawn/Vehicle/Cargo", def.shader, def.DrawSize, def.defaultColor, def.defaultColorTwo);
            graphic_Handle = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>("Things/Pawn/Vehicle/Cargo_Handle", def.shader, def.DrawSize, def.defaultColor, def.defaultColorTwo);
        }
Example #8
0
            public Graphic_Multi GetGraphic(Color color)
            {
                for (int i = 0; i < this.graphics.Count; i++)
                {
                    if (color.IndistinguishableFrom(this.graphics[i].Key))
                    {
                        return(this.graphics[i].Value);
                    }
                }
                Graphic_Multi graphic_Multi = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(this.graphicPath, ShaderDatabase.CutoutSkin, Vector2.one, color);

                this.graphics.Add(new KeyValuePair <Color, Graphic_Multi>(color, graphic_Multi));
                return(graphic_Multi);
            }
        // My own methods
        internal static Graphic GetChildHeadGraphics(PawnGraphicSet graphicSet, Shader shader, Color skinColor)
        {
            Graphic_Multi graphic = null;
            string        str     = "Male_Average_Normal";

            if (graphicSet.pawn.gender == Gender.Female)
            {
                str = "Female_Average_Normal";
            }
            string path = "Things/Pawn/Humanlike/Children/Heads/" + str;

            graphic = GraphicDatabase.Get <Graphic_Multi> (path, shader, Vector2.one, skinColor) as Graphic_Multi;
            return(graphic);
        }
        internal static Graphic GetChildBodyGraphics(PawnGraphicSet graphicSet, Shader shader, Color skinColor)
        {
            Graphic_Multi graphic = null;
            string        str     = "Naked_Boy";

            if (graphicSet.pawn.gender == Gender.Female)
            {
                str = "Naked_Girl";
            }
            string path = "Things/Pawn/Humanlike/Children/Bodies/" + str;

            graphic = GraphicDatabase.Get <Graphic_Multi> (path, shader, Vector2.one, skinColor) as Graphic_Multi;
            return(graphic);
        }
 private void UpdateGraphics()
 {
     if (axlesComp.HasAxles())
     {
         string text = "Things/Pawn/" + def.defName + "/Wheel";
         graphic_Wheel_Single = new Graphic_Single();
         graphic_Wheel_Single = GraphicDatabase.Get <Graphic_Single>(text, def.graphic.Shader, def.graphic.drawSize, def.graphic.color, def.graphic.colorTwo) as Graphic_Single;
     }
     if (vehicleComp.ShowsStorage())
     {
         string text2 = string.Concat("Things/Pawn/", def.defName, "/", def.defName, "_FullStorage");
         graphic_FullStorage = new Graphic_Multi();
         graphic_FullStorage = GraphicDatabase.Get <Graphic_Multi>(text2, def.graphic.Shader, def.graphic.drawSize, def.graphic.color, def.graphic.colorTwo) as Graphic_Multi;
     }
 }
        public void RestoreTheGraphics()
        {
            this.main_graphic  = this.ageTracker.CurKindLifeStage.bodyGraphicData.texPath;
            this.pawn_renderer = ((Pawn_DrawTracker)typeof(Pawn).GetField("drawer", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(this)).renderer;


            LongEventHandler.ExecuteWhenFinished(delegate
            {
                Vector2 vector = this.ageTracker.CurKindLifeStage.bodyGraphicData.drawSize;
                //Log.Message(this.ageTracker.CurKindLifeStage.bodyGraphicData.texPath + "Alternate");
                Graphic_Multi nakedGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(this.ageTracker.CurKindLifeStage.bodyGraphicData.texPath, ShaderDatabase.Cutout, vector, Color.white);
                this.pawn_renderer.graphics.nakedGraphic = nakedGraphic;
                (this.pawn_renderer.graphics.nakedGraphic.data = new GraphicData()).shadowData = this.ageTracker.CurKindLifeStage.bodyGraphicData.shadowData;
            });
        }
            public Graphic_Multi GetGraphic(Color color, bool dessicated = false)
            {
                Shader shader = (!dessicated) ? ShaderDatabase.CutoutSkin : ShaderDatabase.Cutout;

                for (int i = 0; i < graphics.Count; i++)
                {
                    if (color.IndistinguishableFrom(graphics[i].Key) && graphics[i].Value.Shader == shader)
                    {
                        return(graphics[i].Value);
                    }
                }
                Graphic_Multi graphic_Multi = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(graphicPath, shader, Vector2.one, color);

                graphics.Add(new KeyValuePair <Color, Graphic_Multi>(color, graphic_Multi));
                return(graphic_Multi);
            }
        public override void Tick()
        {
            tickCounter++;
            if (tickCounter > tickCounterMax)
            {
                this.pawn_renderer = this.pawn.Drawer.renderer;

                LongEventHandler.ExecuteWhenFinished(delegate
                {
                    Vector2 vector = new Vector2(1, 1);
                    Graphic_Multi headGraphicNew            = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>("Things/Pawn/Heads/Bear/Male_Average_Normal", ShaderDatabase.Cutout, vector, this.pawn_renderer.graphics.nakedGraphic.Color);
                    this.pawn_renderer.graphics.headGraphic = headGraphicNew;
                });
                tickCounter = 0;
            }
            base.Tick();
        }
Example #15
0
        // My own methods
        internal static Graphic GetChildHeadGraphics(PawnGraphicSet graphicSet, Shader shader, Color skinColor)
        {
            Graphic_Multi graphic = null;
            Pawn          pawn    = graphicSet.pawn;

            if (ChildrenUtility.IsHumanlikeChild(pawn))
            {
                string str  = "Male_Child";
                string path = "Things/Pawn/Humanlike/Children/Heads/" + str;
                graphic = GraphicDatabase.Get <Graphic_Multi>(path, shader, Vector2.one, skinColor) as Graphic_Multi;
            }
            else
            {
                graphic = graphicSet.headGraphic as Graphic_Multi;
            }
            return(graphic);
        }
Example #16
0
        public void ReturnToOriginalGraphics()
        {
            Vector2 vector = pawn.ageTracker.CurKindLifeStage.bodyGraphicData.drawSize;

            LongEventHandler.ExecuteWhenFinished(delegate
            {
                if (this.pawn_renderer != null)
                {
                    try
                    {
                        Graphic_Multi nakedGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(pawn.ageTracker.CurKindLifeStage.bodyGraphicData.texPath, ShaderDatabase.Cutout, vector, Color.white);
                        this.pawn_renderer.graphics.ResolveAllGraphics();
                        this.pawn_renderer.graphics.nakedGraphic = nakedGraphic;
                        (this.pawn_renderer.graphics.nakedGraphic.data = new GraphicData()).shadowData = pawn.ageTracker.CurKindLifeStage.bodyGraphicData.shadowData;
                    }
                    catch (NullReferenceException) { }
                }
            });
        }
        public void ChangeGraphic()
        {
            Vector2       sizeVector   = this.parent.Graphic.drawSize;
            Color         objectColour = this.parent.Graphic.color;
            ShaderTypeDef shaderUsed   = this.parent.def.graphicData.shaderType;

            if (this.parent.Faction != null && this.parent.Faction.IsPlayer)
            {
                if (this.parent.def.graphicData.graphicClass == typeof(Graphic_Multi))
                {
                    if (newGraphicPath == "")
                    {
                        newGraphicPath = Props.randomGraphics.RandomElement();
                        newGraphic     = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(newGraphicPath, shaderUsed.Shader, sizeVector, objectColour);
                    }
                    else
                    {
                        newGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(newGraphicPath, shaderUsed.Shader, sizeVector, objectColour);
                    }
                    Type      typ  = typeof(Thing);
                    FieldInfo type = typ.GetField("graphicInt", BindingFlags.Instance | BindingFlags.NonPublic);
                    type.SetValue(thingToGrab, newGraphic);
                }
                else if (this.parent.def.graphicData.graphicClass == typeof(Graphic_Single))
                {
                    if (newGraphicSinglePath == "")
                    {
                        newGraphicSinglePath = Props.randomGraphics.RandomElement();
                        newGraphicSingle     = (Graphic_Single)GraphicDatabase.Get <Graphic_Single>(newGraphicSinglePath, shaderUsed.Shader, sizeVector, objectColour);
                    }
                    else
                    {
                        newGraphicSingle = (Graphic_Single)GraphicDatabase.Get <Graphic_Single>(newGraphicSinglePath, shaderUsed.Shader, sizeVector, objectColour);
                    }
                    Type      typ  = typeof(Thing);
                    FieldInfo type = typ.GetField("graphicInt", BindingFlags.Instance | BindingFlags.NonPublic);
                    type.SetValue(thingToGrab, newGraphicSingle);
                }
            }
        }
Example #18
0
 public override void SpawnSetup()
 {
     base.SpawnSetup();
     graphic = new Graphic_Multi();
     graphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>("Things/Pawn/Vehicle/Cargo_Wheel", parent.def.shader, parent.def.DrawSize, parent.def.defaultColor, parent.def.defaultColorTwo);
 }
Example #19
0
 // ==================================
 private void UpdateGraphics()
 {
     graphic_Wheel = new Graphic_Multi();
     graphic_Wheel = GraphicDatabase.Get<Graphic_Multi>("Things/Pawn/Vehicle/Cart_Wheel", def.graphic.Shader, def.graphic.drawSize, def.graphic.color, def.graphic.colorTwo) as Graphic_Multi;
     graphic_Handle = new Graphic_Multi();
     graphic_Handle = GraphicDatabase.Get<Graphic_Multi>("Things/Pawn/Vehicle/Cart_Handle", def.graphic.Shader, def.graphic.drawSize, def.graphic.color, def.graphic.colorTwo) as Graphic_Multi;
     graphic_FullStorage = new Graphic_Multi();
     graphic_FullStorage = GraphicDatabase.Get<Graphic_Multi>("Things/Pawn/Vehicle/Cart_FullStorage", def.graphic.Shader, def.graphic.drawSize, def.graphic.color, def.graphic.colorTwo) as Graphic_Multi;
 }
Example #20
0
 public override void SpawnSetup()
 {
     base.SpawnSetup();
     graphic = new Graphic_Multi();
     graphic = (Graphic_Multi)GraphicDatabase.Get<Graphic_Multi>("Things/Pawn/Vehicle/Cargo_Wheel", parent.def.shader, parent.def.DrawSize, parent.def.defaultColor, parent.def.defaultColorTwo);
 }
Example #21
0
        /// <summary>
        /// Import the graphics
        /// </summary>
        private void UpdateGraphics()
        {
            graphic_Body = new Graphic_Multi();
            graphic_Handle = new Graphic_Multi();
            graphic_Wheel = new Graphic_Multi();

            graphic_Wheel = (Graphic_Multi)GraphicDatabase.Get<Graphic_Multi>("Things/Pawn/Vehicle/Cargo_Wheel", def.shader, def.DrawSize, def.defaultColor, def.defaultColorTwo);
            graphic_Body = (Graphic_Multi)GraphicDatabase.Get<Graphic_Multi>("Things/Pawn/Vehicle/Cargo", def.shader, def.DrawSize, def.defaultColor, def.defaultColorTwo);
            graphic_Handle = (Graphic_Multi)GraphicDatabase.Get<Graphic_Multi>("Things/Pawn/Vehicle/Cargo_Handle", def.shader, def.DrawSize, def.defaultColor, def.defaultColorTwo);
        }
        public void ChangeGraphic()
        {
            try
            {
                Vector2       sizeVector   = parent.Graphic.drawSize;
                Color         objectColour = parent.Graphic.color;
                ShaderTypeDef shaderUsed   = parent.def.graphicData.shaderType;

                if (parent.Faction != null && parent.Faction.IsPlayer)
                {
                    if (parent.def.graphicData.graphicClass == typeof(Graphic_Multi))
                    {
                        if (!VFECore.VFEGlobal.settings.isRandomGraphic)
                        {
                            if (!reloading)
                            {
                                int newGraphicPathIndex = Props.randomGraphics.IndexOf(newGraphicPath);
                                if (newGraphicPathIndex + 1 > Props.randomGraphics.Count - 1)
                                {
                                    newGraphicPathIndex = 0;
                                }
                                else
                                {
                                    newGraphicPathIndex++;
                                }
                                newGraphicPath = Props.randomGraphics[newGraphicPathIndex];
                                newGraphic     = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(newGraphicPath, shaderUsed.Shader, sizeVector, objectColour);
                            }
                            else
                            {
                                if (newGraphicPath == "")
                                {
                                    newGraphicPath = Props.randomGraphics[0];
                                    newGraphic     = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(newGraphicPath, shaderUsed.Shader, sizeVector, objectColour);
                                }
                                else
                                {
                                    newGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(newGraphicPath, shaderUsed.Shader, sizeVector, objectColour);
                                }
                                reloading = false;
                            }
                        }
                        else if (newGraphicPath == "")
                        {
                            newGraphicPath = Props.randomGraphics.RandomElement();
                            newGraphic     = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(newGraphicPath, shaderUsed.Shader, sizeVector, objectColour);
                        }
                        else
                        {
                            newGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(newGraphicPath, shaderUsed.Shader, sizeVector, objectColour);
                        }
                        Type      typ  = typeof(Thing);
                        FieldInfo type = typ.GetField("graphicInt", BindingFlags.Instance | BindingFlags.NonPublic);
                        type.SetValue(thingToGrab, newGraphic);
                    }
                    else if (parent.def.graphicData.graphicClass == typeof(Graphic_Single))
                    {
                        if (!VFECore.VFEGlobal.settings.isRandomGraphic)
                        {
                            if (!reloading)
                            {
                                int newGraphicPathIndex = Props.randomGraphics.IndexOf(newGraphicSinglePath);
                                if (newGraphicPathIndex + 1 > Props.randomGraphics.Count - 1)
                                {
                                    newGraphicPathIndex = 0;
                                }
                                else
                                {
                                    newGraphicPathIndex++;
                                }
                                newGraphicSinglePath = Props.randomGraphics[newGraphicPathIndex];
                                newGraphicSingle     = (Graphic_Single)GraphicDatabase.Get <Graphic_Single>(newGraphicSinglePath, shaderUsed.Shader, sizeVector, objectColour);
                            }
                            else
                            {
                                if (newGraphicSinglePath == "")
                                {
                                    newGraphicSinglePath = Props.randomGraphics[0];
                                    newGraphicSingle     = (Graphic_Single)GraphicDatabase.Get <Graphic_Single>(newGraphicSinglePath, shaderUsed.Shader, sizeVector, objectColour);
                                }
                                else
                                {
                                    newGraphicSingle = (Graphic_Single)GraphicDatabase.Get <Graphic_Single>(newGraphicSinglePath, shaderUsed.Shader, sizeVector, objectColour);
                                }
                                reloading = false;
                            }
                        }
                        else
                        if (newGraphicSinglePath == "")
                        {
                            newGraphicSinglePath = Props.randomGraphics.RandomElement();
                            newGraphicSingle     = (Graphic_Single)GraphicDatabase.Get <Graphic_Single>(newGraphicSinglePath, shaderUsed.Shader, sizeVector, objectColour);
                        }
                        else
                        {
                            newGraphicSingle = (Graphic_Single)GraphicDatabase.Get <Graphic_Single>(newGraphicSinglePath, shaderUsed.Shader, sizeVector, objectColour);
                        }
                        Type      typ  = typeof(Thing);
                        FieldInfo type = typ.GetField("graphicInt", BindingFlags.Instance | BindingFlags.NonPublic);
                        type.SetValue(thingToGrab, newGraphicSingle);
                    }
                }
            }
            catch (Exception) { Log.Message("The variations mod has probably been added to a running save. Ignoring load error."); }
        }
Example #23
0
        public bool AddNewBaby(Pawn mother, Pawn father)
        {
            float  melanin;
            string lastname;

            if (xxx.is_human(mother))
            {
                if (xxx.is_human(father))
                {
                    melanin = ChildRelationUtility.GetRandomChildSkinColor(father.story?.melanin ?? 0f, mother.story?.melanin ?? 0f);
                    //melanin = (mother.story?.melanin ?? 0f + father.story?.melanin ?? 0f) / 2;
                    lastname = NameTriple.FromString(father.Name.ToStringFull).Last;
                }
                else
                {
                    melanin  = mother.story?.melanin ?? 0f;
                    lastname = NameTriple.FromString(mother.Name.ToStringFull).Last;
                }
            }
            else if (xxx.is_human(father))
            {
                melanin  = father.story?.melanin ?? 0f;
                lastname = NameTriple.FromString(father.Name.ToStringFull).Last;
            }
            else
            {
                melanin  = Rand.Range(0, 1.0f);
                lastname = "";
            }

            PawnGenerationRequest request = new PawnGenerationRequest(
                newborn: true,
                allowDowned: true,
                faction: mother.IsPrisoner ? null : mother.Faction,
                canGeneratePawnRelations: false,
                forceGenerateNewPawn: true,
                colonistRelationChanceFactor: 0,
                allowFood: false,
                allowAddictions: false,
                relationWithExtraPawnChanceFactor: 0,
                fixedMelanin: melanin,
                fixedLastName: lastname,
                kind: BabyPawnKindDecider(mother, father)
                //fixedIdeo: mother.Ideo,
                //forbidAnyTitle: true,
                //forceNoBackstory:true
                );

            int         division       = 1;
            HairDef     firsthair      = null;
            Color       firsthaircolor = Color.white;
            BodyTypeDef firstbody      = null;
            CrownType   firstcrown     = CrownType.Undefined;
            string      firstheadpath  = null;
            string      firstHARcrown  = null;

            while (Rand.Chance(Configurations.EnzygoticTwinsChance) && division < Configurations.MaxEnzygoticTwins)
            {
                division++;
            }
            for (int i = 0; i < division; i++)
            {
                Pawn baby = GenerateBaby(request, mother, father);
                if (division > 1)
                {
                    if (i == 0 && baby.story != null)
                    {
                        firsthair           = baby.story.hairDef;
                        firsthaircolor      = baby.story.hairColor;
                        request.FixedGender = baby.gender;
                        firstbody           = baby.story.bodyType;
                        firstcrown          = baby.story.crownType;
                        firstheadpath       = (string)baby.story.GetMemberValue("headGraphicPath");
                        if (firstheadpath == null)
                        {
                            Graphic_Multi head = GraphicDatabaseHeadRecords.GetHeadRandom(baby.gender, baby.story.SkinColor, baby.story.crownType, true);
                            if (head != null)
                            {
                                baby.story.SetMemberValue("headGraphicPath", head.GraphicPath);
                            }
                            firstheadpath = (string)baby.story.GetMemberValue("headGraphicPath");
                        }
                        if (Configurations.HARActivated && baby.IsHAR())
                        {
                            firstHARcrown = baby.GetHARCrown();
                        }
                    }
                    else
                    {
                        if (baby.story != null)
                        {
                            baby.story.hairDef   = firsthair;
                            baby.story.hairColor = firsthaircolor;
                            baby.story.bodyType  = firstbody;
                            baby.story.crownType = firstcrown;
                            baby.story.SetMemberValue("headGraphicPath", firstheadpath);

                            if (Configurations.HARActivated && baby.IsHAR())
                            {
                                baby.SetHARCrown(firstHARcrown);
                            }
                        }
                    }
                }

                if (baby != null)
                {
                    babies.Add(baby);
                }
            }



            return(true);
        }
Example #24
0
 /// <summary>
 /// Import the graphics
 /// </summary>
 private void UpdateGraphics()
 {
     graphic_Saddle = new Graphic_Multi();
     graphic_Saddle = GraphicDatabase.Get <Graphic_Multi>("Things/Pawn/Vehicle/Saddle", def.graphic.Shader, def.graphic.drawSize, def.graphic.color, def.graphic.colorTwo) as Graphic_Multi;
 }
        public bool ApplyNewSkin(int index)
        {
            // gender texture
            bool female = this.gender == Gender.Female && ageTracker.CurKindLifeStage.femaleGraphicData != null;

            string base_graphic_path =
                female ? ageTracker.CurKindLifeStage.femaleGraphicData.texPath
                                : ageTracker.CurKindLifeStage.bodyGraphicData.texPath;


            TryLoadSkinSet();

            // Throw an error when index out of range
            if (index > num_skins(ageTracker.CurLifeStageIndex, female))
            {
                Log.Error("Error in " + assembly_name + ": AnimalVaried.ApplyNewSkin tried to set skin index out of available range for " + def.defName);
                return(false);
            }

            Vector2 draw_size   = ageTracker.CurKindLifeStage.bodyGraphicData.drawSize;
            Color   draw_color  = Color.white;
            Color   draw_color2 = Color.white;
            Shader  shader      = ShaderDatabase.Cutout;

            int ageInd = ageTracker.CurLifeStageIndex;

            // Use the winter coat instead
            if ((winter_coat_timer == winter_coat_trans_time || winterized) && UsesWinterCoat(ageTracker.CurLifeStageIndex))
            {
                //
                string winter_graphic = base_graphic_path;

                // Look for a custom winter graphic
                // For males
                if (!female)
                {
                    if (GetWinterCoatValue(ageInd, "texName") != null)
                    {
                        winter_graphic = base_graphic_path.Substring(0, base_graphic_path.LastIndexOf('/') + 1) + GetWinterCoatValue(ageInd, "texName");
                    }
                    else
                    {
                        // Look for the default name instead
                        if (DoesTexSetExist(base_graphic_path + "_winter"))
                        {
                            winter_graphic = base_graphic_path + "_winter";
                        }
                    }
                }
                // For females
                else
                {
                    if (GetWinterCoatValue(ageInd, "texNameFemale") != null)
                    {
                        winter_graphic = base_graphic_path.Substring(0, base_graphic_path.LastIndexOf('/') + 1) + GetWinterCoatValue(ageInd, "texNameFemale");
                    }
                    else
                    {
                        // Look for the default name instead
                        if (DoesTexSetExist(base_graphic_path + "_winter"))
                        {
                            winter_graphic = base_graphic_path + "_winter";
                        }
                    }
                }

                if (bool.Parse(GetWinterCoatValue(ageInd, "useComplexShader")))
                {
                    shader = ShaderDatabase.CutoutComplex;
                }
                draw_color  = ParseXMLColor(GetWinterCoatValue(ageInd, "color"));
                draw_color2 = ParseXMLColor(GetWinterCoatValue(ageInd, "color2"));

                draw_size *= float.Parse(GetWinterCoatValue(ageInd, "scale"));

                //Drawer.renderer.graphics.ClearCache();
                Drawer.renderer.graphics.nakedGraphic = GraphicDatabase.Get <Graphic_Multi> (winter_graphic, shader, draw_size, draw_color, draw_color2);
                skin_index = index;
                ReloadGraphicData();
                return(true);
            }

            // Use the default skin
            if (index == 0)
            {
                // Get default values
                if (ageTracker.CurKindLifeStage.bodyGraphicData != null)
                {
                    draw_color  = ageTracker.CurKindLifeStage.bodyGraphicData.color;
                    draw_color2 = ageTracker.CurKindLifeStage.bodyGraphicData.colorTwo;
                    if (this.gender == Gender.Female && ageTracker.CurKindLifeStage.femaleGraphicData != null)
                    {
                        draw_size   = ageTracker.CurKindLifeStage.femaleGraphicData.drawSize;
                        draw_color  = ageTracker.CurKindLifeStage.femaleGraphicData.color;
                        draw_color2 = ageTracker.CurKindLifeStage.bodyGraphicData.colorTwo;
                    }
                }
                // Get default shader type
                GraphicData gdata = ageTracker.CurKindLifeStage.bodyGraphicData;
                if (gender == Gender.Female && ageTracker.CurKindLifeStage.femaleGraphicData != null)
                {
                    gdata = ageTracker.CurKindLifeStage.femaleGraphicData;
                }
                if (gdata.shaderType == ShaderTypeDefOf.CutoutComplex)
                {
                    shader = ShaderDatabase.CutoutComplex;
                }


                //Drawer.renderer.graphics.ClearCache();
                Drawer.renderer.graphics.nakedGraphic = GraphicDatabase.Get <Graphic_Multi> (base_graphic_path, shader, draw_size, draw_color, draw_color2);
                ReloadGraphicData();
                skin_index = 0;
                return(true);
            }

            // Use a variant skin
            if (GetSkinNode(ageInd, index, female) != null && index != 0)
            {
                draw_color  = ParseXMLColor(GetSkinValue(ageInd, index, "color", female));
                draw_color2 = ParseXMLColor(GetSkinValue(ageInd, index, "color2", female));

                XmlNode skin_node = GetSkinNode(ageInd, index, female);
                foreach (XmlNode node in skin_node.ChildNodes)
                {
                    // Get colors
                    if (node.Name == "color" || node.Name == "colour")
                    {
                        draw_color = ParseXMLColor(node.InnerText);
                    }

                    if (node.Name == "color2" || node.Name == "colour2")
                    {
                        draw_color2 = ParseXMLColor(node.InnerText);
                    }
                }
            }

            if (GetSkinValue(ageInd, index, "useComplexShader", female) == "true")
            {
                shader = ShaderDatabase.CutoutComplex;
            }

            // Set the scale of the skin
            draw_size *= float.Parse(GetSkinValue(ageInd, index, "scale", female));

            // Set a new skin
            string texSetPath = base_graphic_path;

            if (GetSkinValue(ageInd, index, "texName", female) == null)
            {
                texSetPath = base_graphic_path;
            }
            else
            {
                texSetPath = texSetPath.Substring(0, texSetPath.LastIndexOf('/') + 1) + GetSkinValue(ageInd, index, "texName", female);
            }

            //Drawer.renderer.graphics.ClearCache();
            Graphic_Multi new_graphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi> (texSetPath, shader, draw_size, draw_color, draw_color2);

            Drawer.renderer.graphics.nakedGraphic = new_graphic;
            skin_index = index;
            ReloadGraphicData();
            return(true);
        }
Example #26
0
 public void ChangeTheGraphics()
 {
     if (this.Map != null)
     {
         if ((this.Position.GetTerrain(this.Map) == TerrainDef.Named("Ice")) || (this.Position.GetSnowDepth(this.Map) > 0) || (this.Map.mapTemperature.OutdoorTemp < -10f))
         {
             LongEventHandler.ExecuteWhenFinished(delegate
             {
                 Vector2 vector             = this.ageTracker.CurKindLifeStage.bodyGraphicData.drawSize;
                 Graphic_Multi nakedGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(this.ageTracker.CurKindLifeStage.bodyGraphicData.texPath + "Winter", ShaderDatabase.Cutout, vector, Color.white);
                 this.pawn_renderer.graphics.nakedGraphic = nakedGraphic;
                 (this.pawn_renderer.graphics.nakedGraphic.data = new GraphicData()).shadowData = this.ageTracker.CurKindLifeStage.bodyGraphicData.shadowData;
                 StatExtension.SetStatBaseValue(this.def, StatDefOf.ComfyTemperatureMin, -60f);
                 StatExtension.SetStatBaseValue(this.def, StatDefOf.ComfyTemperatureMax, 10f);
             });
             woolType = 1;
         }
         else if ((this.Position.GetTerrain(this.Map) == TerrainDef.Named("MossyTerrain")) || (this.Position.GetTerrain(this.Map) == TerrainDef.Named("MarshyTerrain")) || (this.Position.GetTerrain(this.Map) == TerrainDef.Named("SoilRich")) ||
                  (this.Position.GetTerrain(this.Map).IsWater))
         {
             LongEventHandler.ExecuteWhenFinished(delegate
             {
                 Vector2 vector             = this.ageTracker.CurKindLifeStage.bodyGraphicData.drawSize;
                 Graphic_Multi nakedGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(this.ageTracker.CurKindLifeStage.bodyGraphicData.texPath + "Jungle", ShaderDatabase.Cutout, vector, Color.white);
                 this.pawn_renderer.graphics.nakedGraphic = nakedGraphic;
                 (this.pawn_renderer.graphics.nakedGraphic.data = new GraphicData()).shadowData = this.ageTracker.CurKindLifeStage.bodyGraphicData.shadowData;
                 StatExtension.SetStatBaseValue(this.def, StatDefOf.ComfyTemperatureMin, -10f);
                 StatExtension.SetStatBaseValue(this.def, StatDefOf.ComfyTemperatureMax, 35f);
             });
             woolType = 2;
         }
         else if ((this.Position.GetTerrain(this.Map) == TerrainDef.Named("Sand")) || (this.Position.GetTerrain(this.Map) == TerrainDef.Named("SoftSand")))
         {
             LongEventHandler.ExecuteWhenFinished(delegate
             {
                 Vector2 vector             = this.ageTracker.CurKindLifeStage.bodyGraphicData.drawSize;
                 Graphic_Multi nakedGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(this.ageTracker.CurKindLifeStage.bodyGraphicData.texPath + "Desert", ShaderDatabase.Cutout, vector, Color.white);
                 this.pawn_renderer.graphics.nakedGraphic = nakedGraphic;
                 (this.pawn_renderer.graphics.nakedGraphic.data = new GraphicData()).shadowData = this.ageTracker.CurKindLifeStage.bodyGraphicData.shadowData;
                 StatExtension.SetStatBaseValue(this.def, StatDefOf.ComfyTemperatureMin, 0f);
                 StatExtension.SetStatBaseValue(this.def, StatDefOf.ComfyTemperatureMax, 65f);
             });
             woolType = 3;
         }
         else
         {
             LongEventHandler.ExecuteWhenFinished(delegate
             {
                 Vector2 vector             = this.ageTracker.CurKindLifeStage.bodyGraphicData.drawSize;
                 Graphic_Multi nakedGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(this.ageTracker.CurKindLifeStage.bodyGraphicData.texPath, ShaderDatabase.Cutout, vector, Color.white);
                 this.pawn_renderer.graphics.nakedGraphic = nakedGraphic;
                 (this.pawn_renderer.graphics.nakedGraphic.data = new GraphicData()).shadowData = this.ageTracker.CurKindLifeStage.bodyGraphicData.shadowData;
                 StatExtension.SetStatBaseValue(this.def, StatDefOf.ComfyTemperatureMin, -10f);
                 StatExtension.SetStatBaseValue(this.def, StatDefOf.ComfyTemperatureMax, 35f);
             });
             woolType = 0;
         }
     }
     else
     {
         StatExtension.SetStatBaseValue(this.def, StatDefOf.ComfyTemperatureMin, -60f);
         StatExtension.SetStatBaseValue(this.def, StatDefOf.ComfyTemperatureMax, 60f);
     }
 }
Example #27
0
        public void ChangeTheGraphics()
        {
            if (this.parent.Map != null && this.parent.Faction == Faction.OfPlayer && AnimalBehaviours_Settings.flagGraphicChanging)
            {
                bool styleFound = false;
                List <ThingStyleCategoryWithPriority> listStyles = Current.Game.World.factionManager.OfPlayer.ideos.PrimaryIdeo.thingStyleCategories;
                foreach (ThingStyleCategoryWithPriority listStyle in listStyles)
                {
                    if (listStyle.category == Props.style)
                    {
                        styleFound = true;
                    }
                }

                Pawn pawn = this.parent as Pawn;
                if (this.pawn_renderer == null)
                {
                    this.pawn_renderer = pawn.Drawer.renderer;
                }

                Vector2 vector = pawn.ageTracker.CurKindLifeStage.bodyGraphicData.drawSize;

                if (styleFound)
                {
                    LongEventHandler.ExecuteWhenFinished(delegate
                    {
                        if (this.pawn_renderer != null)
                        {
                            try
                            {
                                Graphic_Multi nakedGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(Props.newImagePath, ShaderDatabase.Cutout, vector, Color.white);
                                if (Props.changeDesiccatedGraphic)
                                {
                                    this.pawn_renderer.graphics.dessicatedGraphic = dessicatedGraphic;
                                }
                                this.pawn_renderer.graphics.ResolveAllGraphics();
                                this.pawn_renderer.graphics.nakedGraphic = nakedGraphic;
                                (this.pawn_renderer.graphics.nakedGraphic.data = new GraphicData()).shadowData = pawn.ageTracker.CurKindLifeStage.bodyGraphicData.shadowData;
                            }
                            catch (NullReferenceException) { }
                        }
                    });
                }
                else
                {
                    LongEventHandler.ExecuteWhenFinished(delegate
                    {
                        if (this.pawn_renderer != null)
                        {
                            try
                            {
                                Graphic nakedGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(pawn.ageTracker.CurKindLifeStage.bodyGraphicData.texPath, ShaderDatabase.Cutout, vector, Color.white);
                                if (Props.changeDesiccatedGraphic)
                                {
                                    this.pawn_renderer.graphics.dessicatedGraphic = pawn.ageTracker.CurKindLifeStage.dessicatedBodyGraphicData.Graphic;
                                }
                                this.pawn_renderer.graphics.ResolveAllGraphics();
                                this.pawn_renderer.graphics.nakedGraphic = nakedGraphic;
                                (this.pawn_renderer.graphics.nakedGraphic.data = new GraphicData()).shadowData = pawn.ageTracker.CurKindLifeStage.bodyGraphicData.shadowData;
                            }
                            catch (NullReferenceException) { }
                        }
                    });
                }
            }
        }
        public void ChangeTheGraphics()
        {
            string currentName = "";

            if (this.parent.Map != null && AnimalBehaviours_Settings.flagGraphicChanging)
            {
                Pawn pawn = this.parent as Pawn;
                if (this.pawn_renderer == null)
                {
                    Pawn_DrawTracker drawtracker = ((Pawn_DrawTracker)typeof(Pawn).GetField("drawer", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(pawn));
                    if (drawtracker != null)
                    {
                        this.pawn_renderer = drawtracker.renderer;
                    }
                }

                Vector2 vector = pawn.ageTracker.CurKindLifeStage.bodyGraphicData.drawSize;
                if (Props.waterOverride && this.parent.Position.GetTerrain(this.parent.Map).IsWater)
                {
                    currentName = "Water";
                    if (this.terrainName != currentName)
                    {
                        LongEventHandler.ExecuteWhenFinished(delegate
                        {
                            if (this.pawn_renderer != null)
                            {
                                try
                                {
                                    Graphic_Multi nakedGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(pawn.ageTracker.CurKindLifeStage.bodyGraphicData.texPath + Props.waterSuffix, ShaderDatabase.Cutout, vector, Color.white);
                                    this.pawn_renderer.graphics.dessicatedGraphic = dessicatedGraphic;
                                    this.pawn_renderer.graphics.ResolveAllGraphics();
                                    this.pawn_renderer.graphics.nakedGraphic = nakedGraphic;
                                    (this.pawn_renderer.graphics.nakedGraphic.data = new GraphicData()).shadowData = pawn.ageTracker.CurKindLifeStage.bodyGraphicData.shadowData;
                                    this.terrainName = pawn.Position.GetTerrain(pawn.Map).defName;
                                    RemoveHediffs(pawn);
                                    if (Props.waterHediffToApply != "")
                                    {
                                        pawn.health.AddHediff(DefDatabase <HediffDef> .GetNamed(Props.waterHediffToApply));
                                    }
                                    if (Props.provideSeasonalItems && animalProductComp != null)
                                    {
                                        animalProductComp.seasonalItemIndex = Props.waterSeasonalItemsIndex;
                                    }
                                }
                                catch (NullReferenceException) { }
                            }
                        });
                    }
                }
                else
                if (Props.lowTemperatureOverride && this.parent.Map.mapTemperature.OutdoorTemp < Props.temperatureThreshold)
                {
                    currentName = "Cold";
                    if (this.terrainName != currentName)
                    {
                        LongEventHandler.ExecuteWhenFinished(delegate
                        {
                            if (this.pawn_renderer != null)
                            {
                                try
                                {
                                    Graphic_Multi nakedGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(pawn.ageTracker.CurKindLifeStage.bodyGraphicData.texPath + Props.lowTemperatureSuffix, ShaderDatabase.Cutout, vector, Color.white);
                                    this.pawn_renderer.graphics.dessicatedGraphic = dessicatedGraphic;
                                    this.pawn_renderer.graphics.ResolveAllGraphics();
                                    this.pawn_renderer.graphics.nakedGraphic = nakedGraphic;
                                    (this.pawn_renderer.graphics.nakedGraphic.data = new GraphicData()).shadowData = pawn.ageTracker.CurKindLifeStage.bodyGraphicData.shadowData;
                                    this.terrainName = pawn.Position.GetTerrain(pawn.Map).defName;
                                    RemoveHediffs(pawn);
                                    if (Props.lowTemperatureHediffToApply != "")
                                    {
                                        pawn.health.AddHediff(DefDatabase <HediffDef> .GetNamed(Props.lowTemperatureHediffToApply));
                                    }
                                    if (Props.provideSeasonalItems && animalProductComp != null)
                                    {
                                        animalProductComp.seasonalItemIndex = Props.lowTemperatureSeasonalItemsIndex;
                                    }
                                }
                                catch (NullReferenceException) { }
                            }
                        });
                    }
                }
                else if (Props.snowOverride && this.parent.Position.GetSnowDepth(this.parent.Map) > 0)
                {
                    currentName = "Snowy";
                    if (this.terrainName != currentName)
                    {
                        LongEventHandler.ExecuteWhenFinished(delegate
                        {
                            if (this.pawn_renderer != null)
                            {
                                try
                                {
                                    Graphic_Multi nakedGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(pawn.ageTracker.CurKindLifeStage.bodyGraphicData.texPath + Props.snowySuffix, ShaderDatabase.Cutout, vector, Color.white);
                                    this.pawn_renderer.graphics.dessicatedGraphic = dessicatedGraphic;
                                    this.pawn_renderer.graphics.ResolveAllGraphics();
                                    this.pawn_renderer.graphics.nakedGraphic = nakedGraphic;
                                    (this.pawn_renderer.graphics.nakedGraphic.data = new GraphicData()).shadowData = pawn.ageTracker.CurKindLifeStage.bodyGraphicData.shadowData;
                                    this.terrainName = pawn.Position.GetTerrain(pawn.Map).defName;
                                    RemoveHediffs(pawn);
                                    if (Props.snowyHediffToApply != "")
                                    {
                                        pawn.health.AddHediff(DefDatabase <HediffDef> .GetNamed(Props.snowyHediffToApply));
                                    }
                                    if (Props.provideSeasonalItems && animalProductComp != null)
                                    {
                                        animalProductComp.seasonalItemIndex = Props.snowySeasonalItemsIndex;
                                    }
                                }
                                catch (NullReferenceException) { }
                            }
                        });
                    }
                }
                else



                if (Props.terrains.Contains(pawn.Position.GetTerrain(pawn.Map).defName))
                {
                    int indexTerrain = Props.terrains.IndexOf(pawn.Position.GetTerrain(pawn.Map).defName);

                    currentName = pawn.Position.GetTerrain(pawn.Map).defName;
                    if (this.terrainName != currentName)
                    {
                        LongEventHandler.ExecuteWhenFinished(delegate
                        {
                            if (this.pawn_renderer != null)
                            {
                                try
                                {
                                    Graphic_Multi nakedGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(pawn.ageTracker.CurKindLifeStage.bodyGraphicData.texPath + Props.suffix[indexTerrain], ShaderDatabase.Cutout, vector, Color.white);
                                    this.pawn_renderer.graphics.dessicatedGraphic = dessicatedGraphic;
                                    this.pawn_renderer.graphics.ResolveAllGraphics();
                                    this.pawn_renderer.graphics.nakedGraphic = nakedGraphic;
                                    (this.pawn_renderer.graphics.nakedGraphic.data = new GraphicData()).shadowData = pawn.ageTracker.CurKindLifeStage.bodyGraphicData.shadowData;
                                    this.terrainName = pawn.Position.GetTerrain(pawn.Map).defName;
                                    RemoveHediffs(pawn);
                                    if (Props.hediffToApply != null)
                                    {
                                        pawn.health.AddHediff(DefDatabase <HediffDef> .GetNamed(Props.hediffToApply[indexTerrain]));
                                    }
                                    if (Props.provideSeasonalItems && animalProductComp != null)
                                    {
                                        animalProductComp.seasonalItemIndex = Props.seasonalItemsIndexes[indexTerrain];
                                    }
                                }
                                catch (NullReferenceException) { }
                            }
                        });
                    }
                }
                else
                {
                    currentName = "Normal";
                    if (this.terrainName != currentName)
                    {
                        LongEventHandler.ExecuteWhenFinished(delegate
                        {
                            if (this.pawn_renderer != null)
                            {
                                try
                                {
                                    Graphic_Multi nakedGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(pawn.ageTracker.CurKindLifeStage.bodyGraphicData.texPath, ShaderDatabase.Cutout, vector, Color.white);
                                    this.pawn_renderer.graphics.nakedGraphic      = nakedGraphic;
                                    this.pawn_renderer.graphics.dessicatedGraphic = dessicatedGraphic;
                                    this.pawn_renderer.graphics.ResolveAllGraphics();
                                    (this.pawn_renderer.graphics.nakedGraphic.data = new GraphicData()).shadowData = pawn.ageTracker.CurKindLifeStage.bodyGraphicData.shadowData;
                                    this.terrainName = "Normal";
                                    RemoveHediffs(pawn);
                                    if (Props.provideSeasonalItems && animalProductComp != null)
                                    {
                                        animalProductComp.seasonalItemIndex = 0;
                                    }
                                }
                                catch (NullReferenceException) { }
                            }
                        });
                    }
                }
            }
        }
Example #29
0
        public bool ApplyNewSkin(int index)
        {
            string text = this.male_graphic;
            bool   flag = false;

            if (this.gender == Gender.Female && this.female_graphic != null)
            {
                flag = true;
                text = this.female_graphic;
            }
            this.TryLoadSkinSet();
            bool result;

            if (index > this.num_skins(this.ageTracker.CurLifeStageIndex, flag))
            {
                Log.Error("Error in " + AnimalMultiSkins.assembly_name + ": AnimalVaried.ApplyNewSkin tried to set skin index out of available range for " + this.def.defName);
                result = false;
            }
            else
            {
                Vector2 vector            = this.ageTracker.CurKindLifeStage.bodyGraphicData.drawSize;
                Color   color             = Color.white;
                Color   color2            = Color.white;
                Shader  shader            = ShaderDatabase.Cutout;
                int     curLifeStageIndex = this.ageTracker.CurLifeStageIndex;
                if ((this.winter_coat_timer == 50 || this.winterized) && this.UsesWinterCoat(this.ageTracker.CurLifeStageIndex))
                {
                    string text2 = text;
                    if (!flag)
                    {
                        if (this.GetWinterCoatValue(curLifeStageIndex, "texName") != null)
                        {
                            text2 = text.Substring(0, text.LastIndexOf('/') + 1) + this.GetWinterCoatValue(curLifeStageIndex, "texName");
                        }
                        else if (this.DoesTexSetExist(text + "_winter"))
                        {
                            text2 = text + "_winter";
                        }
                    }
                    else if (this.GetWinterCoatValue(curLifeStageIndex, "texNameFemale") != null)
                    {
                        text2 = text.Substring(0, text.LastIndexOf('/') + 1) + this.GetWinterCoatValue(curLifeStageIndex, "texNameFemale");
                    }
                    else if (this.DoesTexSetExist(text + "_winter"))
                    {
                        text2 = text + "_winter";
                    }
                    if (bool.Parse(this.GetWinterCoatValue(curLifeStageIndex, "useComplexShader")))
                    {
                        shader = ShaderDatabase.CutoutComplex;
                    }
                    color   = AnimalMultiSkins.ParseXMLColor(this.GetWinterCoatValue(curLifeStageIndex, "color"));
                    color2  = AnimalMultiSkins.ParseXMLColor(this.GetWinterCoatValue(curLifeStageIndex, "color2"));
                    vector *= float.Parse(this.GetWinterCoatValue(curLifeStageIndex, "scale"));
                    this.pawn_renderer.graphics.ClearCache();
                    this.pawn_renderer.graphics.nakedGraphic = GraphicDatabase.Get <Graphic_Multi>(text2, shader, vector, color, color2);
                    this.skin_index = index;
                    result          = true;
                }
                else if (index == 0)
                {
                    if (this.ageTracker.CurKindLifeStage.bodyGraphicData != null)
                    {
                        color  = this.ageTracker.CurKindLifeStage.bodyGraphicData.color;
                        color2 = this.ageTracker.CurKindLifeStage.bodyGraphicData.colorTwo;
                        if (this.gender == Gender.Female && this.ageTracker.CurKindLifeStage.femaleGraphicData != null)
                        {
                            vector = this.ageTracker.CurKindLifeStage.femaleGraphicData.drawSize;
                            color  = this.ageTracker.CurKindLifeStage.femaleGraphicData.color;
                            color2 = this.ageTracker.CurKindLifeStage.bodyGraphicData.colorTwo;
                        }
                    }
                    GraphicData graphicData = this.ageTracker.CurKindLifeStage.bodyGraphicData;
                    if (this.gender == Gender.Female && this.ageTracker.CurKindLifeStage.femaleGraphicData != null)
                    {
                        graphicData = this.ageTracker.CurKindLifeStage.femaleGraphicData;
                    }
                    if (graphicData.shaderType == ShaderType.CutoutComplex)
                    {
                        shader = ShaderDatabase.CutoutComplex;
                    }
                    this.pawn_renderer.graphics.ClearCache();
                    this.pawn_renderer.graphics.nakedGraphic = GraphicDatabase.Get <Graphic_Multi>(text, shader, vector, color, color2);
                    this.skin_index = 0;
                    result          = true;
                }
                else
                {
                    if (this.GetSkinNode(curLifeStageIndex, index, flag) != null && index != 0)
                    {
                        color  = AnimalMultiSkins.ParseXMLColor(this.GetSkinValue(curLifeStageIndex, index, "color", flag));
                        color2 = AnimalMultiSkins.ParseXMLColor(this.GetSkinValue(curLifeStageIndex, index, "color2", flag));
                        XmlNode     skinNode   = this.GetSkinNode(curLifeStageIndex, index, flag);
                        IEnumerator enumerator = skinNode.ChildNodes.GetEnumerator();
                        try
                        {
                            while (enumerator.MoveNext())
                            {
                                XmlNode xmlNode = (XmlNode)enumerator.Current;
                                if (xmlNode.Name == "color" || xmlNode.Name == "colour")
                                {
                                    color = AnimalMultiSkins.ParseXMLColor(xmlNode.InnerText);
                                }
                                if (xmlNode.Name == "color2" || xmlNode.Name == "colour2")
                                {
                                    color2 = AnimalMultiSkins.ParseXMLColor(xmlNode.InnerText);
                                }
                            }
                        }
                        finally
                        {
                            IDisposable disposable;
                            if ((disposable = (enumerator as IDisposable)) != null)
                            {
                                disposable.Dispose();
                            }
                        }
                    }
                    if (this.GetSkinValue(curLifeStageIndex, index, "useComplexShader", flag) == "true")
                    {
                        shader = ShaderDatabase.CutoutComplex;
                    }
                    vector *= float.Parse(this.GetSkinValue(curLifeStageIndex, index, "scale", flag));
                    string text3 = text;
                    if (this.GetSkinValue(curLifeStageIndex, index, "texName", flag) == null)
                    {
                        text3 = text;
                    }
                    else
                    {
                        text3 = text3.Substring(0, text3.LastIndexOf('/') + 1) + this.GetSkinValue(curLifeStageIndex, index, "texName", flag);
                    }
                    this.pawn_renderer.graphics.ClearCache();
                    Graphic_Multi nakedGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(text3, shader, vector, color, color2);
                    this.pawn_renderer.graphics.nakedGraphic = nakedGraphic;
                    this.skin_index = index;
                    result          = true;
                }
            }
            return(result);
        }