Esempio n. 1
0
        public void ApplySleeveColor(string texture_name, Color[] pixels, Farmer who)
        {
            Color[] shirtData = new Color[shirtsTexture.Bounds.Width * shirtsTexture.Bounds.Height];
            shirtsTexture.GetData(shirtData);
            int   index            = ClampShirt(who.GetShirtIndex()) * 8 / 128 * 32 * shirtsTexture.Bounds.Width + ClampShirt(who.GetShirtIndex()) * 8 % 128 + shirtsTexture.Width * 4;
            int   dye_index        = index + 128;
            Color shirtSleeveColor = Color.White;

            if (who.GetShirtExtraData().Contains("Sleeveless") || index >= shirtData.Length)
            {
                Texture2D skinColors     = farmerTextureManager.Load <Texture2D>("Characters\\Farmer\\skinColors");
                Color[]   skinColorsData = new Color[skinColors.Width * skinColors.Height];
                int       skin_index     = skin.Value;
                if (skin_index < 0)
                {
                    skin_index = skinColors.Height - 1;
                }
                if (skin_index > skinColors.Height - 1)
                {
                    skin_index = 0;
                }
                skinColors.GetData(skinColorsData);
                Color darkest  = skinColorsData[skin_index * 3 % (skinColors.Height * 3)];
                Color medium   = skinColorsData[skin_index * 3 % (skinColors.Height * 3) + 1];
                Color lightest = skinColorsData[skin_index * 3 % (skinColors.Height * 3) + 2];
                if (_sickFrame)
                {
                    darkest  = pixels[260 + baseTexture.Width];
                    medium   = pixels[261 + baseTexture.Width];
                    lightest = pixels[262 + baseTexture.Width];
                }
                shirtSleeveColor = darkest;
                _SwapColor(texture_name, pixels, 256, darkest);
                _SwapColor(texture_name, pixels, 257, medium);
                _SwapColor(texture_name, pixels, 258, lightest);
                return;
            }
            Color color = Utility.MakeCompletelyOpaque(who.GetShirtColor());

            shirtSleeveColor = shirtData[dye_index];
            Color clothes_color = color;

            if (shirtSleeveColor.A < byte.MaxValue)
            {
                shirtSleeveColor = shirtData[index];
                clothes_color    = Color.White;
            }
            shirtSleeveColor = Utility.MultiplyColor(shirtSleeveColor, clothes_color);
            _SwapColor(texture_name, pixels, 256, shirtSleeveColor);
            shirtSleeveColor = shirtData[dye_index - shirtsTexture.Width];
            if (shirtSleeveColor.A < byte.MaxValue)
            {
                shirtSleeveColor = shirtData[index - shirtsTexture.Width];
                clothes_color    = Color.White;
            }
            shirtSleeveColor = Utility.MultiplyColor(shirtSleeveColor, clothes_color);
            _SwapColor(texture_name, pixels, 257, shirtSleeveColor);
            shirtSleeveColor = shirtData[dye_index - shirtsTexture.Width * 2];
            if (shirtSleeveColor.A < byte.MaxValue)
            {
                shirtSleeveColor = shirtData[index - shirtsTexture.Width * 2];
                clothes_color    = Color.White;
            }
            shirtSleeveColor = Utility.MultiplyColor(shirtSleeveColor, clothes_color);
            _SwapColor(texture_name, pixels, 258, shirtSleeveColor);
        }