using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Threading; using BepInEx; using Buttplug.Client; using Buttplug.Client.Connectors.WebsocketConnector; using Buttplug.Core; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("BonerBuzzer")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Buttplug.io support for Trombone Champ")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BonerBuzzer")] [assembly: AssemblyTitle("BonerBuzzer")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BonerBuzzer { [BepInPlugin("BonerBuzzer", "BonerBuzzer", "1.0.0")] public class BonerBuzzerPlugin : BaseUnityPlugin { private static ButtplugClient buttplugClient; public static BonerBuzzerPlugin Instance; private void Awake() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown if (!((Object)(object)Instance != (Object)null)) { Instance = this; buttplugClient = new ButtplugClient("Tromboner"); buttplugClient.DeviceAdded += DeviceAdded; buttplugClient.DeviceRemoved += DeviceRemoved; buttplugClient.PingTimeout += PingTimeout; buttplugClient.ErrorReceived += ErrorReceived; Connect(); Harmony.CreateAndPatchAll(typeof(Patches), (string)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin BonerBuzzer is loaded!"); } } private void DeviceAdded(object sender, DeviceAddedEventArgs args) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("Device " + args.Device.DisplayName + " added")); } private void DeviceRemoved(object sender, DeviceRemovedEventArgs args) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("Device " + args.Device.DisplayName + " removed")); } private void PingTimeout(object sender, EventArgs args) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Client timed out"); } private void ErrorReceived(object sender, ButtplugExceptionEventArgs args) { ((BaseUnityPlugin)this).Logger.LogError((object)$"{args.Exception}"); } private void Connect() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown try { ButtplugWebsocketConnector val = new ButtplugWebsocketConnector(new Uri("ws://localhost:12345")); buttplugClient.ConnectAsync((IButtplugClientConnector)(object)val, default(CancellationToken)).Wait(); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Exception occured during connection: {arg}"); } } public void SendVibrations(float strength) { LogInfo($"Sending vibrations of strength {strength} to devices..."); ButtplugClientDevice[] devices = buttplugClient.Devices; foreach (ButtplugClientDevice val in devices) { val.VibrateAsync((double)strength); } } public void LogInfo(string message) { ((BaseUnityPlugin)this).Logger.LogInfo((object)message); } public void LogDebug(string message) { ((BaseUnityPlugin)this).Logger.LogDebug((object)message); } } public class Patches { [HarmonyPatch(typeof(GameController), "Update")] [HarmonyPostfix] public static void VibrateOnToot(GameController __instance) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (__instance.notebuttonpressed && !__instance.outofbreath) { float y = __instance.pointer.transform.localPosition.y; BonerBuzzerPlugin.Instance.LogInfo($"Pointer Location: {y}"); BonerBuzzerPlugin.Instance.SendVibrations((y + 180f) / 360f); } else { BonerBuzzerPlugin.Instance.SendVibrations(0f); } } } public static class PluginInfo { public const string PLUGIN_GUID = "BonerBuzzer"; public const string PLUGIN_NAME = "BonerBuzzer"; public const string PLUGIN_VERSION = "1.0.0"; } }