Пример #1
0
        public static TriColorGraphic Get(
            System.Type graphicClass,
            string path,
            Shader shader,
            Vector2 drawSize,
            Color color,
            Color colorTwo,
            Color colorThree,
            GraphicData data,
            List <ShaderParameter> shaderParameters)
        {
            TriColorGraphicRequest req = new TriColorGraphicRequest(graphicClass, path, shader, drawSize, color, colorTwo, colorThree, data, 0, shaderParameters);

            if (req.graphicClass == typeof(Graphic_Multi))
            {
                return((TriColorGraphic)TriColorGraphicDatabase.GetInner <TriColorGraphic_Multi>(req));
            }
            try
            {
                return((TriColorGraphic)GenGeneric.InvokeStaticGenericMethod(typeof(TriColorGraphicDatabase), req.graphicClass, "GetInner", (object)req));
            }
            catch (Exception ex)
            {
                Log.Error("Exception getting " + (object)graphicClass + " at " + path + ": " + ex.ToString(), false);
            }
            return((TriColorGraphic)BaseContent.BadGraphic);
        }
Пример #2
0
        private static T GetInner <T>(TriColorGraphicRequest req) where T : TriColorGraphic, new()
        {
            req.color      = (Color)(Color32)req.color;
            req.colorTwo   = (Color)(Color32)req.colorTwo;
            req.colorThree = (Color)(Color32)req.colorThree;
            TriColorGraphic graphic;

            if (!TriColorGraphicDatabase.allGraphics.TryGetValue(req, out graphic))
            {
                graphic = (TriColorGraphic) new T();
                graphic.Init(req);
                TriColorGraphicDatabase.allGraphics.Add(req, graphic);
            }
            return((T)graphic);
        }
Пример #3
0
 public virtual void Init(TriColorGraphicRequest req)
 {
     Log.ErrorOnce("Cannot init Graphic of class " + this.GetType().ToString(), 658928, false);
 }
Пример #4
0
        public override void Init(TriColorGraphicRequest req)
        {
            this.data       = req.graphicData;
            this.path       = req.path;
            this.color      = req.color;
            this.colorTwo   = req.colorTwo;
            this.colorThree = req.colorThree;
            this.drawSize   = req.drawSize;
            Texture2D[] texture2DArray1 = new Texture2D[this.mats.Length];
            texture2DArray1[0] = ContentFinder <Texture2D> .Get(req.path + "_north", false);

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

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

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

            if (texture2DArray1[0] == null)
            {
                if (texture2DArray1[2] != null)
                {
                    texture2DArray1[0] = texture2DArray1[2];
                    this.drawRotatedExtraAngleOffset = 180f;
                }
                else if (texture2DArray1[1] != null)
                {
                    texture2DArray1[0] = texture2DArray1[1];
                    this.drawRotatedExtraAngleOffset = -90f;
                }
                else if (texture2DArray1[3] != null)
                {
                    texture2DArray1[0] = texture2DArray1[3];
                    this.drawRotatedExtraAngleOffset = 90f;
                }
                else
                {
                    texture2DArray1[0] = ContentFinder <Texture2D> .Get(req.path, false);
                }
            }
            if (texture2DArray1[0] == null)
            {
                Log.Error("Failed to find any textures at " + req.path + " while constructing " + this.ToStringSafe <TriColorGraphic_Multi>(), false);
            }

            else
            {
                if (texture2DArray1[2] == null)
                {
                    texture2DArray1[2] = texture2DArray1[0];
                }
                if (texture2DArray1[1] == null)
                {
                    if (texture2DArray1[3] != null)
                    {
                        texture2DArray1[1] = texture2DArray1[3];
                        this.eastFlipped   = this.DataAllowsFlip;
                    }
                    else
                    {
                        texture2DArray1[1] = texture2DArray1[0];
                    }
                }
                if (texture2DArray1[3] == null)
                {
                    if (texture2DArray1[1] != null)
                    {
                        texture2DArray1[3] = texture2DArray1[1];
                        this.westFlipped   = this.DataAllowsFlip;
                    }
                    else
                    {
                        texture2DArray1[3] = texture2DArray1[0];
                    }
                }
                Texture2D[] texture2DArray2 = new Texture2D[this.mats.Length];
                if (req.shader == TriColorShaderDatabase.Tricolor)
                {
                    texture2DArray2[0] = ContentFinder <Texture2D> .Get(req.path + "_northm", false);

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

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

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

                    if (texture2DArray2[0] == null)
                    {
                        if (texture2DArray2[2] != null)
                        {
                            texture2DArray2[0] = texture2DArray2[2];
                        }
                        else if (texture2DArray2[1] != null)
                        {
                            texture2DArray2[0] = texture2DArray2[1];
                        }
                        else if (texture2DArray2[3] != null)
                        {
                            texture2DArray2[0] = texture2DArray2[3];
                        }
                    }
                    if (texture2DArray2[2] == null)
                    {
                        texture2DArray2[2] = texture2DArray2[0];
                    }
                    if (texture2DArray2[1] == null)
                    {
                        texture2DArray2[1] = !(texture2DArray2[3] != null) ? texture2DArray2[0] : texture2DArray2[3];
                    }
                    if (texture2DArray2[3] == null)
                    {
                        texture2DArray2[3] = !(texture2DArray2[1] != null) ? texture2DArray2[0] : texture2DArray2[1];
                    }
                }
                for (int index = 0; index < this.mats.Length; ++index)
                {
                    this.mats[index] = TriColorMaterialPool.MatFrom(new TriColorMaterialRequest()
                    {
                        mainTex          = texture2DArray1[index],
                        shader           = req.shader,
                        color            = this.color,
                        colorTwo         = this.colorTwo,
                        colorThree       = this.colorThree,
                        maskTex          = texture2DArray2[index],
                        shaderParameters = req.shaderParameters
                    });
                }
                ;
            }
        }