Decompiled source of LethalCompanyBetterScaling v1.4.0

LethalCompanyScalingMaster.dll

Decompiled a year ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using LC_API.ServerAPI;
using LethalCompanyModV2.Component;
using LethalCompanyScalingMaster;
using LethalCompanyScalingMaster.Component;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LethalCompanyScalingMaster")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A mod for variable and configurable scaling based on the amount of players in game. Fully customaizable and compatible with biggelobbies and only the host needs it.")]
[assembly: AssemblyFileVersion("1.4.0.0")]
[assembly: AssemblyInformationalVersion("1.4.0")]
[assembly: AssemblyProduct("LethalCompanyScalingMaster")]
[assembly: AssemblyTitle("LethalCompanyScalingMaster")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.4.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public static class NetworkManagerPatch
{
}
namespace LethalCompanyModV2.Patches
{
	[HarmonyPatch(typeof(TimeOfDay))]
	[HarmonyPatch("SetNewProfitQuota")]
	internal class QuotaPatch
	{
		private static bool Prefix()
		{
			TimeOfDay instance = TimeOfDay.Instance;
			Debug.Log((object)"SetNewProfitQuotaPatch");
			instance.timesFulfilledQuota++;
			int num = instance.quotaFulfilled - instance.profitQuota;
			float num2 = Mathf.Clamp(1f + (float)instance.timesFulfilledQuota * ((float)instance.timesFulfilledQuota / instance.quotaVariables.increaseSteepness), 0f, 10000f);
			num2 = instance.quotaVariables.baseIncrease * num2;
			instance.profitQuota = (int)Mathf.Clamp((float)instance.profitQuota + num2, 0f, 1E+09f);
			instance.quotaFulfilled = 0;
			_ = instance.totalTime;
			_ = instance.quotaVariables.deadlineDaysAmount;
			int num3 = num / 5 + 15 * instance.daysUntilDeadline;
			Debug.Log((object)"Syncing new profit quota!");
			TimeOfDay.Instance.SyncNewProfitQuotaClientRpc(instance.profitQuota, num3, instance.timesFulfilledQuota);
			return false;
		}
	}
}
namespace LethalCompanyModV2.Component
{
	public class ControlManager : MonoBehaviour
	{
		private bool _isMenuOpen;

		private GUIManager _guiManager;

		private bool isInitialized;

		public void Awake()
		{
			Debug.LogWarning((object)"Control Manager Started");
			_guiManager = new GUIManager();
		}

		public void Update()
		{
			if (!isInitialized && !isInitialized && (Object)(object)StartOfRound.Instance != (Object)null && Plugin.GetConnectedPlayers() == 1 && StartOfRound.Instance.fullyLoadedPlayers.Count > 0)
			{
				Debug.Log((object)("Fully loaded players count: " + StartOfRound.Instance.fullyLoadedPlayers.Count));
				((MonoBehaviour)this).Invoke("InitializeFunctions", 2f);
				isInitialized = true;
			}
			if (Keyboard.current.ctrlKey.isPressed && ((ButtonControl)Keyboard.current.mKey).wasPressedThisFrame && Plugin.Host)
			{
				Debug.Log((object)"Ctrl key held down and 'm' key pressed - Triggering Method2");
				Debug.Log((object)("Plugin Host: " + Plugin.Host));
				ToggleMenu();
			}
		}

		private void InitializeFunctions()
		{
			ToggleMenu();
		}

		private void ToggleMenu()
		{
			if (Plugin.Host)
			{
				_isMenuOpen = !_isMenuOpen;
				if (_isMenuOpen)
				{
					Debug.Log((object)"Opening Menu...");
					Cursor.lockState = (CursorLockMode)0;
					Cursor.visible = true;
				}
				else
				{
					Debug.Log((object)"Closing Menu...");
					Cursor.lockState = (CursorLockMode)1;
					Cursor.visible = false;
				}
			}
		}

		private void OnGUI()
		{
			if (_isMenuOpen)
			{
				_guiManager.OnGUI();
			}
		}
	}
	public class GUIManager
	{
		public static TimeOfDay _tod;

		private bool _initialized;

		public static string _playerCountQuotaModifier = "10";

		public static string _baseQuota = "120";

		public static string _baseIncreaseInput = "80";

		public static float _quotaIncreaseSteepness = 8.5f;

		public static int _deathPenalty = 20;

		public static string _daysUntilDeadlineInput = "4";

		private bool _enableAutoUpdatedScaling = true;

		private string _perPlayerCredits = "15";

		public static int _totalStartingCredits = 60;

		private GUIStyle _currentStyle;

		private GUIStyle _textFieldStyle;

		private GUIStyle _titleLabelStyle;

		private GUIStyle _headerLabelStyle;

		private bool _showSideMenu;

		public void OnGUI()
		{
			//IL_0022: 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_05fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0656: Unknown result type (might be due to invalid IL or missing references)
			//IL_06db: Unknown result type (might be due to invalid IL or missing references)
			if (!_initialized)
			{
				Init();
			}
			GUILayout.BeginArea(new Rect(10f, 35f, 500f, 600f));
			GUI.Box(new Rect(0f, 0f, 520f, 600f), "", _currentStyle);
			GUILayout.Label("LC - Better Quota Scaler", _headerLabelStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Label("(CTRL + M TO TOGGLE)", Array.Empty<GUILayoutOption>());
			GUILayout.Label("Quota Settings", _titleLabelStyle, Array.Empty<GUILayoutOption>());
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("Starting Quota", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) });
			GUILayout.Label("=", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(15f) });
			GUILayout.Label("Base Quota", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) });
			GUILayout.Label("+", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(15f) });
			GUILayout.Label("(", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(15f) });
			GUILayout.Label("Player Count", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) });
			GUILayout.Label("X", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(15f) });
			GUILayout.Label("Player Count Modifier", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(125f) });
			GUILayout.Label(")", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(15f) });
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (float.TryParse(_baseQuota, out var result) && float.TryParse(_playerCountQuotaModifier, out var result2))
			{
				GUILayout.Label(((int)(result + (float)Plugin.GetConnectedPlayers() * result2)).ToString(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) });
			}
			GUILayout.Label("=", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(15f) });
			_baseQuota = FilterNumericInput(GUILayout.TextField(_baseQuota, _textFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }));
			GUILayout.Label("+", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(15f) });
			GUILayout.Label("(", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(15f) });
			GUILayout.Label(Plugin.GetConnectedPlayers().ToString(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) });
			GUILayout.Label("X", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(15f) });
			_playerCountQuotaModifier = FilterNumericInput(GUILayout.TextField(_playerCountQuotaModifier, _textFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(125f) }));
			GUILayout.Label(")", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(15f) });
			GUILayout.EndHorizontal();
			GUILayout.EndVertical();
			if (float.TryParse(_baseQuota, out var result3) && float.TryParse(_playerCountQuotaModifier, out var result4))
			{
				GUILayout.Label("Starting Profit Quota = " + (int)(result3 + (float)Plugin.GetConnectedPlayers() * result4), Array.Empty<GUILayoutOption>());
			}
			GUILayout.Width(400f);
			GUILayout.Label("Quota increase steepness: " + _quotaIncreaseSteepness, Array.Empty<GUILayoutOption>());
			_quotaIncreaseSteepness = Mathf.Round(GUILayout.HorizontalSlider(_quotaIncreaseSteepness, 0f, 10f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) }) * 2f) / 2f;
			GUILayout.Label("Quota increase base increase value: " + _tod.quotaVariables.baseIncrease, Array.Empty<GUILayoutOption>());
			_baseIncreaseInput = FilterNumericInput(GUILayout.TextField(_baseIncreaseInput, _textFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) }));
			GUILayout.Label("Deadline settings", _titleLabelStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Label("Deadline: " + _tod.daysUntilDeadline, Array.Empty<GUILayoutOption>());
			_daysUntilDeadlineInput = FilterNumericInput(GUILayout.TextField(_daysUntilDeadlineInput, _textFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) }));
			GUILayout.Label("Death Penalty Settings", _titleLabelStyle, Array.Empty<GUILayoutOption>());
			_deathPenalty = Mathf.RoundToInt(GUILayout.HorizontalSlider((float)_deathPenalty / 100f, 0f, 1f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) }) * 100f);
			string text = _deathPenalty + "%";
			GUILayout.Label("Death Penalty: " + text, Array.Empty<GUILayoutOption>());
			GUILayout.Label("Per Player Death Penalty: " + text, Array.Empty<GUILayoutOption>());
			GUILayout.Label("Max percentage of money you can lose is " + (_deathPenalty * Plugin.GetConnectedPlayers()).ToString("0.00") + "%", Array.Empty<GUILayoutOption>());
			GUILayout.Label("Credit/Funds settings", _titleLabelStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Label("Per Player Starting Credits: " + _perPlayerCredits, Array.Empty<GUILayoutOption>());
			_perPlayerCredits = FilterNumericInput(GUILayout.TextField(_perPlayerCredits, _textFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) }));
			if (float.TryParse(_perPlayerCredits, out var result5))
			{
				_totalStartingCredits = (int)((float)Plugin.GetConnectedPlayers() * result5);
				GUILayout.Label("Total Starting credits with these settings " + _totalStartingCredits, Array.Empty<GUILayoutOption>());
			}
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUI.backgroundColor = (_enableAutoUpdatedScaling ? Color.green : Color.red);
			if (GUILayout.Button("Auto Update on player join: " + (_enableAutoUpdatedScaling ? "Enabled" : "Disabled"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(250f) }))
			{
				_enableAutoUpdatedScaling = !_enableAutoUpdatedScaling;
				Plugin.AutoUpdateQuota = _enableAutoUpdatedScaling;
			}
			GUI.backgroundColor = Color.white;
			if (GUILayout.Button("Save values", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(250f) }))
			{
				Plugin.SaveValues();
			}
			GUILayout.EndHorizontal();
			if (GUILayout.Button("Show Calculated Values", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(500f) }))
			{
				_showSideMenu = !_showSideMenu;
			}
			GUILayout.EndArea();
			if (_showSideMenu)
			{
				GUILayout.BeginArea(new Rect(560f, 10f, 200f, 550f));
				GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
				GUILayout.Label("Quotas for the next rounds", _titleLabelStyle, Array.Empty<GUILayoutOption>());
				for (int i = 1; i <= 10; i++)
				{
					int num = CalculateQuotaForRound(i);
					GUILayout.Label("Round " + i + ": " + num, Array.Empty<GUILayoutOption>());
				}
				GUILayout.EndVertical();
				GUILayout.EndArea();
			}
		}

		private string FilterNumericInput(string input)
		{
			if (string.IsNullOrWhiteSpace(input))
			{
				return "0";
			}
			string text = new string(input.Where((char c) => char.IsDigit(c) || c == '.').ToArray());
			if (string.IsNullOrWhiteSpace(text))
			{
				return "0";
			}
			return text;
		}

		private int CalculateQuotaForRound(int round)
		{
			QuotaSettings quotaVariables = _tod.quotaVariables;
			int num = quotaVariables.startingQuota;
			if (round == 1)
			{
				return num;
			}
			for (int i = 1; i < round; i++)
			{
				float num2 = Mathf.Clamp(1f + (float)i * ((float)i / quotaVariables.increaseSteepness), 0f, 10000f);
				num2 = quotaVariables.baseIncrease * num2;
				num = (int)Mathf.Clamp((float)num + num2, 0f, 1E+09f);
			}
			return num;
		}

		public void Init()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_0063: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Expected O, but got Unknown
			_tod = TimeOfDay.Instance;
			Plugin.DeathPenalty = 80 / Plugin.GetConnectedPlayers();
			_deathPenalty = 80 / Plugin.GetConnectedPlayers();
			if (_currentStyle == null)
			{
				_currentStyle = new GUIStyle(GUI.skin.box);
				_currentStyle.normal.background = MakeTex(2, 2, new Color(0.2f, 0f, 0f, 1f));
				_currentStyle.normal.textColor = new Color(1f, 1f, 1f, 1f);
			}
			if (_textFieldStyle == null)
			{
				_textFieldStyle = new GUIStyle(GUI.skin.textField);
			}
			if (_titleLabelStyle == null)
			{
				_titleLabelStyle = new GUIStyle(GUI.skin.label);
				_titleLabelStyle.fontSize = 15;
				_titleLabelStyle.alignment = (TextAnchor)3;
			}
			if (_headerLabelStyle == null)
			{
				_headerLabelStyle = new GUIStyle(GUI.skin.label);
				_headerLabelStyle.fontSize = 24;
				_headerLabelStyle.alignment = (TextAnchor)4;
			}
			_initialized = true;
		}

		private Texture2D MakeTex(int width, int height, Color col)
		{
			//IL_000f: 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_0021: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			Color[] array = (Color[])(object)new Color[width * height];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = col;
			}
			Texture2D val = new Texture2D(width, height);
			val.SetPixels(array);
			val.Apply();
			return val;
		}
	}
}
namespace LethalCompanyScalingMaster
{
	[BepInPlugin("LethalCompanyScalingMaster", "LethalCompanyScalingMaster", "1.4.0")]
	public class Plugin : BaseUnityPlugin
	{
		private static bool _loaded;

		public static int DeadlineAmount;

		public static int groupCredits;

		public static bool AutoUpdateQuota = true;

		private Harmony _harmony;

		public static bool Host { get; set; }

		public static int DeathPenalty { get; set; }

		private void Awake()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin LethalCompanyScalingMaster is starting up...");
			_harmony = new Harmony("LethalCompanyScalingMaster");
			_harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin LethalCompanyScalingMaster has loaded!");
		}

		private void Start()
		{
			Initialize();
		}

		private void OnDestroy()
		{
			Initialize();
		}

		private void Initialize()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (!_loaded)
			{
				GameObject val = new GameObject("DontDestroy");
				Object.DontDestroyOnLoad((Object)val);
				val.AddComponent<ControlManager>();
				val.AddComponent<BroadcastingComponent>();
				ModdedServer.SetServerModdedOnly();
				_loaded = true;
			}
		}

		public static int GetConnectedPlayers()
		{
			return StartOfRound.Instance.connectedPlayersAmount + 1;
		}

		public static void OnPlayerJoin()
		{
			if (AutoUpdateQuota)
			{
				SaveValues();
			}
		}

		public static void SaveValues()
		{
			if (float.TryParse(GUIManager._baseQuota, out var result) && float.TryParse(GUIManager._playerCountQuotaModifier, out var result2))
			{
				int num = (int)(result + (float)GetConnectedPlayers() * result2);
				GUIManager._tod.quotaVariables.startingQuota = num;
				GUIManager._tod.profitQuota = num;
			}
			if (float.TryParse(GUIManager._baseIncreaseInput, out var result3))
			{
				GUIManager._tod.quotaVariables.baseIncrease = result3;
			}
			if (int.TryParse(GUIManager._daysUntilDeadlineInput, out var result4))
			{
				DeadlineAmount = result4;
				GUIManager._tod.quotaVariables.deadlineDaysAmount = result4;
			}
			GUIManager._tod.quotaVariables.increaseSteepness = GUIManager._quotaIncreaseSteepness;
			groupCredits = GUIManager._totalStartingCredits;
			DeathPenalty = GUIManager._deathPenalty;
			BroadcastingComponent.BroadcastDeathPenalty(DeathPenalty);
			UpdateAndSyncValues();
		}

		public static void UpdateAndSyncValues()
		{
			TimeOfDay instance = TimeOfDay.Instance;
			Debug.Log((object)("Updating Profit Quota's " + GetConnectedPlayers()));
			if (((NetworkBehaviour)instance).IsServer)
			{
				Terminal val = Object.FindObjectOfType<Terminal>();
				if (!((NetworkBehaviour)val).IsServer)
				{
					Debug.Log((object)"This terminal instance is not a server!!!");
				}
				else
				{
					Debug.Log((object)"This terminal instance is a server");
					val.SyncGroupCreditsClientRpc(groupCredits, val.numberOfItemsInDropship);
				}
				instance.SyncNewProfitQuotaClientRpc(instance.profitQuota, 0, instance.timesFulfilledQuota);
				instance.SyncTimeClientRpc(instance.globalTime, (int)((float)DeadlineAmount * instance.totalTime));
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "LethalCompanyScalingMaster";

		public const string PLUGIN_NAME = "LethalCompanyScalingMaster";

		public const string PLUGIN_VERSION = "1.4.0";
	}
}
namespace LethalCompanyScalingMaster.Patches
{
	[HarmonyPatch(typeof(HUDManager))]
	[HarmonyPatch("ApplyPenalty")]
	internal class DeathPenaltyPatch
	{
		private static bool Prefix(ref int playersDead, ref int bodiesInsured)
		{
			float num = (float)Plugin.DeathPenalty / 100f;
			Terminal val = Object.FindObjectOfType<Terminal>();
			int groupCredits = val.groupCredits;
			bodiesInsured = Mathf.Max(bodiesInsured, 0);
			for (int i = 0; i < playersDead - bodiesInsured; i++)
			{
				val.groupCredits -= (int)((double)groupCredits * (double)num);
			}
			for (int j = 0; j < bodiesInsured; j++)
			{
				val.groupCredits -= (int)((double)groupCredits * ((double)num / 2.5));
			}
			if (val.groupCredits < 0)
			{
				val.groupCredits = 0;
			}
			Debug.Log((object)("Death penalty is:" + num));
			((TMP_Text)HUDManager.Instance.statsUIElements.penaltyAddition).text = $"{playersDead} casualties: -{(float)((double)num * 100.0 * (double)(playersDead - bodiesInsured))}%\n({bodiesInsured} bodies recovered)";
			((TMP_Text)HUDManager.Instance.statsUIElements.penaltyTotal).text = $"DUE: ${groupCredits - val.groupCredits}";
			Debug.Log((object)$"New group credits after penalty: {val.groupCredits}");
			return false;
		}
	}
	[HarmonyPatch(typeof(HUDManager), "Start")]
	public static class HUDManagerStartPatch
	{
		[HarmonyPrefix]
		public static void ApplyStartPrefix()
		{
			Debug.Log((object)"APPLYING HUDMANAGER PREFIX");
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	[HarmonyPatch("OnPlayerConnectedClientRpc")]
	public class OnPlayerConnectedClientRpcPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "OnPlayerConnectedClientRpc")]
		private static void Postfix(ulong clientId, int connectedPlayers, int profitQuota)
		{
			Plugin.OnPlayerJoin();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		private static void AwakePostFix()
		{
			Debug.Log((object)"Starting the patch: Postfix for OnPlayerConnectedClientRpc()");
			Plugin.Host = ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost;
			Debug.Log((object)("Plugin host has been set to: " + ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost));
		}
	}
}
namespace LethalCompanyScalingMaster.Component
{
	public class BroadcastingComponent : MonoBehaviour
	{
		private static BroadcastingComponent _instance;

		public static BroadcastingComponent Instance
		{
			get
			{
				//IL_0012: 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_0027: Expected O, but got Unknown
				if ((Object)(object)_instance == (Object)null)
				{
					GameObject val = new GameObject("(BroadcastingComponent.cs)BroadcastingComponent");
					_instance = val.AddComponent<BroadcastingComponent>();
					Object.DontDestroyOnLoad((Object)val);
				}
				return _instance;
			}
		}

		public static void BroadcastDeathPenalty(int penalty)
		{
			Debug.Log((object)("(BroadcastingComponent.cs) Broadcasting new dp value: " + penalty));
			Networking.Broadcast(penalty, "death_penalty");
		}

		private void OnEnable()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			Debug.Log((object)"(BroadcastingComponent.cs)Broadcasting: Subscribed");
			Networking.GetInt = (GotIntEventDelegate)Delegate.Combine((Delegate?)(object)Networking.GetInt, (Delegate?)new GotIntEventDelegate(OnGotInt));
		}

		private void OnDisable()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			Debug.Log((object)"(BroadcastingComponent.cs)Broadcasting: Unsubscribed");
			Networking.GetInt = (GotIntEventDelegate)Delegate.Remove((Delegate?)(object)Networking.GetInt, (Delegate?)new GotIntEventDelegate(OnGotInt));
		}

		private void OnGotInt(int data, string signature)
		{
			if (signature.Equals("death_penalty"))
			{
				Debug.Log((object)("(BroadcastingComponent.cs) Got an int for (" + signature + ") with data: " + data));
				UpdateDeathPenalty(data);
			}
		}

		private void UpdateDeathPenalty(int deathPenalty)
		{
			Plugin.DeathPenalty = deathPenalty;
			GUIManager._deathPenalty = deathPenalty;
		}

		private void Awake()
		{
			if ((Object)(object)_instance == (Object)null)
			{
				_instance = this;
				Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			}
			else
			{
				Debug.Log((object)"Destroying the Broadcasting component");
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
}