Decompiled source of StarPointer v0.1.6

plugins/StarPointer/StarPointer.dll

Decompiled 13 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using EntityStates;
using KinematicCharacterController;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
using On.RoR2;
using On.RoR2.UI;
using PassivePlayers;
using R2API;
using R2API.Utils;
using Rewired;
using RoR2;
using RoR2.Networking;
using RoR2.Skills;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("StarPointer")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.6.0")]
[assembly: AssemblyInformationalVersion("0.1.6")]
[assembly: AssemblyProduct("StarPointer")]
[assembly: AssemblyTitle("StarPointer")]
[assembly: AssemblyVersion("0.1.6.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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;
		}
	}
	[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 StarPointer
{
	internal static class Assets
	{
		internal static readonly Sprite[] Skins = (Sprite[])(object)new Sprite[2];

		internal static void Load()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < 2; i++)
			{
				string suffix = ((i == 0) ? "Player2.png" : "Player1.png");
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				string name = Array.Find(executingAssembly.GetManifestResourceNames(), (string x) => x.EndsWith(suffix));
				using Stream stream = executingAssembly.GetManifestResourceStream(name);
				using MemoryStream memoryStream = new MemoryStream();
				stream.CopyTo(memoryStream);
				Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false)
				{
					name = suffix,
					filterMode = (FilterMode)1,
					wrapMode = (TextureWrapMode)1
				};
				if (!ImageConversion.LoadImage(val, memoryStream.ToArray()))
				{
					throw new InvalidOperationException("Cannot load " + suffix);
				}
				Skins[i] = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), (float)((Texture)val).width);
			}
		}

		internal static Sprite For(uint skin)
		{
			return Skins[(skin == 1) ? 1u : 0u];
		}

		internal static void ConfigureSkins(GameObject prefab)
		{
			ModelSkinController componentInChildren = prefab.GetComponentInChildren<ModelSkinController>(true);
			SkinDef val = componentInChildren.skins[0];
			SkinDef[] array = (SkinDef[])(object)new SkinDef[2];
			for (int i = 0; i < 2; i++)
			{
				SkinDef val2 = Object.Instantiate<SkinDef>(val);
				((Object)val2).name = "StarPointer_" + ((i == 0) ? "Player2" : "Player1");
				Set(val2, "nameToken", (i == 0) ? "SP_SKIN2" : "SP_SKIN1");
				Set(val2, "unlockableDef", null);
				Set(val2, "unlockableName", string.Empty);
				Set(val2, "rootObject", ((Component)componentInChildren).gameObject);
				Set(val2, "baseSkins", Array.Empty<SkinDef>());
				Set(val2, "icon", Skins[i]);
				string[] array2 = new string[2] { "skinDefParamsAddress", "optimizedSkinDefParamsAddress" };
				foreach (string name in array2)
				{
					FieldInfo field = typeof(SkinDef).GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (field != null)
					{
						field.SetValue(val2, Activator.CreateInstance(field.FieldType, string.Empty));
					}
				}
				Type? obj = typeof(SkinDef).Assembly.GetType("RoR2.SkinDefParams") ?? throw new InvalidOperationException("SkinDefParams API required");
				ScriptableObject val3 = ScriptableObject.CreateInstance(obj);
				FieldInfo[] fields = obj.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (FieldInfo fieldInfo in fields)
				{
					if (fieldInfo.FieldType.IsArray)
					{
						fieldInfo.SetValue(val3, Array.CreateInstance(fieldInfo.FieldType.GetElementType(), 0));
					}
				}
				Set(val3, "rendererInfos", ((Component)componentInChildren).GetComponent<CharacterModel>().baseRendererInfos);
				Set(val2, "skinDefParams", val3);
				Set(val2, "optimizedSkinDefParams", val3);
				Set(val2, "_runtimeSkin", null);
				array[i] = val2;
			}
			componentInChildren.skins = array;
		}

		private static void Set(object target, string field, object? value)
		{
			FieldInfo field2 = target.GetType().GetField(field, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field2 != null)
			{
				field2.SetValue(target, value);
				return;
			}
			PropertyInfo property = target.GetType().GetProperty(field, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (property?.GetSetMethod(nonPublic: true) != null)
			{
				property.SetValue(target, value);
			}
		}

		internal static SpriteRenderer Sprite(string name, Transform parent, uint skin, float size)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			SpriteRenderer val2 = val.AddComponent<SpriteRenderer>();
			val2.sprite = For(skin);
			val.transform.localScale = Vector3.one * size;
			((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0;
			val.AddComponent<Billboard>();
			return val2;
		}
	}
	public sealed class Billboard : MonoBehaviour
	{
		private void OnWillRenderObject()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)Camera.current))
			{
				((Component)this).transform.rotation = ((Component)Camera.current).transform.rotation;
			}
		}
	}
	public sealed class PointerDisplay : MonoBehaviour
	{
		private SpriteRenderer sprite;

		private void Start()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].forceRenderingOff = true;
			}
			sprite = Assets.Sprite("Player 2", ((Component)this).transform, 0u, 2.5f);
			((Component)sprite).transform.localPosition = Vector3.up * 1.3f;
		}

		private void Update()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)sprite))
			{
				LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
				if (firstLocalUser != null && Object.op_Implicit((Object)(object)Plugin.BodyPrefab))
				{
					sprite.sprite = Assets.For(firstLocalUser.userProfile.loadout.bodyLoadoutManager.GetSkinIndex(BodyCatalog.FindBodyIndex(Plugin.BodyPrefab)));
				}
			}
		}
	}
	internal static class CameraRelay
	{
		private sealed class Sample
		{
			internal CameraState State;

			internal float At;

			internal Vector3 BodyPosition;
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static NetworkMessageDelegate <0>__ReceiveServer;

			public static NetworkMessageDelegate <1>__ReceiveClient;
		}

		private const short MessageId = 29121;

		private static readonly Dictionary<NetworkInstanceId, Sample> poses = new Dictionary<NetworkInstanceId, Sample>();

		private static readonly Dictionary<NetworkInstanceId, float> sentAt = new Dictionary<NetworkInstanceId, float>();

		private static bool serverRegistered;

		private static NetworkClient? clientRegistered;

		internal static void Tick()
		{
			//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_002e: Expected O, but got Unknown
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			if (NetworkServer.active && !serverRegistered)
			{
				object obj = <>O.<0>__ReceiveServer;
				if (obj == null)
				{
					NetworkMessageDelegate val = ReceiveServer;
					<>O.<0>__ReceiveServer = val;
					obj = (object)val;
				}
				NetworkServer.RegisterHandler((short)29121, (NetworkMessageDelegate)obj);
				serverRegistered = true;
			}
			if (!NetworkServer.active)
			{
				serverRegistered = false;
			}
			NetworkClient val2 = (Object.op_Implicit((Object)(object)NetworkManager.singleton) ? NetworkManager.singleton.client : null);
			if (val2 != clientRegistered)
			{
				if (clientRegistered != null)
				{
					clientRegistered.UnregisterHandler((short)29121);
				}
				clientRegistered = val2;
				if (val2 != null)
				{
					object obj2 = <>O.<1>__ReceiveClient;
					if (obj2 == null)
					{
						NetworkMessageDelegate val3 = ReceiveClient;
						<>O.<1>__ReceiveClient = val3;
						obj2 = (object)val3;
					}
					val2.RegisterHandler((short)29121, (NetworkMessageDelegate)obj2);
				}
			}
			if (!Object.op_Implicit((Object)(object)Run.instance))
			{
				poses.Clear();
				sentAt.Clear();
			}
		}

		internal static bool Get(CharacterBody body, out CameraState state)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			if (poses.TryGetValue(((NetworkBehaviour)body).netId, out Sample value) && Time.unscaledTime - value.At < 2f)
			{
				state = value.State;
				ref Vector3 position = ref state.position;
				position += body.corePosition - value.BodyPosition;
				return true;
			}
			state = default(CameraState);
			return false;
		}

		internal static void Publish(CameraRigController rig, CameraState state)
		{
			//IL_0045: 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_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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			LocalUser localUserViewer = rig.localUserViewer;
			CharacterBody val = ((localUserViewer != null) ? localUserViewer.cachedBody : null);
			if (Object.op_Implicit((Object)(object)val) && !((Object)(object)rig.targetBody != (Object)(object)val) && !PassivePlayerAPI.IsPassive(val) && val.healthComponent.alive && (!sentAt.TryGetValue(((NetworkBehaviour)val).netId, out var value) || !(Time.unscaledTime - value < 0.1f)))
			{
				sentAt[((NetworkBehaviour)val).netId] = Time.unscaledTime;
				CameraPoseMessage cameraPoseMessage = new CameraPoseMessage
				{
					BodyId = ((NetworkBehaviour)val).netId,
					Position = state.position,
					Rotation = state.rotation,
					Fov = state.fov
				};
				if (NetworkServer.active)
				{
					Accept(cameraPoseMessage);
				}
				else if (clientRegistered != null && clientRegistered.isConnected)
				{
					clientRegistered.Send((short)29121, (MessageBase)(object)cameraPoseMessage);
				}
			}
		}

		private static void ReceiveServer(NetworkMessage message)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			CameraPoseMessage cameraPoseMessage = message.ReadMessage<CameraPoseMessage>();
			GameObject val = Util.FindNetworkObject(cameraPoseMessage.BodyId);
			CharacterBody val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<CharacterBody>() : null);
			if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val2.master))
			{
				PlayerCharacterMasterController component = ((Component)val2.master).GetComponent<PlayerCharacterMasterController>();
				if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.networkUser) && ((NetworkBehaviour)component.networkUser).connectionToClient == message.conn)
				{
					Accept(cameraPoseMessage);
				}
			}
		}

		private static void Accept(CameraPoseMessage message)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Util.FindNetworkObject(message.BodyId);
			CharacterBody val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<CharacterBody>() : null);
			if ((Object)(object)val2 == (Object)null || !Object.op_Implicit((Object)(object)val2) || PassivePlayerAPI.IsPassive(val2) || !val2.healthComponent.alive || !Finite(message.Position) || !Rules.Finite(message.Rotation.x) || !Rules.Finite(message.Rotation.y) || !Rules.Finite(message.Rotation.z) || !Rules.Finite(message.Rotation.w) || !Rules.Finite(message.Fov))
			{
				return;
			}
			Vector3 val3 = message.Position - val2.corePosition;
			if (!(((Vector3)(ref val3)).sqrMagnitude > 2500f) && (!poses.TryGetValue(message.BodyId, out Sample value) || !(Time.unscaledTime - value.At < 0.075f)))
			{
				float num = message.Rotation.x * message.Rotation.x + message.Rotation.y * message.Rotation.y + message.Rotation.z * message.Rotation.z + message.Rotation.w * message.Rotation.w;
				if (!(num < 0.9f) && !(num > 1.1f))
				{
					Store(message);
					NetworkServer.SendToAll((short)29121, (MessageBase)(object)message);
				}
			}
		}

		private static void ReceiveClient(NetworkMessage message)
		{
			if (!NetworkServer.active)
			{
				Store(message.ReadMessage<CameraPoseMessage>());
			}
		}

		private static void Store(CameraPoseMessage message)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Util.FindNetworkObject(message.BodyId);
			CharacterBody val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<CharacterBody>() : null);
			poses[message.BodyId] = new Sample
			{
				State = new CameraState
				{
					position = message.Position,
					rotation = ((Quaternion)(ref message.Rotation)).normalized,
					fov = Mathf.Clamp(message.Fov, 20f, 140f)
				},
				At = Time.unscaledTime,
				BodyPosition = (Object.op_Implicit((Object)(object)val2) ? val2.corePosition : message.Position)
			};
		}

		private static bool Finite(Vector3 v)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (Rules.Finite(v.x) && Rules.Finite(v.y))
			{
				return Rules.Finite(v.z);
			}
			return false;
		}

		internal static void Shutdown()
		{
			if (serverRegistered && NetworkServer.active)
			{
				NetworkServer.UnregisterHandler((short)29121);
			}
			if (clientRegistered != null)
			{
				clientRegistered.UnregisterHandler((short)29121);
			}
			serverRegistered = false;
			clientRegistered = null;
			poses.Clear();
			sentAt.Clear();
		}
	}
	public sealed class CameraPoseMessage : MessageBase
	{
		public NetworkInstanceId BodyId;

		public Vector3 Position;

		public Quaternion Rotation;

		public float Fov;

		public override void Serialize(NetworkWriter w)
		{
			//IL_0002: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			w.Write(BodyId);
			w.Write(Position);
			w.Write(Rotation);
			w.Write(Fov);
		}

		public override void Deserialize(NetworkReader r)
		{
			//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)
			//IL_001a: 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)
			BodyId = r.ReadNetworkId();
			Position = r.ReadVector3();
			Rotation = r.ReadQuaternion();
			Fov = r.ReadSingle();
		}
	}
	internal static class HealingFeedback
	{
		internal const string EffectAddress = "RoR2/Base/Medkit/MedkitHealEffect.prefab";

		private static GameObject effect;

		internal static void Initialize()
		{
			//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)
			effect = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Medkit/MedkitHealEffect.prefab").WaitForCompletion();
			EffectComponent component = effect.GetComponent<EffectComponent>();
			if (!Object.op_Implicit((Object)(object)component) || string.IsNullOrEmpty(component.soundName))
			{
				throw new InvalidOperationException("Native healing effect is missing its positional sound.");
			}
		}

		internal static void Show(CharacterBody target)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)target))
			{
				return;
			}
			ShakeHealFeedbackCooldown shakeHealFeedbackCooldown = ((Component)target).GetComponent<ShakeHealFeedbackCooldown>();
			if (!Object.op_Implicit((Object)(object)shakeHealFeedbackCooldown))
			{
				shakeHealFeedbackCooldown = ((Component)target).gameObject.AddComponent<ShakeHealFeedbackCooldown>();
			}
			if (!(Time.fixedTime < shakeHealFeedbackCooldown.NextAt))
			{
				shakeHealFeedbackCooldown.NextAt = Time.fixedTime + 1f;
				EffectData val = new EffectData
				{
					origin = target.corePosition,
					scale = Mathf.Clamp(target.radius, 0.5f, 2f)
				};
				if (Object.op_Implicit((Object)(object)target.mainHurtBox))
				{
					val.SetHurtBoxReference(target.mainHurtBox);
				}
				else
				{
					val.SetNetworkedObjectReference(((Component)target).gameObject);
				}
				EffectManager.SpawnEffect(effect, val, true);
			}
		}
	}
	public sealed class ShakeHealFeedbackCooldown : MonoBehaviour
	{
		internal float NextAt;
	}
	[BepInPlugin("local.starpointer.survivor", "Star Pointer", "0.1.6")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Action<DamageReport> <0>__OnDeath;

			public static hook_AttemptGrant <1>__BlockPickup;

			public static hook_TakeDamage <2>__Damage;

			public static hook_OnInteractionBegin <3>__Purchase;

			public static hook_IsBodyInChargingRadius_HoldoutZoneController_Vector3_float_CharacterBody <4>__Holdout;

			public static hook_CountLivingPlayers <5>__CountLiving;
		}

		public const string Guid = "local.starpointer.survivor";

		internal static GameObject BodyPrefab;

		internal static ManualLogSource Log;

		internal static float ShotInterval;

		internal static float ShotDamage;

		internal static float OrbitSpeed;

		internal static float CameraDistance;

		internal static int BitsPerKill;

		private SurvivorDef survivor;

		private void Awake()
		{
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0401: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Unknown result type (might be due to invalid IL or missing references)
			//IL_0503: Unknown result type (might be due to invalid IL or missing references)
			//IL_0508: Unknown result type (might be due to invalid IL or missing references)
			//IL_057d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0582: Unknown result type (might be due to invalid IL or missing references)
			//IL_0588: Expected O, but got Unknown
			//IL_059d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a8: Expected O, but got Unknown
			//IL_05bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c8: Expected O, but got Unknown
			//IL_05dd: 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_05e8: Expected O, but got Unknown
			//IL_05fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0602: Unknown result type (might be due to invalid IL or missing references)
			//IL_0608: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			BitsPerKill = Mathf.Clamp(((BaseUnityPlugin)this).Config.Bind<int>("Balance", "BitsPerEnemy", 3, "Collectible Star Bits dropped per enemy death.").Value, 1, 20);
			ShotInterval = Mathf.Clamp(((BaseUnityPlugin)this).Config.Bind<float>("Balance", "ShotInterval", 0.2f, "Seconds between two-shot bursts or free gray shots before the watched player's attack speed.").Value, 0.05f, 5f);
			ShotDamage = Mathf.Clamp(((BaseUnityPlugin)this).Config.Bind<float>("Balance", "ShotDamage", 1f, "Damage coefficient of the watched player's damage stat. Proc coefficient is 1.").Value, 0.01f, 100f);
			OrbitSpeed = Mathf.Clamp(((BaseUnityPlugin)this).Config.Bind<float>("Camera", "OrbitSpeed", 105f, "WASD orbit degrees per second.").Value, 10f, 360f);
			if (Mathf.Approximately(OrbitSpeed, 90f))
			{
				OrbitSpeed = 105f;
			}
			CameraDistance = Mathf.Clamp(((BaseUnityPlugin)this).Config.Bind<float>("Camera", "Distance", 12f, "Distance from the watched player.").Value, 3f, 40f);
			Assets.Load();
			StarBitVisual.Initialize();
			HealingFeedback.Initialize();
			SurvivorDef val = Load<SurvivorDef>("RoR2/Base/Commando/Commando.asset");
			BodyPrefab = PrefabAPI.InstantiateClone(Load<GameObject>("RoR2/Base/Commando/CommandoBody.prefab"), "StarPointerBody");
			CharacterBody component = BodyPrefab.GetComponent<CharacterBody>();
			component.baseNameToken = "SP_NAME";
			component.subtitleNameToken = "SP_SUBTITLE";
			component.portraitIcon = (Texture)(object)Assets.Skins[0].texture;
			component.baseMaxHealth = 1f;
			component.levelMaxHealth = 0f;
			component.baseRegen = 0f;
			component.levelRegen = 0f;
			component.baseMaxShield = 0f;
			component.baseMoveSpeed = 0f;
			component.baseJumpPower = 0f;
			component.hideCrosshair = true;
			component.preferredPodPrefab = null;
			PassivePlayerAPI.RegisterBodyPrefab(BodyPrefab);
			BodyPrefab.AddComponent<PointerActor>();
			EntityStateMachine[] components = BodyPrefab.GetComponents<EntityStateMachine>();
			foreach (EntityStateMachine val2 in components)
			{
				if (val2.customName == "Body")
				{
					val2.mainStateType = new SerializableEntityStateType(typeof(PointerMain));
				}
			}
			bool flag = default(bool);
			ContentAddition.AddEntityState<PointerMain>(ref flag);
			ContentAddition.AddEntityState<PointerSkill>(ref flag);
			SkillLocator component2 = BodyPrefab.GetComponent<SkillLocator>();
			component2.passiveSkill.enabled = true;
			component2.passiveSkill.skillNameToken = "SP_PASSIVE";
			component2.passiveSkill.skillDescriptionToken = "SP_PASSIVE_DESC";
			component2.passiveSkill.icon = Assets.Skins[0];
			string[] array = new string[4] { "HOLD", "SHOOT", "ALIGN", "CYCLE" };
			int num = 0;
			GenericSkill[] array2 = (GenericSkill[])(object)new GenericSkill[4] { component2.primary, component2.secondary, component2.utility, component2.special };
			foreach (GenericSkill obj in array2)
			{
				SkillDef val3 = ScriptableObject.CreateInstance<SkillDef>();
				val3.skillName = "StarPointer" + array[num];
				((Object)val3).name = val3.skillName;
				val3.skillNameToken = "SP_" + array[num];
				val3.skillDescriptionToken = val3.skillNameToken + "_DESC";
				val3.icon = Assets.Skins[0];
				val3.activationState = new SerializableEntityStateType(typeof(PointerSkill));
				val3.activationStateMachineName = "Weapon";
				val3.baseMaxStock = 1;
				val3.baseRechargeInterval = 0f;
				val3.requiredStock = 1;
				val3.stockToConsume = 0;
				val3.isCombatSkill = num < 2;
				SkillFamily val4 = ScriptableObject.CreateInstance<SkillFamily>();
				((Object)val4).name = val3.skillName + "Family";
				val4.variants = (Variant[])(object)new Variant[1]
				{
					new Variant
					{
						skillDef = val3
					}
				};
				typeof(GenericSkill).GetField("_skillFamily", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(obj, val4);
				ContentAddition.AddSkillDef(val3);
				ContentAddition.AddSkillFamily(val4);
				num++;
			}
			Assets.ConfigureSkins(BodyPrefab);
			GameObject val5 = PrefabAPI.InstantiateClone(val.displayPrefab, "StarPointerDisplay", false);
			val5.AddComponent<PointerDisplay>();
			survivor = ScriptableObject.CreateInstance<SurvivorDef>();
			survivor.cachedName = "StarPointer";
			survivor.bodyPrefab = BodyPrefab;
			survivor.displayPrefab = val5;
			survivor.displayNameToken = "SP_NAME";
			survivor.descriptionToken = "SP_DESC";
			survivor.outroFlavorToken = "SP_OUTRO";
			survivor.mainEndingEscapeFailureFlavorToken = "SP_FAIL";
			survivor.primaryColor = new Color(1f, 0.6f, 0f);
			survivor.desiredSortPosition = 72f;
			AddLanguage();
			ContentAddition.AddBody(BodyPrefab);
			ContentAddition.AddSurvivorDef(survivor);
			StarBit.RegisterPrefab();
			PointerNetwork.Install();
			PointerView.Install();
			TerrainView.Install();
			GlobalEventManager.onCharacterDeathGlobal += StarBit.OnDeath;
			object obj2 = <>O.<1>__BlockPickup;
			if (obj2 == null)
			{
				hook_AttemptGrant val6 = BlockPickup;
				<>O.<1>__BlockPickup = val6;
				obj2 = (object)val6;
			}
			GenericPickupController.AttemptGrant += (hook_AttemptGrant)obj2;
			object obj3 = <>O.<2>__Damage;
			if (obj3 == null)
			{
				hook_TakeDamage val7 = Damage;
				<>O.<2>__Damage = val7;
				obj3 = (object)val7;
			}
			HealthComponent.TakeDamage += (hook_TakeDamage)obj3;
			object obj4 = <>O.<3>__Purchase;
			if (obj4 == null)
			{
				hook_OnInteractionBegin val8 = Purchase;
				<>O.<3>__Purchase = val8;
				obj4 = (object)val8;
			}
			PurchaseInteraction.OnInteractionBegin += (hook_OnInteractionBegin)obj4;
			object obj5 = <>O.<4>__Holdout;
			if (obj5 == null)
			{
				hook_IsBodyInChargingRadius_HoldoutZoneController_Vector3_float_CharacterBody val9 = Holdout;
				<>O.<4>__Holdout = val9;
				obj5 = (object)val9;
			}
			HoldoutZoneController.IsBodyInChargingRadius_HoldoutZoneController_Vector3_float_CharacterBody += (hook_IsBodyInChargingRadius_HoldoutZoneController_Vector3_float_CharacterBody)obj5;
			object obj6 = <>O.<5>__CountLiving;
			if (obj6 == null)
			{
				hook_CountLivingPlayers val10 = CountLiving;
				<>O.<5>__CountLiving = val10;
				obj6 = (object)val10;
			}
			HoldoutZoneController.CountLivingPlayers += (hook_CountLivingPlayers)obj6;
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(CatalogCheck));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Star Pointer registered with Passive Players contract v1.");
		}

		private void CatalogCheck()
		{
			//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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Catalog: body=" + ((object)BodyCatalog.FindBodyIndex(BodyPrefab)/*cast due to .constrained prefix*/).ToString() + " survivor=" + ((object)survivor.survivorIndex/*cast due to .constrained prefix*/).ToString()));
		}

		private static T Load<T>(string address) where T : Object
		{
			//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)
			return Addressables.LoadAssetAsync<T>((object)address).WaitForCompletion();
		}

		private static void BlockPickup(orig_AttemptGrant orig, GenericPickupController pickup, CharacterBody body)
		{
			if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)((Component)body).GetComponent<PointerActor>()))
			{
				orig.Invoke(pickup, body);
			}
		}

		private static void Damage(orig_TakeDamage orig, HealthComponent health, DamageInfo info)
		{
			if (Object.op_Implicit((Object)(object)health.body) && Object.op_Implicit((Object)(object)((Component)health.body).GetComponent<PointerActor>()) && !((Component)health.body).GetComponent<PointerActor>().TeamWiped)
			{
				info.rejected = true;
			}
			else
			{
				orig.Invoke(health, info);
			}
		}

		private static void Purchase(orig_OnInteractionBegin orig, PurchaseInteraction purchase, Interactor interactor)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)interactor) || !Object.op_Implicit((Object)(object)((Component)interactor).GetComponent<PointerActor>()) || PointerActions.AllowedCost(purchase.costType))
			{
				orig.Invoke(purchase, interactor);
			}
		}

		private static bool Holdout(orig_IsBodyInChargingRadius_HoldoutZoneController_Vector3_float_CharacterBody orig, HoldoutZoneController zone, Vector3 center, float radius, CharacterBody body)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)((Component)body).GetComponent<PointerActor>()))
			{
				return orig.Invoke(zone, center, radius, body);
			}
			return false;
		}

		private static int CountLiving(orig_CountLivingPlayers orig, TeamIndex team)
		{
			//IL_0001: 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)
			int num = orig.Invoke(team);
			foreach (TeamComponent teamMember in TeamComponent.GetTeamMembers(team))
			{
				if (Object.op_Implicit((Object)(object)teamMember.body) && teamMember.body.isPlayerControlled && Object.op_Implicit((Object)(object)((Component)teamMember.body).GetComponent<PointerActor>()))
				{
					num--;
				}
			}
			return Mathf.Max(0, num);
		}

		private static void AddLanguage()
		{
			LanguageAPI.Add("SP_NAME", "Star Pointer");
			LanguageAPI.Add("SP_SUBTITLE", "Player Two");
			LanguageAPI.Add("SP_DESC", "Support living teammates with a free star cursor. <style=cIsUtility>WASD</style> orbits the watched player. Hover over Star Bits to collect <style=cIsUtility>$1</style> each. Shake over an ally for over 0.5 seconds to heal 1% of their maximum HP per second. No HP or item pickups. Dies when all non-passive players are dead.\n\nPrimary: hold enemies in place or use affordable interactables.\nSecondary: spend $1 for a two-round burst; fire gray quarter-damage singles when broke.\nUtility: toggle camera binding. Special: watch the next living player.");
			LanguageAPI.Add("SP_PASSIVE", "A Helping Star");
			LanguageAPI.Add("SP_PASSIVE_DESC", "Enemies killed by anyone drop Star Bits. Hover over a bit to collect <style=cIsUtility>$1</style>. Shake over an ally for over 0.5 seconds to heal <style=cIsHealing>1% of their maximum HP per second</style> while shaking, with a forgiving radius and brief pauses. Cannot collect items or pay HP costs. Dies only when every connected non-passive teammate is dead, respecting pending revives.");
			LanguageAPI.Add("SP_HOLD", "Helping Hand");
			LanguageAPI.Add("SP_HOLD_DESC", "Hold primary over an enemy to apply the <style=cIsUtility>lunar root effect</style> continuously. Click an interactable to use it and pay its normal cost. Health and item costs are unavailable.");
			LanguageAPI.Add("SP_SHOOT", "Star Bit");
			LanguageAPI.Add("SP_SHOOT_DESC", "Spend <style=cIsUtility>$1</style> to fire a <style=cIsDamage>two-round burst</style>. With no money, fire single gray Star Bits for <style=cIsDamage>25% damage</style> at no cost. Uses the watched player's damage, attack speed, critical chance and on-hit effects. Fired bits cannot be collected.");
			LanguageAPI.Add("SP_ALIGN", "Align Camera");
			LanguageAPI.Add("SP_ALIGN_DESC", "Toggle continuous binding to the watched player's camera. Toggle off to orbit freely.");
			LanguageAPI.Add("SP_CYCLE", "Next Player");
			LanguageAPI.Add("SP_CYCLE_DESC", "Watch the next living, non-passive player on your team.");
			LanguageAPI.Add("SP_SKIN2", "Player 2");
			LanguageAPI.Add("SP_SKIN1", "Player 1");
			LanguageAPI.Add("SP_OUTRO", "...and so they left, with a helping hand.");
			LanguageAPI.Add("SP_FAIL", "...and so they vanished, with their last friend.");
		}

		private void Update()
		{
			PointerNetwork.Tick();
			CameraRelay.Tick();
			PointerView.Tick();
		}

		private void OnDestroy()
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//IL_00b0: 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_00bb: Expected O, but got Unknown
			//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_00db: Expected O, but got Unknown
			GlobalEventManager.onCharacterDeathGlobal -= StarBit.OnDeath;
			RoR2Application.onLoad = (Action)Delegate.Remove(RoR2Application.onLoad, new Action(CatalogCheck));
			object obj = <>O.<1>__BlockPickup;
			if (obj == null)
			{
				hook_AttemptGrant val = BlockPickup;
				<>O.<1>__BlockPickup = val;
				obj = (object)val;
			}
			GenericPickupController.AttemptGrant -= (hook_AttemptGrant)obj;
			object obj2 = <>O.<2>__Damage;
			if (obj2 == null)
			{
				hook_TakeDamage val2 = Damage;
				<>O.<2>__Damage = val2;
				obj2 = (object)val2;
			}
			HealthComponent.TakeDamage -= (hook_TakeDamage)obj2;
			object obj3 = <>O.<3>__Purchase;
			if (obj3 == null)
			{
				hook_OnInteractionBegin val3 = Purchase;
				<>O.<3>__Purchase = val3;
				obj3 = (object)val3;
			}
			PurchaseInteraction.OnInteractionBegin -= (hook_OnInteractionBegin)obj3;
			object obj4 = <>O.<4>__Holdout;
			if (obj4 == null)
			{
				hook_IsBodyInChargingRadius_HoldoutZoneController_Vector3_float_CharacterBody val4 = Holdout;
				<>O.<4>__Holdout = val4;
				obj4 = (object)val4;
			}
			HoldoutZoneController.IsBodyInChargingRadius_HoldoutZoneController_Vector3_float_CharacterBody -= (hook_IsBodyInChargingRadius_HoldoutZoneController_Vector3_float_CharacterBody)obj4;
			object obj5 = <>O.<5>__CountLiving;
			if (obj5 == null)
			{
				hook_CountLivingPlayers val5 = CountLiving;
				<>O.<5>__CountLiving = val5;
				obj5 = (object)val5;
			}
			HoldoutZoneController.CountLivingPlayers -= (hook_CountLivingPlayers)obj5;
			TerrainView.Uninstall();
			PointerView.Uninstall();
			PointerNetwork.Shutdown();
			CameraRelay.Shutdown();
			StarBitVisual.Shutdown();
		}
	}
	public sealed class PointerMain : BaseState
	{
	}
	public sealed class PointerSkill : BaseState
	{
		public override void OnEnter()
		{
			((BaseState)this).OnEnter();
			if (((EntityState)this).isAuthority)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
		}
	}
	internal static class PointerActions
	{
		internal const float Range = 120f;

		internal static float VisibleRange(Ray ray)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit val = default(RaycastHit);
			if (!Physics.Raycast(ray, ref val, 120f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1))
			{
				return 120f;
			}
			return ((RaycastHit)(ref val)).distance;
		}

		internal static bool AllowedCost(CostTypeIndex type)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Invalid comparison between Unknown and I4
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			if ((int)type != 0 && (int)type != 1 && (int)type != 3)
			{
				return (int)type == 14;
			}
			return true;
		}

		internal static void Root(PointerActor actor, Ray ray)
		{
			//IL_0000: 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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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)
			RaycastHit val = default(RaycastHit);
			if (Physics.SphereCast(ray, 0.55f, ref val, VisibleRange(ray), LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.entityPrecise)).mask), (QueryTriggerInteraction)1))
			{
				HurtBox component = ((Component)((RaycastHit)(ref val)).collider).GetComponent<HurtBox>();
				CharacterBody val2 = ((Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.healthComponent)) ? component.healthComponent.body : null);
				if (Object.op_Implicit((Object)(object)val2) && val2.healthComponent.alive && val2.teamComponent.teamIndex != actor.Body.teamComponent.teamIndex && (int)val2.teamComponent.teamIndex != 0)
				{
					val2.AddTimedBuff(Buffs.LunarSecondaryRoot, 0.12f);
				}
			}
		}

		internal static CharacterBody? HealingAlly(PointerActor actor, Ray ray, CharacterBody? previous)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			float range = VisibleRange(ray);
			if (Near(previous))
			{
				return previous;
			}
			CharacterBody result = null;
			float num = float.MaxValue;
			foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList)
			{
				if (Near(readOnlyInstances))
				{
					float num2 = Vector3.Dot(readOnlyInstances.corePosition - ((Ray)(ref ray)).origin, ((Ray)(ref ray)).direction);
					if (num2 < num)
					{
						num = num2;
						result = readOnlyInstances;
					}
				}
			}
			return result;
			bool Near(CharacterBody? body)
			{
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: 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_007f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c9: 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_00e2: 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)
				if (!Object.op_Implicit((Object)(object)body) || (Object)(object)body == (Object)(object)actor.Body || !Object.op_Implicit((Object)(object)body.healthComponent) || !body.healthComponent.alive || body.teamComponent.teamIndex != actor.Body.teamComponent.teamIndex || PassivePlayerAPI.IsPassive(body))
				{
					return false;
				}
				Vector3 val = body.corePosition - ((Ray)(ref ray)).origin;
				float num3 = Vector3.Dot(val, ((Ray)(ref ray)).direction);
				float num4 = Mathf.Max(0.5f, body.radius) + 3f;
				if (num3 >= 0f && num3 <= range)
				{
					Vector3 val2 = val - ((Ray)(ref ray)).direction * num3;
					if (((Vector3)(ref val2)).sqrMagnitude <= num4 * num4)
					{
						return !Physics.Linecast(((Ray)(ref ray)).origin, body.corePosition, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1);
					}
				}
				return false;
			}
		}

		internal static IInteractable? FindInteractable(PointerActor actor, Ray ray)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit[] array = Physics.SphereCastAll(ray, 0.75f, VisibleRange(ray) + 0.2f, LayerMask.op_Implicit(CommonMasks.interactable), (QueryTriggerInteraction)2);
			Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance));
			RaycastHit[] array2 = array;
			for (int num = 0; num < array2.Length; num++)
			{
				RaycastHit val = array2[num];
				GameObject entity = EntityLocator.GetEntity(((Component)((RaycastHit)(ref val)).collider).gameObject);
				MonoBehaviour[] array3 = (Object.op_Implicit((Object)(object)entity) ? entity.GetComponentsInParent<MonoBehaviour>() : ((Component)((RaycastHit)(ref val)).collider).GetComponentsInParent<MonoBehaviour>());
				foreach (MonoBehaviour val2 in array3)
				{
					IInteractable val3 = (IInteractable)(object)((val2 is IInteractable) ? val2 : null);
					if (val3 != null && !(val2 is GenericPickupController) && !(val2 is PickupPickerController) && !(val2 is VehicleSeat))
					{
						PurchaseInteraction val4 = (PurchaseInteraction)(object)((val2 is PurchaseInteraction) ? val2 : null);
						if (val4 != null && !AllowedCost(val4.costType))
						{
							return null;
						}
						return val3;
					}
				}
			}
			return null;
		}

		internal static void Interact(PointerActor actor, Ray ray)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Invalid comparison between Unknown and I4
			Interactor component = ((Component)actor).GetComponent<Interactor>();
			IInteractable val = FindInteractable(actor, ray);
			if (val != null && (int)val.GetInteractability(component) == 2)
			{
				val.OnInteractionBegin(component);
			}
		}
	}
	public sealed class PointerActor : NetworkBehaviour
	{
		internal CharacterBody Body;

		internal CharacterBody? Watched;

		private CharacterMotor motor;

		private KinematicCharacterMotor kcc;

		private float inputAt;

		private float acceptedAt;

		private float interactAt;

		private uint sentSequence;

		private uint receivedSequence;

		private bool receivedAny;

		private bool holding;

		private bool shooting;

		private bool inputEnabled;

		private readonly BurstFire burst = new BurstFire();

		private readonly ShakeGesture shake = new ShakeGesture();

		private CharacterBody? healingAlly;

		private Ray ray;

		private NetworkInstanceId watchedId;

		private Vector3 synchronizedPosition;

		private float cycleAt;

		internal bool TeamWiped => ((Component)this).GetComponent<PassivePlayer>().WipeInProgress;

		private void Awake()
		{
			Body = ((Component)this).GetComponent<CharacterBody>();
			motor = ((Component)this).GetComponent<CharacterMotor>();
			kcc = ((Component)this).GetComponent<KinematicCharacterMotor>();
		}

		private void Start()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)motor))
			{
				motor.velocity = Vector3.zero;
				((Behaviour)motor).enabled = false;
			}
			if (Object.op_Implicit((Object)(object)kcc))
			{
				((Behaviour)kcc).enabled = false;
				KinematicCharacterSystem.CharacterMotors.Remove(kcc);
			}
			CharacterNetworkTransform component = ((Component)this).GetComponent<CharacterNetworkTransform>();
			if (Object.op_Implicit((Object)(object)component))
			{
				((Behaviour)component).enabled = false;
			}
			InteractionDriver component2 = ((Component)this).GetComponent<InteractionDriver>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				((Behaviour)component2).enabled = false;
			}
			Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].forceRenderingOff = true;
			}
			Collider[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<Collider>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				componentsInChildren2[i].enabled = false;
			}
			HurtBox[] componentsInChildren3 = ((Component)this).GetComponentsInChildren<HurtBox>(true);
			for (int i = 0; i < componentsInChildren3.Length; i++)
			{
				((Behaviour)componentsInChildren3[i]).enabled = false;
			}
			if (Object.op_Implicit((Object)(object)Body.teamComponent))
			{
				((Behaviour)Body.teamComponent).enabled = false;
			}
			if (NetworkServer.active)
			{
				Body.healthComponent.godMode = true;
				if (Object.op_Implicit((Object)(object)Body.master))
				{
					PassivePlayerAPI.SetCannotRevive(Body.master, false);
				}
				SelectNext();
			}
			synchronizedPosition = ((Component)this).transform.position;
		}

		internal bool ValidPlayer(CharacterBody? body)
		{
			//IL_0053: 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)
			if (!Object.op_Implicit((Object)(object)body) || (Object)(object)body == (Object)(object)Body || !Object.op_Implicit((Object)(object)body.master) || !body.isPlayerControlled || PassivePlayerAPI.IsPassive(body) || !Object.op_Implicit((Object)(object)body.healthComponent) || !body.healthComponent.alive || body.teamComponent.teamIndex != Body.teamComponent.teamIndex)
			{
				return false;
			}
			PlayerCharacterMasterController component = ((Component)body.master).GetComponent<PlayerCharacterMasterController>();
			if (Object.op_Implicit((Object)(object)component))
			{
				return component.isConnected;
			}
			return false;
		}

		internal void SelectNext()
		{
			CharacterBody val = null;
			bool flag = !Object.op_Implicit((Object)(object)Watched);
			bool flag2 = false;
			foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
			{
				CharacterBody val2 = (Object.op_Implicit((Object)(object)instance.master) ? instance.master.GetBody() : null);
				if (ValidPlayer(val2))
				{
					if (!Object.op_Implicit((Object)(object)val))
					{
						val = val2;
					}
					if (flag)
					{
						SetWatched(val2);
						flag2 = true;
						break;
					}
					if ((Object)(object)val2 == (Object)(object)Watched)
					{
						flag = true;
					}
				}
			}
			if (!flag2)
			{
				SetWatched(val);
			}
		}

		private void SetWatched(CharacterBody? body)
		{
			//IL_0075: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)body != (Object)(object)Watched)
			{
				acceptedAt = float.NegativeInfinity;
				holding = (shooting = (inputEnabled = false));
				healingAlly = null;
				shake.Reset();
				burst.Step(Time.fixedTime, trigger: false, fresh: false, hasMoney: false, Plugin.ShotInterval);
			}
			Watched = body;
			watchedId = (Object.op_Implicit((Object)(object)body) ? ((NetworkBehaviour)body).netId : NetworkInstanceId.Invalid);
			if (NetworkServer.active)
			{
				((NetworkBehaviour)this).SetDirtyBit(1u);
			}
		}

		private void Update()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active && (!Object.op_Implicit((Object)(object)Watched) || ((NetworkBehaviour)Watched).netId != watchedId))
			{
				GameObject val = Util.FindNetworkObject(watchedId);
				Watched = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<CharacterBody>() : null);
			}
		}

		private void FixedUpdate()
		{
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: 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_0248: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)Body) || !Object.op_Implicit((Object)(object)Body.healthComponent) || !Body.healthComponent.alive)
			{
				return;
			}
			if (NetworkServer.active)
			{
				if (!ValidPlayer(Watched))
				{
					SelectNext();
				}
				if (!TeamWiped)
				{
					Body.healthComponent.godMode = true;
				}
				if (Object.op_Implicit((Object)(object)Watched))
				{
					synchronizedPosition = Watched.corePosition;
					((NetworkBehaviour)this).SetDirtyBit(1u);
				}
				if (inputEnabled && Time.fixedTime - acceptedAt <= 0.25f && ValidPlayer(Watched))
				{
					StarBit.Collect(this, ray);
					if (holding)
					{
						PointerActions.Root(this, ray);
					}
					ShotKind shotKind = burst.Step(Time.fixedTime, shooting, fresh: true, Object.op_Implicit((Object)(object)Body.master) && Body.master.money != 0, Plugin.ShotInterval / Mathf.Clamp(Watched.attackSpeed, 0.1f, 10f));
					if (shotKind != ShotKind.None)
					{
						if (shotKind == ShotKind.PaidFirst)
						{
							CharacterMaster master = Body.master;
							master.money -= 1;
						}
						StarBit.Fire(this, ray, shotKind == ShotKind.Gray);
					}
					if (inputEnabled && Object.op_Implicit((Object)(object)healingAlly) && healingAlly.healthComponent.alive && healingAlly.teamComponent.teamIndex == Body.teamComponent.teamIndex && !PassivePlayerAPI.IsPassive(healingAlly) && shake.Healing(Time.fixedTime) && !Physics.Linecast(((Ray)(ref ray)).origin, healingAlly.corePosition, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1) && healingAlly.healthComponent.Heal(healingAlly.healthComponent.fullHealth * 0.01f * Time.fixedDeltaTime, default(ProcChainMask), true) > 0f)
					{
						HealingFeedback.Show(healingAlly);
					}
				}
				else
				{
					holding = false;
					shooting = false;
					shake.Reset();
					healingAlly = null;
					burst.Step(Time.fixedTime, trigger: false, fresh: false, hasMoney: false, Plugin.ShotInterval);
				}
			}
			if (Object.op_Implicit((Object)(object)kcc))
			{
				kcc.SetPosition(synchronizedPosition, true);
			}
			else
			{
				((Component)this).transform.position = synchronizedPosition;
			}
		}

		internal void Send(Ray cursor, Vector2 screenCursor, bool primary, bool secondary, bool click, bool cycle, bool enabled = true)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_0092: 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_00ad: 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)
			if (((NetworkBehaviour)this).hasAuthority && (!(Time.unscaledTime < inputAt) || click || cycle))
			{
				inputAt = Time.unscaledTime + 0.05f;
				PointerNetwork.Send(new PointerIntent
				{
					BodyId = ((NetworkBehaviour)this).netId,
					Sequence = ++sentSequence,
					Origin = ((Ray)(ref cursor)).origin,
					Direction = ((Ray)(ref cursor)).direction,
					Primary = primary,
					Secondary = secondary,
					Click = click,
					Cycle = cycle,
					Cursor = screenCursor,
					Enabled = enabled,
					WatchedId = (Object.op_Implicit((Object)(object)Watched) ? ((NetworkBehaviour)Watched).netId : NetworkInstanceId.Invalid)
				});
			}
		}

		internal void Accept(PointerIntent input)
		{
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: 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_01a9: 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_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: 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_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)Body) || !Body.healthComponent.alive || TeamWiped || (receivedAny && !Rules.Newer(receivedSequence, input.Sequence)))
			{
				return;
			}
			receivedSequence = input.Sequence;
			receivedAny = true;
			if (input.Cycle && Time.fixedTime >= cycleAt)
			{
				cycleAt = Time.fixedTime + 0.25f;
				SelectNext();
			}
			if (input.Cycle)
			{
				holding = (shooting = false);
				shake.Reset();
				healingAlly = null;
				burst.Step(Time.fixedTime, trigger: false, fresh: false, hasMoney: false, Plugin.ShotInterval);
			}
			else
			{
				if ((Object.op_Implicit((Object)(object)Watched) && input.WatchedId != ((NetworkBehaviour)Watched).netId) || !ValidPlayer(Watched) || !Finite(input.Origin) || !Finite(input.Direction) || !Rules.Finite(input.Cursor.x) || !Rules.Finite(input.Cursor.y) || input.Cursor.x < 0f || input.Cursor.x > 8f || input.Cursor.y < 0f || input.Cursor.y > 1f)
				{
					return;
				}
				float magnitude = ((Vector3)(ref input.Direction)).magnitude;
				if (magnitude < 0.9f || magnitude > 1.1f)
				{
					return;
				}
				Vector3 val = input.Origin - Watched.corePosition;
				if (((Vector3)(ref val)).sqrMagnitude > 2500f)
				{
					return;
				}
				ray = new Ray(input.Origin, ((Vector3)(ref input.Direction)).normalized);
				acceptedAt = Time.fixedTime;
				holding = input.Enabled && input.Primary;
				shooting = input.Enabled && input.Secondary;
				inputEnabled = input.Enabled;
				if (!input.Enabled)
				{
					shake.Reset();
					healingAlly = null;
					burst.Step(Time.fixedTime, trigger: false, fresh: false, hasMoney: false, Plugin.ShotInterval);
				}
				else
				{
					CharacterBody val2 = PointerActions.HealingAlly(this, ray, healingAlly);
					if (Object.op_Implicit((Object)(object)val2) && (Object)(object)val2 != (Object)(object)healingAlly)
					{
						healingAlly = val2;
						shake.Reset();
					}
					shake.Sample(Time.fixedTime, input.Cursor.x, input.Cursor.y, Object.op_Implicit((Object)(object)val2));
				}
				if (input.Enabled && input.Click && input.Primary && Time.fixedTime >= interactAt)
				{
					interactAt = Time.fixedTime + 0.35f;
					PointerActions.Interact(this, ray);
				}
			}
		}

		private static bool Finite(Vector3 v)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (Rules.Finite(v.x) && Rules.Finite(v.y))
			{
				return Rules.Finite(v.z);
			}
			return false;
		}

		public override bool OnSerialize(NetworkWriter writer, bool initialState)
		{
			//IL_0002: 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)
			writer.Write(watchedId);
			writer.Write(((Component)this).transform.position);
			return true;
		}

		public override void OnDeserialize(NetworkReader reader, bool initialState)
		{
			//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)
			watchedId = reader.ReadNetworkId();
			synchronizedPosition = reader.ReadVector3();
		}
	}
	internal static class PointerNetwork
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static NetworkMessageDelegate <0>__Receive;
		}

		private const short IntentId = 29120;

		private static bool registered;

		internal static void Install()
		{
			Tick();
		}

		internal static void Tick()
		{
			//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_002e: Expected O, but got Unknown
			if (NetworkServer.active && !registered)
			{
				object obj = <>O.<0>__Receive;
				if (obj == null)
				{
					NetworkMessageDelegate val = Receive;
					<>O.<0>__Receive = val;
					obj = (object)val;
				}
				NetworkServer.RegisterHandler((short)29120, (NetworkMessageDelegate)obj);
				registered = true;
			}
			if (!NetworkServer.active)
			{
				registered = false;
			}
		}

		internal static void Send(PointerIntent input)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			Tick();
			if (NetworkServer.active)
			{
				GameObject val = Util.FindNetworkObject(input.BodyId);
				if (Object.op_Implicit((Object)(object)val))
				{
					val.GetComponent<PointerActor>()?.Accept(input);
				}
			}
			else
			{
				NetworkClient val2 = (Object.op_Implicit((Object)(object)NetworkManager.singleton) ? NetworkManager.singleton.client : null);
				if (val2 != null && val2.isConnected)
				{
					val2.Send((short)29120, (MessageBase)(object)input);
				}
			}
		}

		private static void Receive(NetworkMessage message)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			PointerIntent pointerIntent = message.ReadMessage<PointerIntent>();
			GameObject val = Util.FindNetworkObject(pointerIntent.BodyId);
			PointerActor pointerActor = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<PointerActor>() : null);
			if (Object.op_Implicit((Object)(object)pointerActor) && Object.op_Implicit((Object)(object)pointerActor.Body.master))
			{
				PlayerCharacterMasterController component = ((Component)pointerActor.Body.master).GetComponent<PlayerCharacterMasterController>();
				if (((NetworkBehaviour)pointerActor).connectionToClient == message.conn || (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.networkUser) && ((NetworkBehaviour)component.networkUser).connectionToClient == message.conn))
				{
					pointerActor.Accept(pointerIntent);
				}
			}
		}

		internal static void Shutdown()
		{
			if (registered && NetworkServer.active)
			{
				NetworkServer.UnregisterHandler((short)29120);
			}
			registered = false;
		}
	}
	public sealed class PointerIntent : MessageBase
	{
		public NetworkInstanceId BodyId;

		public NetworkInstanceId WatchedId;

		public uint Sequence;

		public Vector3 Origin;

		public Vector3 Direction;

		public Vector2 Cursor;

		public bool Primary;

		public bool Secondary;

		public bool Click;

		public bool Cycle;

		public bool Enabled;

		public override void Serialize(NetworkWriter w)
		{
			//IL_0002: 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_0026: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			w.Write(BodyId);
			w.Write(WatchedId);
			w.Write(Sequence);
			w.Write(Origin);
			w.Write(Direction);
			w.Write(Primary);
			w.Write(Secondary);
			w.Write(Click);
			w.Write(Cycle);
			w.Write(Cursor);
			w.Write(Enabled);
		}

		public override void Deserialize(NetworkReader r)
		{
			//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)
			//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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			BodyId = r.ReadNetworkId();
			WatchedId = r.ReadNetworkId();
			Sequence = r.ReadUInt32();
			Origin = r.ReadVector3();
			Direction = r.ReadVector3();
			Primary = r.ReadBoolean();
			Secondary = r.ReadBoolean();
			Click = r.ReadBoolean();
			Cycle = r.ReadBoolean();
			Cursor = r.ReadVector2();
			Enabled = r.ReadBoolean();
		}
	}
	internal static class PointerView
	{
		private sealed class ViewGUI
		{
			internal GameObject? Object;
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static hook_SetCameraState <0>__CameraState;

			public static hook_LateUpdate <1>__CursorUpdate;

			public static hook_AttemptPing <2>__Ping;

			public static hook_ModifyAimRayIfApplicable <3>__PreserveCursorRay;
		}

		private static PointerActor? local;

		private static Hook? visibilityHook;

		private static CharacterBody? lastWatched;

		private static CameraRigController? activeRig;

		private static float yaw;

		private static float pitch;

		private static float viewFov = 60f;

		private static float yawVelocity;

		private static float pitchVelocity;

		private static float zoomGoal = 12f;

		private static bool cameraBound;

		private static bool boundPoseReady;

		private static bool haveMouse;

		private static CameraState boundPose;

		private static Vector2 previousMouse;

		private static float pointerAngle;

		private static float spinVelocity;

		private static Ray cursorRay;

		private static bool haveCursorRay;

		private static int lastPingFrame = -1;

		private static Vector3 viewOffset = new Vector3(0f, 0f, -12f);

		private static bool waitingForPose;

		private static bool primaryHeld;

		private static bool utilityHeld;

		private static bool specialHeld;

		private static bool cursorOwned;

		private static bool oldVisible;

		private static CursorLockMode oldLock;

		private static int inputFrame = -1;

		private static GameObject? hiddenHealth;

		private static bool oldHealthActive;

		private static readonly ViewGUI gui = new ViewGUI();

		internal static Vector3 Subject
		{
			get
			{
				//IL_001d: 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)
				if (!Object.op_Implicit((Object)(object)local) || !Object.op_Implicit((Object)(object)local.Watched))
				{
					return Vector3.zero;
				}
				return local.Watched.corePosition;
			}
		}

		internal static CharacterBody? WatchedBody
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)local))
				{
					return null;
				}
				return local.Watched;
			}
		}

		internal static void Install()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_009f: 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_00aa: Expected O, but got Unknown
			visibilityHook = new Hook((MethodBase)typeof(MPEventSystem).GetProperty("isCursorVisible").GetGetMethod(), (Delegate)new Func<Func<MPEventSystem, bool>, MPEventSystem, bool>(CursorVisible));
			object obj = <>O.<0>__CameraState;
			if (obj == null)
			{
				hook_SetCameraState val = CameraState;
				<>O.<0>__CameraState = val;
				obj = (object)val;
			}
			CameraRigController.SetCameraState += (hook_SetCameraState)obj;
			object obj2 = <>O.<1>__CursorUpdate;
			if (obj2 == null)
			{
				hook_LateUpdate val2 = CursorUpdate;
				<>O.<1>__CursorUpdate = val2;
				obj2 = (object)val2;
			}
			MPEventSystem.LateUpdate += (hook_LateUpdate)obj2;
			object obj3 = <>O.<2>__Ping;
			if (obj3 == null)
			{
				hook_AttemptPing val3 = Ping;
				<>O.<2>__Ping = val3;
				obj3 = (object)val3;
			}
			PingerController.AttemptPing += (hook_AttemptPing)obj3;
			object obj4 = <>O.<3>__PreserveCursorRay;
			if (obj4 == null)
			{
				hook_ModifyAimRayIfApplicable val4 = PreserveCursorRay;
				<>O.<3>__PreserveCursorRay = val4;
				obj4 = (object)val4;
			}
			CameraRigController.ModifyAimRayIfApplicable += (hook_ModifyAimRayIfApplicable)obj4;
			gui.Object = new GameObject("StarPointer UI");
			Object.DontDestroyOnLoad((Object)(object)gui.Object);
			gui.Object.AddComponent<PointerGUI>();
		}

		internal static bool IsPointerCamera(Camera camera)
		{
			if (Object.op_Implicit((Object)(object)activeRig) && (Object)(object)activeRig.sceneCam == (Object)(object)camera && Object.op_Implicit((Object)(object)local))
			{
				return local.Body.healthComponent.alive;
			}
			return false;
		}

		private static PointerActor? For(CameraRigController rig)
		{
			LocalUser localUserViewer = rig.localUserViewer;
			if (localUserViewer == null || localUserViewer.inputPlayer == null || !localUserViewer.inputPlayer.controllers.hasKeyboard || !Object.op_Implicit((Object)(object)localUserViewer.cachedBody))
			{
				return null;
			}
			return ((Component)localUserViewer.cachedBody).GetComponent<PointerActor>();
		}

		private static bool Blocked(CameraRigController rig)
		{
			LocalUser localUserViewer = rig.localUserViewer;
			if (!Application.isFocused || localUserViewer == null || Object.op_Implicit((Object)(object)localUserViewer.pauseScreenController) || Time.timeScale == 0f)
			{
				return true;
			}
			MPEventSystem val = MPEventSystem.FindByPlayer(localUserViewer.inputPlayer);
			if (Object.op_Implicit((Object)(object)val) && val.cursorOpenerCount > 0)
			{
				return true;
			}
			GameObject val2 = (Object.op_Implicit((Object)(object)EventSystem.current) ? EventSystem.current.currentSelectedGameObject : null);
			if ((Object)(object)val2 != (Object)null && Object.op_Implicit((Object)(object)val2))
			{
				if (!Object.op_Implicit((Object)(object)val2.GetComponent<InputField>()))
				{
					return Object.op_Implicit((Object)(object)val2.GetComponent<TMP_InputField>());
				}
				return true;
			}
			return false;
		}

		private static void CameraState(orig_SetCameraState orig, CameraRigController rig, CameraState state)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: 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_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: 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_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0409: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0445: Unknown result type (might be due to invalid IL or missing references)
			//IL_0447: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Unknown result type (might be due to invalid IL or missing references)
			//IL_0415: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: 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_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_049b: Unknown result type (might be due to invalid IL or missing references)
			PointerActor pointerActor = For(rig);
			if ((Object)(object)pointerActor == (Object)null || !Object.op_Implicit((Object)(object)pointerActor) || !pointerActor.Body.healthComponent.alive)
			{
				if ((Object)(object)activeRig == (Object)(object)rig)
				{
					Release();
				}
				orig.Invoke(rig, state);
				CameraRelay.Publish(rig, state);
				return;
			}
			local = pointerActor;
			activeRig = rig;
			HideHealth(rig);
			if (!Object.op_Implicit((Object)(object)pointerActor.Watched))
			{
				orig.Invoke(rig, state);
				return;
			}
			CharacterBody watched = pointerActor.Watched;
			if ((Object)(object)lastWatched != (Object)(object)watched)
			{
				lastWatched = watched;
				boundPoseReady = false;
				Align(watched);
			}
			if (waitingForPose && CameraRelay.Get(watched, out var _))
			{
				Align(watched);
			}
			bool flag = Blocked(rig);
			if (inputFrame != Time.frameCount)
			{
				inputFrame = Time.frameCount;
				Player inputPlayer = rig.localUserViewer.inputPlayer;
				bool flag2 = !flag && inputPlayer.GetButton(7);
				bool secondary = !flag && inputPlayer.GetButton(8);
				bool num = !flag && inputPlayer.GetButton(9);
				bool flag3 = !flag && inputPlayer.GetButton(10);
				if (num && !utilityHeld)
				{
					cameraBound = !cameraBound;
					boundPoseReady = false;
					Align(watched);
				}
				float num2 = Mathf.Min(0.1f, Time.unscaledDeltaTime);
				float num3 = ((!flag && !cameraBound) ? ((Input.GetKey((KeyCode)97) ? 1 : 0) - (Input.GetKey((KeyCode)100) ? 1 : 0)) : 0);
				float num4 = ((!flag && !cameraBound) ? ((Input.GetKey((KeyCode)119) ? 1 : 0) - (Input.GetKey((KeyCode)115) ? 1 : 0)) : 0);
				yawVelocity = Rules.Approach(yawVelocity, num3 * Plugin.OrbitSpeed, num2);
				pitchVelocity = Rules.Approach(pitchVelocity, num4 * Plugin.OrbitSpeed, num2);
				if (!flag && !cameraBound)
				{
					yaw += yawVelocity * num2;
					pitch = Mathf.Clamp(pitch + pitchVelocity * num2, -80f, 80f);
					if (pitch <= -80f || pitch >= 80f)
					{
						pitchVelocity = 0f;
					}
					float y = Input.mouseScrollDelta.y;
					if (y != 0f)
					{
						zoomGoal = Rules.ZoomDistance(zoomGoal, y);
						waitingForPose = false;
					}
					float magnitude = ((Vector3)(ref viewOffset)).magnitude;
					viewOffset = ((magnitude > 0.001f) ? (viewOffset / magnitude) : Vector3.back) * Rules.Approach(magnitude, zoomGoal, num2, 0.12f);
				}
				Vector2 val = Vector2.op_Implicit(Input.mousePosition);
				Vector2 val2 = ((haveMouse && !flag) ? (val - previousMouse) : Vector2.zero);
				previousMouse = val;
				haveMouse = true;
				if (num2 > 0f)
				{
					spinVelocity = Rules.PointerSpin(spinVelocity, val2.x / num2 * 0.02f, (0f - val2.y) / num2 * 0.02f, num2);
				}
				pointerAngle = Mathf.Repeat(pointerAngle + spinVelocity * num2, 360f);
				Calculate(watched, ref state);
				Camera sceneCam = rig.sceneCam;
				Vector3 position = ((Component)sceneCam).transform.position;
				Quaternion rotation = ((Component)sceneCam).transform.rotation;
				float fieldOfView = sceneCam.fieldOfView;
				sceneCam.fieldOfView = state.fov;
				((Component)sceneCam).transform.SetPositionAndRotation(state.position, state.rotation);
				Ray val3 = (cursorRay = sceneCam.ScreenPointToRay(Input.mousePosition));
				haveCursorRay = true;
				((Component)sceneCam).transform.SetPositionAndRotation(position, rotation);
				sceneCam.fieldOfView = fieldOfView;
				Vector3 mousePosition = Input.mousePosition;
				Rect pixelRect = sceneCam.pixelRect;
				Vector2 screenCursor = default(Vector2);
				((Vector2)(ref screenCursor))..ctor((mousePosition.x - ((Rect)(ref pixelRect)).x) / ((Rect)(ref pixelRect)).height, (mousePosition.y - ((Rect)(ref pixelRect)).y) / ((Rect)(ref pixelRect)).height);
				if (((Rect)(ref pixelRect)).Contains(mousePosition))
				{
					pointerActor.Send(val3, screenCursor, flag2, secondary, flag2 && !primaryHeld, flag3 && !specialHeld, !flag);
				}
				else
				{
					pointerActor.Send(val3, Vector2.zero, primary: false, secondary: false, click: false, cycle: false, enabled: false);
				}
				if (!flag && ((Rect)(ref pixelRect)).Contains(mousePosition) && Input.GetMouseButtonDown(2) && Object.op_Implicit((Object)(object)pointerActor.Body.master))
				{
					PingerController component = ((Component)pointerActor.Body.master).GetComponent<PingerController>();
					if (Object.op_Implicit((Object)(object)component))
					{
						component.AttemptPing(val3, ((Component)pointerActor.Body).gameObject);
					}
				}
				primaryHeld = flag2;
				utilityHeld = num;
				specialHeld = flag3;
			}
			else
			{
				Calculate(watched, ref state);
			}
			orig.Invoke(rig, state);
		}

		private static void HideHealth(CameraRigController rig)
		{
			if (Object.op_Implicit((Object)(object)rig.hud) && Object.op_Implicit((Object)(object)rig.hud.healthBar))
			{
				GameObject gameObject = ((Component)rig.hud.healthBar).gameObject;
				if ((Object)(object)hiddenHealth != (Object)(object)gameObject)
				{
					RestoreHealth();
					hiddenHealth = gameObject;
					oldHealthActive = gameObject.activeSelf;
				}
				gameObject.SetActive(false);
			}
		}

		internal static void Tick()
		{
			if (cursorOwned && (!Object.op_Implicit((Object)(object)local) || !Object.op_Implicit((Object)(object)activeRig) || !Object.op_Implicit((Object)(object)Run.instance) || !local.Body.healthComponent.alive))
			{
				Release();
			}
		}

		private static void Calculate(CharacterBody watched, ref CameraState state)
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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)
			if (cameraBound && CameraRelay.Get(watched, out var state2))
			{
				if (!boundPoseReady)
				{
					boundPose = state2;
					boundPoseReady = true;
				}
				float num = 1f - Mathf.Exp(-18f * Time.unscaledDeltaTime);
				boundPose.position = Vector3.Lerp(boundPose.position, state2.position, num);
				boundPose.rotation = Quaternion.Slerp(boundPose.rotation, state2.rotation, num);
				boundPose.fov = Mathf.Lerp(boundPose.fov, state2.fov, num);
				state = boundPose;
			}
			else
			{
				state.rotation = Quaternion.Euler(pitch, yaw, 0f);
				state.position = watched.corePosition + state.rotation * viewOffset;
				state.fov = viewFov;
			}
		}

		private static void Align(CharacterBody watched)
		{
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: 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_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			yawVelocity = (pitchVelocity = 0f);
			if (CameraRelay.Get(watched, out var state))
			{
				Quaternion rotation = state.rotation;
				Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles;
				yaw = eulerAngles.y;
				pitch = Mathf.Clamp(Mathf.DeltaAngle(0f, eulerAngles.x), -80f, 80f);
				viewOffset = Quaternion.Inverse(Quaternion.Euler(pitch, yaw, 0f)) * (state.position - watched.corePosition);
				viewFov = state.fov;
				zoomGoal = ((Vector3)(ref viewOffset)).magnitude;
				waitingForPose = false;
				return;
			}
			waitingForPose = true;
			viewOffset = new Vector3(0f, 0f, 0f - Plugin.CameraDistance);
			zoomGoal = Plugin.CameraDistance;
			viewFov = 60f;
			Vector3 val = (Object.op_Implicit((Object)(object)watched.inputBank) ? watched.inputBank.aimDirection : ((Component)watched).transform.forward);
			if (((Vector3)(ref val)).sqrMagnitude < 0.1f)
			{
				val = ((Component)watched).transform.forward;
			}
			Quaternion val2 = Quaternion.LookRotation(val);
			Vector3 eulerAngles2 = ((Quaternion)(ref val2)).eulerAngles;
			yaw = eulerAngles2.y;
			pitch = Mathf.Clamp(Mathf.DeltaAngle(0f, eulerAngles2.x), -80f, 80f);
		}

		private static bool CursorVisible(Func<MPEventSystem, bool> orig, MPEventSystem events)
		{
			if (!orig(events))
			{
				if (Object.op_Implicit((Object)(object)activeRig) && Object.op_Implicit((Object)(object)local) && local.Body.healthComponent.alive && !Blocked(activeRig))
				{
					if (events.localUser != activeRig.localUserViewer)
					{
						return events.isCombinedEventSystem;
					}
					return true;
				}
				return false;
			}
			return true;
		}

		private static void CursorUpdate(orig_LateUpdate orig, MPEventSystem events)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(events);
			if (!Object.op_Implicit((Object)(object)activeRig) || !Object.op_Implicit((Object)(object)local) || !local.Body.healthComponent.alive || events.localUser != activeRig.localUserViewer)
			{
				return;
			}
			if (Blocked(activeRig))
			{
				RestoreCursor();
				return;
			}
			if (!cursorOwned)
			{
				oldLock = Cursor.lockState;
				oldVisible = Cursor.visible;
				cursorOwned = true;
			}
			Cursor.lockState = (CursorLockMode)0;
			Cursor.visible = false;
		}

		internal static void Draw()
		{
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_006f: 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_0086: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)local) || !Object.op_Implicit((Object)(object)activeRig) || !local.Body.healthComponent.alive || Blocked(activeRig))
			{
				return;
			}
			Rect pixelRect = activeRig.sceneCam.pixelRect;
			Vector3 mousePosition = Input.mousePosition;
			if (!((Rect)(ref pixelRect)).Contains(mousePosition))
			{
				return;
			}
			Matrix4x4 matrix = GUI.matrix;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(mousePosition.x, (float)Screen.height - mousePosition.y);
			try
			{
				GUIUtility.RotateAroundPivot(pointerAngle, val);
				GUI.DrawTexture(new Rect(val.x - 16f, val.y - 16f, 32f, 32f), (Texture)(object)Assets.For(local.Body.skinIndex).texture);
			}
			finally
			{
				GUI.matrix = matrix;
			}
		}

		private static void Ping(orig_AttemptPing orig, PingerController pinger, Ray ray, GameObject body)
		{
			//IL_00be: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)local) && Object.op_Implicit((Object)(object)activeRig) && Object.op_Implicit((Object)(object)local.Body.master) && (Object)(object)((Component)pinger).gameObject == (Object)(object)((Component)local.Body.master).gameObject)
			{
				if (Blocked(activeRig) || !haveCursorRay || lastPingFrame == Time.frameCount)
				{
					return;
				}
				lastPingFrame = Time.frameCount;
				ray = ((inputFrame == Time.frameCount) ? cursorRay : activeRig.sceneCam.ScreenPointToRay(Input.mousePosition));
				body = ((Component)local.Body).gameObject;
			}
			orig.Invoke(pinger, ray, body);
		}

		private static Ray PreserveCursorRay(orig_ModifyAimRayIfApplicable orig, Ray ray, GameObject body, out float extraDistance)
		{
			//IL_001f: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.GetComponent<PointerActor>()))
			{
				extraDistance = 0f;
				return ray;
			}
			return orig.Invoke(ray, body, ref extraDistance);
		}

		private static void RestoreCursor()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if (cursorOwned)
			{
				Cursor.lockState = oldLock;
				Cursor.visible = oldVisible;
				cursorOwned = false;
			}
		}

		private static void RestoreHealth()
		{
			if (Object.op_Implicit((Object)(object)hiddenHealth))
			{
				hiddenHealth.SetActive(oldHealthActive);
			}
			hiddenHealth = null;
		}

		private static void Release()
		{
			RestoreCursor();
			RestoreHealth();
			local = null;
			activeRig = null;
			lastWatched = null;
			cameraBound = (boundPoseReady = (haveMouse = (haveCursorRay = false)));
			yawVelocity = (pitchVelocity = (spinVelocity = 0f));
			primaryHeld = (utilityHeld = (specialHeld = false));
		}

		internal static void Uninstall()
		{
			//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: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			object obj = <>O.<0>__CameraState;
			if (obj == null)
			{
				hook_SetCameraState val = CameraState;
				<>O.<0>__CameraState = val;
				obj = (object)val;
			}
			CameraRigController.SetCameraState -= (hook_SetCameraState)obj;
			object obj2 = <>O.<1>__CursorUpdate;
			if (obj2 == null)
			{
				hook_LateUpdate val2 = CursorUpdate;
				<>O.<1>__CursorUpdate = val2;
				obj2 = (object)val2;
			}
			MPEventSystem.LateUpdate -= (hook_LateUpdate)obj2;
			object obj3 = <>O.<2>__Ping;
			if (obj3 == null)
			{
				hook_AttemptPing val3 = Ping;
				<>O.<2>__Ping = val3;
				obj3 = (object)val3;
			}
			PingerController.AttemptPing -= (hook_AttemptPing)obj3;
			object obj4 = <>O.<3>__PreserveCursorRay;
			if (obj4 == null)
			{
				hook_ModifyAimRayIfApplicable val4 = PreserveCursorRay;
				<>O.<3>__PreserveCursorRay = val4;
				obj4 = (object)val4;
			}
			CameraRigController.ModifyAimRayIfApplicable -= (hook_ModifyAimRayIfApplicable)obj4;
			Hook? obj5 = visibilityHook;
			if (obj5 != null)
			{
				obj5.Dispose();
			}
			visibilityHook = null;
			Release();
			if (Object.op_Implicit((Object)(object)gui.Object))
			{
				Object.Destroy((Object)(object)gui.Object);
			}
		}
	}
	public sealed class PointerGUI : MonoBehaviour
	{
		private void OnGUI()
		{
			PointerView.Draw();
		}

		private void OnApplicationFocus(bool focus)
		{
			if (!focus)
			{
				Cursor.visible = true;
			}
		}
	}
	public static class Rules
	{
		public const float CollectRadius = 1.5f;

		public const float HealingHalo = 3f;

		public const float HealFractionPerSecond = 0.01f;

		public const float CollectibleLif

plugins/StarPointer/PassivePlayers.dll

Decompiled 13 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API.Utils;
using RoR2;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PassivePlayers")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("PassivePlayers")]
[assembly: AssemblyTitle("PassivePlayers")]
[assembly: AssemblyVersion("0.1.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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;
		}
	}
	[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 PassivePlayers
{
	public sealed class PassivePlayer : MonoBehaviour
	{
		public bool WipeInProgress { get; internal set; }
	}
	public static class PassivePlayerAPI
	{
		public const string PluginGUID = "local.passiveplayers.api";

		public const int ContractVersion = 1;

		private static readonly HashSet<string> names = new HashSet<string>(StringComparer.Ordinal);

		public static void RegisterBodyName(string catalogBodyName)
		{
			if (string.IsNullOrWhiteSpace(catalogBodyName))
			{
				throw new ArgumentException("A body prefab/catalog name is required.");
			}
			names.Add(catalogBodyName);
		}

		public static void RegisterBodyPrefab(GameObject prefab)
		{
			if (!Object.op_Implicit((Object)(object)prefab))
			{
				throw new ArgumentNullException("prefab");
			}
			if (!Object.op_Implicit((Object)(object)prefab.GetComponent<PassivePlayer>()))
			{
				prefab.AddComponent<PassivePlayer>();
			}
			RegisterBodyName(((Object)prefab).name);
		}

		public static bool IsPassive(CharacterBody body)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)body))
			{
				if (!Object.op_Implicit((Object)(object)((Component)body).GetComponent<PassivePlayer>()) && !names.Contains(BodyCatalog.GetBodyName(body.bodyIndex)))
				{
					return names.Contains(((Object)((Component)body).gameObject).name.Replace("(Clone)", ""));
				}
				return true;
			}
			return false;
		}

		public static bool IsPassive(CharacterMaster master)
		{
			if (!Object.op_Implicit((Object)(object)master))
			{
				return false;
			}
			CharacterBody body = master.GetBody();
			if (Object.op_Implicit((Object)(object)body))
			{
				return IsPassive(body);
			}
			if (Object.op_Implicit((Object)(object)master.bodyPrefab))
			{
				if (!Object.op_Implicit((Object)(object)master.bodyPrefab.GetComponent<PassivePlayer>()))
				{
					return names.Contains(((Object)master.bodyPrefab).name);
				}
				return true;
			}
			return false;
		}

		public static void SetCannotRevive(CharacterMaster master, bool value)
		{
			typeof(CharacterMaster).GetField("cannotRevive")?.SetValue(master, value);
		}

		public static bool HasActivePlayer(TeamIndex team)
		{
			//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)
			if (!NetworkServer.active)
			{
				return false;
			}
			foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
			{
				CharacterMaster master = instance.master;
				if (Object.op_Implicit((Object)(object)master) && master.teamIndex == team && TeamPolicy.CountsAsActive(IsPassive(master), instance.isConnected, master.IsDeadAndOutOfLivesServer()))
				{
					return true;
				}
			}
			return false;
		}
	}
	[BepInPlugin("local.passiveplayers.api", "Passive Players API", "1.0.0")]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public sealed class PassivePlayersPlugin : BaseUnityPlugin
	{
		private float readyAt;

		private void Awake()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			Stage.onStageStartGlobal += StageStarted;
			Run.FixedUpdate += new hook_FixedUpdate(RunTick);
		}

		private void StageStarted(Stage stage)
		{
			readyAt = Time.unscaledTime + 3f;
		}

		private void RunTick(orig_FixedUpdate orig, Run run)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkServer.active && Object.op_Implicit((Object)(object)Stage.instance) && Time.unscaledTime >= readyAt && !run.isGameOverServer)
			{
				foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
				{
					CharacterMaster master = instance.master;
					if (!Object.op_Implicit((Object)(object)master) || !PassivePlayerAPI.IsPassive(master) || PassivePlayerAPI.HasActivePlayer(master.teamIndex))
					{
						continue;
					}
					CharacterBody body = master.GetBody();
					if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.healthComponent) && body.healthComponent.alive)
					{
						master.preventGameOver = false;
						PassivePlayerAPI.SetCannotRevive(master, value: true);
						PassivePlayer component = ((Component)body).GetComponent<PassivePlayer>();
						if (Object.op_Implicit((Object)(object)component))
						{
							component.WipeInProgress = true;
						}
						body.healthComponent.godMode = false;
						body.healthComponent.Suicide((GameObject)null, (GameObject)null, DamageTypeCombo.op_Implicit((DamageType)65536));
					}
				}
			}
			orig.Invoke(run);
		}

		private void OnDestroy()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			Stage.onStageStartGlobal -= StageStarted;
			Run.FixedUpdate -= new hook_FixedUpdate(RunTick);
		}
	}
	public static class TeamPolicy
	{
		public static bool CountsAsActive(bool passive, bool connected, bool deadAndOutOfLives)
		{
			if (!passive && connected)
			{
				return !deadAndOutOfLives;
			}
			return false;
		}
	}
}