/
SubModule.cs
33 lines (29 loc) · 1018 Bytes
/
SubModule.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
using System.IO;
using Microsoft.CodeAnalysis.Scripting;
using Microsoft.CSharp.RuntimeBinder;
using TaleWorlds.CampaignSystem;
using TaleWorlds.Core;
using TaleWorlds.MountAndBlade;
namespace Int19h.Bannerlord.CSharp.Scripting {
public class SubModule : MBSubModuleBase {
protected override void OnSubModuleLoad() {
OmniSharpConfig.Update();
}
protected override void OnGameStart(Game game, IGameStarter starter) {
base.OnGameStart(game, starter);
if (starter is CampaignGameStarter campaignStarter) {
campaignStarter.AddBehavior(new CampaignBehavior());
}
dynamic? subModule;
try {
subModule = ScriptGlobals.Scripts.SubModule;
} catch (CompilationErrorException) {
subModule = null;
}
try {
subModule?.OnGameStart(game, starter);
} catch (RuntimeBinderException) {
}
}
}
}