Beispiel #1
0
        public override void Init(GraphicRequest req)
        {
            base.data     = req.graphicData;
            base.path     = req.path;
            base.color    = req.color;
            base.colorTwo = req.colorTwo;
            base.drawSize = req.drawSize;
            Texture2D[] array = new Texture2D[3]
            {
                ContentFinder <Texture2D> .Get(req.path + "_back", false),
                null,
                null
            };
            if ((Object)array[0] == (Object)null)
            {
                Log.Error("Failed to find any texture while constructing " + this.ToString());
            }
            else
            {
                array[1] = ContentFinder <Texture2D> .Get(req.path + "_side", false);

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

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

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

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

                        if ((Object)array2[2] == (Object)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    = base.color;
                    req2.colorTwo = base.colorTwo;
                    req2.maskTex  = array2[i];
                    this.mats[i]  = MaterialPool.MatFrom(req2);
                }
            }
        }
        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));
        }
Beispiel #3
0
 public static Material MatFrom(string texPath, Shader shader, Color color)
 {
     return(MatFrom(new MaterialRequest(ContentFinder <Texture2D> .Get(texPath), shader, color)));
 }
 private void <PostLoad> m__0()
 {
     this.icon = ContentFinder <Texture2D> .Get(this.iconPath, true);
 }
Beispiel #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[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);
            }
        }
Beispiel #6
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))
                    {
                        Log.Error("Failed to find any texture while constructing " + this.ToStringSafe() + ". Filenames have changed; if you are converting an old mod, recommend renaming textures from *_back to *_north, *_side to *_east, and *_front to *_south.");
                        return;
                    }
                    array[0] = array[3];
                    drawRotatedExtraAngleOffset = 90f;
                }
            }
            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);
            }
        }