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 LethalAlcoolico v1.1.0
Sociors.LethalAlcoolico.dll
Decompiled 2 months 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.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalAlcoolico.Board; using LethalAlcoolico.Network; using LethalAlcoolico.Patches; using LethalAlcoolico.Save; using LethalConfig; using LethalConfig.ConfigItems; using LethalConfig.ConfigItems.Options; using LobbyCompatibility.Attributes; using Microsoft.CodeAnalysis; using Sociors.LethalAlcoolico.NetcodePatcher; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; [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("Sociors.LethalAlcoolico")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("LethalAlcoolico")] [assembly: AssemblyTitle("Sociors.LethalAlcoolico")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] internal class <Module> { static <Module>() { NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<float>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<float>(); } } 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; } } } public static class LAConfig { public static ConfigEntry<float> PlayerWeight; public static ConfigEntry<float> AlcoholABV; public static ConfigEntry<float> ShotSize; public static ConfigEntry<int> ShotsPerDeath; public static void Init(ConfigFile config) { PlayerWeight = config.Bind<float>("Geral", "Seu Peso (kg)", 75f, "Seu peso para a estimativa de sobriedade."); AlcoholABV = config.Bind<float>("Geral", "Teor Alcoólico", 0.35f, "Teor da bebida (ex: 0.35 para 35%)."); ShotSize = config.Bind<float>("Geral", "Tamanho do Shot (ml)", 50f, "Volume de cada dose em ml."); ShotsPerDeath = config.Bind<int>("Geral", "Shots por Morte", 1, "Quantidade de shots pendentes por morte."); } public static void RegisterLethalConfig() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown ConfigEntry<float> playerWeight = PlayerWeight; FloatStepSliderOptions val = new FloatStepSliderOptions { RequiresRestart = false }; ((BaseRangeOptions<float>)val).Min = 40f; ((BaseRangeOptions<float>)val).Max = 200f; val.Step = 1f; FloatStepSliderConfigItem val2 = new FloatStepSliderConfigItem(playerWeight, val); ConfigEntry<float> alcoholABV = AlcoholABV; FloatStepSliderOptions val3 = new FloatStepSliderOptions { RequiresRestart = false }; ((BaseRangeOptions<float>)val3).Min = 0.01f; ((BaseRangeOptions<float>)val3).Max = 0.99f; val3.Step = 0.01f; FloatStepSliderConfigItem val4 = new FloatStepSliderConfigItem(alcoholABV, val3); ConfigEntry<float> shotSize = ShotSize; FloatStepSliderOptions val5 = new FloatStepSliderOptions { RequiresRestart = false }; ((BaseRangeOptions<float>)val5).Min = 10f; ((BaseRangeOptions<float>)val5).Max = 500f; val5.Step = 5f; FloatStepSliderConfigItem val6 = new FloatStepSliderConfigItem(shotSize, val5); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val4); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val6); } } public class AlcoholButtonInteract : MonoBehaviour { public void OnInteract(PlayerControllerB playerWhoPressed) { if ((Object)(object)playerWhoPressed == (Object)(object)GameNetworkManager.Instance.localPlayerController) { LethalAlcoolicoPlayerState component = ((Component)playerWhoPressed).GetComponent<LethalAlcoolicoPlayerState>(); if ((Object)(object)component != (Object)null) { component.OnButtonPressed(playerWhoPressed); } } } } namespace LethalAlcoolico { internal static class AlcoholAssets { public static AssetBundle Bundle; public static GameObject ScreenPrefab; public static GameObject PlayerPagePrefab; public static GameObject PlayerPrefab; public static void Load() { if ((Object)(object)Bundle != (Object)null) { return; } string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string text = Path.Combine(directoryName, "alcoholmod"); Bundle = AssetBundle.LoadFromFile(text); if ((Object)(object)Bundle == (Object)null) { LethalAlcoolico.Logger.LogError((object)"Failed to load alcoholmod AssetBundle"); return; } ScreenPrefab = Bundle.LoadAsset<GameObject>("ScreenPrefab"); PlayerPagePrefab = Bundle.LoadAsset<GameObject>("PlayerPage"); PlayerPrefab = Bundle.LoadAsset<GameObject>("Player"); if ((Object)(object)ScreenPrefab == (Object)null) { LethalAlcoolico.Logger.LogError((object)"ScreenPrefab não encontrado!"); } if ((Object)(object)PlayerPagePrefab == (Object)null) { LethalAlcoolico.Logger.LogError((object)"PlayerPage não encontrado!"); } if ((Object)(object)PlayerPrefab == (Object)null) { LethalAlcoolico.Logger.LogError((object)"PlayerPrefab não encontrado!"); } LethalAlcoolico.Logger.LogInfo((object)"AlcoholMod assets loaded"); } } [BepInPlugin("Sociors.LethalAlcoolico", "LethalAlcoolico", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [LobbyCompatibility(/*Could not decode attribute arguments.*/)] public class LethalAlcoolico : BaseUnityPlugin { public static LethalAlcoolico Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } internal static Harmony? Harmony { get; set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; AlcoholAssets.Load(); LAConfig.Init(((BaseUnityPlugin)this).Config); if (Chainloader.PluginInfos.ContainsKey("com.sayless.lethalconfig")) { RegisterLethalConfigWrapper(); } Patch(); Logger.LogInfo((object)"Sociors.LethalAlcoolico v1.0.0 has loaded!"); } private void RegisterLethalConfigWrapper() { LAConfig.RegisterLethalConfig(); } 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("Sociors.LethalAlcoolico"); } 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!"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "Sociors.LethalAlcoolico"; public const string PLUGIN_NAME = "LethalAlcoolico"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace LethalAlcoolico.Board { public class PlayerInfoManager : MonoBehaviour { public TMP_Text playerName; public TMP_Text playerShots; public TMP_Text playerPendingShots; public TMP_Text playerBloodAlcohol; private void Awake() { if ((Object)(object)playerName == (Object)null) { playerName = ((Component)((Component)this).transform.Find("Name")).GetComponent<TMP_Text>(); } if ((Object)(object)playerShots == (Object)null) { playerShots = ((Component)((Component)this).transform.Find("ShotCount")).GetComponent<TMP_Text>(); } if ((Object)(object)playerPendingShots == (Object)null) { playerPendingShots = ((Component)((Component)this).transform.Find("ShotPending")).GetComponent<TMP_Text>(); } if ((Object)(object)playerBloodAlcohol == (Object)null) { playerBloodAlcohol = ((Component)((Component)this).transform.Find("AlcBlood")).GetComponent<TMP_Text>(); } } public void ChangePlayerStats(string playerName, string playerShots, string playerPendingShots, string playerBloodAlcohol) { this.playerName.text = playerName; this.playerShots.text = playerShots; this.playerPendingShots.text = playerPendingShots; this.playerBloodAlcohol.text = playerBloodAlcohol; } } public class PlayerPageManager : MonoBehaviour { public Transform[] slots = (Transform[])(object)new Transform[10]; private void Awake() { int childCount = ((Component)this).transform.childCount; slots = (Transform[])(object)new Transform[childCount]; for (int i = 0; i < childCount; i++) { slots[i] = ((Component)this).transform.GetChild(i); } } } } namespace LethalAlcoolico.Save { [Serializable] public class PlayerStats { public int deaths; public float drunkPercent; } public static class SaveManager { private const string ES3Key = "LethalAlcoolico_PlayerData"; private static string CurrentFile => GameNetworkManager.Instance.currentSaveFileName; public static void Save() { if ((Object)(object)GameNetworkManager.Instance == (Object)null || string.IsNullOrEmpty(CurrentFile)) { return; } if ((Object)(object)GameNetworkManager.Instance == (Object)null || string.IsNullOrEmpty(CurrentFile)) { LethalAlcoolico.Logger.LogError((object)$"[Save] FALHOU! GameNetworkManager null: {(Object)(object)GameNetworkManager.Instance == (Object)null} | File vazio: {string.IsNullOrEmpty(CurrentFile)}"); return; } LethalAlcoolico.Logger.LogInfo((object)("[Save] Salvando em: " + CurrentFile)); Dictionary<string, PlayerStats> dictionary = new Dictionary<string, PlayerStats>(); StartOfRound instance = StartOfRound.Instance; PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!((Object)(object)val == (Object)null) && val.isPlayerControlled) { LethalAlcoolicoPlayerState component = ((Component)val).GetComponent<LethalAlcoolicoPlayerState>(); if ((Object)(object)component != (Object)null) { dictionary[val.playerSteamId.ToString()] = new PlayerStats { deaths = component.TotalDeaths.Value, drunkPercent = component.DrunkPercentage.Value }; } } } ES3.Save<Dictionary<string, PlayerStats>>("LethalAlcoolico_PlayerData", dictionary, CurrentFile); } public static Dictionary<string, PlayerStats> Load() { if ((Object)(object)GameNetworkManager.Instance == (Object)null || string.IsNullOrEmpty(CurrentFile)) { LethalAlcoolico.Logger.LogError((object)("[Load] FALHOU! File: '" + CurrentFile + "'")); return new Dictionary<string, PlayerStats>(); } LethalAlcoolico.Logger.LogInfo((object)string.Format("[Load] Carregando de: {0} | Key existe: {1}", CurrentFile, ES3.KeyExists("LethalAlcoolico_PlayerData", CurrentFile))); if ((Object)(object)GameNetworkManager.Instance != (Object)null && ES3.KeyExists("LethalAlcoolico_PlayerData", CurrentFile)) { return ES3.Load<Dictionary<string, PlayerStats>>("LethalAlcoolico_PlayerData", CurrentFile); } return new Dictionary<string, PlayerStats>(); } } } namespace LethalAlcoolico.Patches { [HarmonyPatch(typeof(PlayerControllerB))] public static class LethalAlcoolicoPatches { private static Dictionary<PlayerControllerB, List<GameObject>> playerCups = new Dictionary<PlayerControllerB, List<GameObject>>(); private static Dictionary<PlayerControllerB, float> baseCarryWeight = new Dictionary<PlayerControllerB, float>(); private const float CupWeightLb = 5f; private static GameObject plasticCupPrefab; public static Animator boardAnimator; private static bool firstDeathAnnounced = false; public static bool firstDeathEnabled = false; public static Transform[] slots; [HarmonyPatch(typeof(HUDManager), "Update")] [HarmonyPostfix] public static void CheckKeys() { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.localPlayerController == (Object)null) { return; } PlayerControllerB localPlayerController = instance.localPlayerController; if (localPlayerController.isPlayerControlled) { LethalAlcoolicoPlayerState component = ((Component)localPlayerController).GetComponent<LethalAlcoolicoPlayerState>(); if (!((Object)(object)component == (Object)null) && ((NetworkBehaviour)component).IsSpawned && ((NetworkBehaviour)component).IsOwner && ((ButtonControl)Keyboard.current.numpadEqualsKey).wasPressedThisFrame) { RefreshBoard(); } } } private static void RunFullDump(StartOfRound round, LethalAlcoolicoPlayerState localNet) { LethalAlcoolico.Logger.LogWarning((object)"========== [Alcoolico][DUMP MANUAL] =========="); LethalAlcoolico.Logger.LogInfo((object)("Local Player: " + round.localPlayerController.playerUsername)); LethalAlcoolico.Logger.LogInfo((object)("Componente Local: " + (((Object)(object)localNet != (Object)null) ? "OK" : "NULL"))); if (round.allPlayerScripts == null) { return; } for (int i = 0; i < round.allPlayerScripts.Length; i++) { PlayerControllerB val = round.allPlayerScripts[i]; if (!((Object)(object)val == (Object)null) && val.isPlayerControlled) { LethalAlcoolicoPlayerState component = ((Component)val).GetComponent<LethalAlcoolicoPlayerState>(); LethalAlcoolico.Logger.LogInfo((object)string.Format("[{0}] {1} | State: {2} | Deaths: {3}", i, val.playerUsername, ((Object)(object)component != (Object)null) ? "OK" : "MISSING", ((Object)(object)component != (Object)null) ? component.TotalDeaths.Value : (-1))); } } LethalAlcoolico.Logger.LogWarning((object)"======================================="); } [HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")] [HarmonyPostfix] private static void OnPlayerDied(PlayerControllerB __instance) { LethalAlcoolicoPlayerState component = ((Component)__instance).GetComponent<LethalAlcoolicoPlayerState>(); if (!((Object)(object)component == (Object)null) && ((NetworkBehaviour)component).IsOwner) { if (firstDeathEnabled && !firstDeathAnnounced) { firstDeathAnnounced = true; int num = LAConfig.ShotsPerDeath.Value + 1; NetworkVariable<int> pendingCups = component.PendingCups; pendingCups.Value += num; HUDManager.Instance.AddTextToChatOnServer($"☠ {__instance.playerUsername} foi o primeiro a morrer! Bebe {num} shots!", -1); } else { NetworkVariable<int> pendingCups2 = component.PendingCups; pendingCups2.Value += LAConfig.ShotsPerDeath.Value; } } } private static void ApplyWeight(PlayerControllerB p, int pending) { if (!baseCarryWeight.ContainsKey(p)) { baseCarryWeight[p] = p.carryWeight; } p.carryWeight = baseCarryWeight[p] + (float)pending * 0.05f; } public static void SyncVisuals(PlayerControllerB player, int pendingCount) { float num = (float)pendingCount * 0.05f; player.carryWeight = 1f + num; RebuildCups(player, pendingCount); LethalAlcoolico.Logger.LogInfo((object)$"[Alcoolico] Visual atualizado para {player.playerUsername}: {pendingCount} copos."); } private static void RebuildCups(PlayerControllerB p, int pending) { //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) if (!playerCups.TryGetValue(p, out List<GameObject> value)) { value = new List<GameObject>(); playerCups[p] = value; } LethalAlcoolico.Logger.LogInfo((object)$"[Alcoolico] Rebuild solicitado para {p.playerUsername}. Pendentes: {pending}. Copos atuais na lista: {value.Count}"); if (value.Count == pending) { LethalAlcoolico.Logger.LogInfo((object)"[Alcoolico] Quantidade já bate, ignorando spawn."); return; } foreach (GameObject item in value) { if ((Object)(object)item != (Object)null) { Object.Destroy((Object)(object)item); } } value.Clear(); GameObject val = GetPlasticCupPrefab(); if ((Object)(object)val == (Object)null) { LethalAlcoolico.Logger.LogError((object)"[Alcoolico] ERRO FATAL: Prefab do copo não foi encontrado no GetPlasticCupPrefab!"); return; } for (int i = 0; i < pending; i++) { GameObject val2 = Object.Instantiate<GameObject>(val, p.playerGlobalHead); if (((NetworkBehaviour)p).IsOwner) { val2.layer = 23; } if ((Object)(object)val2 == (Object)null) { LethalAlcoolico.Logger.LogError((object)"[Alcoolico] Instantiate falhou e retornou NULL!"); continue; } CleanCup(val2); val2.transform.localPosition = new Vector3(0f, 0.53f + (float)i * 0.05f, -0.02f); val2.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f); val2.transform.localScale = Vector3.one * 0.3f; value.Add(val2); } } public static void RefreshBoard() { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)boardAnimator != (Object)null) { boardAnimator.Play("ScreenRefreshing", 0, 0f); } if (slots == null) { return; } Transform[] array = slots; foreach (Transform val in array) { foreach (Transform item in val) { Transform val2 = item; Object.Destroy((Object)(object)((Component)val2).gameObject); } } StartOfRound instance = StartOfRound.Instance; List<(string, int, int, float)> list = new List<(string, int, int, float)>(); PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val3 in allPlayerScripts) { if (!((Object)(object)val3 == (Object)null) && val3.isPlayerControlled) { LethalAlcoolicoPlayerState component = ((Component)val3).GetComponent<LethalAlcoolicoPlayerState>(); if (!((Object)(object)component == (Object)null)) { list.Add((val3.playerUsername, component.TotalDeaths.Value, component.PendingCups.Value, component.DrunkPercentage.Value)); } } } list.Sort(delegate((string name, int deaths, int pending, float drunk) a, (string name, int deaths, int pending, float drunk) b) { int num = b.deaths.CompareTo(a.deaths); return (num != 0) ? num : b.pending.CompareTo(a.pending); }); for (int k = 0; k < list.Count && k < slots.Length; k++) { GameObject val4 = Object.Instantiate<GameObject>(AlcoholAssets.PlayerPrefab, slots[k]); val4.transform.localPosition = Vector3.zero; val4.transform.localRotation = Quaternion.identity; val4.transform.localScale = Vector3.one; PlayerInfoManager playerInfoManager = val4.AddComponent<PlayerInfoManager>(); string playerBloodAlcohol = list[k].Item4.ToString("F1") + "%"; playerInfoManager.ChangePlayerStats(list[k].Item1, list[k].Item2.ToString(), list[k].Item3.ToString(), playerBloodAlcohol); } } [HarmonyPatch(typeof(StartOfRound), "StartGame")] [HarmonyPostfix] private static void OnRoundStart() { firstDeathAnnounced = false; RefreshBoard(); } [HarmonyPatch(typeof(GameNetworkManager), "SaveGameValues")] [HarmonyPostfix] private static void OnSaveGameValues() { SaveManager.Save(); } [HarmonyPatch(typeof(StartOfRound), "Start")] [HarmonyPostfix] private static void OnStart() { SpawnBoard(); } private static GameObject GetPlasticCupPrefab() { if ((Object)(object)plasticCupPrefab != (Object)null) { return plasticCupPrefab; } List<Item> itemsList = StartOfRound.Instance.allItemsList.itemsList; foreach (Item item in itemsList) { if (item.itemName == "Plastic cup") { return plasticCupPrefab = item.spawnPrefab; } } return null; } private static void CleanCup(GameObject cup) { Object.Destroy((Object)(object)cup.GetComponent<GrabbableObject>()); Object.Destroy((Object)(object)cup.GetComponent<Rigidbody>()); Object.Destroy((Object)(object)cup.GetComponent<Collider>()); MonoBehaviour[] components = cup.GetComponents<MonoBehaviour>(); foreach (MonoBehaviour val in components) { Object.Destroy((Object)(object)val); } } private static void SpawnBoard() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Expected O, but got Unknown //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Expected O, but got Unknown //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Expected O, but got Unknown Transform elevatorTransform = StartOfRound.Instance.elevatorTransform; GameObject val = Object.Instantiate<GameObject>(AlcoholAssets.ScreenPrefab, elevatorTransform); val.transform.localPosition = new Vector3(0f, 0f, -4.8f); val.transform.localRotation = Quaternion.Euler(0f, 270f, 0f); val.transform.localScale = new Vector3(0.8f, 0.8f, 0.8f); boardAnimator = val.GetComponent<Animator>(); Transform val2 = val.transform.Find("Screen/PlayerPage"); int childCount = val2.childCount; slots = (Transform[])(object)new Transform[childCount]; for (int i = 0; i < childCount; i++) { slots[i] = val2.GetChild(i); } LethalAlcoolico.Logger.LogWarning((object)"[Alcoolico] Board spawnado com sucesso"); Transform val3 = val.transform.Find("Button"); if ((Object)(object)val3 == (Object)null) { LethalAlcoolico.Logger.LogError((object)"[Alcoolico] Botão não encontrado no prefab!"); return; } MeshCollider component = ((Component)val3).GetComponent<MeshCollider>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } BoxCollider val4 = ((Component)val3).gameObject.AddComponent<BoxCollider>(); ((Collider)val4).isTrigger = true; ((Component)val3).gameObject.layer = 9; ((Component)val3).gameObject.tag = "InteractTrigger"; InteractTrigger val5 = ((Component)val3).gameObject.AddComponent<InteractTrigger>(); typeof(InteractTrigger).GetField("playersManager", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(val5, StartOfRound.Instance); val5.hoverTip = "Beber Shot"; val5.interactable = true; val5.holdInteraction = false; val5.cooldownTime = 5f; val5.interactCooldown = true; val5.disableTriggerMesh = false; val5.hidePlayerItem = false; GameObject val6 = GameObject.Find("LightSwitch"); InteractTrigger componentInChildren = val6.GetComponentInChildren<InteractTrigger>(); val5.hoverIcon = componentInChildren.hoverIcon; val5.disabledHoverIcon = componentInChildren.disabledHoverIcon; val5.onInteract = new InteractEvent(); val5.onStopInteract = new InteractEvent(); val5.onCancelAnimation = new InteractEvent(); AlcoholButtonInteract alcoholButtonInteract = ((Component)val3).gameObject.AddComponent<AlcoholButtonInteract>(); ((UnityEvent<PlayerControllerB>)(object)val5.onInteract).AddListener((UnityAction<PlayerControllerB>)alcoholButtonInteract.OnInteract); } } [HarmonyPatch(typeof(PlayerControllerB), "Awake")] public static class PlayerInjectionPatch { [HarmonyPostfix] public static void Postfix(PlayerControllerB __instance) { if ((Object)(object)((Component)__instance).GetComponent<LethalAlcoolicoPlayerState>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<LethalAlcoolicoPlayerState>(); } } } } namespace LethalAlcoolico.Network { public class LethalAlcoolicoPlayerState : NetworkBehaviour { [Header("Network Data")] public NetworkVariable<int> PendingCups = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)1); public NetworkVariable<int> TotalDeaths = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)1); public NetworkVariable<float> DrunkPercentage = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)1); private float decayTimer = 0f; public override void OnNetworkSpawn() { PlayerControllerB pc = ((Component)this).GetComponent<PlayerControllerB>(); NetworkVariable<int> pendingCups = PendingCups; pendingCups.OnValueChanged = (OnValueChangedDelegate<int>)(object)Delegate.Combine((Delegate?)(object)pendingCups.OnValueChanged, (Delegate?)(object)(OnValueChangedDelegate<int>)delegate(int oldVal, int newVal) { if ((Object)(object)pc != (Object)null) { LethalAlcoolicoPatches.SyncVisuals(pc, newVal); } }); NetworkVariable<int> totalDeaths = TotalDeaths; totalDeaths.OnValueChanged = (OnValueChangedDelegate<int>)(object)Delegate.Combine((Delegate?)(object)totalDeaths.OnValueChanged, (Delegate?)(object)(OnValueChangedDelegate<int>)delegate(int oldVal, int newVal) { if (((NetworkBehaviour)this).IsOwner) { CalculateBAC(newVal); } LethalAlcoolicoPatches.RefreshBoard(); }); if (((NetworkBehaviour)this).IsServer) { Dictionary<string, PlayerStats> dictionary = SaveManager.Load(); ulong playerSteamId = pc.playerSteamId; string text = playerSteamId.ToString(); LethalAlcoolico.Logger.LogInfo((object)$"[Load] Tentando carregar player: {pc.playerUsername} | SteamID: {text} | Key existe: {dictionary.ContainsKey(text)}"); if (dictionary.ContainsKey(text)) { TotalDeaths.Value = dictionary[text].deaths; DrunkPercentage.Value = dictionary[text].drunkPercent; LethalAlcoolico.Logger.LogInfo((object)$"[Load] Carregado! Deaths: {TotalDeaths.Value} | Drunk: {DrunkPercentage.Value}"); } } ((MonoBehaviour)this).StartCoroutine(DelayedRefresh()); } private void Update() { if (((NetworkBehaviour)this).IsOwner && !(DrunkPercentage.Value <= 0f)) { decayTimer += Time.deltaTime; if (decayTimer >= 12f) { decayTimer = 0f; float num = 0.00125f; DrunkPercentage.Value = Mathf.Max(0f, DrunkPercentage.Value - num); } } } public void OnButtonPressed(PlayerControllerB playerWhoPressed) { if ((Object)(object)playerWhoPressed == (Object)(object)GameNetworkManager.Instance.localPlayerController) { int value; if (PendingCups.Value > 0) { NetworkVariable<int> pendingCups = PendingCups; value = pendingCups.Value; pendingCups.Value = value - 1; } NetworkVariable<int> totalDeaths = TotalDeaths; value = totalDeaths.Value; totalDeaths.Value = value + 1; } } private void CalculateBAC(int totalShots) { if (totalShots <= 0) { DrunkPercentage.Value = 0f; return; } float value = LAConfig.PlayerWeight.Value; float value2 = LAConfig.AlcoholABV.Value; float value3 = LAConfig.ShotSize.Value; float num = 0.65f; float num2 = 4f; float num3 = (float)totalShots * value3 * value2 * 0.8f; float num4 = num3 / (value * num); float num5 = num4 / num2 * 100f; DrunkPercentage.Value = num5; LethalAlcoolico.Logger.LogInfo((object)$"[BAC] Novo valor: {num5:F1}% para {totalShots} shots."); } private IEnumerator DelayedRefresh() { yield return (object)new WaitForSeconds(2.5f); LethalAlcoolicoPatches.RefreshBoard(); } protected override void __initializeVariables() { if (PendingCups == null) { throw new Exception("LethalAlcoolicoPlayerState.PendingCups cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)PendingCups).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)PendingCups, "PendingCups"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)PendingCups); if (TotalDeaths == null) { throw new Exception("LethalAlcoolicoPlayerState.TotalDeaths cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)TotalDeaths).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)TotalDeaths, "TotalDeaths"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)TotalDeaths); if (DrunkPercentage == null) { throw new Exception("LethalAlcoolicoPlayerState.DrunkPercentage cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)DrunkPercentage).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)DrunkPercentage, "DrunkPercentage"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)DrunkPercentage); ((NetworkBehaviour)this).__initializeVariables(); } protected internal override string __getTypeName() { return "LethalAlcoolicoPlayerState"; } } } namespace LethalAlcoolico.Commands { [HarmonyPatch(typeof(HUDManager))] public static class ChatCommandHandler { [HarmonyPatch("SubmitChat_performed")] [HarmonyPrefix] public static bool OnChatSubmit(HUDManager __instance) { PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)val == (Object)null) { return true; } string text = __instance.chatTextField.text.Trim(); if (!text.StartsWith("!")) { return true; } if (!NetworkManager.Singleton.IsHost) { __instance.chatTextField.text = ""; HUDManager.Instance.AddTextToChatOnServer("[Alcoolico] Apenas o host pode usar comandos!", -1); return false; } string[] array = text.Split(' '); switch (array[0].ToLower()) { case "!setshots": { if (array.Length < 3 || !int.TryParse(array[2], out var result2)) { SendFeedback("Uso: !setshots <nome> <quantidade>"); break; } PlayerControllerB val4 = FindPlayer(array[1]); if ((Object)(object)val4 == (Object)null) { SendFeedback("Player '" + array[1] + "' não encontrado!"); break; } LethalAlcoolicoPlayerState component3 = ((Component)val4).GetComponent<LethalAlcoolicoPlayerState>(); if ((Object)(object)component3 == (Object)null) { SendFeedback("State não encontrado!"); break; } component3.TotalDeaths.Value = result2; SendFeedback($"Shots de {val4.playerUsername} setado para {result2}!"); break; } case "!setpending": { if (array.Length < 3 || !int.TryParse(array[2], out var result)) { SendFeedback("Uso: !setpending <nome> <quantidade>"); break; } PlayerControllerB val3 = FindPlayer(array[1]); if ((Object)(object)val3 == (Object)null) { SendFeedback("Player '" + array[1] + "' não encontrado!"); break; } LethalAlcoolicoPlayerState component2 = ((Component)val3).GetComponent<LethalAlcoolicoPlayerState>(); if ((Object)(object)component2 == (Object)null) { SendFeedback("State não encontrado!"); break; } component2.PendingCups.Value = result; SendFeedback($"Pending de {val3.playerUsername} setado para {result}!"); break; } case "!firstdeath": if (array.Length < 2) { SendFeedback("Uso: !firstdeath <true/false>"); } else { SendFeedback("First death " + ((LethalAlcoolicoPatches.firstDeathEnabled = array[1].ToLower() == "true") ? "ativado" : "desativado") + "!"); } break; case "!refreshboard": LethalAlcoolicoPatches.RefreshBoard(); SendFeedback("Board refreshado!"); break; case "!syncvisuals": { if (array.Length < 2) { SendFeedback("Uso: !syncvisuals <nome>"); break; } PlayerControllerB val2 = FindPlayer(array[1]); if ((Object)(object)val2 == (Object)null) { SendFeedback("Player '" + array[1] + "' não encontrado!"); break; } LethalAlcoolicoPlayerState component = ((Component)val2).GetComponent<LethalAlcoolicoPlayerState>(); if ((Object)(object)component == (Object)null) { SendFeedback("State não encontrado!"); break; } LethalAlcoolicoPatches.SyncVisuals(val2, component.PendingCups.Value); SendFeedback("Visuals de " + val2.playerUsername + " sincronizados!"); break; } case "!help": SendFeedback("Comandos: !setshots !setpending !setfirstshot !refreshboard !syncvisuals"); break; default: return true; } __instance.chatTextField.text = ""; return false; } private static PlayerControllerB FindPlayer(string nameArg) { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!((Object)(object)val == (Object)null) && val.isPlayerControlled && val.playerUsername.ToLower().Contains(nameArg.ToLower())) { return val; } } return null; } private static void SendFeedback(string msg) { HUDManager.Instance.AddTextToChatOnServer("[Alcoolico] " + msg, -1); } } } namespace Sociors.LethalAlcoolico.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }