Example #1
0
        internal static Rectangle ShirtRectDye(int index)
        {
            var rect = ContentInjector1.ShirtRectPlain(index);

            rect.X += 16 * 8;
            return(rect);
        }
Example #2
0
        private void InjectCharactersFarmerShirts(IAssetData asset)
        {
            var oldTex = asset.AsImage().Data;

            asset.AsImage().ExtendImage(oldTex.Width, 4096);
            Log.Trace($"Shirts are now ({oldTex.Width}, {Math.Max(oldTex.Height, 4096)})");

            foreach (var shirt in Mod.instance.Shirts)
            {
                try
                {
                    string rects = ContentInjector1.ShirtRectPlain(shirt.GetMaleIndex()).ToString();
                    if (shirt.Dyeable)
                    {
                        rects += ", " + ContentInjector1.ShirtRectDye(shirt.GetMaleIndex()).ToString();
                    }
                    if (shirt.HasFemaleVariant)
                    {
                        rects += ", " + ContentInjector1.ShirtRectPlain(shirt.GetFemaleIndex()).ToString();
                        if (shirt.Dyeable)
                        {
                            rects += ", " + ContentInjector1.ShirtRectDye(shirt.GetFemaleIndex()).ToString();
                        }
                    }

                    Log.Verbose($"Injecting {shirt.Name} sprites @ {rects}");
                    asset.AsImage().PatchExtendedTileSheet(shirt.textureMale, null, ContentInjector1.ShirtRectPlain(shirt.GetMaleIndex()));
                    if (shirt.Dyeable)
                    {
                        asset.AsImage().PatchExtendedTileSheet(shirt.textureMaleColor, null, ContentInjector1.ShirtRectDye(shirt.GetMaleIndex()));
                    }
                    if (shirt.HasFemaleVariant)
                    {
                        asset.AsImage().PatchExtendedTileSheet(shirt.textureFemale, null, ContentInjector1.ShirtRectPlain(shirt.GetFemaleIndex()));
                        if (shirt.Dyeable)
                        {
                            asset.AsImage().PatchExtendedTileSheet(shirt.textureFemaleColor, null, ContentInjector1.ShirtRectDye(shirt.GetFemaleIndex()));
                        }
                    }
                }
                catch (Exception e)
                {
                    Log.Error($"Exception injecting sprite for {shirt.Name}: {e}");
                }
            }
        }