-
Notifications
You must be signed in to change notification settings - Fork 10
/
ModEntry.cs
69 lines (56 loc) · 2.76 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewMods.ArchaeologyHouseContentManagementHelper.Framework;
using StardewModdingAPI;
using StardewModdingAPI.Events;
using Harmony;
using StardewMods.Common;
using StardewMods.ArchaeologyHouseContentManagementHelper.Framework.Services;
using StardewMods.ArchaeologyHouseContentManagementHelper.Patches;
using Constants = StardewMods.ArchaeologyHouseContentManagementHelper.Common.Constants;
namespace StardewMods.ArchaeologyHouseContentManagementHelper
{
/// <summary>The mod entry point.</summary>
internal class ModEntry : Mod
{
private MuseumInteractionDialogService menuInteractDialogService;
private LostBookFoundDialogService lostBookFoundDialogService;
private CollectionPageExMenuService collectionPageExMenuService;
public static CommonServices CommonServices { get; private set; }
/// <summary>The mod configuration from the player.</summary>
public static ModConfig ModConfig { get; private set; }
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
/// <param name="helper">Provides simplified APIs for writing mods.</param>
public override void Entry(IModHelper helper)
{
if (helper == null)
{
Monitor.Log("Error: [modHelper] cannot be [null]!", LogLevel.Error);
throw new ArgumentNullException(nameof(helper), "Error: [modHelper] cannot be [null]!");
}
// Set services and mod configurations
CommonServices = new CommonServices(Monitor, helper.Events, helper.Translation, helper.Reflection, helper.Content, helper.Data);
ModConfig = Helper.ReadConfig<ModConfig>();
// Apply game patches
var harmony = HarmonyInstance.Create(Constants.MOD_ID);
var addItemToInventoryBoolPatch = new AddItemToInventoryBoolPatch();
var couldInventoryAcceptThisObjectPatch = new CouldInventoryAcceptThisObjectPatch();
addItemToInventoryBoolPatch.Apply(harmony);
couldInventoryAcceptThisObjectPatch.Apply(harmony);
collectionPageExMenuService = new CollectionPageExMenuService();
collectionPageExMenuService.Start();
helper.Events.GameLoop.SaveLoaded += Bootstrap;
}
private void Bootstrap(object sender, SaveLoadedEventArgs e)
{
// Start remaining services
menuInteractDialogService = new MuseumInteractionDialogService();
lostBookFoundDialogService = new LostBookFoundDialogService();
menuInteractDialogService.Start();
lostBookFoundDialogService.Start();
}
}
}