Пример #1
0
        public override void Init(GraphicRequestRGB req, bool cacheResults = true)
        {
            if (cacheResults is true)
            {
                masks           = new Texture2D[MatCount];
                maskMatPatterns = new Dictionary <PatternDef, Pair <string, Material[]> >();
            }
            data       = req.graphicData;
            path       = req.path;
            color      = req.color;
            colorTwo   = req.colorTwo;
            colorThree = req.colorThree;
            tiles      = req.tiles;
            drawSize   = req.drawSize;
            var files = ContentFinder <Texture2D> .GetAllInFolder(req.path);

            List <Texture2D> list = (from x in files
                                     where !x.name.EndsWith(MaskSuffix)
                                     orderby x.name
                                     select x).ToList();
            List <Texture2D> listM = (from x in files
                                      where x.name.EndsWith(MaskSuffix)
                                      orderby x.name
                                      select x).ToList();

            if (list.NullOrEmpty())
            {
                Log.Error("Collection cannot init: No textures found at path " + req.path);
                graphicPaths = new string[]
                {
                    BaseContent.BadGraphic.path
                };
                return;
            }
            graphicPaths = new string[list.Count];
            subGraphics  = new Graphic_Cannon[list.Count];
            subTextures  = list.ToArray();
            if (list.Count != listM.Count && !listM.NullOrEmpty())
            {
                Log.Error($"{VehicleHarmony.LogLabel} Could not apply masks for animation classes at path {req.path}. " +
                          $"Mask and texture count do not match up." +
                          $"\nMainTextures: {list.Count} Masks: {listM.Count}");
                graphicPaths = new string[]
                {
                    BaseContent.BadGraphic.path
                };
                return;
            }
            for (int i = 0; i < list.Count; i++)
            {
                string fullPath = string.Concat(req.path, '/', list[i].name);
                graphicPaths[i] = fullPath;
                subGraphics[i]  = GraphicDatabaseRGB.Get <Graphic_Cannon>(fullPath, req.shader, req.drawSize, req.color, req.colorTwo, req.colorThree, req.tiles,
                                                                          req.displacement.x, req.displacement.y, DataRGB, req.shaderParameters) as Graphic_Cannon;
            }
        }
Пример #2
0
 public Graphic SubGraphicCycle(int index, Shader newShader, Color colorOne, Color colorTwo, Color colorThree, float tiles = 1, float displacementX = 0, float displacementY = 0)
 {
     if (index > (graphicPaths.Length - 1))
     {
         Log.Warning($"Graphic Retrieval for Graphic_CannonAnimate indexed past maximum length of {graphicPaths.Length}. Self correcting.");
         while (index > (graphicPaths.Length - 1))
         {
             index -= (graphicPaths.Length - 1);
         }
     }
     return(GraphicDatabaseRGB.Get <Graphic_Cannon>(graphicPaths[index], newShader, drawSize, colorOne, colorTwo, colorThree, tiles, displacementX, displacementY, DataRGB));
 }
Пример #3
0
        public virtual void Init()
        {
            if (graphicClass is null)
            {
                cachedRGBGraphic = null;
                return;
            }
            ShaderTypeDef cutout = shaderType;

            if (cutout == null)
            {
                cutout = RGBShaderTypeDefOf.CutoutComplexRGB;
            }
            Shader shader = cutout.Shader;

            cachedRGBGraphic = GraphicDatabaseRGB.Get(graphicClass, texPath, shader, drawSize, color, colorTwo, colorThree, tiles, displacement.x, displacement.y, this, shaderParameters);
            AccessTools.Field(typeof(GraphicData), "cachedGraphic").SetValue(this, cachedRGBGraphic);
        }
Пример #4
0
 public override Graphic_RGB GetColoredVersion(Shader shader, Color colorOne, Color colorTwo, Color colorThree, float tiles = 1, float displacementX = 0, float displacementY = 0)
 {
     return(GraphicDatabaseRGB.Get <Graphic_CannonAnimate>(path, shader, drawSize, colorOne, colorTwo, colorThree, tiles, displacementX, displacementY, DataRGB));
 }