-
Notifications
You must be signed in to change notification settings - Fork 0
/
ModEntry.cs
105 lines (87 loc) · 3.51 KB
/
ModEntry.cs
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
using GenericModConfigMenu;
using HarmonyLib;
using ScytheToolEnchantments;
using StardewModdingAPI;
using StardewModdingAPI.Events;
using StardewValley.Minigames;
namespace CustomMoss;
public class ModEntry : Mod
{
public static void Log(string v)
{
_log.Log(v, LogLevel.Debug);
}
public static IMonitor _log = null!;
public static ModConfig Config;
public static IScytheToolEnchantmentsApi? ScytheAPI;
public override void Entry(IModHelper helper)
{
Config = Helper.ReadConfig<ModConfig>();
_log = Monitor;
var harmony = new Harmony(ModManifest.UniqueID);
Helper.Events.Content.AssetRequested += OnAssetRequested;
Helper.Events.GameLoop.GameLaunched += OnGameLaunched;
Helper.Events.GameLoop.GameLaunched += InitConfig;
harmony.PatchAll();
}
private void OnGameLaunched(object? sender, GameLaunchedEventArgs e)
{
if (!Helper.ModRegistry.IsLoaded("mushymato.ScytheToolEnchantments")) return;
ScytheAPI = Helper.ModRegistry.GetApi<IScytheToolEnchantmentsApi>("mushymato.ScytheToolEnchantments");
}
private static void OnAssetRequested(object? sender, AssetRequestedEventArgs e)
{
/*
* "aceynk.CustomMoss/Trees" like:
*
* {
* "MossId": {
* "DropWhenShaken": <bool>,
* "ValidSeasons": <GSQ>, [Implemented]
* "ValidTrees": <list<string>>, [Implemented]
* "MaxAmount": <int>, [Implemented]
* "MinAmount": <int>, [Implemented]
* "TextureOak": <texture fp>, [Implemented]
* "TextureMaple": <asset>, [Implemented]
* "TexturePine": <asset>, [Implemented]
* "Texture1": <asset>, [Implemented]
* "Texture2": <asset>, [Implemented]
* "Chance": <int>, [Implemented]
* "Experience": <int> [Implemented]
* }
* }
*/
if (e.Name.IsEquivalentTo("aceynk.CustomMoss/Tree"))
{
e.LoadFrom(() => new Dictionary<string, Dictionary<string, string>>(), AssetLoadPriority.High);
}
if (e.Name.IsEquivalentTo("aceynk.CustomMoss/Stone"))
{
e.LoadFrom(() => new Dictionary<string, Dictionary<string, string>>(), AssetLoadPriority.High);
}
}
private void InitConfig(object? sender, GameLaunchedEventArgs e)
{
var menu = Helper.ModRegistry.GetApi<IGenericModConfigMenuApi>("spacechase0.GenericModConfigMenu");
if (menu is null)
{
return;
}
menu.Register(
mod: ModManifest,
reset: () => Config = new ModConfig(),
save: () => Helper.WriteConfig(Config)
);
menu.AddSectionTitle(
mod: ModManifest,
text: () => Helper.Translation.Get("GMCM.MainTitle")
);
menu.AddBoolOption(
mod: ModManifest,
name: () => Helper.Translation.Get("GMCM.VanillaMossOverrides.Name"),
tooltip: () => Helper.Translation.Get("GMCM.VanillaMossOverrides.Desc"),
getValue: () => Config.VanillaMossOverrides,
setValue: v => Config.VanillaMossOverrides = v
);
}
}