/// <summary>
 /// Load shader asset for RGB shader types
 /// </summary>
 /// <param name="__instance"></param>
 /// <param name="___shaderInt"></param>
 public static void ShaderFromAssetBundle(ShaderTypeDef __instance, ref Shader ___shaderInt)
 {
     if (__instance is RGBShaderTypeDef)
     {
         ___shaderInt = AssetBundleDatabase.LoadAssetBundleShader(__instance.shaderPath);
     }
 }
 public override void ResolveReferences()
 {
     base.ResolveReferences();
     if (shaderType == null)
     {
         shaderType = ShaderTypeDefOf.Cutout;
     }
 }
Example #3
0
        // Token: 0x06000036 RID: 54 RVA: 0x000031C4 File Offset: 0x000013C4
        public Graphic GetColoredVersion(ShaderTypeDef newShaderType, Color newColor, Color newColorTwo,
                                         ShadowData newShadowData)
        {
            var graphicData = new GraphicData();

            graphicData.CopyFrom(data);
            graphicData.shaderType = newShaderType;
            graphicData.color      = newColor;
            graphicData.colorTwo   = newColorTwo;
            graphicData.shadowData = newShadowData;
            return(graphicData.Graphic);
        }
Example #4
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);
        }
Example #5
0
        public override void ResolveReferences()
        {
            base.ResolveReferences();

            if (this.shader == null)
            {
                this.shader = ShaderTypeDefOf.Cutout;
            }

            foreach (string tag in this.tags)
            {
                if (!tagDictionary.ContainsKey(tag))
                {
                    tagDictionary.Add(tag, new List <FacepaintDef>());
                }
                tagDictionary[tag].Add(this);
            }
        }
        public void ChangeGraphic()
        {
            Vector2       sizeVector   = this.parent.Graphic.drawSize;
            Color         objectColour = this.parent.Graphic.color;
            ShaderTypeDef shaderUsed   = this.parent.def.graphicData.shaderType;

            if (this.parent.Faction != null && this.parent.Faction.IsPlayer)
            {
                if (this.parent.def.graphicData.graphicClass == typeof(Graphic_Multi))
                {
                    if (newGraphicPath == "")
                    {
                        newGraphicPath = Props.randomGraphics.RandomElement();
                        newGraphic     = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(newGraphicPath, shaderUsed.Shader, sizeVector, objectColour);
                    }
                    else
                    {
                        newGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(newGraphicPath, shaderUsed.Shader, sizeVector, objectColour);
                    }
                    Type      typ  = typeof(Thing);
                    FieldInfo type = typ.GetField("graphicInt", BindingFlags.Instance | BindingFlags.NonPublic);
                    type.SetValue(thingToGrab, newGraphic);
                }
                else if (this.parent.def.graphicData.graphicClass == typeof(Graphic_Single))
                {
                    if (newGraphicSinglePath == "")
                    {
                        newGraphicSinglePath = Props.randomGraphics.RandomElement();
                        newGraphicSingle     = (Graphic_Single)GraphicDatabase.Get <Graphic_Single>(newGraphicSinglePath, shaderUsed.Shader, sizeVector, objectColour);
                    }
                    else
                    {
                        newGraphicSingle = (Graphic_Single)GraphicDatabase.Get <Graphic_Single>(newGraphicSinglePath, shaderUsed.Shader, sizeVector, objectColour);
                    }
                    Type      typ  = typeof(Thing);
                    FieldInfo type = typ.GetField("graphicInt", BindingFlags.Instance | BindingFlags.NonPublic);
                    type.SetValue(thingToGrab, newGraphicSingle);
                }
            }
        }
        public void ChangeGraphic()
        {
            Vector2       sizeVector   = this.parent.Graphic.drawSize;
            Color         objectColour = this.parent.Graphic.color;
            ShaderTypeDef shaderUsed   = this.parent.def.graphicData.shaderType;

            if (!reloading)
            {
                int newGraphicPathIndex = Props.newGraphics.IndexOf(newGraphicPath);
                if (newGraphicPathIndex + 1 > Props.newGraphics.Count - 1)
                {
                    newGraphicPathIndex = 0;
                }
                else
                {
                    newGraphicPathIndex++;
                }
                newGraphicPath = Props.newGraphics[newGraphicPathIndex];
                newGraphic     = (Graphic_Random)GraphicDatabase.Get <Graphic_Random>(newGraphicPath, shaderUsed.Shader, sizeVector, objectColour);
            }
            else
            {
                if (newGraphicPath == "")
                {
                    newGraphicPath = Props.newGraphics[0];
                    newGraphic     = (Graphic_Random)GraphicDatabase.Get <Graphic_Random>(newGraphicPath, shaderUsed.Shader, sizeVector, objectColour);
                }
                else
                {
                    newGraphic = (Graphic_Random)GraphicDatabase.Get <Graphic_Random>(newGraphicPath, shaderUsed.Shader, sizeVector, objectColour);
                }
                reloading = false;
            }
            Type      typ  = typeof(Thing);
            FieldInfo type = typ.GetField("graphicInt", BindingFlags.Instance | BindingFlags.NonPublic);

            type.SetValue(thingToGrab, newGraphic);
        }
Example #8
0
 public void CopyFrom(AvaliGraphicData other)
 {
     this.texPath                   = other.texPath;
     this.graphicClass              = other.graphicClass;
     this.shaderType                = other.shaderType;
     this.color                     = other.color;
     this.colorTwo                  = other.colorTwo;
     this.colorThree                = other.colorThree;
     this.drawSize                  = other.drawSize;
     this.drawOffset                = other.drawOffset;
     this.drawOffsetNorth           = other.drawOffsetNorth;
     this.drawOffsetEast            = other.drawOffsetEast;
     this.drawOffsetSouth           = other.drawOffsetSouth;
     this.drawOffsetWest            = other.drawOffsetSouth;
     this.onGroundRandomRotateAngle = other.onGroundRandomRotateAngle;
     this.drawRotated               = other.drawRotated;
     this.allowFlip                 = other.allowFlip;
     this.flipExtraRotation         = other.flipExtraRotation;
     this.shadowData                = other.shadowData;
     this.damageData                = other.damageData;
     this.linkType                  = other.linkType;
     this.linkFlags                 = other.linkFlags;
     this.cachedGraphic             = (AvaliGraphic)null;
 }
Example #9
0
 public static ShaderTypeDef MakeMetaIfOverFog(ShaderTypeDef def)
 {
     return(GhostOverFogChecker.ghostIsOverFog ? ShaderTypeDefOf.MetaOverlay : def);
 }
        public void ChangeGraphic()
        {
            try
            {
                Vector2       sizeVector   = parent.Graphic.drawSize;
                Color         objectColour = parent.Graphic.color;
                ShaderTypeDef shaderUsed   = parent.def.graphicData.shaderType;

                if (parent.Faction != null && parent.Faction.IsPlayer)
                {
                    if (parent.def.graphicData.graphicClass == typeof(Graphic_Multi))
                    {
                        if (!VFECore.VFEGlobal.settings.isRandomGraphic)
                        {
                            if (!reloading)
                            {
                                int newGraphicPathIndex = Props.randomGraphics.IndexOf(newGraphicPath);
                                if (newGraphicPathIndex + 1 > Props.randomGraphics.Count - 1)
                                {
                                    newGraphicPathIndex = 0;
                                }
                                else
                                {
                                    newGraphicPathIndex++;
                                }
                                newGraphicPath = Props.randomGraphics[newGraphicPathIndex];
                                newGraphic     = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(newGraphicPath, shaderUsed.Shader, sizeVector, objectColour);
                            }
                            else
                            {
                                if (newGraphicPath == "")
                                {
                                    newGraphicPath = Props.randomGraphics[0];
                                    newGraphic     = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(newGraphicPath, shaderUsed.Shader, sizeVector, objectColour);
                                }
                                else
                                {
                                    newGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(newGraphicPath, shaderUsed.Shader, sizeVector, objectColour);
                                }
                                reloading = false;
                            }
                        }
                        else if (newGraphicPath == "")
                        {
                            newGraphicPath = Props.randomGraphics.RandomElement();
                            newGraphic     = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(newGraphicPath, shaderUsed.Shader, sizeVector, objectColour);
                        }
                        else
                        {
                            newGraphic = (Graphic_Multi)GraphicDatabase.Get <Graphic_Multi>(newGraphicPath, shaderUsed.Shader, sizeVector, objectColour);
                        }
                        Type      typ  = typeof(Thing);
                        FieldInfo type = typ.GetField("graphicInt", BindingFlags.Instance | BindingFlags.NonPublic);
                        type.SetValue(thingToGrab, newGraphic);
                    }
                    else if (parent.def.graphicData.graphicClass == typeof(Graphic_Single))
                    {
                        if (!VFECore.VFEGlobal.settings.isRandomGraphic)
                        {
                            if (!reloading)
                            {
                                int newGraphicPathIndex = Props.randomGraphics.IndexOf(newGraphicSinglePath);
                                if (newGraphicPathIndex + 1 > Props.randomGraphics.Count - 1)
                                {
                                    newGraphicPathIndex = 0;
                                }
                                else
                                {
                                    newGraphicPathIndex++;
                                }
                                newGraphicSinglePath = Props.randomGraphics[newGraphicPathIndex];
                                newGraphicSingle     = (Graphic_Single)GraphicDatabase.Get <Graphic_Single>(newGraphicSinglePath, shaderUsed.Shader, sizeVector, objectColour);
                            }
                            else
                            {
                                if (newGraphicSinglePath == "")
                                {
                                    newGraphicSinglePath = Props.randomGraphics[0];
                                    newGraphicSingle     = (Graphic_Single)GraphicDatabase.Get <Graphic_Single>(newGraphicSinglePath, shaderUsed.Shader, sizeVector, objectColour);
                                }
                                else
                                {
                                    newGraphicSingle = (Graphic_Single)GraphicDatabase.Get <Graphic_Single>(newGraphicSinglePath, shaderUsed.Shader, sizeVector, objectColour);
                                }
                                reloading = false;
                            }
                        }
                        else
                        if (newGraphicSinglePath == "")
                        {
                            newGraphicSinglePath = Props.randomGraphics.RandomElement();
                            newGraphicSingle     = (Graphic_Single)GraphicDatabase.Get <Graphic_Single>(newGraphicSinglePath, shaderUsed.Shader, sizeVector, objectColour);
                        }
                        else
                        {
                            newGraphicSingle = (Graphic_Single)GraphicDatabase.Get <Graphic_Single>(newGraphicSinglePath, shaderUsed.Shader, sizeVector, objectColour);
                        }
                        Type      typ  = typeof(Thing);
                        FieldInfo type = typ.GetField("graphicInt", BindingFlags.Instance | BindingFlags.NonPublic);
                        type.SetValue(thingToGrab, newGraphicSingle);
                    }
                }
            }
            catch (Exception) { Log.Message("The variations mod has probably been added to a running save. Ignoring load error."); }
        }