Exemple #1
0
        /// <summary> Try to load the Graphic of appropriate type based on current life stage </summary>
        Graphic LoadGraphic(string variant)
        {
            string path = ageTracker.CurKindLifeStage.bodyGraphicData.texPath + "_" + variant;

            if (Prefs.DevMode)
            {
                Log.Message($"path: {path}");
            }
            // determine graphic class type
            System.Type type = null;
            if (contentHolder.Get(path + "_south") != null)
            {
                type = typeof(Graphic_Multi);
            }
            else if (contentHolder.Get(path) != null)
            {
                type = typeof(Graphic_Single);
            }

            if (type == null)
            {
                return(null);                // texture not found, skip graphic
            }
            var data = new GraphicData();

            data.CopyFrom(ageTracker.CurKindLifeStage.bodyGraphicData);
            data.texPath      = path;
            data.graphicClass = type;
            return(data.Graphic);
        }
Exemple #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);
        }
Exemple #3
0
        /// <summary> Set the movementGraphic based on the current life stage </summary>
        private Graphic LoadGraphic(string variant)
        {
            string path = ageTracker.CurKindLifeStage.bodyGraphicData.texPath + "_" + variant;

            // try getting the texture to see if it exists
            var texture = contentHolder.Get(path + "_south");

            if (texture == null)
            {
                return(null);
            }

            var data = new GraphicData();

            data.CopyFrom(ageTracker.CurKindLifeStage.bodyGraphicData);
            data.texPath = path;

            if (data.shadowData != null && variant == "moving")              // meerkat-specific shadow fix
            {
                var shadow = new ShadowData();
                shadow.volume   = data.shadowData.volume + new Vector3(0.15f, -0.15f, -0.1f);
                shadow.offset   = data.shadowData.offset + new Vector3(0.04f, 0, 0.18f);
                data.shadowData = shadow;
            }

            return(data.Graphic);
        }
Exemple #4
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);
        }
 public virtual Graphic GetShadowlessGraphic()
 {
     if (this.data != null && this.data.shadowData != null)
     {
         if (this.cachedShadowlessGraphicInt == null)
         {
             GraphicData graphicData = new GraphicData();
             graphicData.CopyFrom(this.data);
             graphicData.shadowData          = null;
             this.cachedShadowlessGraphicInt = graphicData.Graphic;
         }
         return(this.cachedShadowlessGraphicInt);
     }
     return(this);
 }
Exemple #6
0
 public virtual Graphic GetShadowlessGraphic()
 {
     if (data == null || data.shadowData == null)
     {
         return(this);
     }
     if (cachedShadowlessGraphicInt == null)
     {
         GraphicData graphicData = new GraphicData();
         graphicData.CopyFrom(data);
         graphicData.shadowData     = null;
         cachedShadowlessGraphicInt = graphicData.Graphic;
     }
     return(cachedShadowlessGraphicInt);
 }
Exemple #7
0
 public Graphic GetGraphic(Graphic other)
 {
     if (graphicData == null)
     {
         graphicData = new GraphicData();
     }
     graphicData.CopyFrom(other.data);
     if (!texPath.NullOrEmpty())
     {
         graphicData.texPath = texPath;
     }
     graphicData.color    = (color ?? other.color);
     graphicData.colorTwo = (colorTwo ?? other.colorTwo);
     return(graphicData.Graphic);
 }
        public virtual Graphic GetShadowlessGraphic()
        {
            Graphic result;

            if (this.data == null || this.data.shadowData == null)
            {
                result = this;
            }
            else
            {
                if (this.cachedShadowlessGraphicInt == null)
                {
                    GraphicData graphicData = new GraphicData();
                    graphicData.CopyFrom(this.data);
                    graphicData.shadowData          = null;
                    this.cachedShadowlessGraphicInt = graphicData.Graphic;
                }
                result = this.cachedShadowlessGraphicInt;
            }
            return(result);
        }