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 QTShockLC v1.0.2
BepInEx/plugins/QTShock.QTShockLC.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Net; using System.Net.Http; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LobbyCompatibility.Attributes; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("QTShock.QTShockLC")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("QTShockLC")] [assembly: AssemblyTitle("QTShock.QTShockLC")] [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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 QTShockLC { [BepInPlugin("QTShock.QTShockLC", "QTShockLC", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [LobbyCompatibility(/*Could not decode attribute arguments.*/)] public class QTShockLC : BaseUnityPlugin { public static int strength = 10; public static IPAddress? qtshockIP; public static int damageMode = 0; public static QTShockLC Instance { get; private set; } = null; internal static ManualLogSource Logger { get; private set; } = null; internal static Harmony? Harmony { get; set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; Object.DontDestroyOnLoad((Object)(object)this); Patch(); SceneManager.sceneLoaded += OnSceneLoaded; try { qtshockIP = Dns.GetHostEntry("qtshock.local").AddressList[0]; } catch (Exception ex) { Logger.LogInfo((object)("Something went wrong when connecting to your QTShock, are you sure you have set up your QShock correctly and it is currently powered on? Exception caught: " + ex.ToString())); } Logger.LogInfo((object)"QTShock.QTShockLC v1.0.0 has loaded!"); } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { Logger.LogInfo((object)("New Scene: " + ((Scene)(ref scene)).name)); if (((Scene)(ref scene)).name == "MainMenu") { Logger.LogInfo((object)"Starting MenuUISetup!!!!!!"); ((MonoBehaviour)this).StartCoroutine(MenuUISetup()); } } private IEnumerator MenuUISetup() { Logger.LogInfo((object)"Started UISetup!"); while ((Object)(object)GameObject.Find("Canvas/MenuContainer/SettingsPanel") == (Object)null) { Logger.LogInfo((object)"sex"); yield return null; } GameObject canvas = GameObject.Find("Canvas"); Logger.LogInfo((object)"1"); Transform menuContainer = canvas.transform.Find("MenuContainer"); Logger.LogInfo((object)"2"); Transform settingsPanel = menuContainer.Find("SettingsPanel"); Logger.LogInfo((object)"3"); Transform originalFramerateCap = settingsPanel.Find("FramerateCap"); Transform originalBrightnessSetting = settingsPanel.Find("BrightnessSetting"); Transform originalDisplayHeader = settingsPanel.Find("Headers/Display"); Logger.LogInfo((object)"4"); Transform qtshockHeader = Object.Instantiate<Transform>(originalDisplayHeader, originalDisplayHeader.parent); ((Object)qtshockHeader).name = "qtshock"; ((Component)qtshockHeader).GetComponent<RectTransform>().anchoredPosition = new Vector2(13f, 254f); TextMeshProUGUI headerLabel = ((Component)qtshockHeader).GetComponent<TextMeshProUGUI>(); ((TMP_Text)headerLabel).text = "<color=#ff3460>QT</color>Shock"; Logger.LogInfo((object)"5"); Transform qtshockMode = Object.Instantiate<Transform>(originalFramerateCap, originalFramerateCap.parent); ((Object)qtshockMode).name = "DamageMode"; ((Component)qtshockMode).GetComponent<RectTransform>().anchoredPosition = new Vector2(46.5f, 192.9129f); TextMeshProUGUI modeLabel = ((Component)qtshockMode.Find("Label2")).GetComponent<TextMeshProUGUI>(); ((TMP_Text)modeLabel).text = "Damage mode:"; Object.Destroy((Object)(object)((Component)qtshockMode).GetComponent<SettingsOption>()); TMP_Dropdown modeDropdown = ((Component)qtshockMode).GetComponent<TMP_Dropdown>(); modeDropdown.ClearOptions(); modeDropdown.AddOptions(new List<OptionData> { new OptionData("Shock"), new OptionData("Vibrate") }); modeDropdown.onValueChanged = new DropdownEvent(); ((UnityEvent<int>)(object)modeDropdown.onValueChanged).AddListener((UnityAction<int>)delegate(int i) { damageMode = i; }); Logger.LogInfo((object)"6"); Transform qtshockStrength = Object.Instantiate<Transform>(originalBrightnessSetting, originalBrightnessSetting.parent); ((Object)qtshockStrength).name = "QTShockStrength"; Object.Destroy((Object)(object)((Component)qtshockStrength).GetComponentInChildren<SettingsOption>()); ((Component)qtshockStrength).GetComponent<RectTransform>().anchoredPosition = new Vector2(31f, 135f); TextMeshProUGUI strengthLabel = ((Component)qtshockStrength.Find("Text (1)")).GetComponent<TextMeshProUGUI>(); ((TMP_Text)strengthLabel).text = "Max <color=red>strength</color>:"; Object.Destroy((Object)(object)qtshockStrength.Find("Image")); Slider strengthSlider = ((Component)qtshockStrength).GetComponentInChildren<Slider>(); strengthSlider.minValue = 0f; strengthSlider.maxValue = 100f; strengthSlider.onValueChanged = new SliderEvent(); ((UnityEvent<float>)(object)strengthSlider.onValueChanged).AddListener((UnityAction<float>)delegate(float f) { strength = (int)Mathf.Round(f); ((TMP_Text)strengthLabel).text = $"Max <color=red>strength</color>: {(int)Mathf.Round(f)}"; }); strengthSlider.value = strength; Logger.LogInfo((object)"Finished UISetup!"); } internal static void Patch() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("QTShock.QTShockLC"); } Logger.LogInfo((object)"Patching..."); Harmony.PatchAll(); Logger.LogInfo((object)"Finished patching!"); } internal static void Unpatch() { Logger.LogInfo((object)"Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogInfo((object)"Finished unpatching!"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "QTShock.QTShockLC"; public const string PLUGIN_NAME = "QTShockLC"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace QTShockLC.Patches { [HarmonyPatch(typeof(PlayerControllerB))] public class DamagePatch { [HarmonyPatch("DamagePlayer")] [HarmonyPostfix] private static void DamagePlayerPostfix(int damageNumber, bool hasDamageSFX = true, bool callRPC = true, CauseOfDeath causeOfDeath = 0, int deathAnimation = 0, bool fallDamage = false, Vector3 force = default(Vector3)) { if (QTShockLC.qtshockIP == null) { QTShockLC.Logger.LogInfo((object)"Something went wrong when connecting to your QTShock, are you sure you have set up your QShock correctly and it is currently powered on?"); } int num = Mathf.Clamp(damageNumber, 0, 100); int num2 = (int)Math.Round((float)QTShockLC.strength / 100f * (float)num); QTShockLC.Logger.LogInfo((object)("Shock Strength: " + num2.ToString("000"))); try { HttpClient httpClient = new HttpClient(); httpClient.Timeout = new TimeSpan(3000000000L); Dictionary<string, string> dictionary = new Dictionary<string, string>(); dictionary.Add("shocker", "0"); dictionary.Add("strength", num2.ToString("000")); Uri requestUri = new Uri("http://" + QTShockLC.qtshockIP?.ToString() + ((QTShockLC.damageMode == 0) ? "/shock" : "/vibrate")); httpClient.PostAsync(requestUri, new FormUrlEncodedContent(dictionary)); } catch (Exception ex) { QTShockLC.Logger.LogInfo((object)ex.ToString()); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }