Decompiled source of ArcRaidersMod v0.1.1

ArcRaidersMod.dll

Decompiled 4 minutes ago
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace ArcRaidersMod;

[BepInPlugin("arcmod.repo.arcraiders", "ARC Raiders Mod", "0.1.1")]
public class ArcRaidersPlugin : BaseUnityPlugin
{
	public const string PluginGuid = "arcmod.repo.arcraiders";

	public const string PluginName = "ARC Raiders Mod";

	public const string PluginVersion = "0.1.1";

	internal static ManualLogSource Log;

	internal static ConfigEntry<bool> CamEnabled;

	internal static ConfigEntry<Key> CamToggleKey;

	internal static ConfigEntry<Key> CamSwapKey;

	internal static ConfigEntry<float> CamDistance;

	internal static ConfigEntry<float> CamShoulder;

	internal static ConfigEntry<float> CamHeight;

	internal static ConfigEntry<float> CamRadius;

	internal static ConfigEntry<bool> CamStartOn;

	internal static ConfigEntry<float> SlideBoost;

	internal static ConfigEntry<float> SlideDuration;

	internal static ConfigEntry<float> JumpMultiplier;

	internal static ConfigEntry<int> ExtraJumps;

	internal static ConfigEntry<bool> VaultEnabled;

	internal static ConfigEntry<bool> VaultAuto;

	internal static ConfigEntry<float> VaultMaxHeight;

	internal static ConfigEntry<float> VaultSpeed;

	internal static ConfigEntry<bool> EnemiesEnabled;

	internal static ConfigEntry<float> EnemyCount;

	internal static ConfigEntry<float> EnemySpeed;

	private Harmony harmony;

	private void Awake()
	{
		//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fc: Expected O, but got Unknown
		//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BaseUnityPlugin)this).Logger;
		try
		{
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
		}
		catch (Exception)
		{
		}
		CamEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Camera", "Enabled", true, "Allow the third-person camera.");
		CamStartOn = ((BaseUnityPlugin)this).Config.Bind<bool>("Camera", "StartInThirdPerson", true, "Start every session in third-person.");
		CamToggleKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Camera", "ToggleKey", (Key)99, "Key that toggles first/third person.");
		CamSwapKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Camera", "SwapShoulderKey", (Key)100, "Key that swaps the camera to the other shoulder.");
		CamDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "Distance", 2.4f, "How far behind the player the camera sits (meters).");
		CamShoulder = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "ShoulderOffset", 0.55f, "Sideways offset (meters). Positive = right shoulder.");
		CamHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "HeightOffset", 0.2f, "Extra camera height (meters).");
		CamRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "CollisionRadius", 0.18f, "Camera collision sphere radius (meters).");
		SlideBoost = ((BaseUnityPlugin)this).Config.Bind<float>("Movement", "SlideSpeedMultiplier", 1.35f, "Initial slide speed multiplier (1 = vanilla).");
		SlideDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Movement", "SlideDurationMultiplier", 1.4f, "Slide duration multiplier (1 = vanilla).");
		JumpMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Movement", "JumpForceMultiplier", 1.1f, "Jump force multiplier (1 = vanilla).");
		ExtraJumps = ((BaseUnityPlugin)this).Config.Bind<int>("Movement", "ExtraJumps", 0, "Minimum number of extra air jumps (0 = none, 1 = double jump).");
		VaultEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Movement", "VaultEnabled", true, "Press jump next to a ledge to vault over it.");
		VaultAuto = ((BaseUnityPlugin)this).Config.Bind<bool>("Movement", "VaultWhileHoldingJump", true, "Also vault when you hold jump while running into a ledge.");
		VaultMaxHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Movement", "VaultMaxHeight", 1.4f, "Highest ledge you can vault (meters above your feet).");
		VaultSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Movement", "VaultSpeed", 6.5f, "Vault climbing speed.");
		EnemiesEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Enabled", true, "Apply enemy tuning (only has an effect when you are the host).");
		EnemyCount = ((BaseUnityPlugin)this).Config.Bind<float>("Enemies", "CountMultiplier", 1.5f, "Multiplier for the number of enemies per level (1 = vanilla).");
		EnemySpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Enemies", "SpeedMultiplier", 1.2f, "Multiplier for enemy pathfinding speed (1 = vanilla).");
		Extras.Init(((BaseUnityPlugin)this).Config, ((BaseUnityPlugin)this).Logger);
		ThirdPerson.Active = CamStartOn.Value;
		ThirdPerson.Hook();
		harmony = new Harmony("arcmod.repo.arcraiders");
		Type[] array = new Type[5]
		{
			typeof(PC_Start),
			typeof(PC_FixedUpdate),
			typeof(ED_AmountSetup),
			typeof(NMA_UpdateAgent),
			typeof(NMA_OverrideAgent)
		};
		for (int i = 0; i < array.Length; i++)
		{
			try
			{
				harmony.CreateClassProcessor(array[i]).Patch();
			}
			catch (Exception ex2)
			{
				Log.LogError((object)("Patch failed: " + array[i].Name + " : " + ex2.Message));
			}
		}
		Log.LogInfo((object)string.Concat("ARC Raiders Mod 0.1.1 loaded. ", CamToggleKey.Value, " = toggle camera, ", CamSwapKey.Value, " = swap shoulder."));
	}

	private void OnDestroy()
	{
		Log.LogWarning((object)"Plugin object destroyed.");
		ThirdPerson.Unhook();
	}

	private void Update()
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		ThirdPerson.RestoreAll();
		try
		{
			Keyboard current = Keyboard.current;
			if (current != null)
			{
				if (((ButtonControl)current[CamToggleKey.Value]).wasPressedThisFrame)
				{
					ThirdPerson.Active = !ThirdPerson.Active;
					ThirdPerson.ResetSmoothing();
				}
				if (((ButtonControl)current[CamSwapKey.Value]).wasPressedThisFrame)
				{
					CamShoulder.Value = 0f - CamShoulder.Value;
				}
			}
		}
		catch (Exception)
		{
		}
		ThirdPerson.Tick();
		Movement.ApplyBase(PlayerController.instance);
		Extras.Update();
	}

	private void OnGUI()
	{
		Extras.OnGui();
	}
}
internal static class Refl
{
	private static readonly Dictionary<string, FieldInfo> cache = new Dictionary<string, FieldInfo>();

	private static FieldInfo F(Type t, string name)
	{
		string key = t.FullName + "." + name;
		if (!cache.TryGetValue(key, out var value))
		{
			value = AccessTools.Field(t, name);
			cache[key] = value;
		}
		return value;
	}

	internal static T Get<T>(object o, string name, T def)
	{
		try
		{
			if (o == null)
			{
				return def;
			}
			FieldInfo fieldInfo = F(o.GetType(), name);
			if (fieldInfo == null)
			{
				return def;
			}
			return (T)fieldInfo.GetValue(o);
		}
		catch (Exception)
		{
			return def;
		}
	}

	internal static void Set(object o, string name, object value)
	{
		try
		{
			if (o != null)
			{
				FieldInfo fieldInfo = F(o.GetType(), name);
				if (fieldInfo != null)
				{
					fieldInfo.SetValue(o, value);
				}
			}
		}
		catch (Exception)
		{
		}
	}
}
internal static class ThirdPerson
{
	internal static bool Active;

	private static bool enabledNow;

	private static Camera primary;

	private static readonly List<Camera> rig = new List<Camera>();

	private static readonly Dictionary<Camera, Vector3> originalPos = new Dictionary<Camera, Vector3>();

	private static readonly Dictionary<Camera, int> originalMask = new Dictionary<Camera, int>();

	private static int computedFrame = -1;

	private static Vector3 frameDelta;

	private static float currentLength;

	private static int localLayer = -2;

	internal static void Hook()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Expected O, but got Unknown
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		Camera.onPreCull = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(OnPreCull));
		Camera.onPostRender = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPostRender, (Delegate?)new CameraCallback(OnPostRender));
		RenderPipelineManager.beginCameraRendering += OnBeginCamera;
		RenderPipelineManager.endCameraRendering += OnEndCamera;
	}

	internal static void Unhook()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Expected O, but got Unknown
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		Camera.onPreCull = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(OnPreCull));
		Camera.onPostRender = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPostRender, (Delegate?)new CameraCallback(OnPostRender));
		RenderPipelineManager.beginCameraRendering -= OnBeginCamera;
		RenderPipelineManager.endCameraRendering -= OnEndCamera;
		RestoreAll();
	}

	internal static void ResetSmoothing()
	{
		currentLength = 0f;
	}

	private static void OnPreCull(Camera cam)
	{
		Apply(cam);
	}

	private static void OnPostRender(Camera cam)
	{
		Restore(cam);
	}

	private static void OnBeginCamera(ScriptableRenderContext ctx, Camera cam)
	{
		Apply(cam);
	}

	private static void OnEndCamera(ScriptableRenderContext ctx, Camera cam)
	{
		Restore(cam);
	}

	internal static void Tick()
	{
		enabledNow = ShouldBeActive();
		if (!enabledNow)
		{
			currentLength = 0f;
			return;
		}
		try
		{
			PlayerAvatar instance = PlayerAvatar.instance;
			if ((Object)(object)instance != (Object)null && (Object)(object)instance.playerAvatarVisuals != (Object)null)
			{
				instance.playerAvatarVisuals.ShowSelfOverride(0.15f);
			}
		}
		catch (Exception)
		{
		}
	}

	private static bool ShouldBeActive()
	{
		if (!Active || !ArcRaidersPlugin.CamEnabled.Value)
		{
			return false;
		}
		try
		{
			if (SemiFunc.IsMainMenu() || SemiFunc.MenuLevel())
			{
				return false;
			}
			PlayerAvatar instance = PlayerAvatar.instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)PlayerController.instance == (Object)null)
			{
				return false;
			}
			if (Refl.Get(instance, "deadSet", def: false))
			{
				return false;
			}
			if (Refl.Get(instance, "spectating", def: false))
			{
				return false;
			}
			if (Refl.Get(instance, "isDisabled", def: false))
			{
				return false;
			}
			return true;
		}
		catch (Exception)
		{
			return false;
		}
	}

	private static void FindRig()
	{
		primary = null;
		rig.Clear();
		PlayerController instance = PlayerController.instance;
		if ((Object)(object)instance != (Object)null && (Object)(object)instance.cameraGameObject != (Object)null)
		{
			Camera[] componentsInChildren = instance.cameraGameObject.GetComponentsInChildren<Camera>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				rig.Add(componentsInChildren[i]);
			}
		}
		Camera main = Camera.main;
		if ((Object)(object)main != (Object)null)
		{
			primary = main;
		}
		if (!((Object)(object)primary == (Object)null))
		{
			return;
		}
		for (int j = 0; j < rig.Count; j++)
		{
			if ((Object)(object)rig[j] != (Object)null && ((Behaviour)rig[j]).isActiveAndEnabled)
			{
				primary = rig[j];
				break;
			}
		}
	}

	private static bool ShouldAffect(Camera cam)
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//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_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)cam == (Object)null || (Object)(object)primary == (Object)null)
		{
			return false;
		}
		if ((Object)(object)cam == (Object)(object)primary)
		{
			return true;
		}
		if ((int)cam.cameraType != 1)
		{
			return false;
		}
		Vector3 val = ((Component)primary).transform.position;
		if (originalPos.TryGetValue(primary, out var value))
		{
			val = value;
		}
		Vector3 val2 = ((Component)cam).transform.position - val;
		return ((Vector3)(ref val2)).sqrMagnitude < 0.25f;
	}

	private static bool ValidHit(RaycastHit h)
	{
		Collider collider = ((RaycastHit)(ref h)).collider;
		if ((Object)(object)collider == (Object)null || collider.isTrigger)
		{
			return false;
		}
		if ((Object)(object)((RaycastHit)(ref h)).rigidbody != (Object)null)
		{
			return false;
		}
		if ((Object)(object)((Component)collider).GetComponentInParent<PlayerAvatar>() != (Object)null)
		{
			return false;
		}
		return true;
	}

	private static void ComputeFrame()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: 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_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: 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_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: 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_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		computedFrame = Time.frameCount;
		Transform transform = ((Component)primary).transform;
		Vector3 position = transform.position;
		float num = Mathf.Max(0.3f, ArcRaidersPlugin.CamDistance.Value);
		Vector3 val = -transform.forward * num + transform.right * ArcRaidersPlugin.CamShoulder.Value + Vector3.up * ArcRaidersPlugin.CamHeight.Value;
		float magnitude = ((Vector3)(ref val)).magnitude;
		if (magnitude < 0.01f)
		{
			frameDelta = Vector3.zero;
			return;
		}
		Vector3 val2 = val / magnitude;
		float num2 = magnitude;
		RaycastHit[] array = Physics.SphereCastAll(position, ArcRaidersPlugin.CamRadius.Value, val2, magnitude, -1, (QueryTriggerInteraction)1);
		for (int i = 0; i < array.Length; i++)
		{
			RaycastHit h = array[i];
			if (!(((RaycastHit)(ref h)).distance <= 0f) && ValidHit(h) && ((RaycastHit)(ref h)).distance < num2)
			{
				num2 = ((RaycastHit)(ref h)).distance;
			}
		}
		num2 = Mathf.Max(0.25f, num2 - 0.08f);
		float num3 = Mathf.Min(Time.unscaledDeltaTime, 0.1f);
		if (num2 < currentLength)
		{
			currentLength = Mathf.Lerp(currentLength, num2, 1f - Mathf.Exp(-30f * num3));
		}
		else
		{
			currentLength = Mathf.Lerp(currentLength, num2, 1f - Mathf.Exp(-6f * num3));
		}
		frameDelta = val2 * currentLength;
	}

	private static void Apply(Camera cam)
	{
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: 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_008a: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (!enabledNow || (Object)(object)cam == (Object)null || originalPos.ContainsKey(cam))
			{
				return;
			}
			if ((Object)(object)primary == (Object)null || !((Behaviour)primary).isActiveAndEnabled)
			{
				FindRig();
			}
			if (ShouldAffect(cam))
			{
				if (computedFrame != Time.frameCount)
				{
					ComputeFrame();
				}
				originalPos[cam] = ((Component)cam).transform.position;
				((Component)cam).transform.position = ((Component)cam).transform.position + frameDelta;
				if (localLayer == -2)
				{
					localLayer = LayerMask.NameToLayer("PlayerVisualsLocal");
				}
				if (localLayer >= 0)
				{
					originalMask[cam] = cam.cullingMask;
					cam.cullingMask |= 1 << localLayer;
				}
			}
		}
		catch (Exception)
		{
		}
	}

	private static void Restore(Camera cam)
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (!((Object)(object)cam == (Object)null))
			{
				if (originalPos.TryGetValue(cam, out var value))
				{
					((Component)cam).transform.position = value;
					originalPos.Remove(cam);
				}
				if (originalMask.TryGetValue(cam, out var value2))
				{
					cam.cullingMask = value2;
					originalMask.Remove(cam);
				}
			}
		}
		catch (Exception)
		{
		}
	}

	internal static void RestoreAll()
	{
		if (originalPos.Count != 0 || originalMask.Count != 0)
		{
			List<Camera> list = new List<Camera>(originalPos.Keys);
			for (int i = 0; i < list.Count; i++)
			{
				Restore(list[i]);
			}
			list = new List<Camera>(originalMask.Keys);
			for (int j = 0; j < list.Count; j++)
			{
				Restore(list[j]);
			}
			originalPos.Clear();
			originalMask.Clear();
		}
	}
}
internal static class Movement
{
	private static PlayerController configured;

	private static bool wasSliding;

	private static bool vaulting;

	private static Vector3 vaultTarget;

	private static Vector3 vaultDir;

	private static float vaultTimer;

	private static float vaultCooldown;

	internal static void ApplyBase(PlayerController pc)
	{
		try
		{
			if ((Object)(object)pc == (Object)null)
			{
				return;
			}
			if ((Object)(object)configured != (Object)(object)pc)
			{
				configured = pc;
				float num = Mathf.Max(0.1f, ArcRaidersPlugin.SlideDuration.Value);
				pc.SlideTime *= num;
				pc.SlideDecay /= num;
				pc.JumpForce *= Mathf.Max(0.1f, ArcRaidersPlugin.JumpMultiplier.Value);
				wasSliding = false;
				vaulting = false;
			}
			int value = ArcRaidersPlugin.ExtraJumps.Value;
			if (value > 0)
			{
				int num2 = Refl.Get(pc, "JumpExtra", 0);
				if (num2 < value)
				{
					Refl.Set(pc, "JumpExtra", value);
				}
			}
		}
		catch (Exception)
		{
		}
	}

	internal static void FixedTick(PlayerController pc)
	{
		try
		{
			if (!((Object)(object)pc == (Object)null))
			{
				RealSlide.FixedTick(pc);
				SlideTick(pc);
				VaultTick(pc);
			}
		}
		catch (Exception)
		{
		}
	}

	private static void SlideTick(PlayerController pc)
	{
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: 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_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		bool sliding = pc.Sliding;
		if (sliding && !wasSliding)
		{
			float value = ArcRaidersPlugin.SlideBoost.Value;
			if (value > 0.01f && Mathf.Abs(value - 1f) > 0.001f)
			{
				Vector3 val = Refl.Get<Vector3>(pc, "SlideDirectionCurrent", Vector3.zero);
				Vector3 val2 = Refl.Get<Vector3>(pc, "SlideDirection", Vector3.zero);
				Refl.Set(pc, "SlideDirectionCurrent", val * value);
				Refl.Set(pc, "SlideDirection", val2 * value);
			}
		}
		wasSliding = sliding;
	}

	private static bool ValidHit(RaycastHit h)
	{
		Collider collider = ((RaycastHit)(ref h)).collider;
		if ((Object)(object)collider == (Object)null || collider.isTrigger)
		{
			return false;
		}
		if ((Object)(object)((RaycastHit)(ref h)).rigidbody != (Object)null)
		{
			return false;
		}
		if ((Object)(object)((Component)collider).GetComponentInParent<PlayerAvatar>() != (Object)null)
		{
			return false;
		}
		return true;
	}

	private static bool Probe(Vector3 origin, Vector3 dir, float len, out RaycastHit best)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: 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_0048: 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)
		best = default(RaycastHit);
		RaycastHit[] array = Physics.RaycastAll(origin, dir, len, -1, (QueryTriggerInteraction)1);
		float num = float.MaxValue;
		bool result = false;
		for (int i = 0; i < array.Length; i++)
		{
			RaycastHit val = array[i];
			if (ValidHit(val) && ((RaycastHit)(ref val)).distance < num)
			{
				num = ((RaycastHit)(ref val)).distance;
				best = val;
				result = true;
			}
		}
		return result;
	}

	private static void VaultTick(PlayerController pc)
	{
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: 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_014f: 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_0175: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0208: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0217: Unknown result type (might be due to invalid IL or missing references)
		//IL_021c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0221: Unknown result type (might be due to invalid IL or missing references)
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_0240: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: 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_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_0274: Unknown result type (might be due to invalid IL or missing references)
		//IL_0279: Unknown result type (might be due to invalid IL or missing references)
		//IL_027e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0286: Unknown result type (might be due to invalid IL or missing references)
		//IL_028d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0292: Unknown result type (might be due to invalid IL or missing references)
		//IL_0297: Unknown result type (might be due to invalid IL or missing references)
		//IL_0299: Unknown result type (might be due to invalid IL or missing references)
		//IL_029b: Unknown result type (might be due to invalid IL or missing references)
		//IL_029d: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a7: 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)
		if ((Object)(object)pc.rb == (Object)null)
		{
			return;
		}
		float fixedDeltaTime = Time.fixedDeltaTime;
		if (vaultCooldown > 0f)
		{
			vaultCooldown -= fixedDeltaTime;
		}
		if (vaulting)
		{
			VaultContinue(pc, fixedDeltaTime);
		}
		else
		{
			if (!ArcRaidersPlugin.VaultEnabled.Value || vaultCooldown > 0f)
			{
				return;
			}
			PlayerAvatar playerAvatarScript = pc.playerAvatarScript;
			if ((Object)(object)playerAvatarScript == (Object)null || Refl.Get(playerAvatarScript, "isTumbling", def: false) || Refl.Get(playerAvatarScript, "deadSet", def: false) || Refl.Get(playerAvatarScript, "isDisabled", def: false) || pc.Crawling)
			{
				return;
			}
			bool flag = SemiFunc.InputDown((InputKey)1);
			if (!flag && ArcRaidersPlugin.VaultAuto.Value)
			{
				flag = SemiFunc.InputHold((InputKey)1);
			}
			if (!flag)
			{
				return;
			}
			Vector3 inputDirection = pc.InputDirection;
			inputDirection.y = 0f;
			if (((Vector3)(ref inputDirection)).sqrMagnitude < 0.04f)
			{
				return;
			}
			((Vector3)(ref inputDirection)).Normalize();
			Collider col = pc.col;
			if ((Object)(object)col == (Object)null)
			{
				return;
			}
			Bounds bounds = col.bounds;
			float y = ((Bounds)(ref bounds)).min.y;
			float num = Mathf.Max(0.6f, ArcRaidersPlugin.VaultMaxHeight.Value);
			Vector3 origin = default(Vector3);
			((Vector3)(ref origin))..ctor(((Bounds)(ref bounds)).center.x, y + 0.3f, ((Bounds)(ref bounds)).center.z);
			if (!Probe(origin, inputDirection, 0.9f, out var best) || ((RaycastHit)(ref best)).normal.y > 0.5f)
			{
				return;
			}
			Vector3 origin2 = new Vector3(((RaycastHit)(ref best)).point.x, y + num + 0.1f, ((RaycastHit)(ref best)).point.z) + inputDirection * 0.35f;
			float num2 = num - 0.3f;
			if (!(num2 < 0.1f) && Probe(origin2, Vector3.down, num2, out var best2) && !(((RaycastHit)(ref best2)).normal.y < 0.7f))
			{
				float len = Mathf.Max(0.5f, ((Bounds)(ref bounds)).size.y * 0.9f);
				if (!Probe(((RaycastHit)(ref best2)).point + Vector3.up * 0.05f, Vector3.up, len, out var _))
				{
					Vector3 val = new Vector3(((RaycastHit)(ref best2)).point.x, ((RaycastHit)(ref best2)).point.y + ((Bounds)(ref bounds)).extents.y + 0.05f, ((RaycastHit)(ref best2)).point.z) + inputDirection * 0.25f;
					Vector3 val2 = pc.rb.position - ((Bounds)(ref bounds)).center;
					vaultTarget = val + val2;
					vaultDir = inputDirection;
					vaultTimer = 0f;
					vaulting = true;
				}
			}
		}
	}

	private static void VaultContinue(PlayerController pc, float dt)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//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_001e: 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_0060: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: 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_00da: 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_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_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		vaultTimer += dt;
		Vector3 position = pc.rb.position;
		Vector3 val = vaultTarget - position;
		float num = Mathf.Max(1f, ArcRaidersPlugin.VaultSpeed.Value);
		if (((Vector3)(ref val)).magnitude < 0.12f || vaultTimer > 0.7f)
		{
			pc.rb.linearVelocity = vaultDir * 3f;
			vaulting = false;
			vaultCooldown = 0.5f;
			return;
		}
		Vector3 linearVelocity;
		if (val.y > 0.1f)
		{
			linearVelocity = Vector3.up * num + vaultDir * (num * 0.35f);
		}
		else
		{
			Vector3 val2 = val;
			val2.y = 0f;
			linearVelocity = ((Vector3)(ref val2)).normalized * (num * 0.8f);
		}
		pc.rb.linearVelocity = linearVelocity;
		pc.AntiGravity(0.1f);
	}
}
[HarmonyPatch(typeof(PlayerController), "Start")]
internal static class PC_Start
{
	private static void Postfix(PlayerController __instance)
	{
		Movement.ApplyBase(__instance);
	}
}
[HarmonyPatch(typeof(PlayerController), "FixedUpdate")]
internal static class PC_FixedUpdate
{
	private static void Postfix(PlayerController __instance)
	{
		Movement.FixedTick(__instance);
	}
}
[HarmonyPatch(typeof(EnemyDirector), "AmountSetup")]
internal static class ED_AmountSetup
{
	private static void Postfix(EnemyDirector __instance)
	{
		try
		{
			if (!ArcRaidersPlugin.EnemiesEnabled.Value)
			{
				return;
			}
			float value = ArcRaidersPlugin.EnemyCount.Value;
			if (value <= 1.001f)
			{
				return;
			}
			int num = Refl.Get(__instance, "totalAmount", 0);
			int num2 = Mathf.RoundToInt((float)num * (value - 1f));
			if (num2 <= 0)
			{
				return;
			}
			MethodInfo methodInfo = AccessTools.Method(typeof(EnemyDirector), "PickEnemies", (Type[])null, (Type[])null);
			if (methodInfo == null)
			{
				return;
			}
			List<EnemySetup> list = Refl.Get<List<EnemySetup>>(__instance, "enemyListCurrent", null);
			if (list == null)
			{
				return;
			}
			int count = list.Count;
			for (int i = 0; i < num2; i++)
			{
				List<EnemySetup> list2 = __instance.enemiesDifficulty1;
				int num3 = Random.Range(0, 100);
				if (num3 < 20)
				{
					list2 = __instance.enemiesDifficulty3;
				}
				else if (num3 < 55)
				{
					list2 = __instance.enemiesDifficulty2;
				}
				methodInfo.Invoke(__instance, new object[1] { list2 });
			}
			int num4 = list.Count - count;
			if (num4 > 0)
			{
				Refl.Set(__instance, "totalAmount", num + num4);
			}
			ArcRaidersPlugin.Log.LogInfo((object)("Enemy count: " + num + " -> " + (num + num4)));
		}
		catch (Exception ex)
		{
			ArcRaidersPlugin.Log.LogWarning((object)("AmountSetup patch: " + ex.Message));
		}
	}
}
[HarmonyPatch(typeof(EnemyNavMeshAgent), "UpdateAgent")]
internal static class NMA_UpdateAgent
{
	private static void Prefix(ref float speed, ref float acceleration)
	{
		if (ArcRaidersPlugin.EnemiesEnabled.Value)
		{
			float value = ArcRaidersPlugin.EnemySpeed.Value;
			speed *= value;
			acceleration *= value;
		}
	}
}
[HarmonyPatch(typeof(EnemyNavMeshAgent), "OverrideAgent")]
internal static class NMA_OverrideAgent
{
	private static void Prefix(ref float speed, ref float acceleration)
	{
		if (ArcRaidersPlugin.EnemiesEnabled.Value)
		{
			float value = ArcRaidersPlugin.EnemySpeed.Value;
			speed *= value;
			acceleration *= value;
		}
	}
}
internal static class Extras
{
	internal static ManualLogSource Log;

	internal static ConfigEntry<bool> SlideEnabled;

	internal static ConfigEntry<Key> SlideKey;

	internal static ConfigEntry<float> SlideSpeed;

	internal static ConfigEntry<float> SlideTime;

	internal static ConfigEntry<float> SlideCooldown;

	internal static ConfigEntry<bool> WeaponsEnabled;

	internal static ConfigEntry<Key> PistolKey;

	internal static ConfigEntry<Key> ShotgunKey;

	internal static ConfigEntry<Key> ReloadKey;

	internal static ConfigEntry<float> WeaponDamage;

	internal static ConfigEntry<float> AimAssist;

	internal static ConfigEntry<bool> RobotsEnabled;

	internal static ConfigEntry<int> DroneCount;

	internal static ConfigEntry<int> CrawlerCount;

	internal static ConfigEntry<float> RobotDamage;

	internal static ConfigEntry<Key> SpawnKey;

	private static readonly HashSet<string> logged = new HashSet<string>();

	internal static void Init(ConfigFile cfg, ManualLogSource log)
	{
		Log = log;
		SlideEnabled = cfg.Bind<bool>("Slide", "Enabled", true, "Real slide: press the slide key while running.");
		SlideKey = cfg.Bind<Key>("Slide", "Key", (Key)17, "Key that starts a slide.");
		SlideSpeed = cfg.Bind<float>("Slide", "Speed", 10f, "Minimum slide start speed (m/s).");
		SlideTime = cfg.Bind<float>("Slide", "Duration", 0.9f, "Slide duration in seconds.");
		SlideCooldown = cfg.Bind<float>("Slide", "Cooldown", 0.5f, "Seconds before you can slide again.");
		WeaponsEnabled = cfg.Bind<bool>("Weapons", "Enabled", true, "Give the player a pistol and a shotgun.");
		PistolKey = cfg.Bind<Key>("Weapons", "PistolKey", (Key)44, "Equip / holster the pistol.");
		ShotgunKey = cfg.Bind<Key>("Weapons", "ShotgunKey", (Key)45, "Equip / holster the shotgun.");
		ReloadKey = cfg.Bind<Key>("Weapons", "ReloadKey", (Key)34, "Reload.");
		WeaponDamage = cfg.Bind<float>("Weapons", "DamageMultiplier", 1f, "Weapon damage multiplier.");
		AimAssist = cfg.Bind<float>("Weapons", "AimAssistDegrees", 20f, "Shots snap to a robot within this angle of the crosshair (0 = off).");
		RobotsEnabled = cfg.Bind<bool>("Robots", "Enabled", true, "Spawn the mod's robots in levels (singleplayer only).");
		DroneCount = cfg.Bind<int>("Robots", "SentryDrones", 1, "Flying sentry drones per level.");
		CrawlerCount = cfg.Bind<int>("Robots", "Crawlers", 1, "Walking crawlers per level.");
		RobotDamage = cfg.Bind<float>("Robots", "DamageMultiplier", 1f, "Damage the robots deal to you.");
		SpawnKey = cfg.Bind<Key>("Robots", "SpawnKey", (Key)101, "Spawn one drone and one crawler in front of you (singleplayer, for testing and fun).");
	}

	internal static void LogOnce(string where, Exception e)
	{
		string item = where + ":" + e.GetType().Name + ":" + e.Message;
		if (logged.Add(item))
		{
			Log.LogWarning((object)(where + " failed: " + e));
		}
	}

	internal static void Update()
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Keyboard current = Keyboard.current;
			if (current != null && SlideEnabled.Value && ((ButtonControl)current[SlideKey.Value]).wasPressedThisFrame)
			{
				RealSlide.Request();
			}
			Weapons.Update(current);
			if (current != null && RobotsEnabled.Value && ((ButtonControl)current[SpawnKey.Value]).wasPressedThisFrame && InLevelWorld() && !SemiFunc.IsMultiplayer())
			{
				Robots.SpawnNearPlayer();
			}
		}
		catch (Exception e)
		{
			LogOnce("Extras.Update", e);
		}
		try
		{
			Robots.Update();
		}
		catch (Exception e2)
		{
			LogOnce("Robots.Update", e2);
		}
	}

	internal static void OnGui()
	{
		try
		{
			Weapons.OnGui();
		}
		catch (Exception e)
		{
			LogOnce("Extras.OnGui", e);
		}
	}

	internal static bool InLevelWorld()
	{
		if (SemiFunc.IsMainMenu() || SemiFunc.MenuLevel())
		{
			return false;
		}
		if ((Object)(object)PlayerAvatar.instance != (Object)null)
		{
			return (Object)(object)PlayerController.instance != (Object)null;
		}
		return false;
	}

	internal static bool GetPlayerTarget(out Vector3 pos)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		pos = Vector3.zero;
		PlayerController instance = PlayerController.instance;
		PlayerAvatar instance2 = PlayerAvatar.instance;
		if ((Object)(object)instance == (Object)null || (Object)(object)instance2 == (Object)null)
		{
			return false;
		}
		if (Refl.Get(instance2, "deadSet", def: false))
		{
			return false;
		}
		pos = ((Component)instance).transform.position + Vector3.up * 0.5f;
		return true;
	}

	internal static string KeyName(Key k)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		string text = ((object)k).ToString();
		if (text.StartsWith("Digit"))
		{
			text = text.Substring(5);
		}
		return text;
	}

	internal static void HurtPlayer(float amount)
	{
		try
		{
			PlayerAvatar instance = PlayerAvatar.instance;
			if ((Object)(object)instance != (Object)null && (Object)(object)instance.playerHealth != (Object)null)
			{
				instance.playerHealth.Hurt(Mathf.Max(1, Mathf.RoundToInt(amount * RobotDamage.Value)), false, -1, false);
			}
		}
		catch (Exception e)
		{
			LogOnce("HurtPlayer", e);
		}
	}

	internal static bool IsPlayerCollider(Collider c)
	{
		if ((Object)(object)c == (Object)null)
		{
			return false;
		}
		if (!((Object)(object)((Component)c).GetComponentInParent<PlayerController>() != (Object)null))
		{
			return (Object)(object)((Component)c).GetComponentInParent<PlayerAvatar>() != (Object)null;
		}
		return true;
	}
}
internal static class Build
{
	private static Material baseMat;

	private static bool searched;

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

	private static Material GetBase()
	{
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Expected O, but got Unknown
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Expected O, but got Unknown
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Expected O, but got Unknown
		if ((Object)(object)baseMat != (Object)null)
		{
			return baseMat;
		}
		if (searched)
		{
			return null;
		}
		searched = true;
		try
		{
			string[] array = (((Object)(object)GraphicsSettings.currentRenderPipeline != (Object)null) ? new string[3] { "Universal Render Pipeline/Lit", "HDRP/Lit", "Universal Render Pipeline/Simple Lit" } : new string[2] { "Standard", "Legacy Shaders/Diffuse" });
			for (int i = 0; i < array.Length; i++)
			{
				if (!((Object)(object)baseMat == (Object)null))
				{
					break;
				}
				Shader val = Shader.Find(array[i]);
				if ((Object)(object)val != (Object)null && val.isSupported)
				{
					baseMat = new Material(val);
				}
			}
			if ((Object)(object)baseMat == (Object)null)
			{
				MeshRenderer[] array2 = Object.FindObjectsByType<MeshRenderer>((FindObjectsSortMode)0);
				for (int j = 0; j < array2.Length; j++)
				{
					Material sharedMaterial = ((Renderer)array2[j]).sharedMaterial;
					if (!((Object)(object)sharedMaterial == (Object)null) && !((Object)(object)sharedMaterial.shader == (Object)null) && (sharedMaterial.HasProperty("_BaseColor") || sharedMaterial.HasProperty("_Color")))
					{
						baseMat = new Material(sharedMaterial);
						break;
					}
				}
			}
		}
		catch (Exception e)
		{
			Extras.LogOnce("Build.GetBase", e);
		}
		if ((Object)(object)baseMat == (Object)null)
		{
			Shader val2 = Shader.Find("Sprites/Default");
			if ((Object)(object)val2 != (Object)null)
			{
				baseMat = new Material(val2);
			}
		}
		return baseMat;
	}

	internal static Material Mat(Color c, float glow)
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Expected O, but got Unknown
		//IL_006c: 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_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		Material val = GetBase();
		Material val2 = (((Object)(object)val != (Object)null) ? new Material(val) : new Material(Shader.Find("Sprites/Default")));
		try
		{
			if (val2.HasProperty("_MainTex"))
			{
				val2.SetTexture("_MainTex", (Texture)null);
			}
			if (val2.HasProperty("_BaseMap"))
			{
				val2.SetTexture("_BaseMap", (Texture)null);
			}
			if (val2.HasProperty("_BaseColor"))
			{
				val2.SetColor("_BaseColor", c);
			}
			if (val2.HasProperty("_Color"))
			{
				val2.SetColor("_Color", c);
			}
			if (val2.HasProperty("_Metallic"))
			{
				val2.SetFloat("_Metallic", 0.35f);
			}
			if (val2.HasProperty("_Glossiness"))
			{
				val2.SetFloat("_Glossiness", 0.45f);
			}
			if (val2.HasProperty("_Smoothness"))
			{
				val2.SetFloat("_Smoothness", 0.45f);
			}
			if (glow > 0f && val2.HasProperty("_EmissionColor"))
			{
				val2.EnableKeyword("_EMISSION");
				val2.SetColor("_EmissionColor", c * glow);
			}
		}
		catch (Exception)
		{
		}
		return val2;
	}

	internal static GameObject Part(Transform parent, PrimitiveType type, Vector3 pos, Vector3 scale, Color c, float glow)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: 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)
		GameObject val = GameObject.CreatePrimitive(type);
		Collider component = val.GetComponent<Collider>();
		if ((Object)(object)component != (Object)null)
		{
			Object.DestroyImmediate((Object)(object)component);
		}
		val.transform.SetParent(parent, false);
		val.transform.localPosition = pos;
		val.transform.localScale = scale;
		Renderer component2 = val.GetComponent<Renderer>();
		if ((Object)(object)component2 != (Object)null)
		{
			component2.sharedMaterial = Mat(c, glow);
			component2.shadowCastingMode = (ShadowCastingMode)0;
			component2.receiveShadows = false;
		}
		return val;
	}

	internal static void Tracer(Vector3 a, Vector3 b, Color c, float width, float life)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_001b: 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_003e: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			GameObject val = new GameObject("ArcTracer");
			LineRenderer val2 = val.AddComponent<LineRenderer>();
			val2.positionCount = 2;
			val2.SetPosition(0, a);
			val2.SetPosition(1, b);
			val2.startWidth = width;
			val2.endWidth = width * 0.4f;
			((Renderer)val2).sharedMaterial = Mat(c, 3f);
			((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0;
			Object.Destroy((Object)(object)val, life);
		}
		catch (Exception e)
		{
			Extras.LogOnce("Tracer", e);
		}
	}

	internal static void Puff(Vector3 pos, Color c, float size)
	{
		//IL_0023: 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_0035: 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_0051: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
			Collider component = val.GetComponent<Collider>();
			if ((Object)(object)component != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)component);
			}
			val.transform.position = pos;
			val.transform.localScale = Vector3.one * size * 0.3f;
			Renderer component2 = val.GetComponent<Renderer>();
			component2.sharedMaterial = Mat(c, 4f);
			component2.shadowCastingMode = (ShadowCastingMode)0;
			PuffFx puffFx = val.AddComponent<PuffFx>();
			puffFx.Size = size;
		}
		catch (Exception e)
		{
			Extras.LogOnce("Puff", e);
		}
	}

	private static AudioClip Clip(string name, float seconds, Func<float, float, float> f)
	{
		if (clips.TryGetValue(name, out var value) && (Object)(object)value != (Object)null)
		{
			return value;
		}
		int num = 44100;
		int num2 = (int)((float)num * seconds);
		float[] array = new float[num2];
		Random random = new Random(name.GetHashCode());
		for (int i = 0; i < num2; i++)
		{
			float arg = (float)i / (float)num;
			float arg2 = (float)(random.NextDouble() * 2.0 - 1.0);
			array[i] = Mathf.Clamp(f(arg, arg2), -1f, 1f);
		}
		value = AudioClip.Create(name, num2, 1, num, false);
		value.SetData(array, 0);
		clips[name] = value;
		return value;
	}

	internal static void Sound(string kind, Vector3 pos, float volume)
	{
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			AudioClip val = null;
			switch (kind)
			{
			case "pistol":
				val = Clip(kind, 0.25f, (float t, float nz) => nz * Mathf.Exp((0f - t) * 40f) * 0.8f + Mathf.Sin(879.64795f * t) * Mathf.Exp((0f - t) * 28f) * 0.6f);
				break;
			case "shotgun":
				val = Clip(kind, 0.45f, (float t, float nz) => nz * Mathf.Exp((0f - t) * 14f) * 0.9f + Mathf.Sin(439.82397f * t) * Mathf.Exp((0f - t) * 12f) * 0.7f);
				break;
			case "laser":
				val = Clip(kind, 0.3f, (float t, float nz) => Mathf.Sin(6.2832f * (1100f - 2200f * t) * t) * Mathf.Exp((0f - t) * 9f) * 0.6f);
				break;
			case "hit":
				val = Clip(kind, 0.08f, (float t, float nz) => nz * Mathf.Exp((0f - t) * 60f) * 0.6f);
				break;
			case "boom":
				val = Clip(kind, 0.7f, (float t, float nz) => nz * Mathf.Exp((0f - t) * 6f) * 0.8f + Mathf.Sin(345.576f * t) * Mathf.Exp((0f - t) * 5f) * 0.6f);
				break;
			case "reload":
				val = Clip(kind, 0.12f, (float t, float nz) => (Mathf.Sin(5654.88f * t) * 0.3f + nz * 0.3f) * Mathf.Exp((0f - t) * 35f));
				break;
			}
			if ((Object)(object)val != (Object)null)
			{
				AudioSource.PlayClipAtPoint(val, pos, volume);
			}
		}
		catch (Exception e)
		{
			Extras.LogOnce("Sound", e);
		}
	}
}
internal sealed class PuffFx : MonoBehaviour
{
	internal float Size = 1f;

	private float t;

	private void Update()
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		t += Time.deltaTime;
		float num = t / 0.3f;
		((Component)this).transform.localScale = Vector3.one * Size * Mathf.Lerp(0.3f, 1f, num);
		if (num >= 1f)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
}
internal static class RealSlide
{
	private static bool requested;

	private static bool sliding;

	private static float timer;

	private static float total;

	private static float startSpeed;

	private static float cooldown;

	private static float airTime;

	private static float age;

	private static Vector3 dir;

	internal static void Request()
	{
		requested = true;
	}

	internal static void FixedTick(PlayerController pc)
	{
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: 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_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0361: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
		if (!Extras.SlideEnabled.Value || (Object)(object)pc == (Object)null || (Object)(object)pc.rb == (Object)null)
		{
			return;
		}
		float fixedDeltaTime = Time.fixedDeltaTime;
		if (cooldown > 0f)
		{
			cooldown -= fixedDeltaTime;
		}
		PlayerAvatar playerAvatarScript = pc.playerAvatarScript;
		if ((Object)(object)playerAvatarScript == (Object)null || Refl.Get(playerAvatarScript, "deadSet", def: false) || Refl.Get(playerAvatarScript, "isDisabled", def: false) || Refl.Get(playerAvatarScript, "isTumbling", def: false))
		{
			sliding = false;
			requested = false;
			return;
		}
		bool flag = (Object)(object)pc.CollisionGrounded != (Object)null && Refl.Get(pc.CollisionGrounded, "Grounded", def: false);
		Vector3 linearVelocity = pc.rb.linearVelocity;
		Vector3 val = default(Vector3);
		((Vector3)(ref val))..ctor(linearVelocity.x, 0f, linearVelocity.z);
		if (!sliding)
		{
			if (requested && cooldown <= 0f && flag)
			{
				Vector3 inputDirection = pc.InputDirection;
				inputDirection.y = 0f;
				Vector3 val2 = ((((Vector3)(ref inputDirection)).sqrMagnitude > 0.04f) ? ((Vector3)(ref inputDirection)).normalized : ((((Vector3)(ref val)).magnitude > 1.5f) ? ((Vector3)(ref val)).normalized : Vector3.zero));
				if (val2 != Vector3.zero)
				{
					sliding = true;
					dir = val2;
					total = Mathf.Max(0.3f, Extras.SlideTime.Value);
					timer = total;
					age = 0f;
					airTime = 0f;
					startSpeed = Mathf.Max(Extras.SlideSpeed.Value, ((Vector3)(ref val)).magnitude * 1.25f);
					Extras.Log.LogInfo((object)("Slide start, speed " + startSpeed.ToString("0.0")));
				}
			}
			requested = false;
			if (!sliding)
			{
				return;
			}
		}
		requested = false;
		timer -= fixedDeltaTime;
		age += fixedDeltaTime;
		airTime = (flag ? 0f : (airTime + fixedDeltaTime));
		bool flag2 = SemiFunc.InputDown((InputKey)1);
		bool flag3 = age > 0.15f && ((Vector3)(ref val)).magnitude < startSpeed * 0.3f;
		if (timer <= 0f || airTime > 0.3f || flag2 || flag3)
		{
			Extras.Log.LogInfo((object)("Slide end, t=" + age.ToString("0.00") + (flag2 ? " (jump)" : (flag3 ? " (blocked)" : ""))));
			sliding = false;
			cooldown = Extras.SlideCooldown.Value;
			return;
		}
		Vector3 inputDirection2 = pc.InputDirection;
		inputDirection2.y = 0f;
		if (((Vector3)(ref inputDirection2)).sqrMagnitude > 0.04f)
		{
			dir = Vector3.RotateTowards(dir, ((Vector3)(ref inputDirection2)).normalized, 1.3f * fixedDeltaTime, 0f);
		}
		float num = 1f - timer / total;
		float num2 = Mathf.Lerp(startSpeed, startSpeed * 0.3f, num * num);
		linearVelocity.x = dir.x * num2;
		linearVelocity.z = dir.z * num2;
		pc.rb.linearVelocity = linearVelocity;
		pc.CrouchOverride(0.2f);
	}
}
internal static class Weapons
{
	private static int current;

	private static readonly int[] mag = new int[3] { 0, 12, 5 };

	private static readonly int[] magSize = new int[3] { 0, 12, 5 };

	private static readonly int[] reserve = new int[3] { 0, 72, 25 };

	private static readonly float[] fireDelay = new float[3] { 0f, 0.28f, 0.95f };

	private static readonly float[] reloadTime = new float[3] { 0f, 1.1f, 1.9f };

	private static readonly string[] names = new string[3] { "", "PISTOL", "SHOTGUN" };

	private static GameObject holder;

	private static readonly GameObject[] models = (GameObject[])(object)new GameObject[3];

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

	private static GameObject flashObj;

	private static Camera mountCam;

	private static float fireTimer;

	private static float reloadTimer;

	private static bool reloading;

	private static float kick;

	private static float flashTimer;

	private static float helpTimer;

	private static object lastLevel;

	private static bool warnedCursor;

	private static GUIStyle style;

	internal static void Update(Keyboard kb)
	{
		//IL_00f0: 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_0132: 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_019e: Invalid comparison between Unknown and I4
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		if (!Extras.WeaponsEnabled.Value)
		{
			Holster();
			return;
		}
		if (!Extras.InLevelWorld())
		{
			Holster();
			return;
		}
		PlayerAvatar instance = PlayerAvatar.instance;
		if (Refl.Get(instance, "deadSet", def: false) || Refl.Get(instance, "isDisabled", def: false))
		{
			Holster();
			return;
		}
		object instance2 = LevelGenerator.Instance;
		if (instance2 != null && instance2 != lastLevel)
		{
			lastLevel = instance2;
			mag[1] = magSize[1];
			mag[2] = magSize[2];
			reserve[1] = 72;
			reserve[2] = 25;
			helpTimer = 12f;
		}
		float deltaTime = Time.deltaTime;
		if (fireTimer > 0f)
		{
			fireTimer -= deltaTime;
		}
		if (helpTimer > 0f)
		{
			helpTimer -= deltaTime;
		}
		kick = Mathf.MoveTowards(kick, 0f, deltaTime * 7f);
		if (kb != null)
		{
			if (((ButtonControl)kb[Extras.PistolKey.Value]).wasPressedThisFrame)
			{
				Equip(1);
			}
			if (((ButtonControl)kb[Extras.ShotgunKey.Value]).wasPressedThisFrame)
			{
				Equip(2);
			}
			if (current > 0 && ((ButtonControl)kb[Extras.ReloadKey.Value]).wasPressedThisFrame)
			{
				StartReload();
			}
		}
		if (reloading)
		{
			reloadTimer -= deltaTime;
			if (reloadTimer <= 0f)
			{
				FinishReload();
			}
		}
		if (current > 0)
		{
			EnsureModel();
			AnimateModel(deltaTime);
			Mouse val = Mouse.current;
			if (val != null && val.leftButton.wasPressedThisFrame)
			{
				if ((int)Cursor.lockState != 1)
				{
					if (!warnedCursor)
					{
						warnedCursor = true;
						Extras.Log.LogInfo((object)string.Concat("Weapons: fire ignored, cursor is not locked (state=", Cursor.lockState, ", visible=", Cursor.visible, ")"));
					}
				}
				else
				{
					TryFire();
				}
			}
		}
		if ((Object)(object)flashObj != (Object)null && flashObj.activeSelf)
		{
			flashTimer -= deltaTime;
			if (flashTimer <= 0f)
			{
				flashObj.SetActive(false);
			}
		}
	}

	private static void Holster()
	{
		if (current != 0)
		{
			current = 0;
			reloading = false;
		}
		if ((Object)(object)holder != (Object)null)
		{
			holder.SetActive(false);
		}
	}

	private static void Equip(int w)
	{
		if (current == w)
		{
			current = 0;
			reloading = false;
			if ((Object)(object)holder != (Object)null)
			{
				holder.SetActive(false);
			}
		}
		else
		{
			current = w;
			reloading = false;
			fireTimer = 0.25f;
			EnsureModel();
		}
	}

	private static void StartReload()
	{
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		if (!reloading && current != 0 && mag[current] < magSize[current] && reserve[current] > 0)
		{
			reloading = true;
			reloadTimer = reloadTime[current];
			Build.Sound("reload", ModelPos(), 0.5f);
		}
	}

	private static void FinishReload()
	{
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		reloading = false;
		int num = magSize[current] - mag[current];
		int num2 = Mathf.Min(num, reserve[current]);
		mag[current] += num2;
		reserve[current] -= num2;
		Build.Sound("reload", ModelPos(), 0.5f);
	}

	private static Vector3 ModelPos()
	{
		//IL_001b: 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)
		Camera main = Camera.main;
		if (!((Object)(object)main != (Object)null))
		{
			return Vector3.zero;
		}
		return ((Component)main).transform.position;
	}

	private static void TryFire()
	{
		if (reloading || fireTimer > 0f)
		{
			return;
		}
		if (mag[current] <= 0)
		{
			StartReload();
			return;
		}
		mag[current]--;
		fireTimer = fireDelay[current];
		Fire(current);
		if (mag[current] <= 0 && reserve[current] > 0)
		{
			StartReload();
		}
	}

	private static void Fire(int w)
	{
		//IL_0367: Unknown result type (might be due to invalid IL or missing references)
		//IL_037f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0384: Unknown result type (might be due to invalid IL or missing references)
		//IL_0386: Unknown result type (might be due to invalid IL or missing references)
		//IL_0397: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cc: 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_021a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0231: Unknown result type (might be due to invalid IL or missing references)
		//IL_0236: Unknown result type (might be due to invalid IL or missing references)
		//IL_023b: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: Unknown result type (might be due to invalid IL or missing references)
		//IL_0249: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: Unknown result type (might be due to invalid IL or missing references)
		//IL_024d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Unknown result type (might be due to invalid IL or missing references)
		//IL_025e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0260: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0305: 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_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_0340: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: 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_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0204: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_020b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0210: 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_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		Camera main = Camera.main;
		if ((Object)(object)main == (Object)null)
		{
			return;
		}
		kick = 1f;
		flashTimer = 0.05f;
		if ((Object)(object)flashObj != (Object)null)
		{
			flashObj.SetActive(true);
		}
		Build.Sound((w == 2) ? "shotgun" : "pistol", ((Component)main).transform.position, 0.8f);
		int num = ((w != 2) ? 1 : 8);
		float num2 = ((w == 2) ? 3.5f : 0.35f);
		float num3 = ((w == 2) ? 14f : 28f) * Extras.WeaponDamage.Value;
		Vector3 position = ((Component)main).transform.position;
		Transform val = muzzles[w];
		Vector3 a = (((Object)(object)val != (Object)null) ? val.position : (position + ((Component)main).transform.forward * 0.6f));
		Quaternion val2 = ((Component)main).transform.rotation;
		float num4 = Extras.AimAssist.Value;
		Robot robot = null;
		if (num4 > 0f)
		{
			RaycastHit val4 = default(RaycastHit);
			for (int i = 0; i < Robot.All.Count; i++)
			{
				Robot robot2 = Robot.All[i];
				if ((Object)(object)robot2 == (Object)null)
				{
					continue;
				}
				Vector3 val3 = ((Component)robot2).transform.position + Vector3.up * robot2.AimHeight - position;
				if (!(((Vector3)(ref val3)).magnitude > 70f))
				{
					float num5 = Vector3.Angle(((Component)main).transform.forward, val3);
					if (!(num5 >= num4) && (!Physics.Raycast(position, ((Vector3)(ref val3)).normalized, ref val4, ((Vector3)(ref val3)).magnitude, -1, (QueryTriggerInteraction)1) || !((Object)(object)((Component)((RaycastHit)(ref val4)).collider).GetComponentInParent<Robot>() == (Object)null) || Extras.IsPlayerCollider(((RaycastHit)(ref val4)).collider)))
					{
						num4 = num5;
						robot = robot2;
					}
				}
			}
			if ((Object)(object)robot != (Object)null)
			{
				val2 = Quaternion.LookRotation(((Component)robot).transform.position + Vector3.up * robot.AimHeight - position);
			}
		}
		for (int j = 0; j < num; j++)
		{
			Quaternion val5 = val2 * Quaternion.Euler(Random.Range(0f - num2, num2), Random.Range(0f - num2, num2), 0f);
			Vector3 val6 = val5 * Vector3.forward;
			Vector3 val7 = position + val6 * 80f;
			RaycastHit[] array = Physics.RaycastAll(position, val6, 80f, -1, (QueryTriggerInteraction)2);
			Array.Sort(array, (RaycastHit x, RaycastHit y) => ((RaycastHit)(ref x)).distance.CompareTo(((RaycastHit)(ref y)).distance));
			for (int num6 = 0; num6 < array.Length; num6++)
			{
				Collider collider = ((RaycastHit)(ref array[num6])).collider;
				if ((Object)(object)collider == (Object)null || Extras.IsPlayerCollider(collider))
				{
					continue;
				}
				Robot componentInParent = ((Component)collider).GetComponentInParent<Robot>();
				if ((Object)(object)componentInParent != (Object)null)
				{
					componentInParent.Damage(num3, val6);
					val7 = ((RaycastHit)(ref array[num6])).point;
					Build.Puff(val7, new Color(1f, 0.7f, 0.2f), 0.25f);
					break;
				}
				if (collider.isTrigger)
				{
					continue;
				}
				EnemyHealth componentInParent2 = ((Component)collider).GetComponentInParent<EnemyHealth>();
				if ((Object)(object)componentInParent2 != (Object)null)
				{
					try
					{
						componentInParent2.Hurt(Mathf.RoundToInt(num3), val6);
					}
					catch (Exception e)
					{
						Extras.LogOnce("EnemyHealth.Hurt", e);
					}
					Build.Sound("hit", ((RaycastHit)(ref array[num6])).point, 0.5f);
				}
				val7 = ((RaycastHit)(ref array[num6])).point;
				Build.Puff(val7, new Color(1f, 0.85f, 0.4f), 0.12f);
				break;
			}
			Build.Tracer(a, val7, new Color(1f, 0.85f, 0.35f), 0.025f, 0.06f);
		}
	}

	private static void EnsureModel()
	{
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Expected O, but got Unknown
		//IL_0088: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_0189: Unknown result type (might be due to invalid IL or missing references)
		Camera main = Camera.main;
		if ((Object)(object)main == (Object)null)
		{
			return;
		}
		if ((Object)(object)holder == (Object)null || (Object)(object)mountCam != (Object)(object)main)
		{
			if ((Object)(object)holder != (Object)null)
			{
				Object.Destroy((Object)(object)holder);
			}
			mountCam = main;
			holder = new GameObject("ArcWeaponHolder");
			holder.transform.SetParent(((Component)main).transform, false);
			holder.transform.localPosition = new Vector3(0.2f, -0.17f, 0.62f);
			models[1] = BuildPistol(holder.transform, out muzzles[1]);
			models[2] = BuildShotgun(holder.transform, out muzzles[2]);
			flashObj = Build.Part(holder.transform, (PrimitiveType)0, Vector3.zero, Vector3.one * 0.09f, new Color(1f, 0.8f, 0.3f), 6f);
			flashObj.SetActive(false);
		}
		holder.SetActive(true);
		models[1].SetActive(current == 1);
		models[2].SetActive(current == 2);
		if ((Object)(object)flashObj != (Object)null && (Object)(object)muzzles[current] != (Object)null)
		{
			flashObj.transform.position = muzzles[current].position;
		}
	}

	private static void AnimateModel(float dt)
	{
		//IL_008b: 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_00a3: 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_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_00ff: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)holder == (Object)null))
		{
			float num = 0f;
			if (reloading)
			{
				num = Mathf.Sin(Mathf.Clamp01(1f - reloadTimer / Mathf.Max(0.01f, reloadTime[current])) * (float)Math.PI);
			}
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(0.2f, -0.17f - num * 0.18f, 0.62f - kick * 0.07f);
			holder.transform.localPosition = Vector3.Lerp(holder.transform.localPosition, val, 1f - Mathf.Exp(-25f * dt));
			Quaternion val2 = Quaternion.Euler((0f - kick) * 6f + num * 35f, 0f, num * -10f);
			holder.transform.localRotation = Quaternion.Slerp(holder.transform.localRotation, val2, 1f - Mathf.Exp(-25f * dt));
		}
	}

	private static GameObject BuildPistol(Transform parent, out Transform muzzle)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_0070: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: 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_0117: Expected O, but got Unknown
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("Pistol");
		val.transform.SetParent(parent, false);
		Color c = default(Color);
		((Color)(ref c))..ctor(0.32f, 0.34f, 0.38f);
		Color c2 = default(Color);
		((Color)(ref c2))..ctor(0.6f, 0.62f, 0.66f);
		Color c3 = default(Color);
		((Color)(ref c3))..ctor(1f, 0.45f, 0.08f);
		Build.Part(val.transform, (PrimitiveType)3, new Vector3(0f, 0f, 0.05f), new Vector3(0.05f, 0.07f, 0.28f), c2, 0.3f);
		Build.Part(val.transform, (PrimitiveType)3, new Vector3(0f, -0.075f, -0.03f), new Vector3(0.045f, 0.12f, 0.06f), c, 0.3f);
		Build.Part(val.transform, (PrimitiveType)3, new Vector3(0f, 0.045f, 0.06f), new Vector3(0.03f, 0.015f, 0.24f), c3, 1.2f);
		GameObject val2 = new GameObject("Muzzle");
		val2.transform.SetParent(val.transform, false);
		val2.transform.localPosition = new Vector3(0f, 0f, 0.2f);
		muzzle = val2.transform;
		return val;
	}

	private static GameObject BuildShotgun(Transform parent, out Transform muzzle)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_0070: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: 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_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Expected O, but got Unknown
		//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("Shotgun");
		val.transform.SetParent(parent, false);
		Color c = default(Color);
		((Color)(ref c))..ctor(0.32f, 0.34f, 0.38f);
		Color c2 = default(Color);
		((Color)(ref c2))..ctor(0.62f, 0.64f, 0.68f);
		Color c3 = default(Color);
		((Color)(ref c3))..ctor(1f, 0.45f, 0.08f);
		Build.Part(val.transform, (PrimitiveType)3, new Vector3(0f, 0f, 0.15f), new Vector3(0.06f, 0.08f, 0.55f), c2, 0.3f);
		Build.Part(val.transform, (PrimitiveType)2, new Vector3(0f, 0.01f, 0.4f), new Vector3(0.05f, 0.18f, 0.05f), c, 0.3f).transform.localRotation = Quaternion.Euler(90f, 0f, 0f);
		Build.Part(val.transform, (PrimitiveType)3, new Vector3(0f, -0.07f, 0.28f), new Vector3(0.07f, 0.05f, 0.18f), c, 0.3f);
		Build.Part(val.transform, (PrimitiveType)3, new Vector3(0f, -0.08f, -0.08f), new Vector3(0.05f, 0.12f, 0.1f), c, 0.3f);
		Build.Part(val.transform, (PrimitiveType)3, new Vector3(0f, 0.05f, 0.1f), new Vector3(0.03f, 0.015f, 0.4f), c3, 1.2f);
		GameObject val2 = new GameObject("Muzzle");
		val2.transform.SetParent(val.transform, false);
		val2.transform.localPosition = new Vector3(0f, 0.01f, 0.6f);
		muzzle = val2.transform;
		return val;
	}

	internal static void OnGui()
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Expected O, but got Unknown
		//IL_0055: 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_0079: Expected O, but got Unknown
		//IL_009c: 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_00c9: 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_00fd: 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_01cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Expected O, but got Unknown
		//IL_020e: Unknown result type (might be due to invalid IL or missing references)
		if (Extras.WeaponsEnabled.Value && Extras.InLevelWorld())
		{
			if (style == null)
			{
				style = new GUIStyle();
				style.fontSize = 22;
				style.fontStyle = (FontStyle)1;
				style.normal.textColor = new Color(1f, 0.6f, 0.15f);
			}
			if (helpTimer > 0f)
			{
				GUIStyle val = new GUIStyle(style);
				val.fontSize = 16;
				GUI.Label(new Rect(20f, (float)Screen.height - 70f, 700f, 24f), Extras.KeyName(Extras.PistolKey.Value) + " = pistol,  " + Extras.KeyName(Extras.ShotgunKey.Value) + " = shotgun,  " + Extras.KeyName(Extras.ReloadKey.Value) + " = reload,  " + Extras.KeyName(Extras.SlideKey.Value) + " = slide", val);
			}
			if (current != 0)
			{
				string text = names[current] + "   " + mag[current] + " / " + reserve[current] + (reloading ? "   RELOADING" : "");
				GUI.Label(new Rect((float)Screen.width - 380f, (float)Screen.height - 70f, 360f, 30f), text, style);
				GUIStyle val2 = new GUIStyle(style);
				val2.alignment = (TextAnchor)4;
				val2.fontSize = 18;
				GUI.Label(new Rect((float)Screen.width * 0.5f - 15f, (float)Screen.height * 0.5f - 15f, 30f, 30f), "+", val2);
			}
		}
	}
}
internal static class Robots
{
	private static object lastLevel;

	private static bool spawned;

	private static float delay;

	private static bool warnedMulti;

	internal static void Update()
	{
		if (!Extras.RobotsEnabled.Value)
		{
			return;
		}
		if (!Extras.InLevelWorld() || !SemiFunc.RunIsLevel() || SemiFunc.RunIsArena())
		{
			lastLevel = null;
			return;
		}
		if (SemiFunc.IsMultiplayer())
		{
			if (!warnedMulti)
			{
				warnedMulti = true;
				Extras.Log.LogInfo((object)"Robots: multiplayer detected, robots are singleplayer-only and stay disabled.");
			}
			return;
		}
		LevelGenerator instance = LevelGenerator.Instance;
		if ((Object)(object)instance == (Object)null || !instance.Generated)
		{
			return;
		}
		if (!object.ReferenceEquals(instance, lastLevel))
		{
			lastLevel = instance;
			spawned = false;
			delay = 5f;
		}
		if (!spawned)
		{
			delay -= Time.deltaTime;
			if (!(delay > 0f))
			{
				spawned = true;
				SpawnAll();
			}
		}
	}

	internal static void SpawnNearPlayer()
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_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_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		PlayerController instance = PlayerController.instance;
		Camera main = Camera.main;
		if (!((Object)(object)instance == (Object)null) && !((Object)(object)main == (Object)null))
		{
			Vector3 forward = ((Component)main).transform.forward;
			forward.y = 0f;
			if (((Vector3)(ref forward)).sqrMagnitude < 0.01f)
			{
				forward = Vector3.forward;
			}
			((Vector3)(ref forward)).Normalize();
			Vector3 val = Vector3.Cross(Vector3.up, forward);
			Vector3 val2 = ((Component)instance).transform.position + forward * 8f;
			Vector3 val3 = val2 + val * 2f;
			NavMeshHit val4 = default(NavMeshHit);
			if (NavMesh.SamplePosition(val3, ref val4, 6f, -1))
			{
				val3 = ((NavMeshHit)(ref val4)).position;
			}
			Drone.Create(val2 - val * 2f + Vector3.up * 2f);
			Crawler.Create(val3);
			Extras.Log.LogInfo((object)"Robots: spawned a drone and a crawler near the player.");
		}
	}

	private static void SpawnAll()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: 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_0055: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		PlayerController instance = PlayerController.instance;
		if ((Object)(object)instance == (Object)null)
		{
			return;
		}
		Vector3 position = ((Component)instance).transform.position;
		List<Vector3> list = new List<Vector3>();
		LevelPoint[] array = Object.FindObjectsByType<LevelPoint>((FindObjectsSortMode)0);
		for (int i = 0; i < array.Length; i++)
		{
			if (!((Object)(object)array[i] == (Object)null) && !array[i].Truck)
			{
				Vector3 position2 = ((Component)array[i]).transform.position;
				float num = Vector3.Distance(position2, position);
				if (num > 22f && num < 160f)
				{
					list.Add(position2);
				}
			}
		}
		int num2 = Mathf.Max(0, Extras.DroneCount.Value);
		int num3 = Mathf.Max(0, Extras.CrawlerCount.Value);
		int num4 = 0;
		NavMeshHit val3 = default(NavMeshHit);
		for (int j = 0; j < num2 + num3; j++)
		{
			Vector3 val;
			if (list.Count > 0)
			{
				val = list[Random.Range(0, list.Count)];
			}
			else
			{
				Vector2 insideUnitCircle = Random.insideUnitCircle;
				Vector2 val2 = ((Vector2)(ref insideUnitCircle)).normalized * Random.Range(22f, 40f);
				val = position + new Vector3(val2.x, 0f, val2.y);
			}
			if (NavMesh.SamplePosition(val, ref val3, 6f, -1))
			{
				val = ((NavMeshHit)(ref val3)).position;
			}
			if (j < num2)
			{
				Drone.Create(val + Vector3.up * 1.8f);
			}
			else
			{
				Crawler.Create(val);
			}
			num4++;
		}
		Extras.Log.LogInfo((object)("Robots: spawned " + num4 + " (" + num2 + " drones, " + num3 + " crawlers)."));
	}
}
internal abstract class Robot : MonoBehaviour
{
	internal static readonly List<Robot> All = new List<Robot>();

	internal float Health = 50f;

	protected Vector3 baseScale = Vector3.one;

	private float punch;

	private bool dead;

	internal virtual float AimHeight => 0.6f;

	protected virtual void Awake()
	{
		All.Add(this);
	}

	private void OnDestroy()
	{
		All.Remove(this);
	}

	internal void Damage(float amount, Vector3 dir)
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		if (!dead)
		{
			Health -= amount;
			punch = 1f;
			Build.Sound("hit", ((Component)this).transform.position, 0.6f);
			OnHurt(dir);
			if (Health <= 0f)
			{
				Die();
			}
		}
	}

	protected virtual void OnHurt(Vector3 dir)
	{
	}

	private void Die()
	{
		//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_001c: 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_0035: 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)
		dead = true;
		Build.Puff(((Component)this).transform.position + Vector3.up * 0.5f, new Color(1f, 0.5f, 0.1f), 1.6f);
		Build.Sound("boom", ((Component)this).transform.position, 1f);
		Object.Destroy((Object)(object)((Component)this).gameObject);
	}

	private void Update()
	{
		//IL_0040: 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)
		if (dead)
		{
			return;
		}
		float deltaTime = Time.deltaTime;
		if (punch > 0f)
		{
			punch = Mathf.MoveTowards(punch, 0f, deltaTime * 6f);
			((Component)this).transform.localScale = baseScale * (1f + 0.12f * punch);
		}
		try
		{
			Tick(deltaTime);
		}
		catch (Exception e)
		{
			Extras.LogOnce(((object)this).GetType().Name + ".Tick", e);
		}
	}

	protected abstract void Tick(float dt);

	protected bool HasLineOfSight(Vector3 from, Vector3 to)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		RaycastHit val = default(RaycastHit);
		if (Physics.Linecast(from, to, ref val, -1, (QueryTriggerInteraction)1))
		{
			return Extras.IsPlayerCollider(((RaycastHit)(ref val)).collider);
		}
		return true;
	}
}
internal sealed class Drone : Robot
{
	private Transform ring;

	private Transform eye;

	private Vector3 vel;

	private float shootTimer = 3f;

	private float orbit = 1f;

	private float orbitTimer = 3f;

	private float windup;

	internal override float AimHeight => 0f;

	internal static void Create(Vector3 pos)
	{
		//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_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_009b: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: 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_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: 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_0185: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0225: Unknown result type (might be due to invalid IL or missing references)
		//IL_022a: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("ArcSentryDrone");
		val.transform.position = pos;
		Color c = default(Color);
		((Color)(ref c))..ctor(0.16f, 0.17f, 0.2f);
		Color c2 = default(Color);
		((Color)(ref c2))..ctor(0.32f, 0.34f, 0.38f);
		Color c3 = default(Color);
		((Color)(ref c3))..ctor(1f, 0.42f, 0.05f);
		Build.Part(val.transform, (PrimitiveType)0, Vector3.zero, new Vector3(0.9f, 0.55f, 0.9f), c, 0f);
		Build.Part(val.transform, (PrimitiveType)0, new Vector3(0f, 0.18f, 0f), new Vector3(0.55f, 0.3f, 0.55f), c2, 0f);
		GameObject val2 = Build.Part(val.transform, (PrimitiveType)2, Vector3.zero, new Vector3(1.25f, 0.025f, 1.25f), c3, 1.4f);
		GameObject val3 = Build.Part(val.transform, (PrimitiveType)0, new Vector3(0f, 0.02f, 0.4f), new Vector3(0.22f, 0.22f, 0.22f), new Color(1f, 0.1f, 0.05f), 3f);
		for (int i = 0; i < 4; i++)
		{
			float num = 45f + 90f * (float)i;
			Vector3 pos2 = Quaternion.Euler(0f, num, 0f) * new Vector3(0f, -0.1f, 0.5f);
			Build.Part(val.transform, (PrimitiveType)2, pos2, new Vector3(0.14f, 0.05f, 0.14f), c3, 2.2f);
		}
		SphereCollider val4 = val.AddComponent<SphereCollider>();
		((Collider)val4).isTrigger = true;
		val4.radius = 0.55f;
		Drone drone = val.AddComponent<Drone>();
		drone.Health = 45f;
		drone.ring = val2.transform;
		drone.eye = val3.transform;
		drone.orbit = ((Random.value > 0.5f) ? 1f : (-1f));
		drone.baseScale = val.transform.localScale;
	}

	protected override void Tick(float dt)
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0152: 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_00fd: 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_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_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: 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_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_026e: Unknown result type (might be due to invalid IL or missing references)
		//IL_026f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0271: Unknown result type (might be due to invalid IL or missing references)
		//IL_0210: Unknown result type (might be due to invalid IL or missing references)
		//IL_0218: Unknown result type (might be due to invalid IL or missing references)
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_023e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0243: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_024e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Unknown result type (might be due to invalid IL or missing references)
		//IL_0291: Unknown result type (might be due to invalid IL or missing references)
		//IL_0288: Unknown result type (might be due to invalid IL or missing references)
		//IL_0326: Unknown result type (might be due to invalid IL or missing references)
		//IL_0330: Unknown result type (might be due to invalid IL or missing references)
		//IL_0337: Unknown result type (might be due to invalid IL or missing references)
		//IL_0341: Unknown result type (might be due to invalid IL or missing references)
		//IL_0296: Unknown result type (might be due to invalid IL or missing references)
		//IL_029b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0361: Unknown result type (might be due to invalid IL or missing references)
		//IL_036b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0376: Unknown result type (might be due to invalid IL or missing references)
		//IL_039a: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03af: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
		ring.Rotate(0f, 140f * dt, 0f, (Space)1);
		Vector3 pos;
		bool playerTarget = Extras.GetPlayerTarget(out pos);
		Vector3 position = ((Component)this).transform.position;
		Vector3 val = pos - position;
		Vector3 val2 = default(Vector3);
		((Vector3)(ref val2))..ctor(val.x, 0f, val.z);
		float magnitude = ((Vector3)(ref val2)).magnitude;
		Vector3 val3 = ((magnitude > 0.01f) ? (val2 / magnitude) : ((Component)this).transform.forward);
		bool flag = playerTarget && ((Vector3)(ref val)).magnitude < 45f;
		Vector3 val4 = Vector3.zero;
		if (flag)
		{
			orbitTimer -= dt;
			if (orbitTimer <= 0f)
			{
				orbit = 0f - orbit;
				orbitTimer = Random.Range(2.5f, 5f);
			}
			float num = Mathf.Clamp((magnitude - 7f) * 0.8f, -3f, 5f);
			val4 = val3 * num + Vector3.Cross(Vector3.up, val3) * orbit * 2.2f;
		}
		float num2 = position.y - 4f;
		RaycastHit val5 = default(RaycastHit);
		if (Physics.Raycast(position + Vector3.up * 0.5f, Vector3.down, ref val5, 10f, -1, (QueryTriggerInteraction)1))
		{
			num2 = ((RaycastHit)(ref val5)).point.y;
		}
		float num3 = num2 + (flag ? 1.7f : 1.9f) + Mathf.Sin(Time.time * 1.7f + (float)((Object)this).GetInstanceID()) * 0.15f;
		val4.y = Mathf.Clamp((num3 - position.y) * 2f, -3f, 3f);
		vel = Vector3.Lerp(vel, val4, 1f - Mathf.Exp(-3f * dt));
		Vector3 val6 = vel * dt;
		RaycastHit val7 = default(RaycastHit);
		if (((Vector3)(ref val6)).sqrMagnitude > 1E-06f && Physics.SphereCast(position, 0.4f, ((Vector3)(ref val6)).normalized, ref val7, ((Vector3)(ref val6)).magnitude + 0.15f, -1, (QueryTriggerInteraction)1))
		{
			vel = Vector3.ProjectOnPlane(vel, ((RaycastHit)(ref val7)).normal);
			val6 = vel * dt;
			orbit = 0f - orbit;
		}
		((Component)this).transform.position = position + val6;
		if (playerTarget)
		{
			Quaternion val8 = Quaternion.LookRotation(flag ? ((Vector3)(ref val)).normalized : ((Component)this).transform.forward, Vector3.up);
			((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, val8, 1f - Mathf.Exp(-5f * dt));
		}
		if (!flag)
		{
			return;
		}
		shootTimer -= dt;
		if (windup > 0f)
		{
			windup -= dt;
			float num4 = 1f + 0.5f * Mathf.Sin(Time.time * 40f);
			eye.localScale = Vector3.one * 0.22f * num4 * 1.4f;
			if (windup <= 0f)
			{
				eye.localScale = Vector3.one * 0.22f;
				FireAt(pos);
			}
		}
		else if (shootTimer <= 0f && magnitude < 38f && HasLineOfSight(((Component)this).transform.position + ((Component)this).transform.forward * 0.4f, pos))
		{
			windup = 0.7f;
			shootTimer = Random.Range(3f, 4.5f);
		}
	}

	private void FireAt(Vector3 tp)
	{
		//IL_0006: 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_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_0025: Unknown result type (might be due to invalid IL or