Decompiled source of BowTrajectory v1.0.2

BowTrajectory.dll

Decompiled 3 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BowTrajectory
{
	[BepInPlugin("dev.modded.bowtrajectory", "Bow Trajectory", "1.0.0")]
	public class BowTrajectoryPlugin : BaseUnityPlugin
	{
		public const string GUID = "dev.modded.bowtrajectory";

		public const string NAME = "Bow Trajectory";

		public const string VERSION = "1.0.0";

		internal static BowTrajectoryPlugin Instance;

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<KeyboardShortcut> ToggleKey;

		internal static ConfigEntry<float> MinDrawPercent;

		internal static ConfigEntry<bool> StopAtCharacters;

		internal static ConfigEntry<bool> ShowForCrossbows;

		internal static ConfigEntry<Color> StartColor;

		internal static ConfigEntry<Color> EndColor;

		internal static ConfigEntry<float> LineWidth;

		internal static ConfigEntry<bool> ShowImpactMarker;

		internal static ConfigEntry<Color> ImpactColor;

		internal static ConfigEntry<float> ImpactMarkerSize;

		internal static ConfigEntry<int> MaxPoints;

		private GameObject _manager;

		private void Awake()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Expected O, but got Unknown
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Expected O, but got Unknown
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Expected O, but got Unknown
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Expected O, but got Unknown
			Instance = this;
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Master toggle for the trajectory preview.");
			ToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "ToggleKey", new KeyboardShortcut((KeyCode)98, Array.Empty<KeyCode>()), "Hotkey to toggle the trajectory preview on/off while playing.");
			MinDrawPercent = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MinDrawPercent", 0.05f, new ConfigDescription("Only show the bow trajectory once the draw passes this fraction (0-1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			ShowForCrossbows = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowForCrossbows", true, "Also show the trajectory while aiming a crossbow (crossbows always fire at full power).");
			StopAtCharacters = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "StopAtCharacters", true, "If true, the predicted path and impact marker stop on creatures/animals/players too, not just terrain and structures. Set false to let the line pass through characters and only land on the world.");
			StartColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Appearance", "StartColor", new Color(1f, 1f, 1f, 0.85f), "Line color near the bow.");
			EndColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Appearance", "EndColor", new Color(1f, 0.25f, 0.2f, 0.85f), "Line color near the impact point.");
			LineWidth = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "LineWidth", 0.06f, new ConfigDescription("Width of the trajectory line in meters.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 0.5f), Array.Empty<object>()));
			ShowImpactMarker = ((BaseUnityPlugin)this).Config.Bind<bool>("Appearance", "ShowImpactMarker", true, "Show a ring marker where the arrow is predicted to land.");
			ImpactColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Appearance", "ImpactColor", new Color(1f, 0.25f, 0.2f, 0.9f), "Color of the impact marker ring.");
			ImpactMarkerSize = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "ImpactMarkerSize", 0.5f, new ConfigDescription("Radius of the impact marker ring in meters.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 3f), Array.Empty<object>()));
			MaxPoints = ((BaseUnityPlugin)this).Config.Bind<int>("Advanced", "MaxPoints", 400, new ConfigDescription("Maximum number of simulated points along the path. The simulation always uses the game's live physics timestep so the predicted arc matches the real arrow.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(16, 2048), Array.Empty<object>()));
			_manager = new GameObject("BowTrajectory_Manager");
			_manager.AddComponent<TrajectoryRenderer>();
			Object.DontDestroyOnLoad((Object)(object)_manager);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Bow Trajectory v1.0.0 loaded.");
		}

		private void OnDestroy()
		{
			if ((Object)(object)_manager != (Object)null)
			{
				Object.Destroy((Object)(object)_manager);
				_manager = null;
			}
		}
	}
	public class TrajectoryRenderer : MonoBehaviour
	{
		private LineRenderer _line;

		private LineRenderer _marker;

		private bool _userEnabled = true;

		private int _solidMask;

		private int _solidWithCharMask;

		private bool _masksReady;

		private Vector3[] _points;

		private readonly RaycastHit[] _hitBuffer = (RaycastHit[])(object)new RaycastHit[32];

		private Color _lastStart;

		private Color _lastEnd;

		private Color _lastImpact;

		private float _lastWidth = -1f;

		private void Awake()
		{
			_line = CreateLineRenderer("BowTrajectory_Line", loop: false);
			_marker = CreateLineRenderer("BowTrajectory_Marker", loop: true);
			SetVisible(visible: false);
		}

		private LineRenderer CreateLineRenderer(string name, bool loop)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			GameObject val = new GameObject(name);
			val.transform.SetParent(((Component)this).transform, false);
			LineRenderer val2 = val.AddComponent<LineRenderer>();
			val2.useWorldSpace = true;
			val2.loop = loop;
			val2.numCapVertices = 4;
			val2.numCornerVertices = 2;
			val2.textureMode = (LineTextureMode)0;
			((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)val2).receiveShadows = false;
			val2.alignment = (LineAlignment)0;
			val2.positionCount = 0;
			Shader val3 = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Particles/Standard Unlit");
			if ((Object)(object)val3 != (Object)null)
			{
				((Renderer)val2).material = new Material(val3);
			}
			if ((Object)(object)((Renderer)val2).material != (Object)null)
			{
				((Renderer)val2).material.renderQueue = 3100;
			}
			return val2;
		}

		private void EnsureMasks()
		{
			if (!_masksReady)
			{
				_solidMask = LayerMask.GetMask(new string[6] { "Default", "static_solid", "Default_small", "piece", "terrain", "vehicle" });
				_solidWithCharMask = _solidMask | LayerMask.GetMask(new string[5] { "character", "character_net", "character_ghost", "hitbox", "character_noenv" });
				_masksReady = true;
			}
		}

		private void Update()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			KeyboardShortcut value = BowTrajectoryPlugin.ToggleKey.Value;
			if (((KeyboardShortcut)(ref value)).IsDown() && !IsTextFieldFocused())
			{
				_userEnabled = !_userEnabled;
			}
		}

		private void LateUpdate()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Invalid comparison between Unknown and I4
			//IL_00f4: 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)
			if (!BowTrajectoryPlugin.Enabled.Value || !_userEnabled)
			{
				SetVisible(visible: false);
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				SetVisible(visible: false);
				return;
			}
			ItemData currentWeapon = ((Humanoid)localPlayer).GetCurrentWeapon();
			if (currentWeapon == null || currentWeapon.m_shared == null || currentWeapon.m_shared.m_attack == null)
			{
				SetVisible(visible: false);
				return;
			}
			SkillType skillType = currentWeapon.m_shared.m_skillType;
			bool bowDraw = currentWeapon.m_shared.m_attack.m_bowDraw;
			bool flag = (int)skillType == 14;
			if (!bowDraw && (!flag || !BowTrajectoryPlugin.ShowForCrossbows.Value))
			{
				SetVisible(visible: false);
				return;
			}
			float attackDrawPercentage = ((Humanoid)localPlayer).GetAttackDrawPercentage();
			Vector3 spawn;
			Vector3 dir;
			float speed;
			float gravity;
			float drag;
			float ttl;
			if (bowDraw && attackDrawPercentage < BowTrajectoryPlugin.MinDrawPercent.Value)
			{
				SetVisible(visible: false);
			}
			else if (flag && !((Character)localPlayer).IsDrawingBow() && !IsAiming(localPlayer))
			{
				SetVisible(visible: false);
			}
			else if (!ResolveLaunch(localPlayer, currentWeapon, bowDraw, attackDrawPercentage, out spawn, out dir, out speed, out gravity, out drag, out ttl))
			{
				SetVisible(visible: false);
			}
			else
			{
				Simulate(localPlayer, spawn, dir, speed, gravity, drag, ttl);
			}
		}

		private bool ResolveLaunch(Player player, ItemData weapon, bool isBow, float drawPct, out Vector3 spawn, out Vector3 dir, out float speed, out float gravity, out float drag, out float ttl)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			spawn = Vector3.zero;
			dir = Vector3.forward;
			speed = 0f;
			gravity = 0f;
			drag = 0f;
			ttl = 4f;
			Attack attack = weapon.m_shared.m_attack;
			ItemData ammoItem = ((Humanoid)player).GetAmmoItem();
			GameObject attackProjectile = attack.m_attackProjectile;
			float num = attack.m_projectileVel;
			float num2 = attack.m_projectileVelMin;
			AnimationCurve drawVelocityCurve = attack.m_drawVelocityCurve;
			if (ammoItem != null && ammoItem.m_shared != null && ammoItem.m_shared.m_attack != null && (Object)(object)ammoItem.m_shared.m_attack.m_attackProjectile != (Object)null)
			{
				attackProjectile = ammoItem.m_shared.m_attack.m_attackProjectile;
				num += ammoItem.m_shared.m_attack.m_projectileVel;
				num2 += ammoItem.m_shared.m_attack.m_projectileVelMin;
				drawVelocityCurve = ammoItem.m_shared.m_attack.m_drawVelocityCurve;
			}
			if ((Object)(object)attackProjectile == (Object)null)
			{
				return false;
			}
			if (isBow)
			{
				float num3 = ((drawVelocityCurve != null && drawVelocityCurve.length > 0) ? drawVelocityCurve.Evaluate(drawPct) : drawPct);
				speed = Mathf.Lerp(num2, num, num3);
			}
			else
			{
				speed = num;
			}
			if (speed <= 0.01f)
			{
				return false;
			}
			Projectile component = attackProjectile.GetComponent<Projectile>();
			if ((Object)(object)component != (Object)null)
			{
				gravity = component.m_gravity;
				drag = component.m_drag;
				ttl = ((component.m_ttl > 0f) ? component.m_ttl : 4f);
			}
			GetSpawnAndAim(player, weapon, attack, out spawn, out dir);
			return true;
		}

		private void GetSpawnAndAim(Player player, ItemData weapon, Attack shared, out Vector3 spawn, out Vector3 dir)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			Attack currentAttack = ((Humanoid)player).m_currentAttack;
			if (currentAttack != null && currentAttack.GetWeapon() == weapon)
			{
				try
				{
					currentAttack.GetProjectileSpawnPoint(ref spawn, ref dir);
					return;
				}
				catch
				{
				}
			}
			Transform transform = ((Component)player).transform;
			Transform val = transform;
			string attackOriginJoint = shared.m_attackOriginJoint;
			if (!string.IsNullOrEmpty(attackOriginJoint))
			{
				GameObject visual = ((Character)player).GetVisual();
				Transform val2 = Utils.FindChild(((Object)(object)visual != (Object)null) ? visual.transform : transform, attackOriginJoint, (IterativeSearchType)0);
				if ((Object)(object)val2 != (Object)null)
				{
					val = val2;
				}
			}
			spawn = val.position + transform.up * shared.m_attackHeight + transform.forward * shared.m_attackRange + transform.right * shared.m_attackOffset;
			dir = ((Humanoid)player).GetAimDir(spawn);
		}

		private void Simulate(Player owner, Vector3 spawn, Vector3 dir, float speed, float gravity, float drag, float ttl)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: 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_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			EnsureMasks();
			int value = BowTrajectoryPlugin.MaxPoints.Value;
			if (_points == null || _points.Length != value)
			{
				_points = (Vector3[])(object)new Vector3[value];
			}
			float num = Time.fixedDeltaTime;
			if (num <= 0f)
			{
				num = 0.02f;
			}
			int mask = (BowTrajectoryPlugin.StopAtCharacters.Value ? _solidWithCharMask : _solidMask);
			Vector3 val = spawn;
			Vector3 val2 = ((Vector3)(ref dir)).normalized * speed;
			_points[0] = val;
			int num2 = 1;
			float num3 = 0f;
			bool flag = false;
			Vector3 val3 = Vector3.zero;
			Vector3 normal = Vector3.up;
			while (num2 < value && num3 < ttl)
			{
				val2 += Vector3.down * (gravity * num);
				if (drag != 0f)
				{
					float num4 = ((Vector3)(ref val2)).sqrMagnitude * drag * num;
					val2 -= ((Vector3)(ref val2)).normalized * num4;
				}
				Vector3 val4 = val + val2 * num;
				Vector3 val5 = val4 - val;
				float magnitude = ((Vector3)(ref val5)).magnitude;
				if (magnitude > 0.0001f && SegmentCast(val, ((Vector3)(ref val5)).normalized, magnitude, mask, owner, out var best))
				{
					val3 = ((RaycastHit)(ref best)).point;
					normal = ((RaycastHit)(ref best)).normal;
					_points[num2++] = val3;
					flag = true;
					break;
				}
				val = val4;
				_points[num2++] = val;
				num3 += num;
			}
			ApplyStyleIfChanged();
			_line.positionCount = num2;
			_line.SetPositions(_points);
			((Renderer)_line).enabled = true;
			if (flag && BowTrajectoryPlugin.ShowImpactMarker.Value)
			{
				DrawMarker(val3, normal);
				((Renderer)_marker).enabled = true;
			}
			else
			{
				((Renderer)_marker).enabled = false;
			}
		}

		private bool SegmentCast(Vector3 origin, Vector3 dirNorm, float dist, int mask, Player owner, out RaycastHit best)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			best = default(RaycastHit);
			int num = Physics.RaycastNonAlloc(origin, dirNorm, _hitBuffer, dist, mask, (QueryTriggerInteraction)1);
			bool result = false;
			float num2 = float.MaxValue;
			for (int i = 0; i < num; i++)
			{
				RaycastHit val = _hitBuffer[i];
				if (!((Object)(object)((RaycastHit)(ref val)).collider == (Object)null) && (!((Object)(object)owner != (Object)null) || !((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<Character>() == (Object)(object)owner)) && ((RaycastHit)(ref val)).distance < num2)
				{
					num2 = ((RaycastHit)(ref val)).distance;
					best = val;
					result = true;
				}
			}
			return result;
		}

		private void DrawMarker(Vector3 point, Vector3 normal)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			Vector3 normalized = ((Vector3)(ref normal)).normalized;
			Vector3 val = Vector3.Cross(normalized, Vector3.up);
			if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
			{
				val = Vector3.Cross(normalized, Vector3.forward);
			}
			((Vector3)(ref val)).Normalize();
			Vector3 val2 = Vector3.Cross(normalized, val);
			float value = BowTrajectoryPlugin.ImpactMarkerSize.Value;
			Vector3 val3 = point + normalized * 0.03f;
			if (_marker.positionCount != 28)
			{
				_marker.positionCount = 28;
			}
			for (int i = 0; i < 28; i++)
			{
				float num = (float)i / 28f * (float)Math.PI * 2f;
				Vector3 val4 = val3 + (val * Mathf.Cos(num) + val2 * Mathf.Sin(num)) * value;
				_marker.SetPosition(i, val4);
			}
		}

		private void ApplyStyleIfChanged()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			float value = BowTrajectoryPlugin.LineWidth.Value;
			Color value2 = BowTrajectoryPlugin.StartColor.Value;
			Color value3 = BowTrajectoryPlugin.EndColor.Value;
			Color value4 = BowTrajectoryPlugin.ImpactColor.Value;
			if (!Mathf.Approximately(value, _lastWidth) || !(value2 == _lastStart) || !(value3 == _lastEnd) || !(value4 == _lastImpact))
			{
				_lastWidth = value;
				_lastStart = value2;
				_lastEnd = value3;
				_lastImpact = value4;
				_line.widthMultiplier = value;
				Gradient val = new Gradient();
				val.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
				{
					new GradientColorKey(value2, 0f),
					new GradientColorKey(value3, 1f)
				}, (GradientAlphaKey[])(object)new GradientAlphaKey[2]
				{
					new GradientAlphaKey(value2.a, 0f),
					new GradientAlphaKey(value3.a, 1f)
				});
				_line.colorGradient = val;
				_marker.widthMultiplier = value;
				_marker.startColor = value4;
				_marker.endColor = value4;
			}
		}

		private void SetVisible(bool visible)
		{
			if ((Object)(object)_line != (Object)null)
			{
				((Renderer)_line).enabled = visible;
			}
			if ((Object)(object)_marker != (Object)null)
			{
				((Renderer)_marker).enabled = visible;
			}
		}

		private static bool IsAiming(Player player)
		{
			return ((Character)player).InAttack();
		}

		private static bool IsTextFieldFocused()
		{
			try
			{
				if (Console.IsVisible())
				{
					return true;
				}
				if ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus())
				{
					return true;
				}
			}
			catch
			{
			}
			return false;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}