From 0d5b4e9983dd30fc7c586c22d69d54cd44e7a627 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 2 Apr 2021 20:13:23 -0400 Subject: update resource clump logic for SDV 1.5 (#770) --- .../Framework/Commands/World/ClearCommand.cs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/SMAPI.Mods.ConsoleCommands/Framework/Commands') diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/ClearCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/ClearCommand.cs index 4b0e45a0..4cfaf242 100644 --- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/ClearCommand.cs +++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/ClearCommand.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using StardewValley; using StardewValley.Locations; @@ -224,18 +223,17 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World { int removed = 0; - // get resource clumps - IList resourceClumps = - (location as Farm)?.resourceClumps - ?? (IList)(location as Woods)?.stumps - ?? new List(); + foreach (var clump in location.resourceClumps.Where(shouldRemove).ToArray()) + { + location.resourceClumps.Remove(clump); + removed++; + } - // remove matching clumps - foreach (var clump in resourceClumps.ToArray()) + if (location is Woods woods) { - if (shouldRemove(clump)) + foreach (ResourceClump clump in woods.stumps.Where(shouldRemove).ToArray()) { - resourceClumps.Remove(clump); + woods.stumps.Remove(clump); removed++; } } -- cgit