Esempio n. 1
0
        public void drawMiniPortrat(SpriteBatch b, Vector2 position, float layerDepth, float scale, int facingDirection, Farmer who)
        {
            int hair_style = who.getHair(ignore_hat: true);
            HairStyleMetadata hair_metadata = Farmer.GetHairStyleMetadata(who.hair.Value);

            executeRecolorActions(who);
            facingDirection = 2;
            bool      flip             = false;
            int       yOffset          = 0;
            int       feature_y_offset = 0;
            Texture2D hair_texture     = hairStylesTexture;

            hairstyleSourceRect = new Rectangle(hair_style * 16 % hairStylesTexture.Width, hair_style * 16 / hairStylesTexture.Width * 96, 16, 15);
            if (hair_metadata != null)
            {
                hair_texture        = hair_metadata.texture;
                hairstyleSourceRect = new Rectangle(hair_metadata.tileX * 16, hair_metadata.tileY * 16, 16, 15);
            }
            switch (facingDirection)
            {
            case 0:
                yOffset = 64;
                hairstyleSourceRect.Offset(0, 64);
                feature_y_offset = featureYOffsetPerFrame[12];
                break;

            case 3:
                if (hair_metadata != null && hair_metadata.usesUniqueLeftSprite)
                {
                    flip    = false;
                    yOffset = 96;
                }
                else
                {
                    flip    = true;
                    yOffset = 32;
                }
                hairstyleSourceRect.Offset(0, 32);
                feature_y_offset = featureYOffsetPerFrame[6];
                break;

            case 1:
                yOffset = 32;
                hairstyleSourceRect.Offset(0, 32);
                feature_y_offset = featureYOffsetPerFrame[6];
                break;

            case 2:
                yOffset = 0;
                hairstyleSourceRect.Offset(0, 0);
                feature_y_offset = featureYOffsetPerFrame[0];
                break;
            }
            b.Draw(baseTexture, position, new Rectangle(0, yOffset, 16, who.isMale ? 15 : 16), Color.White, 0f, Vector2.Zero, scale, flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, layerDepth);
            int sort_direction = ((!Game1.isUsingBackToFrontSorting) ? 1 : (-1));

            b.Draw(hair_texture, position + new Vector2(0f, feature_y_offset * 4 + ((who.IsMale && (int)who.hair >= 16) ? (-4) : ((!who.IsMale && (int)who.hair < 16) ? 4 : 0))) * scale / 4f, hairstyleSourceRect, who.hairstyleColor, 0f, Vector2.Zero, scale, flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, layerDepth + 1.1E-07f * (float)sort_direction);
        }
Esempio n. 2
0
        public void drawHairAndAccesories(SpriteBatch b, int facingDirection, Farmer who, Vector2 position, Vector2 origin, float scale, int currentFrame, float rotation, Color overrideColor, float layerDepth)
        {
            int hair_style = who.getHair();
            HairStyleMetadata hair_metadata = Farmer.GetHairStyleMetadata(who.hair.Value);

            if (who != null && who.hat.Value != null && who.hat.Value.hairDrawType.Value == 1 && hair_metadata != null && hair_metadata.coveredIndex != -1)
            {
                hair_style    = hair_metadata.coveredIndex;
                hair_metadata = Farmer.GetHairStyleMetadata(hair_style);
            }
            executeRecolorActions(who);
            shirtSourceRect = new Rectangle(ClampShirt(who.GetShirtIndex()) * 8 % 128, ClampShirt(who.GetShirtIndex()) * 8 / 128 * 32, 8, 8);
            Texture2D hair_texture = hairStylesTexture;

            hairstyleSourceRect = new Rectangle(hair_style * 16 % hairStylesTexture.Width, hair_style * 16 / hairStylesTexture.Width * 96, 16, 32);
            if (hair_metadata != null)
            {
                hair_texture        = hair_metadata.texture;
                hairstyleSourceRect = new Rectangle(hair_metadata.tileX * 16, hair_metadata.tileY * 16, 16, 32);
            }
            if ((int)who.accessory >= 0)
            {
                accessorySourceRect = new Rectangle((int)who.accessory * 16 % accessoriesTexture.Width, (int)who.accessory * 16 / accessoriesTexture.Width * 32, 16, 16);
            }
            if (who.hat.Value != null)
            {
                hatSourceRect = new Rectangle(20 * (int)who.hat.Value.which % hatsTexture.Width, 20 * (int)who.hat.Value.which / hatsTexture.Width * 20 * 4, 20, 20);
            }
            Rectangle dyed_shirt_source_rect = shirtSourceRect;
            float     dye_layer_offset       = 1E-07f;
            float     hair_draw_layer        = 2.2E-05f;

            switch (facingDirection)
            {
            case 0:
                shirtSourceRect.Offset(0, 24);
                hairstyleSourceRect.Offset(0, 64);
                dyed_shirt_source_rect = shirtSourceRect;
                dyed_shirt_source_rect.Offset(128, 0);
                if (who.hat.Value != null)
                {
                    hatSourceRect.Offset(0, 60);
                }
                if (!who.bathingClothes)
                {
                    b.Draw(shirtsTexture, position + origin + positionOffset + new Vector2(16f * scale + (float)(featureXOffsetPerFrame[currentFrame] * 4), (float)(56 + featureYOffsetPerFrame[currentFrame] * 4) + (float)(int)heightOffset * scale), shirtSourceRect, overrideColor.Equals(Color.White) ? Color.White : overrideColor, rotation, origin, 4f * scale, SpriteEffects.None, layerDepth + 1.8E-07f);
                    b.Draw(shirtsTexture, position + origin + positionOffset + new Vector2(16f * scale + (float)(featureXOffsetPerFrame[currentFrame] * 4), (float)(56 + featureYOffsetPerFrame[currentFrame] * 4) + (float)(int)heightOffset * scale), dyed_shirt_source_rect, overrideColor.Equals(Color.White) ? Utility.MakeCompletelyOpaque(who.GetShirtColor()) : overrideColor, rotation, origin, 4f * scale, SpriteEffects.None, layerDepth + 1.8E-07f + dye_layer_offset);
                }
                b.Draw(hair_texture, position + origin + positionOffset + new Vector2(featureXOffsetPerFrame[currentFrame] * 4, featureYOffsetPerFrame[currentFrame] * 4 + 4 + ((who.IsMale && hair_style >= 16) ? (-4) : ((!who.IsMale && hair_style < 16) ? 4 : 0))), hairstyleSourceRect, overrideColor.Equals(Color.White) ? ((Color)who.hairstyleColor) : overrideColor, rotation, origin, 4f * scale, SpriteEffects.None, layerDepth + hair_draw_layer);
                break;

            case 1:
                shirtSourceRect.Offset(0, 8);
                hairstyleSourceRect.Offset(0, 32);
                dyed_shirt_source_rect = shirtSourceRect;
                dyed_shirt_source_rect.Offset(128, 0);
                if ((int)who.accessory >= 0)
                {
                    accessorySourceRect.Offset(0, 16);
                }
                if (who.hat.Value != null)
                {
                    hatSourceRect.Offset(0, 20);
                }
                if (rotation == -(float)Math.PI / 32f)
                {
                    rotationAdjustment.X = 6f;
                    rotationAdjustment.Y = -2f;
                }
                else if (rotation == (float)Math.PI / 32f)
                {
                    rotationAdjustment.X = -6f;
                    rotationAdjustment.Y = 1f;
                }
                if (!who.bathingClothes)
                {
                    b.Draw(shirtsTexture, position + origin + positionOffset + rotationAdjustment + new Vector2(16f * scale + (float)(featureXOffsetPerFrame[currentFrame] * 4), 56f * scale + (float)(featureYOffsetPerFrame[currentFrame] * 4) + (float)(int)heightOffset * scale), shirtSourceRect, overrideColor.Equals(Color.White) ? Color.White : overrideColor, rotation, origin, 4f * scale + ((rotation != 0f) ? 0f : 0f), SpriteEffects.None, layerDepth + 1.8E-07f);
                    b.Draw(shirtsTexture, position + origin + positionOffset + rotationAdjustment + new Vector2(16f * scale + (float)(featureXOffsetPerFrame[currentFrame] * 4), 56f * scale + (float)(featureYOffsetPerFrame[currentFrame] * 4) + (float)(int)heightOffset * scale), dyed_shirt_source_rect, overrideColor.Equals(Color.White) ? Utility.MakeCompletelyOpaque(who.GetShirtColor()) : overrideColor, rotation, origin, 4f * scale + ((rotation != 0f) ? 0f : 0f), SpriteEffects.None, layerDepth + 1.8E-07f + dye_layer_offset);
                }
                if ((int)who.accessory >= 0)
                {
                    b.Draw(accessoriesTexture, position + origin + positionOffset + rotationAdjustment + new Vector2(featureXOffsetPerFrame[currentFrame] * 4, 4 + featureYOffsetPerFrame[currentFrame] * 4 + (int)heightOffset), accessorySourceRect, (overrideColor.Equals(Color.White) && (int)who.accessory < 6) ? ((Color)who.hairstyleColor) : overrideColor, rotation, origin, 4f * scale + ((rotation != 0f) ? 0f : 0f), SpriteEffects.None, layerDepth + (((int)who.accessory < 8) ? 1.9E-05f : 2.9E-05f));
                }
                b.Draw(hair_texture, position + origin + positionOffset + new Vector2(featureXOffsetPerFrame[currentFrame] * 4, featureYOffsetPerFrame[currentFrame] * 4 + ((who.IsMale && (int)who.hair >= 16) ? (-4) : ((!who.IsMale && (int)who.hair < 16) ? 4 : 0))), hairstyleSourceRect, overrideColor.Equals(Color.White) ? ((Color)who.hairstyleColor) : overrideColor, rotation, origin, 4f * scale, SpriteEffects.None, layerDepth + hair_draw_layer);
                break;

            case 2:
                dyed_shirt_source_rect = shirtSourceRect;
                dyed_shirt_source_rect.Offset(128, 0);
                if (!who.bathingClothes)
                {
                    b.Draw(shirtsTexture, position + origin + positionOffset + new Vector2(16 + featureXOffsetPerFrame[currentFrame] * 4, (float)(56 + featureYOffsetPerFrame[currentFrame] * 4) + (float)(int)heightOffset * scale - (float)(who.IsMale ? 0 : 0)), shirtSourceRect, overrideColor.Equals(Color.White) ? Color.White : overrideColor, rotation, origin, 4f * scale, SpriteEffects.None, layerDepth + 1.5E-07f);
                    b.Draw(shirtsTexture, position + origin + positionOffset + new Vector2(16 + featureXOffsetPerFrame[currentFrame] * 4, (float)(56 + featureYOffsetPerFrame[currentFrame] * 4) + (float)(int)heightOffset * scale - (float)(who.IsMale ? 0 : 0)), dyed_shirt_source_rect, overrideColor.Equals(Color.White) ? Utility.MakeCompletelyOpaque(who.GetShirtColor()) : overrideColor, rotation, origin, 4f * scale, SpriteEffects.None, layerDepth + 1.5E-07f + dye_layer_offset);
                }
                if ((int)who.accessory >= 0)
                {
                    b.Draw(accessoriesTexture, position + origin + positionOffset + rotationAdjustment + new Vector2(featureXOffsetPerFrame[currentFrame] * 4, 8 + featureYOffsetPerFrame[currentFrame] * 4 + (int)heightOffset - 4), accessorySourceRect, (overrideColor.Equals(Color.White) && (int)who.accessory < 6) ? ((Color)who.hairstyleColor) : overrideColor, rotation, origin, 4f * scale + ((rotation != 0f) ? 0f : 0f), SpriteEffects.None, layerDepth + (((int)who.accessory < 8) ? 1.9E-05f : 2.9E-05f));
                }
                b.Draw(hair_texture, position + origin + positionOffset + new Vector2(featureXOffsetPerFrame[currentFrame] * 4, featureYOffsetPerFrame[currentFrame] * 4 + ((who.IsMale && (int)who.hair >= 16) ? (-4) : ((!who.IsMale && (int)who.hair < 16) ? 4 : 0))), hairstyleSourceRect, overrideColor.Equals(Color.White) ? ((Color)who.hairstyleColor) : overrideColor, rotation, origin, 4f * scale, SpriteEffects.None, layerDepth + hair_draw_layer);
                break;

            case 3:
            {
                bool flip2 = true;
                shirtSourceRect.Offset(0, 16);
                dyed_shirt_source_rect = shirtSourceRect;
                dyed_shirt_source_rect.Offset(128, 0);
                if ((int)who.accessory >= 0)
                {
                    accessorySourceRect.Offset(0, 16);
                }
                if (hair_metadata != null && hair_metadata.usesUniqueLeftSprite)
                {
                    flip2 = false;
                    hairstyleSourceRect.Offset(0, 96);
                }
                else
                {
                    hairstyleSourceRect.Offset(0, 32);
                }
                if (who.hat.Value != null)
                {
                    hatSourceRect.Offset(0, 40);
                }
                if (rotation == -(float)Math.PI / 32f)
                {
                    rotationAdjustment.X = 6f;
                    rotationAdjustment.Y = -2f;
                }
                else if (rotation == (float)Math.PI / 32f)
                {
                    rotationAdjustment.X = -5f;
                    rotationAdjustment.Y = 1f;
                }
                if (!who.bathingClothes)
                {
                    b.Draw(shirtsTexture, position + origin + positionOffset + rotationAdjustment + new Vector2(16 - featureXOffsetPerFrame[currentFrame] * 4, 56 + featureYOffsetPerFrame[currentFrame] * 4 + (int)heightOffset), shirtSourceRect, overrideColor.Equals(Color.White) ? Color.White : overrideColor, rotation, origin, 4f * scale + ((rotation != 0f) ? 0f : 0f), SpriteEffects.None, layerDepth + 1.5E-07f);
                    b.Draw(shirtsTexture, position + origin + positionOffset + rotationAdjustment + new Vector2(16 - featureXOffsetPerFrame[currentFrame] * 4, 56 + featureYOffsetPerFrame[currentFrame] * 4 + (int)heightOffset), dyed_shirt_source_rect, overrideColor.Equals(Color.White) ? Utility.MakeCompletelyOpaque(who.GetShirtColor()) : overrideColor, rotation, origin, 4f * scale + ((rotation != 0f) ? 0f : 0f), SpriteEffects.None, layerDepth + 1.5E-07f + dye_layer_offset);
                }
                if ((int)who.accessory >= 0)
                {
                    b.Draw(accessoriesTexture, position + origin + positionOffset + rotationAdjustment + new Vector2(-featureXOffsetPerFrame[currentFrame] * 4, 4 + featureYOffsetPerFrame[currentFrame] * 4 + (int)heightOffset), accessorySourceRect, (overrideColor.Equals(Color.White) && (int)who.accessory < 6) ? ((Color)who.hairstyleColor) : overrideColor, rotation, origin, 4f * scale + ((rotation != 0f) ? 0f : 0f), SpriteEffects.FlipHorizontally, layerDepth + (((int)who.accessory < 8) ? 1.9E-05f : 2.9E-05f));
                }
                b.Draw(hair_texture, position + origin + positionOffset + new Vector2(-featureXOffsetPerFrame[currentFrame] * 4, featureYOffsetPerFrame[currentFrame] * 4 + ((who.IsMale && (int)who.hair >= 16) ? (-4) : ((!who.IsMale && (int)who.hair < 16) ? 4 : 0))), hairstyleSourceRect, overrideColor.Equals(Color.White) ? ((Color)who.hairstyleColor) : overrideColor, rotation, origin, 4f * scale, flip2 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, layerDepth + hair_draw_layer);
                break;
            }
            }
            if (who.hat.Value != null && !who.bathingClothes)
            {
                bool  flip         = who.FarmerSprite.CurrentAnimationFrame.flip;
                float layer_offset = 3.9E-05f;
                if (who.hat.Value.isMask && facingDirection == 0)
                {
                    Rectangle mask_draw_rect = hatSourceRect;
                    mask_draw_rect.Height -= 11;
                    mask_draw_rect.Y      += 11;
                    b.Draw(hatsTexture, position + origin + positionOffset + new Vector2(0f, 44f) + new Vector2(-8 + ((!flip) ? 1 : (-1)) * featureXOffsetPerFrame[currentFrame] * 4, -16 + featureYOffsetPerFrame[currentFrame] * 4 + ((!who.hat.Value.ignoreHairstyleOffset) ? hairstyleHatOffset[(int)who.hair % 16] : 0) + 4 + (int)heightOffset), mask_draw_rect, Color.White, rotation, origin, 4f * scale, SpriteEffects.None, layerDepth + layer_offset);
                    mask_draw_rect        = hatSourceRect;
                    mask_draw_rect.Height = 11;
                    layer_offset          = -1E-06f;
                    b.Draw(hatsTexture, position + origin + positionOffset + new Vector2(-8 + ((!flip) ? 1 : (-1)) * featureXOffsetPerFrame[currentFrame] * 4, -16 + featureYOffsetPerFrame[currentFrame] * 4 + ((!who.hat.Value.ignoreHairstyleOffset) ? hairstyleHatOffset[(int)who.hair % 16] : 0) + 4 + (int)heightOffset), mask_draw_rect, who.hat.Value.isPrismatic ? Utility.GetPrismaticColor() : Color.White, rotation, origin, 4f * scale, SpriteEffects.None, layerDepth + layer_offset);
                }
                else
                {
                    b.Draw(hatsTexture, position + origin + positionOffset + new Vector2(-8 + ((!flip) ? 1 : (-1)) * featureXOffsetPerFrame[currentFrame] * 4, -16 + featureYOffsetPerFrame[currentFrame] * 4 + ((!who.hat.Value.ignoreHairstyleOffset) ? hairstyleHatOffset[(int)who.hair % 16] : 0) + 4 + (int)heightOffset), hatSourceRect, who.hat.Value.isPrismatic ? Utility.GetPrismaticColor() : Color.White, rotation, origin, 4f * scale, SpriteEffects.None, layerDepth + layer_offset);
                }
            }
        }