コード例 #1
0
 public static Material MatFrom(string texPath, Shader shader, Color color, int renderQueue)
 {
     return(MaterialPool.MatFrom(new MaterialRequest(ContentFinder <Texture2D> .Get(texPath, true), shader, color)
     {
         renderQueue = renderQueue
     }));
 }
コード例 #2
0
 public static Material MatFrom(Texture2D srcTex, Shader shader, Color color, int renderQueue)
 {
     return(MaterialPool.MatFrom(new MaterialRequest(srcTex, shader, color)
     {
         renderQueue = renderQueue
     }));
 }
コード例 #3
0
        public static Material MatFrom(string texPath, Shader shader, int renderQueue)
        {
            MaterialRequest req = new MaterialRequest(ContentFinder <Texture2D> .Get(texPath, true), shader);

            req.renderQueue = renderQueue;
            return(MaterialPool.MatFrom(req));
        }
コード例 #4
0
        public static List <Material> MatsFromTexturesInFolder(string dirPath)
        {
            string path = "Textures/" + dirPath;

            return((from Texture2D tex in Resources.LoadAll(path, typeof(Texture2D))
                    select MaterialPool.MatFrom(tex)).ToList <Material>());
        }
コード例 #5
0
        public override void Init(GraphicRequest req)
        {
            this.data     = req.graphicData;
            this.path     = req.path;
            this.color    = req.color;
            this.colorTwo = req.colorTwo;
            this.drawSize = req.drawSize;
            Texture2D[] array = new Texture2D[3];
            array[0] = ContentFinder <Texture2D> .Get(req.path + "_back", false);

            if (array[0] == null)
            {
                Log.Error("Failed to find any texture while constructing " + this.ToString());
                return;
            }
            array[1] = ContentFinder <Texture2D> .Get(req.path + "_side", false);

            if (array[1] == null)
            {
                array[1] = array[0];
            }
            array[2] = ContentFinder <Texture2D> .Get(req.path + "_front", false);

            if (array[2] == null)
            {
                array[2] = array[0];
            }
            Texture2D[] array2 = new Texture2D[3];
            if (req.shader.SupportsMaskTex())
            {
                array2[0] = ContentFinder <Texture2D> .Get(req.path + "_backm", false);

                if (array2[0] != null)
                {
                    array2[1] = ContentFinder <Texture2D> .Get(req.path + "_sidem", false);

                    if (array2[1] == null)
                    {
                        array2[1] = array2[0];
                    }
                    array2[2] = ContentFinder <Texture2D> .Get(req.path + "_frontm", false);

                    if (array2[2] == null)
                    {
                        array2[2] = array2[0];
                    }
                }
            }
            for (int i = 0; i < 3; i++)
            {
                MaterialRequest req2 = default(MaterialRequest);
                req2.mainTex  = array[i];
                req2.shader   = req.shader;
                req2.color    = this.color;
                req2.colorTwo = this.colorTwo;
                req2.maskTex  = array2[i];
                this.mats[i]  = MaterialPool.MatFrom(req2);
            }
        }
コード例 #6
0
 public override void ResolveReferences()
 {
     base.ResolveReferences();
     LongEventHandler.ExecuteWhenFinished(delegate
     {
         this.iconMat = MaterialPool.MatFrom(this.texturePath, ShaderDatabase.MetaOverlay);
     });
 }
コード例 #7
0
 public static Material MatFrom(string texPath, bool reportFailure)
 {
     if (texPath != null && !(texPath == "null"))
     {
         MaterialRequest req = new MaterialRequest(ContentFinder <Texture2D> .Get(texPath, reportFailure));
         return(MaterialPool.MatFrom(req));
     }
     return(null);
 }
コード例 #8
0
ファイル: MaterialPool.cs プロジェクト: sachdevs/RW-Decompile
        public static Material MatFrom(string texPath)
        {
            if (texPath == null || texPath == "null")
            {
                return(null);
            }
            MaterialRequest req = new MaterialRequest(ContentFinder <Texture2D> .Get(texPath, true));

            return(MaterialPool.MatFrom(req));
        }
コード例 #9
0
ファイル: GenDraw.cs プロジェクト: potsh/RimWorld
        public static void DrawFieldEdges(List <IntVec3> cells, Color color)
        {
            Map             currentMap = Find.CurrentMap;
            MaterialRequest req        = default(MaterialRequest);

            req.shader      = ShaderDatabase.Transparent;
            req.color       = color;
            req.BaseTexPath = "UI/Overlays/TargetHighlight_Side";
            Material material = MaterialPool.MatFrom(req);

            material.GetTexture("_MainTex").wrapMode = TextureWrapMode.Clamp;
            if (fieldGrid == null)
            {
                fieldGrid = new BoolGrid(currentMap);
            }
            else
            {
                fieldGrid.ClearAndResizeTo(currentMap);
            }
            IntVec3 size  = currentMap.Size;
            int     x     = size.x;
            IntVec3 size2 = currentMap.Size;
            int     z     = size2.z;
            int     count = cells.Count;

            for (int i = 0; i < count; i++)
            {
                if (cells[i].InBounds(currentMap))
                {
                    BoolGrid boolGrid = fieldGrid;
                    IntVec3  intVec   = cells[i];
                    int      x2       = intVec.x;
                    IntVec3  intVec2  = cells[i];
                    boolGrid[x2, intVec2.z] = true;
                }
            }
            for (int j = 0; j < count; j++)
            {
                IntVec3 c = cells[j];
                if (c.InBounds(currentMap))
                {
                    rotNeeded[0] = (c.z < z - 1 && !fieldGrid[c.x, c.z + 1]);
                    rotNeeded[1] = (c.x < x - 1 && !fieldGrid[c.x + 1, c.z]);
                    rotNeeded[2] = (c.z > 0 && !fieldGrid[c.x, c.z - 1]);
                    rotNeeded[3] = (c.x > 0 && !fieldGrid[c.x - 1, c.z]);
                    for (int k = 0; k < 4; k++)
                    {
                        if (rotNeeded[k])
                        {
                            Graphics.DrawMesh(MeshPool.plane10, c.ToVector3ShiftedWithAltitude(AltitudeLayer.MetaOverlays), new Rot4(k).AsQuat, material, 0);
                        }
                    }
                }
            }
        }
コード例 #10
0
 public override void PostLoad()
 {
     base.PostLoad();
     if (this.defName == "UnnamedDef")
     {
         this.defName = "Scatterable_" + this.texturePath;
     }
     LongEventHandler.ExecuteWhenFinished(delegate
     {
         this.mat = MaterialPool.MatFrom(this.texturePath, ShaderDatabase.Transparent);
     });
 }
コード例 #11
0
ファイル: GenDraw.cs プロジェクト: sachdevs/RW-Decompile
        public static void DrawFieldEdges(List <IntVec3> cells, Color color)
        {
            Map      visibleMap = Find.VisibleMap;
            Material material   = MaterialPool.MatFrom(new MaterialRequest
            {
                shader      = ShaderDatabase.Transparent,
                color       = color,
                BaseTexPath = "UI/Overlays/TargetHighlight_Side"
            });

            material.GetTexture("_MainTex").wrapMode = TextureWrapMode.Clamp;
            if (GenDraw.fieldGrid == null)
            {
                GenDraw.fieldGrid = new BoolGrid(visibleMap);
            }
            else
            {
                GenDraw.fieldGrid.ClearAndResizeTo(visibleMap);
            }
            int x     = visibleMap.Size.x;
            int z     = visibleMap.Size.z;
            int count = cells.Count;

            for (int i = 0; i < count; i++)
            {
                if (cells[i].InBounds(visibleMap))
                {
                    GenDraw.fieldGrid[cells[i].x, cells[i].z] = true;
                }
            }
            for (int j = 0; j < count; j++)
            {
                IntVec3 c = cells[j];
                if (c.InBounds(visibleMap))
                {
                    GenDraw.rotNeeded[0] = (c.z < z - 1 && !GenDraw.fieldGrid[c.x, c.z + 1]);
                    GenDraw.rotNeeded[1] = (c.x < x - 1 && !GenDraw.fieldGrid[c.x + 1, c.z]);
                    GenDraw.rotNeeded[2] = (c.z > 0 && !GenDraw.fieldGrid[c.x, c.z - 1]);
                    GenDraw.rotNeeded[3] = (c.x > 0 && !GenDraw.fieldGrid[c.x - 1, c.z]);
                    for (int k = 0; k < 4; k++)
                    {
                        if (GenDraw.rotNeeded[k])
                        {
                            Mesh    arg_219_0 = MeshPool.plane10;
                            Vector3 arg_219_1 = c.ToVector3ShiftedWithAltitude(AltitudeLayer.MetaOverlays);
                            Rot4    rot       = new Rot4(k);
                            Graphics.DrawMesh(arg_219_0, arg_219_1, rot.AsQuat, material, 0);
                        }
                    }
                }
            }
        }
コード例 #12
0
        public static Material MatFrom(string texPath)
        {
            Material result;

            if (texPath == null || texPath == "null")
            {
                result = null;
            }
            else
            {
                MaterialRequest req = new MaterialRequest(ContentFinder <Texture2D> .Get(texPath, true));
                result = MaterialPool.MatFrom(req);
            }
            return(result);
        }
コード例 #13
0
 public void ResolveReferencesSpecial()
 {
     LongEventHandler.ExecuteWhenFinished(delegate
     {
         if (scratches != null)
         {
             scratchMats = new List <Material>();
             for (int i = 0; i < scratches.Count; i++)
             {
                 scratchMats[i] = MaterialPool.MatFrom(scratches[i], ShaderDatabase.Transparent);
             }
         }
         if (cornerTL != null)
         {
             cornerTLMat = MaterialPool.MatFrom(cornerTL, ShaderDatabase.Transparent);
         }
         if (cornerTR != null)
         {
             cornerTRMat = MaterialPool.MatFrom(cornerTR, ShaderDatabase.Transparent);
         }
         if (cornerBL != null)
         {
             cornerBLMat = MaterialPool.MatFrom(cornerBL, ShaderDatabase.Transparent);
         }
         if (cornerBR != null)
         {
             cornerBRMat = MaterialPool.MatFrom(cornerBR, ShaderDatabase.Transparent);
         }
         if (edgeTop != null)
         {
             edgeTopMat = MaterialPool.MatFrom(edgeTop, ShaderDatabase.Transparent);
         }
         if (edgeBot != null)
         {
             edgeBotMat = MaterialPool.MatFrom(edgeBot, ShaderDatabase.Transparent);
         }
         if (edgeLeft != null)
         {
             edgeLeftMat = MaterialPool.MatFrom(edgeLeft, ShaderDatabase.Transparent);
         }
         if (edgeRight != null)
         {
             edgeRightMat = MaterialPool.MatFrom(edgeRight, ShaderDatabase.Transparent);
         }
     });
 }
コード例 #14
0
 private void <ResolveReferencesSpecial> m__0()
 {
     if (this.scratches != null)
     {
         this.scratchMats = new List <Material>();
         for (int i = 0; i < this.scratches.Count; i++)
         {
             this.scratchMats[i] = MaterialPool.MatFrom(this.scratches[i], ShaderDatabase.Transparent);
         }
     }
     if (this.cornerTL != null)
     {
         this.cornerTLMat = MaterialPool.MatFrom(this.cornerTL, ShaderDatabase.Transparent);
     }
     if (this.cornerTR != null)
     {
         this.cornerTRMat = MaterialPool.MatFrom(this.cornerTR, ShaderDatabase.Transparent);
     }
     if (this.cornerBL != null)
     {
         this.cornerBLMat = MaterialPool.MatFrom(this.cornerBL, ShaderDatabase.Transparent);
     }
     if (this.cornerBR != null)
     {
         this.cornerBRMat = MaterialPool.MatFrom(this.cornerBR, ShaderDatabase.Transparent);
     }
     if (this.edgeTop != null)
     {
         this.edgeTopMat = MaterialPool.MatFrom(this.edgeTop, ShaderDatabase.Transparent);
     }
     if (this.edgeBot != null)
     {
         this.edgeBotMat = MaterialPool.MatFrom(this.edgeBot, ShaderDatabase.Transparent);
     }
     if (this.edgeLeft != null)
     {
         this.edgeLeftMat = MaterialPool.MatFrom(this.edgeLeft, ShaderDatabase.Transparent);
     }
     if (this.edgeRight != null)
     {
         this.edgeRightMat = MaterialPool.MatFrom(this.edgeRight, ShaderDatabase.Transparent);
     }
 }
コード例 #15
0
        public override void Init(GraphicRequest req)
        {
            this.data     = req.graphicData;
            this.path     = req.path;
            this.color    = req.color;
            this.colorTwo = req.colorTwo;
            this.drawSize = req.drawSize;
            MaterialRequest req2 = default(MaterialRequest);

            req2.mainTex = ContentFinder <Texture2D> .Get(req.path, true);

            req2.shader      = req.shader;
            req2.color       = this.color;
            req2.colorTwo    = this.colorTwo;
            req2.renderQueue = req.renderQueue;
            if (req.shader.SupportsMaskTex())
            {
                req2.maskTex = ContentFinder <Texture2D> .Get(req.path + Graphic_Single.MaskSuffix, false);
            }
            this.mat = MaterialPool.MatFrom(req2);
        }
コード例 #16
0
        public override void Init(GraphicRequest req)
        {
            data     = req.graphicData;
            path     = req.path;
            color    = req.color;
            colorTwo = req.colorTwo;
            drawSize = req.drawSize;
            MaterialRequest req2 = default(MaterialRequest);

            req2.mainTex = ContentFinder <Texture2D> .Get(req.path);

            req2.shader           = req.shader;
            req2.color            = color;
            req2.colorTwo         = colorTwo;
            req2.renderQueue      = req.renderQueue;
            req2.shaderParameters = req.shaderParameters;
            if (req.shader.SupportsMaskTex())
            {
                req2.maskTex = ContentFinder <Texture2D> .Get(req.path + MaskSuffix, reportFailure : false);
            }
            mat = MaterialPool.MatFrom(req2);
        }
コード例 #17
0
 private void <PostLoad> m__0()
 {
     this.mat = MaterialPool.MatFrom(this.texturePath, ShaderDatabase.Transparent);
 }
コード例 #18
0
        public static Material MatFrom(Texture2D srcTex)
        {
            MaterialRequest req = new MaterialRequest(srcTex);

            return(MaterialPool.MatFrom(req));
        }
コード例 #19
0
        public static Material MatFrom(string texPath, Shader shader, Color color)
        {
            MaterialRequest req = new MaterialRequest(ContentFinder <Texture2D> .Get(texPath, true), shader, color);

            return(MaterialPool.MatFrom(req));
        }
コード例 #20
0
        public override void Init(GraphicRequest req)
        {
            this.data     = req.graphicData;
            this.path     = req.path;
            this.color    = req.color;
            this.colorTwo = req.colorTwo;
            this.drawSize = req.drawSize;
            Texture2D[] array = new Texture2D[this.mats.Length];
            array[0] = ContentFinder <Texture2D> .Get(req.path + "_north", false);

            if (array[0] == null)
            {
                Log.Error("Failed to find any texture while constructing " + this.ToString() + ". Filenames have changed; if you are converting an old mod, recommend renaming textures from *_back to *_north, *_side to *_east, and *_front to *_south.", false);
            }
            else
            {
                array[1] = ContentFinder <Texture2D> .Get(req.path + "_east", false);

                if (array[1] == null)
                {
                    array[1] = array[0];
                }
                array[2] = ContentFinder <Texture2D> .Get(req.path + "_south", false);

                if (array[2] == null)
                {
                    array[2] = array[0];
                }
                array[3] = ContentFinder <Texture2D> .Get(req.path + "_west", false);

                if (array[3] == null)
                {
                    array[3]         = array[1];
                    this.westFlipped = base.WestFlipped;
                }
                Texture2D[] array2 = new Texture2D[this.mats.Length];
                if (req.shader.SupportsMaskTex())
                {
                    array2[0] = ContentFinder <Texture2D> .Get(req.path + "_northm", false);

                    if (array2[0] != null)
                    {
                        array2[1] = ContentFinder <Texture2D> .Get(req.path + "_eastm", false);

                        if (array2[1] == null)
                        {
                            array2[1] = array2[0];
                        }
                        array2[2] = ContentFinder <Texture2D> .Get(req.path + "_southm", false);

                        if (array2[2] == null)
                        {
                            array2[2] = array2[0];
                        }
                        array2[3] = ContentFinder <Texture2D> .Get(req.path + "_westm", false);

                        if (array2[3] == null)
                        {
                            array2[3] = array2[1];
                        }
                    }
                }
                for (int i = 0; i < this.mats.Length; i++)
                {
                    MaterialRequest req2 = default(MaterialRequest);
                    req2.mainTex          = array[i];
                    req2.shader           = req.shader;
                    req2.color            = this.color;
                    req2.colorTwo         = this.colorTwo;
                    req2.maskTex          = array2[i];
                    req2.shaderParameters = req.shaderParameters;
                    this.mats[i]          = MaterialPool.MatFrom(req2);
                }
            }
        }
コード例 #21
0
 private static Material <MatsFromTexturesInFolder> m__0(Texture2D tex)
 {
     return(MaterialPool.MatFrom(tex));
 }
コード例 #22
0
        public static Material MatFrom(Texture2D srcTex, Shader shader, Color color)
        {
            MaterialRequest req = new MaterialRequest(srcTex, shader, color);

            return(MaterialPool.MatFrom(req));
        }
コード例 #23
0
 private void <ResolveReferences> m__0()
 {
     this.iconMat = MaterialPool.MatFrom(this.texturePath, ShaderDatabase.MetaOverlay);
 }
コード例 #24
0
        public override void Init(GraphicRequest req)
        {
            data     = req.graphicData;
            path     = req.path;
            color    = req.color;
            colorTwo = req.colorTwo;
            drawSize = req.drawSize;
            Texture2D[] array = new Texture2D[mats.Length];
            array[0] = ContentFinder <Texture2D> .Get(req.path + "_north", reportFailure : false);

            array[1] = ContentFinder <Texture2D> .Get(req.path + "_east", reportFailure : false);

            array[2] = ContentFinder <Texture2D> .Get(req.path + "_south", reportFailure : false);

            array[3] = ContentFinder <Texture2D> .Get(req.path + "_west", reportFailure : false);

            if (array[0] == null)
            {
                if (array[2] != null)
                {
                    array[0] = array[2];
                    drawRotatedExtraAngleOffset = 180f;
                }
                else if (array[1] != null)
                {
                    array[0] = array[1];
                    drawRotatedExtraAngleOffset = -90f;
                }
                else if (array[3] != null)
                {
                    array[0] = array[3];
                    drawRotatedExtraAngleOffset = 90f;
                }
                else
                {
                    array[0] = ContentFinder <Texture2D> .Get(req.path, reportFailure : false);
                }
            }
            if (array[0] == null)
            {
                Log.Error("Failed to find any textures at " + req.path + " while constructing " + this.ToStringSafe());
                return;
            }
            if (array[2] == null)
            {
                array[2] = array[0];
            }
            if (array[1] == null)
            {
                if (array[3] != null)
                {
                    array[1]    = array[3];
                    eastFlipped = base.DataAllowsFlip;
                }
                else
                {
                    array[1] = array[0];
                }
            }
            if (array[3] == null)
            {
                if (array[1] != null)
                {
                    array[3]    = array[1];
                    westFlipped = base.DataAllowsFlip;
                }
                else
                {
                    array[3] = array[0];
                }
            }
            Texture2D[] array2 = new Texture2D[mats.Length];
            if (req.shader.SupportsMaskTex())
            {
                array2[0] = ContentFinder <Texture2D> .Get(req.path + "_northm", reportFailure : false);

                array2[1] = ContentFinder <Texture2D> .Get(req.path + "_eastm", reportFailure : false);

                array2[2] = ContentFinder <Texture2D> .Get(req.path + "_southm", reportFailure : false);

                array2[3] = ContentFinder <Texture2D> .Get(req.path + "_westm", reportFailure : false);

                if (array2[0] == null)
                {
                    if (array2[2] != null)
                    {
                        array2[0] = array2[2];
                    }
                    else if (array2[1] != null)
                    {
                        array2[0] = array2[1];
                    }
                    else if (array2[3] != null)
                    {
                        array2[0] = array2[3];
                    }
                }
                if (array2[2] == null)
                {
                    array2[2] = array2[0];
                }
                if (array2[1] == null)
                {
                    if (array2[3] != null)
                    {
                        array2[1] = array2[3];
                    }
                    else
                    {
                        array2[1] = array2[0];
                    }
                }
                if (array2[3] == null)
                {
                    if (array2[1] != null)
                    {
                        array2[3] = array2[1];
                    }
                    else
                    {
                        array2[3] = array2[0];
                    }
                }
            }
            for (int i = 0; i < mats.Length; i++)
            {
                MaterialRequest req2 = default(MaterialRequest);
                req2.mainTex          = array[i];
                req2.shader           = req.shader;
                req2.color            = color;
                req2.colorTwo         = colorTwo;
                req2.maskTex          = array2[i];
                req2.shaderParameters = req.shaderParameters;
                mats[i] = MaterialPool.MatFrom(req2);
            }
        }
コード例 #25
0
        public override void Init(GraphicRequest req)
        {
            this.data     = req.graphicData;
            this.path     = req.path;
            this.color    = req.color;
            this.colorTwo = req.colorTwo;
            this.drawSize = req.drawSize;
            Texture2D[] array = new Texture2D[4];
            array[0] = ContentFinder <Texture2D> .Get(req.path + "_north", false);

            if (array[0] == null)
            {
                Log.Error("Failed to find any texture while constructing " + this);
                return;
            }
            array[1] = ContentFinder <Texture2D> .Get(req.path + "_east", false);

            if (array[1] == null)
            {
                array[1] = array[0];
            }
            array[2] = ContentFinder <Texture2D> .Get(req.path + "_south", false);

            if (array[2] == null)
            {
                array[2] = array[0];
            }
            array[3] = ContentFinder <Texture2D> .Get(req.path + "_west", false);

            if (array[3] == null)
            {
                array[3] = array[1];
            }

            Texture2D[] array2 = new Texture2D[4];
            if (req.shader.SupportsMaskTex())
            {
                array2[0] = ContentFinder <Texture2D> .Get(req.path + "_northm", false);

                if (array2[0] == null)
                {
                    array2[0] = FaceTextures.RedTexture;
                }
                array2[1] = ContentFinder <Texture2D> .Get(req.path + "_eastm", false);

                if (array2[1] == null)
                {
                    array2[1] = FaceTextures.RedTexture;
                }
                array2[2] = ContentFinder <Texture2D> .Get(req.path + "_southm", false);

                if (array2[2] == null)
                {
                    array2[2] = FaceTextures.RedTexture;
                }
                array2[3] = ContentFinder <Texture2D> .Get(req.path + "_westm", false);

                if (array2[3] == null)
                {
                    array2[3] = FaceTextures.RedTexture;
                }
            }
            for (int i = 0; i < 4; i++)
            {
                MaterialRequest req2 = default;
                req2.mainTex  = array[i];
                req2.shader   = req.shader;
                req2.color    = this.color;
                req2.colorTwo = this.colorTwo;
                req2.maskTex  = array2[i];
                this.mats[i]  = MaterialPool.MatFrom(req2);
            }
        }