-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCore.cs
47 lines (42 loc) · 1.35 KB
/
Core.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
using Kingmaker.PubSubSystem;
using ModMaker;
using System;
using System.Reflection;
using static KingmakerHarmony2Template.Main;
using static KingmakerHarmony2Template.Utilities.SettingsWrapper;
namespace KingmakerHarmony2Template
{
class Core :
IModEventHandler
{
public int Priority => 200;
public void ResetSettings()
{
Mod.Debug(MethodBase.GetCurrentMethod());
Mod.ResetSettings();
Mod.Settings.lastModVersion = Mod.Version.ToString();
LocalizationFileName = Local.FileName;
}
public void HandleModEnable()
{
Mod.Debug(MethodBase.GetCurrentMethod());
if (!string.IsNullOrEmpty(LocalizationFileName))
{
Local.Import(LocalizationFileName, e => Mod.Error(e));
LocalizationFileName = Local.FileName;
}
if (!Version.TryParse(Mod.Settings.lastModVersion, out Version version) || version < new Version(0, 0, 0))
ResetSettings();
else
{
Mod.Settings.lastModVersion = Mod.Version.ToString();
}
EventBus.Subscribe(this);
}
public void HandleModDisable()
{
Mod.Debug(MethodBase.GetCurrentMethod());
EventBus.Unsubscribe(this);
}
}
}