-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStart.cs
More file actions
174 lines (166 loc) · 7.52 KB
/
Start.cs
File metadata and controls
174 lines (166 loc) · 7.52 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
using Harmony;
using System;
namespace DisForLС
{
/*class Debug
{
public static void Log(string path, string message)
{
File.AppendAllText(path+"\\Error.txt", "Probably broken stream, message: " + message + "\n");
}
}*/
public class Harmony_Patch
{
public static Traverse[] storedFI = new Traverse[2];
public Harmony_Patch()
{
PresenceController._instance = new PresenceController();
if (!PresenceController._instance.presenceInit()) {
PresenceController.logger.Info("DisForLC mod initialization failed");
PresenceController._instance.Close();
return;
}
HarmonyInstance harmonyInstance = HarmonyInstance.Create("Lobotomy.justnikocat.LCRichPresence");
#region Patching
harmonyInstance.Patch(
typeof(LoadingScreen).GetMethod(nameof(LoadingScreen.LoadTitleScene), AccessTools.all),
null,
new HarmonyMethod(typeof(Harmony_Patch).GetMethod("LoadingScreen_LoadTitleScene")),
null);
harmonyInstance.Patch(
typeof(DeployUI).GetMethod("Awake", AccessTools.all),
null,
new HarmonyMethod(typeof(Harmony_Patch).GetMethod("DeployUI_Awake")),
null);
harmonyInstance.Patch(
typeof(GameManager).GetMethod("StartGame", AccessTools.all),
null,
new HarmonyMethod(typeof(Harmony_Patch).GetMethod("GlobalGame_StartGame")),
null);
harmonyInstance.Patch(
typeof(EnergyModel).GetMethod(nameof(EnergyModel.AddEnergy), AccessTools.all),
null,
new HarmonyMethod(typeof(Harmony_Patch).GetMethod("EnergyModel_AddEnergy")),
null);
harmonyInstance.Patch(
typeof(EnergyModel).GetMethod(nameof(EnergyModel.SubEnergy), AccessTools.all),
null,
new HarmonyMethod(typeof(Harmony_Patch).GetMethod("EnergyModel_SubEnergy")),
null);
harmonyInstance.Patch(
typeof(CreatureOverloadManager).GetMethod(nameof(CreatureOverloadManager.AddOverloadGague), AccessTools.all),
null,
new HarmonyMethod(typeof(Harmony_Patch).GetMethod("CreatureOverloadManager_AddOverloadGague")),
null);
harmonyInstance.Patch(
typeof(BgmManager).GetMethod(nameof(BgmManager.SetBgm), AccessTools.all),
null,
new HarmonyMethod(typeof(Harmony_Patch).GetMethod("BgmManager_SetBgm")),
null);
harmonyInstance.Patch(
typeof(ResultScreen).GetMethod(nameof(ResultScreen.OnSuccessManagement), AccessTools.all),
null,
new HarmonyMethod(typeof(Harmony_Patch).GetMethod("ResultScreen_OnSuccessManagement")),
null);
harmonyInstance.Patch(
typeof(StoryUI).GetMethod("Command_background", AccessTools.all),
null,
new HarmonyMethod(typeof(Harmony_Patch).GetMethod("StoryUI_Command_background")),
null);
harmonyInstance.Patch(
typeof(StoryUI).GetMethod("LoadStory", AccessTools.all),
null,
new HarmonyMethod(typeof(Harmony_Patch).GetMethod("StoryUI_LoadStory")),
null);
harmonyInstance.Patch(
typeof(GlobalGameManager).GetMethod("OnApplicationQuit", AccessTools.all),
null,
new HarmonyMethod(typeof(Harmony_Patch).GetMethod("GGG_OnApplicationQuit")),
null);
#endregion
#region Hooks
storedFI[0] = Traverse.Create(CreatureOverloadManager.instance).Field("qliphothOverloadGauge");
Notice.instance.Observe("OnAgentDead", delegate(object[] _){ PresenceController.GI.deadAgents++; });
Notice.instance.Observe("OnAgentPanic", delegate (object[] _) { PresenceController.GI.panicAgents += 1; });
Notice.instance.Observe("OnAgentPanicReturn", delegate (object[] _) { PresenceController.GI.panicAgents -= 1; });
#endregion
PresenceController.logger.Trace("Inited");
}
#region Patches
public static void LoadingScreen_LoadTitleScene()
{
PresenceController.GI.Scene = 0;
}
public static void DeployUI_Awake()
{
PresenceController.GI.ResetScene();
PresenceController.GI.Scene = 1;
PresenceController.GI.currDay = DeployUI.instance.Day + 1;
PresenceController.GI.allAgents = AgentManager.instance.GetAllAgentCount();
PresenceController.GI.deployMoney = MoneyModel.instance.money;
}
public static void GlobalGame_StartGame()
{
PresenceController.GI.Scene = 2;
PresenceController.GI.maxQliphoth = CreatureOverloadManager.instance.qliphothOverloadMax;
PresenceController.GI.maxEnergy = (int)StageTypeInfo.instnace.GetEnergyNeed(PlayerModel.instance.GetDay());
PresenceController.GI.agentsOnMission = AgentManager.instance.GetAgentList().Count;
}
public static void EnergyModel_AddEnergy()
{
PresenceController.GI.currEnergy = (int)EnergyModel.instance.GetEnergy();
}
public static void EnergyModel_SubEnergy()
{
PresenceController.GI.currEnergy = (int)EnergyModel.instance.GetEnergy();
}
public static void CreatureOverloadManager_AddOverloadGague()
{
try
{
PresenceController.GI.currQliphoth = (int)storedFI[0].GetValue();
PresenceController.GI.qliphothLevel = CreatureOverloadManager.instance.GetQliphothOverloadLevel();
}
catch (Exception) { }
}
public static void BgmManager_SetBgm(EmergencyLevel level)
{
PresenceController.GI.Trumpet = level.ToString();
}
public static void ResultScreen_OnSuccessManagement()
{
PresenceController.GI.endOfTheDay = true;
PresenceController.GI.Scene = 4;
PresenceController.GI.previousGrade.grade = ResultScreen.instance.report.Rank.text;
PresenceController.GI.previousGrade.promoted = ResultScreen.instance.report.promoted.promoted;
PresenceController.GI.previousGrade.lobRecieved = int.Parse(ResultScreen.instance.report.tortalLob.text);
PresenceController.GI.UpdatePrev();
PresenceController._instance.InstantUpdate();
}
public static void StoryUI_LoadStory(StoryUI __instance)
{
storedFI[1] = Traverse.Create(__instance).Field("_curCmd");
PresenceController.GI.storyBG = "AngelaBackground";
PresenceController.GI.cutsceneDay = __instance.dayCount.text.Remove(0, 4);
PresenceController.GI.Scene = 5;
}
public static void StoryUI_Command_background()
{
try
{
PresenceController.GI.storyBG = ((StoryScriptCommand_background)storedFI[1].GetValue()).src;
PresenceController.GI.Scene = 5;
}
catch (Exception) { }
}
public static void GGG_OnApplicationQuit()
{
try
{
PresenceController._instance.Close();
}
catch (Exception) { }
}
#endregion
}
}