コード例 #1
0
        internal static Rectangle ShirtRectDye(int index)
        {
            var rect = ContentInjector1.ShirtRectPlain(index);

            rect.X += 16 * 8;
            return(rect);
        }
コード例 #2
0
        private void InjectTileSheetsWeapons(IAssetData asset)
        {
            using var oldTex = asset.AsImage().Data;
            Texture2D newTex = new Texture2D(Game1.graphics.GraphicsDevice, oldTex.Width, Math.Max(oldTex.Height, 4096));

            asset.ReplaceWith(newTex);
            asset.AsImage().PatchImage(oldTex);
            Log.Trace($"Weapons are now ({oldTex.Width}, {Math.Max(oldTex.Height, 4096)})");

            foreach (var weapon in Mod.instance.Weapons)
            {
                try
                {
                    Log.Verbose($"Injecting {weapon.Name} sprites @ {ContentInjector1.WeaponRect(weapon.GetWeaponId())}");
                    asset.AsImage().PatchImage(weapon.texture, null, ContentInjector1.WeaponRect(weapon.GetWeaponId()));

                    var rect = ContentInjector1.WeaponRect(weapon.GetWeaponId());
                    int ts   = 0;// TileSheetExtensions.GetAdjustedTileSheetTarget(asset.AssetName, rect).TileSheet;
                    weapon.tilesheet  = asset.AssetName + (ts == 0 ? "" : (ts + 1).ToString());
                    weapon.tilesheetX = rect.X;
                    weapon.tilesheetY = rect.Y;
                }
                catch (Exception e)
                {
                    Log.Error($"Exception injecting sprite for {weapon.Name}: {e}");
                }
            }
        }
コード例 #3
0
        private void InjectCharactersFarmerHats(IAssetData asset)
        {
            using var oldTex = asset.AsImage().Data;
            Texture2D newTex = new Texture2D(Game1.graphics.GraphicsDevice, oldTex.Width, Math.Max(oldTex.Height, 4096));

            asset.ReplaceWith(newTex);
            asset.AsImage().PatchImage(oldTex);
            Log.Trace($"Hats are now ({oldTex.Width}, {Math.Max(oldTex.Height, 4096)})");

            foreach (var hat in Mod.instance.Hats)
            {
                try
                {
                    Log.Verbose($"Injecting {hat.Name} sprites @ {ContentInjector1.HatRect(hat.GetHatId())}");
                    asset.AsImage().PatchExtendedTileSheet(hat.texture, null, ContentInjector1.HatRect(hat.GetHatId()));

                    var rect   = ContentInjector1.HatRect(hat.GetHatId());
                    var target = TileSheetExtensions.GetAdjustedTileSheetTarget(asset.AssetName, rect);
                    int ts     = target.TileSheet;
                    hat.tilesheet  = asset.AssetName + (ts == 0 ? "" : (ts + 1).ToString());
                    hat.tilesheetX = rect.X;
                    hat.tilesheetY = target.Y;
                }
                catch (Exception e)
                {
                    Log.Error($"Exception injecting sprite for {hat.Name}: {e}");
                }
            }
        }
コード例 #4
0
        private void InjectTileSheetsFruitTrees(IAssetData asset)
        {
            using var oldTex = asset.AsImage().Data;
            Texture2D newTex = new Texture2D(Game1.graphics.GraphicsDevice, oldTex.Width, Math.Max(oldTex.Height, 4096));

            asset.ReplaceWith(newTex);
            asset.AsImage().PatchImage(oldTex);

            foreach (var fruitTree in Mod.instance.FruitTrees)
            {
                try
                {
                    Log.Verbose($"Injecting {fruitTree.Name} fruit tree images @ {ContentInjector1.FruitTreeRect(fruitTree.GetFruitTreeIndex())}");
                    asset.AsImage().PatchExtendedTileSheet(fruitTree.texture, null, ContentInjector1.FruitTreeRect(fruitTree.GetFruitTreeIndex()));

                    var rect   = ContentInjector1.FruitTreeRect(fruitTree.GetFruitTreeIndex());
                    var target = TileSheetExtensions.GetAdjustedTileSheetTarget(asset.AssetName, rect);
                    int ts     = target.TileSheet;
                    fruitTree.tilesheet  = asset.AssetName + (ts == 0 ? "" : (ts + 1).ToString());
                    fruitTree.tilesheetX = rect.X;
                    fruitTree.tilesheetY = target.Y;
                }
                catch (Exception e)
                {
                    Log.Error($"Exception injecting fruit tree sprite for {fruitTree.Name}: {e}");
                }
            }
        }
コード例 #5
0
        private void InjectMapsSpringobjects(IAssetData asset)
        {
            var oldTex = asset.AsImage().Data;

            asset.AsImage().ExtendImage(oldTex.Width, 4096);
            //Texture2D newTex = new Texture2D(Game1.graphics.GraphicsDevice, oldTex.Width, Math.Max(oldTex.Height, 4096));
            //asset.ReplaceWith(newTex);
            //asset.AsImage().PatchImage(oldTex);

            foreach (var obj in Mod.instance.Objects)
            {
                try
                {
                    Log.Verbose($"Injecting {obj.Name} sprites @ {ContentInjector1.ObjectRect(obj.GetObjectId())}");
                    asset.AsImage().PatchExtendedTileSheet(obj.texture, null, ContentInjector1.ObjectRect(obj.GetObjectId()));
                    if (obj.IsColored)
                    {
                        Log.Verbose($"Injecting {obj.Name} color sprites @ {ContentInjector1.ObjectRect(obj.GetObjectId() + 1)}");
                        asset.AsImage().PatchExtendedTileSheet(obj.textureColor, null, ContentInjector1.ObjectRect(obj.GetObjectId() + 1));
                    }

                    var rect   = ContentInjector1.ObjectRect(obj.GetObjectId());
                    var target = TileSheetExtensions.GetAdjustedTileSheetTarget(asset.AssetName, rect);
                    int ts     = target.TileSheet;
                    obj.tilesheet  = asset.AssetName + (ts == 0 ? "" : (ts + 1).ToString());
                    obj.tilesheetX = rect.X;
                    obj.tilesheetY = target.Y;
                }
                catch (Exception e)
                {
                    Log.Error($"Exception injecting sprite for {obj.Name}: {e}");
                }
            }

            foreach (var boots in Mod.instance.Boots)
            {
                try
                {
                    Log.Verbose($"Injecting {boots.Name} sprites @ {ContentInjector1.ObjectRect(boots.GetObjectId())}");
                    asset.AsImage().PatchExtendedTileSheet(boots.texture, null, ContentInjector1.ObjectRect(boots.GetObjectId()));

                    var rect   = ContentInjector1.ObjectRect(boots.GetObjectId());
                    var target = TileSheetExtensions.GetAdjustedTileSheetTarget(asset.AssetName, rect);
                    int ts     = target.TileSheet;
                    boots.tilesheet  = asset.AssetName + (ts == 0 ? "" : (ts + 1).ToString());
                    boots.tilesheetX = rect.X;
                    boots.tilesheetY = target.Y;
                }
                catch (Exception e)
                {
                    Log.Error($"Exception injecting sprite for {boots.Name}: {e}");
                }
            }
        }
コード例 #6
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}");
                }
            }
        }
コード例 #7
0
        private void InjectCharactersFarmerShoeColors(IAssetData asset)
        {
            using var oldTex = asset.AsImage().Data;
            Texture2D newTex = new Texture2D(Game1.graphics.GraphicsDevice, oldTex.Width, Math.Max(oldTex.Height, 4096));

            asset.ReplaceWith(newTex);
            asset.AsImage().PatchImage(oldTex);
            Log.Trace($"Boots are now ({oldTex.Width}, {Math.Max(oldTex.Height, 4096)})");

            foreach (var boots in Mod.instance.Boots)
            {
                try
                {
                    Log.Verbose($"Injecting {boots.Name} sprites @ {ContentInjector1.BootsRect(boots.GetTextureIndex())}");
                    asset.AsImage().PatchExtendedTileSheet(boots.textureColor, null, ContentInjector1.BootsRect(boots.GetTextureIndex()));
                }
                catch (Exception e)
                {
                    Log.Error($"Exception injecting sprite for {boots.Name}: {e}");
                }
            }
        }
コード例 #8
0
        private void InjectTileSheetsCraftables(IAssetData asset)
        {
            using var oldTex = asset.AsImage().Data;
            Texture2D newTex = new Texture2D(Game1.graphics.GraphicsDevice, oldTex.Width, Math.Max(oldTex.Height, 4096));

            asset.ReplaceWith(newTex);
            asset.AsImage().PatchImage(oldTex);
            Log.Trace($"Big craftables are now ({oldTex.Width}, {Math.Max(oldTex.Height, 4096)})");

            foreach (var big in Mod.instance.BigCraftables)
            {
                try
                {
                    Log.Verbose($"Injecting {big.Name} sprites @ {ContentInjector1.BigCraftableRect(big.GetCraftableId())}");
                    asset.AsImage().PatchExtendedTileSheet(big.texture, null, ContentInjector1.BigCraftableRect(big.GetCraftableId()));
                    if (big.ReserveExtraIndexCount > 0)
                    {
                        for (int i = 0; i < big.ReserveExtraIndexCount; ++i)
                        {
                            Log.Verbose($"Injecting {big.Name} reserved extra sprite {i + 1} @ {ContentInjector1.BigCraftableRect(big.GetCraftableId() + i + 1)}");
                            asset.AsImage().PatchExtendedTileSheet(big.extraTextures[i], null, ContentInjector1.BigCraftableRect(big.GetCraftableId() + i + 1));
                        }
                    }

                    var rect = ContentInjector1.BigCraftableRect(big.GetCraftableId());
                    int ts   = TileSheetExtensions.GetAdjustedTileSheetTarget(asset.AssetName, rect).TileSheet;
                    big.tilesheet  = asset.AssetName + (ts == 0 ? "" : (ts + 1).ToString());
                    big.tilesheetX = rect.X;
                    big.tilesheetY = rect.Y;
                }
                catch (Exception e)
                {
                    Log.Error($"Exception injecting sprite for {big.Name}: {e}");
                }
            }
        }