Decompiled source of DevilDeal v1.0.3

BepInEx/plugins/DevilDeal/com.github.xuuxiaolan.devildeal.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using DevilDeal.Persistence;
using DevilDeal.Util;
using DevilDeal.Util.AssetLoading;
using DevilDeal.Util.Extensions;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLevelLoader;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Unity.Mathematics;
using Unity.Netcode;
using Unity.Netcode.Components;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using com.github.xuuxiaolan.devildeal.NetcodePatcher;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("com.github.xuuxiaolan.devildeal")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("asdfasdfasdasdasd")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f350e443ef6c359cf6ada1822fb6d47e431ea920")]
[assembly: AssemblyProduct("DevilDeal")]
[assembly: AssemblyTitle("com.github.xuuxiaolan.devildeal")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
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 DevilDeal
{
	public class Dealer : NetworkBehaviour
	{
		public enum CardNumber
		{
			One,
			Two,
			Three
		}

		public enum PositiveEffect
		{
			IncreaseMovementSpeed,
			SpawnShotgunWithShells,
			IncreaseStamina,
			IncreaseHealth,
			DecreaseMoonPrices,
			SpawnGoldBar,
			IncreaseCarrySlotNumber,
			SpawnJetpack,
			RandomShopItem,
			RandomShipUpgrade
		}

		public enum NegativeEffect
		{
			DecreaseMovementSpeed,
			StealCreditOrScrap,
			DecreaseStamina,
			IncreaseMoonPrices,
			DecreaseCarrySlotNumber,
			DealPlayerDamage
		}

		public Animator animator;

		public NetworkAnimator networkAnimator;

		public InteractTrigger trigger;

		public InteractTrigger[] cardTriggers;

		public Renderer[] cardRenderers;

		public ParticleSystem mainParticles;

		public ParticleSystem[] handParticles;

		private bool dealMade;

		private bool particlesEnabled;

		private PlayerControllerB? playerWhoCanDoShit;

		public Transform ItemSpawnSpot;

		[Header("Audio")]
		[SerializeField]
		private AudioSource _voicelineSource;

		[SerializeField]
		private AudioClip[] _greetingSFX;

		[SerializeField]
		private AudioClip[] _dealMadeSFX;

		[SerializeField]
		private AudioClip[] _dealDeclinedSFX;

		private bool _playedGreetingSFX;

		private Dictionary<CardNumber, (PositiveEffect positive, NegativeEffect negative)> cardEffects = new Dictionary<CardNumber, (PositiveEffect, NegativeEffect)>();

		private bool cardPlayingAnimation;

		private List<PositiveEffect> positiveEffects = new List<PositiveEffect>
		{
			PositiveEffect.IncreaseMovementSpeed,
			PositiveEffect.SpawnShotgunWithShells,
			PositiveEffect.IncreaseStamina,
			PositiveEffect.IncreaseHealth,
			PositiveEffect.DecreaseMoonPrices,
			PositiveEffect.SpawnGoldBar,
			PositiveEffect.IncreaseCarrySlotNumber,
			PositiveEffect.SpawnJetpack
		};

		private List<NegativeEffect> negativeEffects = new List<NegativeEffect>
		{
			NegativeEffect.DecreaseMovementSpeed,
			NegativeEffect.StealCreditOrScrap,
			NegativeEffect.DecreaseStamina,
			NegativeEffect.IncreaseMoonPrices,
			NegativeEffect.DecreaseCarrySlotNumber,
			NegativeEffect.DealPlayerDamage
		};

		private Random random = new Random();

		public static List<int> slotIndexes = new List<int>();

		public static List<Item> ShopItemList = new List<Item>();

		internal static Dealer Instance { get; private set; }

		public void Awake()
		{
			random = new Random(StartOfRound.Instance.randomMapSeed);
			networkAnimator = ((Component)this).GetComponent<NetworkAnimator>();
			animator = ((Component)this).GetComponent<Animator>();
			Instance = this;
			Renderer[] array = cardRenderers;
			foreach (Renderer val in array)
			{
				val.enabled = false;
			}
			InteractTrigger[] array2 = cardTriggers;
			foreach (InteractTrigger val2 in array2)
			{
				val2.interactable = false;
			}
			((UnityEvent<PlayerControllerB>)(object)trigger.onInteract).AddListener((UnityAction<PlayerControllerB>)OnInteract);
		}

		private void OnInteract(PlayerControllerB playerInteracting)
		{
			if (!((Object)(object)playerInteracting != (Object)(object)GameNetworkManager.Instance.localPlayerController))
			{
				HandleInteractionForPlayerServerRpc(Array.IndexOf(StartOfRound.Instance.allPlayerScripts, playerInteracting));
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void HandleInteractionForPlayerServerRpc(int playerThatInteracted)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1417409867u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerThatInteracted);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1417409867u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					HandleInteractionForPlayerClientRpc(playerThatInteracted);
				}
			}
		}

		[ClientRpc]
		public void HandleInteractionForPlayerClientRpc(int playerThatInteracted)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2599425644u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerThatInteracted);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2599425644u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			playerWhoCanDoShit = StartOfRound.Instance.allPlayerScripts[playerThatInteracted];
			int num = 0;
			InteractTrigger[] array = cardTriggers;
			foreach (InteractTrigger val3 in array)
			{
				val3.interactable = true;
				switch (num)
				{
				case 0:
					cardEffects[CardNumber.One] = GetCardEffects();
					((UnityEvent<PlayerControllerB>)(object)val3.onInteract).AddListener((UnityAction<PlayerControllerB>)Card1InteractionResult);
					val3.hoverTip = $"{cardEffects[CardNumber.One].positive} and {cardEffects[CardNumber.One].negative}";
					break;
				case 1:
					cardEffects[CardNumber.Two] = GetCardEffects();
					((UnityEvent<PlayerControllerB>)(object)val3.onInteract).AddListener((UnityAction<PlayerControllerB>)Card2InteractionResult);
					val3.hoverTip = $"{cardEffects[CardNumber.Two].positive} and {cardEffects[CardNumber.Two].negative}";
					break;
				case 2:
					cardEffects[CardNumber.Three] = GetCardEffects();
					((UnityEvent<PlayerControllerB>)(object)val3.onInteract).AddListener((UnityAction<PlayerControllerB>)Card3InteractionResult);
					val3.hoverTip = $"{cardEffects[CardNumber.Three].positive} and {cardEffects[CardNumber.Three].negative}";
					break;
				}
				num++;
				val3.interactable = true;
			}
			Renderer[] array2 = cardRenderers;
			foreach (Renderer val4 in array2)
			{
				val4.enabled = true;
			}
			((Component)trigger).gameObject.SetActive(false);
		}

		public (PositiveEffect positive, NegativeEffect negative) GetCardEffects()
		{
			PositiveEffect item = positiveEffects[random.NextInt(0, positiveEffects.Count - 1)];
			NegativeEffect item2 = negativeEffects[random.NextInt(0, negativeEffects.Count - 1)];
			return (item, item2);
		}

		[ServerRpc(RequireOwnership = false)]
		public void ThreeCardInteractionServerRpc(int cardPickedIndex, int playerModifiedIndex)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2107298348u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, cardPickedIndex);
					BytePacker.WriteValueBitPacked(val2, playerModifiedIndex);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2107298348u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ThreeCardInteractionClientRpc(cardPickedIndex, playerModifiedIndex);
				}
			}
		}

		[ClientRpc]
		public void ThreeCardInteractionClientRpc(int cardPickedIndex, int playerModifiedIndex)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1866112370u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, cardPickedIndex);
				BytePacker.WriteValueBitPacked(val2, playerModifiedIndex);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1866112370u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				InteractTrigger[] array = cardTriggers;
				foreach (InteractTrigger val3 in array)
				{
					val3.interactable = false;
				}
				if (cardPickedIndex == -1 || playerModifiedIndex == -1)
				{
					((MonoBehaviour)this).StartCoroutine(ThreeCardInteractionAnimation(-1, null));
				}
				else
				{
					((MonoBehaviour)this).StartCoroutine(ThreeCardInteractionAnimation(cardPickedIndex, StartOfRound.Instance.allPlayerScripts[playerModifiedIndex]));
				}
			}
		}

		private void Card1InteractionResult(PlayerControllerB? playerThatInteracted)
		{
			if (!((Object)(object)playerThatInteracted != (Object)(object)playerWhoCanDoShit))
			{
				ThreeCardInteractionServerRpc(0, Array.IndexOf(StartOfRound.Instance.allPlayerScripts, playerThatInteracted));
				DevilDeal.ExtendedLogging("Card1InteractionResult");
			}
		}

		private void Card2InteractionResult(PlayerControllerB? playerThatInteracted)
		{
			if (!((Object)(object)playerThatInteracted != (Object)(object)playerWhoCanDoShit))
			{
				ThreeCardInteractionServerRpc(1, Array.IndexOf(StartOfRound.Instance.allPlayerScripts, playerThatInteracted));
				DevilDeal.ExtendedLogging("Card2InteractionResult");
			}
		}

		private void Card3InteractionResult(PlayerControllerB? playerThatInteracted)
		{
			if (!((Object)(object)playerThatInteracted != (Object)(object)playerWhoCanDoShit))
			{
				ThreeCardInteractionServerRpc(2, Array.IndexOf(StartOfRound.Instance.allPlayerScripts, playerThatInteracted));
				DevilDeal.ExtendedLogging("Card3InteractionResult");
			}
		}

		internal void DealDeclined()
		{
			_voicelineSource.PlayOneShot(random.NextItem(_dealDeclinedSFX));
		}

		public void Update()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			bool flag = Vector3.Distance(((Component)this).transform.position, ((Component)GameNetworkManager.Instance.localPlayerController).transform.position) <= 10f;
			if (flag && !_playedGreetingSFX)
			{
				_playedGreetingSFX = true;
				_voicelineSource.PlayOneShot(random.NextItem(_greetingSFX));
			}
			if (flag && !particlesEnabled && !dealMade)
			{
				ParticleSystem[] array = handParticles;
				foreach (ParticleSystem val in array)
				{
					val.Play();
				}
				DevilDeal.ExtendedLogging("Enabling hand particles");
				particlesEnabled = true;
			}
			else if ((!flag || dealMade) && particlesEnabled)
			{
				ParticleSystem[] array2 = handParticles;
				foreach (ParticleSystem val2 in array2)
				{
					val2.Stop();
				}
				DevilDeal.ExtendedLogging("Disabling hand particles");
				particlesEnabled = false;
			}
			if (cardPlayingAnimation && (Vector3.Distance(((Component)cardTriggers[0]).gameObject.transform.position, ((Component)cardTriggers[1]).gameObject.transform.position) > 0.01f || Vector3.Distance(((Component)cardTriggers[2]).gameObject.transform.position, ((Component)cardTriggers[1]).gameObject.transform.position) > 0.01f))
			{
				((Component)cardTriggers[0]).gameObject.transform.position = Vector3.Lerp(((Component)cardTriggers[0]).gameObject.transform.position, ((Component)cardTriggers[1]).gameObject.transform.position, Time.deltaTime * 0.5f);
				((Component)cardTriggers[2]).gameObject.transform.position = Vector3.Lerp(((Component)cardTriggers[2]).gameObject.transform.position, ((Component)cardTriggers[1]).gameObject.transform.position, Time.deltaTime * 0.5f);
			}
			if ((Object)(object)playerWhoCanDoShit != (Object)null && !dealMade && Vector3.Distance(((Component)playerWhoCanDoShit).transform.position, ((Component)this).transform.position) > 10f && (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)playerWhoCanDoShit)
			{
				playerWhoCanDoShit.DamagePlayer(99, true, false, (CauseOfDeath)13, 0, false, default(Vector3));
				playerWhoCanDoShit = null;
				ThreeCardInteractionServerRpc(-1, -1);
			}
		}

		private IEnumerator ThreeCardInteractionAnimation(int cardPickedIndex, PlayerControllerB? playerModified)
		{
			mainParticles.Play();
			Renderer[] array = cardRenderers;
			foreach (Renderer val in array)
			{
				val.material.color = Color.black;
				val.material.mainTexture = null;
			}
			cardPlayingAnimation = true;
			yield return (object)new WaitForSeconds(7f);
			dealMade = true;
			if (!((Object)(object)playerModified == (Object)null) && cardPickedIndex != -1)
			{
				_voicelineSource.PlayOneShot(random.NextItem(_dealMadeSFX));
				switch (cardPickedIndex)
				{
				case 0:
					ExecutePositiveEffect(cardEffects[CardNumber.One].positive, playerModified);
					ExecuteNegativeEffect(cardEffects[CardNumber.One].negative, playerModified);
					break;
				case 1:
					ExecutePositiveEffect(cardEffects[CardNumber.Two].positive, playerModified);
					ExecuteNegativeEffect(cardEffects[CardNumber.Two].negative, playerModified);
					break;
				case 2:
					ExecutePositiveEffect(cardEffects[CardNumber.Three].positive, playerModified);
					ExecuteNegativeEffect(cardEffects[CardNumber.Three].negative, playerModified);
					break;
				}
				DevilDeal.ExtendedLogging("main particles animation done");
			}
		}

		private void OnDisable()
		{
			Instance = null;
		}

		public static void IncreaseMovementSpeed(PlayerControllerB? playerModified)
		{
			if ((Object)(object)playerModified == (Object)null)
			{
				DevilDeal.Logger.LogError((object)"playerModified is null");
				return;
			}
			playerModified.movementSpeed *= 1.25f;
			if (((NetworkBehaviour)StartOfRound.Instance).IsHost || ((NetworkBehaviour)StartOfRound.Instance).IsServer)
			{
				playerModified.GetPersistentData().MovementSpeedUpgrades++;
			}
			DevilDeal.ExtendedLogging("IncreaseMovementSpeed");
		}

		[ClientRpc]
		public void UpdateScanNodeClientRpc(NetworkObjectReference go, int value)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(415053026u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref go, default(ForNetworkSerializable));
				BytePacker.WriteValueBitPacked(val2, value);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 415053026u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				NetworkObject val3 = default(NetworkObject);
				((NetworkObjectReference)(ref go)).TryGet(ref val3, (NetworkManager)null);
				GrabbableObject val4 = default(GrabbableObject);
				if ((Object)(object)val3 != (Object)null && ((Component)val3).gameObject.TryGetComponent<GrabbableObject>(ref val4))
				{
					val4.SetScrapValue(value);
					DevilDeal.ExtendedLogging($"Scrap Value: {value}");
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SpawnShotgunWithShellsServerRpc()
		{
			//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)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1382023074u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1382023074u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				Item val3 = StartOfRound.Instance.allItemsList.itemsList.Where((Item x) => x.itemName == "Shotgun").First();
				GameObject val4 = Object.Instantiate<GameObject>(val3.spawnPrefab, ItemSpawnSpot.position, Quaternion.Euler(val3.restingRotation), RoundManager.Instance.spawnedScrapContainer);
				GrabbableObject component = val4.GetComponent<GrabbableObject>();
				component.SetScrapValue((int)((float)random.NextInt(val3.minValue, val3.maxValue) * RoundManager.Instance.scrapValueMultiplier));
				((NetworkBehaviour)component).NetworkObject.Spawn(false);
				UpdateScanNodeClientRpc(new NetworkObjectReference(val4), component.scrapValue);
				((Component)component).gameObject.transform.position = ItemSpawnSpot.position;
				Item val5 = StartOfRound.Instance.allItemsList.itemsList.Where((Item x) => x.itemName == "Ammo").First();
				for (int i = 0; i < 3; i++)
				{
					GameObject val6 = Object.Instantiate<GameObject>(val5.spawnPrefab, ItemSpawnSpot.position, Quaternion.Euler(val5.restingRotation), RoundManager.Instance.spawnedScrapContainer);
					GrabbableObject component2 = val6.GetComponent<GrabbableObject>();
					((NetworkBehaviour)component2).NetworkObject.Spawn(false);
					((Component)component2).gameObject.transform.position = ItemSpawnSpot.position;
				}
				DevilDeal.ExtendedLogging("SpawnShotgunWithShellsServerRpc");
			}
		}

		public static void IncreaseStamina(PlayerControllerB? playerModified)
		{
			if ((Object)(object)playerModified == (Object)null)
			{
				DevilDeal.Logger.LogError((object)"playerModified is null");
				return;
			}
			playerModified.sprintTime += 5f;
			if (((NetworkBehaviour)StartOfRound.Instance).IsHost || ((NetworkBehaviour)StartOfRound.Instance).IsServer)
			{
				playerModified.GetPersistentData().StaminaUpgrades++;
			}
			DevilDeal.ExtendedLogging("IncreaseStamina");
		}

		public void IncreaseHealth(PlayerControllerB? playerModified)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)playerModified == (Object)null)
			{
				DevilDeal.Logger.LogError((object)"playerModified is null");
				return;
			}
			playerModified.DamagePlayer(playerModified.health - 125, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
			DevilDeal.ExtendedLogging("IncreaseHealth");
		}

		public static void DecreaseMoonPrices()
		{
			foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels)
			{
				extendedLevel.RoutePrice = (int)((float)extendedLevel.RoutePrice / 1.2f);
			}
			if (((NetworkBehaviour)StartOfRound.Instance).IsHost || ((NetworkBehaviour)StartOfRound.Instance).IsServer)
			{
				DevilDealSave.Current.MoonPriceUpgrade++;
			}
			DevilDeal.ExtendedLogging("DecreaseMoonPrices");
		}

		[ServerRpc(RequireOwnership = false)]
		public void SpawnGoldbarServerRpc()
		{
			//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)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(512554314u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 512554314u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				Item val3 = StartOfRound.Instance.allItemsList.itemsList.Where((Item x) => x.itemName == "Gold bar").First();
				GameObject val4 = Object.Instantiate<GameObject>(val3.spawnPrefab, ItemSpawnSpot.position, Quaternion.Euler(val3.restingRotation), RoundManager.Instance.spawnedScrapContainer);
				GrabbableObject component = val4.GetComponent<GrabbableObject>();
				component.SetScrapValue((int)((float)random.NextInt(val3.minValue, val3.maxValue) * RoundManager.Instance.scrapValueMultiplier));
				((NetworkBehaviour)component).NetworkObject.Spawn(false);
				((Component)component).gameObject.transform.position = ItemSpawnSpot.position;
				UpdateScanNodeClientRpc(new NetworkObjectReference(val4), component.scrapValue);
				DevilDeal.ExtendedLogging("SpawnGoldbarServerRpc");
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SpawnJetpackServerRpc()
		{
			//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)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1040790356u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1040790356u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				Item val3 = StartOfRound.Instance.allItemsList.itemsList.Where((Item x) => x.itemName == "Jetpack").First();
				GameObject val4 = Object.Instantiate<GameObject>(val3.spawnPrefab, ItemSpawnSpot.position, Quaternion.Euler(val3.restingRotation), RoundManager.Instance.spawnedScrapContainer);
				GrabbableObject component = val4.GetComponent<GrabbableObject>();
				((NetworkBehaviour)component).NetworkObject.Spawn(false);
				((Component)component).gameObject.transform.position = ItemSpawnSpot.position;
				DevilDeal.ExtendedLogging("SpawnJetpackServerRpc");
			}
		}

		public static void IncreaseCarrySlotNumber(PlayerControllerB? playerModified)
		{
			if ((Object)(object)playerModified == (Object)null)
			{
				DevilDeal.Logger.LogError((object)"playerModified is null");
				return;
			}
			playerModified.DropAllHeldItems(true, false);
			List<GrabbableObject> list = playerModified.ItemSlots.ToList();
			playerModified.ItemSlots = (GrabbableObject[])(object)new GrabbableObject[list.Count + 1];
			if ((Object)(object)playerModified == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				UpdateHUD(add: true);
			}
			if (((NetworkBehaviour)StartOfRound.Instance).IsHost || ((NetworkBehaviour)StartOfRound.Instance).IsServer)
			{
				playerModified.GetPersistentData().CarrySlotUpgrades++;
			}
			DevilDeal.ExtendedLogging("IncreaseCarrySlotNumber");
		}

		public static void DecreaseMovementSpeed(PlayerControllerB? playerModified)
		{
			if ((Object)(object)playerModified == (Object)null)
			{
				DevilDeal.Logger.LogError((object)"playerModified is null");
				return;
			}
			playerModified.movementSpeed /= 1.25f;
			if (((NetworkBehaviour)StartOfRound.Instance).IsHost || ((NetworkBehaviour)StartOfRound.Instance).IsServer)
			{
				playerModified.GetPersistentData().MovementSpeedUpgrades--;
			}
			DevilDeal.ExtendedLogging("DecreaseMovementSpeed");
		}

		[ServerRpc(RequireOwnership = false)]
		public void StealCreditOrScrapServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1697669267u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1697669267u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					DetermineScrapToDestroyOrCreditsToSteal();
					DevilDeal.ExtendedLogging("StealCreditOrScrap");
				}
			}
		}

		public static void DecreaseStamina(PlayerControllerB? playerModified)
		{
			if ((Object)(object)playerModified == (Object)null)
			{
				DevilDeal.Logger.LogError((object)"playerModified is null");
			}
			else if (!(playerModified.sprintTime < 1f))
			{
				playerModified.sprintTime = Mathf.Clamp(playerModified.sprintTime - 2.5f, 1f, 1000f);
				if (((NetworkBehaviour)StartOfRound.Instance).IsHost || ((NetworkBehaviour)StartOfRound.Instance).IsServer)
				{
					playerModified.GetPersistentData().StaminaUpgrades--;
				}
				DevilDeal.ExtendedLogging("DecreaseStamina");
			}
		}

		public static void IncreaseMoonPrices()
		{
			foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels)
			{
				extendedLevel.RoutePrice = (int)((float)extendedLevel.RoutePrice * 1.2f);
			}
			if (((NetworkBehaviour)StartOfRound.Instance).IsHost || ((NetworkBehaviour)StartOfRound.Instance).IsServer)
			{
				DevilDealSave.Current.MoonPriceUpgrade--;
			}
			DevilDeal.ExtendedLogging("IncreaseMoonPrices");
		}

		public static void DecreaseCarrySlotNumber(PlayerControllerB? playerModified)
		{
			if ((Object)(object)playerModified == (Object)null)
			{
				DevilDeal.Logger.LogError((object)"playerModified is null");
				return;
			}
			playerModified.DropAllHeldItems(true, false);
			List<GrabbableObject> list = playerModified.ItemSlots.ToList();
			playerModified.ItemSlots = (GrabbableObject[])(object)new GrabbableObject[list.Count - 1];
			if ((Object)(object)playerModified == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				UpdateHUD(add: false);
			}
			if (((NetworkBehaviour)StartOfRound.Instance).IsHost || ((NetworkBehaviour)StartOfRound.Instance).IsServer)
			{
				playerModified.GetPersistentData().CarrySlotUpgrades--;
			}
			DevilDeal.ExtendedLogging("DecreaseCarrySlotNumber");
		}

		public void DealPlayerDamage(PlayerControllerB? playerModified)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)playerModified == (Object)null)
			{
				DevilDeal.Logger.LogError((object)"playerModified is null");
				return;
			}
			playerModified.DamagePlayer(50, true, false, (CauseOfDeath)13, 0, false, default(Vector3));
			DevilDeal.ExtendedLogging("DealPlayerDamage");
		}

		private void DetermineScrapToDestroyOrCreditsToSteal()
		{
			int groupCredits = Object.FindObjectOfType<Terminal>().groupCredits;
			int num = 0;
			List<GrabbableObject> list = (from x in GameObject.Find("/Environment/HangarShip").GetComponentsInChildren<GrabbableObject>()
				where x.itemProperties.isScrap
				select x).ToList();
			if (groupCredits > 700)
			{
				num = (int)((float)groupCredits * 0.8f);
			}
			if (num > 0)
			{
				UpdateCreditsClientRpc(num);
			}
			else if (list.Count >= 3)
			{
				for (int i = 0; i < 3; i++)
				{
					int index = Random.Range(0, list.Count);
					GrabbableObject val = list[index];
					list.RemoveAt(index);
					NetworkObject component = ((Component)val).GetComponent<NetworkObject>();
					if ((Object)(object)component != (Object)null && component.IsSpawned)
					{
						component.Despawn(true);
					}
				}
				UpdateCurrentShipItemCountClientRpc();
			}
			else if (Random.Range(0f, 100f) > 95f)
			{
				UpdateCreditsClientRpc(666);
			}
			else
			{
				UpdateCreditsClientRpc(0);
			}
		}

		[ClientRpc]
		private void UpdateCurrentShipItemCountClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(784974604u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 784974604u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					StartOfRound instance = StartOfRound.Instance;
					instance.currentShipItemCount -= 3;
				}
			}
		}

		[ClientRpc]
		private void UpdateCreditsClientRpc(int credits)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3633659879u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, credits);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3633659879u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					Object.FindObjectOfType<Terminal>().groupCredits = credits;
				}
			}
		}

		private void ExecutePositiveEffect(PositiveEffect effect, PlayerControllerB? playerModified)
		{
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			switch (effect)
			{
			case PositiveEffect.IncreaseMovementSpeed:
				IncreaseMovementSpeed(playerModified);
				break;
			case PositiveEffect.SpawnShotgunWithShells:
				if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)playerModified)
				{
					SpawnShotgunWithShellsServerRpc();
				}
				break;
			case PositiveEffect.IncreaseStamina:
				IncreaseStamina(playerModified);
				break;
			case PositiveEffect.SpawnJetpack:
				if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)playerModified)
				{
					SpawnJetpackServerRpc();
				}
				break;
			case PositiveEffect.IncreaseHealth:
				IncreaseHealth(playerModified);
				break;
			case PositiveEffect.DecreaseMoonPrices:
				DecreaseMoonPrices();
				break;
			case PositiveEffect.SpawnGoldBar:
				if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)playerModified)
				{
					SpawnGoldbarServerRpc();
				}
				break;
			case PositiveEffect.IncreaseCarrySlotNumber:
				IncreaseCarrySlotNumber(playerModified);
				break;
			case PositiveEffect.RandomShopItem:
				if (((NetworkBehaviour)this).IsHost)
				{
					Item randomShopItem = GetRandomShopItem();
					GameObject val = Object.Instantiate<GameObject>(randomShopItem.spawnPrefab, ItemSpawnSpot.position, Quaternion.Euler(randomShopItem.restingRotation), RoundManager.Instance.spawnedScrapContainer);
					GrabbableObject component = val.GetComponent<GrabbableObject>();
					if ((Object)(object)component == (Object)null)
					{
						Object.Destroy((Object)(object)val);
						break;
					}
					component.SetScrapValue((int)((float)random.Next(randomShopItem.minValue + 10, randomShopItem.maxValue + 10) * RoundManager.Instance.scrapValueMultiplier));
					((NetworkBehaviour)component).NetworkObject.Spawn(false);
					UpdateScanNodeClientRpc(new NetworkObjectReference(val), component.scrapValue);
				}
				break;
			case PositiveEffect.RandomShipUpgrade:
				if (((NetworkBehaviour)this).IsHost)
				{
					List<UnlockableItem> unlockables = StartOfRound.Instance.unlockablesList.unlockables;
					UnlockableItem item = random.NextItem(unlockables);
					StartOfRound.Instance.BuyShipUnlockableServerRpc(unlockables.IndexOf(item), Object.FindObjectOfType<Terminal>().groupCredits);
				}
				break;
			}
		}

		private void ExecuteNegativeEffect(NegativeEffect effect, PlayerControllerB? playerModified)
		{
			switch (effect)
			{
			case NegativeEffect.DecreaseMovementSpeed:
				DecreaseMovementSpeed(playerModified);
				break;
			case NegativeEffect.StealCreditOrScrap:
				if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)playerModified)
				{
					StealCreditOrScrapServerRpc();
				}
				break;
			case NegativeEffect.DecreaseStamina:
				DecreaseStamina(playerModified);
				break;
			case NegativeEffect.IncreaseMoonPrices:
				IncreaseMoonPrices();
				break;
			case NegativeEffect.DecreaseCarrySlotNumber:
				DecreaseCarrySlotNumber(playerModified);
				break;
			case NegativeEffect.DealPlayerDamage:
				DealPlayerDamage(playerModified);
				break;
			}
		}

		public static void ApplyEffects(PlayerControllerB player)
		{
			DevilDeal.Logger.LogInfo((object)"applying effects..");
			DevilDealLocalSave persistentData = player.GetPersistentData();
			ApplyEffect(player, persistentData.MovementSpeedUpgrades, IncreaseMovementSpeed, DecreaseMovementSpeed);
			ApplyEffect(player, persistentData.StaminaUpgrades, IncreaseStamina, DecreaseStamina);
			ApplyEffect(player, persistentData.CarrySlotUpgrades, IncreaseCarrySlotNumber, DecreaseCarrySlotNumber);
		}

		private static void ApplyEffect(PlayerControllerB player, int amount, Action<PlayerControllerB> positive, Action<PlayerControllerB> negative)
		{
			if (amount == 0)
			{
				return;
			}
			for (int i = 0; i < Math.Abs(amount); i++)
			{
				if (amount > 0)
				{
					positive(player);
				}
				else
				{
					negative(player);
				}
			}
		}

		public static void UpdateHUD(bool add)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: 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)
			slotIndexes.Clear();
			HUDManager instance = HUDManager.Instance;
			if (add)
			{
				Image val = instance.itemSlotIconFrames[0];
				Image val2 = instance.itemSlotIcons[0];
				int num = instance.itemSlotIconFrames.Length;
				float x = ((Graphic)val).rectTransform.sizeDelta.x;
				float y = ((Graphic)val).rectTransform.sizeDelta.y;
				float num2 = ((Graphic)val).rectTransform.anchoredPosition.y + 1.125f * y;
				Vector3 localEulerAngles = ((Transform)((Graphic)val).rectTransform).localEulerAngles;
				Vector3 localEulerAngles2 = ((Transform)((Graphic)val2).rectTransform).localEulerAngles;
				List<Image> list = instance.itemSlotIconFrames.ToList();
				List<Image> list2 = instance.itemSlotIcons.ToList();
				int count = list.Count;
				DevilDeal.ExtendedLogging("Adding 1 item slots! Surely this will go well..");
				DevilDeal.ExtendedLogging($"Adding after index: {count}");
				int num3 = num - 4;
				float num4 = 0f - ((Component)((Transform)((Graphic)val).rectTransform).parent).GetComponent<RectTransform>().sizeDelta.x / 2f - 3f;
				float num5 = num4 + (float)num3 * x + (float)num3 * 15f;
				Image val3 = list[0];
				Image val4 = Object.Instantiate<Image>(val3, ((Component)val).transform.parent);
				((Object)val4).name = $"Slot{num + num3}[ProjectSCPDealDevil]";
				((Graphic)val4).rectTransform.anchoredPosition = new Vector2(num5, num2);
				((Transform)((Graphic)val4).rectTransform).eulerAngles = localEulerAngles;
				Image component = ((Component)((Component)val4).transform.GetChild(0)).GetComponent<Image>();
				((Object)component).name = "icon";
				((Behaviour)component).enabled = false;
				((Transform)((Graphic)component).rectTransform).eulerAngles = localEulerAngles2;
				((Transform)((Graphic)component).rectTransform).Rotate(new Vector3(0f, 0f, -90f));
				list.Add(val4);
				list2.Add(component);
				((Component)val4).transform.SetSiblingIndex(num3);
				instance.itemSlotIconFrames = list.ToArray();
				instance.itemSlotIcons = list2.ToArray();
				DevilDeal.ExtendedLogging("Added 1 item slots!");
				return;
			}
			List<Image> list3 = instance.itemSlotIconFrames.ToList();
			List<Image> list4 = instance.itemSlotIcons.ToList();
			int count2 = list3.Count;
			int num6 = 0;
			for (int num7 = count2 - 1; num7 >= 0; num7--)
			{
				num6++;
				Image val5 = list3[num7];
				list3.RemoveAt(num7);
				list4.RemoveAt(num7);
				Object.Destroy((Object)(object)((Component)val5).gameObject);
				if (num6 >= 1)
				{
					break;
				}
			}
			instance.itemSlotIconFrames = list3.ToArray();
			instance.itemSlotIcons = list4.ToArray();
			DevilDeal.ExtendedLogging("Removed 1 item slots!");
		}

		public static Item GetRandomShopItem()
		{
			if (ShopItemList.Count == 0)
			{
				Terminal val = Object.FindObjectOfType<Terminal>();
				foreach (Item items in StartOfRound.Instance.allItemsList.itemsList)
				{
					if (!items.isScrap && val.buyableItemsList.Contains(items))
					{
						ShopItemList.Add(items);
					}
				}
			}
			return ShopItemList[Random.Range(0, ShopItemList.Count)];
		}

		internal static bool IsDealerSpawnValidNow()
		{
			return TimeOfDay.Instance.daysUntilDeadline == 0;
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_Dealer()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(1417409867u, new RpcReceiveHandler(__rpc_handler_1417409867));
			NetworkManager.__rpc_func_table.Add(2599425644u, new RpcReceiveHandler(__rpc_handler_2599425644));
			NetworkManager.__rpc_func_table.Add(2107298348u, new RpcReceiveHandler(__rpc_handler_2107298348));
			NetworkManager.__rpc_func_table.Add(1866112370u, new RpcReceiveHandler(__rpc_handler_1866112370));
			NetworkManager.__rpc_func_table.Add(415053026u, new RpcReceiveHandler(__rpc_handler_415053026));
			NetworkManager.__rpc_func_table.Add(1382023074u, new RpcReceiveHandler(__rpc_handler_1382023074));
			NetworkManager.__rpc_func_table.Add(512554314u, new RpcReceiveHandler(__rpc_handler_512554314));
			NetworkManager.__rpc_func_table.Add(1040790356u, new RpcReceiveHandler(__rpc_handler_1040790356));
			NetworkManager.__rpc_func_table.Add(1697669267u, new RpcReceiveHandler(__rpc_handler_1697669267));
			NetworkManager.__rpc_func_table.Add(784974604u, new RpcReceiveHandler(__rpc_handler_784974604));
			NetworkManager.__rpc_func_table.Add(3633659879u, new RpcReceiveHandler(__rpc_handler_3633659879));
		}

		private static void __rpc_handler_1417409867(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerThatInteracted = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerThatInteracted);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Dealer)(object)target).HandleInteractionForPlayerServerRpc(playerThatInteracted);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2599425644(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerThatInteracted = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerThatInteracted);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((Dealer)(object)target).HandleInteractionForPlayerClientRpc(playerThatInteracted);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2107298348(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int cardPickedIndex = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref cardPickedIndex);
				int playerModifiedIndex = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerModifiedIndex);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Dealer)(object)target).ThreeCardInteractionServerRpc(cardPickedIndex, playerModifiedIndex);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1866112370(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int cardPickedIndex = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref cardPickedIndex);
				int playerModifiedIndex = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerModifiedIndex);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((Dealer)(object)target).ThreeCardInteractionClientRpc(cardPickedIndex, playerModifiedIndex);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_415053026(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_005c: 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)
			{
				NetworkObjectReference go = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref go, default(ForNetworkSerializable));
				int value = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref value);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((Dealer)(object)target).UpdateScanNodeClientRpc(go, value);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1382023074(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)1;
				((Dealer)(object)target).SpawnShotgunWithShellsServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_512554314(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)1;
				((Dealer)(object)target).SpawnGoldbarServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1040790356(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)1;
				((Dealer)(object)target).SpawnJetpackServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1697669267(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)1;
				((Dealer)(object)target).StealCreditOrScrapServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_784974604(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;
				((Dealer)(object)target).UpdateCurrentShipItemCountClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3633659879(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int credits = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref credits);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((Dealer)(object)target).UpdateCreditsClientRpc(credits);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "Dealer";
		}
	}
	[BepInPlugin("com.github.xuuxiaolan.devildeal", "DevilDeal", "1.0.0")]
	public class DevilDeal : BaseUnityPlugin
	{
		internal static ManualLogSource Logger { get; private set; }

		internal static DevilDealAssets Assets { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Assets = new DevilDealAssets("devilassetbundle");
			NetcodePatcher();
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.github.xuuxiaolan.devildeal");
			Logger.LogInfo((object)"com.github.xuuxiaolan.devildeal v1.0.0 has loaded!");
		}

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

		internal static void ExtendedLogging(object text)
		{
			Logger.LogInfo(text);
		}
	}
	public class DevilDealAssets : AssetBundleLoader<DevilDealAssets>
	{
		[LoadFromBundle("DevilContainer.prefab")]
		public GameObject DevilContainerPrefab { get; private set; }

		public DevilDealAssets(string bundleName)
			: base(bundleName, registerNetworkPrefabs: true, fixMixerGroups: true)
		{
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.github.xuuxiaolan.devildeal";

		public const string PLUGIN_NAME = "DevilDeal";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace DevilDeal.Util
{
	public class DevilDealManager : NetworkBehaviour
	{
		private GameObject _devilDealContainerInstance;

		internal static DevilDealManager Instance { get; private set; }

		internal static GameObject Prefab { get; set; }

		[ServerRpc(RequireOwnership = false)]
		private void RequestLoadSaveDataServerRPC(int playerID)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(701949036u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerID);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 701949036u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ulong playerSteamId = StartOfRound.Instance.allPlayerScripts[playerID].playerSteamId;
				if (!DevilDealSave.Current.PlayerData.ContainsKey(playerSteamId))
				{
					DevilDealSave.Current.PlayerData[playerSteamId] = new DevilDealLocalSave();
					DevilDealSave.Current.Save();
				}
				SetSaveDataClientRPC(playerID, JsonConvert.SerializeObject((object)DevilDealSave.Current));
			}
		}

		[ClientRpc]
		private void SetSaveDataClientRPC(int playerID, string saveData)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_0095: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Expected O, but got Unknown
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(927886976u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerID);
				bool flag = saveData != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(saveData, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 927886976u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			DevilDeal.ExtendedLogging("Received save data from host!");
			if (!((NetworkBehaviour)this).IsHost && !((NetworkBehaviour)this).IsServer)
			{
				DevilDealSave.Current = JsonConvert.DeserializeObject<DevilDealSave>(saveData, new JsonSerializerSettings
				{
					ContractResolver = (IContractResolver)(object)new IncludePrivateSetterContractResolver()
				});
			}
			if ((Object)(object)StartOfRound.Instance.allPlayerScripts[playerID] == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
				foreach (PlayerControllerB val3 in allPlayerScripts)
				{
					if (val3.isPlayerControlled)
					{
						Dealer.ApplyEffects(val3);
					}
				}
				for (int j = 0; j < Math.Abs(DevilDealSave.Current.MoonPriceUpgrade); j++)
				{
					if (DevilDealSave.Current.MoonPriceUpgrade > 0)
					{
						Dealer.DecreaseMoonPrices();
					}
					else
					{
						Dealer.IncreaseMoonPrices();
					}
				}
			}
			else
			{
				Dealer.ApplyEffects(StartOfRound.Instance.allPlayerScripts[playerID]);
			}
		}

		public override void OnNetworkSpawn()
		{
			Instance = this;
			if (((NetworkBehaviour)this).IsHost || ((NetworkBehaviour)this).IsServer)
			{
				DevilDealSave.Current = PersistentDataHandler.Load<DevilDealSave>($"DevilSave{GameNetworkManager.Instance.saveFileNum}");
				DevilDeal.Logger.LogInfo((object)"Loaded persistent data");
			}
			RequestLoadSaveDataServerRPC(StartOfRound.Instance.ClientPlayerList[NetworkManager.Singleton.LocalClientId]);
		}

		public void SpawnDevilProps()
		{
			_devilDealContainerInstance = Object.Instantiate<GameObject>(DevilDeal.Assets.DevilContainerPrefab);
			_devilDealContainerInstance.GetComponent<NetworkObject>().Spawn(false);
			DevilDeal.ExtendedLogging("Spawned devil deal container!");
		}

		public void DespawnDevilProps()
		{
			_devilDealContainerInstance.GetComponent<NetworkObject>().Despawn(true);
			DevilDeal.ExtendedLogging("Despawned!");
		}

		private void OnDisable()
		{
			if (!((Object)(object)Instance != (Object)(object)this))
			{
				DevilDealSave.Current = null;
				Instance = null;
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_DevilDealManager()
		{
			//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
			NetworkManager.__rpc_func_table.Add(701949036u, new RpcReceiveHandler(__rpc_handler_701949036));
			NetworkManager.__rpc_func_table.Add(927886976u, new RpcReceiveHandler(__rpc_handler_927886976));
		}

		private static void __rpc_handler_701949036(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerID = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerID);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((DevilDealManager)(object)target).RequestLoadSaveDataServerRPC(playerID);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_927886976(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_006e: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerID = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerID);
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string saveData = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref saveData, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((DevilDealManager)(object)target).SetSaveDataClientRPC(playerID, saveData);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "DevilDealManager";
		}
	}
}
namespace DevilDeal.Util.Extensions
{
	public static class NetworkObjectExtensions
	{
		public static IEnumerator WaitUntilSpawned(this NetworkObject networkObject)
		{
			yield return (object)new WaitUntil((Func<bool>)(() => networkObject.IsSpawned));
		}

		private static IEnumerator RunActionAfterSpawned(NetworkObject networkObject, Action action)
		{
			yield return networkObject.WaitUntilSpawned();
			action();
		}

		public static void OnSpawn(this NetworkObject networkObject, Action action)
		{
			((MonoBehaviour)networkObject).StartCoroutine(RunActionAfterSpawned(networkObject, action));
		}
	}
	internal static class PlayerControllerExtensions
	{
		internal static DevilDealLocalSave GetPersistentData(this PlayerControllerB player)
		{
			return DevilDealSave.Current.PlayerData[player.playerSteamId];
		}
	}
	public static class RandomExtensions
	{
		public static T NextEnum<T>(this Random random) where T : struct, Enum
		{
			Array values = Enum.GetValues(typeof(T));
			return (T)values.GetValue(random.Next(values.Length));
		}

		public static T NextItem<T>(this Random random, List<T> collection)
		{
			int index = random.Next(collection.Count);
			return collection[index];
		}

		public static T NextItem<T>(this Random random, T[] collection)
		{
			int num = random.Next(collection.Length);
			return collection[num];
		}

		public static double NextDouble(this Random random, double min, double max)
		{
			return random.NextDouble() * (max - min) + min;
		}

		public static float NextFloat(this Random random, float min, float max)
		{
			return (float)random.NextDouble(min, max);
		}

		public static int NextInt(this Random random, int min, int max)
		{
			return random.Next(min, max + 1);
		}

		public static bool NextBool(this Random random)
		{
			return random.Next(0, 2) == 0;
		}

		public static int NextSign(this Random random)
		{
			if (!random.NextBool())
			{
				return -1;
			}
			return 1;
		}

		public static Quaternion NextQuaternion(this Random random)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			return quaternion.op_Implicit(quaternion.Euler(random.NextFloat(0f, 360f), random.NextFloat(0f, 360f), random.NextFloat(0f, 360f), (RotationOrder)4));
		}
	}
	internal static class TransformExtensions
	{
		public static void KillAllChildren(this Transform transform)
		{
			for (int num = transform.childCount - 1; num >= 0; num--)
			{
				Object.Destroy((Object)(object)((Component)transform.GetChild(num)).gameObject);
			}
		}
	}
}
namespace DevilDeal.Util.AssetLoading
{
	public class AssetBundleLoader<T> where T : AssetBundleLoader<T>
	{
		protected AssetBundle bundle;

		protected AssetBundleLoader(string filePath, bool registerNetworkPrefabs = true, bool fixMixerGroups = true)
		{
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), filePath);
			bundle = AssetBundle.LoadFromFile(text);
			DevilDeal.Logger.LogDebug((object)("[AssetBundle Loading] " + filePath + " contains these objects: \n" + string.Join("\n", bundle.GetAllAssetNames())));
			Type typeFromHandle = typeof(T);
			PropertyInfo[] properties = typeFromHandle.GetProperties();
			foreach (PropertyInfo propertyInfo in properties)
			{
				LoadFromBundleAttribute loadFromBundleAttribute = (LoadFromBundleAttribute)propertyInfo.GetCustomAttribute(typeof(LoadFromBundleAttribute));
				if (loadFromBundleAttribute != null)
				{
					propertyInfo.SetValue(this, LoadAsset(bundle, loadFromBundleAttribute.BundleFile));
				}
			}
			GameObject[] array = bundle.LoadAllAssets<GameObject>();
			foreach (GameObject val in array)
			{
				if (fixMixerGroups)
				{
					Utilities.FixMixerGroups(val);
					DevilDeal.ExtendedLogging("[AssetBundle Loading] Fixed Mixer Groups: " + ((Object)val).name);
				}
				if (registerNetworkPrefabs && !((Object)(object)val.GetComponent<NetworkObject>() == (Object)null))
				{
					NetworkPrefabs.RegisterNetworkPrefab(val);
					DevilDeal.ExtendedLogging("[AssetBundle Loading] Registered Network Prefab: " + ((Object)val).name);
				}
			}
			Item[] array2 = bundle.LoadAllAssets<Item>();
			foreach (Item val2 in array2)
			{
				if (registerNetworkPrefabs && !((Object)(object)val2.spawnPrefab == (Object)null) && !((Object)(object)val2.spawnPrefab.GetComponent<NetworkObject>() == (Object)null))
				{
					NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
					DevilDeal.ExtendedLogging("[AssetBundle Loading] Registered Network Prefab: " + ((Object)val2).name);
				}
			}
		}

		private Object LoadAsset(AssetBundle bundle, string path)
		{
			Object val = bundle.LoadAsset<Object>(path);
			if (val == (Object)null)
			{
				throw new ArgumentException(path + " is not valid in the assetbundle!");
			}
			return val;
		}
	}
	[AttributeUsage(AttributeTargets.Property)]
	internal class LoadFromBundleAttribute : Attribute
	{
		public string BundleFile { get; private set; }

		public LoadFromBundleAttribute(string bundleFile)
		{
			BundleFile = bundleFile;
			base..ctor();
		}
	}
}
namespace DevilDeal.Persistence
{
	internal abstract class SaveableData
	{
		[JsonIgnore]
		public string FileName { get; private set; }

		protected SaveableData(string fileName)
		{
			FileName = fileName;
			base..ctor();
		}

		public virtual void Save()
		{
			PersistentDataHandler.Save(FileName, this);
		}
	}
	internal static class PersistentDataHandler
	{
		private const string SAVE_EXTENSION = ".devil_deal_save";

		private static string GetFullPath(string fileName)
		{
			string text = Path.Combine(Application.persistentDataPath, "DevilDeal");
			Directory.CreateDirectory(text);
			return Path.Combine(text, fileName);
		}

		internal static T Load<T>(string fileName)
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			string fullPath = GetFullPath(fileName + ".devil_deal_save");
			if (!File.Exists(fullPath))
			{
				DevilDeal.ExtendedLogging("Data does not exist! Using default constructor!");
				T val = (T)typeof(T).GetConstructor(new Type[1] { typeof(string) }).Invoke(new object[1] { fileName });
				Save(fileName, val);
				return val;
			}
			DevilDeal.ExtendedLogging("Save exists! Attempting to load!");
			return JsonConvert.DeserializeObject<T>(File.ReadAllText(fullPath), new JsonSerializerSettings
			{
				ContractResolver = (IContractResolver)(object)new IncludePrivateSetterContractResolver()
			});
		}

		internal static void Save<T>(string fileName, T data)
		{
			File.WriteAllText(GetFullPath(fileName + ".devil_deal_save"), JsonConvert.SerializeObject((object)data));
		}

		internal static bool TryDelete(string fileName)
		{
			string fullPath = GetFullPath(fileName + ".devil_deal_save");
			if (File.Exists(fullPath))
			{
				File.Delete(fullPath);
				return true;
			}
			return false;
		}
	}
	internal class IncludePrivateSetterContractResolver : DefaultContractResolver
	{
		protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			JsonProperty val = ((DefaultContractResolver)this).CreateProperty(member, memberSerialization);
			if (!val.Writable && member is PropertyInfo propertyInfo && !val.Ignored)
			{
				val.Writable = propertyInfo.GetSetMethod(nonPublic: true) != null;
			}
			return val;
		}
	}
	internal class DevilDealSave : SaveableData
	{
		public static DevilDealSave Current;

		public int MoonPriceUpgrade { get; set; }

		public Dictionary<ulong, DevilDealLocalSave> PlayerData { get; private set; } = new Dictionary<ulong, DevilDealLocalSave>();


		public DevilDealSave(string fileName)
			: base(fileName)
		{
		}

		public override void Save()
		{
			EnsureHost();
			base.Save();
		}

		private void EnsureHost()
		{
			if (!((NetworkBehaviour)StartOfRound.Instance).IsHost && !((NetworkBehaviour)StartOfRound.Instance).IsServer)
			{
				throw new InvalidOperationException("Only the host should save.");
			}
		}
	}
	internal class DevilDealLocalSave
	{
		public int MovementSpeedUpgrades { get; set; }

		public int StaminaUpgrades { get; set; }

		public int CarrySlotUpgrades { get; set; }
	}
}
namespace DevilDeal.Patches
{
	[HarmonyPatch(typeof(DeleteFileButton))]
	internal static class DeleteFileButtonPatch
	{
		[HarmonyPatch("DeleteFile")]
		[HarmonyPostfix]
		private static void DeleteCodeRebirthData(DeleteFileButton __instance)
		{
			PersistentDataHandler.TryDelete($"DevilSave{__instance.fileToDelete}");
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal static class GameNetworkManagerPatch
	{
		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		[HarmonyPrefix]
		private static void AddNetworkPrefab()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			DevilDealManager.Prefab = new GameObject("DevilDealDataManager");
			((Object)DevilDealManager.Prefab).hideFlags = (HideFlags)61;
			NetworkObject val = DevilDealManager.Prefab.AddComponent<NetworkObject>();
			val.GlobalObjectIdHash = BitConverter.ToUInt32(Encoding.UTF8.GetBytes(((Object)DevilDealManager.Prefab).name), 0);
			DevilDealManager.Prefab.AddComponent<DevilDealManager>();
			NetworkManager.Singleton.AddNetworkPrefab(DevilDealManager.Prefab);
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal static class RoundManagerPatch
	{
		[HarmonyPatch("LoadNewLevelWait")]
		[HarmonyPrefix]
		public static void LoadNewLevelWaitPatch(RoundManager __instance)
		{
			if (__instance.currentLevel.levelID == 3 && Dealer.IsDealerSpawnValidNow())
			{
				DevilDeal.ExtendedLogging("Spawning Devil deal objects");
				if (((NetworkBehaviour)RoundManager.Instance).IsServer)
				{
					DevilDealManager.Instance.SpawnDevilProps();
				}
			}
		}

		[HarmonyPatch("DespawnPropsAtEndOfRound")]
		[HarmonyPostfix]
		public static void DespawnPropsAtEndOfRoundPatch(RoundManager __instance)
		{
			if (__instance.currentLevel.levelID == 3 && Dealer.IsDealerSpawnValidNow())
			{
				DevilDeal.ExtendedLogging("Despawning Devil deal objects");
				if (((NetworkBehaviour)RoundManager.Instance).IsServer)
				{
					DevilDealManager.Instance.DespawnDevilProps();
				}
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal static class StartOfRoundPatch
	{
		[HarmonyPatch("ShipLeave")]
		[HarmonyPostfix]
		private static void HandleDealDeclinedSFX()
		{
			if ((Object)(object)Dealer.Instance != (Object)null)
			{
				Dealer.Instance.DealDeclined();
			}
		}

		[HarmonyPatch("ResetShip")]
		[HarmonyPostfix]
		private static void ResetSave()
		{
			DevilDealSave.Current = new DevilDealSave(DevilDealSave.Current.FileName);
			if (((NetworkBehaviour)StartOfRound.Instance).IsHost || ((NetworkBehaviour)StartOfRound.Instance).IsServer)
			{
				DevilDealSave.Current.Save();
			}
		}

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void StartOfRound_Awake(ref StartOfRound __instance)
		{
			((NetworkBehaviour)__instance).NetworkObject.OnSpawn(CreateNetworkManager);
		}

		private static void CreateNetworkManager()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)StartOfRound.Instance).IsServer || ((NetworkBehaviour)StartOfRound.Instance).IsHost)
			{
				if ((Object)(object)DevilDealManager.Instance == (Object)null)
				{
					GameObject val = Object.Instantiate<GameObject>(DevilDealManager.Prefab);
					SceneManager.MoveGameObjectToScene(val, ((Component)StartOfRound.Instance).gameObject.scene);
					val.GetComponent<NetworkObject>().Spawn(false);
					Scene scene = val.scene;
					DevilDeal.ExtendedLogging("Created DevilManager. Scene is: '" + ((Scene)(ref scene)).name + "'");
				}
				else
				{
					DevilDeal.Logger.LogWarning((object)"DevilManager already exists?");
				}
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace com.github.xuuxiaolan.devildeal.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}