Repository navigation
Expand file tree
/
Copy pathSubModule.cs
More file actions
99 lines (79 loc) · 2.88 KB
/
Copy pathSubModule.cs
File metadata and controls
99 lines (79 loc) · 2.88 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
using HarmonyLib;
using System.Reflection;
using TaleWorlds.CampaignSystem;
using TaleWorlds.CampaignSystem.CharacterCreationContent;
using TaleWorlds.Core;
using TaleWorlds.MountAndBlade;
namespace StartAsAnyone
{
public class SubModule : MBSubModuleBase
{
private static readonly Harmony _harmony = new Harmony("com.kerema14.startasanyone");
private static bool _isInitialized = false;
public static Hero heroToBeSet;
public static bool heroInit;
public static CampaignTime heroBirthday;
public static bool startAsAnyone;
internal static float heroWeight;
internal static float heroBuild;
internal static StaticBodyProperties heroStaticBodyProperties;
protected override void OnSubModuleLoad()
{
base.OnSubModuleLoad();
//InformationManager.DisplayMessage(new InformationMessage("Start As Anyone has been loaded"));
Harmony.DEBUG = false;
heroInit = false;
if (!_isInitialized)
{
_harmony.PatchAll(Assembly.GetExecutingAssembly());
_isInitialized = true;
}
#if SAA_CAPTURE
CaptureDirector.Initialize();
#endif
}
#if SAA_CAPTURE
protected override void OnBeforeInitialModuleScreenSetAsRoot()
{
base.OnBeforeInitialModuleScreenSetAsRoot();
CaptureDirector.OnMainMenuReady();
}
#endif
public override void OnNewGameCreated(Game game, object initializerObject)
{
base.OnNewGameCreated(game, initializerObject);
SubModule.heroToBeSet = Hero.MainHero;
CampaignEvents.OnCharacterCreationIsOverEvent.AddNonSerializedListener(this, setHeroAge);
CampaignEvents.OnCharacterCreationInitializedEvent.AddNonSerializedListener(this, addSAAStageAction);
}
private void addSAAStageAction(CharacterCreationManager manager)
{
manager.AddStage(new CharacterCreationStartAsAnyoneOrNewStage());
}
public override void OnGameLoaded(Game game, object initializerObject)
{
base.OnGameLoaded(game, initializerObject);
}
protected override void OnApplicationTick(float dt)
{
base.OnApplicationTick(dt);
#if SAA_CAPTURE
CaptureDirector.Tick();
#endif
}
protected override void InitializeGameStarter(Game game, IGameStarter starterObject)
{
base.InitializeGameStarter(game, starterObject);
}
public void setHeroAge()
{
if (heroInit)
{
Hero.MainHero.SetBirthDay(heroBirthday);
Hero.MainHero.Weight = heroWeight;
Hero.MainHero.Build = heroBuild;
Hero.MainHero.StaticBodyProperties = heroStaticBodyProperties;
}
}
}
}