示例#1
0
 public new void ResolveAllGraphics()
 {
     this.ClearCache();
     if (this.pawn.RaceProps.Humanlike)
     {
         this.nakedGraphic          = new Graphic_Invisible();
         this.rottingGraphic        = new Graphic_Invisible();
         this.dessicatedGraphic     = new Graphic_Invisible();
         this.headGraphic           = null;
         this.desiccatedHeadGraphic = new Graphic_Invisible();
         this.skullGraphic          = new Graphic_Invisible();
         this.hairGraphic           = new Graphic_Invisible();
         this.ResolveApparelGraphics();
     }
     else
     {
         PawnKindLifeStage curKindLifeStage = this.pawn.ageTracker.CurKindLifeStage;
         this.nakedGraphic   = new Graphic_Invisible();
         this.rottingGraphic = new Graphic_Invisible();
         if (this.pawn.RaceProps.packAnimal)
         {
             this.packGraphic = new Graphic_Invisible();
         }
         if (curKindLifeStage.dessicatedBodyGraphicData != null)
         {
             this.dessicatedGraphic = new Graphic_Invisible();
         }
     }
 }
示例#2
0
        public override void MapLoaded(Map map)
        {
            base.MapLoaded(map);
            if (cancelControlMechTextures.Count == 0)
            {
                Texture2D cancelTex = ContentFinder <Texture2D> .Get(("UI/Cancel")).GetReadableTexture();

                List <ThingDef> allMechs = (from td in DefDatabase <ThingDef> .AllDefs where td.race != null && td.race.IsMechanoid select td).ToList();
                foreach (ThingDef mechDef in allMechs)
                {
                    if (mechDef.GetConcreteExample() is Pawn mech)
                    {
                        PawnKindLifeStage curKindLifeStage = mech.ageTracker.CurKindLifeStage;
                        Texture2D         mechTex          = curKindLifeStage.bodyGraphicData.Graphic.MatSouth.mainTexture as Texture2D;
                        cancelControlMechTextures.Add(mech.def.defName, mechTex.GetReadableTexture().AddWatermark(cancelTex));
                    }
                }
            }
            if (cancelControlTurretTextures.Count == 0)
            {
                Texture2D cancelTex = ContentFinder <Texture2D> .Get(("UI/Cancel")).GetReadableTexture();

                List <ThingDef> allTurrets = (from td in DefDatabase <ThingDef> .AllDefs where td.thingClass == typeof(Building_TurretGun) select td).ToList();
                foreach (ThingDef turretDef in allTurrets)
                {
                    cancelControlTurretTextures.Add(turretDef.defName, turretDef.uiIcon.GetReadableTexture().AddWatermark(cancelTex));
                }
            }
        }
示例#3
0
 internal static void _ResolveAllGraphics(this PawnGraphicSet _this)
 {
     _this.ClearCache();
     if (_this.pawn.RaceProps.Humanlike)
     {
         ResolveAgeGraphics(_this);
         _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
        public void ResolveBaseGraphic()
        {
            if (this.Props.cycledGraphic != null &&
                Lumberer.Drawer?.renderer?.graphics is PawnGraphicSet pawnGraphicSet)
            {
                pawnGraphicSet.ClearCache();

                //Duplicated code from -> Verse.PawnGrapic -> ResolveAllGraphics
                PawnKindLifeStage curKindLifeStage = this.Lumberer.ageTracker.CurKindLifeStage;
                if (this.Lumberer.gender != Gender.Female || curKindLifeStage.femaleGraphicData == null)
                {
                    pawnGraphicSet.nakedGraphic = curKindLifeStage.bodyGraphicData.Graphic;
                }
                else
                {
                    pawnGraphicSet.nakedGraphic = curKindLifeStage.femaleGraphicData.Graphic;
                }
                pawnGraphicSet.rottingGraphic = pawnGraphicSet.nakedGraphic.GetColoredVersion(ShaderDatabase.CutoutSkin, PawnGraphicSet.RottingColor, PawnGraphicSet.RottingColor);
                if (this.Lumberer.RaceProps.packAnimal)
                {
                    pawnGraphicSet.packGraphic = GraphicDatabase.Get <Graphic_Multi>(pawnGraphicSet.nakedGraphic.path + "Pack", ShaderDatabase.Cutout, pawnGraphicSet.nakedGraphic.drawSize, Color.white);
                }
                if (curKindLifeStage.dessicatedBodyGraphicData != null)
                {
                    pawnGraphicSet.dessicatedGraphic = curKindLifeStage.dessicatedBodyGraphicData.GraphicColoredFor(this.Lumberer);
                }
            }
        }
示例#5
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);
         }
     }
 }
示例#6
0
        public static Vector2 ForPawn(Pawn pawn)
        {
            if (pawn.RaceProps.Humanlike)
            {
                PawnRenderer   renderer   = pawn.Drawer.renderer;
                PawnGraphicSet graphicSet = renderer.graphics;

                if (!graphicSet.AllResolved)
                {
                    graphicSet.ResolveAllGraphics();
                }

                if (pawn.IsDessicated() && graphicSet.dessicatedGraphic != null)
                {
                    return(BoundMap(
                               graphicSet.dessicatedGraphic,
                               GraphicType.Pawn,
                               graphicSet.desiccatedHeadGraphic,
                               new Vector2(renderer.BaseHeadOffsetAt(Rot4.South).x,
                                           renderer.BaseHeadOffsetAt(Rot4.East).z)));
                }

                return(BoundMap(
                           graphicSet.nakedGraphic,
                           GraphicType.Pawn,
                           graphicSet.headGraphic,
                           new Vector2(renderer.BaseHeadOffsetAt(Rot4.South).x,
                                       renderer.BaseHeadOffsetAt(Rot4.East).z)));
            }
            else
            {
                PawnKindLifeStage lifeStage = pawn.ageTracker.CurKindLifeStage;

                GraphicData graphicData;

                if (pawn.IsDessicated() && lifeStage.dessicatedBodyGraphicData != null)
                {
                    graphicData = lifeStage.dessicatedBodyGraphicData;
                }
                else if (pawn.gender == Gender.Female && lifeStage.femaleGraphicData != null)
                {
                    graphicData = lifeStage.femaleGraphicData;
                }
                else
                {
                    graphicData = lifeStage.bodyGraphicData;
                }

                return(Vector2.Scale(BoundMap(graphicData.Graphic, GraphicType.Pawn), graphicData.drawSize));
            }
        }
示例#7
0
        public static void setDrawOffset(ExtendedPawnData pawnData)
        {
            PawnKindLifeStage curKindLifeStage = pawnData.mount.ageTracker.CurKindLifeStage;
            Texture2D unreadableTexture = curKindLifeStage.bodyGraphicData.Graphic.MatSide.mainTexture as Texture2D;
            Texture2D t = TextureUtility.getReadableTexture(unreadableTexture);
            int backHeight = TextureUtility.getBackHeight(t);
            float backHeightRelative = (float)backHeight / (float)t.height;

            float textureHeight = curKindLifeStage.bodyGraphicData.drawSize.y;
            //If animal texture does not fit in a tile, take this into account
            float extraOffset = textureHeight > 1f ? (textureHeight - 1f) / 2f : 0;
            //Small extra offset, you don't want to draw pawn exactly on back
            extraOffset += (float)textureHeight / 20f;
            pawnData.drawOffset = (textureHeight * backHeightRelative - extraOffset);
        }
示例#8
0
        private void SetDrawOffset()
        {
            PawnKindLifeStage curKindLifeStage  = mountedTo.ageTracker.CurKindLifeStage;
            Texture2D         unreadableTexture = curKindLifeStage.bodyGraphicData.Graphic.MatEast.mainTexture as Texture2D;
            Texture2D         t      = unreadableTexture.GetReadableTexture();
            int   backHeight         = GetBackHeight(t);
            float backHeightRelative = (float)backHeight / (float)t.height;
            float textureHeight      = curKindLifeStage.bodyGraphicData.drawSize.y;
            //If animal texture does not fit in a tile, take this into account
            float extraOffset = textureHeight > 1f ? (textureHeight - 1f) / 2f : 0;

            //Small extra offset, you don't want to draw pawn exactly on back
            extraOffset += 0.5f;
            drawOffset   = (textureHeight * backHeightRelative - extraOffset);
        }
示例#9
0
        public static List <PawnKindLifeStage> PawnKindLifeStages(IEnumerable <PawnKindLifeStage> stages, float sizeMultiplier)
        {
            List <PawnKindLifeStage> ret = new List <PawnKindLifeStage>();

            foreach (PawnKindLifeStage stage in stages)
            {
                PawnKindLifeStage pawnKindLifeStage = new PawnKindLifeStage();
                foreach (FieldInfo field in stage.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance))
                {
                    field.SetValue(pawnKindLifeStage, field.GetValue(stage));
                }
                //make it even bigger
                pawnKindLifeStage.bodyGraphicData.drawSize *= sizeMultiplier;
                //set the dessicated graphic to the largest available
                pawnKindLifeStage.dessicatedBodyGraphicData.texPath = "Things/Pawn/Animal/Dessicated/CritterDessicatedMedium";
                //make it bigger
                pawnKindLifeStage.dessicatedBodyGraphicData.drawSize *= sizeMultiplier;
                ret.Add(pawnKindLifeStage);
            }
            return(ret);
        }
示例#10
0
        private static bool PawnGraphicSet_ResolveAllGraphics_prefix(PawnGraphicSet __instance)
        {
            if (__instance.pawn.RaceProps.Animal)
            {
                Pawn pawn = __instance.pawn;
                PawnKindLifeStage curKindLifeStage = __instance.pawn.ageTracker.CurKindLifeStage;

                Graphic baseGraphic = pawn.gender != Gender.Female || curKindLifeStage.femaleGraphicData == null ? curKindLifeStage.bodyGraphicData.Graphic : curKindLifeStage.femaleGraphicData.Graphic;
                Color color = baseGraphic.color;
                Color ColorTwo = baseGraphic.colorTwo;
                Shader shader = ShaderDatabase.Cutout;

                if (__instance.pawn.ageTracker.CurKindLifeStage.bodyGraphicData.graphicClass == typeof(Graphic_MultiRandom))
                {
                    int TextureCountTotal = TextureCount(baseGraphic.path);
                    if (TextureCountTotal > 0)
                    {
                        int textureIndex = (new System.Random(pawn.thingIDNumber * 2)).Next() % TextureCountTotal;
                        string safeTextureIndex = (1 + textureIndex).ToString();

                        __instance.ClearCache();

                        if (curKindLifeStage.dessicatedBodyGraphicData is GraphicData dessicated)
                        {
                            __instance.dessicatedGraphic = dessicated.GraphicColoredFor(__instance.pawn);
                        }

                        __instance.nakedGraphic = (new Graphic_MultiRandom(baseGraphic)).GetColoredVersion(ShaderDatabase.ShaderFromType(shader), color, safeTextureIndex);
                        return false;

                    }
                }
                return true;
            }
            return true;
        }
示例#11
0
        private void InitializeGraphicsFrontPaws()
        {
            if (!this.CompAni.Props.quadruped)
            {
                return;
            }
            string texNameFoot = "Paws/" + this.CompAni.Props.handType + STR_Foot;

            Color skinColor;

            if (this._pawn.story != null)
            {
                skinColor = this._pawn.story.SkinColor;
            }
            else
            {
                PawnKindLifeStage curKindLifeStage = this._pawn.ageTracker.CurKindLifeStage;

                skinColor = curKindLifeStage.bodyGraphicData.color;
            }

            Color rightColorFoot = Color.cyan;
            Color leftColorFoot  = Color.magenta;

            Color rightFootColor = skinColor;
            Color leftFootColor  = skinColor;
            Color metal          = new Color(0.51f, 0.61f, 0.66f);

            switch (this.CompAni.BodyStat.FootRight)
            {
            case PartStatus.Artificial:
                rightFootColor = metal;
                break;
            }

            switch (this.CompAni.BodyStat.FootLeft)
            {
            case PartStatus.Artificial:
                leftFootColor = metal;
                break;
            }

            Color rightFootColorShadow = rightFootColor * this._shadowColor;
            Color leftFootColorShadow  = leftFootColor * this._shadowColor;

            this.FrontPawGraphicRight = GraphicDatabase.Get <Graphic_Multi_Four>(
                texNameFoot,
                ShaderDatabase.CutoutSkin,
                new Vector2(1f, 1f),
                rightFootColor,
                skinColor);

            this.FrontPawGraphicLeft = GraphicDatabase.Get <Graphic_Multi_Four>(
                texNameFoot,
                ShaderDatabase.CutoutSkin,
                new Vector2(1f, 1f),
                leftFootColor,
                skinColor);

            this.FrontPawGraphicRightShadow = GraphicDatabase.Get <Graphic_Multi_Four>(
                texNameFoot,
                ShaderDatabase.CutoutSkin,
                new Vector2(1f, 1f),
                rightFootColorShadow,
                skinColor);

            this.FrontPawGraphicLeftShadow = GraphicDatabase.Get <Graphic_Multi_Four>(
                texNameFoot,
                ShaderDatabase.CutoutSkin,
                new Vector2(1f, 1f),
                leftFootColorShadow,
                skinColor);

            this.FrontPawGraphicRightCol = GraphicDatabase.Get <Graphic_Multi_Four>(
                texNameFoot,
                ShaderDatabase.CutoutSkin,
                new Vector2(1f, 1f),
                rightColorFoot,
                skinColor);

            this.FrontPawGraphicLeftCol = GraphicDatabase.Get <Graphic_Multi_Four>(
                texNameFoot,
                ShaderDatabase.CutoutSkin,
                new Vector2(1f, 1f),
                leftColorFoot,
                skinColor);
        }
示例#12
0
        protected override void FillTab()
        {
            Rect rect  = new Rect(0f, TopPadding, size.x, size.y - TopPadding);
            Rect rect2 = rect.ContractedBy(10f);

            GUI.BeginGroup(rect2);
            Text.Font = GameFont.Small;
            GUI.color = Color.white;
            float num = 0f;

            UpgradeNode additionalStatNode    = null;
            UpgradeNode highlightedPreMetNode = null;

            Rect upgradeButtonRect = new Rect(screenWidth - BottomDisplayedOffset - 80f, BottomWindowEdge - 30f, 75, 25f);
            Rect displayRect       = new Rect(Comp.Props.displayUICoord.x, Comp.Props.displayUICoord.y, Comp.Props.displayUISize.x, Comp.Props.displayUISize.y);

            if (RimShipMod.mod.settings.debugDrawNodeGrid)
            {
                DrawBackgroundGrid();
            }
            if (Prefs.DevMode)
            {
                var font = Text.Font;
                Text.Font = GameFont.Tiny;
                Rect screenInfo = new Rect(LeftWindowEdge + 5f, GridSpacing.y + 3f, screenWidth - LeftWindowEdge - 10f, 50f);
                Widgets.Label(screenInfo, $"Screen Size: ({this.size.x},{this.size.y}) \nBottomEdge: {BottomWindowEdge}px \nLeftWindowEdge: {LeftWindowEdge}px");
                Text.Font = font;
            }

            if (selectedNode != null)
            {
                float imageWidth   = TotalIconSizeScalar / selectedNode.UpgradeImage.width;
                float imageHeight  = TotalIconSizeScalar / selectedNode.UpgradeImage.height;
                Rect  selectedRect = new Rect(GridOrigin.x + (GridSpacing.x * selectedNode.GridCoordinate.x) - (imageWidth / 2), GridOrigin.y + (GridSpacing.y * selectedNode.GridCoordinate.z) - (imageHeight / 2) + (TopPadding * 2), imageWidth, imageHeight);
                selectedRect.ContractedBy(3f);
                GUI.DrawTexture(selectedRect, BaseContent.WhiteTex);
            }

            if (Widgets.ButtonText(upgradeButtonRect, "Upgrade".Translate()) && selectedNode != null && !selectedNode.upgradeActive)
            {
                if (Comp.Disabled(selectedNode))
                {
                    Messages.Message("DisabledFromOtherNode".Translate(), MessageTypeDefOf.RejectInput, false);
                }
                else if (Comp.PrerequisitesMet(selectedNode))
                {
                    SoundDefOf.ExecuteTrade.PlayOneShotOnCamera(SelPawnUpgrade.Map);
                    SoundDefOf.Building_Complete.PlayOneShot(SelPawnUpgrade);

                    Comp.StartUnlock(selectedNode);
                    selectedNode.upgradePurchased = true;
                    selectedNode = null;
                }
                else
                {
                    Messages.Message("MissingPrerequisiteUpgrade".Translate(), MessageTypeDefOf.RejectInput, false);
                }
            }

            foreach (UpgradeNode upgradeNode in Comp.upgradeList)
            {
                if (upgradeNode.prerequisiteNodes?.Any() ?? false)
                {
                    foreach (UpgradeNode prerequisite in Comp.upgradeList.FindAll(x => upgradeNode.prerequisiteNodes.Contains(x.upgradeID)))
                    {
                        Vector2 start = new Vector2(GridOrigin.x + (GridSpacing.x * prerequisite.GridCoordinate.x), GridOrigin.y + (GridSpacing.y * prerequisite.GridCoordinate.z) + (TopPadding * 2));
                        Vector2 end   = new Vector2(GridOrigin.x + (GridSpacing.x * upgradeNode.GridCoordinate.x), GridOrigin.y + (GridSpacing.y * upgradeNode.GridCoordinate.z) + (TopPadding * 2));
                        Color   color = Color.grey;
                        if (upgradeNode.upgradeActive)
                        {
                            color = Color.white;
                        }
                        else if (!string.IsNullOrEmpty(upgradeNode.disableIfUpgradeNodeEnabled))
                        {
                            try
                            {
                                UpgradeNode preUpgrade     = Comp.upgradeList.First(x => x.upgradeID == upgradeNode.disableIfUpgradeNodeEnabled);
                                float       imageWidth     = TotalIconSizeScalar / preUpgrade.UpgradeImage.width;
                                float       imageHeight    = TotalIconSizeScalar / preUpgrade.UpgradeImage.height;
                                Rect        preUpgradeRect = new Rect(GridOrigin.x + (GridSpacing.x * preUpgrade.GridCoordinate.x) - (imageWidth / 2), GridOrigin.y + (GridSpacing.y * preUpgrade.GridCoordinate.z) - (imageHeight / 2) + (TopPadding * 2), imageWidth, imageHeight);
                                if (preUpgrade.upgradePurchased)
                                {
                                    color = Color.black;
                                }
                                else if (Mouse.IsOver(preUpgradeRect))
                                {
                                    color = Color.red;
                                }
                            }
                            catch
                            {
                                Log.Error($"Unable to find UpgradeNode {upgradeNode.disableIfUpgradeNodeEnabled} on iteration. Are you referencing the proper upgradeID?");
                            }
                        }
                        Widgets.DrawLine(start, end, color, 2f);
                    }
                }
            }
            bool preDrawingDescriptions = false;

            for (int i = 0; i < Comp.upgradeList.Count; i++)
            {
                UpgradeNode upgradeNode = Comp.upgradeList[i];
                float       imageWidth  = TotalIconSizeScalar / upgradeNode.UpgradeImage.width;
                float       imageHeight = TotalIconSizeScalar / upgradeNode.UpgradeImage.height;

                Rect upgradeRect = new Rect(GridOrigin.x + (GridSpacing.x * upgradeNode.GridCoordinate.x) - (imageWidth / 2), GridOrigin.y + (GridSpacing.y * upgradeNode.GridCoordinate.z) - (imageHeight / 2) + (TopPadding * 2), imageWidth, imageHeight);
                Widgets.DrawTextureFitted(upgradeRect, upgradeNode.UpgradeImage, 1);

                if (!upgradeNode.prerequisiteNodes.Any())
                {
                    if (!string.IsNullOrEmpty(upgradeNode.rootNodeLabel))
                    {
                        Rect nodeLabelRect = new Rect(upgradeRect.x, upgradeRect.y - 20f, 10f * upgradeNode.rootNodeLabel.Count(), 25f);
                        Widgets.Label(nodeLabelRect, upgradeNode.rootNodeLabel);
                    }
                }
                Rect buttonRect = new Rect(GridOrigin.x + (GridSpacing.x * upgradeNode.GridCoordinate.x) - (imageWidth / 2), GridOrigin.y + (GridSpacing.y * upgradeNode.GridCoordinate.z) - (imageHeight / 2) + (TopPadding * 2), imageWidth, imageHeight);

                Rect     infoLabelRect = new Rect(5f, BottomWindowEdge, LeftWindowEdge, 150f);
                GUIStyle infoLabelFont = new GUIStyle(Text.CurFontStyle);
                infoLabelFont.fontStyle = FontStyle.Bold;

                if (Mouse.IsOver(upgradeRect))
                {
                    preDrawingDescriptions = true;

                    if (!upgradeNode.upgradePurchased)
                    {
                        additionalStatNode    = upgradeNode;
                        highlightedPreMetNode = upgradeNode;
                    }
                    HelperMethods.LabelStyled(infoLabelRect, upgradeNode.label, infoLabelFont);

                    Widgets.Label(new Rect(infoLabelRect.x, infoLabelRect.y + 20f, infoLabelRect.width, 140f), upgradeNode.informationHighlighted);
                }

                if ((Mouse.IsOver(upgradeRect) || upgradeNode.upgradePurchased) && Comp.PrerequisitesMet(upgradeNode))
                {
                    GUI.DrawTexture(upgradeRect, TexUI.HighlightTex);
                }

                if (!upgradeNode.upgradePurchased && Comp.PrerequisitesMet(upgradeNode))
                {
                    if (Widgets.ButtonInvisible(buttonRect, true))
                    {
                        if (selectedNode != upgradeNode)
                        {
                            selectedNode = upgradeNode;
                            SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera();
                        }
                        else
                        {
                            selectedNode = null;
                            SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera();
                        }
                    }
                }
            }
            Rect     selectedLabelRect = new Rect(5f, BottomWindowEdge, LeftWindowEdge, 150f);
            GUIStyle selectedLabelFont = new GUIStyle(Text.CurFontStyle);

            selectedLabelFont.fontStyle = FontStyle.Bold;

            if (selectedNode != null && !preDrawingDescriptions)
            {
                if (!selectedNode.upgradePurchased)
                {
                    additionalStatNode = selectedNode;
                }

                HelperMethods.LabelStyled(selectedLabelRect, selectedNode.label, selectedLabelFont);

                Widgets.Label(new Rect(selectedLabelRect.x, selectedLabelRect.y + 20f, selectedLabelRect.width, 140f), selectedNode.informationHighlighted);
            }

            Rect labelRect = new Rect(0f, 0f, rect2.width - 16f, 20f);

            num += labelRect.height;
            if (!RimShipMod.mod.settings.debugDrawNodeGrid)
            {
                Widgets.Label(labelRect, SelPawnUpgrade.Label);
            }

            Color lineColor = GUI.color;

            GUI.color = new Color(0.3f, 0.3f, 0.3f, 1f);

            Widgets.DrawLineHorizontal(0, num, screenWidth);
            Widgets.DrawLineHorizontal(0, BottomWindowEdge, screenWidth);
            Widgets.DrawLineHorizontal(0, screenHeight - SideDisplayedOffset - 1f, screenWidth);

            Widgets.DrawLineVertical(0, num, screenHeight);
            Widgets.DrawLineVertical(screenWidth - BottomDisplayedOffset - 1f, num, screenHeight);

            if (RimShipMod.mod.settings.drawUpgradeInformationScreen)
            {
                Widgets.DrawLineVertical(LeftWindowEdge, num, screenHeight);
            }
            GUI.color = lineColor;

            if (RimShipMod.mod.settings.drawUpgradeInformationScreen)
            {
                if (SelPawnUpgrade != null)
                {
                    try
                    {
                        Texture2D tex = ContentFinder <Texture2D> .Get(SelPawnUpgrade.kindDef.lifeStages.FirstOrDefault().bodyGraphicData.texPath + "_north", true);

                        GUI.DrawTexture(displayRect, tex);

                        if (RimShipMod.mod.settings.debugDrawCannonGrid)
                        {
                            Widgets.DrawLineHorizontal(displayRect.x, displayRect.y, displayRect.width);
                            Widgets.DrawLineHorizontal(displayRect.x, displayRect.y + displayRect.height, displayRect.width);
                            Widgets.DrawLineVertical(displayRect.x, displayRect.y, displayRect.height);
                            Widgets.DrawLineVertical(displayRect.x + displayRect.width, displayRect.y, displayRect.height);
                            if (screenWidth - (displayRect.x + displayRect.width) < 0)
                            {
                                Resize      = new Vector2(screenWidth + displayRect.x, screenHeight);
                                resizeCheck = true;
                            }
                        }
                        if (RimShipMod.mod.settings.debugDrawNodeGrid)
                        {
                            Widgets.DrawLineHorizontal(LeftWindowEdge, 70f, screenWidth - LeftWindowEdge);
                            int lineCount = (int)(screenWidth - LeftWindowEdge) / 10;

                            for (int i = 1; i <= lineCount; i++)
                            {
                                Widgets.DrawLineVertical(LeftWindowEdge + 10 * i, 70f, (i % 5 == 0) ? 10 : 5);
                            }
                            var color = GUI.color;
                            GUI.color = Color.red;
                            Widgets.DrawLineVertical(LeftWindowEdge + (((screenWidth - BottomDisplayedOffset) - LeftWindowEdge) / 2), 70f, 12f);
                            GUI.color = color;
                        }

                        foreach (CannonHandler cannon in Comp.upgradeList.Where(x => x.upgradeActive && (x.cannonsUnlocked?.Any() ?? false)).SelectMany(y => y.cannonsUnlocked))
                        {
                            PawnKindLifeStage biggestStage = SelPawnUpgrade.kindDef.lifeStages.MaxBy(x => x.bodyGraphicData?.drawSize ?? Vector2.zero);
                            float             baseWidth    = (Comp.Props.displayUISize.x / biggestStage.bodyGraphicData.drawSize.x) * cannon.baseCannonDrawSize.x;
                            float             baseHeight   = (Comp.Props.displayUISize.y / biggestStage.bodyGraphicData.drawSize.y) * cannon.baseCannonDrawSize.y;

                            float xBase = displayRect.x + (displayRect.width / 2) - (baseWidth / 2) - ((Comp.Props.displayUISize.x / biggestStage.bodyGraphicData.drawSize.x) * cannon.baseCannonRenderLocation.x);
                            float yBase = displayRect.y + (displayRect.height / 2) - (baseHeight / 2) - ((Comp.Props.displayUISize.y / biggestStage.bodyGraphicData.drawSize.y) * cannon.baseCannonRenderLocation.y);

                            Rect baseCannonDrawnRect = new Rect(xBase, yBase, baseWidth, baseHeight);
                            GUI.DrawTexture(baseCannonDrawnRect, cannon.CannonBaseTexture);

                            float cannonWidth  = (Comp.Props.displayUISize.x / biggestStage.bodyGraphicData.drawSize.x) * cannon.cannonTurretDrawSize.x;
                            float cannonHeight = (Comp.Props.displayUISize.y / biggestStage.bodyGraphicData.drawSize.y) * cannon.cannonTurretDrawSize.y;

                            float xCannon = displayRect.x + (displayRect.width / 2) - (cannonWidth / 2) - ((Comp.Props.displayUISize.x / biggestStage.bodyGraphicData.drawSize.x) * cannon.cannonRenderLocation.x);
                            float yCannon = displayRect.y + (displayRect.height / 2) - (cannonHeight / 2) - ((Comp.Props.displayUISize.y / biggestStage.bodyGraphicData.drawSize.y) * cannon.cannonRenderLocation.y);

                            Rect cannonDrawnRect = new Rect(xCannon, yCannon, cannonWidth, cannonHeight);
                            GUI.DrawTexture(cannonDrawnRect, cannon.CannonTexture);

                            if (RimShipMod.mod.settings.debugDrawCannonGrid)
                            {
                                Widgets.DrawLineHorizontal(cannonDrawnRect.x, cannonDrawnRect.y, cannonDrawnRect.width);
                                Widgets.DrawLineHorizontal(cannonDrawnRect.x, cannonDrawnRect.y + cannonDrawnRect.height, cannonDrawnRect.width);
                                Widgets.DrawLineVertical(cannonDrawnRect.x, cannonDrawnRect.y, cannonDrawnRect.height);
                                Widgets.DrawLineVertical(cannonDrawnRect.x + cannonDrawnRect.width, cannonDrawnRect.y, cannonDrawnRect.height);
                            }
                        }
                        if (selectedNode?.cannonsUnlocked?.Any() ?? false)
                        {
                            foreach (CannonHandler cannon in selectedNode.cannonsUnlocked)
                            {
                                PawnKindLifeStage biggestStage = SelPawnUpgrade.kindDef.lifeStages.MaxBy(x => x.bodyGraphicData?.drawSize ?? Vector2.zero);
                                float             baseWidth    = (Comp.Props.displayUISize.x / biggestStage.bodyGraphicData.drawSize.x) * cannon.baseCannonDrawSize.x;
                                float             baseHeight   = (Comp.Props.displayUISize.y / biggestStage.bodyGraphicData.drawSize.y) * cannon.baseCannonDrawSize.y;
                                float             test         = ((Comp.Props.displayUISize.y / biggestStage.bodyGraphicData.drawSize.y) * cannon.baseCannonRenderLocation.y);

                                float xBase = displayRect.x + (displayRect.width / 2) - (baseWidth / 2) - ((Comp.Props.displayUISize.x / biggestStage.bodyGraphicData.drawSize.x) * cannon.baseCannonRenderLocation.x);
                                float yBase = displayRect.y + (displayRect.height / 2) - (baseHeight / 2) - ((Comp.Props.displayUISize.y / biggestStage.bodyGraphicData.drawSize.y) * cannon.baseCannonRenderLocation.y);

                                Rect baseCannonDrawnRect = new Rect(xBase, yBase, baseWidth, baseHeight);
                                GUI.DrawTexture(baseCannonDrawnRect, cannon.CannonBaseTexture);

                                float cannonWidth  = (Comp.Props.displayUISize.x / biggestStage.bodyGraphicData.drawSize.x) * cannon.cannonTurretDrawSize.x;
                                float cannonHeight = (Comp.Props.displayUISize.y / biggestStage.bodyGraphicData.drawSize.y) * cannon.cannonTurretDrawSize.y;

                                float xCannon = displayRect.x + (displayRect.width / 2) - (cannonWidth / 2) - ((Comp.Props.displayUISize.x / biggestStage.bodyGraphicData.drawSize.x) * cannon.cannonRenderLocation.x);
                                float yCannon = displayRect.y + (displayRect.height / 2) - (cannonHeight / 2) - ((Comp.Props.displayUISize.y / biggestStage.bodyGraphicData.drawSize.y) * cannon.cannonRenderLocation.y);

                                Rect cannonDrawnRect = new Rect(xCannon, yCannon, cannonWidth, cannonHeight);
                                GUI.DrawTexture(cannonDrawnRect, cannon.CannonTexture);

                                if (RimShipMod.mod.settings.debugDrawCannonGrid)
                                {
                                    Widgets.DrawLineHorizontal(cannonDrawnRect.x, cannonDrawnRect.y, cannonDrawnRect.width);
                                    Widgets.DrawLineHorizontal(cannonDrawnRect.x, cannonDrawnRect.y + cannonDrawnRect.height, cannonDrawnRect.width);
                                    Widgets.DrawLineVertical(cannonDrawnRect.x, cannonDrawnRect.y, cannonDrawnRect.height);
                                    Widgets.DrawLineVertical(cannonDrawnRect.x + cannonDrawnRect.width, cannonDrawnRect.y, cannonDrawnRect.height);
                                }
                            }
                        }
                        else if ((highlightedPreMetNode?.cannonsUnlocked?.Any() ?? false) && !highlightedPreMetNode.upgradeActive)
                        {
                            foreach (CannonHandler cannon in highlightedPreMetNode.cannonsUnlocked)
                            {
                                PawnKindLifeStage biggestStage = SelPawnUpgrade.kindDef.lifeStages.MaxBy(x => x.bodyGraphicData?.drawSize ?? Vector2.zero);
                                float             baseWidth    = (Comp.Props.displayUISize.x / biggestStage.bodyGraphicData.drawSize.x) * cannon.baseCannonDrawSize.x;
                                float             baseHeight   = (Comp.Props.displayUISize.y / biggestStage.bodyGraphicData.drawSize.y) * cannon.baseCannonDrawSize.y;

                                float xBase = displayRect.x + (displayRect.width / 2) - (baseWidth / 2) - ((Comp.Props.displayUISize.x / biggestStage.bodyGraphicData.drawSize.x) * cannon.baseCannonRenderLocation.x);
                                float yBase = displayRect.y + (displayRect.height / 2) - (baseHeight / 2) - ((Comp.Props.displayUISize.y / biggestStage.bodyGraphicData.drawSize.y) * cannon.baseCannonRenderLocation.y);

                                Rect baseCannonDrawnRect = new Rect(xBase, yBase, baseWidth, baseHeight);
                                GUI.DrawTexture(baseCannonDrawnRect, cannon.CannonBaseTexture);

                                float cannonWidth  = (Comp.Props.displayUISize.x / biggestStage.bodyGraphicData.drawSize.x) * cannon.cannonTurretDrawSize.x;
                                float cannonHeight = (Comp.Props.displayUISize.y / biggestStage.bodyGraphicData.drawSize.y) * cannon.cannonTurretDrawSize.y;

                                float xCannon = displayRect.x + (displayRect.width / 2) - (cannonWidth / 2) - ((Comp.Props.displayUISize.x / biggestStage.bodyGraphicData.drawSize.x) * cannon.cannonRenderLocation.x);
                                float yCannon = displayRect.y + (displayRect.height / 2) - (cannonHeight / 2) - ((Comp.Props.displayUISize.y / biggestStage.bodyGraphicData.drawSize.y) * cannon.cannonRenderLocation.y);

                                Rect cannonDrawnRect = new Rect(xCannon, yCannon, cannonWidth, cannonHeight);
                                GUI.DrawTexture(cannonDrawnRect, cannon.CannonTexture);

                                if (RimShipMod.mod.settings.debugDrawCannonGrid)
                                {
                                    Widgets.DrawLineHorizontal(cannonDrawnRect.x, cannonDrawnRect.y, cannonDrawnRect.width);
                                    Widgets.DrawLineHorizontal(cannonDrawnRect.x, cannonDrawnRect.y + cannonDrawnRect.height, cannonDrawnRect.width);
                                    Widgets.DrawLineVertical(cannonDrawnRect.x, cannonDrawnRect.y, cannonDrawnRect.height);
                                    Widgets.DrawLineVertical(cannonDrawnRect.x + cannonDrawnRect.width, cannonDrawnRect.y, cannonDrawnRect.height);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.ErrorOnce($"Unable to display {SelPawnUpgrade.def.LabelCap} Texture on Upgrade Screen. Error: {ex.Message} \n StackTrace: {ex.StackTrace}", SelPawnUpgrade.thingIDNumber, true);
                    }
                }
            }

            DrawStats(additionalStatNode);

            GUI.EndGroup();

            GUI.color   = Color.white;
            Text.Anchor = TextAnchor.UpperLeft;
        }
 private static void CacheAccessibleThings(int nearTile)
 {
     if (nearTile != PlayerItemAccessibilityUtility.cachedAccessibleThingsForTile || RealTime.frameCount != PlayerItemAccessibilityUtility.cachedAccessibleThingsForFrame)
     {
         PlayerItemAccessibilityUtility.cachedAccessibleThings.Clear();
         PlayerItemAccessibilityUtility.cachedPossiblyAccessibleThings.Clear();
         WorldGrid  worldGrid = Find.WorldGrid;
         List <Map> maps      = Find.Maps;
         for (int i = 0; i < maps.Count; i++)
         {
             float num = worldGrid.ApproxDistanceInTiles(nearTile, maps[i].Tile);
             if (num <= 5f)
             {
                 ThingOwnerUtility.GetAllThingsRecursively(maps[i], PlayerItemAccessibilityUtility.tmpThings, false, null);
                 PlayerItemAccessibilityUtility.cachedAccessibleThings.AddRange(PlayerItemAccessibilityUtility.tmpThings);
             }
         }
         List <Caravan> caravans = Find.WorldObjects.Caravans;
         for (int j = 0; j < caravans.Count; j++)
         {
             if (caravans[j].IsPlayerControlled)
             {
                 float num2 = worldGrid.ApproxDistanceInTiles(nearTile, caravans[j].Tile);
                 if (num2 <= 5f)
                 {
                     ThingOwnerUtility.GetAllThingsRecursively(caravans[j], PlayerItemAccessibilityUtility.tmpThings, false, null);
                     PlayerItemAccessibilityUtility.cachedAccessibleThings.AddRange(PlayerItemAccessibilityUtility.tmpThings);
                 }
             }
         }
         for (int k = 0; k < PlayerItemAccessibilityUtility.cachedAccessibleThings.Count; k++)
         {
             Thing thing = PlayerItemAccessibilityUtility.cachedAccessibleThings[k];
             PlayerItemAccessibilityUtility.cachedPossiblyAccessibleThings.Add(new ThingDefCount(thing.def, thing.stackCount));
             if (GenLeaving.CanBuildingLeaveResources(thing, DestroyMode.Deconstruct))
             {
                 List <ThingDefCountClass> list = thing.CostListAdjusted();
                 for (int l = 0; l < list.Count; l++)
                 {
                     int num3 = Mathf.RoundToInt((float)list[l].count * thing.def.resourcesFractionWhenDeconstructed);
                     if (num3 > 0)
                     {
                         PlayerItemAccessibilityUtility.cachedPossiblyAccessibleThings.Add(new ThingDefCount(list[l].thingDef, num3));
                     }
                 }
             }
             Plant plant = thing as Plant;
             if (plant != null)
             {
                 if (plant.HarvestableNow || plant.HarvestableSoon)
                 {
                     int num4 = Mathf.RoundToInt(plant.def.plant.harvestYield * Find.Storyteller.difficulty.cropYieldFactor);
                     if (num4 > 0)
                     {
                         PlayerItemAccessibilityUtility.cachedPossiblyAccessibleThings.Add(new ThingDefCount(plant.def.plant.harvestedThingDef, num4));
                     }
                 }
             }
             if (!thing.def.butcherProducts.NullOrEmpty <ThingDefCountClass>())
             {
                 for (int m = 0; m < thing.def.butcherProducts.Count; m++)
                 {
                     PlayerItemAccessibilityUtility.cachedPossiblyAccessibleThings.Add(thing.def.butcherProducts[m]);
                 }
             }
             Pawn pawn = thing as Pawn;
             if (pawn != null)
             {
                 if (pawn.RaceProps.meatDef != null)
                 {
                     int num5 = Mathf.RoundToInt(pawn.GetStatValue(StatDefOf.MeatAmount, true));
                     if (num5 > 0)
                     {
                         PlayerItemAccessibilityUtility.cachedPossiblyAccessibleThings.Add(new ThingDefCount(pawn.RaceProps.meatDef, num5));
                     }
                 }
                 if (pawn.RaceProps.leatherDef != null)
                 {
                     int num6 = GenMath.RoundRandom(pawn.GetStatValue(StatDefOf.LeatherAmount, true));
                     if (num6 > 0)
                     {
                         PlayerItemAccessibilityUtility.cachedPossiblyAccessibleThings.Add(new ThingDefCount(pawn.RaceProps.leatherDef, num6));
                     }
                 }
                 if (!pawn.RaceProps.Humanlike)
                 {
                     PawnKindLifeStage curKindLifeStage = pawn.ageTracker.CurKindLifeStage;
                     if (curKindLifeStage.butcherBodyPart != null)
                     {
                         PlayerItemAccessibilityUtility.cachedPossiblyAccessibleThings.Add(new ThingDefCount(curKindLifeStage.butcherBodyPart.thing, 1));
                     }
                 }
             }
             if (thing.def.smeltable)
             {
                 List <ThingDefCountClass> list2 = thing.CostListAdjusted();
                 for (int n = 0; n < list2.Count; n++)
                 {
                     if (!list2[n].thingDef.intricate)
                     {
                         int num7 = Mathf.RoundToInt((float)list2[n].count * 0.25f);
                         if (num7 > 0)
                         {
                             PlayerItemAccessibilityUtility.cachedPossiblyAccessibleThings.Add(new ThingDefCount(list2[n].thingDef, num7));
                         }
                     }
                 }
             }
             if (thing.def.smeltable && !thing.def.smeltProducts.NullOrEmpty <ThingDefCountClass>())
             {
                 for (int num8 = 0; num8 < thing.def.smeltProducts.Count; num8++)
                 {
                     PlayerItemAccessibilityUtility.cachedPossiblyAccessibleThings.Add(thing.def.smeltProducts[num8]);
                 }
             }
         }
         int num9 = 0;
         for (int num10 = 0; num10 < PlayerItemAccessibilityUtility.cachedAccessibleThings.Count; num10++)
         {
             Pawn pawn2 = PlayerItemAccessibilityUtility.cachedAccessibleThings[num10] as Pawn;
             if (pawn2 != null && pawn2.IsFreeColonist && !pawn2.Dead && !pawn2.Downed && pawn2.workSettings.WorkIsActive(WorkTypeDefOf.Crafting))
             {
                 num9++;
             }
         }
         if (num9 > 0)
         {
             PlayerItemAccessibilityUtility.tmpWorkTables.Clear();
             for (int num11 = 0; num11 < PlayerItemAccessibilityUtility.cachedAccessibleThings.Count; num11++)
             {
                 Building_WorkTable building_WorkTable = PlayerItemAccessibilityUtility.cachedAccessibleThings[num11] as Building_WorkTable;
                 if (building_WorkTable != null && building_WorkTable.Spawned && PlayerItemAccessibilityUtility.tmpWorkTables.Add(building_WorkTable.def))
                 {
                     List <RecipeDef> allRecipes = building_WorkTable.def.AllRecipes;
                     for (int num12 = 0; num12 < allRecipes.Count; num12++)
                     {
                         if (allRecipes[num12].AvailableNow)
                         {
                             if (allRecipes[num12].products.Any <ThingDefCountClass>())
                             {
                                 if (!allRecipes[num12].PotentiallyMissingIngredients(null, building_WorkTable.Map).Any <ThingDef>())
                                 {
                                     ThingDef stuffDef = (!allRecipes[num12].products[0].thingDef.MadeFromStuff) ? null : GenStuff.DefaultStuffFor(allRecipes[num12].products[0].thingDef);
                                     float    num13    = allRecipes[num12].WorkAmountTotal(stuffDef);
                                     if (num13 > 0f)
                                     {
                                         int num14 = Mathf.FloorToInt((float)(num9 * 60000 * 5) * 0.09f / num13);
                                         if (num14 > 0)
                                         {
                                             for (int num15 = 0; num15 < allRecipes[num12].products.Count; num15++)
                                             {
                                                 PlayerItemAccessibilityUtility.cachedPossiblyAccessibleThings.Add(new ThingDefCount(allRecipes[num12].products[num15].thingDef, allRecipes[num12].products[num15].count * num14));
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         PlayerItemAccessibilityUtility.cachedAccessibleThingsForTile  = nearTile;
         PlayerItemAccessibilityUtility.cachedAccessibleThingsForFrame = RealTime.frameCount;
     }
 }
示例#14
0
        public static Vector2 ForPawn(Pawn pawn)
        {
            if (pawn.RaceProps.Humanlike)
            {
                PawnRenderer   renderer   = pawn.Drawer.renderer;
                PawnGraphicSet graphicSet = renderer.graphics;

                if (!graphicSet.AllResolved)
                {
                    graphicSet.ResolveAllGraphics();
                }

                try
                {
                    if (pawn.IsDessicated() && graphicSet.dessicatedGraphic != null)
                    {
                        return(BoundMap(
                                   graphicSet.dessicatedGraphic,
                                   GraphicType.Pawn,
                                   graphicSet.desiccatedHeadGraphic,
                                   new Vector2(renderer.BaseHeadOffsetAt(Rot4.South).x,
                                               renderer.BaseHeadOffsetAt(Rot4.East).z)));
                    }

                    return(BoundMap(
                               graphicSet.nakedGraphic,
                               GraphicType.Pawn,
                               graphicSet.headGraphic,
                               new Vector2(renderer.BaseHeadOffsetAt(Rot4.South).x,
                                           renderer.BaseHeadOffsetAt(Rot4.East).z)));
                }
                catch (ArgumentException e) { throw new ArgumentException(pawn + ".graphics." + (pawn.IsDessicated() ? "dessicated/dessicatedHead" : "naked/head") + "Graphic", e); }
            }
            else
            {
                PawnKindLifeStage lifeStage = pawn.ageTracker.CurKindLifeStage;

                try
                {
                    if (pawn.IsDessicated() && lifeStage.dessicatedBodyGraphicData != null)
                    {
                        return(Vector2.Scale(BoundMap(lifeStage.dessicatedBodyGraphicData.Graphic, GraphicType.Pawn), lifeStage.dessicatedBodyGraphicData.drawSize));
                    }
                }
                catch (ArgumentException e) { throw new ArgumentException(pawn + ".lifeStage[" + pawn.ageTracker.CurLifeStageIndex + "].dessicatedBodyGraphicData", e); }

                try
                {
                    if (pawn.gender == Gender.Female && lifeStage.femaleGraphicData != null)
                    {
                        return(Vector2.Scale(BoundMap(lifeStage.femaleGraphicData.Graphic, GraphicType.Pawn), lifeStage.femaleGraphicData.drawSize));
                    }
                }
                catch (ArgumentException e) { throw new ArgumentException(pawn + ".lifeStage[" + pawn.ageTracker.CurLifeStageIndex + "].femaleGraphicData", e); }

                try { if (lifeStage.bodyGraphicData != null)
                      {
                          return(Vector2.Scale(BoundMap(lifeStage.bodyGraphicData.Graphic, GraphicType.Pawn), lifeStage.bodyGraphicData.drawSize));
                      }
                }
                catch (ArgumentException e) { throw new ArgumentException(pawn + ".lifeStage[" + pawn.ageTracker.CurLifeStageIndex + "].bodyGraphicData", e); }

                return(Vector2.zero);
            }
        }
示例#15
0
        public static void Inject()
        {
            foreach (PawnKindDef def in DefDatabase <PawnKindDef> .AllDefs.Where(x => !x.RaceProps.Humanlike))
            {
                for (int i = 0; i < def.lifeStages.Count; i++)
                {
                    PawnKindLifeStage lifeStage = def.lifeStages[i];

                    try
                    {
                        if (lifeStage.bodyGraphicData != null && lifeStage.bodyGraphicData.Graphic != null)
                        {
                            BoundMap(lifeStage.bodyGraphicData.Graphic, GraphicType.Pawn);
                        }
                    }
                    catch (Exception e) { throw new Exception(def + ".lifeStages[" + i + "].bodyGraphicData", e); }

                    try
                    {
                        if (lifeStage.femaleGraphicData != null && lifeStage.femaleGraphicData.Graphic != null)
                        {
                            BoundMap(lifeStage.femaleGraphicData.Graphic, GraphicType.Pawn);
                        }
                    }
                    catch (Exception e) { throw new Exception(def + ".lifeStages[" + i + "].femaleGraphicData", e); }

                    try
                    {
                        if (lifeStage.dessicatedBodyGraphicData != null && lifeStage.dessicatedBodyGraphicData.Graphic != null)
                        {
                            BoundMap(lifeStage.dessicatedBodyGraphicData.Graphic, GraphicType.Pawn);
                        }
                    }
                    catch (Exception e) { throw new Exception(def + ".lifeStages[" + i + "].dessicatedBodyGraphicData", e); }
                }
            }

            foreach (ThingDef def in DefDatabase <ThingDef> .AllDefs.Where <ThingDef>(x => x.plant != null))
            {
                try
                {
                    if (def.graphicData != null && def.graphicData.Graphic != null)
                    {
                        BoundMap(def.graphicData.Graphic, GraphicType.Plant);
                    }
                }
                catch (Exception e) { throw new Exception(def + ".graphicData", e); }

                try
                {
                    if (def.plant.leaflessGraphic != null)
                    {
                        BoundMap(def.plant.leaflessGraphic, GraphicType.Plant);
                    }
                }
                catch (Exception e) { throw new Exception(def + ".plant.leaflessGraphic", e); }

                try
                {
                    if (def.plant.immatureGraphic != null)
                    {
                        BoundMap(def.plant.immatureGraphic, GraphicType.Plant);
                    }
                }
                catch (Exception e) { throw new Exception(def + ".plant.immatureGraphic", e); }
            }

            Graphic graphicSowing = (Graphic)(typeof(Plant).GetField("GraphicSowing", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null));

            try
            {
                if (graphicSowing != null)
                {
                    BoundMap(graphicSowing, GraphicType.Plant);
                }
            }
            catch (Exception e) { throw new Exception("GraphicSowing", e); }

            Log.Message("Combat Extended :: Bounds pre-generated");
        }
示例#16
0
        public static Vector2 ForPawn(Pawn pawn)
        {
            if (pawn.RaceProps.Humanlike)
            {
                return(new Vector2(0.5f, 1));

                // Disabling sprite bounds for humans for balance and game design reasons -NIA

                /*
                 *              PawnRenderer renderer = pawn.Drawer.renderer;
                 *              PawnGraphicSet graphicSet = renderer.graphics;
                 *
                 *              if (!graphicSet.AllResolved)
                 *                      graphicSet.ResolveAllGraphics();
                 *
                 *              try
                 *              {
                 *                      if (pawn.IsDessicated() && graphicSet.dessicatedGraphic != null)
                 *                      {
                 *                              return BoundMap(
                 *                                      graphicSet.dessicatedGraphic,
                 *                                      GraphicType.Pawn,
                 *                                      graphicSet.desiccatedHeadGraphic,
                 *                                      new Vector2(renderer.BaseHeadOffsetAt(Rot4.South).x,
                 *                                                  renderer.BaseHeadOffsetAt(Rot4.East).z));
                 *                      }
                 *
                 *                      return BoundMap(
                 *                              graphicSet.nakedGraphic,
                 *                              GraphicType.Pawn,
                 *                              graphicSet.headGraphic,
                 *                              new Vector2(renderer.BaseHeadOffsetAt(Rot4.South).x,
                 *                                          renderer.BaseHeadOffsetAt(Rot4.East).z));
                 *              }
                 *              catch (ArgumentException e) {	throw new ArgumentException(pawn+".graphics."+(pawn.IsDessicated() ? "dessicated/dessicatedHead" : "naked/head")+"Graphic", e);	}
                 */
            }
            else
            {
                PawnKindLifeStage lifeStage = pawn.ageTracker.CurKindLifeStage;

                try { if (pawn.IsDessicated() && lifeStage.dessicatedBodyGraphicData != null)
                      {
                          return(Vector2.Scale(BoundMap(lifeStage.dessicatedBodyGraphicData.Graphic, GraphicType.Pawn), lifeStage.dessicatedBodyGraphicData.drawSize));
                      }
                }
                catch (ArgumentException e) { throw new ArgumentException(pawn + ".lifeStage[" + pawn.ageTracker.CurLifeStageIndex + "].dessicatedBodyGraphicData", e); }

                try { if (pawn.gender == Gender.Female && lifeStage.femaleGraphicData != null)
                      {
                          return(Vector2.Scale(BoundMap(lifeStage.femaleGraphicData.Graphic, GraphicType.Pawn), lifeStage.femaleGraphicData.drawSize));
                      }
                }
                catch (ArgumentException e) { throw new ArgumentException(pawn + ".lifeStage[" + pawn.ageTracker.CurLifeStageIndex + "].femaleGraphicData", e); }

                try { if (lifeStage.bodyGraphicData != null)
                      {
                          return(Vector2.Scale(BoundMap(lifeStage.bodyGraphicData.Graphic, GraphicType.Pawn), lifeStage.bodyGraphicData.drawSize));
                      }
                }
                catch (ArgumentException e) { throw new ArgumentException(pawn + ".lifeStage[" + pawn.ageTracker.CurLifeStageIndex + "].bodyGraphicData", e); }

                return(Vector2.zero);
            }
        }
示例#17
0
        private void InitializeGraphicsHand()
        {
            if (!this.CompAni.Props.bipedWithHands)
            {
                return;
            }

            string texNameHand;
            Color  skinColor;

            if (this._pawn.story == null)
            {
                PawnKindLifeStage curKindLifeStage = this._pawn.ageTracker.CurKindLifeStage;

                skinColor   = curKindLifeStage.bodyGraphicData.color;
                texNameHand = "Paws/" + this.CompAni.Props.handType + STR_Hand;
            }
            else
            {
                skinColor   = this._pawn.story.SkinColor;
                texNameHand = StringsFS.PathHumanlike + "Hands/" + this.CompAni.Props.handType + STR_Hand;
            }

            Color rightColorHand = Color.cyan;
            Color leftColorHand  = Color.magenta;

            Color rightHandColor = skinColor;
            Color leftHandColor  = skinColor;

            Color metal = new Color(0.51f, 0.61f, 0.66f);

            switch (this.CompAni.BodyStat.HandRight)
            {
            case PartStatus.Artificial:
                rightHandColor = metal;
                break;
            }

            switch (this.CompAni.BodyStat.HandLeft)
            {
            case PartStatus.Artificial:
                leftHandColor = metal;
                break;
            }

            Color leftHandColorShadow  = leftHandColor * this._shadowColor;
            Color rightHandColorShadow = rightHandColor * this._shadowColor;

            this.HandGraphicRight = GraphicDatabase.Get <Graphic_Multi_Four>(
                texNameHand,
                ShaderDatabase.CutoutSkin,
                new Vector2(1f, 1f),
                rightHandColor,
                skinColor);

            this.HandGraphicLeft = GraphicDatabase.Get <Graphic_Multi_Four>(
                texNameHand,
                ShaderDatabase.CutoutSkin,
                new Vector2(1f, 1f),
                leftHandColor,
                skinColor);

            this.HandGraphicRightShadow = GraphicDatabase.Get <Graphic_Multi_Four>(
                texNameHand,
                ShaderDatabase.CutoutSkin,
                new Vector2(1f, 1f),
                rightHandColorShadow,
                skinColor);

            this.HandGraphicLeftShadow = GraphicDatabase.Get <Graphic_Multi_Four>(
                texNameHand,
                ShaderDatabase.CutoutSkin,
                new Vector2(1f, 1f),
                leftHandColorShadow,
                skinColor);

            // for development
            this.HandGraphicRightCol = GraphicDatabase.Get <Graphic_Multi_Four>(
                texNameHand,
                ShaderDatabase.CutoutSkin,
                new Vector2(1f, 1f),
                rightColorHand,
                skinColor);

            this.HandGraphicLeftCol = GraphicDatabase.Get <Graphic_Multi_Four>(
                texNameHand,
                ShaderDatabase.CutoutSkin,
                new Vector2(1f, 1f),
                leftColorHand,
                skinColor);
        }
示例#18
0
        public static Vector2 ForPawn(Pawn pawn)
        {
            if (pawn.RaceProps.Humanlike)
            {
                return(new Vector2(0.5f, 1));

                // Disabling sprite bounds for humans for balance and game design reasons -NIA

                /*
                 *              PawnRenderer renderer = pawn.Drawer.renderer;
                 *              PawnGraphicSet graphicSet = renderer.graphics;
                 *
                 *              if (!graphicSet.AllResolved)
                 *                      graphicSet.ResolveAllGraphics();
                 *
                 *              try
                 *              {
                 *                      if (pawn.IsDessicated() && graphicSet.dessicatedGraphic != null)
                 *                      {
                 *                              return BoundMap(
                 *                                      graphicSet.dessicatedGraphic,
                 *                                      GraphicType.Pawn,
                 *                                      graphicSet.desiccatedHeadGraphic,
                 *                                      new Vector2(renderer.BaseHeadOffsetAt(Rot4.South).x,
                 *                                                  renderer.BaseHeadOffsetAt(Rot4.East).z));
                 *                      }
                 *
                 *                      return BoundMap(
                 *                              graphicSet.nakedGraphic,
                 *                              GraphicType.Pawn,
                 *                              graphicSet.headGraphic,
                 *                              new Vector2(renderer.BaseHeadOffsetAt(Rot4.South).x,
                 *                                          renderer.BaseHeadOffsetAt(Rot4.East).z));
                 *              }
                 *              catch (ArgumentException e) {	throw new ArgumentException(pawn+".graphics."+(pawn.IsDessicated() ? "dessicated/dessicatedHead" : "naked/head")+"Graphic", e);	}
                 */
            }
            else
            {
                //Revert to old system:
                //return new Vector2(pawn.BodySize, pawn.BodySize);

                PawnKindLifeStage lifeStage = pawn.ageTracker.CurKindLifeStage;

                //Exact mimick of PawnGraphicSet
                GraphicData data = pawn.IsDessicated() && lifeStage.dessicatedBodyGraphicData != null
                    ? (pawn.gender != Gender.Female || lifeStage.femaleDessicatedBodyGraphicData == null)
                        ? lifeStage.dessicatedBodyGraphicData
                        : lifeStage.femaleDessicatedBodyGraphicData
                    : (pawn.gender != Gender.Female || lifeStage.femaleGraphicData == null)
                        ? lifeStage.bodyGraphicData
                        : lifeStage.femaleGraphicData;

                var name = pawn.IsDessicated() && lifeStage.dessicatedBodyGraphicData != null
                    ? (pawn.gender != Gender.Female || lifeStage.femaleDessicatedBodyGraphicData == null)
                        ? "dessicatedBodyGraphicData"
                        : "femaleDessicatedBodyGraphicData"
                    : (pawn.gender != Gender.Female || lifeStage.femaleGraphicData == null)
                        ? "bodyGraphicData"
                        : "femaleGraphicData";

                var graphic = data.Graphic;
                var size    = data.drawSize;

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

                    name    = "alternateGraphics";
                    graphic = pawn.Drawer.renderer.graphics.nakedGraphic;
                }

                if (graphic == null)
                {
                    Log.Error(pawn + ".lifeStage[" + pawn.ageTracker.CurLifeStageIndex + "]." + name + " could not be found");
                    return(Vector2.zero);
                }
                else
                {
                    try { return(Vector2.Scale(BoundMap(graphic, GraphicType.Pawn), size)); }
                    catch (ArgumentException e)
                    {
                        throw new ArgumentException(pawn + ".lifeStage[" + pawn.ageTracker.CurLifeStageIndex + "]." + name, e);
                    }
                }
            }
        }
示例#19
0
        private void InitializeGraphicsFeet()
        {
            string texNameFoot;

            if (this._pawn.RaceProps.Humanlike)
            {
                texNameFoot = StringsFS.PathHumanlike + "Feet/" + this.CompAni.Props.handType + STR_Foot;
            }
            else
            {
                texNameFoot = "Paws/" + this.CompAni.Props.handType + STR_Foot;
            }
            Color skinColor;

            if (this._pawn.story == null)
            {
                PawnKindLifeStage curKindLifeStage = this._pawn.ageTracker.CurKindLifeStage;

                skinColor = curKindLifeStage.bodyGraphicData.color;
            }
            else
            {
                skinColor = this._pawn.story.SkinColor;
            }

            Color rightColorFoot = Color.red;
            Color leftColorFoot  = Color.blue;

            Color rightFootColor = skinColor;
            Color leftFootColor  = skinColor;
            Color metal          = new Color(0.51f, 0.61f, 0.66f);

            switch (this.CompAni.BodyStat.FootRight)
            {
            case PartStatus.Artificial:
                rightFootColor = metal;
                break;
            }

            switch (this.CompAni.BodyStat.FootLeft)
            {
            case PartStatus.Artificial:
                leftFootColor = metal;
                break;
            }

            Color rightFootShadowColor = rightFootColor * this._shadowColor;
            Color leftFootShadowColor  = leftFootColor * this._shadowColor;

            this.FootGraphicRight = GraphicDatabase.Get <Graphic_Multi_Four>(
                texNameFoot,
                ShaderDatabase.CutoutSkin,
                new Vector2(1f, 1f),
                rightFootColor,
                skinColor);

            this.FootGraphicLeft = GraphicDatabase.Get <Graphic_Multi_Four>(
                texNameFoot,
                ShaderDatabase.CutoutSkin,
                new Vector2(1f, 1f),
                leftFootColor,
                skinColor);

            this.FootGraphicRightShadow = GraphicDatabase.Get <Graphic_Multi_Four>(
                texNameFoot,
                ShaderDatabase.CutoutSkin,
                new Vector2(1f, 1f),
                rightFootShadowColor,
                skinColor);

            this.FootGraphicLeftShadow = GraphicDatabase.Get <Graphic_Multi_Four>(
                texNameFoot,
                ShaderDatabase.CutoutSkin,
                new Vector2(1f, 1f),
                leftFootShadowColor,
                skinColor);

            this.FootGraphicRightCol = GraphicDatabase.Get <Graphic_Multi_Four>(
                texNameFoot,
                ShaderDatabase.CutoutSkin,
                new Vector2(1f, 1f),
                rightColorFoot,
                skinColor);

            this.FootGraphicLeftCol = GraphicDatabase.Get <Graphic_Multi_Four>(
                texNameFoot,
                ShaderDatabase.CutoutSkin,
                new Vector2(1f, 1f),
                leftColorFoot,
                skinColor);
        }
        public override IEnumerable <Thing> ButcherProducts(Pawn butcher, float efficiency)
        {
            if (RaceProps.meatDef != null)
            {
                int num = GenMath.RoundRandom(this.GetStatValue(StatDefOf.MeatAmount) * efficiency);
                if (num > 0)
                {
                    Thing thing = ThingMaker.MakeThing(RaceProps.meatDef);
                    thing.stackCount = num;
                    yield return(thing);
                }
            }



            if (this.def.defName == "Rath")
            {
                if (this.gender == Gender.Male)
                {
                    int num2 = GenMath.RoundRandom(this.GetStatValue(StatDefOf.LeatherAmount) * efficiency);
                    if (num2 > 0)
                    {
                        Thing thing2 = ThingMaker.MakeThing(MHRWDefOf.Leather_Rathalos);
                        thing2.stackCount = num2;
                        yield return(thing2);
                    }
                }
                else
                {
                    int num2 = GenMath.RoundRandom(this.GetStatValue(StatDefOf.LeatherAmount) * efficiency);
                    if (num2 > 0)
                    {
                        Thing thing2 = ThingMaker.MakeThing(MHRWDefOf.Leather_Rathian);
                        thing2.stackCount = num2;
                        yield return(thing2);
                    }
                }
            }
            if (this.def.defName == "Tesuka")
            {
                if (this.gender == Gender.Male)
                {
                    int num2 = GenMath.RoundRandom(this.GetStatValue(StatDefOf.LeatherAmount) * efficiency);
                    if (num2 > 0)
                    {
                        Thing thing2 = ThingMaker.MakeThing(MHRWDefOf.Leather_Teostra);
                        thing2.stackCount = num2;
                        yield return(thing2);
                    }
                }
                else
                {
                    int num2 = GenMath.RoundRandom(this.GetStatValue(StatDefOf.LeatherAmount) * efficiency);
                    if (num2 > 0)
                    {
                        Thing thing2 = ThingMaker.MakeThing(MHRWDefOf.Leather_Lunastra);
                        thing2.stackCount = num2;
                        yield return(thing2);
                    }
                }
            }

            if (RaceProps.Humanlike)
            {
                yield break;
            }
            PawnKindLifeStage lifeStage = ageTracker.CurKindLifeStage;

            if (lifeStage.butcherBodyPart == null || (gender != 0 && (gender != Gender.Male || !lifeStage.butcherBodyPart.allowMale) && (gender != Gender.Female || !lifeStage.butcherBodyPart.allowFemale)))
            {
                yield break;
            }
            while (true)
            {
                BodyPartRecord bodyPartRecord = (from x in health.hediffSet.GetNotMissingParts()
                                                 where x.IsInGroup(lifeStage.butcherBodyPart.bodyPartGroup)
                                                 select x).FirstOrDefault();
                if (bodyPartRecord != null)
                {
                    health.AddHediff(HediffMaker.MakeHediff(HediffDefOf.MissingBodyPart, this, bodyPartRecord));
                    yield return((lifeStage.butcherBodyPart.thing == null) ? ThingMaker.MakeThing(bodyPartRecord.def.spawnThingOnRemoved) : ThingMaker.MakeThing(lifeStage.butcherBodyPart.thing));

                    continue;
                }
                break;
            }
        }
        private static void CacheAccessibleThings(int nearTile)
        {
            if (nearTile == cachedAccessibleThingsForTile && RealTime.frameCount == cachedAccessibleThingsForFrame)
            {
                return;
            }
            cachedAccessibleThings.Clear();
            cachedPossiblyAccessibleThings.Clear();
            cachedMakeableItemDefs.Clear();
            WorldGrid  worldGrid = Find.WorldGrid;
            List <Map> maps      = Find.Maps;

            for (int i = 0; i < maps.Count; i++)
            {
                if (!(worldGrid.ApproxDistanceInTiles(nearTile, maps[i].Tile) > 5f))
                {
                    ThingOwnerUtility.GetAllThingsRecursively(maps[i], tmpThings, allowUnreal: false);
                    cachedAccessibleThings.AddRange(tmpThings);
                }
            }
            List <Caravan> caravans = Find.WorldObjects.Caravans;

            for (int j = 0; j < caravans.Count; j++)
            {
                if (caravans[j].IsPlayerControlled && !(worldGrid.ApproxDistanceInTiles(nearTile, caravans[j].Tile) > 5f))
                {
                    ThingOwnerUtility.GetAllThingsRecursively(caravans[j], tmpThings, allowUnreal: false);
                    cachedAccessibleThings.AddRange(tmpThings);
                }
            }
            for (int k = 0; k < cachedAccessibleThings.Count; k++)
            {
                Thing thing = cachedAccessibleThings[k];
                cachedPossiblyAccessibleThings.Add(new ThingDefCount(thing.def, thing.stackCount));
                if (GenLeaving.CanBuildingLeaveResources(thing, DestroyMode.Deconstruct))
                {
                    List <ThingDefCountClass> list = thing.CostListAdjusted();
                    for (int l = 0; l < list.Count; l++)
                    {
                        int num = Mathf.RoundToInt((float)list[l].count * thing.def.resourcesFractionWhenDeconstructed);
                        if (num > 0)
                        {
                            cachedPossiblyAccessibleThings.Add(new ThingDefCount(list[l].thingDef, num));
                            cachedMakeableItemDefs.Add(list[l].thingDef);
                        }
                    }
                }
                Plant plant = thing as Plant;
                if (plant != null && (plant.HarvestableNow || plant.HarvestableSoon))
                {
                    int num2 = Mathf.RoundToInt(plant.def.plant.harvestYield * Find.Storyteller.difficultyValues.cropYieldFactor);
                    if (num2 > 0)
                    {
                        cachedPossiblyAccessibleThings.Add(new ThingDefCount(plant.def.plant.harvestedThingDef, num2));
                        cachedMakeableItemDefs.Add(plant.def.plant.harvestedThingDef);
                    }
                }
                if (!thing.def.butcherProducts.NullOrEmpty())
                {
                    for (int m = 0; m < thing.def.butcherProducts.Count; m++)
                    {
                        cachedPossiblyAccessibleThings.Add(thing.def.butcherProducts[m]);
                        cachedMakeableItemDefs.Add(thing.def.butcherProducts[m].thingDef);
                    }
                }
                Pawn pawn = thing as Pawn;
                if (pawn != null)
                {
                    if (pawn.RaceProps.meatDef != null)
                    {
                        int num3 = Mathf.RoundToInt(pawn.GetStatValue(StatDefOf.MeatAmount));
                        if (num3 > 0)
                        {
                            cachedPossiblyAccessibleThings.Add(new ThingDefCount(pawn.RaceProps.meatDef, num3));
                            cachedMakeableItemDefs.Add(pawn.RaceProps.meatDef);
                        }
                    }
                    if (pawn.RaceProps.leatherDef != null)
                    {
                        int num4 = GenMath.RoundRandom(pawn.GetStatValue(StatDefOf.LeatherAmount));
                        if (num4 > 0)
                        {
                            cachedPossiblyAccessibleThings.Add(new ThingDefCount(pawn.RaceProps.leatherDef, num4));
                            cachedMakeableItemDefs.Add(pawn.RaceProps.leatherDef);
                        }
                    }
                    if (!pawn.RaceProps.Humanlike)
                    {
                        PawnKindLifeStage curKindLifeStage = pawn.ageTracker.CurKindLifeStage;
                        if (curKindLifeStage.butcherBodyPart != null)
                        {
                            cachedPossiblyAccessibleThings.Add(new ThingDefCount(curKindLifeStage.butcherBodyPart.thing, 1));
                            cachedMakeableItemDefs.Add(curKindLifeStage.butcherBodyPart.thing);
                        }
                    }
                }
                if (thing.def.smeltable)
                {
                    List <ThingDefCountClass> list2 = thing.CostListAdjusted();
                    for (int n = 0; n < list2.Count; n++)
                    {
                        if (!list2[n].thingDef.intricate)
                        {
                            int num5 = Mathf.RoundToInt((float)list2[n].count * 0.25f);
                            if (num5 > 0)
                            {
                                cachedPossiblyAccessibleThings.Add(new ThingDefCount(list2[n].thingDef, num5));
                                cachedMakeableItemDefs.Add(list2[n].thingDef);
                            }
                        }
                    }
                }
                if (thing.def.smeltable && !thing.def.smeltProducts.NullOrEmpty())
                {
                    for (int num6 = 0; num6 < thing.def.smeltProducts.Count; num6++)
                    {
                        cachedPossiblyAccessibleThings.Add(thing.def.smeltProducts[num6]);
                        cachedMakeableItemDefs.Add(thing.def.smeltProducts[num6].thingDef);
                    }
                }
            }
            int num7 = 0;

            for (int num8 = 0; num8 < cachedAccessibleThings.Count; num8++)
            {
                Pawn pawn2 = cachedAccessibleThings[num8] as Pawn;
                if (pawn2 != null && pawn2.IsFreeColonist && !pawn2.Dead && !pawn2.Downed && pawn2.workSettings.WorkIsActive(WorkTypeDefOf.Crafting))
                {
                    num7++;
                }
            }
            if (num7 > 0)
            {
                tmpWorkTables.Clear();
                for (int num9 = 0; num9 < cachedAccessibleThings.Count; num9++)
                {
                    Building_WorkTable building_WorkTable = cachedAccessibleThings[num9] as Building_WorkTable;
                    if (building_WorkTable == null || !building_WorkTable.Spawned || !tmpWorkTables.Add(building_WorkTable.def))
                    {
                        continue;
                    }
                    List <RecipeDef> allRecipes = building_WorkTable.def.AllRecipes;
                    for (int num10 = 0; num10 < allRecipes.Count; num10++)
                    {
                        if (!allRecipes[num10].AvailableNow || !allRecipes[num10].AvailableOnNow(building_WorkTable) || !allRecipes[num10].products.Any() || allRecipes[num10].PotentiallyMissingIngredients(null, building_WorkTable.Map).Any())
                        {
                            continue;
                        }
                        ThingDef stuffDef = (allRecipes[num10].products[0].thingDef.MadeFromStuff ? GenStuff.DefaultStuffFor(allRecipes[num10].products[0].thingDef) : null);
                        float    num11    = allRecipes[num10].WorkAmountTotal(stuffDef);
                        if (num11 <= 0f)
                        {
                            continue;
                        }
                        int num12 = Mathf.FloorToInt((float)(num7 * 60000 * 5) * 0.09f / num11);
                        if (num12 > 0)
                        {
                            for (int num13 = 0; num13 < allRecipes[num10].products.Count; num13++)
                            {
                                cachedPossiblyAccessibleThings.Add(new ThingDefCount(allRecipes[num10].products[num13].thingDef, allRecipes[num10].products[num13].count * num12));
                                cachedMakeableItemDefs.Add(allRecipes[num10].products[num13].thingDef);
                            }
                        }
                    }
                }
            }
            cachedAccessibleThingsForTile  = nearTile;
            cachedAccessibleThingsForFrame = RealTime.frameCount;
        }
        public static bool Prefix(PawnGraphicSet __instance)
        {
            if (__instance.pawn.RaceProps.Animal)
            {
                bool isCustom = false;
                Pawn pawn     = __instance.pawn;
                PawnKindLifeStage curKindLifeStage = __instance.pawn.ageTracker.CurKindLifeStage;

                Graphic baseGraphic = new Graphic(((pawn.gender == Gender.Female) ?
                                                   curKindLifeStage.femaleGraphicData?.Graphic ?? curKindLifeStage.bodyGraphicData.Graphic :
                                                   curKindLifeStage.bodyGraphicData.Graphic));

                if (baseGraphic is null)
                {
                    Debug.Log("Basegraphic for " + pawn.ThingID + " null");
                    return(true);
                }
                Color color = baseGraphic.color;

                /*if (baseGraphic.Shader.name != ShaderType.Cutout.ToString()) {
                 *  Log.Error("boutta override " + pawn.Label + "'s " + baseGraphic.Shader.name + " with cutoutskin :(");
                 * }*/
                Shader shader = ShaderDatabase.Cutout;
                //has custom colors
                Debug.Log("Checking custom color " + pawn.Label);

                if (__instance.pawn.kindDef.GetModExtension <BPTModExtension>() is BPTModExtension extension)
                {
                    isCustom = true;
                    int colorIndex = (new System.Random(pawn.thingIDNumber)).Next() % extension.colors.Count;
                    color = extension.colors[colorIndex];
                    FieldInfo fieldInfo = typeof(ShaderDatabase).GetField(extension.shaderType, BindingFlags.Static | BindingFlags.Public);
                    shader = (Shader)fieldInfo.GetValue(null);
                    Debug.Log("chose special color " + color + " with shader " + shader);
                    Debug.Log(typeof(ShaderDatabase).GetFields(BindingFlags.Static | BindingFlags.Public).ToStringSafeEnumerable());
                }
                else
                {
                    Debug.Log(__instance.pawn.kindDef.GetModExtension <BPTModExtension>().ToStringSafe());
                }

                string safeTextureIndex = "";
                //has custom texture
                Debug.Log("Checking custom texture " + pawn.Label);
                if (__instance.pawn.ageTracker.CurKindLifeStage.bodyGraphicData.graphicClass == typeof(Graphic))
                {
                    isCustom = true;
                    int availableTextureCount = Graphic.ModTextureCount(baseGraphic.path);
                    if (availableTextureCount > 0)
                    {
                        int textureIndex = (new System.Random(pawn.thingIDNumber * 2)).Next() % availableTextureCount;
                        safeTextureIndex = (1 + textureIndex).ToString();
                    }
                    Debug.Log("chose texture " + safeTextureIndex);
                }


                if (isCustom)
                {
                    __instance.ClearCache();

                    if (curKindLifeStage.dessicatedBodyGraphicData is GraphicData dessicated)
                    {
                        __instance.dessicatedGraphic = dessicated.GraphicColoredFor(__instance.pawn);
                    }

                    //may spawn packs all default colors
                    if (pawn.RaceProps.packAnimal)
                    {
                        Debug.Log("pack animal with shader:" + shader.ToStringSafe() + color.ToStringSafe());
                        __instance.packGraphic = GraphicDatabase.Get <Graphic_Multi>(Graphic.PathBase(baseGraphic.path) + "Pack", shader, baseGraphic.drawSize, color);
                    }
                    __instance.nakedGraphic = (new Graphic(baseGraphic)).GetColoredVersion(shader, color, safeTextureIndex);
                    Debug.Log("Resolved " + __instance.nakedGraphic);
                    return(false);
                }

                return(true);
            }
            return(true);
        }