Decompiled source of Vanny Mask Core v1.7.1

VannyMask.dll

Decompiled 2 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Numerics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Bonelab;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.AI;
using Il2CppSLZ.Marrow.Interaction;
using Il2CppSLZ.Marrow.Pool;
using Il2CppSLZ.Marrow.SceneStreaming;
using Il2CppSLZ.Marrow.Warehouse;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;
using VannyMask;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Mod), "Vanny Mask (AR)", "1.0.0", "somewhatmaxy", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("VannyMask")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("VannyMask")]
[assembly: AssemblyTitle("VannyMask")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 VannyMask
{
	public class Mod : MelonMod
	{
		private class Item
		{
			public Poolee poolee;

			public Rigidbody rb;

			public Transform art;

			public Transform col;

			public float since = -1f;

			public Quaternion qRel = Quaternion.Euler(0f, 180f, 0f);

			public bool haveQ;

			public bool kin;

			public Transform maskoff;

			public Transform maskT;

			public float dumpAt = -1f;

			public bool locked;

			public bool lockedMine;

			public Collider gripCol;

			public Behaviour[] offScripts;

			public Transform putOn;

			public Behaviour[] onScripts;

			public bool putTried;

			public Hand snatchHand;

			public float snatchAt = -1f;

			public float restoreAt;

			public readonly List<(Collider a, Collider b)> ignored = new List<(Collider, Collider)>();

			public Renderer mr;

			public Quaternion artRot = Quaternion.identity;

			public Quaternion colRot = Quaternion.identity;

			public bool wornByThis;

			public Grip grip;

			public bool watching;

			public bool gripHeld;

			public bool sqL;

			public bool sqR;
		}

		private class Pallet
		{
			public Poolee poolee;

			public Collider[] cols;

			public Renderer art;

			public bool ignoring;

			public float nextApply;

			public GameObject holo;

			public WarpMesh box;

			public bool bent;

			public readonly Dictionary<int, Collider> extra = new Dictionary<int, Collider>();
		}

		private class WarpMesh
		{
			public Mesh mesh;

			public Vector3[] home;

			public Il2CppStructArray<Vector3> cur;
		}

		private class PhaseBeam
		{
			public Vector3 a;

			public Vector3 b;

			public Vector3 da;

			public Vector3 db;

			public float s;

			public bool reacts;

			public bool away;
		}

		private class PhasePanel
		{
			public Transform t;

			public Vector3 off;

			public Quaternion rot;

			public float phase;
		}

		private class Panel
		{
			public Poolee poolee;

			public Rigidbody rb;

			public Transform root;

			public float[] lvl = new float[2];

			public float[] bandLo = new float[2];

			public float[] bandHi = new float[2];

			public float drive;

			public float leak;

			public bool solved;

			public float inBandT;

			public int stop;

			public float dial;

			public bool stepBack;

			public float nextStepAt;

			public float swingT = -1f;

			public float swingFrom;

			public float[] glow = new float[2];

			public float[] glowShown = new float[2];

			public float[] fillK = new float[2] { 1f, 1f };

			public float[] overK = new float[2] { 1f, 1f };

			public float[] softK = new float[6];

			public PipeCut[] red = new PipeCut[2];

			public PipeCut[] band = new PipeCut[2];

			public PipeCut[] fill = new PipeCut[2];

			public PipeCut[] over = new PipeCut[2];

			public PipeCut[] ringA = new PipeCut[2];

			public PipeCut[] ringB = new PipeCut[2];

			public PipeCut[] soft = new PipeCut[6];

			public Material[] fillM = (Material[])(object)new Material[2];

			public Material[] overM = (Material[])(object)new Material[2];

			public Material[] softM = (Material[])(object)new Material[6];

			public int[] look = new int[2];

			public GameObject[] lamps = (GameObject[])(object)new GameObject[2];

			public Renderer icon;

			public GameObject plug;

			public GameObject help;

			public MeshFilter artMf;

			public AudioSource hum;

			public Transform lid;

			public CapsuleCollider cap;

			public Light light;

			public bool lidUp;

			public float lidT = -1f;

			public float lidY;

			public float lidFrom;

			public float lightLvl;

			public float lightFrom;

			public AudioSource tubeFill;

			public AudioSource tubeEmpty;

			public AudioSource tubeBoth;

			public AudioSource conduit;

			public bool session;

			public float headAt = -1f;

			public float loopAt = -1f;

			public float tailAt = -1f;

			public bool wasActive;

			public bool placed;

			public float placeAt;

			public Vector3 pos;

			public Quaternion rot;
		}

		private class Wrench
		{
			public Poolee poolee;

			public Rigidbody rb;

			public Transform root;

			public Grip grip;

			public Panel into;

			public bool held;

			public float noInsertUntil;

			public bool refused;

			public bool drawn;

			public float stowAt = -1f;

			public float insertAt;

			public Vector3 fromPos;

			public Quaternion fromRot;

			public bool twisting;

			public bool useRight;

			public Vector3 lastDir;

			public float dialAtGrab;

			public float twist;
		}

		private class PipeCut
		{
			public Mesh mesh;

			public Vector3[] V;

			public Vector3[] N;

			public Vector2[] U;

			public int[] I;

			public float len;

			public float grow;

			public float[] range = new float[4] { -1f, -1f, -1f, -1f };
		}

		private struct Pt
		{
			public Vector3 p;

			public Vector3 n;

			public Vector2 u;
		}

		private struct Layout
		{
			public string name;

			public float lo0;

			public float hi0;

			public float lo1;

			public float hi1;

			public float leak;
		}

		private bool _arOn;

		private const float FxLength = 1.99f;

		private const float FlyOnAt = 0.2f;

		private const float ArOnAt = 0.9f;

		private const float MaskGoneAt = 0.95f;

		private const float SwapOffAt = 1f;

		private const float LowerFrom = 1.05f;

		private const float LowerEnd = 1.4f;

		private static readonly Vector3 MaskViewPos = new Vector3(0f, -0.01f, 0.07f);

		private static readonly Vector3 MaskAwayPos = new Vector3(0.14f, -0.3f, 0.12f);

		private float _fxT = -1f;

		private bool _fxOn;

		private bool _fxSounded;

		private bool _fxSwapped;

		private GameObject _maskView;

		private GameObject _fxRoot;

		private Material _mWash;

		private Material _mFlash;

		private Material _mGrid;

		private Material _mBands;

		private Material _mGrain;

		private Material _mVig;

		private Material _mDark;

		private Renderer _qWash;

		private Renderer _qFlash;

		private Renderer _qGrid;

		private Renderer _qBands;

		private Renderer _qGrain;

		private Renderer _qVig;

		private Renderer _qDark;

		private float _nextJump;

		private static readonly float[] CurveBright = new float[6] { 0.38f, 1f, 0.5f, 0f, 0.62f, 1f };

		private static readonly float[] CurveChroma = new float[8] { 0.33f, 0f, 0.44f, 1f, 0.9f, 1f, 1f, 0f };

		private static readonly float[] CurveFlicker = new float[14]
		{
			0.69f, 0f, 0.72f, 1f, 0.755f, 0.2f, 0.79f, 0.8f, 0.825f, 0.1f,
			0.845f, 0.6f, 0.87f, 0f
		};

		private static readonly float[] CurveVignette = new float[6] { 0f, 0.4f, 0.853f, 0.99f, 0.962f, 0.2f };

		private static readonly float[] CurveGrain = new float[6] { 0f, 0f, 0.736f, 0.87f, 1f, 0.43f };

		private const float FxSize = 5f;

		private Texture2D _whiteTex;

		private Texture2D _radialTex;

		private Texture2D _noiseTex;

		private const string AmbienceRes = "amb_ar.wav";

		private const int AmbBlocksPerStep = 12;

		private const float AmbFade = 0.6f;

		private MelonPreferences_Entry<float> _ambVol;

		private byte[] _ambData;

		private int _ambAt;

		private int _ambEnd;

		private int _ambCh;

		private int _ambBlock;

		private int _ambPerBlock;

		private int _ambTotal;

		private int _ambDone;

		private Il2CppStructArray<float> _ambBuf;

		private AudioClip _ambClip;

		private AudioSource _amb;

		private bool _ambReady;

		private bool _ambFailed;

		private static readonly int[] ImaSteps = new int[89]
		{
			7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
			19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
			50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
			130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
			337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
			876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
			2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
			5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
			15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
		};

		private static readonly int[] ImaIndex = new int[8] { -1, -1, -1, -1, 2, 4, 6, 8 };

		private MelonPreferences_Entry<bool> _arSquares;

		private MelonPreferences_Entry<bool> _arTears;

		private const int SquareCount = 28;

		private GameObject _squareRoot;

		private Material _sqWhite;

		private Material _sqPink;

		private readonly Transform[] _sq = (Transform[])(object)new Transform[28];

		private readonly Renderer[] _sqR = (Renderer[])(object)new Renderer[28];

		private readonly float[] _sqLife = new float[28];

		private readonly float[] _sqRise = new float[28];

		private GameObject _tearRoot;

		private Material _mTear;

		private float _nextTear;

		private float _tearEnd;

		private float _nextTearJump;

		private static readonly Vector3 EyeInRoot = new Vector3(0f, -0.017f, -0.098f);

		private const float ArtScale = 39.549f;

		private static readonly Vector3 ArtLocalPos = new Vector3(0f, -0.0967f, 0.0386f);

		public static bool InhibitorActive;

		private MelonPreferences_Entry<bool> _inhTest;

		private MelonPreferences_Entry<bool> _invertDial;

		private MelonPreferences_Entry<float> _dialGain;

		private MelonPreferences_Entry<float> _inhLight;

		private MelonPreferences_Entry<float> _puzzleBright;

		private float _nextDeny;

		private int _denyCount;

		private MelonPreferences_Entry<string> _itemPrefix;

		private MelonPreferences_Entry<float> _wearDelay;

		private MelonPreferences_Entry<float> _wearForward;

		private MelonPreferences_Entry<float> _wearUp;

		private MelonPreferences_Entry<float> _nearHead;

		private readonly List<Item> _items = new List<Item>();

		private readonly HashSet<int> _itemSeen = new HashSet<int>();

		private readonly HashSet<int> _itemRoots = new HashSet<int>();

		private float _nextItemScan;

		private float _orphanAt = -1f;

		private Hand _pressHand;

		private readonly Dictionary<string, Texture2D> _resTex = new Dictionary<string, Texture2D>();

		private readonly Dictionary<string, AudioClip> _resClip = new Dictionary<string, AudioClip>();

		private GameObject _hudRoot;

		private GameObject _hudBlocked;

		private GameObject _hudNormal;

		private Material[] _hudLoop;

		private Material[] _hudIdle;

		private static readonly float[] HudIdleAlpha = new float[4] { 0.3f, 1f, 0.7f, 1f };

		private const float HudIconDelay = 1.1f;

		private const float HudLinger = 2f;

		private const float HudFade = 0.5f;

		private float _hudWornAt = -1f;

		private float _hudUntil;

		private Mesh _shearMesh;

		private Il2CppStructArray<Vector3> _shearV;

		private float _shearK;

		private float _hudLoopT;

		private static readonly float[][] HudKeys = new float[7][]
		{
			new float[6] { 0f, 1f, 0.1f, 1f, 0.15f, 0f },
			new float[8] { 0.1f, 0f, 0.15f, 1f, 0.3f, 1f, 0.35f, 0f },
			new float[8] { 0f, 0f, 0.3f, 1f, 0.45f, 1f, 0.5f, 0f },
			new float[8] { 0.45f, 0f, 0.5f, 1f, 0.6f, 1f, 0.65f, 0f },
			new float[8] { 0f, 0f, 0.6f, 1f, 0.75f, 1f, 0.8f, 0f },
			new float[16]
			{
				0f, 1f, 0.1f, 0f, 0.15f, 1f, 0.2f, 0f, 0.4f, 1f,
				0.45f, 0.5f, 0.55f, 1f, 0.8f, 0f
			},
			new float[14]
			{
				0f, 0.5f, 0.05f, 1f, 0.1f, 0.5f, 0.15f, 0.5f, 0.2f, 0f,
				0.35f, 1f, 0.8f, 1f
			}
		};

		private const float HudLoop = 0.8f;

		private const float HudShearDeg = 10.701f;

		private const float BlurbSeconds = 4f;

		private readonly HelpiBlurb _blurb = new HelpiBlurb();

		private float _nextInhBlurb;

		private bool _fpLogged;

		private Texture2D _emisTex;

		private Shader _litSh;

		private Texture _maskBaseTex;

		private float _phaseLockUntil;

		private const float PhaseLockHold = 0.35f;

		private readonly HashSet<int> _lockedCols = new HashSet<int>();

		private static readonly Vector3 PalletCentre = new Vector3(0f, 0.1f, 0f);

		private static readonly Vector3 PalletHalf = new Vector3(0.6f, 0.1f, 0.6f);

		private readonly HashSet<int> _rigIds = new HashSet<int>();

		private readonly Dictionary<int, Collider> _carried = new Dictionary<int, Collider>();

		private readonly List<int> _dropped = new List<int>();

		private float _nextCarried;

		private const string OverlayName = "VannyAR";

		private MelonPreferences_Entry<bool> _enabled;

		private MelonPreferences_Entry<bool> _staticWorld;

		private MelonPreferences_Entry<float> _maskScale;

		private MelonPreferences_Entry<float> _tintAmount;

		private MelonPreferences_Entry<float> _scanlines;

		private MelonPreferences_Entry<float> _cell;

		private MelonPreferences_Entry<float> _lineWidth;

		private MelonPreferences_Entry<float> _scanInterval;

		private MelonPreferences_Entry<float> _range;

		private MelonPreferences_Entry<string> _tintHex;

		private MelonPreferences_Entry<string> _lineHex;

		private MelonPreferences_Entry<string> _holoHex;

		private MelonPreferences_Entry<int> _maxOverlays;

		private Shader _tintSh;

		private Shader _wireSh;

		private Shader _holoSh;

		private GameObject _maskPrefab;

		private bool _loadFailed;

		private Material _tintMat;

		private Material _wireMat;

		private Material _holoMat;

		private GameObject _tintSphere;

		private Transform _cam;

		private bool _worn;

		private float _nextScan;

		private MelonPreferences_Entry<float> _sfxVol;

		private MelonPreferences_Entry<float> _maxObj;

		private MelonPreferences_Entry<bool> _tintOn;

		private MelonPreferences_Entry<bool> _wireOn;

		private MelonPreferences_Entry<bool> _holoOn;

		private AudioClip[] _sfxOn;

		private AudioClip[] _sfxOff;

		private AudioClip _flyOn;

		private AudioClip _flyOff;

		private AudioClip _canUse;

		private AudioSource _sfxSrc;

		private RigManager _localRig;

		private MelonPreferences_Entry<bool> _helpiOn;

		private MelonPreferences_Entry<bool> _helpiEvery;

		private MelonPreferences_Entry<float> _helpiVol;

		private Helpi _helpi = new Helpi();

		private bool _helpiShown;

		private float _helpiAt = -1f;

		private string _levelId;

		private float _nextLevelCheck;

		private readonly List<(Renderer src, Renderer ov)> _overlays = new List<(Renderer, Renderer)>();

		private readonly HashSet<int> _seen = new HashSet<int>();

		private int _ovLog;

		private int _skipBatched;

		private static readonly Vector3 PalletMin = new Vector3(-0.6f, 0f, -0.6f);

		private static readonly Vector3 PalletMax = new Vector3(0.6f, 0.2f, 0.6f);

		private const float LatCell = 0.4f;

		private const float BeamTh = 0.008f;

		private const float HaloW = 0.036f;

		private const int HaloCount = 80;

		private readonly List<Pallet> _pallets = new List<Pallet>();

		private readonly List<Collider> _rigCols = new List<Collider>();

		private readonly List<Collider> _bodyCols = new List<Collider>();

		private float _nextRigCols;

		private float _near;

		private float _deep;

		private bool _inPallet;

		private float _inChanged;

		private GameObject _phaseRoot;

		private GameObject _latGo;

		private GameObject _panelRoot;

		private readonly List<PhaseBeam> _beams = new List<PhaseBeam>();

		private readonly List<Transform> _halos = new List<Transform>();

		private readonly List<PhasePanel> _panels42 = new List<PhasePanel>();

		private readonly List<WarpMesh> _panelMeshes = new List<WarpMesh>();

		private Mesh _latMesh;

		private Mesh _haloMesh;

		private Il2CppStructArray<Vector3> _latV;

		private Material _mBeam;

		private Material _mHalo;

		private Material _mBoxGrid;

		private Material _mPanel;

		private Material _mBar;

		private Vector3 _panelAnchor;

		private int[] _beamOrder;

		private float[] _beamDist;

		private Vector3[] _ends;

		private AudioSource _phaseOne;

		private AudioSource _phaseOut;

		private AudioSource _phaseLoop;

		private readonly int[] _lastIn = new int[2] { -1, -1 };

		private readonly int[] _lastOut = new int[2] { -1, -1 };

		private static readonly Color PanelCol = new Color(0.55f, 0.14f, 0.53f, 1f);

		private readonly List<Panel> _panels = new List<Panel>();

		private readonly List<Wrench> _wrenches = new List<Wrench>();

		private bool _testInh;

		private bool _prevInh;

		private bool _arWarned;

		private static readonly Vector3 PlateLocal = new Vector3(0.72f, 1.07f, -0.293f);

		private const float RowA = 0.029f;

		private const float RowB = -0.025f;

		private const float PipeX0 = -0.209f;

		private const float ZPipe = -0.008f;

		private static readonly Vector3 DialLocal = new Vector3(0.21f, 0f, -0.028f);

		private static readonly Vector3 PlugLocal = new Vector3(0.21f, 0f, -0.037f);

		private static readonly Vector3 WrenchTipLocal = new Vector3(0f, 0.148f, 0.012f);

		private readonly Dictionary<string, Mesh> _meshes = new Dictionary<string, Mesh>();

		private const int WorldQueue = 2990;

		private static readonly Color32 ColCurrent = new Color32((byte)232, (byte)108, (byte)90, byte.MaxValue);

		private static readonly Color32 ColCurrentOver = new Color32((byte)216, (byte)56, (byte)38, byte.MaxValue);

		private static readonly Color32 ColInside = new Color32((byte)210, (byte)250, (byte)252, byte.MaxValue);

		private static readonly Color32 ColInsideOver = new Color32((byte)85, (byte)220, (byte)232, byte.MaxValue);

		private static readonly Color32 ColEmpty = new Color32((byte)80, (byte)35, (byte)38, byte.MaxValue);

		private static readonly Color32 ColTarget = new Color32((byte)20, (byte)95, (byte)110, byte.MaxValue);

		private static readonly Color32 ColStub = new Color32((byte)70, (byte)6, (byte)10, byte.MaxValue);

		private static readonly Color32 ColSeam = new Color32((byte)8, (byte)8, (byte)10, byte.MaxValue);

		private static readonly Color32 ColLamp = new Color32((byte)245, (byte)254, byte.MaxValue, byte.MaxValue);

		private static readonly Color32 ColIcon = new Color32((byte)205, (byte)250, (byte)225, byte.MaxValue);

		private static readonly Color32 ColIconDim = new Color32((byte)6, (byte)45, (byte)18, byte.MaxValue);

		private static readonly Color32 ColIconDone = new Color32((byte)253, (byte)243, (byte)198, byte.MaxValue);

		private const int SoftSlices = 3;

		private const float SoftWidth = 0.036f;

		private readonly Dictionary<int, Texture2D> _flatTex = new Dictionary<int, Texture2D>();

		private readonly Dictionary<int, Material> _flatMats = new Dictionary<int, Material>();

		private float _flatGain = 1f;

		private Material _faceMat;

		private readonly HashSet<int> _keepSolved = new HashSet<int>();

		private static readonly List<Vector3> _cutV = new List<Vector3>();

		private static readonly List<Vector3> _cutN = new List<Vector3>();

		private static readonly List<Vector2> _cutU = new List<Vector2>();

		private static readonly List<int> _cutI = new List<int>();

		private static readonly List<Pt> _polyA = new List<Pt>(8);

		private static readonly List<Pt> _polyB = new List<Pt>(8);

		private Material _helpMat;

		private const float LidTravel = 0.331f;

		private static readonly float[] LidRise = new float[5] { 0f, 0.0725f, 0.281f, 0.595f, 1f };

		private static readonly float[] LidFall = new float[5] { 0f, 0.033f, 0.172f, 0.474f, 1f };

		private const float HumGain = 0.8f;

		private const float StereoGain = 0.2f;

		private const string StereoLoop = "inh_loop_st.wav";

		private Material _inhGlowMat;

		private AudioSource _inhSt;

		private const float FillRate = 0.12f;

		private static readonly Layout[] Layouts = new Layout[3]
		{
			new Layout
			{
				name = "Gator Golf 1A",
				lo0 = 0.6f,
				hi0 = 0.85f,
				lo1 = 0.5f,
				hi1 = 0.75f,
				leak = 0.1f
			},
			new Layout
			{
				name = "Food court",
				lo0 = 0.2f,
				hi0 = 0.5f,
				lo1 = 0.65f,
				hi1 = 0.95f,
				leak = 0.1f
			},
			new Layout
			{
				name = "Gator Golf 2A",
				lo0 = 0.1f,
				hi0 = 0.3f,
				lo1 = 0.7f,
				hi1 = 0.9f,
				leak = 0.25f
			}
		};

		private static readonly string[] InteractClips = new string[4] { "conduit_interact1.wav", "conduit_interact2.wav", "conduit_interact3.wav", "conduit_interact4.wav" };

		private static readonly string[] HeadClips = new string[4] { "conduit_head1.wav", "conduit_head2.wav", "conduit_head3.wav", "conduit_head4.wav" };

		private static readonly string[] TailClips = new string[4] { "conduit_tail1.wav", "conduit_tail2.wav", "conduit_tail3.wav", "conduit_tail4.wav" };

		private static readonly float[] Stops = new float[4] { 0f, 68f, 111f, 180f };

		private const float StopHysteresis = 4f;

		private static readonly string[] ClickClips = new string[4] { "switch_turn1.wav", "switch_turn2.wav", "switch_turn3.wav", "switch_turn4.wav" };

		private int _lastClick = -1;

		private static readonly float[,] SeatKeys = new float[7, 9]
		{
			{ 0f, -2.68f, 16.59f, -0.007f, 0.122f, -0.992f, -0.059f, 0.991f, 0.123f },
			{ -0.12f, -2.66f, 16.45f, -0.001f, 0.121f, -0.993f, -0.01f, 0.993f, 0.121f },
			{ -0.18f, -1.97f, 16.13f, 0.001f, 0.071f, -0.997f, 0.014f, 0.997f, 0.071f },
			{ -0.12f, -0.71f, 14.15f, 0f, -0.006f, -1f, -0.055f, 0.998f, -0.006f },
			{ -0.11f, 0.06f, 13.2f, 0.005f, -0.045f, -0.999f, -0.106f, 0.993f, -0.045f },
			{ -0.14f, -0.38f, 13.44f, 0f, -0.008f, -1f, -0.017f, 1f, -0.008f },
			{ -0.15f, -0.49f, 13.4f, 0f, 0f, -1f, 0f, 1f, 0f }
		};

		private const float ApproachTime = 0.15f;

		private const float SeatTime = 0.45000002f;

		private float _nextPuzzleWarn;

		private readonly List<Renderer> _menuHidden = new List<Renderer>();

		private bool _menuHiding;

		private int _menuLog;

		private int _emisAmtId;

		private const float FedGlow = 0.18f;

		private bool PhaseLocked => Time.unscaledTime < _phaseLockUntil;

		private bool PhaseVisuals => _arOn;

		private float PuzzleGain => Mathf.Clamp((_puzzleBright != null) ? _puzzleBright.Value : 1f, 0.2f, 3f);

		private static float Smooth01(float x)
		{
			x = Mathf.Clamp01(x);
			return x * x * (3f - 2f * x);
		}

		private static float FxLevel(float t)
		{
			if (!(t < 1f))
			{
				return Smooth01((1.99f - t) / 0.99f);
			}
			return Smooth01(t);
		}

		private static float FxBias(float level)
		{
			if (!(level < 0.7f))
			{
				return 0.45f + (level - 0.7f) * 1.8333333f;
			}
			return level * (9f / 14f);
		}

		private void SetArVisual(bool on)
		{
			if (_arOn == on)
			{
				return;
			}
			_arOn = on;
			_nextScan = 0f;
			if (!on)
			{
				ClearOverlays();
				if ((Object)(object)_tintSphere != (Object)null && !((Il2CppObjectBase)_tintSphere).WasCollected)
				{
					_tintSphere.SetActive(false);
				}
			}
		}

		private void StartTransition(bool on)
		{
			_fxOn = on;
			_fxT = 0f;
			_fxSounded = false;
			_fxSwapped = false;
			_nextJump = 0f;
			if (!on && !_arOn)
			{
				_fxT = 1f;
			}
		}

		private void EndTransition()
		{
			_fxT = -1f;
			if ((Object)(object)_maskView != (Object)null && !((Il2CppObjectBase)_maskView).WasCollected)
			{
				_maskView.SetActive(false);
			}
			if ((Object)(object)_fxRoot != (Object)null && !((Il2CppObjectBase)_fxRoot).WasCollected)
			{
				_fxRoot.SetActive(false);
			}
		}

		private void UpdateTransition(Transform cam, float dt)
		{
			if (_fxT < 0f)
			{
				return;
			}
			float fxT = _fxT;
			_fxT += Mathf.Min(dt, 0.05f);
			if (_fxOn)
			{
				if (!_fxSounded && fxT >= 0.2f)
				{
					_fxSounded = true;
					PlaySfx(_flyOn, 0.9f);
				}
				if (!_fxSwapped && fxT >= 0.9f)
				{
					_fxSwapped = true;
					SetArVisual(on: true);
				}
			}
			else if (!_fxSwapped && fxT >= 1f)
			{
				_fxSwapped = true;
				SetArVisual(on: false);
				PlaySfx(_flyOff, 0.9f);
			}
			if (fxT >= 1.99f)
			{
				EndTransition();
				return;
			}
			try
			{
				DrawMaskView(cam, fxT);
				DrawTransitionFx(cam, fxT);
			}
			catch (Exception ex)
			{
				((MelonBase)this).LoggerInstance.Warning("transition: " + ex.Message);
				EndTransition();
				SetArVisual(_worn);
			}
		}

		private void DrawMaskView(Transform cam, float t)
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			bool num;
			if (!_fxOn)
			{
				if (!(t >= 1f))
				{
					goto IL_0027;
				}
				num = t < 1.4f;
			}
			else
			{
				num = t < 0.95f;
			}
			if (num)
			{
				if (!Load() || (Object)(object)_maskPrefab == (Object)null)
				{
					return;
				}
				if ((Object)(object)_maskView == (Object)null || ((Il2CppObjectBase)_maskView).WasCollected)
				{
					_maskView = new GameObject("VannyMaskView")
					{
						hideFlags = (HideFlags)32
					};
					GameObject val = Object.Instantiate<GameObject>(_maskPrefab);
					((Object)val).name = "VannyMaskFx";
					val.SetActive(true);
					val.transform.SetParent(_maskView.transform, false);
					foreach (Collider componentsInChild in val.GetComponentsInChildren<Collider>(true))
					{
						Object.Destroy((Object)(object)componentsInChild);
					}
					foreach (Renderer componentsInChild2 in val.GetComponentsInChildren<Renderer>(true))
					{
						componentsInChild2.shadowCastingMode = (ShadowCastingMode)0;
						componentsInChild2.receiveShadows = false;
					}
				}
				Transform transform = _maskView.transform;
				if ((Object)(object)transform.parent != (Object)(object)cam)
				{
					transform.SetParent(cam, false);
				}
				float num2 = (_fxOn ? 0f : Smooth01((t - 1.05f) / 0.35000002f));
				transform.localPosition = Vector3.Lerp(MaskViewPos, MaskAwayPos, num2);
				transform.localRotation = Quaternion.Euler(25f * num2, 0f, -12f * num2) * Quaternion.Euler(0f, 180f, 0f);
				transform.localScale = Vector3.one * Mathf.Clamp(_maskScale.Value, 0.6f, 1.4f);
				if (!_maskView.activeSelf)
				{
					_maskView.SetActive(true);
				}
				return;
			}
			goto IL_0027;
			IL_0027:
			if ((Object)(object)_maskView != (Object)null && !((Il2CppObjectBase)_maskView).WasCollected && _maskView.activeSelf)
			{
				_maskView.SetActive(false);
			}
		}

		private static Texture2D MakeTex(int size, Func<int, int, Color32> px, TextureWrapMode wrap, FilterMode filter = (FilterMode)1)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(size, size, (TextureFormat)4, false)
			{
				hideFlags = (HideFlags)32
			};
			Color32[] array = (Color32[])(object)new Color32[size * size];
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					array[i * size + j] = px(j, i);
				}
			}
			val.SetPixels32(Il2CppStructArray<Color32>.op_Implicit(array));
			val.Apply();
			((Texture)val).wrapMode = wrap;
			((Texture)val).filterMode = filter;
			return val;
		}

		private Texture2D WhiteTex()
		{
			if (!((Object)(object)_whiteTex != (Object)null) || ((Il2CppObjectBase)_whiteTex).WasCollected)
			{
				return _whiteTex = MakeTex(2, (int x, int y) => new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue), (TextureWrapMode)1, (FilterMode)1);
			}
			return _whiteTex;
		}

		private Texture2D RadialTex()
		{
			if (!((Object)(object)_radialTex != (Object)null) || ((Il2CppObjectBase)_radialTex).WasCollected)
			{
				return _radialTex = MakeTex(128, delegate(int x, int y)
				{
					//IL_006e: Unknown result type (might be due to invalid IL or missing references)
					float num = ((float)x + 0.5f) / 128f - 0.5f;
					float num2 = ((float)y + 0.5f) / 128f - 0.5f;
					float num3 = Mathf.Atan(Mathf.Sqrt(num * num + num2 * num2) * 5f) * 57.29578f;
					return new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(255f * Smooth01((num3 - 22f) / 30f)));
				}, (TextureWrapMode)1, (FilterMode)1);
			}
			return _radialTex;
		}

		private Texture2D NoiseTex()
		{
			if ((Object)(object)_noiseTex != (Object)null && !((Il2CppObjectBase)_noiseTex).WasCollected)
			{
				return _noiseTex;
			}
			Random rnd = new Random(7);
			return _noiseTex = MakeTex(128, delegate
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				byte num = (byte)rnd.Next(256);
				return new Color32(num, num, num, (byte)rnd.Next(256));
			}, (TextureWrapMode)0, (FilterMode)0);
		}

		private static void Fx(Renderer r, Material m, float red, float green, float blue, float a)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			bool flag = a > 0.004f;
			if (r.enabled != flag)
			{
				r.enabled = flag;
			}
			if (flag)
			{
				m.SetColor("_Color", new Color(red, green, blue, Mathf.Clamp01(a)));
			}
		}

		private bool BuildTransitionFx()
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_fxRoot != (Object)null && !((Il2CppObjectBase)_fxRoot).WasCollected)
			{
				return true;
			}
			Texture2D val = ResTex("fx_pixelgrid.png");
			Texture2D val2 = ResTex("fx_bands.png");
			if ((Object)(object)_helpi.Ui == (Object)null || (Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
			{
				return false;
			}
			TextureWrapMode wrapMode = (TextureWrapMode)0;
			((Texture)val2).wrapMode = (TextureWrapMode)0;
			((Texture)val).wrapMode = wrapMode;
			_fxRoot = new GameObject("VannyTransition")
			{
				hideFlags = (HideFlags)32
			};
			Vector3 size = new Vector3(5f, 5f, 1f);
			_qWash = Q("wash", WhiteTex(), 3990, out _mWash);
			_qFlash = Q("flash", WhiteTex(), 3991, out _mFlash);
			_qGrid = Q("pixelgrid", val, 3992, out _mGrid);
			_mGrid.SetTextureScale("_MainTex", new Vector2(14f, 14f));
			_qBands = Q("bands", val2, 3993, out _mBands);
			_mBands.SetTextureScale("_MainTex", new Vector2(1f, 3f));
			_qGrain = Q("grain", NoiseTex(), 3994, out _mGrain);
			_mGrain.SetTextureScale("_MainTex", new Vector2(8f, 8f));
			_qVig = Q("vignette", RadialTex(), 3995, out _mVig);
			_qDark = Q("dark", WhiteTex(), 3996, out _mDark);
			return true;
			Renderer Q(string n, Texture2D tex, int queue, out Material m)
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				m = UiMat(tex, queue);
				return UiQuad(_fxRoot.transform, n, m, Vector3.zero, size);
			}
		}

		private void DrawTransitionFx(Transform cam, float t)
		{
			//IL_003b: 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_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			if (BuildTransitionFx())
			{
				Transform transform = _fxRoot.transform;
				if ((Object)(object)transform.parent != (Object)(object)cam)
				{
					transform.SetParent(cam, false);
					transform.localPosition = new Vector3(0f, 0f, 1f);
					transform.localRotation = Quaternion.identity;
				}
				if (!_fxRoot.activeSelf)
				{
					_fxRoot.SetActive(true);
				}
				float num = FxLevel(t);
				float t2 = FxBias(num);
				float num2 = Mathf.Clamp01(num * 5f);
				float num3 = 1f - Keyed(CurveBright, t2);
				float num4 = Keyed(CurveChroma, t2);
				float num5 = Keyed(CurveFlicker, t2);
				float num6 = Keyed(CurveVignette, t2) * num2;
				float num7 = Keyed(CurveGrain, t2) * num2;
				bool flag = (_fxOn ? (t < 0.95f) : (t >= 1f && t < 1.4f));
				float num8 = (_fxOn ? Smooth01((t - 0.7f) / 0.15f) : 0f);
				Fx(_qWash, _mWash, Mathf.Lerp(0.07f, 0.7f, num8), Mathf.Lerp(0.02f, 0.18f, num8), Mathf.Lerp(0.11f, 0.85f, num8), flag ? Mathf.Lerp(0.5f, 0.25f, num8) : 0f);
				Fx(_qFlash, _mFlash, 1f, 0.7f, 0.95f, num5 * 0.28f);
				Fx(_qGrid, _mGrid, 1f, 0.78f, 1f, Mathf.Max(num5 * 0.3f, num4 * 0.06f));
				Fx(_qBands, _mBands, 1f, 0.3f, 0.9f, num4 * 0.4f);
				Fx(_qGrain, _mGrain, 1f, 1f, 1f, num7 * 0.12f);
				Fx(_qVig, _mVig, 0.03f, 0f, 0.05f, num6 * 0.9f);
				Fx(_qDark, _mDark, 0f, 0f, 0f, num3 * 0.97f);
				if (Time.unscaledTime >= _nextJump)
				{
					_nextJump = Time.unscaledTime + 0.05f;
					_mBands.SetTextureOffset("_MainTex", new Vector2(0f, Random.value));
					_mGrain.SetTextureOffset("_MainTex", new Vector2(Random.value, Random.value));
				}
			}
		}

		private void PreloadAmbience()
		{
			if (_ambFailed || (_ambReady && (Object)(object)_ambClip != (Object)null && !((Il2CppObjectBase)_ambClip).WasCollected) || _ambData != null)
			{
				return;
			}
			try
			{
				byte[] array = Res("amb_ar.wav");
				if (array == null)
				{
					_ambFailed = true;
					return;
				}
				int i = 12;
				int num = 0;
				int num2 = 0;
				_ambCh = 0;
				_ambTotal = 0;
				_ambAt = 0;
				_ambEnd = 0;
				int num3;
				for (; i + 8 <= array.Length; i += 8 + num3 + (num3 & 1))
				{
					string text = Encoding.ASCII.GetString(array, i, 4);
					num3 = BitConverter.ToInt32(array, i + 4);
					switch (text)
					{
					case "fmt ":
						num2 = BitConverter.ToInt16(array, i + 8);
						_ambCh = BitConverter.ToInt16(array, i + 10);
						num = BitConverter.ToInt32(array, i + 12);
						_ambBlock = BitConverter.ToInt16(array, i + 20);
						_ambPerBlock = BitConverter.ToInt16(array, i + 26);
						continue;
					case "fact":
						_ambTotal = BitConverter.ToInt32(array, i + 8);
						continue;
					case "data":
						break;
					default:
						continue;
					}
					_ambAt = i + 8;
					_ambEnd = _ambAt + Math.Min(num3, array.Length - _ambAt);
					break;
				}
				if (num2 != 17 || _ambCh < 1 || _ambCh > 2 || _ambBlock <= 4 * _ambCh || _ambPerBlock <= 1 || _ambAt == 0)
				{
					throw new Exception("not an IMA ADPCM wav");
				}
				int num4 = (_ambEnd - _ambAt) / _ambBlock * _ambPerBlock;
				if (_ambTotal <= 0 || _ambTotal > num4)
				{
					_ambTotal = num4;
				}
				_ambClip = AudioClip.Create("VannyArAmbience", _ambTotal, _ambCh, num, false);
				((Object)_ambClip).hideFlags = (HideFlags)32;
				_ambData = array;
				_ambDone = 0;
				_ambReady = false;
				_ambBuf = null;
			}
			catch (Exception ex)
			{
				_ambFailed = true;
				_ambData = null;
				((MelonBase)this).LoggerInstance.Warning("AR ambience: " + ex.Message);
			}
		}

		private static void ImaBlock(byte[] d, int at, int block, int ch, int per, Il2CppStructArray<float> to, int offset, int frames)
		{
			for (int i = 0; i < ch; i++)
			{
				int num = at + 4 * i;
				int num2 = BitConverter.ToInt16(d, num);
				int num3 = Math.Min((int)d[num + 2], 88);
				if (frames > 0)
				{
					((Il2CppArrayBase<float>)(object)to)[offset + i] = (float)num2 / 32768f;
				}
				int num4 = at + 4 * ch + 4 * i;
				for (int j = 1; j < per && j < frames; j++)
				{
					int num5 = j - 1;
					int num6 = d[num4 + num5 / 8 * 4 * ch + num5 % 8 / 2];
					int num7 = (((num5 & 1) == 0) ? (num6 & 0xF) : (num6 >> 4));
					int num8 = ImaSteps[num3];
					int num9 = num8 >> 3;
					if ((num7 & 4) != 0)
					{
						num9 += num8;
					}
					if ((num7 & 2) != 0)
					{
						num9 += num8 >> 1;
					}
					if ((num7 & 1) != 0)
					{
						num9 += num8 >> 2;
					}
					num2 += (((num7 & 8) != 0) ? (-num9) : num9);
					if (num2 > 32767)
					{
						num2 = 32767;
					}
					else if (num2 < -32768)
					{
						num2 = -32768;
					}
					num3 += ImaIndex[num7 & 7];
					if (num3 < 0)
					{
						num3 = 0;
					}
					else if (num3 > 88)
					{
						num3 = 88;
					}
					((Il2CppArrayBase<float>)(object)to)[offset + j * ch + i] = (float)num2 / 32768f;
				}
			}
		}

		private void UnpackAmbience()
		{
			if (_ambData == null)
			{
				return;
			}
			try
			{
				if ((Object)(object)_ambClip == (Object)null || ((Il2CppObjectBase)_ambClip).WasCollected)
				{
					_ambData = null;
					_ambBuf = null;
					return;
				}
				int num = Math.Min(_ambTotal - _ambDone, 12 * _ambPerBlock);
				if (_ambBuf == null || ((Il2CppArrayBase<float>)(object)_ambBuf).Length != num * _ambCh)
				{
					_ambBuf = new Il2CppStructArray<float>((long)(num * _ambCh));
				}
				int num2 = _ambDone / _ambPerBlock;
				for (int i = 0; i * _ambPerBlock < num; i++)
				{
					ImaBlock(_ambData, _ambAt + (num2 + i) * _ambBlock, _ambBlock, _ambCh, _ambPerBlock, _ambBuf, i * _ambPerBlock * _ambCh, num - i * _ambPerBlock);
				}
				_ambClip.SetData(_ambBuf, _ambDone);
				_ambDone += num;
				if (_ambDone >= _ambTotal)
				{
					_ambReady = true;
					_ambData = null;
					_ambBuf = null;
				}
			}
			catch (Exception ex)
			{
				_ambFailed = true;
				_ambData = null;
				_ambBuf = null;
				((MelonBase)this).LoggerInstance.Warning("AR ambience: " + ex.Message);
			}
		}

		private void UpdateAmbience(Transform cam, float dt)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			UnpackAmbience();
			float num = Mathf.Clamp01(_sfxVol.Value * _ambVol.Value);
			if (_worn)
			{
				if (!_ambReady || (Object)(object)_ambClip == (Object)null || ((Il2CppObjectBase)_ambClip).WasCollected)
				{
					_ambReady = false;
					PreloadAmbience();
					return;
				}
				if ((Object)(object)_amb == (Object)null || ((Il2CppObjectBase)_amb).WasCollected)
				{
					GameObject val = new GameObject("VannyArAmbience");
					val.transform.SetParent(cam, false);
					_amb = val.AddComponent<AudioSource>();
					_amb.playOnAwake = false;
					_amb.loop = true;
					_amb.spatialBlend = 0f;
					_amb.volume = 0f;
				}
				if (!_amb.isPlaying)
				{
					_amb.clip = _ambClip;
					_amb.volume = 0f;
					_amb.Play();
				}
				_amb.volume = Mathf.MoveTowards(_amb.volume, num, Mathf.Max(0.01f, num) * dt / 0.6f);
			}
			else if ((Object)(object)_amb != (Object)null && !((Il2CppObjectBase)_amb).WasCollected && _amb.isPlaying)
			{
				_amb.volume = Mathf.MoveTowards(_amb.volume, 0f, Mathf.Max(0.01f, num) * dt / 0.6f);
				if (_amb.volume <= 0.001f)
				{
					_amb.Stop();
				}
			}
		}

		private void StopAmbience()
		{
			if ((Object)(object)_amb != (Object)null && !((Il2CppObjectBase)_amb).WasCollected)
			{
				_amb.volume = 0f;
				_amb.Stop();
			}
		}

		private void PlaceSquare(int i, Vector3 head)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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)
			float num = Random.Range(0f, (float)Math.PI * 2f);
			float num2 = Random.Range(1f, 4.5f);
			_sq[i].position = head + new Vector3(Mathf.Cos(num) * num2, Random.Range(-1.1f, 1f), Mathf.Sin(num) * num2);
			_sq[i].localScale = Vector3.one * Random.Range(0.008f, 0.026f);
			_sqLife[i] = Random.Range(2.5f, 7f);
			_sqRise[i] = Random.Range(0.015f, 0.07f);
		}

		private void UpdateSquares(Transform cam, float dt)
		{
			//IL_004b: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: 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_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: 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_017b: Unknown result type (might be due to invalid IL or missing references)
			if (!_arOn || !_arSquares.Value)
			{
				if ((Object)(object)_squareRoot != (Object)null && !((Il2CppObjectBase)_squareRoot).WasCollected && _squareRoot.activeSelf)
				{
					_squareRoot.SetActive(false);
				}
				return;
			}
			Vector3 position = cam.position;
			if ((Object)(object)_squareRoot == (Object)null || ((Il2CppObjectBase)_squareRoot).WasCollected)
			{
				if (!EnsureLit())
				{
					return;
				}
				_squareRoot = new GameObject("VannyArSquares");
				if ((Object)(object)_sqWhite == (Object)null || ((Il2CppObjectBase)_sqWhite).WasCollected)
				{
					_sqWhite = SolidMat(Color32.op_Implicit(new Color32((byte)250, (byte)238, byte.MaxValue, byte.MaxValue)), 0f);
				}
				if ((Object)(object)_sqPink == (Object)null || ((Il2CppObjectBase)_sqPink).WasCollected)
				{
					_sqPink = SolidMat(Color32.op_Implicit(new Color32(byte.MaxValue, (byte)140, (byte)225, byte.MaxValue)), 0f);
				}
				for (int i = 0; i < 28; i++)
				{
					_sqR[i] = UiQuad(_squareRoot.transform, "square", (i % 3 == 0) ? _sqWhite : _sqPink, Vector3.zero, Vector3.one);
					_sq[i] = ((Component)_sqR[i]).transform;
					PlaceSquare(i, position);
				}
			}
			if (!_squareRoot.activeSelf)
			{
				_squareRoot.SetActive(true);
			}
			float unscaledTime = Time.unscaledTime;
			for (int num = 0; num < 28; num++)
			{
				_sqLife[num] -= dt;
				Vector3 position2 = _sq[num].position;
				if (!(_sqLife[num] <= 0f))
				{
					Vector3 val = position2 - position;
					if (!(((Vector3)(ref val)).sqrMagnitude > 36f))
					{
						goto IL_020e;
					}
				}
				PlaceSquare(num, position);
				position2 = _sq[num].position;
				goto IL_020e;
				IL_020e:
				position2.y += _sqRise[num] * dt;
				Vector3 val2 = position2 - position;
				if (((Vector3)(ref val2)).sqrMagnitude > 0.01f)
				{
					_sq[num].SetPositionAndRotation(position2, Quaternion.LookRotation(val2));
				}
				bool flag = Mathf.PerlinNoise(unscaledTime * 5f + (float)num * 7.3f, (float)num * 1.7f) < 0.76f && ((Vector3)(ref val2)).sqrMagnitude > 0.36f;
				if (_sqR[num].enabled != flag)
				{
					_sqR[num].enabled = flag;
				}
			}
		}

		private void UpdateTears(Transform cam)
		{
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Expected O, but got Unknown
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: 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_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			float unscaledTime = Time.unscaledTime;
			if (!_arOn || !_arTears.Value || (Object)(object)_helpi.Ui == (Object)null)
			{
				if ((Object)(object)_tearRoot != (Object)null && !((Il2CppObjectBase)_tearRoot).WasCollected && _tearRoot.activeSelf)
				{
					_tearRoot.SetActive(false);
				}
				_nextTear = unscaledTime + Random.Range(4f, 10f);
				_tearEnd = 0f;
				return;
			}
			if (unscaledTime >= _nextTear)
			{
				_nextTear = unscaledTime + Random.Range(6f, 15f);
				_tearEnd = unscaledTime + Random.Range(0.08f, 0.2f);
				_nextTearJump = 0f;
			}
			if (unscaledTime >= _tearEnd)
			{
				if ((Object)(object)_tearRoot != (Object)null && !((Il2CppObjectBase)_tearRoot).WasCollected && _tearRoot.activeSelf)
				{
					_tearRoot.SetActive(false);
				}
				return;
			}
			if ((Object)(object)_tearRoot == (Object)null || ((Il2CppObjectBase)_tearRoot).WasCollected)
			{
				Texture2D val = ResTex("fx_bands.png");
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				((Texture)val).wrapMode = (TextureWrapMode)0;
				_tearRoot = new GameObject("VannyArTear")
				{
					hideFlags = (HideFlags)32
				};
				_mTear = UiMat(val, 3981);
				_mTear.SetColor("_Color", new Color(1f, 0.65f, 1f, 0.3f));
				UiQuad(_tearRoot.transform, "tear", _mTear, Vector3.zero, new Vector3(5f, 0.05f, 1f));
			}
			Transform transform = _tearRoot.transform;
			if ((Object)(object)transform.parent != (Object)(object)cam)
			{
				transform.SetParent(cam, false);
			}
			if (unscaledTime >= _nextTearJump)
			{
				_nextTearJump = unscaledTime + 0.04f;
				transform.localPosition = new Vector3(Random.Range(-0.05f, 0.05f), Random.Range(-0.35f, 0.35f), 1f);
				transform.localRotation = Quaternion.identity;
				_mTear.SetTextureOffset("_MainTex", new Vector2(0f, Random.value));
			}
			if (!_tearRoot.activeSelf)
			{
				_tearRoot.SetActive(true);
			}
		}

		private void UpdateArExtras(Transform cam, float dt)
		{
			try
			{
				UpdateSquares(cam, dt);
				UpdateTears(cam);
			}
			catch (Exception ex)
			{
				((MelonBase)this).LoggerInstance.Warning("ar extras: " + ex.Message);
			}
		}

		private void StopArView()
		{
			EndTransition();
			SetArVisual(on: false);
			StopAmbience();
			_helpi.Stop();
			if ((Object)(object)_tintSphere != (Object)null && !((Il2CppObjectBase)_tintSphere).WasCollected && _tintSphere.activeSelf)
			{
				_tintSphere.SetActive(false);
			}
			GameObject[] array = (GameObject[])(object)new GameObject[2] { _squareRoot, _tearRoot };
			foreach (GameObject val in array)
			{
				if ((Object)(object)val != (Object)null && !((Il2CppObjectBase)val).WasCollected && val.activeSelf)
				{
					val.SetActive(false);
				}
			}
		}

		private void InitItems(MelonPreferences_Category cat)
		{
			_inhTest = cat.CreateEntry<bool>("InhibitorTest", false, (string)null, "Testing: F9 toggles the AR inhibitor (the mask can't be put on or taken off while it is on)", false, false, (ValueValidator)null, (string)null);
			_invertDial = cat.CreateEntry<bool>("InvertDial", false, (string)null, "Flip the direction the conduit dial turns when you twist the Faz Wrench", false, false, (ValueValidator)null, (string)null);
			_dialGain = cat.CreateEntry<float>("DialTwistGain", 1.3f, (string)null, "How far the conduit dial turns per degree you twist your wrist (its stops are at 0, 68, 111 and 180 degrees)", false, false, (ValueValidator)null, (string)null);
			_puzzleBright = cat.CreateEntry<float>("PuzzleBrightness", 1f, (string)null, "Brightness of the conduit panel's tubes, lamps and wrench symbol (1 = matched to the game)", false, false, (ValueValidator)null, (string)null);
			_inhLight = cat.CreateEntry<float>("InhibitorLightIntensity", 1.5f, (string)null, "Brightness of the AR inhibitor's cyan light (0 = no light)", false, false, (ValueValidator)null, (string)null);
			_itemPrefix = cat.CreateEntry<string>("MaskBarcodePrefix", "somewhatmaxy.VannyMaskAR.Spawnable.", (string)null, "Crate barcode prefix of the spawnable Vanny mask", false, false, (ValueValidator)null, (string)null);
			_wearDelay = cat.CreateEntry<float>("WornDelay", 0.2f, (string)null, "Seconds the mask must be worn (kinematic, at your head) before the AR view starts", false, false, (ValueValidator)null, (string)null);
			_nearHead = cat.CreateEntry<float>("WornMaxDistance", 0.8f, (string)null, "A kinematic mask farther than this (metres) from your head camera is not counted as worn", false, false, (ValueValidator)null, (string)null);
			_wearForward = cat.CreateEntry<float>("WearOffsetForward", 0.015f, (string)null, "Move the worn mask forward (metres, along your view) relative to your eyes; negative = towards your face", false, false, (ValueValidator)null, (string)null);
			_wearUp = cat.CreateEntry<float>("WearOffsetUp", 0f, (string)null, "Move the worn mask up (metres, along your head's up); negative = down", false, false, (ValueValidator)null, (string)null);
		}

		private void ClearItems()
		{
			ClearPallets();
			ClearPuzzle();
			_items.Clear();
			_itemSeen.Clear();
			_itemRoots.Clear();
			_nextItemScan = 0f;
			_orphanAt = -1f;
			_denyCount = 0;
			_nextDeny = 0f;
			_hudLoopT = 0f;
			_hudUntil = 0f;
			_hudWornAt = -1f;
			_nextInhBlurb = 0f;
			_blurb.Stop();
		}

		private static Transform FindDeep(Transform t, string name)
		{
			if (((Object)t).name == name)
			{
				return t;
			}
			for (int i = 0; i < t.childCount; i++)
			{
				Transform val = FindDeep(t.GetChild(i), name);
				if ((Object)(object)val != (Object)null)
				{
					return val;
				}
			}
			return null;
		}

		private void ScanItems()
		{
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			string value = _itemPrefix.Value;
			foreach (Poolee item2 in Object.FindObjectsOfType<Poolee>())
			{
				if ((Object)(object)item2 == (Object)null)
				{
					continue;
				}
				int instanceID = ((Object)item2).GetInstanceID();
				if (_itemSeen.Contains(instanceID))
				{
					continue;
				}
				SpawnableCrate spawnableCrate = item2.SpawnableCrate;
				string text = (((Object)(object)spawnableCrate != (Object)null && ((Scannable)spawnableCrate).Barcode != (Barcode)null) ? ((Scannable)spawnableCrate).Barcode.ID : null);
				switch (text)
				{
				case "somewhatmaxy.VannyMaskAR.Spawnable.FreddyMaskSpringlockRemote":
					_itemSeen.Add(instanceID);
					_itemRoots.Add(instanceID);
					try
					{
						AddWrench(item2);
					}
					catch (Exception ex)
					{
						((MelonBase)this).LoggerInstance.Warning("wrench: " + ex);
					}
					continue;
				case "somewhatmaxy.VannyMaskAR.Spawnable.FreddyMask":
					_itemSeen.Add(instanceID);
					_itemRoots.Add(instanceID);
					try
					{
						AddPanel(item2);
					}
					catch (Exception ex3)
					{
						((MelonBase)this).LoggerInstance.Warning("inhibitor: " + ex3);
					}
					continue;
				case "somewhatmaxy.VannyMaskAR.Spawnable.FreddyMaskNightVision":
					_itemSeen.Add(instanceID);
					try
					{
						_itemRoots.Add(instanceID);
						AddPallet(item2);
					}
					catch (Exception ex2)
					{
						((MelonBase)this).LoggerInstance.Warning("pallet: " + ex2);
					}
					continue;
				}
				try
				{
					if ((Object)(object)((Component)item2).GetComponentInChildren<RigManager>(true) != (Object)null || (Object)(object)((Component)item2).GetComponentInParent<RigManager>(true) != (Object)null)
					{
						_itemSeen.Add(instanceID);
						continue;
					}
				}
				catch
				{
				}
				Transform val = FindDeep(((Component)item2).transform, "freddymaskart");
				if ((Object)(object)val == (Object)null && text == null)
				{
					continue;
				}
				int num = -1;
				try
				{
					MeshFilter val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<MeshFilter>() : null);
					if ((Object)(object)val2 != (Object)null && (Object)(object)val2.sharedMesh != (Object)null)
					{
						num = val2.sharedMesh.vertexCount;
					}
				}
				catch
				{
				}
				_itemSeen.Add(instanceID);
				bool flag = ((text == null) ? (num == 11436 && ((Object)item2).name.IndexOf("Mask", StringComparison.OrdinalIgnoreCase) >= 0) : (text == "somewhatmaxy.VannyMaskAR.Spawnable.FreddyMaskNoSpringlocks" || text.StartsWith(value, StringComparison.Ordinal)));
				if ((Object)(object)val != (Object)null)
				{
					((MelonBase)this).LoggerInstance.Msg($"mask candidate: '{((Object)item2).name}' code={text} verts={num} ours={flag}");
				}
				if (flag)
				{
					Item item = new Item
					{
						poolee = item2,
						rb = (((Component)item2).GetComponent<Rigidbody>() ?? ((Component)item2).GetComponentInChildren<Rigidbody>()),
						art = val,
						artRot = (((Object)(object)val != (Object)null) ? val.localRotation : Quaternion.identity),
						col = FindDeep(((Component)item2).transform, "freddymaskColliderNormal")
					};
					if ((Object)(object)val != (Object)null)
					{
						item.mr = ((Component)val).GetComponent<Renderer>();
					}
					if ((Object)(object)item.col != (Object)null)
					{
						item.grip = ((Component)item.col).GetComponent<Grip>();
					}
					item.maskoff = FindDeep(((Component)item2).transform, "maskoff");
					item.maskT = FindDeep(((Component)item2).transform, "mask");
					try
					{
						LogForcePull(((Component)item2).transform);
					}
					catch (Exception ex4)
					{
						((MelonBase)this).LoggerInstance.Warning("forcepull diag: " + ex4.Message);
					}
					if ((Object)(object)item.col != (Object)null)
					{
						item.colRot = item.col.localRotation;
					}
					PreloadAmbience();
					_items.Add(item);
					_itemRoots.Add(instanceID);
					try
					{
						ApplyGlow(item);
					}
					catch (Exception ex5)
					{
						((MelonBase)this).LoggerInstance.Warning("glow: " + ex5.Message);
					}
					try
					{
						AddForcePull(item.col, item.poolee, "mask");
					}
					catch (Exception ex6)
					{
						((MelonBase)this).LoggerInstance.Warning("force pull: " + ex6);
					}
					((MelonBase)this).LoggerInstance.Msg($"Vanny mask spawned ({text}): rb={(Object)(object)item.rb != (Object)null} art={(Object)(object)item.art != (Object)null} collider={(Object)(object)item.col != (Object)null}. Grab it and put it on your face.");
				}
			}
		}

		private void UpdateItems(Transform cam, float dt)
		{
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0526: Unknown result type (might be due to invalid IL or missing references)
			//IL_052b: Unknown result type (might be due to invalid IL or missing references)
			//IL_053b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0540: Unknown result type (might be due to invalid IL or missing references)
			//IL_0545: Unknown result type (might be due to invalid IL or missing references)
			//IL_0575: Unknown result type (might be due to invalid IL or missing references)
			//IL_058e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0593: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b3: Unknown result type (might be due to invalid IL or missing references)
			if (Time.unscaledTime >= _nextItemScan)
			{
				_nextItemScan = Time.unscaledTime + 0.7f;
				try
				{
					ScanItems();
				}
				catch (Exception ex)
				{
					((MelonBase)this).LoggerInstance.Warning("item scan: " + ex.Message);
				}
			}
			try
			{
				if (_inhTest.Value && Input.GetKeyDown((KeyCode)290))
				{
					_testInh = !_testInh;
					((MelonBase)this).LoggerInstance.Msg("inhibitor test toggle " + (_testInh ? "ON" : "OFF"));
				}
			}
			catch
			{
			}
			InhibitorVrToggle(cam);
			UpdatePuzzle(cam, dt);
			UpdatePallets(cam, dt);
			UpdateHud(cam, dt);
			_blurb.Update(dt);
			for (int num = _items.Count - 1; num >= 0; num--)
			{
				Item item = _items[num];
				if ((Object)(object)item.poolee == (Object)null || ((Il2CppObjectBase)item.poolee).WasCollected || (Object)(object)item.rb == (Object)null || ((Il2CppObjectBase)item.rb).WasCollected)
				{
					if (item.wornByThis && _worn)
					{
						SetWorn(on: false, instant: true);
					}
					_items.RemoveAt(num);
				}
				else
				{
					bool flag = false;
					try
					{
						flag = Live(item) && (HoldLockedKin(item) || (item.rb.isKinematic && Vector3.Distance(cam.position, ((Component)item.poolee).transform.position) < (item.wornByThis ? _nearHead.Value : 0.4f) && WornByMe(item, cam)));
					}
					catch
					{
					}
					item.kin = flag;
					try
					{
						ApplyMaskLock(item);
					}
					catch (Exception ex2)
					{
						((MelonBase)this).LoggerInstance.Warning("mask lock: " + ex2.Message);
					}
					try
					{
						WatchPutOn(item, cam);
					}
					catch (Exception ex3)
					{
						((MelonBase)this).LoggerInstance.Warning("put-on watch: " + ex3.Message);
					}
					if (item.dumpAt > 0f && Time.unscaledTime >= item.dumpAt)
					{
						item.dumpAt = -1f;
						try
						{
							DumpState(item);
						}
						catch (Exception ex4)
						{
							((MelonBase)this).LoggerInstance.Warning("dump: " + ex4.Message);
						}
					}
					if (item.snatchAt > 0f && Time.unscaledTime >= item.snatchAt)
					{
						Hand snatchHand = item.snatchHand;
						item.snatchAt = -1f;
						item.snatchHand = null;
						if (!flag)
						{
							Snatch(item, snatchHand, "take-off");
						}
					}
					if (item.lockedMine && item.wornByThis)
					{
						if (GrabbedAtFace(item, cam))
						{
							Deny();
						}
					}
					else
					{
						item.watching = false;
					}
					if (flag && item.wornByThis && HandAtFacePressed(cam))
					{
						if (item.locked)
						{
							Deny();
						}
						else
						{
							((MelonBase)this).LoggerInstance.Msg("take-off gesture (trigger at face)");
							try
							{
								DumpState(item);
							}
							catch
							{
							}
							if ((Object)(object)item.maskoff != (Object)null)
							{
								((Component)item.maskoff).gameObject.SetActive(true);
							}
							if ((Object)(object)_pressHand != (Object)null)
							{
								item.snatchHand = _pressHand;
								item.snatchAt = Time.unscaledTime + 0.15f;
							}
						}
					}
					if (item.ignored.Count > 0 && !flag && !item.wornByThis && (Vector3.Distance(cam.position, ((Component)item.poolee).transform.position) > 0.45f || Time.unscaledTime > item.restoreAt))
					{
						foreach (var (val, val2) in item.ignored)
						{
							try
							{
								if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null && !((Il2CppObjectBase)val).WasCollected && !((Il2CppObjectBase)val2).WasCollected)
								{
									Physics.IgnoreCollision(val, val2, false);
								}
							}
							catch
							{
							}
						}
						item.ignored.Clear();
						((MelonBase)this).LoggerInstance.Msg("mask collisions restored");
					}
					if (flag && !item.wornByThis && _worn && DonorWorn(item) && !_items.Exists((Item o) => o.wornByThis))
					{
						item.wornByThis = true;
						((MelonBase)this).LoggerInstance.Msg("Vanny mask found again on your head (re-scan)");
						try
						{
							IgnoreBody(item, cam);
						}
						catch (Exception ex5)
						{
							((MelonBase)this).LoggerInstance.Warning("ignore-collision: " + ex5.Message);
						}
					}
					else if (flag && !item.wornByThis)
					{
						if (item.since < 0f)
						{
							item.since = Time.unscaledTime;
						}
						if (Time.unscaledTime - item.since >= _wearDelay.Value && !_worn)
						{
							item.wornByThis = true;
							try
							{
								item.qRel = Quaternion.Inverse(cam.rotation) * ((Component)item.poolee).transform.rotation;
								item.haveQ = true;
								((MelonBase)this).LoggerInstance.Msg($"donor pose rel. to head cam: euler={((Quaternion)(ref item.qRel)).eulerAngles} pos={Quaternion.Inverse(cam.rotation) * (((Component)item.poolee).transform.position - cam.position)}");
							}
							catch
							{
							}
							((MelonBase)this).LoggerInstance.Msg("Vanny mask worn (donor equipped it)");
							item.dumpAt = Time.unscaledTime + 1.5f;
							try
							{
								IgnoreBody(item, cam);
							}
							catch (Exception ex6)
							{
								((MelonBase)this).LoggerInstance.Warning("ignore-collision: " + ex6.Message);
							}
							SetWorn(on: true, instant: false);
						}
					}
					else if (!flag && item.wornByThis)
					{
						item.wornByThis = false;
						item.since = -1f;
						((MelonBase)this).LoggerInstance.Msg("Vanny mask taken off");
						item.restoreAt = Time.unscaledTime + 6f;
						if (_worn)
						{
							SetWorn(on: false, !Live(item));
						}
					}
					else if (!flag)
					{
						item.since = -1f;
					}
				}
			}
			if (_worn && !_items.Exists((Item o) => o.wornByThis))
			{
				if (_orphanAt < 0f)
				{
					_orphanAt = Time.unscaledTime + 2f;
				}
				else if (Time.unscaledTime >= _orphanAt)
				{
					_orphanAt = -1f;
					((MelonBase)this).LoggerInstance.Msg("worn mask is gone");
					SetWorn(on: false, instant: true);
				}
			}
			else
			{
				_orphanAt = -1f;
			}
		}

		public override void OnLateUpdate()
		{
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: 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_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			HoldPanels();
			if (!_enabled.Value || _items.Count == 0)
			{
				return;
			}
			Transform val = Cam();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			foreach (Item item in _items)
			{
				if ((Object)(object)item.poolee == (Object)null || ((Il2CppObjectBase)item.poolee).WasCollected)
				{
					continue;
				}
				try
				{
					if ((Object)(object)item.mr != (Object)null && !((Il2CppObjectBase)item.mr).WasCollected && item.mr.enabled == item.kin)
					{
						item.mr.enabled = !item.kin;
					}
				}
				catch
				{
				}
				if (!item.kin)
				{
					continue;
				}
				try
				{
					Transform transform = ((Component)item.poolee).transform;
					if ((Object)(object)transform.parent != (Object)null)
					{
						transform.SetParent((Transform)null, true);
					}
					transform.rotation = val.rotation * Quaternion.Euler(0f, 180f, 0f);
					transform.localScale = Vector3.one;
					Transform[] array = (Transform[])(object)new Transform[2] { item.art, item.col };
					foreach (Transform val2 in array)
					{
						if (!((Object)(object)val2 == (Object)null) && !((Il2CppObjectBase)val2).WasCollected)
						{
							val2.localScale = new Vector3(39.549f, 39.549f, 39.549f);
							val2.localPosition = ArtLocalPos;
							val2.localRotation = (((Object)(object)val2 == (Object)(object)item.art) ? item.artRot : item.colRot);
						}
					}
					Vector3 val3 = val.position + val.forward * _wearForward.Value + val.up * _wearUp.Value;
					transform.position = val3 - transform.rotation * EyeInRoot;
				}
				catch (Exception ex)
				{
					((MelonBase)this).LoggerInstance.Warning("align: " + ex.Message);
				}
			}
		}

		private bool WornByMe(Item it, Transform cam)
		{
			Transform transform = ((Component)it.poolee).transform;
			if ((Object)(object)transform.parent == (Object)null)
			{
				return true;
			}
			RigManager componentInParent = ((Component)cam).GetComponentInParent<RigManager>();
			RigManager componentInParent2 = ((Component)transform).GetComponentInParent<RigManager>();
			if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent2 != (Object)null)
			{
				return (Object)(object)componentInParent2 == (Object)(object)componentInParent;
			}
			return false;
		}

		private void IgnoreBody(Item it, Transform cam)
		{
			RigManager componentInParent = ((Component)cam).GetComponentInParent<RigManager>();
			if ((Object)(object)componentInParent == (Object)null)
			{
				return;
			}
			Il2CppArrayBase<Collider> componentsInChildren = ((Component)it.poolee).GetComponentsInChildren<Collider>(true);
			int num = 0;
			foreach (Collider componentsInChild in ((Component)componentInParent).GetComponentsInChildren<Collider>(true))
			{
				foreach (Collider item in componentsInChildren)
				{
					if ((Object)(object)componentsInChild != (Object)null && (Object)(object)item != (Object)null && (Object)(object)componentsInChild != (Object)(object)item)
					{
						Physics.IgnoreCollision(componentsInChild, item, true);
						it.ignored.Add((componentsInChild, item));
						num++;
					}
				}
			}
			((MelonBase)this).LoggerInstance.Msg($"mask ignores {num} body collider pairs");
		}

		private void Snatch(Item it, Hand hand, string why)
		{
			try
			{
				Grip val = (((Object)(object)it.col != (Object)null) ? ((Component)it.col).GetComponent<Grip>() : null);
				if (!((Object)(object)val == (Object)null) && !((Object)(object)hand == (Object)null))
				{
					val.Snatch(hand, true);
					((MelonBase)this).LoggerInstance.Msg("snatch (" + why + ") -> " + ((Object)hand).name);
				}
			}
			catch (Exception ex)
			{
				((MelonBase)this).LoggerInstance.Warning("snatch: " + ex.Message);
			}
		}

		private static byte[] Res(string name)
		{
			using Stream stream = typeof(Mod).Assembly.GetManifestResourceStream("res." + name);
			if (stream == null)
			{
				return null;
			}
			using MemoryStream memoryStream = new MemoryStream();
			stream.CopyTo(memoryStream);
			return memoryStream.ToArray();
		}

		private Texture2D ResTex(string name)
		{
			//IL_0033: 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_0041: Expected O, but got Unknown
			if (_resTex.TryGetValue(name, out var value) && (Object)(object)value != (Object)null && !((Il2CppObjectBase)value).WasCollected)
			{
				return value;
			}
			byte[] array = Res(name);
			if (array == null)
			{
				return null;
			}
			value = new Texture2D(2, 2, (TextureFormat)4, false)
			{
				hideFlags = (HideFlags)32
			};
			ImageConversion.LoadImage(value, Il2CppStructArray<byte>.op_Implicit(array));
			_resTex[name] = value;
			return value;
		}

		private AudioClip ResClip(string name)
		{
			if (_resClip.TryGetValue(name, out var value) && (Object)(object)value != (Object)null && !((Il2CppObjectBase)value).WasCollected)
			{
				return value;
			}
			byte[] array = Res(name);
			if (array == null)
			{
				((MelonBase)this).LoggerInstance.Warning("missing sound " + name);
				return null;
			}
			try
			{
				int i = 12;
				int num = 2;
				int num2 = 44100;
				int num3 = 16;
				int num4 = 1;
				int num5 = 0;
				int num6 = 0;
				int num7;
				for (; i + 8 <= array.Length; i += 8 + num7 + (num7 & 1))
				{
					string text = Encoding.ASCII.GetString(array, i, 4);
					num7 = BitConverter.ToInt32(array, i + 4);
					if (text == "fmt ")
					{
						num4 = BitConverter.ToInt16(array, i + 8);
						num = BitConverter.ToInt16(array, i + 10);
						num2 = BitConverter.ToInt32(array, i + 12);
						num3 = BitConverter.ToInt16(array, i + 22);
					}
					else if (text == "data")
					{
						num5 = i + 8;
						num6 = Math.Min(num7, array.Length - num5);
						break;
					}
				}
				int num8 = num6 / (num3 / 8);
				float[] array2 = new float[num8];
				if (num3 == 16)
				{
					for (int j = 0; j < num8; j++)
					{
						array2[j] = (float)BitConverter.ToInt16(array, num5 + j * 2) / 32768f;
					}
				}
				else
				{
					if (num3 != 32 || num4 != 3)
					{
						throw new Exception($"unsupported wav {num3} bit fmt {num4}");
					}
					for (int k = 0; k < num8; k++)
					{
						array2[k] = BitConverter.ToSingle(array, num5 + k * 4);
					}
				}
				value = AudioClip.Create(name, num8 / num, num, num2, false);
				value.SetData(Il2CppStructArray<float>.op_Implicit(array2), 0);
				((Object)value).hideFlags = (HideFlags)32;
				_resClip[name] = value;
				return value;
			}
			catch (Exception ex)
			{
				((MelonBase)this).LoggerInstance.Warning("wav " + name + ": " + ex.Message);
				return null;
			}
		}

		private AudioClip ResClipOpt(string n)
		{
			if (!_resClip.TryGetValue(n, out var value) || !((Object)(object)value != (Object)null) || ((Il2CppObjectBase)value).WasCollected)
			{
				if (Res(n) != null)
				{
					return ResClip(n);
				}
				return null;
			}
			return value;
		}

		private void Play3D(string name, Vector3 pos, float gain = 1f)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			try
			{
				AudioClip val = ResClipOpt(name);
				if (!((Object)(object)val == (Object)null))
				{
					GameObject val2 = new GameObject("VannySfx3D");
					val2.transform.position = pos;
					AudioSource obj = val2.AddComponent<AudioSource>();
					obj.clip = val;
					obj.spatialBlend = 1f;
					obj.minDistance = 0.8f;
					obj.maxDistance = 14f;
					obj.volume = Mathf.Clamp01(_sfxVol.Value * gain);
					obj.Play();
					Object.Destroy((Object)val2, val.length + 0.5f);
				}
			}
			catch (Exception ex)
			{
				((MelonBase)this).LoggerInstance.Warning("sfx3d: " + ex.Message);
			}
		}

		private static float Keyed(float[] k, float t)
		{
			if (t <= k[0])
			{
				return k[1];
			}
			for (int i = 2; i < k.Length; i += 2)
			{
				if (t < k[i])
				{
					float num = (t - k[i - 2]) / (k[i] - k[i - 2]);
					return Mathf.Lerp(k[i - 1], k[i + 1], num * num * (3f - 2f * num));
				}
			}
			return k[^1];
		}

		private Material UiMat(Texture2D t, int queue)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			Material val = new Material(_helpi.Ui)
			{
				hideFlags = (HideFlags)32
			};
			if ((Object)(object)t != (Object)null)
			{
				val.SetTexture("_MainTex", (Texture)(object)t);
			}
			val.SetColor("_Color", Color.white);
			val.SetFloat("_Reveal", 1000f);
			val.renderQueue = queue;
			return val;
		}

		private static void Alpha(Material m, float a)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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)
			Color color = m.GetColor("_Color");
			color.a = Mathf.Clamp01(a);
			m.SetColor("_Color", color);
		}

		private static Renderer UiQuad(Transform parent, string n, Material m, Vector3 pos, Vector3 scale)
		{
			//IL_0052: 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)
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)5);
			((Object)obj).name = n;
			Collider component = obj.GetComponent<Collider>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			Renderer component2 = obj.GetComponent<Renderer>();
			component2.sharedMaterial = m;
			component2.shadowCastingMode = (ShadowCastingMode)0;
			component2.receiveShadows = false;
			obj.transform.SetParent(parent, false);
			obj.transform.localPosition = pos;
			obj.transform.localScale = scale;
			return component2;
		}

		private bool BuildHud(Transform cam)
		{
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Expected O, but got Unknown
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Expected O, but got Unknown
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Expected O, but got Unknown
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_hudRoot != (Object)null && !((Il2CppObjectBase)_hudRoot).WasCollected)
			{
				return true;
			}
			string[] array = new string[7] { "inh_g1.png", "inh_g2.png", "inh_g3.png", "inh_g4.png", "inh_g5.png", "hud_outline.png", "inh_stop.png" };
			Texture2D[] array2 = (Texture2D[])(object)new Texture2D[array.Length];
			for (int i = 0; i < array.Length; i++)
			{
				array2[i] = ResTex(array[i]);
				if ((Object)(object)array2[i] == (Object)null)
				{
					return false;
				}
				((Texture)array2[i]).wrapMode = (TextureWrapMode)1;
			}
			string[] array3 = new string[4] { "inh_backing.png", "hud_eyes.png", "hud_eyes2.png", "hud_outline.png" };
			Texture2D[] array4 = (Texture2D[])(object)new Texture2D[array3.Length];
			for (int j = 0; j < array3.Length; j++)
			{
				array4[j] = ResTex(array3[j]);
				if ((Object)(object)array4[j] == (Object)null)
				{
					return false;
				}
				((Texture)array4[j]).wrapMode = (TextureWrapMode)1;
			}
			_hudRoot = new GameObject("VannyHudIcon")
			{
				hideFlags = (HideFlags)32
			};
			_hudRoot.transform.SetParent(cam, false);
			_hudRoot.transform.localPosition = new Vector3(-0.2f, -0.15f, 0.55f);
			_hudRoot.transform.localScale = Vector3.one * 0.12f;
			_hudBlocked = new GameObject("blocked");
			_hudBlocked.transform.SetParent(_hudRoot.transform, false);
			_hudLoop = (Material[])(object)new Material[array.Length];
			for (int k = 0; k < array.Length; k++)
			{
				_hudLoop[k] = UiMat(array2[k], 4020 + ((k >= 5) ? (k - 4) : 0));
				Renderer val = UiQuad(_hudBlocked.transform, "layer" + k, _hudLoop[k], Vector3.zero, Vector3.one);
				if (k == 5)
				{
					((Component)val).GetComponent<MeshFilter>().sharedMesh = ShearQuad();
				}
			}
			_hudNormal = new GameObject("normal");
			_hudNormal.transform.SetParent(_hudRoot.transform, false);
			_hudIdle = (Material[])(object)new Material[array3.Length];
			for (int l = 0; l < array3.Length; l++)
			{
				_hudIdle[l] = UiMat(array4[l], 4020 + l);
				UiQuad(_hudNormal.transform, "layer" + l, _hudIdle[l], Vector3.zero, Vector3.one);
			}
			return true;
		}

		private Mesh ShearQuad()
		{
			//IL_0041: 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_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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			_shearV = new Il2CppStructArray<Vector3>(4L);
			Il2CppStructArray<Vector2> val = new Il2CppStructArray<Vector2>(4L);
			Il2CppStructArray<int> val2 = new Il2CppStructArray<int>(6L);
			for (int i = 0; i < 4; i++)
			{
				((Il2CppArrayBase<Vector3>)(object)_shearV)[i] = new Vector3((float)(i & 1) - 0.5f, (float)(i >> 1) - 0.5f, 0f);
				((Il2CppArrayBase<Vector2>)(object)val)[i] = new Vector2((float)(i & 1), (float)(i >> 1));
			}
			int[] array = new int[6] { 0, 2, 1, 2, 3, 1 };
			for (int j = 0; j < 6; j++)
			{
				((Il2CppArrayBase<int>)(object)val2)[j] = array[j];
			}
			_shearMesh = new Mesh
			{
				name = "VannyShearQuad",
				hideFlags = (HideFlags)32
			};
			_shearMesh.vertices = _shearV;
			_shearMesh.uv = val;
			_shearMesh.triangles = val2;
			_shearMesh.RecalculateBounds();
			_shearK = 0f;
			return _shearMesh;
		}

		private void Shear(float degrees)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Tan(degrees * ((float)Math.PI / 180f));
			if (!((Object)(object)_shearMesh == (Object)null) && !((Il2CppObjectBase)_shearMesh).WasCollected && !(Mathf.Abs(num - _shearK) < 0.002f))
			{
				_shearK = num;
				for (int i = 0; i < 4; i++)
				{
					float num2 = (float)(i >> 1) - 0.5f;
					((Il2CppArrayBase<Vector3>)(object)_shearV)[i] = new Vector3((float)(i & 1) - 0.5f - num * num2, num2, 0f);
				}
				_shearMesh.vertices = _shearV;
			}
		}

		private void HideHud()
		{
			if ((Object)(object)_hudRoot != (Object)null && !((Il2CppObjectBase)_hudRoot).WasCollected && _hudRoot.activeSelf)
			{
				_hudRoot.SetActive(false);
			}
		}

		private void UpdateHud(Transform cam, float dt)
		{
			float unscaledTime = Time.unscaledTime;
			if (_worn)
			{
				if (_hudWornAt < 0f)
				{
					_hudWornAt = unscaledTime;
				}
				if (unscaledTime - _hudWornAt >= 1.1f)
				{
					_hudUntil = unscaledTime + 2f;
				}
			}
			else
			{
				_hudWornAt = -1f;
			}
			bool inhibitorActive = InhibitorActive;
			float num = (inhibitorActive ? 0f : Mathf.Clamp01((_hudUntil - unscaledTime) / 0.5f));
			if (!inhibitorActive)
			{
				_hudLoopT = 0f;
			}
			if (!inhibitorActive && num <= 0f)
			{
				HideHud();
			}
			else
			{
				if (!Load() || (Object)(object)_helpi.Ui == (Object)null || !BuildHud(cam))
				{
					return;
				}
				if (!_hudRoot.activeSelf)
				{
					_hudRoot.SetActive(true);
				}
				if ((Object)(object)_hudRoot.transform.parent != (Object)(object)cam)
				{
					_hudRoot.transform.SetParent(cam, false);
				}
				if (_hudBlocked.activeSelf != inhibitorActive)
				{
					_hudBlocked.SetActive(inhibitorActive);
				}
				if (_hudNormal.activeSelf == inhibitorActive)
				{
					_hudNormal.SetActive(!inhibitorActive);
				}
				if (inhibitorActive)
				{
					_hudLoopT = Mathf.Repeat(_hudLoopT + dt, 0.8f);
					for (int i = 0; i < _hudLoop.Length; i++)
					{
						Alpha(_hudLoop[i], Keyed(HudKeys[i], _hudLoopT));
					}
					Shear(10.701f * _hudLoopT / 0.8f);
				}
				else
				{
					for (int j = 0; j < _hudIdle.Length; j++)
					{
						Alpha(_hudIdle[j], HudIdleAlpha[j] * num);
					}
				}
			}
		}

		private void InhibitorVrToggle(Transform cam)
		{
			//IL_0097: 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)
			if (!_inhTest.Value || !_worn)
			{
				return;
			}
			RigManager val = null;
			try
			{
				val = ((Component)cam).GetComponentInParent<RigManager>();
			}
			catch
			{
			}
			if ((Object)(object)val == (Object)null || (Object)(object)val.physicsRig == (Object)null)
			{
				return;
			}
			Hand[] array = (Hand[])(object)new Hand[2]
			{
				val.physicsRig.leftHand,
				val.physicsRig.rightHand
			};
			foreach (Hand val2 in array)
			{
				BaseController val3 = (((Object)(object)val2 != (Object)null) ? val2.Controller : null);
				if (!((Object)(object)val3 == (Object)null) && val3.GetAButtonDown() && Vector3.Distance(((Component)val2).transform.position, cam.position) < 0.3f)
				{
					_testInh = !_testInh;
					((MelonBase)this).LoggerInstance.Msg("inhibitor test toggle " + (_testInh ? "ON" : "OFF") + " (A/X at face)");
				}
			}
		}

		private void Deny()
		{
			if (Time.unscaledTime < _nextDeny)
			{
				return;
			}
			if (!InhibitorActive)
			{
				_nextDeny = Time.unscaledTime + 1.2f;
				((MelonBase)this).LoggerInstance.Msg("phasing: the mask cannot be removed inside a pallet");
				PlaySfx(ResClipOpt("cannotUse2.wav"));
				return;
			}
			_nextDeny = Time.unscaledTime + 0.4f;
			_denyCount++;
			((MelonBase)this).LoggerInstance.Msg($"the AR inhibitor is active: the mask cannot be removed (attempt {_denyCount})");
			if ((_denyCount & 1) == 1)
			{
				PlaySfx(ResClipOpt("cannotUse2.wav"));
			}
			if (Time.unscaledTime >= _nextInhBlurb)
			{
				_nextInhBlurb = Time.unscaledTime + 10f;
				ShowBlurb("blurb_inhibitor.png", 4f);
			}
		}

		private void DenyPutOn()
		{
			if (!(Time.unscaledTime < _nextDeny))
			{
				_nextDeny = Time.unscaledTime + 0.4f;
				((MelonBase)this).LoggerInstance.Msg("the AR inhibitor is active: the mask cannot be put on");
				PlaySfx(ResClipOpt("cannotUse2.wav"));
				if (Time.unscaledTime >= _nextInhBlurb)
				{
					_nextInhBlurb = Time.unscaledTime + 10f;
					ShowBlurb("blurb_inhibitor.png", 4f);
				}
			}
		}

		private void ShowBlurb(string message, float seconds)
		{
			try
			{
				Transform val = Cam();
				if (!((Object)(object)val == (Object)null) && Load() && !((Object)(object)_helpi.Ui == (Object)null))
				{
					_blurb.Show(val, _helpi.Ui, ResTex(message), ResTex("blurb_bar_bg.png"), ResTex("blurb_bar.png"), seconds);
				}
			}
			catch (Exception ex)
			{
				((MelonBase)this).LoggerInstance.Warning("blurb: " + ex.Message);
			}
		}

		private bool GrabbedAtFace(Item it, Transform cam)
		{
			bool flag = false;
			try
			{
				flag = (Object)(object)it.grip != (Object)null && !((Il2CppObjectBase)it.grip).WasCollected && it.grip.HasAttachedHands();
			}
			catch
			{
			}
			bool flag2 = false;
			bool flag3 = false;
			RigManager val = null;
			try
			{
				val = ((Component)cam).GetComponentInParent<RigManager>();
			}
			catch
			{
			}
			if ((Object)(object)val != (Object)null && (Object)(object)val.physicsRig != (Object)null)
			{
				flag2 = SqueezeAtFace(val.physicsRig.leftHand, cam);
				flag3 = SqueezeAtFace(val.physicsRig.rightHand, cam);
			}
			bool result = it.watching && ((flag && !it.gripHeld) || (flag2 && !it.sqL) || (flag3 && !it.sqR));
			it.watching = true;
			it.gripHeld = flag;
			it.sqL = flag2;
			it.sqR = flag3;
			return result;
		}

		private static bool SqueezeAtFace(Hand h, Transform cam)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			BaseController val = (((Object)(object)h != (Object)null) ? h.Controller : null);
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			try
			{
				return val.GetGrabbedState() && Vector3.Distance(((Component)h).transform.position, cam.position) < 0.25f;
			}
			catch
			{
				return false;
			}
		}

		private bool HandAtFacePressed(Transform cam)
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			_pressHand = null;
			RigManager val = null;
			try
			{
				val = ((Component)cam).GetComponentInParent<RigManager>();
			}
			catch
			{
			}
			if ((Object)(object)val == (Object)null || (Object)(object)val.physicsRig == (Object)null)
			{
				return false;
			}
			Hand[] array = (Hand[])(object)new Hand[2]
			{
				val.physicsRig.leftHand,
				val.physicsRig.rightHand
			};
			foreach (Hand val2 in array)
			{
				BaseController val3 = (((Object)(object)val2 != (Object)null) ? val2.Controller : null);
				if (!((Object)(object)val3 == (Object)null) && val3.GetPrimaryInteractionButtonDown() && Vector3.Distance(((Component)val2).transform.position, cam.position) < 0.25f)
				{
					_pressHand = val2;
					return true;
				}
			}
			return false;
		}

		private void DumpState(Item it)
		{
			Collider val = (((Object)(object)it.col != (Object)null) ? ((Component)it.col).GetComponent<Collider>() : null);
			((MelonBase)this).LoggerInstance.Msg($"state: root kin={it.rb.isKinematic} | mask[{P(it.maskT)}] maskoff[{P(it.maskoff)}] col[{P(it.col)}] colTrigger={(((Object)(object)val != (Object)null) ? val.isTrigger.ToString() : "?")} colEnabled={(((Object)(object)val != (Object)null) ? val.enabled.ToString() : "?")} layer={(((Object)(object)it.col != (Object)null) ? ((Component)it.col).gameObject.layer : (-1))} parent={(((Object)(object)((Component)it.poolee).transform.parent != (Object)null) ? ((Object)((Component)it.poolee).transform.parent).name : "none")}");
			static string P(Transform t)
			{
				if (!((Object)(object)t == (Object)null))
				{
					return $"{((Object)t).name} self={((Component)t).gameObject.activeSelf} h={((Component)t).gameObject.activeInHierarchy}";
				}
				return "null";
			}
		}

		private void AddForcePull(Transform colT, Poolee root, string tag)
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)colT == (Object)null)
			{
				return;
			}
			GameObject gameObject = ((Component)colT).gameObject;
			Grip component = gameObject.GetComponent<Grip>();
			if ((Object)(object)component == (Object)null)
			{
				((MelonBase)this).LoggerInstance.Warning("force pull: no grip on the " + tag + " collider");
				return;
			}
			if ((Object)(object)gameObject.GetComponent<ForcePullGrip>() != (Object)null)
			{
				((MelonBase)this).LoggerInstance.Msg("force pull: " + tag + " grip already has one");
				return;
			}
			bool activeSelf = gameObject.activeSelf;
			gameObject.SetActive(false);
			ForcePullGrip val = gameObject.AddComponent<ForcePullGrip>();
			val._grip = component;
			val.maxForce = 250f;
			val.maxSpeed = float.PositiveInfinity;
			try
			{
				component.gripOptions = (InteractionOptions)(component.gripOptions | 4);
				component.gripDistance = float.PositiveInfinity;
			}
			catch (Exception ex)
			{
				((MelonBase)this).LoggerInstance.Warning("grip tweak: " + ex.Message);
			}
			gameObject.SetActive(activeSelf);
			try
			{
				InteractableHost val2 = ((Component)root).GetComponent<InteractableHost>() ?? ((Component)root).GetComponentInChildren<InteractableHost>();
				if ((Object)(object)val2 != (Object)null)
				{
					try
					{
						if (val2._fpGrips != null && !val2._fpGrips.Contains(val))
						{
							val2._fpGrips.Add(val);
						}
					}
					catch (Exception ex2)
					{
						((MelonBase)this).LoggerInstance.Warning("fpGrips: " + ex2.Message);
					}
					try
					{
						val2.EnableFarHover();
					}
					catch (Exception ex3)
					{
						((MelonBase)this).LoggerInstance.Warning("EnableFarHover: " + ex3.Message);
					}
					((MelonBase)this).LoggerInstance.Msg($"force-grab ({tag}): host fpGrips={((val2._fpGrips != null) ? val2._fpGrips.Count : (-1))} farHover={val2.IsFarHoverEnabled}");
				}
				else
				{
					((MelonBase)this).LoggerInstance.Warning("force pull: no InteractableHost on " + tag);
				}
			}
			catch (Exception ex4)
			{
				((MelonBase)this).LoggerInstance.Warning("force pull host: " + ex4.Message);
			}
			((MelonBase)this).LoggerInstance.Msg("force-grab: ForcePullGrip added to the " + tag + " grip");
		}

		private void LogForcePull(Transform root)
		{
			if (_fpLogged)
			{
				return;
			}
			_fpLogged = true;
			Type typeFromHandle = typeof(ForcePullGrip);
			((MelonBase)this).LoggerInstance.Msg("ForcePullGrip props: " + string.Join(", ", Array.ConvertAll(typeFromHandle.GetProperties(), (PropertyInfo x) => x.PropertyType.Name + " " + x.Name)));
			foreach (ForcePullGrip item in Object.FindObjectsOfType<ForcePullGrip>())
			{
				if ((Object)(object)item == (Object)null)
				{
					continue;
				}
				((MelonBase)this).LoggerInstance.Msg("existing ForcePullGrip on " + PathOf(((Component)item).transform) + $" layer={((Component)item).gameObject.layer} collider={(((Object)(object)((Component)item).GetComponent<Collider>() != (Object)null) ? (((object)((Component)item).GetComponent<Collider>()).GetType().Name + " trigger=" + ((Component)item).GetComponent<Collider>().isTrigger) : "none")}");
				PropertyInfo[] properties = typeFromHandle.GetProperties();
				foreach (PropertyInfo propertyInfo in properties)
				{
					try
					{
						if (propertyInfo.GetIndexParameters().Length == 0 && propertyInfo.DeclaringType == typeFromHandle)
						{
							((MelonBase)this).LoggerInstance.Msg($"   {propertyInfo.Name} = {propertyInfo.GetValue(item)}");
						}
					}
					catch
					{
					}
				}
				break;
			}
		}

		private void ApplyGlow(Item it)
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Expected O, but got Unknown
			if ((Object)(object)_litSh == (Object)null && Load() && (Object)(object)_maskPrefab != (Object)null)
			{
				Renderer componentInChildren = _maskPrefab.GetComponentInChildren<Renderer>(true);
				if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.sharedMaterial != (Object)null)
				{
					_litSh = componentInChildren.sharedMaterial.shader;
				}
			}
			if ((Object)(object)_emisTex == (Object)null)
			{
				using Stream stream = typeof(Mod).Assembly.GetManifestResourceStream("vanny_emis");
				using MemoryStream memoryStream = new MemoryStream();
				stream.CopyTo(memoryStream);
				_emisTex = new Texture2D(2, 2, (TextureFormat)4, false)
				{
					hideFlags = (HideFlags)32
				};
				ImageConversion.LoadImage(_emisTex, Il2CppStructArray<byte>.op_Implicit(memoryStream.ToArray()));
			}
			if ((Object)(object)_litSh == (Object)null || (Object)(object)it.art == (Object)null)
			{
				((MelonBase)this).LoggerInstance.Warning("glow: shader or art missing");
				return;
			}
			Renderer component = ((Component)it.art).GetComponent<Renderer>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			Material sharedMaterial = component.sharedMaterial;
			if ((Object)(object)sharedMaterial != (Object)null && (Object)(object)sharedMaterial.shader == (Object)(object)_litSh && sharedMaterial.HasProperty("_Emis"))
			{
				return;
			}
			Material val = new Material(_litSh)
			{
				hideFlags = (HideFlags)32,
				renderQueue = 2990
			};
			Texture val2 = null;
			try
			{
				if ((Object)(object)sharedMaterial != (Object)null)
				{
					val2 = sharedMaterial.mainTexture;
				}
			}
			catch
			{
			}
			if ((Object)(object)val2 == (Object)null)
			{
				val2 = _maskBaseTex;
			}
			else
			{
				_maskBaseTex = val2;
			}
			val.SetTexture("_BaseMap", val2);
			val.SetTexture("_Emis", (Texture)(object)_emisTex);
			val.SetFloat("_EmisAmt", 2.2f);
			val.SetFloat("_Ambient", 0.7f);
			component.sharedMaterial = val;
			((MelonBase)this).LoggerInstance.Msg("LED glow material applied");
		}

		private static bool Live(Item it)
		{
			if ((Object)(object)it.poolee != (Object)null && !((Il2CppObjectBase)it.poolee).WasCollected)
			{
				return ((Component)it.poolee).gameObject.activeInHierarchy;
			}
			return false;
		}

		private static bool DonorWorn(Item it)
		{
			if (!((Object)(object)it.maskT != (Object)null) || ((Il2CppObjectBase)it.maskT).WasCollected)
			{
				return it.kin;
			}
			return ((Component)it.maskT).gameObject.activeSelf;
		}

		private static bool Usable(Collider c)
		{
			if ((Object)(object)c != (Object)null && !((Il2CppObjectBase)c).WasCollected && c.enabled)
			{
				return ((Component)c).gameObject.activeInHierarchy;
			}
			return false;
		}

		private bool HoldLockedKin(Item it)
		{
			if (!it.lockedMine || !Live(it) || !DonorWorn(it))
			{
				return false;
			}
			if (!it.rb.isKinematic)
			{
				it.rb.isKinematic = true;
			}
			return true;
		}

		private void ApplyPutOnLock(Item it)
		{
			if ((Object)(object)it.poolee == (Object)null || ((Il2CppObjectBase)it.poolee).WasCollected)
			{
				return;
			}
			if ((Object)(object)it.putOn == (Object)null || ((Il2CppObjectBase)it.putOn).WasCollected)
			{
				it.putOn = FindDeep(((Component)it.poolee).transform, "if False");
				if ((Object)(object)it.putOn == (Object)null)
				{
					return;
				}
				it.onScripts = Il2CppArrayBase<Behaviour>.op_Implicit(((Component)it.putOn).GetComponents<Behaviour>());
			}
			Behaviour[] onScripts;
			if (InhibitorActive && Live(it))
			{
				onScripts = it.onScripts;
				foreach (Behaviour val in onScripts)
				{
					if ((Object)(object)val != (Object)null && val.enabled)
					{
						val.enabled = false;
					}
				}
				return;
			}
			bool flag = false;
			onScripts = it.onScripts;
			foreach (Behaviour val2 in onScripts)
			{
				if ((Object)(object)val2 != (Object)null && !val2.enabled)
				{
					flag = true;
				}
			}
			if (!flag)
			{
				return;
			}
			((Component)it.putOn).gameObject.SetActive(false);
			onScripts = it.onScripts;
			foreach (Behaviour val3 in onScripts)
			{
				if ((Object)(object)val3 != (Object)null)
				{
					val3.enabled = true;
				}
			}
		}

		private void WatchPutOn(Item it, Transform cam)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			if (!InhibitorActive || it.kin || !Live(it) || (Object)(object)it.grip == (Object)null || ((Il2CppObjectBase)it.grip).WasCollected || !it.grip.HasAttachedHands())
			{
				it.putTried = false;
				return;
			}
			float num = Vector3.Distance(cam.position, ((Component)it.poolee).transform.position);
			if (num > 0.35f)
			{
				it.putTried = false;
			}
			else if (num < 0.25f && !it.putTried)
			{
				it.putTried = true;
				DenyPutOn();
			}
		}

		private void ApplyMaskLock(Item it)
		{
			ApplyPutOnLock(it);
			if ((Object)(object)it.col == (Object)null || ((Il2CppObjectBase)it.col).WasCollected || (Object)(object)it.maskoff == (Object)null || ((Il2CppObjectBase)it.maskoff).WasCollected)
			{
				return;
			}
			if ((Object)(object)it.gripCol == (Object)null)
			{
				it.gripCol = ((Component)it.col).GetComponent<Collider>();
			}
			if ((Object)(object)it.grip == (Object)null)
			{
				it.grip = ((Component)it.col).GetComponent<Grip>();
			}
			if (it.offScripts == null)
			{
				it.offScripts = Il2CppArrayBase<Behaviour>.op_Implicit(((Component)it.maskoff).GetComponents<Behaviour>());
			}
			int num;
			int num2;
			if (Live(it))
			{
				num = (DonorWorn(it) ? 1 : 0);
				if (num != 0)
				{
					num2 = (it.kin ? 1 : 0);
					goto IL_00b7;
				}
			}
			else
			{
				num = 0;
			}
			num2 = 0;
			goto IL_00b7;
			IL_00b7:
			bool flag = (byte)num2 != 0;
			bool flag2 = num != 0 && !it.kin && InhibitorActive && (Object)(object)((Component)it.poolee).GetComponentInParent<RigManager>() != (Object)null;
			bool flag3 = (flag && (InhibitorActive || PhaseLocked)) || flag2;
			bool locked = it.locked;
			it.locked = flag3;
			it.lockedMine = flag3 && flag;
			if (flag3)
			{
				Behaviour[] offScripts = it.offScripts;
				foreach (Behaviour val in offScripts)
				{
					if ((Object)(object)val != (Object)null && val.enabled)
					{
						val.enabled = false;
					}
				}
				if (((Component)it.maskoff).gameObject.activeSelf)
				{
					((Component)it.maskoff).gameObject.SetActive(false);
				}
				if ((Object)(object)it.gripCol != (Object)null && it.gripCol.enabled)
				{
					it.gripCol.enabled = false;
					_lockedCols.Add(((Object)it.gripCol).GetInstanceID());
				}
				if ((Object)(object)it.grip != (Object)null && it.grip.HasAttachedHands())
				{
					it.grip.ForceDetach();
					((MelonBase)this).LoggerInstance.Msg("mask lock: a hand was thrown off");
				}
				it.snatchAt = -1f;
				it.snatchHand = null;
			}
			else
			{
				bool flag4 = false;
				Behaviour[] offScripts = it.offScripts;
				foreach (Behaviour val2 in offScripts)
				{
					if ((Object)(object)val2 != (Object)null && !val2.enabled)
					{
						flag4 = true;
					}
				}
				if (flag4)
				{
					((Component)it.maskoff).gameObject.SetActive(false);
					offScripts = it.offScripts;
					foreach (Behaviour val3 in offScripts)
					{
						if ((Object)(object)val3 != (Object)null)
						{
							val3.enabled = true;
						}
					}
				}
				if ((Object)(object)it.gripCol != (Object)null && _lockedCols.Remove(((Object)it.gripCol).GetInstanceID()))
				{
					it.gripCol.enabled = true;
					if (flag)
					{
						ReignoreMask(it);
					}
				}
			}
			if (flag3 != locked)
			{
				((MelonBase)this).LoggerInstance.Msg(flag3 ? $"mask LOCKED (inhibitor={InhibitorActive} phasing={PhaseLocked})" : "mask unlocked");
			}
		}

		private void ReignoreMask(Item it)
		{
			try
			{
				Transform val = Cam(

MxesEntity.dll

Decompiled 2 hours 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 HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using MelonLoader;
using Microsoft.CodeAnalysis;
using MxesEntity;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UI;
using VannyMask;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Mod), "M.X.E.S. Entity", "1.7.1", "somewhatmaxy", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("MxesEntity")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MxesEntity")]
[assembly: AssemblyTitle("MxesEntity")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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;
		}
	}
}
namespace MxesEntity
{
	public sealed class Mod : MelonMod
	{
		private sealed class PoseClip
		{
			public int Frames;

			public int Vertices;

			public float Fps;

			public short[] Coordinates = Array.Empty<short>();

			public int[] Connectors = Array.Empty<int>();

			public Vector3 Position(int frame, int vertex)
			{
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				int num = (frame * Vertices + vertex) * 3;
				return new Vector3((float)Coordinates[num] / 4096f, (float)Coordinates[num + 1] / 4096f, (float)Coordinates[num + 2] / 4096f);
			}
		}

		private const float SpawnSeconds = 45f;

		private const float TeleportDistance = 2f;

		private const float TeleportPause = 3f;

		private const float TeleportTransitSeconds = 0.35f;

		private const float SpawnDistance = 13f;

		private const float CatchDistance = 1.5f;

		private const float ScareSeconds = 1.9333667f;

		private const string PatchId = "somewhatmaxy.vannymask.mxes";

		private static Mod? _instance;

		private Harmony? _harmony;

		private static readonly (string Name, float LoA, float HiA, float LoB, float HiB, float Leak)[] PuzzleLayouts = new(string, float, float, float, float, float)[7]
		{
			("Two pipes - training", 0.28f, 0.57f, 0.35f, 0.64f, 0.07f),
			("Two pipes - staggered", 0.12f, 0.39f, 0.58f, 0.87f, 0.09f),
			("Two pipes - high charge", 0.63f, 0.86f, 0.55f, 0.8f, 0.11f),
			("Two pipes - narrow", 0.29f, 0.46f, 0.53f, 0.7f, 0.12f),
			("Two pipes - inversion", 0.68f, 0.85f, 0.17f, 0.36f, 0.12f),
			("Two pipes - fast leak", 0.35f, 0.53f, 0.44f, 0.62f, 0.17f),
			("Two pipes - precision", 0.7f, 0.84f, 0.47f, 0.61f, 0.15f)
		};

		private FieldInfo? _arField;

		private object? _maskInstance;

		private float _wearStart = -1f;

		private float _nextGlitch;

		private GameObject? _entity;

		private Mesh? _mesh;

		private Il2CppStructArray<Vector3>? _posedPositions;

		private PoseClip[]? _poseClips;

		private int _clipIndex;

		private float _clipStart;

		private float _alertPoseUntil;

		private float _nextPose;

		private Material? _material;

		private Texture2D? _baseTexture;

		private Texture2D? _emissiveTexture;

		private Texture2D? _glowMask;

		private Material? _glowMaterial;

		private Material? _portalMaterial;

		private MeshRenderer? _glowRenderer;

		private Light? _glowLight;

		private GameObject? _portal;

		private GameObject? _arrivalPortal;

		private Vector3 _portalFrom;

		private readonly List<LineRenderer> _portalLines = new List<LineRenderer>();

		private AudioSource? _sound;

		private AudioClip? _spawn;

		private AudioClip? _idle;

		private AudioClip? _alert;

		private AudioClip? _teleportIn;

		private AudioClip? _teleportOut;

		private AudioClip? _scareSound;

		private MeshRenderer? _renderer;

		private float _nextTeleport;

		private float _arriveAt = -1f;

		private float _departStart = -1f;

		private readonly List<GameObject> _scareScreens = new List<GameObject>();

		private readonly List<RawImage> _scareImages = new List<RawImage>();

		private GameObject? _staticCanvas;

		private RawImage? _staticNoise;

		private RawImage? _staticVeil;

		private Texture2D[]? _staticFrames;

		private AudioClip? _staticFarClip;

		private AudioClip? _staticNearClip;

		private AudioSource? _staticFarAudio;

		private AudioSource? _staticNearAudio;

		private int _staticFrame = -1;

		private float _nextStaticFrame;

		private Camera? _staticCamera;

		private Material? _scareMaterial;

		private Texture2D[]? _scareFrames;

		private float _scareStart = -1f;

		private int _scareFrame = -1;

		private bool _scareGuiLogged;

		private AudioSource? _scareAudio;

		private readonly List<Canvas> _hiddenCanvases = new List<Canvas>();

		private LineRenderer[]? _electricArms;

		private bool _alerted;

		private const float LostPlayerDistance = 17f;

		private const float PanelSearchDistance = 13f;

		private const float InhibitorSetupSeconds = 4f;

		private object? _setupPanel;

		private Vector3 _setupPoint;

		private float _setupStart = -1f;

		private bool _setupApplied;

		private float _nextSetupAllowed;

		private AudioClip? _inhibitorActivateClip;

		public override void OnInitializeMelon()
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Expected O, but got Unknown
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			_instance = this;
			Type typeFromHandle = typeof(Mod);
			_arField = AccessTools.Field(typeFromHandle, "_arOn");
			MethodInfo methodInfo = AccessTools.Method(typeFromHandle, "OnUpdate", (Type[])null, (Type[])null);
			MethodInfo methodInfo2 = AccessTools.Method(typeof(Mod), "AfterMaskUpdate", (Type[])null, (Type[])null);
			if (_arField == null || methodInfo == null || methodInfo2 == null)
			{
				((MelonBase)this).LoggerInstance.Error("Could not connect to VannyMask state; M.X.E.S. disabled.");
				return;
			}
			_harmony = new Harmony("somewhatmaxy.vannymask.mxes");
			_harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			MethodInfo methodInfo3 = AccessTools.Method(typeFromHandle, "PickLayout", (Type[])null, (Type[])null);
			if (methodInfo3 != null)
			{
				_harmony.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(Mod), "AfterPickLayout", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			((MelonBase)this).LoggerInstance.Msg("M.X.E.S. ready; mask-world spawn delay: 45 seconds.");
		}

		public override void OnSceneWasInitialized(int buildIndex, string sceneName)
		{
			Reset();
			ReleaseResources();
		}

		public override void OnGUI()
		{
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			if (!(_scareStart < 0f) && _scareFrames != null && _scareFrame >= 0 && !((IEnumerable<Camera>)Camera.allCameras).Any((Camera cam) => (Object)(object)cam != (Object)null && ((Behaviour)cam).enabled && ((Object)cam).name.Contains("Headset", StringComparison.OrdinalIgnoreCase)))
			{
				if (!_scareGuiLogged)
				{
					((MelonBase)this).LoggerInstance.Msg($"M.X.E.S. scare IMGUI active at {Screen.width}x{Screen.height}.");
					_scareGuiLogged = true;
				}
				GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)_scareFrames[_scareFrame], (ScaleMode)2);
			}
		}

		public override void OnDeinitializeMelon()
		{
			Reset();
			ReleaseResources();
			Harmony? harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void ReleaseResources()
		{
			if ((Object)(object)_mesh != (Object)null)
			{
				Object.Destroy((Object)(object)_mesh);
			}
			_mesh = null;
			_posedPositions = null;
			_poseClips = null;
			if ((Object)(object)_material != (Object)null)
			{
				Object.Destroy((Object)(object)_material);
			}
			_material = null;
			if ((Object)(object)_baseTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_baseTexture);
			}
			_baseTexture = null;
			if ((Object)(object)_emissiveTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_emissiveTexture);
			}
			_emissiveTexture = null;
			if ((Object)(object)_glowMask != (Object)null)
			{
				Object.Destroy((Object)(object)_glowMask);
			}
			_glowMask = null;
			if ((Object)(object)_glowMaterial != (Object)null)
			{
				Object.Destroy((Object)(object)_glowMaterial);
			}
			_glowMaterial = null;
			if ((Object)(object)_portalMaterial != (Object)null)
			{
				Object.Destroy((Object)(object)_portalMaterial);
			}
			_portalMaterial = null;
			if ((Object)(object)_spawn != (Object)null)
			{
				Object.Destroy((Object)(object)_spawn);
			}
			_spawn = null;
			if ((Object)(object)_idle != (Object)null)
			{
				Object.Destroy((Object)(object)_idle);
			}
			_idle = null;
			if ((Object)(object)_alert != (Object)null)
			{
				Object.Destroy((Object)(object)_alert);
			}
			_alert = null;
			if ((Object)(object)_teleportIn != (Object)null)
			{
				Object.Destroy((Object)(object)_teleportIn);
			}
			_teleportIn = null;
			if ((Object)(object)_teleportOut != (Object)null)
			{
				Object.Destroy((Object)(object)_teleportOut);
			}
			_teleportOut = null;
			if ((Object)(object)_scareSound != (Object)null)
			{
				Object.Destroy((Object)(object)_scareSound);
			}
			_scareSound = null;
			if ((Object)(object)_scareMaterial != (Object)null)
			{
				Object.Destroy((Object)(object)_scareMaterial);
			}
			_scareMaterial = null;
			if (_scareFrames != null)
			{
				Texture2D[] scareFrames = _scareFrames;
				for (int i = 0; i < scareFrames.Length; i++)
				{
					Object.Destroy((Object)(object)scareFrames[i]);
				}
			}
			_scareFrames = null;
			if (_staticFrames != null)
			{
				Texture2D[] scareFrames = _staticFrames;
				for (int i = 0; i < scareFrames.Length; i++)
				{
					Object.Destroy((Object)(object)scareFrames[i]);
				}
			}
			_staticFrames = null;
			if ((Object)(object)_staticFarClip != (Object)null)
			{
				Object.Destroy((Object)(object)_staticFarClip);
			}
			_staticFarClip = null;
			if ((Object)(object)_staticNearClip != (Object)null)
			{
				Object.Destroy((Object)(object)_staticNearClip);
			}
			_staticNearClip = null;
		}

		private static void AfterMaskUpdate(object __instance)
		{
			_instance?.Tick(__instance);
		}

		private static void AfterPickLayout(object __0, ref string __result)
		{
			try
			{
				(string, float, float, float, float, float) tuple = PuzzleLayouts[Random.Range(0, PuzzleLayouts.Length)];
				Type type = __0.GetType();
				((float[])AccessTools.Field(type, "bandLo").GetValue(__0))[0] = tuple.Item2;
				((float[])AccessTools.Field(type, "bandHi").GetValue(__0))[0] = tuple.Item3;
				((float[])AccessTools.Field(type, "bandLo").GetValue(__0))[1] = tuple.Item4;
				((float[])AccessTools.Field(type, "bandHi").GetValue(__0))[1] = tuple.Item5;
				AccessTools.Field(type, "leak").SetValue(__0, tuple.Item6);
				(__result, _, _, _, _, _) = tuple;
			}
			catch (Exception ex)
			{
				Mod? instance = _instance;
				if (instance != null)
				{
					((MelonBase)instance).LoggerInstance.Warning("Puzzle variation skipped: " + ex.Message);
				}
			}
		}

		private void Tick(object mask)
		{
			//IL_00af: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_046d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0482: Unknown result type (might be due to invalid IL or missing references)
			//IL_048d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0497: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_050f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0550: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0605: Unknown result type (might be due to invalid IL or missing references)
			//IL_0593: Unknown result type (might be due to invalid IL or missing references)
			//IL_0598: Unknown result type (might be due to invalid IL or missing references)
			//IL_0599: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a0: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				_maskInstance = mask;
				if (_scareStart >= 0f)
				{
					UpdateScare();
					return;
				}
				if (!(bool)(_arField?.GetValue(mask) ?? ((object)false)))
				{
					Reset();
					return;
				}
				if (_wearStart < 0f)
				{
					_wearStart = Time.unscaledTime;
				}
				Camera val = LocalCamera();
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				Transform transform = ((Component)val).transform;
				if ((Object)(object)_entity == (Object)null)
				{
					if (Time.unscaledTime - _wearStart >= 45f)
					{
						Spawn(transform);
					}
					return;
				}
				Vector3 val2 = transform.position - _entity.transform.position;
				val2.y = 0f;
				UpdateStatic(val, ((Vector3)(ref val2)).magnitude);
				if (_arriveAt >= 0f && Time.unscaledTime >= _arriveAt)
				{
					float num = Math.Min(2f, Math.Max(0f, ((Vector3)(ref val2)).magnitude - 0.9f));
					RaycastHit val3 = default(RaycastHit);
					if (Physics.Raycast(_entity.transform.position + Vector3.up * 1.4f, ((Vector3)(ref val2)).normalized, ref val3, num))
					{
						num = Math.Max(0f, ((RaycastHit)(ref val3)).distance - 0.4f);
					}
					Transform transform2 = _entity.transform;
					transform2.position += ((Vector3)(ref val2)).normalized * num;
					((Renderer)_renderer).enabled = true;
					if ((Object)(object)_glowRenderer != (Object)null)
					{
						((Renderer)_glowRenderer).enabled = true;
					}
					if (_electricArms != null)
					{
						LineRenderer[] electricArms = _electricArms;
						for (int i = 0; i < electricArms.Length; i++)
						{
							((Renderer)electricArms[i]).enabled = true;
						}
					}
					if ((Object)(object)_teleportIn != (Object)null)
					{
						AudioSource? sound = _sound;
						if (sound != null)
						{
							sound.PlayOneShot(_teleportIn);
						}
					}
					_arriveAt = -1f;
					_departStart = -1f;
					StartArrivalEffect();
					_nextTeleport = Time.unscaledTime + 3f;
					_alertPoseUntil = Time.unscaledTime + 2f;
					_nextPose = 0f;
					val2 = transform.position - _entity.transform.position;
					val2.y = 0f;
				}
				if (_arriveAt >= 0f)
				{
					bool enabled = ((int)((Time.unscaledTime - _departStart) * 32f) & 1) == 0;
					((Renderer)_renderer).enabled = enabled;
					if ((Object)(object)_glowRenderer != (Object)null)
					{
						((Renderer)_glowRenderer).enabled = enabled;
					}
					if (_electricArms != null)
					{
						LineRenderer[] electricArms = _electricArms;
						for (int i = 0; i < electricArms.Length; i++)
						{
							((Renderer)electricArms[i]).enabled = enabled;
						}
					}
					UpdatePortal((Time.unscaledTime - _departStart) / 0.35f);
					if (Time.unscaledTime >= _nextPose)
					{
						AnimatePose();
						_nextPose = Time.unscaledTime + 0.08f;
					}
					return;
				}
				if (_clipIndex == 2 && Time.unscaledTime >= _alertPoseUntil)
				{
					_clipIndex = 1;
					_clipStart = Time.unscaledTime;
					_nextPose = 0f;
				}
				if (TickInhibitorSetup(transform, ((Vector3)(ref val2)).magnitude))
				{
					return;
				}
				if (((Vector3)(ref val2)).magnitude <= 1.5f)
				{
					StartScare(val);
					return;
				}
				if (!_alerted && ((Vector3)(ref val2)).sqrMagnitude < 9f)
				{
					_alerted = true;
					if ((Object)(object)_alert != (Object)null)
					{
						AudioSource? sound2 = _sound;
						if (sound2 != null)
						{
							sound2.PlayOneShot(_alert);
						}
					}
				}
				if (Time.unscaledTime >= _nextTeleport)
				{
					if ((Object)(object)_teleportOut != (Object)null)
					{
						AudioSource? sound3 = _sound;
						if (sound3 != null)
						{
							sound3.PlayOneShot(_teleportOut);
						}
					}
					_clipIndex = 2;
					_clipStart = Time.unscaledTime;
					_departStart = Time.unscaledTime;
					_arriveAt = Time.unscaledTime + 0.35f;
					StartPortal();
					_nextPose = 0f;
					return;
				}
				_entity.transform.LookAt(new Vector3(transform.position.x, _entity.transform.position.y, transform.position.z));
				if (Time.unscaledTime >= _nextPose)
				{
					AnimatePose();
					_nextPose = Time.unscaledTime + 0.08f;
				}
				if (Time.unscaledTime >= _nextGlitch)
				{
					_nextGlitch = Time.unscaledTime + Random.Range(0.08f, 0.25f);
					_entity.transform.localScale = Vector3.one * Random.Range(0.97f, 1.03f);
					if ((Object)(object)_material != (Object)null)
					{
						_material.SetColor("_EmissionColor", new Color(4f, Random.Range(4f, 5f), 6f, 1f));
					}
					if (_electricArms != null)
					{
						LineRenderer[] electricArms = _electricArms;
						foreach (LineRenderer obj in electricArms)
						{
							Color startColor = (obj.endColor = new Color(0.5f, Random.Range(1.2f, 2.2f), 5f, 1f));
							obj.startColor = startColor;
						}
					}
					if ((Object)(object)_glowMaterial != (Object)null)
					{
						Color val5 = default(Color);
						((Color)(ref val5))..ctor(0.75f, Random.Range(1.3f, 2.1f), 3f, 1f);
						_glowMaterial.SetColor("_Color", val5);
						_glowMaterial.SetColor("_TintColor", val5);
					}
				}
				if ((Object)(object)_portal != (Object)null && _departStart < 0f)
				{
					UpdatePortal((Time.unscaledTime - (_nextTeleport - 3f)) / 0.45f);
					if (Time.unscaledTime >= _nextTeleport - 3f + 0.45f)
					{
						DestroyPortal();
					}
				}
			}
			catch (Exception ex)
			{
				((MelonBase)this).LoggerInstance.Error("M.X.E.S. update failed: " + ex);
				Reset();
				ReleaseResources();
			}
		}

		private void Spawn(Transform cam)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0011: 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)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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_0058: 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_00af: 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_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)
			//IL_00ca: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Expected O, but got Unknown
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Expected O, but got Unknown
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Expected O, but got Unknown
			//IL_0426: Unknown result type (might be due to invalid IL or missing references)
			//IL_0430: Unknown result type (might be due to invalid IL or missing references)
			//IL_048d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0494: Expected O, but got Unknown
			//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f1: Expected O, but got Unknown
			//IL_073a: Unknown result type (might be due to invalid IL or missing references)
			//IL_075f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0791: Unknown result type (might be due to invalid IL or missing references)
			//IL_0798: Unknown result type (might be due to invalid IL or missing references)
			//IL_0814: Unknown result type (might be due to invalid IL or missing references)
			_entity = new GameObject("M.X.E.S. (DLC Rabbit)");
			Vector3 forward = cam.forward;
			forward.y = 0f;
			((Vector3)(ref forward)).Normalize();
			float num = 0f;
			Vector3 val = forward;
			RaycastHit val3 = default(RaycastHit);
			for (int i = 0; i < 8; i++)
			{
				Vector3 val2 = Quaternion.Euler(0f, (float)i * 45f, 0f) * forward;
				float num2 = (Physics.Raycast(cam.position, val2, ref val3, 13f) ? Math.Max(0.5f, ((RaycastHit)(ref val3)).distance - 0.5f) : 13f);
				if (!(num2 <= num))
				{
					num = num2;
					val = val2;
				}
			}
			_entity.transform.position = cam.position + val * num - Vector3.up * 1.5f;
			_entity.transform.LookAt(new Vector3(cam.position.x, _entity.transform.position.y, cam.position.z));
			MeshFilter val4 = _entity.AddComponent<MeshFilter>();
			if ((Object)(object)_mesh == (Object)null)
			{
				_mesh = LoadMesh();
			}
			if (_poseClips == null)
			{
				_poseClips = new PoseClip[3]
				{
					LoadPoseClip("A_DLC_Rabbit_Watching03"),
					LoadPoseClip("A_DLC_Rabbit_Agitated05"),
					LoadPoseClip("A_DLC_Rabbit_Alerted02_R")
				};
			}
			_clipIndex = 0;
			_clipStart = Time.unscaledTime;
			val4.sharedMesh = _mesh;
			MeshRenderer val5 = (_renderer = _entity.AddComponent<MeshRenderer>());
			if ((Object)(object)_material == (Object)null)
			{
				Shader val6 = Shader.Find("Universal Render Pipeline/Lit (PBR Workflow)") ?? Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Unlit/Texture");
				if ((Object)(object)val6 == (Object)null)
				{
					throw new InvalidOperationException("No compatible Unity shader found");
				}
				_material = new Material(val6);
				_baseTexture = LoadTexture("TEX_DLC_Rabbit_BaseColor.png");
				_emissiveTexture = LoadTexture("TEX_DLC_Rabbit_01_Emissive.png");
				_material.mainTexture = (Texture)(object)_baseTexture;
				_material.SetTexture("_BaseMap", _material.mainTexture);
				_material.SetTexture("_EmissionMap", (Texture)(object)_emissiveTexture);
				_material.SetColor("_BaseColor", Color.white);
				_material.SetColor("_EmissionColor", new Color(1.6f, 2f, 2.5f, 1f));
				_material.EnableKeyword("_EMISSION");
				_material.SetInt("_Cull", 0);
			}
			((Renderer)val5).sharedMaterial = _material;
			((Renderer)val5).shadowCastingMode = (ShadowCastingMode)0;
			if (_glowMask == null)
			{
				_glowMask = LoadTexture("TEX_DLC_Rabbit_GlowMask.png");
			}
			Shader val7 = Shader.Find("UI/Default") ?? Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Transparent");
			if ((Object)(object)val7 != (Object)null)
			{
				_glowMaterial = new Material(val7);
				_glowMaterial.renderQueue = 3100;
				_glowMaterial.mainTexture = (Texture)(object)_glowMask;
				_glowMaterial.SetTexture("_BaseMap", (Texture)(object)_glowMask);
				_glowMaterial.SetColor("_TintColor", new Color(0.9f, 1.1f, 1.3f, 1f));
				_glowMaterial.SetColor("_BaseColor", new Color(0.9f, 1.1f, 1.3f, 1f));
				_glowMaterial.SetColor("_Color", new Color(0.9f, 1.1f, 1.3f, 1f));
				_glowMaterial.SetInt("_Cull", 0);
				GameObject val8 = new GameObject("M.X.E.S. emissive circuitry");
				val8.transform.SetParent(_entity.transform, false);
				val8.transform.localScale = Vector3.one * 1.003f;
				val8.AddComponent<MeshFilter>().sharedMesh = _mesh;
				_glowRenderer = val8.AddComponent<MeshRenderer>();
				((Renderer)_glowRenderer).sharedMaterial = _glowMaterial;
				((Renderer)_glowRenderer).shadowCastingMode = (ShadowCastingMode)0;
			}
			else
			{
				((MelonBase)this).LoggerInstance.Warning("No transparent shader available for M.X.E.S. glow layer.");
			}
			GameObject val9 = new GameObject("M.X.E.S. blue glow");
			val9.transform.SetParent(_entity.transform, false);
			val9.transform.localPosition = new Vector3(0f, 1.6f, 0f);
			_glowLight = val9.AddComponent<Light>();
			_glowLight.type = (LightType)2;
			_glowLight.color = new Color(0.27f, 0.58f, 1f);
			_glowLight.range = 3f;
			_glowLight.intensity = 0.6f;
			_sound = _entity.AddComponent<AudioSource>();
			_sound.spatialBlend = 1f;
			_sound.maxDistance = 20f;
			if ((Object)(object)_spawn == (Object)null)
			{
				_spawn = LoadAudio("spawn.wav");
			}
			if ((Object)(object)_idle == (Object)null)
			{
				_idle = LoadAudio("idle.wav");
			}
			if ((Object)(object)_alert == (Object)null)
			{
				_alert = LoadAudio("alert.wav");
			}
			_sound.PlayOneShot(_spawn);
			_sound.clip = _idle;
			_sound.loop = true;
			_sound.PlayDelayed(_spawn.length);
			if ((Object)(object)_teleportIn == (Object)null)
			{
				_teleportIn = LoadAudio("teleport_in.wav");
			}
			if ((Object)(object)_teleportOut == (Object)null)
			{
				_teleportOut = LoadAudio("teleport_out.wav");
			}
			if ((Object)(object)_scareSound == (Object)null)
			{
				_scareSound = LoadAudio("scare.wav");
			}
			_nextTeleport = Time.unscaledTime + 3f;
			_arriveAt = -1f;
			_electricArms = (LineRenderer[]?)(object)new LineRenderer[6];
			Color val13 = default(Color);
			for (int j = 0; j < 6; j++)
			{
				GameObject val10 = new GameObject($"M.X.E.S. electric connector {j + 1}");
				val10.transform.SetParent(_entity.transform, false);
				LineRenderer val11 = val10.AddComponent<LineRenderer>();
				val11.useWorldSpace = false;
				val11.positionCount = 5;
				val11.widthMultiplier = 0.025f;
				Material val12 = new Material(_material);
				val12.mainTexture = (Texture)(object)Texture2D.whiteTexture;
				val12.SetTexture("_BaseMap", (Texture)(object)Texture2D.whiteTexture);
				val12.SetTexture("_EmissionMap", (Texture)(object)Texture2D.whiteTexture);
				val12.SetColor("_BaseColor", new Color(0.4f, 1f, 3f, 1f));
				val12.SetColor("_EmissionColor", new Color(3f, 5f, 8f, 1f));
				((Renderer)val11).sharedMaterial = val12;
				((Color)(ref val13))..ctor(0.5f, 2f, 5f, 1f);
				val11.endColor = val13;
				val11.startColor = val13;
				val11.numCapVertices = 2;
				_electricArms[j] = val11;
			}
			AnimatePose();
			_nextPose = Time.unscaledTime + 0.08f;
			Instance loggerInstance = ((MelonBase)this).LoggerInstance;
			DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(88, 4);
			defaultInterpolatedStringHandler.AppendLiteral("M.X.E.S. appeared after 45 seconds in the mask world; distance=");
			defaultInterpolatedStringHandler.AppendFormatted(num, "F2");
			defaultInterpolatedStringHandler.AppendLiteral("m, mesh=");
			defaultInterpolatedStringHandler.AppendFormatted<Bounds>(_mesh.bounds);
			defaultInterpolatedStringHandler.AppendLiteral(", shader=");
			defaultInterpolatedStringHandler.AppendFormatted(((Object)_material.shader).name);
			defaultInterpolatedStringHandler.AppendLiteral(", glow=");
			Material? glowMaterial = _glowMaterial;
			defaultInterpolatedStringHandler.AppendFormatted(((glowMaterial != null) ? ((Object)glowMaterial.shader).name : null) ?? "none");
			defaultInterpolatedStringHandler.AppendLiteral(".");
			loggerInstance.Msg(defaultInterpolatedStringHandler.ToStringAndClear());
		}

		private void StartPortal()
		{
			//IL_0021: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0051: 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_00e1: 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_00b2: Expected O, but got Unknown
			DestroyPortal();
			if ((Object)(object)_entity == (Object)null)
			{
				return;
			}
			_portalFrom = _entity.transform.position;
			_portal = new GameObject("M.X.E.S. departure fragments");
			_portal.transform.position = _entity.transform.position;
			_portal.transform.rotation = _entity.transform.rotation;
			Shader val = Shader.Find("UI/Default") ?? Shader.Find("Unlit/Color");
			if (!((Object)(object)val == (Object)null))
			{
				if (_portalMaterial == null)
				{
					_portalMaterial = new Material(val);
				}
				_portalMaterial.renderQueue = 3100;
				_portalMaterial.SetColor("_Color", new Color(0.55f, 0.9f, 1.4f, 1f));
				AddFragments(_portal, 24);
			}
		}

		private void StartArrivalEffect()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_0043: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: 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)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_entity == (Object)null) && !((Object)(object)_portalMaterial == (Object)null))
			{
				_arrivalPortal = new GameObject("M.X.E.S. arrival fragments");
				_arrivalPortal.transform.position = _entity.transform.position;
				_arrivalPortal.transform.rotation = _entity.transform.rotation;
				AddFragments(_arrivalPortal, 28);
				Vector3 val = _entity.transform.position - _portalFrom;
				Color val4 = default(Color);
				for (int i = 0; i < 10; i++)
				{
					GameObject val2 = new GameObject($"teleport trail fragment {i}");
					val2.transform.SetParent(_arrivalPortal.transform, false);
					val2.transform.localPosition = Vector3.zero;
					LineRenderer val3 = val2.AddComponent<LineRenderer>();
					val3.useWorldSpace = true;
					val3.positionCount = 2;
					val3.widthMultiplier = Random.Range(0.012f, 0.035f);
					((Renderer)val3).sharedMaterial = _portalMaterial;
					((Color)(ref val4))..ctor(0.45f, 0.9f, 1.5f, 0.9f);
					val3.endColor = val4;
					val3.startColor = val4;
					float num = ((float)i + Random.value * 0.5f) / 10f;
					Vector3 val5 = _portalFrom + val * num + Vector3.up * Random.Range(0.5f, 2.2f);
					val5 += _entity.transform.right * Random.Range(-0.4f, 0.4f);
					val3.SetPosition(0, val5);
					val3.SetPosition(1, val5 + new Vector3(Random.Range(-0.15f, 0.15f), Random.Range(-0.2f, 0.2f), Random.Range(-0.15f, 0.15f)));
					_portalLines.Add(val3);
				}
			}
		}

		private void AddFragments(GameObject root, int count)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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_010e: Unknown result type (might be due to invalid IL or missing references)
			Color val3 = default(Color);
			for (int i = 0; i < count; i++)
			{
				GameObject val = new GameObject($"digital fragment {i}");
				val.transform.SetParent(root.transform, false);
				LineRenderer val2 = val.AddComponent<LineRenderer>();
				val2.useWorldSpace = false;
				val2.positionCount = 2;
				val2.widthMultiplier = Random.Range(0.012f, 0.055f);
				((Renderer)val2).sharedMaterial = _portalMaterial;
				((Color)(ref val3))..ctor(0.45f, 0.9f, 1.5f, 0.9f);
				val2.endColor = val3;
				val2.startColor = val3;
				float num = Random.Range(-0.65f, 0.65f);
				float num2 = Random.Range(0.1f, 2.7f);
				float num3 = Random.Range(-0.35f, 0.35f);
				float num4 = Random.Range(0.08f, 0.33f);
				val2.SetPosition(0, new Vector3(num, num2, num3));
				val2.SetPosition(1, new Vector3(num + Random.Range(-0.06f, 0.06f), num2 + num4, num3));
				_portalLines.Add(val2);
			}
		}

		private void UpdatePortal(float progress)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_portal == (Object)null)
			{
				return;
			}
			float num = Mathf.Clamp01(progress);
			_portal.transform.localScale = Vector3.one * ((_departStart >= 0f) ? Mathf.Lerp(1f, 0.2f, num) : 0.2f);
			if ((Object)(object)_arrivalPortal != (Object)null)
			{
				_arrivalPortal.transform.localScale = Vector3.one * Mathf.Lerp(0.4f, 1.25f, num);
			}
			foreach (LineRenderer portalLine in _portalLines)
			{
				if (!((Object)(object)portalLine == (Object)null))
				{
					float num2 = (0.65f + 0.35f * Mathf.Sin(Time.unscaledTime * 38f)) * ((_departStart >= 0f) ? 1f : (1f - num));
					Color startColor = (portalLine.endColor = new Color(0.55f * num2, 1.1f * num2, 1.8f * num2, num2));
					portalLine.startColor = startColor;
				}
			}
		}

		private void DestroyPortal()
		{
			if ((Object)(object)_portal != (Object)null)
			{
				Object.Destroy((Object)(object)_portal);
			}
			if ((Object)(object)_arrivalPortal != (Object)null)
			{
				Object.Destroy((Object)(object)_arrivalPortal);
			}
			_portal = null;
			_arrivalPortal = null;
			_portalLines.Clear();
		}

		private void UpdateStatic(Camera camera, float distance)
		{
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Expected O, but got Unknown
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0409: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Clamp01((8f - distance) / 6.5f);
			if (num <= 0.01f)
			{
				if ((Object)(object)_staticCanvas != (Object)null)
				{
					_staticCanvas.SetActive(false);
				}
				return;
			}
			if ((Object)(object)_staticCanvas == (Object)null || (Object)(object)_staticCamera != (Object)(object)camera)
			{
				DestroyStatic();
				if (_staticFrames == null)
				{
					_staticFrames = (from i in Enumerable.Range(0, 4)
						select LoadTexture($"static_{i:00}.png")).ToArray();
				}
				Texture2D[] staticFrames = _staticFrames;
				foreach (Texture2D obj in staticFrames)
				{
					((Texture)obj).filterMode = (FilterMode)0;
					((Texture)obj).wrapMode = (TextureWrapMode)0;
				}
				_staticCanvas = new GameObject("M.X.E.S. proximity interference");
				_staticCanvas.layer = Enumerable.Range(0, 32).First((int layer) => (camera.cullingMask & (1 << layer)) != 0);
				_staticCanvas.transform.SetParent(((Component)camera).transform, false);
				_staticCanvas.transform.localPosition = new Vector3(0f, 0f, 0.75f);
				Canvas obj2 = _staticCanvas.AddComponent<Canvas>();
				obj2.renderMode = (RenderMode)2;
				obj2.overrideSorting = true;
				obj2.sortingOrder = 32000;
				RectTransform obj3 = _staticCanvas.GetComponent<RectTransform>() ?? _staticCanvas.AddComponent<RectTransform>();
				obj3.sizeDelta = new Vector2(1600f, 900f);
				float fieldOfView = camera.fieldOfView;
				float num3 = ((fieldOfView >= 30f && fieldOfView <= 150f) ? camera.fieldOfView : 90f);
				float num4 = 1.5f * Mathf.Tan(num3 * 0.5f * ((float)Math.PI / 180f));
				((Transform)obj3).localScale = new Vector3(num4 * camera.aspect * 1.15f / 1600f, num4 * 1.15f / 900f, 1f);
				_staticVeil = AddOverlayImage(_staticCanvas, "dark AR veil");
				_staticVeil.texture = (Texture)(object)Texture2D.whiteTexture;
				_staticNoise = AddOverlayImage(_staticCanvas, "animated AR static");
				if (_staticFarClip == null)
				{
					_staticFarClip = LoadAudio("static_far.wav");
				}
				if (_staticNearClip == null)
				{
					_staticNearClip = LoadAudio("static_close.wav");
				}
				_staticFarAudio = _staticCanvas.AddComponent<AudioSource>();
				_staticFarAudio.clip = _staticFarClip;
				_staticFarAudio.loop = true;
				_staticFarAudio.spatialBlend = 0f;
				_staticFarAudio.volume = 0f;
				_staticFarAudio.Play();
				_staticNearAudio = _staticCanvas.AddComponent<AudioSource>();
				_staticNearAudio.clip = _staticNearClip;
				_staticNearAudio.loop = true;
				_staticNearAudio.spatialBlend = 0f;
				_staticNearAudio.volume = 0f;
				_staticNearAudio.Play();
				_staticCamera = camera;
				((MelonBase)this).LoggerInstance.Msg("M.X.E.S. proximity static attached to " + ((Object)camera).name + ".");
			}
			_staticCanvas.SetActive(true);
			if ((Object)(object)_staticFarAudio != (Object)null && !_staticFarAudio.isPlaying)
			{
				_staticFarAudio.Play();
			}
			if ((Object)(object)_staticNearAudio != (Object)null && !_staticNearAudio.isPlaying)
			{
				_staticNearAudio.Play();
			}
			((Graphic)_staticVeil).color = new Color(0.28f, 0.27f, 0.34f, 0.16f * num * num);
			((Graphic)_staticNoise).color = new Color(1f, 1f, 1f, 0.42f * num);
			if ((Object)(object)_staticFarAudio != (Object)null)
			{
				_staticFarAudio.volume = 0.22f * num * (1f - 0.55f * num);
			}
			if ((Object)(object)_staticNearAudio != (Object)null)
			{
				_staticNearAudio.volume = 0.43f * num * num * num;
			}
			if (Time.unscaledTime >= _nextStaticFrame)
			{
				_staticFrame = (_staticFrame + 1) % _staticFrames.Length;
				_staticNoise.texture = (Texture)(object)_staticFrames[_staticFrame];
				_staticNoise.uvRect = new Rect(Random.value, Random.value, 1f, 1f);
				_nextStaticFrame = Time.unscaledTime + 0.09f;
			}
		}

		private static RawImage AddOverlayImage(GameObject parent, string name)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name)
			{
				layer = parent.layer
			};
			val.transform.SetParent(parent.transform, false);
			RawImage obj = val.AddComponent<RawImage>();
			((Graphic)obj).rectTransform.anchorMin = Vector2.zero;
			((Graphic)obj).rectTransform.anchorMax = Vector2.one;
			((Graphic)obj).rectTransform.offsetMin = Vector2.zero;
			((Graphic)obj).rectTransform.offsetMax = Vector2.zero;
			((Graphic)obj).raycastTarget = false;
			return obj;
		}

		private void DestroyStatic()
		{
			if ((Object)(object)_staticCanvas != (Object)null)
			{
				Object.Destroy((Object)(object)_staticCanvas);
			}
			_staticCanvas = null;
			_staticNoise = null;
			_staticVeil = null;
			_staticCamera = null;
			_staticFrame = -1;
			_staticFarAudio = null;
			_staticNearAudio = null;
		}

		private void StartScare(Camera camera)
		{
			//IL_009c: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Expected O, but got Unknown
			//IL_02c7: 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_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Unknown result type (might be due to invalid IL or missing references)
			DestroyStatic();
			if (_scareFrames == null)
			{
				_scareFrames = (from i in Enumerable.Range(0, 25)
					select LoadTexture($"scare_{i:00}.jpg")).ToArray();
			}
			Shader val = Shader.Find("Universal Render Pipeline/Unlit") ?? Shader.Find("Unlit/Texture") ?? throw new InvalidOperationException("No unlit shader for M.X.E.S. scare");
			if (_scareMaterial == null)
			{
				_scareMaterial = new Material(val);
			}
			_scareMaterial.renderQueue = 5000;
			_scareMaterial.SetColor("_BaseColor", Color.white);
			_scareMaterial.SetColor("_Color", Color.white);
			_scareMaterial.SetInt("_ZTest", 8);
			_scareMaterial.SetInt("_ZWrite", 0);
			_scareMaterial.SetInt("_Cull", 0);
			_scareScreens.Clear();
			_scareImages.Clear();
			Camera val2 = LocalCamera() ?? camera;
			if ((Object)(object)val2 == (Object)null || !((Behaviour)val2).enabled)
			{
				throw new InvalidOperationException("No local headset camera for M.X.E.S. scare");
			}
			int mask = val2.cullingMask;
			if (mask == 0)
			{
				throw new InvalidOperationException("Local headset camera has no visible layers");
			}
			GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)5);
			((Object)val3).name = "M.X.E.S. jumpscare screen";
			val3.layer = Enumerable.Range(0, 32).First((int layer) => (mask & (1 << layer)) != 0);
			Collider component = val3.GetComponent<Collider>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			val3.transform.SetParent(((Component)val2).transform, false);
			float num = Math.Max(0.85f, val2.nearClipPlane + 0.1f);
			val3.transform.localPosition = new Vector3(0f, 0f, num);
			val3.transform.localRotation = Quaternion.Euler(0f, 180f, 0f);
			float fieldOfView = val2.fieldOfView;
			float num2 = ((fieldOfView >= 30f && fieldOfView <= 150f) ? val2.fieldOfView : 90f);
			float num3 = 2f * num * Mathf.Tan(num2 * 0.5f * ((float)Math.PI / 180f)) * 1.2f;
			val3.transform.localScale = new Vector3(num3, num3, 1f);
			((Renderer)val3.GetComponent<MeshRenderer>()).sharedMaterial = _scareMaterial;
			_scareScreens.Add(val3);
			GameObject val4 = new GameObject("M.X.E.S. VR jumpscare canvas");
			val4.layer = val3.layer;
			val4.transform.SetParent(((Component)val2).transform, false);
			val4.transform.localPosition = new Vector3(0f, 0f, num - 0.02f);
			val4.transform.localRotation = Quaternion.identity;
			Canvas obj = val4.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)2;
			obj.overrideSorting = true;
			obj.sortingOrder = 32767;
			RectTransform obj2 = val4.GetComponent<RectTransform>() ?? val4.AddComponent<RectTransform>();
			obj2.sizeDelta = new Vector2(640f, 640f);
			((Transform)obj2).localScale = new Vector3(num3 / 640f, num3 / 640f, 1f);
			GameObject val5 = new GameObject("animated jumpscare frames")
			{
				layer = val3.layer
			};
			val5.transform.SetParent(val4.transform, false);
			RawImage val6 = val5.AddComponent<RawImage>();
			((Graphic)val6).rectTransform.anchorMin = Vector2.zero;
			((Graphic)val6).rectTransform.anchorMax = Vector2.one;
			((Graphic)val6).rectTransform.offsetMin = Vector2.zero;
			((Graphic)val6).rectTransform.offsetMax = Vector2.zero;
			((Graphic)val6).raycastTarget = false;
			_scareImages.Add(val6);
			_scareScreens.Add(val4);
			((MelonBase)this).LoggerInstance.Msg($"M.X.E.S. scare target: {((Object)val2).name}, stereo={val2.stereoEnabled}, eye={val2.stereoTargetEye}, fov={val2.fieldOfView:F1}, square={num3:F2}m, layer={val3.layer}.");
			if (_scareScreens.Count == 0)
			{
				throw new InvalidOperationException("No active camera for M.X.E.S. scare");
			}
			_scareAudio = _scareScreens[0].AddComponent<AudioSource>();
			_scareAudio.spatialBlend = 0f;
			if ((Object)(object)_scareSound != (Object)null)
			{
				_scareAudio.PlayOneShot(_scareSound);
			}
			AudioSource? sound = _sound;
			if (sound != null)
			{
				sound.Stop();
			}
			_scareStart = Time.unscaledTime;
			_scareFrame = -1;
			_scareGuiLogged = false;
			UpdateScare();
			((MelonBase)this).LoggerInstance.Msg($"M.X.E.S. caught the player; displaying RUIN scare on {_scareScreens.Count} camera(s), shader={((Object)_scareMaterial.shader).name}, supported={_scareMaterial.shader.isSupported}.");
		}

		private void UpdateScare()
		{
			float num = Time.unscaledTime - _scareStart;
			if (num >= 1.9333667f)
			{
				Camera val = LocalCamera();
				Player_Health val2 = (((Object)(object)val != (Object)null) ? LocalHealth(val) : null);
				if ((Object)(object)val != (Object)null)
				{
					RemoveLocalMask(val);
				}
				Reset();
				if ((Object)(object)val2 == (Object)null)
				{
					((MelonBase)this).LoggerInstance.Error("M.X.E.S. scare ended, but local Player_Health was not found; no remote player was harmed.");
				}
				else
				{
					val2.ApplyKillDamage();
				}
				return;
			}
			int num2 = Math.Clamp((int)(num / 1.9333667f * 25f), 0, 24);
			if (num2 == _scareFrame)
			{
				return;
			}
			_scareFrame = num2;
			_scareMaterial.mainTexture = (Texture)(object)_scareFrames[num2];
			_scareMaterial.SetTexture("_BaseMap", (Texture)(object)_scareFrames[num2]);
			_scareMaterial.SetTexture("_MainTex", (Texture)(object)_scareFrames[num2]);
			foreach (RawImage scareImage in _scareImages)
			{
				if ((Object)(object)scareImage != (Object)null)
				{
					scareImage.texture = (Texture)(object)_scareFrames[num2];
				}
			}
		}

		private static Player_Health? LocalHealth(Camera camera)
		{
			RigManager componentInParent = ((Component)camera).GetComponentInParent<RigManager>();
			if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent.health != (Object)null)
			{
				return ((Il2CppObjectBase)componentInParent.health).TryCast<Player_Health>();
			}
			Il2CppArrayBase<Player_Health> val = Object.FindObjectsOfType<Player_Health>();
			if (val.Length != 1)
			{
				return null;
			}
			return val[0];
		}

		private static Camera? LocalCamera()
		{
			Camera main = Camera.main;
			if ((Object)(object)main != (Object)null && ((Behaviour)main).enabled && ((Object)main).name.Contains("Headset", StringComparison.OrdinalIgnoreCase))
			{
				return main;
			}
			return ((IEnumerable<Camera>)Camera.allCameras).FirstOrDefault((Func<Camera, bool>)((Camera cam) => (Object)(object)cam != (Object)null && ((Behaviour)cam).enabled && ((Object)cam).name.Contains("Headset", StringComparison.OrdinalIgnoreCase))) ?? main;
		}

		private void RemoveLocalMask(Camera camera)
		{
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			if (_maskInstance == null)
			{
				return;
			}
			try
			{
				Type type = _maskInstance.GetType();
				if (!(AccessTools.Field(type, "_items")?.GetValue(_maskInstance) is IEnumerable enumerable))
				{
					return;
				}
				foreach (object item in enumerable)
				{
					if (item == null)
					{
						continue;
					}
					Type type2 = item.GetType();
					object obj = AccessTools.Field(type2, "wornByThis")?.GetValue(item);
					if (!(obj is bool) || !(bool)obj)
					{
						continue;
					}
					obj = AccessTools.Method(type, "WornByMe", (Type[])null, (Type[])null)?.Invoke(_maskInstance, new object[2]
					{
						item,
						((Component)camera).transform
					});
					if (!(obj is bool) || !(bool)obj)
					{
						continue;
					}
					object? obj2 = AccessTools.Field(type2, "maskoff")?.GetValue(item);
					Transform val = (Transform)((obj2 is Transform) ? obj2 : null);
					if ((Object)(object)val != (Object)null)
					{
						((Component)val).gameObject.SetActive(true);
					}
					object? obj3 = AccessTools.Field(type2, "poolee")?.GetValue(item);
					Component val2 = (Component)((obj3 is Component) ? obj3 : null);
					if ((Object)(object)val2 != (Object)null)
					{
						Transform transform = val2.transform;
						transform.SetParent((Transform)null, true);
						transform.position = ((Component)camera).transform.position + ((Component)camera).transform.right * 0.45f + ((Component)camera).transform.forward * 0.35f - ((Component)camera).transform.up * 0.28f;
						object? obj4 = AccessTools.Field(type2, "rb")?.GetValue(item);
						Rigidbody val3 = (Rigidbody)((obj4 is Rigidbody) ? obj4 : null);
						if ((Object)(object)val3 != (Object)null)
						{
							val3.isKinematic = false;
						}
					}
					object? obj5 = AccessTools.Field(type2, "mr")?.GetValue(item);
					Renderer val4 = (Renderer)((obj5 is Renderer) ? obj5 : null);
					if ((Object)(object)val4 != (Object)null)
					{
						val4.enabled = true;
					}
					AccessTools.Field(type2, "wornByThis")?.SetValue(item, false);
					AccessTools.Field(type2, "lockedMine")?.SetValue(item, false);
					AccessTools.Field(type2, "since")?.SetValue(item, -1f);
					((MelonBase)this).LoggerInstance.Msg("M.X.E.S. removed the local player's mask after the jumpscare.");
					break;
				}
				AccessTools.Method(type, "SetWorn", (Type[])null, (Type[])null)?.Invoke(_maskInstance, new object[2] { false, true });
			}
			catch (Exception ex)
			{
				((MelonBase)this).LoggerInstance.Warning("Could not finish local mask removal: " + ex);
			}
		}

		private static byte[] Resource(string name)
		{
			using Stream stream = typeof(Mod).Assembly.GetManifestResourceStream("MxesEntity.Resources." + name) ?? throw new FileNotFoundException("Embedded M.X.E.S. resource missing", name);
			using MemoryStream memoryStream = new MemoryStream();
			stream.CopyTo(memoryStream);
			return memoryStream.ToArray();
		}

		private Mesh LoadMesh()
		{
			//IL_0060: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Expected O, but got Unknown
			using BinaryReader binaryReader = new BinaryReader(new MemoryStream(Resource("rabbit.mesh")));
			int num = binaryReader.ReadInt32();
			int num2 = binaryReader.ReadInt32();
			Il2CppStructArray<Vector3> val = new Il2CppStructArray<Vector3>((long)num);
			Il2CppStructArray<Vector3> val2 = new Il2CppStructArray<Vector3>((long)num);
			Il2CppStructArray<Vector2> val3 = new Il2CppStructArray<Vector2>((long)num);
			Il2CppStructArray<int> val4 = new Il2CppStructArray<int>((long)num2);
			for (int i = 0; i < num; i++)
			{
				((Il2CppArrayBase<Vector3>)(object)val)[i] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
			}
			_posedPositions = new Il2CppStructArray<Vector3>((long)num);
			for (int j = 0; j < num; j++)
			{
				((Il2CppArrayBase<Vector3>)(object)val2)[j] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
			}
			for (int k = 0; k < num; k++)
			{
				((Il2CppArrayBase<Vector2>)(object)val3)[k] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle());
			}
			for (int l = 0; l < num2; l++)
			{
				((Il2CppArrayBase<int>)(object)val4)[l] = binaryReader.ReadInt32();
			}
			Mesh val5 = new Mesh
			{
				name = "M.X.E.S. LOD0",
				indexFormat = (IndexFormat)1,
				vertices = val,
				normals = val2,
				uv = val3,
				triangles = val4
			};
			val5.MarkDynamic();
			val5.RecalculateBounds();
			return val5;
		}

		private static PoseClip LoadPoseClip(string name)
		{
			using BinaryReader binaryReader = new BinaryReader(new MemoryStream(Resource(name + ".poses")));
			int num = binaryReader.ReadInt32();
			int num2 = binaryReader.ReadInt32();
			float num3 = binaryReader.ReadSingle();
			if (num < 2 || num2 < 1 || num3 <= 0f)
			{
				throw new InvalidDataException("Bad rabbit pose clip: " + name);
			}
			short[] array = new short[num * num2 * 3];
			byte[] array2 = binaryReader.ReadBytes(array.Length * 2);
			if (array2.Length != array.Length * 2)
			{
				throw new EndOfStreamException(name);
			}
			Buffer.BlockCopy(array2, 0, array, 0, array2.Length);
			using BinaryReader binaryReader2 = new BinaryReader(new MemoryStream(Resource(name + ".connectors")));
			if (binaryReader2.ReadInt32() != num || binaryReader2.ReadInt32() != 6)
			{
				throw new InvalidDataException("Bad rabbit connector clip: " + name);
			}
			int[] array3 = new int[num * 6 * 2];
			for (int i = 0; i < array3.Length; i++)
			{
				array3[i] = binaryReader2.ReadInt32();
				if (array3[i] < 0 || array3[i] >= num2)
				{
					throw new InvalidDataException("Bad rabbit connector index");
				}
			}
			return new PoseClip
			{
				Frames = num,
				Vertices = num2,
				Fps = num3,
				Coordinates = array,
				Connectors = array3
			};
		}

		private void AnimatePose()
		{
			//IL_0095: 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_00a4: 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)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: 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_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_mesh == (Object)null || _posedPositions == null || _poseClips == null)
			{
				return;
			}
			PoseClip poseClip = _poseClips[_clipIndex];
			if (((Il2CppArrayBase<Vector3>)(object)_posedPositions).Length != poseClip.Vertices)
			{
				throw new InvalidDataException("Rabbit pose vertex count mismatch");
			}
			float num = Mathf.Repeat((Time.unscaledTime - _clipStart) * poseClip.Fps, (float)(poseClip.Frames - 1));
			int num2 = (int)num;
			int frame = Math.Min(num2 + 1, poseClip.Frames - 1);
			float num3 = num - (float)num2;
			for (int i = 0; i < poseClip.Vertices; i++)
			{
				((Il2CppArrayBase<Vector3>)(object)_posedPositions)[i] = Vector3.Lerp(poseClip.Position(num2, i), poseClip.Position(frame, i), num3);
			}
			_mesh.vertices = _posedPositions;
			_mesh.RecalculateNormals();
			_mesh.RecalculateBounds();
			if (_electricArms == null)
			{
				return;
			}
			for (int j = 0; j < 6; j++)
			{
				LineRenderer val = _electricArms[j];
				int num4 = (num2 * 6 + j) * 2;
				Vector3 val2 = ((Il2CppArrayBase<Vector3>)(object)_posedPositions)[poseClip.Connectors[num4]];
				Vector3 val3 = ((Il2CppArrayBase<Vector3>)(object)_posedPositions)[poseClip.Connectors[num4 + 1]];
				for (int k = 0; k < 5; k++)
				{
					Vector3 val4 = Vector3.Lerp(val2, val3, (float)k / 4f);
					if (k == 1 || k == 3)
					{
						val4.y += 0.04f;
					}
					val.SetPosition(k, val4);
				}
			}
		}

		private static Texture2D LoadTexture(string name)
		{
			//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_0037: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			byte[] array = Resource(name);
			Il2CppStructArray<byte> val = new Il2CppStructArray<byte>((long)array.Length);
			for (int i = 0; i < array.Length; i++)
			{
				((Il2CppArrayBase<byte>)(object)val)[i] = array[i];
			}
			Texture2D val2 = new Texture2D(2, 2);
			if (!ImageConversion.LoadImage(val2, val))
			{
				throw new InvalidDataException("Could not decode texture: " + name);
			}
			((Object)val2).name = name;
			return val2;
		}

		private static AudioClip LoadAudio(string name)
		{
			using BinaryReader binaryReader = new BinaryReader(new MemoryStream(Resource(name)));
			if (new string(binaryReader.ReadChars(4)) != "RIFF")
			{
				throw new InvalidDataException(name);
			}
			binaryReader.ReadUInt32();
			if (new string(binaryReader.ReadChars(4)) != "WAVE")
			{
				throw new InvalidDataException(name);
			}
			int num = 0;
			int num2 = 0;
			byte[] array = null;
			while (binaryReader.BaseStream.Position + 8 <= binaryReader.BaseStream.Length)
			{
				string text = new string(binaryReader.ReadChars(4));
				int num3 = binaryReader.ReadInt32();
				long position = binaryReader.BaseStream.Position;
				if (text == "fmt ")
				{
					if (binaryReader.ReadUInt16() != 1)
					{
						throw new InvalidDataException("Expected PCM WAV: " + name);
					}
					num = binaryReader.ReadUInt16();
					num2 = binaryReader.ReadInt32();
					binaryReader.ReadInt32();
					binaryReader.ReadUInt16();
					if (binaryReader.ReadUInt16() != 16)
					{
						throw new InvalidDataException("Expected 16-bit WAV: " + name);
					}
				}
				else if (text == "data")
				{
					array = binaryReader.ReadBytes(num3);
				}
				binaryReader.BaseStream.Position = position + num3 + (num3 & 1);
			}
			if (array == null || num == 0 || num2 == 0)
			{
				throw new InvalidDataException(name);
			}
			Il2CppStructArray<float> val = new Il2CppStructArray<float>((long)(array.Length / 2));
			for (int i = 0; i < ((Il2CppArrayBase<float>)(object)val).Length; i++)
			{
				((Il2CppArrayBase<float>)(object)val)[i] = (float)BitConverter.ToInt16(array, i * 2) / 32768f;
			}
			AudioClip obj = AudioClip.Create(name, ((Il2CppArrayBase<float>)(object)val).Length / num, num, num2, false);
			obj.SetData(val, 0);
			return obj;
		}

		private void Reset()
		{
			ResetInhibitorFeature();
			_wearStart = -1f;
			_scareStart = -1f;
			_arriveAt = -1f;
			_departStart = -1f;
			foreach (GameObject scareScreen in _scareScreens)
			{
				if ((Object)(object)scareScreen != (Object)null)
				{
					Object.Destroy((Object)(object)scareScreen);
				}
			}
			_scareScreens.Clear();
			_scareImages.Clear();
			DestroyStatic();
			DestroyPortal();
			_scareAudio = null;
			foreach (Canvas hiddenCanvase in _hiddenCanvases)
			{
				if ((Object)(object)hiddenCanvase != (Object)null)
				{
					((Behaviour)hiddenCanvase).enabled = true;
				}
			}
			_hiddenCanvases.Clear();
			if (_electricArms != null)
			{
				LineRenderer[] electricArms = _electricArms;
				foreach (LineRenderer val in electricArms)
				{
					if ((Object)(object)val != (Object)null && (Object)(object)((Renderer)val).sharedMaterial != (Object)null)
					{
						Object.Destroy((Object)(object)((Renderer)val).sharedMaterial);
					}
				}
			}
			_electricArms = null;
			if ((Object)(object)_entity != (Object)null)
			{
				Object.Destroy((Object)(object)_entity);
			}
			_entity = null;
			_renderer = null;
			_glowRenderer = null;
			_glowLight = null;
			_sound = null;
			_alerted = false;
		}

		private bool TickInhibitorSetup(Transform playerCamera, float distance)
		{
			//IL_0036: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: 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_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_entity == (Object)null || _maskInstance == null)
			{
				return false;
			}
			if (_setupStart >= 0f)
			{
				float num = Time.unscaledTime - _setupStart;
				if (_setupPoint != _entity.transform.position)
				{
					_entity.transform.LookAt(new Vector3(_setupPoint.x, _entity.transform.position.y, _setupPoint.z));
				}
				if (Time.unscaledTime >= _nextPose)
				{
					AnimatePose();
					_nextPose = Time.unscaledTime + 0.08f;
				}
				if ((Object)(object)_portal != (Object)null)
				{
					UpdatePortal(num / 0.45f);
					if (num >= 0.45f)
					{
						DestroyPortal();
					}
				}
				if (!_setupApplied && num >= 2f)
				{
					_setupApplied = true;
					if (_setupPanel != null && ActivateExistingPanel(_setupPanel))
					{
						if (_inhibitorActivateClip == null)
						{
							_inhibitorActivateClip = LoadAudio("inhibitor_activate.wav");
						}
						if ((Object)(object)_inhibitorActivateClip != (Object)null)
						{
							AudioSource? sound = _sound;
							if (sound != null)
							{
								sound.PlayOneShot(_inhibitorActivateClip);
							}
						}
					}
				}
				if (num >= 4f)
				{
					_setupStart = -1f;
					_setupPanel = null;
					ReturnToPlayer(playerCamera);
					_nextSetupAllowed = Time.unscaledTime + 3f;
					((MelonBase)this).LoggerInstance.Msg("M.X.E.S. finished activating the inhibitor and returned to the player.");
				}
				return true;
			}
			if (distance <= 17f || Time.unscaledTime < _nextSetupAllowed || Mod.InhibitorActive)
			{
				return false;
			}
			FindDeactivatedPanel(out _setupPanel, out Component chosenPoolee, out _setupPoint);
			if (_setupPanel == null || (Object)(object)chosenPoolee == (Object)null)
			{
				return false;
			}
			Vector3 val = _entity.transform.position - _setupPoint;
			Vector3 val2 = ((Vector3)(ref val)).normalized;
			val2.y = 0f;
			if (((Vector3)(ref val2)).sqrMagnitude < 0.01f)
			{
				val2 = -playerCamera.forward;
			}
			((Vector3)(ref val2)).Normalize();
			WarpTo(_setupPoint + val2 * 1.6f);
			_setupStart = Time.unscaledTime;
			_setupApplied = false;
			_clipIndex = 2;
			_clipStart = Time.unscaledTime;
			_alertPoseUntil = Time.unscaledTime + 4f;
			_nextPose = 0f;
			((MelonBase)this).LoggerInstance.Msg("M.X.E.S. lost the player and began reactivating a solved inhibitor.");
			return true;
		}

		private void FindDeactivatedPanel(out object? chosen, out Component? chosenPoolee, out Vector3 position)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: 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_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: 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)
			chosen = null;
			chosenPoolee = null;
			position = Vector3.zero;
			if (_maskInstance == null || (Object)(object)_entity == (Object)null || !(AccessTools.Field(_maskInstance.GetType(), "_panels")?.GetValue(_maskInstance) is IEnumerable enumerable))
			{
				return;
			}
			float num = 13f;
			foreach (object item in enumerable)
			{
				if (item == null)
				{
					continue;
				}
				Type type = item.GetType();
				object obj = AccessTools.Field(type, "solved")?.GetValue(item);
				if (!(obj is bool) || !(bool)obj)
				{
					continue;
				}
				obj = AccessTools.Field(type, "wasActive")?.GetValue(item);
				if (!(obj is bool) || !(bool)obj)
				{
					continue;
				}
				object? obj2 = AccessTools.Field(type, "poolee")?.GetValue(item);
				Component val = (Component)((obj2 is Component) ? obj2 : null);
				if (!((Object)(object)val == (Object)null) && val.gameObject.activeInHierarchy)
				{
					Vector3 position2 = val.transform.position;
					float num2 = Vector3.Distance(_entity.transform.position, position2);
					if (!(num2 >= num))
					{
						num = num2;
						chosen = item;
						chosenPoolee = val;
						position = position2;
					}
				}
			}
		}

		private bool ActivateExistingPanel(object panel)
		{
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			if (_maskInstance == null)
			{
				return false;
			}
			try
			{
				object? obj = AccessTools.Field(panel.GetType(), "poolee")?.GetValue(panel);
				Component val = (Component)((obj is Component) ? obj : null);
				if ((Object)(object)val == (Object)null || !val.gameObject.activeInHierarchy)
				{
					return false;
				}
				(AccessTools.Field(_maskInstance.GetType(), "_keepSolved")?.GetValue(_maskInstance) as HashSet<int>)?.Remove(((Object)val).GetInstanceID());
				(AccessTools.Method(_maskInstance.GetType(), "ResetPanel", (Type[])null, (Type[])null) ?? throw new MissingMethodException("VannyMask.ResetPanel")).Invoke(_maskInstance, new object[1] { panel });
				object obj2 = AccessTools.Field(panel.GetType(), "solved")?.GetValue(panel);
				if (obj2 is bool && (bool)obj2)
				{
					throw new InvalidOperationException("The inhibitor remained solved after reset");
				}
				Mod.InhibitorActive = true;
				((MelonBase)this).LoggerInstance.Msg($"M.X.E.S. reset the nearby inhibitor puzzle at {val.transform.position}.");
				return true;
			}
			catch (Exception ex)
			{
				((MelonBase)this).LoggerInstance.Warning("Could not reactivate an existing inhibitor: " + ex);
				return false;
			}
		}

		private void WarpTo(Vector3 destination)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_entity == (Object)null)
			{
				return;
			}
			StartPortal();
			_entity.transform.position = destination;
			_departStart = -1f;
			StartArrivalEffect();
			if ((Object)(object)_teleportOut != (Object)null)
			{
				AudioSource? sound = _sound;
				if (sound != null)
				{
					sound.PlayOneShot(_teleportOut);
				}
			}
			if ((Object)(object)_teleportIn != (Object)null)
			{
				AudioSource? sound2 = _sound;
				if (sound2 != null)
				{
					sound2.PlayOneShot(_teleportIn);
				}
			}
			_nextTeleport = Time.unscaledTime + 3f;
		}

		private void ReturnToPlayer(Transform camera)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_entity == (Object)null)
			{
				return;
			}
			Vector3 forward = camera.forward;
			forward.y = 0f;
			((Vector3)(ref forward)).Normalize();
			float num = 0f;
			Vector3 val = forward;
			float num2 = 6.5f;
			RaycastHit val3 = default(RaycastHit);
			for (int i = 0; i < 8; i++)
			{
				Vector3 val2 = Quaternion.Euler(0f, (float)i * 45f, 0f) * forward;
				float num3 = (Physics.Raycast(camera.position, val2, ref val3, num2) ? Mathf.Max(1.8f, ((RaycastHit)(ref val3)).distance - 0.5f) : num2);
				if (!(num3 <= num))
				{
					num = num3;
					val = val2;
				}
			}
			WarpTo(camera.position + val * num - Vector3.up * 1.5f);
			_clipIndex = 1;
			_clipStart = Time.unscaledTime;
			_nextPose = 0f;
		}

		private void ResetInhibitorFeature()
		{
			_setupStart = -1f;
			_setupPanel = null;
			_setupApplied = false;
			_nextSetupAllowed = 0f;
			if ((Object)(object)_inhibitorActivateClip != (Object)null)
			{
				Object.Destroy((Object)(object)_inhibitorActivateClip);
			}
			_inhibitorActivateClip = null;
		}
	}
}