Decompiled source of HackPad Weight Patch v0.0.1

HackPad-WeightPatch.dll

Decompiled 2 months ago
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PortableMultiTool.Items;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("HackPad-WeightPatch")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Fixes a bug with the HackPad's weight caused by changes in the base game since the original release")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1+7a741e1cf660783db05303df582cd48cd5b2c5b7")]
[assembly: AssemblyProduct("HackPad-WeightPatch")]
[assembly: AssemblyTitle("HackPad-WeightPatch")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.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 System.Runtime.Versioning
{
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiresPreviewFeaturesAttribute : Attribute
	{
		public string? Message { get; }

		public string? Url { get; set; }

		public RequiresPreviewFeaturesAttribute()
		{
		}

		public RequiresPreviewFeaturesAttribute(string? message)
		{
			Message = message;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CallerArgumentExpressionAttribute : Attribute
	{
		public string ParameterName { get; }

		public CallerArgumentExpressionAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CollectionBuilderAttribute : Attribute
	{
		public Type BuilderType { get; }

		public string MethodName { get; }

		public CollectionBuilderAttribute(Type builderType, string methodName)
		{
			BuilderType = builderType;
			MethodName = methodName;
		}
	}
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CompilerFeatureRequiredAttribute : Attribute
	{
		public const string RefStructs = "RefStructs";

		public const string RequiredMembers = "RequiredMembers";

		public string FeatureName { get; }

		public bool IsOptional { get; set; }

		public CompilerFeatureRequiredAttribute(string featureName)
		{
			FeatureName = featureName;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class InterpolatedStringHandlerArgumentAttribute : Attribute
	{
		public string[] Arguments { get; }

		public InterpolatedStringHandlerArgumentAttribute(string argument)
		{
			Arguments = new string[1] { argument };
		}

		public InterpolatedStringHandlerArgumentAttribute(params string[] arguments)
		{
			Arguments = arguments;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class InterpolatedStringHandlerAttribute : Attribute
	{
	}
	[EditorBrowsable(EditorBrowsableState.Never)]
	[ExcludeFromCodeCoverage]
	internal static class IsExternalInit
	{
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ModuleInitializerAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiredMemberAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[EditorBrowsable(EditorBrowsableState.Never)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiresLocationAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class SkipLocalsInitAttribute : Attribute
	{
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ExperimentalAttribute : Attribute
	{
		public string DiagnosticId { get; }

		public string? UrlFormat { get; set; }

		public ExperimentalAttribute(string diagnosticId)
		{
			DiagnosticId = diagnosticId;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	internal sealed class MemberNotNullAttribute : Attribute
	{
		public string[] Members { get; }

		public MemberNotNullAttribute(string member)
		{
			Members = new string[1] { member };
		}

		public MemberNotNullAttribute(params string[] members)
		{
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	internal sealed class MemberNotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public string[] Members { get; }

		public MemberNotNullWhenAttribute(bool returnValue, string member)
		{
			ReturnValue = returnValue;
			Members = new string[1] { member };
		}

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class SetsRequiredMembersAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class StringSyntaxAttribute : Attribute
	{
		public const string CompositeFormat = "CompositeFormat";

		public const string DateOnlyFormat = "DateOnlyFormat";

		public const string DateTimeFormat = "DateTimeFormat";

		public const string EnumFormat = "EnumFormat";

		public const string GuidFormat = "GuidFormat";

		public const string Json = "Json";

		public const string NumericFormat = "NumericFormat";

		public const string Regex = "Regex";

		public const string TimeOnlyFormat = "TimeOnlyFormat";

		public const string TimeSpanFormat = "TimeSpanFormat";

		public const string Uri = "Uri";

		public const string Xml = "Xml";

		public string Syntax { get; }

		public object?[] Arguments { get; }

		public StringSyntaxAttribute(string syntax)
		{
			Syntax = syntax;
			Arguments = new object[0];
		}

		public StringSyntaxAttribute(string syntax, params object?[] arguments)
		{
			Syntax = syntax;
			Arguments = arguments;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class UnscopedRefAttribute : Attribute
	{
	}
}
namespace HackPadWeightPatch
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.willis.lc.portablehackpad.weightpatch", "HackPad Weight Patch", "0.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		internal static Plugin Instance { get; private set; }

		public ManualLogSource Logger => ((BaseUnityPlugin)this).Logger;

		public void Awake()
		{
			Instance = this;
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.willis.lc.portablehackpad.weightpatch");
		}
	}
	internal static class GeneratedPluginInfo
	{
		public const string Identifier = "com.willis.lc.portablehackpad.weightpatch";

		public const string Name = "HackPad Weight Patch";

		public const string Version = "0.0.1";
	}
}
namespace HackPadWeightPatch.Patches
{
	[HarmonyPatch(typeof(MultiTool))]
	internal class MultiToolPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Awake")]
		private static void Awake_Patch(MultiTool __instance)
		{
			((GrabbableObject)__instance).itemProperties.weight = 1f;
		}
	}
}

PortableMultiTool.dll

Decompiled 2 months ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using LethalSettings.UI;
using LethalSettings.UI.Components;
using Microsoft.CodeAnalysis;
using PortableMultiTool.Items;
using PortableMultiTool.Networking;
using PortableMultiTool.Properties;
using PortableMultiTool.Util;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("PortableMultiTool")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+85d2a83a763b752ebaf4bd5bbbaac6237a5cfb50")]
[assembly: AssemblyProduct("PortableMultiTool")]
[assembly: AssemblyTitle("PortableMultiTool")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
internal class <Module>
{
	static <Module>()
	{
	}
}
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 PortableMultiTool
{
	internal static class Assets
	{
		private static AssetBundle bundle;

		internal static GameObject CustomNetworkedPlayerPrefab { get; private set; }

		internal static Sprite HandIcon { get; private set; }

		internal static MultiTool MultiToolPrefab { get; private set; }

		public static void LoadAssets()
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			PortableMultiToolBase.Instance.Logger.LogWarning((object)"Loading custom assets");
			bundle = AssetBundle.LoadFromMemory(Resources.assets);
			HandIcon = bundle.LoadAsset<Sprite>("HandIcon");
			MultiToolPrefab = bundle.LoadAsset<GameObject>("MultiTool").GetComponent<MultiTool>();
			NetworkPrefabs.RegisterNetworkPrefab(((Component)MultiToolPrefab).gameObject);
			ShopUtils.RegisterDynamicShopItem(((GrabbableObject)MultiToolPrefab).itemProperties, () => Config.hackPadCost.Value);
			CustomNetworkedPlayerPrefab = new GameObject("Custom Networked Player Controller");
			((Object)CustomNetworkedPlayerPrefab).hideFlags = (HideFlags)61;
			CustomNetworkedPlayerPrefab.SetActive(false);
			CustomNetworkedPlayerPrefab.AddComponent<NetworkObject>();
			CustomNetworkedPlayerPrefab.AddComponent<CustomNetworkedPlayer>();
			NetworkPrefabs.RegisterNetworkPrefab(CustomNetworkedPlayerPrefab);
		}
	}
	[Serializable]
	[HarmonyPatch]
	public class Config : SyncedInstance<Config>
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__OnRequestSync;

			public static HandleNamedMessageDelegate <1>__OnReceiveSync;
		}

		public static ConfigEntry<int> hackPadCost;

		public static ConfigEntry<float> hackPadHackDuration;

		public static ConfigEntry<float> hackPadBatteryLife;

		public Config(ConfigFile cfg)
		{
			InitInstance(this);
			hackPadCost = cfg.Bind<int>("com.willis.lc.portablehackpad", "HackPad_Cost", 60, "Cost (in credits) to purchase the Hack Pad from the ship computer.");
			hackPadHackDuration = cfg.Bind<float>("com.willis.lc.portablehackpad", "HackPad_HackDuration", 5f, "Number of seconds it takes for the Hack Pad to complete its hack.");
			hackPadBatteryLife = cfg.Bind<float>("com.willis.lc.portablehackpad", "HackPad_BatteryLife", 60f, "Number of seconds the Hack Pad battery lasts from a full charge.");
		}

		public static void RequestSync()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (!SyncedInstance<Config>.IsClient)
			{
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(SyncedInstance<Config>.IntSize, (Allocator)2, -1);
			try
			{
				SyncedInstance<Config>.MessageManager.SendNamedMessage("HackPad_OnRequestConfigSync", 0uL, val, (NetworkDelivery)3);
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

		public static void OnRequestSync(ulong clientId, FastBufferReader _)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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)
			if (!SyncedInstance<Config>.IsHost)
			{
				return;
			}
			PortableMultiToolBase.Instance.Logger.LogInfo((object)$"Config sync request received from client: {clientId}");
			byte[] array = SyncedInstance<Config>.SerializeToBytes(SyncedInstance<Config>.Instance);
			int num = array.Length;
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(num + SyncedInstance<Config>.IntSize, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteBytesSafe(array, -1, 0);
				SyncedInstance<Config>.MessageManager.SendNamedMessage("HackPad_OnReceiveConfigSync", clientId, val, (NetworkDelivery)3);
			}
			catch (Exception arg)
			{
				PortableMultiToolBase.Instance.Logger.LogInfo((object)$"Error occurred syncing config with client: {clientId}\n{arg}");
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

		public static void OnReceiveSync(ulong _, FastBufferReader reader)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if (!((FastBufferReader)(ref reader)).TryBeginRead(SyncedInstance<Config>.IntSize))
			{
				PortableMultiToolBase.Instance.Logger.LogError((object)"Config sync error: Could not begin reading buffer.");
				return;
			}
			int num = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
			if (!((FastBufferReader)(ref reader)).TryBeginRead(num))
			{
				PortableMultiToolBase.Instance.Logger.LogError((object)"Config sync error: Host could not sync.");
				return;
			}
			byte[] data = new byte[num];
			((FastBufferReader)(ref reader)).ReadBytesSafe(ref data, num, 0);
			SyncedInstance<Config>.SyncInstance(data);
			PortableMultiToolBase.Instance.Logger.LogInfo((object)"Successfully synced config with host.");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		public static void InitializeLocalPlayer()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			if (SyncedInstance<Config>.IsHost)
			{
				CustomMessagingManager messageManager = SyncedInstance<Config>.MessageManager;
				object obj = <>O.<0>__OnRequestSync;
				if (obj == null)
				{
					HandleNamedMessageDelegate val = OnRequestSync;
					<>O.<0>__OnRequestSync = val;
					obj = (object)val;
				}
				messageManager.RegisterNamedMessageHandler("HackPad_OnRequestConfigSync", (HandleNamedMessageDelegate)obj);
				SyncedInstance<Config>.Synced = true;
				return;
			}
			SyncedInstance<Config>.Synced = false;
			CustomMessagingManager messageManager2 = SyncedInstance<Config>.MessageManager;
			object obj2 = <>O.<1>__OnReceiveSync;
			if (obj2 == null)
			{
				HandleNamedMessageDelegate val2 = OnReceiveSync;
				<>O.<1>__OnReceiveSync = val2;
				obj2 = (object)val2;
			}
			messageManager2.RegisterNamedMessageHandler("HackPad_OnReceiveConfigSync", (HandleNamedMessageDelegate)obj2);
			RequestSync();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")]
		public static void PlayerLeave()
		{
			SyncedInstance<Config>.RevertSync();
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.willis.lc.portablehackpad", "PortableHackPad", "1.1.3")]
	public class PortableMultiToolBase : BaseUnityPlugin
	{
		public const string MODGUID = "com.willis.lc.portablehackpad";

		public const string MODNAME = "PortableHackPad";

		public const string MODVERSION = "1.1.3";

		public static PortableMultiToolBase Instance { get; private set; }

		public static Config ModConfiguration { get; private set; }

		public ManualLogSource Logger => ((BaseUnityPlugin)this).Logger;

		public void Awake()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			ModConfiguration = new Config(((BaseUnityPlugin)this).Config);
			Assets.LoadAssets();
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.willis.lc.portablehackpad");
			NetcodeWeaver();
			new GameObject("Hack Pad Settings Manager").AddComponent<SettingsMenu>();
		}

		private static void NetcodeWeaver()
		{
			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 class SettingsMenu : MonoBehaviour
	{
		private SliderComponent costSlider;

		private SliderComponent hackTimeSlider;

		private SliderComponent batteryLifeSlider;

		private static SettingsMenu Instance { get; set; }

		private bool IsInGame => (Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsClient;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			else if ((Object)(object)Instance != (Object)(object)this)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
		}

		private void Start()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_0079: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Expected O, but got Unknown
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: 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_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Expected O, but got Unknown
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Expected O, but got Unknown
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Expected O, but got Unknown
			costSlider = new SliderComponent
			{
				Text = "Hack Pad Cost: $",
				Value = Config.hackPadCost.Value,
				MinValue = 10f,
				MaxValue = 150f,
				WholeNumbers = true,
				ShowValue = true,
				OnValueChanged = delegate(SliderComponent self, float value)
				{
					Config.hackPadCost.Value = (int)value;
				}
			};
			hackTimeSlider = new SliderComponent
			{
				Text = "Hack Duration (seconds):",
				Value = Config.hackPadHackDuration.Value,
				MinValue = 1f,
				MaxValue = 20f,
				WholeNumbers = true,
				ShowValue = true,
				OnValueChanged = delegate(SliderComponent self, float value)
				{
					Config.hackPadHackDuration.Value = (int)value;
				}
			};
			batteryLifeSlider = new SliderComponent
			{
				Text = "Battery Life (seconds):",
				Value = Config.hackPadBatteryLife.Value,
				MinValue = 10f,
				MaxValue = 120f,
				WholeNumbers = true,
				ShowValue = true,
				OnValueChanged = delegate(SliderComponent self, float value)
				{
					Config.hackPadBatteryLife.Value = (int)value;
				}
			};
			ModSettingsConfig val = new ModSettingsConfig();
			val.Name = "Hack Pad";
			val.Id = "com.willis.lc.portablehackpad";
			val.Description = "Adds the \"Hack Pad\" item as purchasable equipment allowing the holder to disable turrets and open/close Big Doors they come across while scrap hunting.";
			val.MenuComponents = (MenuComponent[])(object)new MenuComponent[4]
			{
				(MenuComponent)costSlider,
				(MenuComponent)hackTimeSlider,
				(MenuComponent)batteryLifeSlider,
				(MenuComponent)new ButtonComponent
				{
					Text = "Restore Defaults",
					OnClick = ResetDefaults
				}
			};
			ModMenu.RegisterMod(val);
		}

		private void Update()
		{
			SliderComponent obj = costSlider;
			SliderComponent obj2 = hackTimeSlider;
			bool flag2 = (batteryLifeSlider.Enabled = !IsInGame);
			bool enabled = (obj2.Enabled = flag2);
			obj.Enabled = enabled;
		}

		private void ResetDefaults(ButtonComponent component)
		{
			Config.hackPadCost.Value = (int)((ConfigEntryBase)Config.hackPadCost).DefaultValue;
			costSlider.Value = Config.hackPadCost.Value;
			Config.hackPadHackDuration.Value = (float)((ConfigEntryBase)Config.hackPadHackDuration).DefaultValue;
			hackTimeSlider.Value = Config.hackPadHackDuration.Value;
			Config.hackPadBatteryLife.Value = (float)((ConfigEntryBase)Config.hackPadBatteryLife).DefaultValue;
			batteryLifeSlider.Value = Config.hackPadBatteryLife.Value;
		}
	}
}
namespace PortableMultiTool.Util
{
	public class AudioMixerFixer : MonoBehaviour
	{
		private static AudioMixerGroup _masterDiageticMixer;

		[SerializeField]
		private List<AudioSource> sourcesToFix;

		public static AudioMixerGroup MasterDiageticMixer
		{
			get
			{
				if ((Object)(object)_masterDiageticMixer == (Object)null)
				{
					AudioSource val = (from p in ((Component)GameNetworkManager.Instance).GetComponent<NetworkManager>().NetworkConfig.Prefabs.Prefabs
						select p.Prefab.GetComponentInChildren<NoisemakerProp>() into p
						where (Object)(object)p != (Object)null
						select ((Component)p).GetComponentInChildren<AudioSource>() into p
						where (Object)(object)p != (Object)null
						select p).FirstOrDefault();
					if ((Object)(object)val == (Object)null)
					{
						throw new Exception("Failed to locate a suitable AudioSource output mixer to reference! Could you be calling this method before the GameNetworkManager is initialized?");
					}
					_masterDiageticMixer = val.outputAudioMixerGroup;
				}
				return _masterDiageticMixer;
			}
		}

		private void Start()
		{
			AudioSource[] componentsInChildren = ((Component)this).GetComponentsInChildren<AudioSource>();
			foreach (AudioSource item in componentsInChildren)
			{
				if (!sourcesToFix.Contains(item))
				{
					sourcesToFix.Add(item);
				}
			}
			foreach (AudioSource item2 in sourcesToFix)
			{
				item2.outputAudioMixerGroup = MasterDiageticMixer;
			}
		}
	}
	public static class ShopUtils
	{
		private static readonly Dictionary<Item, Func<int>> itemCreditsWorthMap = new Dictionary<Item, Func<int>>();

		private static readonly Dictionary<TerminalNode, Func<int>> terminalNodeCostMap = new Dictionary<TerminalNode, Func<int>>();

		public static void RegisterDynamicShopItem(Item item, Func<int> costProvider)
		{
			TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
			((Object)val).name = item.itemName.Replace(" ", "-") + "BuyNode1";
			val.displayText = "You have requested to order " + item.itemName + ". Amount: [variableAmount].\nTotal cost of items: [totalCost].\n\nPlease CONFIRM or DENY.\r\n\r\n";
			val.clearPreviousText = true;
			val.maxCharactersToType = 35;
			itemCreditsWorthMap.Add(item, costProvider);
			terminalNodeCostMap.Add(val, costProvider);
			Items.RegisterShopItem(item, val, (TerminalNode)null, (TerminalNode)null, -1);
		}

		public static int GetTerminalNodeCost(TerminalNode node)
		{
			if (terminalNodeCostMap.TryGetValue(node, out var value))
			{
				return value();
			}
			return node.itemCost;
		}

		public static int GetItemCreditsWorth(Item item)
		{
			if (itemCreditsWorthMap.TryGetValue(item, out var value))
			{
				return value();
			}
			return item.creditsWorth;
		}
	}
}
namespace PortableMultiTool.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					ResourceManager resourceManager = new ResourceManager("PortableMultiTool.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal static byte[] assets
		{
			get
			{
				object @object = ResourceManager.GetObject("assets", resourceCulture);
				return (byte[])@object;
			}
		}

		internal Resources()
		{
		}
	}
}
namespace PortableMultiTool.Patches
{
	[HarmonyPatch(typeof(Terminal))]
	public class Terminal_Patches
	{
		[HarmonyTranspiler]
		[HarmonyPatch("LoadNewNodeIfAffordable")]
		[HarmonyPatch("OnSubmit")]
		[HarmonyPatch("TextPostProcess")]
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator ilGenerator)
		{
			FieldInfo itemCostFieldInfo = AccessTools.Field(typeof(TerminalNode), "itemCost");
			MethodInfo getTerminalNodeCostMemthodInfo = AccessTools.Method(typeof(ShopUtils), "GetTerminalNodeCost", (Type[])null, (Type[])null);
			FieldInfo creditsWorthFieldInfo = AccessTools.Field(typeof(Item), "creditsWorth");
			MethodInfo getItemCreditsWorthMethodInfo = AccessTools.Method(typeof(ShopUtils), "GetItemCreditsWorth", (Type[])null, (Type[])null);
			foreach (CodeInstruction instruction in instructions)
			{
				if (instruction.opcode == OpCodes.Ldfld && instruction.operand == itemCostFieldInfo)
				{
					yield return new CodeInstruction(OpCodes.Call, (object)getTerminalNodeCostMemthodInfo);
				}
				else if (instruction.opcode == OpCodes.Ldfld && instruction.operand == creditsWorthFieldInfo)
				{
					yield return new CodeInstruction(OpCodes.Call, (object)getItemCreditsWorthMethodInfo);
				}
				else
				{
					yield return instruction;
				}
			}
		}
	}
}
namespace PortableMultiTool.Networking
{
	internal class CustomNetworkedPlayer : NetworkBehaviour
	{
		private PlayerControllerB playerController;

		public void Initialize(PlayerControllerB playerController)
		{
			this.playerController = playerController;
		}

		public override void OnNetworkSpawn()
		{
			((Behaviour)this).enabled = true;
			((Component)this).gameObject.SetActive(true);
			((Component)this).transform.SetParent(((Component)playerController).transform);
			((NetworkBehaviour)this).OnNetworkSpawn();
		}

		private void Update()
		{
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if ((Object)(object)localPlayerController != (Object)null && (Object)(object)playerController == (Object)(object)localPlayerController)
			{
				LocalUpdate();
			}
		}

		private void LocalUpdate()
		{
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected internal override string __getTypeName()
		{
			return "CustomNetworkedPlayer";
		}
	}
	[Serializable]
	public class SyncedInstance<T>
	{
		[NonSerialized]
		protected static int IntSize = 4;

		internal static CustomMessagingManager MessageManager => NetworkManager.Singleton.CustomMessagingManager;

		internal static bool IsClient => NetworkManager.Singleton.IsClient;

		internal static bool IsHost => NetworkManager.Singleton.IsHost;

		public static T Default { get; private set; }

		public static T Instance { get; private set; }

		public static bool Synced { get; internal set; }

		protected void InitInstance(T instance)
		{
			Default = instance;
			Instance = instance;
			IntSize = 4;
		}

		internal static void SyncInstance(byte[] data)
		{
			Instance = DeserializeFromBytes(data);
			Synced = true;
		}

		internal static void RevertSync()
		{
			Instance = Default;
			Synced = false;
		}

		public static byte[] SerializeToBytes(T val)
		{
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			using MemoryStream memoryStream = new MemoryStream();
			try
			{
				binaryFormatter.Serialize(memoryStream, val);
				return memoryStream.ToArray();
			}
			catch (Exception arg)
			{
				PortableMultiToolBase.Instance.Logger.LogError((object)$"Error serializing instance: {arg}");
				return null;
			}
		}

		public static T DeserializeFromBytes(byte[] data)
		{
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			using MemoryStream serializationStream = new MemoryStream(data);
			try
			{
				return (T)binaryFormatter.Deserialize(serializationStream);
			}
			catch (Exception arg)
			{
				PortableMultiToolBase.Instance.Logger.LogError((object)$"Error deserializing instance: {arg}");
				return default(T);
			}
		}
	}
}
namespace PortableMultiTool.Items
{
	public class MultiTool : GrabbableObject
	{
		private enum AudioType
		{
			IDLE,
			HACK_PROGRESS,
			HACK_SUCCESS,
			HACK_FAILURE,
			HACK_ABORT,
			POWER_ON,
			POWER_OFF
		}

		[SerializeField]
		private TextMeshProUGUI screenText;

		[SerializeField]
		private string screenTextPrefix;

		[SerializeField]
		private string screenTextCaret;

		[SerializeField]
		private float caretBlinkRate = 0.5f;

		private float hackProgress = -1f;

		private bool displayingCompletedHack = false;

		private readonly Dictionary<TerminalAccessibleObject, InteractTrigger> hackTriggers = new Dictionary<TerminalAccessibleObject, InteractTrigger>();

		private TerminalAccessibleObject currentHackTarget = null;

		[SerializeField]
		private AudioSource idle;

		[SerializeField]
		private AudioSource hackInProgress;

		[SerializeField]
		private AudioSource hackFailure;

		[SerializeField]
		private AudioSource hackSuccess;

		[SerializeField]
		private AudioSource hackAbort;

		[SerializeField]
		private AudioSource powerOn;

		[SerializeField]
		private AudioSource powerOff;

		private Dictionary<AudioType, AudioSource> audioSourceMap = new Dictionary<AudioType, AudioSource>();

		private Coroutine idleCoroutine;

		private bool IsHacking => hackProgress > 0f && (Object)(object)currentHackTarget != (Object)null;

		private void Awake()
		{
			base.itemProperties.batteryUsage = Config.hackPadBatteryLife.Value;
			audioSourceMap = new Dictionary<AudioType, AudioSource>
			{
				{
					AudioType.IDLE,
					idle
				},
				{
					AudioType.HACK_PROGRESS,
					hackInProgress
				},
				{
					AudioType.HACK_SUCCESS,
					hackSuccess
				},
				{
					AudioType.HACK_FAILURE,
					hackFailure
				},
				{
					AudioType.HACK_ABORT,
					hackAbort
				},
				{
					AudioType.POWER_ON,
					powerOn
				},
				{
					AudioType.POWER_OFF,
					powerOff
				}
			};
		}

		private void OnEnable()
		{
			idleCoroutine = ((MonoBehaviour)this).StartCoroutine(IdleCoroutine());
		}

		private void OnDisable()
		{
			if (idleCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(idleCoroutine);
			}
		}

		private void FixedUpdate()
		{
			//IL_00ea: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			if (base.isBeingUsed)
			{
				((TMP_Text)screenText).text = CalculateScreenText();
				if ((Object)(object)base.playerHeldBy == (Object)null || !((NetworkBehaviour)this).IsOwner || displayingCompletedHack)
				{
					return;
				}
				List<TerminalAccessibleObject> list = hackTriggers.Keys.ToList();
				foreach (TerminalAccessibleObject item in list)
				{
					if (item.inCooldown)
					{
						Object.Destroy((Object)(object)((Component)hackTriggers[item]).gameObject);
						hackTriggers.Remove(item);
					}
				}
				Ray val = default(Ray);
				((Ray)(ref val))..ctor(((Component)base.playerHeldBy.gameplayCamera).transform.position, ((Component)base.playerHeldBy.gameplayCamera).transform.forward);
				TerminalAccessibleObject val2 = (from c in (from hit in Physics.RaycastAll(val, 3f)
						orderby ((RaycastHit)(ref hit)).distance
						select hit).SelectMany((RaycastHit hit) => (IEnumerable<TerminalAccessibleObject>)(object)new TerminalAccessibleObject[2]
					{
						((Component)((RaycastHit)(ref hit)).collider).GetComponentInChildren<TerminalAccessibleObject>(),
						((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent<TerminalAccessibleObject>()
					})
					where (Object)(object)c != (Object)null && !c.inCooldown && c.isPoweredOn
					where !((Object)((Component)c).gameObject).name.ToLower().Contains("landmine")
					where !hackTriggers.ContainsKey(c)
					select c).FirstOrDefault();
				if ((Object)(object)val2 != (Object)null)
				{
					InteractTrigger value = ConfigureHackInteraction(val2, OnHackProgress, OnFinishHack, OnStopHack, Config.hackPadHackDuration.Value);
					hackTriggers.Add(val2, value);
				}
			}
			else
			{
				((TMP_Text)screenText).text = "";
			}
		}

		private IEnumerator IdleCoroutine()
		{
			while (true)
			{
				yield return (object)new WaitForSeconds(3f);
				if (((NetworkBehaviour)this).IsOwner && base.isBeingUsed)
				{
					PlayAudio(AudioType.IDLE);
				}
			}
		}

		[ServerRpc]
		private void PlayAudio_ServerRpc(int type, bool isLoud)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(489812496u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, type);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref isLoud, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 489812496u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				PlayAudio_ClientRpc(type, isLoud);
			}
		}

		[ClientRpc]
		private void PlayAudio_ClientRpc(int type, bool isLoud)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2585778738u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, type);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref isLoud, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2585778738u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			if (audioSourceMap.TryGetValue((AudioType)type, out var value))
			{
				PortableMultiToolBase.Instance.Logger.LogWarning((object)$"Playing audio {type}");
				value.Play();
				WalkieTalkie.TransmitOneShotAudio(value, value.clip, value.volume);
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 10f, 0.5f, 0, base.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
				if (isLoud && (Object)(object)base.playerHeldBy != (Object)null)
				{
					base.playerHeldBy.timeSinceMakingLoudNoise = 0f;
				}
			}
			else
			{
				PortableMultiToolBase.Instance.Logger.LogWarning((object)$"Tried to play invalid audio type of value: {type}");
			}
		}

		private void PlayAudio(AudioType type, bool isLoud = true)
		{
			if (((NetworkBehaviour)this).IsOwner)
			{
				if (type != 0)
				{
					StopAudio();
				}
				if (((NetworkBehaviour)this).IsHost)
				{
					PlayAudio_ClientRpc((int)type, isLoud);
				}
				else
				{
					PlayAudio_ServerRpc((int)type, isLoud);
				}
			}
		}

		[ServerRpc]
		private void StopAudio_ServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(4015297935u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4015297935u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				StopAudio_ClientRpc();
			}
		}

		[ClientRpc]
		private void StopAudio_ClientRpc()
		{
			//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)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1057787546u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1057787546u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			foreach (AudioType key in audioSourceMap.Keys)
			{
				audioSourceMap[key].Stop();
			}
		}

		private void StopAudio()
		{
			if (((NetworkBehaviour)this).IsOwner)
			{
				if (((NetworkBehaviour)this).IsHost || ((NetworkBehaviour)this).IsServer)
				{
					StopAudio_ClientRpc();
				}
				else
				{
					StopAudio_ServerRpc();
				}
			}
		}

		private string CalculateScreenText()
		{
			if (IsHacking)
			{
				if (hackProgress >= 1f)
				{
					return "hacking...\n0%  . . . . . . . . . \n10% . . . . . . . . . \n20% . . . . . . . . . \n30% . . . . . . . . . \n40% . . . . . . . . . \n50% . . . . . . . . . \n60% . . . . . . . . . \n70% . . . . . . . . . \n80% . . . . . . . . . \n90% . . . . . . . . . \n100% - Passcode: " + currentHackTarget.objectCode.ToUpper() + "!";
				}
				StringBuilder stringBuilder = new StringBuilder();
				stringBuilder.AppendLine("hacking...");
				int num = 10;
				int num2 = 9;
				int num3 = num * num2;
				int num4 = (int)Math.Ceiling(hackProgress * (float)num3);
				for (int i = 0; i <= 90; i += 10)
				{
					stringBuilder.Append((i == 0) ? "0%  " : $"{i}% ");
					int count = Math.Min(num2, num4);
					stringBuilder.Append(new string('.', count).Replace(".", ". "));
					stringBuilder.AppendLine();
					num4 -= num2;
					if (num4 <= 0)
					{
						break;
					}
				}
				return stringBuilder.ToString();
			}
			int count2 = (int)((double)(Time.time / caretBlinkRate) % 3.9);
			string text = new string(screenTextCaret[0], count2);
			return screenTextPrefix + text;
		}

		public override void DiscardItem()
		{
			base.isBeingUsed = false;
			((GrabbableObject)this).DiscardItem();
			ClearTriggers();
		}

		public override void UseUpBatteries()
		{
			((GrabbableObject)this).UseUpBatteries();
			ClearTriggers();
			PlayAudio(AudioType.POWER_OFF);
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			PortableMultiToolBase.Instance.Logger.LogWarning((object)$"Item used: {used}; button down: {buttonDown}");
			if (!used)
			{
				ClearTriggers();
				PlayAudio(AudioType.POWER_OFF);
			}
			else
			{
				PlayAudio(AudioType.POWER_ON);
			}
		}

		private void ClearTriggers()
		{
			foreach (InteractTrigger value in hackTriggers.Values)
			{
				Object.Destroy((Object)(object)((Component)value).gameObject);
			}
			hackTriggers.Clear();
			ResetHackProgress();
		}

		private void ResetHackProgress()
		{
			hackProgress = -1f;
		}

		private void OnHackProgress(TerminalAccessibleObject hackTarget, float progress)
		{
			if (!IsHacking)
			{
				OnStartHack(hackTarget, progress);
			}
			hackProgress = progress;
			currentHackTarget = hackTarget;
		}

		private void OnStartHack(TerminalAccessibleObject hackTarget, float progress)
		{
			PlayAudio(AudioType.HACK_PROGRESS);
		}

		private void OnFinishHack(TerminalAccessibleObject hackTarget, PlayerControllerB interactingPlayer)
		{
			PortableMultiToolBase.Instance.Logger.LogWarning((object)"Finished hacking");
			PlayAudio(AudioType.HACK_SUCCESS);
			ClearTriggers();
			displayingCompletedHack = true;
			hackProgress = 1f;
			((MonoBehaviour)this).StartCoroutine(ExecuteAfter(3f, delegate
			{
				displayingCompletedHack = false;
				ResetHackProgress();
				currentHackTarget = null;
			}));
			hackTarget.CallFunctionFromTerminal();
		}

		private void OnStopHack(TerminalAccessibleObject hackTarget, PlayerControllerB interactingPlayer)
		{
			if (!displayingCompletedHack)
			{
				PortableMultiToolBase.Instance.Logger.LogWarning((object)"Hacking aborted");
				PlayAudio(AudioType.HACK_ABORT);
				ResetHackProgress();
				currentHackTarget = null;
			}
		}

		private IEnumerator ExecuteAfter(float seconds, Action action)
		{
			yield return (object)new WaitForSeconds(seconds);
			action();
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			((Behaviour)screenText).enabled = true;
		}

		public override void PocketItem()
		{
			((GrabbableObject)this).PocketItem();
			StopAudio();
			((Behaviour)screenText).enabled = false;
		}

		private static InteractTrigger ConfigureHackInteraction(TerminalAccessibleObject target, Action<TerminalAccessibleObject, float> onInteractionHold, Action<TerminalAccessibleObject, PlayerControllerB> onFinishInteract, Action<TerminalAccessibleObject, PlayerControllerB> onStopInteract, float hackDuration)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Expected O, but got Unknown
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Expected O, but got Unknown
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Expected O, but got Unknown
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Expected O, but got Unknown
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Expected O, but got Unknown
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
			val.transform.position = ((Component)target).transform.position;
			if (target.isBigDoor)
			{
				Transform transform = val.transform;
				transform.position += Vector3.up * 2f;
				val.transform.localScale = new Vector3(1f, 3f, 1f);
			}
			BoxCollider component = val.GetComponent<BoxCollider>();
			if (component != null && (Object)(object)component != (Object)null)
			{
				((Collider)component).isTrigger = true;
			}
			else
			{
				((Collider)val.AddComponent<BoxCollider>()).isTrigger = true;
			}
			val.tag = "InteractTrigger";
			val.layer = LayerMask.NameToLayer("InteractableObject");
			InteractTrigger val2 = val.AddComponent<InteractTrigger>();
			val2.hoverIcon = Assets.HandIcon;
			val2.hoverTip = "Hack: [E]";
			val2.holdTip = "";
			val2.interactable = true;
			val2.oneHandedItemAllowed = true;
			val2.holdInteraction = true;
			val2.timeToHold = hackDuration;
			val2.timeToHoldSpeedMultiplier = 1f;
			val2.interactCooldown = true;
			val2.cooldownTime = hackDuration * 2f;
			val2.stopAnimationString = "SA_stopAnimation";
			val2.animationWaitTime = 2f;
			val2.lockPlayerPosition = true;
			val2.onInteract = new InteractEvent();
			val2.onInteractEarly = new InteractEvent();
			val2.onStopInteract = new InteractEvent();
			val2.holdingInteractEvent = new InteractEventFloat();
			val2.onCancelAnimation = new InteractEvent();
			((UnityEvent<PlayerControllerB>)(object)val2.onInteract).AddListener((UnityAction<PlayerControllerB>)delegate(PlayerControllerB p)
			{
				onFinishInteract?.Invoke(target, p);
			});
			((UnityEvent<float>)(object)val2.holdingInteractEvent).AddListener((UnityAction<float>)delegate(float v)
			{
				onInteractionHold?.Invoke(target, v);
			});
			((UnityEvent<PlayerControllerB>)(object)val2.onStopInteract).AddListener((UnityAction<PlayerControllerB>)delegate(PlayerControllerB p)
			{
				onStopInteract?.Invoke(target, p);
			});
			PortableMultiToolBase.Instance.Logger.LogWarning((object)("Added hacking interaction trigger to: \"" + ((Object)target).name + "\""));
			return val2;
		}

		protected override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_MultiTool()
		{
			//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
			NetworkManager.__rpc_func_table.Add(489812496u, new RpcReceiveHandler(__rpc_handler_489812496));
			NetworkManager.__rpc_func_table.Add(2585778738u, new RpcReceiveHandler(__rpc_handler_2585778738));
			NetworkManager.__rpc_func_table.Add(4015297935u, new RpcReceiveHandler(__rpc_handler_4015297935));
			NetworkManager.__rpc_func_table.Add(1057787546u, new RpcReceiveHandler(__rpc_handler_1057787546));
		}

		private static void __rpc_handler_489812496(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//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_0070: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				int type = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref type);
				bool isLoud = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref isLoud, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((MultiTool)(object)target).PlayAudio_ServerRpc(type, isLoud);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2585778738(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int type = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref type);
				bool isLoud = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref isLoud, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((MultiTool)(object)target).PlayAudio_ClientRpc(type, isLoud);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_4015297935(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((MultiTool)(object)target).StopAudio_ServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1057787546(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;
				((MultiTool)(object)target).StopAudio_ClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "MultiTool";
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}