Exemplo n.º 1
0
        public override void Init(AvaliGraphicRequest req)
        {
            this.data     = req.graphicData;
            this.path     = req.path;
            this.color    = req.color;
            this.drawSize = req.drawSize;
            List <StuffAppearanceDef> defsListForReading = DefDatabase <StuffAppearanceDef> .AllDefsListForReading;

            this.subGraphics = new AvaliGraphic[defsListForReading.Count];
            for (int index = 0; index < this.subGraphics.Length; ++index)
            {
                StuffAppearanceDef stuffAppearance = defsListForReading[index];
                string             folderPath      = req.path;
                if (!stuffAppearance.pathPrefix.NullOrEmpty())
                {
                    folderPath = stuffAppearance.pathPrefix + "/" + ((IEnumerable <string>)folderPath.Split('/')).Last <string>();
                }
                Texture2D texture2D = ContentFinder <Texture2D> .GetAllInFolder(folderPath).Where <Texture2D>((Func <Texture2D, bool>)(x => x.name.EndsWith(stuffAppearance.defName))).FirstOrDefault <Texture2D>();

                if ((UnityEngine.Object)texture2D != (UnityEngine.Object)null)
                {
                    this.subGraphics[index] = AvaliGraphicDatabase.Get <AvaliGraphic_Single>(folderPath + "/" + texture2D.name, req.shader, this.drawSize, this.color);
                }
            }
            for (int index = 0; index < this.subGraphics.Length; ++index)
            {
                if (this.subGraphics[index] == null)
                {
                    this.subGraphics[index] = this.subGraphics[(int)StuffAppearanceDefOf.Smooth.index];
                }
            }
        }
Exemplo n.º 2
0
        public override void Init(AvaliGraphicRequest req)
        {
            this.data = req.graphicData;
            if (req.path.NullOrEmpty())
            {
                throw new ArgumentNullException("folderPath");
            }
            if ((UnityEngine.Object)req.shader == (UnityEngine.Object)null)
            {
                throw new ArgumentNullException("shader");
            }
            this.path     = req.path;
            this.color    = req.color;
            this.colorTwo = req.colorTwo;
            this.drawSize = req.drawSize;
            List <Texture2D> list = ContentFinder <Texture2D> .GetAllInFolder(req.path).Where <Texture2D>((Func <Texture2D, bool>)(x => !x.name.EndsWith(Graphic_Single.MaskSuffix))).OrderBy <Texture2D, string>((Func <Texture2D, string>)(x => x.name)).ToList <Texture2D>();

            if (list.NullOrEmpty <Texture2D>())
            {
                Log.Error("Collection cannot init: No textures found at path " + req.path, false);
                this.subGraphics = new AvaliGraphic[1]
                {
                    AvaliBaseContent.BadGraphic
                };
            }
            else
            {
                this.subGraphics = new AvaliGraphic[list.Count];
                for (int index = 0; index < list.Count; ++index)
                {
                    string path = req.path + "/" + list[index].name;
                    this.subGraphics[index] = AvaliGraphicDatabase.Get(typeof(Graphic_Single), path, req.shader, this.drawSize, this.color, this.colorTwo, this.colorThree, (AvaliGraphicData)null, req.shaderParameters);
                }
            }
        }
Exemplo n.º 3
0
        private static T GetInner <T>(AvaliGraphicRequest req) where T : AvaliGraphic, new()
        {
            req.color      = (Color)(Color32)req.color;
            req.colorTwo   = (Color)(Color32)req.colorTwo;
            req.colorThree = (Color)(Color32)req.colorThree;
            AvaliGraphic graphic;

            if (!AvaliGraphicDatabase.allGraphics.TryGetValue(req, out graphic))
            {
                graphic = (AvaliGraphic) new T();
                graphic.Init(req);
                AvaliGraphicDatabase.allGraphics.Add(req, graphic);
            }
            return((T)graphic);
        }
Exemplo n.º 4
0
        public override void Init(AvaliGraphicRequest req)
        {
            this.data     = req.graphicData;
            this.path     = req.path;
            this.color    = req.color;
            this.colorTwo = req.colorTwo;
            this.drawSize = req.drawSize;
            MaterialRequest req1 = new MaterialRequest();

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

            req1.shader           = req.shader;
            req1.color            = this.color;
            req1.colorTwo         = this.colorTwo;
            req1.renderQueue      = req.renderQueue;
            req1.shaderParameters = req.shaderParameters;
            if (req.shader.SupportsMaskTex())
            {
                req1.maskTex = ContentFinder <Texture2D> .Get(req.path + Graphic_Single.MaskSuffix, false);
            }
            this.mat = MaterialPool.MatFrom(req1);
        }
Exemplo n.º 5
0
        public override void Init(AvaliGraphicRequest 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 <AvaliGraphic_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.SupportsMaskTex())
                if (req.shader == AvaliShaderDatabase.Tricolor)
                {
                    //Log.Message("Generating MaskTex");
                    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] = MaterialPool.MatFrom(new MaterialRequest()
                    this.mats[index] = AvaliMaterialPool.MatFrom(new AvaliMaterialRequest()
                    {
                        mainTex          = texture2DArray1[index],
                        shader           = req.shader,
                        color            = this.color,
                        colorTwo         = this.colorTwo,
                        colorThree       = this.colorThree,
                        maskTex          = texture2DArray2[index],
                        shaderParameters = req.shaderParameters
                    });
                }
                ;
            }
        }
Exemplo n.º 6
0
 public override void Init(AvaliGraphicRequest req)
 {
     base.Init(req);
 }
Exemplo n.º 7
0
        public static AvaliGraphic Get(
            System.Type graphicClass,
            string path,
            Shader shader,
            Vector2 drawSize,
            Color color,
            Color colorTwo,
            Color colorThree,
            AvaliGraphicData data,
            List <ShaderParameter> shaderParameters)
        {
            AvaliGraphicRequest req = new AvaliGraphicRequest(graphicClass, path, shader, drawSize, color, colorTwo, colorThree, data, 0, shaderParameters);

            // liQdComment 2 This is what the game requests
            if (req.graphicClass == typeof(Graphic_Multi))
            {
                //Log.Message("AvaliGraphic request of type Graphic_Multi");
                return((AvaliGraphic)AvaliGraphicDatabase.GetInner <AvaliGraphic_Multi>(req));
            }
            if (req.graphicClass == typeof(AvaliGraphic_Single))
            {
                return((AvaliGraphic)AvaliGraphicDatabase.GetInner <AvaliGraphic_Single>(req));
            }
            if (req.graphicClass == typeof(AvaliGraphic_Terrain))
            {
                return((AvaliGraphic)AvaliGraphicDatabase.GetInner <AvaliGraphic_Terrain>(req));
            }
            if (req.graphicClass == typeof(AvaliGraphic_Multi))
            {
                return((AvaliGraphic)AvaliGraphicDatabase.GetInner <AvaliGraphic_Multi>(req));
            }
            if (req.graphicClass == typeof(AvaliGraphic_Mote))
            {
                return((AvaliGraphic)AvaliGraphicDatabase.GetInner <AvaliGraphic_Mote>(req));
            }
            if (req.graphicClass == typeof(AvaliGraphic_Random))
            {
                return((AvaliGraphic)AvaliGraphicDatabase.GetInner <AvaliGraphic_Random>(req));
            }
            if (req.graphicClass == typeof(AvaliGraphic_Flicker))
            {
                return((AvaliGraphic)AvaliGraphicDatabase.GetInner <AvaliGraphic_Flicker>(req));
            }
            if (req.graphicClass == typeof(AvaliGraphic_Appearances))
            {
                return((AvaliGraphic)AvaliGraphicDatabase.GetInner <AvaliGraphic_Appearances>(req));
            }
            if (req.graphicClass == typeof(AvaliGraphic_StackCount))
            {
                return((AvaliGraphic)AvaliGraphicDatabase.GetInner <AvaliGraphic_StackCount>(req));
            }
            try
            {
                return((AvaliGraphic)GenGeneric.InvokeStaticGenericMethod(typeof(AvaliGraphicDatabase), req.graphicClass, "GetInner", (object)req));
            }
            catch (Exception ex)
            {
                Log.Error("Exception getting " + (object)graphicClass + " at " + path + ": " + ex.ToString(), false);
            }
            return(AvaliBaseContent.BadGraphic);
        }
Exemplo n.º 8
0
 public virtual void Init(AvaliGraphicRequest req)
 {
     Log.ErrorOnce("Cannot init Graphic of class " + this.GetType().ToString(), 658928, false);
 }