Beispiel #1
0
        public static Graphic GhostGraphicFor(Graphic baseGraphic, ThingDef thingDef, Color ghostCol)
        {
            int seed = 0;

            seed = Gen.HashCombine(seed, baseGraphic);
            seed = Gen.HashCombine(seed, thingDef);
            seed = Gen.HashCombineStruct(seed, ghostCol);
            if (!ghostGraphics.TryGetValue(seed, out Graphic value))
            {
                if (thingDef.graphicData.Linked || thingDef.IsDoor)
                {
                    value = GraphicDatabase.Get <Graphic_Single>(thingDef.uiIconPath, ShaderTypeDefOf.EdgeDetect.Shader, thingDef.graphicData.drawSize, ghostCol);
                }
                else
                {
                    if (baseGraphic == null)
                    {
                        baseGraphic = thingDef.graphic;
                    }
                    GraphicData graphicData = null;
                    if (baseGraphic.data != null)
                    {
                        graphicData = new GraphicData();
                        graphicData.CopyFrom(baseGraphic.data);
                        graphicData.shadowData = null;
                    }
                    value = GraphicDatabase.Get(baseGraphic.GetType(), baseGraphic.path, ShaderTypeDefOf.EdgeDetect.Shader, baseGraphic.drawSize, ghostCol, Color.white, graphicData, null);
                }
                ghostGraphics.Add(seed, value);
            }
            return(value);
        }
Beispiel #2
0
        private static Graphic GhostGraphicFor(Graphic baseGraphic, ThingDef thingDef, Color ghostCol)
        {
            int num = 0;

            num = Gen.HashCombine <Graphic>(num, baseGraphic);
            num = Gen.HashCombine <ThingDef>(num, thingDef);
            num = Gen.HashCombineStruct <Color>(num, ghostCol);
            Graphic graphic;

            if (!GhostDrawer.ghostGraphics.TryGetValue(num, out graphic))
            {
                if (thingDef.graphicData.Linked || thingDef.IsDoor)
                {
                    graphic = GraphicDatabase.Get <Graphic_Single>(thingDef.uiIconPath, ShaderDatabase.Transparent, thingDef.graphicData.drawSize, ghostCol);
                }
                else
                {
                    if (baseGraphic == null)
                    {
                        baseGraphic = thingDef.graphic;
                    }
                    GraphicData graphicData = null;
                    if (baseGraphic.data != null && baseGraphic.ShadowGraphic != null)
                    {
                        graphicData = new GraphicData();
                        graphicData.CopyFrom(baseGraphic.data);
                        graphicData.shadowData = null;
                    }
                    graphic = GraphicDatabase.Get(baseGraphic.GetType(), baseGraphic.path, ShaderDatabase.Transparent, baseGraphic.drawSize, ghostCol, Color.white, graphicData);
                }
                GhostDrawer.ghostGraphics.Add(num, graphic);
            }
            return(graphic);
        }
Beispiel #3
0
        public Graphic Graphic(Graphic graphic)
        {
            if (_graphic == null)
            {
                if (Props.randomised)
                {
                    Traverse traverse = Traverse.Create(graphic);
                    if (graphic.GetType() == typeof(Graphic_RandomRotated))
                    {
                        Graphic_Random subGraphic = (Graphic_Random)AM_Graphic_RandomRotated_DrawWorker_Debuff_Patch.subgraphic.GetValue(graphic);
                        if (subGraphic != null)
                        {
                            Traverse  traverse2   = Traverse.Create(subGraphic);
                            Graphic[] subGraphics = (Graphic[])AM_Graphic_RandomRotated_DrawWorker_Debuff_Patch.subgraphics.GetValue(subGraphic);
                            if (!subGraphics.NullOrEmpty())
                            {
                                List <Verse.Graphic> gfx = subGraphics.Where(x => !x.path.EndsWith("_Glow") && !x.path.EndsWith("m")).ToList();
                                if (gfxint == -1)
                                {
                                    gfxint = Rand.Range(0, gfx.Count());
                                    //    Log.Message("gfxint is Rand.Range(0, subGraphics.Count())");
                                }
                                if (true)
                                {
                                    ;
                                }
                                _graphic = gfx[gfxint];
                                //    Log.Message(string.Format("_graphic is Random subGraphics[gfxint] DrawRotatedExtraAngleOffset: {0}, ShouldDrawRotated: {1}", gfx[gfxint].DrawRotatedExtraAngleOffset, gfx[gfxint].ShouldDrawRotated));
                            }
                        }
                    }
                }
                if (Props.quality)
                {
                    Traverse traverse = Traverse.Create(graphic);
                    if (graphic.GetType() == typeof(Graphic_RandomRotated))
                    {
                        Graphic_Random subGraphic = (Graphic_Random)AM_Graphic_RandomRotated_DrawWorker_Debuff_Patch.subgraphic.GetValue(graphic);
                        if (subGraphic != null)
                        {
                            Traverse  traverse2   = Traverse.Create(subGraphic);
                            Graphic[] subGraphics = (Graphic[])AM_Graphic_RandomRotated_DrawWorker_Debuff_Patch.subgraphics.GetValue(subGraphic);
                            if (!subGraphics.NullOrEmpty())
                            {
                                List <Verse.Graphic> gfx     = subGraphics.Where(x => !x.path.EndsWith("_Glow") && !x.path.EndsWith("m")).ToList();
                                CompQuality          quality = this.parent.TryGetComp <CompQuality>();
                                if (quality == null)
                                {
                                    Log.Warning(string.Format("WARNING!! {0} is set to use quality graphics but has no CompQuality, using random graphic", this.parent.Label));
                                    gfxint = Rand.Range(0, gfx.Count());
                                    return(gfx[gfxint]);
                                }
                                if (gfxint == -1)
                                {
                                    //    Log.Message("gfxint == -1");
                                    //    Log.Message(string.Format("{0} Quality: {1}", this.parent.Label, quality.Quality));
                                    //    Log.Message(string.Format("{0} minQuality: {1}", this.parent.Label, Props.minQuality));
                                    if ((int)quality.Quality >= (int)Props.minQuality)
                                    {
                                        //    Log.Message("quality Min reached");
                                        int i = (int)quality.Quality - (int)Props.minQuality + 1;
                                        //    Log.Message(string.Format("{0} Quality: {1}, Min Quality: {2}, set: {3}/{4}", this.parent.Label, quality.Quality, Props.minQuality, i, gfx.Count));
                                        gfxint = Math.Min(i, gfx.Count - 1);
                                    }
                                    else
                                    {
                                        gfxint = 0;
                                    }
                                    //    Log.Message("gfxint is Rand.Range(0, subGraphics.Count())");
                                }
                                else
                                {
                                    //    Log.Message(string.Format("{0} gfxint: {1}", this.parent.Label, gfxint));
                                }
                                if (true)
                                {
                                }
                                _graphic = gfx[gfxint];
                                //    Log.Message(string.Format("_graphic is Quality subGraphics[gfxint] DrawRotatedExtraAngleOffset: {0}, ShouldDrawRotated: {1}", gfx[gfxint].DrawRotatedExtraAngleOffset, gfx[gfxint].ShouldDrawRotated));
                            }
                        }
                    }
                }
            }

            if (_graphic == null)
            {
                //    Log.Message("_graphic is null");

                _graphic = graphic;
            }
            return(_graphic);
        }