Decompiled source of GraveyardMod v1.0.1

Mods/GraveyardMod.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using GraveyardMod;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Bonelab;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.AI;
using Il2CppSLZ.Marrow.Combat;
using Il2CppSLZ.Marrow.PuppetMasta;
using Il2CppSLZ.Marrow.Warehouse;
using Il2CppSLZ.VRMK;
using Il2CppSystem;
using MelonLoader;
using MelonLoader.Preferences;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: MelonInfo(typeof(GYMod), "GraveyardMod", "1.0.0", "Sanadid", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: SecurityPermission((SecurityAction)8, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace GraveyardMod;

public class GYMod : MelonMod
{
	private class RagRec
	{
		public AIBrain b;

		public float until;

		public float mw;

		public float damp;
	}

	private class Thrown
	{
		public AIBrain b;

		public Rigidbody rb;

		public float until;

		public float lastSpeed;

		public float frac;
	}

	private class MatRec
	{
		public Material m;

		public Color em;

		public Color col;

		public int kind;

		public bool tendril;
	}

	private class Finger
	{
		public Transform[] b = (Transform[])(object)new Transform[3];

		public Quaternion[] rest = (Quaternion[])(object)new Quaternion[3];

		public Vector3[] ax = (Vector3[])(object)new Vector3[3];

		public Vector3[] ax2 = (Vector3[])(object)new Vector3[3];

		public float[] max = new float[3];

		public int input;
	}

	private class HandRig
	{
		public bool left;

		public bool ok;

		public Transform fore;

		public Transform upper;

		public Transform hand;

		public Transform ph;

		public Vector3 fingerLocal;

		public List<Finger> fingers = new List<Finger>();

		public Vector3 calib;

		public float[] curl = new float[4];

		public bool shotOpen;

		public bool shotFist;
	}

	private class FLim
	{
		public Transform b;

		public Quaternion rest;

		public float max;
	}

	private class Soul
	{
		public GameObject go;

		public Vector3 pos;

		public Vector3 vel;

		public float age;

		public float ang;

		public float rad;

		public float hgt;

		public float life;

		public int phase;

		public bool ambient;
	}

	private enum RS
	{
		Follow,
		Swoop,
		Arc,
		Skid,
		Present,
		Joy,
		Sad,
		TakeOff,
		Return,
		Climb,
		Throw,
		Coast,
		Dive,
		Glide
	}

	private enum TM
	{
		Idle,
		Ready,
		Shoot,
		Grab,
		Grapple,
		Fan
	}

	private bool capeOK;

	private Transform chest;

	private Transform hipsB;

	private Transform neckB;

	private Transform lUL;

	private Transform lLL;

	private Transform lF;

	private Transform rUL;

	private Transform rLL;

	private Transform rF;

	private int NC = 3;

	private readonly Transform[,] cb = new Transform[5, 5];

	private readonly Quaternion[,] cRest = new Quaternion[5, 5];

	private readonly Vector3[,] cDir = new Vector3[5, 4];

	private readonly float[,] cLen = new float[5, 4];

	private readonly Vector3[,] cp = new Vector3[5, 5];

	private readonly Vector3[,] cpp = new Vector3[5, 5];

	private readonly Vector3[,] cRestL = new Vector3[5, 5];

	private readonly float[,] cH = new float[4, 5];

	private Transform pupil;

	private Transform headB;

	private Vector3 pupilRest;

	private Vector3 faceF;

	private Vector3 faceU;

	private Vector3 faceR;

	private Vector3 eyeOff;

	private Vector3 eyeTgt;

	private Vector3 sacc;

	private bool eyeHas;

	private float eyeScan;

	private float saccT;

	private float tremT = 2f;

	private float tremBurst;

	private bool eyeLogged;

	private bool collarOK;

	private readonly Transform[] colB = (Transform[])(object)new Transform[7];

	private readonly Transform[] colE = (Transform[])(object)new Transform[7];

	private readonly Quaternion[] colRest = (Quaternion[])(object)new Quaternion[7];

	private readonly Vector3[] colP = (Vector3[])(object)new Vector3[7];

	private readonly Vector3[] colV = (Vector3[])(object)new Vector3[7];

	private readonly float[] colLen = new float[7];

	public static GYMod I;

	public const string HUB = "c2534c5a-6b79-40ec-8e98-e58c5363656e";

	public static MelonPreferences_Entry<bool> pHub;

	public static MelonPreferences_Entry<float> pStrength;

	public static MelonPreferences_Entry<float> pJump;

	public static MelonPreferences_Entry<float> pWrist;

	private RigManager rm;

	private float rmSearch;

	private Avatar curAv;

	private bool worn;

	private bool hasTendrils;

	private bool hasReem;

	private bool isHD;

	private Transform root;

	private Transform fxRoot;

	private MelonPreferences_Entry<float> pSfxVol;

	private MelonPreferences_Entry<bool> pMirror;

	private readonly Dictionary<string, Transform> B = new Dictionary<string, Transform>();

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

	private float lastPostLate = -10f;

	private float now;

	private readonly Dictionary<string, float> errT = new Dictionary<string, float>();

	private AIBrain[] brainCache = (AIBrain[])(object)new AIBrain[0];

	private float brainT = -10f;

	private readonly List<RagRec> rags = new List<RagRec>();

	private readonly List<Thrown> thrown = new List<Thrown>();

	private readonly DoubleTap dtY = new DoubleTap();

	private readonly DoubleTap dtB = new DoubleTap();

	private readonly DoubleTap dtStick = new DoubleTap();

	private readonly DoubleTap dtX = new DoubleTap();

	private readonly DoubleTap dtRS = new DoubleTap();

	private bool lTrig;

	private bool rTrig;

	private readonly List<MatRec> mats = new List<MatRec>();

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

	private readonly List<Il2CppReferenceArray<Material>> matOrig = new List<Il2CppReferenceArray<Material>>();

	private float coreFlash;

	private float tGlowLvl;

	private float tGlowTarget;

	private readonly List<ParticleSystem> leaks = new List<ParticleSystem>();

	private float jumpOrig = -1f;

	private readonly List<Rigidbody> playerRbs = new List<Rigidbody>();

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

	public static MelonPreferences_Entry<string> pDbgAvatar;

	public static MelonPreferences_Entry<bool> pDbgTest;

	private float dbgSwapAt = -1f;

	private float dbgT0 = -1f;

	private bool dbgSwapped;

	private int dbgStep;

	private string dbgLast = "";

	private Rigidbody dbgCube;

	private Rigidbody dbgBall;

	private HandRig hR;

	private HandRig hL;

	public static MelonPreferences_Entry<string> pCalR;

	public static MelonPreferences_Entry<string> pCalL;

	public static MelonPreferences_Entry<string> pHDHands;

	public static MelonPreferences_Entry<bool> pDbgHands;

	private float handLogT;

	private float handSetupT;

	private readonly List<SkinnedMeshRenderer> hbSmr = new List<SkinnedMeshRenderer>();

	private readonly List<Il2CppReferenceArray<Transform>> hbOrig = new List<Il2CppReferenceArray<Transform>>();

	private readonly Dictionary<string, Transform> proxy = new Dictionary<string, Transform>();

	private readonly List<FLim> flim = new List<FLim>();

	private GameObject mirGO;

	private GameObject mirCamGO;

	private Camera mirCam;

	private RenderTexture mirRT;

	private Material mirMat;

	private Vector3 mirP;

	private Vector3 mirN;

	private const float MW = 2.4f;

	private const float MH = 4f;

	private float amCharge;

	private float amChargedAt;

	private float amBuzzT;

	private bool amCharging;

	private bool amCharged;

	private GameObject amFX;

	private GameObject amGlow;

	private GameObject amLightGO;

	private GYPunchSensor amSensor;

	private readonly List<Soul> souls = new List<Soul>();

	private float ambientT = 20f;

	public static MelonPreferences_Entry<bool> pRec;

	private const string RECDIR = "D:\\BonelabMods\\captures";

	private const int RW = 400;

	private const int RH = 400;

	private GameObject recCamGO;

	private Camera recCam;

	private RenderTexture recRT;

	private Texture2D recTex;

	private string recPending;

	private int recIdx;

	private int recReem;

	private int recTend;

	private bool recBroken;

	private bool recBody;

	private readonly Queue<KeyValuePair<string, Func<Vector3[]>>> recQ = new Queue<KeyValuePair<string, Func<Vector3[]>>>();

	private TM recLastTm;

	private float recTendUntil;

	private float recTendNext;

	private float recReemNext;

	private float recWornT;

	private RS rs;

	private float rsT;

	private bool reemReady;

	private static readonly string[] RN = new string[21]
	{
		"Reem_Root", "Reem_Body", "Reem_Neck", "Reem_Head", "Reem_Halo", "Reem_UpperArm_R", "Reem_Forearm_R", "Reem_UpperArm_L", "Reem_Forearm_L", "Reem_WingRoot_A",
		"Reem_WingWrist_A", "Reem_WingRoot_B", "Reem_WingWrist_B", "Reem_Thigh_R", "Reem_Shin_R", "Reem_Thigh_L", "Reem_Shin_L", "Reem_Tail_1", "Reem_Tail_2", "Reem_Tail_3",
		"Reem_Tail_4"
	};

	private const int R_ROOT = 0;

	private const int R_BODY = 1;

	private const int R_NECK = 2;

	private const int R_HEAD = 3;

	private const int R_HALO = 4;

	private const int R_UAR = 5;

	private const int R_FAR = 6;

	private const int R_UAL = 7;

	private const int R_FAL = 8;

	private const int R_WRA = 9;

	private const int R_WWA = 10;

	private const int R_WRB = 11;

	private const int R_WWB = 12;

	private const int R_THR = 13;

	private const int R_SHR = 14;

	private const int R_THL = 15;

	private const int R_SHL = 16;

	private const int R_T1 = 17;

	private Transform rRig;

	private Transform rRigParent;

	private Transform rPivot;

	private Vector3 rRigLP;

	private Quaternion rRigLR;

	private Transform[] rbn;

	private Quaternion[] rbRest;

	private Vector3 rHaloLP;

	private Vector3 rHandLR;

	private Vector3 rHandLL;

	private Vector3 rPos;

	private Vector3 rVel;

	private Vector3 rPrevVel;

	private Vector3 aimPointR;

	private float rYaw;

	private float rYawVel;

	private float rSpin;

	private float rPitch;

	private float rRoll;

	private float rBarrel;

	private float rBarrelT = -1f;

	private float rLookYaw;

	private float rLookPit;

	private float wPh;

	private float cMid;

	private float cAmp;

	private float cFreq;

	private float cSweep;

	private float cFold;

	private float cWrap;

	private float cArmFwd;

	private float cArmRaise;

	private float cElbow;

	private float cLegTuck;

	private float cLegTrail;

	private float cKick;

	private float cBody;

	private float cTilt;

	private float cCrouch;

	private float cHeadDown;

	private float tMid;

	private float tAmp;

	private float tFreq;

	private float tSweep;

	private float tFold;

	private float tWrap;

	private float tArmFwd;

	private float tArmRaise;

	private float tElbow;

	private float tLegTuck;

	private float tLegTrail;

	private float tKick;

	private float tBody;

	private float tTilt;

	private float tCrouch;

	private float tHeadDown;

	private float legSwing;

	private float legSwingV;

	private float hopT;

	private float groundY;

	private float sadT;

	private bool lookAtPlayer = true;

	private Rigidbody rTgt;

	private AIBrain rBrainT;

	private GameObject rAnchor;

	private Rigidbody rAnchorRb;

	private ConfigurableJoint rJoint;

	private Vector3 rStart;

	private Vector3 presentSpot;

	private float rTop;

	private bool rHoldUp;

	private GameObject rAura;

	private GameObject rTrail;

	private GameObject rReticle;

	private Material rHaloMat;

	private Color rHaloEm;

	private SkinnedMeshRenderer reemSmr;

	private Il2CppReferenceArray<Material> reemOrig;

	private float readyGlow;

	private float readyFlash;

	private readonly Quaternion[] tlRest = (Quaternion[])(object)new Quaternion[4];

	private readonly Vector3[] tlDir = (Vector3[])(object)new Vector3[4];

	private readonly float[] tlLen = new float[4];

	private readonly Vector3[] tlp = (Vector3[])(object)new Vector3[5];

	private readonly Vector3[] tlpp = (Vector3[])(object)new Vector3[5];

	private readonly Vector3[] tlRestL = (Vector3[])(object)new Vector3[5];

	private bool tailOK;

	private Quaternion rDiagSet;

	private bool rDiagHas;

	private int rDiagN;

	private float rHip = 0.47f;

	private float skidFx;

	private float watchT;

	private float waveT;

	private float waveCool;

	private float idleT = 4f;

	private float idleLook;

	private float tWave;

	private float cWave;

	private float skidDec = 15f;

	private Vector3 idleLookAt;

	private float fYaw;

	private bool fYawInit;

	private bool rNpc;

	private bool skidDown;

	private bool rSnap;

	private bool rLookSet;

	private bool rFlapSfx;

	private float blinkT = 3f;

	private float blinkHold;

	private float tStomp;

	private float cStomp;

	private float stompPh;

	private float rHoldY = -0.3f;

	private int exEyes;

	private int exMouth;

	private Vector3 standPos;

	private Vector3 rLookAt;

	private Transform fEyeO;

	private Transform fEyeH;

	private Transform fEyeB;

	private Transform fMouS;

	private Transform fMouO;

	private float vArmFwd;

	private float vArmRaise;

	private float vElbow;

	private float vBody;

	private float vTilt;

	private float vHeadDown;

	private float vTrail;

	private float vTuck;

	private float vCrouch;

	private float vSplit;

	private float cSq = 1f;

	private float vSq;

	private float tSq = 1f;

	private float cSplit;

	private float tSplit;

	private float cPump;

	private float tPump;

	private float cRock;

	private float tRock;

	private readonly List<Rigidbody> cRbs = new List<Rigidbody>();

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

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

	private bool carrying;

	private Quaternion carryRel;

	private float tTailA = 13f;

	private float tTailF = 0.9f;

	private float tTailP;

	private float cTailA = 13f;

	private float cTailF = 0.9f;

	private float cTailP;

	private float tailPh;

	private float tlX;

	private float tlY;

	private float tlXV;

	private float tlYV;

	private Vector3 rLv;

	private const int DN = 2;

	private readonly Transform[,] db = new Transform[2, 4];

	private readonly Quaternion[,] dRest = new Quaternion[2, 4];

	private readonly Vector3[,] dDir = new Vector3[2, 3];

	private readonly float[,] dLen = new float[2, 3];

	private readonly Vector3[,] dp = new Vector3[2, 4];

	private readonly Vector3[,] dpp = new Vector3[2, 4];

	private readonly bool[] dOK = new bool[2];

	private TM tm;

	private TM tmBeforeFan;

	private readonly Transform[] tb = (Transform[])(object)new Transform[6];

	private readonly Quaternion[] tRest = (Quaternion[])(object)new Quaternion[6];

	private readonly Vector3[] tDir = (Vector3[])(object)new Vector3[6];

	private readonly Vector3[] tRestLP = (Vector3[])(object)new Vector3[6];

	private readonly float[] tLen = new float[6];

	private readonly float[] tCur = new float[6];

	private readonly float[] tCum = new float[7];

	private readonly Vector3[] tp = (Vector3[])(object)new Vector3[7];

	private readonly Vector3[] tpp = (Vector3[])(object)new Vector3[7];

	private readonly Vector3[] tRestL = (Vector3[])(object)new Vector3[7];

	private readonly Vector3[] tTgt = (Vector3[])(object)new Vector3[7];

	private Transform foreL;

	private Transform handL;

	private readonly Transform[] claws = (Transform[])(object)new Transform[3];

	private readonly Quaternion[] clawRest = (Quaternion[])(object)new Quaternion[3];

	private readonly Vector3[] clawAx = (Vector3[])(object)new Vector3[3];

	private float clawOpen;

	private float clawOpenT;

	private float tStretch = 1f;

	private float tStretchT = 1f;

	private GameObject tReticle;

	private GameObject tAimLine;

	private GameObject tTrail;

	private GameObject tSmear;

	private GameObject shieldGO;

	private Rigidbody shieldRb;

	private bool aimValid;

	private Vector3 aimPoint;

	private Vector3 aimNormal = Vector3.up;

	private Rigidbody aimRb;

	private AIBrain aimBrain;

	private Rigidbody gRb;

	private AIBrain gBrain;

	private GameObject gAnchor;

	private Rigidbody gAnchorRb;

	private ConfigurableJoint gJoint;

	private float gHold;

	private float gShoot;

	private Vector3 gPrevAnchor;

	private Vector3 gAnchorVel;

	private Vector3 gLocal;

	private Vector3 gpPoint;

	private Vector3 shootTarget;

	private float gpLen;

	private bool shootIsGrapple;

	private float fanAng;

	private float fanSpeed;

	private float whipT = -10f;

	private float whipCd;

	private Vector3 whipDir;

	private readonly Dictionary<global::System.IntPtr, float> fanHit = new Dictionary<global::System.IntPtr, float>();

	private const float TRANGE = 26f;

	private float liveK;

	private float hScan;

	private float gSwing;

	private float gExt;

	private float gHandHold;

	private float tipSoft;

	private bool lGrip;

	private bool gHand;

	private bool hadCand;

	private Rigidbody hCand;

	private Vector3 hCandPoint;

	private Vector3 gPrevAim;

	private Vector3 gSpring;

	private Vector3 gSpringV;

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

	private readonly List<AudioSource> sfxPool = new List<AudioSource>();

	private AudioSource breathSrc;

	private Animator jawAnim;

	private float jawPrevT = -1f;

	private float growlT = 12f;

	private float sfxVol = 1f;

	private int sfxNext;

	private readonly float[] stepBase = new float[2];

	private readonly bool[] stepUp = new bool[2];

	private float stepCool;

	private BaseController LC => rm.controllerRig.leftController;

	private BaseController RC => rm.controllerRig.rightController;

	private void SetupCape()
	{
		//IL_01b0: 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_01ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_020b: Unknown result type (might be due to invalid IL or missing references)
		//IL_023e: 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_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_0285: Unknown result type (might be due to invalid IL or missing references)
		//IL_0286: Unknown result type (might be due to invalid IL or missing references)
		//IL_0288: Unknown result type (might be due to invalid IL or missing references)
		//IL_028d: Unknown result type (might be due to invalid IL or missing references)
		//IL_028f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_030f: Unknown result type (might be due to invalid IL or missing references)
		capeOK = false;
		chest = Bn("Chest");
		hipsB = Bn("Hips");
		neckB = Bn("Neck");
		lUL = Bn("LeftUpperLeg");
		lLL = Bn("LeftLowerLeg");
		lF = Bn("LeftFoot");
		rUL = Bn("RightUpperLeg");
		rLL = Bn("RightLowerLeg");
		rF = Bn("RightFoot");
		if ((Object)(object)chest == (Object)null || (Object)(object)hipsB == (Object)null || (Object)(object)neckB == (Object)null || (Object)(object)lF == (Object)null || (Object)(object)rF == (Object)null)
		{
			return;
		}
		string[] array = ((!((Object)(object)Bn("GY_Cape_A1") != (Object)null)) ? new string[3] { "R", "C", "L" } : new string[5] { "A", "B", "C", "D", "E" });
		NC = array.Length;
		for (int i = 0; i < NC; i++)
		{
			for (int j = 0; j < 5; j++)
			{
				cb[i, j] = Bn("GY_Cape_" + array[i] + (j + 1));
				if ((Object)(object)cb[i, j] == (Object)null)
				{
					return;
				}
				cRest[i, j] = cb[i, j].localRotation;
			}
		}
		for (int k = 0; k < NC; k++)
		{
			for (int l = 0; l < 4; l++)
			{
				Vector3 val = cb[k, l + 1].position - cb[k, l].position;
				cLen[k, l] = ((Vector3)(ref val)).magnitude;
				cDir[k, l] = cb[k, l].InverseTransformDirection(((Vector3)(ref val)).normalized);
			}
			for (int m = 0; m < 5; m++)
			{
				cp[k, m] = (cpp[k, m] = cb[k, m].position);
				cRestL[k, m] = chest.InverseTransformPoint(cb[k, m].position);
			}
		}
		for (int n = 0; n < 5; n++)
		{
			for (int num = 0; num < NC - 1; num++)
			{
				cH[num, n] = Vector3.Distance(cp[num, n], cp[num + 1, n]);
			}
		}
		capeOK = true;
	}

	private void TeardownCape()
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		if (!capeOK)
		{
			return;
		}
		for (int i = 0; i < NC; i++)
		{
			for (int j = 0; j < 5; j++)
			{
				if ((Object)(object)cb[i, j] != (Object)null)
				{
					cb[i, j].localRotation = cRest[i, j];
				}
			}
		}
		capeOK = false;
	}

	private void CapeSim(float dt)
	{
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: 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_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: 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_0076: 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_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: 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_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0301: Unknown result type (might be due to invalid IL or missing references)
		//IL_0309: Unknown result type (might be due to invalid IL or missing references)
		//IL_030e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0316: Unknown result type (might be due to invalid IL or missing references)
		//IL_031b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0323: Unknown result type (might be due to invalid IL or missing references)
		//IL_0328: Unknown result type (might be due to invalid IL or missing references)
		//IL_0330: Unknown result type (might be due to invalid IL or missing references)
		//IL_0335: 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_0342: Unknown result type (might be due to invalid IL or missing references)
		//IL_034a: Unknown result type (might be due to invalid IL or missing references)
		//IL_034f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0357: Unknown result type (might be due to invalid IL or missing references)
		//IL_035c: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fc: 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_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_021e: 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_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: Unknown result type (might be due to invalid IL or missing references)
		//IL_024a: Unknown result type (might be due to invalid IL or missing references)
		//IL_024f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: 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_02aa: 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_02cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0558: Unknown result type (might be due to invalid IL or missing references)
		//IL_056e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0573: Unknown result type (might be due to invalid IL or missing references)
		//IL_0578: Unknown result type (might be due to invalid IL or missing references)
		//IL_0586: Unknown result type (might be due to invalid IL or missing references)
		//IL_058d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0592: Unknown result type (might be due to invalid IL or missing references)
		//IL_0597: 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_05ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_05b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_05b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_05be: Unknown result type (might be due to invalid IL or missing references)
		//IL_0440: Unknown result type (might be due to invalid IL or missing references)
		//IL_0442: Unknown result type (might be due to invalid IL or missing references)
		//IL_045d: Unknown result type (might be due to invalid IL or missing references)
		//IL_045f: Unknown result type (might be due to invalid IL or missing references)
		//IL_047a: Unknown result type (might be due to invalid IL or missing references)
		//IL_047c: 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_0499: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
		if (!capeOK || (Object)(object)chest == (Object)null)
		{
			return;
		}
		dt = Mathf.Clamp(dt, 0.001f, 0.033f);
		for (int i = 0; i < NC; i++)
		{
			for (int j = 0; j < 5; j++)
			{
				cb[i, j].localRotation = cRest[i, j];
			}
		}
		Vector3 val = Vector3.zero;
		try
		{
			val = rm.physicsRig.wholeBodyVelocity;
		}
		catch
		{
		}
		float num = Mathf.Min(lF.position.y, rF.position.y) - 0.16f;
		float num2 = dt / 2f;
		Vector3 val2 = Physics.gravity * 0.8f;
		Vector3 val3 = new Vector3(Mathf.Sin(now * 0.7f), 0f, Mathf.Cos(now * 0.53f)) * 0.5f + new Vector3(Mathf.PerlinNoise(now * 0.8f, 0.3f) - 0.5f, 0f, Mathf.PerlinNoise(0.7f, now * 0.8f) - 0.5f) * 1.8f;
		for (int k = 0; k < 2; k++)
		{
			for (int l = 0; l < NC; l++)
			{
				cp[l, 0] = cb[l, 0].position;
				cpp[l, 0] = cp[l, 0];
				for (int m = 1; m < 5; m++)
				{
					Vector3 val4 = (cp[l, m] - cpp[l, m]) * 0.97f;
					cpp[l, m] = cp[l, m];
					Vector3 val5 = val2 + (val3 - val * 0.35f) * (0.25f + 0.2f * (float)m);
					ref Vector3 reference = ref cp[l, m];
					reference += val4 + val5 * num2 * num2;
					Vector3 val6 = chest.TransformPoint(cRestL[l, m]);
					float num3 = Mathf.Lerp(0.09f, 0.035f, (float)(m - 1) / 3f);
					cp[l, m] = Vector3.Lerp(cp[l, m], val6, 1f - Mathf.Pow(1f - num3, num2 * 60f));
				}
			}
			Vector3 position = hipsB.position;
			Vector3 position2 = neckB.position;
			Vector3 position3 = lUL.position;
			Vector3 position4 = lLL.position;
			Vector3 position5 = lF.position;
			Vector3 position6 = rUL.position;
			Vector3 position7 = rLL.position;
			Vector3 position8 = rF.position;
			for (int n = 0; n < 3; n++)
			{
				for (int num4 = 0; num4 < NC; num4++)
				{
					for (int num5 = 1; num5 < 5; num5++)
					{
						Dist(ref cp[num4, num5 - 1], ref cp[num4, num5], cLen[num4, num5 - 1], num5 == 1);
					}
				}
				for (int num6 = 1; num6 < 5; num6++)
				{
					for (int num7 = 0; num7 < NC - 1; num7++)
					{
						MaxDist(ref cp[num7, num6], ref cp[num7 + 1, num6], cH[num7, num6]);
					}
				}
				for (int num8 = 0; num8 < NC; num8++)
				{
					for (int num9 = 1; num9 < 5; num9++)
					{
						Capsule(ref cp[num8, num9], position, position2, 0.25f);
						Capsule(ref cp[num8, num9], position3, position4, 0.2f);
						Capsule(ref cp[num8, num9], position4, position5, 0.23f);
						Capsule(ref cp[num8, num9], position6, position7, 0.2f);
						Capsule(ref cp[num8, num9], position7, position8, 0.23f);
						if (cp[num8, num9].y < num)
						{
							cp[num8, num9].y = num;
						}
					}
				}
			}
		}
		for (int num10 = 0; num10 < NC; num10++)
		{
			for (int num11 = 0; num11 < 4; num11++)
			{
				Transform val7 = cb[num10, num11];
				val7.localRotation = cRest[num10, num11];
				Vector3 val8 = val7.TransformDirection(cDir[num10, num11]);
				Vector3 val9 = cp[num10, num11 + 1] - val7.position;
				if (((Vector3)(ref val9)).sqrMagnitude > 1E-08f)
				{
					val7.rotation = Quaternion.FromToRotation(val8, ((Vector3)(ref val9)).normalized) * val7.rotation;
				}
			}
		}
	}

	private Vector3 RestDirInBone(string meshName, string boneName, Vector3 dirRoot)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: 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_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: 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_009a: Unknown result type (might be due to invalid IL or missing references)
		Transform val = Bn(meshName);
		if ((Object)(object)val == (Object)null)
		{
			return Vector3.zero;
		}
		SkinnedMeshRenderer component = ((Component)val).GetComponent<SkinnedMeshRenderer>();
		if ((Object)(object)component == (Object)null)
		{
			return Vector3.zero;
		}
		Il2CppReferenceArray<Transform> bones = component.bones;
		Il2CppStructArray<Matrix4x4> bindposes = component.sharedMesh.bindposes;
		Vector3 val2 = ((Component)component).transform.InverseTransformDirection(root.TransformDirection(dirRoot));
		for (int i = 0; i < ((Il2CppArrayBase<Transform>)(object)bones).Length && i < ((Il2CppArrayBase<Matrix4x4>)(object)bindposes).Length; i++)
		{
			if ((Object)(object)((Il2CppArrayBase<Transform>)(object)bones)[i] != (Object)null && ((Object)((Il2CppArrayBase<Transform>)(object)bones)[i]).name == boneName)
			{
				Matrix4x4 val3 = ((Il2CppArrayBase<Matrix4x4>)(object)bindposes)[i];
				Vector3 val4 = ((Matrix4x4)(ref val3)).MultiplyVector(val2);
				return ((Vector3)(ref val4)).normalized;
			}
		}
		return Vector3.zero;
	}

	private void SetupEyes()
	{
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		pupil = Bn("GY_Pupil");
		headB = Bn("Head");
		if ((Object)(object)pupil == (Object)null || (Object)(object)headB == (Object)null)
		{
			pupil = null;
			return;
		}
		pupilRest = pupil.localPosition;
		faceF = RestDirInBone("HeadMesh", "Head", Vector3.forward);
		faceU = RestDirInBone("HeadMesh", "Head", Vector3.up);
		if (faceF == Vector3.zero || faceU == Vector3.zero)
		{
			pupil = null;
			return;
		}
		Vector3 val = Vector3.Cross(faceU, faceF);
		faceR = ((Vector3)(ref val)).normalized;
		eyeOff = Vector3.zero;
	}

	private void Eyes(float dt)
	{
		//IL_004b: 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_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: 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_0090: 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_009a: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: 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_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_0175: 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_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0292: Unknown result type (might be due to invalid IL or missing references)
		//IL_0297: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0314: Unknown result type (might be due to invalid IL or missing references)
		//IL_0319: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)pupil == (Object)null || (Object)(object)headB == (Object)null)
		{
			return;
		}
		eyeScan -= dt;
		if (eyeScan <= 0f)
		{
			eyeScan = 0.35f;
			eyeHas = NearestNpc(headB.position, 15f, out eyeTgt);
		}
		Vector3 val;
		float num2;
		float num3;
		if (eyeHas)
		{
			Transform obj = headB;
			val = eyeTgt - headB.position;
			Vector3 val2 = obj.InverseTransformDirection(((Vector3)(ref val)).normalized);
			float num = Mathf.Max(Vector3.Dot(val2, faceF), 0.3f);
			num2 = Mathf.Clamp(Vector3.Dot(val2, faceR) / num, -1f, 1f);
			num3 = Mathf.Clamp(Vector3.Dot(val2, faceU) / num, -1f, 1f);
		}
		else
		{
			saccT -= dt;
			if (saccT <= 0f)
			{
				saccT = Random.Range(0.25f, 1.9f);
				sacc = new Vector3(Random.Range(-0.85f, 0.85f), Random.Range(-0.6f, 0.6f), 0f);
			}
			num2 = sacc.x;
			num3 = sacc.y;
		}
		eyeOff = Vector3.Lerp(eyeOff, new Vector3(num2, num3, 0f), 1f - Mathf.Exp(-22f * dt));
		Vector3 val3 = headB.TransformDirection(faceR);
		Vector3 val4 = headB.TransformDirection(faceU);
		tremT -= dt;
		if (tremT <= 0f)
		{
			tremT = Random.Range(1.4f, 3.8f);
			tremBurst = Random.Range(0.3f, 0.8f);
		}
		float num4 = (eyeHas ? 0.016f : 0.011f);
		if (tremBurst > 0f)
		{
			tremBurst -= dt;
			num4 = 0.034f;
		}
		float num5 = (Mathf.PerlinNoise(now * 34f, 0.37f) - 0.5f) * 2f;
		float num6 = (Mathf.PerlinNoise(0.71f, now * 41f) - 0.5f) * 2f;
		Vector3 val5 = val3 * (eyeOff.x * 0.062f + num5 * num4) + val4 * (eyeOff.y * 0.045f + num6 * num4);
		Transform parent = pupil.parent;
		pupil.localPosition = pupilRest + (((Object)(object)parent != (Object)null) ? parent.InverseTransformVector(val5) : val5);
		if (!eyeLogged)
		{
			eyeLogged = true;
			Instance loggerInstance = ((MelonBase)this).LoggerInstance;
			val = pupil.lossyScale;
			loggerInstance.Msg("[Eyes] pupil ok, bone scale=" + val.x.ToString("F3"));
		}
	}

	private void SetupCollar()
	{
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//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_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_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		collarOK = false;
		for (int i = 0; i < 7; i++)
		{
			colB[i] = Bn("GY_Collar_" + (i + 1));
			colE[i] = Bn("GY_CollarEnd_" + (i + 1));
			if ((Object)(object)colB[i] == (Object)null || (Object)(object)colE[i] == (Object)null)
			{
				return;
			}
			colRest[i] = colB[i].localRotation;
			colP[i] = colE[i].position;
			colV[i] = Vector3.zero;
			colLen[i] = Mathf.Max(0.05f, Vector3.Distance(colB[i].position, colE[i].position));
		}
		collarOK = true;
	}

	private void CollarSim(float dt)
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: 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_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_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_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: 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)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: 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_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Unknown result type (might be due to invalid IL or missing references)
		//IL_025c: 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_0263: Unknown result type (might be due to invalid IL or missing references)
		//IL_026c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0271: 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_01f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: 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)
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_0219: Unknown result type (might be due to invalid IL or missing references)
		//IL_021e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_0233: Unknown result type (might be due to invalid IL or missing references)
		//IL_0238: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_0255: Unknown result type (might be due to invalid IL or missing references)
		//IL_0299: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a0: 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_02ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
		if (!collarOK)
		{
			return;
		}
		dt = Mathf.Clamp(dt, 0.001f, 0.05f);
		int num = Mathf.Max(1, Mathf.CeilToInt(dt / 0.009f));
		float num2 = dt / (float)num;
		for (int i = 0; i < 7; i++)
		{
			Transform val = colB[i];
			val.localRotation = colRest[i];
			Vector3 position = val.position;
			Vector3 position2 = colE[i].position;
			float num3 = colLen[i];
			position2 += (root.right * Mathf.Sin(now * 1.9f + (float)i * 1.3f) + Vector3.up * Mathf.Cos(now * 2.3f + (float)i)) * (0.012f * num3);
			Vector3 val2 = colP[i] - position2;
			if (((Vector3)(ref val2)).sqrMagnitude > 9f * num3 * num3)
			{
				colP[i] = position2;
				colV[i] = Vector3.zero;
			}
			for (int j = 0; j < num; j++)
			{
				ref Vector3 reference = ref colV[i];
				reference += ((position2 - colP[i]) * 441f - colV[i] * 12.6f) * num2;
				ref Vector3 reference2 = ref colP[i];
				reference2 += colV[i] * num2;
			}
			Vector3 val3 = colP[i] - position2;
			float magnitude = ((Vector3)(ref val3)).magnitude;
			float num4 = 0.3f * num3;
			if (magnitude > num4)
			{
				colP[i] = position2 + val3 * (num4 / magnitude);
				ref Vector3 reference3 = ref colV[i];
				reference3 -= val3 / magnitude * Mathf.Max(0f, Vector3.Dot(colV[i], val3 / magnitude));
			}
			Vector3 val4 = position2 - position;
			Vector3 val5 = colP[i] - position;
			if (((Vector3)(ref val4)).sqrMagnitude > 1E-08f && ((Vector3)(ref val5)).sqrMagnitude > 1E-08f)
			{
				val.rotation = Quaternion.FromToRotation(((Vector3)(ref val4)).normalized, ((Vector3)(ref val5)).normalized) * val.rotation;
			}
		}
	}

	private void TeardownCollar()
	{
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		if (!collarOK)
		{
			return;
		}
		for (int i = 0; i < 7; i++)
		{
			if ((Object)(object)colB[i] != (Object)null)
			{
				colB[i].localRotation = colRest[i];
			}
		}
		collarOK = false;
	}

	public override void OnInitializeMelon()
	{
		I = this;
		MelonPreferences_Category val = MelonPreferences.CreateCategory("Graveyard");
		pHub = val.CreateEntry<bool>("BootToHub", true, "Skip Void G114 and start in the BONELAB Hub", (string)null, false, false, (ValueValidator)null, (string)null);
		pStrength = val.CreateEntry<float>("StrengthMultiplier", 2.2f, "Arm/grip strength multiplier while Graveyard is worn", (string)null, false, false, (ValueValidator)null, (string)null);
		pJump = val.CreateEntry<float>("JumpMultiplier", 1.6f, "Jump velocity multiplier while Graveyard is worn", (string)null, false, false, (ValueValidator)null, (string)null);
		pWrist = val.CreateEntry<float>("WristRelax", 0.3f, "0 = off, 1 = empty hands fully follow the forearm", (string)null, false, false, (ValueValidator)null, (string)null);
		pDbgAvatar = val.CreateEntry<string>("DebugAutoAvatar", "", "(debug) avatar barcode to auto-equip on load", (string)null, false, false, (ValueValidator)null, (string)null);
		pDbgTest = val.CreateEntry<bool>("DebugSelfTest", false, "(debug) run the ability self test after equipping", (string)null, false, false, (ValueValidator)null, (string)null);
		pDbgHands = val.CreateEntry<bool>("DebugHands", false, "(debug) log hand/arm angles every second", (string)null, false, false, (ValueValidator)null, (string)null);
		pCalR = val.CreateEntry<string>("WristOffsetRight", "43,0,0", "wrist straightening for the right hand (degrees)", (string)null, false, false, (ValueValidator)null, (string)null);
		pCalL = val.CreateEntry<string>("WristOffsetLeft", "46,0,0", "wrist straightening for the left hand (degrees)", (string)null, false, false, (ValueValidator)null, (string)null);
		pHDHands = val.CreateEntry<string>("HDHandMode", "native", "Graveyard HD hands: native = the game poses the fingers, proxy = the mod poses them", (string)null, false, false, (ValueValidator)null, (string)null);
		pMirror = val.CreateEntry<bool>("Mirror", false, "double-tap X puts a mirror in front of you (off by default: X is also the slow motion button)", (string)null, false, false, (ValueValidator)null, (string)null);
		pSfxVol = val.CreateEntry<float>("SoundVolume", 1f, "volume of the Graveyard / Reem sound effects (0 = off, 1 = normal, 2 = loud)", (string)null, false, false, (ValueValidator)null, (string)null);
		pRec = val.CreateEntry<bool>("Recorder", false, "save pictures of the avatar to D:\\BonelabMods\\captures while playing", (string)null, false, false, (ValueValidator)null, (string)null);
		try
		{
			if (Directory.Exists("D:\\BonelabMods\\captures"))
			{
				string[] files = Directory.GetFiles("D:\\BonelabMods\\captures", "*.bmp");
				for (int i = 0; i < files.Length; i++)
				{
					File.Delete(files[i]);
				}
			}
		}
		catch
		{
		}
		try
		{
			ClassInjector.RegisterTypeInIl2Cpp<GYPunchSensor>();
		}
		catch (global::System.Exception ex)
		{
			((MelonBase)this).LoggerInstance.Warning("sensor register: " + ex.Message);
		}
		((MelonBase)this).LoggerInstance.Msg("Graveyard mod ready (Sanadid + Claude).");
	}

	public void Err(string where, global::System.Exception e)
	{
		float num = default(float);
		if (!errT.TryGetValue(where, ref num) || !(Time.time - num < 5f))
		{
			errT[where] = Time.time;
			((MelonBase)this).LoggerInstance.Warning("[" + where + "] " + (object)e);
		}
	}

	private void TryRun(string n, Action a)
	{
		try
		{
			a.Invoke();
		}
		catch (global::System.Exception e)
		{
			Err(n, e);
		}
	}

	private Transform Bn(string n)
	{
		Transform result = default(Transform);
		if (!B.TryGetValue(n, ref result))
		{
			return null;
		}
		return result;
	}

	private static bool IsGraveyard(Avatar av)
	{
		try
		{
			return (Object)(object)av != (Object)null && (Object)(object)((Component)av).transform.Find("GY_FX") != (Object)null;
		}
		catch
		{
			return false;
		}
	}

	public override void OnUpdate()
	{
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Expected O, but got Unknown
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Expected O, but got Unknown
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Expected O, but got Unknown
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Expected O, but got Unknown
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Expected O, but got Unknown
		//IL_019e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a8: Expected O, but got Unknown
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Expected O, but got Unknown
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Expected O, but got Unknown
		now = Time.time;
		try
		{
			if ((Object)(object)rm == (Object)null)
			{
				if (worn)
				{
					Teardown();
				}
				curAv = null;
				rmSearch -= Time.unscaledDeltaTime;
				if (rmSearch > 0f)
				{
					return;
				}
				rmSearch = 1f;
				rm = Object.FindObjectOfType<RigManager>();
				if ((Object)(object)rm == (Object)null)
				{
					return;
				}
			}
			Avatar avatar = rm.avatar;
			if ((Object)(object)avatar != (Object)(object)curAv)
			{
				if (worn)
				{
					Teardown();
				}
				curAv = avatar;
				if (IsGraveyard(avatar))
				{
					Setup(avatar);
				}
			}
			TryRun("Debug", new Action(DebugUpdate));
			if (worn)
			{
				TryRun("RecRead", new Action(RecRead));
			}
			if (!worn)
			{
				return;
			}
			if ((Object)(object)root == (Object)null)
			{
				Teardown();
				return;
			}
			float dt = Time.deltaTime;
			TryRun("Input", new Action(Inputs));
			if (hasTendrils)
			{
				TryRun("Tendrils", (Action)delegate
				{
					UpdateTendrils(dt);
				});
			}
			TryRun("Antimatter", (Action)delegate
			{
				UpdateAntimatter(dt);
			});
			TryRun("Souls", (Action)delegate
			{
				UpdateSouls(dt);
			});
			TryRun("Glow", (Action)delegate
			{
				UpdateGlow(dt);
			});
			TryRun("Thrown", (Action)delegate
			{
				UpdateThrown(dt);
			});
		}
		catch (global::System.Exception e)
		{
			Err("Update", e);
		}
	}

	public void PostLate(RigManager r)
	{
		if (worn && !((Object)(object)rm == (Object)null) && !((Object)(object)r == (Object)null) && !(((Il2CppObjectBase)r).Pointer != ((Il2CppObjectBase)rm).Pointer))
		{
			lastPostLate = Time.time;
			AnimateAll(Time.deltaTime);
		}
	}

	public override void OnLateUpdate()
	{
		if (worn && Time.time - lastPostLate > 0.3f)
		{
			AnimateAll(Time.deltaTime);
		}
	}

	private void AnimateAll(float dt)
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Expected O, but got Unknown
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Expected O, but got Unknown
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Expected O, but got Unknown
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Expected O, but got Unknown
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Expected O, but got Unknown
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Expected O, but got Unknown
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Expected O, but got Unknown
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Expected O, but got Unknown
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Expected O, but got Unknown
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Expected O, but got Unknown
		TryRun("Hands", (Action)delegate
		{
			Hands(dt);
		});
		TryRun("Mirror", new Action(MirrorUpdate));
		TryRun("Rec", new Action(RecTick));
		TryRun("Cape", (Action)delegate
		{
			CapeSim(dt);
		});
		TryRun("Collar", (Action)delegate
		{
			CollarSim(dt);
		});
		if (hasTendrils)
		{
			TryRun("TendrilSim", (Action)delegate
			{
				TendrilSim(dt);
			});
		}
		if (hasReem)
		{
			TryRun("Reem", (Action)delegate
			{
				UpdateReem(dt);
			});
		}
		TryRun("Eyes", (Action)delegate
		{
			Eyes(dt);
		});
		TryRun("Drool", (Action)delegate
		{
			DroolSim(dt);
		});
		TryRun("SfxAmb", (Action)delegate
		{
			SfxAmbient(dt);
		});
	}

	public override void OnFixedUpdate()
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Expected O, but got Unknown
		if (!worn)
		{
			return;
		}
		float dt = Time.fixedDeltaTime;
		if (hasTendrils)
		{
			TryRun("TFixed", (Action)delegate
			{
				TendrilFixed(dt);
			});
		}
		if (hasReem)
		{
			TryRun("RFixed", (Action)delegate
			{
				ReemFixed(dt);
			});
		}
	}

	private void Setup(Avatar av)
	{
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Expected O, but got Unknown
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Expected O, but got Unknown
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Expected O, but got Unknown
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Expected O, but got Unknown
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Expected O, but got Unknown
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Expected O, but got Unknown
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Expected O, but got Unknown
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b4: Expected O, but got Unknown
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Expected O, but got Unknown
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Expected O, but got Unknown
		//IL_020e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0218: Expected O, but got Unknown
		//IL_0225: Unknown result type (might be due to invalid IL or missing references)
		//IL_022f: Expected O, but got Unknown
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0246: Expected O, but got Unknown
		//IL_0253: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: Expected O, but got Unknown
		//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d3: Expected O, but got Unknown
		root = ((Component)av).transform;
		B.Clear();
		global::System.Collections.Generic.IEnumerator<Transform> enumerator = ((Component)root).GetComponentsInChildren<Transform>(true).GetEnumerator();
		try
		{
			while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
			{
				Transform current = enumerator.Current;
				if (!B.ContainsKey(((Object)current).name))
				{
					B[((Object)current).name] = current;
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator)?.Dispose();
		}
		fxRoot = Bn("GY_FX");
		hasTendrils = (Object)(object)Bn("LeftArm_Tendrils") != (Object)null && (Object)(object)Bn("GY_Tendril_1") != (Object)null;
		hasReem = (Object)(object)Bn("Reem_Root") != (Object)null && (Object)(object)Bn("Reem") != (Object)null;
		isHD = (Object)(object)Bn("GY_HD") != (Object)null;
		worn = true;
		TryRun("SetupMats", new Action(SetupMats));
		TryRun("SetupLeaks", new Action(SetupLeaks));
		TryRun("SetupCape", new Action(SetupCape));
		TryRun("SetupEyes", new Action(SetupEyes));
		TryRun("SetupPlayer", new Action(SetupPlayerBodies));
		TryRun("SetupHands", new Action(SetupHands));
		TryRun("SetupAntimatter", new Action(SetupAntimatter));
		if (hasTendrils)
		{
			TryRun("SetupTendrils", new Action(SetupTendrils));
		}
		if (hasReem)
		{
			TryRun("SetupReem", new Action(SetupReem));
		}
		TryRun("Shaders", new Action(ShaderSafety));
		TryRun("SetupDrool", new Action(SetupDrool));
		TryRun("SetupSfx", new Action(SetupSfx));
		TryRun("SetupCollar", new Action(SetupCollar));
		TryRun("SetupJump", new Action(SetupJump));
		TryRun("RecSetup", new Action(RecSetup));
		((MelonBase)this).LoggerInstance.Msg(string.Concat(new string[8]
		{
			"Graveyard worn: ",
			((Object)((Component)av).gameObject).name,
			"  tendrils=",
			hasTendrils.ToString(),
			" reem=",
			hasReem.ToString(),
			" hd=",
			isHD.ToString()
		}));
	}

	private void Teardown()
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Expected O, but got Unknown
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Expected O, but got Unknown
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Expected O, but got Unknown
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Expected O, but got Unknown
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Expected O, but got Unknown
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Expected O, but got Unknown
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Expected O, but got Unknown
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Expected O, but got Unknown
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Expected O, but got Unknown
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Expected O, but got Unknown
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Expected O, but got Unknown
		//IL_010a: 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)
		worn = false;
		TryRun("TD Tendrils", new Action(TeardownTendrils));
		TryRun("TD Reem", new Action(TeardownReem));
		TryRun("TD Anti", new Action(TeardownAntimatter));
		TryRun("TD Souls", new Action(TeardownSouls));
		TryRun("TD Cape", new Action(TeardownCape));
		TryRun("TD Collar", new Action(TeardownCollar));
		TryRun("TD Mats", new Action(TeardownMats));
		TryRun("TD Leaks", new Action(TeardownLeaks));
		TryRun("TD Jump", new Action(TeardownJump));
		TryRun("TD Hands", new Action(TeardownHands));
		TryRun("TD Mirror", new Action(DestroyMirror));
		Enumerator<GameObject> enumerator = spawned.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				GameObject current = enumerator.Current;
				try
				{
					if ((Object)(object)current != (Object)null)
					{
						Object.Destroy((Object)(object)current);
					}
				}
				catch
				{
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
		spawned.Clear();
		root = null;
		fxRoot = null;
		B.Clear();
	}

	public GameObject SpawnFX(string name, Vector3 pos, Quaternion rot, float life)
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)fxRoot == (Object)null)
		{
			return null;
		}
		Transform val = fxRoot.Find(name);
		if ((Object)(object)val == (Object)null)
		{
			return null;
		}
		GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject);
		val2.transform.SetPositionAndRotation(pos, rot);
		val2.SetActive(true);
		spawned.RemoveAll((Predicate<GameObject>)((GameObject x) => (Object)(object)x == (Object)null));
		spawned.Add(val2);
		if (life > 0f)
		{
			Object.Destroy((Object)(object)val2, life);
		}
		return val2;
	}

	private static void SetActive(GameObject g, bool on)
	{
		if ((Object)(object)g != (Object)null && g.activeSelf != on)
		{
			g.SetActive(on);
		}
	}

	private static void KillGO(ref GameObject g)
	{
		if ((Object)(object)g != (Object)null)
		{
			try
			{
				Object.Destroy((Object)(object)g);
			}
			catch
			{
			}
		}
		g = null;
	}

	private static void SetMatColor(GameObject g, Color c)
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)g == (Object)null))
		{
			Renderer component = g.GetComponent<Renderer>();
			if ((Object)(object)component != (Object)null)
			{
				component.material.SetColor("_BaseColor", c);
			}
		}
	}

	private void Buzz(BaseController c, float dur, float amp)
	{
		try
		{
			if ((Object)(object)c != (Object)null)
			{
				c.HapticAction(0f, dur, 160f, amp);
			}
		}
		catch
		{
		}
	}

	private bool IsSelf(Rigidbody rb)
	{
		try
		{
			return (Object)(object)rb != (Object)null && rm.physicsRig.selfRbs.Contains(rb);
		}
		catch
		{
			return false;
		}
	}

	private Vector3 HandVel(bool left)
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		return (left ? rm.physicsRig.leftHand : rm.physicsRig.rightHand).rb.velocity - rm.physicsRig.torso.rbPelvis.velocity;
	}

	private Vector3 PlayerFwd()
	{
		//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_002e: 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)
		Vector3 forward = root.forward;
		forward.y = 0f;
		if (!(((Vector3)(ref forward)).sqrMagnitude > 0.0001f))
		{
			return Vector3.forward;
		}
		return ((Vector3)(ref forward)).normalized;
	}

	private static float Yaw(Vector3 v)
	{
		//IL_0000: 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)
		return Mathf.Atan2(v.x, v.z) * 57.29578f;
	}

	private static float Ease(float a, float b, float rate, float dt)
	{
		return Mathf.Lerp(a, b, 1f - Mathf.Exp((0f - rate) * dt));
	}

	public bool AimCast(Vector3 o, Vector3 d, float range, float radius, out RaycastHit best)
	{
		//IL_0002: 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_0013: 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_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		best = default(RaycastHit);
		float num = 3.4028235E+38f;
		bool result = false;
		Il2CppStructArray<RaycastHit> val = Physics.SphereCastAll(o, radius, d, range, -1, (QueryTriggerInteraction)1);
		for (int i = 0; i < ((Il2CppArrayBase<RaycastHit>)(object)val).Length; i++)
		{
			RaycastHit val2 = ((Il2CppArrayBase<RaycastHit>)(object)val)[i];
			if (((RaycastHit)(ref val2)).distance <= 0.001f)
			{
				continue;
			}
			Collider collider = ((RaycastHit)(ref val2)).collider;
			if (!((Object)(object)collider == (Object)null))
			{
				Rigidbody rigidbody = ((RaycastHit)(ref val2)).rigidbody;
				if ((!((Object)(object)rigidbody != (Object)null) || (!IsSelf(rigidbody) && (!rigidbody.isKinematic || !((Object)((Component)rigidbody).gameObject).name.StartsWith("GY_")))) && (!((Object)(object)shieldGO != (Object)null) || !((Object)(object)((Component)collider).gameObject == (Object)(object)shieldGO)) && ((RaycastHit)(ref val2)).distance < num)
				{
					num = ((RaycastHit)(ref val2)).distance;
					best = val2;
					result = true;
				}
			}
		}
		return result;
	}

	private static void Dist(ref Vector3 a, ref Vector3 b, float len, bool pinA)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: 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_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_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: 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)
		Vector3 val = b - a;
		float magnitude = ((Vector3)(ref val)).magnitude;
		if (!(magnitude < 1E-06f))
		{
			Vector3 val2 = val * ((magnitude - len) / magnitude);
			if (pinA)
			{
				b -= val2;
				return;
			}
			a += val2 * 0.5f;
			b -= val2 * 0.5f;
		}
	}

	private static void MaxDist(ref Vector3 a, ref Vector3 b, float len)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: 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_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = b - a;
		float magnitude = ((Vector3)(ref val)).magnitude;
		if (!(magnitude <= len) && !(magnitude < 1E-06f))
		{
			Vector3 val2 = val * ((magnitude - len) / magnitude) * 0.5f;
			a += val2;
			b -= val2;
		}
	}

	private static void Capsule(ref Vector3 p, Vector3 a, Vector3 b, float r)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: 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_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: 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_0041: 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_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: 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_0083: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = b - a;
		float num = Mathf.Clamp01(Vector3.Dot(p - a, val) / Mathf.Max(((Vector3)(ref val)).sqrMagnitude, 1E-06f));
		Vector3 val2 = a + val * num;
		Vector3 val3 = p - val2;
		float magnitude = ((Vector3)(ref val3)).magnitude;
		if (magnitude < r)
		{
			val3 = ((!(magnitude < 1E-05f)) ? (val3 / magnitude) : Vector3.back);
			p = val2 + val3 * r;
		}
	}

	public AIBrain[] Brains()
	{
		if (now - brainT > 1.5f)
		{
			brainT = now;
			List<AIBrain> val = new List<AIBrain>();
			try
			{
				global::System.Collections.Generic.IEnumerator<AIBrain> enumerator = Object.FindObjectsOfType<AIBrain>().GetEnumerator();
				try
				{
					while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
					{
						AIBrain current = enumerator.Current;
						if ((Object)(object)current != (Object)null)
						{
							val.Add(current);
						}
					}
				}
				finally
				{
					((global::System.IDisposable)enumerator)?.Dispose();
				}
			}
			catch
			{
			}
			brainCache = val.ToArray();
		}
		return brainCache;
	}

	private static bool Dead(AIBrain b)
	{
		try
		{
			return (Object)(object)b == (Object)null || b.isDead;
		}
		catch
		{
			return true;
		}
	}

	public static Vector3 NpcPos(AIBrain b)
	{
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Il2CppReferenceArray<Muscle> muscles = b.puppetMaster.muscles;
			if (muscles != null && ((Il2CppArrayBase<Muscle>)(object)muscles).Length > 0 && ((Il2CppArrayBase<Muscle>)(object)muscles)[0] != null)
			{
				return ((Il2CppArrayBase<Muscle>)(object)muscles)[0].transform.position;
			}
		}
		catch
		{
		}
		return ((Component)b).transform.position;
	}

	public static Rigidbody NpcPelvis(AIBrain b)
	{
		try
		{
			Il2CppReferenceArray<Muscle> muscles = b.puppetMaster.muscles;
			if (muscles != null && ((Il2CppArrayBase<Muscle>)(object)muscles).Length > 0)
			{
				return ((Component)((Il2CppArrayBase<Muscle>)(object)muscles)[0].transform).GetComponent<Rigidbody>();
			}
		}
		catch
		{
		}
		return null;
	}

	public static List<Rigidbody> NpcRbs(AIBrain b)
	{
		List<Rigidbody> val = new List<Rigidbody>();
		try
		{
			Il2CppReferenceArray<Muscle> muscles = b.puppetMaster.muscles;
			for (int i = 0; i < ((Il2CppArrayBase<Muscle>)(object)muscles).Length; i++)
			{
				Rigidbody component = ((Component)((Il2CppArrayBase<Muscle>)(object)muscles)[i].transform).GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					val.Add(component);
				}
			}
		}
		catch
		{
		}
		return val;
	}

	private static float NpcMass(AIBrain b)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		float num = 0f;
		Enumerator<Rigidbody> enumerator = NpcRbs(b).GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				Rigidbody current = enumerator.Current;
				num += current.mass;
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
		if (!(num > 0f))
		{
			return 60f;
		}
		return num;
	}

	private bool NearestNpc(Vector3 from, float range, out Vector3 pos)
	{
		//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_002a: 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_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: 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_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		pos = Vector3.zero;
		float num = range;
		bool result = false;
		AIBrain[] array = Brains();
		foreach (AIBrain b in array)
		{
			if (!Dead(b))
			{
				Vector3 val = NpcPos(b);
				float num2 = Vector3.Distance(from, val);
				if (num2 < num)
				{
					num = num2;
					pos = val + Vector3.up * 0.45f;
					result = true;
				}
			}
		}
		return result;
	}

	public void Ragdoll(AIBrain b, float seconds)
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)b == (Object)null)
		{
			return;
		}
		try
		{
			PuppetMaster puppetMaster = b.puppetMaster;
			if ((Object)(object)puppetMaster == (Object)null)
			{
				return;
			}
			RagRec ragRec = null;
			Enumerator<RagRec> enumerator = rags.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					RagRec current = enumerator.Current;
					if ((Object)(object)current.b != (Object)null && ((Il2CppObjectBase)current.b).Pointer == ((Il2CppObjectBase)b).Pointer)
					{
						ragRec = current;
					}
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
			if (ragRec == null)
			{
				ragRec = new RagRec
				{
					b = b,
					mw = 1f,
					damp = 1f
				};
				try
				{
					Props props = ((Il2CppArrayBase<Muscle>)(object)puppetMaster.muscles)[0].props;
					ragRec.mw = props.muscleWeight;
					ragRec.damp = props.muscleDamper;
				}
				catch
				{
				}
				rags.Add(ragRec);
			}
			ragRec.until = ((seconds <= 0f) ? 3.4028235E+38f : Mathf.Max((ragRec.until == 3.4028235E+38f) ? 0f : ragRec.until, now + seconds));
			int num = 0;
			puppetMaster.SetMuscleWeightsRecursive(num, 0f, 0f, 1f, 0f);
		}
		catch (global::System.Exception e)
		{
			Err("Ragdoll", e);
		}
	}

	public void ReleaseRagdoll(AIBrain b, float delay)
	{
		//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)
		if ((Object)(object)b == (Object)null)
		{
			return;
		}
		Enumerator<RagRec> enumerator = rags.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				RagRec current = enumerator.Current;
				if ((Object)(object)current.b != (Object)null && ((Il2CppObjectBase)current.b).Pointer == ((Il2CppObjectBase)b).Pointer)
				{
					current.until = now + delay;
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
	}

	private void UpdateRagdolls()
	{
		for (int num = rags.Count - 1; num >= 0; num--)
		{
			RagRec ragRec = rags[num];
			if ((Object)(object)ragRec.b == (Object)null)
			{
				rags.RemoveAt(num);
			}
			else if (!(now < ragRec.until))
			{
				try
				{
					if (!Dead(ragRec.b))
					{
						int num2 = 0;
						ragRec.b.puppetMaster.SetMuscleWeightsRecursive(num2, (ragRec.mw <= 0f) ? 1f : ragRec.mw, 1f, 1f, ragRec.damp);
					}
				}
				catch
				{
				}
				rags.RemoveAt(num);
			}
		}
	}

	public void Damage(AIBrain b, float frac, Vector3 origin, Vector3 dir)
	{
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: 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_0056: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)b == (Object)null || Dead(b))
		{
			return;
		}
		try
		{
			SubBehaviourHealth health = b.behaviour.health;
			if (health != null)
			{
				float damage = Mathf.Max(0.25f, health.maxHitPoints * frac);
				Attack val = new Attack();
				val.damage = damage;
				val.origin = origin;
				val.direction = dir;
				val.normal = -dir;
				health.TakeDamage(1, val);
			}
		}
		catch (global::System.Exception e)
		{
			Err("Damage", e);
			try
			{
				if (frac >= 1f)
				{
					b.behaviour.health.Kill();
				}
			}
			catch
			{
			}
		}
	}

	public void TrackSmash(AIBrain b, Rigidbody rb, float dur, float frac)
	{
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)b == (Object)null) && !((Object)(object)rb == (Object)null))
		{
			thrown.RemoveAll((Predicate<Thrown>)((Thrown x) => (Object)(object)x.b == (Object)null || ((Il2CppObjectBase)x.b).Pointer == ((Il2CppObjectBase)b).Pointer));
			List<Thrown> obj = thrown;
			Thrown obj2 = new Thrown
			{
				b = b,
				rb = rb,
				until = now + dur
			};
			Vector3 velocity = rb.velocity;
			obj2.lastSpeed = ((Vector3)(ref velocity)).magnitude;
			obj2.frac = frac;
			obj.Add(obj2);
		}
	}

	private void UpdateThrown(float dt)
	{
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		UpdateRagdolls();
		for (int num = this.thrown.Count - 1; num >= 0; num--)
		{
			Thrown thrown = this.thrown[num];
			if ((Object)(object)thrown.b == (Object)null || (Object)(object)thrown.rb == (Object)null || now > thrown.until || Dead(thrown.b))
			{
				this.thrown.RemoveAt(num);
			}
			else
			{
				Vector3 velocity = thrown.rb.velocity;
				float magnitude = ((Vector3)(ref velocity)).magnitude;
				if (thrown.lastSpeed > 7.5f && magnitude < thrown.lastSpeed * 0.45f)
				{
					float num2 = Mathf.InverseLerp(7.5f, 18f, thrown.lastSpeed);
					SpawnFX("FX_Impact", thrown.rb.position, Quaternion.identity, 2f);
					Damage(thrown.b, thrown.frac * (0.35f + num2), thrown.rb.position, Vector3.down);
					Buzz(LC, 0.05f, 0.35f);
					Buzz(RC, 0.05f, 0.35f);
				}
				thrown.lastSpeed = magnitude;
			}
		}
	}

	private void Inputs()
	{
		BaseController lC = LC;
		BaseController rC = RC;
		if ((Object)(object)lC == (Object)null || (Object)(object)rC == (Object)null)
		{
			return;
		}
		if (hasTendrils)
		{
			if (dtY.Feed(lC.GetBButtonDown(), now))
			{
				ToggleTendrilReady();
			}
			if (dtStick.Feed(lC.GetThumbStickDown(), now))
			{
				ToggleFan();
			}
			bool flag = lC.GetPrimaryInteractionButtonAxis() > 0.55f;
			if (flag && !lTrig)
			{
				LeftTriggerDown();
			}
			if (!flag && lTrig)
			{
				LeftTriggerUp();
			}
			lTrig = flag;
		}
		if (pMirror != null && pMirror.Value && dtX.Feed(lC.GetAButtonDown(), now))
		{
			ToggleMirror();
		}
		if (dtRS.Feed(rC.GetThumbStickDown(), now))
		{
			ToggleAntimatter();
		}
		if (hasReem)
		{
			if (dtB.Feed(rC.GetBButtonDown(), now))
			{
				ToggleReemReady();
			}
			bool flag2 = rC.GetPrimaryInteractionButtonAxis() > 0.55f;
			if (flag2 && !rTrig && reemReady && rs == RS.Follow)
			{
				ReemStrike();
			}
			rTrig = flag2;
		}
	}

	private void ShaderSafety()
	{
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: 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_016d: Unknown result type (might be due to invalid IL or missing references)
		Shader val = null;
		int num = 0;
		int num2 = 0;
		int num3 = 0;
		List<Material> val2 = new List<Material>();
		global::System.Collections.Generic.IEnumerator<SkinnedMeshRenderer> enumerator = ((Component)root).GetComponentsInChildren<SkinnedMeshRenderer>(true).GetEnumerator();
		try
		{
			while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
			{
				Il2CppReferenceArray<Material> materials = ((Renderer)enumerator.Current).materials;
				for (int i = 0; i < ((Il2CppArrayBase<Material>)(object)materials).Length; i++)
				{
					if ((Object)(object)((Il2CppArrayBase<Material>)(object)materials)[i] != (Object)null)
					{
						val2.Add(((Il2CppArrayBase<Material>)(object)materials)[i]);
					}
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator)?.Dispose();
		}
		Enumerator<Material> enumerator2 = val2.GetEnumerator();
		try
		{
			while (enumerator2.MoveNext())
			{
				Material current = enumerator2.Current;
				num3++;
				Shader shader = current.shader;
				if ((Object)(object)val == (Object)null && (Object)(object)shader != (Object)null && shader.isSupported && ((Object)shader).name.Contains("Unlit"))
				{
					val = shader;
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose();
		}
		enumerator2 = val2.GetEnumerator();
		try
		{
			while (enumerator2.MoveNext())
			{
				Material current2 = enumerator2.Current;
				Shader shader2 = current2.shader;
				if (!((Object)(object)shader2 != (Object)null) || !shader2.isSupported || ((Object)shader2).name.Contains("Error"))
				{
					num++;
					if (!((Object)(object)val == (Object)null))
					{
						Color val3 = (current2.HasProperty("_BaseColor") ? current2.GetColor("_BaseColor") : Color.white);
						current2.shader = val;
						current2.SetColor("_BaseColor", val3);
						num2++;
					}
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose();
		}
		((MelonBase)this).LoggerInstance.Msg(string.Concat(new string[6]
		{
			"[Shaders] materials=",
			num3.ToString(),
			" unsupported=",
			num.ToString(),
			" switched=",
			num2.ToString()
		}));
	}

	private void SetupMats()
	{
		//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_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		mats.Clear();
		matR.Clear();
		matOrig.Clear();
		global::System.Collections.Generic.IEnumerator<SkinnedMeshRenderer> enumerator = ((Component)root).GetComponentsInChildren<SkinnedMeshRenderer>(true).GetEnumerator();
		try
		{
			while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
			{
				SkinnedMeshRenderer current = enumerator.Current;
				string name = ((Object)((Component)current).gameObject).name;
				if (name == "Reem")
				{
					continue;
				}
				matR.Add((Renderer)(object)current);
				matOrig.Add(((Renderer)current).sharedMaterials);
				Il2CppReferenceArray<Material> materials = ((Renderer)current).materials;
				bool flag = name.StartsWith("LeftArm_Tendrils");
				for (int i = 0; i < ((Il2CppArrayBase<Material>)(object)materials).Length; i++)
				{
					Material val = ((Il2CppArrayBase<Material>)(object)materials)[i];
					if ((Object)(object)val == (Object)null)
					{
						continue;
					}
					string name2 = ((Object)val).name;
					MatRec matRec = new MatRec
					{
						m = val,
						tendril = flag,
						kind = -1
					};
					if (name2.StartsWith("GY_GlowPurple"))
					{
						matRec.kind = 0;
					}
					else if (name2.StartsWith("GY_GlowCore"))
					{
						matRec.kind = 1;
					}
					else if (name2.StartsWith("GY_Outline"))
					{
						matRec.kind = 2;
					}
					else if (name2.StartsWith("GY_Black") && flag)
					{
						matRec.kind = 3;
					}
					else if (name2.StartsWith("GY_RedGlow"))
					{
						matRec.kind = 4;
					}
					if (matRec.kind >= 0)
					{
						if (val.HasProperty("_EmissionColor"))
						{
							matRec.em = val.GetColor("_EmissionColor");
						}
						if (val.HasProperty("_BaseColor"))
						{
							matRec.col = val.GetColor("_BaseColor");
						}
						if (matRec.kind == 3)
						{
							val.EnableKeyword("_EMISSION");
						}
						mats.Add(matRec);
					}
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator)?.Dispose();
		}
	}

	private void TeardownMats()
	{
		for (int i = 0; i < matR.Count; i++)
		{
			try
			{
				if ((Object)(object)matR[i] != (Object)null)
				{
					matR[i].sharedMaterials = matOrig[i];
				}
			}
			catch
			{
			}
		}
		mats.Clear();
		matR.Clear();
		matOrig.Clear();
	}

	private void UpdateGlow(float dt)
	{
		//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_0182: 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_020c: 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_024d: Unknown result type (might be due to invalid IL or missing references)
		//IL_026f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dc: 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)
		float num = Mathf.Pow(Mathf.Max(0f, Mathf.Sin(now * 5.4f)), 10f) + 0.6f * Mathf.Pow(Mathf.Max(0f, Mathf.Sin(now * 5.4f - 0.9f)), 10f);
		float num2 = 0.5f + 0.5f * Mathf.Sin(now * 1.3f);
		coreFlash = Mathf.MoveTowards(coreFlash, 0f, dt * 1.5f);
		tGlowLvl = Ease(tGlowLvl, tGlowTarget, 6f, dt);
		Enumerator<MatRec> enumerator = mats.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				MatRec current = enumerator.Current;
				if ((Object)(object)current.m == (Object)null)
				{
					continue;
				}
				switch (current.kind)
				{
				case 0:
				{
					float num5 = 0.62f + 0.18f * num2 + 0.3f * num;
					if (current.tendril)
					{
						num5 *= 1f + tGlowLvl * 1.6f;
					}
					current.m.SetColor("_EmissionColor", current.em * num5);
					break;
				}
				case 1:
				{
					float num4 = 0.8f + 0.6f * num + coreFlash * 4f;
					current.m.SetColor("_EmissionColor", current.em * num4);
					break;
				}
				case 2:
				{
					float num3 = (current.tendril ? (1f + tGlowLvl * 0.5f) : (1f + 0.08f * num + coreFlash * 0.5f));
					current.m.SetColor("_BaseColor", current.col * num3);
					break;
				}
				case 3:
					current.m.SetColor("_EmissionColor", new Color(0.35f, 0.08f, 0.7f) * (tGlowLvl * (0.6f + 0.4f * Mathf.Sin(now * 9f))));
					break;
				case 4:
					current.m.SetColor("_EmissionColor", current.em * (1f + 0.25f * Mathf.Sin(now * 2.1f)));
					break;
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
	}

	private int LeakMask()
	{
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: 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_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)
		int num = 0;
		try
		{
			global::System.Collections.Generic.IEnumerator<Collider> enumerator = ((Component)rm.physicsRig).GetComponentsInChildren<Collider>(true).GetEnumerator();
			try
			{
				while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
				{
					Collider current = enumerator.Current;
					num |= 1 << ((Component)current).gameObject.layer;
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator)?.Dispose();
			}
		}
		catch
		{
		}
		num &= -2;
		try
		{
			Il2CppStructArray<RaycastHit> val = Physics.RaycastAll(rm.physicsRig.torso.rbPelvis.position, Vector3.down, 6f, -1, (QueryTriggerInteraction)1);
			for (int i = 0; i < ((Il2CppArrayBase<RaycastHit>)(object)val).Length; i++)
			{
				RaycastHit val2 = ((Il2CppArrayBase<RaycastHit>)(object)val)[i];
				if ((Object)(object)((RaycastHit)(ref val2)).rigidbody == (Object)null)
				{
					int num2 = num;
					val2 = ((Il2CppArrayBase<RaycastHit>)(object)val)[i];
					num = num2 & ~(1 << ((Component)((RaycastHit)(ref val2)).collider).gameObject.layer);
				}
			}
		}
		catch
		{
		}
		return ~num;
	}

	private void SetupLeaks()
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		leaks.Clear();
		int num = LeakMask();
		global::System.Collections.Generic.IEnumerator<ParticleSystem> enumerator = ((Component)root).GetComponentsInChildren<ParticleSystem>(true).GetEnumerator();
		try
		{
			while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
			{
				ParticleSystem current = enumerator.Current;
				if (((Object)((Component)current).gameObject).name.StartsWith("GY_Leak"))
				{
					current.collision.collidesWith = LayerMask.op_Implicit(num);
					current.Play(true);
					leaks.Add(current);
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator)?.Dispose();
		}
	}

	private void TeardownLeaks()
	{
		//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)
		Enumerator<ParticleSystem> enumerator = leaks.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				ParticleSystem current = enumerator.Current;
				try
				{
					if ((Object)(object)current != (Object)null)
					{
						current.Stop(true, (ParticleSystemStopBehavior)0);
					}
				}
				catch
				{
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
		leaks.Clear();
	}

	private void SetupJump()
	{
		RemapRig remapHeptaRig = rm.remapHeptaRig;
		jumpOrig = remapHeptaRig.jumpVelocity;
		remapHeptaRig.jumpVelocity = jumpOrig * pJump.Value;
	}

	private void TeardownJump()
	{
		try
		{
			if (jumpOrig > 0f && (Object)(object)rm != (Object)null)
			{
				rm.remapHeptaRig.jumpVelocity = jumpOrig;
			}
		}
		catch
		{
		}
		jumpOrig = -1f;
	}

	private void SetupPlayerBodies()
	{
		playerRbs.Clear();
		playerCols.Clear();
		global::System.Collections.Generic.IEnumerator<Rigidbody> enumerator = ((Component)rm.physicsRig).GetComponentsInChildren<Rigidbody>(true).GetEnumerator();
		try
		{
			while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
			{
				Rigidbody current = enumerator.Current;
				playerRbs.Add(current);
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator)?.Dispose();
		}
		global::System.Collections.Generic.IEnumerator<Collider> enumerator2 = ((Component)rm.physicsRig).GetComponentsInChildren<Collider>(true).GetEnumerator();
		try
		{
			while (((global::System.Collections.IEnumerator)enumerator2).MoveNext())
			{
				Collider current2 = enumerator2.Current;
				playerCols.Add(current2);
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator2)?.Dispose();
		}
	}

	public static void BoostStats(Avatar a)
	{
		try
		{
			if (!((Object)(object)a == (Object)null) && !((Object)(object)((Component)a).transform.Find("GY_FX") == (Object)null))
			{
				float num = ((pStrength != null) ? pStrength.Value : 2.2f);
				a._strengthUpper *= num;
				a._strengthLower *= Mathf.Lerp(1f, num, 0.5f);
				a._strengthGrip *= num;
				a._vitality *= 2f;
				a._speed *= 1.12f;
				a._agility *= 1.2f;
			}
		}
		catch (global::System.Exception ex)
		{
			MelonLogger.Warning("[Graveyard] stats: " + ex.Message);
		}
	}

	private void DebugUpdate()
	{
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Expected O, but got Unknown
		if (pDbgAvatar == null || (Object)(object)rm == (Object)null)
		{
			return;
		}
		string value = pDbgAvatar.Value;
		if (!string.IsNullOrEmpty(value) && !worn && !dbgSwapped)
		{
			if (dbgSwapAt < 0f)
			{
				dbgSwapAt = now + 5f;
			}
			else if (now > dbgSwapAt)
			{
				dbgSwapped = true;
				((MelonBase)this).LoggerInstance.Msg("[DBG] swapping avatar to " + value);
				rm.SwapAvatarCrate(new Barcode(value), true, (Action<bool>)null);
			}
		}
		if (worn && pDbgTest.Value)
		{
			string text = string.Concat(new string[14]
			{
				"tm=",
				((object)tm/*cast due to .constrained prefix*/).ToString(),
				" stretch=",
				tStretch.ToString("F2"),
				" rs=",