Decompiled source of LethalGym v3.6.1

plugins/LethalGym.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalGym.Scripts;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;

[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("LethalGym")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LethalGym")]
[assembly: AssemblyTitle("LethalGym")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
public class Equipment : NetworkBehaviour
{
	[CompilerGenerated]
	private sealed class <RefreshBenchAnimatorAfterExit>d__37 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public PlayerControllerB player;

		public Equipment <>4__this;

		private AnimatorOverrideController <controller>5__1;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <RefreshBenchAnimatorAfterExit>d__37(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<controller>5__1 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = null;
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(0.1f);
				<>1__state = 2;
				return true;
			case 2:
			{
				<>1__state = -1;
				if ((Object)(object)player == (Object)null || (Object)(object)player.playerBodyAnimator == (Object)null)
				{
					return false;
				}
				ref AnimatorOverrideController reference = ref <controller>5__1;
				RuntimeAnimatorController runtimeAnimatorController = player.playerBodyAnimator.runtimeAnimatorController;
				reference = (AnimatorOverrideController)(object)((runtimeAnimatorController is AnimatorOverrideController) ? runtimeAnimatorController : null);
				if ((Object)(object)<controller>5__1 != (Object)null)
				{
					resetAnimations(<controller>5__1);
				}
				player.playerBodyAnimator.Update(0f);
				return false;
			}
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <playRep>d__28 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public Equipment <>4__this;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <playRep>d__28(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				if ((Object)(object)<>4__this.playerController != (Object)null && (Object)(object)<>4__this.playerController.playerBodyAnimator != (Object)null)
				{
					<>4__this.playerController.playerBodyAnimator.Play("SpecialAnimations.TypeOnTerminal2", -1, 0f);
				}
				if ((Object)(object)<>4__this.animator != (Object)null)
				{
					<>4__this.animator.Play("Base Layer.EquipmentRepAnimation", -1, 0f);
				}
				<>4__this.isRepping = true;
				<>2__current = (object)new WaitForSeconds(1f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<>4__this.isRepping = false;
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	public PlayerActions playerActions;

	public InteractTrigger trigger;

	public Animator animator;

	public TMP_Text nameText;

	public TMP_Text repsText;

	public GameObject[] weights;

	public string EquipmentName;

	public int playerStrengthLevel;

	public AnimatorOverrideController overrideController;

	public AnimationClip equipmentEnter;

	public AnimationClip equipmentRep;

	public static AnimationClip benchEnter;

	public static AnimationClip benchRep;

	public static AnimationClip squatEnter;

	public static AnimationClip squatRep;

	public int reps;

	public bool inUse;

	public bool isRepping;

	public PlayerControllerB playerController;

	public PlayerStrengthLevel psl;

	public void Awake()
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Expected O, but got Unknown
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		inUse = false;
		playerActions = new PlayerActions();
		MovementActions movement = playerActions.Movement;
		((MovementActions)(ref movement)).Enable();
		trigger = ((Component)this).GetComponent<InteractTrigger>();
	}

	private void OnEnable()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: 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)
		MovementActions movement = playerActions.Movement;
		((MovementActions)(ref movement)).Interact.performed += BackOut;
		movement = playerActions.Movement;
		((MovementActions)(ref movement)).Use.performed += Rep;
	}

	private void OnDisable()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: 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)
		MovementActions movement = playerActions.Movement;
		((MovementActions)(ref movement)).Interact.performed -= BackOut;
		movement = playerActions.Movement;
		((MovementActions)(ref movement)).Use.performed -= Rep;
	}

	public void Start()
	{
		nameText.text = "Enter Bench";
		repsText.text = "To Start Count";
		if (EquipmentName == "Bench")
		{
			equipmentEnter = benchEnter;
			equipmentRep = benchRep;
		}
		else if (EquipmentName == "Squat")
		{
			equipmentEnter = squatEnter;
			equipmentRep = squatRep;
		}
		else
		{
			Debug.LogError((object)"No Name?");
		}
	}

	public void Update()
	{
		if ((Object)(object)nameText != (Object)null && (Object)(object)repsText != (Object)null && (Object)(object)psl != (Object)null && (Object)(object)playerController != (Object)null)
		{
			nameText.text = playerController.playerUsername + "'s";
			repsText.text = "Reps:" + psl.currentRepsInLevel;
		}
	}

	public void Rep(CallbackContext context)
	{
		if (inUse && !isRepping && !((Object)(object)playerController == (Object)null) && playerController.playerClientId == GameNetworkManager.Instance.localPlayerController.playerClientId)
		{
			RepServerRpc();
		}
	}

	[ServerRpc(RequireOwnership = false)]
	public void RepServerRpc()
	{
		if (!((Object)(object)playerController == (Object)null))
		{
			((MonoBehaviour)this).StartCoroutine(playRep());
			reps++;
			PlayerStrengthLevel component = ((Component)playerController).gameObject.GetComponent<PlayerStrengthLevel>();
			if ((Object)(object)component != (Object)null)
			{
				component.addRep(this);
			}
			RepClientRpc(reps);
		}
	}

	[ClientRpc]
	public void RepClientRpc(int serverReps)
	{
		reps = serverReps;
		((MonoBehaviour)this).StartCoroutine(playRep());
	}

	[IteratorStateMachine(typeof(<playRep>d__28))]
	public IEnumerator playRep()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <playRep>d__28(0)
		{
			<>4__this = this
		};
	}

	public void OnEnter(PlayerControllerB player)
	{
		Debug.LogWarning((object)"Entered");
		PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
		OnEnterServerRpc(localPlayerController.playerClientId);
	}

	[ServerRpc(RequireOwnership = false)]
	public void OnEnterServerRpc(ulong playerInBenchID)
	{
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Expected O, but got Unknown
		inUse = true;
		PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
		PlayerControllerB[] array2 = array;
		foreach (PlayerControllerB val in array2)
		{
			if (val.playerClientId == playerInBenchID)
			{
				playerController = val;
				RuntimeAnimatorController runtimeAnimatorController = val.playerBodyAnimator.runtimeAnimatorController;
				overrideController = (AnimatorOverrideController)(object)((runtimeAnimatorController is AnimatorOverrideController) ? runtimeAnimatorController : null);
				if ((Object)(object)overrideController == (Object)null)
				{
					overrideController = new AnimatorOverrideController(runtimeAnimatorController);
					val.playerBodyAnimator.runtimeAnimatorController = (RuntimeAnimatorController)(object)overrideController;
				}
				psl = ((Component)val).GetComponent<PlayerStrengthLevel>();
				playerStrengthLevel = ((Component)val).GetComponent<PlayerStrengthLevel>().playerStrength;
				break;
			}
		}
		if ((Object)(object)equipmentEnter == (Object)null)
		{
			Debug.LogError((object)"equipmentEnter is null");
		}
		else
		{
			Debug.LogError((object)((Object)equipmentEnter).name.ToString());
		}
		if ((Object)(object)equipmentRep == (Object)null)
		{
			Debug.LogError((object)"equipmentRep is null");
		}
		else
		{
			Debug.LogError((object)((Object)equipmentRep).name.ToString());
		}
		if ((Object)(object)overrideController != (Object)null)
		{
			Debug.LogError((object)((Object)overrideController).name.ToString());
			overrideController["TypeOnTerminal"] = equipmentEnter;
			overrideController["TypeOnTerminal2"] = equipmentRep;
		}
		SetWeights(playerStrengthLevel);
		Debug.LogError((object)playerStrengthLevel);
		animator.ResetTrigger("EquipmentRep");
		animator.SetTrigger("EquipmentRep");
		reps = 1;
		OnEnterClientRpc(playerInBenchID);
	}

	[ClientRpc]
	public void OnEnterClientRpc(ulong playerInBenchID)
	{
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Expected O, but got Unknown
		inUse = true;
		PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
		PlayerControllerB[] array2 = array;
		foreach (PlayerControllerB val in array2)
		{
			if (val.playerClientId == playerInBenchID)
			{
				playerController = val;
				RuntimeAnimatorController runtimeAnimatorController = val.playerBodyAnimator.runtimeAnimatorController;
				overrideController = (AnimatorOverrideController)(object)((runtimeAnimatorController is AnimatorOverrideController) ? runtimeAnimatorController : null);
				if ((Object)(object)overrideController == (Object)null)
				{
					overrideController = new AnimatorOverrideController(runtimeAnimatorController);
					val.playerBodyAnimator.runtimeAnimatorController = (RuntimeAnimatorController)(object)overrideController;
				}
				psl = ((Component)val).GetComponent<PlayerStrengthLevel>();
				if ((Object)(object)psl == (Object)null)
				{
					Debug.LogWarning((object)"no psl");
				}
				playerStrengthLevel = ((Component)val).GetComponent<PlayerStrengthLevel>().playerStrength;
				break;
			}
		}
		if ((Object)(object)equipmentEnter == (Object)null)
		{
			Debug.LogError((object)"equipmentEnter is null");
		}
		else
		{
			Debug.LogError((object)((Object)equipmentEnter).name.ToString());
		}
		if ((Object)(object)equipmentRep == (Object)null)
		{
			Debug.LogError((object)"equipmentRep is null");
		}
		else
		{
			Debug.LogError((object)((Object)equipmentRep).name.ToString());
		}
		if ((Object)(object)overrideController == (Object)null)
		{
			Debug.LogError((object)"no overridecontroller");
		}
		else
		{
			overrideController["TypeOnTerminal"] = equipmentEnter;
			overrideController["TypeOnTerminal2"] = equipmentRep;
		}
		SetWeights(playerStrengthLevel);
		Debug.LogError((object)playerStrengthLevel);
		animator.ResetTrigger("EquipmentRep");
		animator.SetTrigger("EquipmentRep");
		reps = 1;
	}

	public void BackOut(CallbackContext context)
	{
		if (inUse && !((Object)(object)playerController == (Object)null) && playerController.playerClientId == GameNetworkManager.Instance.localPlayerController.playerClientId)
		{
			StopSpecialAnimation();
			BackOutServerRpc();
		}
	}

	public void StopSpecialAnimation()
	{
		if ((Object)(object)trigger != (Object)null)
		{
			trigger.StopSpecialAnimation();
		}
	}

	[ServerRpc(RequireOwnership = false)]
	public void BackOutServerRpc()
	{
		Debug.LogWarning((object)"BACKOUT CONFIRM");
		LeaveEquipment();
		BackOutClientRpc();
	}

	[ClientRpc]
	public void BackOutClientRpc()
	{
		Debug.LogWarning((object)"BACKOUT CONFIRM");
		LeaveEquipment();
	}

	public void LeaveEquipment()
	{
		PlayerControllerB val = playerController;
		bool flag = EquipmentName == "Bench";
		if ((Object)(object)animator != (Object)null)
		{
			animator.SetTrigger("StopAnimation");
		}
		inUse = false;
		isRepping = false;
		playerController = null;
		psl = null;
		if (flag && (Object)(object)val != (Object)null)
		{
			((MonoBehaviour)this).StartCoroutine(RefreshBenchAnimatorAfterExit(val));
		}
	}

	[IteratorStateMachine(typeof(<RefreshBenchAnimatorAfterExit>d__37))]
	private IEnumerator RefreshBenchAnimatorAfterExit(PlayerControllerB player)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <RefreshBenchAnimatorAfterExit>d__37(0)
		{
			<>4__this = this,
			player = player
		};
	}

	public void SetWeights(int levelNumber)
	{
		for (int i = 0; i < weights.Length; i++)
		{
			if (i == 0)
			{
				weights[i].SetActive(true);
			}
			else
			{
				weights[i].SetActive(false);
			}
		}
		if (levelNumber == 1)
		{
			weights[0].SetActive(true);
		}
		if (levelNumber >= 2)
		{
			weights[1].SetActive(true);
		}
		if (levelNumber >= 3)
		{
			weights[2].SetActive(true);
		}
		if (levelNumber >= 4)
		{
			weights[3].SetActive(true);
		}
		if (levelNumber >= 5)
		{
			weights[4].SetActive(true);
		}
		if (levelNumber >= 6)
		{
			weights[5].SetActive(true);
		}
	}

	[ServerRpc(RequireOwnership = false)]
	public void BeginTerminalServerRPC(ulong playerID)
	{
		PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
		PlayerControllerB[] array2 = array;
		foreach (PlayerControllerB val in array2)
		{
			if (val.playerClientId == playerID)
			{
				RuntimeAnimatorController runtimeAnimatorController = val.playerBodyAnimator.runtimeAnimatorController;
				AnimatorOverrideController val2 = (AnimatorOverrideController)(object)((runtimeAnimatorController is AnimatorOverrideController) ? runtimeAnimatorController : null);
				if ((Object)(object)val2 != (Object)null)
				{
					resetAnimations(val2);
				}
				break;
			}
		}
		BeginTerminalClientRPC(playerID);
	}

	[ClientRpc]
	public void BeginTerminalClientRPC(ulong playerID)
	{
		PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
		PlayerControllerB[] array2 = array;
		foreach (PlayerControllerB val in array2)
		{
			if (val.playerClientId == playerID)
			{
				RuntimeAnimatorController runtimeAnimatorController = val.playerBodyAnimator.runtimeAnimatorController;
				AnimatorOverrideController val2 = (AnimatorOverrideController)(object)((runtimeAnimatorController is AnimatorOverrideController) ? runtimeAnimatorController : null);
				if ((Object)(object)val2 != (Object)null)
				{
					resetAnimations(val2);
				}
				break;
			}
		}
	}

	public static void resetAnimations(AnimatorOverrideController controller)
	{
		List<KeyValuePair<AnimationClip, AnimationClip>> list = new List<KeyValuePair<AnimationClip, AnimationClip>>(controller.overridesCount);
		controller.GetOverrides(list);
		for (int i = 0; i < list.Count; i++)
		{
			list[i] = new KeyValuePair<AnimationClip, AnimationClip>(list[i].Key, null);
		}
		controller.ApplyOverrides((IList<KeyValuePair<AnimationClip, AnimationClip>>)list);
	}
}
public class PlayerStrengthLevel : NetworkBehaviour
{
	public int playerStrength = 1;

	public int currentRepsInLevel = 0;

	public static int repsNeededL1 = 25;

	public static int repsNeededL2 = 50;

	public static int repsNeededL3 = 75;

	public static int repsNeededL4 = 100;

	public static int repsNeededL5 = 200;

	public bool canGrab;

	public bool canDrop;

	public static bool strongerBodyStatus;

	public float originalCarryWeight;

	public PlayerControllerB playerController;

	public void Start()
	{
		originalCarryWeight = 1f;
		canGrab = true;
		canDrop = true;
	}

	public void Update()
	{
	}

	public void UpdateConfigs(bool nStrongerBodyStatus)
	{
		strongerBodyStatus = nStrongerBodyStatus;
	}

	public void addRep(Equipment bench)
	{
		currentRepsInLevel++;
		Debug.LogWarning((object)currentRepsInLevel.ToString());
		if (playerStrength == 1 && currentRepsInLevel >= repsNeededL1)
		{
			playerStrength++;
			currentRepsInLevel = 0;
			bench.SetWeights(playerStrength);
			Debug.Log((object)(playerStrength + " PlayerUpgraded!"));
		}
		if (playerStrength == 2 && currentRepsInLevel >= repsNeededL2)
		{
			playerStrength++;
			currentRepsInLevel = 0;
			bench.SetWeights(playerStrength);
			Debug.Log((object)(playerStrength + " PlayerUpgraded!"));
		}
		if (playerStrength == 3 && currentRepsInLevel >= repsNeededL3)
		{
			playerStrength++;
			currentRepsInLevel = 0;
			bench.SetWeights(playerStrength);
			Debug.Log((object)(playerStrength + " PlayerUpgraded!"));
		}
		if (playerStrength == 4 && currentRepsInLevel >= repsNeededL4)
		{
			playerStrength++;
			currentRepsInLevel = 0;
			bench.SetWeights(playerStrength);
			Debug.Log((object)(playerStrength + " PlayerUpgraded!"));
		}
		if (playerStrength == 5 && currentRepsInLevel >= repsNeededL5)
		{
			bench.repsText.text = "MAXED OUT";
			Debug.Log((object)"Bro is maxed out");
		}
	}
}
namespace LethalGym
{
	[BepInPlugin("Dryedcoolbro.LethalGym", "LethalGym", "1.0.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "Dryedcoolbro.LethalGym";

		private const string modName = "LethalGym";

		private const string modVersion = "1.0.0.0";

		private readonly Harmony harmony = new Harmony("Dryedcoolbro.LethalGym");

		private static Plugin Instance;

		internal static ManualLogSource Logger;

		public static AssetBundle assetBundle;

		public static AnimationClip pushupAnimation;

		public static UnlockablesList unlockablesList;

		public static Config Config { get; private set; }

		public static bool IsModLoaded(string guid)
		{
			return Chainloader.PluginInfos.ContainsKey(guid);
		}

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Config = new Config(((BaseUnityPlugin)this).Config);
			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);
					}
				}
			}
			Logger = Logger.CreateLogSource("Dryedcoolbro.LethalGym");
			assetBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "lethalequipment"));
			LoadAnimations();
			if ((Object)(object)pushupAnimation == (Object)null)
			{
				Logger.LogError((object)"pushupAnim not exist!");
			}
			else
			{
				Logger.LogInfo((object)((Object)pushupAnimation).name);
			}
			if ((Object)(object)assetBundle == (Object)null)
			{
				Logger.LogError((object)"Assetbundle not exist!");
			}
			else
			{
				Logger.LogInfo((object)((object)assetBundle).ToString());
				Logger.LogInfo((object)((Object)assetBundle).name);
			}
			harmony.PatchAll();
			NetworkObjectManager.assetBundle = assetBundle;
			unlockablesList = assetBundle.LoadAsset<UnlockablesList>("Assets/MyAssets/Unlockables.asset");
			unlockablesList = unlockablesList;
			LoadNetworkPrefabs();
			RegisterUnlockables();
		}

		public static void LoadAnimations()
		{
			Equipment.benchEnter = assetBundle.LoadAsset<AnimationClip>("Assets/MyAssets/Bench/BenchPressStart.anim");
			Equipment.benchRep = assetBundle.LoadAsset<AnimationClip>("Assets/MyAssets/Bench/BenchRep.anim");
			Equipment.squatEnter = assetBundle.LoadAsset<AnimationClip>("Assets/MyAssets/SquatRack/SquatEnter.anim");
			Equipment.squatRep = assetBundle.LoadAsset<AnimationClip>("Assets/MyAssets/SquatRack/SquatRep.anim");
		}

		public static void LoadNetworkPrefabs()
		{
			NetworkPrefabs.RegisterNetworkPrefab(unlockablesList.unlockables[0].prefabObject);
			NetworkPrefabs.RegisterNetworkPrefab(unlockablesList.unlockables[1].prefabObject);
		}

		public static void RegisterUnlockables()
		{
			ConfigApply.unlockablesList = unlockablesList;
			Unlockables.RegisterUnlockable(unlockablesList.unlockables[0], (StoreType)1, (TerminalNode)null, (TerminalNode)null, (TerminalNode)null, 60);
			Unlockables.RegisterUnlockable(unlockablesList.unlockables[1], (StoreType)1, (TerminalNode)null, (TerminalNode)null, (TerminalNode)null, 60);
		}
	}
	[DataContract]
	public class Config : SyncedInstance<Config>
	{
		[DataMember]
		public bool strongerBody { get; private set; }

		[DataMember]
		public bool overridePrices { get; private set; }

		[DataMember]
		public int benchPrice { get; private set; }

		[DataMember]
		public int squatPrice { get; private set; }

		public Config(ConfigFile cfg)
		{
			InitInstance(this);
			strongerBody = cfg.Bind<bool>("General", "Stronger Body", false, "More strength levels you have, the faster you can walk while carrying heavy items").Value;
			overridePrices = cfg.Bind<bool>("Prices", "Override Prices", false, "If set to true, all prices underneath will be set as the price no matter what.").Value;
			benchPrice = cfg.Bind<int>("Prices", "Bench Price", 60, "Default is 60").Value;
			squatPrice = cfg.Bind<int>("Prices", "Squat Rack Price", 60, "Default is 60").Value;
		}

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

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

		public static void OnReceiveSync(ulong _, FastBufferReader reader)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if (!((FastBufferReader)(ref reader)).TryBeginRead(SyncedInstance<Config>.IntSize))
			{
				Plugin.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))
			{
				Plugin.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);
			Plugin.Logger.LogInfo((object)"Successfully synced config with host.");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		public static void InitializeLocalPlayer()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			if (SyncedInstance<Config>.IsHost)
			{
				SyncedInstance<Config>.MessageManager.RegisterNamedMessageHandler("ModName_OnRequestConfigSync", new HandleNamedMessageDelegate(OnRequestSync));
				SyncedInstance<Config>.Synced = true;
			}
			else
			{
				SyncedInstance<Config>.Synced = false;
				SyncedInstance<Config>.MessageManager.RegisterNamedMessageHandler("ModName_OnReceiveConfigSync", new HandleNamedMessageDelegate(OnReceiveSync));
				RequestSync();
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")]
		public static void PlayerLeave()
		{
			SyncedInstance<Config>.RevertSync();
		}
	}
	[Serializable]
	public class SyncedInstance<T>
	{
		[NonSerialized]
		protected static int IntSize = 4;

		[NonSerialized]
		private static readonly DataContractSerializer serializer = new DataContractSerializer(typeof(T));

		internal static bool Synced;

		[NonSerialized]
		private static int MAX_BUFFER_SIZE = 1300;

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

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

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

		internal static T Default { get; private set; }

		internal static T Instance { get; private set; }

		protected void InitInstance(T instance, int maxSize = 1024)
		{
			Default = instance;
			Instance = instance;
			IntSize = 4;
			if (maxSize < 1300)
			{
				MAX_BUFFER_SIZE = maxSize;
			}
		}

		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)
		{
			using MemoryStream memoryStream = new MemoryStream();
			try
			{
				serializer.WriteObject(memoryStream, val);
				return memoryStream.ToArray();
			}
			catch (Exception arg)
			{
				Plugin.Logger.LogError((object)$"Error serializing instance: {arg}");
				return null;
			}
		}

		public static T DeserializeFromBytes(byte[] data)
		{
			using MemoryStream stream = new MemoryStream(data);
			try
			{
				return (T)serializer.ReadObject(stream);
			}
			catch (Exception arg)
			{
				Plugin.Logger.LogError((object)$"Error deserializing instance: {arg}");
				return default(T);
			}
		}

		internal static void SendMessage(string label, ulong clientId, FastBufferWriter stream)
		{
			//IL_0017: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			bool flag = ((FastBufferWriter)(ref stream)).Capacity > MAX_BUFFER_SIZE;
			NetworkDelivery val = (NetworkDelivery)(flag ? 4 : 2);
			if (flag)
			{
				Plugin.Logger.LogDebug((object)($"Size of stream ({((FastBufferWriter)(ref stream)).Capacity}) was past the max buffer size.\n" + "Config instance will be sent in fragments to avoid overflowing the buffer."));
			}
			MessageManager.SendNamedMessage(label, clientId, stream, val);
		}
	}
}
namespace LethalGym.Scripts
{
	[HarmonyPatch]
	internal class MoreEmotesPatcher
	{
		public static bool moreEmotes;

		[HarmonyPatch(typeof(PreInitSceneScript), "Awake")]
		[HarmonyPostfix]
		public static void ApplyPatch()
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Expected O, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Expected O, but got Unknown
			if (!Plugin.IsModLoaded("MoreEmotes") || !Chainloader.PluginInfos.TryGetValue("MoreEmotes", out var value))
			{
				return;
			}
			Assembly assembly = ((object)value.Instance).GetType().Assembly;
			if (assembly != null)
			{
				Plugin.Logger.LogWarning((object)"Applying compatibility patch for More_Emotes");
				Type type = assembly.GetType("MoreEmotes.Patch.EmotePatch");
				FieldInfo field = type.GetField("local", BindingFlags.Static | BindingFlags.Public);
				RuntimeAnimatorController val = (RuntimeAnimatorController)field.GetValue(null);
				if ((Object)(object)val != (Object)null && !(val is AnimatorOverrideController))
				{
					field.SetValue(null, (object?)new AnimatorOverrideController(val));
				}
				FieldInfo field2 = type.GetField("others", BindingFlags.Static | BindingFlags.Public);
				RuntimeAnimatorController val2 = (RuntimeAnimatorController)field2.GetValue(null);
				if ((Object)(object)val2 != (Object)null && !(val2 is AnimatorOverrideController))
				{
					field2.SetValue(null, (object?)new AnimatorOverrideController(val2));
				}
				moreEmotes = true;
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		[HarmonyPostfix]
		public static void AddEmote(StartOfRound __instance)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			__instance.localClientAnimatorController = (RuntimeAnimatorController)new AnimatorOverrideController(__instance.localClientAnimatorController);
			__instance.otherClientsAnimatorController = (RuntimeAnimatorController)new AnimatorOverrideController(__instance.otherClientsAnimatorController);
		}
	}
	public class EquipmentNetworkHandler : NetworkBehaviour
	{
		[CompilerGenerated]
		private sealed class <ChangeWeights>d__14 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PlayerControllerB player;

			public PlayerStrengthLevel psl;

			public EquipmentNetworkHandler <>4__this;

			private int <>s__1;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ChangeWeights>d__14(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(0.1f);
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					int playerStrength = psl.playerStrength;
					<>s__1 = playerStrength;
					switch (<>s__1)
					{
					case 1:
						player.carryWeight = psl.originalCarryWeight / 1f;
						break;
					case 2:
						player.carryWeight = psl.originalCarryWeight / 1.05f;
						break;
					case 3:
						player.carryWeight = psl.originalCarryWeight / 1.1f;
						break;
					case 4:
						player.carryWeight = psl.originalCarryWeight / 1.3f;
						break;
					case 5:
						player.carryWeight = psl.originalCarryWeight / 1.5f;
						break;
					}
					Debug.LogError((object)("(Grab) Middle instance: " + player.carryWeight));
					if (player.carryWeight < 1f)
					{
						player.carryWeight = 1f;
						psl.originalCarryWeight = 1f;
						Debug.LogWarning((object)"Carry weight less than 1.0");
					}
					Debug.LogError((object)("(grab) Last original: " + psl.originalCarryWeight));
					Debug.LogError((object)("(Grab) Last instance: " + player.carryWeight));
					<>4__this.DoubleCheckGrabFunction(psl, GrabOrDrop: false);
					psl.canDrop = false;
					return false;
				}
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <DoubleCheckGrab>d__12 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PlayerStrengthLevel psl;

			public bool GrabOrDrop;

			public EquipmentNetworkHandler <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <DoubleCheckGrab>d__12(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(0.1f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (GrabOrDrop)
					{
						psl.canGrab = true;
					}
					else
					{
						psl.canDrop = true;
					}
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <UpdateDecorPrice>d__21 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public UnlockablesList unlockablesList;

			public EquipmentNetworkHandler <>4__this;

			private int <i>5__1;

			private int <i>5__2;

			private int <i>5__3;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <UpdateDecorPrice>d__21(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(2f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (!SyncedInstance<Config>.Instance.overridePrices)
					{
						if (SyncedInstance<Config>.Instance.strongerBody)
						{
							<i>5__1 = 0;
							while (<i>5__1 < Unlockables.registeredUnlockables.Count)
							{
								if (Unlockables.registeredUnlockables[<i>5__1].unlockable == unlockablesList.unlockables[0])
								{
									Unlockables.UpdateUnlockablePrice(Unlockables.registeredUnlockables[<i>5__1].unlockable, 299);
								}
								else if (Unlockables.registeredUnlockables[<i>5__1].unlockable == unlockablesList.unlockables[1])
								{
									Unlockables.UpdateUnlockablePrice(Unlockables.registeredUnlockables[<i>5__1].unlockable, 299);
								}
								<i>5__1++;
							}
						}
						else
						{
							<i>5__2 = 0;
							while (<i>5__2 < Unlockables.registeredUnlockables.Count)
							{
								if (Unlockables.registeredUnlockables[<i>5__2].unlockable == unlockablesList.unlockables[0])
								{
									Unlockables.UpdateUnlockablePrice(Unlockables.registeredUnlockables[<i>5__2].unlockable, 60);
								}
								else if (Unlockables.registeredUnlockables[<i>5__2].unlockable == unlockablesList.unlockables[1])
								{
									Unlockables.UpdateUnlockablePrice(Unlockables.registeredUnlockables[<i>5__2].unlockable, 60);
								}
								<i>5__2++;
							}
						}
					}
					else
					{
						<i>5__3 = 0;
						while (<i>5__3 < Unlockables.registeredUnlockables.Count)
						{
							if (Unlockables.registeredUnlockables[<i>5__3].unlockable == unlockablesList.unlockables[0])
							{
								Unlockables.UpdateUnlockablePrice(Unlockables.registeredUnlockables[<i>5__3].unlockable, SyncedInstance<Config>.Instance.benchPrice);
							}
							else if (Unlockables.registeredUnlockables[<i>5__3].unlockable == unlockablesList.unlockables[1])
							{
								Unlockables.UpdateUnlockablePrice(Unlockables.registeredUnlockables[<i>5__3].unlockable, SyncedInstance<Config>.Instance.squatPrice);
							}
							<i>5__3++;
						}
					}
					setConfigs(SyncedInstance<Config>.Instance.strongerBody);
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public static bool strongerBody;

		public static bool overridePrices;

		public static int benchPrce;

		public static int squatPrice;

		public static EquipmentNetworkHandler Instance { get; private set; }

		public override void OnNetworkSpawn()
		{
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				EquipmentNetworkHandler instance = Instance;
				if (instance != null)
				{
					((Component)instance).gameObject.GetComponent<NetworkObject>().Despawn(true);
				}
			}
			Instance = this;
			((NetworkBehaviour)this).OnNetworkSpawn();
		}

		[ServerRpc(RequireOwnership = false)]
		public void SyncStrengthValuesServerRpc()
		{
			PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
			PlayerControllerB[] array2 = array;
			foreach (PlayerControllerB val in array2)
			{
				PlayerStrengthLevel component = ((Component)val).GetComponent<PlayerStrengthLevel>();
				SyncStrengthValuesClientRpc(val.playerClientId, component.playerStrength, component.currentRepsInLevel, component.originalCarryWeight, strongerBody);
			}
		}

		[ClientRpc]
		public void SyncStrengthValuesClientRpc(ulong playerID, int playerStrength, int currentRepsInLevel, float carryWeight, bool strongerBody)
		{
			PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
			PlayerControllerB[] array2 = array;
			foreach (PlayerControllerB val in array2)
			{
				if (val.playerClientId == playerID)
				{
					PlayerStrengthLevel playerStrengthLevel = ((Component)val).GetComponent<PlayerStrengthLevel>();
					if ((Object)(object)playerStrengthLevel == (Object)null)
					{
						playerStrengthLevel = ((Component)val).gameObject.AddComponent<PlayerStrengthLevel>();
					}
					playerStrengthLevel.playerStrength = playerStrength;
					playerStrengthLevel.currentRepsInLevel = currentRepsInLevel;
					playerStrengthLevel.originalCarryWeight = carryWeight;
					PlayerStrengthLevel.strongerBodyStatus = strongerBody;
				}
			}
		}

		public void DoubleCheckGrabFunction(PlayerStrengthLevel psl, bool GrabOrDrop)
		{
			((MonoBehaviour)this).StartCoroutine(DoubleCheckGrab(psl, GrabOrDrop));
		}

		[IteratorStateMachine(typeof(<DoubleCheckGrab>d__12))]
		public IEnumerator DoubleCheckGrab(PlayerStrengthLevel psl, bool GrabOrDrop)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DoubleCheckGrab>d__12(0)
			{
				<>4__this = this,
				psl = psl,
				GrabOrDrop = GrabOrDrop
			};
		}

		public void ChangeWeightsFunction(PlayerControllerB player, PlayerStrengthLevel psl)
		{
			((MonoBehaviour)this).StartCoroutine(ChangeWeights(player, psl));
		}

		[IteratorStateMachine(typeof(<ChangeWeights>d__14))]
		public IEnumerator ChangeWeights(PlayerControllerB player, PlayerStrengthLevel psl)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ChangeWeights>d__14(0)
			{
				<>4__this = this,
				player = player,
				psl = psl
			};
		}

		public static void setConfigs(bool strongerBodyValue)
		{
			strongerBody = strongerBodyValue;
			PlayerStrengthLevel[] array = Object.FindObjectsOfType<PlayerStrengthLevel>();
			PlayerStrengthLevel[] array2 = array;
			foreach (PlayerStrengthLevel playerStrengthLevel in array2)
			{
				playerStrengthLevel.UpdateConfigs(strongerBody);
			}
		}

		[ServerRpc]
		public void GrabWeightServerRpc(ulong playerID, float grabbedObjectWeight)
		{
			PlayerControllerB val = null;
			PlayerStrengthLevel playerStrengthLevel = null;
			PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
			PlayerControllerB[] array2 = array;
			foreach (PlayerControllerB val2 in array2)
			{
				if (val2.playerClientId == playerID)
				{
					val = val2;
					playerStrengthLevel = ((Component)val).GetComponent<PlayerStrengthLevel>();
					break;
				}
			}
			GrabWeightClientRpc(playerID, grabbedObjectWeight);
		}

		[ClientRpc]
		public void GrabWeightClientRpc(ulong playerID, float grabbedObjectWeight)
		{
			PlayerControllerB val = null;
			PlayerStrengthLevel playerStrengthLevel = null;
			PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
			PlayerControllerB[] array2 = array;
			foreach (PlayerControllerB val2 in array2)
			{
				if (val2.playerClientId == playerID)
				{
					val = val2;
					playerStrengthLevel = ((Component)val).GetComponent<PlayerStrengthLevel>();
					break;
				}
			}
			playerStrengthLevel.originalCarryWeight += Mathf.Clamp(grabbedObjectWeight - 1f, 0f, 10f);
			switch (playerStrengthLevel.playerStrength)
			{
			case 1:
				val.carryWeight = playerStrengthLevel.originalCarryWeight / 1f;
				break;
			case 2:
				val.carryWeight = playerStrengthLevel.originalCarryWeight / 1.05f;
				break;
			case 3:
				val.carryWeight = playerStrengthLevel.originalCarryWeight / 1.1f;
				break;
			case 4:
				val.carryWeight = playerStrengthLevel.originalCarryWeight / 1.3f;
				break;
			case 5:
				val.carryWeight = playerStrengthLevel.originalCarryWeight / 1.5f;
				break;
			}
			if (val.carryWeight < 1f)
			{
				val.carryWeight = 1f;
				playerStrengthLevel.originalCarryWeight = 1f;
			}
			Debug.LogWarning((object)playerStrengthLevel.originalCarryWeight.ToString());
		}

		[ServerRpc]
		public void DropWeightServerRpc(ulong playerID, float grabbedObjectWeight)
		{
			PlayerControllerB val = null;
			PlayerStrengthLevel playerStrengthLevel = null;
			PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
			PlayerControllerB[] array2 = array;
			foreach (PlayerControllerB val2 in array2)
			{
				if (val2.playerClientId == playerID)
				{
					val = val2;
					playerStrengthLevel = ((Component)val).GetComponent<PlayerStrengthLevel>();
					break;
				}
			}
			DropWeightClientRpc(playerID, grabbedObjectWeight);
		}

		[ClientRpc]
		public void DropWeightClientRpc(ulong playerID, float grabbedObjectWeight)
		{
			PlayerControllerB val = null;
			PlayerStrengthLevel playerStrengthLevel = null;
			PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
			PlayerControllerB[] array2 = array;
			foreach (PlayerControllerB val2 in array2)
			{
				if (val2.playerClientId == playerID)
				{
					val = val2;
					playerStrengthLevel = ((Component)val).GetComponent<PlayerStrengthLevel>();
					break;
				}
			}
			playerStrengthLevel.originalCarryWeight -= Mathf.Clamp(grabbedObjectWeight - 1f, 0f, 10f);
			switch (playerStrengthLevel.playerStrength)
			{
			case 1:
				val.carryWeight = playerStrengthLevel.originalCarryWeight / 1f;
				break;
			case 2:
				val.carryWeight = playerStrengthLevel.originalCarryWeight / 1.05f;
				break;
			case 3:
				val.carryWeight = playerStrengthLevel.originalCarryWeight / 1.1f;
				break;
			case 4:
				val.carryWeight = playerStrengthLevel.originalCarryWeight / 1.3f;
				break;
			case 5:
				val.carryWeight = playerStrengthLevel.originalCarryWeight / 1.5f;
				break;
			}
			if (val.carryWeight < 1f)
			{
				val.carryWeight = 1f;
				playerStrengthLevel.originalCarryWeight = 1f;
			}
			Debug.LogWarning((object)playerStrengthLevel.originalCarryWeight.ToString());
			Debug.LogWarning((object)playerStrengthLevel.originalCarryWeight.ToString());
		}

		public void UpdateDecorPriceStart(UnlockablesList unlockablesList)
		{
			((MonoBehaviour)this).StartCoroutine(UpdateDecorPrice(unlockablesList));
		}

		[IteratorStateMachine(typeof(<UpdateDecorPrice>d__21))]
		public IEnumerator UpdateDecorPrice(UnlockablesList unlockablesList)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <UpdateDecorPrice>d__21(0)
			{
				<>4__this = this,
				unlockablesList = unlockablesList
			};
		}

		[ServerRpc(RequireOwnership = false)]
		public void BeginTerminalServerRPC(ulong playerID)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
			PlayerControllerB[] array2 = array;
			foreach (PlayerControllerB val in array2)
			{
				if (val.playerClientId == playerID)
				{
					AnimatorOverrideController controller = (AnimatorOverrideController)val.playerBodyAnimator.runtimeAnimatorController;
					Debug.LogWarning((object)((object)val.playerBodyAnimator.runtimeAnimatorController).ToString());
					resetAnimations(controller);
					break;
				}
			}
			BeginTerminalClientRPC(playerID);
		}

		[ClientRpc]
		public void BeginTerminalClientRPC(ulong playerID)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
			PlayerControllerB[] array2 = array;
			foreach (PlayerControllerB val in array2)
			{
				if (val.playerClientId == playerID)
				{
					AnimatorOverrideController controller = (AnimatorOverrideController)val.playerBodyAnimator.runtimeAnimatorController;
					resetAnimations(controller);
					break;
				}
			}
		}

		public static void resetAnimations(AnimatorOverrideController controller)
		{
			List<KeyValuePair<AnimationClip, AnimationClip>> list = new List<KeyValuePair<AnimationClip, AnimationClip>>(controller.overridesCount);
			controller.GetOverrides(list);
			for (int i = 0; i < list.Count; i++)
			{
				list[i] = new KeyValuePair<AnimationClip, AnimationClip>(list[i].Key, null);
			}
			controller.ApplyOverrides((IList<KeyValuePair<AnimationClip, AnimationClip>>)list);
		}
	}
	[HarmonyPatch]
	internal class LethalGymPatches
	{
		public static AnimationClip benchEnter;

		public static AnimationClip benchRep;

		public static AnimationClip term1;

		public static AnimationClip term2;

		[HarmonyPatch(typeof(Terminal), "BeginUsingTerminal")]
		[HarmonyPostfix]
		public static void ResetAnimation(Terminal __instance)
		{
			EquipmentNetworkHandler equipmentNetworkHandler = Object.FindObjectOfType<EquipmentNetworkHandler>();
			if ((Object)(object)equipmentNetworkHandler != (Object)null)
			{
				equipmentNetworkHandler.BeginTerminalServerRPC(GameNetworkManager.Instance.localPlayerController.playerClientId);
			}
		}

		[HarmonyPatch(typeof(ShipBuildModeManager), "StoreShipObjectClientRpc")]
		[HarmonyPrefix]
		public static void KickPlayerOutClientRpc()
		{
			Equipment equipment = Object.FindObjectOfType<Equipment>();
			if ((Object)(object)equipment != (Object)null)
			{
				equipment.LeaveEquipment();
				equipment.StopSpecialAnimation();
			}
		}

		[HarmonyPatch(typeof(ShipBuildModeManager), "StoreObjectServerRpc")]
		[HarmonyPrefix]
		public static void KickPlayerOutServerRpc()
		{
			Equipment equipment = Object.FindObjectOfType<Equipment>();
			if ((Object)(object)equipment != (Object)null)
			{
				equipment.LeaveEquipment();
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Start")]
		[HarmonyPrefix]
		public static void CheckLiftName()
		{
			Equipment[] array = Object.FindObjectsOfType<Equipment>();
			Equipment[] array2 = array;
			foreach (Equipment equipment in array2)
			{
				if (equipment.EquipmentName == "Bench")
				{
					equipment.equipmentEnter = Equipment.benchEnter;
					equipment.equipmentRep = Equipment.benchRep;
				}
				else if (equipment.EquipmentName == "Squat")
				{
					equipment.equipmentEnter = Equipment.squatEnter;
					equipment.equipmentRep = Equipment.squatRep;
				}
				else
				{
					Debug.LogError((object)"No Name?");
				}
			}
		}
	}
	[HarmonyPatch]
	internal class NetworkObjectManager
	{
		public static AssetBundle assetBundle;

		private static GameObject networkPrefab;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		public static void Init()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			if (!((Object)(object)networkPrefab != (Object)null))
			{
				networkPrefab = (GameObject)assetBundle.LoadAsset("Assets/MyAssets/EquipmentNetworkHandlerPrefab.prefab");
				networkPrefab.AddComponent<EquipmentNetworkHandler>();
				NetworkManager.Singleton.AddNetworkPrefab(networkPrefab);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		private static void SpawnNetworkHandler()
		{
			//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)
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				GameObject val = Object.Instantiate<GameObject>(networkPrefab, Vector3.zero, Quaternion.identity);
				val.GetComponent<NetworkObject>().Spawn(false);
			}
		}
	}
	[HarmonyPatch]
	internal class StrengthValuesSaveAndLoad : NetworkBehaviour
	{
		private static StrengthValuesSaveAndLoad Instance;

		public void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
		}

		[HarmonyPatch(typeof(GameNetworkManager), "SaveGameValues")]
		[HarmonyPostfix]
		private static void SaveStrengthValues(GameNetworkManager __instance)
		{
			PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
			PlayerControllerB[] array2 = array;
			foreach (PlayerControllerB val in array2)
			{
				PlayerStrengthLevel component = ((Component)val).GetComponent<PlayerStrengthLevel>();
				if ((Object)(object)component != (Object)null)
				{
					ES3.Save<int>("PlayerStrength" + val.playerSteamId, component.playerStrength, __instance.currentSaveFileName);
					ES3.Save<int>("PlayerReps" + val.playerSteamId, component.currentRepsInLevel, __instance.currentSaveFileName);
					Debug.LogWarning((object)val.playerSteamId.ToString());
					Debug.LogWarning((object)(component.playerStrength + " " + component.currentRepsInLevel));
				}
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "SendNewPlayerValuesClientRpc")]
		[HarmonyPostfix]
		private static void LoadStrengthValues(PlayerControllerB __instance)
		{
			PlayerStrengthLevel playerStrengthLevel = ((Component)__instance).gameObject.GetComponent<PlayerStrengthLevel>();
			if ((Object)(object)((Component)__instance).gameObject.GetComponent<PlayerStrengthLevel>() == (Object)null)
			{
				playerStrengthLevel = ((Component)__instance).gameObject.AddComponent<PlayerStrengthLevel>();
			}
			if ((Object)(object)playerStrengthLevel != (Object)null)
			{
				Debug.LogWarning((object)"psl not null");
				playerStrengthLevel.playerController = __instance;
				string currentSaveFileName = Object.FindObjectOfType<GameNetworkManager>().currentSaveFileName;
				Debug.LogWarning((object)currentSaveFileName);
				playerStrengthLevel.playerStrength = ES3.Load<int>("PlayerStrength" + __instance.playerSteamId, currentSaveFileName, 1);
				playerStrengthLevel.currentRepsInLevel = ES3.Load<int>("PlayerReps" + __instance.playerSteamId, currentSaveFileName, 0);
				Debug.LogWarning((object)__instance.playerSteamId.ToString());
				Debug.LogWarning((object)(playerStrengthLevel.playerStrength + " " + playerStrengthLevel.currentRepsInLevel));
			}
			Object.FindObjectOfType<EquipmentNetworkHandler>().SyncStrengthValuesServerRpc();
		}
	}
	[HarmonyPatch]
	internal class StrengthPatches : NetworkBehaviour
	{
		[HarmonyPatch(typeof(PlayerControllerB), "GrabObjectClientRpc")]
		[HarmonyPostfix]
		private static void BeginGrab(PlayerControllerB __instance)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			PlayerStrengthLevel component = ((Component)__instance).GetComponent<PlayerStrengthLevel>();
			GrabbableObject val = (GrabbableObject)Traverse.Create((object)__instance).Field("currentlyGrabbingObject").GetValue();
			if (component.canGrab && PlayerStrengthLevel.strongerBodyStatus)
			{
				Object.FindObjectOfType<EquipmentNetworkHandler>().DoubleCheckGrabFunction(component, GrabOrDrop: true);
				Object.FindObjectOfType<EquipmentNetworkHandler>().GrabWeightServerRpc(__instance.playerClientId, val.itemProperties.weight);
				component.canGrab = false;
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "DiscardHeldObject")]
		[HarmonyPrefix]
		private static void BeginDrop(PlayerControllerB __instance, bool placeObject = false, NetworkObject parentObjectTo = null, Vector3 placePosition = default(Vector3), bool matchRotationOfParent = true)
		{
			PlayerStrengthLevel component = ((Component)__instance).GetComponent<PlayerStrengthLevel>();
			if (component.canDrop && PlayerStrengthLevel.strongerBodyStatus)
			{
				Object.FindObjectOfType<EquipmentNetworkHandler>().ChangeWeightsFunction(__instance, component);
				Object.FindObjectOfType<EquipmentNetworkHandler>().DropWeightServerRpc(__instance.playerClientId, __instance.currentlyHeldObjectServer.itemProperties.weight);
				component.canDrop = false;
			}
		}

		[HarmonyPatch(typeof(HUDManager), "Update")]
		[HarmonyPostfix]
		private static void ChangeHUDWeight(HUDManager __instance)
		{
			if (PlayerStrengthLevel.strongerBodyStatus)
			{
				PlayerStrengthLevel component = ((Component)GameNetworkManager.Instance.localPlayerController).gameObject.GetComponent<PlayerStrengthLevel>();
				if ((Object)(object)component == (Object)null)
				{
					Debug.LogWarning((object)"no psl?>?>");
				}
				float num = Mathf.RoundToInt(Mathf.Clamp(component.originalCarryWeight - 1f, 0f, 100f) * 105f);
				((TMP_Text)__instance.weightCounter).text = $"{num} lb";
				__instance.weightCounterAnimator.SetFloat("weight", num / 130f);
			}
		}
	}
	[HarmonyPatch]
	internal class ConfigApply : NetworkBehaviour
	{
		public static UnlockablesList unlockablesList;

		[HarmonyPatch(typeof(PlayerControllerB), "Start")]
		[HarmonyPostfix]
		private static void UpdateBenchPriceController()
		{
			Object.FindObjectOfType<EquipmentNetworkHandler>().UpdateDecorPriceStart(unlockablesList);
		}
	}
}