Decompiled source of AbysseLaMalice v2.1.0

BepInEx\plugins\FlyInvisToggle.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 BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("FlyInvisToggle")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.1.0.0")]
[assembly: AssemblyInformationalVersion("2.1.0")]
[assembly: AssemblyProduct("FlyInvisToggle")]
[assembly: AssemblyTitle("FlyInvisToggle")]
[assembly: AssemblyVersion("2.1.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace FlyInvisToggle
{
	[HarmonyPatch(typeof(PlayerInventory), "CheckSlots")]
	internal static class PlayerInventoryCheckSlotsPatch
	{
		internal static volatile int ExtraSlotsAboveVanillaCap;

		private static void Postfix(PlayerInventory __instance)
		{
			int extraSlotsAboveVanillaCap = ExtraSlotsAboveVanillaCap;
			if (extraSlotsAboveVanillaCap > 0)
			{
				Traverse val = Traverse.Create((object)__instance);
				int value = val.Field("availableSlots").GetValue<int>();
				int num = Mathf.Clamp(value + extraSlotsAboveVanillaCap, 5, 24);
				if (num > value)
				{
					val.Field("availableSlots").SetValue((object)num);
					__instance.SpawnItemSlots();
				}
			}
		}
	}
	[DefaultExecutionOrder(32000)]
	internal sealed class CheatRuntime : MonoBehaviour
	{
		private const float FlySpeed = 18f;

		private const float InvisTimerHold = 86400f;

		private static readonly float[] ObjectXRayRadii = new float[5] { 10f, 20f, 40f, 80f, 200f };

		private bool _panelOpen;

		private CursorLockMode _prevLock;

		private bool _prevCursorVisible;

		private bool _fly;

		private bool _invis;

		private bool _npcXRay;

		private bool _objXRay;

		private int _objRadiusIndex = 2;

		private bool _autoTruckWhenSellable;

		private float _nextAutoTruckCheckAt;

		private float _nextXRayRefreshAt;

		private float _nextAutoTeleportAt;

		private Component? _player;

		private CharacterController? _cc;

		private Rigidbody? _rb;

		private readonly List<bool> _rendererStates = new List<bool>();

		private Renderer[]? _renderers;

		private FppReflection? _fpp;

		private MethodInfo? _rpcActivateInvisibility;

		private Type? _npcType;

		private Type? _pickupableType;

		private Type[]? _pickupableTypes;

		private Type? _highlightEffectType;

		private PropertyInfo? _highlightedProp;

		private FieldInfo? _npcIsHighlighted;

		private FieldInfo? _npcHighlightTime;

		private MethodInfo? _highlightSetHighlighted;

		private MethodInfo? _highlightSetTargets;

		private MethodInfo? _highlightSetTarget;

		private MethodInfo? _highlightInitIfNeeded;

		private Type? _cursorLockManagerType;

		private Type? _qualityLevelEnum;

		private Type? _seeThroughModeEnum;

		private readonly Dictionary<int, (GameObject go, bool weAddedComponent)> _objXRayTracked = new Dictionary<int, (GameObject, bool)>();

		private readonly List<XRayLabelEntry> _xrayLabels = new List<XRayLabelEntry>();

		private Rect _winRect;

		private Vector2 _scroll;

		private string _toast = "";

		private float _toastUntil;

		internal static CheatRuntime? Instance { get; private set; }

		private void OnEnable()
		{
			Instance = this;
		}

		private void OnDisable()
		{
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
			if (_panelOpen)
			{
				_panelOpen = false;
				SetGameCursorLocked(gameShouldLockCursor: true);
			}
			PlayerInventoryCheckSlotsPatch.ExtraSlotsAboveVanillaCap = 0;
			ClearObjectXRay();
			_npcXRay = false;
			ClearNpcXRayVisual();
		}

		private void Start()
		{
			//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)
			_winRect = new Rect((float)Screen.width / 2f - 260f, (float)Screen.height / 2f - 300f, 520f, 600f);
			CacheGameTypes();
		}

		private void CacheGameTypes()
		{
			_npcType = Type.GetType("NPC, Assembly-CSharp", throwOnError: false);
			_pickupableType = Type.GetType("Pickupable, Assembly-CSharp", throwOnError: false);
			_highlightEffectType = Type.GetType("HighlightPlus.HighlightEffect, HighlightPlus", throwOnError: false);
			if (_highlightEffectType == null)
			{
				_highlightEffectType = AppDomain.CurrentDomain.GetAssemblies().SelectMany(delegate(Assembly a)
				{
					try
					{
						return a.GetTypes();
					}
					catch
					{
						return Type.EmptyTypes;
					}
				}).FirstOrDefault((Type t) => t.FullName == "HighlightPlus.HighlightEffect" || t.Name == "HighlightEffect");
			}
			_cursorLockManagerType = Type.GetType("CursorLockManager, Assembly-CSharp", throwOnError: false);
			_qualityLevelEnum = Type.GetType("HighlightPlus.QualityLevel, HighlightPlus", throwOnError: false);
			_seeThroughModeEnum = Type.GetType("HighlightPlus.SeeThroughMode, HighlightPlus", throwOnError: false);
			Assembly assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly a) => a.GetName().Name == "Assembly-CSharp");
			if (assembly != null)
			{
				_pickupableTypes = (from t in assembly.GetTypes()
					where t.IsClass && !t.IsAbstract && (t.Name.IndexOf("Pickup", StringComparison.OrdinalIgnoreCase) >= 0 || t.Name.IndexOf("Loot", StringComparison.OrdinalIgnoreCase) >= 0 || t.Name.IndexOf("Valuable", StringComparison.OrdinalIgnoreCase) >= 0 || t.Name.IndexOf("Scrap", StringComparison.OrdinalIgnoreCase) >= 0)
					select t).ToArray();
			}
			if (_pickupableTypes == null || _pickupableTypes.Length == 0)
			{
				_pickupableTypes = ((!(_pickupableType != null)) ? Array.Empty<Type>() : new Type[1] { _pickupableType });
			}
			if (_highlightEffectType != null)
			{
				_highlightedProp = _highlightEffectType.GetProperty("highlighted", BindingFlags.Instance | BindingFlags.Public);
				_highlightSetHighlighted = _highlightEffectType.GetMethod("SetHighlighted", BindingFlags.Instance | BindingFlags.Public, null, new Type[1] { typeof(bool) }, null);
				_highlightSetTargets = _highlightEffectType.GetMethod("SetTargets", BindingFlags.Instance | BindingFlags.Public, null, new Type[2]
				{
					typeof(Transform),
					typeof(Renderer[])
				}, null);
				_highlightSetTarget = _highlightEffectType.GetMethod("SetTarget", BindingFlags.Instance | BindingFlags.Public, null, new Type[1] { typeof(Transform) }, null);
				_highlightInitIfNeeded = _highlightEffectType.GetMethod("InitIfNeeded", BindingFlags.Instance | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
			}
			if (_npcType != null)
			{
				_npcIsHighlighted = _npcType.GetField("isHighlighted", BindingFlags.Instance | BindingFlags.Public);
				_npcHighlightTime = _npcType.GetField("highlightTime", BindingFlags.Instance | BindingFlags.Public);
			}
		}

		private void Update()
		{
			//IL_0076: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_player != (Object)null && !Object.op_Implicit((Object)(object)_player))
			{
				_fly = false;
				_invis = false;
				ClearPlayerCache();
			}
			if (Input.GetKeyDown((KeyCode)112))
			{
				_panelOpen = !_panelOpen;
				if (_panelOpen)
				{
					_prevLock = Cursor.lockState;
					_prevCursorVisible = Cursor.visible;
					SetGameCursorLocked(gameShouldLockCursor: false);
				}
				else
				{
					SetGameCursorLocked(gameShouldLockCursor: true);
					Cursor.lockState = _prevLock;
					Cursor.visible = _prevCursorVisible;
				}
			}
			if (Input.GetKeyDown((KeyCode)27) && _panelOpen)
			{
				_panelOpen = false;
				SetGameCursorLocked(gameShouldLockCursor: true);
				Cursor.lockState = _prevLock;
				Cursor.visible = _prevCursorVisible;
			}
			if (!_panelOpen)
			{
				if (_fly)
				{
					DoFlyMovement();
				}
				if (_invis)
				{
					MaintainNpcInvisibility();
				}
				if (_autoTruckWhenSellable && Time.time >= _nextAutoTruckCheckAt)
				{
					TryAutoTeleportToTruckWhenSellable();
				}
			}
		}

		private void LateUpdate()
		{
			if (_panelOpen)
			{
				SetGameCursorLocked(gameShouldLockCursor: false);
			}
			if ((_npcXRay || _objXRay) && Time.time >= _nextXRayRefreshAt)
			{
				RefreshXRayLabels();
			}
			if (_fly && (Object)(object)_player != (Object)null)
			{
				SuppressFallDamageState();
			}
		}

		private void OnGUI()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			DrawToast();
			DrawXRayLabels();
			if (_panelOpen)
			{
				GUI.backgroundColor = new Color(0.12f, 0.12f, 0.14f, 0.95f);
				_winRect = GUI.Window(928374, _winRect, new WindowFunction(DrawPanelWindow), "AbysseLaMalice");
				GUI.backgroundColor = Color.white;
			}
		}

		private void DrawToast()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			if (!(Time.unscaledTime > _toastUntil) && !string.IsNullOrEmpty(_toast))
			{
				GUIStyle val = new GUIStyle(GUI.skin.label)
				{
					fontSize = 24,
					alignment = (TextAnchor)4,
					fontStyle = (FontStyle)1
				};
				val.normal.textColor = Color.white;
				GUIStyle val2 = new GUIStyle(val);
				val2.normal.textColor = Color.black;
				GUIStyle val3 = val2;
				Rect val4 = default(Rect);
				((Rect)(ref val4))..ctor(0f, (float)Screen.height * 0.42f, (float)Screen.width, 72f);
				GUI.Label(new Rect(((Rect)(ref val4)).x - 2f, ((Rect)(ref val4)).y, ((Rect)(ref val4)).width, ((Rect)(ref val4)).height), _toast, val3);
				GUI.Label(new Rect(((Rect)(ref val4)).x + 2f, ((Rect)(ref val4)).y, ((Rect)(ref val4)).width, ((Rect)(ref val4)).height), _toast, val3);
				GUI.Label(new Rect(((Rect)(ref val4)).x, ((Rect)(ref val4)).y - 2f, ((Rect)(ref val4)).width, ((Rect)(ref val4)).height), _toast, val3);
				GUI.Label(new Rect(((Rect)(ref val4)).x, ((Rect)(ref val4)).y + 2f, ((Rect)(ref val4)).width, ((Rect)(ref val4)).height), _toast, val3);
				GUI.Label(val4, _toast, val);
			}
		}

		private void DrawPanelWindow(int id)
		{
			//IL_0025: 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)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: 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_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			GUILayout.Label("P = ouvrir / fermer (souris libre). Echap ferme aussi.", GUI.skin.box, Array.Empty<GUILayoutOption>());
			_scroll = GUILayout.BeginScrollView(_scroll, Array.Empty<GUILayoutOption>());
			ToggleRow("Vol (WASD, Espace, Ctrl)", ref _fly, delegate
			{
				ApplyFly(_fly);
			}, "Vol active", "Vol desactive");
			ToggleRow("Invisibilite (PNJ + visuel)", ref _invis, delegate
			{
				ApplyInvisibility(_invis);
			}, "Invisibilite active", "Invisibilite desactive");
			ToggleRow("X-Ray humains (noms)", ref _npcXRay, delegate
			{
				if (!_npcXRay)
				{
					ClearNpcXRayVisual();
				}
				_nextXRayRefreshAt = 0f;
			}, "X-Ray PNJ active", "X-Ray PNJ desactive");
			ToggleRow("X-Ray objets (noms + rayon)", ref _objXRay, delegate
			{
				if (!_objXRay)
				{
					ClearObjectXRay();
				}
				_nextXRayRefreshAt = 0f;
			}, "X-Ray objets active", "X-Ray objets desactive");
			GUILayout.Space(6f);
			GUILayout.Label("Rayon X-Ray objets :", Array.Empty<GUILayoutOption>());
			for (int i = 0; i < ObjectXRayRadii.Length; i++)
			{
				GUI.backgroundColor = (Color)((i == _objRadiusIndex) ? new Color(0.35f, 0.55f, 0.95f) : Color.white);
				if (GUILayout.Button($"{ObjectXRayRadii[i]:0} m", Array.Empty<GUILayoutOption>()))
				{
					_objRadiusIndex = i;
				}
				GUI.backgroundColor = Color.white;
			}
			GUILayout.Space(10f);
			GUI.backgroundColor = new Color(0.55f, 0.85f, 0.45f);
			if (GUILayout.Button("+10 munitions pour chaque type (toutes armes)", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
			{
				TryAddTenEachAmmo();
			}
			GUI.backgroundColor = Color.white;
			GUI.backgroundColor = new Color(0.95f, 0.75f, 0.35f);
			if (GUILayout.Button("Spawn loot aleatoire ~999$", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
			{
				TrySpawnRandomLootNear999();
			}
			GUI.backgroundColor = Color.white;
			GUI.backgroundColor = new Color(0.65f, 0.55f, 0.95f);
			if (GUILayout.Button("Teleport au camion", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
			{
				TryTeleportToTruck();
			}
			GUI.backgroundColor = Color.white;
			ToggleRow("Auto TP camion si objet vendable en inventaire", ref _autoTruckWhenSellable, delegate
			{
				_nextAutoTruckCheckAt = 0f;
			}, "Auto TP camion active", "Auto TP camion desactive");
			GUI.backgroundColor = new Color(0.86f, 0.63f, 0.33f);
			if (GUILayout.Button("Reparer objets dans la hotbar", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
			{
				TryRepairHotbarObjects();
			}
			GUI.backgroundColor = Color.white;
			GUILayout.Space(10f);
			GUI.backgroundColor = new Color(0.4f, 0.65f, 1f);
			if (GUILayout.Button("Debloquer toutes les competences (silencieux)", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) }))
			{
				TryUnlockAllSkills();
			}
			GUI.backgroundColor = Color.white;
			GUI.backgroundColor = new Color(1f, 0.55f, 0.25f);
			if (GUILayout.Button("Debloquer tous les succes Steam (local)", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) }))
			{
				TryUnlockAllSteamAchievements();
			}
			GUI.backgroundColor = Color.white;
			GUILayout.Space(8f);
			GUILayout.Label("Slots hotbar en plus (apres le max 10 du jeu) :", Array.Empty<GUILayoutOption>());
			int extraSlotsAboveVanillaCap = PlayerInventoryCheckSlotsPatch.ExtraSlotsAboveVanillaCap;
			int num = Mathf.RoundToInt(GUILayout.HorizontalSlider((float)extraSlotsAboveVanillaCap, 0f, 14f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(18f) }));
			if (num != extraSlotsAboveVanillaCap)
			{
				PlayerInventoryCheckSlotsPatch.ExtraSlotsAboveVanillaCap = num;
				TryRefreshInventorySlots();
			}
			GUILayout.Label($"Bonus hotbar actuel : +{PlayerInventoryCheckSlotsPatch.ExtraSlotsAboveVanillaCap} (max total ~24).", Array.Empty<GUILayoutOption>());
			GUILayout.EndScrollView();
			GUILayout.EndVertical();
			GUI.DragWindow(new Rect(0f, 0f, 10000f, 24f));
		}

		private void ToggleRow(string label, ref bool state, Action onChange, string onMsg, string offMsg)
		{
			//IL_004c: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(220f) });
			GUI.backgroundColor = (state ? new Color(0.35f, 0.85f, 0.4f) : new Color(0.9f, 0.3f, 0.3f));
			if (GUILayout.Button(state ? "ACTIF" : "INACTIF", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(120f),
				GUILayout.Height(28f)
			}))
			{
				state = !state;
				onChange();
				PushToast(state ? onMsg : offMsg);
			}
			GUI.backgroundColor = Color.white;
			GUILayout.EndHorizontal();
		}

		private void PushToast(string text)
		{
			_toast = text;
			_toastUntil = Time.unscaledTime + 2.2f;
		}

		private void TryRefreshInventorySlots()
		{
			Component val = ResolvePlayer();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			try
			{
				object obj = ((object)val).GetType().GetField("inventory", BindingFlags.Instance | BindingFlags.Public)?.GetValue(val);
				typeof(PlayerInventory).GetMethod("CheckSlots", new Type[1] { typeof(bool) })?.Invoke(obj, new object[1] { false });
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("CheckSlots: " + ex.Message));
			}
		}

		private void SetGameCursorLocked(bool gameShouldLockCursor)
		{
			try
			{
				if (_cursorLockManagerType == null)
				{
					_cursorLockManagerType = Type.GetType("CursorLockManager, Assembly-CSharp", throwOnError: false);
				}
				object obj = (_cursorLockManagerType?.GetProperty("Instance", BindingFlags.Static | BindingFlags.Public))?.GetValue(null, null);
				(_cursorLockManagerType?.GetMethod("LockCursor", BindingFlags.Instance | BindingFlags.Public, null, new Type[1] { typeof(bool) }, null))?.Invoke(obj, new object[1] { gameShouldLockCursor });
			}
			catch (Exception ex)
			{
				Plugin.Log.LogDebug((object)("CursorLockManager: " + ex.Message));
			}
			if (!gameShouldLockCursor)
			{
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
			}
		}

		private void LateNpcXRay()
		{
			if (_npcType == null || (Object)(object)_player == (Object)null)
			{
				return;
			}
			_xrayLabels.RemoveAll((XRayLabelEntry e) => e.Kind == XRayKind.Npc);
			foreach (Component item in FindSceneComponents(_npcType))
			{
				GameObject gameObject = item.gameObject;
				string text = ReadDisplayName(item) ?? "PNJ";
				_xrayLabels.Add(new XRayLabelEntry(gameObject.transform, text, XRayKind.Npc));
			}
		}

		private void ClearNpcXRayVisual()
		{
			_xrayLabels.RemoveAll((XRayLabelEntry e) => e.Kind == XRayKind.Npc);
		}

		private void LateObjectXRay()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_player == (Object)null)
			{
				return;
			}
			_xrayLabels.RemoveAll((XRayLabelEntry e) => e.Kind == XRayKind.Object);
			float num = ObjectXRayRadii[Mathf.Clamp(_objRadiusIndex, 0, ObjectXRayRadii.Length - 1)];
			Vector3 position = _player.transform.position;
			float num2 = num * num;
			HashSet<int> hashSet = new HashSet<int>();
			Type[] array = _pickupableTypes ?? Array.Empty<Type>();
			for (int i = 0; i < array.Length; i++)
			{
				foreach (Component item in FindSceneComponents(array[i]))
				{
					GameObject gameObject = item.gameObject;
					int instanceID = ((Object)gameObject).GetInstanceID();
					if (hashSet.Add(instanceID))
					{
						Vector3 val = gameObject.transform.position - position;
						if (!(((Vector3)(ref val)).sqrMagnitude > num2))
						{
							string text = ReadDisplayName(item) ?? ReadDisplayName(gameObject) ?? "Objet";
							_xrayLabels.Add(new XRayLabelEntry(gameObject.transform, text, XRayKind.Object));
						}
					}
				}
			}
		}

		private void ClearObjectXRay()
		{
			_xrayLabels.RemoveAll((XRayLabelEntry e) => e.Kind == XRayKind.Object);
		}

		private void RefreshXRayLabels()
		{
			_nextXRayRefreshAt = Time.time + 0.2f;
			if (_npcXRay)
			{
				LateNpcXRay();
			}
			else
			{
				_xrayLabels.RemoveAll((XRayLabelEntry e) => e.Kind == XRayKind.Npc);
			}
			if (_objXRay)
			{
				LateObjectXRay();
				return;
			}
			_xrayLabels.RemoveAll((XRayLabelEntry e) => e.Kind == XRayKind.Object);
		}

		private void DrawXRayLabels()
		{
			//IL_002b: 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_0038: 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)
			//IL_0047: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			if (!_npcXRay && !_objXRay)
			{
				return;
			}
			Camera main = Camera.main;
			if ((Object)(object)main == (Object)null)
			{
				return;
			}
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				fontSize = 14,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)4
			};
			GUIStyle val2 = new GUIStyle(val);
			val2.normal.textColor = Color.black;
			Rect val5 = default(Rect);
			foreach (XRayLabelEntry item in _xrayLabels.ToList())
			{
				if (!((Object)(object)item.Target == (Object)null))
				{
					Vector3 val3 = item.Target.position + Vector3.up * 0.55f;
					Vector3 val4 = main.WorldToScreenPoint(val3);
					if (!(val4.z <= 0.01f))
					{
						float x = val4.x;
						float num = (float)Screen.height - val4.y;
						float num2 = Mathf.Max(90f, (float)item.Text.Length * 8f);
						((Rect)(ref val5))..ctor(x - num2 * 0.5f, num - 24f, num2, 24f);
						val.normal.textColor = ((item.Kind == XRayKind.Npc) ? new Color(1f, 0.85f, 0.25f) : new Color(0.25f, 1f, 1f));
						GUI.Label(new Rect(((Rect)(ref val5)).x - 1f, ((Rect)(ref val5)).y, ((Rect)(ref val5)).width, ((Rect)(ref val5)).height), item.Text, val2);
						GUI.Label(new Rect(((Rect)(ref val5)).x + 1f, ((Rect)(ref val5)).y, ((Rect)(ref val5)).width, ((Rect)(ref val5)).height), item.Text, val2);
						GUI.Label(new Rect(((Rect)(ref val5)).x, ((Rect)(ref val5)).y - 1f, ((Rect)(ref val5)).width, ((Rect)(ref val5)).height), item.Text, val2);
						GUI.Label(new Rect(((Rect)(ref val5)).x, ((Rect)(ref val5)).y + 1f, ((Rect)(ref val5)).width, ((Rect)(ref val5)).height), item.Text, val2);
						GUI.Label(val5, item.Text, val);
					}
				}
			}
		}

		private static bool TryGetOrAddHighlight(GameObject root, Type highlightType, out MonoBehaviour he, out bool weAddedComponent)
		{
			weAddedComponent = false;
			he = null;
			Component componentInChildren = root.GetComponentInChildren(highlightType, true);
			he = (MonoBehaviour)(object)((componentInChildren is MonoBehaviour) ? componentInChildren : null);
			if ((Object)(object)he != (Object)null)
			{
				return true;
			}
			Component obj = root.AddComponent(highlightType);
			he = (MonoBehaviour)(object)((obj is MonoBehaviour) ? obj : null);
			weAddedComponent = (Object)(object)he != (Object)null;
			return weAddedComponent;
		}

		private void ConfigureHighlightForXRay(MonoBehaviour he, Transform targetRoot)
		{
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			if (_highlightEffectType == null)
			{
				return;
			}
			try
			{
				_highlightInitIfNeeded?.Invoke(he, null);
				Type type = ((object)he).GetType();
				type.GetField("ignore", BindingFlags.Instance | BindingFlags.Public)?.SetValue(he, false);
				((Behaviour)he).enabled = true;
				if (_qualityLevelEnum != null)
				{
					object value = Enum.Parse(_qualityLevelEnum, "Highest");
					type.GetField("outlineQuality", BindingFlags.Instance | BindingFlags.Public)?.SetValue(he, value);
					type.GetField("glowQuality", BindingFlags.Instance | BindingFlags.Public)?.SetValue(he, value);
				}
				type.GetField("outline", BindingFlags.Instance | BindingFlags.Public)?.SetValue(he, 1f);
				type.GetField("outlineWidth", BindingFlags.Instance | BindingFlags.Public)?.SetValue(he, 2.2f);
				type.GetField("outlineColor", BindingFlags.Instance | BindingFlags.Public)?.SetValue(he, (object)new Color(0.15f, 0.95f, 1f, 1f));
				type.GetField("glow", BindingFlags.Instance | BindingFlags.Public)?.SetValue(he, 0.35f);
				type.GetField("glowWidth", BindingFlags.Instance | BindingFlags.Public)?.SetValue(he, 0.4f);
				if (_seeThroughModeEnum != null)
				{
					object obj = ((Enum.GetValues(_seeThroughModeEnum).Length > 0) ? TryParseSeeThroughAlways() : null);
					if (obj != null)
					{
						type.GetField("seeThrough", BindingFlags.Instance | BindingFlags.Public)?.SetValue(he, obj);
						type.GetField("seeThroughIntensity", BindingFlags.Instance | BindingFlags.Public)?.SetValue(he, 0.95f);
					}
				}
				Renderer[] array = CollectRenderersForHighlight(targetRoot);
				if (array.Length != 0 && _highlightSetTargets != null)
				{
					_highlightSetTargets.Invoke(he, new object[2] { targetRoot, array });
				}
				else
				{
					_highlightSetTarget?.Invoke(he, new object[1] { targetRoot });
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogDebug((object)("ConfigureHighlight: " + ex.Message));
			}
		}

		private object? TryParseSeeThroughAlways()
		{
			if (_seeThroughModeEnum == null)
			{
				return null;
			}
			string[] array = new string[3] { "AlwaysWhenOccluded", "WhenHighlighted", "Always" };
			foreach (string value in array)
			{
				try
				{
					return Enum.Parse(_seeThroughModeEnum, value);
				}
				catch
				{
				}
			}
			return null;
		}

		private static Renderer[] CollectRenderersForHighlight(Transform targetRoot)
		{
			List<Renderer> list = new List<Renderer>();
			Renderer[] componentsInChildren = ((Component)targetRoot).GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				if (!((Object)(object)val == (Object)null) && val.enabled)
				{
					list.Add(val);
				}
			}
			return list.ToArray();
		}

		private void InvokeSetHighlighted(MonoBehaviour he, bool on)
		{
			try
			{
				if (_highlightSetHighlighted != null)
				{
					_highlightSetHighlighted.Invoke(he, new object[1] { on });
				}
				else if (_highlightedProp != null)
				{
					_highlightedProp.SetValue(he, on, null);
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogDebug((object)("SetHighlighted: " + ex.Message));
			}
		}

		private void StripObjectHighlight(GameObject go, bool destroyIfWeAdded)
		{
			if (_highlightEffectType == null)
			{
				return;
			}
			foreach (MonoBehaviour item in go.GetComponentsInChildren(_highlightEffectType, true).OfType<MonoBehaviour>())
			{
				InvokeSetHighlighted(item, on: false);
			}
			if (destroyIfWeAdded)
			{
				Component component = go.GetComponent(_highlightEffectType);
				MonoBehaviour val = (MonoBehaviour)(object)((component is MonoBehaviour) ? component : null);
				if ((Object)(object)val != (Object)null)
				{
					Object.Destroy((Object)(object)val);
				}
			}
		}

		private void TryAddTenEachAmmo()
		{
			Component val = ResolvePlayer();
			if ((Object)(object)val == (Object)null)
			{
				PushToast("Joueur introuvable.");
				return;
			}
			try
			{
				object obj = ((object)val).GetType().GetField("weaponManager", BindingFlags.Instance | BindingFlags.Public)?.GetValue(val);
				if (obj == null)
				{
					PushToast("WeaponManager introuvable.");
					return;
				}
				if (!((obj.GetType().GetField("weapons", BindingFlags.Instance | BindingFlags.Public) ?? obj.GetType().GetField("Weapons", BindingFlags.Instance | BindingFlags.Public))?.GetValue(obj) is IList list))
				{
					PushToast("Liste d'armes introuvable.");
					return;
				}
				int num = 0;
				foreach (object item in list)
				{
					if (item == null)
					{
						continue;
					}
					Type type = item.GetType();
					if (!((type.GetField("ammoTypes", BindingFlags.Instance | BindingFlags.Public) ?? type.GetField("ammoType", BindingFlags.Instance | BindingFlags.Public))?.GetValue(item) is IList list2))
					{
						continue;
					}
					foreach (object item2 in list2)
					{
						if (item2 == null)
						{
							continue;
						}
						Type type2 = item2.GetType();
						string[] array = new string[5] { "amountInInventory", "AmountInInventory", "amount", "currentAmount", "ammoCount" };
						foreach (string name in array)
						{
							FieldInfo fieldInfo = type2.GetField(name, BindingFlags.Instance | BindingFlags.Public) ?? type2.GetField(name, BindingFlags.Instance | BindingFlags.NonPublic);
							if (!(fieldInfo == null))
							{
								int num2 = Convert.ToInt32(fieldInfo.GetValue(item2) ?? ((object)0));
								fieldInfo.SetValue(item2, num2 + 10);
								num++;
								break;
							}
						}
					}
				}
				obj.GetType().GetMethod("SaveAmmo", BindingFlags.Instance | BindingFlags.Public)?.Invoke(obj, null);
				PushToast((num > 0) ? $"+10 munitions ({num} types)." : "Aucune munition modifiee.");
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)ex);
				PushToast("Erreur munitions.");
			}
		}

		private void TryTeleportToTruck()
		{
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			Component val = ResolvePlayer();
			if ((Object)(object)val == (Object)null)
			{
				PushToast("Joueur introuvable.");
				return;
			}
			try
			{
				Type type = Type.GetType("WorldManager, Assembly-CSharp", throwOnError: false);
				object obj = type?.GetProperty("Instance", BindingFlags.Static | BindingFlags.Public)?.GetValue(null, null);
				Transform val2 = null;
				if (obj != null)
				{
					object? obj2 = type.GetField("truckObj", BindingFlags.Instance | BindingFlags.Public)?.GetValue(obj);
					val2 = (Transform)(((obj2 is Transform) ? obj2 : null) ?? ((object)/*isinst with value type is only supported in some contexts*/));
				}
				if ((Object)(object)val2 == (Object)null)
				{
					object obj3 = ((object)val).GetType().GetField("WM", BindingFlags.Instance | BindingFlags.Public)?.GetValue(val);
					if (obj3 != null)
					{
						Type type2 = obj3.GetType();
						object? obj4 = type2.GetField("truckObj", BindingFlags.Instance | BindingFlags.Public)?.GetValue(obj3);
						val2 = (Transform)(((obj4 is Transform) ? obj4 : null) ?? ((object)/*isinst with value type is only supported in some contexts*/));
					}
				}
				if ((Object)(object)val2 == (Object)null)
				{
					PushToast("Camion introuvable.");
					return;
				}
				Vector3 pos = val2.position + Vector3.up * 1.8f;
				((MonoBehaviour)this).StartCoroutine(ForceTeleportRoutine(val, pos));
				PushToast("Teleport au camion.");
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)ex);
				PushToast("Erreur teleport.");
			}
		}

		private void TryAutoTeleportToTruckWhenSellable()
		{
			_nextAutoTruckCheckAt = Time.time + 0.75f;
			Component val = ResolvePlayer();
			if (!((Object)(object)val == (Object)null) && HasSellableInventoryObject(val) && !(Time.time < _nextAutoTeleportAt))
			{
				_nextAutoTeleportAt = Time.time + 2.5f;
				TryTeleportToTruck();
			}
		}

		private static bool HasSellableInventoryObject(Component player)
		{
			try
			{
				object obj = ((object)player).GetType().GetField("inventory", BindingFlags.Instance | BindingFlags.Public)?.GetValue(player);
				if (obj == null)
				{
					return false;
				}
				foreach (object likelySlot in GetLikelySlots(obj))
				{
					if (likelySlot == null)
					{
						continue;
					}
					object itemFromSlot = GetItemFromSlot(likelySlot);
					if (itemFromSlot != null && itemFromSlot.GetType().Name.IndexOf("Tool", StringComparison.OrdinalIgnoreCase) < 0 && !TryReadBoolByNames(itemFromSlot, "isTool", "tool", "isWeapon", "isEquipment"))
					{
						bool flag = TryReadBoolByNames(itemFromSlot, "canSell", "sellable", "isSellable", "isLoot", "isValuable");
						int num = TryReadIntByNames(itemFromSlot, "value", "price", "sellPrice", "cashValue");
						if ((flag || num > 0) && TryReadIntByNames(likelySlot, "amount", "count", "quantity", "stackAmount") > 0)
						{
							return true;
						}
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogDebug((object)("AutoTruck scan: " + ex.Message));
			}
			return false;
		}

		private void TryRepairHotbarObjects()
		{
			Component val = ResolvePlayer();
			if ((Object)(object)val == (Object)null)
			{
				PushToast("Joueur introuvable.");
				return;
			}
			try
			{
				int num = 0;
				object obj = ((object)val).GetType().GetField("inventory", BindingFlags.Instance | BindingFlags.Public)?.GetValue(val);
				if (obj == null)
				{
					PushToast("Inventaire introuvable.");
					return;
				}
				foreach (object likelySlot in GetLikelySlots(obj))
				{
					if (likelySlot != null && LooksLikeHotbarSlot(likelySlot))
					{
						object itemFromSlot = GetItemFromSlot(likelySlot);
						if (itemFromSlot != null)
						{
							num += TryRepairObject(itemFromSlot);
						}
					}
				}
				PushToast((num > 0) ? $"Hotbar reparee ({num} objet(s))." : "Aucun objet a reparer.");
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)ex);
				PushToast("Erreur reparation hotbar.");
			}
		}

		private static int TryRepairObject(object obj)
		{
			int num = 0;
			Type type = obj.GetType();
			BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
			(string, string)[] array = new(string, string)[6]
			{
				("durability", "maxDurability"),
				("currentDurability", "maxDurability"),
				("durabilityCurrent", "durabilityMax"),
				("itemDurability", "itemDurabilityMax"),
				("health", "maxHealth"),
				("condition", "maxCondition")
			};
			for (int i = 0; i < array.Length; i++)
			{
				(string, string) tuple = array[i];
				FieldInfo field = type.GetField(tuple.Item1, bindingAttr);
				FieldInfo field2 = type.GetField(tuple.Item2, bindingAttr);
				if (!(field == null) && !(field2 == null))
				{
					object value = field2.GetValue(obj);
					if (value != null)
					{
						field.SetValue(obj, value);
						num++;
					}
				}
			}
			string[] array2 = new string[4] { "Repair", "Fix", "RestoreDurability", "RepairItem" };
			foreach (string name in array2)
			{
				MethodInfo method = type.GetMethod(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
				if (!(method == null))
				{
					try
					{
						method.Invoke(obj, null);
						num++;
					}
					catch
					{
					}
				}
			}
			return num;
		}

		private static IEnumerable<object?> GetLikelySlots(object inventory)
		{
			foreach (object item in EnumerateNestedObjects(inventory, 2))
			{
				if (item != null)
				{
					Type type = item.GetType();
					if (type.Name.IndexOf("Slot", StringComparison.OrdinalIgnoreCase) >= 0 || type.Name.IndexOf("Hotbar", StringComparison.OrdinalIgnoreCase) >= 0)
					{
						yield return item;
					}
				}
			}
		}

		private static bool LooksLikeHotbarSlot(object slot)
		{
			Type type = slot.GetType();
			if (TryReadBoolByNames(slot, "isHotbar", "inHotbar", "hotbarSlot"))
			{
				return true;
			}
			int num = TryReadIntByNames(slot, "slotIndex", "index", "id");
			if (num >= 0 && num <= 9)
			{
				return true;
			}
			return type.Name.IndexOf("Hotbar", StringComparison.OrdinalIgnoreCase) >= 0;
		}

		private static object? GetItemFromSlot(object slot)
		{
			BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
			Type type = slot.GetType();
			string[] array = new string[5] { "item", "currentItem", "storedItem", "Item", "inventoryItem" };
			foreach (string name in array)
			{
				FieldInfo field = type.GetField(name, bindingAttr);
				if (field != null)
				{
					return field.GetValue(slot);
				}
				PropertyInfo property = type.GetProperty(name, bindingAttr);
				if (property != null)
				{
					return property.GetValue(slot, null);
				}
			}
			return null;
		}

		private static IEnumerable<object?> EnumerateNestedObjects(object root, int maxDepth)
		{
			HashSet<object> seen = new HashSet<object>(ReferenceEqualityComparer.Instance);
			Queue<(object obj, int depth)> queue = new Queue<(object, int)>();
			queue.Enqueue((root, 0));
			while (queue.Count > 0)
			{
				var (obj, depth) = queue.Dequeue();
				if (obj == null || depth > maxDepth || !seen.Add(obj))
				{
					continue;
				}
				yield return obj;
				if (obj is string)
				{
					continue;
				}
				if (obj is IEnumerable enumerable)
				{
					foreach (object item in enumerable)
					{
						if (item != null)
						{
							queue.Enqueue((item, depth + 1));
						}
					}
				}
				Type type = obj.GetType();
				if (type.IsPrimitive || type.IsEnum || type == typeof(string))
				{
					continue;
				}
				FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (FieldInfo fieldInfo in fields)
				{
					object obj2 = null;
					try
					{
						obj2 = fieldInfo.GetValue(obj);
					}
					catch
					{
					}
					if (obj2 != null)
					{
						queue.Enqueue((obj2, depth + 1));
					}
				}
			}
		}

		private static bool TryReadBoolByNames(object obj, params string[] names)
		{
			Type type = obj.GetType();
			BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
			foreach (string name in names)
			{
				FieldInfo field = type.GetField(name, bindingAttr);
				if (field?.FieldType == typeof(bool))
				{
					object value = field.GetValue(obj);
					if (value is bool)
					{
						return (bool)value;
					}
				}
				PropertyInfo property = type.GetProperty(name, bindingAttr);
				if (property?.PropertyType == typeof(bool))
				{
					object value = property.GetValue(obj, null);
					if (value is bool)
					{
						return (bool)value;
					}
				}
			}
			return false;
		}

		private static int TryReadIntByNames(object obj, params string[] names)
		{
			Type type = obj.GetType();
			BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
			foreach (string name in names)
			{
				try
				{
					FieldInfo field = type.GetField(name, bindingAttr);
					if (field != null)
					{
						return Convert.ToInt32(field.GetValue(obj) ?? ((object)0));
					}
					PropertyInfo property = type.GetProperty(name, bindingAttr);
					if (property != null)
					{
						return Convert.ToInt32(property.GetValue(obj, null) ?? ((object)0));
					}
				}
				catch
				{
				}
			}
			return 0;
		}

		private static string? ReadDisplayName(object obj)
		{
			Type type = obj.GetType();
			BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
			string[] array = new string[5] { "itemName", "displayName", "name", "npcName", "characterName" };
			foreach (string name in array)
			{
				if (type.GetField(name, bindingAttr)?.GetValue(obj) is string text && !string.IsNullOrWhiteSpace(text))
				{
					return text;
				}
				if (type.GetProperty(name, bindingAttr)?.GetValue(obj, null) is string text2 && !string.IsNullOrWhiteSpace(text2))
				{
					return text2;
				}
			}
			Component val = (Component)((obj is Component) ? obj : null);
			if (val != null && !string.IsNullOrWhiteSpace(((Object)val.gameObject).name))
			{
				return ((Object)val.gameObject).name;
			}
			GameObject val2 = (GameObject)((obj is GameObject) ? obj : null);
			if (val2 != null && !string.IsNullOrWhiteSpace(((Object)val2).name))
			{
				return ((Object)val2).name;
			}
			return null;
		}

		private IEnumerator ForceTeleportRoutine(Component player, Vector3 pos)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			CachePlayerRefs(player);
			CharacterController cc = _cc;
			if ((Object)(object)cc != (Object)null)
			{
				((Collider)cc).enabled = false;
			}
			for (int i = 0; i < 3; i++)
			{
				player.transform.position = pos;
				if ((Object)(object)_rb != (Object)null)
				{
					_rb.velocity = Vector3.zero;
					_rb.angularVelocity = Vector3.zero;
				}
				yield return null;
			}
			if ((Object)(object)cc != (Object)null)
			{
				((Collider)cc).enabled = true;
			}
		}

		private void TrySpawnRandomLootNear999()
		{
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			Component val = ResolvePlayer();
			if ((Object)(object)val == (Object)null)
			{
				PushToast("Joueur introuvable.");
				return;
			}
			Type type = Type.GetType("Item, Assembly-CSharp", throwOnError: false);
			if (type == null)
			{
				PushToast("Type Item introuvable.");
				return;
			}
			try
			{
				MethodInfo methodInfo = typeof(Resources).GetMethods(BindingFlags.Static | BindingFlags.Public).FirstOrDefault((MethodInfo m) => m.Name == "FindObjectsOfTypeAll" && m.IsGenericMethodDefinition);
				if (methodInfo == null)
				{
					PushToast("API Unity incomplete.");
					return;
				}
				if (!(methodInfo.MakeGenericMethod(type).Invoke(null, null) is Array array) || array.Length == 0)
				{
					PushToast("Aucun Item en memoire.");
					return;
				}
				List<object> list = new List<object>();
				for (int i = 0; i < array.Length; i++)
				{
					object value = array.GetValue(i);
					if (value == null || ((uint)Convert.ToInt32(value.GetType().GetProperty("hideFlags")?.GetValue(value, null) ?? ((object)0)) & 0x3Du) != 0)
					{
						continue;
					}
					object obj = type.GetField("isLoot", BindingFlags.Instance | BindingFlags.Public)?.GetValue(value);
					if (!(obj is bool) || (bool)obj)
					{
						int num = ReadItemValueApprox(value);
						if (num >= 950 && num <= 1050)
						{
							list.Add(value);
						}
					}
				}
				if (list.Count == 0)
				{
					for (int j = 0; j < array.Length; j++)
					{
						object value2 = array.GetValue(j);
						if (value2 == null)
						{
							continue;
						}
						object obj = type.GetField("isLoot", BindingFlags.Instance | BindingFlags.Public)?.GetValue(value2);
						if (!(obj is bool) || (bool)obj)
						{
							int num2 = ReadItemValueApprox(value2);
							if (num2 >= 700 && num2 <= 1300)
							{
								list.Add(value2);
							}
						}
					}
				}
				if (list.Count == 0)
				{
					PushToast("Pas de loot ~999$ trouve.");
					return;
				}
				object obj2 = list[Random.Range(0, list.Count)];
				object obj3 = (type.GetField("itemDropPrefab", BindingFlags.Instance | BindingFlags.Public) ?? type.GetField("ItemDropPrefab", BindingFlags.Instance | BindingFlags.Public))?.GetValue(obj2);
				object obj4 = ((obj3 is GameObject) ? obj3 : null);
				if (obj4 == null)
				{
					object obj5 = ((obj3 is Component) ? obj3 : null);
					obj4 = ((obj5 != null) ? ((Component)obj5).gameObject : null);
				}
				GameObject val2 = (GameObject)obj4;
				if ((Object)(object)val2 == (Object)null)
				{
					PushToast("Prefab de drop introuvable.");
					return;
				}
				Vector3 pos = val.transform.position + val.transform.forward * 1.2f + Vector3.up * 0.35f;
				Quaternion identity = Quaternion.identity;
				if (!TrySpawnNetworkPrefab(val, val2, pos, identity))
				{
					PushToast("Spawn reseau impossible (hors session ?).");
					return;
				}
				string arg = ((type.GetField("itemName", BindingFlags.Instance | BindingFlags.Public) ?? type.GetField("name", BindingFlags.Instance | BindingFlags.Public))?.GetValue(obj2) as string) ?? "loot";
				PushToast($"Spawn : {arg} (~{ReadItemValueApprox(obj2)}$).");
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)ex);
				PushToast("Erreur spawn loot.");
			}
		}

		private static int ReadItemValueApprox(object item)
		{
			try
			{
				Type type = item.GetType();
				object obj = type.GetField("value", BindingFlags.Instance | BindingFlags.Public)?.GetValue(item) ?? type.GetProperty("value", BindingFlags.Instance | BindingFlags.Public)?.GetValue(item, null);
				if (obj == null)
				{
					return -1;
				}
				PropertyInfo property = obj.GetType().GetProperty("Value", BindingFlags.Instance | BindingFlags.Public);
				if (property != null)
				{
					return Convert.ToInt32(property.GetValue(obj, null));
				}
				return Convert.ToInt32(obj);
			}
			catch
			{
				return -1;
			}
		}

		private static Component? FindFusionNetworkObject(GameObject prefabGo)
		{
			Component[] componentsInChildren = prefabGo.GetComponentsInChildren(typeof(Component), true);
			foreach (Component val in componentsInChildren)
			{
				if (!((Object)(object)val == (Object)null) && ((object)val).GetType().Name == "NetworkObject" && ((object)val).GetType().Namespace != null && ((object)val).GetType().Namespace.Contains("Fusion"))
				{
					return val;
				}
			}
			return null;
		}

		private static bool TrySpawnNetworkPrefab(Component player, GameObject prefabGo, Vector3 pos, Quaternion rot)
		{
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				object obj = ((object)player).GetType().GetProperty("Runner", BindingFlags.Instance | BindingFlags.Public)?.GetValue(player, null);
				if (obj == null)
				{
					return TryInstantiateLocalPrefab(prefabGo, pos, rot);
				}
				Component val = FindFusionNetworkObject(prefabGo);
				if ((Object)(object)val == (Object)null)
				{
					return TryInstantiateLocalPrefab(prefabGo, pos, rot);
				}
				MethodInfo[] methods = obj.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public);
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.Name != "Spawn" || methodInfo.IsGenericMethod)
					{
						continue;
					}
					ParameterInfo[] parameters = methodInfo.GetParameters();
					if (parameters.Length == 0 || !parameters[0].ParameterType.IsInstanceOfType(val))
					{
						continue;
					}
					object[] array = new object[parameters.Length];
					array[0] = val;
					for (int j = 1; j < parameters.Length; j++)
					{
						Type parameterType = parameters[j].ParameterType;
						if (parameterType == typeof(Vector3))
						{
							array[j] = pos;
						}
						else if (parameterType == typeof(Quaternion))
						{
							array[j] = rot;
						}
						else if (parameterType == typeof(Vector3?))
						{
							array[j] = pos;
						}
						else if (parameterType == typeof(Quaternion?))
						{
							array[j] = rot;
						}
						else if (parameterType.IsByRef)
						{
							array[j] = null;
						}
						else if (!parameterType.IsValueType)
						{
							array[j] = null;
						}
						else
						{
							array[j] = Activator.CreateInstance(parameterType);
						}
					}
					try
					{
						methodInfo.Invoke(obj, array);
						return true;
					}
					catch
					{
					}
				}
				return TryInstantiateLocalPrefab(prefabGo, pos, rot);
			}
			catch
			{
				return TryInstantiateLocalPrefab(prefabGo, pos, rot);
			}
		}

		private static bool TryInstantiateLocalPrefab(GameObject prefabGo, Vector3 pos, Quaternion rot)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				return (Object)(object)Object.Instantiate<GameObject>(prefabGo, pos, rot) != (Object)null;
			}
			catch
			{
				return false;
			}
		}

		private static IEnumerable<Component> FindSceneComponents(Type t)
		{
			for (int i = 0; i < SceneManager.sceneCount; i++)
			{
				Scene sceneAt = SceneManager.GetSceneAt(i);
				if (!((Scene)(ref sceneAt)).isLoaded || !((Scene)(ref sceneAt)).IsValid())
				{
					continue;
				}
				GameObject[] rootGameObjects = ((Scene)(ref sceneAt)).GetRootGameObjects();
				foreach (GameObject val in rootGameObjects)
				{
					Component[] componentsInChildren = val.GetComponentsInChildren(t, true);
					for (int k = 0; k < componentsInChildren.Length; k++)
					{
						yield return componentsInChildren[k];
					}
				}
			}
		}

		private void TryUnlockAllSkills()
		{
			Component val = ResolvePlayer();
			if ((Object)(object)val == (Object)null)
			{
				PushToast("Joueur introuvable.");
				return;
			}
			try
			{
				object? obj = ((object)val).GetType().GetField("skillManager", BindingFlags.Instance | BindingFlags.Public)?.GetValue(val);
				Component val2 = (Component)((obj is Component) ? obj : null);
				if ((Object)(object)val2 == (Object)null)
				{
					PushToast("skillManager introuvable.");
					return;
				}
				if (!(((object)val2).GetType().GetField("skills", BindingFlags.Instance | BindingFlags.Public)?.GetValue(val2) is IList list))
				{
					PushToast("Liste skills introuvable.");
					return;
				}
				foreach (object item in list)
				{
					item?.GetType().GetField("isLearned", BindingFlags.Instance | BindingFlags.Public)?.SetValue(item, true);
				}
				((object)val2).GetType().GetMethod("CheckSkills", BindingFlags.Instance | BindingFlags.Public)?.Invoke(val2, null);
				((object)val).GetType().GetMethod("CalculateBonusesToPlayer", BindingFlags.Instance | BindingFlags.Public)?.Invoke(val, null);
				object obj2 = ((object)val2).GetType().GetField("inventory", BindingFlags.Instance | BindingFlags.Public)?.GetValue(val2);
				typeof(PlayerInventory).GetMethod("CheckSlots", new Type[1] { typeof(bool) })?.Invoke(obj2, new object[1] { false });
				((object)val2).GetType().GetMethod("TryRefreshComputerSkills", BindingFlags.Instance | BindingFlags.Public)?.Invoke(val2, null);
				PushToast("Competences debloquees.");
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)ex);
				PushToast("Erreur competences.");
			}
		}

		private void TryUnlockAllSteamAchievements()
		{
			try
			{
				Assembly assembly = TryLoadSteamworks();
				if (assembly == null)
				{
					PushToast("Steamworks DLL introuvable.");
					return;
				}
				Type type = assembly.GetType("Steamworks.SteamUserStats");
				if (type == null)
				{
					PushToast("SteamUserStats introuvable.");
					return;
				}
				MethodInfo method = type.GetMethod("GetNumAchievements", BindingFlags.Static | BindingFlags.Public);
				MethodInfo method2 = type.GetMethod("GetAchievementName", BindingFlags.Static | BindingFlags.Public);
				if (method == null || method2 == null)
				{
					PushToast("API Steam incomplete.");
					return;
				}
				uint num = Convert.ToUInt32(method.Invoke(null, null));
				MethodInfo methodInfo = Type.GetType("SteamAchievementManager, Assembly-CSharp", throwOnError: false)?.GetMethod("UnlockAchievement", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(string) }, null);
				int num2 = 0;
				for (uint num3 = 0u; num3 < num; num3++)
				{
					string text = method2.Invoke(null, new object[1] { num3 }) as string;
					if (!string.IsNullOrEmpty(text))
					{
						methodInfo?.Invoke(null, new object[1] { text });
						num2++;
					}
				}
				PushToast($"Steam : {num2} succes traites.");
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)ex);
				PushToast("Erreur Steam.");
			}
		}

		private static Assembly? TryLoadSteamworks()
		{
			try
			{
				string text = Path.Combine(Path.Combine(Paths.GameRootPath, "Crime Simulator_Data", "Managed"), "com.rlabrecque.steamworks.net.dll");
				if (!File.Exists(text))
				{
					return null;
				}
				return Assembly.LoadFrom(text);
			}
			catch
			{
				return null;
			}
		}

		private void ApplyFly(bool on)
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			Component val = ResolvePlayer();
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogWarning((object)"Joueur introuvable.");
				_fly = false;
				return;
			}
			CachePlayerRefs(val);
			EnsureFppCache(val);
			if ((Object)(object)_cc != (Object)null)
			{
				((Collider)_cc).enabled = !on;
			}
			if ((Object)(object)_rb != (Object)null)
			{
				if (on)
				{
					_rb.useGravity = false;
					_rb.velocity = Vector3.zero;
					_rb.angularVelocity = Vector3.zero;
				}
				else
				{
					_rb.useGravity = true;
				}
			}
			SuppressFallDamageState();
		}

		private void DoFlyMovement()
		{
			//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)
			//IL_006a: 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)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: 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_00cd: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: 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_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_player == (Object)null)
			{
				return;
			}
			Camera main = Camera.main;
			if (!((Object)(object)main == (Object)null))
			{
				Transform transform = _player.transform;
				Vector3 forward = ((Component)main).transform.forward;
				forward.y = 0f;
				if (((Vector3)(ref forward)).sqrMagnitude < 0.0001f)
				{
					forward = ((Component)main).transform.forward;
				}
				((Vector3)(ref forward)).Normalize();
				Vector3 right = ((Component)main).transform.right;
				right.y = 0f;
				((Vector3)(ref right)).Normalize();
				Vector3 val = forward * Input.GetAxisRaw("Vertical") + right * Input.GetAxisRaw("Horizontal");
				if (Input.GetKey((KeyCode)32))
				{
					val += Vector3.up;
				}
				if (Input.GetKey((KeyCode)306))
				{
					val -= Vector3.up;
				}
				if (((Vector3)(ref val)).sqrMagnitude > 0.0001f)
				{
					transform.position += ((Vector3)(ref val)).normalized * (18f * Time.deltaTime);
				}
			}
		}

		private void ApplyInvisibility(bool on)
		{
			Component val = ResolvePlayer();
			if ((Object)(object)val == (Object)null)
			{
				_invis = false;
				return;
			}
			EnsureFppCache(val);
			if (on)
			{
				TryRpcInvisibility(active: true);
				_fpp?.SetInvisibleState(invisible: true, 86400f);
			}
			else
			{
				TryRpcInvisibility(active: false);
				_fpp?.SetInvisibleState(invisible: false, 0f);
			}
			ApplyVisualInvisibility(on);
		}

		private void MaintainNpcInvisibility()
		{
			if (!((Object)(object)_player == (Object)null))
			{
				_fpp?.SetInvisibleState(invisible: true, 86400f);
			}
		}

		private void TryRpcInvisibility(bool active)
		{
			if ((Object)(object)_player == (Object)null)
			{
				return;
			}
			if (_rpcActivateInvisibility == null)
			{
				_rpcActivateInvisibility = ((object)_player).GetType().GetMethod("RPC_ActivateInvisibility", BindingFlags.Instance | BindingFlags.Public, null, new Type[2]
				{
					typeof(bool),
					typeof(float)
				}, null);
			}
			try
			{
				_rpcActivateInvisibility?.Invoke(_player, new object[2]
				{
					active,
					active ? 86400f : 0f
				});
			}
			catch (Exception ex)
			{
				Plugin.Log.LogDebug((object)("RPC_ActivateInvisibility: " + ex.Message));
			}
		}

		private void ApplyVisualInvisibility(bool on)
		{
			Component val = ResolvePlayer();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			if (_renderers == null || (Object)(object)_player != (Object)(object)val)
			{
				_renderers = val.GetComponentsInChildren<Renderer>(true);
				_rendererStates.Clear();
				Renderer[] renderers = _renderers;
				for (int i = 0; i < renderers.Length; i++)
				{
					_ = renderers[i];
					_rendererStates.Add(item: true);
				}
				_player = val;
			}
			for (int j = 0; j < _renderers.Length; j++)
			{
				Renderer val2 = _renderers[j];
				if ((Object)(object)val2 == (Object)null || IsUnderCamera(((Component)val2).transform))
				{
					continue;
				}
				if (on)
				{
					if (j < _rendererStates.Count)
					{
						_rendererStates[j] = val2.enabled;
					}
					val2.enabled = false;
				}
				else
				{
					bool enabled = j >= _rendererStates.Count || _rendererStates[j];
					val2.enabled = enabled;
				}
			}
		}

		private void SuppressFallDamageState()
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_player == (Object)null))
			{
				EnsureFppCache(_player);
				_fpp?.ClearFallLandingState();
				Rigidbody val = _rb;
				if ((Object)(object)val == (Object)null && (Object)(object)_fpp?.MyRigidbody != (Object)null)
				{
					val = _fpp.MyRigidbody;
				}
				if ((Object)(object)val != (Object)null)
				{
					val.velocity = Vector3.zero;
					val.angularVelocity = Vector3.zero;
				}
			}
		}

		private static bool IsUnderCamera(Transform t)
		{
			Transform val = t;
			while ((Object)(object)val != (Object)null)
			{
				if ((Object)(object)((Component)val).GetComponent<Camera>() != (Object)null)
				{
					return true;
				}
				val = val.parent;
			}
			return false;
		}

		private Component? ResolvePlayer()
		{
			if ((Object)(object)_player != (Object)null && Object.op_Implicit((Object)(object)_player))
			{
				return _player;
			}
			Type type = Type.GetType("FPP_Player, Assembly-CSharp", throwOnError: false);
			if (type != null)
			{
				Object obj = Object.FindObjectOfType(type);
				Component val = (Component)(object)((obj is Component) ? obj : null);
				if ((Object)(object)val != (Object)null)
				{
					_player = val;
					return val;
				}
			}
			Type type2 = Type.GetType("WeaponManager, Assembly-CSharp", throwOnError: false);
			if (type2 != null)
			{
				Object val2 = Object.FindObjectOfType(type2);
				if (val2 != (Object)null)
				{
					object? obj2 = type2.GetField("player", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(val2);
					Component val3 = (Component)((obj2 is Component) ? obj2 : null);
					if ((Object)(object)val3 != (Object)null)
					{
						_player = val3;
						return val3;
					}
				}
			}
			return null;
		}

		private void CachePlayerRefs(Component player)
		{
			if (!((Object)(object)_player == (Object)(object)player) || !((Object)(object)_cc != (Object)null))
			{
				_player = player;
				_cc = player.GetComponent<CharacterController>() ?? player.GetComponentInChildren<CharacterController>(true);
				_rb = player.GetComponent<Rigidbody>() ?? player.GetComponentInChildren<Rigidbody>(true);
				_renderers = null;
				_fpp = null;
				_rpcActivateInvisibility = null;
			}
		}

		private void EnsureFppCache(Component player)
		{
			if ((_fpp == null || !((Object)(object)_fpp.Target == (Object)(object)player)) && !(((object)player).GetType().Name != "FPP_Player"))
			{
				_fpp = new FppReflection(player);
			}
		}

		private void ClearPlayerCache()
		{
			_player = null;
			_cc = null;
			_rb = null;
			_renderers = null;
			_rendererStates.Clear();
			_fpp = null;
			_rpcActivateInvisibility = null;
		}
	}
	internal sealed class ReferenceEqualityComparer : IEqualityComparer<object>
	{
		internal static readonly ReferenceEqualityComparer Instance = new ReferenceEqualityComparer();

		public new bool Equals(object? x, object? y)
		{
			return x == y;
		}

		public int GetHashCode(object obj)
		{
			return RuntimeHelpers.GetHashCode(obj);
		}
	}
	internal enum XRayKind
	{
		Npc,
		Object
	}
	internal readonly struct XRayLabelEntry
	{
		internal readonly Transform Target;

		internal readonly string Text;

		internal readonly XRayKind Kind;

		internal XRayLabelEntry(Transform target, string text, XRayKind kind)
		{
			Target = target;
			Text = text;
			Kind = kind;
		}
	}
	internal sealed class FppReflection
	{
		private readonly FieldInfo? _fallingVelocity;

		private readonly FieldInfo? _ungroundedTime;

		private readonly FieldInfo? _groundedTime;

		private readonly FieldInfo? _inAirBacking;

		private readonly FieldInfo? _landingBacking;

		private readonly FieldInfo? _isInvisible;

		private readonly FieldInfo? _invisibilityTimer;

		private readonly FieldInfo? _myRigidbody;

		internal Component Target { get; }

		internal Rigidbody? MyRigidbody
		{
			get
			{
				object? obj = _myRigidbody?.GetValue(Target);
				return (Rigidbody?)((obj is Rigidbody) ? obj : null);
			}
		}

		internal FppReflection(Component target)
		{
			Target = target;
			Type type = ((object)target).GetType();
			_fallingVelocity = type.GetField("fallingVelocity", BindingFlags.Instance | BindingFlags.Public);
			_ungroundedTime = type.GetField("ungroundedTime", BindingFlags.Instance | BindingFlags.NonPublic);
			_groundedTime = type.GetField("groundedTime", BindingFlags.Instance | BindingFlags.NonPublic);
			_inAirBacking = type.GetField("_inAir", BindingFlags.Instance | BindingFlags.NonPublic);
			_landingBacking = type.GetField("_landing", BindingFlags.Instance | BindingFlags.NonPublic);
			_isInvisible = type.GetField("isInvisible", BindingFlags.Instance | BindingFlags.Public);
			_invisibilityTimer = type.GetField("invisibilityTimer", BindingFlags.Instance | BindingFlags.Public);
			_myRigidbody = type.GetField("myRigidbody", BindingFlags.Instance | BindingFlags.Public);
		}

		internal void ClearFallLandingState()
		{
			_fallingVelocity?.SetValue(Target, 0f);
			_ungroundedTime?.SetValue(Target, 0f);
			_groundedTime?.SetValue(Target, 0.25f);
			_inAirBacking?.SetValue(Target, false);
			_landingBacking?.SetValue(Target, false);
			Type type = ((object)Target).GetType();
			string[] array = new string[2] { "isNormalLanding", "isDamagingLanding" };
			foreach (string name in array)
			{
				type.GetField(name, BindingFlags.Instance | BindingFlags.Public)?.SetValue(Target, false);
			}
		}

		internal void SetInvisibleState(bool invisible, float timer)
		{
			_isInvisible?.SetValue(Target, invisible);
			_invisibilityTimer?.SetValue(Target, timer);
		}
	}
	[BepInPlugin("com.abysse.crimesimulator.flyinvis", "AbysseLaMalice", "2.1.0")]
	public sealed class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_002a: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			new Harmony("com.abysse.crimesimulator.flyinvis").PatchAll();
			GameObject val = new GameObject("AbysseLaMalice_Runtime");
			Object.DontDestroyOnLoad((Object)val);
			((Object)val).hideFlags = (HideFlags)61;
			val.AddComponent<CheatRuntime>();
			Log.LogInfo((object)"AbysseLaMalice 2.1 — P = panneau de cheats.");
		}
	}
}