Example #1
0
        private static void replace(ThingDef def, string tex, Color color, BionicIconsTextureDef textureDef)
        {
            if (textureDef != null)
            {
                def.graphicData.graphicClass    = typeof(Graphic_SingleWithMask);
                def.graphicData.drawSize        = new Vector2(1.0f, 1.0f);
                def.graphicData.color           = textureDef.color;
                def.graphicData.texPath         = textureDef.replacement;
                def.graphicData.shaderType      = ShaderTypeDefOf.CutoutComplex;
                Graphic_SingleWithMask.maskPath = tex;
                def.graphicData.colorTwo        = textureDef.colorIcon;
            }
            else
            {
                def.graphicData.graphicClass = typeof(Graphic_Single);
                def.graphicData.drawSize     = new Vector2(1.0f, 1.0f);
                def.graphicData.color        = color;
                def.graphicData.texPath      = tex;
            }

            graphicDataInit.Invoke(def.graphicData, new object[] { });
            def.graphic     = def.graphicData.Graphic;
            def.uiIcon      = def.graphicData.Graphic.MatSingle.mainTexture as Texture2D;
            def.uiIconColor = color;
        }
Example #2
0
        private static bool processDef(RecipeDef recipe, List <BionicIconsIconDef> icons, ThingDef def)
        {
            if (icons == null)
            {
                return(false);
            }
            if (def.graphicData == null)
            {
                return(false);
            }

            List <BionicIconsTextureDef> colors;

            if (!replacements.TryGetValue(def.graphicData.texPath, out colors))
            {
                return(false);
            }


            string tex = null;

            foreach (BionicIconsIconDef option in icons)
            {
                if (option.nameContains != null && !def.defName.Contains(option.nameContains))
                {
                    continue;
                }
                if (recipe.addsHediff != null)
                {
                    bool isSolid = recipe.addsHediff.addedPartProps != null && recipe.addsHediff.addedPartProps.solid;

                    if (option.SolidOnly && !isSolid)
                    {
                        continue;
                    }
                    if (option.SoftOnly && isSolid)
                    {
                        continue;
                    }
                }

                tex = option.texture;
                break;
            }
            if (tex == null)
            {
                return(false);
            }

            Color color = Color.white;
            BionicIconsTextureDef textureDef = null;

            foreach (BionicIconsTextureDef option in colors)
            {
                if (option.nameContains != null && !def.defName.Contains(option.nameContains))
                {
                    continue;
                }
                if (option.onlyForColor != BionicIconsTextureDef.colorMissing && option.onlyForColor != def.graphicData.color)
                {
                    continue;
                }
                if (option.onlyForMod != null && def.modContentPack != null && option.onlyForMod != def.modContentPack.PackageId)
                {
                    continue;
                }

                textureDef = option;
                color      = option.color;
                break;
            }

            alteredThings.Add(def);
            replace(def, tex, color, textureDef);
            return(true);
        }