This repository was archived by the owner on Jun 16, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModEntry.cs
More file actions
108 lines (90 loc) · 3.72 KB
/
Copy pathModEntry.cs
File metadata and controls
108 lines (90 loc) · 3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
using StardewModdingAPI;
using StardewModdingAPI.Events;
using StardewValley;
namespace Cylix.FarmCleaner;
internal sealed class ModEntry : Mod
{
private ModConfig config = null!;
private FarmClearer farmClearer = null!;
public override void Entry(IModHelper helper)
{
config = Helper.ReadConfig<ModConfig>();
farmClearer = new FarmClearer(Helper, Monitor);
FarmCleanerPatches.Apply(ModManifest.UniqueID, Monitor);
helper.Events.Input.ButtonsChanged += OnButtonsChanged;
helper.Events.GameLoop.GameLaunched += OnGameLaunched;
helper.ConsoleCommands.Add("clearfarm",
"Clears all trees, stones, grass, and debris from your farm.\n\nUsage: clearfarm",
(_, _) => farmClearer.ClearFarm(config.ClearFruitTrees, config.DropMultiplier, config.EnableExperience, config.ClearTappedTrees, config.ClearGrowingTrees));
}
private void OnButtonsChanged(object? sender, ButtonsChangedEventArgs e)
{
if (!Context.IsWorldReady)
return;
if (!config.ClearKey.JustPressed())
return;
if (Game1.currentLocation is not Farm)
{
Monitor.Log("You must be on your farm to use this.", LogLevel.Info);
return;
}
farmClearer.ClearFarm(config.ClearFruitTrees, config.DropMultiplier, config.EnableExperience, config.ClearTappedTrees, config.ClearGrowingTrees);
}
private void OnGameLaunched(object? sender, GameLaunchedEventArgs e)
{
var gmcm = Helper.ModRegistry.GetApi<IGenericModConfigMenuApi>(
"spacechase0.GenericModConfigMenu");
if (gmcm is null)
return;
gmcm.Register(
mod: ModManifest,
reset: () => config = new ModConfig(),
save: () => Helper.WriteConfig(config)
);
gmcm.AddKeybindList(
mod: ModManifest,
getValue: () => config.ClearKey,
setValue: val => config.ClearKey = val,
name: () => "Clear Key",
tooltip: () => "Key to clear all trees, stones, grass, and debris from your farm."
);
gmcm.AddBoolOption(
mod: ModManifest,
getValue: () => config.ClearFruitTrees,
setValue: val => config.ClearFruitTrees = val,
name: () => "Clear Fruit Trees",
tooltip: () => "If enabled, fruit trees will also be cleared."
);
gmcm.AddBoolOption(
mod: ModManifest,
getValue: () => config.EnableExperience,
setValue: val => config.EnableExperience = val,
name: () => "Enable Experience",
tooltip: () => "If disabled, no experience is gained from clearing the farm."
);
gmcm.AddBoolOption(
mod: ModManifest,
getValue: () => config.ClearTappedTrees,
setValue: val => config.ClearTappedTrees = val,
name: () => "Clear Tapped Trees",
tooltip: () => "If enabled, trees with tappers will also be cleared."
);
gmcm.AddBoolOption(
mod: ModManifest,
getValue: () => config.ClearGrowingTrees,
setValue: val => config.ClearGrowingTrees = val,
name: () => "Clear Growing Trees",
tooltip: () => "If enabled, trees that are not fully grown will also be cleared."
);
gmcm.AddNumberOption(
mod: ModManifest,
getValue: () => config.DropMultiplier,
setValue: val => config.DropMultiplier = val,
name: () => "Drop Multiplier",
tooltip: () => "Multiplies the number of dropped items (wood, stone, fiber, etc).",
min: 0.5f,
max: 10f,
interval: 0.5f
);
}
}