Decompiled source of ChallengeGates v1.0.2

ChallengeGates.dll

Decompiled 2 weeks 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 BepInEx;
using BepInEx.Configuration;
using ChallengeGates.NetcodePatcher;
using ChallengeGates.Utils;
using GameNetcodeStuff;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using LethalLib.Extras;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ChallengeGates")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("ChallengeGates")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e352df4f7450cc5eaf1a1112a3316c2aa0546725")]
[assembly: AssemblyProduct("ChallengeGates")]
[assembly: AssemblyTitle("ChallengeGates")]
[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 ChallengeGates
{
	[BepInPlugin("wexop.challenge_gates", "ChallengeGates", "1.0.2")]
	public class ChallengeGatesPlugin : BaseUnityPlugin
	{
		private const string GUID = "wexop.challenge_gates";

		private const string NAME = "ChallengeGates";

		private const string VERSION = "1.0.2";

		public static ChallengeGatesPlugin instance;

		public ConfigEntry<float> baseRoomYPosition;

		public ConfigEntry<int> maxSpawn;

		public ConfigEntry<int> minSpawn;

		public ConfigEntry<int> baseTrophyValue;

		public ConfigEntry<int> trophyDecreaseAmount;

		public ConfigEntry<int> trophyDecreaseDelay;

		public ConfigEntry<bool> debug;

		public int numberOfRoom = 0;

		public Dictionary<int, Vector3> spawnedRooms = new Dictionary<int, Vector3>();

		public GameObject trophyGameObject;

		public GameObject gateGameObject;

		public GameObject movingSpikesObject;

		private float timer;

		private void Update()
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			if (!debug.Value)
			{
				return;
			}
			timer -= Time.deltaTime;
			if (timer > 0f)
			{
				return;
			}
			float num = IngamePlayerSettings.Instance.playerInput.actions.FindAction("Discard", false).ReadValue<float>();
			if (num > 0f && (Object)(object)gateGameObject != (Object)null)
			{
				GameObject val = Object.Instantiate<GameObject>(gateGameObject, ((Component)GameNetworkManager.Instance.localPlayerController).transform.position + ((Component)GameNetworkManager.Instance.localPlayerController).transform.forward * 15f, Quaternion.identity);
				NetworkObject component = val.GetComponent<NetworkObject>();
				if (component.IsOwner)
				{
					component.Spawn(false);
				}
				timer = 2f;
			}
		}

		private void Awake()
		{
			instance = this;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"ChallengeGates starting....");
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "challengegates");
			AssetBundle bundle = AssetBundle.LoadFromFile(text);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"ChallengeGates bundle found !");
			NetcodePatcher();
			LoadConfigs();
			RegisterScrap(bundle);
			RegisterHazard(bundle);
			RegisterNetworkPrefabs(bundle);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"ChallengeGates is ready!");
		}

		public (int, Vector3) GetNewRoomPos()
		{
			//IL_004c: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			int num = numberOfRoom;
			numberOfRoom++;
			Vector3 value = default(Vector3);
			((Vector3)(ref value))..ctor(0f, 0f - baseRoomYPosition.Value, 0f);
			foreach (KeyValuePair<int, Vector3> spawnedRoom in spawnedRooms)
			{
				if (Vector3.Distance(Vector3.zero, value) < Vector3.Distance(Vector3.zero, spawnedRoom.Value))
				{
					value = spawnedRoom.Value;
				}
			}
			Vector3 val = value + new Vector3(100f, 0f, 0f);
			spawnedRooms.Add(num, val);
			return (num, val);
		}

		private string RarityString(int rarity)
		{
			return $"Modded:{rarity},ExperimentationLevel:{rarity},AssuranceLevel:{rarity},VowLevel:{rarity},OffenseLevel:{rarity},MarchLevel:{rarity},RendLevel:{rarity},DineLevel:{rarity},TitanLevel:{rarity},Adamance:{rarity},Embrion:{rarity},Artifice:{rarity}";
		}

		private void LoadConfigs()
		{
			baseRoomYPosition = ((BaseUnityPlugin)this).Config.Bind<float>("General", "baseRoomYPosition", 450f, "Position Y of room. You don't need to restart the game :)");
			CreateFloatConfig(baseRoomYPosition, 0f, 1000f);
			minSpawn = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MinSpawn", 0, "Min challenge gate possible for one game. You need to restart the game.");
			CreateIntConfig(minSpawn, 0, 100, restart: true);
			maxSpawn = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxSpawn", 2, "Max challenge gate possible for one game. You need to restart the game.");
			CreateIntConfig(maxSpawn, 0, 100, restart: true);
			baseTrophyValue = ((BaseUnityPlugin)this).Config.Bind<int>("Trophy", "BaseTrophyValue", 250, "Base trophy value. Note that value decrease will you do the challenge and stop when you grab the trophy. You don't need to restart the game :)");
			CreateIntConfig(baseTrophyValue, 0, 750);
			trophyDecreaseAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Trophy", "TrophyDecreaseAmount", 5, "Trophy value decrease with time. Amount that trophy lose each time. You don't need to restart the game :)");
			CreateIntConfig(trophyDecreaseAmount);
			trophyDecreaseDelay = ((BaseUnityPlugin)this).Config.Bind<int>("Trophy", "TrophyDecreaseDelay", 5, "Trophy value decrease with time. Delay in seconds. You don't need to restart the game :)");
			CreateIntConfig(trophyDecreaseDelay, 0, 60);
			debug = ((BaseUnityPlugin)this).Config.Bind<bool>("DEV", "Debug", false, "Enable debug");
			CreateBoolConfig(debug);
		}

		private void RegisterNetworkPrefabs(AssetBundle bundle)
		{
			GameObject val = bundle.LoadAsset<GameObject>("Assets/LethalCompany/Mods/ChallengeGates/MovingSpikes.prefab");
			NetworkPrefabs.RegisterNetworkPrefab(val);
			Utilities.FixMixerGroups(val);
			((BaseUnityPlugin)this).Logger.LogInfo((object)(((Object)val).name + " FOUND"));
			movingSpikesObject = val;
		}

		private void RegisterScrap(AssetBundle bundle)
		{
			Item val = bundle.LoadAsset<Item>("Assets/LethalCompany/Mods/ChallengeGates/Trophy.asset");
			((BaseUnityPlugin)this).Logger.LogInfo((object)(((Object)val).name + " FOUND"));
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"{val.spawnPrefab} prefab");
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Utilities.FixMixerGroups(val.spawnPrefab);
			RegisterUtil.RegisterScrapWithConfig("", val);
			trophyGameObject = val.spawnPrefab;
		}

		private void RegisterHazard(AssetBundle bundle)
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			SpawnableMapObjectDef val = bundle.LoadAsset<SpawnableMapObjectDef>("Assets/LethalCompany/Mods/ChallengeGates/ChallengeGate.asset");
			((BaseUnityPlugin)this).Logger.LogInfo((object)(((Object)val.spawnableMapObject.prefabToSpawn).name + " FOUND"));
			AnimationCurve curve = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
			{
				new Keyframe(0f, (float)instance.minSpawn.Value, 0.267f, 0.267f, 0f, 0f),
				new Keyframe(1f, (float)instance.maxSpawn.Value, 61f, 61f, 0.015f * (float)instance.maxSpawn.Value, 0f)
			});
			val.spawnableMapObject.numberToSpawn = curve;
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnableMapObject.prefabToSpawn);
			Utilities.FixMixerGroups(val.spawnableMapObject.prefabToSpawn);
			MapObjects.RegisterMapObject(val, (LevelTypes)(-1), (Func<SelectableLevel, AnimationCurve>)((SelectableLevel _) => curve));
			gateGameObject = val.spawnableMapObject.prefabToSpawn;
		}

		private static void NetcodePatcher()
		{
			Type[] array;
			try
			{
				array = Assembly.GetExecutingAssembly().GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				array = ex.Types.Where((Type type) => type != null).ToArray();
			}
			Type[] array2 = array;
			foreach (Type type2 in array2)
			{
				MethodInfo[] methods = type2.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}

		private void CreateFloatConfig(ConfigEntry<float> configEntry, float min = 0f, float max = 100f)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			FloatSliderOptions val = new FloatSliderOptions();
			((BaseRangeOptions<float>)val).Min = min;
			((BaseRangeOptions<float>)val).Max = max;
			((BaseOptions)val).RequiresRestart = false;
			FloatSliderConfigItem val2 = new FloatSliderConfigItem(configEntry, val);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
		}

		private void CreateIntConfig(ConfigEntry<int> configEntry, int min = 0, int max = 100, bool restart = false)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			IntSliderOptions val = new IntSliderOptions();
			((BaseRangeOptions<int>)val).Min = min;
			((BaseRangeOptions<int>)val).Max = max;
			((BaseOptions)val).RequiresRestart = restart;
			IntSliderConfigItem val2 = new IntSliderConfigItem(configEntry, val);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
		}

		private void CreateStringConfig(ConfigEntry<string> configEntry, bool requireRestart = false)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			TextInputFieldConfigItem val = new TextInputFieldConfigItem(configEntry, new TextInputFieldOptions
			{
				RequiresRestart = requireRestart
			});
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val);
		}

		public bool StringContain(string name, string verifiedName)
		{
			string text = name.ToLower();
			while (text.Contains(" "))
			{
				text = text.Replace(" ", "");
			}
			string text2 = verifiedName.ToLower();
			while (text2.Contains(" "))
			{
				text2 = text2.Replace(" ", "");
			}
			return text.Contains(text2);
		}

		private void CreateBoolConfig(ConfigEntry<bool> configEntry)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			BoolCheckBoxConfigItem val = new BoolCheckBoxConfigItem(configEntry, new BoolCheckBoxOptions
			{
				RequiresRestart = false
			});
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "ChallengeGates";

		public const string PLUGIN_NAME = "ChallengeGates";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace ChallengeGates.Utils
{
	public class RegisterUtil
	{
		public static void RegisterEnemyWithConfig(string configMoonRarity, EnemyType enemy, TerminalNode terminalNode, TerminalKeyword terminalKeyword, float powerLevel, int spawnCount)
		{
			enemy.MaxCount = spawnCount;
			enemy.PowerLevel = powerLevel;
			var (dictionary, dictionary2) = ConfigParsing(configMoonRarity);
			Enemies.RegisterEnemy(enemy, dictionary, dictionary2, terminalNode, terminalKeyword);
		}

		public static void RegisterScrapWithConfig(string configMoonRarity, Item scrap)
		{
			var (dictionary, dictionary2) = ConfigParsing(configMoonRarity);
			Items.RegisterScrap(scrap, dictionary, dictionary2);
		}

		public static void RegisterShopItemWithConfig(bool enabledScrap, Item item, TerminalNode terminalNode, int itemCost, string configMoonRarity)
		{
			Items.RegisterShopItem(item, (TerminalNode)null, (TerminalNode)null, terminalNode, itemCost);
			if (enabledScrap)
			{
				RegisterScrapWithConfig(configMoonRarity, item);
			}
		}

		public static (Dictionary<LevelTypes, int> spawnRateByLevelType, Dictionary<string, int> spawnRateByCustomLevelType) ConfigParsing(string configMoonRarity)
		{
			//IL_0099: 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)
			Dictionary<LevelTypes, int> dictionary = new Dictionary<LevelTypes, int>();
			Dictionary<string, int> dictionary2 = new Dictionary<string, int>();
			foreach (string item in from s in configMoonRarity.Split(',')
				select s.Trim())
			{
				string[] array = item.Split(':');
				if (array.Length != 2)
				{
					continue;
				}
				string text = array[0];
				if (!int.TryParse(array[1], out var result))
				{
					continue;
				}
				if (Enum.TryParse<LevelTypes>(text, ignoreCase: true, out LevelTypes result2))
				{
					dictionary[result2] = result;
					continue;
				}
				string value = text + "Level";
				if (Enum.TryParse<LevelTypes>(value, ignoreCase: true, out result2))
				{
					dictionary[result2] = result;
				}
				else
				{
					dictionary2[text] = result;
				}
			}
			return (dictionary, dictionary2);
		}
	}
}
namespace ChallengeGates.Scripts
{
	public class ChallengeGate : NetworkBehaviour
	{
		[CompilerGenerated]
		private sealed class <>c__DisplayClass13_0
		{
			public ulong playerId;

			public ChallengeGate <>4__this;

			internal void <TeleportationAnimation>b__0(PlayerControllerB player)
			{
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				if (player.playerClientId == playerId)
				{
					((Component)player).transform.position = <>4__this.level.playerSpawnPos.position;
					player.disableMoveInput = false;
					player.sprintMeter = 1f;
					<>4__this.level.OnPlayerEnter(playerId);
				}
			}
		}

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

			private object <>2__current;

			public ulong playerId;

			public ChallengeGate <>4__this;

			private <>c__DisplayClass13_0 <>8__1;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_005d: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>8__1 = new <>c__DisplayClass13_0();
					<>8__1.playerId = playerId;
					<>8__1.<>4__this = <>4__this;
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (((NetworkBehaviour)<>4__this).IsServer)
					{
						<>4__this.level.trophyScript.SetTimerStateServerRpc(running: true);
					}
					StartOfRound.Instance.allPlayerScripts.ToList().ForEach(delegate(PlayerControllerB player)
					{
						//IL_002a: Unknown result type (might be due to invalid IL or missing references)
						if (player.playerClientId == <>8__1.playerId)
						{
							((Component)player).transform.position = <>8__1.<>4__this.level.playerSpawnPos.position;
							player.disableMoveInput = false;
							player.sprintMeter = 1f;
							<>8__1.<>4__this.level.OnPlayerEnter(<>8__1.playerId);
						}
					});
					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();
			}
		}

		private static readonly int Close = Animator.StringToHash("close");

		public Animator animator;

		public AudioSource audioSource;

		public AudioSource audioLoopSource;

		public List<GameObject> levelObjects;

		private ChallengeLevel level;

		private bool gateIsEnabled = true;

		private void Start()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)this).IsServer)
			{
				(int, Vector3) newRoomPos = ChallengeGatesPlugin.instance.GetNewRoomPos();
				SpawnLevelServerRpc(Random.Range(0, levelObjects.Count), newRoomPos.Item1, newRoomPos.Item2);
			}
		}

		[ServerRpc]
		private void SpawnLevelServerRpc(int index, int id, Vector3 pos)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Invalid comparison between Unknown and I4
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2896143563u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, index);
				BytePacker.WriteValueBitPacked(val2, id);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref pos);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2896143563u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				SpawnLevelClientRpc(index, id, pos);
			}
		}

		[ClientRpc]
		private void SpawnLevelClientRpc(int index, int id, Vector3 pos)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: 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(2892234299u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, index);
				BytePacker.WriteValueBitPacked(val2, id);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref pos);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2892234299u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				GameObject val3 = levelObjects[index];
				GameObject val4 = Object.Instantiate<GameObject>(val3, pos, Quaternion.identity);
				level = val4.GetComponent<ChallengeLevel>();
				level.connectedPosition = ((Component)this).transform.position;
				level.id = id;
				if (((NetworkBehaviour)this).IsServer)
				{
					level.OnSpawnServer();
				}
			}
		}

		private void OnTriggerEnter(Collider other)
		{
			if (Object.op_Implicit((Object)(object)level) && gateIsEnabled && ((Component)other).CompareTag("Player"))
			{
				PlayerControllerB component = ((Component)other).GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.playerClientId == GameNetworkManager.Instance.localPlayerController.playerClientId)
				{
					OnPlayerCollideServerRpc(GameNetworkManager.Instance.localPlayerController.playerClientId);
					component.disableMoveInput = true;
					component.DropAllHeldItems(true, false);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void OnPlayerCollideServerRpc(ulong 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)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(766131858u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 766131858u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					OnPlayerCollideClientRpc(playerId);
				}
			}
		}

		[ClientRpc]
		private void OnPlayerCollideClientRpc(ulong 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)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1817029727u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1817029727u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					audioLoopSource.Stop();
					audioSource.Play();
					animator.SetTrigger(Close);
					gateIsEnabled = false;
					((MonoBehaviour)this).StartCoroutine(TeleportationAnimation(playerId));
				}
			}
		}

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

		public override void OnDestroy()
		{
			Object.Destroy((Object)(object)((Component)level).gameObject);
			((NetworkBehaviour)this).OnDestroy();
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_ChallengeGate()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2896143563u, new RpcReceiveHandler(__rpc_handler_2896143563));
			NetworkManager.__rpc_func_table.Add(2892234299u, new RpcReceiveHandler(__rpc_handler_2892234299));
			NetworkManager.__rpc_func_table.Add(766131858u, new RpcReceiveHandler(__rpc_handler_766131858));
			NetworkManager.__rpc_func_table.Add(1817029727u, new RpcReceiveHandler(__rpc_handler_1817029727));
		}

		private static void __rpc_handler_2896143563(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
				return;
			}
			int index = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref index);
			int id = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref id);
			Vector3 pos = default(Vector3);
			((FastBufferReader)(ref reader)).ReadValueSafe(ref pos);
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((ChallengeGate)(object)target).SpawnLevelServerRpc(index, id, pos);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}

		private static void __rpc_handler_2892234299(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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int index = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref index);
				int id = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref id);
				Vector3 pos = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref pos);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ChallengeGate)(object)target).SpawnLevelClientRpc(index, id, pos);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_766131858(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)
			{
				ulong playerId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ChallengeGate)(object)target).OnPlayerCollideServerRpc(playerId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1817029727(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)
			{
				ulong playerId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ChallengeGate)(object)target).OnPlayerCollideClientRpc(playerId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "ChallengeGate";
		}
	}
	public class ChallengeLevel : MonoBehaviour
	{
		public int id;

		public Transform playerSpawnPos;

		public Transform trophySpawnPos;

		public List<UnityEvent<PlayerControllerB>> onPlayerEscape;

		public string enterNotification;

		private GameObject trophy;

		public Trophy trophyScript;

		public Vector3 connectedPosition;

		public virtual void OnSpawnServerExtra()
		{
		}

		public virtual void OnSpawnServer()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			trophy = Object.Instantiate<GameObject>(ChallengeGatesPlugin.instance.trophyGameObject, trophySpawnPos.position, Quaternion.identity);
			trophy.GetComponent<NetworkObject>().Spawn(false);
			trophyScript = trophy.GetComponent<Trophy>();
			OnSpawnServerExtra();
		}

		public void OnPlayerEscape(PlayerControllerB player)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			onPlayerEscape.ForEach(delegate(UnityEvent<PlayerControllerB> e)
			{
				e.Invoke(player);
			});
			((Component)player).transform.position = connectedPosition;
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		public virtual void OnPlayerEnter(ulong playerId)
		{
			if (enterNotification.Length > 0 && GameNetworkManager.Instance.localPlayerController.playerClientId == playerId)
			{
				HUDManager.Instance.DisplayTip("Warning", enterNotification, false, false, "LC_Tip1");
			}
		}

		public virtual void OnDestroy()
		{
			ChallengeGatesPlugin.instance.spawnedRooms.Remove(id);
			if (!((NetworkBehaviour)GameNetworkManager.Instance.localPlayerController).IsServer)
			{
				return;
			}
			try
			{
				if (((GrabbableObject)trophyScript).scrapValue == ChallengeGatesPlugin.instance.baseTrophyValue.Value)
				{
					trophy.GetComponent<NetworkObject>().Despawn(true);
				}
			}
			catch
			{
			}
		}
	}
	public class ChallengeLevelMovingSpikes : ChallengeLevel
	{
		public Transform spikesPosition;

		public MovingSpikes spikes;

		public override void OnSpawnServerExtra()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(ChallengeGatesPlugin.instance.movingSpikesObject, spikesPosition.position, spikesPosition.rotation);
			spikes = val.GetComponent<MovingSpikes>();
			((NetworkBehaviour)spikes).NetworkObject.Spawn(false);
		}

		public override void OnPlayerEnter(ulong playerId)
		{
			base.OnPlayerEnter(playerId);
			if ((Object)(object)spikes != (Object)null)
			{
				spikes.StartMovingServerRpc();
			}
		}

		public override void OnDestroy()
		{
			base.OnDestroy();
			Object.Destroy((Object)(object)((Component)spikes).gameObject);
		}
	}
	public class MovingSpikes : NetworkBehaviour
	{
		[CompilerGenerated]
		private sealed class <MoveDelay>d__6 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public MovingSpikes <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(<>4__this.startMovingDelay);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this.move = 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();
			}
		}

		private float moveSpeed = 2.4f;

		private float startMovingDelay = 5f;

		private bool move;

		private void Update()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (move)
			{
				Transform transform = ((Component)this).transform;
				transform.position += new Vector3(0f, 0f, (0f - moveSpeed) * Time.deltaTime);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void StartMovingServerRpc()
		{
			//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(4056041810u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4056041810u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					StartMovingClientRpc();
				}
			}
		}

		[ClientRpc]
		private void StartMovingClientRpc()
		{
			//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(2460718619u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2460718619u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((MonoBehaviour)this).StartCoroutine(MoveDelay());
				}
			}
		}

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

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_MovingSpikes()
		{
			//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(4056041810u, new RpcReceiveHandler(__rpc_handler_4056041810));
			NetworkManager.__rpc_func_table.Add(2460718619u, new RpcReceiveHandler(__rpc_handler_2460718619));
		}

		private static void __rpc_handler_4056041810(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;
				((MovingSpikes)(object)target).StartMovingServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2460718619(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;
				((MovingSpikes)(object)target).StartMovingClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "MovingSpikes";
		}
	}
	public class Trophy : GrabbableObject
	{
		private float valueTimer;

		private float valueDelay;

		private bool timerIsRunning = false;

		public override void Start()
		{
			((GrabbableObject)this).Start();
			if (((NetworkBehaviour)this).IsServer)
			{
				valueDelay = ChallengeGatesPlugin.instance.trophyDecreaseDelay.Value;
				valueTimer = valueDelay;
				SetValueServerRpc(ChallengeGatesPlugin.instance.baseTrophyValue.Value);
			}
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			if (((NetworkBehaviour)this).IsServer && timerIsRunning)
			{
				valueTimer -= Time.deltaTime;
				if (base.scrapValue > 0 && valueTimer <= 0f)
				{
					valueTimer = valueDelay;
					int num = base.scrapValue - ChallengeGatesPlugin.instance.trophyDecreaseAmount.Value;
					SetValueServerRpc((num > 0) ? num : 0);
				}
			}
		}

		public override void GrabItem()
		{
			((GrabbableObject)this).GrabItem();
			SetTimerStateServerRpc(running: false);
		}

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

		[ClientRpc]
		public void SetValueClientRpc(int value)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2040514245u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, value);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2040514245u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (ChallengeGatesPlugin.instance.debug.Value)
				{
					Debug.Log((object)$"TROPHY CHANGED VALUE {value}");
				}
				((GrabbableObject)this).SetScrapValue(value);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SetTimerStateServerRpc(bool running)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3905544232u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref running, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3905544232u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					timerIsRunning = running;
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_Trophy()
		{
			//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
			NetworkManager.__rpc_func_table.Add(3446543251u, new RpcReceiveHandler(__rpc_handler_3446543251));
			NetworkManager.__rpc_func_table.Add(2040514245u, new RpcReceiveHandler(__rpc_handler_2040514245));
			NetworkManager.__rpc_func_table.Add(3905544232u, new RpcReceiveHandler(__rpc_handler_3905544232));
		}

		private static void __rpc_handler_3446543251(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				int valueServerRpc = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref valueServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Trophy)(object)target).SetValueServerRpc(valueServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2040514245(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 valueClientRpc = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref valueClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((Trophy)(object)target).SetValueClientRpc(valueClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3905544232(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool timerStateServerRpc = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref timerStateServerRpc, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Trophy)(object)target).SetTimerStateServerRpc(timerStateServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "Trophy";
		}
	}
}
namespace ChallengeGates.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}