Esempio n. 1
0
        public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI)
        {
            Vector2          position = item.position - Main.screenPosition + new Vector2(item.width / 2, item.height / 2);
            List <Texture2D> textures = new List <Texture2D>();
            List <Vector2>   offsets  = new List <Vector2>();

            parts = parts.OrderBy(x => GunHelper.GetPartType(x).layer).ToList();
            foreach (string key in parts)
            {
                try
                {
                    GunPart   partType = GunHelper.GetPartType(key);
                    Texture2D tex      = ModContent.GetTexture(partType.useTexture);
                    textures.Add(tex);
                    Vector2 offset = partType.offset;
                    offsets.Add(offset);
                }
                catch (Exception e)
                {
                    Gunplay.instance.Logger.Error("Something failed when getting invTexture in PostDrawInWorld! " + e.Message);
                }
            }
            for (int index = 0; index < textures.Count; index++)
            {
                Texture2D texture = textures[index];
                Vector2   offset  = offsets[index] / 2f;
                spriteBatch.Draw(texture, position + offset, null, lightColor, rotation, texture.Size() * 0.5f, scale, SpriteEffects.None, 0f);
            }
        }
Esempio n. 2
0
        public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
        {
            parts = parts.OrderBy(x => GunHelper.GetPartType(x).layer).ToList();
            List <Texture2D> textures = new List <Texture2D>();
            List <Vector2>   offsets  = new List <Vector2>();

            foreach (string key in parts)
            {
                try
                {
                    GunPart   partType = GunHelper.GetPartType(key);
                    Texture2D texture  = ModContent.GetTexture(partType.useTexture);
                    textures.Add(texture);
                    Vector2 offset = partType.offset;
                    offsets.Add(offset);
                }
                catch (Exception e)
                {
                    Gunplay.instance.Logger.Error("Something failed when getting invTexture in PostDrawInInventory! " + e.Message);
                }
            }
            for (int index = 0; index < textures.Count; index++)
            {
                Texture2D texture = textures[index];
                Vector2   offset  = offsets[index];
                spriteBatch.Draw(texture, position + offset, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f);
            }
        }