/
MPSetup.cs
401 lines (366 loc) · 23.6 KB
/
MPSetup.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
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using HarmonyLib;
using Overload;
using UnityEngine;
namespace GameMod {
[HarmonyPatch(typeof(NetworkMatch), "SetDefaultMatchSettings")]
class MPSetupDefault
{
public static void Postfix()
{
MPDownloadLevel.Reset();
MPTeams.NetworkMatchTeamCount = 2;
MPJoinInProgress.NetworkMatchEnabled = false;
RearView.MPNetworkMatchEnabled = false;
MPSuddenDeath.SuddenDeathMatchEnabled = false;
MPClassic.matchEnabled = false;
}
}
[HarmonyPatch(typeof(NetworkMatch), "ApplyPrivateMatchSettings")]
class MPSetupApplyPMD
{
public static void ApplyMatchOLModData()
{
Debug.Log("Apply PMD name " + String.Join(",", NetworkMatch.m_name.Select(x => ((int)x).ToString()).ToArray()));
var i = NetworkMatch.m_name.IndexOf('\0');
if (i == -1)
{
MPSetupDefault.Postfix();
}
else
{
MPTeams.NetworkMatchTeamCount = (NetworkMatch.m_name[i + 1] & 7) + 2;
MPJoinInProgress.NetworkMatchEnabled = (NetworkMatch.m_name[i + 1] & 8) != 0;
RearView.MPNetworkMatchEnabled = (NetworkMatch.m_name[i + 1] & 16) != 0;
MPSuddenDeath.SuddenDeathMatchEnabled = (NetworkMatch.m_name[i + 1] & 32) != 0;
}
}
private static void Postfix(ref bool __result, PrivateMatchDataMessage pmd, ref int ___m_num_players_to_start_match)
{
ApplyMatchOLModData();
if (___m_num_players_to_start_match == 2) // always allow start with 1
___m_num_players_to_start_match = 1;
if (!__result && !Config.NoDownload && !string.IsNullOrEmpty(pmd.m_addon_level_name_hash)) // unknown level?
{
MPDownloadLevel.StartGetLevel(pmd.m_addon_level_name_hash);
__result = true;
}
}
}
[HarmonyPatch(typeof(NetworkMatch), "OnAcceptedToLobby")]
class MPSetupAcceptedToLobby
{
static void Postfix()
{
MPSetupApplyPMD.ApplyMatchOLModData();
}
}
[HarmonyPatch(typeof(MenuManager), "BuildPrivateMatchData")]
class MPSetupBuildPMD
{
static void Postfix(PrivateMatchDataMessage __result)
{
Debug.Log("Build PMD name jipsingle " + MPJoinInProgress.SingleMatchEnable);
if ((MPTeams.MenuManagerTeamCount > 2 || MPJoinInProgress.MenuManagerEnabled || MPJoinInProgress.SingleMatchEnable || RearView.MPMenuManagerEnabled ||
MPSuddenDeath.SuddenDeathMenuEnabled) &&
MenuManager.m_mp_lan_match)
{
__result.m_name += new string(new char[] { '\0', (char)(
((Math.Max(2, MPTeams.MenuManagerTeamCount) - 2) & 7) |
(MPJoinInProgress.MenuManagerEnabled || MPJoinInProgress.SingleMatchEnable ? 8 : 0) |
(RearView.MPMenuManagerEnabled ? 16 : 0) |
(MPSuddenDeath.SuddenDeathMenuEnabled ? 32 : 0))});
}
Debug.Log("Build PMD name " + String.Join(",", __result.m_name.Select(x => ((int)x).ToString()).ToArray()));
if (MPJoinInProgress.MenuManagerEnabled || MPJoinInProgress.SingleMatchEnable ||
(MenuManager.m_mp_lan_match && MPInternet.Enabled))
__result.m_num_players_to_start = 1;
if ((int)__result.m_match_mode > (int)ExtMatchMode.CTF) // newer matchmodes are sent with ModPrivateData
__result.m_match_mode = NetworkMatch.IsTeamMode(__result.m_match_mode) ? MatchMode.TEAM_ANARCHY : MatchMode.ANARCHY;
}
}
[HarmonyPatch(typeof(MenuManager), "InitMpPrivateMatch")]
class MPSetupMenuInit
{
public static void Postfix()
{
MPTeams.MenuManagerTeamCount = 2;
MPJoinInProgress.MenuManagerEnabled = false;
RearView.MPMenuManagerEnabled = false;
MPSuddenDeath.SuddenDeathMenuEnabled = false;
ExtMenuManager.mms_ext_lap_limit = 0;
}
}
[HarmonyPatch(typeof(MenuManager), "SetPreferencesDefaults")]
class MPSetupMenuDefault
{
static void Postfix()
{
MPSetupMenuInit.Postfix();
Console.KeyEnabled = false;
Console.CustomUIColor = 0;
}
}
static class ModPrefs
{
private static Hashtable m_prefs_hashtable = new Hashtable();
private static string m_serialized_data = string.Empty;
private static object oldPrefs, oldData;
private static FieldInfo _GamePreferences_m_prefs_hashtable_Field = typeof(GamePreferences).GetField("m_prefs_hashtable", BindingFlags.NonPublic | BindingFlags.Static);
private static FieldInfo _GamePreferences_m_serialized_data_Field = typeof(GamePreferences).GetField("m_serialized_data", BindingFlags.NonPublic | BindingFlags.Static);
private static void SwapPre()
{
oldPrefs = _GamePreferences_m_prefs_hashtable_Field.GetValue(null);
oldData = _GamePreferences_m_serialized_data_Field.GetValue(null);
_GamePreferences_m_prefs_hashtable_Field.SetValue(null, m_prefs_hashtable);
_GamePreferences_m_serialized_data_Field.SetValue(null, m_serialized_data);
}
private static void SwapPost()
{
m_prefs_hashtable = (Hashtable)_GamePreferences_m_prefs_hashtable_Field.GetValue(null);
m_serialized_data = (string)_GamePreferences_m_serialized_data_Field.GetValue(null);
_GamePreferences_m_prefs_hashtable_Field.SetValue(null, oldPrefs);
_GamePreferences_m_serialized_data_Field.SetValue(null, oldData);
oldPrefs = null;
oldData = null;
}
public static bool Load(string filename)
{
SwapPre();
GamePreferences.Load(filename);
SwapPost();
return m_serialized_data != null;
}
public static void Flush(string filename)
{
SwapPre();
GamePreferences.Flush(filename);
SwapPost();
}
public static void DeleteAll()
{
m_prefs_hashtable.Clear();
}
public static int GetInt(string key, int defaultValue)
{
try {
if (m_prefs_hashtable.ContainsKey(key)) {
return (int)m_prefs_hashtable[key];
}
} catch (Exception) {
Debug.Log($"MPSetup: Could not convert key {key} value {m_prefs_hashtable[key]} to an int, resetting to default {defaultValue}.");
}
m_prefs_hashtable.Add(key, defaultValue);
return defaultValue;
}
public static bool GetBool(string key, bool defaultValue)
{
try {
if (m_prefs_hashtable.ContainsKey(key)) {
return (bool)m_prefs_hashtable[key];
}
} catch (Exception) {
Debug.Log($"MPSetup: Could not convert key {key} value {m_prefs_hashtable[key]} to a bool, resetting to default {defaultValue}.");
}
m_prefs_hashtable.Add(key, defaultValue);
return defaultValue;
}
public static void SetInt(string key, int value)
{
m_prefs_hashtable[key] = value;
}
public static void SetBool(string key, bool value)
{
m_prefs_hashtable[key] = value;
}
public static string GetString(string key, string defaultValue)
{
if (m_prefs_hashtable.ContainsKey(key))
{
return (string)m_prefs_hashtable[key];
}
m_prefs_hashtable.Add(key, defaultValue);
return defaultValue;
}
public static void SetString(string key, string value)
{
m_prefs_hashtable[key] = value;
}
}
[HarmonyPatch(typeof(MenuManager), "LoadPreferences")]
class MPSetupLoad
{
static void Postfix(string filename)
{
if (ModPrefs.Load(filename + "mod"))
{
MPTeams.MenuManagerTeamCount = ModPrefs.GetInt("MP_PM_TEAM_COUNT", MPTeams.MenuManagerTeamCount);
MPJoinInProgress.MenuManagerEnabled = ModPrefs.GetBool("MP_PM_JIP", MPJoinInProgress.MenuManagerEnabled);
RearView.MPMenuManagerEnabled = ModPrefs.GetBool("MP_PM_REARVIEW", RearView.MPMenuManagerEnabled);
RearView.MenuManagerEnabled = ModPrefs.GetBool("O_PM_REARVIEW", RearView.MenuManagerEnabled);
MPSuddenDeath.SuddenDeathMenuEnabled = ModPrefs.GetBool("MP_PM_SUDDENDEATH", MPSuddenDeath.SuddenDeathMenuEnabled);
ExtMenuManager.mms_ext_lap_limit = ModPrefs.GetInt("MP_PM_LAP_LIMIT", ExtMenuManager.mms_ext_lap_limit);
Console.KeyEnabled = ModPrefs.GetBool("O_CONSOLE_KEY", Console.KeyEnabled);
Console.CustomUIColor = ModPrefs.GetInt("O_CUSTOM_UI_COLOR", Console.CustomUIColor);
Menus.mms_damage_numbers = ModPrefs.GetBool("MP_DAMAGE_NUMBERS", Menus.mms_damage_numbers);
Menus.mms_client_damage_numbers = ModPrefs.GetBool("MP_CLIENT_DAMAGE_NUMBERS", Menus.mms_client_damage_numbers);
MPThunderboltPassthrough.isAllowed = ModPrefs.GetBool("MP_THUNDERBOLT_PASSTHROUGH", MPThunderboltPassthrough.isAllowed);
Menus.mms_always_cloaked = ModPrefs.GetBool("MP_ALWAYS_CLOAKED", Menus.mms_always_cloaked);
Menus.mms_classic_spawns = ModPrefs.GetBool("MP_CLASSIC_SPAWNS", Menus.mms_classic_spawns);
Menus.mms_assist_scoring = ModPrefs.GetBool("MP_ASSIST_SCORING", Menus.mms_assist_scoring);
Menus.mms_allow_smash = ModPrefs.GetBool("MP_ALLOW_SMASH", Menus.mms_allow_smash);
JoystickRotationFix.alt_turn_ramp_mode = ModPrefs.GetBool("SCALE_UP_ROTATION", JoystickRotationFix.alt_turn_ramp_mode);
MPColoredPlayerNames.isActive = ModPrefs.GetBool("MP_COLORED_NAMES", MPColoredPlayerNames.isActive);
DisableProfanityFilter.profanity_filter = ModPrefs.GetBool("MP_PROFANITY_FILTER", DisableProfanityFilter.profanity_filter);
Menus.mms_scale_respawn_time = ModPrefs.GetBool("MP_PM_SCALE_RESPAWN_TIME", Menus.mms_scale_respawn_time);
if (Core.GameMod.HasInternetMatch())
MPInternet.MenuIPAddress = ModPrefs.GetString("MP_PM_IP_ADDRESS", MPInternet.MenuIPAddress);
Menus.mms_lag_compensation = ModPrefs.GetInt("MP_PM_LAG_COMPENSATION", Menus.mms_lag_compensation);
Menus.mms_lag_compensation_advanced = ModPrefs.GetBool("MP_PM_LAG_COMPENSATION_ADVANCED", Menus.mms_lag_compensation_advanced);
Menus.mms_ship_lag_compensation_max = ModPrefs.GetInt("MP_PM_SHIP_LAG_COMPENSATION", Menus.mms_ship_lag_compensation_max);
Menus.mms_weapon_lag_compensation_max = ModPrefs.GetInt("MP_PM_WEAPON_LAG_COMPENSATION", Menus.mms_weapon_lag_compensation_max);
Menus.mms_lag_compensation_strength = ModPrefs.GetInt("MP_PM_LAG_COMPENSATION_STRENGTH", Menus.mms_lag_compensation_strength);
Menus.mms_lag_compensation_use_interpolation = ModPrefs.GetInt("MP_PM_LAG_COMPENSATION_USE_INTERPOLATION", Menus.mms_lag_compensation_use_interpolation);
Menus.mms_lag_compensation_ship_added_lag = ModPrefs.GetInt("MP_PM_LAG_COMPENSATION_SHIP_ADDED_LAG", Menus.mms_lag_compensation_ship_added_lag);
Menus.mms_ship_lag_compensation_scale = ModPrefs.GetInt("MP_PM_SHIP_LAG_COMPENSATION_SCALE", Menus.mms_ship_lag_compensation_scale);
Menus.mms_weapon_lag_compensation_scale = ModPrefs.GetInt("MP_PM_WEAPON_LAG_COMPENSATION_SCALE", Menus.mms_weapon_lag_compensation_scale);
Menus.mms_lag_compensation_collision_limit = ModPrefs.GetInt("MP_PM_SHIP_LAG_COMPENSATION_COLLISION_LIMIT", Menus.mms_lag_compensation_collision_limit);
Menus.mms_sticky_death_summary = ModPrefs.GetBool("MP_PM_STICKY_DEATH_SUMMARY", Menus.mms_sticky_death_summary);
MPDeathReview.stickyDeathReview = Menus.mms_sticky_death_summary;
Menus.mms_reduced_ship_explosions = ModPrefs.GetBool("MP_PM_REDUCED_SHIP_EXPLOSIONS", Menus.mms_reduced_ship_explosions);
Menus.mms_damageeffect_alpha_mult = ModPrefs.GetInt("MP_PM_DAMAGEEFFECT_ALPHA_MULT", Menus.mms_damageeffect_alpha_mult);
Menus.mms_damageeffect_drunk_blur_mult = ModPrefs.GetInt("MP_PM_DAMAGEEFFECT_DRUNK_BLUR_MULT", Menus.mms_damageeffect_drunk_blur_mult);
Menus.mms_match_time_limit = ModPrefs.GetInt("MP_PM_MATCH_TIME_LIMIT", Menus.mms_match_time_limit);
Menus.mms_team_color_default = ModPrefs.GetBool("MP_PM_TEAM_COLOR_DEFAULT", Menus.mms_team_color_default);
Menus.mms_team_color_self = ModPrefs.GetInt("MP_PM_TEAM_COLOR_SELF", Menus.mms_team_color_self);
Menus.mms_team_color_enemy = ModPrefs.GetInt("MP_PM_TEAM_COLOR_ENEMY", Menus.mms_team_color_enemy);
Menus.mms_team_health = ModPrefs.GetBool("MP_PM_TEAM_HEALTH", Menus.mms_team_health);
HUDVelocity.MenuManagerEnabled = ModPrefs.GetBool("MP_PM_SHOWHUDVELOCITY", HUDVelocity.MenuManagerEnabled);
Menus.mms_show_framerate = ModPrefs.GetBool("MP_PM_SHOWFRAMERATE", Menus.mms_show_framerate);
Menus.mms_audio_occlusion_strength = ModPrefs.GetInt("MP_PM_AUDIO_OCCLUSION_STRENGTH", Menus.mms_audio_occlusion_strength);
Menus.mms_directional_warnings = ModPrefs.GetBool("MP_PM_DIRECTIONAL_WARNINGS", Menus.mms_directional_warnings);
Menus.mms_loadout_hotkeys = ModPrefs.GetInt("MP_PM_LOADOUT_HOTKEYS2", Menus.mms_loadout_hotkeys);
MPLoadouts.Loadouts[0].weapons[0] = (WeaponType)ModPrefs.GetInt("MP_PM_LOADOUT_BOMBER1_W1", (int)MPLoadouts.Loadouts[0].weapons[0]);
MPLoadouts.Loadouts[0].missiles[0] = (MissileType)ModPrefs.GetInt("MP_PM_LOADOUT_BOMBER1_M1", (int)MPLoadouts.Loadouts[0].missiles[0]);
MPLoadouts.Loadouts[0].missiles[1] = (MissileType)ModPrefs.GetInt("MP_PM_LOADOUT_BOMBER1_M2", (int)MPLoadouts.Loadouts[0].missiles[1]);
MPLoadouts.Loadouts[1].weapons[0] = (WeaponType)ModPrefs.GetInt("MP_PM_LOADOUT_GUNNER1_W1", (int)MPLoadouts.Loadouts[1].weapons[0]);
MPLoadouts.Loadouts[1].weapons[1] = (WeaponType)ModPrefs.GetInt("MP_PM_LOADOUT_GUNNER1_W2", (int)MPLoadouts.Loadouts[1].weapons[1]);
MPLoadouts.Loadouts[1].missiles[0] = (MissileType)ModPrefs.GetInt("MP_PM_LOADOUT_GUNNER1_M1", (int)MPLoadouts.Loadouts[1].missiles[0]);
MPLoadouts.Loadouts[2].weapons[0] = (WeaponType)ModPrefs.GetInt("MP_PM_LOADOUT_BOMBER2_W1", (int)MPLoadouts.Loadouts[2].weapons[0]);
MPLoadouts.Loadouts[2].missiles[0] = (MissileType)ModPrefs.GetInt("MP_PM_LOADOUT_BOMBER2_M1", (int)MPLoadouts.Loadouts[2].missiles[0]);
MPLoadouts.Loadouts[2].missiles[1] = (MissileType)ModPrefs.GetInt("MP_PM_LOADOUT_BOMBER2_M2", (int)MPLoadouts.Loadouts[2].missiles[1]);
MPLoadouts.Loadouts[3].weapons[0] = (WeaponType)ModPrefs.GetInt("MP_PM_LOADOUT_GUNNER2_W1", (int)MPLoadouts.Loadouts[1].weapons[0]);
MPLoadouts.Loadouts[3].weapons[1] = (WeaponType)ModPrefs.GetInt("MP_PM_LOADOUT_GUNNER2_W2", (int)MPLoadouts.Loadouts[1].weapons[1]);
MPLoadouts.Loadouts[3].missiles[0] = (MissileType)ModPrefs.GetInt("MP_PM_LOADOUT_GUNNER2_M1", (int)MPLoadouts.Loadouts[1].missiles[0]);
MPAudioTaunts.AClient.active = ModPrefs.GetBool("MP_AUDIOTAUNTS_ACTIVE", true);
MPAudioTaunts.AClient.loaded_local_taunts = ModPrefs.GetString("MP_LOCAL_AUDIOTAUNTS", MPAudioTaunts.AClient.loaded_local_taunts);
MPAudioTaunts.AClient.LoadLocalAudioTauntsFromPilotPrefs();
MPAudioTaunts.AClient.audio_taunt_volume = ModPrefs.GetInt("MP_AUDIOTAUNT_VOLUME", 50);
for (int i = 0; i < MPAudioTaunts.AMOUNT_OF_TAUNTS_PER_CLIENT; i++){
MPAudioTaunts.AClient.keybinds[i] = ModPrefs.GetInt("MP_AUDIOTAUNT_KEYBIND_" + i.ToString(), -1);}
MPAudioTaunts.AClient.display_audio_spectrum = ModPrefs.GetBool("MP_AUDIOTAUNT_SHOW_FREQUENCYBAND", true);
}
else // for compatibility with old olmod, no need to add new settings
{
MPTeams.MenuManagerTeamCount = MenuManager.LocalGetInt("MP_PM_TEAM_COUNT", MPTeams.MenuManagerTeamCount);
MPJoinInProgress.MenuManagerEnabled = MenuManager.LocalGetBool("MP_PM_JIP", MPJoinInProgress.MenuManagerEnabled);
RearView.MPMenuManagerEnabled = MenuManager.LocalGetBool("MP_PM_REARVIEW", RearView.MPMenuManagerEnabled);
Console.KeyEnabled = MenuManager.LocalGetBool("O_CONSOLE_KEY", Console.KeyEnabled);
Console.CustomUIColor = MenuManager.LocalGetInt("O_CUSTOM_UI_COLOR", Console.CustomUIColor);
}
}
}
[HarmonyPatch(typeof(MenuManager), "SavePreferences")]
class MPSetupSave
{
private static int lastXP;
public static void Store()
{
if (MenuManager.LocalGetInt("PS_XP2", 0) == 0 && lastXP > 0)
MenuManager.LocalSetInt("PS_XP2", lastXP);
}
private static void Prefix(string filename)
{
lastXP = MenuManager.LocalGetInt("PS_XP2", 0);
ModPrefs.DeleteAll();
ModPrefs.SetInt("MP_PM_TEAM_COUNT", MPTeams.MenuManagerTeamCount);
ModPrefs.SetBool("MP_PM_JIP", MPJoinInProgress.MenuManagerEnabled);
ModPrefs.SetBool("MP_PM_REARVIEW", RearView.MPMenuManagerEnabled);
ModPrefs.SetBool("O_PM_REARVIEW", RearView.MenuManagerEnabled);
ModPrefs.SetBool("MP_PM_SUDDENDEATH", MPSuddenDeath.SuddenDeathMenuEnabled);
ModPrefs.SetInt("MP_PM_LAP_LIMIT", ExtMenuManager.mms_ext_lap_limit);
ModPrefs.SetBool("O_CONSOLE_KEY", Console.KeyEnabled);
ModPrefs.SetInt("O_CUSTOM_UI_COLOR", Console.CustomUIColor);
ModPrefs.SetBool("SCALE_UP_ROTATION", JoystickRotationFix.alt_turn_ramp_mode);
ModPrefs.SetBool("MP_COLORED_NAMES", MPColoredPlayerNames.isActive);
ModPrefs.SetBool("MP_PROFANITY_FILTER", DisableProfanityFilter.profanity_filter);
ModPrefs.SetString("MP_PM_IP_ADDRESS", MPInternet.MenuIPAddress);
ModPrefs.SetBool("MP_PM_SCALE_RESPAWN_TIME", Menus.mms_scale_respawn_time);
ModPrefs.SetInt("MP_PM_LAG_COMPENSATION", Menus.mms_lag_compensation);
ModPrefs.SetBool("MP_PM_LAG_COMPENSATION_ADVANCED", Menus.mms_lag_compensation_advanced);
ModPrefs.SetInt("MP_PM_SHIP_LAG_COMPENSATION", Menus.mms_ship_lag_compensation_max);
ModPrefs.SetInt("MP_PM_WEAPON_LAG_COMPENSATION", Menus.mms_weapon_lag_compensation_max);
ModPrefs.SetInt("MP_PM_LAG_COMPENSATION_STRENGTH", Menus.mms_lag_compensation_strength);
ModPrefs.SetInt("MP_PM_LAG_COMPENSATION_USE_INTERPOLATION", Menus.mms_lag_compensation_use_interpolation);
ModPrefs.SetInt("MP_PM_LAG_COMPENSATION_SHIP_ADDED_LAG", Menus.mms_lag_compensation_ship_added_lag);
ModPrefs.SetInt("MP_PM_WEAPON_LAG_COMPENSATION_SCALE", Menus.mms_weapon_lag_compensation_scale);
ModPrefs.SetInt("MP_PM_SHIP_LAG_COMPENSATION_SCALE", Menus.mms_ship_lag_compensation_scale);
ModPrefs.SetInt("MP_PM_SHIP_LAG_COMPENSATION_COLLISION_LIMIT", Menus.mms_lag_compensation_collision_limit);
ModPrefs.SetBool("MP_PM_STICKY_DEATH_SUMMARY", Menus.mms_sticky_death_summary);
ModPrefs.SetBool("MP_PM_REDUCED_SHIP_EXPLOSIONS", Menus.mms_reduced_ship_explosions);
ModPrefs.SetInt("MP_PM_DAMAGEEFFECT_ALPHA_MULT", Menus.mms_damageeffect_alpha_mult);
ModPrefs.SetInt("MP_PM_DAMAGEEFFECT_DRUNK_BLUR_MULT", Menus.mms_damageeffect_drunk_blur_mult);
ModPrefs.SetInt("MP_PM_MATCH_TIME_LIMIT", Menus.mms_match_time_limit);
ModPrefs.SetBool("MP_PM_TEAM_COLOR_DEFAULT", Menus.mms_team_color_default);
ModPrefs.SetInt("MP_PM_TEAM_COLOR_SELF", Menus.mms_team_color_self);
ModPrefs.SetInt("MP_PM_TEAM_COLOR_ENEMY", Menus.mms_team_color_enemy);
ModPrefs.SetBool("MP_PM_TEAM_HEALTH", Menus.mms_team_health);
ModPrefs.SetBool("MP_PM_SHOWHUDVELOCITY", HUDVelocity.MenuManagerEnabled);
ModPrefs.SetBool("MP_PM_SHOWFRAMERATE", Menus.mms_show_framerate);
ModPrefs.SetInt("MP_PM_AUDIO_OCCLUSION_STRENGTH", Menus.mms_audio_occlusion_strength);
ModPrefs.SetBool("MP_PM_DIRECTIONAL_WARNINGS", Menus.mms_directional_warnings);
ModPrefs.SetInt("MP_PM_LOADOUT_HOTKEYS2", Menus.mms_loadout_hotkeys);
ModPrefs.SetInt("MP_PM_LOADOUT_BOMBER1_W1", (int)MPLoadouts.Loadouts[0].weapons[0]);
ModPrefs.SetInt("MP_PM_LOADOUT_BOMBER1_M1", (int)MPLoadouts.Loadouts[0].missiles[0]);
ModPrefs.SetInt("MP_PM_LOADOUT_BOMBER1_M2", (int)MPLoadouts.Loadouts[0].missiles[1]);
ModPrefs.SetInt("MP_PM_LOADOUT_GUNNER1_W1", (int)MPLoadouts.Loadouts[1].weapons[0]);
ModPrefs.SetInt("MP_PM_LOADOUT_GUNNER1_W2", (int)MPLoadouts.Loadouts[1].weapons[1]);
ModPrefs.SetInt("MP_PM_LOADOUT_GUNNER1_M1", (int)MPLoadouts.Loadouts[1].missiles[0]);
ModPrefs.SetInt("MP_PM_LOADOUT_BOMBER2_W1", (int)MPLoadouts.Loadouts[2].weapons[0]);
ModPrefs.SetInt("MP_PM_LOADOUT_BOMBER2_M1", (int)MPLoadouts.Loadouts[2].missiles[0]);
ModPrefs.SetInt("MP_PM_LOADOUT_BOMBER2_M2", (int)MPLoadouts.Loadouts[2].missiles[1]);
ModPrefs.SetInt("MP_PM_LOADOUT_GUNNER2_W1", (int)MPLoadouts.Loadouts[3].weapons[0]);
ModPrefs.SetInt("MP_PM_LOADOUT_GUNNER2_W2", (int)MPLoadouts.Loadouts[3].weapons[1]);
ModPrefs.SetInt("MP_PM_LOADOUT_GUNNER2_M1", (int)MPLoadouts.Loadouts[3].missiles[0]);
ModPrefs.SetBool("MP_DAMAGE_NUMBERS", Menus.mms_damage_numbers);
ModPrefs.SetBool("MP_CLIENT_DAMAGE_NUMBERS", Menus.mms_client_damage_numbers);
ModPrefs.SetBool("MP_THUNDERBOLT_PASSTHROUGH", MPThunderboltPassthrough.isAllowed);
ModPrefs.SetBool("MP_ALWAYS_CLOAKED", Menus.mms_always_cloaked);
ModPrefs.SetBool("MP_CLASSIC_SPAWNS", Menus.mms_classic_spawns);
ModPrefs.SetBool("MP_ASSIST_SCORING", Menus.mms_assist_scoring);
ModPrefs.SetBool("MP_ALLOW_SMASH", Menus.mms_allow_smash);
ModPrefs.SetBool("MP_AUDIOTAUNTS_ACTIVE", MPAudioTaunts.AClient.active);
ModPrefs.SetString("MP_LOCAL_AUDIOTAUNTS", MPAudioTaunts.AClient.ChainTogetherHashesOfLocalTaunts());
ModPrefs.SetInt("MP_AUDIOTAUNT_VOLUME", MPAudioTaunts.AClient.audio_taunt_volume);
for (int i = 0; i < MPAudioTaunts.AMOUNT_OF_TAUNTS_PER_CLIENT; i++){
ModPrefs.SetInt("MP_AUDIOTAUNT_KEYBIND_" + i.ToString(), MPAudioTaunts.AClient.keybinds[i]);}
ModPrefs.SetBool("MP_AUDIOTAUNT_SHOW_FREQUENCYBAND", MPAudioTaunts.AClient.display_audio_spectrum);
ModPrefs.Flush(filename + "mod");
}
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> codes)
{
var mpSetupSave_Store_Method = AccessTools.Method(typeof(MPSetupSave), "Store");
foreach (var code in codes)
{
if (code.opcode == OpCodes.Call && ((MethodInfo)code.operand).Name == "Flush")
yield return new CodeInstruction(OpCodes.Call, mpSetupSave_Store_Method);
yield return code;
}
}
}
}