Decompiled source of KamikazeFPVDrone v1.0.0

FPVDrone.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json.Linq;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("FPVDrone")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FPVDrone")]
[assembly: AssemblyTitle("FPVDrone")]
[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 FPVDrone
{
	internal enum FlightMode
	{
		Assist,
		Angle,
		Acro
	}
	internal class DroneFlight : MonoBehaviour
	{
		internal const float Mass = 1.1f;

		internal Rigidbody Body;

		internal Transform CamMount;

		internal Player Pilot;

		internal bool Linked = true;

		internal FlightMode Mode;

		internal float AimYaw;

		internal float AimPitch;

		internal bool Chase;

		internal float Throttle;

		internal float Battery = 1f;

		internal float Signal = 1f;

		internal bool Armed;

		internal float FlightTime;

		internal float CamPitch;

		internal float GroundDistance;

		internal Vector3 Home;

		internal bool Exploded;

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

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

		private float _spin;

		private float _acroThrottle;

		private AudioSource _motor;

		private float _badSignal;

		private float _restTime;

		private float _unlinkedTime;

		private float _pitchIn;

		private float _rollIn;

		private float _yawIn;

		private float _thrIn;

		private float _pitchSm;

		private float _rollSm;

		private Vector2 _mouse;

		private bool _boost;

		private bool _cut;

		private Renderer[] _renderers;

		private bool _hiddenFromFpv;

		internal bool Acro => Mode == FlightMode.Acro;

		private static float MouseDeg => PlayerController.m_mouseSens * Cfg.MouseSens.Value;

		private float MaxThrust => Cfg.ThrustToWeight.Value * 1.1f * (0f - Physics.gravity.y);

		internal static string ModeName(FlightMode m)
		{
			return m switch
			{
				FlightMode.Angle => "ANGL", 
				FlightMode.Assist => "ASST", 
				_ => "ACRO", 
			};
		}

		internal static DroneFlight Spawn(Player pilot, Vector3 pos, Quaternion rot)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0011: 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_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_0086: 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_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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: 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_0105: Expected O, but got Unknown
			//IL_0151: 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_018c: 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_01a5: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("FPVDroneLive");
			val.transform.SetPositionAndRotation(pos, rot);
			int num = LayerMask.NameToLayer("vehicle");
			if (num < 0)
			{
				num = LayerMask.NameToLayer("item");
			}
			if (num < 0)
			{
				num = 0;
			}
			GameObject val2 = FpvAssets.NewDrone(val.transform);
			Transform[] componentsInChildren = val.GetComponentsInChildren<Transform>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				((Component)componentsInChildren[i]).gameObject.layer = num;
			}
			Bounds val3 = FpvItems.LocalBounds(val.transform, val2);
			BoxCollider obj = val.AddComponent<BoxCollider>();
			obj.center = ((Bounds)(ref val3)).center;
			obj.size = new Vector3(((Bounds)(ref val3)).size.x * 0.8f, Mathf.Max(((Bounds)(ref val3)).size.y, 0.08f), ((Bounds)(ref val3)).size.z * 0.8f);
			((Collider)obj).sharedMaterial = new PhysicsMaterial("fpv")
			{
				bounciness = 0.15f,
				dynamicFriction = 0.5f,
				staticFriction = 0.6f
			};
			Rigidbody val4 = val.AddComponent<Rigidbody>();
			val4.mass = 1.1f;
			val4.linearDamping = 0f;
			val4.angularDamping = 0.5f;
			val4.maxAngularVelocity = 40f;
			val4.interpolation = (RigidbodyInterpolation)1;
			val4.collisionDetectionMode = (CollisionDetectionMode)2;
			val4.centerOfMass = ((Bounds)(ref val3)).center;
			val4.inertiaTensor = new Vector3(0.012f, 0.02f, 0.012f);
			DroneFlight droneFlight = val.AddComponent<DroneFlight>();
			droneFlight.Body = val4;
			droneFlight.Pilot = pilot;
			droneFlight.Home = pos;
			droneFlight.Mode = Cfg.StartMode.Value;
			droneFlight.AimYaw = ((Quaternion)(ref rot)).eulerAngles.y;
			droneFlight.AimPitch = 5f;
			droneFlight._renderers = val2.GetComponentsInChildren<Renderer>(true);
			droneFlight.CamMount = FindDeep(val2.transform, "CamMount") ?? val2.transform;
			droneFlight.SetupProps(val2.transform);
			droneFlight._motor = FpvAssets.AddSource(val, FpvAssets.Motor, loop: true, 3f, 140f);
			droneFlight._motor.volume = 0f;
			droneFlight._motor.Play();
			return droneFlight;
		}

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

		internal static void CollectProps(Transform root, List<Transform> props, List<Renderer> discs)
		{
			Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if (((Object)val).name.StartsWith("Prop_"))
				{
					props.Add(val);
					discs.Add(MakeBlurDisc(val));
				}
			}
		}

		private void SetupProps(Transform model)
		{
			CollectProps(model, _props, _discs);
		}

		private static Renderer MakeBlurDisc(Transform prop)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_007f: 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_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_0032: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Expected O, but got Unknown
			//IL_0197: 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_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Expected O, but got Unknown
			MeshFilter component = ((Component)prop).GetComponent<MeshFilter>();
			float num;
			if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.sharedMesh))
			{
				num = 0.09f;
			}
			else
			{
				Bounds bounds = component.sharedMesh.bounds;
				float x = ((Bounds)(ref bounds)).extents.x;
				bounds = component.sharedMesh.bounds;
				num = Mathf.Max(x, ((Bounds)(ref bounds)).extents.z);
			}
			float num2 = num;
			GameObject val = new GameObject("PropDisc");
			val.transform.SetParent(prop.parent, false);
			val.transform.localPosition = prop.localPosition;
			val.transform.localRotation = prop.localRotation;
			val.layer = ((Component)prop).gameObject.layer;
			Vector3[] array = (Vector3[])(object)new Vector3[25];
			int[] array2 = new int[144];
			for (int i = 0; i < 24; i++)
			{
				float num3 = (float)i * (float)Math.PI * 2f / 24f;
				array[i + 1] = new Vector3(Mathf.Cos(num3) * num2, 0f, Mathf.Sin(num3) * num2);
				int num4 = (i + 1) % 24 + 1;
				array2[i * 6] = 0;
				array2[i * 6 + 1] = num4;
				array2[i * 6 + 2] = i + 1;
				array2[i * 6 + 3] = 0;
				array2[i * 6 + 4] = i + 1;
				array2[i * 6 + 5] = num4;
			}
			Mesh val2 = new Mesh
			{
				vertices = array,
				triangles = array2
			};
			val2.RecalculateNormals();
			val.AddComponent<MeshFilter>().sharedMesh = val2;
			MeshRenderer obj = val.AddComponent<MeshRenderer>();
			((Renderer)obj).sharedMaterial = new Material(FpvAssets.ParticleMaterial(additive: false))
			{
				color = new Color(0.08f, 0.08f, 0.08f, 0f)
			};
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)obj).enabled = false;
			return (Renderer)(object)obj;
		}

		internal static void SpinProps(List<Transform> props, List<Renderer> discs, float spin, float dt)
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < props.Count; i++)
			{
				Transform val = props[i];
				if (!Object.op_Implicit((Object)(object)val))
				{
					continue;
				}
				bool flag = ((Object)val).name.EndsWith("FR") || ((Object)val).name.EndsWith("BL");
				val.Rotate(0f, (flag ? (-1f) : 1f) * spin * dt, 0f, (Space)1);
				Renderer val2 = discs[i];
				if (Object.op_Implicit((Object)(object)val2))
				{
					float num = Mathf.Clamp01((spin - 900f) / 3000f) * 0.45f;
					val2.enabled = num > 0.01f;
					if (val2.enabled)
					{
						Color color = val2.material.color;
						color.a = num;
						val2.material.color = color;
					}
				}
			}
		}

		private bool InputAllowed()
		{
			if (!Linked)
			{
				return false;
			}
			if (Menu.IsVisible() || Console.IsVisible() || InventoryGui.IsVisible() || Minimap.IsOpen())
			{
				return false;
			}
			if (Object.op_Implicit((Object)(object)Chat.instance) && Chat.instance.HasFocus())
			{
				return false;
			}
			return true;
		}

		private static float Axis(string pos, string neg)
		{
			return (ZInput.GetButton(pos) ? 1f : 0f) - (ZInput.GetButton(neg) ? 1f : 0f);
		}

		private void Update()
		{
			//IL_0011: 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_0020: 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)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_0082: 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_00d3: 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_0136: 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_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: 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_02fc: 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)
			//IL_01a0: 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_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: 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_03e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0432: Unknown result type (might be due to invalid IL or missing references)
			//IL_046f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0452: Unknown result type (might be due to invalid IL or missing references)
			float deltaTime = Time.deltaTime;
			if (InputAllowed())
			{
				Vector2 val = ZInput.GetMouseDelta() * MouseDeg;
				if (Cfg.InvertMouseY.Value != PlayerController.m_invertMouse)
				{
					val.y = 0f - val.y;
				}
				_mouse += val;
				if (Mode == FlightMode.Assist)
				{
					AimYaw = Mathf.Repeat(AimYaw + val.x, 360f);
					AimPitch = Mathf.Clamp(AimPitch - val.y, -60f, 85f);
				}
				Vector2 val2 = default(Vector2);
				((Vector2)(ref val2))..ctor(ZInput.GetJoyLeftStickX(), 0f - ZInput.GetJoyLeftStickY());
				Vector2 zero = default(Vector2);
				((Vector2)(ref zero))..ctor(ZInput.GetJoyRightStickX(), 0f - ZInput.GetJoyRightStickY());
				bool flag = ZInput.IsGamepadActive();
				if (!flag)
				{
					val2 = (zero = Vector2.zero);
				}
				_boost = ZInput.GetButton("Run") || ZInput.GetButton("JoyRun");
				if (Acro)
				{
					_thrIn = Axis("Forward", "Backward") + Axis("Jump", "Crouch");
					_yawIn = Axis("Right", "Left") + val2.x;
					_pitchIn = zero.y;
					_rollIn = zero.x;
					_cut = false;
					if (flag)
					{
						_acroThrottle = Mathf.Clamp01((val2.y + 1f) * 0.5f);
					}
				}
				else if (Mode == FlightMode.Assist)
				{
					AimYaw = Mathf.Repeat(AimYaw + zero.x * 150f * deltaTime, 360f);
					AimPitch = Mathf.Clamp(AimPitch - zero.y * 110f * deltaTime, -60f, 85f);
					_pitchIn = Mathf.Clamp(Axis("Forward", "Backward") + val2.y, -1f, 1f);
					_rollIn = Mathf.Clamp(Axis("Right", "Left") + val2.x, -1f, 1f);
					_thrIn = Mathf.Clamp(Axis("Jump", "Crouch") + (flag ? (ZInput.GetJoyRTrigger() - ZInput.GetJoyLTrigger()) : 0f), -1f, 1f);
					_yawIn = 0f;
					_cut = false;
				}
				else
				{
					_pitchIn = Mathf.Clamp(Axis("Forward", "Backward") + zero.y, -1f, 1f);
					_rollIn = Mathf.Clamp(Axis("Right", "Left") + zero.x, -1f, 1f);
					_thrIn = Mathf.Clamp(Axis("Jump", "Crouch") + val2.y, -1f, 1f);
					_yawIn = val2.x;
					_cut = false;
				}
				if (ZInput.GetKeyDown(Cfg.KeyMode.Value, true))
				{
					Mode = (FlightMode)((int)(Mode + 1) % 3);
					_acroThrottle = Throttle;
					CamPitch = 0f;
					Vector3 val3 = Vector3.ProjectOnPlane(((Component)this).transform.forward, Vector3.up);
					if (((Vector3)(ref val3)).sqrMagnitude > 0.01f)
					{
						AimYaw = Mathf.Atan2(val3.x, val3.z) * 57.29578f;
					}
					AimPitch = 5f;
					MessageHud instance = MessageHud.instance;
					if (instance != null)
					{
						instance.ShowMessage((MessageType)1, "Flight mode: " + ModeName(Mode), 0, (Sprite)null, false, true);
					}
				}
				if (ZInput.GetKeyDown(Cfg.KeyChase.Value, true))
				{
					Chase = !Chase;
				}
				if (ZInput.GetMouseButtonDown(2))
				{
					CamPitch = 0f;
					AimPitch = 5f;
				}
				if (FlightTime > 0.6f && (ZInput.GetKeyDown(Cfg.KeyDetonate.Value, true) || ZInput.GetButtonDown("JoyAttack")))
				{
					Detonate(((Component)this).transform.position);
					return;
				}
				if (FlightTime > 0.6f && (ZInput.GetKeyDown(Cfg.KeyExit.Value, true) || ZInput.GetButtonDown("JoyUse")))
				{
					FpvSession.Disconnect("DISCONNECTED");
					return;
				}
			}
			else
			{
				_pitchIn = (_rollIn = (_yawIn = (_thrIn = 0f)));
				_boost = false;
			}
			bool flag2 = Linked && !Chase;
			if (flag2 != _hiddenFromFpv && _renderers != null)
			{
				_hiddenFromFpv = flag2;
				Renderer[] renderers = _renderers;
				foreach (Renderer val4 in renderers)
				{
					if (Object.op_Implicit((Object)(object)val4))
					{
						val4.shadowCastingMode = (ShadowCastingMode)((!flag2) ? 1 : 3);
					}
				}
			}
			bool flag3 = Linked && Battery > 0f;
			float num = (flag3 ? (1500f + Throttle * 5200f) : 0f);
			_spin = Mathf.MoveTowards(_spin, num, (flag3 ? 12000f : 2500f) * deltaTime);
			SpinProps(_props, _discs, _spin, deltaTime);
			if (_hiddenFromFpv)
			{
				foreach (Renderer disc in _discs)
				{
					if (Object.op_Implicit((Object)(object)disc))
					{
						disc.enabled = false;
					}
				}
			}
			Vector3 linearVelocity = Body.linearVelocity;
			float magnitude = ((Vector3)(ref linearVelocity)).magnitude;
			float num2 = (flag3 ? (0.3f + Throttle * 0.7f) : (Mathf.Clamp01(_spin / 3000f) * 0.4f));
			_motor.volume = Mathf.MoveTowards(_motor.volume, num2 * Cfg.MotorVolume.Value, deltaTime * 3f);
			_motor.pitch = Mathf.Lerp(_motor.pitch, 0.65f + Throttle * 0.85f + magnitude * 0.004f, deltaTime * 8f);
		}

		private void FixedUpdate()
		{
			//IL_0023: 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_005f: 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_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_0081: 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_008f: 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_0097: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			if (!Exploded)
			{
				float fixedDeltaTime = Time.fixedDeltaTime;
				FlightTime += fixedDeltaTime;
				Vector3 linearVelocity = Body.linearVelocity;
				bool motorsOn = Linked && Battery > 0f;
				float num = MaxThrust / (Cfg.TopSpeed.Value * Cfg.TopSpeed.Value);
				Vector3 val = -linearVelocity * (((Vector3)(ref linearVelocity)).magnitude * num + 0.05f);
				Body.AddForce(val, (ForceMode)0);
				Vector2 mouse = _mouse;
				_mouse = Vector2.zero;
				if (Mode == FlightMode.Assist)
				{
					FlyAssist(fixedDeltaTime, linearVelocity, val, motorsOn);
				}
				else
				{
					FlyManual(fixedDeltaTime, linearVelocity, mouse, motorsOn);
				}
				UpdateBattery(fixedDeltaTime);
				UpdateSignal(fixedDeltaTime);
				UpdateFuse();
				UpdateGround();
				if (!Linked)
				{
					UpdateUnlinked(fixedDeltaTime);
				}
				FpvNet.SendState(this);
			}
		}

		private void FlyAssist(float dt, Vector3 v, Vector3 drag, bool motorsOn)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_003c: 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_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_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_0099: 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_00a4: 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_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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: 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_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: 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_0164: 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_0176: 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_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			Quaternion val = Quaternion.Euler(0f, AimYaw, 0f);
			Vector3 val2 = Quaternion.Euler(AimPitch, AimYaw, 0f) * Vector3.forward;
			Vector3 val3 = val * Vector3.right;
			float num = Cfg.TopSpeed.Value * (_boost ? 0.95f : 0.55f);
			Vector3 val4 = Vector3.ClampMagnitude((val2 * (_pitchIn * num) + val3 * (_rollIn * num * 0.45f) + Vector3.up * (_thrIn * 7f) - v) * 1.6f, 22f);
			Vector3 val5 = 1.1f * val4 - 1.1f * Physics.gravity - drag;
			float num2 = (_boost ? 78f : 62f) * ((float)Math.PI / 180f);
			float num3 = Mathf.Max(val5.y, 1.1f * (0f - Physics.gravity.y) * 0.25f);
			val5 = Vector3.ClampMagnitude(Vector3.ClampMagnitude(new Vector3(val5.x, 0f, val5.z), num3 * Mathf.Tan(num2)) + Vector3.up * num3, MaxThrust);
			float num4 = (motorsOn ? Mathf.Clamp01(Vector3.Dot(val5, ((Component)this).transform.up) / MaxThrust) : 0f);
			Throttle = Mathf.MoveTowards(Throttle, num4, dt * 6f);
			Body.AddForce(((Component)this).transform.up * (MaxThrust * Throttle), (ForceMode)0);
			if (motorsOn)
			{
				Quaternion goal = Quaternion.FromToRotation(Vector3.up, ((Vector3)(ref val5)).normalized) * val;
				Body.angularVelocity = Vector3.Lerp(Body.angularVelocity, AttitudeRate(goal, 7f, 10f), 1f - Mathf.Exp(-16f * dt));
			}
		}

		private Vector3 AttitudeRate(Quaternion goal, float gain, float limit)
		{
			//IL_0000: 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_0016: 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_004d: 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_005d: 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)
			Quaternion val = goal * Quaternion.Inverse(((Component)this).transform.rotation);
			float num = default(float);
			Vector3 val2 = default(Vector3);
			((Quaternion)(ref val)).ToAngleAxis(ref num, ref val2);
			if (num > 180f)
			{
				num -= 360f;
			}
			if (float.IsNaN(val2.x) || ((Vector3)(ref val2)).sqrMagnitude < 1E-06f)
			{
				return Vector3.zero;
			}
			return Vector3.ClampMagnitude(val2 * (num * ((float)Math.PI / 180f) * gain), limit);
		}

		private void FlyManual(float dt, Vector3 v, Vector2 mouse, bool motorsOn)
		{
			//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_001b: 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_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: 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_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: 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_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: 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_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			float num = Vector3.Angle(((Component)this).transform.up, Vector3.up);
			float num2 = 1.1f * (0f - Physics.gravity.y) / (MaxThrust * Mathf.Max(Mathf.Cos(num * ((float)Math.PI / 180f)), 0.35f));
			float num3;
			if (Acro)
			{
				_acroThrottle = Mathf.Clamp01(_acroThrottle + _thrIn * 0.8f * dt);
				num3 = (_boost ? 1f : _acroThrottle);
			}
			else
			{
				num3 = (_boost ? Mathf.Max(num2, 0.85f) : ((_thrIn > 0.01f) ? Mathf.Lerp(num2, 1f, _thrIn) : ((!(_thrIn < -0.01f)) ? (num2 - Mathf.Clamp(v.y * 0.08f, -0.25f, 0.25f)) : Mathf.Lerp(num2, 0.04f, 0f - _thrIn))));
				num3 = Mathf.Clamp01(num3);
			}
			if (_cut || !motorsOn)
			{
				num3 = 0f;
			}
			Throttle = Mathf.MoveTowards(Throttle, num3, dt * 6f);
			Body.AddForce(((Component)this).transform.up * (MaxThrust * Throttle), (ForceMode)0);
			if (!motorsOn)
			{
				return;
			}
			Vector3 val2;
			if (Acro)
			{
				float value = Cfg.AcroRate.Value;
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor((0f - mouse.y) / dt + _pitchIn * value, _yawIn * Cfg.YawRate.Value, (0f - mouse.x) / dt - _rollIn * value);
				val = Vector3.ClampMagnitude(val, 1600f);
				val2 = ((Component)this).transform.TransformDirection(val * ((float)Math.PI / 180f));
			}
			else
			{
				_pitchSm = Mathf.MoveTowards(_pitchSm, _pitchIn, dt * 2.5f);
				_rollSm = Mathf.MoveTowards(_rollSm, _rollIn, dt * 2.5f);
				CamPitch = Mathf.Clamp(CamPitch + mouse.y, -75f, 35f);
				float num4 = Cfg.MaxTilt.Value + (_boost ? 20f : 0f);
				Vector3 val3 = Vector3.ProjectOnPlane(((Component)this).transform.forward, Vector3.up);
				if (((Vector3)(ref val3)).sqrMagnitude < 0.01f)
				{
					val3 = Vector3.ProjectOnPlane(-((Component)this).transform.up * Mathf.Sign(((Component)this).transform.forward.y), Vector3.up);
				}
				float num5 = Mathf.Atan2(val3.x, val3.z) * 57.29578f;
				Quaternion goal = Quaternion.Euler(_pitchSm * num4, num5, (0f - _rollSm) * num4);
				float num6 = Mathf.Clamp(mouse.x / dt + _yawIn * Cfg.YawRate.Value, -720f, 720f);
				val2 = AttitudeRate(goal, 6f, 12f) + Vector3.up * (num6 * ((float)Math.PI / 180f));
			}
			Body.angularVelocity = Vector3.Lerp(Body.angularVelocity, val2, 1f - Mathf.Exp(-22f * dt));
		}

		private void UpdateBattery(float dt)
		{
			if (Linked && !(Battery <= 0f))
			{
				float num = 1f / Mathf.Max(Cfg.ThrustToWeight.Value, 1.1f);
				Battery -= dt / Mathf.Max(Cfg.BatterySeconds.Value, 10f) * (0.3f + Throttle) / (0.3f + num);
				if (Battery <= 0f)
				{
					Battery = 0f;
					FpvSession.Disconnect("BATTERY EMPTY");
				}
			}
		}

		private void UpdateSignal(float dt)
		{
			//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_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_005d: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			if (!Linked)
			{
				return;
			}
			if (!Object.op_Implicit((Object)(object)Pilot) || ((Character)Pilot).IsDead())
			{
				FpvSession.Disconnect("PILOT DOWN");
				return;
			}
			Vector3 val = ((Component)Pilot).transform.position + Vector3.up * 1.6f;
			float value = Cfg.SignalRange.Value;
			float num = Vector3.Distance(val, ((Component)this).transform.position);
			float num2 = 1f - Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(value * 0.6f, value, num));
			if (Physics.Linecast(val, ((Component)this).transform.position, LayerMask.GetMask(new string[3] { "terrain", "static_solid", "piece" }), (QueryTriggerInteraction)1))
			{
				num2 = num2 * 0.55f - Mathf.InverseLerp(value * 0.15f, value * 0.5f, num) * 0.35f;
			}
			Signal = Mathf.Lerp(Signal, Mathf.Clamp01(num2), dt * 3f);
			_badSignal = ((Signal < 0.06f) ? (_badSignal + dt) : 0f);
			if (_badSignal > 0.8f)
			{
				FpvSession.Disconnect("NO SIGNAL");
			}
		}

		private void UpdateFuse()
		{
			//IL_0070: 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_0038: 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)
			if (!Armed && Object.op_Implicit((Object)(object)Pilot) && FlightTime > 1.5f && Vector3.Distance(((Component)Pilot).transform.position, ((Component)this).transform.position) > Cfg.ArmDistance.Value)
			{
				Armed = true;
			}
			if (!Armed || !Cfg.ProximityFuse.Value)
			{
				return;
			}
			Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, 0.6f, LayerMask.GetMask(new string[3] { "character", "character_net", "character_noenv" }), (QueryTriggerInteraction)1);
			for (int i = 0; i < array.Length; i++)
			{
				Character componentInParent = ((Component)array[i]).GetComponentInParent<Character>();
				if (Object.op_Implicit((Object)(object)componentInParent) && (Object)(object)componentInParent != (Object)(object)Pilot && !componentInParent.IsDead())
				{
					Detonate(((Component)this).transform.position);
					break;
				}
			}
		}

		private void UpdateGround()
		{
			//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_0070: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit val = default(RaycastHit);
			GroundDistance = (Physics.Raycast(((Component)this).transform.position, Vector3.down, ref val, 500f, LayerMask.GetMask(new string[4] { "terrain", "static_solid", "piece", "Default" }), (QueryTriggerInteraction)1) ? ((RaycastHit)(ref val)).distance : 500f);
			if (Object.op_Implicit((Object)(object)ZoneSystem.instance) && ((Component)this).transform.position.y < ZoneSystem.instance.m_waterLevel - 0.3f)
			{
				FpvNet.SendEnd();
				if (Linked)
				{
					FpvSession.Disconnect("SPLASHED");
				}
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		private void UpdateUnlinked(float dt)
		{
			//IL_0014: 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)
			_unlinkedTime += dt;
			Vector3 linearVelocity = Body.linearVelocity;
			bool flag = ((Vector3)(ref linearVelocity)).sqrMagnitude < 0.04f && GroundDistance < 0.6f;
			_restTime = (flag ? (_restTime + dt) : 0f);
			if (_restTime > 1.2f || _unlinkedTime > 40f)
			{
				BecomeItem();
			}
		}

		private void BecomeItem()
		{
			//IL_0043: 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_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_0067: 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)
			if (!Exploded)
			{
				Exploded = true;
				FpvNet.SendEnd();
				if (Object.op_Implicit((Object)(object)FpvItems.Drone))
				{
					ItemData obj = FpvItems.Drone.GetComponent<ItemDrop>().m_itemData.Clone();
					obj.m_stack = 1;
					ItemDrop.DropItem(obj, 1, ((Component)this).transform.position + Vector3.up * 0.15f, Quaternion.Euler(0f, ((Component)this).transform.eulerAngles.y, 0f));
				}
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		private void OnCollisionEnter(Collision c)
		{
			//IL_000a: 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_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_004d: 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_0052: 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)
			if (Exploded)
			{
				return;
			}
			Vector3 relativeVelocity = c.relativeVelocity;
			float magnitude = ((Vector3)(ref relativeVelocity)).magnitude;
			if (Armed && magnitude >= Cfg.FuseSpeed.Value)
			{
				Vector3 val;
				if (c.contactCount <= 0)
				{
					val = ((Component)this).transform.position;
				}
				else
				{
					ContactPoint contact = c.GetContact(0);
					val = ((ContactPoint)(ref contact)).point;
				}
				Vector3 point = val;
				Detonate(point);
			}
		}

		internal void Detonate(Vector3 point)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			if (!Exploded)
			{
				Exploded = true;
				FpvExplosion.Detonate(point, Pilot);
				FpvNet.SendEnd();
				if (Linked)
				{
					FpvSession.LinkLost("SIGNAL LOST", boom: true);
				}
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		internal void Unlink()
		{
			Linked = false;
			Chase = false;
		}

		private void OnDestroy()
		{
			if ((Object)(object)FpvSession.Flight == (Object)(object)this)
			{
				FpvSession.Forget(this);
			}
		}
	}
	internal static class FpvAssets
	{
		private static GameObject _droneTemplate;

		private static GameObject _remoteTemplate;

		private static AudioClip _motor;

		private static AudioClip _boom;

		private static Material _particleAdd;

		private static Material _particleAlpha;

		private static Transform _holder;

		internal static Sprite DroneIcon;

		internal static Sprite RemoteIcon;

		private static Texture2D _dot;

		private static MethodInfo _loadImage;

		private static AudioMixerGroup _sfxGroup;

		private static bool _sfxSearched;

		private static Transform Holder
		{
			get
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Expected O, but got Unknown
				if (Object.op_Implicit((Object)(object)_holder))
				{
					return _holder;
				}
				GameObject val = new GameObject("FPVDroneTemplates");
				val.SetActive(false);
				Object.DontDestroyOnLoad((Object)val);
				_holder = val.transform;
				return _holder;
			}
		}

		internal static Transform PrefabHolder => Holder;

		internal static AudioClip Motor
		{
			get
			{
				if (Object.op_Implicit((Object)(object)_motor))
				{
					return _motor;
				}
				try
				{
					_motor = LoadWav(Resource("motor.wav"), "fpv_motor", 0.25f);
				}
				catch (Exception ex)
				{
					FpvPlugin.Error("motor.wav: " + ex.Message);
				}
				if (!Object.op_Implicit((Object)(object)_motor))
				{
					_motor = SynthMotor();
				}
				return _motor;
			}
		}

		internal static AudioClip Boom
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)_boom))
				{
					return _boom = SynthBoom();
				}
				return _boom;
			}
		}

		internal static AudioMixerGroup SfxGroup
		{
			get
			{
				if (_sfxSearched || !Object.op_Implicit((Object)(object)ZNetScene.instance))
				{
					return _sfxGroup;
				}
				_sfxSearched = true;
				string[] array = new string[4] { "sfx_wood_destroyed", "sfx_rock_hit", "sfx_build_hammer_wood", "sfx_arrow_hit" };
				foreach (string text in array)
				{
					GameObject prefab = ZNetScene.instance.GetPrefab(text);
					AudioSource val = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponentInChildren<AudioSource>(true) : null);
					if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.outputAudioMixerGroup))
					{
						_sfxGroup = val.outputAudioMixerGroup;
						break;
					}
				}
				return _sfxGroup;
			}
		}

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

		private static GameObject Template(ref GameObject cache, string res, string name)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)cache))
			{
				return cache;
			}
			try
			{
				GameObject val = GlbLoader.Load(Resource(res), name);
				val.transform.SetParent(Holder, false);
				cache = val;
			}
			catch (Exception ex)
			{
				FpvPlugin.Error("Failed to load " + res + ": " + ex);
				GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)3);
				Object.DestroyImmediate((Object)(object)val2.GetComponent<Collider>());
				((Object)val2).name = name;
				val2.transform.localScale = new Vector3(0.3f, 0.08f, 0.3f);
				val2.transform.SetParent(Holder, false);
				cache = val2;
			}
			return cache;
		}

		internal static GameObject NewDrone(Transform parent)
		{
			GameObject obj = Object.Instantiate<GameObject>(Template(ref _droneTemplate, "drone.glb", "FPVDroneModel"), parent, false);
			((Object)obj).name = "FPVDroneModel";
			obj.SetActive(true);
			return obj;
		}

		internal static GameObject NewRemote(Transform parent)
		{
			GameObject obj = Object.Instantiate<GameObject>(Template(ref _remoteTemplate, "remote.glb", "FPVRemoteModel"), parent, false);
			((Object)obj).name = "FPVRemoteModel";
			obj.SetActive(true);
			return obj;
		}

		internal static Material MakeMaterial(Color color, Texture2D tex, float metallic, float gloss, bool blend)
		{
			//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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			Shader val = Shader.Find("Standard");
			if (!Object.op_Implicit((Object)(object)val) || !val.isSupported)
			{
				val = Shader.Find("Legacy Shaders/Diffuse");
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = GameShader();
			}
			Material val2 = new Material(val)
			{
				color = color
			};
			if (Object.op_Implicit((Object)(object)tex))
			{
				val2.mainTexture = (Texture)(object)tex;
			}
			if (((Object)val).name == "Standard")
			{
				val2.SetFloat("_Metallic", Mathf.Clamp01(metallic));
				val2.SetFloat("_Glossiness", Mathf.Clamp(gloss, 0.05f, 0.85f));
				if (blend)
				{
					val2.SetFloat("_Mode", 3f);
					val2.SetInt("_SrcBlend", 1);
					val2.SetInt("_DstBlend", 10);
					val2.SetInt("_ZWrite", 0);
					val2.EnableKeyword("_ALPHAPREMULTIPLY_ON");
					val2.renderQueue = 3000;
				}
			}
			return val2;
		}

		private static Shader GameShader()
		{
			GameObject val = (Object.op_Implicit((Object)(object)ObjectDB.instance) ? ObjectDB.instance.GetItemPrefab("Club") : null);
			Renderer val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponentInChildren<Renderer>(true) : null);
			if (!Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val2.sharedMaterial))
			{
				return Shader.Find("Sprites/Default");
			}
			return val2.sharedMaterial.shader;
		}

		internal static Material ParticleMaterial(bool additive)
		{
			//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_00b8: Expected O, but got Unknown
			ref Material reference = ref additive ? ref _particleAdd : ref _particleAlpha;
			if (Object.op_Implicit((Object)(object)reference))
			{
				return reference;
			}
			string[] obj = ((!additive) ? new string[4] { "Legacy Shaders/Particles/Alpha Blended", "Particles/Alpha Blended", "Mobile/Particles/Alpha Blended", "Sprites/Default" } : new string[4] { "Legacy Shaders/Particles/Additive", "Particles/Additive", "Mobile/Particles/Additive", "Sprites/Default" });
			Shader val = null;
			string[] array = obj;
			for (int i = 0; i < array.Length; i++)
			{
				val = Shader.Find(array[i]);
				if (Object.op_Implicit((Object)(object)val) && val.isSupported)
				{
					break;
				}
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = GameShader();
			}
			reference = new Material(val)
			{
				mainTexture = (Texture)(object)SoftDot()
			};
			return reference;
		}

		private static Texture2D SoftDot()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_00d7: 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)
			if (Object.op_Implicit((Object)(object)_dot))
			{
				return _dot;
			}
			_dot = new Texture2D(64, 64, (TextureFormat)4, false)
			{
				wrapMode = (TextureWrapMode)1
			};
			Color32[] array = (Color32[])(object)new Color32[4096];
			Random random = new Random(7);
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					float num = ((float)j + 0.5f) / 64f * 2f - 1f;
					float num2 = ((float)i + 0.5f) / 64f * 2f - 1f;
					float num3 = Mathf.Sqrt(num * num + num2 * num2);
					float num4 = Mathf.Clamp01(1f - num3);
					num4 = num4 * num4 * (0.8f + 0.2f * (float)random.NextDouble());
					array[i * 64 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num4 * 255f));
				}
			}
			_dot.SetPixels32(array);
			_dot.Apply();
			return _dot;
		}

		private static AudioClip LoadWav(byte[] wav, string name, float crossfade)
		{
			if (wav == null)
			{
				return null;
			}
			int num = 1;
			int num2 = 44100;
			int num3 = 16;
			int i = 12;
			int num4 = -1;
			int num5 = 0;
			int num6;
			for (; i + 8 <= wav.Length; i += 8 + num6 + (num6 & 1))
			{
				string text = Encoding.ASCII.GetString(wav, i, 4);
				num6 = BitConverter.ToInt32(wav, i + 4);
				if (text == "fmt ")
				{
					num = BitConverter.ToInt16(wav, i + 10);
					num2 = BitConverter.ToInt32(wav, i + 12);
					num3 = BitConverter.ToInt16(wav, i + 22);
				}
				else if (text == "data")
				{
					num4 = i + 8;
					num5 = Math.Min(num6, wav.Length - num4);
					break;
				}
			}
			if (num4 < 0 || num3 != 16)
			{
				return null;
			}
			int num7 = num5 / (2 * num);
			float[] array = new float[num7];
			for (int j = 0; j < num7; j++)
			{
				float num8 = 0f;
				for (int k = 0; k < num; k++)
				{
					num8 += (float)BitConverter.ToInt16(wav, num4 + (j * num + k) * 2) / 32768f;
				}
				array[j] = num8 / (float)num;
			}
			int num9 = Mathf.Min((int)((float)num2 * crossfade), num7 / 3);
			int num10 = num7 - num9;
			float[] array2 = new float[num10];
			Array.Copy(array, array2, num10);
			for (int l = 0; l < num9; l++)
			{
				float num11 = (float)l / (float)num9;
				array2[l] = array[l] * num11 + array[num10 + l] * (1f - num11);
			}
			Normalize(array2, 0.9f);
			return MakeClip(name, array2, num2);
		}

		private static AudioClip MakeClip(string name, float[] samples, int rate)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			int pos = 0;
			return AudioClip.Create(name, samples.Length, 1, rate, false, (PCMReaderCallback)delegate(float[] buffer)
			{
				int num = Mathf.Min(buffer.Length, samples.Length - pos);
				if (num > 0)
				{
					Array.Copy(samples, pos, buffer, 0, num);
				}
				for (int i = Mathf.Max(num, 0); i < buffer.Length; i++)
				{
					buffer[i] = 0f;
				}
				pos += Mathf.Max(num, 0);
			});
		}

		internal static bool LoadImage(Texture2D tex, byte[] data)
		{
			if (_loadImage == null)
			{
				_loadImage = typeof(ImageConversion).GetMethod("LoadImage", new Type[3]
				{
					typeof(Texture2D),
					typeof(byte[]),
					typeof(bool)
				});
			}
			if (_loadImage != null)
			{
				return (bool)_loadImage.Invoke(null, new object[3] { tex, data, false });
			}
			return false;
		}

		private static void Normalize(float[] d, float peak)
		{
			float num = 0.0001f;
			for (int i = 0; i < d.Length; i++)
			{
				num = Mathf.Max(num, Mathf.Abs(d[i]));
			}
			float num2 = peak / num;
			for (int j = 0; j < d.Length; j++)
			{
				d[j] *= num2;
			}
		}

		private static AudioClip SynthMotor()
		{
			int num = 44100;
			float[] array = new float[num];
			Random random = new Random(3);
			for (int i = 0; i < num; i++)
			{
				float num2 = (float)i / 44100f;
				array[i] = 0.5f * Mathf.Sin((float)Math.PI * 440f * num2) + 0.25f * Mathf.Sin((float)Math.PI * 880f * num2) + 0.15f * ((float)random.NextDouble() * 2f - 1f);
			}
			return MakeClip("fpv_motor_synth", array, 44100);
		}

		private static AudioClip SynthBoom()
		{
			int num = 132300;
			float[] array = new float[num];
			Random random = new Random(11);
			float num2 = 0f;
			float num3 = 0f;
			for (int i = 0; i < num; i++)
			{
				float num4 = (float)i / 44100f;
				float num5 = (float)random.NextDouble() * 2f - 1f;
				num2 += (num5 - num2) * 0.08f;
				num3 += (num2 - num3) * 0.04f;
				float num6 = num5 * Mathf.Exp((0f - num4) * 60f);
				float num7 = Mathf.Sin((float)Math.PI * 2f * (55f - 25f * num4) * num4) * Mathf.Exp((0f - num4) * 4f);
				float num8 = num3 * 6f * Mathf.Exp((0f - num4) * 1.3f);
				array[i] = num6 * 0.9f + num7 * 0.9f + num8;
			}
			Normalize(array, 0.95f);
			return MakeClip("fpv_boom", array, 44100);
		}

		internal static AudioSource AddSource(GameObject go, AudioClip clip, bool loop, float minDist, float maxDist)
		{
			AudioSource val = go.AddComponent<AudioSource>();
			val.clip = clip;
			val.loop = loop;
			val.spatialBlend = 1f;
			val.rolloffMode = (AudioRolloffMode)1;
			val.minDistance = minDist;
			val.maxDistance = maxDist;
			val.dopplerLevel = 0.6f;
			val.playOnAwake = false;
			if (Object.op_Implicit((Object)(object)SfxGroup))
			{
				val.outputAudioMixerGroup = SfxGroup;
			}
			return val;
		}

		internal static void MakeIcons()
		{
			//IL_0021: 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_003e: 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)
			if (!Object.op_Implicit((Object)(object)DroneIcon))
			{
				DroneIcon = RenderIcon(NewDrone(null), new Vector3(35f, -140f, 0f)) ?? FlatIcon(new Color(0.2f, 0.2f, 0.22f));
			}
			if (!Object.op_Implicit((Object)(object)RemoteIcon))
			{
				RemoteIcon = RenderIcon(NewRemote(null), new Vector3(-55f, 180f, 0f)) ?? FlatIcon(new Color(0.75f, 0.68f, 0.52f));
			}
		}

		private static Sprite RenderIcon(GameObject model, Vector3 euler)
		{
			//IL_0022: 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_002f: 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_003c: 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_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_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			//IL_00f5: 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_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: 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_0168: 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)
			//IL_017e: 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_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Expected O, but got Unknown
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: 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_026a: Expected O, but got Unknown
			//IL_0280: 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_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = null;
			GameObject val2 = null;
			RenderTexture val3 = null;
			try
			{
				Vector3 val4 = default(Vector3);
				((Vector3)(ref val4))..ctor(0f, -5000f, 0f);
				model.transform.position = val4;
				model.transform.rotation = Quaternion.Euler(euler);
				Bounds bounds = default(Bounds);
				((Bounds)(ref bounds))..ctor(val4, Vector3.zero);
				bool flag = false;
				Renderer[] componentsInChildren = model.GetComponentsInChildren<Renderer>();
				foreach (Renderer val5 in componentsInChildren)
				{
					if (!flag)
					{
						bounds = val5.bounds;
					}
					else
					{
						((Bounds)(ref bounds)).Encapsulate(val5.bounds);
					}
					flag = true;
				}
				int num = 31;
				Transform[] componentsInChildren2 = model.GetComponentsInChildren<Transform>(true);
				for (int i = 0; i < componentsInChildren2.Length; i++)
				{
					((Component)componentsInChildren2[i]).gameObject.layer = num;
				}
				val = new GameObject("FPVIconCam");
				Camera val6 = val.AddComponent<Camera>();
				((Behaviour)val6).enabled = false;
				val6.clearFlags = (CameraClearFlags)2;
				val6.backgroundColor = new Color(0f, 0f, 0f, 0f);
				val6.cullingMask = 1 << num;
				val6.orthographic = true;
				val6.orthographicSize = Mathf.Max(((Bounds)(ref bounds)).extents.x, ((Bounds)(ref bounds)).extents.y) * 1.08f;
				Transform transform = ((Component)val6).transform;
				Vector3 center = ((Bounds)(ref bounds)).center;
				Vector3 forward = Vector3.forward;
				Vector3 extents = ((Bounds)(ref bounds)).extents;
				transform.position = center - forward * (((Vector3)(ref extents)).magnitude + 1f);
				((Component)val6).transform.rotation = Quaternion.identity;
				val6.nearClipPlane = 0.01f;
				extents = ((Bounds)(ref bounds)).extents;
				val6.farClipPlane = ((Vector3)(ref extents)).magnitude * 2f + 2f;
				val2 = new GameObject("FPVIconLight");
				Light obj = val2.AddComponent<Light>();
				obj.type = (LightType)1;
				obj.intensity = 1.3f;
				obj.cullingMask = 1 << num;
				val2.transform.rotation = Quaternion.Euler(40f, 30f, 0f);
				val3 = (val6.targetTexture = RenderTexture.GetTemporary(128, 128, 24, (RenderTextureFormat)0));
				Color ambientLight = RenderSettings.ambientLight;
				RenderSettings.ambientLight = new Color(0.55f, 0.55f, 0.55f);
				val6.Render();
				RenderSettings.ambientLight = ambientLight;
				RenderTexture active = RenderTexture.active;
				RenderTexture.active = val3;
				Texture2D val7 = new Texture2D(128, 128, (TextureFormat)4, false);
				val7.ReadPixels(new Rect(0f, 0f, 128f, 128f), 0, 0);
				val7.Apply();
				RenderTexture.active = active;
				Color32[] pixels = val7.GetPixels32();
				int num2 = 0;
				Color32[] array = pixels;
				for (int i = 0; i < array.Length; i++)
				{
					if (array[i].a > 10)
					{
						num2++;
					}
				}
				if (num2 < 200)
				{
					return null;
				}
				return Sprite.Create(val7, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f));
			}
			catch (Exception ex)
			{
				FpvPlugin.Warn("Icon render failed: " + ex.Message);
				return null;
			}
			finally
			{
				if (Object.op_Implicit((Object)(object)val3))
				{
					RenderTexture.ReleaseTemporary(val3);
				}
				if (Object.op_Implicit((Object)(object)val))
				{
					Object.Destroy((Object)(object)val);
				}
				if (Object.op_Implicit((Object)(object)val2))
				{
					Object.Destroy((Object)(object)val2);
				}
				Object.Destroy((Object)(object)model);
			}
		}

		private static Sprite FlatIcon(Color c)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: 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_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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false);
			Color32[] array = (Color32[])(object)new Color32[4096];
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					bool flag = Mathf.Abs(j - i) < 4 || Mathf.Abs(j + i - 63) < 4;
					bool flag2 = false;
					Vector2[] array2 = (Vector2[])(object)new Vector2[4]
					{
						new Vector2(12f, 12f),
						new Vector2(51f, 12f),
						new Vector2(12f, 51f),
						new Vector2(51f, 51f)
					};
					foreach (Vector2 val2 in array2)
					{
						bool num = flag2;
						Vector2 val3 = new Vector2((float)j, (float)i) - val2;
						flag2 = num | (((Vector2)(ref val3)).magnitude < 10f);
					}
					array[i * 64 + j] = (Color32)((flag || flag2) ? Color32.op_Implicit(c) : new Color32((byte)0, (byte)0, (byte)0, (byte)0));
				}
			}
			val.SetPixels32(array);
			val.Apply();
			return Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f));
		}
	}
	internal static class FpvExplosion
	{
		private class FlashFade : MonoBehaviour
		{
			private Light _l;

			private float _t;

			private void Awake()
			{
				_l = ((Component)this).GetComponent<Light>();
			}

			private void Update()
			{
				_t += Time.deltaTime;
				if (Object.op_Implicit((Object)(object)_l))
				{
					_l.intensity = 9f * Mathf.Exp((0f - _t) * 6f) + ((_t < 1.5f) ? (1.2f * Mathf.PerlinNoise(_t * 12f, 0f) * (1.5f - _t)) : 0f);
				}
			}
		}

		private static GameObject _vanilla;

		private static bool _searched;

		internal static void Detonate(Vector3 point, Player attacker)
		{
			//IL_0000: 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)
			ApplyDamage(point, attacker);
			FpvNet.SendBoom(point);
		}

		private static void ApplyDamage(Vector3 point, Player attacker)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: 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_00aa: 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_00c4: 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_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_00bc: 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_00f5: 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_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_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Expected O, but got Unknown
			//IL_01a0: 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_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			float value = Cfg.BlastRadius.Value;
			float value2 = Cfg.BlastDamage.Value;
			float value3 = Cfg.BlastChop.Value;
			int mask = LayerMask.GetMask(new string[2] { "terrain", "static_solid" });
			HashSet<Component> hashSet = new HashSet<Component>();
			Collider[] array = Physics.OverlapSphere(point, value, -1, (QueryTriggerInteraction)1);
			foreach (Collider val in array)
			{
				if (!Object.op_Implicit((Object)(object)val))
				{
					continue;
				}
				IDestructible componentInParent = ((Component)val).GetComponentInParent<IDestructible>();
				Component val2 = (Component)(object)((componentInParent is Component) ? componentInParent : null);
				if (val2 == null || !hashSet.Add(val2))
				{
					continue;
				}
				MeshCollider val3 = (MeshCollider)(object)((val is MeshCollider) ? val : null);
				Vector3 val4;
				if (val3 == null || val3.convex)
				{
					val4 = val.ClosestPoint(point);
				}
				else
				{
					Bounds bounds = val.bounds;
					val4 = ((Bounds)(ref bounds)).ClosestPoint(point);
				}
				Vector3 val5 = val4;
				float num = Vector3.Distance(point, val5);
				float num2 = Mathf.Clamp01(1f - Mathf.Pow(num / value, 1.4f));
				if (!(num2 <= 0f))
				{
					Vector3 val6 = val5 - point;
					if (((Vector3)(ref val6)).magnitude > 0.3f && Physics.Raycast(point, ((Vector3)(ref val6)).normalized, ((Vector3)(ref val6)).magnitude - 0.2f, mask, (QueryTriggerInteraction)1))
					{
						num2 *= 0.5f;
					}
					HitData val7 = new HitData();
					val7.m_damage.m_blunt = value2 * 0.45f * num2;
					val7.m_damage.m_pierce = value2 * 0.35f * num2;
					val7.m_damage.m_fire = value2 * 0.2f * num2;
					val7.m_damage.m_chop = value3 * num2;
					val7.m_damage.m_pickaxe = value3 * num2;
					val7.m_point = val5;
					val7.m_dir = ((((Vector3)(ref val6)).sqrMagnitude > 0.001f) ? ((Vector3)(ref val6)).normalized : Vector3.up);
					val7.m_pushForce = 80f * num2;
					val7.m_staggerMultiplier = 3f;
					val7.m_toolTier = 4;
					val7.m_blockable = false;
					val7.m_dodgeable = false;
					val7.m_ranged = true;
					if (Object.op_Implicit((Object)(object)attacker))
					{
						val7.SetAttacker((Character)(object)attacker);
					}
					try
					{
						componentInParent.Damage(val7);
					}
					catch (Exception ex)
					{
						FpvPlugin.Warn("Blast damage on " + ((Object)val2).name + ": " + ex.Message);
					}
				}
			}
			array = Physics.OverlapSphere(point, value * 1.2f, -1, (QueryTriggerInteraction)1);
			foreach (Collider val8 in array)
			{
				Rigidbody val9 = (Object.op_Implicit((Object)(object)val8) ? val8.attachedRigidbody : null);
				if (Object.op_Implicit((Object)(object)val9) && !val9.isKinematic && !Object.op_Implicit((Object)(object)((Component)val9).GetComponent<Character>()))
				{
					val9.AddExplosionForce(12f * val9.mass, point, value * 1.2f, 0.6f, (ForceMode)1);
				}
			}
		}

		private static GameObject VanillaFx()
		{
			if (_searched || !Object.op_Implicit((Object)(object)ZNetScene.instance))
			{
				return _vanilla;
			}
			_searched = true;
			string value = Cfg.VanillaExplosion.Value;
			if (!string.IsNullOrEmpty(value))
			{
				_vanilla = ZNetScene.instance.GetPrefab(value);
				if (!Object.op_Implicit((Object)(object)_vanilla))
				{
					FpvPlugin.Warn("VanillaEffectPrefab '" + value + "' not found");
				}
				if (Object.op_Implicit((Object)(object)_vanilla) && Object.op_Implicit((Object)(object)_vanilla.GetComponent<ZNetView>()))
				{
					_vanilla = null;
				}
				if (Object.op_Implicit((Object)(object)_vanilla))
				{
					return _vanilla;
				}
			}
			string[] array = new string[6] { "fx_siegebomb_explosion", "fx_fireball_staff_explosion", "fx_goblinking_meteor_hit", "fx_Fader_Meteor_Hit", "fx_DvergerMage_Fire_hit", "fx_fireball_explosion" };
			List<string> list = new List<string>();
			foreach (GameObject prefab in ZNetScene.instance.m_prefabs)
			{
				if (Object.op_Implicit((Object)(object)prefab) && !Object.op_Implicit((Object)(object)prefab.GetComponent<ZNetView>()))
				{
					string text = ((Object)prefab).name.ToLowerInvariant();
					if ((text.StartsWith("fx_") || text.StartsWith("vfx_")) && (text.Contains("explo") || text.Contains("meteor_hit") || text.Contains("bomb")))
					{
						list.Add(((Object)prefab).name);
					}
				}
			}
			FpvPlugin.Log("Vanilla explosion candidates: " + string.Join(", ", list));
			string[] array2 = array;
			foreach (string n in array2)
			{
				string text2 = list.Find((string f) => f.Equals(n, StringComparison.OrdinalIgnoreCase));
				if (text2 != null)
				{
					_vanilla = ZNetScene.instance.GetPrefab(text2);
					break;
				}
			}
			if (!Object.op_Implicit((Object)(object)_vanilla))
			{
				string text3 = list.Find((string f) => f.ToLowerInvariant().Contains("explo"));
				if (text3 != null)
				{
					_vanilla = ZNetScene.instance.GetPrefab(text3);
				}
			}
			if (Object.op_Implicit((Object)(object)_vanilla))
			{
				FpvPlugin.Log("Using vanilla explosion effect " + ((Object)_vanilla).name);
			}
			return _vanilla;
		}

		internal static void Visual(Vector3 point)
		{
			//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_0034: 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_0057: 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_0084: 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_009a: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			//IL_000f: 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_010d: Expected O, but got Unknown
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = VanillaFx();
			if (Object.op_Implicit((Object)(object)val))
			{
				Object.Destroy((Object)(object)Object.Instantiate<GameObject>(val, point, Quaternion.identity), 12f);
			}
			GameObject val2 = new GameObject("FPVExplosion");
			val2.transform.position = point;
			Light obj = val2.AddComponent<Light>();
			obj.type = (LightType)2;
			obj.color = new Color(1f, 0.65f, 0.3f);
			obj.range = 26f;
			obj.intensity = 9f;
			obj.shadows = (LightShadows)0;
			val2.AddComponent<FlashFade>();
			Fireball(val2.transform);
			Smoke(val2.transform);
			Sparks(val2.transform);
			Dust(val2.transform);
			AudioSource obj2 = FpvAssets.AddSource(val2, FpvAssets.Boom, loop: false, 8f, 260f);
			obj2.volume = 1f;
			obj2.dopplerLevel = 0f;
			obj2.Play();
			if (Object.op_Implicit((Object)(object)GameCamera.instance))
			{
				GameCamera.instance.AddShake(point, 45f, 5f, false);
			}
			Object.Destroy((Object)val2, 9f);
		}

		private static ParticleSystem NewSystem(Transform parent, string name, bool additive)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0023: 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_0042: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			ParticleSystem obj = val.AddComponent<ParticleSystem>();
			obj.Stop(true, (ParticleSystemStopBehavior)0);
			MainModule main = obj.main;
			((MainModule)(ref main)).loop = false;
			((MainModule)(ref main)).playOnAwake = false;
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			EmissionModule emission = obj.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
			ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>();
			((Renderer)component).sharedMaterial = FpvAssets.ParticleMaterial(additive);
			((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
			return obj;
		}

		private static Gradient Fade(Color a, Color b, float peak)
		{
			//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_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_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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			Gradient val = new Gradient();
			val.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
			{
				new GradientColorKey(a, 0f),
				new GradientColorKey(b, 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
			{
				new GradientAlphaKey(peak, 0f),
				new GradientAlphaKey(peak * 0.7f, 0.4f),
				new GradientAlphaKey(0f, 1f)
			});
			return val;
		}

		private static void Fireball(Transform parent)
		{
			//IL_000d: 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_002b: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//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_009c: 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_00c2: 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_00e1: 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_0104: 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_0114: 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_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			ParticleSystem obj = NewSystem(parent, "Fire", additive: true);
			MainModule main = obj.main;
			((MainModule)(ref main)).duration = 0.3f;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.35f, 0.8f);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(3f, 11f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(1.5f, 3.6f);
			((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(1f, 0.85f, 0.45f), new Color(1f, 0.45f, 0.1f));
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.15f);
			ShapeModule shape = obj.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
			((ShapeModule)(ref shape)).radius = 0.4f;
			ColorOverLifetimeModule colorOverLifetime = obj.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(Fade(new Color(1f, 0.8f, 0.4f), new Color(0.6f, 0.12f, 0.02f), 1f));
			SizeOverLifetimeModule sizeOverLifetime = obj.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, AnimationCurve.EaseInOut(0f, 0.6f, 1f, 1.6f));
			LimitVelocityOverLifetimeModule limitVelocityOverLifetime = obj.limitVelocityOverLifetime;
			((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime)).enabled = true;
			((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime)).limit = MinMaxCurve.op_Implicit(2f);
			((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime)).dampen = 0.25f;
			obj.Play();
			obj.Emit(45);
		}

		private static void Smoke(Transform parent)
		{
			//IL_000d: 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_002b: 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_0057: 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_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_00a6: 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_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_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_00f2: 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_0106: 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_013f: 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_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: 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)
			ParticleSystem obj = NewSystem(parent, "Smoke", additive: false);
			MainModule main = obj.main;
			((MainModule)(ref main)).duration = 0.5f;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(3f, 6f);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(1.5f, 6f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(2f, 4.5f);
			((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(0.12f, 0.11f, 0.1f, 0.85f), new Color(0.3f, 0.28f, 0.26f, 0.75f));
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.05f);
			((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, (float)Math.PI * 2f);
			ShapeModule shape = obj.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)2;
			((ShapeModule)(ref shape)).radius = 0.8f;
			ColorOverLifetimeModule colorOverLifetime = obj.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(Fade(Color.white, Color.white, 0.9f));
			SizeOverLifetimeModule sizeOverLifetime = obj.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 0.7f, 1f, 2.6f));
			LimitVelocityOverLifetimeModule limitVelocityOverLifetime = obj.limitVelocityOverLifetime;
			((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime)).enabled = true;
			((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime)).limit = MinMaxCurve.op_Implicit(1.2f);
			((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime)).dampen = 0.15f;
			VelocityOverLifetimeModule velocityOverLifetime = obj.velocityOverLifetime;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)1;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = new MinMaxCurve(0f, 0f);
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = new MinMaxCurve(0.6f, 1.4f);
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = new MinMaxCurve(0f, 0f);
			obj.Play();
			obj.Emit(34);
		}

		private static void Sparks(Transform parent)
		{
			//IL_000d: 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_002b: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//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_009c: 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_00e4: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: 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_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			ParticleSystem obj = NewSystem(parent, "Sparks", additive: true);
			MainModule main = obj.main;
			((MainModule)(ref main)).duration = 0.2f;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.5f, 1.4f);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(12f, 32f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(0.06f, 0.16f);
			((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(1f, 0.9f, 0.6f), new Color(1f, 0.55f, 0.2f));
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(1.2f);
			ShapeModule shape = obj.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
			((ShapeModule)(ref shape)).radius = 0.2f;
			ParticleSystemRenderer component = ((Component)obj).GetComponent<ParticleSystemRenderer>();
			component.renderMode = (ParticleSystemRenderMode)1;
			component.velocityScale = 0.06f;
			component.lengthScale = 1f;
			ColorOverLifetimeModule colorOverLifetime = obj.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(Fade(Color.white, new Color(1f, 0.3f, 0.05f), 1f));
			CollisionModule collision = obj.collision;
			((CollisionModule)(ref collision)).enabled = true;
			((CollisionModule)(ref collision)).type = (ParticleSystemCollisionType)1;
			((CollisionModule)(ref collision)).bounce = MinMaxCurve.op_Implicit(0.3f);
			((CollisionModule)(ref collision)).dampen = MinMaxCurve.op_Implicit(0.4f);
			((CollisionModule)(ref collision)).lifetimeLoss = MinMaxCurve.op_Implicit(0.3f);
			obj.Play();
			obj.Emit(90);
		}

		private static void Dust(Transform parent)
		{
			//IL_000d: 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_002b: 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_0057: 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_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_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_00cc: 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_00dc: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: 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_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			ParticleSystem obj = NewSystem(parent, "Dust", additive: false);
			MainModule main = obj.main;
			((MainModule)(ref main)).duration = 0.3f;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(1.5f, 3f);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(6f, 12f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(1.2f, 2.6f);
			((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(0.42f, 0.36f, 0.28f, 0.7f), new Color(0.3f, 0.26f, 0.2f, 0.6f));
			ShapeModule shape = obj.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)10;
			((ShapeModule)(ref shape)).radius = 0.5f;
			((ShapeModule)(ref shape)).rotation = new Vector3(90f, 0f, 0f);
			ColorOverLifetimeModule colorOverLifetime = obj.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(Fade(Color.white, Color.white, 0.8f));
			LimitVelocityOverLifetimeModule limitVelocityOverLifetime = obj.limitVelocityOverLifetime;
			((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime)).enabled = true;
			((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime)).limit = MinMaxCurve.op_Implicit(0.5f);
			((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime)).dampen = 0.3f;
			SizeOverLifetimeModule sizeOverLifetime = obj.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 0.8f, 1f, 2f));
			obj.Play();
			obj.Emit(28);
		}
	}
	internal class FpvHud : MonoBehaviour
	{
		private const int NoiseW = 192;

		private const int NoiseH = 108;

		private Texture2D _noise;

		private Texture2D _white;

		private Texture2D _vignette;

		private Texture2D _scan;

		private Color32[] _px;

		private GUIStyle _style;

		private GUIStyle _big;

		private GUIStyle _small;

		private Random _rng = new Random();

		private float _helpUntil;

		private DroneFlight _lastFlight;

		private void Awake()
		{
			//IL_000a: 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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00d7: 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)
			_noise = new Texture2D(192, 108, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)0,
				wrapMode = (TextureWrapMode)1
			};
			_px = (Color32[])(object)new Color32[20736];
			_white = Texture2D.whiteTexture;
			_vignette = new Texture2D(128, 128, (TextureFormat)4, false)
			{
				wrapMode = (TextureWrapMode)1
			};
			Color32[] array = (Color32[])(object)new Color32[16384];
			for (int i = 0; i < 128; i++)
			{
				for (int j = 0; j < 128; j++)
				{
					float num = (float)j / 127f * 2f - 1f;
					float num2 = (float)i / 127f * 2f - 1f;
					float num3 = Mathf.Clamp01((Mathf.Sqrt(num * num * 0.8f + num2 * num2) - 0.65f) / 0.75f);
					array[i * 128 + j] = new Color32((byte)0, (byte)0, (byte)0, (byte)(num3 * num3 * 200f));
				}
			}
			_vignette.SetPixels32(array);
			_vignette.Apply();
			_scan = new Texture2D(1, 4, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)0
			};
			_scan.SetPixels32((Color32[])(object)new Color32[4]
			{
				new Color32((byte)0, (byte)0, (byte)0, (byte)40),
				new Color32((byte)0, (byte)0, (byte)0, (byte)0),
				new Color32((byte)0, (byte)0, (byte)0, (byte)0),
				new Color32((byte)0, (byte)0, (byte)0, (byte)0)
			});
			_scan.Apply();
		}

		private void Styles()
		{
			//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_004d: 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_0060: Expected O, but got Unknown
			//IL_006b: 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_0081: 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_0096: Expected O, but got Unknown
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			int num = Mathf.Max(12, Mathf.RoundToInt((float)Screen.height / 1080f * 24f));
			if (_style == null || _style.fontSize != num)
			{
				_style = new GUIStyle(GUI.skin.label)
				{
					fontSize = num,
					fontStyle = (FontStyle)1,
					richText = false
				};
				_style.normal.textColor = Color.white;
				_big = new GUIStyle(_style)
				{
					fontSize = num * 2,
					alignment = (TextAnchor)4
				};
				_small = new GUIStyle(_style)
				{
					fontSize = Mathf.RoundToInt((float)num * 0.7f),
					alignment = (TextAnchor)7
				};
			}
		}

		private void FillNoise(float level, float tear)
		{
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			float time = Time.time;
			for (int i = 0; i < 108; i++)
			{
				float num = Mathf.Max(0f, Mathf.Sin((float)i * 0.11f + time * 9f)) * 0.25f;
				bool flag = _rng.NextDouble() < (double)tear;
				float num2 = Mathf.Clamp01(level + num * level + (flag ? 0.5f : 0f));
				for (int j = 0; j < 192; j++)
				{
					int num3 = _rng.Next(256);
					byte b = (byte)(num2 * (float)(flag ? 255 : (120 + num3 / 2)));
					_px[i * 192 + j] = new Color32((byte)num3, (byte)num3, (byte)num3, b);
				}
			}
			_noise.SetPixels32(_px);
			_noise.Apply(false);
		}

		private void OnGUI()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: 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)
			if ((int)Event.current.type != 7 || !FpvSession.CameraActive)
			{
				return;
			}
			Styles();
			DroneFlight flight = FpvSession.Flight;
			if ((Object)(object)flight != (Object)(object)_lastFlight)
			{
				_lastFlight = flight;
				if (Object.op_Implicit((Object)(object)flight))
				{
					_helpUntil = Time.time + 8f;
				}
			}
			float num = Screen.width;
			float num2 = Screen.height;
			Rect val = new Rect(0f, 0f, num, num2);
			GUI.color = Color.white;
			GUI.DrawTexture(val, (Texture)(object)_vignette);
			GUI.DrawTextureWithTexCoords(val, (Texture)(object)_scan, new Rect(0f, 0f, 1f, num2 / 4f));
			float num3 = 0.04f;
			float num4 = 0.002f;
			if (FpvSession.Linked)
			{
				float num5 = Mathf.Clamp01((0.8f - flight.Signal) / 0.75f);
				num3 += num5 * num5 * 0.85f;
				num4 += num5 * 0.08f;
			}
			if (FpvSession.ShowingStatic)
			{
				float num6 = Time.time - FpvSession.StaticStart;
				bool num7 = !FpvSession.Linked;
				num3 = (num7 ? 1f : Mathf.Max(num3, 1f - num6 / 0.45f));
				num4 = (num7 ? 0.3f : num4);
			}
			FillNoise(num3, num4);
			GUI.DrawTexture(val, (Texture)(object)_noise);
			if (!FpvSession.Linked)
			{
				if (lostBlink())
				{
					Shadowed(new Rect(0f, num2 * 0.42f, num, num2 * 0.16f), FpvSession.LostReason ?? "NO SIGNAL", _big);
				}
			}
			else
			{
				DrawOsd(flight, num, num2);
			}
		}

		private static bool lostBlink()
		{
			return Mathf.Repeat(Time.time, 0.6f) < 0.42f;
		}

		private void DrawOsd(DroneFlight f, float w, float h)
		{
			//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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might b