summaryrefslogtreecommitdiff
path: root/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-07-28 00:36:34 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-07-28 00:36:34 -0400
commite3010f7c41028c3420df06e025f9af594b866c2b (patch)
tree4f9642d8d9308b0c22f2612d9d521bf44a2e2cee /src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World
parent428f0c5880fa8b133f601beda2e27c87dc7134af (diff)
downloadSMAPI-e3010f7c41028c3420df06e025f9af594b866c2b.tar.gz
SMAPI-e3010f7c41028c3420df06e025f9af594b866c2b.tar.bz2
SMAPI-e3010f7c41028c3420df06e025f9af594b866c2b.zip
refactor new code a bit
Diffstat (limited to 'src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World')
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/ClearCommand.cs20
1 files changed, 5 insertions, 15 deletions
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/ClearCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/ClearCommand.cs
index d7cd40ec..44adc4c9 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/ClearCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/ClearCommand.cs
@@ -15,7 +15,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
** Fields
*********/
/// <summary>The valid types that can be cleared.</summary>
- private readonly string[] ValidTypes = { "crops", "debris", "fruit-trees", "furniture", "grass", "trees", "removeable", "everything" };
+ private readonly string[] ValidTypes = { "crops", "debris", "fruit-trees", "furniture", "grass", "trees", "removable", "everything" };
/// <summary>The resource clump IDs to consider debris.</summary>
private readonly int[] DebrisClumps = { ResourceClump.stumpIndex, ResourceClump.hollowLogIndex, ResourceClump.meteoriteIndex, ResourceClump.boulderIndex };
@@ -31,7 +31,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
description: "Clears in-game entities in a given location.\n\n"
+ "Usage: world_clear <location> <object type>\n"
+ " - location: the location name for which to clear objects (like Farm), or 'current' for the current location.\n"
- + " - object type: the type of object clear. You can specify 'crops', 'debris' (stones/twigs/weeds and dead crops), 'furniture', 'grass', and 'trees' / 'fruit-trees'. You can also specify 'removeable', which includes everything that can be removed or destroyed during normal game play, or 'everything', which includes permanent bushes."
+ + " - object type: the type of object clear. You can specify 'crops', 'debris' (stones/twigs/weeds and dead crops), 'furniture', 'grass', and 'trees' / 'fruit-trees'. You can also specify 'removable' (remove everything that can be removed or destroyed during normal gameplay) or 'everything' (remove everything including permanent bushes)."
)
{ }
@@ -133,25 +133,15 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
break;
}
- case "removeable":
- {
- int removed =
- this.RemoveFurniture(location, p => true)
- + this.RemoveObjects(location, p => true)
- + this.RemoveTerrainFeatures(location, p => true)
- + this.RemoveLargeTerrainFeatures(location, p => !(p is Bush) || ((Bush)p).isDestroyable(location, p.currentTileLocation))
- + this.RemoveResourceClumps(location, p => true);
- monitor.Log($"Done! Removed {removed} entities from {location.Name}.", LogLevel.Info);
- break;
- }
-
+ case "removable":
case "everything":
{
+ bool everything = type == "everything";
int removed =
this.RemoveFurniture(location, p => true)
+ this.RemoveObjects(location, p => true)
+ this.RemoveTerrainFeatures(location, p => true)
- + this.RemoveLargeTerrainFeatures(location, p => true)
+ + this.RemoveLargeTerrainFeatures(location, p => everything || p is not Bush bush || bush.isDestroyable(location, p.currentTileLocation))
+ this.RemoveResourceClumps(location, p => true);
monitor.Log($"Done! Removed {removed} entities from {location.Name}.", LogLevel.Info);
break;