Decompiled source of RecurveBow v0.0.3

RecurveBow.dll

Decompiled 21 hours ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Agents;
using AssetShards;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using Enemies;
using FluffyUnderware.DevTools.Extensions;
using GTFO.API;
using GameData;
using Gear;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Localization;
using Microsoft.CodeAnalysis;
using Player;
using SNetwork;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("RecurveBow")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RecurveBow")]
[assembly: AssemblyTitle("RecurveBow")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace RecurveBow
{
	public class ArrowHandler : MonoBehaviour
	{
		public static PlayerAgent owner;

		public static int slot;

		public Vector3 position;

		public Vector3 startpos;

		public Vector3 direction;

		public Vector3 target;

		public float speed = 0.7f;

		public MeleeWeaponFirstPerson weapon;

		public MeleeWeaponThirdPerson weapontp;

		public CellSoundPlayer audio;

		public GameObject arrowtip = new GameObject();

		public GameObject arrow = new GameObject();

		private float shoottime;

		private bool isprop;

		private bool isbuilt;

		private float soundendtime;

		public int status;

		public Vector3 velocity = Vector3.zero;

		public bool enemyhit;

		public Agent hitagent;

		public bool proparrowbuilt;

		public int arrowindex;

		public int myslot;

		public static GameObject Build(bool isprop)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_0082: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)2);
			val.GetComponent<Collider>().enabled = false;
			Object.Destroy((Object)(object)val.GetComponent<Collider>());
			((Object)val).name = "Bow_Arrow";
			MeshRenderer component = val.GetComponent<MeshRenderer>();
			((Renderer)component).sharedMaterial = new Material(Shader.Find("GTFO/Standard"));
			((Renderer)component).sharedMaterial.shader = Shader.Find("Cell/Player/CustomGearShader");
			((Renderer)component).sharedMaterial.SetTexture("_MainTex", (Texture)(object)Texture2D.redTexture);
			val.transform.localPosition = new Vector3(0f, 0f, 0f);
			val.transform.localScale = new Vector3(0.01f, 1.3f, 0.005f);
			val.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
			GameObject obj = Object.Instantiate<GameObject>(((Component)AssetAPI.GetLoadedAsset<GameObject>("Assets/AssetPrefabs/Items/Gear/Parts/Melee/Heads/Head_Spear_1.prefab").GetComponentInChildren<MeshRenderer>()).gameObject);
			Object.Destroy((Object)(object)obj.GetComponent<Collider>());
			obj.transform.parent = val.transform;
			((Object)obj).name = "Arrow_Tip";
			obj.transform.localEulerAngles = new Vector3(270f, 0f, 0f);
			obj.transform.localScale = new Vector3(19.1f, 20f, 1f);
			obj.transform.localPosition = new Vector3(0f, 0.9f, 0f);
			return val;
		}

		public void Shoot()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_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_00ec: 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_0134: 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_0159: Expected O, but got Unknown
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Expected O, but got Unknown
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Expected O, but got Unknown
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: 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_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0429: Unknown result type (might be due to invalid IL or missing references)
			//IL_0434: Unknown result type (might be due to invalid IL or missing references)
			if (speed < 0.7f)
			{
				speed = 0.7f;
			}
			((Component)this).transform.localScale = new Vector3(0.3f, 0.3f, 0.6f);
			((Component)this).transform.position = position;
			((Component)this).transform.LookAt(target, ((Component)this).transform.up);
			Transform transform = ((Component)this).transform;
			transform.position += ((Component)this).transform.forward * 0.5f;
			arrow = GameObject.CreatePrimitive((PrimitiveType)2);
			arrow.transform.parent = ((Component)this).transform;
			arrow.GetComponent<Collider>().enabled = false;
			Object.Destroy((Object)(object)arrow.GetComponent<Collider>());
			arrow.transform.localPosition = new Vector3(0f, 0f, 0f);
			arrow.transform.localScale = new Vector3(0.05f, 1f, 0.05f);
			arrow.transform.localEulerAngles = new Vector3(90f, 0f, 0f);
			((Object)arrow).name = "Flying_Arrow";
			audio = new CellSoundPlayer();
			if ((Object)(object)weapon != (Object)null)
			{
				((ItemEquippable)weapon).Sound.Post(803249283u, true);
			}
			if ((Object)(object)weapontp != (Object)null)
			{
				((ItemEquippable)weapontp).Sound.Post(803249283u, true);
			}
			audio.UpdatePosition(((Component)this).transform.position);
			audio.Post(2470408129u, true);
			MeshRenderer component = arrow.GetComponent<MeshRenderer>();
			((Renderer)component).sharedMaterial = new Material(Shader.Find("GTFO/Standard"));
			((Renderer)component).sharedMaterial.shader = Shader.Find("Cell/Player/CustomGearShader");
			if ((Object)(object)weapon != (Object)null)
			{
				((Renderer)component).sharedMaterial.SetTexture("_MainTex", (Texture)(object)Texture2D.redTexture);
			}
			if ((Object)(object)weapontp != (Object)null)
			{
				((Renderer)component).sharedMaterial.SetTexture("_MainTex", (Texture)(object)Texture2D.grayTexture);
			}
			GameObject loadedAsset = AssetAPI.GetLoadedAsset<GameObject>("Assets/AssetPrefabs/Items/Gear/Parts/Melee/Heads/Head_Spear_1.prefab");
			arrowtip = Object.Instantiate<GameObject>(((Component)loadedAsset.GetComponentInChildren<MeshRenderer>()).gameObject);
			Object.Destroy((Object)(object)arrowtip.GetComponent<Collider>());
			((Renderer)arrowtip.GetComponentInChildren<MeshRenderer>()).sharedMaterial = new Material(Shader.Find("GTFO/Standard"));
			((Renderer)arrowtip.GetComponentInChildren<MeshRenderer>()).sharedMaterial.shader = Shader.Find("Cell/Player/CustomGearShader");
			arrowtip.transform.parent = arrow.transform;
			arrowtip.transform.localPosition = new Vector3(0f, 0.9f, 0f);
			arrowtip.transform.localEulerAngles = new Vector3(270f, 0f, 0f);
			((Object)arrowtip).name = "Arrow_Tip";
			arrowtip.transform.localScale = new Vector3(19.1f, 20f, 1f);
			shoottime = Time.time;
			startpos = position;
			((Component)this).transform.position = position;
			status = 1;
			velocity = ((Component)this).transform.forward + direction * (speed * 48f);
			Light obj = arrow.AddComponent<Light>();
			obj.range = 1f;
			obj.intensity = 0.6f;
			isbuilt = true;
			if ((Object)(object)weapon != (Object)null)
			{
				Plugin.arrowindex++;
			}
			if ((Object)(object)weapon != (Object)null)
			{
				arrowindex = Plugin.arrowindex;
			}
			if ((Object)(object)weapon != (Object)null)
			{
				NetworkAPI.InvokeEvent<Plugin.ArrowNetInfo>("ArrowNetInfo", new Plugin.ArrowNetInfo(arrowindex, myslot, ((Component)this).transform.position, ((Component)this).transform.forward, speed, 0, 0u), (SNet_ChannelType)2);
			}
		}

		public void FixedUpdate()
		{
			//IL_009b: 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_00e3: 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_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06df: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_070a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0710: Unknown result type (might be due to invalid IL or missing references)
			//IL_071a: Unknown result type (might be due to invalid IL or missing references)
			//IL_071f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0735: Unknown result type (might be due to invalid IL or missing references)
			//IL_073a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: 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_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: 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_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			//IL_045b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0461: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_050a: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e9: Expected O, but got Unknown
			//IL_0560: Unknown result type (might be due to invalid IL or missing references)
			//IL_0567: Unknown result type (might be due to invalid IL or missing references)
			//IL_0572: Unknown result type (might be due to invalid IL or missing references)
			//IL_0577: Unknown result type (might be due to invalid IL or missing references)
			//IL_057c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0580: Unknown result type (might be due to invalid IL or missing references)
			//IL_060e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0613: Unknown result type (might be due to invalid IL or missing references)
			//IL_0632: Unknown result type (might be due to invalid IL or missing references)
			//IL_063d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0648: Unknown result type (might be due to invalid IL or missing references)
			//IL_064f: Unknown result type (might be due to invalid IL or missing references)
			//IL_065f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0664: Unknown result type (might be due to invalid IL or missing references)
			//IL_068d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0693: Unknown result type (might be due to invalid IL or missing references)
			if (isprop || !isbuilt)
			{
				return;
			}
			if (enemyhit && !hitagent.Alive && !proparrowbuilt)
			{
				Object.Destroy((Object)(object)arrow);
				arrow = Object.Instantiate<GameObject>(Build(isprop: true));
				arrow.AddComponent<Light>().range = 1f;
				((Object)arrow).name = "Arrow_Prop";
				arrow.transform.parent = ((Component)this).transform;
				((Component)this).transform.position = hitagent.Position;
				arrow.transform.localPosition = new Vector3(0f, 0f, 0f);
				arrow.transform.localScale = new Vector3(0.05f, 2f, 0.05f);
				proparrowbuilt = true;
				status = 3;
				if ((Object)(object)weapon != (Object)null)
				{
					NetworkAPI.InvokeEvent<Plugin.ArrowNetInfo>("ArrowNetInfo", new Plugin.ArrowNetInfo(arrowindex, myslot, ((Component)this).transform.position, velocity, speed, 3, 0u), (SNet_ChannelType)2);
				}
			}
			if (enemyhit && (Object)(object)arrow != (Object)null && !proparrowbuilt)
			{
				((Component)this).transform.position = arrow.transform.position;
			}
			if (status == 3)
			{
				if (audio != null)
				{
					audio.Recycle();
					audio = null;
				}
				if ((Object)(object)weapon != (Object)null && Vector3.Distance(((Agent)((Item)weapon).Owner).Position, ((Component)this).transform.position) < 2.5f)
				{
					BowHandlerFP component = ((Component)weapon).GetComponent<BowHandlerFP>();
					if ((Object)(object)component != (Object)null)
					{
						component.inbackabs++;
						GuiManager.PlayerLayer.Inventory.SetSlotAmmo((InventorySlot)10, 1, component.inbackabs, component.inbackrel);
						NetworkAPI.InvokeEvent<Plugin.ArrowNetInfo>("ArrowNetInfo", new Plugin.ArrowNetInfo(arrowindex, myslot, ((Component)this).transform.position, velocity, speed, 5, 0u), (SNet_ChannelType)2);
						pPlayerData_Session session = SNet.LocalPlayer.Session;
						NetworkAPI.InvokeEvent<Plugin.BowNetInfo>("BowNetInfo", new Plugin.BowNetInfo(0, ((pPlayerData_Session)(ref session)).playerSlotIndex, component.inbackabs), (SNet_ChannelType)2);
						Object.Destroy((Object)(object)arrowtip);
						Object.Destroy((Object)(object)arrow);
						Object.Destroy((Object)(object)this);
					}
				}
			}
			if (Time.time - shoottime > 10f && status < 3)
			{
				if (audio != null)
				{
					audio.Stop();
					audio.Recycle();
				}
				speed = 0f;
				velocity = Vector3.zero;
				status = 3;
			}
			else
			{
				if (status > 2)
				{
					return;
				}
				if (status == 2)
				{
					audio.Stop();
					audio.Recycle();
					status = 3;
					return;
				}
				if ((Object)(object)weapon != (Object)null)
				{
					Ray val = default(Ray);
					((Ray)(ref val))..ctor(((Component)this).transform.position + ((Component)this).transform.forward * 1f, ((Component)this).transform.forward);
					RaycastHit val2 = default(RaycastHit);
					if (Physics.Raycast(val, ref val2, 2.5f, LayerManager.MASK_PING_TARGET, (QueryTriggerInteraction)1) || Physics.Raycast(val, ref val2, 2.5f, LayerManager.MASK_GLUEGUN_TARGETS, (QueryTriggerInteraction)1) || Physics.CapsuleCast(((Component)this).transform.position, ((Component)this).transform.position + ((Component)this).transform.forward * 1.2f, 0.04f, ((Component)this).transform.forward, ref val2, 2f, LayerManager.MASK_GLUEGUN_TARGETS, (QueryTriggerInteraction)1))
					{
						Collider collider = ((RaycastHit)(ref val2)).collider;
						Vector3 val3 = ((Component)collider).transform.position - ((RaycastHit)(ref val2)).point - ((Component)this).transform.position;
						_ = ((Vector3)(ref val3)).normalized;
						hitagent = ((Component)collider).GetComponentInParent<Agent>();
						if ((Object)(object)hitagent != (Object)null)
						{
							NetworkAPI.InvokeEvent<Plugin.ArrowNetInfo>("ArrowNetInfo", new Plugin.ArrowNetInfo(arrowindex, myslot, ((Component)this).transform.position, velocity, speed, 4, (uint)(hitagent.m_replicator.Key + 1)), (SNet_ChannelType)2);
							enemyhit = true;
							arrow.transform.SetParent(((Component)collider).transform);
							arrow.transform.localPosition = new Vector3(0f, 0f, 0f);
							arrow.transform.localEulerAngles = new Vector3(0f, 0f, 180f);
							arrow.transform.localScale = new Vector3(0.01f, 0.3f, 0.01f);
						}
						IDamageable val4 = null;
						ColliderMaterial component2 = ((Component)collider).GetComponent<ColliderMaterial>();
						if ((Object)(object)component2 != (Object)null)
						{
							val4 = component2.Damageable;
						}
						if (val4 == null)
						{
							val4 = ((Component)collider).GetComponent<IDamageable>();
						}
						if (val4 != null)
						{
							IDamageable obj = val4;
							float num = speed * (float)Plugin._BowMaxDamage;
							PlayerAgent obj2 = ((Item)weapon).Owner;
							Vector3 point = ((RaycastHit)(ref val2)).point;
							val3 = ((RaycastHit)(ref val2)).point - ((Component)this).transform.position;
							obj.MeleeDamage(num, (Agent)(object)obj2, point, ((Vector3)(ref val3)).normalized, 1f, 1f, 1f, 1f, 1f, false, (DamageNoiseLevel)1, 0u);
						}
						else
						{
							weapon.DoAttackDamage(new MeleeWeaponDamageData
							{
								damageGO = ((Component)((RaycastHit)(ref val2)).collider).gameObject,
								hitPos = ((RaycastHit)(ref val2)).point,
								sourcePos = ((Component)this).transform.position
							}, false);
						}
						audio.Post(3762526143u, true);
						soundendtime = Time.time;
						status = 2;
						velocity = Vector3.zero;
						speed = 0f;
						if (!enemyhit)
						{
							Transform transform = ((Component)this).transform;
							transform.position += ((Component)this).transform.forward * (Vector3.Distance(((Component)this).transform.position, ((RaycastHit)(ref val2)).point) - 0.5f);
						}
						if (!enemyhit)
						{
							NetworkAPI.InvokeEvent<Plugin.ArrowNetInfo>("ArrowNetInfo", new Plugin.ArrowNetInfo(arrowindex, myslot, ((Component)this).transform.position, velocity, speed, 2, 0u), (SNet_ChannelType)2);
						}
						return;
					}
				}
				Transform transform2 = ((Component)this).transform;
				transform2.position += velocity * Time.fixedDeltaTime;
				velocity += ((Component)this).transform.up * (-9.81f * Time.fixedDeltaTime);
				((Component)this).transform.LookAt(((Component)this).transform.position + velocity * Time.fixedDeltaTime);
				audio.UpdatePosition(((Component)this).transform.position);
			}
		}

		public ArrowHandler()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			pPlayerData_Session session = SNet.LocalPlayer.Session;
			myslot = ((pPlayerData_Session)(ref session)).playerSlotIndex;
			((MonoBehaviour)this)..ctor();
		}
	}
	internal class BowCreator : MonoBehaviour
	{
		public static GameObject Build()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_002e: 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_007a: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0622: Unknown result type (might be due to invalid IL or missing references)
			//IL_062c: Expected O, but got Unknown
			//IL_066a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0689: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject();
			((Object)val).hideFlags = (HideFlags)61;
			val.layer = LayerManager.LAYER_FIRST_PERSON_ITEM;
			val.transform.position = new Vector3(0f, 1000f, 0f);
			string path = Path.Combine(Paths.ConfigPath, "../Assets/RecurveBow/recurvebow1.png");
			if (!File.Exists(path))
			{
				Debug.Log(Object.op_Implicit("RecurveBow - cant find bow image"));
				return null;
			}
			byte[] array = File.ReadAllBytes(path);
			Texture2D val2 = new Texture2D(237, 693, (TextureFormat)5, false);
			ImageConversion.LoadImage(val2, Il2CppStructArray<byte>.op_Implicit(array));
			Dictionary<int, int> dictionary = new Dictionary<int, int>();
			Dictionary<int, int> dictionary2 = new Dictionary<int, int>();
			List<Vector3> list = new List<Vector3>();
			new List<Vector3>();
			List<Vector2> list2 = new List<Vector2>();
			bool flag = false;
			List<int> list3 = new List<int>();
			for (int i = 0; i < 693; i += 5)
			{
				for (int j = 0; j < 237; j++)
				{
					if (flag && j == 0)
					{
						flag = false;
					}
					if (!flag && val2.GetPixel(j, i).a != 0f)
					{
						dictionary[i] = j;
						flag = true;
					}
					if (flag && val2.GetPixel(j, i).a == 0f)
					{
						dictionary2[i] = j - 1;
						flag = false;
					}
				}
			}
			Debug.Log(Object.op_Implicit($"RecurveBow - rowstart {dictionary.Count} rowend {dictionary2.Count}"));
			float num = 0.02f;
			_ = 1 / dictionary2.Count();
			foreach (KeyValuePair<int, int> item in dictionary2)
			{
				if (!dictionary.ContainsKey(item.Key))
				{
					Debug.Log(Object.op_Implicit($"RecurveBow - rivi {item.Key} ei loydy"));
					continue;
				}
				float num2 = (float)item.Key / 693f - 0.5f;
				float num3 = (float)dictionary[item.Key] / 237f - 0.48f;
				float num4 = (float)dictionary2[item.Key] / 237f - 0.48f;
				list.Add(new Vector3(num, num2, num3));
				list2.Add(new Vector2(num3, num2));
				list.Add(new Vector3(num, num2, num3));
				list2.Add(new Vector2(num3, num2));
				list.Add(new Vector3(num, num2, num4));
				list2.Add(new Vector2(num4, num2));
				list.Add(new Vector3(num, num2, num4));
				list2.Add(new Vector2(num4, num2));
				list.Add(new Vector3(num - 0.04f, num2, num3));
				list2.Add(new Vector2(num3, num2));
				list.Add(new Vector3(num - 0.04f, num2, num3));
				list2.Add(new Vector2(num3, num2));
				list.Add(new Vector3(num - 0.04f, num2, num4));
				list2.Add(new Vector2(num4, num2));
				list.Add(new Vector3(num - 0.04f, num2, num4));
				list2.Add(new Vector2(num4, num2));
			}
			for (int k = 0; k < list.Count - 8; k += 8)
			{
				list3.Add(k);
				list3.Add(k + 8);
				list3.Add(k + 2);
				list3.Add(k + 8);
				list3.Add(k + 10);
				list3.Add(k + 2);
				list3.Add(k + 3);
				list3.Add(k + 11);
				list3.Add(k + 6);
				list3.Add(k + 11);
				list3.Add(k + 14);
				list3.Add(k + 6);
				list3.Add(k + 7);
				list3.Add(k + 15);
				list3.Add(k + 4);
				list3.Add(k + 15);
				list3.Add(k + 12);
				list3.Add(k + 4);
				list3.Add(k + 5);
				list3.Add(k + 13);
				list3.Add(k + 1);
				list3.Add(k + 13);
				list3.Add(k + 9);
				list3.Add(k + 1);
			}
			Debug.Log(Object.op_Implicit($"RecurveBow - vertices {list.Count} triangles {list3.Count}"));
			MeshFilter val3 = val.AddComponent<MeshFilter>();
			MeshRenderer obj = val.AddComponent<MeshRenderer>();
			val3.mesh.vertices = Il2CppStructArray<Vector3>.op_Implicit(list.ToArray());
			val3.mesh.triangles = Il2CppStructArray<int>.op_Implicit(list3.ToArray());
			val3.mesh.uv = Il2CppStructArray<Vector2>.op_Implicit(list2.ToArray());
			val3.mesh.RecalculateNormals();
			val3.mesh.RecalculateBounds();
			val3.mesh.RecalculateTangents();
			Debug.Log(Object.op_Implicit($"RecurveBow - mesh vertices {((Il2CppArrayBase<Vector3>)(object)val3.mesh.vertices).Length} triangles {((Il2CppArrayBase<int>)(object)val3.mesh.triangles).Length} uv {((Il2CppArrayBase<Vector2>)(object)val3.mesh.uv).Length}"));
			((Renderer)obj).sharedMaterial = new Material(Shader.Find("GTFO/Standard"));
			((Renderer)obj).sharedMaterial.shader = Shader.Find("Cell/Player/CustomGearShader");
			((Renderer)obj).sharedMaterial.SetTexture("_MainTex", (Texture)(object)Texture2D.blackTexture);
			val.transform.localScale = new Vector3(1f, 1f, 1f);
			val.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
			return val;
		}
	}
	internal class BowHandlerFP : MonoBehaviour
	{
		public bool arrowshouldfire;

		private eMeleeWeaponState prevstate;

		public bool animneedsbreak;

		public bool animrunning;

		private string animname = "Idle";

		public string nextanim = "";

		private MeleeWeaponFirstPerson weapon;

		private PlayerAgent plr;

		public bool started;

		private MWS_Base mystate = new MWS_Base();

		private GameObject sight;

		private Transform meleealign = new Transform();

		private Texture2D bowpic2 = new Texture2D(512, 512);

		private float origfov;

		public GameObject arrow = new GameObject();

		public GameObject handarrow = new GameObject();

		private float shoveTime;

		public int inbackabs = Plugin._BowMaxAmmo;

		public int clipabs;

		public float inbackrel;

		public int inbackmax = Plugin._BowMaxAmmo;

		private bool reloadrunning;

		private void Awake()
		{
			string path = Path.Combine(Paths.ConfigPath, "../Assets/RecurveBow/recurvebowcamo.png");
			if (File.Exists(path))
			{
				Debug.Log(Object.op_Implicit("RecurveBow - loading bow texture from file recurvebowcamo.png"));
				byte[] array = File.ReadAllBytes(path);
				ImageConversion.LoadImage(bowpic2, Il2CppStructArray<byte>.op_Implicit(array));
				bowpic2.Apply();
				Object.DontDestroyOnLoad((Object)(object)bowpic2);
			}
			((Object)bowpic2).hideFlags = (HideFlags)61;
		}

		public void BeginGame()
		{
			//IL_00a6: 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_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: 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_0360: 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_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Expected O, but got Unknown
			//IL_044f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0473: Unknown result type (might be due to invalid IL or missing references)
			weapon = ((Component)this).GetComponent<MeleeWeaponFirstPerson>();
			if ((Object)(object)weapon == (Object)null || (Object)(object)((Component)this).GetComponentInParent<FirstPersonItemHolder>() == (Object)null)
			{
				return;
			}
			plr = ((Item)weapon).Owner;
			foreach (Transform componentsInChild in ((Component)weapon).GetComponentsInChildren<Transform>())
			{
				if (((Object)componentsInChild).name == "melee_align")
				{
					meleealign = componentsInChild;
				}
			}
			((ItemEquippable)weapon).GearPartHolder.SightPart.transform.localScale = new Vector3(1f, 1f, 1f);
			((ItemEquippable)weapon).GearPartHolder.SightPart.transform.localPosition = new Vector3(0f, 0.1f, 0f);
			((ItemEquippable)weapon).GearPartHolder.SightPart.transform.localEulerAngles = new Vector3(0f, 0f, 90f);
			((Component)meleealign).transform.localPosition = new Vector3(0.14f, 0.2f, -0.2f);
			((Component)meleealign).transform.localEulerAngles = new Vector3(335f, 340f, 216f);
			((Behaviour)((Component)weapon).GetComponentInChildren<Animator>()).enabled = false;
			((ItemEquippable)weapon).StopAnimationSequenceCoroutine();
			origfov = CellSettingsManager.SettingsData.Video.Fov.Value;
			string path = Path.Combine(Paths.ConfigPath, "recurvebowcamo.png");
			if (File.Exists(path))
			{
				((Renderer)((ItemEquippable)weapon).GearPartHolder.MeleeHandlePart.GetComponentInChildren<MeshRenderer>()).sharedMaterial.SetTexture("_MainTex", (Texture)(object)bowpic2);
			}
			if (!File.Exists(path))
			{
				Debug.Log(Object.op_Implicit("RecurveBow - cant find bow texture"));
			}
			GameObject val = Object.Instantiate<GameObject>(AssetAPI.GetLoadedAsset<GameObject>("Assets/AssetPrefabs/Items/Gear/Parts/Melee/Heads/Head_Knife_1.prefab"));
			((Object)val).name = "Bow_Knife_Attachment";
			val.transform.parent = ((Component)((ItemEquippable)weapon).GearPartHolder.MeleeHandlePart.GetComponentInChildren<MeshRenderer>()).gameObject.transform;
			val.transform.localPosition = new Vector3(0f, 0f, 0f);
			val.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
			val.transform.localScale = new Vector3(1f, 1f, 1f);
			GameObject gameObject = ((Component)val.GetComponentInChildren<MeshRenderer>()).gameObject;
			gameObject.transform.localScale = new Vector3(0.5f, 0.2f, 1.2f);
			gameObject.transform.localPosition = new Vector3(0f, 0.05f, 0f);
			gameObject.transform.localEulerAngles = new Vector3(0f, 0f, 180f);
			gameObject.layer = LayerManager.LAYER_FIRST_PERSON_ITEM;
			arrow = Object.Instantiate<GameObject>(ArrowHandler.Build(isprop: true));
			Transform transform = arrow.transform;
			Transform parent = (val.transform.parent = ((Component)((ItemEquippable)weapon).GearPartHolder.MeleeHandlePart.GetComponentInChildren<MeshRenderer>()).gameObject.transform);
			transform.parent = parent;
			arrow.transform.localEulerAngles = new Vector3(90f, 0f, 0f);
			arrow.transform.localPosition = new Vector3(-0.03f, 0.03f, 0.6f);
			arrow.transform.localScale = new Vector3(0.013f, 1.2839f, 0.005f);
			arrow.gameObject.SetActive(false);
			Transform parent2 = new Transform();
			foreach (Transform componentsInChild2 in ((Component)plr.FPItemHolder).GetComponentsInChildren<Transform>())
			{
				if (((Object)componentsInChild2).name == "RightIndex1")
				{
					parent2 = componentsInChild2;
				}
			}
			handarrow = Object.Instantiate<GameObject>(ArrowHandler.Build(isprop: true));
			handarrow.transform.parent = parent2;
			handarrow.transform.localEulerAngles = new Vector3(325f, 62f, 130f);
			handarrow.transform.localPosition = new Vector3(0f, 0f, 0f);
			inbackrel = (float)inbackabs / (float)inbackmax;
			GuiManager.PlayerLayer.Inventory.SetSlotAmmo((InventorySlot)10, 0, inbackabs, inbackrel);
			started = true;
		}

		private void FixedUpdate()
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Invalid comparison between Unknown and I4
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Invalid comparison between Unknown and I4
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Invalid comparison between Unknown and I4
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: 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_038b: Unknown result type (might be due to invalid IL or missing references)
			if (!started)
			{
				return;
			}
			if (clipabs <= 0)
			{
				arrowshouldfire = false;
				arrow.gameObject.SetActive(false);
				if (inbackabs > 0)
				{
					CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(AnimReload()), (Action)null);
				}
			}
			if (clipabs > 0)
			{
				arrow.gameObject.SetActive(true);
			}
			if ((int)weapon.CurrentStateName == 13 && InputMapper.GetButtonKeyMouse((InputAction)12, (eFocusState)0) && (int)prevstate != 13)
			{
				CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(AnimShove()), (Action)null);
			}
			else
			{
				if ((int)weapon.CurrentStateName == 13 && (int)prevstate == 13)
				{
					return;
				}
				if (!InputMapper.GetButtonKeyMouse((InputAction)7, (eFocusState)0) && !InputMapper.GetButtonKeyMouse((InputAction)8, (eFocusState)0) && !animrunning)
				{
					CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(AnimIdle()), (Action)null);
				}
				else if (!InputMapper.GetButtonKeyMouse((InputAction)7, (eFocusState)0) && !InputMapper.GetButtonKeyMouse((InputAction)8, (eFocusState)0) && animrunning && animname != "Idle" && !InputMapper.GetButtonKeyMouse((InputAction)12, (eFocusState)0))
				{
					nextanim = "Idle";
					animneedsbreak = true;
				}
				else if (!InputMapper.GetButtonKeyMouse((InputAction)7, (eFocusState)0) && animrunning && animname == "Aim")
				{
					nextanim = "Idle";
					animneedsbreak = true;
				}
				else
				{
					if ((InputMapper.GetButtonKeyMouse((InputAction)7, (eFocusState)0) && InputMapper.GetButtonKeyMouse((InputAction)8, (eFocusState)0) && animrunning && animname == "Aim") || (InputMapper.GetButtonKeyMouse((InputAction)7, (eFocusState)0) && InputMapper.GetButtonKeyMouse((InputAction)8, (eFocusState)0) && animrunning && animname == "ChargeArrow"))
					{
						return;
					}
					if (InputMapper.GetButtonKeyMouse((InputAction)7, (eFocusState)0) && !InputMapper.GetButtonKeyMouse((InputAction)8, (eFocusState)0) && animrunning && animname != "Aim")
					{
						nextanim = "Aim";
						animneedsbreak = true;
					}
					else
					{
						if (InputMapper.GetButtonKeyMouse((InputAction)7, (eFocusState)0) && animrunning && animname == "Aim")
						{
							return;
						}
						prevstate = weapon.CurrentStateName;
						if (animrunning && animneedsbreak)
						{
							return;
						}
						if (!animrunning && animneedsbreak)
						{
							animneedsbreak = false;
						}
						if (!animrunning)
						{
							if (nextanim == "Idle")
							{
								CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(AnimIdle()), (Action)null);
							}
							if (nextanim == "Aim")
							{
								CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(AnimAim()), (Action)null);
							}
							if (nextanim == "ChargeMelee")
							{
								CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(AnimChargeMelee()), (Action)null);
							}
							if (nextanim == "ChargeArrow")
							{
								CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(AnimChargeArrow()), (Action)null);
							}
							if (nextanim == "Shove")
							{
								CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(AnimShove()), (Action)null);
							}
							((Item)weapon).LeftHandGripTrans.localPosition = new Vector3(0.11f, 0.2f, -0.29f);
							((Item)weapon).LeftHandGripTrans.localEulerAngles = new Vector3(42f, 92f, 333f);
							((Item)weapon).RightHandGripTrans.position = ((Item)weapon).LeftHandGripTrans.position - ((Item)weapon).LeftHandGripTrans.forward * 0.3f;
							nextanim = "Idle";
						}
					}
				}
			}
		}

		private IEnumerator AnimIdle()
		{
			arrow.transform.localPosition = new Vector3(-0.03f, 0.03f, 0.6f);
			plr.FPSCamera.OverrideFieldOfView(origfov);
			pPlayerData_Session session = SNet.LocalPlayer.Session;
			NetworkAPI.InvokeEvent<Plugin.BowNetInfo>("BowNetInfo", new Plugin.BowNetInfo(0, ((pPlayerData_Session)(ref session)).playerSlotIndex, inbackabs), (SNet_ChannelType)2);
			if (clipabs == 0 && inbackabs == 0)
			{
				session = SNet.LocalPlayer.Session;
				NetworkAPI.InvokeEvent<Plugin.BowNetInfo>("BowNetInfo", new Plugin.BowNetInfo(6, ((pPlayerData_Session)(ref session)).playerSlotIndex, inbackabs), (SNet_ChannelType)2);
			}
			animname = "Idle";
			nextanim = "";
			animrunning = true;
			animneedsbreak = false;
			float starttime = Time.time;
			bool animdone = false;
			float progress = 0f;
			Vector3 origpos = ((Item)weapon).LeftHandGripTrans.localPosition;
			Vector3 origeul = ((Item)weapon).LeftHandGripTrans.localEulerAngles;
			Vector3 maorigpos = ((Component)meleealign).transform.localPosition;
			Vector3 maorigeul = ((Component)meleealign).transform.localEulerAngles;
			Vector3 origrpos = ((Item)weapon).RightHandGripTrans.localPosition;
			Vector3 origreul = ((Item)weapon).RightHandGripTrans.localEulerAngles;
			while (true)
			{
				if (((int)weapon.CurrentStateName == 7) | ((int)weapon.CurrentStateName == 9))
				{
					nextanim = "ChargeMelee";
					animneedsbreak = true;
					animrunning = false;
					yield break;
				}
				if ((int)weapon.CurrentStateName == 13 && (int)prevstate != 13 && InputMapper.GetButtonKeyMouse((InputAction)12, (eFocusState)0))
				{
					animname = "Shove";
					CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(AnimShove()), (Action)null);
					yield break;
				}
				prevstate = (eMeleeWeaponState)1;
				if (animneedsbreak)
				{
					break;
				}
				if (progress < 1f)
				{
					progress = (Time.time - starttime) * 4f;
				}
				if (!animdone && progress >= 1f)
				{
					animdone = true;
					progress = 0.99999f;
				}
				if (progress < 1f)
				{
					((Component)meleealign).transform.localPosition = Vector3.Lerp(maorigpos, new Vector3(0.14f, 0.2f, -0.2f), progress);
					((Component)meleealign).transform.localEulerAngles = Vector3.Lerp(maorigeul, new Vector3(335f, 340f, 216f), progress);
					((Item)weapon).LeftHandGripTrans.localPosition = Vector3.Lerp(origpos, new Vector3(0.11f, 0.2f, -0.29f), progress);
					((Item)weapon).LeftHandGripTrans.localEulerAngles = Vector3.Lerp(origeul, new Vector3(42f, 92f, 333f), progress);
					((Item)weapon).RightHandGripTrans.localPosition = Vector3.Lerp(origrpos, new Vector3(-0.26f, 0f, -0.53f), progress);
					((Item)weapon).RightHandGripTrans.localEulerAngles = Vector3.Lerp(origreul, new Vector3(36f, 64f, 327f), progress);
				}
				yield return null;
			}
			animrunning = false;
			animname = "";
		}

		private IEnumerator AnimAim()
		{
			pPlayerData_Session session = SNet.LocalPlayer.Session;
			NetworkAPI.InvokeEvent<Plugin.BowNetInfo>("BowNetInfo", new Plugin.BowNetInfo(2, ((pPlayerData_Session)(ref session)).playerSlotIndex, inbackabs), (SNet_ChannelType)2);
			arrow.transform.localPosition = new Vector3(-0.03f, 0.03f, 0.6f);
			animname = "Aim";
			nextanim = "";
			animrunning = true;
			animneedsbreak = false;
			float progress = 0f;
			Vector3 origpos = ((Item)weapon).LeftHandGripTrans.localPosition;
			Vector3 origeul = ((Item)weapon).LeftHandGripTrans.localEulerAngles;
			Vector3 maorigpos = ((Component)meleealign).transform.localPosition;
			Vector3 maorigeul = ((Component)meleealign).transform.localEulerAngles;
			plr.FPSCamera.OverrideFieldOfView((float)((ItemEquippable)weapon).ItemFPSData.ItemCameraFOVZoom);
			float starttime = Time.time;
			bool animdone = false;
			while (true)
			{
				if ((((int)weapon.CurrentStateName == 13) | ((int)prevstate != 13)) && InputMapper.GetButtonKeyMouse((InputAction)12, (eFocusState)0) && Time.time - shoveTime > 1.5f)
				{
					prevstate = (eMeleeWeaponState)1;
					animname = "Shove";
					CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(AnimShove()), (Action)null);
					yield break;
				}
				prevstate = (eMeleeWeaponState)1;
				if (clipabs == 1 && (((int)weapon.CurrentStateName == 7) | ((int)weapon.CurrentStateName == 9)))
				{
					nextanim = "ChargeArrow";
					animneedsbreak = true;
					animrunning = false;
					yield break;
				}
				if (animneedsbreak | !InputMapper.GetButtonKeyMouse((InputAction)7, (eFocusState)0))
				{
					break;
				}
				if (progress < 1f)
				{
					progress = (Time.time - starttime) * 4f;
				}
				if (!animdone && progress >= 1f)
				{
					animdone = true;
					progress = 0.99999f;
				}
				if (progress < 1f)
				{
					((Component)meleealign).transform.localPosition = Vector3.Lerp(maorigpos, new Vector3(0.26f, 0.14f, -0.285f), progress);
					((Component)meleealign).transform.localEulerAngles = Vector3.Lerp(maorigeul, new Vector3(333f, 334f, 258f), progress);
					((Item)weapon).LeftHandGripTrans.localPosition = Vector3.Lerp(origpos, new Vector3(0.22f, 0.145f, -0.37f), progress);
					((Item)weapon).LeftHandGripTrans.localEulerAngles = Vector3.Lerp(origeul, new Vector3(24f, 92f, 333f), progress);
				}
				yield return null;
			}
			animrunning = false;
			animname = "";
			nextanim = "Idle";
		}

		public IEnumerator AnimShove()
		{
			animrunning = true;
			animname = "Shove";
			prevstate = (eMeleeWeaponState)13;
			plr.FPSCamera.OverrideFieldOfView(origfov);
			Debug.Log(Object.op_Implicit("RecurveBow - shove coroutine"));
			shoveTime = Time.time;
			((Component)meleealign).transform.localPosition = new Vector3(0.14f, 0.3f, -0.1f);
			((Component)meleealign).transform.localEulerAngles = new Vector3(335f, 340f, 216f);
			((Item)weapon).LeftHandGripTrans.localPosition = new Vector3(0.11f, 0.3f, -0.19f);
			((Item)weapon).LeftHandGripTrans.localEulerAngles = new Vector3(42f, 92f, 333f);
			((Item)weapon).RightHandGripTrans.localPosition = new Vector3(0.17f, 0.13f, -0.15f);
			((Item)weapon).RightHandGripTrans.localEulerAngles = new Vector3(36f, 64f, 327f);
			yield return (object)new WaitForSeconds(0.25f);
			nextanim = "Idle";
			animneedsbreak = false;
			animrunning = false;
			yield return null;
		}

		private IEnumerator AnimChargeMelee()
		{
			plr.FPSCamera.OverrideFieldOfView(origfov);
			animname = "ChargeMelee";
			nextanim = "";
			animrunning = true;
			animneedsbreak = false;
			while (true)
			{
				if (((int)weapon.CurrentStateName == 14) | ((int)weapon.CurrentStateName == 15) | InputMapper.GetButtonKeyMouse((InputAction)12, (eFocusState)0))
				{
					pPlayerData_Session session = SNet.LocalPlayer.Session;
					NetworkAPI.InvokeEvent<Plugin.BowNetInfo>("BowNetInfo", new Plugin.BowNetInfo(0, ((pPlayerData_Session)(ref session)).playerSlotIndex, inbackabs), (SNet_ChannelType)2);
					weapon.ChangeState((eMeleeWeaponState)1);
					nextanim = "Idle";
					animneedsbreak = true;
					animrunning = false;
					yield break;
				}
				if (((int)weapon.CurrentStateName == 11) | ((int)weapon.CurrentStateName == 12) | ((int)weapon.CurrentStateName == 5) | ((int)weapon.CurrentStateName == 6) | ((int)weapon.CurrentStateName == 3) | ((int)weapon.CurrentStateName == 4) | ((int)weapon.CurrentStateName == 8) | ((int)weapon.CurrentStateName == 10))
				{
					CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(AnimShove()), (Action)null);
					yield break;
				}
				if (animneedsbreak)
				{
					break;
				}
				yield return null;
			}
			animrunning = false;
		}

		private IEnumerator AnimChargeArrow()
		{
			pPlayerData_Session session = SNet.LocalPlayer.Session;
			NetworkAPI.InvokeEvent<Plugin.BowNetInfo>("BowNetInfo", new Plugin.BowNetInfo(4, ((pPlayerData_Session)(ref session)).playerSlotIndex, inbackabs), (SNet_ChannelType)2);
			animname = "ChargeArrow";
			nextanim = "";
			animrunning = true;
			animneedsbreak = false;
			float aimstarttime = Time.time;
			arrowshouldfire = true;
			while (true)
			{
				if (((int)weapon.CurrentStateName == 14) | ((int)weapon.CurrentStateName == 15) | InputMapper.GetButtonKeyMouse((InputAction)12, (eFocusState)0))
				{
					prevstate = (eMeleeWeaponState)13;
					weapon.ChangeState((eMeleeWeaponState)1);
					nextanim = "Aim";
					animneedsbreak = true;
					animrunning = false;
					yield break;
				}
				if (((int)weapon.CurrentStateName == 11) | ((int)weapon.CurrentStateName == 12) | ((int)weapon.CurrentStateName == 5) | ((int)weapon.CurrentStateName == 6) | ((int)weapon.CurrentStateName == 3) | ((int)weapon.CurrentStateName == 4) | ((int)weapon.CurrentStateName == 8) | ((int)weapon.CurrentStateName == 10) | ((int)weapon.CurrentStateName == 5) | ((int)weapon.CurrentStateName == 6) | ((int)weapon.CurrentStateName == 3) | ((int)weapon.CurrentStateName == 4))
				{
					nextanim = "Aim";
					animneedsbreak = true;
					animrunning = false;
					yield break;
				}
				if (animneedsbreak)
				{
					break;
				}
				((Component)meleealign).transform.localPosition = new Vector3(0.26f, 0.14f, -0.285f);
				((Component)meleealign).transform.localEulerAngles = new Vector3(333f, 334f, 258f);
				((Item)weapon).LeftHandGripTrans.localPosition = new Vector3(0.22f, 0.145f, -0.37f);
				((Item)weapon).LeftHandGripTrans.localEulerAngles = new Vector3(24f, 92f, 333f);
				float num = (Time.time - aimstarttime) / ((ItemEquippable)weapon).MeleeAnimationData.MaxDamageChargeTime;
				if (num > 1f)
				{
					num = 1f;
				}
				float num2 = num * 1.7f;
				arrow.transform.localPosition = new Vector3(-0.03f, 0.03f, 0.6f - num2);
				yield return null;
			}
			animrunning = false;
		}

		private IEnumerator AnimReload()
		{
			if (reloadrunning)
			{
				yield break;
			}
			reloadrunning = true;
			pPlayerData_Session session = SNet.LocalPlayer.Session;
			NetworkAPI.InvokeEvent<Plugin.BowNetInfo>("BowNetInfo", new Plugin.BowNetInfo(1, ((pPlayerData_Session)(ref session)).playerSlotIndex, inbackabs), (SNet_ChannelType)2);
			float progress = 0f;
			Vector3 origpos = ((Item)weapon).RightHandGripTrans.localPosition;
			Vector3 origeul = ((Item)weapon).RightHandGripTrans.localEulerAngles;
			float starttime2 = Time.time;
			bool animdone2 = false;
			while (!animdone2)
			{
				if (progress < 1f)
				{
					progress = (Time.time - starttime2) * 2f;
				}
				if (!animdone2 && progress >= 1f)
				{
					animdone2 = true;
					progress = 0.99999f;
				}
				if (progress < 1f)
				{
					((Component)((Item)weapon).RightHandGripTrans).transform.localPosition = Vector3.Lerp(origpos, new Vector3(1.04f, -0.1f, 1.47f), progress);
					((Component)((Item)weapon).RightHandGripTrans).transform.localEulerAngles = Vector3.Lerp(origeul, new Vector3(36f, 90f, 327f), progress);
				}
				yield return null;
			}
			handarrow.SetActive(true);
			animdone2 = false;
			progress = 0f;
			starttime2 = Time.time;
			Vector3 newpos = ((Item)weapon).RightHandGripTrans.localPosition;
			Vector3 neweul = ((Item)weapon).RightHandGripTrans.localEulerAngles;
			while (!animdone2)
			{
				if (progress < 1f)
				{
					progress = (Time.time - starttime2) * 2f;
				}
				if (!animdone2 && progress >= 1f)
				{
					animdone2 = true;
					progress = 0.99999f;
				}
				if (progress < 1f)
				{
					((Item)weapon).RightHandGripTrans.localPosition = Vector3.Lerp(newpos, new Vector3(-0.26f, 0f, -0.53f), progress);
					((Item)weapon).RightHandGripTrans.localEulerAngles = Vector3.Lerp(neweul, new Vector3(36f, 64f, 327f), progress);
				}
				yield return null;
			}
			handarrow.SetActive(false);
			arrow.SetActive(true);
			if (inbackabs > 0)
			{
				inbackabs += -1;
			}
			clipabs = 1;
			inbackrel = (float)inbackabs / (float)inbackmax;
			GuiManager.PlayerLayer.Inventory.SetSlotAmmo((InventorySlot)10, 1, inbackabs, inbackrel);
			reloadrunning = false;
			session = SNet.LocalPlayer.Session;
			NetworkAPI.InvokeEvent<Plugin.BowNetInfo>("BowNetInfo", new Plugin.BowNetInfo(2, ((pPlayerData_Session)(ref session)).playerSlotIndex, inbackabs), (SNet_ChannelType)2);
			yield return null;
		}
	}
	internal class BowHandlerTP : MonoBehaviour
	{
		private float begintime;

		public bool arrowloaded;

		public bool arrowshouldfire;

		private eMeleeWeaponState prevstate;

		public bool animneedsbreak;

		public bool animrunning;

		private string animname = "Idle";

		public string nextanim = "";

		public MeleeWeaponThirdPerson weapon;

		private PlayerAgent plr;

		public bool started;

		private MWS_Base mystate = new MWS_Base();

		private GameObject sight;

		private Transform meleealign = new Transform();

		private Texture2D bowpic2 = new Texture2D(512, 512);

		public GameObject arrow = new GameObject();

		public GameObject knife = new GameObject();

		public GameObject handarrow = new GameObject();

		private float shoveTime;

		public int inbackabs = 10;

		public int clipabs;

		public float inbackrel;

		public int inbackmax = Plugin._BowMaxAmmo;

		public bool aimrunning;

		public bool reloadrunning;

		public bool chargearrowrunning;

		public bool shoverunning;

		public Transform lefthand;

		public Transform righthand;

		public Transform head;

		public GameObject quiver;

		public Transform backpackalign;

		public GameObject[] backpackammo = (GameObject[])(object)new GameObject[10];

		private void Awake()
		{
			string path = Path.Combine(Paths.ConfigPath, "../Assets/RecurveBow/recurvebowcamo.png");
			if (File.Exists(path))
			{
				Debug.Log(Object.op_Implicit("RecurveBow - loading bow texture from file recurvebowcamo.png"));
				byte[] array = File.ReadAllBytes(path);
				ImageConversion.LoadImage(bowpic2, Il2CppStructArray<byte>.op_Implicit(array));
				bowpic2.Apply();
				Object.DontDestroyOnLoad((Object)(object)bowpic2);
			}
			((Object)bowpic2).hideFlags = (HideFlags)61;
		}

		public void BeginGame()
		{
			//IL_0111: 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_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_042f: Unknown result type (might be due to invalid IL or missing references)
			//IL_044e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0496: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0516: Unknown result type (might be due to invalid IL or missing references)
			//IL_0544: Unknown result type (might be due to invalid IL or missing references)
			//IL_0631: Unknown result type (might be due to invalid IL or missing references)
			//IL_0655: Unknown result type (might be due to invalid IL or missing references)
			//IL_0679: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0754: Unknown result type (might be due to invalid IL or missing references)
			//IL_0778: Unknown result type (might be due to invalid IL or missing references)
			//IL_079c: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07dc: Expected O, but got Unknown
			//IL_0867: Unknown result type (might be due to invalid IL or missing references)
			//IL_088b: Unknown result type (might be due to invalid IL or missing references)
			begintime = Time.time;
			Debug.Log(Object.op_Implicit("recurvebow - bowhandlertp trying to start.."));
			weapon = ((Component)this).gameObject.GetComponent<MeleeWeaponThirdPerson>();
			if ((Object)(object)weapon == (Object)null)
			{
				return;
			}
			plr = ((Item)weapon).Owner;
			foreach (Transform componentsInChild in ((Component)((Item)weapon).Owner.AnimatorBody).GetComponentsInChildren<Transform>())
			{
				if (((Object)componentsInChild).name.Contains("MeleeWeaponSlot_bp"))
				{
					backpackalign = ((Component)componentsInChild).transform;
				}
			}
			quiver = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)quiver).name = "RecurveBow_Quiver";
			Object.Destroy((Object)(object)quiver.GetComponentInChildren<Collider>());
			((Renderer)quiver.GetComponent<MeshRenderer>()).material.SetTexture("_MainTex", (Texture)(object)bowpic2);
			quiver.transform.SetParent(backpackalign);
			quiver.transform.localEulerAngles = Vector3.zero;
			quiver.transform.localPosition = new Vector3(0.1f, 0.1f, 0.1f);
			quiver.transform.localScale = new Vector3(0.1f, 0.3f, 0.1f);
			((Item)weapon).Owner.m_movingCuller.CullBucket.AddRenderer((Renderer)(object)quiver.GetComponentInChildren<MeshRenderer>());
			int num = 0;
			for (float num2 = -0.14f; num2 < 0.15f; num2 += 0.14f)
			{
				for (float num3 = -0.14f; num3 < 0.15f; num3 += 0.14f)
				{
					GameObject val = Object.Instantiate<GameObject>(ArrowHandler.Build(isprop: true));
					val.GetComponentInChildren<Collider>().enabled = false;
					((Renderer)val.GetComponentInChildren<MeshRenderer>()).sharedMaterial.SetTexture("_MainTex", (Texture)(object)Texture2D.grayTexture);
					((Object)val.transform).name = "BackPackArrow";
					val.transform.SetParent(quiver.transform);
					val.transform.localScale = new Vector3(0.05f, 1.2f, 0.05f);
					val.transform.localPosition = new Vector3(num2, 0.5f, num3);
					val.transform.localEulerAngles = new Vector3(0f, 0f, 180f);
					backpackammo[num] = val;
					num++;
				}
			}
			foreach (Transform componentsInChild2 in ((Component)this).GetComponentsInChildren<Transform>())
			{
				if (((Object)componentsInChild2).name == "Bow_GripAlign")
				{
					meleealign = componentsInChild2;
				}
			}
			foreach (Transform componentsInChild3 in ((Component)((Item)weapon).Owner.AnimatorBody).GetComponentsInChildren<Transform>())
			{
				if (((Object)componentsInChild3).name == "Head")
				{
					head = componentsInChild3;
				}
			}
			foreach (Transform componentsInChild4 in ((Component)weapon).GetComponentsInChildren<Transform>())
			{
				if (((Object)componentsInChild4).name == "RightHand")
				{
					righthand = componentsInChild4;
				}
			}
			foreach (Transform componentsInChild5 in ((Component)weapon).GetComponentsInChildren<Transform>())
			{
				if (((Object)componentsInChild5).name == "LeftHand")
				{
					lefthand = componentsInChild5;
				}
			}
			if ((Object)(object)righthand != (Object)null)
			{
				righthand.localPosition = new Vector3(0.04f, 0.1f, -0.23f);
				righthand.localEulerAngles = new Vector3(281f, 11f, 97f);
			}
			if ((Object)(object)lefthand != (Object)null)
			{
				lefthand.localPosition = new Vector3(0f, -0.08f, -0.1f);
				lefthand.localEulerAngles = new Vector3(285f, 264f, 176f);
			}
			if ((Object)(object)head != (Object)null)
			{
				((Component)weapon).transform.SetParent(head);
			}
			((Component)weapon).transform.localPosition = new Vector3(0.06f, -0.2f, 0.63f);
			((Component)weapon).transform.localEulerAngles = new Vector3(13f, 347f, 300f);
			((ItemEquippable)weapon).GearPartHolder.SightPart.transform.localScale = new Vector3(1f, 1f, 1f);
			((ItemEquippable)weapon).GearPartHolder.SightPart.transform.localPosition = new Vector3(0f, 0.1f, 0f);
			((ItemEquippable)weapon).GearPartHolder.SightPart.transform.localEulerAngles = new Vector3(0f, 0f, 90f);
			((Behaviour)((Component)weapon).GetComponentInChildren<Animator>()).enabled = false;
			((ItemEquippable)weapon).StopAnimationSequenceCoroutine();
			string path = Path.Combine(Paths.ConfigPath, "recurvebowcamo.png");
			if (File.Exists(path))
			{
				((Renderer)((ItemEquippable)weapon).GearPartHolder.MeleeHandlePart.GetComponentInChildren<MeshRenderer>()).sharedMaterial.SetTexture("_MainTex", (Texture)(object)bowpic2);
			}
			if (!File.Exists(path))
			{
				Debug.Log(Object.op_Implicit("RecurveBow - cant find bow texture"));
			}
			GameObject loadedAsset = AssetAPI.GetLoadedAsset<GameObject>("Assets/AssetPrefabs/Items/Gear/Parts/Melee/Heads/Head_Knife_1.prefab");
			knife = Object.Instantiate<GameObject>(loadedAsset);
			((Object)knife).name = "Bow_Knife_Attachment";
			knife.transform.parent = ((Component)((ItemEquippable)weapon).GearPartHolder.MeleeHandlePart.GetComponentInChildren<MeshRenderer>()).gameObject.transform;
			knife.transform.localPosition = new Vector3(0f, 0f, 0f);
			knife.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
			knife.transform.localScale = new Vector3(1f, 1.5f, 1.5f);
			GameObject gameObject = ((Component)knife.GetComponentInChildren<MeshRenderer>()).gameObject;
			gameObject.transform.localScale = new Vector3(0.5f, 0.2f, 1.2f);
			gameObject.transform.localPosition = new Vector3(0f, 0.035f, 0f);
			gameObject.transform.localEulerAngles = new Vector3(0f, 0f, 180f);
			gameObject.layer = LayerManager.LAYER_THIRD_PERSON_ITEM;
			arrow = Object.Instantiate<GameObject>(ArrowHandler.Build(isprop: true));
			arrow.transform.parent = ((Component)((ItemEquippable)weapon).GearPartHolder.MeleeHandlePart.GetComponentInChildren<MeshRenderer>()).gameObject.transform;
			arrow.transform.localScale = new Vector3(0.008f, 1.2f, 0.005f);
			arrow.transform.localEulerAngles = new Vector3(90f, 0f, 0f);
			arrow.transform.localPosition = new Vector3(-0.03f, 0.01f, 0.81f);
			((Renderer)arrow.GetComponentInChildren<MeshRenderer>()).sharedMaterial.SetTexture("_MainTex", (Texture)(object)Texture2D.grayTexture);
			arrow.gameObject.SetActive(false);
			Transform parent = new Transform();
			foreach (Transform componentsInChild6 in ((Component)((Item)weapon).Owner.AnimatorBody).GetComponentsInChildren<Transform>())
			{
				if (((Object)componentsInChild6).name == "RightIndex1")
				{
					parent = componentsInChild6;
				}
			}
			handarrow = Object.Instantiate<GameObject>(ArrowHandler.Build(isprop: true));
			handarrow.transform.parent = parent;
			handarrow.transform.localEulerAngles = new Vector3(64f, 31f, 70f);
			handarrow.transform.localPosition = new Vector3(0f, 0f, 0f);
			((Renderer)handarrow.GetComponentInChildren<MeshRenderer>()).sharedMaterial.SetTexture("_MainTex", (Texture)(object)Texture2D.grayTexture);
			handarrow.gameObject.SetActive(false);
			((Item)weapon).Owner.SyncIK.SetRightArmTarget(righthand);
			((Item)weapon).Owner.SyncIK.SetRightArmWeight(1f);
			((Item)weapon).Owner.SyncIK.SetLeftArmTarget(lefthand);
			((Item)weapon).Owner.SyncIK.SetLeftArmWeight(1f);
			inbackrel = (float)inbackabs / (float)inbackmax;
			clipabs = 1;
			started = true;
			StartIdle();
		}

		public void OnWield()
		{
			//IL_0043: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			knife.SetActive(true);
			if (arrowloaded)
			{
				arrow.SetActive(true);
			}
			if ((Object)(object)righthand != (Object)null)
			{
				righthand.localPosition = new Vector3(0.04f, 0.1f, -0.23f);
				righthand.localEulerAngles = new Vector3(281f, 11f, 97f);
			}
			if ((Object)(object)lefthand != (Object)null)
			{
				lefthand.localPosition = new Vector3(0f, -0.01f, -0.1f);
				lefthand.localEulerAngles = new Vector3(285f, 264f, 176f);
			}
			if ((Object)(object)head != (Object)null)
			{
				((Component)weapon).transform.SetParent(head);
			}
			((Component)weapon).transform.localPosition = new Vector3(0.06f, -0.2f, 0.63f);
			((Component)weapon).transform.localEulerAngles = new Vector3(13f, 347f, 300f);
			((Behaviour)((Component)weapon).GetComponentInChildren<Animator>()).enabled = false;
			((ItemEquippable)weapon).StopAnimationSequenceCoroutine();
			((Item)weapon).Owner.SyncIK.SetRightArmTarget(righthand);
			((Item)weapon).Owner.SyncIK.SetRightArmWeight(1f);
			((Item)weapon).Owner.SyncIK.SetLeftArmTarget(lefthand);
			((Item)weapon).Owner.SyncIK.SetLeftArmWeight(1f);
			((Behaviour)((Item)weapon).Owner.SyncIK.m_rightArmIK).enabled = true;
			StartIdle();
		}

		private void Update()
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: 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_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: 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_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: 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_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			if (Time.time - begintime < 2f || !started)
			{
				return;
			}
			if (clipabs == 0)
			{
				arrowloaded = false;
				arrowshouldfire = false;
				arrow.SetActive(false);
			}
			if (clipabs == 1)
			{
				arrowloaded = true;
				arrowshouldfire = true;
				arrow.SetActive(true);
			}
			Vector3 val = ((ItemEquippable)weapon).GearPartHolder.MeleeHandlePart.transform.position + ((ItemEquippable)weapon).GearPartHolder.MeleeHandlePart.transform.up * 0.7f;
			val += -(((ItemEquippable)weapon).GearPartHolder.MeleeHandlePart.transform.forward * 0.11f);
			Vector3 val2 = ((ItemEquippable)weapon).GearPartHolder.MeleeHandlePart.transform.position - ((ItemEquippable)weapon).GearPartHolder.MeleeHandlePart.transform.forward * 0.11f;
			Vector3 val3 = ((ItemEquippable)weapon).GearPartHolder.MeleeHandlePart.transform.position - ((ItemEquippable)weapon).GearPartHolder.MeleeHandlePart.transform.up * 0.7f;
			val3 += -(((ItemEquippable)weapon).GearPartHolder.MeleeHandlePart.transform.forward * 0.11f);
			if (inbackabs == 0)
			{
				for (int i = 0; i < 9; i++)
				{
					backpackammo[i].SetActive(false);
				}
			}
			if (inbackabs > 0)
			{
				for (int j = 1; j < 10; j++)
				{
					if (inbackabs >= j)
					{
						backpackammo[j - 1].SetActive(true);
					}
					if (inbackabs < j)
					{
						backpackammo[j - 1].SetActive(false);
					}
				}
			}
			if ((Object)(object)((Item)weapon).Owner.Inventory.WieldedItem != (Object)(object)weapon)
			{
				knife.SetActive(false);
				arrow.SetActive(false);
				DebugDraw3D.DrawCone(val, val2, 0.005f, Color.blue, 0f, "");
				DebugDraw3D.DrawCone(val3, val2, 0.005f, Color.blue, 0f, "");
				return;
			}
			if (clipabs <= 0)
			{
				arrowshouldfire = false;
				arrow.gameObject.SetActive(false);
			}
			if (clipabs > 0)
			{
				arrow.gameObject.SetActive(true);
			}
			if (chargearrowrunning)
			{
				DebugDraw3D.DrawCone(val, ((Component)weapon).transform.position - ((Component)weapon).transform.forward * 0.5f + ((Component)weapon).transform.up * 0.03f, 0.005f, Color.blue, 0f, "");
				DebugDraw3D.DrawCone(val3, ((Component)weapon).transform.position - ((Component)weapon).transform.forward * 0.5f + ((Component)weapon).transform.up * 0.03f, 0.005f, Color.blue, 0f, "");
			}
			if (!chargearrowrunning)
			{
				DebugDraw3D.DrawCone(val, val2, 0.005f, Color.blue, 0f, "");
				DebugDraw3D.DrawCone(val3, val2, 0.005f, Color.blue, 0f, "");
			}
		}

		public void StartReload()
		{
			CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(AnimReload()), (Action)null);
		}

		public void StartAim()
		{
			CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(AnimAim()), (Action)null);
		}

		public void StartChargeArrow()
		{
			CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(AnimChargeArrow()), (Action)null);
		}

		public void StartIdle()
		{
			CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(AnimIdle()), (Action)null);
		}

		public IEnumerator AnimIdle()
		{
			aimrunning = false;
			reloadrunning = false;
			chargearrowrunning = false;
			((Component)weapon).transform.localPosition = new Vector3(0.06f, -0.2f, 0.63f);
			((Component)weapon).transform.localEulerAngles = new Vector3(13f, 347f, 300f);
			arrow.transform.localPosition = new Vector3(-0.03f, 0.03f, 0.81f);
			righthand.localPosition = new Vector3(0.04f, 0.1f, -0.23f);
			yield return null;
		}

		public IEnumerator AnimAim()
		{
			aimrunning = true;
			arrow.transform.localPosition = new Vector3(-0.03f, 0.03f, 0.81f);
			animname = "Aim";
			nextanim = "";
			animneedsbreak = false;
			float progress = 0f;
			_ = ((Item)weapon).LeftHandGripTrans.localPosition;
			_ = ((Item)weapon).LeftHandGripTrans.localEulerAngles;
			Vector3 maorigpos = ((Component)weapon).transform.localPosition;
			Vector3 maorigeul = ((Component)weapon).transform.localEulerAngles;
			_ = ((Item)weapon).RightHandGripTrans.localPosition;
			_ = ((Item)weapon).RightHandGripTrans.localEulerAngles;
			float starttime = Time.time;
			bool animdone = false;
			prevstate = (eMeleeWeaponState)1;
			while (aimrunning)
			{
				if (progress < 1f)
				{
					progress = (Time.time - starttime) * 4f;
				}
				if (!animdone && progress >= 1f)
				{
					animdone = true;
					progress = 0.99999f;
				}
				if (progress < 1f && !animdone)
				{
					((Component)weapon).transform.localPosition = Vector3.Lerp(maorigpos, new Vector3(0.06f, 0f, 0.63f), progress);
					((Component)weapon).transform.localEulerAngles = Vector3.Lerp(maorigeul, new Vector3(-7f, 355f, 335f), progress);
				}
				yield return null;
			}
			yield return null;
		}

		public IEnumerator AnimShove()
		{
			animrunning = true;
			animname = "Shove";
			prevstate = (eMeleeWeaponState)13;
			shoveTime = Time.time;
			((Component)meleealign).transform.localPosition = new Vector3(0.14f, 0.3f, -0.1f);
			((Component)meleealign).transform.localEulerAngles = new Vector3(335f, 340f, 216f);
			((Item)weapon).LeftHandGripTrans.localPosition = new Vector3(0.11f, 0.3f, -0.19f);
			((Item)weapon).LeftHandGripTrans.localEulerAngles = new Vector3(42f, 92f, 333f);
			((Item)weapon).RightHandGripTrans.localPosition = new Vector3(0.17f, 0.13f, -0.15f);
			((Item)weapon).RightHandGripTrans.localEulerAngles = new Vector3(36f, 64f, 327f);
			yield return (object)new WaitForSeconds(0.25f);
			StartIdle();
			nextanim = "Idle";
			animneedsbreak = false;
			animrunning = false;
			yield return null;
		}

		private IEnumerator AnimChargeMelee()
		{
			animname = "ChargeMelee";
			nextanim = "";
			animrunning = true;
			animneedsbreak = false;
			yield return null;
		}

		public IEnumerator AnimChargeArrow()
		{
			chargearrowrunning = true;
			animname = "ChargeArrow";
			nextanim = "";
			animrunning = true;
			animneedsbreak = false;
			float progress = 0f;
			Vector3 origpos = ((Item)weapon).RightHandGripTrans.localPosition;
			_ = ((Item)weapon).RightHandGripTrans.localEulerAngles;
			Vector3 arroworigpos = ((Item)weapon).RightHandGripTrans.localPosition;
			float starttime = Time.time;
			bool animdone = false;
			while (!animdone)
			{
				prevstate = (eMeleeWeaponState)1;
				if (progress < 1f)
				{
					progress = (Time.time - starttime) * 4f;
				}
				if (!animdone && progress >= 1f)
				{
					animdone = true;
					progress = 0.99999f;
				}
				if (progress < 1f)
				{
					((Item)weapon).RightHandGripTrans.localPosition = Vector3.Lerp(origpos, new Vector3(0.04f, 0.1f, -0.63f), progress);
					arrow.transform.localPosition = Vector3.Lerp(arroworigpos, new Vector3(-0.03f, 0.03f, -0.39f), progress);
				}
				yield return null;
			}
			yield return null;
		}

		public IEnumerator AnimReload()
		{
			if (reloadrunning)
			{
				yield break;
			}
			chargearrowrunning = false;
			if (inbackabs < 1)
			{
				arrowshouldfire = false;
				StartIdle();
				yield break;
			}
			reloadrunning = true;
			float progress2 = 0f;
			Vector3 origpos = ((Item)weapon).RightHandGripTrans.localPosition;
			Vector3 origeul = ((Item)weapon).RightHandGripTrans.localEulerAngles;
			float starttime2 = Time.time;
			bool animdone2 = false;
			((Component)((Item)weapon).RightHandGripTrans).transform.localEulerAngles = new Vector3(180f, 0f, 0f);
			while (!animdone2)
			{
				if (progress2 < 1f)
				{
					progress2 = (Time.time - starttime2) * 2f;
				}
				if (!animdone2 && progress2 >= 1f)
				{
					animdone2 = true;
					progress2 = 0.99999f;
				}
				if (progress2 < 1f)
				{
					((Component)((Item)weapon).RightHandGripTrans).transform.localPosition = Vector3.Lerp(origpos, new Vector3(-0.16f, 0.2f, -0.73f), progress2);
				}
				yield return null;
			}
			handarrow.SetActive(true);
			animdone2 = false;
			progress2 = 0f;
			starttime2 = Time.time;
			Vector3 newpos = ((Item)weapon).RightHandGripTrans.localPosition;
			_ = ((Item)weapon).RightHandGripTrans.localEulerAngles;
			((Item)weapon).RightHandGripTrans.localEulerAngles = origeul;
			while (!animdone2)
			{
				if (progress2 < 1f)
				{
					progress2 = (Time.time - starttime2) * 2f;
				}
				if (!animdone2 && progress2 >= 1f)
				{
					animdone2 = true;
					progress2 = 0.99999f;
				}
				if (progress2 < 1f)
				{
					((Item)weapon).RightHandGripTrans.localPosition = Vector3.Lerp(newpos, origpos, progress2);
				}
				yield return null;
			}
			handarrow.SetActive(false);
			arrow.SetActive(true);
			arrowloaded = true;
			if (inbackabs > 0)
			{
				inbackabs--;
			}
			clipabs = 1;
			inbackrel = (float)inbackabs / (float)inbackmax;
			reloadrunning = false;
			yield return null;
		}
	}
	[HarmonyPatch]
	internal class BowPatches : MonoBehaviour
	{
		private static float lastupdate;

		[HarmonyPatch(typeof(MeleeWeaponFirstPerson), "OnWield")]
		[HarmonyPrefix]
		private static bool PrefixOnWield(MeleeWeaponFirstPerson __instance)
		{
			if (((GameDataBlockBase<ItemDataBlock>)(object)((Item)__instance).ItemDataBlock).name == "GEAR_RecurveBow")
			{
				((Item)__instance).Owner.AnimatorArms.Play("Spear_Idle", 7, 0f);
				BowHandlerFP component = ((Component)__instance).GetComponent<BowHandlerFP>();
				if (!component.started)
				{
					component.BeginGame();
				}
			}
			return true;
		}

		[HarmonyPatch(typeof(MeleeWeaponThirdPerson), "OnWield")]
		[HarmonyPrefix]
		private static bool PrefixTPOnWield(MeleeWeaponThirdPerson __instance)
		{
			if (((GameDataBlockBase<ItemDataBlock>)(object)((Item)__instance).ItemDataBlock).name == "GEAR_RecurveBow")
			{
				((Behaviour)__instance).enabled = true;
				((Item)__instance).Owner.AnimatorArms.Play("Spear_Idle", 7, 0f);
				BowHandlerTP component = ((Component)__instance).GetComponent<BowHandlerTP>();
				if (!component.started)
				{
					component.BeginGame();
				}
				component.OnWield();
			}
			return true;
		}

		[HarmonyPatch(typeof(MeleeWeaponThirdPerson), "Update")]
		[HarmonyPrefix]
		private static bool PrefixTPUpdate(MeleeWeaponThirdPerson __instance)
		{
			if (((GameDataBlockBase<ItemDataBlock>)(object)((Item)__instance).ItemDataBlock).name == "GEAR_RecurveBow")
			{
				if (Time.time - lastupdate > 1f)
				{
					BowHandlerTP component = ((Component)__instance).GetComponent<BowHandlerTP>();
					if (!component.aimrunning && !component.reloadrunning && !component.chargearrowrunning)
					{
						component.OnWield();
					}
					lastupdate = Time.time;
				}
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(MWS_Push), "Enter")]
		[HarmonyPrefix]
		private static bool PrefixPushEnter(MWS_Push __instance)
		{
			//IL_005f: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Expected O, but got Unknown
			if (((GameDataBlockBase<ItemDataBlock>)(object)((Item)((MWS_Base)__instance).m_weapon).ItemDataBlock).name != "GEAR_RecurveBow")
			{
				return true;
			}
			if ((Object)(object)((Item)((MWS_Base)__instance).m_weapon).Owner != (Object)(object)PlayerManager.GetLocalPlayerAgent())
			{
				return false;
			}
			if (InputMapper.GetButtonKeyMouseGamepad((InputAction)7, (eFocusState)0))
			{
				if (InputMapper.GetButtonKeyMouseGamepad((InputAction)12, (eFocusState)0))
				{
					return true;
				}
				return false;
			}
			List<EnemyAgent> list = new List<EnemyAgent>();
			Collider[] array = Il2CppArrayBase<Collider>.op_Implicit((Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(((Agent)((Item)((MWS_Base)__instance).m_weapon).Owner).Position + ((Component)((Item)((MWS_Base)__instance).m_weapon).Owner).transform.forward * 0.5f, 0.5f, LayerManager.MASK_MELEE_ATTACK_TARGETS));
			foreach (Collider val in array)
			{
				if ((Object)(object)((Component)val).GetComponentInParent<EnemyAgent>() != (Object)null)
				{
					list.Add(((Component)val).GetComponentInParent<EnemyAgent>());
				}
			}
			if (list.Count > 0)
			{
				((MWS_Base)__instance).m_weapon.DoAttackDamage(new MeleeWeaponDamageData
				{
					damageGO = ((Component)((Agent)((Component)list[0]).GetComponentInParent<EnemyAgent>()).AimTarget).gameObject,
					sourcePos = ((Agent)((Item)((MWS_Base)__instance).m_weapon).Owner).Position
				}, true);
			}
			return true;
		}

		[HarmonyPatch(typeof(MWS_AttackLight), "Enter")]
		[HarmonyPrefix]
		private static bool PrefixAttackLightEnter(MWS_AttackLight __instance)
		{
			if (((GameDataBlockBase<ItemDataBlock>)(object)((Item)((MWS_Base)__instance).m_weapon).ItemDataBlock).name != "GEAR_RecurveBow")
			{
				return true;
			}
			if ((Object)(object)((Item)((MWS_Base)__instance).m_weapon).Owner == (Object)(object)PlayerManager.GetLocalPlayerAgent())
			{
				CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(((Component)((MWS_Base)__instance).m_weapon).GetComponent<BowHandlerFP>().AnimShove()), (Action)null);
			}
			if ((Object)(object)((Item)((MWS_Base)__instance).m_weapon).Owner != (Object)(object)PlayerManager.GetLocalPlayerAgent())
			{
				CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(((Component)((MWS_Base)__instance).m_weapon).GetComponent<BowHandlerTP>().AnimShove()), (Action)null);
			}
			return true;
		}

		[HarmonyPatch(typeof(MWS_AttackHeavy), "Enter")]
		[HarmonyPrefix]
		private static bool PrefixAttackHeavy(MWS_AttackHeavy __instance)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			if (((GameDataBlockBase<ItemDataBlock>)(object)((Item)((MWS_Base)__instance).m_weapon).ItemDataBlock).name != "GEAR_RecurveBow")
			{
				return true;
			}
			if ((Object)(object)((Item)((MWS_Base)__instance).m_weapon).Owner != (Object)(object)PlayerManager.GetLocalPlayerAgent())
			{
				return false;
			}
			if (!InputMapper.GetButtonKeyMouseGamepad((InputAction)7, (eFocusState)0))
			{
				return true;
			}
			BowHandlerFP component = ((Component)((MWS_Base)__instance).m_weapon).GetComponent<BowHandlerFP>();
			if (!component.arrowshouldfire)
			{
				return true;
			}
			pPlayerData_Session session = SNet.LocalPlayer.Session;
			NetworkAPI.InvokeEvent<Plugin.BowNetInfo>("BowNetInfo", new Plugin.BowNetInfo(5, ((pPlayerData_Session)(ref session)).playerSlotIndex, component.inbackabs), (SNet_ChannelType)2);
			component.clipabs = 0;
			component.inbackrel = (float)component.inbackabs / (float)component.inbackmax;
			GuiManager.PlayerLayer.Inventory.SetSlotAmmo((InventorySlot)10, 0, component.inbackabs, component.inbackrel);
			RaycastHit val = default(RaycastHit);
			Physics.Raycast(Camera.current.ScreenPointToRay(Input.mousePosition), ref val, 200f, LayerManager.MASK_PING_TARGET, (QueryTriggerInteraction)1);
			float speed = Mathf.Min(((MWS_AttackSwingBase)__instance).m_elapsed / ((ItemEquippable)((MWS_Base)__instance).m_weapon).MeleeAnimationData.MaxDamageChargeTime, 1f);
			ArrowHandler arrowHandler = new GameObject("Arrow").AddComponent<ArrowHandler>();
			arrowHandler.position = component.arrow.transform.position;
			Vector3 val2 = ((RaycastHit)(ref val)).point - arrowHandler.position;
			arrowHandler.direction = ((Vector3)(ref val2)).normalized;
			arrowHandler.weapon = ((MWS_Base)__instance).m_weapon;
			arrowHandler.speed = speed;
			arrowHandler.target = ((RaycastHit)(ref val)).point;
			arrowHandler.Shoot();
			component.arrow.gameObject.SetActive(false);
			return false;
		}
	}
	[BepInPlugin("RecurveBow", "RecurveBow", "0.0.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BasePlugin
	{
		public struct ArrowNetInfo
		{
			public int ARROWINDEX;

			public int SLOT;

			public Vector3 POSITION;

			public Vector3 DIRECTION;

			public float SPEED;

			public int STATUS;

			public uint ENEMYAGENT;

			public static string NetworkIdentity => "ArrowNetInfo";

			public ArrowNetInfo(int arrowindex, int slot, Vector3 position, Vector3 direction, float speed, int status, uint enemyagent)
			{
				//IL_0016: 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_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				this = default(ArrowNetInfo);
				ARROWINDEX = arrowindex;
				SLOT = slot;
				POSITION = position;
				DIRECTION = direction;
				SPEED = speed;
				STATUS = status;
				ENEMYAGENT = enemyagent;
			}
		}

		public struct ArrowInfo
		{
			public int ARROWINDEX;

			public int SLOT;

			public Vector3 POSITION;

			public Vector3 DIRECTION;

			public float SPEED;

			public int STATUS;

			public uint ENEMYAGENT;

			public ArrowInfo(int arrowindex, int slot, Vector3 position, Vector3 direction, float speed, int status, uint enemyagent)
			{
				//IL_0016: 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_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				this = default(ArrowInfo);
				ARROWINDEX = arrowindex;
				SLOT = slot;
				POSITION = position;
				DIRECTION = direction;
				SPEED = speed;
				STATUS = status;
				ENEMYAGENT = enemyagent;
			}

			public ArrowInfo(ArrowNetInfo network)
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				this = default(ArrowInfo);
				ARROWINDEX = network.ARROWINDEX;
				SLOT = network.SLOT;
				POSITION = network.POSITION;
				DIRECTION = network.DIRECTION;
				SPEED = network.SPEED;
				STATUS = network.STATUS;
				ENEMYAGENT = network.ENEMYAGENT;
			}
		}

		public struct BowNetInfo
		{
			public int FUNC;

			public int SLOT;

			public int AMMOCOUNT;

			public static string NetworkIdentity => "BowNetInfo";

			public BowNetInfo(int func, int slot, int ammocount)
			{
				this = default(BowNetInfo);
				FUNC = func;
				SLOT = slot;
				AMMOCOUNT = ammocount;
			}
		}

		public struct BowInfo
		{
			public int FUNC;

			public int SLOT;

			public int AMMOCOUNT;

			public BowInfo(int func, int slot, int ammocount)
			{
				this = default(BowInfo);
				FUNC = func;
				SLOT = slot;
				AMMOCOUNT = ammocount;
			}

			public BowInfo(BowNetInfo network)
			{
				this = default(BowInfo);
				FUNC = network.FUNC;
				SLOT = network.SLOT;
				AMMOCOUNT = network.AMMOCOUNT;
			}
		}

		public class RecurveBow : MonoBehaviour
		{
			public static void ReceiveArrowNetInfo(ulong sender, ArrowNetInfo netInfo)
			{
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_014e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0150: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_030b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0310: Unknown result type (might be due to invalid IL or missing references)
				//IL_0336: Unknown result type (might be due to invalid IL or missing references)
				//IL_0480: Unknown result type (might be due to invalid IL or missing references)
				//IL_06f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_05e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0566: Unknown result type (might be due to invalid IL or missing references)
				EnemyAgent val = null;
				string[] obj = new string[16]
				{
					"RecurveBow - ArrowNet - received data from sender ",
					sender.ToString(),
					": arrowindex:",
					netInfo.ARROWINDEX.ToString(),
					" slot:",
					netInfo.SLOT.ToString(),
					" position:",
					null,
					null,
					null,
					null,
					null,
					null,
					null,
					null,
					null
				};
				Vector3 val2 = netInfo.POSITION;
				obj[7] = ((object)(Vector3)(ref val2)).ToString();
				obj[8] = " direction:";
				val2 = netInfo.DIRECTION;
				obj[9] = ((object)(Vector3)(ref val2)).ToString();
				obj[10] = " speed:";
				obj[11] = netInfo.SPEED.ToString();
				obj[12] = " status:";
				obj[13] = netInfo.STATUS.ToString();
				obj[14] = " enemyagent:";
				obj[15] = netInfo.ENEMYAGENT.ToString();
				Debug.Log(Object.op_Implicit(string.Concat(obj)));
				int num = 20;
				for (int i = 0; i < PlayerManager.PlayerAgentsInLevel.Count; i++)
				{
					PlayerAgent val3 = PlayerManager.PlayerAgentsInLevel[i];
					if (sender == ((Agent)val3).m_replicator.OwningPlayer.Lookup)
					{
						num = i;
					}
				}
				if (num == 20)
				{
					return;
				}
				PlayerAgent val4 = PlayerManager.PlayerAgentsInLevel[num];
				if (netInfo.ENEMYAGENT != 0)
				{
					pReplicator pRep = default(pReplicator);
					pRep.keyPlusOne = (ushort)netInfo.ENEMYAGENT;
					pAgent val5 = default(pAgent);
					val5.pRep = pRep;
					Agent val6 = default(Agent);
					((pAgent)(ref val5)).TryGet(ref val6);
					val = ((Il2CppObjectBase)val6).TryCast<EnemyAgent>();
				}
				if (netInfo.STATUS == 0)
				{
					GameObject val7 = new GameObject($"Arrow_{val4.PlayerName}_{netInfo.ARROWINDEX}");
					val7.transform.position = netInfo.POSITION;
					val7.transform.eulerAngles = netInfo.DIRECTION;
					ArrowHandler arrowHandler = val7.AddComponent<ArrowHandler>();
					arrowHandler.position = netInfo.POSITION;
					arrowHandler.direction = netInfo.DIRECTION;
					arrowHandler.weapontp = ((Component)val4).gameObject.GetComponentInChildren<MeleeWeaponThirdPerson>();
					arrowHandler.speed = netInfo.SPEED;
					arrowHandler.arrowindex = netInfo.ARROWINDEX;
					arrowHandler.Shoot();
					arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX] = arrowHandler;
				}
				if (netInfo.STATUS == 2 && (Object)(object)arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX] != (Object)null)
				{
					arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX].audio.Post(3762526143u, true);
					arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX].speed = 0f;
					arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX].status = 2;
					arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX].velocity = Vector3.zero;
					((Component)arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX]).transform.position = netInfo.POSITION;
				}
				if (netInfo.STATUS == 3 && (Object)(object)arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX] != (Object)null)
				{
					Object.Destroy((Object)(object)arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX].arrow);
					arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX].arrow = Object.Instantiate<GameObject>(ArrowHandler.Build(isprop: true));
					Light obj2 = arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX].arrow.AddComponent<Light>();
					obj2.range = 1f;
					obj2.intensity = 0.6f;
					((Renderer)arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX].arrow.GetComponent<MeshRenderer>()).sharedMaterial.SetTexture("_MainTex", (Texture)(object)Texture2D.grayTexture);
					((Object)arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX].arrow).name = "Arrow_Prop";
					((Component)arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX]).transform.position = netInfo.POSITION;
					arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX].arrow.transform.parent = ((Component)arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX]).transform;
					if ((Object)(object)val != (Object)null)
					{
						arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX].hitagent = (Agent)(object)val;
					}
					if ((Object)(object)arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX].hitagent != (Object)null)
					{
						((Component)arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX]).transform.position = arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX].hitagent.Position;
					}
					arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX].arrow.transform.localPosition = new Vector3(0f, 0f, 0f);
					arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX].arrow.transform.localScale = new Vector3(0.05f, 2f, 0.05f);
					arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX].proparrowbuilt = true;
					arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX].status = 3;
				}
				if (netInfo.STATUS == 4 && (Object)(object)arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX] != (Object)null)
				{
					arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX].hitagent = (Agent)(object)val;
					arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX].enemyhit = true;
					arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX].arrow.transform.parent = ((Agent)val).AimTarget;
					arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX].arrow.transform.localPosition = Vector3.zero;
					arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX].status = 4;
				}
				if (netInfo.STATUS == 5 && (Object)(object)arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX] != (Object)null)
				{
					Object.Destroy((Object)(object)arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX].arrowtip);
					Object.Destroy((Object)(object)arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX].arrow);
					Object.Destroy((Object)(object)((Component)arrowinfo[netInfo.SLOT][netInfo.ARROWINDEX]).gameObject);
				}
			}

			public static void ReceiveBowNetInfo(ulong sender, BowNetInfo netInfo)
			{
				Debug.Log(Object.op_Implicit("RecurveBow - BowNet - received data from sender " + sender + ": func:" + netInfo.FUNC + " slot:" + netInfo.SLOT + " ammocount:" + netInfo.AMMOCOUNT));
				int num = 20;
				for (int i = 0; i < PlayerManager.PlayerAgentsInLevel.Count; i++)
				{
					PlayerAgent val = PlayerManager.PlayerAgentsInLevel[i];
					if (sender == ((Agent)val).m_replicator.OwningPlayer.Lookup)
					{
						num = i;
					}
				}
				if (num != 20)
				{
					BowHandlerTP componentInChildren = ((Component)PlayerManager.PlayerAgentsInLevel[num]).gameObject.GetComponentInChildren<BowHandlerTP>();
					((ItemEquippable)componentInChildren.weapon).StopAnimationSequenceCoroutine();
					((Behaviour)((Component)componentInChildren.weapon).GetComponentInChildren<Animator>()).enabled = false;
					componentInChildren.inbackabs = netInfo.AMMOCOUNT;
					if (netInfo.FUNC == 0)
					{
						componentInChildren.reloadrunning = false;
						componentInChildren.aimrunning = false;
						componentInChildren.chargearrowrunning = false;
						componentInChildren.shoverunning = false;
						componentInChildren.StartIdle();
					}
					if (netInfo.FUNC == 1)
					{
						componentInChildren.StartReload();
					}
					if (netInfo.FUNC == 2)
					{
						componentInChildren.StartAim();
					}
					if (netInfo.FUNC == 4)
					{
						componentInChildren.StartChargeArro