public static void StashToNearbyChests(int radius, AcceptingFunction f) { ModEntry.Log("Stash to nearby chests"); var movedAtLeastOne = false; foreach (var chest in Game1.player.GetNearbyChests(radius)) { var moveItems = Game1.player.Items .Where(i => i != null) .Where(i => f(chest, i)) .ToList(); if (!moveItems.Any()) { continue; } var movedItems = chest.DumpItemsToChest(Game1.player.Items, moveItems); if (movedItems.Any()) { movedAtLeastOne = true; } } if (!movedAtLeastOne) { return; } // List of sounds: https://gist.github.com/gasolinewaltz/46b1473415d412e220a21cb84dd9aad6 Game1.playSound(Game1.soundBank.GetCue("pickUpItem").Name); }
public static void StashToChest(Chest chest, AcceptingFunction f) { ModEntry.Log("Stash to current chest"); var inventory = Game1.player.Items.Where(i => i != null).ToList(); var toBeMoved = inventory.Where(i => f(chest, i)).ToList(); if (toBeMoved.Any() && chest.DumpItemsToChest(Game1.player.Items, toBeMoved).Any()) { Game1.playSound(Game1.soundBank.GetCue("pickUpItem").Name); } }