Please disclose if your mod was created primarily 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 Gambling v1.0.4
Gambling.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using Gambling.Util; using GameNetcodeStuff; using HarmonyLib; using LCSoundTool; using LC_API.BundleAPI; using LC_API.GameInterfaceAPI; using LC_API.GameInterfaceAPI.Events.EventArgs.Player; using LC_API.GameInterfaceAPI.Events.Handlers; using LC_API.GameInterfaceAPI.Features; using LethalCompanyInputUtils.Api; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.Serialization; [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: AssemblyCompany("Presti")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("A Mod to allow Gambling!")] [assembly: AssemblyFileVersion("1.0.4.0")] [assembly: AssemblyInformationalVersion("1.0.4+c14f990354544dcb8ed1159974dbb6c9c6cbea14")] [assembly: AssemblyProduct("Gambling")] [assembly: AssemblyTitle("Gambling")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.4.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 Gambling { [BepInPlugin("Gambling", "Gambling", "1.0.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class GamblingPlugin : BaseUnityPlugin { [HarmonyPatch(typeof(PlayerControllerB))] internal class PlayerControllerPatch { [HarmonyPatch("Awake")] [HarmonyPostfix] public static void GambitPatch(PlayerControllerB __instance) { ((Component)__instance).gameObject.AddComponent<GamblingController>(); } } [HarmonyPatch(typeof(EnemyAI))] internal class DamagePatch { [HarmonyPatch("PlayerIsTargetable")] [HarmonyPrefix] public static bool KillPatch(EnemyAI __instance, ref bool __result, PlayerControllerB playerScript) { if (!(__instance is FlowermanAI) && !(__instance is CentipedeAI) && !(__instance is MaskedPlayerEnemy)) { return true; } GamblingController gamblingController = default(GamblingController); ((Component)playerScript).TryGetComponent<GamblingController>(ref gamblingController); if (gamblingController != null && gamblingController.domainActive && gamblingController.domainUser == playerScript.actualClientId) { return __result = false; } return true; } } public readonly ManualLogSource Log = new ManualLogSource(" Always bet on Hakari"); private readonly Harmony _harmony = new Harmony("Gambling"); internal static GamblingInput InputActionsInstance = new GamblingInput(); public static GamblingPlugin Instance; public LoadedAssetBundle Bundle; public bool shouldDebug; public AudioClip gambit; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } Logger.Sources.Add((ILogSource)(object)Log); Log.LogInfo((object)"Plugin Gambling is loaded!"); gambit = SoundTool.GetAudioClip("Presti-Gambling", "gambit.mp3"); Log.LogInfo((object)"Loaded Gambit Audio."); _harmony.PatchAll(typeof(GamblingPlugin)); _harmony.PatchAll(typeof(PlayerControllerPatch)); _harmony.PatchAll(typeof(DamagePatch)); Log.LogInfo((object)"Finished patching."); } } public static class PluginInfo { public const string PLUGIN_GUID = "Gambling"; public const string PLUGIN_NAME = "Gambling"; public const string PLUGIN_VERSION = "1.0.4"; } } namespace Gambling.Util { public class GamblingController : MonoBehaviour { private PlayerControllerB _playerControllerB; [FormerlySerializedAs("_domainUser")] public ulong domainUser = 99999999uL; [FormerlySerializedAs("_domainActive")] public bool domainActive; private void Awake() { _playerControllerB = ((Component)this).GetComponent<PlayerControllerB>(); Player.Hurting += SillyBilly; Player.Dying += SillyBob; GameState.WentIntoOrbit += ResetGambitOnOrbit; } private void OnDestroy() { Player.Hurting -= SillyBilly; Player.Dying -= SillyBob; GameState.WentIntoOrbit -= ResetGambitOnOrbit; } public void SillyBilly(HurtingEventArgs ev) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (domainActive && ev.Player.ClientId == domainUser && !shouldSkip(ev.CauseOfDeath)) { GamblingPlugin.Instance.Log.LogInfo((object)"NO PAIN FOR ME BABY!"); ev.IsAllowed = false; } } public void SillyBob(DyingEventArgs ev) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (domainActive && ev.Player.ClientId == domainUser && !shouldSkip(ev.CauseOfDeath)) { GamblingPlugin.Instance.Log.LogInfo((object)"NO DEATH FOR ME BABY!"); ev.IsAllowed = false; } } private bool shouldSkip(CauseOfDeath causeOfDeath) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Invalid comparison between Unknown and I4 return (int)causeOfDeath == 10; } private void Update() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Invalid comparison between Unknown and I4 if (!((NetworkBehaviour)_playerControllerB).IsOwner || !_playerControllerB.isPlayerControlled) { return; } if (domainActive) { _playerControllerB.sprintMeter = 100f; } if (!GamblingPlugin.InputActionsInstance.ExpansionKey.triggered || domainActive || (int)GameState.ShipState != 1) { return; } GamblingPlugin.Instance.Log.LogInfo((object)(domainActive + " - " + domainUser)); if ((double)Random.Range(0f, 1f) >= 0.85 || GamblingPlugin.Instance.shouldDebug) { if (!_playerControllerB.isPlayerDead) { domainActive = true; GameTips.ShowTip("IDLE DEATH GAMBLE: Start", "JACKPOT BABY!!!!!!!!!"); Player val = Player.Get(_playerControllerB); GamblingPlugin.Instance.Log.LogInfo((object)val.ClientId); domainUser = val.ClientId; val.SprintMeter = float.PositiveInfinity; _playerControllerB.HealServerRpc(); if (GamblingPlugin.Instance.gambit != null) { GamblingPlugin.Instance.Log.LogInfo((object)"Fuck dion."); PlayAudio(); } else { GameTips.ShowTip("IDLE DEATH GAMBLE: Info", "NO SOUND BABY!"); } ((MonoBehaviour)this).Invoke("DisableImmortality", 251f); Item.CreateAndGiveItem("shovel", val, false, true); } } else { Hurt(); } } [ServerRpc(RequireOwnership = true)] public void EnableImmortality() { domainActive = true; domainUser = Player.Get(_playerControllerB).ClientId; } [ServerRpc(RequireOwnership = true)] public void Hurt() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) Player.Get(_playerControllerB).Hurt(50, (CauseOfDeath)0, default(Vector3), false, 0, false, true); } [ServerRpc(RequireOwnership = true)] public void PlayAudio() { AudioSource val = ((Component)this).gameObject.AddComponent<AudioSource>(); val.clip = GamblingPlugin.Instance.gambit; val.Play(); ((MonoBehaviour)this).Invoke("ResetGambit", 251f); } public void DisableMyMomJOOO() { DisableImmortality(); domainActive = false; domainUser = 99999999uL; } [ServerRpc(RequireOwnership = true)] public void DisableImmortality() { ResetGambit(); } [ClientRpc] public void SendNotification() { GameTips.ShowTip("IDLE DEATH GAMBLE: End", "Maybe round 2?"); } public void ResetGambitOnOrbit() { ((MonoBehaviour)this).CancelInvoke("DisableMyMomJOOO"); DisableMyMomJOOO(); } public void ResetGambit() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 if (domainActive) { if ((int)GameState.ShipState == 1 && !_playerControllerB.isPlayerDead) { SendNotification(); } domainActive = false; domainUser = 99999999uL; } } } public class GamblingFists : GrabbableObject { private static Item theseFists; public static void addItem() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0022: 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_003b: Expected O, but got Unknown Item val = new Item { Name = "Left Right Goodnight." }; val.GrabbableObject.itemProperties = getItem(); val.GrabbableObject.grabbable = false; val.GrabbableObject.scrapValue = 0; Item val2 = val; } public static Item getItem() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown if ((Object)(object)theseFists == (Object)null) { theseFists = (Item)ScriptableObject.CreateInstance(typeof(Item)); theseFists.spawnPrefab = GamblingPlugin.Instance.Bundle.GetAsset<GameObject>("Fists"); theseFists.canBeGrabbedBeforeGameStart = false; theseFists.allowDroppingAheadOfPlayer = false; theseFists.itemIcon = GamblingPlugin.Instance.Bundle.GetAsset<Sprite>("FistIcon"); theseFists.weight = 0f; theseFists.itemSpawnsOnGround = false; ((Object)theseFists).name = "Left Right Good Night."; theseFists.itemName = "Left Right Good Night."; theseFists.creditsWorth = 0; theseFists.toolTips = new string[1] { "CATCH THESE HANDS!" }; theseFists.twoHanded = true; theseFists.holdButtonUse = true; } return theseFists; } } public class GamblingInput : LcInputActions { [InputAction("<Keyboard>/g", Name = "Gamble")] public InputAction ExpansionKey { get; set; } } }