public static void ReceiveRpc(MessageReader reader) { PluginSingleton <ProxyOfUs> .Instance.Log.LogInfo($"Options received:"); while (reader.BytesRemaining > 0) { int id = reader.ReadInt32(); CustomOption customOption = CustomOption.AllOptions.FirstOrDefault(option => option.ID == id); // Works but may need to change to gameObject.name check var type = customOption?.Type; object value = null; if (type == CustomOptionType.Toggle) { value = reader.ReadBoolean(); } else if (type == CustomOptionType.Number) { value = reader.ReadSingle(); } else if (type == CustomOptionType.String) { value = reader.ReadInt32(); } customOption?.Set(value); PluginSingleton <ProxyOfUs> .Instance.Log.LogInfo($"{customOption?.Name} : {customOption}:"); } }
private static bool OnEnable(OptionBehaviour opt) { if (opt == ExportButton.Setting) { ExportButton.OptionCreated(); return(false); } if (opt == ImportButton.Setting) { ImportButton.OptionCreated(); return(false); } CustomOption customOption = CustomOption.AllOptions.FirstOrDefault(option => option.Setting == opt); // Works but may need to change to gameObject.name check if (customOption == null) { customOption = ExportButton.SlotButtons.FirstOrDefault(option => option.Setting == opt); if (customOption == null) { customOption = ImportButton.SlotButtons.FirstOrDefault(option => option.Setting == opt); if (customOption == null) { return(true); } } } customOption.OptionCreated(); return(false); }
public static bool Prefix(StringOption __instance) { CustomOption option = CustomOption.AllOptions.FirstOrDefault(option => option.Setting == __instance); // Works but may need to change to gameObject.name check if (option is CustomStringOption str) { str.Decrease(); return(false); } return(true); }
public static void SendRpc(CustomOption optionn = null) { List <CustomOption> options; if (optionn != null) { options = new List <CustomOption> { optionn }; } else { options = CustomOption.AllOptions; } var writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncCustomSettings, SendOption.Reliable); foreach (var option in options) { writer.Write(option.ID); if (option.Type == CustomOptionType.Toggle) { writer.Write((bool)option.Value); } else if (option.Type == CustomOptionType.Number) { writer.Write((float)option.Value); } else if (option.Type == CustomOptionType.String) { writer.Write((int)option.Value); } } writer.EndMessage(); }
public static bool Prefix(ToggleOption __instance) { CustomOption option = CustomOption.AllOptions.FirstOrDefault(option => option.Setting == __instance); // Works but may need to change to gameObject.name check if (option is CustomToggleOption toggle) { toggle.Toggle(); return(false); } if (__instance == ExportButton.Setting) { if (!AmongUsClient.Instance.AmHost) { return(false); } ExportButton.Do(); return(false); } if (__instance == ImportButton.Setting) { if (!AmongUsClient.Instance.AmHost) { return(false); } ImportButton.Do(); return(false); } if (option is CustomHeaderOption) { return(false); } CustomOption option2 = ExportButton.SlotButtons.FirstOrDefault(option => option.Setting == __instance); if (option2 is CustomButtonOption button) { if (!AmongUsClient.Instance.AmHost) { return(false); } button.Do(); return(false); } CustomOption option3 = ImportButton.SlotButtons.FirstOrDefault(option => option.Setting == __instance); if (option3 is CustomButtonOption button2) { if (!AmongUsClient.Instance.AmHost) { return(false); } button2.Do(); return(false); } return(true); }