Decompiled source of BetterBreakerBox v0.0.5

den.betterbreakerbox.dll

Decompiled 6 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
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 BetterBreakerBox.Behaviours;
using BetterBreakerBox.Configs;
using BetterBreakerBox.Patches;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using TMPro;
using TerminalApi;
using TerminalApi.Classes;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using den.betterbreakerbox.NetcodePatcher;

[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("den")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.0.5.0")]
[assembly: AssemblyInformationalVersion("0.0.5+2cb282b104111cd2190aac23aa1b6402b3ef3fff")]
[assembly: AssemblyProduct("BetterBreakerBox")]
[assembly: AssemblyTitle("den.betterbreakerbox")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.5.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>();
		NetworkVariableSerializationTypes.InitializeSerializer_ManagedINetworkSerializable<IntArrayWrapper>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_ManagedClassEquals<IntArrayWrapper>();
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BetterBreakerBox
{
	[BepInPlugin("den.betterbreakerbox", "BetterBreakerBox", "0.0.5")]
	[BepInDependency("evaisa.lethallib", "0.16.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BetterBreakerBox : BaseUnityPlugin
	{
		internal static BetterBreakerBox? Instance;

		public static AssetBundle BetterBreakerBoxAssets;

		private readonly Harmony harmony = new Harmony("den.betterbreakerbox");

		internal static ManualLogSource logger = Logger.CreateLogSource("den.betterbreakerbox");

		public static GameObject BetterBreakerBoxManagerPrefab = null;

		private List<ActionDefinition> actionsDefinitions = new List<ActionDefinition>();

		internal Dictionary<string, ActionDefinition> switchActionMap = new Dictionary<string, ActionDefinition>();

		private HashSet<ActionDefinition> returnedActions = new HashSet<ActionDefinition>();

		internal static BreakerBox breakerBoxInstance;

		private static GameObject timerObject;

		private static TextMeshProUGUI timerTextMesh;

		public static bool isHost;

		public static bool hasRandomizedActions = false;

		public static bool isTimer;

		public static bool[] SwitchStates = new bool[5];

		public static string SwitchesTurnedOn = "";

		public static bool StatesSet = false;

		public static string LastState = "";

		public static bool ActionLock = false;

		public static bool LocalPlayerTriggered = false;

		public static bool isPowerOffAction = false;

		public static bool isBreakerBoxEnabled = true;

		public static bool isFacilityPowered = false;

		public static bool isTriggeredByLungProp = false;

		public static bool DisarmTurrets = false;

		public static bool BerserkTurrets = false;

		public static bool LeaveShip = false;

		internal static Dictionary<string, int> actionToIndex = new Dictionary<string, int>
		{
			{ "Error", -1 },
			{ "TurretsDisarm", 0 },
			{ "TurretsBerserk", 1 },
			{ "ShipLeave", 2 },
			{ "DoNothing", 3 },
			{ "ChargeEnable", 4 },
			{ "Zap", 5 },
			{ "SwapDoors", 6 },
			{ "SwitchPower", 7 },
			{ "EMP", 8 }
		};

		public Dictionary<int, string> indexToAction = new Dictionary<int, string>();

		public static BetterBreakerBoxConfig MyConfig { get; internal set; }

		public static Dictionary<string, ActionDefinition> GetSwitchActionMap()
		{
			return Instance?.switchActionMap;
		}

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
				MyConfig = new BetterBreakerBoxConfig(((BaseUnityPlugin)this).Config);
				indexToActionInit();
				ApplyPatches();
				PopulateActions();
				NetcodePatcher();
				InitializePrefabs();
				string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
				BetterBreakerBoxAssets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "betterbreakerboxassets"));
				logger.LogInfo((object)"den.betterbreakerbox-0.0.5 has been loaded!");
			}
		}

		private void indexToActionInit()
		{
			foreach (KeyValuePair<string, int> item in actionToIndex)
			{
				indexToAction[item.Value] = item.Key;
			}
		}

		private void InitializePrefabs()
		{
			BetterBreakerBoxManagerPrefab = NetworkPrefabs.CreateNetworkPrefab("BetterBreakerBox Manager");
			BetterBreakerBoxManagerPrefab.AddComponent<BetterBreakerBoxManager>();
		}

		private static void NetcodePatcher()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}

		internal void ApplyPatches()
		{
			logger.LogInfo((object)"Patching methods...");
			TryPatches(typeof(BreakerBoxPatch), "BreakerBox");
			TryPatches(typeof(RoundManagerPatch), "RoundManager");
			TryPatches(typeof(TurretPatch), "Turret");
			TryPatches(typeof(StartOfRoundPatch), "StartOfRound");
			TryPatches(typeof(PlayerControllerBPatch), "PlayerControllerB");
			TryPatches(typeof(LungPropPatch), "LungProp");
		}

		private void TryPatches(Type patchType, string name)
		{
			try
			{
				harmony.PatchAll(patchType);
				logger.LogInfo((object)(name + " successfully patched!"));
			}
			catch (Exception arg)
			{
				logger.LogError((object)$"Couldn't patch {name}!!!:\n{arg}");
			}
		}

		internal void PrepareCommand(int price)
		{
			//IL_0017: 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_0027: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			if ((Object)(object)TerminalApi.GetKeyword("breakerbox") == (Object)null)
			{
				TerminalApi.AddCommand("breakerbox", new CommandInfo
				{
					Title = "breakerbox",
					Category = "other",
					Description = $"Retrieve entries of the Facility's Handbook [{Math.Clamp(price, 0, int.MaxValue)} credits]",
					DisplayTextSupplier = OnBreakerBoxCommand
				}, (string)null, true);
			}
		}

		public string OnBreakerBoxCommand()
		{
			Terminal val = Object.FindObjectOfType<Terminal>();
			string text = "";
			string text2 = "<color=red>Already retrieved entries this period.\nTry again next period!</color>\n\n";
			string text3 = "\n\n<color=red>Insufficient credits to retrieve entries from the Facility Handbook.</color>\n\n";
			string text4 = "<color=blue><u>-- Facility Handbook --</u></color>\n\nBreaker Box:\nInitial inspection of the Facility's wiring has revealed that the previous electrician got a bit...distracted.\nThe breaker box is a mess, and the switches are not labeled. In their stead the Company has decided to promote you to Electrician Specialist!!! We expect you to see to it that the breaker box is fully functional and in pristine condition.\nWe have graciously supplied you with notes from the previous electrician. We have good faith that you won't let The Company down like the previous disappointment. You wouldn't want us to instate our disciplinary measures.\n\n";
			BetterBreakerBoxManager instance = BetterBreakerBoxManager.Instance;
			if (instance != null)
			{
				bool value = instance.hasBoughtThisPeriod.Value;
				int value2 = instance.hintPrice.Value;
				bool flag = val.groupCredits >= value2;
				int num = instance.terminalOutputIndex.Value;
				double num2 = new Random().NextDouble();
				int num3 = ((num2 < 0.2) ? 1 : ((num2 < 0.5) ? 2 : ((num2 < 0.8) ? 3 : 4)));
				int[] data = instance.actions.Value.Data;
				int[] data2 = instance.combos.Value.Data;
				if (!value && flag)
				{
					instance.SyncGroupCredits(val.groupCredits - value2);
					val.PlayTerminalAudioServerRpc(0);
					instance.SethasBoughtThisPeriod(value: true);
					num += num3;
					instance.SetTerminalOutputIndex(num);
				}
				if (data.Length != 0 && data2.Length != 0)
				{
					for (int i = 0; i < num; i++)
					{
						if (i >= data.Length || i >= data2.Length)
						{
							text += "No more entries available.\n";
							break;
						}
						text = text + "<color=orange>" + indexToAction[data[i]] + ": " + IntToCombos(data2[i]) + "</color>\n";
					}
				}
				text = text4 + text;
				if (value)
				{
					text = text2 + text;
					val.PlayTerminalAudioServerRpc(2);
				}
				else if (!flag)
				{
					text += text3;
					val.PlayTerminalAudioServerRpc(2);
				}
			}
			return text;
		}

		internal static void ResetNewDay()
		{
			DestroyTimerObject();
			SwitchesTurnedOn = "";
			StatesSet = false;
			LastState = "";
			ActionLock = false;
			LocalPlayerTriggered = false;
			isBreakerBoxEnabled = true;
			isTriggeredByLungProp = false;
			ResetActions();
			if ((Object)(object)BreakerBoxPatch.stickyNoteInstance != (Object)null)
			{
				Object.Destroy((Object)(object)BreakerBoxPatch.stickyNoteInstance);
				logger.LogDebug((object)"Destroyed sticky note");
			}
		}

		internal static void ResetNewRound()
		{
			hasRandomizedActions = false;
			BetterBreakerBoxManager instance = BetterBreakerBoxManager.Instance;
			if (instance != null)
			{
				instance.SetTerminalOutputIndex(0);
				instance.InitializeActions(0);
				instance.InitializeCombos(0);
			}
			ResetNewDay();
		}

		internal static void ResetActions()
		{
			DisarmTurrets = false;
			BerserkTurrets = false;
			LeaveShip = false;
			isPowerOffAction = false;
		}

		public static void UpdateSwitchStates(int index, bool state)
		{
			if (index >= 0 && index < SwitchStates.Length)
			{
				SwitchStates[index] = state;
			}
		}

		private void PopulateActions()
		{
			int weight = Math.Clamp(BetterBreakerBoxConfig.weightDoNothing.Value, 0, int.MaxValue);
			bool assignOnce = BetterBreakerBoxConfig.doNothingOnce.Value;
			if (new bool[9]
			{
				BetterBreakerBoxConfig.disarmTurretsOnce.Value,
				BetterBreakerBoxConfig.berserkTurretsOnce.Value,
				BetterBreakerBoxConfig.shipLeaveOnce.Value,
				BetterBreakerBoxConfig.doNothingOnce.Value,
				BetterBreakerBoxConfig.enableChargeOnce.Value,
				BetterBreakerBoxConfig.zapOnce.Value,
				BetterBreakerBoxConfig.swapDoorsOnce.Value,
				BetterBreakerBoxConfig.switchPowerOnce.Value,
				BetterBreakerBoxConfig.empOnce.Value
			}.All((bool value) => value) || new int[9]
			{
				BetterBreakerBoxConfig.weightBerserkTurrets.Value,
				BetterBreakerBoxConfig.weightDisarmTurrets.Value,
				BetterBreakerBoxConfig.weightShipLeave.Value,
				BetterBreakerBoxConfig.weightDoNothing.Value,
				BetterBreakerBoxConfig.weightEnableCharge.Value,
				BetterBreakerBoxConfig.weightZap.Value,
				BetterBreakerBoxConfig.weightSwapDoors.Value,
				BetterBreakerBoxConfig.weightSwitchPower.Value,
				BetterBreakerBoxConfig.weightEMP.Value
			}.Sum() == 0)
			{
				assignOnce = false;
				weight = 1;
			}
			bool displayMessage = false;
			actionsDefinitions.Add(new ActionDefinition(TurretsDisarm, Math.Clamp(BetterBreakerBoxConfig.weightDisarmTurrets.Value, 0, int.MaxValue), BetterBreakerBoxConfig.disarmTurretsOnce.Value, "<color=red>Critical power loss!</color>", "Turrets temporarily disarmed.", isWarning: false, displayMessage));
			actionsDefinitions.Add(new ActionDefinition(TurretsBerserk, Math.Clamp(BetterBreakerBoxConfig.weightBerserkTurrets.Value, 0, int.MaxValue), BetterBreakerBoxConfig.berserkTurretsOnce.Value, "<color=red>Security breach detected!", "Activating Turret berserk mode for enhanced Facility protection!", isWarning: true, displayMessage));
			actionsDefinitions.Add(new ActionDefinition(ShipLeave, Math.Clamp(BetterBreakerBoxConfig.weightShipLeave.Value, 0, int.MaxValue), BetterBreakerBoxConfig.shipLeaveOnce.Value, "Electromagnetic anomaly!", "The Company strongly advises all Employees to evacuate to the Autopilot Ship immediately!", isWarning: true, displayMessage: true));
			actionsDefinitions.Add(new ActionDefinition(DoNothing, weight, assignOnce, "LOL", "We're doing nothing", isWarning: false, displayMessage));
			actionsDefinitions.Add(new ActionDefinition(ChargeEnable, Math.Clamp(BetterBreakerBoxConfig.weightEnableCharge.Value, 0, int.MaxValue), BetterBreakerBoxConfig.enableChargeOnce.Value, "<color=blue>Charging enabled!</color>", "Battery-powered items can now be charged at the Breaker Box.", isWarning: false, displayMessage));
			actionsDefinitions.Add(new ActionDefinition(Zap, Math.Clamp(BetterBreakerBoxConfig.weightZap.Value, 0, int.MaxValue), BetterBreakerBoxConfig.zapOnce.Value, "<color=red>ZAP!</color>", "Player has been zapped!", isWarning: true, displayMessage));
			actionsDefinitions.Add(new ActionDefinition(SwapDoors, Math.Clamp(BetterBreakerBoxConfig.weightSwapDoors.Value, 0, int.MaxValue), BetterBreakerBoxConfig.swapDoorsOnce.Value, "<color=blue>Doors swapped!</color>", "Big doors have been swapped.", isWarning: false, displayMessage));
			actionsDefinitions.Add(new ActionDefinition(SwitchPower, Math.Clamp(BetterBreakerBoxConfig.weightSwitchPower.Value, 0, int.MaxValue), BetterBreakerBoxConfig.switchPowerOnce.Value, "<color=red>Power off!</color>", "Facility power has been turned off.", isWarning: true, displayMessage));
			actionsDefinitions.Add(new ActionDefinition(EMP, Math.Clamp(BetterBreakerBoxConfig.weightEMP.Value, 0, int.MaxValue), BetterBreakerBoxConfig.empOnce.Value, "<color=red>EMP!</color>", "EMP has been activated. All electronic systems offline", isWarning: true, displayMessage));
		}

		internal async void RandomizeActions()
		{
			switchActionMap.Clear();
			List<ActionDefinition> list = new List<ActionDefinition>(actionsDefinitions);
			Random rng = new Random();
			double totalWeight = list.Sum((ActionDefinition a) => a.Weight);
			List<(double, ActionDefinition)> list2 = new List<(double, ActionDefinition)>();
			double cumulative = 0.0;
			foreach (ActionDefinition item in list)
			{
				cumulative += (double)item.Weight / totalWeight;
				list2.Add((cumulative, item));
			}
			int num = 32;
			int num2 = 0;
			if (BetterBreakerBoxConfig.ensureAction.Value)
			{
				List<(double, ActionDefinition)> source = list2.Where<(double, ActionDefinition)>(((double cumulativeWeight, ActionDefinition action) wa) => wa.action.Weight > 0).ToList();
				source = source.OrderBy<(double, ActionDefinition), int>(((double cumulativeWeight, ActionDefinition action) a) => rng.Next()).ToList();
				foreach (var actionToAssign in source)
				{
					string key = Convert.ToString(num2++, 2).PadLeft(5, '0');
					switchActionMap[key] = actionToAssign.Item2;
					if (actionToAssign.Item2.AssignOnce)
					{
						list2.RemoveAll(((double cumulativeWeight, ActionDefinition action) wa) => wa.action == actionToAssign.Item2);
						totalWeight -= actionToAssign.Item2.Weight;
						cumulative = 0.0;
						list2 = list2.Select<(double, ActionDefinition), (double, ActionDefinition)>(delegate((double cumulativeWeight, ActionDefinition action) wa)
						{
							cumulative += (double)wa.action.Weight / totalWeight;
							return (cumulative, wa.action);
						}).ToList();
					}
				}
			}
			for (int i = num2; i < num; i++)
			{
				string key2 = Convert.ToString(i, 2).PadLeft(5, '0');
				double randomValue = rng.NextDouble();
				ActionDefinition selectedAction = list2.FirstOrDefault<(double, ActionDefinition)>(((double cumulativeWeight, ActionDefinition action) wa) => wa.cumulativeWeight >= randomValue).Item2;
				switchActionMap[key2] = selectedAction;
				if (selectedAction.AssignOnce)
				{
					list2.RemoveAll(((double cumulativeWeight, ActionDefinition action) wa) => wa.action == selectedAction);
					totalWeight -= selectedAction.Weight;
					cumulative = 0.0;
					list2 = list2.Select<(double, ActionDefinition), (double, ActionDefinition)>(delegate((double cumulativeWeight, ActionDefinition action) wa)
					{
						cumulative += (double)wa.action.Weight / totalWeight;
						return (cumulative, wa.action);
					}).ToList();
				}
			}
			returnedActions.Clear();
			PrepareTerminalHints();
		}

		public static void DisplayActionMessage(string headerText, string bodyText, bool isWarning)
		{
			HUDManager.Instance.DisplayTip(headerText, bodyText, isWarning, false, "LC_Tip1");
		}

		public static void DisplayTimer(string name, float timeLeft, float totalTime)
		{
			//IL_0024: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.FindObjectOfType<PlayerControllerB>().isPlayerDead)
			{
				int num = (int)timeLeft / 60;
				int num2 = (int)timeLeft % 60;
				float percentage = timeLeft / totalTime * 100f;
				Color colorForPercentage = GetColorForPercentage(percentage);
				if ((Object)(object)timerObject == (Object)null)
				{
					CreateTimerObject();
					return;
				}
				((TMP_Text)timerTextMesh).text = $"{num:D2}:{num2:D2}";
				((Graphic)timerTextMesh).color = colorForPercentage;
			}
		}

		private static Color GetColorForPercentage(float percentage)
		{
			//IL_0008: 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_0016: Unknown result type (might be due to invalid IL or missing references)
			if (percentage < 25f)
			{
				return Color.red;
			}
			if (percentage < 50f)
			{
				return Color.yellow;
			}
			return Color.green;
		}

		public void PrepareTerminalHints()
		{
			returnedActions.Clear();
			List<KeyValuePair<string, ActionDefinition>> list = switchActionMap.Where<KeyValuePair<string, ActionDefinition>>((KeyValuePair<string, ActionDefinition> pair) => pair.Value.Action.Method.Name != "DoNothing").ToList();
			if (list.Count > 0)
			{
				BetterBreakerBoxManager instance = BetterBreakerBoxManager.Instance;
				if (instance == null)
				{
					return;
				}
				instance.InitializeActions(list.Count);
				instance.InitializeCombos(list.Count);
				int count = list.Count;
				for (int i = 0; i < count; i++)
				{
					list = list.Where((KeyValuePair<string, ActionDefinition> pair) => !returnedActions.Contains(pair.Value)).ToList();
					count = list.Count;
					if (count < 1)
					{
						break;
					}
					Random random = new Random();
					ActionDefinition randomAction = list[random.Next(list.Count)].Value;
					returnedActions.Add(randomAction);
					List<string> list2 = (from pair in switchActionMap
						where pair.Value == randomAction
						select pair.Key).ToList();
					int num = 0;
					foreach (string item in list2)
					{
						int num2 = Convert.ToInt32(item, 2);
						num |= 1 << num2 - 1;
					}
					instance.SetAction(i, actionToIndex[randomAction.Action.Method.Name]);
					instance.SetCombo(i, num);
				}
			}
			else
			{
				BetterBreakerBoxManager instance2 = BetterBreakerBoxManager.Instance;
				if (instance2 != null)
				{
					instance2.InitializeActions(1);
					instance2.SetAction(0, -1);
					instance2.SetCombo(0, -1);
				}
			}
		}

		public string IntToCombos(int intCombos)
		{
			StringBuilder stringBuilder = new StringBuilder();
			for (int i = 0; i < 32; i++)
			{
				if ((intCombos & (1 << i)) != 0)
				{
					string text = Convert.ToString(i + 1, 2).PadLeft(5, '0');
					string text2 = text;
					int length = text2.Length;
					int num = length - 5;
					text = text2.Substring(num, length - num);
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(", ");
					}
					stringBuilder.Append(text);
				}
			}
			return stringBuilder.ToString();
		}

		public static int BinaryStringToInt(string binaryString)
		{
			try
			{
				return Convert.ToInt32(binaryString, 2);
			}
			catch (FormatException)
			{
				logger.LogError((object)"Input string is not a valid binary number.\n{e}");
				return -1;
			}
		}

		public static void UpdateHintPrice(int newPrice)
		{
			BetterBreakerBoxManager.Instance?.SetHintPrice(Math.Clamp(newPrice, 0, int.MaxValue));
		}

		public void TurretsDisarm()
		{
			ResetActions();
			DisarmTurrets = true;
		}

		public void TurretsBerserk()
		{
			ResetActions();
			BerserkTurrets = true;
		}

		public void ShipLeave()
		{
			ResetActions();
			LeaveShip = true;
		}

		public void DoNothing()
		{
			ResetActions();
			ActionLock = false;
		}

		public void SwitchPower()
		{
			ResetActions();
			isPowerOffAction = true;
			logger.LogDebug((object)$"isFacilityPowered: {isFacilityPowered} | setting Facility power to: {!isFacilityPowered}");
			if (isFacilityPowered)
			{
				RoundManager.Instance.PowerSwitchOffClientRpc();
				BetterBreakerBoxManager.Instance.ToggleBreakerBoxHumClientRpc(on: false);
			}
			else
			{
				RoundManager.Instance.PowerSwitchOnClientRpc();
				BetterBreakerBoxManager.Instance.ToggleBreakerBoxHumClientRpc(on: true);
			}
			isFacilityPowered = !isFacilityPowered;
			ActionLock = false;
			isPowerOffAction = false;
		}

		public void ChargeEnable()
		{
			ResetActions();
			BetterBreakerBoxManager.Instance.ChargeEnableClientRpc();
			ActionLock = false;
		}

		public static void Zap()
		{
			ResetActions();
			BetterBreakerBoxManager.Instance.ZapClientRpc();
			ActionLock = false;
		}

		public void StealthMines()
		{
		}

		public void DisableMines()
		{
		}

		public void Lockdown()
		{
		}

		public void SwapDoors()
		{
			ResetActions();
			TerminalAccessibleObject[] array = (from obj in Object.FindObjectsOfType<TerminalAccessibleObject>()
				where obj.isBigDoor
				select obj).ToArray();
			if (array.Length != 0)
			{
				TerminalAccessibleObject[] array2 = array;
				foreach (TerminalAccessibleObject val in array2)
				{
					val.SetDoorOpen(!val.isDoorOpen);
				}
			}
			ActionLock = false;
		}

		public void Thunderstorm()
		{
		}

		public void EMP()
		{
			ResetActions();
			isPowerOffAction = true;
			isBreakerBoxEnabled = false;
			RoundManager.Instance.PowerSwitchOffClientRpc();
			RoundManager.Instance.powerOffPermanently = true;
			breakerBoxInstance.isPowerOn = false;
			BetterBreakerBoxManager.Instance.ToggleBreakerBoxHumClientRpc(on: false);
			StartOfRound.Instance.PowerSurgeShip();
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			List<UnlockableItem> unlockables = StartOfRound.Instance.unlockablesList.unlockables;
			GameObject prefabObject = unlockables.Find((UnlockableItem u) => u.unlockableName == "Teleporter").prefabObject;
			ShipTeleporter component = prefabObject.GetComponent<ShipTeleporter>();
			localPlayerController.statusEffectAudio.PlayOneShot(component.teleporterBeamUpSFX);
			BetterBreakerBoxManager.Instance.DrainBatteriesClientRpc();
			DisarmTurrets = true;
			TerminalAccessibleObject[] array = (from obj in Object.FindObjectsOfType<TerminalAccessibleObject>()
				where obj.isBigDoor
				select obj).ToArray();
			if (array.Length != 0)
			{
				TerminalAccessibleObject[] array2 = array;
				foreach (TerminalAccessibleObject val in array2)
				{
					if (BetterBreakerBoxConfig.lockDoorsOnEmp.Value)
					{
						((Component)val).gameObject.GetComponent<AnimatedObjectTrigger>().SetBoolOnClientOnly(false);
						logger.LogDebug((object)("Door " + ((Object)val).name + " is now closed"));
					}
				}
			}
			else
			{
				logger.LogDebug((object)"No big doors found");
			}
			BetterBreakerBoxManager.Instance.ChargeDisableClientRpc();
			ActionLock = false;
		}

		public void FlipMeltdown()
		{
		}

		public static bool CreateTimerObject()
		{
			//IL_0079: 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)
			GameObject val = GameObject.Find("/Systems/UI/Canvas/IngamePlayerHUD/TopRightCorner/ControlTip1");
			if (!Object.op_Implicit((Object)(object)val))
			{
				logger.LogError((object)"Could not find ControlTip1");
				return false;
			}
			GameObject val2 = GameObject.Find("/Systems/UI/Canvas/IngamePlayerHUD/TopRightCorner/ControlTip2");
			if (!Object.op_Implicit((Object)(object)val2))
			{
				logger.LogError((object)"Could not find ControlTip2");
				return false;
			}
			timerObject = Object.Instantiate<GameObject>(val.gameObject, val.transform.parent, false);
			((Object)timerObject).name = "BBB Timer";
			float num = val.transform.position.y - val2.transform.position.y;
			timerObject.transform.Translate(0f, num, 0f);
			timerTextMesh = timerObject.GetComponentInChildren<TextMeshProUGUI>();
			logger.LogDebug((object)"BBB Timer created");
			return true;
		}

		public static void DestroyTimerObject()
		{
			if (Object.op_Implicit((Object)(object)timerObject))
			{
				Object.Destroy((Object)(object)timerObject);
				timerObject = null;
				timerTextMesh = null;
			}
		}

		public static void ToggleBreakerBoxHum(bool on)
		{
			if ((Object)(object)breakerBoxInstance != (Object)null)
			{
				if (on)
				{
					breakerBoxInstance.breakerBoxHum.Play();
				}
				else
				{
					breakerBoxInstance.breakerBoxHum.Stop();
				}
			}
		}

		public static void DrainBatteries()
		{
			GrabbableObject[] array = (from obj in Object.FindObjectsOfType<GrabbableObject>()
				where obj.itemProperties.requiresBattery
				select obj).ToArray();
			if (array.Length != 0)
			{
				GrabbableObject[] array2 = array;
				foreach (GrabbableObject val in array2)
				{
					val.insertedBattery.charge = 0f;
				}
			}
		}
	}
	public class ActionDefinition
	{
		public SwitchAction Action { get; set; }

		public int Weight { get; set; }

		public bool AssignOnce { get; set; }

		public string HeaderText { get; set; }

		public string BodyText { get; set; }

		public bool IsWarning { get; set; }

		public bool DisplayMessage { get; set; }

		public ActionDefinition(SwitchAction action, int weight, bool assignOnce, string headerText, string bodyText, bool isWarning, bool displayMessage)
		{
			Action = action;
			Weight = weight;
			AssignOnce = assignOnce;
			HeaderText = headerText;
			BodyText = bodyText;
			IsWarning = isWarning;
			DisplayMessage = displayMessage;
		}
	}
	public delegate void SwitchAction();
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "den.betterbreakerbox";

		public const string PLUGIN_NAME = "BetterBreakerBox";

		public const string PLUGIN_VERSION = "0.0.5";
	}
}
namespace BetterBreakerBox.Patches
{
	[HarmonyPatch(typeof(BreakerBox))]
	internal class BreakerBoxPatch
	{
		internal static GameObject stickyNotePrefab;

		internal static GameObject stickyNoteInstance;

		[HarmonyPatch("SwitchBreaker")]
		[HarmonyPrefix]
		private static bool SwitchBreakerPostfix(BreakerBox __instance)
		{
			BetterBreakerBox.isFacilityPowered = __instance.isPowerOn;
			BetterBreakerBox.logger.LogDebug((object)$"isPowerOn {__instance.isPowerOn}");
			BetterBreakerBox.LocalPlayerTriggered = false;
			BetterBreakerBox.logger.LogDebug((object)("Number of levers turned off:  " + __instance.leversSwitchedOff));
			BetterBreakerBox.logger.LogDebug((object)"Current lever positions: ");
			BetterBreakerBox.SwitchesTurnedOn = "";
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			for (int i = 0; i < __instance.breakerSwitches.Length; i++)
			{
				bool @bool = __instance.breakerSwitches[i].GetBool("turnedLeft");
				InteractTrigger hoveringOverTrigger = localPlayerController.hoveringOverTrigger;
				InteractTrigger component = ((Component)__instance.breakerSwitches[i]).gameObject.GetComponent<InteractTrigger>();
				if ((Object)(object)hoveringOverTrigger == (Object)(object)component && BetterBreakerBox.SwitchStates[i] != @bool)
				{
					BetterBreakerBox.logger.LogDebug((object)$"Switch {i + 1} was triggered by the local player");
					BetterBreakerBox.LocalPlayerTriggered = true;
				}
				BetterBreakerBox.logger.LogDebug((object)$"Switch {i + 1}: {@bool}");
				BetterBreakerBox.UpdateSwitchStates(i, @bool);
				BetterBreakerBox.SwitchesTurnedOn += (@bool ? "1" : "0");
			}
			BetterBreakerBox.StatesSet = true;
			return false;
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch(BreakerBox __instance)
		{
			//IL_003e: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_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)
			BetterBreakerBox.breakerBoxInstance = __instance;
			stickyNotePrefab = BetterBreakerBox.BetterBreakerBoxAssets.LoadAsset<GameObject>("assets/prefabinstance/stickynoteitem.prefab");
			Transform val = ((Component)__instance).transform.Find("Mesh/PowerBoxDoor");
			try
			{
				GameObject val2 = Object.Instantiate<GameObject>(stickyNotePrefab, val);
				Transform transform = val2.transform;
				transform.position -= val2.transform.right * 0.25f;
				Transform transform2 = val2.transform;
				transform2.position -= val2.transform.up * 0.25f;
				Transform transform3 = val2.transform;
				transform3.position -= val2.transform.forward * 0.025f;
				val2.transform.Rotate(0f, 180f, 0f);
			}
			catch (Exception arg)
			{
				BetterBreakerBox.logger.LogError((object)$"Failed to spawn sticky note:\n{arg}");
			}
			if (BetterBreakerBox.isHost)
			{
				Animator[] breakerSwitches = __instance.breakerSwitches;
				foreach (Animator val3 in breakerSwitches)
				{
					bool flag = Random.Range(0, 2) == 0;
					AnimatedObjectTrigger component = ((Component)val3).gameObject.GetComponent<AnimatedObjectTrigger>();
					component.boolValue = flag;
					component.setInitialState = flag;
					val3.SetBool("turnedLeft", flag);
				}
			}
		}
	}
	[HarmonyPatch(typeof(LungProp))]
	internal class LungPropPatch
	{
		[HarmonyPatch("EquipItem")]
		[HarmonyPrefix]
		private static void EquipItemPrefix(LungProp __instance)
		{
			if (__instance.isLungDocked)
			{
				BetterBreakerBox.isTriggeredByLungProp = true;
				BetterBreakerBox.isBreakerBoxEnabled = false;
			}
		}

		[HarmonyPatch("DisconnectFromMachinery")]
		[HarmonyPostfix]
		private static void EquipItemPostfix(LungProp __instance)
		{
			BetterBreakerBox.isTriggeredByLungProp = false;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("KillPlayer")]
		[HarmonyPrefix]
		private static void KillPlayerPatch(PlayerControllerB __instance)
		{
			BetterBreakerBox.logger.LogDebug((object)"Player died, destroying timer object.");
			BetterBreakerBox.DestroyTimerObject();
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch(RoundManager __instance)
		{
			BetterBreakerBox.hasRandomizedActions = false;
			BetterBreakerBox.isHost = GameNetworkManager.Instance.isHostingGame;
			if (((NetworkBehaviour)__instance).IsOwner)
			{
				if ((Object)(object)BetterBreakerBoxManager.Instance != (Object)null)
				{
					return;
				}
				try
				{
					GameObject val = Object.Instantiate<GameObject>(BetterBreakerBox.BetterBreakerBoxManagerPrefab, ((Component)__instance).transform);
					((Object)val).hideFlags = (HideFlags)0;
					val.GetComponent<NetworkObject>().Spawn(false);
					BetterBreakerBox.logger.LogDebug((object)"Spawned BetterBreakerBoxManager");
				}
				catch (Exception arg)
				{
					BetterBreakerBox.logger.LogError((object)$"Failed to spawn BetterBreakerBoxManager:\n{arg}");
				}
			}
			if (!BetterBreakerBox.isHost)
			{
				BetterBreakerBox.Instance.PrepareCommand(BetterBreakerBoxManager.Instance.hintPrice.Value);
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePatch(RoundManager __instance)
		{
			if (BetterBreakerBox.isHost)
			{
				if ((TimeOfDay.Instance.daysUntilDeadline == 3 && !BetterBreakerBox.hasRandomizedActions) || (BetterBreakerBoxConfig.resetAfterDay.Value && !BetterBreakerBox.hasRandomizedActions && TimeOfDay.Instance.daysUntilDeadline != 3))
				{
					BetterBreakerBoxManager.Instance.Reset();
					BetterBreakerBox.Instance.RandomizeActions();
					BetterBreakerBox.Instance.PrepareTerminalHints();
					BetterBreakerBox.UpdateHintPrice(Math.Clamp(BetterBreakerBoxConfig.hintPrice.Value, 0, int.MaxValue));
					BetterBreakerBox.Instance.PrepareCommand(BetterBreakerBoxManager.Instance.hintPrice.Value);
					BetterBreakerBox.hasRandomizedActions = true;
					BetterBreakerBox.logger.LogDebug((object)("Randomized actions at beginning of " + (BetterBreakerBoxConfig.resetAfterDay.Value ? "day" : "round")));
				}
				else if (TimeOfDay.Instance.daysUntilDeadline <= 0)
				{
					BetterBreakerBox.hasRandomizedActions = false;
				}
			}
		}

		[HarmonyPatch("SwitchPower")]
		[HarmonyPrefix]
		private static bool SwitchPowerPatch(RoundManager __instance)
		{
			BetterBreakerBox.logger.LogDebug((object)("isTriggeredByLungProp: " + BetterBreakerBox.isTriggeredByLungProp));
			return BetterBreakerBox.isTriggeredByLungProp;
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePatch(StartOfRound __instance)
		{
			if (!BetterBreakerBox.StatesSet || !BetterBreakerBox.isHost || !(BetterBreakerBox.LastState != BetterBreakerBox.SwitchesTurnedOn))
			{
				return;
			}
			Dictionary<string, ActionDefinition> switchActionMap = BetterBreakerBox.GetSwitchActionMap();
			if (switchActionMap != null && switchActionMap.TryGetValue(BetterBreakerBox.SwitchesTurnedOn, out ActionDefinition value) && !BetterBreakerBox.ActionLock && BetterBreakerBox.isBreakerBoxEnabled)
			{
				BetterBreakerBox.ActionLock = true;
				if (value.DisplayMessage)
				{
					BetterBreakerBoxManager.Instance?.DisplayActionMessageClientRpc(value.HeaderText, value.BodyText, value.IsWarning);
				}
				if ((!BetterBreakerBox.DisarmTurrets || !(value.Action.Method.Name == "TurretsDisarm")) && (!BetterBreakerBox.BerserkTurrets || !(value.Action.Method.Name == "TurretsBerserk")) && (!BetterBreakerBox.LeaveShip || !(value.Action.Method.Name == "ShipLeave")))
				{
					if (value.Action.Method.Name != "DoNothing")
					{
						BetterBreakerBox.breakerBoxInstance.thisAudioSource.PlayOneShot(RoundManager.Instance.PressButtonSFX1);
					}
					value.Action();
					BetterBreakerBox.LocalPlayerTriggered = false;
				}
			}
			BetterBreakerBox.LastState = BetterBreakerBox.SwitchesTurnedOn;
		}

		[HarmonyPatch("playersFiredGameOver")]
		[HarmonyPostfix]
		private static void playersFiredGameOverPatch()
		{
			BetterBreakerBox.ResetNewRound();
		}

		[HarmonyPatch("ShipHasLeft")]
		[HarmonyPrefix]
		private static void ShipHasLeftPatch()
		{
			BetterBreakerBox.ResetNewDay();
			BetterBreakerBox.logger.LogInfo((object)"Ship has left, resetting.");
			if (BetterBreakerBox.isHost && BetterBreakerBoxConfig.resetAfterDay.Value)
			{
				BetterBreakerBox.hasRandomizedActions = false;
			}
		}
	}
	[HarmonyPatch(typeof(Turret))]
	internal class TurretPatch
	{
		private static MethodInfo switchTurretModeMethod = null;

		private static readonly object[] berserkParameter = new object[1] { 3 };

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static bool UpdatePatch(Turret __instance)
		{
			if (BetterBreakerBox.DisarmTurrets)
			{
				return false;
			}
			if ((object)switchTurretModeMethod == null)
			{
				switchTurretModeMethod = typeof(Turret).GetMethod("SwitchTurretMode", BindingFlags.Instance | BindingFlags.NonPublic);
			}
			if (BetterBreakerBox.BerserkTurrets)
			{
				if (switchTurretModeMethod != null)
				{
					switchTurretModeMethod.Invoke(__instance, berserkParameter);
				}
				else
				{
					BetterBreakerBox.logger.LogWarning((object)"SwitchTurretMode() method not found! Not setting berserk mode!");
				}
			}
			return true;
		}
	}
}
namespace BetterBreakerBox.Configs
{
	public class BetterBreakerBoxConfig
	{
		public static ConfigEntry<int> weightDisarmTurrets;

		public static ConfigEntry<int> weightBerserkTurrets;

		public static ConfigEntry<int> weightShipLeave;

		public static ConfigEntry<int> weightDoNothing;

		public static ConfigEntry<int> weightEnableCharge;

		public static ConfigEntry<int> weightZap;

		public static ConfigEntry<int> weightSwapDoors;

		public static ConfigEntry<int> weightSwitchPower;

		public static ConfigEntry<int> weightEMP;

		public static ConfigEntry<bool> disarmTurretsOnce;

		public static ConfigEntry<bool> berserkTurretsOnce;

		public static ConfigEntry<bool> shipLeaveOnce;

		public static ConfigEntry<bool> doNothingOnce;

		public static ConfigEntry<bool> enableChargeOnce;

		public static ConfigEntry<bool> zapOnce;

		public static ConfigEntry<bool> swapDoorsOnce;

		public static ConfigEntry<bool> switchPowerOnce;

		public static ConfigEntry<bool> empOnce;

		public static ConfigEntry<int> disarmTurretsTimer;

		public static ConfigEntry<int> berserkTurretsTimer;

		public static ConfigEntry<int> shipLeaveTimer;

		public static ConfigEntry<bool> lockDoorsOnEmp;

		public static ConfigEntry<int> zapDamage;

		public static ConfigEntry<int> hintPrice;

		public static ConfigEntry<bool> resetAfterDay;

		public static ConfigEntry<bool> ensureAction;

		public static ConfigEntry<bool> enableChainZap;

		public BetterBreakerBoxConfig(ConfigFile cfg)
		{
			string text = "disarming Turrets in the facility";
			string text2 = "making Turrets enter berserk mode";
			string text3 = "making the Ship leave early";
			string text4 = "having no action";
			string text5 = "enabling charging battery-powered items on the breaker box";
			string text6 = "zapping the player with a small amount of damage";
			string text7 = "swapping the state of all doors in the facility";
			string text8 = "toggling the power in the facility";
			string text9 = "disabling all electronic devices on the moon";
			string text10 = "Adjusts the probability that a switch combination will trigger the action of";
			string text11 = "Higher weights make this action more likely to be assigned to one of the switch combinations, a weight of 0 will prevent the action from being assigned.";
			string text12 = "Select if the action of";
			string text13 = "should only be able to be assigned to one switch combination, regardless of the weight assigned to it.";
			string text14 = "The configured time represents the maximum time. Should the remaining time of day be less than the configured time, the timer will be set to the remaining time of day instead.";
			weightDisarmTurrets = cfg.Bind<int>("Weights", "weightDisarmTurrets", 15, text10 + " " + text + ". " + text11);
			weightBerserkTurrets = cfg.Bind<int>("Weights", "weightBerserkTurrets", 10, text10 + " " + text2 + ". " + text11);
			weightShipLeave = cfg.Bind<int>("Weights", "weightShipLeave", 1, text10 + " " + text3 + ". " + text11);
			weightDoNothing = cfg.Bind<int>("Weights", "weightDoNothing", 30, text10 + " " + text4 + ". " + text11);
			weightEnableCharge = cfg.Bind<int>("Weights", "weightEnableCharge", 10, text10 + " " + text5 + ". " + text11);
			weightZap = cfg.Bind<int>("Weights", "weightZap", 20, text10 + " " + text6 + ". " + text11);
			weightSwapDoors = cfg.Bind<int>("Weights", "weightSwapDoors", 20, text10 + " " + text7 + ". " + text11);
			weightSwitchPower = cfg.Bind<int>("Weights", "weightSwitchPower", 20, text10 + " " + text8 + ". " + text11);
			weightEMP = cfg.Bind<int>("Weights", "weightEMP", 1, text10 + " " + text9 + ". " + text11);
			disarmTurretsOnce = cfg.Bind<bool>("Limits", "disarmTurretsOnce", false, text12 + " " + text + " " + text13);
			berserkTurretsOnce = cfg.Bind<bool>("Limits", "berserkTurretsOnce", false, text12 + " " + text2 + " " + text13);
			shipLeaveOnce = cfg.Bind<bool>("Limits", "shipLeaveOnce", true, text12 + " " + text3 + " " + text13);
			doNothingOnce = cfg.Bind<bool>("Limits", "doNothingOnce", false, text12 + " " + text4 + " " + text13);
			enableChargeOnce = cfg.Bind<bool>("Limits", "enableChargeOnce", false, text12 + " " + text5 + " " + text13);
			zapOnce = cfg.Bind<bool>("Limits", "zapOnce", false, text12 + " " + text6 + " " + text13);
			swapDoorsOnce = cfg.Bind<bool>("Limits", "swapDoorsOnce", false, text12 + " " + text7 + " " + text13);
			switchPowerOnce = cfg.Bind<bool>("Limits", "switchPowerOnce", false, text12 + " " + text8 + " " + text13);
			empOnce = cfg.Bind<bool>("Limits", "empOnce", false, text12 + " " + text9 + " " + text13);
			disarmTurretsTimer = cfg.Bind<int>("Timers", "disarmTurretsTimer", 30, "Time in seconds before Turrets are re-armed after being disarmed. " + text14);
			berserkTurretsTimer = cfg.Bind<int>("Timers", "berserkTurretsTimer", 30, "Time in seconds before Turrets exit berserk mode. " + text14);
			shipLeaveTimer = cfg.Bind<int>("Timers", "shipLeaveTimer", 120, "Time in seconds before the Ship leaves after being triggered to leave early. " + text14);
			lockDoorsOnEmp = cfg.Bind<bool>("Misc", "lockDoorsOnEmp", false, "If true, all automatic doors will be locked when the EMP action is triggered");
			zapDamage = cfg.Bind<int>("Misc", "zapDamage", 25, "Amount of damage dealt to the player when the Zap action is triggered");
			hintPrice = cfg.Bind<int>("Misc", "hintPrice", 50, "Credits required to purchase a hint from the terminal.");
			resetAfterDay = cfg.Bind<bool>("Misc", "resetAfterDay", true, "If enabled, the switch combinations will be reset after each day.");
			ensureAction = cfg.Bind<bool>("Misc", "ensureAction", true, "If enabled, each action with a weight greater than 0 is guaranteed to be assigned to at least one switch combination. The remaining actions will be assigned based on their weights.");
			enableChainZap = cfg.Bind<bool>("Misc", "enableChainZap", true, "If enabled, the Zap action will chain to other players in the vicinity of the player that triggered the action.");
		}
	}
}
namespace BetterBreakerBox.Behaviours
{
	internal class BetterBreakerBoxManager : NetworkBehaviour
	{
		internal float leaveShipTimer = Math.Clamp(BetterBreakerBoxConfig.shipLeaveTimer.Value, 0f, float.MaxValue);

		internal float disarmTurretsTimer = Math.Clamp(BetterBreakerBoxConfig.disarmTurretsTimer.Value, 0f, float.MaxValue);

		internal float berserkTurretsTimer = Math.Clamp(BetterBreakerBoxConfig.berserkTurretsTimer.Value, 0f, float.MaxValue);

		internal bool leaveShipTimerStarted;

		internal bool disarmTurretsTimerStarted;

		internal bool berserkTurretsTimerStarted;

		internal float startTime;

		internal TimeOfDay timeOfDay;

		public NetworkVariable<int> hintPrice = new NetworkVariable<int>(50, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<int> terminalOutputIndex = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<bool> hasBoughtThisPeriod = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<IntArrayWrapper> actions = new NetworkVariable<IntArrayWrapper>(new IntArrayWrapper(), (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<IntArrayWrapper> combos = new NetworkVariable<IntArrayWrapper>(new IntArrayWrapper(), (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public static BetterBreakerBoxManager? Instance { get; private set; }

		public void Reset()
		{
			SetHintPrice(50);
			SetTerminalOutputIndex(0);
			SethasBoughtThisPeriod(value: false);
		}

		public void SetAction(int index, int value)
		{
			if (!BetterBreakerBox.isHost)
			{
				SetActionServerRpc(index, value);
			}
			else
			{
				actions.Value.Data[index] = value;
			}
		}

		public void InitializeActions(int length)
		{
			actions.Value.Data = new int[length];
		}

		public void SetCombo(int index, int value)
		{
			if (!BetterBreakerBox.isHost)
			{
				SetComboServerRpc(index, value);
			}
			else
			{
				combos.Value.Data[index] = value;
			}
		}

		public void InitializeCombos(int length)
		{
			combos.Value.Data = new int[length];
		}

		public void SetHintPrice(int value)
		{
			if (!BetterBreakerBox.isHost)
			{
				SetHintPriceServerRpc(value);
			}
			else
			{
				hintPrice.Value = value;
			}
		}

		public void SetTerminalOutputIndex(int value)
		{
			if (!BetterBreakerBox.isHost)
			{
				SetTerminalOutputIndexServerRpc(value);
			}
			else
			{
				terminalOutputIndex.Value = value;
			}
		}

		public void SethasBoughtThisPeriod(bool value)
		{
			if (!BetterBreakerBox.isHost)
			{
				SethasBoughtThisPeriodServerRpc(value);
			}
			else
			{
				hasBoughtThisPeriod.Value = value;
			}
		}

		public void SyncGroupCredits(int credits)
		{
			Terminal val = Object.FindObjectOfType<Terminal>();
			if (BetterBreakerBox.isHost)
			{
				val.SyncGroupCreditsClientRpc(credits, val.numberOfItemsInDropship);
			}
			else
			{
				MySyncGroupCreditsServerRpc(credits);
			}
		}

		[ClientRpc]
		public void DisplayActionMessageClientRpc(string headerText, string bodyText, bool isWarning)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2719760394u, val, (RpcDelivery)0);
				bool flag = headerText != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(headerText, false);
				}
				bool flag2 = bodyText != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives));
				if (flag2)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(bodyText, false);
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref isWarning, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2719760394u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				BetterBreakerBox.DisplayActionMessage(headerText, bodyText, isWarning);
			}
		}

		[ClientRpc]
		public void DisplayTimerClientRpc(string name, float timeLeft, float totalTime)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_00c1: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3294938841u, val, (RpcDelivery)0);
				bool flag = name != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(name, false);
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref timeLeft, default(ForPrimitives));
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref totalTime, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3294938841u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				BetterBreakerBox.DisplayTimer(name, timeLeft, totalTime);
			}
		}

		[ClientRpc]
		public void CreateTimerObjectClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3577715068u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3577715068u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					BetterBreakerBox.CreateTimerObject();
				}
			}
		}

		[ClientRpc]
		public void DestroyTimerObjectClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3666406714u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3666406714u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					BetterBreakerBox.DestroyTimerObject();
				}
			}
		}

		[ClientRpc]
		public void ZapClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1941160110u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1941160110u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
				if (BetterBreakerBox.LocalPlayerTriggered)
				{
					ZapRemotePlayerServerRpc((int)localPlayerController.playerClientId);
				}
			}
		}

		[ClientRpc]
		public void ZapDamageClientRpc(int playerID, int damage)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2019522705u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerID);
				BytePacker.WriteValueBitPacked(val2, damage);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2019522705u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
				if (playerID == (int)localPlayerController.playerClientId)
				{
					HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
					localPlayerController.DamagePlayer(damage, true, true, (CauseOfDeath)11, 0, false, default(Vector3));
					localPlayerController.beamUpParticle.Play();
					ItemCharger val3 = Object.FindObjectOfType<ItemCharger>();
					localPlayerController.statusEffectAudio.PlayOneShot(val3.zapAudio.clip);
				}
			}
		}

		[ClientRpc]
		public void ZapEffectsClientRpc(int playerID)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0071: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3597902685u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerID);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3597902685u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				int playerID2 = playerID;
				PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
				PlayerControllerB val3 = RoundManager.Instance.playersManager.allPlayerScripts.Where((PlayerControllerB p) => (int)p.playerClientId == playerID2).FirstOrDefault();
				if ((Object)(object)val3 != (Object)null && val3.playerClientId != localPlayerController.playerClientId)
				{
					val3.beamUpParticle.Play();
					val3.statusEffectAudio.PlayOneShot(Object.FindObjectOfType<ItemCharger>().zapAudio.clip);
				}
			}
		}

		[ClientRpc]
		public void ChargeEnableClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(649523096u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 649523096u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && (Object)(object)((Component)BetterBreakerBox.breakerBoxInstance).GetComponent<ChargingManager>() == (Object)null)
			{
				((Component)BetterBreakerBox.breakerBoxInstance).gameObject.AddComponent<ChargingManager>();
				PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
				List<UnlockableItem> unlockables = StartOfRound.Instance.unlockablesList.unlockables;
				GameObject prefabObject = unlockables.Find((UnlockableItem u) => u.unlockableName == "Teleporter").prefabObject;
				ShipTeleporter component = prefabObject.GetComponent<ShipTeleporter>();
				localPlayerController.statusEffectAudio.PlayOneShot(component.buttonPressSFX);
			}
		}

		[ClientRpc]
		public void ChargeDisableClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2786422657u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2786422657u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && (Object)(object)((Component)BetterBreakerBox.breakerBoxInstance).GetComponent<ChargingManager>() != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)BetterBreakerBox.breakerBoxInstance).GetComponent<ChargingManager>());
				}
			}
		}

		[ClientRpc]
		public void PrepareCommandClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(119479454u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 119479454u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					BetterBreakerBox.Instance.PrepareCommand(hintPrice.Value);
				}
			}
		}

		[ClientRpc]
		public void ToggleBreakerBoxHumClientRpc(bool on)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007d: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2402368327u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref on, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2402368327u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					BetterBreakerBox.ToggleBreakerBoxHum(on);
				}
			}
		}

		[ClientRpc]
		public void DrainBatteriesClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3946942377u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3946942377u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					BetterBreakerBox.DrainBatteries();
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SetTerminalOutputIndexServerRpc(int value)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0071: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2825422443u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, value);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2825422443u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					terminalOutputIndex.Value = value;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SethasBoughtThisPeriodServerRpc(bool status)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007d: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2150649326u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref status, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2150649326u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					hasBoughtThisPeriod.Value = status;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void MySyncGroupCreditsServerRpc(int credits)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0071: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1296817719u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, credits);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1296817719u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					Terminal val3 = Object.FindObjectOfType<Terminal>();
					val3.SyncGroupCreditsClientRpc(credits, val3.numberOfItemsInDropship);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SetHintPriceServerRpc(int value)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0071: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(183286411u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, value);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 183286411u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					hintPrice.Value = value;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SetActionServerRpc(int index, int value)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(180440706u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, index);
					BytePacker.WriteValueBitPacked(val2, value);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 180440706u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					actions.Value.Data[index] = value;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SetComboServerRpc(int index, int value)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1053860063u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, index);
					BytePacker.WriteValueBitPacked(val2, value);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1053860063u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					combos.Value.Data[index] = value;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void PrepareCommandServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(530458573u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 530458573u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					PrepareCommandClientRpc();
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void ZapRemotePlayerServerRpc(int playerID)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0071: 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_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(4189300279u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerID);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4189300279u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			int playerID2 = playerID;
			ZapEffectsClientRpc(playerID2);
			ZapDamageClientRpc(playerID2, Math.Clamp(BetterBreakerBoxConfig.zapDamage.Value, 0, int.MaxValue));
			if (!BetterBreakerBoxConfig.enableChainZap.Value)
			{
				return;
			}
			Vector3 zappedPlayerPosition = ((Component)RoundManager.Instance.playersManager.allPlayerScripts.Where((PlayerControllerB p) => (int)p.playerClientId == playerID2).FirstOrDefault()).transform.position;
			IEnumerable<PlayerControllerB> enumerable = RoundManager.Instance.playersManager.allPlayerScripts.Where((PlayerControllerB p) => (int)p.playerClientId != playerID2 && Vector3.Distance(((Component)p).transform.position, zappedPlayerPosition) < 5f);
			foreach (PlayerControllerB item in enumerable)
			{
				BetterBreakerBox.logger.LogInfo((object)$"Chain zapping player {item.playerClientId} in range of player {playerID2}");
				ZapEffectsClientRpc((int)item.playerClientId);
				ZapDamageClientRpc((int)item.playerClientId, Math.Clamp(BetterBreakerBoxConfig.zapDamage.Value, 0, int.MaxValue));
			}
		}

		private void Update()
		{
			if (!BetterBreakerBox.isHost || !BetterBreakerBox.isBreakerBoxEnabled || (!BetterBreakerBox.LeaveShip && !BetterBreakerBox.DisarmTurrets && !BetterBreakerBox.BerserkTurrets))
			{
				return;
			}
			if ((Object)(object)timeOfDay == (Object)null)
			{
				timeOfDay = TimeOfDay.Instance;
			}
			float num = timeOfDay.totalTime - timeOfDay.currentDayTime;
			if (BetterBreakerBox.DisarmTurrets)
			{
				if (!disarmTurretsTimerStarted)
				{
					disarmTurretsTimer = ((disarmTurretsTimer > num) ? num : disarmTurretsTimer);
					disarmTurretsTimerStarted = true;
					startTime = disarmTurretsTimer;
					BetterBreakerBox.ActionLock = false;
				}
				disarmTurretsTimer -= Time.deltaTime * timeOfDay.globalTimeSpeedMultiplier;
				if (disarmTurretsTimer <= 0f)
				{
					disarmTurretsTimerStarted = false;
					BetterBreakerBox.DisarmTurrets = false;
					disarmTurretsTimer = BetterBreakerBoxConfig.disarmTurretsTimer.Value;
				}
			}
			else if (BetterBreakerBox.BerserkTurrets)
			{
				if (!berserkTurretsTimerStarted)
				{
					berserkTurretsTimer = ((berserkTurretsTimer > num) ? num : berserkTurretsTimer);
					startTime = berserkTurretsTimer;
					berserkTurretsTimerStarted = true;
					BetterBreakerBox.ActionLock = false;
				}
				berserkTurretsTimer -= Time.deltaTime * timeOfDay.globalTimeSpeedMultiplier;
				if (berserkTurretsTimer <= 0f)
				{
					berserkTurretsTimerStarted = false;
					BetterBreakerBox.BerserkTurrets = false;
					berserkTurretsTimer = BetterBreakerBoxConfig.berserkTurretsTimer.Value;
				}
			}
			else if (BetterBreakerBox.LeaveShip)
			{
				if (!leaveShipTimerStarted)
				{
					leaveShipTimer = ((leaveShipTimer > num) ? num : leaveShipTimer);
					leaveShipTimerStarted = true;
					startTime = leaveShipTimer;
					BetterBreakerBox.ActionLock = false;
				}
				DisplayTimerClientRpc("Ship departs in: ", leaveShipTimer, startTime);
				leaveShipTimer -= Time.deltaTime * timeOfDay.globalTimeSpeedMultiplier;
				if (leaveShipTimer <= 0f)
				{
					leaveShipTimerStarted = false;
					BetterBreakerBox.LeaveShip = false;
					leaveShipTimer = BetterBreakerBoxConfig.shipLeaveTimer.Value;
					DisplayActionMessageClientRpc("Emergency evacuation!", "The Company has deemed this operation too dangerous. Autopilot Ship is departing ahead of schedule!", isWarning: true);
					StartOfRound.Instance.ShipLeave();
					DestroyTimerObjectClientRpc();
				}
			}
		}

		public override void OnNetworkSpawn()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			BetterBreakerBox.logger.LogInfo((object)"Spawned BetterBreakerBoxManager");
			((NetworkBehaviour)this).OnNetworkSpawn();
		}

		public override void OnDestroy()
		{
			BetterBreakerBox.logger.LogInfo((object)"Destroyed BetterBreakerBoxManager");
			if (Instance == this)
			{
				Instance = null;
			}
			((NetworkBehaviour)this).OnDestroy();
		}

		protected override void __initializeVariables()
		{
			if (hintPrice == null)
			{
				throw new Exception("BetterBreakerBoxManager.hintPrice cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)hintPrice).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)hintPrice, "hintPrice");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)hintPrice);
			if (terminalOutputIndex == null)
			{
				throw new Exception("BetterBreakerBoxManager.terminalOutputIndex cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)terminalOutputIndex).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)terminalOutputIndex, "terminalOutputIndex");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)terminalOutputIndex);
			if (hasBoughtThisPeriod == null)
			{
				throw new Exception("BetterBreakerBoxManager.hasBoughtThisPeriod cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)hasBoughtThisPeriod).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)hasBoughtThisPeriod, "hasBoughtThisPeriod");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)hasBoughtThisPeriod);
			if (actions == null)
			{
				throw new Exception("BetterBreakerBoxManager.actions cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)actions).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)actions, "actions");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)actions);
			if (combos == null)
			{
				throw new Exception("BetterBreakerBoxManager.combos cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)combos).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)combos, "combos");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)combos);
			((NetworkBehaviour)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_BetterBreakerBoxManager()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Expected O, but got Unknown
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Expected O, but got Unknown
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Expected O, but got Unknown
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Expected O, but got Unknown
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Expected O, but got Unknown
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Expected O, but got Unknown
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Expected O, but got Unknown
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2719760394u, new RpcReceiveHandler(__rpc_handler_2719760394));
			NetworkManager.__rpc_func_table.Add(3294938841u, new RpcReceiveHandler(__rpc_handler_3294938841));
			NetworkManager.__rpc_func_table.Add(3577715068u, new RpcReceiveHandler(__rpc_handler_3577715068));
			NetworkManager.__rpc_func_table.Add(3666406714u, new RpcReceiveHandler(__rpc_handler_3666406714));
			NetworkManager.__rpc_func_table.Add(1941160110u, new RpcReceiveHandler(__rpc_handler_1941160110));
			NetworkManager.__rpc_func_table.Add(2019522705u, new RpcReceiveHandler(__rpc_handler_2019522705));
			NetworkManager.__rpc_func_table.Add(3597902685u, new RpcReceiveHandler(__rpc_handler_3597902685));
			NetworkManager.__rpc_func_table.Add(649523096u, new RpcReceiveHandler(__rpc_handler_649523096));
			NetworkManager.__rpc_func_table.Add(2786422657u, new RpcReceiveHandler(__rpc_handler_2786422657));
			NetworkManager.__rpc_func_table.Add(119479454u, new RpcReceiveHandler(__rpc_handler_119479454));
			NetworkManager.__rpc_func_table.Add(2402368327u, new RpcReceiveHandler(__rpc_handler_2402368327));
			NetworkManager.__rpc_func_table.Add(3946942377u, new RpcReceiveHandler(__rpc_handler_3946942377));
			NetworkManager.__rpc_func_table.Add(2825422443u, new RpcReceiveHandler(__rpc_handler_2825422443));
			NetworkManager.__rpc_func_table.Add(2150649326u, new RpcReceiveHandler(__rpc_handler_2150649326));
			NetworkManager.__rpc_func_table.Add(1296817719u, new RpcReceiveHandler(__rpc_handler_1296817719));
			NetworkManager.__rpc_func_table.Add(183286411u, new RpcReceiveHandler(__rpc_handler_183286411));
			NetworkManager.__rpc_func_table.Add(180440706u, new RpcReceiveHandler(__rpc_handler_180440706));
			NetworkManager.__rpc_func_table.Add(1053860063u, new RpcReceiveHandler(__rpc_handler_1053860063));
			NetworkManager.__rpc_func_table.Add(530458573u, new RpcReceiveHandler(__rpc_handler_530458573));
			NetworkManager.__rpc_func_table.Add(4189300279u, new RpcReceiveHandler(__rpc_handler_4189300279));
		}

		private static void __rpc_handler_2719760394(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0067: 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_009f: 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_00b4: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string headerText = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref headerText, false);
				}
				bool flag2 = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
				string bodyText = null;
				if (flag2)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref bodyText, false);
				}
				bool isWarning = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref isWarning, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((BetterBreakerBoxManager)(object)target).DisplayActionMessageClientRpc(headerText, bodyText, isWarning);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3294938841(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0067: 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_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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string name = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref name, false);
				}
				float timeLeft = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref timeLeft, default(ForPrimitives));
				float totalTime = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref totalTime, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((BetterBreakerBoxManager)(object)target).DisplayTimerClientRpc(name, timeLeft, totalTime);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3577715068(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((BetterBreakerBoxManager)(object)target).CreateTimerObjectClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3666406714(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((BetterBreakerBoxManager)(object)target).DestroyTimerObjectClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1941160110(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((BetterBreakerBoxManager)(object)target).ZapClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2019522705(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0043: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerID = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerID);
				int damage = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref damage);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((BetterBreakerBoxManager)(object)target).ZapDamageClientRpc(playerID, damage);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3597902685(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerID = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerID);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((BetterBreakerBoxManager)(object)target).ZapEffectsClientRpc(playerID);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_649523096(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((BetterBreakerBoxManager)(object)target).ChargeEnableClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2786422657(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((BetterBreakerBoxManager)(object)target).ChargeDisableClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_119479454(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((BetterBreakerBoxManager)(object)target).PrepareCommandClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2402368327(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invali