using 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 System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using DrunkerCompany.Buffs; using DrunkerCompany.Decor; using DrunkerCompany.Enemies; using DrunkerCompany.Items; using DrunkerCompany.Network; using DrunkerCompany.Revive; using DrunkerCompany.State; using DrunkerCompany.Suits; using DrunkerCompany.UI; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("DrunkerCompany")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Team-vs-team drinking-game competition mod for Lethal Company.")] [assembly: AssemblyFileVersion("1.0.2.0")] [assembly: AssemblyInformationalVersion("1.0.2")] [assembly: AssemblyProduct("DrunkerCompany")] [assembly: AssemblyTitle("DrunkerCompany")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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] [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 DrunkerCompany { public static class Config { public static ConfigEntry MaskedCount; public static ConfigEntry PosterEnabled; public static ConfigEntry WalkieCount; public static ConfigEntry SpeedBoostEnabled; public static ConfigEntry SpeedBoostCost; public static ConfigEntry SpeedBoostMultiplier; public static ConfigEntry SpeedBoostDuration; public static ConfigEntry GroupReviveEnabled; public static ConfigEntry GroupReviveCost; public static void Init(ConfigFile cfg) { MaskedCount = cfg.Bind("General", "MaskedEnemyCount", 1, "How many Masked enemies spawn on the surface when the Captain dies."); PosterEnabled = cfg.Bind("General", "ShipPoster", true, "Show the custom drinking-rules poster on the ship wall."); WalkieCount = cfg.Bind("General", "WalkieCount", 2, "How many walkie-talkies are dropped by the terminal at the start of each round."); SpeedBoostEnabled = cfg.Bind("CaptainBuffs", "SpeedBoostEnabled", true, "Allow the Captain to buy a crew-wide speed boost with the terminal 'boost' command."); SpeedBoostCost = cfg.Bind("CaptainBuffs", "SpeedBoostCost", 15, "Credit cost of the speed boost."); SpeedBoostMultiplier = cfg.Bind("CaptainBuffs", "SpeedBoostMultiplier", 1.5f, "Movement-speed multiplier applied to every player during the boost."); SpeedBoostDuration = cfg.Bind("CaptainBuffs", "SpeedBoostDuration", 30f, "How long the speed boost lasts, in seconds."); GroupReviveEnabled = cfg.Bind("CaptainBuffs", "GroupReviveEnabled", true, "Allow the Captain to buy a one-time group revive with the terminal 'revive' command."); GroupReviveCost = cfg.Bind("CaptainBuffs", "GroupReviveCost", 35, "Credit cost of the one-time group revive."); } } [BepInPlugin("DrunkerCompany", "DrunkerCompany", "1.0.2")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Logger; private void Awake() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; Config.Init(((BaseUnityPlugin)this).Config); Harmony val = new Harmony("DrunkerCompany"); int num = 0; Type[] types = typeof(Plugin).Assembly.GetTypes(); foreach (Type type in types) { try { val.CreateClassProcessor(type).Patch(); } catch (Exception arg) { num++; Logger.LogError((object)$"Failed to apply patch class {type.FullName}: {arg}"); } } if (num > 0) { Logger.LogWarning((object)string.Format("Plugin {0} loaded with {1} failed patch class(es) — see errors above.", "DrunkerCompany", num)); } else { Logger.LogInfo((object)"Plugin DrunkerCompany loaded!"); } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "DrunkerCompany"; public const string PLUGIN_NAME = "DrunkerCompany"; public const string PLUGIN_VERSION = "1.0.2"; } } namespace DrunkerCompany.UI { public static class ScoreBoard { public static string Build() { if (RoundState.PlayerTeams.Count == 0) { return "DRUNKER COMPANY\n\nNo round data yet. Teams appear once a round has begun.\n"; } Dictionary dictionary = new Dictionary(); if ((Object)(object)StartOfRound.Instance != (Object)null) { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val != (Object)null && val.isPlayerControlled) { dictionary[val.playerClientId] = (string.IsNullOrEmpty(val.playerUsername) ? $"Player {val.playerClientId}" : val.playerUsername); } } } Dictionary> dictionary2 = new Dictionary>(); int num = 0; foreach (KeyValuePair playerTeam in RoundState.PlayerTeams) { if (!dictionary2.TryGetValue(playerTeam.Value, out var value)) { value = new List(); dictionary2[playerTeam.Value] = value; } value.Add(playerTeam.Key); if (playerTeam.Value > num) { num = playerTeam.Value; } } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("DRUNKER COMPANY - TEAMS"); stringBuilder.AppendLine(); for (int j = 0; j <= num; j++) { if (!dictionary2.TryGetValue(j, out var value2)) { continue; } string arg = RoundState.TeamName(j); int num2 = ((j < RoundState.TeamScrapScores.Length) ? RoundState.TeamScrapScores[j] : 0); stringBuilder.AppendLine($"{arg} - ${num2} collected"); foreach (ulong item in value2) { string value3; string text = (dictionary.TryGetValue(item, out value3) ? value3 : $"Player {item}"); stringBuilder.AppendLine(" " + text); } stringBuilder.AppendLine(); } return stringBuilder.ToString(); } } public class TeamHUD : MonoBehaviour { private static TeamHUD? _instance; private TextMeshProUGUI? _label; public static void Refresh() { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_instance == (Object)null) { Create(); } ulong key = (ulong)(((long?)GameNetworkManager.Instance?.localPlayerController?.playerClientId) ?? (-1L)); if (!RoundState.PlayerTeams.TryGetValue(key, out var value)) { return; } string text = RoundState.TeamName(value); Color color = RoundState.TeamColor(value); if ((Object)(object)_instance._label != (Object)null) { if ((Object)(object)((TMP_Text)_instance._label).font == (Object)null) { TryBorrowFont(_instance._label); } ((TMP_Text)_instance._label).text = "[ " + text + " ]"; ((Graphic)_instance._label).color = color; } ((Component)_instance).gameObject.SetActive(true); } public static void Hide() { if ((Object)(object)_instance != (Object)null) { ((Component)_instance).gameObject.SetActive(false); } } private static void Create() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("DrunkerTeamHUD"); Object.DontDestroyOnLoad((Object)(object)val); _instance = val.AddComponent(); Canvas obj = val.AddComponent(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 50; CanvasScaler obj2 = val.AddComponent(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); val.AddComponent(); GameObject val2 = new GameObject("Label"); val2.transform.SetParent(val.transform, false); _instance._label = val2.AddComponent(); TryBorrowFont(_instance._label); ((TMP_Text)_instance._label).fontSize = 22f; ((TMP_Text)_instance._label).fontStyle = (FontStyles)1; ((TMP_Text)_instance._label).alignment = (TextAlignmentOptions)1025; RectTransform component = val2.GetComponent(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.zero; component.pivot = Vector2.zero; component.anchoredPosition = new Vector2(20f, 20f); component.sizeDelta = new Vector2(320f, 44f); val.SetActive(false); } private static void TryBorrowFont(TextMeshProUGUI label) { TextMeshProUGUI val = Object.FindObjectOfType(); if ((Object)(object)val != (Object)null && (Object)(object)((TMP_Text)val).font != (Object)null) { ((TMP_Text)label).font = ((TMP_Text)val).font; } } } } namespace DrunkerCompany.Suits { public static class SuitManager { internal static bool ModApplyingNow = false; private static readonly string[][] ColorKeywords = new string[8][] { new string[1] { "red" }, new string[1] { "blue" }, new string[1] { "dandelion" }, new string[1] { "neon green" }, new string[1] { "purple" }, new string[1] { "white" }, new string[1] { "pink" }, new string[1] { "orange" } }; private static int[] _suitIds = Array.Empty(); private static bool _suitsScanned; public static void FindSuits() { if (_suitsScanned) { return; } List list = StartOfRound.Instance?.unlockablesList?.unlockables; if (list == null || list.Count == 0) { _suitIds = Array.Empty(); return; } _suitIds = new int[ColorKeywords.Length]; for (int i = 0; i < _suitIds.Length; i++) { _suitIds[i] = -1; } for (int j = 0; j < list.Count; j++) { UnlockableItem val = list[j]; if (val.unlockableType != 0 && (Object)(object)val.suitMaterial == (Object)null) { continue; } string text = val.unlockableName.ToLower().Trim(); for (int k = 0; k < ColorKeywords.Length; k++) { if (_suitIds[k] >= 0) { continue; } string[] array = ColorKeywords[k]; foreach (string value in array) { if (text.Contains(value)) { _suitIds[k] = j; break; } } } } _suitsScanned = true; for (int m = 0; m < ColorKeywords.Length; m++) { Plugin.Logger.LogInfo((object)$"[SuitManager] Team {m} → suit index {_suitIds[m]} (keyword '{ColorKeywords[m][0]}')"); } } public static void ApplyAll(Dictionary playerTeams) { if ((Object)(object)StartOfRound.Instance == (Object)null) { return; } FindSuits(); ModApplyingNow = true; try { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!((Object)(object)val == (Object)null) && val.isPlayerControlled && playerTeams.TryGetValue(val.playerClientId, out var value)) { int num = ((value < _suitIds.Length) ? _suitIds[value] : (-1)); if (num >= 0) { Plugin.Logger.LogDebug((object)$"[SuitManager] {val.playerUsername} (team {value}) → suit[{num}]"); UnlockableSuit.SwitchSuitForPlayer(val, num, false); } else { Plugin.Logger.LogWarning((object)($"[SuitManager] No suit found for team {value} ('{ColorKeywords[value][0]}'); " + val.playerUsername + " keeps their current suit. Install a MoreSuits pack with this colour.")); } } } } finally { ModApplyingNow = false; } } } } namespace DrunkerCompany.State { public static class RoundState { public static ulong CaptainClientId = ulong.MaxValue; public static Dictionary PlayerTeams = new Dictionary(); public static int[] TeamScrapScores = Array.Empty(); public static HashSet DeadPlayers = new HashSet(); public static HashSet CountedScrap = new HashSet(); public static HashSet RevivedPlayers = new HashSet(); public static HashSet DiedOnShip = new HashSet(); public static HashSet OurMaskedNetIds = new HashSet(); public static bool FirstDeathAnnounced; public static bool CaptainDead; public static bool IsRoundActive; public static bool GroupReviveUsed; public static readonly Color[] TeamColors = (Color[])(object)new Color[8] { new Color(0.9f, 0.15f, 0.15f), new Color(0.25f, 0.55f, 1f), new Color(1f, 0.85f, 0.1f), new Color(0.3f, 1f, 0.2f), new Color(0.6f, 0.2f, 0.85f), Color.white, new Color(1f, 0.45f, 0.7f), new Color(1f, 0.5f, 0.1f) }; public static readonly string[] TeamNames = new string[8] { "Captain", "Blue Team", "Yellow Team", "Green Team", "Purple Team", "White Team", "Pink Team", "Orange Team" }; private static readonly string[][] ColorWords = new string[8][] { new string[2] { "red", "captain" }, new string[1] { "blue" }, new string[2] { "yellow", "gold" }, new string[2] { "green", "olive" }, new string[2] { "purple", "violet" }, new string[1] { "white" }, new string[2] { "pink", "rose" }, new string[1] { "orange" } }; public static void Reset() { CaptainClientId = ulong.MaxValue; PlayerTeams.Clear(); TeamScrapScores = Array.Empty(); DeadPlayers.Clear(); CountedScrap.Clear(); RevivedPlayers.Clear(); DiedOnShip.Clear(); OurMaskedNetIds.Clear(); FirstDeathAnnounced = false; CaptainDead = false; IsRoundActive = false; GroupReviveUsed = false; } public static Color GetTeamColor(ulong clientId) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (!PlayerTeams.TryGetValue(clientId, out var value)) { return Color.white; } return TeamColor(value); } public static string GetTeamName(ulong clientId) { if (!PlayerTeams.TryGetValue(clientId, out var value)) { return string.Empty; } return TeamName(value); } public static string TeamName(int team) { if (team < 0 || team >= TeamNames.Length) { return $"Team {team}"; } return TeamNames[team]; } public static Color TeamColor(int team) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (team < 0 || team >= TeamColors.Length) { return Color.white; } return TeamColors[team]; } public static int ParseTeam(string word) { if (string.IsNullOrEmpty(word)) { return -1; } word = word.ToLower(); for (int i = 0; i < ColorWords.Length; i++) { string[] array = ColorWords[i]; for (int j = 0; j < array.Length; j++) { if (array[j] == word) { return i; } } } return -1; } public static string TeamColorWord(int team) { if (team < 0 || team >= ColorWords.Length) { return $"team{team}"; } return ColorWords[team][0]; } public static bool TeamHasPlayers(int team) { foreach (KeyValuePair playerTeam in PlayerTeams) { if (playerTeam.Value == team) { return true; } } return false; } public static bool TeamFullyDead(int team) { int num = 0; int num2 = 0; foreach (KeyValuePair playerTeam in PlayerTeams) { if (playerTeam.Value == team) { num++; if (DeadPlayers.Contains(playerTeam.Key)) { num2++; } } } if (num > 0) { return num2 == num; } return false; } public static string ActiveTeamColors() { SortedSet sortedSet = new SortedSet(); foreach (KeyValuePair playerTeam in PlayerTeams) { sortedSet.Add(playerTeam.Value); } List list = new List(); foreach (int item in sortedSet) { list.Add(TeamColorWord(item)); } return string.Join(", ", list); } public static void GetBestWorst(out int bestTeam, out int bestScrap, out int worstTeam, out int worstScrap) { bestTeam = -1; bestScrap = 0; for (int i = 0; i < TeamScrapScores.Length; i++) { if (TeamScrapScores[i] > bestScrap) { bestScrap = TeamScrapScores[i]; bestTeam = i; } } HashSet hashSet = new HashSet(); foreach (KeyValuePair playerTeam in PlayerTeams) { if (playerTeam.Value != 0) { hashSet.Add(playerTeam.Value); } } worstTeam = -1; int num = int.MaxValue; foreach (int item in hashSet) { int num2 = ((item < TeamScrapScores.Length) ? TeamScrapScores[item] : 0); if (num2 < num) { num = num2; worstTeam = item; } } worstScrap = ((worstTeam >= 0) ? num : 0); } } } namespace DrunkerCompany.Revive { public static class ReviveManager { public static void RevivePlayer(PlayerControllerB player, bool recallBodyToShip = false) { //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: 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) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return; } bool isPlayerDead = player.isPlayerDead; player.isPlayerDead = false; player.isPlayerControlled = true; player.isInElevator = true; player.isInHangarShipRoom = true; player.isInsideFactory = false; player.parentedToElevatorLastFrame = false; player.setPositionOfDeadPlayer = false; player.isClimbingLadder = false; player.clampLooking = false; player.inVehicleAnimation = false; player.disableMoveInput = false; player.disableLookInput = false; player.disableInteract = false; player.health = 100; player.criticallyInjured = false; player.hasBeenCriticallyInjured = false; player.bleedingHeavily = false; player.activatingItem = false; player.twoHanded = false; player.isHoldingObject = false; player.inShockingMinigame = false; player.inSpecialInteractAnimation = false; player.freeRotationInInteractAnimation = false; player.disableSyncInAnimation = false; player.inAnimationWithEnemy = null; player.holdingWalkieTalkie = false; player.speakingToWalkieTalkie = false; player.isSinking = false; player.isUnderwater = false; player.sinkingValue = 0f; player.hinderedMultiplier = 1f; player.isMovementHindered = 0; player.sourcesCausingSinking = 0; player.carryWeight = 1f; player.overrideGameOverSpectatePivot = null; StartOfRound instance = StartOfRound.Instance; HUDManager instance2 = HUDManager.Instance; try { Vector3 val = (((Object)(object)instance != (Object)null) ? instance.GetPlayerSpawnPosition((int)player.playerClientId, false) : ((Component)player).transform.position); if (recallBodyToShip && (Object)(object)player.deadBody != (Object)null) { player.deadBody.SetRagdollPositionSafely(val, true); } player.TeleportPlayer(val, false, 0f, false, true); } catch (Exception arg) { Plugin.Logger.LogError((object)$"[Revive] teleport step failed: {arg}"); } try { player.ResetPlayerBloodObjects(isPlayerDead); if ((Object)(object)player.gameplayCamera != (Object)null) { Vector3 localEulerAngles = ((Component)player.gameplayCamera).transform.localEulerAngles; ((Component)player.gameplayCamera).transform.localEulerAngles = new Vector3(localEulerAngles.x, 0f, localEulerAngles.z); } player.ResetZAndXRotation(); if ((Object)(object)player.thisController != (Object)null) { ((Collider)player.thisController).enabled = true; } if ((Object)(object)player.nightVisionRadar != (Object)null) { ((Behaviour)player.nightVisionRadar).enabled = false; } player.DisablePlayerModel(((Component)player).gameObject, true, true); if ((Object)(object)player.helmetLight != (Object)null) { ((Behaviour)player.helmetLight).enabled = false; } player.Crouch(false); if ((Object)(object)player.playerBodyAnimator != (Object)null) { player.playerBodyAnimator.SetBool("Limp", false); } if ((Object)(object)player.statusEffectAudio != (Object)null) { player.statusEffectAudio.Stop(); } if ((Object)(object)player.mapRadarDotAnimator != (Object)null) { player.mapRadarDotAnimator.SetBool("dead", false); } player.externalForceAutoFade = Vector3.zero; } catch (Exception arg2) { Plugin.Logger.LogError((object)$"[Revive] body step failed: {arg2}"); } if (((NetworkBehaviour)player).IsOwner) { try { if ((Object)(object)instance2 != (Object)null) { instance2.SetCracksOnVisor(100f); if ((Object)(object)instance2.gasHelmetAnimator != (Object)null) { instance2.gasHelmetAnimator.SetBool("gasEmitting", false); } instance2.RemoveSpectateUI(); if ((Object)(object)instance2.gameOverAnimator != (Object)null) { instance2.gameOverAnimator.SetTrigger("revive"); } instance2.UpdateHealthUI(100, false); if ((Object)(object)instance2.audioListenerLowPass != (Object)null) { ((Behaviour)instance2.audioListenerLowPass).enabled = false; } instance2.HideHUD(false); } player.hasBegunSpectating = false; player.spectatedPlayerScript = null; if (instance != null) { instance.SetSpectateCameraToGameOverMode(false, player); } } catch (Exception arg3) { Plugin.Logger.LogError((object)$"[Revive] owner UI step failed: {arg3}"); } } try { if ((Object)(object)player.deadBody != (Object)null) { if ((Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsHost && (Object)(object)player.deadBody.grabBodyObject != (Object)null) { NetworkObject component = ((Component)player.deadBody.grabBodyObject).GetComponent(); if ((Object)(object)component != (Object)null && component.IsSpawned) { component.Despawn(true); } } player.deadBody.DeactivateBody(false); player.deadBody = null; } } catch (Exception arg4) { Plugin.Logger.LogError((object)$"[Revive] body despawn failed: {arg4}"); } if ((Object)(object)instance != (Object)null) { int num = 0; PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val2 in allPlayerScripts) { if ((Object)(object)val2 != (Object)null && val2.isPlayerControlled && !val2.isPlayerDead) { num++; } } instance.livingPlayers = num; instance.allPlayersDead = false; } PlayerControllerB val3 = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)val3 != (Object)null && val3.isPlayerDead && val3.playerClientId != player.playerClientId) { try { if (instance2 != null) { instance2.RemoveSpectateUI(); } } catch (Exception arg5) { Plugin.Logger.LogError((object)$"[Revive] spectate UI reset failed: {arg5}"); } } if (instance2 != null) { instance2.UpdateBoxesSpectateUI(); } } } } namespace DrunkerCompany.Patches { [HarmonyPatch(typeof(HUDManager), "FillEndGameStats")] internal static class EndGameStatsPatch { [HarmonyPostfix] private static void Postfix(HUDManager __instance) { if (RoundState.PlayerTeams.Count == 0) { return; } EndOfGameStatUIElements statsUIElements = __instance.statsUIElements; if (statsUIElements?.playerNamesText == null) { return; } ClearReport(statsUIElements); RoundState.GetBestWorst(out var bestTeam, out var bestScrap, out var worstTeam, out var worstScrap); if (bestTeam < 0 || bestScrap <= 0) { SetName(statsUIElements, 0, "No scrap was collected this round."); return; } SetRow(statsUIElements, 0, "MOST SCRAP", bestTeam, bestScrap); if (worstTeam >= 0 && worstTeam != bestTeam) { SetRow(statsUIElements, 1, "LEAST SCRAP", worstTeam, worstScrap); } } private static void SetRow(EndOfGameStatUIElements ui, int row, string label, int team, int scrap) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) SetName(ui, row, label); string arg = ColorUtility.ToHtmlStringRGB(RoundState.TeamColor(team)); if (ui.playerNotesText != null && row < ui.playerNotesText.Length && (Object)(object)ui.playerNotesText[row] != (Object)null) { TextMeshProUGUI obj = ui.playerNotesText[row]; ((TMP_Text)obj).alignment = (TextAlignmentOptions)257; ((TMP_Text)obj).enableWordWrapping = false; ((TMP_Text)obj).overflowMode = (TextOverflowModes)0; ((TMP_Text)obj).text = $"{RoundState.TeamName(team)} ${scrap}"; ApplyOutline(obj); } } private static void SetName(EndOfGameStatUIElements ui, int row, string text) { if (row < ui.playerNamesText.Length && (Object)(object)ui.playerNamesText[row] != (Object)null) { ((TMP_Text)ui.playerNamesText[row]).text = text; ApplyOutline(ui.playerNamesText[row]); } } private static void ApplyOutline(TextMeshProUGUI t) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)t == (Object)null)) { Material fontMaterial = ((TMP_Text)t).fontMaterial; fontMaterial.SetFloat(ShaderUtilities.ID_OutlineWidth, 0.2f); fontMaterial.SetColor(ShaderUtilities.ID_OutlineColor, Color.black); } } private static void ClearReport(EndOfGameStatUIElements ui) { if (ui.playerNamesText != null) { TextMeshProUGUI[] playerNamesText = ui.playerNamesText; for (int i = 0; i < playerNamesText.Length; i++) { Blank(playerNamesText[i]); } } if (ui.playerNotesText != null) { TextMeshProUGUI[] playerNamesText = ui.playerNotesText; for (int i = 0; i < playerNamesText.Length; i++) { Blank(playerNamesText[i]); } } if (ui.playerStates != null) { Image[] playerStates = ui.playerStates; foreach (Image val in playerStates) { if ((Object)(object)val != (Object)null) { ((Behaviour)val).enabled = false; } } } Blank(ui.penaltyAddition); Blank(ui.penaltyTotal); Blank(ui.challengeCollectedText); Blank(ui.challengeRankText); if ((Object)(object)ui.allPlayersDeadOverlay != (Object)null) { ((Behaviour)ui.allPlayersDeadOverlay).enabled = false; } } private static void Blank(TextMeshProUGUI t) { if ((Object)(object)t != (Object)null) { ((TMP_Text)t).text = ""; } } } [HarmonyPatch(typeof(HUDManager), "ApplyPenalty")] internal static class NoCasualtyPenaltyPatch { [HarmonyPrefix] private static bool Prefix() { return RoundState.PlayerTeams.Count == 0; } } [HarmonyPatch(typeof(Animator), "SetTrigger", new Type[] { typeof(string) })] internal static class NoPenaltyBoxPatch { [HarmonyPrefix] private static bool Prefix(Animator __instance, string name) { if (RoundState.PlayerTeams.Count == 0) { return true; } HUDManager instance = HUDManager.Instance; if (name == "displayPenalty" && (Object)(object)instance != (Object)null && (Object)(object)__instance == (Object)(object)instance.endgameStatsAnimator) { return false; } return true; } } [HarmonyPatch(typeof(Terminal), "LoadNewNodeIfAffordable")] internal static class FreeTravelPatch { [HarmonyPrefix] private static void Prefix(TerminalNode node) { if ((Object)(object)node != (Object)null && node.buyRerouteToMoon != -1) { node.itemCost = 0; } } } [HarmonyPatch(typeof(GameNetworkManager), "Start")] internal static class GameNetworkManagerStartPatch { [HarmonyPostfix] private static void Postfix() { DrunkerMessages.Register(); } } [HarmonyPatch(typeof(StartOfRound), "Awake")] internal static class StartOfRoundAwakePatch { [HarmonyPostfix] private static void Postfix() { DrunkerMessages.Reset(); DrunkerMessages.Register(); } } [HarmonyPatch(typeof(StartOfRound), "Start")] internal static class StartOfRoundStartPosterPatch { [HarmonyPostfix] private static void Postfix(StartOfRound __instance) { Plugin.Logger.LogInfo((object)"[Poster] StartOfRound.Start postfix fired — scheduling poster spawn."); ((MonoBehaviour)__instance).StartCoroutine(PosterSpawner.SpawnSoon()); } } [HarmonyPatch(typeof(StartOfRound), "StartGame")] internal static class StartOfRoundStartGamePatch { [HarmonyPostfix] private static void Postfix(StartOfRound __instance) { NetworkManager singleton = NetworkManager.Singleton; if (singleton == null || !singleton.IsHost) { return; } List list = new List(); PlayerControllerB[] allPlayerScripts = __instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val != (Object)null && val.isPlayerControlled) { list.Add(val); } } if (list.Count != 0) { for (int num = list.Count - 1; num > 0; num--) { int num2 = Random.Range(0, num + 1); List list2 = list; int i = num; int index = num2; PlayerControllerB value = list[num2]; PlayerControllerB value2 = list[num]; list2[i] = value; list[index] = value2; } ulong[] array = new ulong[list.Count]; int[] array2 = new int[list.Count]; array[0] = list[0].playerClientId; array2[0] = 0; for (int j = 1; j < list.Count; j++) { array[j] = list[j].playerClientId; array2[j] = (j - 1) / 2 + 1; } int num3 = list.Count - 1; if (num3 >= 3 && num3 % 2 == 1) { array2[list.Count - 1]--; } DrunkerMessages.BroadcastSyncRound(list[0].playerClientId, array, array2); } } } [HarmonyPatch(typeof(StartOfRound), "ShipLeave")] internal static class StartOfRoundShipLeavePatch { [HarmonyPostfix] private static void Postfix(StartOfRound __instance) { NetworkManager singleton = NetworkManager.Singleton; if (singleton != null && singleton.IsHost && RoundState.IsRoundActive) { DrunkerMessages.BroadcastRoundEnd(); } } } [HarmonyPatch(typeof(EnemyAI), "PlayerIsTargetable")] internal static class MaskedTargetablePatch { [HarmonyPrefix] private static void Prefix(EnemyAI __instance, ref bool overrideInsideFactoryCheck) { if (!overrideInsideFactoryCheck && __instance is MaskedPlayerEnemy && !((Object)(object)((NetworkBehaviour)__instance).NetworkObject == (Object)null) && RoundState.OurMaskedNetIds.Contains(((NetworkBehaviour)__instance).NetworkObjectId)) { overrideInsideFactoryCheck = true; } } } [HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")] internal static class PlayerDeathPatch { [HarmonyPrefix] private static void Prefix(PlayerControllerB __instance) { if (RoundState.IsRoundActive && !__instance.isPlayerDead) { DrunkerMessages.ReportDeath(__instance.playerClientId, __instance.playerUsername, __instance.isInHangarShipRoom); } } } [HarmonyPatch(typeof(PlayerControllerB), "DiscardHeldObject")] internal static class ReviveBodyPatch { [HarmonyPrefix] private static void Prefix(PlayerControllerB __instance, out ulong __state) { __state = ulong.MaxValue; if (!RoundState.IsRoundActive) { return; } PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)val == (Object)null || __instance.playerClientId != val.playerClientId || !__instance.isInHangarShipRoom) { return; } GrabbableObject currentlyHeldObjectServer = __instance.currentlyHeldObjectServer; RagdollGrabbableObject val2 = (RagdollGrabbableObject)(object)((currentlyHeldObjectServer is RagdollGrabbableObject) ? currentlyHeldObjectServer : null); if (val2 != null) { PlayerControllerB val3 = val2.ragdoll?.playerScript; if (!((Object)(object)val3 == (Object)null) && RoundState.DeadPlayers.Contains(val3.playerClientId)) { __state = val3.playerClientId; } } } [HarmonyPostfix] private static void Postfix(ulong __state) { if (__state != ulong.MaxValue) { PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if (!((Object)(object)val == (Object)null)) { DrunkerMessages.RequestRevive(__state, val.playerClientId); } } } } [HarmonyPatch(typeof(PlayerControllerB), "DiscardHeldObject")] internal static class ShipScrapPatch { [HarmonyPrefix] private static void Prefix(PlayerControllerB __instance) { if (!RoundState.IsRoundActive) { return; } PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if (!((Object)(object)val == (Object)null) && __instance.playerClientId == val.playerClientId && __instance.isInHangarShipRoom) { GrabbableObject currentlyHeldObjectServer = __instance.currentlyHeldObjectServer; if (!((Object)(object)currentlyHeldObjectServer == (Object)null) && !((Object)(object)currentlyHeldObjectServer.itemProperties == (Object)null) && currentlyHeldObjectServer.itemProperties.isScrap && !((Object)(object)((NetworkBehaviour)currentlyHeldObjectServer).NetworkObject == (Object)null) && ((NetworkBehaviour)currentlyHeldObjectServer).NetworkObject.IsSpawned && RoundState.PlayerTeams.TryGetValue(val.playerClientId, out var value)) { DrunkerMessages.ReportScrapDeposit(value, currentlyHeldObjectServer.scrapValue, ((NetworkBehaviour)currentlyHeldObjectServer).NetworkObjectId); } } } } [HarmonyPatch(typeof(UnlockableSuit), "SwitchSuitToThis")] internal static class SuitChangePatch { [HarmonyPrefix] private static bool Prefix() { if (!RoundState.IsRoundActive) { return true; } if (SuitManager.ModApplyingNow) { return true; } HUDManager.Instance.DisplayTip("Suit Locked", "You cannot change suits while a round is in progress.", true, false, "LC_Tip1"); return false; } } internal static class ShopRestriction { public static bool IsCreditPurchase(TerminalNode node) { if ((Object)(object)node != (Object)null) { if (node.buyItemIndex == -1 && node.buyVehicleIndex == -1) { return node.shipUnlockableID != -1; } return true; } return false; } public static bool LocalPlayerIsCaptain() { ulong key = (ulong)(((long?)GameNetworkManager.Instance?.localPlayerController?.playerClientId) ?? (-1L)); if (RoundState.PlayerTeams.TryGetValue(key, out var value)) { return value == 0; } return false; } public static void WarnRestricted() { HUDManager instance = HUDManager.Instance; if (instance != null) { instance.DisplayTip("Shop Restricted", "Only the Captain can purchase items this round!", true, false, "LC_Tip1"); } } } [HarmonyPatch(typeof(Terminal), "LoadNewNodeIfAffordable")] internal static class ShopAffordableGatePatch { [HarmonyPrefix] private static bool Prefix(TerminalNode node) { if (!RoundState.IsRoundActive) { return true; } if (!ShopRestriction.IsCreditPurchase(node)) { return true; } if (ShopRestriction.LocalPlayerIsCaptain()) { return true; } ShopRestriction.WarnRestricted(); return false; } } [HarmonyPatch(typeof(Terminal), "LoadNewNode")] internal static class ShopCommitGatePatch { [HarmonyPrefix] private static bool Prefix(TerminalNode node) { if (!RoundState.IsRoundActive) { return true; } if ((Object)(object)node == (Object)null) { return true; } if (!ShopRestriction.IsCreditPurchase(node)) { return true; } if (ShopRestriction.LocalPlayerIsCaptain()) { return true; } ShopRestriction.WarnRestricted(); return false; } } [HarmonyPatch(typeof(Terminal), "TextPostProcess")] internal static class TerminalStoreNoticePatch { [HarmonyPostfix] private static void Postfix(TerminalNode node, ref string __result) { if (node != null && node.displayText != null && __result != null && node.displayText.Contains("[buyableItemsList]")) { int i; for (i = 0; i < __result.Length && (__result[i] == '\n' || __result[i] == '\r'); i++) { } __result = __result.Substring(0, i) + "Only the [Captain] can purchase items from the shop.\n\n" + __result.Substring(i); } } } [HarmonyPatch(typeof(Terminal), "ParsePlayerSentence")] internal static class TerminalScorePatch { private static TerminalNode? _teamsNode; private static TerminalNode? _buffNode; private static TerminalNode? _captainNode; [HarmonyPostfix] private static void Postfix(Terminal __instance, ref TerminalNode __result) { string typedText = GetTypedText(__instance); switch (typedText) { case "teams": case "team": if ((Object)(object)_teamsNode == (Object)null) { _teamsNode = ScriptableObject.CreateInstance(); _teamsNode.clearPreviousText = true; _teamsNode.maxCharactersToType = 9999; } _teamsNode.displayText = ScoreBoard.Build() + "\n"; __result = _teamsNode; return; case "captain": case "captain commands": __result = CaptainMenu(); return; } string[] array = typedText.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string text = ((array.Length != 0) ? array[0] : typedText); string arg = ((array.Length > 1) ? typedText.Substring(text.Length).Trim() : ""); switch (text) { case "boost": case "speed": __result = BuffCommand(__instance, speed: true, arg); return; case "revive": case "rescue": __result = BuffCommand(__instance, speed: false, arg); return; } if (typedText == "help" || typedText == "other") { AddTeamsToCommandList(__result); } } private static TerminalNode BuffCommand(Terminal terminal, bool speed, string arg) { if ((Object)(object)_buffNode == (Object)null) { _buffNode = ScriptableObject.CreateInstance(); _buffNode.clearPreviousText = true; _buffNode.maxCharactersToType = 9999; } _buffNode.displayText = ResolveBuff(terminal, speed, arg) + "\n"; return _buffNode; } private static string ResolveBuff(Terminal terminal, bool speed, string arg) { bool flag = (speed ? Config.SpeedBoostEnabled.Value : Config.GroupReviveEnabled.Value); int num = (speed ? Config.SpeedBoostCost.Value : Config.GroupReviveCost.Value); string text = (speed ? "Speed boost" : "Group revive"); string text2 = (speed ? "boost" : "revive"); if (!RoundState.IsRoundActive) { return "There is no active round."; } if (!flag) { return text + " is disabled."; } if (!ShopRestriction.LocalPlayerIsCaptain()) { return "Only the Captain can buy buffs."; } if (string.IsNullOrEmpty(arg)) { return "Usage: " + text2 + " \nColours this round: " + RoundState.ActiveTeamColors(); } int num2 = RoundState.ParseTeam(arg); if (num2 < 0 || !RoundState.TeamHasPlayers(num2)) { return "No team with colour '" + arg + "'.\nColours this round: " + RoundState.ActiveTeamColors(); } if (!speed && RoundState.GroupReviveUsed) { return "Group revive has already been used this round."; } if (!speed && !RoundState.TeamFullyDead(num2)) { return RoundState.TeamName(num2) + " still has living members — the whole team must be down."; } if (terminal.groupCredits < num) { return $"Not enough credits — {text} costs ${num}."; } if (speed) { DrunkerMessages.RequestSpeedBoost(num2); } else { DrunkerMessages.RequestGroupRevive(num2); } return $"{text} sent to {RoundState.TeamName(num2)} for ${num}!"; } private static TerminalNode CaptainMenu() { if ((Object)(object)_captainNode == (Object)null) { _captainNode = ScriptableObject.CreateInstance(); _captainNode.clearPreviousText = true; _captainNode.maxCharactersToType = 9999; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("CAPTAIN\n"); stringBuilder.Append("Only the Captain can use these during an active round.\n"); if (Config.SpeedBoostEnabled.Value) { stringBuilder.Append($"\n>BOOST [colour]\nSpeed-boost one team. (${Config.SpeedBoostCost.Value})\n"); } if (Config.GroupReviveEnabled.Value) { stringBuilder.Append($"\n>REVIVE [colour]\nRevive one fully-wiped team, once per round. (${Config.GroupReviveCost.Value})\n"); } _captainNode.displayText = stringBuilder.ToString(); return _captainNode; } private static string CommandAdvert() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(">TEAMS\nView this round's teams and their members."); if (Config.SpeedBoostEnabled.Value || Config.GroupReviveEnabled.Value) { stringBuilder.Append("\n\n>CAPTAIN\n[Captain] Give a team speed boost or revive a team."); } return stringBuilder.ToString(); } private static void AddTeamsToCommandList(TerminalNode? node) { if ((Object)(object)node == (Object)null || node.displayText == null) { return; } string displayText = node.displayText; if (displayText.Contains(">TEAMS")) { return; } string text = CommandAdvert(); int num = displayText.IndexOf(">bestiary", StringComparison.OrdinalIgnoreCase); if (num < 0) { node.displayText = displayText.TrimEnd(Array.Empty()) + "\n\n" + text + "\n"; return; } int num2 = displayText.IndexOf("\n>", num + 1, StringComparison.Ordinal); if (num2 < 0) { num2 = displayText.Length; } string value = displayText.Substring(num, num2 - num).TrimEnd(Array.Empty()); string value2 = displayText.Substring(0, num).TrimEnd(Array.Empty()); string text2 = displayText.Substring(num2).Trim(); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(value2); stringBuilder.Append("\n\n").Append(text); if (text2.Length > 0) { stringBuilder.Append("\n\n").Append(text2); } stringBuilder.Append("\n\n").Append(value); stringBuilder.Append('\n'); node.displayText = stringBuilder.ToString(); } private static string GetTypedText(Terminal terminal) { if ((Object)(object)terminal.screenText == (Object)null) { return string.Empty; } string text = terminal.screenText.text; int textAdded = terminal.textAdded; if (textAdded <= 0 || textAdded > text.Length) { return string.Empty; } return text.Substring(text.Length - textAdded).Trim().ToLower(); } } } namespace DrunkerCompany.Network { public static class DrunkerMessages { [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnReceiveSyncRound; public static HandleNamedMessageDelegate <1>__OnReceiveReveal; public static HandleNamedMessageDelegate <2>__OnReceiveDeath; public static HandleNamedMessageDelegate <3>__OnReceiveDeathReport; public static HandleNamedMessageDelegate <4>__OnReceiveScores; public static HandleNamedMessageDelegate <5>__OnReceiveRoundEnd; public static HandleNamedMessageDelegate <6>__OnReceiveScrapReport; public static HandleNamedMessageDelegate <7>__OnReceiveRevive; public static HandleNamedMessageDelegate <8>__OnReceiveReviveReport; public static HandleNamedMessageDelegate <9>__OnReceiveMaskedSpawned; public static HandleNamedMessageDelegate <10>__OnReceiveBuffReq; public static HandleNamedMessageDelegate <11>__OnReceiveSpeedBoost; public static HandleNamedMessageDelegate <12>__OnReceiveGroupRevive; public static HandleNamedMessageDelegate <13>__OnReceiveResync; public static HandleNamedMessageDelegate <14>__OnReceiveAddPlayer; public static Action <15>__HandleClientConnected; } private const string kSyncRound = "DrunkerCompany_SyncRound"; private const string kReveal = "DrunkerCompany_Reveal"; private const string kDeath = "DrunkerCompany_Death"; private const string kDeathReport = "DrunkerCompany_DeathReport"; private const string kScores = "DrunkerCompany_Scores"; private const string kRoundEnd = "DrunkerCompany_RoundEnd"; private const string kScrapReport = "DrunkerCompany_ScrapReport"; private const string kRevive = "DrunkerCompany_Revive"; private const string kReviveReport = "DrunkerCompany_ReviveReport"; private const string kMaskedSpawned = "DrunkerCompany_MaskedSpawned"; private const string kBuffReq = "DrunkerCompany_BuffReq"; private const string kSpeedBoost = "DrunkerCompany_SpeedBoost"; private const string kGroupRevive = "DrunkerCompany_GroupRevive"; private const string kResync = "DrunkerCompany_Resync"; private const string kAddPlayer = "DrunkerCompany_AddPlayer"; private const byte BuffSpeed = 0; private const byte BuffRevive = 1; private static bool _registered; private static bool _connectHooked; private static bool _walkiesSpawnedThisRound; private static bool IsHost { get { if ((Object)(object)NetworkManager.Singleton != (Object)null) { return NetworkManager.Singleton.IsHost; } return false; } } public static void Register() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_0086: 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_0091: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Expected O, but got Unknown //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Expected O, but got Unknown //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Expected O, but got Unknown //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Expected O, but got Unknown //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Expected O, but got Unknown //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Expected O, but got Unknown //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Expected O, but got Unknown if (_registered) { return; } NetworkManager singleton = NetworkManager.Singleton; CustomMessagingManager val = ((singleton != null) ? singleton.CustomMessagingManager : null); if (val != null) { _registered = true; object obj = <>O.<0>__OnReceiveSyncRound; if (obj == null) { HandleNamedMessageDelegate val2 = OnReceiveSyncRound; <>O.<0>__OnReceiveSyncRound = val2; obj = (object)val2; } val.RegisterNamedMessageHandler("DrunkerCompany_SyncRound", (HandleNamedMessageDelegate)obj); object obj2 = <>O.<1>__OnReceiveReveal; if (obj2 == null) { HandleNamedMessageDelegate val3 = OnReceiveReveal; <>O.<1>__OnReceiveReveal = val3; obj2 = (object)val3; } val.RegisterNamedMessageHandler("DrunkerCompany_Reveal", (HandleNamedMessageDelegate)obj2); object obj3 = <>O.<2>__OnReceiveDeath; if (obj3 == null) { HandleNamedMessageDelegate val4 = OnReceiveDeath; <>O.<2>__OnReceiveDeath = val4; obj3 = (object)val4; } val.RegisterNamedMessageHandler("DrunkerCompany_Death", (HandleNamedMessageDelegate)obj3); object obj4 = <>O.<3>__OnReceiveDeathReport; if (obj4 == null) { HandleNamedMessageDelegate val5 = OnReceiveDeathReport; <>O.<3>__OnReceiveDeathReport = val5; obj4 = (object)val5; } val.RegisterNamedMessageHandler("DrunkerCompany_DeathReport", (HandleNamedMessageDelegate)obj4); object obj5 = <>O.<4>__OnReceiveScores; if (obj5 == null) { HandleNamedMessageDelegate val6 = OnReceiveScores; <>O.<4>__OnReceiveScores = val6; obj5 = (object)val6; } val.RegisterNamedMessageHandler("DrunkerCompany_Scores", (HandleNamedMessageDelegate)obj5); object obj6 = <>O.<5>__OnReceiveRoundEnd; if (obj6 == null) { HandleNamedMessageDelegate val7 = OnReceiveRoundEnd; <>O.<5>__OnReceiveRoundEnd = val7; obj6 = (object)val7; } val.RegisterNamedMessageHandler("DrunkerCompany_RoundEnd", (HandleNamedMessageDelegate)obj6); object obj7 = <>O.<6>__OnReceiveScrapReport; if (obj7 == null) { HandleNamedMessageDelegate val8 = OnReceiveScrapReport; <>O.<6>__OnReceiveScrapReport = val8; obj7 = (object)val8; } val.RegisterNamedMessageHandler("DrunkerCompany_ScrapReport", (HandleNamedMessageDelegate)obj7); object obj8 = <>O.<7>__OnReceiveRevive; if (obj8 == null) { HandleNamedMessageDelegate val9 = OnReceiveRevive; <>O.<7>__OnReceiveRevive = val9; obj8 = (object)val9; } val.RegisterNamedMessageHandler("DrunkerCompany_Revive", (HandleNamedMessageDelegate)obj8); object obj9 = <>O.<8>__OnReceiveReviveReport; if (obj9 == null) { HandleNamedMessageDelegate val10 = OnReceiveReviveReport; <>O.<8>__OnReceiveReviveReport = val10; obj9 = (object)val10; } val.RegisterNamedMessageHandler("DrunkerCompany_ReviveReport", (HandleNamedMessageDelegate)obj9); object obj10 = <>O.<9>__OnReceiveMaskedSpawned; if (obj10 == null) { HandleNamedMessageDelegate val11 = OnReceiveMaskedSpawned; <>O.<9>__OnReceiveMaskedSpawned = val11; obj10 = (object)val11; } val.RegisterNamedMessageHandler("DrunkerCompany_MaskedSpawned", (HandleNamedMessageDelegate)obj10); object obj11 = <>O.<10>__OnReceiveBuffReq; if (obj11 == null) { HandleNamedMessageDelegate val12 = OnReceiveBuffReq; <>O.<10>__OnReceiveBuffReq = val12; obj11 = (object)val12; } val.RegisterNamedMessageHandler("DrunkerCompany_BuffReq", (HandleNamedMessageDelegate)obj11); object obj12 = <>O.<11>__OnReceiveSpeedBoost; if (obj12 == null) { HandleNamedMessageDelegate val13 = OnReceiveSpeedBoost; <>O.<11>__OnReceiveSpeedBoost = val13; obj12 = (object)val13; } val.RegisterNamedMessageHandler("DrunkerCompany_SpeedBoost", (HandleNamedMessageDelegate)obj12); object obj13 = <>O.<12>__OnReceiveGroupRevive; if (obj13 == null) { HandleNamedMessageDelegate val14 = OnReceiveGroupRevive; <>O.<12>__OnReceiveGroupRevive = val14; obj13 = (object)val14; } val.RegisterNamedMessageHandler("DrunkerCompany_GroupRevive", (HandleNamedMessageDelegate)obj13); object obj14 = <>O.<13>__OnReceiveResync; if (obj14 == null) { HandleNamedMessageDelegate val15 = OnReceiveResync; <>O.<13>__OnReceiveResync = val15; obj14 = (object)val15; } val.RegisterNamedMessageHandler("DrunkerCompany_Resync", (HandleNamedMessageDelegate)obj14); object obj15 = <>O.<14>__OnReceiveAddPlayer; if (obj15 == null) { HandleNamedMessageDelegate val16 = OnReceiveAddPlayer; <>O.<14>__OnReceiveAddPlayer = val16; obj15 = (object)val16; } val.RegisterNamedMessageHandler("DrunkerCompany_AddPlayer", (HandleNamedMessageDelegate)obj15); if (IsHost && !_connectHooked) { NetworkManager.Singleton.OnClientConnectedCallback += HandleClientConnected; _connectHooked = true; } Plugin.Logger.LogInfo((object)"[DrunkerMessages] Handlers registered."); } } public static void Reset() { _registered = false; } public static void BroadcastSyncRound(ulong captainId, ulong[] playerIds, int[] teamIndices) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) int num = 12 + playerIds.Length * 8 + 4 + teamIndices.Length * 4 + 16; FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(num, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValueSafe(ref captainId, default(ForPrimitives)); int num2 = playerIds.Length; ((FastBufferWriter)(ref val)).WriteValueSafe(ref num2, default(ForPrimitives)); for (num2 = 0; num2 < playerIds.Length; num2++) { ulong num3 = playerIds[num2]; ((FastBufferWriter)(ref val)).WriteValueSafe(ref num3, default(ForPrimitives)); } num2 = teamIndices.Length; ((FastBufferWriter)(ref val)).WriteValueSafe(ref num2, default(ForPrimitives)); for (num2 = 0; num2 < teamIndices.Length; num2++) { int num4 = teamIndices[num2]; ((FastBufferWriter)(ref val)).WriteValueSafe(ref num4, default(ForPrimitives)); } NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("DrunkerCompany_SyncRound", val, (NetworkDelivery)3); ((FastBufferWriter)(ref val)).Dispose(); _walkiesSpawnedThisRound = false; ApplySyncRound(captainId, playerIds, teamIndices); } public static void ReportDeath(ulong clientId, string playerName, bool diedInShip) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) if (IsHost) { HandleDeath(clientId, playerName, diedInShip); return; } byte[] bytes = Encoding.UTF8.GetBytes(playerName); FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(13 + bytes.Length, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValueSafe(ref clientId, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref diedInShip, default(ForPrimitives)); int num = bytes.Length; ((FastBufferWriter)(ref val)).WriteValueSafe(ref num, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteBytesSafe(bytes, -1, 0); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("DrunkerCompany_DeathReport", 0uL, val, (NetworkDelivery)3); ((FastBufferWriter)(ref val)).Dispose(); } private static void HandleDeath(ulong clientId, string playerName, bool diedInShip) { if (!RoundState.DeadPlayers.Contains(clientId)) { bool flag = !RoundState.FirstDeathAnnounced; if (flag) { RoundState.FirstDeathAnnounced = true; } if (diedInShip) { RoundState.DiedOnShip.Add(clientId); } bool flag2 = clientId == RoundState.CaptainClientId; BroadcastDeath(clientId, playerName, flag, flag2); if (flag2 && !RoundState.CaptainDead) { RoundState.CaptainDead = true; MaskedSpawner.SpawnOutsideAfterCaptainDeath(); } } } private static void BroadcastDeath(ulong clientId, string playerName, bool isFirst, bool isCaptain) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) byte[] bytes = Encoding.UTF8.GetBytes(playerName); FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(14 + bytes.Length, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValueSafe(ref clientId, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref isFirst, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref isCaptain, default(ForPrimitives)); int num = bytes.Length; ((FastBufferWriter)(ref val)).WriteValueSafe(ref num, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteBytesSafe(bytes, -1, 0); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("DrunkerCompany_Death", val, (NetworkDelivery)3); ((FastBufferWriter)(ref val)).Dispose(); ApplyDeath(clientId, playerName, isFirst, isCaptain); } private static void BroadcastScores() { //IL_0028: 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_0047: 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) if (IsHost) { int[] teamScrapScores = RoundState.TeamScrapScores; FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(4 + teamScrapScores.Length * 4, (Allocator)2, -1); int num = teamScrapScores.Length; ((FastBufferWriter)(ref val)).WriteValueSafe(ref num, default(ForPrimitives)); int[] array = teamScrapScores; for (num = 0; num < array.Length; num++) { int num2 = array[num]; ((FastBufferWriter)(ref val)).WriteValueSafe(ref num2, default(ForPrimitives)); } NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("DrunkerCompany_Scores", val, (NetworkDelivery)3); ((FastBufferWriter)(ref val)).Dispose(); } } public static void BroadcastRoundEnd() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) BroadcastScores(); FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(4, (Allocator)2, -1); int num = 0; ((FastBufferWriter)(ref val)).WriteValueSafe(ref num, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("DrunkerCompany_RoundEnd", val, (NetworkDelivery)3); ((FastBufferWriter)(ref val)).Dispose(); ApplyRoundEnd(); } public static void BroadcastMaskedSpawned(ulong netId) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) RoundState.OurMaskedNetIds.Add(netId); if (IsHost) { FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(8, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValueSafe(ref netId, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("DrunkerCompany_MaskedSpawned", val, (NetworkDelivery)3); ((FastBufferWriter)(ref val)).Dispose(); } } private static void OnReceiveMaskedSpawned(ulong _, FastBufferReader reader) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) ulong num = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe(ref num, default(ForPrimitives)); RoundState.OurMaskedNetIds.Add(num); if ((Object)(object)StartOfRound.Instance != (Object)null) { ((MonoBehaviour)StartOfRound.Instance).StartCoroutine(MaskedSpawner.MarkOutsideWhenReplicated(num)); } } public static void ReportScrapDeposit(int teamIndex, int value, ulong netId) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) if (IsHost) { AccumulateScrap(teamIndex, value, netId); return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(20, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValueSafe(ref teamIndex, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref value, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref netId, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("DrunkerCompany_ScrapReport", 0uL, val, (NetworkDelivery)3); ((FastBufferWriter)(ref val)).Dispose(); } private static void AccumulateScrap(int teamIndex, int value, ulong netId) { if (teamIndex >= 0 && teamIndex < RoundState.TeamScrapScores.Length && RoundState.CountedScrap.Add(netId)) { RoundState.TeamScrapScores[teamIndex] += value; BroadcastScores(); } } public static void RequestRevive(ulong deadClientId, ulong reviverClientId) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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) if (IsHost) { HandleRevive(deadClientId, reviverClientId); return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(16, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValueSafe(ref deadClientId, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref reviverClientId, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("DrunkerCompany_ReviveReport", 0uL, val, (NetworkDelivery)3); ((FastBufferWriter)(ref val)).Dispose(); } private static void HandleRevive(ulong deadClientId, ulong reviverClientId) { if (deadClientId != reviverClientId && !RoundState.RevivedPlayers.Contains(deadClientId) && RoundState.DeadPlayers.Contains(deadClientId)) { RoundState.RevivedPlayers.Add(deadClientId); BroadcastRevive(deadClientId, reviverClientId); } } private static void BroadcastRevive(ulong deadClientId, ulong reviverClientId) { //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) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(16, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValueSafe(ref deadClientId, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref reviverClientId, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("DrunkerCompany_Revive", val, (NetworkDelivery)3); ((FastBufferWriter)(ref val)).Dispose(); ApplyRevive(deadClientId, reviverClientId); } private static void ApplyRevive(ulong deadClientId, ulong reviverClientId) { PlayerControllerB val = null; if ((Object)(object)StartOfRound.Instance != (Object)null) { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val2 in allPlayerScripts) { if ((Object)(object)val2 != (Object)null && val2.playerClientId == deadClientId) { val = val2; break; } } } if (!((Object)(object)val == (Object)null)) { RoundState.DeadPlayers.Remove(deadClientId); ReviveManager.RevivePlayer(val); AnnounceRevive(deadClientId, reviverClientId, val.playerUsername); } } private static void AnnounceRevive(ulong deadClientId, ulong reviverClientId, string revivedName) { ulong num = (ulong)(((long?)GameNetworkManager.Instance?.localPlayerController?.playerClientId) ?? (-1L)); RoundState.PlayerTeams.TryGetValue(deadClientId, out var value); int value2; bool flag = RoundState.PlayerTeams.TryGetValue(reviverClientId, out value2) && value2 != value; string text = ((value2 < RoundState.TeamNames.Length) ? RoundState.TeamNames[value2] : $"Team {value2}"); int value3; bool flag2 = RoundState.PlayerTeams.TryGetValue(num, out value3) && value3 == value; if (num == deadClientId) { string text2 = (flag ? ("You were brought back by " + text + "!") : "You were brought back to life!"); HUDManager instance = HUDManager.Instance; if (instance != null) { instance.DisplayTip("Revived", text2, false, false, "LC_Tip1"); } } else if (flag2) { string text3 = (flag ? (text + " revived your teammate " + revivedName + "!") : ("Your teammate " + revivedName + " has been brought back to life!")); HUDManager instance2 = HUDManager.Instance; if (instance2 != null) { instance2.DisplayTip("Teammate Revived", text3, false, false, "LC_Tip1"); } } } public static void RequestSpeedBoost(int team) { RequestBuff(0, team); } public static void RequestGroupRevive(int team) { RequestBuff(1, team); } private static void RequestBuff(byte buffType, int team) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) ulong requesterClientId = (ulong)(((long?)GameNetworkManager.Instance?.localPlayerController?.playerClientId) ?? (-1L)); if (IsHost) { HandleBuff(buffType, team, requesterClientId); return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(13, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValueSafe(ref buffType, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref team, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref requesterClientId, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("DrunkerCompany_BuffReq", 0uL, val, (NetworkDelivery)3); ((FastBufferWriter)(ref val)).Dispose(); } private static void HandleBuff(byte buffType, int team, ulong requesterClientId) { if (!IsHost || !RoundState.IsRoundActive || requesterClientId != RoundState.CaptainClientId || !RoundState.TeamHasPlayers(team)) { return; } Terminal val = Object.FindObjectOfType(); if ((Object)(object)val == (Object)null) { return; } switch (buffType) { case 0: if (Config.SpeedBoostEnabled.Value && val.groupCredits >= Config.SpeedBoostCost.Value) { DeductCredits(val, Config.SpeedBoostCost.Value); BroadcastSpeedBoost(Config.SpeedBoostMultiplier.Value, Config.SpeedBoostDuration.Value, team); } break; case 1: if (Config.GroupReviveEnabled.Value && !RoundState.GroupReviveUsed && RoundState.TeamFullyDead(team) && val.groupCredits >= Config.GroupReviveCost.Value) { DeductCredits(val, Config.GroupReviveCost.Value); RoundState.GroupReviveUsed = true; BroadcastGroupRevive(team); } break; } } private static void DeductCredits(Terminal terminal, int cost) { terminal.groupCredits = Mathf.Max(0, terminal.groupCredits - cost); terminal.SyncGroupCreditsClientRpc(terminal.groupCredits, terminal.numberOfItemsInDropship); } private static void BroadcastSpeedBoost(float multiplier, float duration, int team) { //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) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(12, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValueSafe(ref multiplier, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref duration, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref team, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("DrunkerCompany_SpeedBoost", val, (NetworkDelivery)3); ((FastBufferWriter)(ref val)).Dispose(); ApplySpeedBoost(multiplier, duration, team); } private static void OnReceiveSpeedBoost(ulong _, FastBufferReader reader) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) float multiplier = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(ref multiplier, default(ForPrimitives)); float duration = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(ref duration, default(ForPrimitives)); int team = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe(ref team, default(ForPrimitives)); ApplySpeedBoost(multiplier, duration, team); } private static void ApplySpeedBoost(float multiplier, float duration, int team) { ulong key = (ulong)(((long?)GameNetworkManager.Instance?.localPlayerController?.playerClientId) ?? (-1L)); if (RoundState.PlayerTeams.TryGetValue(key, out var value) && value == team) { BuffManager.ApplySpeedBoost(multiplier, duration); } } private static void BroadcastGroupRevive(int team) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0089: 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_00de: Unknown result type (might be due to invalid IL or missing references) List list = new List(); foreach (ulong deadPlayer in RoundState.DeadPlayers) { if (RoundState.PlayerTeams.TryGetValue(deadPlayer, out var value) && value == team) { list.Add(deadPlayer); } } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(8 + list.Count * 8, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValueSafe(ref team, default(ForPrimitives)); int count = list.Count; ((FastBufferWriter)(ref val)).WriteValueSafe(ref count, default(ForPrimitives)); foreach (ulong item in list) { ulong current2 = item; ((FastBufferWriter)(ref val)).WriteValueSafe(ref current2, default(ForPrimitives)); } NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("DrunkerCompany_GroupRevive", val, (NetworkDelivery)3); ((FastBufferWriter)(ref val)).Dispose(); ApplyGroupRevive(team, list.ToArray()); } private static void OnReceiveGroupRevive(ulong _, FastBufferReader reader) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) int team = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe(ref team, default(ForPrimitives)); int num = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe(ref num, default(ForPrimitives)); ulong[] array = new ulong[num]; for (int i = 0; i < num; i++) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref array[i], default(ForPrimitives)); } ApplyGroupRevive(team, array); } private static void ApplyGroupRevive(int team, ulong[] ids) { RoundState.GroupReviveUsed = true; if ((Object)(object)StartOfRound.Instance == (Object)null) { return; } foreach (ulong num in ids) { RoundState.DeadPlayers.Remove(num); RoundState.RevivedPlayers.Add(num); PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val != (Object)null && val.playerClientId == num) { ReviveManager.RevivePlayer(val, recallBodyToShip: true); break; } } } HUDManager instance = HUDManager.Instance; if (instance != null) { instance.DisplayTip("Group Revive", "The Captain brought " + RoundState.TeamName(team) + " back to life!", false, false, "LC_Tip1"); } } private static void HandleClientConnected(ulong clientId) { if (IsHost && RoundState.IsRoundActive && clientId != 0L && (Object)(object)StartOfRound.Instance != (Object)null) { ((MonoBehaviour)StartOfRound.Instance).StartCoroutine(ResyncLateJoiner(clientId)); } } private static IEnumerator ResyncLateJoiner(ulong clientId) { yield return (object)new WaitForSeconds(3f); if (!RoundState.IsRoundActive) { yield break; } if (!RoundState.PlayerTeams.ContainsKey(clientId)) { Dictionary dictionary = new Dictionary(); foreach (KeyValuePair playerTeam in RoundState.PlayerTeams) { if (playerTeam.Value != 0) { dictionary[playerTeam.Value] = ((!dictionary.TryGetValue(playerTeam.Value, out var value)) ? 1 : (value + 1)); } } int num = 1; int num2 = int.MaxValue; foreach (KeyValuePair item in dictionary) { if (item.Value < num2) { num2 = item.Value; num = item.Key; } } RoundState.PlayerTeams[clientId] = num; BroadcastAddPlayer(clientId, num); } SendResyncTo(clientId); Plugin.Logger.LogInfo((object)$"[Resync] Late joiner {clientId} folded into team {RoundState.PlayerTeams[clientId]}."); } private static void BroadcastAddPlayer(ulong clientId, int team) { //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) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(12, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValueSafe(ref clientId, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref team, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("DrunkerCompany_AddPlayer", val, (NetworkDelivery)3); ((FastBufferWriter)(ref val)).Dispose(); ApplyAddPlayer(clientId, team); } private static void OnReceiveAddPlayer(ulong _, FastBufferReader reader) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) ulong clientId = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe(ref clientId, default(ForPrimitives)); int team = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe(ref team, default(ForPrimitives)); ApplyAddPlayer(clientId, team); } private static void ApplyAddPlayer(ulong clientId, int team) { RoundState.PlayerTeams[clientId] = team; SuitManager.ApplyAll(RoundState.PlayerTeams); TeamHUD.Refresh(); } private static void SendResyncTo(ulong clientId) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) List list = new List(); List list2 = new List(); foreach (KeyValuePair playerTeam in RoundState.PlayerTeams) { list.Add(playerTeam.Key); list2.Add(playerTeam.Value); } int[] teamScrapScores = RoundState.TeamScrapScores; List list3 = new List(RoundState.DeadPlayers); int num = 12 + list.Count * 12 + 4 + teamScrapScores.Length * 4 + 4 + list3.Count * 8; FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(num, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValueSafe(ref RoundState.CaptainClientId, default(ForPrimitives)); int count = list.Count; ((FastBufferWriter)(ref val)).WriteValueSafe(ref count, default(ForPrimitives)); for (int i = 0; i < list.Count; i++) { ulong num2 = list[i]; ((FastBufferWriter)(ref val)).WriteValueSafe(ref num2, default(ForPrimitives)); count = list2[i]; ((FastBufferWriter)(ref val)).WriteValueSafe(ref count, default(ForPrimitives)); } count = teamScrapScores.Length; ((FastBufferWriter)(ref val)).WriteValueSafe(ref count, default(ForPrimitives)); int[] array = teamScrapScores; for (count = 0; count < array.Length; count++) { int num3 = array[count]; ((FastBufferWriter)(ref val)).WriteValueSafe(ref num3, default(ForPrimitives)); } count = list3.Count; ((FastBufferWriter)(ref val)).WriteValueSafe(ref count, default(ForPrimitives)); foreach (ulong item in list3) { ulong current2 = item; ((FastBufferWriter)(ref val)).WriteValueSafe(ref current2, default(ForPrimitives)); } NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("DrunkerCompany_Resync", clientId, val, (NetworkDelivery)3); ((FastBufferWriter)(ref val)).Dispose(); } private static void OnReceiveResync(ulong _, FastBufferReader reader) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) ulong num = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe(ref num, default(ForPrimitives)); int num2 = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe(ref num2, default(ForPrimitives)); RoundState.Reset(); RoundState.CaptainClientId = num; RoundState.IsRoundActive = true; int num3 = 0; ulong key = default(ulong); int num4 = default(int); for (int i = 0; i < num2; i++) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref key, default(ForPrimitives)); ((FastBufferReader)(ref reader)).ReadValueSafe(ref num4, default(ForPrimitives)); RoundState.PlayerTeams[key] = num4; if (num4 > num3) { num3 = num4; } } int num5 = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe(ref num5, default(ForPrimitives)); int[] array = new int[num5]; for (int j = 0; j < num5; j++) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref array[j], default(ForPrimitives)); } RoundState.TeamScrapScores = ((array.Length != 0) ? array : new int[num3 + 1]); int num6 = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe(ref num6, default(ForPrimitives)); ulong item = default(ulong); for (int k = 0; k < num6; k++) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref item, default(ForPrimitives)); RoundState.DeadPlayers.Add(item); } RunApplySyncRoundVisuals(num); Plugin.Logger.LogInfo((object)"[Resync] Applied late-join state from host."); } private static void OnReceiveSyncRound(ulong _, FastBufferReader reader) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_0089: Unknown result type (might be due to invalid IL or missing references) ulong captainId = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe(ref captainId, default(ForPrimitives)); int num = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe(ref num, default(ForPrimitives)); ulong[] array = new ulong[num]; for (int i = 0; i < num; i++) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref array[i], default(ForPrimitives)); } int num2 = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe(ref num2, default(ForPrimitives)); int[] array2 = new int[num2]; for (int j = 0; j < num2; j++) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref array2[j], default(ForPrimitives)); } ApplySyncRound(captainId, array, array2); } private static void OnReceiveDeath(ulong _, FastBufferReader reader) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) ulong clientId = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe(ref clientId, default(ForPrimitives)); bool isFirst = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref isFirst, default(ForPrimitives)); bool isCaptain = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref isCaptain, default(ForPrimitives)); int num = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe(ref num, default(ForPrimitives)); byte[] bytes = new byte[num]; ((FastBufferReader)(ref reader)).ReadBytesSafe(ref bytes, num, 0); ApplyDeath(clientId, Encoding.UTF8.GetString(bytes), isFirst, isCaptain); } private static void OnReceiveDeathReport(ulong _, FastBufferReader reader) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) ulong clientId = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe(ref clientId, default(ForPrimitives)); bool diedInShip = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref diedInShip, default(ForPrimitives)); int num = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe(ref num, default(ForPrimitives)); byte[] bytes = new byte[num]; ((FastBufferReader)(ref reader)).ReadBytesSafe(ref bytes, num, 0); HandleDeath(clientId, Encoding.UTF8.GetString(bytes), diedInShip); } private static void OnReceiveScores(ulong _, FastBufferReader reader) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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) int num = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe(ref num, default(ForPrimitives)); int[] array = new int[num]; for (int i = 0; i < num; i++) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref array[i], default(ForPrimitives)); } RoundState.TeamScrapScores = array; } private static void OnReceiveRoundEnd(ulong _, FastBufferReader reader) { ApplyRoundEnd(); } private static void OnReceiveReviveReport(ulong _, FastBufferReader reader) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) ulong deadClientId = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe(ref deadClientId, default(ForPrimitives)); ulong reviverClientId = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe(ref reviverClientId, default(ForPrimitives)); HandleRevive(deadClientId, reviverClientId); } private static void OnReceiveRevive(ulong _, FastBufferReader reader) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) ulong deadClientId = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe(ref deadClientId, default(ForPrimitives)); ulong reviverClientId = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe(ref reviverClientId, default(ForPrimitives)); ApplyRevive(deadClientId, reviverClientId); } private static void OnReceiveScrapReport(ulong _, FastBufferReader reader) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) int teamIndex = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe(ref teamIndex, default(ForPrimitives)); int value = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe(ref value, default(ForPrimitives)); ulong netId = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe(ref netId, default(ForPrimitives)); AccumulateScrap(teamIndex, value, netId); } private static void OnReceiveBuffReq(ulong _, FastBufferReader reader) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) byte buffType = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe(ref buffType, default(ForPrimitives)); int team = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe(ref team, default(ForPrimitives)); ulong requesterClientId = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe(ref requesterClientId, default(ForPrimitives)); HandleBuff(buffType, team, requesterClientId); } private static void ApplySyncRound(ulong captainId, ulong[] playerIds, int[] teamIndices) { RoundState.Reset(); BuffManager.ClearSpeedBoost(); RoundState.CaptainClientId = captainId; RoundState.IsRoundActive = true; int num = 0; for (int i = 0; i < playerIds.Length; i++) { RoundState.PlayerTeams[playerIds[i]] = teamIndices[i]; if (teamIndices[i] > num) { num = teamIndices[i]; } } RoundState.TeamScrapScores = new int[num + 1]; if (IsHost) { SnapshotExistingShipScrap(); if ((Object)(object)StartOfRound.Instance != (Object)null) { ((MonoBehaviour)StartOfRound.Instance).StartCoroutine(RevealAfterDelay(captainId)); } else { BroadcastReveal(captainId); } } } private static void SnapshotExistingShipScrap() { GrabbableObject[] array = Object.FindObjectsOfType(); foreach (GrabbableObject val in array) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.itemProperties == (Object)null) && val.itemProperties.isScrap && (val.isInShipRoom || val.isInElevator) && !((Object)(object)((NetworkBehaviour)val).NetworkObject == (Object)null) && ((NetworkBehaviour)val).NetworkObject.IsSpawned) { RoundState.CountedScrap.Add(((NetworkBehaviour)val).NetworkObjectId); } } } private static IEnumerator RevealAfterDelay(ulong captainId) { yield return (object)new WaitForSeconds(5f); BroadcastReveal(captainId); } private static void BroadcastReveal(ulong captainId) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(8, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValueSafe(ref captainId, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("DrunkerCompany_Reveal", val, (NetworkDelivery)3); ((FastBufferWriter)(ref val)).Dispose(); if (IsHost && !_walkiesSpawnedThisRound && (Object)(object)StartOfRound.Instance != (Object)null) { _walkiesSpawnedThisRound = true; ((MonoBehaviour)StartOfRound.Instance).StartCoroutine(WalkieSpawner.SpawnWhenLanded(Config.WalkieCount.Value)); } RunApplySyncRoundVisuals(captainId); } private static void OnReceiveReveal(ulong _, FastBufferReader reader) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) ulong captainId = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe(ref captainId, default(ForPrimitives)); RunApplySyncRoundVisuals(captainId); } private static void RunApplySyncRoundVisuals(ulong captainId) { SuitManager.ApplyAll(RoundState.PlayerTeams); TeamHUD.Refresh(); PosterSpawner.Spawn(); ulong num = (ulong)(((long?)GameNetworkManager.Instance?.localPlayerController?.playerClientId) ?? (-1L)); string teamName = RoundState.GetTeamName(num); string text = "Unknown"; if ((Object)(object)StartOfRound.Instance != (Object)null) { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val != (Object)null && val.playerClientId == captainId) { text = val.playerUsername; break; } } } string text2 = ((num == captainId) ? "You are the Captain! Only you can purchase items from the shop." : ("You are on: " + teamName + "\nCaptain this round: " + text)); HUDManager instance = HUDManager.Instance; if (instance != null) { instance.DisplayTip("Round Started", text2, false, false, "LC_Tip1"); } } private static void ApplyDeath(ulong clientId, string playerName, bool isFirst, bool isCaptain) { RoundState.DeadPlayers.Add(clientId); if (isCaptain) { string text = (isFirst ? (playerName + ", the Captain, is the FIRST to fall! The monsters grow bold.") : (playerName + ", the Captain, has died! The monsters are growing bold.")); HUDManager instance = HUDManager.Instance; if (instance != null) { instance.DisplayTip("Captain Down", text, true, false, "LC_Tip1"); } bool flag = (((long?)GameNetworkManager.Instance?.localPlayerController?.playerClientId) ?? (-1L)) == (long)clientId; Plugin.Logger.LogInfo((object)($"[Mirage] Captain died. This client is the captain: {flag}. " + $"Local Mirage recordings: {MirageBridge.CountLocalRecordings()}")); } else if (isFirst) { HUDManager instance2 = HUDManager.Instance; if (instance2 != null) { instance2.DisplayTip("First Casualty", playerName + " was the first to fall this round!", true, false, "LC_Tip1"); } } } private static void ApplyRoundEnd() { RoundState.IsRoundActive = false; TeamHUD.Hide(); } } } namespace DrunkerCompany.Items { public static class WalkieSpawner { private static Item? _walkieItem; public static IEnumerator SpawnWhenLanded(int count) { StartOfRound sor = StartOfRound.Instance; if ((Object)(object)sor == (Object)null || (Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsHost) { yield break; } float timeout = 30f; while (!sor.shipHasLanded && timeout > 0f) { timeout -= Time.deltaTime; yield return null; } yield return (object)new WaitForSeconds(1f); int placed = 0; for (int attempt = 0; attempt < 5; attempt++) { if (placed >= count) { break; } placed += SpawnByTerminal(count - placed); if (placed >= count) { break; } Plugin.Logger.LogWarning((object)$"[WalkieSpawner] Placed {placed}/{count} so far; retrying the rest in 3s."); yield return (object)new WaitForSeconds(3f); } } public static int SpawnByTerminal(int count) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsHost) { return count; } StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null) { return 0; } Item val = FindWalkieItem(); if ((Object)(object)val == (Object)null || (Object)(object)val.spawnPrefab == (Object)null) { Plugin.Logger.LogWarning((object)"[WalkieSpawner] Could not find the Walkie-talkie item."); return 0; } Terminal val2 = Object.FindObjectOfType(); if ((Object)(object)val2 == (Object)null) { Plugin.Logger.LogWarning((object)"[WalkieSpawner] Terminal not found — cannot place walkies."); return 0; } Vector3 position = ((Component)val2).transform.position; Vector3 val3 = (((Object)(object)instance.elevatorTransform != (Object)null) ? (instance.elevatorTransform.position - position) : Vector3.forward); val3.y = 0f; val3 = ((((Vector3)(ref val3)).sqrMagnitude > 0.001f) ? ((Vector3)(ref val3)).normalized : Vector3.forward); Vector3 val4 = Vector3.Cross(Vector3.up, val3); Vector3 val5 = position + val3 * 0.8f; int collidersAndRoomMaskAndDefault = instance.collidersAndRoomMaskAndDefault; int num = 0; RaycastHit val6 = default(RaycastHit); for (int i = 0; i < count; i++) { float num2 = ((float)i - (float)(count - 1) * 0.5f) * 0.45f; if (Physics.Raycast(val5 + val4 * num2 + Vector3.up * 0.6f, Vector3.down, ref val6, 3f, collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) && (Object)(object)SpawnWalkieAt(val, ((RaycastHit)(ref val6)).point, instance) != (Object)null) { num++; } } if (num < count) { Plugin.Logger.LogWarning((object)$"[WalkieSpawner] Placed only {num}/{count} walkie-talkie(s) by the terminal."); } else { Plugin.Logger.LogInfo((object)$"[WalkieSpawner] Placed {num} brand-new walkie-talkie(s) on the floor by the terminal."); } return num; } private static NetworkObject? SpawnWalkieAt(Item item, Vector3 floorPos, StartOfRound sor) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0077: Expected O, but got Unknown Vector3 val = floorPos + Vector3.up * 0.1f; GameObject val2 = Object.Instantiate(item.spawnPrefab, val, Quaternion.identity, sor.elevatorTransform); GrabbableObject component = val2.GetComponent(); if ((Object)(object)component == (Object)null) { Object.Destroy((Object)(object)val2); return null; } component.fallTime = 0f; component.scrapPersistedThroughRounds = false; component.isInElevator = true; component.isInShipRoom = true; component.insertedBattery = new Battery(false, 1f); NetworkObject networkObject = ((NetworkBehaviour)component).NetworkObject; if ((Object)(object)networkObject == (Object)null) { Object.Destroy((Object)(object)val2); return null; } networkObject.Spawn(false); component.SyncBatteryServerRpc(100); return networkObject; } private static Item? FindWalkieItem() { if ((Object)(object)_walkieItem != (Object)null) { return _walkieItem; } List list = StartOfRound.Instance?.allItemsList?.itemsList; if (list == null) { return null; } foreach (Item item in list) { if ((Object)(object)item != (Object)null && item.itemName != null && item.itemName.ToLower().Contains("walkie")) { _walkieItem = item; return item; } } return null; } } } namespace DrunkerCompany.Enemies { public static class MaskedSpawner { private static EnemyType? _maskedType; private static readonly Random _rng = new Random(); public static void SpawnOutsideAfterCaptainDeath() { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsHost) { return; } RoundManager instance = RoundManager.Instance; if ((Object)(object)instance == (Object)null) { return; } EnemyType val = FindMaskedType(); if ((Object)(object)val == (Object)null) { Plugin.Logger.LogWarning((object)"[MaskedSpawner] Could not find the Masked EnemyType."); return; } instance.GetOutsideAINodes(true); GameObject[] outsideAINodes = instance.outsideAINodes; if (outsideAINodes == null || outsideAINodes.Length == 0) { Plugin.Logger.LogWarning((object)"[MaskedSpawner] No outside AI nodes to spawn at."); return; } int num = ResolveCaptainIndex(); Plugin.Logger.LogInfo((object)$"[MaskedSpawner] Captain index resolved to {num} (clientId {RoundState.CaptainClientId})."); int num2 = Mathf.Max(0, Config.MaskedCount.Value); int num3 = 0; NetworkObject val4 = default(NetworkObject); for (int i = 0; i < num2; i++) { GameObject val2 = outsideAINodes[_rng.Next(0, outsideAINodes.Length)]; if ((Object)(object)val2 == (Object)null) { continue; } Vector3 randomNavMeshPositionInBoxPredictable = instance.GetRandomNavMeshPositionInBoxPredictable(val2.transform.position, 10f, default(NavMeshHit), _rng, -1, 1f); float num4 = (float)(_rng.NextDouble() * 360.0); NetworkObjectReference val3 = instance.SpawnEnemyGameObject(randomNavMeshPositionInBoxPredictable, num4, -1, val); num3++; if (((NetworkObjectReference)(ref val3)).TryGet(ref val4, (NetworkManager)null) && (Object)(object)val4 != (Object)null) { EnemyAI component = ((Component)val4).GetComponent(); if ((Object)(object)component != (Object)null) { component.SetEnemyOutside(true); } DrunkerMessages.BroadcastMaskedSpawned(val4.NetworkObjectId); ((MonoBehaviour)StartOfRound.Instance).StartCoroutine(ImpersonateCaptain(((Component)val4).gameObject, num)); } else { Plugin.Logger.LogWarning((object)"[MaskedSpawner] Could not resolve spawned enemy NetworkObject."); } } Plugin.Logger.LogInfo((object)string.Format("[MaskedSpawner] Spawned {0} Masked enem{1} outside after the captain died.", num3, (num3 == 1) ? "y" : "ies")); } public static IEnumerator MarkOutsideWhenReplicated(ulong netId) { NetworkManager singleton = NetworkManager.Singleton; NetworkSpawnManager spawnManager = ((singleton != null) ? singleton.SpawnManager : null); if (spawnManager == null) { yield break; } float timeout = 10f; EnemyAI ai = null; while (timeout > 0f) { if (spawnManager.SpawnedObjects.TryGetValue(netId, out var value) && (Object)(object)value != (Object)null) { ai = ((Component)value).GetComponent(); if ((Object)(object)ai != (Object)null) { break; } } timeout -= Time.deltaTime; yield return null; } if (!((Object)(object)ai == (Object)null)) { ai.SetEnemyOutside(true); yield return (object)new WaitForSeconds(1.5f); if ((Object)(object)ai != (Object)null) { ai.SetEnemyOutside(true); } } } private static int ResolveCaptainIndex() { PlayerControllerB[] array = StartOfRound.Instance?.allPlayerScripts; if (array == null) { return -1; } for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i] != (Object)null && array[i].playerClientId == RoundState.CaptainClientId) { return i; } } return -1; } private static IEnumerator ImpersonateCaptain(GameObject enemy, int captainIndex) { yield return (object)new WaitForSeconds(1f); if (!((Object)(object)enemy == (Object)null)) { MirageBridge.LogComponents(enemy); if (captainIndex >= 0) { MirageBridge.ForceMimic(enemy, captainIndex); } StripEmoteController(enemy); EnemyAI component = enemy.GetComponent(); if ((Object)(object)component != (Object)null) { component.SetEnemyOutside(true); } } } private static void StripEmoteController(GameObject enemy) { MonoBehaviour[] componentsInChildren = enemy.GetComponentsInChildren(true); foreach (MonoBehaviour val in componentsInChildren) { if ((Object)(object)val != (Object)null && ((object)val).GetType().Name == "EmoteControllerMaskedEnemy") { Object.Destroy((Object)(object)val); Plugin.Logger.LogInfo((object)"[MaskedSpawner] Stripped TooManyEmotes emote controller from our masked enemy."); break; } } } private static EnemyType? FindMaskedType() { if ((Object)(object)_maskedType != (Object)null) { return _maskedType; } EnemyType val = null; EnemyType[] array = Resources.FindObjectsOfTypeAll(); foreach (EnemyType val2 in array) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.enemyPrefab == (Object)null) && !((Object)(object)val2.enemyPrefab.GetComponentInChildren() == (Object)null)) { if (val == null) { val = val2; } if (PrefabHasMimicPlayer(val2.enemyPrefab)) { _maskedType = val2; Plugin.Logger.LogInfo((object)("[MaskedSpawner] Masked EnemyType resolved (Mirage-instrumented): '" + val2.enemyName + "'.")); return val2; } } } if ((Object)(object)val != (Object)null) { Plugin.Logger.LogWarning((object)("[MaskedSpawner] Masked EnemyType '" + val.enemyName + "' has no Mirage MimicPlayer on its prefab — Mirage may be absent or instruments a different prefab.")); } return val; } private static bool PrefabHasMimicPlayer(GameObject prefab) { MonoBehaviour[] componentsInChildren = prefab.GetComponentsInChildren(true); foreach (MonoBehaviour val in componentsInChildren) { if ((Object)(object)val != (Object)null && ((object)val).GetType().Name == "MimicPlayer") { return true; } } return false; } } internal static class MirageBridge { public static void ForceMimic(GameObject enemy, int playerIndex) { try { Component val = FindComponent(enemy, "MimicPlayer"); if (!((Object)(object)val == (Object)null)) { MethodInfo method = ((object)val).GetType().GetMethod("MimicPlayer", new Type[1] { typeof(int) }); if (method == null) { Plugin.Logger.LogWarning((object)"[MirageBridge] MimicPlayer(int) not found."); return; } method.Invoke(val, new object[1] { playerIndex }); Plugin.Logger.LogInfo((object)$"[MirageBridge] Masked enemy forced to mimic player index {playerIndex}."); } } catch (Exception ex) { Plugin.Logger.LogWarning((object)("[MirageBridge] ForceMimic failed: " + ex.Message)); } } public static void LogComponents(GameObject enemy) { if ((Object)(object)enemy == (Object)null) { Plugin.Logger.LogWarning((object)"[MirageBridge] enemy is null."); return; } StringBuilder stringBuilder = new StringBuilder(); MonoBehaviour[] componentsInChildren = enemy.GetComponentsInChildren(true); foreach (MonoBehaviour val in componentsInChildren) { if ((Object)(object)val != (Object)null) { stringBuilder.Append(((object)val).GetType().Name).Append(' '); } } Plugin.Logger.LogInfo((object)$"[MirageBridge] '{((Object)enemy).name}' behaviours: {stringBuilder}"); } public static int CountLocalRecordings() { try { string recordingDirectory = GetRecordingDirectory(); if (recordingDirectory == null || !Directory.Exists(recordingDirectory)) { return -1; } return Directory.GetFiles(recordingDirectory, "*.opus").Length; } catch (Exception ex) { Plugin.Logger.LogWarning((object)("[MirageBridge] CountLocalRecordings failed: " + ex.Message)); return -1; } } private static string? GetRecordingDirectory() { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (assembly.GetName().Name.StartsWith("Mirage")) { PropertyInfo propertyInfo = assembly.GetType("Mirage.Domain.Directory")?.GetProperty("recordingDirectory", BindingFlags.Static | BindingFlags.Public); if (propertyInfo != null) { return propertyInfo.GetValue(null) as string; } } } return null; } private static Component? FindComponent(GameObject go, string typeName) { if ((Object)(object)go == (Object)null) { return null; } MonoBehaviour[] components = go.GetComponents(); foreach (MonoBehaviour val in components) { if ((Object)(object)val != (Object)null && ((object)val).GetType().Name == typeName) { return (Component?)(object)val; } } return null; } } } namespace DrunkerCompany.Decor { public static class PosterSpawner { private class ShipPin : MonoBehaviour { private Transform? _ship; private Vector3 _localPos; private Quaternion _localRot; public void Pin(Transform ship) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) _ship = ship; _localPos = ship.InverseTransformPoint(((Component)this).transform.position); _localRot = Quaternion.Inverse(ship.rotation) * ((Component)this).transform.rotation; } private void LateUpdate() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_ship == (Object)null)) { ((Component)this).transform.position = _ship.TransformPoint(_localPos); ((Component)this).transform.rotation = _ship.rotation * _localRot; } } } private const float PosterHeight = 3.4f; private const float WallGap = 0.2f; private static readonly Vector3 LocalAnchor = new Vector3(-1.2f, 2f, -3.6f); private static readonly Vector3 LocalFace = new Vector3(0f, 0f, -1f); private static GameObject? _poster; private static Texture2D? _tex; public static void Spawn() { try { SpawnInternal(); } catch (Exception arg) { Plugin.Logger.LogError((object)$"[Poster] Spawn failed: {arg}"); } } public static IEnumerator SpawnSoon() { for (int attempt = 0; attempt < 5; attempt++) { if (!((Object)(object)_poster == (Object)null)) { break; } yield return (object)new WaitForSeconds(2f); Spawn(); } } private static void SpawnInternal() { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Expected O, but got Unknown //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) if (!Config.PosterEnabled.Value) { return; } if ((Object)(object)_poster != (Object)null) { Plugin.Logger.LogInfo((object)"[Poster] Already mounted; skipping."); return; } StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.elevatorTransform == (Object)null) { Plugin.Logger.LogWarning((object)"[Poster] StartOfRound/elevatorTransform not ready yet — will retry at reveal."); return; } Texture2D val = LoadTexture(); if ((Object)(object)val == (Object)null) { Plugin.Logger.LogWarning((object)"[Poster] No embedded PNG found — add one under Assets/. Skipping poster."); return; } Transform elevatorTransform = instance.elevatorTransform; int collidersAndRoomMaskAndDefault = instance.collidersAndRoomMaskAndDefault; float num = (float)((Texture)val).width / (float)((Texture)val).height; float num2 = 3.4f * num; Vector3 val2 = LocalFace; Vector3 val3 = elevatorTransform.TransformDirection(((Vector3)(ref val2)).normalized); Vector3 val4 = elevatorTransform.TransformPoint(LocalAnchor); val2 = Vector3.Cross(Vector3.up, val3); Vector3 normalized = ((Vector3)(ref val2)).normalized; float num3 = float.MaxValue; bool flag = false; RaycastHit val5 = default(RaycastHit); for (int i = -3; i <= 3; i++) { if (Physics.Raycast(val4 + normalized * ((float)i * (num2 / 6f)), -val3, ref val5, 4f, collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) && ((RaycastHit)(ref val5)).distance < num3) { num3 = ((RaycastHit)(ref val5)).distance; flag = true; } } if (!flag) { Plugin.Logger.LogWarning((object)"[Poster] wall-snap rays missed (ship geometry not ready?) — will retry."); return; } Vector3 val6 = val4 - val3 * (num3 - 0.2f); Material val7 = BuildMaterial(val); GameObject val8 = new GameObject("DrunkerCompanyPoster"); val8.transform.position = val6; val8.transform.rotation = Quaternion.LookRotation(val3, Vector3.up); CreateFace(val8.transform, val7, num2, 3.4f, back: false); CreateFace(val8.transform, val7, num2, 3.4f, back: true); val8.AddComponent().Pin(elevatorTransform); _poster = val8; Plugin.Logger.LogInfo((object)($"[Poster] Mounted {((Texture)val).width}x{((Texture)val).height} image at {val6} (local {elevatorTransform.InverseTransformPoint(val6)}), " + $"size {num2:0.0}x{3.4f:0.0}m, faceDir={val3}, shader '{((Object)val7.shader).name}'.")); } private static void CreateFace(Transform parent, Material mat, float w, float h, bool back) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)obj).name = (back ? "PosterBack" : "PosterFront"); Collider component = obj.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } ((Renderer)obj.GetComponent()).material = mat; obj.transform.SetParent(parent, false); obj.transform.localPosition = new Vector3(0f, 0f, back ? (-0.006f) : 0.006f); obj.transform.localRotation = (back ? Quaternion.Euler(0f, 180f, 0f) : Quaternion.identity); obj.transform.localScale = new Vector3(w, h, 1f); } private static Texture2D? LoadTexture() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown if ((Object)(object)_tex != (Object)null) { return _tex; } byte[] array = ReadEmbeddedPng(); if (array == null) { return null; } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val, array)) { Plugin.Logger.LogWarning((object)"[Poster] Embedded PNG failed to decode."); return null; } ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)1; val.Apply(); _tex = val; return val; } private static byte[]? ReadEmbeddedPng() { Assembly assembly = typeof(PosterSpawner).Assembly; string text = null; string[] manifestResourceNames = assembly.GetManifestResourceNames(); foreach (string text2 in manifestResourceNames) { if (text2.EndsWith(".png", StringComparison.OrdinalIgnoreCase)) { text = text2; break; } } if (text == null) { return null; } using Stream stream = assembly.GetManifestResourceStream(text); if (stream == null) { return null; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); return memoryStream.ToArray(); } private static Material BuildMaterial(Texture2D tex) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) Material val = CloneShipMaterialInstance(); string[] array = new string[3] { "_BaseColorMap", "_MainTex", "_UnlitColorMap" }; foreach (string text in array) { if (val.HasProperty(text)) { val.SetTexture(text, (Texture)(object)tex); val.SetTextureScale(text, Vector2.one); val.SetTextureOffset(text, Vector2.zero); } } array = new string[3] { "_BaseColor", "_UnlitColor", "_Color" }; foreach (string text2 in array) { if (val.HasProperty(text2)) { val.SetColor(text2, Color.white); } } val.mainTexture = (Texture)(object)tex; val.mainTextureScale = Vector2.one; val.mainTextureOffset = Vector2.zero; array = new string[6] { "_NormalMap", "_BumpMap", "_MaskMap", "_DetailMap", "_DetailNormalMap", "_EmissiveColorMap" }; foreach (string text3 in array) { if (val.HasProperty(text3)) { val.SetTexture(text3, (Texture)null); } } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", 0f); } if (val.HasProperty("_Smoothness")) { val.SetFloat("_Smoothness", 0.05f); } return val; } private static Material CloneShipMaterialInstance() { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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 Transform val = StartOfRound.Instance?.elevatorTransform; if ((Object)(object)val != (Object)null) { MeshRenderer[] componentsInChildren = ((Component)val).GetComponentsInChildren(); foreach (MeshRenderer val2 in componentsInChildren) { Material val3 = (((Object)(object)val2 != (Object)null) ? ((Renderer)val2).sharedMaterial : null); if ((Object)(object)val3 != (Object)null && (Object)(object)val3.shader != (Object)null && ((Object)val3.shader).name.IndexOf("Lit", StringComparison.OrdinalIgnoreCase) >= 0) { return new Material(val3); } } } return new Material(Shader.Find("HDRP/Lit") ?? Shader.Find("Standard")); } } } namespace DrunkerCompany.Buffs { public static class BuffManager { private static bool _speedActive; private static float _appliedMultiplier = 1f; private static int _token; public static void ApplySpeedBoost(float multiplier, float duration) { StartOfRound instance = StartOfRound.Instance; PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if (!((Object)(object)instance == (Object)null) && !((Object)(object)val == (Object)null) && !_speedActive && !(multiplier <= 0f)) { ((MonoBehaviour)instance).StartCoroutine(SpeedRoutine(val, multiplier, duration, ++_token)); } } private static IEnumerator SpeedRoutine(PlayerControllerB player, float multiplier, float duration, int token) { _speedActive = true; _appliedMultiplier = multiplier; player.movementSpeed *= multiplier; HUDManager instance = HUDManager.Instance; if (instance != null) { instance.DisplayTip("Speed Boost", $"The Captain juiced the crew — run! ({duration:0}s)", false, false, "LC_Tip1"); } yield return (object)new WaitForSeconds(duration); if (token == _token) { ClearSpeedBoost(player); } } public static void ClearSpeedBoost(PlayerControllerB? player = null) { if (_speedActive) { _token++; if (player == null) { player = GameNetworkManager.Instance?.localPlayerController; } if ((Object)(object)player != (Object)null && _appliedMultiplier > 0f) { PlayerControllerB? obj = player; obj.movementSpeed /= _appliedMultiplier; } _appliedMultiplier = 1f; _speedActive = false; } } } }