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 GamblersFallacy v1.0.4
ReindogFan1372.GamblersFallacy.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalCasino.Custom; using Microsoft.CodeAnalysis; using ReindogFan1372.GamblersFallacy.NetcodePatcher; using StaticNetcodeLib; using Unity.Netcode; 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(".NETStandard,Version=v2.1", FrameworkDisplayName = "")] [assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("mrgrm7.LethalCasino")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Jobs")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")] [assembly: IgnoresAccessChecksTo("Unity.Services.QoS")] [assembly: IgnoresAccessChecksTo("Unity.Services.Relay")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("Xilophor.StaticNetcodeLib")] [assembly: AssemblyCompany("ReindogFan1372.GamblersFallacy")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("GamblersFallacy")] [assembly: AssemblyTitle("ReindogFan1372.GamblersFallacy")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: NetcodePatchedAssembly] internal class <Module> { static <Module>() { } } 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; } } } namespace GamblersFallacy { [BepInPlugin("ReindogFan1372.GamblersFallacy", "GamblersFallacy", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class GamblersFallacy : BaseUnityPlugin { internal static AssetBundle MyCustomAssets; public static GamblersFallacy Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } internal static Harmony? Harmony { get; set; } internal static MyModConfig GamblersFallacyModConfig { get; private set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; GamblersFallacyModConfig = new MyModConfig(((BaseUnityPlugin)this).Config); NetcodePatcher(); Patch(); Logger.LogInfo((object)"ReindogFan1372.GamblersFallacy v1.0.0 has loaded!"); string path = "gamblersfallacy"; MyCustomAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), path)); if ((Object)(object)MyCustomAssets == (Object)null) { Logger.LogError((object)"Failed to load custom assets."); } else { ConfigEntry<int> val = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Explosion Minimum Value", 1000, "Minimum value for scrap to be above when going bust for explosion to trigger"); } } 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("ReindogFan1372.GamblersFallacy"); } Logger.LogDebug((object)"Patching..."); Harmony.PatchAll(); Logger.LogDebug((object)"Finished patching!"); } internal static void Unpatch() { Logger.LogDebug((object)"Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogDebug((object)"Finished unpatching!"); } private static void NetcodePatcher() { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); Type[] array = types; foreach (Type type in array) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array2 = methods; foreach (MethodInfo methodInfo in array2) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } } } } internal class MyModConfig { public readonly ConfigEntry<int> explosionMin; public MyModConfig(ConfigFile cfg) { cfg.SaveOnConfigSet = false; explosionMin = cfg.Bind<int>("General", "Explosion Minimum Value", 1000, "Minimum value for scrap to be above when going bust for explosion to trigger"); ClearOrphanedEntries(cfg); cfg.Save(); cfg.SaveOnConfigSet = true; } private static void ClearOrphanedEntries(ConfigFile cfg) { PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries"); Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(cfg); dictionary.Clear(); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "ReindogFan1372.GamblersFallacy"; public const string PLUGIN_NAME = "GamblersFallacy"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace GamblersFallacy.Patches { public class ExplosionCaller { public static IEnumerator DelayedExplosion(PlayerControllerB oopsiePlayer) { yield return (object)new WaitForSeconds(0.7f); Landmine.SpawnExplosion(((Component)oopsiePlayer).transform.position + Vector3.up, true, 2.5f, 2.7f, 50, 0f, (GameObject)null, false); oopsiePlayer.causeOfDeath = (CauseOfDeath)18; } } [StaticNetcode] public static class RpcCaller { [ClientRpc] public static void PlayerGoneBustClientRpc(NetworkBehaviourReference playerWhoWentBust) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown PlayerControllerB val = (PlayerControllerB)NetworkBehaviourReference.op_Implicit(playerWhoWentBust); if ((Object)(object)((Component)val).GetComponentInChildren<AudioSource>() == (Object)null) { ((Component)val).gameObject.AddComponent<AudioSource>(); } AudioSource componentInChildren = ((Component)val).GetComponentInChildren<AudioSource>(); componentInChildren.PlayOneShot(GamblersFallacy.MyCustomAssets.LoadAsset<AudioClip>("assets/lethalcompany/mods/gamblersfallacy/buzzer.wav")); ((MonoBehaviour)val).StartCoroutine(ExplosionCaller.DelayedExplosion(val)); } [ServerRpc] public static void PlayerGoneBustServerRpc(NetworkBehaviourReference playerWhoWentBust) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) PlayerGoneBustClientRpc(playerWhoWentBust); } } [HarmonyPatch(typeof(Roulette))] public class GamblersFallacyRoulettePatch { private static Dictionary<GrabbableObject, int> lastScrapValues = new Dictionary<GrabbableObject, int>(); private static Dictionary<GrabbableObject, PlayerControllerB> gambledScrapOwners = new Dictionary<GrabbableObject, PlayerControllerB>(); [HarmonyPatch("UpdateScrapValueClientRpc")] [HarmonyPostfix] private static void RoulettePostfix(Roulette __instance, NetworkBehaviourReference item) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)__instance).IsServer && !((NetworkBehaviour)__instance).IsHost) { return; } GrabbableObject val = (GrabbableObject)NetworkBehaviourReference.op_Implicit(item); if (!((Object)(object)val == (Object)null) && gambledScrapOwners.ContainsKey(val) && lastScrapValues.ContainsKey(val)) { if (val.scrapValue == 0 && lastScrapValues[val] >= GamblersFallacy.GamblersFallacyModConfig.explosionMin.Value) { RpcCaller.PlayerGoneBustServerRpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)gambledScrapOwners[val])); } if (lastScrapValues.ContainsKey(val)) { lastScrapValues.Remove(val); } if (gambledScrapOwners.ContainsKey(val)) { gambledScrapOwners.Remove(val); } } } [HarmonyPatch("PlaceBetServerRpc")] [HarmonyPostfix] private static void PostixPlaceBetServerRpc(Roulette __instance, NetworkBehaviourReference playerRef, NetworkBehaviourReference scrapRef) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown GrabbableObject val = (GrabbableObject)NetworkBehaviourReference.op_Implicit(scrapRef); if (!lastScrapValues.ContainsKey(val)) { lastScrapValues.Add(val, val.scrapValue); } else { lastScrapValues[val] = val.scrapValue; } if (!gambledScrapOwners.ContainsKey(val)) { gambledScrapOwners.Add(val, (PlayerControllerB)NetworkBehaviourReference.op_Implicit(playerRef)); } else { gambledScrapOwners[val] = (PlayerControllerB)NetworkBehaviourReference.op_Implicit(playerRef); } } } [HarmonyPatch(typeof(Blackjack))] public class GamblersFallacyBlackjackPatch { private static Dictionary<GrabbableObject, int> lastScrapValues = new Dictionary<GrabbableObject, int>(); private static Dictionary<GrabbableObject, PlayerControllerB> gambledScrapOwners = new Dictionary<GrabbableObject, PlayerControllerB>(); [HarmonyPatch("UpdateScrapValueClientRpc")] [HarmonyPostfix] private static void BlackjackPostfix(Blackjack __instance, NetworkBehaviourReference item) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)__instance).IsServer && !((NetworkBehaviour)__instance).IsHost) { return; } GrabbableObject val = (GrabbableObject)NetworkBehaviourReference.op_Implicit(item); if (!((Object)(object)val == (Object)null) && gambledScrapOwners.ContainsKey(val) && lastScrapValues.ContainsKey(val)) { if (val.scrapValue == 0 && lastScrapValues[val] >= GamblersFallacy.GamblersFallacyModConfig.explosionMin.Value) { RpcCaller.PlayerGoneBustServerRpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)gambledScrapOwners[val])); } if (lastScrapValues.ContainsKey(val)) { lastScrapValues.Remove(val); } if (gambledScrapOwners.ContainsKey(val)) { gambledScrapOwners.Remove(val); } } } [HarmonyPatch("JoinGameSuccessfulClientRpc")] [HarmonyPostfix] private static void PostfixJoinGameSuccessfulClientRpc(Blackjack __instance, NetworkBehaviourReference playerRef) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown if (((NetworkBehaviour)__instance).IsHost || ((NetworkBehaviour)__instance).IsServer) { GrabbableObject val = ((PlayerControllerB)NetworkBehaviourReference.op_Implicit(playerRef)).ItemSlots[((PlayerControllerB)NetworkBehaviourReference.op_Implicit(playerRef)).currentItemSlot]; if (!lastScrapValues.ContainsKey(val)) { lastScrapValues.Add(val, val.scrapValue); } else { lastScrapValues[val] = val.scrapValue; } if (!gambledScrapOwners.ContainsKey(val)) { gambledScrapOwners.Add(val, (PlayerControllerB)NetworkBehaviourReference.op_Implicit(playerRef)); } else { gambledScrapOwners[val] = (PlayerControllerB)NetworkBehaviourReference.op_Implicit(playerRef); } } } } [HarmonyPatch(typeof(SlotMachine))] public class GamblersFallacySlotsPatch { private static Dictionary<GrabbableObject, int> lastScrapValues = new Dictionary<GrabbableObject, int>(); private static Dictionary<GrabbableObject, PlayerControllerB> gambledScrapOwners = new Dictionary<GrabbableObject, PlayerControllerB>(); [HarmonyPatch("UpdateScrapValueClientRpc")] [HarmonyPostfix] private static void BlackjackPostfix(SlotMachine __instance, NetworkBehaviourReference item) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)__instance).IsServer && !((NetworkBehaviour)__instance).IsHost) { return; } GrabbableObject val = (GrabbableObject)NetworkBehaviourReference.op_Implicit(item); if (!((Object)(object)val == (Object)null) && gambledScrapOwners.ContainsKey(val) && lastScrapValues.ContainsKey(val)) { if (val.scrapValue == 0 && lastScrapValues[val] >= GamblersFallacy.GamblersFallacyModConfig.explosionMin.Value) { RpcCaller.PlayerGoneBustServerRpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)gambledScrapOwners[val])); } if (lastScrapValues.ContainsKey(val)) { lastScrapValues.Remove(val); } if (gambledScrapOwners.ContainsKey(val)) { gambledScrapOwners.Remove(val); } } } [HarmonyPatch("StartGambleServerRpc")] [HarmonyPostfix] private static void PostfixJoinGameSuccessfulServerRpc(SlotMachine __instance, NetworkBehaviourReference playerRef, NetworkBehaviourReference scrapRef) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown GrabbableObject val = (GrabbableObject)NetworkBehaviourReference.op_Implicit(scrapRef); if (!lastScrapValues.ContainsKey(val)) { lastScrapValues.Add(val, val.scrapValue); } else { lastScrapValues[val] = val.scrapValue; } if (!gambledScrapOwners.ContainsKey(val)) { gambledScrapOwners.Add(val, (PlayerControllerB)NetworkBehaviourReference.op_Implicit(playerRef)); } else { gambledScrapOwners[val] = (PlayerControllerB)NetworkBehaviourReference.op_Implicit(playerRef); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace ReindogFan1372.GamblersFallacy.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }