update resource clump logic for SDV 1.5 (#770)

This commit is contained in:
Jesse Plamondon-Willard 2021-04-02 20:13:23 -04:00
parent c48f6d78cc
commit 0d5b4e9983
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
2 changed files with 13 additions and 11 deletions

View File

@ -7,6 +7,10 @@
* Migrated to Harmony 2.0 (see [_migrate to Harmony 2.0_](https://stardewvalleywiki.com/Modding:Migrate_to_Harmony_2.0) for more info).
-->
## Upcoming release
* For players:
* Fixed `world_clear` console command not removing resource clumps outside the farm and secret woods.
## 3.9.5
Released 21 March 2021 for Stardew Valley 1.5.4 or later.

View File

@ -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<ResourceClump> resourceClumps =
(location as Farm)?.resourceClumps
?? (IList<ResourceClump>)(location as Woods)?.stumps
?? new List<ResourceClump>();
// remove matching clumps
foreach (var clump in resourceClumps.ToArray())
foreach (var clump in location.resourceClumps.Where(shouldRemove).ToArray())
{
if (shouldRemove(clump))
location.resourceClumps.Remove(clump);
removed++;
}
if (location is Woods woods)
{
foreach (ResourceClump clump in woods.stumps.Where(shouldRemove).ToArray())
{
resourceClumps.Remove(clump);
woods.stumps.Remove(clump);
removed++;
}
}