Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of RumblingCompany v0.0.3
BepInEx/plugins/RumblingCompany.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Threading; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Buttplug.Client; using Buttplug.Client.Connectors.WebsocketConnector; using Buttplug.Core; using Costura; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using RumblingCompany.Patches; 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", FrameworkDisplayName = ".NET Framework 4.7")] [assembly: AssemblyCompany("RumblingCompany")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Connecting your vibrator to Lethal Company since 2024")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RumblingCompany")] [assembly: AssemblyTitle("RumblingCompany")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] internal class <Module> { static <Module>() { AssemblyLoader.Attach(); } } 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 RumblingCompany { internal class Config { private static ConfigFile ConfigFile { get; set; } internal static ConfigEntry<string> ServerAdress { get; set; } internal static ConfigEntry<float> VibrationIncreasePerSecond { get; set; } internal static ConfigEntry<float> VibrationDecreasePerSecond { get; set; } internal static ConfigEntry<bool> DiedEnabled { get; set; } internal static ConfigEntry<float> DiedStrength { get; set; } internal static ConfigEntry<bool> HurtEnabled { get; set; } internal static ConfigEntry<bool> SpectatingEnabled { get; set; } internal static ConfigEntry<float> SpectatingStrength { get; set; } internal static ConfigEntry<bool> BeingZappedEnabled { get; set; } internal static ConfigEntry<float> BeingZappedStrength { get; set; } internal static ConfigEntry<bool> KillingEnabled { get; set; } internal static ConfigEntry<float> KillingStrength { get; set; } internal static ConfigEntry<bool> DealingDamageEnabled { get; set; } internal static ConfigEntry<float> DealingDamageStrength { get; set; } internal static ConfigEntry<bool> ZappingEnabled { get; set; } internal static ConfigEntry<float> ZappingStrength { get; set; } internal static ConfigEntry<bool> CollectionEnabled { get; set; } internal static ConfigEntry<float> CollectionStrength { get; set; } internal static ConfigEntry<bool> RunningEnabled { get; set; } internal static ConfigEntry<float> RunningStrength { get; set; } internal static ConfigEntry<bool> JumpingEnabled { get; set; } internal static ConfigEntry<float> JumpingStrength { get; set; } internal static ConfigEntry<bool> ScanningEnabled { get; set; } internal static ConfigEntry<float> ScanningStrength { get; set; } internal static ConfigEntry<bool> UsingWalkieTalkieEnabled { get; set; } internal static ConfigEntry<float> UsingWalkieTalkieStrength { get; set; } internal static ConfigEntry<bool> ReceivingWalkieTalkieEnabled { get; set; } internal static ConfigEntry<float> ReceivingWalkieTalkieStrength { get; set; } internal static ConfigEntry<bool> ChargingItemEnabled { get; set; } internal static ConfigEntry<float> ChargingItemStrength { get; set; } internal static ConfigEntry<bool> JetpackEnabled { get; set; } internal static ConfigEntry<float> JetpackStrength { get; set; } static Config() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown ConfigFile = new ConfigFile(Paths.ConfigPath + "\\RumblingCompany.cfg", true); ServerAdress = ConfigFile.Bind<string>("1.General", "Server Adress", "ws://localhost:12345", "Intiface server adress."); VibrationIncreasePerSecond = ConfigFile.Bind<float>("1.General.Increase", "Strength", 2f, "How fast vibrations increase"); VibrationDecreasePerSecond = ConfigFile.Bind<float>("1.General.Decrease", "Strength", 0.25f, "How fast vibrations decrease"); DiedEnabled = ConfigFile.Bind<bool>("2.Punishment.Died", "Enabled", true, "Vibrate when killed"); DiedStrength = ConfigFile.Bind<float>("2.Punishment.Died", "Strength", 1f, "Intensity of vibrations when you are killed"); HurtEnabled = ConfigFile.Bind<bool>("2.Punishment.WasHurt", "Enabled", true, "Vibrate when hurt (Intensity based on damage taken)"); SpectatingEnabled = ConfigFile.Bind<bool>("2.Punishment.Spectating", "Enabled", false, "Vibrate when spectating other players"); SpectatingStrength = ConfigFile.Bind<float>("2.Punishment.Spectating", "Strength", 0.2f, "Intensity of vibrations while spectating"); BeingZappedEnabled = ConfigFile.Bind<bool>("2.Punishment.Zapped", "Enabled", true, "Vibrate when being zapped"); BeingZappedStrength = ConfigFile.Bind<float>("2.Punishment.Zapped", "Strength", 0.8f, "Intensity of vibrations while being zapped by the Zap Gun"); KillingEnabled = ConfigFile.Bind<bool>("3.Reward.Killed", "Enabled", true, "Vibrate when killing"); KillingStrength = ConfigFile.Bind<float>("3.Reward.Killed", "Strength", 0.8f, "Intensity of vibrations from killing others"); DealingDamageEnabled = ConfigFile.Bind<bool>("3.Reward.DealtDamage", "Enabled", true, "Vibrate on dealing damage"); DealingDamageStrength = ConfigFile.Bind<float>("3.Reward.DealtDamage", "Strength", 0.2f, "Intensity of vibrations from dealing damage to others"); ZappingEnabled = ConfigFile.Bind<bool>("3.Reward.Zapping", "Enabled", true, "Vibrate when zapping"); ZappingStrength = ConfigFile.Bind<float>("3.Reward.Zapping", "Strength", 0.5f, "Intensity of vibrations while zapping others with the Zap Gun"); CollectionEnabled = ConfigFile.Bind<bool>("3.Reward.CollectedScrap", "Enabled", true, "Vibrate when collecting scrap"); CollectionStrength = ConfigFile.Bind<float>("3.Reward.CollectedScrap", "Strength", 0.5f, "Intensity of vibrations from collecting scrap"); RunningEnabled = ConfigFile.Bind<bool>("4.Miscellaneous.Running", "Enabled", true, "Vibrate while running"); RunningStrength = ConfigFile.Bind<float>("4.Miscellaneous.Running", "Strength", 0.2f, "Vibration intensity while running"); JumpingEnabled = ConfigFile.Bind<bool>("4.Miscellaneous.Jumping", "Enabled", true, "Vibrate when jumping"); JumpingStrength = ConfigFile.Bind<float>("4.Miscellaneous.Jumping", "Strength", 0.25f, "Vibration intensity from jumping"); ScanningEnabled = ConfigFile.Bind<bool>("4.Miscellaneous.Scanning", "Enabled", true, "Vibrate when scanning"); ScanningStrength = ConfigFile.Bind<float>("4.Miscellaneous.Scanning", "Strength", 0.2f, "Vibration intensity from scanning"); UsingWalkieTalkieEnabled = ConfigFile.Bind<bool>("4.Miscellaneous.UsingTheWalkieTalkie", "Enabled", true, "Vibrate while using the walkie talkie"); UsingWalkieTalkieStrength = ConfigFile.Bind<float>("4.Miscellaneous.UsingTheWalkieTalkie", "Strength", 0.3f, "Vibration intensity while using the walkie talkie"); ReceivingWalkieTalkieEnabled = ConfigFile.Bind<bool>("4.Miscellaneous.RecievingWalkieTalkieTransmition", "Enabled", true, "Vibrate while receiving audio from the walkie talkie"); ReceivingWalkieTalkieStrength = ConfigFile.Bind<float>("4.Miscellaneous.RecievingWalkieTalkieTransmition", "Strength", 0.25f, "Vibration intensity while receiving audio from the walkie talkie"); ChargingItemEnabled = ConfigFile.Bind<bool>("4.Miscellaneous.CharingItem", "Enabled", true, "Vibrate when charging items"); ChargingItemStrength = ConfigFile.Bind<float>("4.Miscellaneous.CharingItem", "Strength", 0.8f, "Vibration intensity from charting items"); JetpackEnabled = ConfigFile.Bind<bool>("4.Miscellaneous.Jetpack", "Enabled", true, "Vibrate while jetpacking"); JetpackStrength = ConfigFile.Bind<float>("4.Miscellaneous.Jetpack", "Strength", 0.5f, "Vibration intensity while using the jetpack"); } } public class DeviceManager { private float currentVibration = 0f; private float spikeVibration = 0f; private float vibrationIncreasePerSecond = Config.VibrationIncreasePerSecond.Value; private float vibrationDecreasePerSecond = Config.VibrationDecreasePerSecond.Value; public bool isRunning = false; public bool isUsingJetpack = false; public bool isSpectating = false; public bool isUsingWalkieTalkie = false; public bool isRecievingWalkieTalkie = false; public bool isZapping = false; public bool isBeingZapped = false; private List<ButtplugClientDevice> ConnectedDevices { get; set; } private ButtplugClient ButtplugClient { get; set; } public DeviceManager(string clientName) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown ConnectedDevices = new List<ButtplugClientDevice>(); Plugin.Mls.LogInfo((object)("Attempting to connect to Intiface server at " + Config.ServerAdress.Value)); ButtplugClient = new ButtplugClient(clientName); Plugin.Mls.LogInfo((object)"Connection successful. Beginning scan for devices"); ButtplugClient.DeviceAdded += HandleDeviceAdded; ButtplugClient.DeviceRemoved += HandleDeviceRemoved; } public void Vibrate() { float num = calculateVibrationTarget(); currentVibration = ((currentVibration < num) ? Mathf.Clamp(currentVibration + vibrationIncreasePerSecond * Time.deltaTime, 0f, Mathf.Min(num, 1f)) : Mathf.Clamp01(currentVibration - vibrationDecreasePerSecond * Time.deltaTime)); ConnectedDevices.ForEach(Action); spikeVibration = Mathf.Clamp(spikeVibration - vibrationDecreasePerSecond * Time.deltaTime, 0f, 2f); async void Action(ButtplugClientDevice device) { await device.VibrateAsync((double)Mathf.Clamp(currentVibration, 0f, 1f)); } } public void increaseVibration(float increase) { spikeVibration += increase; } public float calculateVibrationTarget() { float num = 0f; if (isRunning) { num += Config.RunningStrength.Value; } if (isUsingJetpack) { num += Config.JetpackStrength.Value; } if (isSpectating) { num += Config.SpectatingStrength.Value; } if (isUsingWalkieTalkie) { num += Config.UsingWalkieTalkieStrength.Value; } if (isRecievingWalkieTalkie) { num += Config.ReceivingWalkieTalkieStrength.Value; } if (isZapping) { num += Config.ZappingStrength.Value; } if (isBeingZapped) { num += Config.BeingZappedStrength.Value; } return spikeVibration + num; } public async void ConnectDevices() { if (ButtplugClient.Connected) { return; } try { await ButtplugClient.ConnectAsync((IButtplugClientConnector)new ButtplugWebsocketConnector(new Uri(Config.ServerAdress.Value)), default(CancellationToken)); await ButtplugClient.StartScanningAsync(default(CancellationToken)); } catch (ButtplugException) { Plugin.Mls.LogInfo((object)"Something went wrong"); } } private void HandleDeviceAdded(object sender, DeviceAddedEventArgs args) { if (!IsVibratableDevice(args.Device)) { Plugin.Mls.LogInfo((object)(args.Device.Name + " was detected but ignored due to it not being vibratable.")); return; } Plugin.Mls.LogInfo((object)(args.Device.Name + " connected to client " + ButtplugClient.Name)); ConnectedDevices.Add(args.Device); } private void HandleDeviceRemoved(object sender, DeviceRemovedEventArgs args) { if (IsVibratableDevice(args.Device)) { Plugin.Mls.LogInfo((object)(args.Device.Name + " disconnected from client " + ButtplugClient.Name)); ConnectedDevices.Remove(args.Device); } } private bool IsVibratableDevice(ButtplugClientDevice device) { return device.VibrateAttributes.Count > 0; } } [BepInPlugin("RumblingCompany", "RumblingCompany", "1.0.0")] public class Plugin : BaseUnityPlugin { internal static DeviceManager DeviceManager { get; private set; } internal static ManualLogSource Mls { get; private set; } private void Awake() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown Mls = ((BaseUnityPlugin)this).Logger; DeviceManager = new DeviceManager("Rumbling Company"); DeviceManager.ConnectDevices(); Harmony val = new Harmony("RumblingCompany"); val.PatchAll(typeof(PlayerControllerBPatch)); val.PatchAll(typeof(HUDManagerPatch)); val.PatchAll(typeof(ItemChargerPatch)); val.PatchAll(typeof(WalkieTalkiePatch)); val.PatchAll(typeof(EnemyAIPatch)); val.PatchAll(typeof(RoundManagerPatch)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin RumblingCompany is loaded!"); } } public static class PluginInfo { public const string PLUGIN_GUID = "RumblingCompany"; public const string PLUGIN_NAME = "RumblingCompany"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace RumblingCompany.Patches { [HarmonyPatch(typeof(EnemyAI))] internal class EnemyAIPatch { [HarmonyPatch(typeof(EnemyAI), "HitEnemy")] [HarmonyPrefix] private static void HitEnemyPatch(PlayerControllerB playerWhoHit, ref int ___enemyHP) { if (!((Object)(object)playerWhoHit != (Object)(object)GameNetworkManager.Instance.localPlayerController) && ___enemyHP != 0) { if (___enemyHP == 1 && Config.KillingEnabled.Value) { Plugin.Mls.LogInfo((object)$"Client killed enemy, spiking vibration (+ {Config.KillingStrength.Value * 100f}%)"); Plugin.DeviceManager.increaseVibration(Config.KillingStrength.Value); } else if (Config.DealingDamageEnabled.Value) { Plugin.Mls.LogInfo((object)$"Client hit enemy, spiking vibration (+ {Config.DealingDamageStrength.Value * 100f}%)"); Plugin.DeviceManager.increaseVibration(Config.DealingDamageStrength.Value); } } } } [HarmonyPatch(typeof(HUDManager))] internal class HUDManagerPatch { [HarmonyPatch(typeof(HUDManager), "PingScan_performed")] [HarmonyPrefix] private static void OnPingPatch(ref float ___playerPingingScan) { if (Config.ScanningEnabled.Value && !(___playerPingingScan > -1f) && !GameNetworkManager.Instance.localPlayerController.isPlayerDead) { Plugin.Mls.LogInfo((object)$"Client scanned, spiking vibration (+ {Config.ScanningStrength.Value * 100f}%)"); Plugin.DeviceManager.increaseVibration(Config.ScanningStrength.Value); } } } [HarmonyPatch(typeof(ItemCharger))] internal class ItemChargerPatch { [HarmonyPatch(typeof(ItemCharger), "ChargeItem")] [HarmonyPostfix] private static void OnItemChargePatch() { if (Config.ChargingItemEnabled.Value) { Plugin.Mls.LogInfo((object)$"Client charged an item, spiking vibration (+ {Config.ChargingItemStrength.Value * 100f}%)"); Plugin.DeviceManager.increaseVibration(Config.ChargingItemStrength.Value); } } } [HarmonyPatch(typeof(PlayerControllerB))] internal class PlayerControllerBPatch { [HarmonyPatch(typeof(PlayerControllerB), "DamagePlayer")] [HarmonyPostfix] private static void OnDamagePatch(int damageNumber) { if (Config.HurtEnabled.Value) { Plugin.Mls.LogInfo((object)$"Client was hurt, spiking vibration (+ {damageNumber}%)"); Plugin.DeviceManager.increaseVibration((float)damageNumber / 100f); } } [HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")] [HarmonyPostfix] private static void OnKilledPatch(ref PlayerControllerB __instance) { if (Config.DiedEnabled.Value && !((Object)(object)__instance != (Object)(object)GameNetworkManager.Instance.localPlayerController)) { Plugin.Mls.LogInfo((object)$"Client died, spiking vibration (+ {Config.DiedStrength.Value * 100f}%)"); Plugin.DeviceManager.increaseVibration(Config.DiedStrength.Value); } } [HarmonyPatch(typeof(PlayerControllerB), "Jump_performed")] [HarmonyPrefix] private static void OnJumpPatch(ref PlayerControllerB __instance, ref bool ___isJumping) { if (Config.JumpingEnabled.Value && !((Object)(object)__instance != (Object)(object)GameNetworkManager.Instance.localPlayerController) && !(!__instance.thisController.isGrounded | ___isJumping) && !__instance.inTerminalMenu) { Plugin.Mls.LogInfo((object)$"Client jumped, spiking vibration (+ {Config.JumpingStrength.Value * 100f}%)"); Plugin.DeviceManager.increaseVibration(Config.JumpingStrength.Value); } } [HarmonyPatch("Update")] [HarmonyPostfix] private static void IsSprintingPatch(ref PlayerControllerB __instance) { if (Config.RunningEnabled.Value && !((Object)(object)__instance != (Object)(object)GameNetworkManager.Instance.localPlayerController)) { Plugin.DeviceManager.isRunning = __instance.isSprinting; } } [HarmonyPatch("Update")] [HarmonyPostfix] private static void IsUsingJetpackPatch(ref PlayerControllerB __instance) { if (Config.JetpackEnabled.Value && !((Object)(object)__instance != (Object)(object)GameNetworkManager.Instance.localPlayerController)) { Plugin.DeviceManager.isUsingJetpack = __instance.jetpackControls; } } [HarmonyPatch("Update")] [HarmonyPostfix] private static void IsSpectatingPatch(ref PlayerControllerB __instance) { if (Config.SpectatingEnabled.Value && !((Object)(object)__instance != (Object)(object)GameNetworkManager.Instance.localPlayerController)) { Plugin.DeviceManager.isSpectating = __instance.hasBegunSpectating; } } [HarmonyPatch("Update")] [HarmonyPostfix] private static void BeingZappedByZapGunPatch(ref PlayerControllerB __instance) { if (Config.BeingZappedEnabled.Value && !((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)(object)__instance)) { if ((double)__instance.hinderedMultiplier < 3.5) { Plugin.DeviceManager.isBeingZapped = false; } else { Plugin.DeviceManager.isBeingZapped = true; } } } [HarmonyPatch("Update")] [HarmonyPostfix] private static void ZappingWithZapGunPatch(ref PlayerControllerB __instance) { if (Config.ZappingEnabled.Value && !((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)(object)__instance)) { Plugin.DeviceManager.isZapping = __instance.inShockingMinigame; } } [HarmonyPatch("Update")] [HarmonyPostfix] private static void Vibrate(ref PlayerControllerB __instance) { if (!((Object)(object)__instance != (Object)(object)GameNetworkManager.Instance.localPlayerController)) { Plugin.DeviceManager.Vibrate(); } } } [HarmonyPatch(typeof(RoundManager))] internal class RoundManagerPatch { [HarmonyPatch(typeof(RoundManager), "CollectNewScrapForThisRound")] [HarmonyPrefix] private static void CollectNewScrapForThisRoundPatch(GrabbableObject scrapObject) { if (Config.CollectionEnabled.Value && !((Object)(object)scrapObject.playerHeldBy != (Object)(object)GameNetworkManager.Instance.localPlayerController) && !RoundManager.Instance.scrapCollectedThisRound.Contains(scrapObject) && !scrapObject.scrapPersistedThroughRounds) { Plugin.Mls.LogInfo((object)$"Client collected scrap, spiking vibration (+ {Config.CollectionStrength.Value * 100f}%)"); Plugin.DeviceManager.increaseVibration(Config.CollectionStrength.Value); } } } [HarmonyPatch(typeof(WalkieTalkie))] internal class WalkieTalkiePatch { [HarmonyPatch(typeof(WalkieTalkie), "SetLocalClientSpeaking")] [HarmonyPostfix] private static void UsingWalkieTalkiePatch(bool speaking) { if (Config.UsingWalkieTalkieEnabled.Value) { Plugin.DeviceManager.isUsingWalkieTalkie = speaking; } } [HarmonyPatch(typeof(WalkieTalkie), "Update")] [HarmonyPostfix] private static void RecievingWalkieTalkiePatch(ref WalkieTalkie __instance, ref List<WalkieTalkie> ___allWalkieTalkies) { if (!Config.ReceivingWalkieTalkieEnabled.Value || !GameNetworkManager.Instance.localPlayerController.holdingWalkieTalkie || (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)(object)((GrabbableObject)__instance).playerHeldBy) { return; } foreach (WalkieTalkie ___allWalkieTalky in ___allWalkieTalkies) { if (((GrabbableObject)___allWalkieTalky).isBeingUsed && (Object)(object)___allWalkieTalky != (Object)(object)__instance && ___allWalkieTalky.clientIsHoldingAndSpeakingIntoThis) { Plugin.DeviceManager.isRecievingWalkieTalkie = true; return; } } Plugin.DeviceManager.isRecievingWalkieTalkie = false; } } } namespace Costura { [CompilerGenerated] internal static class AssemblyLoader { private static object nullCacheLock = new object(); private static Dictionary<string, bool> nullCache = new Dictionary<string, bool>(); private static Dictionary<string, string> assemblyNames = new Dictionary<string, string>(); private static Dictionary<string, string> symbolNames = new Dictionary<string, string>(); private static int isAttached; private static string CultureToString(CultureInfo culture) { if (culture == null) { return ""; } return culture.Name; } private static Assembly ReadExistingAssembly(AssemblyName name) { AppDomain currentDomain = AppDomain.CurrentDomain; Assembly[] assemblies = currentDomain.GetAssemblies(); Assembly[] array = assemblies; foreach (Assembly assembly in array) { AssemblyName name2 = assembly.GetName(); if (string.Equals(name2.Name, name.Name, StringComparison.InvariantCultureIgnoreCase) && string.Equals(CultureToString(name2.CultureInfo), CultureToString(name.CultureInfo), StringComparison.InvariantCultureIgnoreCase)) { return assembly; } } return null; } private static void CopyTo(Stream source, Stream destination) { byte[] array = new byte[81920]; int count; while ((count = source.Read(array, 0, array.Length)) != 0) { destination.Write(array, 0, count); } } private static Stream LoadStream(string fullName) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); if (fullName.EndsWith(".compressed")) { using (Stream stream = executingAssembly.GetManifestResourceStream(fullName)) { using DeflateStream source = new DeflateStream(stream, CompressionMode.Decompress); MemoryStream memoryStream = new MemoryStream(); CopyTo(source, memoryStream); memoryStream.Position = 0L; return memoryStream; } } return executingAssembly.GetManifestResourceStream(fullName); } private static Stream LoadStream(Dictionary<string, string> resourceNames, string name) { if (resourceNames.TryGetValue(name, out var value)) { return LoadStream(value); } return null; } private static byte[] ReadStream(Stream stream) { byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); return array; } private static Assembly ReadFromEmbeddedResources(Dictionary<string, string> assemblyNames, Dictionary<string, string> symbolNames, AssemblyName requestedAssemblyName) { string text = requestedAssemblyName.Name.ToLowerInvariant(); if (requestedAssemblyName.CultureInfo != null && !string.IsNullOrEmpty(requestedAssemblyName.CultureInfo.Name)) { text = requestedAssemblyName.CultureInfo.Name + "." + text; } byte[] rawAssembly; using (Stream stream = LoadStream(assemblyNames, text)) { if (stream == null) { return null; } rawAssembly = ReadStream(stream); } using (Stream stream2 = LoadStream(symbolNames, text)) { if (stream2 != null) { byte[] rawSymbolStore = ReadStream(stream2); return Assembly.Load(rawAssembly, rawSymbolStore); } } return Assembly.Load(rawAssembly); } public static Assembly ResolveAssembly(object sender, ResolveEventArgs e) { lock (nullCacheLock) { if (nullCache.ContainsKey(e.Name)) { return null; } } AssemblyName assemblyName = new AssemblyName(e.Name); Assembly assembly = ReadExistingAssembly(assemblyName); if ((object)assembly != null) { return assembly; } assembly = ReadFromEmbeddedResources(assemblyNames, symbolNames, assemblyName); if ((object)assembly == null) { lock (nullCacheLock) { nullCache[e.Name] = true; } if ((assemblyName.Flags & AssemblyNameFlags.Retargetable) != 0) { assembly = Assembly.Load(assemblyName); } } return assembly; } static AssemblyLoader() { assemblyNames.Add("assembly-csharp", "costura.assembly-csharp.dll.compressed"); assemblyNames.Add("buttplug.client.connectors.websocketconnector", "costura.buttplug.client.connectors.websocketconnector.dll.compressed"); assemblyNames.Add("buttplug", "costura.buttplug.dll.compressed"); assemblyNames.Add("costura", "costura.costura.dll.compressed"); symbolNames.Add("costura", "costura.costura.pdb.compressed"); assemblyNames.Add("deniszykov.websocketlistener", "costura.deniszykov.websocketlistener.dll.compressed"); assemblyNames.Add("microsoft.win32.primitives", "costura.microsoft.win32.primitives.dll.compressed"); assemblyNames.Add("netstandard", "costura.netstandard.dll.compressed"); assemblyNames.Add("newtonsoft.json", "costura.newtonsoft.json.dll.compressed"); assemblyNames.Add("system.appcontext", "costura.system.appcontext.dll.compressed"); assemblyNames.Add("system.collections.concurrent", "costura.system.collections.concurrent.dll.compressed"); assemblyNames.Add("system.collections", "costura.system.collections.dll.compressed"); assemblyNames.Add("system.collections.nongeneric", "costura.system.collections.nongeneric.dll.compressed"); assemblyNames.Add("system.collections.specialized", "costura.system.collections.specialized.dll.compressed"); assemblyNames.Add("system.componentmodel", "costura.system.componentmodel.dll.compressed"); assemblyNames.Add("system.componentmodel.eventbasedasync", "costura.system.componentmodel.eventbasedasync.dll.compressed"); assemblyNames.Add("system.componentmodel.primitives", "costura.system.componentmodel.primitives.dll.compressed"); assemblyNames.Add("system.componentmodel.typeconverter", "costura.system.componentmodel.typeconverter.dll.compressed"); assemblyNames.Add("system.console", "costura.system.console.dll.compressed"); assemblyNames.Add("system.data.common", "costura.system.data.common.dll.compressed"); assemblyNames.Add("system.diagnostics.contracts", "costura.system.diagnostics.contracts.dll.compressed"); assemblyNames.Add("system.diagnostics.debug", "costura.system.diagnostics.debug.dll.compressed"); assemblyNames.Add("system.diagnostics.diagnosticsource", "costura.system.diagnostics.diagnosticsource.dll.compressed"); assemblyNames.Add("system.diagnostics.fileversioninfo", "costura.system.diagnostics.fileversioninfo.dll.compressed"); assemblyNames.Add("system.diagnostics.process", "costura.system.diagnostics.process.dll.compressed"); assemblyNames.Add("system.diagnostics.stacktrace", "costura.system.diagnostics.stacktrace.dll.compressed"); assemblyNames.Add("system.diagnostics.textwritertracelistener", "costura.system.diagnostics.textwritertracelistener.dll.compressed"); assemblyNames.Add("system.diagnostics.tools", "costura.system.diagnostics.tools.dll.compressed"); assemblyNames.Add("system.diagnostics.tracesource", "costura.system.diagnostics.tracesource.dll.compressed"); assemblyNames.Add("system.diagnostics.tracing", "costura.system.diagnostics.tracing.dll.compressed"); assemblyNames.Add("system.drawing.primitives", "costura.system.drawing.primitives.dll.compressed"); assemblyNames.Add("system.dynamic.runtime", "costura.system.dynamic.runtime.dll.compressed"); assemblyNames.Add("system.globalization.calendars", "costura.system.globalization.calendars.dll.compressed"); assemblyNames.Add("system.globalization", "costura.system.globalization.dll.compressed"); assemblyNames.Add("system.globalization.extensions", "costura.system.globalization.extensions.dll.compressed"); assemblyNames.Add("system.io.compression", "costura.system.io.compression.dll.compressed"); assemblyNames.Add("system.io.compression.zipfile", "costura.system.io.compression.zipfile.dll.compressed"); assemblyNames.Add("system.io", "costura.system.io.dll.compressed"); assemblyNames.Add("system.io.filesystem", "costura.system.io.filesystem.dll.compressed"); assemblyNames.Add("system.io.filesystem.driveinfo", "costura.system.io.filesystem.driveinfo.dll.compressed"); assemblyNames.Add("system.io.filesystem.primitives", "costura.system.io.filesystem.primitives.dll.compressed"); assemblyNames.Add("system.io.filesystem.watcher", "costura.system.io.filesystem.watcher.dll.compressed"); assemblyNames.Add("system.io.isolatedstorage", "costura.system.io.isolatedstorage.dll.compressed"); assemblyNames.Add("system.io.memorymappedfiles", "costura.system.io.memorymappedfiles.dll.compressed"); assemblyNames.Add("system.io.pipes", "costura.system.io.pipes.dll.compressed"); assemblyNames.Add("system.io.unmanagedmemorystream", "costura.system.io.unmanagedmemorystream.dll.compressed"); assemblyNames.Add("system.linq", "costura.system.linq.dll.compressed"); assemblyNames.Add("system.linq.expressions", "costura.system.linq.expressions.dll.compressed"); assemblyNames.Add("system.linq.parallel", "costura.system.linq.parallel.dll.compressed"); assemblyNames.Add("system.linq.queryable", "costura.system.linq.queryable.dll.compressed"); assemblyNames.Add("system.net.http", "costura.system.net.http.dll.compressed"); assemblyNames.Add("system.net.nameresolution", "costura.system.net.nameresolution.dll.compressed"); assemblyNames.Add("system.net.networkinformation", "costura.system.net.networkinformation.dll.compressed"); assemblyNames.Add("system.net.ping", "costura.system.net.ping.dll.compressed"); assemblyNames.Add("system.net.primitives", "costura.system.net.primitives.dll.compressed"); assemblyNames.Add("system.net.requests", "costura.system.net.requests.dll.compressed"); assemblyNames.Add("system.net.security", "costura.system.net.security.dll.compressed"); assemblyNames.Add("system.net.sockets", "costura.system.net.sockets.dll.compressed"); assemblyNames.Add("system.net.webheadercollection", "costura.system.net.webheadercollection.dll.compressed"); assemblyNames.Add("system.net.websockets.client", "costura.system.net.websockets.client.dll.compressed"); assemblyNames.Add("system.net.websockets", "costura.system.net.websockets.dll.compressed"); assemblyNames.Add("system.objectmodel", "costura.system.objectmodel.dll.compressed"); assemblyNames.Add("system.reflection", "costura.system.reflection.dll.compressed"); assemblyNames.Add("system.reflection.extensions", "costura.system.reflection.extensions.dll.compressed"); assemblyNames.Add("system.reflection.primitives", "costura.system.reflection.primitives.dll.compressed"); assemblyNames.Add("system.resources.reader", "costura.system.resources.reader.dll.compressed"); assemblyNames.Add("system.resources.resourcemanager", "costura.system.resources.resourcemanager.dll.compressed"); assemblyNames.Add("system.resources.writer", "costura.system.resources.writer.dll.compressed"); assemblyNames.Add("system.runtime.compilerservices.unsafe", "costura.system.runtime.compilerservices.unsafe.dll.compressed"); assemblyNames.Add("system.runtime.compilerservices.visualc", "costura.system.runtime.compilerservices.visualc.dll.compressed"); assemblyNames.Add("system.runtime", "costura.system.runtime.dll.compressed"); assemblyNames.Add("system.runtime.extensions", "costura.system.runtime.extensions.dll.compressed"); assemblyNames.Add("system.runtime.handles", "costura.system.runtime.handles.dll.compressed"); assemblyNames.Add("system.runtime.interopservices", "costura.system.runtime.interopservices.dll.compressed"); assemblyNames.Add("system.runtime.interopservices.runtimeinformation", "costura.system.runtime.interopservices.runtimeinformation.dll.compressed"); assemblyNames.Add("system.runtime.numerics", "costura.system.runtime.numerics.dll.compressed"); assemblyNames.Add("system.runtime.serialization.formatters", "costura.system.runtime.serialization.formatters.dll.compressed"); assemblyNames.Add("system.runtime.serialization.json", "costura.system.runtime.serialization.json.dll.compressed"); assemblyNames.Add("system.runtime.serialization.primitives", "costura.system.runtime.serialization.primitives.dll.compressed"); assemblyNames.Add("system.runtime.serialization.xml", "costura.system.runtime.serialization.xml.dll.compressed"); assemblyNames.Add("system.security.claims", "costura.system.security.claims.dll.compressed"); assemblyNames.Add("system.security.cryptography.algorithms", "costura.system.security.cryptography.algorithms.dll.compressed"); assemblyNames.Add("system.security.cryptography.csp", "costura.system.security.cryptography.csp.dll.compressed"); assemblyNames.Add("system.security.cryptography.encoding", "costura.system.security.cryptography.encoding.dll.compressed"); assemblyNames.Add("system.security.cryptography.primitives", "costura.system.security.cryptography.primitives.dll.compressed"); assemblyNames.Add("system.security.cryptography.x509certificates", "costura.system.security.cryptography.x509certificates.dll.compressed"); assemblyNames.Add("system.security.principal", "costura.system.security.principal.dll.compressed"); assemblyNames.Add("system.security.securestring", "costura.system.security.securestring.dll.compressed"); assemblyNames.Add("system.text.encoding", "costura.system.text.encoding.dll.compressed"); assemblyNames.Add("system.text.encoding.extensions", "costura.system.text.encoding.extensions.dll.compressed"); assemblyNames.Add("system.text.regularexpressions", "costura.system.text.regularexpressions.dll.compressed"); assemblyNames.Add("system.threading.channels", "costura.system.threading.channels.dll.compressed"); assemblyNames.Add("system.threading", "costura.system.threading.dll.compressed"); assemblyNames.Add("system.threading.overlapped", "costura.system.threading.overlapped.dll.compressed"); assemblyNames.Add("system.threading.tasks", "costura.system.threading.tasks.dll.compressed"); assemblyNames.Add("system.threading.tasks.extensions", "costura.system.threading.tasks.extensions.dll.compressed"); assemblyNames.Add("system.threading.tasks.parallel", "costura.system.threading.tasks.parallel.dll.compressed"); assemblyNames.Add("system.threading.thread", "costura.system.threading.thread.dll.compressed"); assemblyNames.Add("system.threading.threadpool", "costura.system.threading.threadpool.dll.compressed"); assemblyNames.Add("system.threading.timer", "costura.system.threading.timer.dll.compressed"); assemblyNames.Add("system.valuetuple", "costura.system.valuetuple.dll.compressed"); assemblyNames.Add("system.xml.readerwriter", "costura.system.xml.readerwriter.dll.compressed"); assemblyNames.Add("system.xml.xdocument", "costura.system.xml.xdocument.dll.compressed"); assemblyNames.Add("system.xml.xmldocument", "costura.system.xml.xmldocument.dll.compressed"); assemblyNames.Add("system.xml.xmlserializer", "costura.system.xml.xmlserializer.dll.compressed"); assemblyNames.Add("system.xml.xpath", "costura.system.xml.xpath.dll.compressed"); assemblyNames.Add("system.xml.xpath.xdocument", "costura.system.xml.xpath.xdocument.dll.compressed"); assemblyNames.Add("unity.netcode.runtime", "costura.unity.netcode.runtime.dll.compressed"); } public static void Attach() { if (Interlocked.Exchange(ref isAttached, 1) == 1) { return; } AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.AssemblyResolve += delegate(object sender, ResolveEventArgs e) { lock (nullCacheLock) { if (nullCache.ContainsKey(e.Name)) { return null; } } AssemblyName assemblyName = new AssemblyName(e.Name); Assembly assembly = ReadExistingAssembly(assemblyName); if ((object)assembly != null) { return assembly; } assembly = ReadFromEmbeddedResources(assemblyNames, symbolNames, assemblyName); if ((object)assembly == null) { lock (nullCacheLock) { nullCache[e.Name] = true; } if ((assemblyName.Flags & AssemblyNameFlags.Retargetable) != 0) { assembly = Assembly.Load(assemblyName); } } return assembly; }; } } } internal class RumblingCompany_ProcessedByFody { internal const string FodyVersion = "6.8.0.0"; internal const string Costura = "5.7.0"; }