Decompiled source of Jetpack v1.3.1

Jetpack.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("Jetpack")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Jetpack")]
[assembly: AssemblyTitle("Jetpack")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Jetpack
{
	internal class GliderVisual : MonoBehaviour
	{
		public bool Open;

		private const float CanopyHeight = 3f;

		private const float HalfSpan = 1.7f;

		private const float Chord = 1.3f;

		private const float EndDroop = 0.65f;

		private const float Camber = 0.15f;

		private static readonly Color DefaultPrimary = new Color(0.93f, 0.87f, 0.72f);

		private static readonly Color DefaultSecondary = new Color(0.7f, 0.16f, 0.12f);

		private static Material _canopyBaseMaterial;

		private static Material _lineMaterial;

		private static Mesh _canopyMesh;

		private Player _player;

		private VisEquipment _vis;

		private Material _material;

		private Texture2D _texture;

		private int _outfitKey = int.MinValue;

		private Transform _canopy;

		private Transform _leftShoulder;

		private Transform _rightShoulder;

		private LineRenderer[] _lines;

		private Vector3[] _lineAnchors;

		private float _deploy;

		public static GliderVisual Create(Player player)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("JetpackGlider");
			val.transform.SetParent(((Component)player).transform, false);
			GliderVisual gliderVisual = val.AddComponent<GliderVisual>();
			gliderVisual.Build(player);
			return gliderVisual;
		}

		private void Build(Player player)
		{
			//IL_0022: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_0040: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: 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)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: 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)
			_player = player;
			_vis = ((Component)player).GetComponent<VisEquipment>();
			EnsureResources();
			_texture = new Texture2D(128, 32, (TextureFormat)4, true)
			{
				wrapMode = (TextureWrapMode)1,
				filterMode = (FilterMode)1
			};
			FillStripes(_texture, DefaultPrimary, DefaultSecondary);
			_material = new Material(_canopyBaseMaterial)
			{
				mainTexture = (Texture)(object)_texture
			};
			Animator componentInChildren = ((Component)player).GetComponentInChildren<Animator>();
			if ((Object)(object)componentInChildren != (Object)null && componentInChildren.isHuman)
			{
				_leftShoulder = componentInChildren.GetBoneTransform((HumanBodyBones)13);
				_rightShoulder = componentInChildren.GetBoneTransform((HumanBodyBones)14);
			}
			GameObject val = new GameObject("Canopy");
			val.transform.SetParent(((Component)this).transform, false);
			val.AddComponent<MeshFilter>().sharedMesh = _canopyMesh;
			MeshRenderer obj = val.AddComponent<MeshRenderer>();
			((Renderer)obj).sharedMaterial = _material;
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1;
			_canopy = val.transform;
			float num = -0.41599998f;
			_lineAnchors = (Vector3[])(object)new Vector3[4]
			{
				new Vector3(-1.36f, num, 0.39000002f),
				new Vector3(-1.36f, num, -0.39000002f),
				new Vector3(1.36f, num, 0.39000002f),
				new Vector3(1.36f, num, -0.39000002f)
			};
			_lines = (LineRenderer[])(object)new LineRenderer[_lineAnchors.Length];
			Color val4 = default(Color);
			for (int i = 0; i < _lines.Length; i++)
			{
				GameObject val2 = new GameObject("Line" + i);
				val2.transform.SetParent(((Component)this).transform, false);
				LineRenderer val3 = val2.AddComponent<LineRenderer>();
				((Renderer)val3).sharedMaterial = _lineMaterial;
				val3.useWorldSpace = true;
				val3.positionCount = 2;
				float startWidth = (val3.endWidth = 0.018f);
				val3.startWidth = startWidth;
				((Color)(ref val4))..ctor(0.2f, 0.15f, 0.1f);
				val3.endColor = val4;
				val3.startColor = val4;
				((Renderer)val3).shadowCastingMode = (ShadowCastingMode)0;
				_lines[i] = val3;
			}
			SetVisible(visible: false);
		}

		private void OnDestroy()
		{
			if ((Object)(object)_material != (Object)null)
			{
				Object.Destroy((Object)(object)_material);
			}
			if ((Object)(object)_texture != (Object)null)
			{
				Object.Destroy((Object)(object)_texture);
			}
		}

		public void Tick()
		{
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: 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_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: 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_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: 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_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_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_player == (Object)null)
			{
				return;
			}
			if (Open)
			{
				RefreshColorsIfOutfitChanged();
			}
			_deploy = Mathf.MoveTowards(_deploy, Open ? 1f : 0f, Time.deltaTime * (Open ? 3.5f : 6f));
			bool flag = _deploy > 0.001f;
			SetVisible(flag);
			if (flag)
			{
				float num = Mathf.SmoothStep(0f, 1f, _deploy);
				float time = Time.time;
				((Component)this).transform.localPosition = new Vector3(0f, Mathf.Lerp(1.6f, 3f, num), 0f);
				((Component)this).transform.localRotation = Quaternion.Euler(Mathf.Sin(time * 1.3f) * 2f - 6f, 0f, Mathf.Sin(time * 0.9f) * 4f);
				((Component)this).transform.localScale = new Vector3(Mathf.Lerp(0.1f, 1f, num), Mathf.Lerp(0.3f, 1f, num), Mathf.Lerp(0.5f, 1f, num));
				Vector3 val = ((Component)_player).transform.position + Vector3.up * 1.45f - ((Component)_player).transform.right * 0.22f;
				Vector3 val2 = ((Component)_player).transform.position + Vector3.up * 1.45f + ((Component)_player).transform.right * 0.22f;
				for (int i = 0; i < _lines.Length; i++)
				{
					bool flag2 = i < 2;
					Transform val3 = (flag2 ? _leftShoulder : _rightShoulder);
					Vector3 val4 = (((Object)(object)val3 != (Object)null) ? val3.position : (flag2 ? val : val2));
					_lines[i].SetPosition(0, _canopy.TransformPoint(_lineAnchors[i]));
					_lines[i].SetPosition(1, val4);
				}
			}
		}

		private void RefreshColorsIfOutfitChanged()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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_0030: 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_0036: 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)
			int num = OutfitColors.OutfitKey(_vis);
			if (num != _outfitKey)
			{
				_outfitKey = num;
				Color primary;
				Color secondary;
				bool flag = OutfitColors.TryGetPalette(_vis, out primary, out secondary);
				if (!flag)
				{
					primary = DefaultPrimary;
					secondary = DefaultSecondary;
				}
				FillStripes(_texture, primary, secondary);
				JetpackPlugin.Log.LogInfo((object)("Glider colours for '" + _player.GetPlayerName() + "': #" + ColorUtility.ToHtmlStringRGB(primary) + " / #" + ColorUtility.ToHtmlStringRGB(secondary) + " (" + (flag ? "from outfit" : "default") + ")."));
			}
		}

		private void SetVisible(bool visible)
		{
			if (((Component)_canopy).gameObject.activeSelf != visible)
			{
				((Component)_canopy).gameObject.SetActive(visible);
			}
			LineRenderer[] lines = _lines;
			for (int i = 0; i < lines.Length; i++)
			{
				((Renderer)lines[i]).enabled = visible;
			}
		}

		private static void EnsureResources()
		{
			//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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_canopyMesh != (Object)null))
			{
				_canopyMesh = BuildCanopyMesh();
				Shader val = ((IEnumerable<string>)new string[4] { "Standard", "Legacy Shaders/Diffuse", "Legacy Shaders/Particles/Alpha Blended", "Sprites/Default" }).Select((Func<string, Shader>)Shader.Find).FirstOrDefault((Func<Shader, bool>)((Shader sh) => (Object)(object)sh != (Object)null));
				_canopyBaseMaterial = new Material(val)
				{
					color = Color.white
				};
				if (_canopyBaseMaterial.HasProperty("_Glossiness"))
				{
					_canopyBaseMaterial.SetFloat("_Glossiness", 0.15f);
				}
				JetpackPlugin.Log.LogInfo((object)("Glider canopy shader: '" + ((val != null) ? ((Object)val).name : null) + "'."));
				Shader val2 = Shader.Find("Sprites/Default");
				_lineMaterial = (Material)((!((Object)(object)val2 != (Object)null)) ? ((object)_canopyBaseMaterial) : ((object)new Material(val2)));
			}
		}

		private static Mesh BuildCanopyMesh()
		{
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: 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)
			//IL_00e3: 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_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0204: 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_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Expected O, but got Unknown
			int num = 175;
			Vector3[] array = (Vector3[])(object)new Vector3[num * 2];
			Vector2[] array2 = (Vector2[])(object)new Vector2[num * 2];
			int[] array3 = new int[1728];
			Vector3 val = default(Vector3);
			for (int i = 0; i <= 6; i++)
			{
				for (int j = 0; j <= 24; j++)
				{
					float num2 = (float)j / 24f;
					float num3 = (float)i / 6f;
					float num4 = num2 * 2f - 1f;
					float num5 = num3 * 2f - 1f;
					float num6 = -0.65f * num4 * num4 + 0.15f * (1f - num5 * num5);
					((Vector3)(ref val))..ctor(num4 * 1.7f, num6, num5 * 1.3f * 0.5f);
					int num7 = i * 25 + j;
					array[num7] = (array[num7 + num] = val);
					array2[num7] = (array2[num7 + num] = new Vector2(num2, num3));
				}
			}
			int num8 = 0;
			for (int k = 0; k < 6; k++)
			{
				for (int l = 0; l < 24; l++)
				{
					int num9 = k * 25 + l;
					int num10 = num9 + 1;
					int num11 = num9 + 24 + 1;
					int num12 = num11 + 1;
					array3[num8++] = num9;
					array3[num8++] = num11;
					array3[num8++] = num10;
					array3[num8++] = num10;
					array3[num8++] = num11;
					array3[num8++] = num12;
					array3[num8++] = num9 + num;
					array3[num8++] = num10 + num;
					array3[num8++] = num11 + num;
					array3[num8++] = num10 + num;
					array3[num8++] = num12 + num;
					array3[num8++] = num11 + num;
				}
			}
			Mesh val2 = new Mesh
			{
				name = "JetpackGliderCanopy",
				vertices = array,
				uv = array2,
				triangles = array3
			};
			val2.RecalculateNormals();
			val2.RecalculateBounds();
			return val2;
		}

		private static void FillStripes(Texture2D tex, Color a, Color b)
		{
			//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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			int width = ((Texture)tex).width;
			int height = ((Texture)tex).height;
			Color val = Color.Lerp(a, Color.black, 0.55f);
			Color[] array = (Color[])(object)new Color[width * height];
			for (int i = 0; i < height; i++)
			{
				for (int j = 0; j < width; j++)
				{
					array[i * width + j] = ((i >= height - 3) ? val : ((j * 9 / width % 2 == 0) ? a : b));
				}
			}
			tex.SetPixels(array);
			tex.Apply();
		}
	}
	public class JetpackController : MonoBehaviour
	{
		internal static JetpackController Local;

		private static readonly int ThrustZdoKey = StringExtensionMethods.GetStableHashCode("lagstedt.jetpack.thrust");

		private static readonly int JetZdoKey = StringExtensionMethods.GetStableHashCode("lagstedt.jetpack.jet");

		private static readonly int GlideZdoKey = StringExtensionMethods.GetStableHashCode("lagstedt.jetpack.glide");

		private static Func<Player, bool> _takeInput;

		private static readonly Vector3 TiltPivot = new Vector3(0f, 1.1f, 0f);

		private const float TiltSpeed = 150f;

		private const float PitchDeadZone = 15f;

		private const float MaxJetPitch = 40f;

		private Player _player;

		private Rigidbody _body;

		private ZNetView _nview;

		private JetpackEffects _fx;

		private GliderVisual _glider;

		private Transform _visual;

		private Vector3 _visualBasePos;

		private bool _thrusting;

		private bool _jetMode;

		private bool _gliding;

		private bool _publishedThrust;

		private bool _publishedJet;

		private bool _publishedGlide;

		private bool _showJet;

		private bool _showGlide;

		private float _tilt;

		private bool _tiltApplied;

		private void Awake()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			_player = ((Component)this).GetComponent<Player>();
			_body = ((Component)this).GetComponent<Rigidbody>();
			_nview = ((Component)this).GetComponent<ZNetView>();
			_visual = ((Component)this).transform.Find("Visual");
			if ((Object)(object)_visual != (Object)null)
			{
				_visualBasePos = _visual.localPosition;
			}
			if (_takeInput == null)
			{
				_takeInput = AccessTools.MethodDelegate<Func<Player, bool>>(AccessTools.Method(typeof(Player), "TakeInput", (Type[])null, (Type[])null), (object)null, true);
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)Local == (Object)(object)this)
			{
				Local = null;
			}
			if ((Object)(object)_fx != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_fx).gameObject);
			}
			if ((Object)(object)_glider != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_glider).gameObject);
			}
		}

		private void Update()
		{
			if (!((Object)(object)_nview == (Object)null) && _nview.IsValid())
			{
				bool flag = (Object)(object)_player == (Object)(object)Player.m_localPlayer;
				if (flag)
				{
					Local = this;
					UpdateLocalInput();
				}
				ZDO zDO = _nview.GetZDO();
				bool flag2 = (flag ? _thrusting : zDO.GetBool(ThrustZdoKey, false));
				_showJet = flag2 && (flag ? _jetMode : zDO.GetBool(JetZdoKey, false));
				if (flag2 && (Object)(object)_fx == (Object)null)
				{
					_fx = JetpackEffects.Create(_player);
				}
				if ((Object)(object)_fx != (Object)null)
				{
					_fx.Thrusting = flag2;
				}
				_showGlide = (flag ? _gliding : zDO.GetBool(GlideZdoKey, false));
				if (_showGlide && (Object)(object)_glider == (Object)null)
				{
					_glider = GliderVisual.Create(_player);
				}
				if ((Object)(object)_glider != (Object)null)
				{
					_glider.Open = _showGlide;
				}
			}
		}

		private void LateUpdate()
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: 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)
			float value = JetpackPlugin.JetTiltAngle.Value;
			_tilt = Mathf.MoveTowards(_tilt, _showJet ? value : 0f, 150f * Time.deltaTime);
			if ((Object)(object)_visual != (Object)null && (_tilt > 0f || _tiltApplied))
			{
				Quaternion val = Quaternion.Euler(_tilt, 0f, 0f);
				_visual.localRotation = val;
				_visual.localPosition = _visualBasePos + TiltPivot - val * TiltPivot;
				_tiltApplied = _tilt > 0f;
			}
			if ((Object)(object)_fx != (Object)null)
			{
				_fx.TiltDegrees = _tilt;
				_fx.JetBlend = ((value > 1f) ? (_tilt / value) : (_showJet ? 1f : 0f));
				_fx.Tick();
			}
			if ((Object)(object)_glider != (Object)null)
			{
				_glider.Tick();
			}
		}

		private void UpdateLocalInput()
		{
			int num;
			int num2;
			if (JetpackPlugin.Enabled.Value && CanFly())
			{
				num = (_takeInput(_player) ? 1 : 0);
				if (num != 0)
				{
					num2 = ((ZInput.GetButton("Jump") || ZInput.GetButton("JoyJump")) ? 1 : 0);
					goto IL_0049;
				}
			}
			else
			{
				num = 0;
			}
			num2 = 0;
			goto IL_0049;
			IL_0049:
			bool flag = (byte)num2 != 0;
			bool flag2 = num != 0 && (ZInput.GetButtonDown("Jump") || ZInput.GetButtonDown("JoyJump"));
			bool flag3 = num != 0 && (ZInput.GetButton("Run") || ZInput.GetButton("JoyRun"));
			bool flag4 = num != 0 && (ZInput.GetButtonDown("Run") || ZInput.GetButtonDown("JoyRun"));
			bool thrusting = _thrusting;
			if (!flag)
			{
				_thrusting = false;
			}
			else if (flag2 && !((Character)_player).IsOnGround())
			{
				_thrusting = true;
			}
			if (!_thrusting && !((Character)_player).IsOnGround() && JetpackPlugin.GliderEnabled.Value && (flag4 || (thrusting && flag3)))
			{
				_gliding = true;
			}
			if (_gliding && (!flag3 || _thrusting || ((Character)_player).IsOnGround() || ((Character)_player).IsSwimming()))
			{
				_gliding = false;
			}
			_jetMode = _thrusting && flag3 && JetpackPlugin.JetModeEnabled.Value;
			PublishFlags();
		}

		private bool CanFly()
		{
			if (!((Character)_player).IsDead() && !((Character)_player).IsAttached() && !((Character)_player).IsRiding() && !((Character)_player).InIntro() && !((Character)_player).IsTeleporting())
			{
				return !((Character)_player).IsDebugFlying();
			}
			return false;
		}

		private void PublishFlags()
		{
			if (_nview.IsOwner())
			{
				if (_publishedThrust != _thrusting)
				{
					_nview.GetZDO().Set(ThrustZdoKey, _thrusting);
					_publishedThrust = _thrusting;
				}
				if (_publishedJet != _jetMode)
				{
					_nview.GetZDO().Set(JetZdoKey, _jetMode);
					_publishedJet = _jetMode;
				}
				if (_publishedGlide != _gliding)
				{
					_nview.GetZDO().Set(GlideZdoKey, _gliding);
					_publishedGlide = _gliding;
				}
			}
		}

		internal void ApplyFlight(float dt)
		{
			if ((Object)(object)_body == (Object)null)
			{
				return;
			}
			if (_gliding)
			{
				ApplyGlide(dt);
			}
			else
			{
				if (!_thrusting)
				{
					return;
				}
				float num = JetpackPlugin.StaminaPerSecond.Value * dt;
				if (num > 0f)
				{
					if (!((Character)_player).HaveStamina(num))
					{
						_thrusting = false;
						_jetMode = false;
						PublishFlags();
						return;
					}
					((Character)_player).UseStamina(num);
				}
				if (_jetMode)
				{
					ApplyJetFlight(dt);
				}
				else
				{
					ApplyHover(dt);
				}
			}
		}

		private void ApplyHover(float dt)
		{
			//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_0016: 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_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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
			Vector3 linearVelocity = _body.linearVelocity;
			float num = JetpackPlugin.UpAcceleration.Value * ((linearVelocity.y < 0f) ? 1.6f : 1f);
			linearVelocity.y = Mathf.MoveTowards(linearVelocity.y, JetpackPlugin.MaxUpSpeed.Value, num * dt);
			Vector3 moveDir = ((Character)_player).GetMoveDir();
			moveDir.y = 0f;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(linearVelocity.x, 0f, linearVelocity.z);
			float num2 = JetpackPlugin.HorizontalAcceleration.Value;
			Vector3 val2;
			if (((Vector3)(ref moveDir)).sqrMagnitude > 0.01f)
			{
				val2 = Vector3.ClampMagnitude(moveDir, 1f) * JetpackPlugin.HorizontalSpeed.Value;
			}
			else
			{
				val2 = Vector3.zero;
				num2 *= 0.35f;
			}
			val = Vector3.MoveTowards(val, val2, num2 * dt);
			linearVelocity.x = val.x;
			linearVelocity.z = val.z;
			_body.linearVelocity = linearVelocity;
		}

		private void ApplyGlide(float dt)
		{
			//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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: 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_00c3: 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_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_007d: 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_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = _body.linearVelocity;
			float num = 0f - JetpackPlugin.GliderFallSpeed.Value;
			val.y = Mathf.MoveTowards(val.y, num, ((val.y < num) ? 40f : 12f) * dt);
			Vector3 val2 = ((Character)_player).GetMoveDir();
			val2.y = 0f;
			if (((Vector3)(ref val2)).sqrMagnitude < 0.01f)
			{
				val2 = Vector3.ProjectOnPlane(((Component)_player).transform.forward, Vector3.up);
			}
			Vector3 val3 = Vector3.MoveTowards(new Vector3(val.x, 0f, val.z), ((Vector3)(ref val2)).normalized * JetpackPlugin.GliderSpeed.Value, JetpackPlugin.GliderAcceleration.Value * dt);
			val.x = val3.x;
			val.z = val3.z;
			if (_body.useGravity)
			{
				val -= Physics.gravity * dt;
			}
			_body.linearVelocity = val;
			if (((Vector3)(ref val3)).sqrMagnitude > 1f)
			{
				((Component)_player).transform.rotation = Quaternion.RotateTowards(((Component)_player).transform.rotation, Quaternion.LookRotation(val3), 360f * dt);
			}
		}

		private void ApplyJetFlight(float dt)
		{
			//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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: 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_00c8: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Vector3 lookDir = ((Character)_player).GetLookDir();
			Vector3 forward = default(Vector3);
			((Vector3)(ref forward))..ctor(lookDir.x, 0f, lookDir.z);
			if (((Vector3)(ref forward)).sqrMagnitude < 0.0001f)
			{
				forward = ((Component)_player).transform.forward;
			}
			((Vector3)(ref forward)).Normalize();
			float num = Mathf.Asin(Mathf.Clamp(lookDir.y, -1f, 1f)) * 57.29578f;
			num = Mathf.Sign(num) * Mathf.Max(0f, Mathf.Abs(num) - 15f);
			num = Mathf.Clamp(num, -40f, 40f) * ((float)Math.PI / 180f);
			Vector3 val = forward * Mathf.Cos(num) + Vector3.up * Mathf.Sin(num);
			Vector3 val2 = Vector3.MoveTowards(_body.linearVelocity, val * JetpackPlugin.JetSpeed.Value, JetpackPlugin.JetAcceleration.Value * dt);
			if (_body.useGravity)
			{
				val2 -= Physics.gravity * dt;
			}
			_body.linearVelocity = val2;
			((Component)_player).transform.rotation = Quaternion.RotateTowards(((Component)_player).transform.rotation, Quaternion.LookRotation(forward), 540f * dt);
		}
	}
	internal class JetpackEffects : MonoBehaviour
	{
		public bool Thrusting;

		public float TiltDegrees;

		public float JetBlend;

		private const float NozzleSpacing = 0.14f;

		private const float BackOffset = 0.28f;

		private static readonly Color FlameColor = new Color(1f, 0.55f, 0.18f);

		private static Material _flameMaterial;

		private static ParticleSystem _flameSource;

		private static bool _materialSearched;

		private static int _groundMask;

		private Player _player;

		private Transform _chest;

		private float _intensity;

		private float _noiseSeed;

		private ParticleSystem[] _backSystems;

		private Light _nozzleLight;

		private Transform _groundRoot;

		private ParticleSystem[] _groundSystems;

		private Light _groundLight;

		public static JetpackEffects Create(Player player)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("JetpackFX");
			val.transform.SetParent(((Component)player).transform, false);
			JetpackEffects jetpackEffects = val.AddComponent<JetpackEffects>();
			jetpackEffects.Build(player);
			return jetpackEffects;
		}

		private void Build(Player player)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//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_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: 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_01ba: Unknown result type (might be due to invalid IL or missing references)
			_player = player;
			_noiseSeed = Random.value * 100f;
			_chest = FindChest(player);
			EnsureMaterial();
			if (_groundMask == 0)
			{
				_groundMask = LayerMask.GetMask(new string[6] { "Default", "static_solid", "Default_small", "piece", "terrain", "vehicle" });
			}
			Quaternion localRot = Quaternion.LookRotation(new Vector3(0f, -1f, -0.22f));
			_backSystems = (ParticleSystem[])(object)new ParticleSystem[4]
			{
				MakeJet("JetL", new Vector3(-0.14f, 0f, 0f), localRot),
				MakeJet("JetR", new Vector3(0.14f, 0f, 0f), localRot),
				MakeSparks("SparksL", new Vector3(-0.14f, 0f, 0f), localRot),
				MakeSparks("SparksR", new Vector3(0.14f, 0f, 0f), localRot)
			};
			_nozzleLight = MakeLight("NozzleLight", ((Component)this).transform, new Vector3(0f, -0.35f, -0.1f), 5f);
			_groundRoot = new GameObject("JetpackGroundFX").transform;
			_groundRoot.SetParent(((Component)this).transform, false);
			_groundSystems = (ParticleSystem[])(object)new ParticleSystem[3]
			{
				MakeGroundFlames(),
				MakeGroundBlast(),
				MakeEmbers()
			};
			_groundLight = MakeLight("GroundLight", _groundRoot, new Vector3(0f, 0f, 1.2f), 8f);
		}

		public void Tick()
		{
			//IL_00a3: 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_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_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: 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_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: 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)
			if (!((Object)(object)_player == (Object)null))
			{
				float deltaTime = Time.deltaTime;
				_intensity = Mathf.MoveTowards(_intensity, Thrusting ? 1f : 0f, deltaTime * (Thrusting ? 8f : 3f));
				float num = Mathf.PerlinNoise(Time.time * 14f, _noiseSeed);
				Transform transform = ((Component)_player).transform;
				Vector3 val = (((Object)(object)_chest != (Object)null) ? _chest.position : (transform.position + Vector3.up * 1.3f));
				Vector3 val2 = Vector3.ProjectOnPlane(transform.forward, Vector3.up);
				Vector3 val3 = ((Vector3)(ref val2)).normalized;
				if (((Vector3)(ref val3)).sqrMagnitude < 0.01f)
				{
					val3 = Vector3.forward;
				}
				Quaternion val4 = Quaternion.LookRotation(val3) * Quaternion.Euler(TiltDegrees, 0f, 0f);
				((Component)this).transform.SetPositionAndRotation(val - val4 * Vector3.forward * 0.28f, val4);
				for (int i = 0; i < 2; i++)
				{
					MainModule main = _backSystems[i].main;
					((MainModule)(ref main)).startLifetimeMultiplier = 1f + 0.8f * JetBlend;
					((MainModule)(ref main)).startSpeedMultiplier = 1f + 0.6f * JetBlend;
				}
				SetEmitting(_backSystems, Thrusting, 1f + 0.5f * JetBlend);
				((Behaviour)_nozzleLight).enabled = _intensity > 0.01f;
				_nozzleLight.intensity = _intensity * (2.2f + num * 1.6f);
				UpdateGround(val3, num);
			}
		}

		private void UpdateGround(Vector3 forward, float flicker)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Max(1f, JetpackPlugin.GroundGlowDistance.Value);
			RaycastHit val = default(RaycastHit);
			if (_intensity > 0.01f && Physics.Raycast(((Component)this).transform.position, Vector3.down, ref val, num, _groundMask, (QueryTriggerInteraction)1))
			{
				float num2 = 1f - ((RaycastHit)(ref val)).distance / num;
				float num3 = num2 * num2;
				_groundRoot.SetPositionAndRotation(((RaycastHit)(ref val)).point + ((RaycastHit)(ref val)).normal * 0.05f, Quaternion.LookRotation(((RaycastHit)(ref val)).normal, forward));
				SetEmitting(_groundSystems, Thrusting, num3);
				((Behaviour)_groundLight).enabled = true;
				_groundLight.intensity = _intensity * (1.5f + 4.5f * num3) * (0.75f + flicker * 0.5f);
				_groundLight.range = 5f + 7f * num2;
			}
			else
			{
				SetEmitting(_groundSystems, on: false, 0f);
				((Behaviour)_groundLight).enabled = false;
			}
		}

		private static void SetEmitting(ParticleSystem[] systems, bool on, float rateScale)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			foreach (ParticleSystem val in systems)
			{
				EmissionModule emission = val.emission;
				((EmissionModule)(ref emission)).enabled = on && rateScale > 0.01f;
				((EmissionModule)(ref emission)).rateOverTimeMultiplier = ((Component)val).GetComponent<BaseRate>().Rate * rateScale;
				if (((EmissionModule)(ref emission)).enabled && !val.isPlaying)
				{
					val.Play();
				}
			}
		}

		private ParticleSystem MakeJet(string name, Vector3 localPos, Quaternion localRot)
		{
			//IL_0008: 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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_0081: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: 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_00db: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: 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_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Expected O, but got Unknown
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			ParticleSystem val = NewSystem(name, ((Component)this).transform, localPos, localRot, 140f);
			MainModule main = val.main;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.18f, 0.32f);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(7f, 11f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(0.22f, 0.4f);
			((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, (float)Math.PI * 2f);
			((MainModule)(ref main)).maxParticles = 200;
			ShapeModule shape = val.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
			((ShapeModule)(ref shape)).angle = 7f;
			((ShapeModule)(ref shape)).radius = 0.04f;
			ColorOverLifetimeModule colorOverLifetime = val.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = Gradient3(new Color(1f, 0.95f, 0.75f), new Color(1f, 0.5f, 0.1f), new Color(0.5f, 0.12f, 0.04f), 1f, 0.85f, 0f);
			SizeOverLifetimeModule sizeOverLifetime = val.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[3]
			{
				new Keyframe(0f, 0.5f),
				new Keyframe(0.35f, 1.1f),
				new Keyframe(1f, 1.6f)
			}));
			return val;
		}

		private ParticleSystem MakeSparks(string name, Vector3 localPos, Quaternion localRot)
		{
			//IL_0008: 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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: 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_011f: Unknown result type (might be due to invalid IL or missing references)
			ParticleSystem obj = NewSystem(name, ((Component)this).transform, localPos, localRot, 35f);
			MainModule main = obj.main;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.25f, 0.6f);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(9f, 16f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(0.03f, 0.07f);
			((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(1f, 0.85f, 0.4f), new Color(1f, 0.45f, 0.1f));
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0.6f);
			((MainModule)(ref main)).maxParticles = 120;
			ShapeModule shape = obj.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
			((ShapeModule)(ref shape)).angle = 14f;
			((ShapeModule)(ref shape)).radius = 0.03f;
			ColorOverLifetimeModule colorOverLifetime = obj.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = Gradient3(Color.white, new Color(1f, 0.6f, 0.2f), new Color(1f, 0.3f, 0.05f), 1f, 1f, 0f);
			ParticleSystemRenderer component = ((Component)obj).GetComponent<ParticleSystemRenderer>();
			component.renderMode = (ParticleSystemRenderMode)1;
			component.velocityScale = 0.04f;
			component.lengthScale = 2f;
			DisableSheet(obj);
			return obj;
		}

		private ParticleSystem MakeGroundFlames()
		{
			//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_0022: 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_0034: 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_0060: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: 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_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_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Expected O, but got Unknown
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			ParticleSystem val = NewSystem("GroundFlames", _groundRoot, Vector3.zero, Quaternion.identity, 70f);
			MainModule main = val.main;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.35f, 0.75f);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(1.2f, 3.2f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(0.45f, 1.1f);
			((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, (float)Math.PI * 2f);
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.15f);
			((MainModule)(ref main)).maxParticles = 250;
			ShapeModule shape = val.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
			((ShapeModule)(ref shape)).angle = 20f;
			((ShapeModule)(ref shape)).radius = 1.1f;
			ColorOverLifetimeModule colorOverLifetime = val.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = Gradient3(new Color(1f, 0.85f, 0.5f), new Color(1f, 0.45f, 0.08f), new Color(0.35f, 0.08f, 0.03f), 0.9f, 0.7f, 0f);
			SizeOverLifetimeModule sizeOverLifetime = val.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[3]
			{
				new Keyframe(0f, 0.6f),
				new Keyframe(0.3f, 1f),
				new Keyframe(1f, 0.2f)
			}));
			return val;
		}

		private ParticleSystem MakeGroundBlast()
		{
			//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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			ParticleSystem obj = NewSystem("GroundBlast", _groundRoot, Vector3.zero, Quaternion.identity, 55f);
			MainModule main = obj.main;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.25f, 0.45f);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(3.5f, 7f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(0.35f, 0.7f);
			((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, (float)Math.PI * 2f);
			((MainModule)(ref main)).maxParticles = 200;
			ShapeModule shape = obj.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
			((ShapeModule)(ref shape)).angle = 82f;
			((ShapeModule)(ref shape)).radius = 0.3f;
			ColorOverLifetimeModule colorOverLifetime = obj.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = Gradient3(new Color(1f, 0.9f, 0.6f), new Color(1f, 0.5f, 0.1f), new Color(0.4f, 0.1f, 0.03f), 0.85f, 0.6f, 0f);
			return obj;
		}

		private ParticleSystem MakeEmbers()
		{
			//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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a4: 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_00e2: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			ParticleSystem obj = NewSystem("GroundEmbers", _groundRoot, Vector3.zero, Quaternion.identity, 25f);
			MainModule main = obj.main;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.8f, 1.6f);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(1.5f, 4f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(0.03f, 0.08f);
			((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(1f, 0.75f, 0.3f), new Color(1f, 0.4f, 0.05f));
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.05f);
			((MainModule)(ref main)).maxParticles = 150;
			ShapeModule shape = obj.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
			((ShapeModule)(ref shape)).angle = 35f;
			((ShapeModule)(ref shape)).radius = 1.4f;
			NoiseModule noise = obj.noise;
			((NoiseModule)(ref noise)).enabled = true;
			((NoiseModule)(ref noise)).strength = MinMaxCurve.op_Implicit(0.8f);
			((NoiseModule)(ref noise)).frequency = 0.6f;
			ColorOverLifetimeModule colorOverLifetime = obj.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = Gradient3(Color.white, new Color(1f, 0.5f, 0.1f), new Color(0.6f, 0.15f, 0.05f), 1f, 0.9f, 0f);
			DisableSheet(obj);
			return obj;
		}

		private ParticleSystem NewSystem(string name, Transform parent, Vector3 localPos, Quaternion localRot, float rate)
		{
			//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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPos;
			val.transform.localRotation = localRot;
			ParticleSystem val2 = val.AddComponent<ParticleSystem>();
			val2.Stop(true, (ParticleSystemStopBehavior)0);
			val.AddComponent<BaseRate>().Rate = rate;
			MainModule main = val2.main;
			((MainModule)(ref main)).loop = true;
			((MainModule)(ref main)).playOnAwake = false;
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)0;
			EmissionModule emission = val2.emission;
			((EmissionModule)(ref emission)).enabled = false;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(rate);
			ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>();
			((Renderer)component).sharedMaterial = _flameMaterial;
			component.renderMode = (ParticleSystemRenderMode)0;
			((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)component).receiveShadows = false;
			CopyTextureSheet(val2);
			return val2;
		}

		private static Light MakeLight(string name, Transform parent, Vector3 localPos, float range)
		{
			//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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPos;
			Light obj = val.AddComponent<Light>();
			obj.type = (LightType)2;
			obj.color = FlameColor;
			obj.range = range;
			obj.intensity = 0f;
			obj.shadows = (LightShadows)0;
			((Behaviour)obj).enabled = false;
			return obj;
		}

		private static MinMaxGradient Gradient3(Color a, Color b, Color c, float alphaA, float alphaB, float alphaC)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			Gradient val = new Gradient();
			val.SetKeys((GradientColorKey[])(object)new GradientColorKey[3]
			{
				new GradientColorKey(a, 0f),
				new GradientColorKey(b, 0.4f),
				new GradientColorKey(c, 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
			{
				new GradientAlphaKey(alphaA, 0f),
				new GradientAlphaKey(alphaB, 0.5f),
				new GradientAlphaKey(alphaC, 1f)
			});
			return new MinMaxGradient(val);
		}

		private static Transform FindChest(Player player)
		{
			Animator componentInChildren = ((Component)player).GetComponentInChildren<Animator>();
			if ((Object)(object)componentInChildren != (Object)null && componentInChildren.isHuman)
			{
				Transform val = componentInChildren.GetBoneTransform((HumanBodyBones)8) ?? componentInChildren.GetBoneTransform((HumanBodyBones)7);
				if ((Object)(object)val != (Object)null)
				{
					return val;
				}
			}
			string[] array = new string[3] { "Spine2", "Spine1", "Spine" };
			foreach (string n in array)
			{
				Transform val2 = ((IEnumerable<Transform>)((Component)player).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform x) => ((Object)x).name == n));
				if ((Object)(object)val2 != (Object)null)
				{
					return val2;
				}
			}
			return null;
		}

		private static void EnsureMaterial()
		{
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Expected O, but got Unknown
			if (_materialSearched)
			{
				return;
			}
			_materialSearched = true;
			string[] obj = new string[5] { "fire_pit", "bonfire", "piece_brazierfloor01", "piece_groundtorch_wood", "Torch" };
			ParticleSystemRenderer val = null;
			int num = 0;
			string[] array = obj;
			foreach (string text in array)
			{
				GameObject val2 = (Object.op_Implicit((Object)(object)ZNetScene.instance) ? ZNetScene.instance.GetPrefab(text) : null);
				if ((Object)(object)val2 == (Object)null && Object.op_Implicit((Object)(object)ObjectDB.instance))
				{
					val2 = ObjectDB.instance.GetItemPrefab(text);
				}
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				ParticleSystemRenderer[] componentsInChildren = val2.GetComponentsInChildren<ParticleSystemRenderer>(true);
				foreach (ParticleSystemRenderer val3 in componentsInChildren)
				{
					if (!((Object)(object)((Renderer)val3).sharedMaterial == (Object)null))
					{
						string text2 = (((Object)val3).name + " " + ((Object)((Renderer)val3).sharedMaterial).name).ToLowerInvariant();
						JetpackPlugin.Log.LogDebug((object)("Fire candidate: " + text + "/" + ((Object)val3).name + " mat=" + ((Object)((Renderer)val3).sharedMaterial).name + " shader=" + ((Object)((Renderer)val3).sharedMaterial.shader).name));
						int num2 = 1;
						if (text2.Contains("fire"))
						{
							num2 += 2;
						}
						if (text2.Contains("flame"))
						{
							num2 += 4;
						}
						if (text2.Contains("smoke") || text2.Contains("spark") || text2.Contains("ember") || text2.Contains("distort"))
						{
							num2 -= 4;
						}
						if (num2 > num)
						{
							num = num2;
							val = val3;
						}
					}
				}
				if (num >= 5)
				{
					break;
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				_flameMaterial = ((Renderer)val).sharedMaterial;
				_flameSource = ((Component)val).GetComponent<ParticleSystem>();
				JetpackPlugin.Log.LogInfo((object)("Using flame material '" + ((Object)_flameMaterial).name + "' (" + ((Object)_flameMaterial.shader).name + ") from '" + ((Object)val).name + "'."));
			}
			else
			{
				Shader val4 = ((IEnumerable<string>)new string[3] { "Particles/Standard Unlit", "Legacy Shaders/Particles/Additive", "Sprites/Default" }).Select((Func<string, Shader>)Shader.Find).FirstOrDefault((Func<Shader, bool>)((Shader s) => (Object)(object)s != (Object)null));
				_flameMaterial = new Material(val4)
				{
					mainTexture = (Texture)(object)MakeSoftDot()
				};
				JetpackPlugin.Log.LogWarning((object)("No vanilla flame material found, using fallback shader '" + ((val4 != null) ? ((Object)val4).name : null) + "'."));
			}
		}

		private static Texture2D MakeSoftDot()
		{
			//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_0013: Expected O, but got Unknown
			//IL_001f: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false)
			{
				wrapMode = (TextureWrapMode)1
			};
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					float num = Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(32f, 32f)) / 32f;
					float num2 = Mathf.Clamp01(1f - num);
					val.SetPixel(j, i, new Color(1f, 1f, 1f, num2 * num2));
				}
			}
			val.Apply();
			return val;
		}

		private static void CopyTextureSheet(ParticleSystem ps)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Invalid comparison between Unknown and I4
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_flameSource == (Object)null)
			{
				return;
			}
			TextureSheetAnimationModule textureSheetAnimation = _flameSource.textureSheetAnimation;
			if (!((TextureSheetAnimationModule)(ref textureSheetAnimation)).enabled)
			{
				return;
			}
			TextureSheetAnimationModule textureSheetAnimation2 = ps.textureSheetAnimation;
			((TextureSheetAnimationModule)(ref textureSheetAnimation2)).enabled = true;
			((TextureSheetAnimationModule)(ref textureSheetAnimation2)).mode = ((TextureSheetAnimationModule)(ref textureSheetAnimation)).mode;
			if ((int)((TextureSheetAnimationModule)(ref textureSheetAnimation)).mode == 1)
			{
				for (int i = 0; i < ((TextureSheetAnimationModule)(ref textureSheetAnimation)).spriteCount; i++)
				{
					((TextureSheetAnimationModule)(ref textureSheetAnimation2)).AddSprite(((TextureSheetAnimationModule)(ref textureSheetAnimation)).GetSprite(i));
				}
			}
			else
			{
				((TextureSheetAnimationModule)(ref textureSheetAnimation2)).numTilesX = ((TextureSheetAnimationModule)(ref textureSheetAnimation)).numTilesX;
				((TextureSheetAnimationModule)(ref textureSheetAnimation2)).numTilesY = ((TextureSheetAnimationModule)(ref textureSheetAnimation)).numTilesY;
				((TextureSheetAnimationModule)(ref textureSheetAnimation2)).animation = ((TextureSheetAnimationModule)(ref textureSheetAnimation)).animation;
				((TextureSheetAnimationModule)(ref textureSheetAnimation2)).rowIndex = ((TextureSheetAnimationModule)(ref textureSheetAnimation)).rowIndex;
			}
			((TextureSheetAnimationModule)(ref textureSheetAnimation2)).frameOverTime = ((TextureSheetAnimationModule)(ref textureSheetAnimation)).frameOverTime;
			((TextureSheetAnimationModule)(ref textureSheetAnimation2)).startFrame = ((TextureSheetAnimationModule)(ref textureSheetAnimation)).startFrame;
			((TextureSheetAnimationModule)(ref textureSheetAnimation2)).cycleCount = ((TextureSheetAnimationModule)(ref textureSheetAnimation)).cycleCount;
		}

		private static void DisableSheet(ParticleSystem ps)
		{
			//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_0017: Unknown result type (might be due to invalid IL or missing references)
			TextureSheetAnimationModule textureSheetAnimation = ps.textureSheetAnimation;
			if (((TextureSheetAnimationModule)(ref textureSheetAnimation)).enabled)
			{
				((TextureSheetAnimationModule)(ref textureSheetAnimation)).frameOverTime = new MinMaxCurve(0f);
				((TextureSheetAnimationModule)(ref textureSheetAnimation)).cycleCount = 1;
			}
		}
	}
	internal class BaseRate : MonoBehaviour
	{
		public float Rate;
	}
	[BepInPlugin("com.lagstedt.jetpack", "Jetpack", "1.3.1")]
	public class JetpackPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.lagstedt.jetpack";

		public const string PluginName = "Jetpack";

		public const string PluginVersion = "1.3.1";

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<float> MaxUpSpeed;

		internal static ConfigEntry<float> UpAcceleration;

		internal static ConfigEntry<float> HorizontalSpeed;

		internal static ConfigEntry<float> HorizontalAcceleration;

		internal static ConfigEntry<float> StaminaPerSecond;

		internal static ConfigEntry<bool> NoFallDamage;

		internal static ConfigEntry<bool> NoFireDamage;

		internal static ConfigEntry<float> GroundGlowDistance;

		internal static ConfigEntry<bool> JetModeEnabled;

		internal static ConfigEntry<float> JetSpeed;

		internal static ConfigEntry<float> JetAcceleration;

		internal static ConfigEntry<float> JetTiltAngle;

		internal static ConfigEntry<bool> GliderEnabled;

		internal static ConfigEntry<float> GliderFallSpeed;

		internal static ConfigEntry<float> GliderSpeed;

		internal static ConfigEntry<float> GliderAcceleration;

		private Harmony _harmony;

		private void Awake()
		{
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Turn the jetpack on or off.");
			MaxUpSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Flight", "MaxUpSpeed", 12f, "Maximum climb speed (m/s) while thrusting.");
			UpAcceleration = ((BaseUnityPlugin)this).Config.Bind<float>("Flight", "UpAcceleration", 35f, "How fast the climb speed builds up (m/s²).");
			HorizontalSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Flight", "HorizontalSpeed", 9f, "Top horizontal speed (m/s) while thrusting.");
			HorizontalAcceleration = ((BaseUnityPlugin)this).Config.Bind<float>("Flight", "HorizontalAcceleration", 12f, "Horizontal steering acceleration (m/s²) while thrusting.");
			StaminaPerSecond = ((BaseUnityPlugin)this).Config.Bind<float>("Flight", "StaminaPerSecond", 0f, "Stamina drained per second of thrust. 0 = free flight.");
			NoFallDamage = ((BaseUnityPlugin)this).Config.Bind<bool>("Protection", "NoFallDamage", true, "Player never takes fall damage.");
			NoFireDamage = ((BaseUnityPlugin)this).Config.Bind<bool>("Protection", "NoFireDamage", true, "Player never takes fire / burning / lava damage.");
			GroundGlowDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Effects", "GroundGlowDistance", 18f, "Max height (m) above ground at which the flames light up and scorch the ground.");
			JetModeEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("JetMode", "Enabled", true, "Hold Run (Shift) while thrusting to fly forward like a jet instead of climbing.");
			JetSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("JetMode", "Speed", 28f, "Cruise speed (m/s) in jet mode.");
			JetAcceleration = ((BaseUnityPlugin)this).Config.Bind<float>("JetMode", "Acceleration", 22f, "How fast you reach cruise speed and turn (m/s²).");
			JetTiltAngle = ((BaseUnityPlugin)this).Config.Bind<float>("JetMode", "TiltAngle", 75f, "How far the body leans forward (degrees) in jet mode.");
			GliderEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Glider", "Enabled", true, "Press Run (Shift) in mid-air, or release jump while holding it, to open a paraglider.");
			GliderFallSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Glider", "FallSpeed", 2.5f, "Sink rate (m/s) under the glider.");
			GliderSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Glider", "Speed", 20f, "Forward glide speed (m/s).");
			GliderAcceleration = ((BaseUnityPlugin)this).Config.Bind<float>("Glider", "Acceleration", 10f, "How fast you reach glide speed and turn (m/s²).");
			_harmony = new Harmony("com.lagstedt.jetpack");
			_harmony.PatchAll(typeof(JetpackPlugin).Assembly);
			Log.LogInfo((object)"Jetpack 1.3.1 loaded.");
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	internal static class OutfitColors
	{
		private static readonly FieldRef<VisEquipment, List<GameObject>> ChestItems = AccessTools.FieldRefAccess<VisEquipment, List<GameObject>>("m_chestItemInstances");

		private static readonly FieldRef<VisEquipment, List<GameObject>> LegItems = AccessTools.FieldRefAccess<VisEquipment, List<GameObject>>("m_legItemInstances");

		private static readonly FieldRef<VisEquipment, List<GameObject>> ShoulderItems = AccessTools.FieldRefAccess<VisEquipment, List<GameObject>>("m_shoulderItemInstances");

		private static readonly FieldRef<VisEquipment, int> ChestHash = AccessTools.FieldRefAccess<VisEquipment, int>("m_currentChestItemHash");

		private static readonly FieldRef<VisEquipment, int> LegHash = AccessTools.FieldRefAccess<VisEquipment, int>("m_currentLegItemHash");

		private static readonly FieldRef<VisEquipment, int> ShoulderHash = AccessTools.FieldRefAccess<VisEquipment, int>("m_currentShoulderItemHash");

		private const int SampleSize = 64;

		public static int OutfitKey(VisEquipment vis)
		{
			if ((Object)(object)vis == (Object)null)
			{
				return 0;
			}
			return (((ChestHash.Invoke(vis) * 397) ^ LegHash.Invoke(vis)) * 397) ^ ShoulderHash.Invoke(vis);
		}

		public static bool TryGetPalette(VisEquipment vis, out Color primary, out Color secondary)
		{
			//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_0008: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			primary = (secondary = Color.white);
			if ((Object)(object)vis == (Object)null)
			{
				return false;
			}
			List<Color> list = new List<Color>(3);
			AddIfFound(list, (ShoulderHash.Invoke(vis) != 0) ? FromItems(ShoulderItems.Invoke(vis)) : ((Color?)null));
			AddIfFound(list, (ChestHash.Invoke(vis) == 0) ? ((Color?)null) : (FromItems(ChestItems.Invoke(vis)) ?? FromBody(vis, "_ChestTex")));
			AddIfFound(list, (LegHash.Invoke(vis) == 0) ? ((Color?)null) : (FromItems(LegItems.Invoke(vis)) ?? FromBody(vis, "_LegsTex")));
			if (list.Count == 0)
			{
				return false;
			}
			primary = Fabric(list[0]);
			secondary = ((list.Count > 1 && Distance(list[0], list[1]) > 0.08f) ? Fabric(list[1]) : Shade(primary, 0.62f));
			return true;
		}

		private static void AddIfFound(List<Color> list, Color? c)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			if (c.HasValue)
			{
				list.Add(c.Value);
			}
		}

		private static Color? FromItems(List<GameObject> instances)
		{
			if (instances == null)
			{
				return null;
			}
			foreach (GameObject instance in instances)
			{
				if ((Object)(object)instance == (Object)null)
				{
					continue;
				}
				Renderer[] componentsInChildren = instance.GetComponentsInChildren<Renderer>();
				foreach (Renderer val in componentsInChildren)
				{
					if (!(val is ParticleSystemRenderer))
					{
						Color? result = FromMaterial(val.sharedMaterial, "_MainTex");
						if (result.HasValue)
						{
							return result;
						}
					}
				}
			}
			return null;
		}

		private static Color? FromBody(VisEquipment vis, string textureProperty)
		{
			if (!((Object)(object)vis.m_bodyModel != (Object)null))
			{
				return null;
			}
			return FromMaterial(((Renderer)vis.m_bodyModel).sharedMaterial, textureProperty);
		}

		private static Color? FromMaterial(Material m, string textureProperty)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)m == (Object)null)
			{
				return null;
			}
			Color val = (m.HasProperty("_Color") ? m.GetColor("_Color") : Color.white);
			Texture val2 = (m.HasProperty(textureProperty) ? m.GetTexture(textureProperty) : null);
			if ((Object)(object)val2 == (Object)null)
			{
				return null;
			}
			Color? val3 = AverageTexture(val2);
			if (!val3.HasValue)
			{
				return null;
			}
			return val3.Value * val;
		}

		private static Color? AverageTexture(Texture tex)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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)
			RenderTexture temporary = RenderTexture.GetTemporary(64, 64, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2);
			RenderTexture active = RenderTexture.active;
			Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false);
			try
			{
				Graphics.Blit(tex, temporary);
				RenderTexture.active = temporary;
				val.ReadPixels(new Rect(0f, 0f, 64f, 64f), 0, 0);
				val.Apply();
				float num = 0f;
				float num2 = 0f;
				float num3 = 0f;
				float num4 = 0f;
				Color[] pixels = val.GetPixels();
				foreach (Color val2 in pixels)
				{
					if (!(val2.a < 0.3f))
					{
						num += val2.r * val2.a;
						num2 += val2.g * val2.a;
						num3 += val2.b * val2.a;
						num4 += val2.a;
					}
				}
				return (num4 > 1f) ? new Color?(new Color(num / num4, num2 / num4, num3 / num4)) : ((Color?)null);
			}
			catch (Exception ex)
			{
				JetpackPlugin.Log.LogDebug((object)("Could not sample '" + ((Object)tex).name + "': " + ex.Message));
				return null;
			}
			finally
			{
				RenderTexture.active = active;
				RenderTexture.ReleaseTemporary(temporary);
				Object.Destroy((Object)(object)val);
			}
		}

		private static Color Fabric(Color c)
		{
			//IL_0000: 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)
			float num = default(float);
			float num2 = default(float);
			float num3 = default(float);
			Color.RGBToHSV(c, ref num, ref num2, ref num3);
			return Color.HSVToRGB(num, Mathf.Clamp01(num2 * 1.35f), Mathf.Clamp(num3 * 1.1f, 0.28f, 0.92f));
		}

		private static Color Shade(Color c, float factor)
		{
			//IL_0000: 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)
			float num = default(float);
			float num2 = default(float);
			float num3 = default(float);
			Color.RGBToHSV(c, ref num, ref num2, ref num3);
			float num4 = ((num3 > 0.5f) ? (num3 * factor) : Mathf.Min(1f, num3 / factor));
			return Color.HSVToRGB(num, num2, num4);
		}

		private static float Distance(Color a, Color b)
		{
			//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)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			return Mathf.Abs(a.r - b.r) + Mathf.Abs(a.g - b.g) + Mathf.Abs(a.b - b.b);
		}
	}
	[HarmonyPatch(typeof(Player), "Awake")]
	internal static class Player_Awake_Patch
	{
		private static void Postfix(Player __instance)
		{
			if ((Object)(object)((Component)__instance).GetComponent<JetpackController>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<JetpackController>();
			}
		}
	}
	[HarmonyPatch(typeof(Character), "CustomFixedUpdate")]
	internal static class Character_CustomFixedUpdate_Patch
	{
		private static void Postfix(Character __instance, float dt)
		{
			Player val = (Player)(object)((__instance is Player) ? __instance : null);
			if (val != null && (Object)(object)val == (Object)(object)Player.m_localPlayer)
			{
				JetpackController.Local?.ApplyFlight(dt);
			}
		}
	}
	[HarmonyPatch(typeof(Character), "RPC_Damage")]
	internal static class Character_RPC_Damage_Patch
	{
		private static bool Prefix(Character __instance, HitData hit)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Invalid comparison between Unknown and I4
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Invalid comparison between Unknown and I4
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Invalid comparison between Unknown and I4
			if (!(__instance is Player) || hit == null)
			{
				return true;
			}
			if (JetpackPlugin.NoFallDamage.Value && (int)hit.m_hitType == 3)
			{
				return false;
			}
			if (JetpackPlugin.NoFireDamage.Value)
			{
				HitType hitType = hit.m_hitType;
				if ((int)hitType == 5 || hitType - 20 <= 3)
				{
					return false;
				}
				hit.m_damage.m_fire = 0f;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(SEMan), "AddStatusEffect", new Type[]
	{
		typeof(StatusEffect),
		typeof(bool),
		typeof(int),
		typeof(float),
		typeof(short)
	})]
	internal static class SEMan_AddStatusEffect_Patch
	{
		private static bool Prefix(StatusEffect statusEffect, Character ___m_character, ref StatusEffect __result)
		{
			if (JetpackPlugin.NoFireDamage.Value && ___m_character is Player && (Object)(object)statusEffect != (Object)null && statusEffect.NameHash() == SEMan.s_statusEffectBurning)
			{
				__result = null;
				return false;
			}
			return true;
		}
	}
}