-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathLobbyConfigManager.cs
73 lines (66 loc) · 3.26 KB
/
LobbyConfigManager.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
using Hazel;
using System.Collections.Generic;
namespace DillyzRoleApi_Rewritten
{
public class LobbyConfigManager
{
public static string OUTPUT_FILE => DillyzRoleApiMain.BEPINEX_CONFIG_FOLDER + "dillyzroleapi-lobby-settings.json";
public static string OUTPUT_FILE_ROLES => DillyzRoleApiMain.BEPINEX_CONFIG_FOLDER + "dillyzroleapi-role-settings.json";
private static List<LobbyRoleSetting> _lobbyRoleSettings = new List<LobbyRoleSetting>();
public static List<LobbyRoleSetting> lobbyRoleSettings => _lobbyRoleSettings;
public static void Save() {
/*string jsonString = JsonSerializer.Serialize(lobbyRoleSettings, new JsonSerializerOptions() { _writeIndented = true });
using (StreamWriter outputFile = new StreamWriter(OUTPUT_FILE_ROLES))
outputFile.WriteLine(jsonString);*/
}
public static void Load()
{
/*using (StreamReader inputFile = new StreamReader(OUTPUT_FILE_ROLES))
{
string json = inputFile.ReadToEnd();
_lobbyRoleSettings = JsonSerializer.Deserialize<List<LobbyRoleSetting>>(json);
}*/
}
public static void UpdateRoleValues() {
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRpc.SetSettings, Hazel.SendOption.None, -1);
writer.Write((byte)(CustomRole.allRoles.Count * 2));
foreach (CustomRole role in CustomRole.allRoles)
{
writer.Write($"LOBBY_ROLE_SETTING-{role.name}-Count");
writer.Write(role.setting_countPerGame);
writer.Write($"LOBBY_ROLE_SETTING-{role.name}-Chance");
writer.Write(role.setting_chancePerGame);
}
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
public static void UpdateAdvancedRoleValues()
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRpc.SetSettings, Hazel.SendOption.None, -1);
writer.Write((byte)(CustomRole.allRoles.Count-1));
foreach (CustomRole role in CustomRole.allRoles)
{
foreach (CustomSetting setting in role.advancedSettings)
{
writer.Write($"LOBBY_ARS-{role.name}-{setting.title}");
switch (setting.settingType) {
case CustomSettingType.Boolean:
writer.Write((setting as CustomBooleanSetting).settingValue);
break;
case CustomSettingType.Float:
writer.Write((setting as CustomFloatSetting).settingValue);
break;
case CustomSettingType.String:
writer.Write((setting as CustomStringSetting).settingValue);
break;
}
}
}
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
}
public class LobbyRoleSetting {
public string roleName { get; set; }
public int roleCount { get; set; }
public int roleChance { get; set; }
}
}