Decompiled source of REPOPowers v1.0.0

REPOPowers.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Photon.Pun;
using REPOLib.Modules;
using REPOPowers.Core;
using REPOPowers.Networking;
using REPOPowers.Powers;
using REPOPowers.UI;
using UnityEngine;

[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace REPOPowers.Powers
{
	public class NoclipPower : PowerBase
	{
		private static readonly Dictionary<PlayerAvatar, List<Collider>> DisabledColliders = new Dictionary<PlayerAvatar, List<Collider>>();

		public override string Id
		{
			[CompilerGenerated]
			get
			{
				return "Noclip";
			}
		}

		public override string DisplayName
		{
			[CompilerGenerated]
			get
			{
				return "Noclip";
			}
		}

		public override string Description
		{
			[CompilerGenerated]
			get
			{
				return "Fly through walls and geometry. Local-only, always works.";
			}
		}

		public override NetworkScope Scope
		{
			[CompilerGenerated]
			get
			{
				return NetworkScope.LocalOnly;
			}
		}

		protected override KeyboardShortcut DefaultKeybind()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return new KeyboardShortcut((KeyCode)287, Array.Empty<KeyCode>());
		}

		protected override void OnActivate()
		{
			ApplyColliders(GameHooks.GetLocalPlayer(), enabled: false);
		}

		protected override void OnDeactivate()
		{
			ApplyColliders(GameHooks.GetLocalPlayer(), enabled: true);
		}

		protected override void OnActiveTick()
		{
			//IL_0040: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_0070: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			PlayerAvatar localPlayer = GameHooks.GetLocalPlayer();
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			PlayerController component = ((Component)localPlayer).GetComponent<PlayerController>();
			if (component != null)
			{
				component.Kinematic(0.5f);
			}
			Camera mainCamera = GameHooks.GetMainCamera();
			if (!((Object)(object)mainCamera == (Object)null))
			{
				Vector3 val = Vector3.zero;
				if (Input.GetKey((KeyCode)119))
				{
					val += ((Component)mainCamera).transform.forward;
				}
				if (Input.GetKey((KeyCode)115))
				{
					val -= ((Component)mainCamera).transform.forward;
				}
				if (Input.GetKey((KeyCode)97))
				{
					val -= ((Component)mainCamera).transform.right;
				}
				if (Input.GetKey((KeyCode)100))
				{
					val += ((Component)mainCamera).transform.right;
				}
				if (Input.GetKey((KeyCode)32))
				{
					val += Vector3.up;
				}
				if (Input.GetKey((KeyCode)306))
				{
					val -= Vector3.up;
				}
				if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f))
				{
					((Vector3)(ref val)).Normalize();
					Transform transform = ((Component)localPlayer).transform;
					transform.position += val * (10f * Time.deltaTime);
				}
			}
		}

		internal static void ApplyColliders(PlayerAvatar avatar, bool enabled)
		{
			if ((Object)(object)avatar == (Object)null)
			{
				return;
			}
			if (!enabled)
			{
				List<Collider> list = new List<Collider>();
				foreach (Collider collider in GameHooks.GetColliders(avatar))
				{
					list.Add(collider);
					collider.enabled = false;
				}
				DisabledColliders[avatar] = list;
			}
			else
			{
				if (!DisabledColliders.TryGetValue(avatar, out var value))
				{
					return;
				}
				foreach (Collider item in value)
				{
					if ((Object)(object)item != (Object)null)
					{
						item.enabled = true;
					}
				}
				DisabledColliders.Remove(avatar);
			}
		}
	}
	public class FlyPower : PowerBase
	{
		public const float Speed = 10f;

		public override string Id
		{
			[CompilerGenerated]
			get
			{
				return "Fly";
			}
		}

		public override string DisplayName
		{
			[CompilerGenerated]
			get
			{
				return "Fly";
			}
		}

		public override string Description
		{
			[CompilerGenerated]
			get
			{
				return "Fly freely using WASD + Space/Ctrl. Local-only movement, always works.";
			}
		}

		public override NetworkScope Scope
		{
			[CompilerGenerated]
			get
			{
				return NetworkScope.LocalOnly;
			}
		}

		protected override KeyboardShortcut DefaultKeybind()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return new KeyboardShortcut((KeyCode)286, Array.Empty<KeyCode>());
		}

		protected override void OnActivate()
		{
			NoclipPower.ApplyColliders(GameHooks.GetLocalPlayer(), enabled: false);
		}

		protected override void OnDeactivate()
		{
			NoclipPower noclipPower = FindNoclipSibling();
			if (noclipPower == null || !noclipPower.IsToggled)
			{
				NoclipPower.ApplyColliders(GameHooks.GetLocalPlayer(), enabled: true);
			}
		}

		protected override void OnActiveTick()
		{
			//IL_0040: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_0070: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: 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_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			PlayerAvatar localPlayer = GameHooks.GetLocalPlayer();
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			PlayerController component = ((Component)localPlayer).GetComponent<PlayerController>();
			if (component != null)
			{
				component.Kinematic(0.5f);
			}
			Camera mainCamera = GameHooks.GetMainCamera();
			if ((Object)(object)mainCamera == (Object)null)
			{
				return;
			}
			Vector3 val = Vector3.zero;
			if (Input.GetKey((KeyCode)119))
			{
				val += ((Component)mainCamera).transform.forward;
			}
			if (Input.GetKey((KeyCode)115))
			{
				val -= ((Component)mainCamera).transform.forward;
			}
			if (Input.GetKey((KeyCode)97))
			{
				val -= ((Component)mainCamera).transform.right;
			}
			if (Input.GetKey((KeyCode)100))
			{
				val += ((Component)mainCamera).transform.right;
			}
			if (Input.GetKey((KeyCode)32))
			{
				val += Vector3.up;
			}
			if (Input.GetKey((KeyCode)306))
			{
				val -= Vector3.up;
			}
			if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f))
			{
				((Vector3)(ref val)).Normalize();
				Rigidbody rigidbody = GameHooks.GetRigidbody(localPlayer);
				if ((Object)(object)rigidbody != (Object)null)
				{
					rigidbody.MovePosition(rigidbody.position + val * (10f * Time.deltaTime));
					return;
				}
				Transform transform = ((Component)localPlayer).transform;
				transform.position += val * (10f * Time.deltaTime);
			}
		}

		private NoclipPower FindNoclipSibling()
		{
			if ((Object)(object)PowerManager.Instance == (Object)null)
			{
				return null;
			}
			NoclipPower noclipPower = default(NoclipPower);
			foreach (IPower power in PowerManager.Instance.Powers)
			{
				object obj = power as NoclipPower;
				if (obj != null)
				{
					noclipPower = (NoclipPower)obj;
					obj = noclipPower;
				}
				if (obj != null)
				{
					return noclipPower;
				}
			}
			return null;
		}
	}
	public class RevivePlayerPower : PowerBase
	{
		public override string Id
		{
			[CompilerGenerated]
			get
			{
				return "RevivePlayer";
			}
		}

		public override string DisplayName
		{
			[CompilerGenerated]
			get
			{
				return "Revive Target";
			}
		}

		public override string Description
		{
			[CompilerGenerated]
			get
			{
				return "Revives the selected target player if downed. Works for host and clients.";
			}
		}

		public override NetworkScope Scope
		{
			[CompilerGenerated]
			get
			{
				return NetworkScope.GameRpc;
			}
		}

		public override bool RequiresTargetPlayer
		{
			[CompilerGenerated]
			get
			{
				return true;
			}
		}

		protected override bool IsToggleType
		{
			[CompilerGenerated]
			get
			{
				return false;
			}
		}

		protected override KeyboardShortcut DefaultKeybind()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return new KeyboardShortcut((KeyCode)291, Array.Empty<KeyCode>());
		}

		protected override void OnPressed()
		{
			PlayerAvatar val = PowerManager.Instance?.GetSelectedTarget();
			if (!((Object)(object)val == (Object)null))
			{
				val.Revive(false);
			}
		}
	}
	public class TelekinesisPower : PowerBase
	{
		public const float ExtendedRange = 40f;

		public const float ExtendedStrength = 40f;

		public override string Id
		{
			[CompilerGenerated]
			get
			{
				return "Telekinesis";
			}
		}

		public override string DisplayName
		{
			[CompilerGenerated]
			get
			{
				return "Telekinesis";
			}
		}

		public override string Description
		{
			[CompilerGenerated]
			get
			{
				return "Massively extends your grab beam's range and strength.";
			}
		}

		public override NetworkScope Scope
		{
			[CompilerGenerated]
			get
			{
				return NetworkScope.LocalOnly;
			}
		}

		protected override KeyboardShortcut DefaultKeybind()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return new KeyboardShortcut((KeyCode)289, Array.Empty<KeyCode>());
		}

		protected override void OnActiveTick()
		{
			PhysGrabber val = GameHooks.GetLocalPlayer()?.physGrabber;
			if (!((Object)(object)val == (Object)null))
			{
				val.OverrideGrabDistance(40f);
				val.OverrideMinimumGrabDistance(0.1f);
				val.OverrideGrabStrength(40f, 0.5f);
			}
		}
	}
	public class SpawnValuablePower : PowerBase
	{
		public int SelectedIndex;

		public override string Id
		{
			[CompilerGenerated]
			get
			{
				return "SpawnValuable";
			}
		}

		public override string DisplayName
		{
			[CompilerGenerated]
			get
			{
				return "Spawn Valuable";
			}
		}

		public override string Description
		{
			[CompilerGenerated]
			get
			{
				return "Spawns the selected valuable in front of you.";
			}
		}

		public override NetworkScope Scope
		{
			[CompilerGenerated]
			get
			{
				return NetworkScope.NetworkSpawn;
			}
		}

		protected override bool IsToggleType
		{
			[CompilerGenerated]
			get
			{
				return false;
			}
		}

		protected override KeyboardShortcut DefaultKeybind()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return new KeyboardShortcut((KeyCode)283, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 });
		}

		public void CycleNext()
		{
			IReadOnlyList<PrefabRef> allValuables = Valuables.AllValuables;
			if (allValuables.Count != 0)
			{
				SelectedIndex = (SelectedIndex + 1) % allValuables.Count;
			}
		}

		public void CyclePrevious()
		{
			IReadOnlyList<PrefabRef> allValuables = Valuables.AllValuables;
			if (allValuables.Count != 0)
			{
				SelectedIndex = (SelectedIndex - 1 + allValuables.Count) % allValuables.Count;
			}
		}

		public string CurrentSelectionName()
		{
			IReadOnlyList<PrefabRef> allValuables = Valuables.AllValuables;
			if (allValuables.Count == 0)
			{
				return "<no valuables registered>";
			}
			SelectedIndex = Mathf.Clamp(SelectedIndex, 0, allValuables.Count - 1);
			return ((PrefabRef<GameObject>)(object)allValuables[SelectedIndex]).PrefabName;
		}

		protected override void OnPressed()
		{
			//IL_0057: 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_006c: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			IReadOnlyList<PrefabRef> allValuables = Valuables.AllValuables;
			if (allValuables.Count != 0)
			{
				SelectedIndex = Mathf.Clamp(SelectedIndex, 0, allValuables.Count - 1);
				PlayerAvatar localPlayer = GameHooks.GetLocalPlayer();
				Camera mainCamera = GameHooks.GetMainCamera();
				if (!((Object)(object)localPlayer == (Object)null) && !((Object)(object)mainCamera == (Object)null))
				{
					Vector3 val = ((Component)localPlayer).transform.position + ((Component)mainCamera).transform.forward * 2f + Vector3.up * 0.5f;
					Valuables.SpawnValuable(allValuables[SelectedIndex], val, Quaternion.identity);
				}
			}
		}
	}
	public class SelfTeleportPower : PowerBase
	{
		public const float MaxDistance = 200f;

		public override string Id
		{
			[CompilerGenerated]
			get
			{
				return "SelfTeleport";
			}
		}

		public override string DisplayName
		{
			[CompilerGenerated]
			get
			{
				return "Self Teleport";
			}
		}

		public override string Description
		{
			[CompilerGenerated]
			get
			{
				return "Teleport yourself to where you're looking.";
			}
		}

		public override NetworkScope Scope
		{
			[CompilerGenerated]
			get
			{
				return NetworkScope.LocalOnly;
			}
		}

		protected override bool IsToggleType
		{
			[CompilerGenerated]
			get
			{
				return false;
			}
		}

		protected override KeyboardShortcut DefaultKeybind()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return new KeyboardShortcut((KeyCode)288, Array.Empty<KeyCode>());
		}

		protected override void OnPressed()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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)
			PlayerAvatar localPlayer = GameHooks.GetLocalPlayer();
			Camera mainCamera = GameHooks.GetMainCamera();
			if (!((Object)(object)localPlayer == (Object)null) && !((Object)(object)mainCamera == (Object)null))
			{
				RaycastHit val = default(RaycastHit);
				Vector3 position = ((!Physics.Raycast(((Component)mainCamera).transform.position, ((Component)mainCamera).transform.forward, ref val, 200f)) ? (((Component)mainCamera).transform.position + ((Component)mainCamera).transform.forward * 200f) : (((RaycastHit)(ref val)).point + Vector3.up * 1f));
				PlayerController component = ((Component)localPlayer).GetComponent<PlayerController>();
				if (component != null)
				{
					component.Kinematic(0.2f);
				}
				Rigidbody rigidbody = GameHooks.GetRigidbody(localPlayer);
				if ((Object)(object)rigidbody != (Object)null)
				{
					rigidbody.position = position;
					rigidbody.velocity = Vector3.zero;
				}
				((Component)localPlayer).transform.position = position;
			}
		}
	}
	public class SpawnItemPower : PowerBase
	{
		public int SelectedIndex;

		public override string Id
		{
			[CompilerGenerated]
			get
			{
				return "SpawnItem";
			}
		}

		public override string DisplayName
		{
			[CompilerGenerated]
			get
			{
				return "Spawn Item";
			}
		}

		public override string Description
		{
			[CompilerGenerated]
			get
			{
				return "Spawns the selected item in front of you.";
			}
		}

		public override NetworkScope Scope
		{
			[CompilerGenerated]
			get
			{
				return NetworkScope.NetworkSpawn;
			}
		}

		protected override bool IsToggleType
		{
			[CompilerGenerated]
			get
			{
				return false;
			}
		}

		protected override KeyboardShortcut DefaultKeybind()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return new KeyboardShortcut((KeyCode)282, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 });
		}

		public void CycleNext()
		{
			IReadOnlyList<Item> allItems = Items.AllItems;
			if (allItems.Count != 0)
			{
				SelectedIndex = (SelectedIndex + 1) % allItems.Count;
			}
		}

		public void CyclePrevious()
		{
			IReadOnlyList<Item> allItems = Items.AllItems;
			if (allItems.Count != 0)
			{
				SelectedIndex = (SelectedIndex - 1 + allItems.Count) % allItems.Count;
			}
		}

		public string CurrentSelectionName()
		{
			IReadOnlyList<Item> allItems = Items.AllItems;
			if (allItems.Count == 0)
			{
				return "<no items registered>";
			}
			SelectedIndex = Mathf.Clamp(SelectedIndex, 0, allItems.Count - 1);
			return allItems[SelectedIndex].itemName;
		}

		protected override void OnPressed()
		{
			//IL_0057: 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_006c: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			IReadOnlyList<Item> allItems = Items.AllItems;
			if (allItems.Count != 0)
			{
				SelectedIndex = Mathf.Clamp(SelectedIndex, 0, allItems.Count - 1);
				PlayerAvatar localPlayer = GameHooks.GetLocalPlayer();
				Camera mainCamera = GameHooks.GetMainCamera();
				if (!((Object)(object)localPlayer == (Object)null) && !((Object)(object)mainCamera == (Object)null))
				{
					Vector3 val = ((Component)localPlayer).transform.position + ((Component)mainCamera).transform.forward * 2f + Vector3.up * 0.5f;
					Items.SpawnItem(allItems[SelectedIndex], val, Quaternion.identity);
				}
			}
		}
	}
	public class PuppetPower : PowerBase
	{
		public const float Speed = 6f;

		private PlayerAvatar _currentTarget;

		public override string Id
		{
			[CompilerGenerated]
			get
			{
				return "Puppet";
			}
		}

		public override string DisplayName
		{
			[CompilerGenerated]
			get
			{
				return "Puppet Target";
			}
		}

		public override string Description
		{
			[CompilerGenerated]
			get
			{
				return "Hold to control the selected target's movement with your WASD (no ragdoll). Requires the target to also have REPO Powers installed.";
			}
		}

		public override NetworkScope Scope
		{
			[CompilerGenerated]
			get
			{
				return NetworkScope.ModRelay;
			}
		}

		public override bool RequiresTargetPlayer
		{
			[CompilerGenerated]
			get
			{
				return true;
			}
		}

		protected override KeyboardShortcut DefaultKeybind()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return new KeyboardShortcut((KeyCode)293, Array.Empty<KeyCode>());
		}

		protected override void OnActivate()
		{
			_currentTarget = PowerManager.Instance?.GetSelectedTarget();
		}

		protected override void OnDeactivate()
		{
			//IL_0023: 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)
			((_currentTarget != null) ? ((Component)_currentTarget).GetComponent<PowerRelay>() : null)?.SendPuppetMove(Vector3.zero, ((Component)_currentTarget).transform.rotation, active: false);
			_currentTarget = null;
		}

		protected override void OnActiveTick()
		{
			//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_005e: 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_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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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_00a0: 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_00a3: 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)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			Camera mainCamera = GameHooks.GetMainCamera();
			PowerRelay powerRelay = ((_currentTarget != null) ? ((Component)_currentTarget).GetComponent<PowerRelay>() : null);
			if (!((Object)(object)mainCamera == (Object)null) && !((Object)(object)powerRelay == (Object)null))
			{
				Vector3 forward = ((Component)mainCamera).transform.forward;
				forward.y = 0f;
				((Vector3)(ref forward)).Normalize();
				Vector3 right = ((Component)mainCamera).transform.right;
				right.y = 0f;
				((Vector3)(ref right)).Normalize();
				Vector3 val = Vector3.zero;
				if (Input.GetKey((KeyCode)119))
				{
					val += forward;
				}
				if (Input.GetKey((KeyCode)115))
				{
					val -= forward;
				}
				if (Input.GetKey((KeyCode)97))
				{
					val -= right;
				}
				if (Input.GetKey((KeyCode)100))
				{
					val += right;
				}
				if (((Vector3)(ref val)).sqrMagnitude > 0.0001f)
				{
					val = ((Vector3)(ref val)).normalized * 6f;
				}
				Quaternion lookRotation = ((!(((Vector3)(ref val)).sqrMagnitude > 0.0001f)) ? ((Component)_currentTarget).transform.rotation : Quaternion.LookRotation(val));
				powerRelay.SendPuppetMove(val, lookRotation, active: true);
			}
		}
	}
	public class HealPlayerPower : PowerBase
	{
		public const int HealAmount = 100;

		public override string Id
		{
			[CompilerGenerated]
			get
			{
				return "HealPlayer";
			}
		}

		public override string DisplayName
		{
			[CompilerGenerated]
			get
			{
				return "Heal Target";
			}
		}

		public override string Description
		{
			[CompilerGenerated]
			get
			{
				return "Fully heals the selected target player. Works for host and clients.";
			}
		}

		public override NetworkScope Scope
		{
			[CompilerGenerated]
			get
			{
				return NetworkScope.GameRpc;
			}
		}

		public override bool RequiresTargetPlayer
		{
			[CompilerGenerated]
			get
			{
				return true;
			}
		}

		protected override bool IsToggleType
		{
			[CompilerGenerated]
			get
			{
				return false;
			}
		}

		protected override KeyboardShortcut DefaultKeybind()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return new KeyboardShortcut((KeyCode)290, Array.Empty<KeyCode>());
		}

		protected override void OnPressed()
		{
			PlayerHealth val = (PowerManager.Instance?.GetSelectedTarget())?.playerHealth;
			if (!((Object)(object)val == (Object)null))
			{
				val.HealOther(100, true);
			}
		}
	}
	public class TeleportPlayerPower : PowerBase
	{
		public const float MaxDistance = 200f;

		public override string Id
		{
			[CompilerGenerated]
			get
			{
				return "TeleportPlayer";
			}
		}

		public override string DisplayName
		{
			[CompilerGenerated]
			get
			{
				return "Teleport Target To Crosshair";
			}
		}

		public override string Description
		{
			[CompilerGenerated]
			get
			{
				return "Teleports the selected target to where you're looking. Requires the target to also have REPO Powers installed.";
			}
		}

		public override NetworkScope Scope
		{
			[CompilerGenerated]
			get
			{
				return NetworkScope.ModRelay;
			}
		}

		public override bool RequiresTargetPlayer
		{
			[CompilerGenerated]
			get
			{
				return true;
			}
		}

		protected override bool IsToggleType
		{
			[CompilerGenerated]
			get
			{
				return false;
			}
		}

		protected override KeyboardShortcut DefaultKeybind()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return new KeyboardShortcut((KeyCode)292, Array.Empty<KeyCode>());
		}

		protected override void OnPressed()
		{
			//IL_003a: 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_0082: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			PlayerAvatar val = PowerManager.Instance?.GetSelectedTarget();
			Camera mainCamera = GameHooks.GetMainCamera();
			if ((Object)(object)val == (Object)null || (Object)(object)mainCamera == (Object)null)
			{
				return;
			}
			RaycastHit val2 = default(RaycastHit);
			Vector3 worldPosition = ((!Physics.Raycast(((Component)mainCamera).transform.position, ((Component)mainCamera).transform.forward, ref val2, 200f)) ? (((Component)mainCamera).transform.position + ((Component)mainCamera).transform.forward * 200f) : (((RaycastHit)(ref val2)).point + Vector3.up * 1f));
			PowerRelay component = ((Component)val).GetComponent<PowerRelay>();
			if ((Object)(object)component == (Object)null)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogWarning((object)$"Cannot teleport {((Object)val).name}: they don't have REPO Powers installed.");
				}
			}
			else
			{
				component.SendTeleport(worldPosition);
			}
		}
	}
	public class SpawnEnemyPower : PowerBase
	{
		public int SelectedIndex;

		public override string Id
		{
			[CompilerGenerated]
			get
			{
				return "SpawnEnemy";
			}
		}

		public override string DisplayName
		{
			[CompilerGenerated]
			get
			{
				return "Spawn Enemy";
			}
		}

		public override string Description
		{
			[CompilerGenerated]
			get
			{
				return "Spawns the selected enemy in front of you. Bypasses the AI director's spawn quota - test host-side first.";
			}
		}

		public override NetworkScope Scope
		{
			[CompilerGenerated]
			get
			{
				return NetworkScope.HostRecommended;
			}
		}

		protected override bool IsToggleType
		{
			[CompilerGenerated]
			get
			{
				return false;
			}
		}

		protected override KeyboardShortcut DefaultKeybind()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return new KeyboardShortcut((KeyCode)284, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 });
		}

		public void CycleNext()
		{
			IReadOnlyList<EnemySetup> allEnemies = Enemies.AllEnemies;
			if (allEnemies.Count != 0)
			{
				SelectedIndex = (SelectedIndex + 1) % allEnemies.Count;
			}
		}

		public void CyclePrevious()
		{
			IReadOnlyList<EnemySetup> allEnemies = Enemies.AllEnemies;
			if (allEnemies.Count != 0)
			{
				SelectedIndex = (SelectedIndex - 1 + allEnemies.Count) % allEnemies.Count;
			}
		}

		public string CurrentSelectionName()
		{
			IReadOnlyList<EnemySetup> allEnemies = Enemies.AllEnemies;
			if (allEnemies.Count == 0)
			{
				return "<no enemies registered>";
			}
			SelectedIndex = Mathf.Clamp(SelectedIndex, 0, allEnemies.Count - 1);
			return ((Object)allEnemies[SelectedIndex]).name;
		}

		protected override void OnPressed()
		{
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			IReadOnlyList<EnemySetup> allEnemies = Enemies.AllEnemies;
			if (allEnemies.Count == 0)
			{
				return;
			}
			SelectedIndex = Mathf.Clamp(SelectedIndex, 0, allEnemies.Count - 1);
			EnemySetup val = allEnemies[SelectedIndex];
			if (val.spawnObjects == null || val.spawnObjects.Count == 0)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogWarning((object)$"Enemy '{((Object)val).name}' has no spawn objects registered.");
				}
				return;
			}
			PlayerAvatar localPlayer = GameHooks.GetLocalPlayer();
			Camera mainCamera = GameHooks.GetMainCamera();
			if ((Object)(object)localPlayer == (Object)null || (Object)(object)mainCamera == (Object)null)
			{
				return;
			}
			Vector3 val2 = ((Component)localPlayer).transform.position + ((Component)mainCamera).transform.forward * 8f;
			PrefabRef val3 = val.spawnObjects[0];
			if (!((PrefabRef<GameObject>)(object)val3).IsValid())
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogWarning((object)$"Enemy '{((Object)val).name}' prefab reference is not valid.");
				}
			}
			else
			{
				PhotonNetwork.Instantiate(((PrefabRef<GameObject>)(object)val3).PrefabName, val2, Quaternion.identity, (byte)0, (object[])null);
			}
		}
	}
}
namespace REPOPowers.UI
{
	public class PowersMenu : MonoBehaviour
	{
		private Rect _windowRect = new Rect(40f, 40f, 480f, 620f);

		private Vector2 _scroll;

		private PowerBase _rebindTarget;

		private bool _rebindingMenuKey;

		public static bool IsCapturingKeybind { get; private set; }

		private void OnGUI()
		{
			//IL_0025: 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_0045: Expected O, but got Unknown
			//IL_0040: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			PowerManager instance = PowerManager.Instance;
			if ((Object)(object)instance == (Object)null || !instance.MenuOpen)
			{
				return;
			}
			_windowRect = GUILayout.Window(1380996865, _windowRect, new WindowFunction(DrawWindow), "REPO Powers", Array.Empty<GUILayoutOption>());
			if (IsCapturingKeybind && Event.current.isKey && (int)Event.current.keyCode != 0)
			{
				KeyboardShortcut newBind = default(KeyboardShortcut);
				((KeyboardShortcut)(ref newBind))..ctor(Event.current.keyCode, Array.Empty<KeyCode>());
				if (_rebindingMenuKey)
				{
					instance.SaveMenuToggleKey(newBind);
					_rebindingMenuKey = false;
				}
				else if (_rebindTarget != null)
				{
					_rebindTarget.SaveKeybind(newBind);
					_rebindTarget = null;
				}
				IsCapturingKeybind = false;
			}
		}

		private void DrawWindow(int id)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			PowerManager instance = PowerManager.Instance;
			GUILayout.Label(string.Format("Multiplayer: {0}   ", (!GameHooks.IsMultiplayer()) ? "No (Singleplayer)" : "Yes") + string.Format("Host: {0}", (!GameHooks.IsMasterClient()) ? "No" : "Yes"), Array.Empty<GUILayoutOption>());
			GUILayout.Space(4f);
			DrawKeybindRow("Open/Close Menu", instance.MenuToggleKey, delegate
			{
				IsCapturingKeybind = true;
				_rebindingMenuKey = true;
				_rebindTarget = null;
			});
			GUILayout.Space(8f);
			DrawTargetPlayerSelector(instance);
			GUILayout.Space(8f);
			_scroll = GUILayout.BeginScrollView(_scroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(430f) });
			foreach (IPower power in instance.Powers)
			{
				DrawPowerRow(power);
				GUILayout.Space(6f);
			}
			GUILayout.EndScrollView();
			GUILayout.Space(6f);
			if (IsCapturingKeybind)
			{
				GUILayout.Label("Press any key to bind... (Esc cancels on next open)", Array.Empty<GUILayoutOption>());
			}
			GUI.DragWindow(new Rect(0f, 0f, 10000f, 20f));
		}

		private void DrawTargetPlayerSelector(PowerManager mgr)
		{
			List<PlayerAvatar> otherPlayers = mgr.GetOtherPlayers();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("Target Player:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(110f) });
			if (otherPlayers.Count == 0)
			{
				GUILayout.Label("<no other players>", Array.Empty<GUILayoutOption>());
			}
			else
			{
				if (GUILayout.Button("<", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(28f) }))
				{
					mgr.SelectedTargetIndex = (mgr.SelectedTargetIndex - 1 + otherPlayers.Count) % otherPlayers.Count;
				}
				mgr.SelectedTargetIndex = Mathf.Clamp(mgr.SelectedTargetIndex, 0, otherPlayers.Count - 1);
				PlayerAvatar val = otherPlayers[mgr.SelectedTargetIndex];
				string text = ((!((Object)(object)val != (Object)null) || !((Object)(object)val.photonView != (Object)null) || val.photonView.Owner == null) ? "?" : val.photonView.Owner.NickName);
				GUILayout.Label(text, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(180f) });
				if (GUILayout.Button(">", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(28f) }))
				{
					mgr.SelectedTargetIndex = (mgr.SelectedTargetIndex + 1) % otherPlayers.Count;
				}
			}
			GUILayout.EndHorizontal();
		}

		private void DrawPowerRow(IPower power)
		{
			//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)
			GUILayout.BeginVertical(GUI.skin.box, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			string arg = ((!power.IsToggled) ? "" : " [ON]");
			GUILayout.Label($"{power.DisplayName}{arg}  -  {ScopeLabel(power.Scope)}", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) });
			if (GUILayout.Button(((object)power.Keybind/*cast due to .constrained prefix*/).ToString(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) }))
			{
				IsCapturingKeybind = true;
				_rebindingMenuKey = false;
				_rebindTarget = power as PowerBase;
			}
			GUILayout.EndHorizontal();
			GUILayout.Label(power.Description, GUI.skin.label, Array.Empty<GUILayoutOption>());
			object obj = power as SpawnItemPower;
			SpawnItemPower spawnItemPower = default(SpawnItemPower);
			if (obj != null)
			{
				spawnItemPower = (SpawnItemPower)obj;
				obj = spawnItemPower;
			}
			if (obj != null)
			{
				DrawCycleRow("Item:", spawnItemPower.CurrentSelectionName(), spawnItemPower.CyclePrevious, spawnItemPower.CycleNext);
			}
			else
			{
				object obj2 = power as SpawnValuablePower;
				SpawnValuablePower spawnValuablePower = default(SpawnValuablePower);
				if (obj2 != null)
				{
					spawnValuablePower = (SpawnValuablePower)obj2;
					obj2 = spawnValuablePower;
				}
				if (obj2 != null)
				{
					DrawCycleRow("Valuable:", spawnValuablePower.CurrentSelectionName(), spawnValuablePower.CyclePrevious, spawnValuablePower.CycleNext);
				}
				else
				{
					object obj3 = power as SpawnEnemyPower;
					SpawnEnemyPower spawnEnemyPower = default(SpawnEnemyPower);
					if (obj3 != null)
					{
						spawnEnemyPower = (SpawnEnemyPower)obj3;
						obj3 = spawnEnemyPower;
					}
					if (obj3 != null)
					{
						DrawCycleRow("Enemy:", spawnEnemyPower.CurrentSelectionName(), spawnEnemyPower.CyclePrevious, spawnEnemyPower.CycleNext);
					}
				}
			}
			GUILayout.EndVertical();
		}

		private void DrawCycleRow(string label, string current, Action prev, Action next)
		{
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) });
			if (GUILayout.Button("<", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(24f) }))
			{
				prev();
			}
			GUILayout.Label(current, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(220f) });
			if (GUILayout.Button(">", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(24f) }))
			{
				next();
			}
			GUILayout.EndHorizontal();
		}

		private unsafe void DrawKeybindRow(string label, KeyboardShortcut bind, Action onRebind)
		{
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) });
			if (GUILayout.Button(((object)(*(KeyboardShortcut*)(&bind))/*cast due to .constrained prefix*/).ToString(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) }))
			{
				onRebind();
			}
			GUILayout.EndHorizontal();
		}

		private static string ScopeLabel(NetworkScope scope)
		{
			return scope switch
			{
				NetworkScope.LocalOnly => "Host+Client", 
				NetworkScope.GameRpc => "Host+Client", 
				NetworkScope.ModRelay => "Host+Client (needs target's REPO Powers)", 
				NetworkScope.NetworkSpawn => "Host+Client", 
				NetworkScope.HostRecommended => "Host recommended", 
				_ => "", 
			};
		}
	}
}
namespace REPOPowers
{
	[BepInPlugin("yourname.repopowers", "REPO Powers", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "yourname.repopowers";

		public const string PluginName = "REPO Powers";

		public const string PluginVersion = "1.0.0";

		public static ManualLogSource Log;

		private Harmony _harmony;

		private void Awake()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)string.Format("{0} v{1} loading...", "REPO Powers", "1.0.0"));
			_harmony = new Harmony("yourname.repopowers");
			_harmony.PatchAll();
			GameObject val = new GameObject("REPOPowersManager");
			Object.DontDestroyOnLoad((Object)(object)val);
			PowerManager powerManager = val.AddComponent<PowerManager>();
			val.AddComponent<PowersMenu>();
			powerManager.RegisterAll(new IPower[11]
			{
				new FlyPower(),
				new NoclipPower(),
				new SelfTeleportPower(),
				new TelekinesisPower(),
				new PuppetPower(),
				new SpawnItemPower(),
				new SpawnValuablePower(),
				new SpawnEnemyPower(),
				new HealPlayerPower(),
				new RevivePlayerPower(),
				new TeleportPlayerPower()
			}, ((BaseUnityPlugin)this).Config);
			Log.LogInfo((object)string.Format("{0} loaded with {1} powers registered.", "REPO Powers", powerManager.Powers.Count));
		}
	}
}
namespace REPOPowers.Networking
{
	public class PowerRelay : MonoBehaviourPun
	{
		private PlayerAvatar _avatar;

		private PlayerController _controller;

		private bool _puppetActive;

		private Vector3 _puppetMoveInput;

		private Quaternion _puppetLookRotation;

		private void Awake()
		{
			_avatar = ((Component)this).GetComponent<PlayerAvatar>();
			_controller = ((Component)this).GetComponent<PlayerController>();
		}

		private void Update()
		{
			if (_puppetActive)
			{
				ApplyPuppetMovement();
			}
		}

		public void SendPuppetMove(Vector3 worldMoveDirection, Quaternion lookRotation, bool active)
		{
			//IL_0014: 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)
			((MonoBehaviourPun)this).photonView.RPC("ReceivePuppetMove", (RpcTarget)0, new object[3] { worldMoveDirection, lookRotation, active });
		}

		[PunRPC]
		private void ReceivePuppetMove(Vector3 worldMoveDirection, Quaternion lookRotation, bool active)
		{
			//IL_0019: 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)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (((MonoBehaviourPun)this).photonView.IsMine)
			{
				_puppetActive = active;
				_puppetMoveInput = worldMoveDirection;
				_puppetLookRotation = lookRotation;
				if (active && (Object)(object)_controller != (Object)null)
				{
					_controller.Kinematic(0.5f);
				}
			}
		}

		private void ApplyPuppetMovement()
		{
			//IL_0066: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_008c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_controller != (Object)null)
			{
				_controller.Kinematic(0.5f);
			}
			Rigidbody rigidbody = GameHooks.GetRigidbody(_avatar);
			if ((Object)(object)rigidbody != (Object)null)
			{
				rigidbody.MovePosition(rigidbody.position + _puppetMoveInput * Time.deltaTime);
			}
			else
			{
				Transform transform = ((Component)this).transform;
				transform.position += _puppetMoveInput * Time.deltaTime;
			}
			((Component)this).transform.rotation = _puppetLookRotation;
		}

		public void SendTeleport(Vector3 worldPosition)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			((MonoBehaviourPun)this).photonView.RPC("ReceiveTeleport", (RpcTarget)0, new object[1] { worldPosition });
		}

		[PunRPC]
		private void ReceiveTeleport(Vector3 worldPosition)
		{
			//IL_0062: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			if (((MonoBehaviourPun)this).photonView.IsMine)
			{
				Rigidbody rigidbody = GameHooks.GetRigidbody(_avatar);
				if ((Object)(object)_controller != (Object)null)
				{
					_controller.Kinematic(0.2f);
				}
				if ((Object)(object)rigidbody != (Object)null)
				{
					rigidbody.position = worldPosition;
					rigidbody.velocity = Vector3.zero;
				}
				((Component)this).transform.position = worldPosition;
			}
		}
	}
}
namespace REPOPowers.Core
{
	public class PowerManager : MonoBehaviour
	{
		public readonly List<IPower> Powers = new List<IPower>();

		public KeyboardShortcut MenuToggleKey = new KeyboardShortcut((KeyCode)285, Array.Empty<KeyCode>());

		private ConfigEntry<KeyboardShortcut> _menuToggleEntry;

		public int SelectedTargetIndex = 0;

		public static PowerManager Instance { get; private set; }

		public bool MenuOpen { get; private set; }

		public void RegisterAll(IEnumerable<IPower> powers, ConfigFile config)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			_menuToggleEntry = config.Bind<KeyboardShortcut>("General", "MenuToggleKey", MenuToggleKey, "Key to open/close the REPO Powers menu.");
			MenuToggleKey = _menuToggleEntry.Value;
			foreach (IPower power in powers)
			{
				power.Initialize(config);
				Powers.Add(power);
			}
		}

		private void Awake()
		{
			Instance = this;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
		}

		private void Update()
		{
			if (((KeyboardShortcut)(ref MenuToggleKey)).IsDown())
			{
				MenuOpen = !MenuOpen;
			}
			if (PowersMenu.IsCapturingKeybind)
			{
				return;
			}
			foreach (IPower power in Powers)
			{
				power.Tick();
			}
		}

		public void SaveMenuToggleKey(KeyboardShortcut newBind)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: 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)
			MenuToggleKey = newBind;
			_menuToggleEntry.Value = newBind;
		}

		public PlayerAvatar GetSelectedTarget()
		{
			List<PlayerAvatar> otherPlayers = GetOtherPlayers();
			if (otherPlayers.Count == 0)
			{
				return null;
			}
			if (SelectedTargetIndex >= otherPlayers.Count)
			{
				SelectedTargetIndex = 0;
			}
			return otherPlayers[SelectedTargetIndex];
		}

		public List<PlayerAvatar> GetOtherPlayers()
		{
			List<PlayerAvatar> list = new List<PlayerAvatar>();
			PlayerAvatar localPlayer = GameHooks.GetLocalPlayer();
			foreach (PlayerAvatar allPlayer in GameHooks.GetAllPlayers())
			{
				if ((Object)(object)allPlayer != (Object)null && (Object)(object)allPlayer != (Object)(object)localPlayer)
				{
					list.Add(allPlayer);
				}
			}
			return list;
		}

		public void DeactivateAll()
		{
			foreach (IPower power in Powers)
			{
				power.Deactivate();
			}
		}
	}
	public abstract class PowerBase : IPower
	{
		protected ConfigEntry<KeyboardShortcut> KeybindEntry;

		public abstract string Id { get; }

		public abstract string DisplayName { get; }

		public abstract string Description { get; }

		public abstract NetworkScope Scope { get; }

		public virtual bool RequiresTargetPlayer
		{
			[CompilerGenerated]
			get
			{
				return false;
			}
		}

		protected virtual bool IsToggleType
		{
			[CompilerGenerated]
			get
			{
				return true;
			}
		}

		public bool IsToggled { get; protected set; }

		public KeyboardShortcut Keybind { get; set; }

		public virtual void Initialize(ConfigFile config)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			KeybindEntry = config.Bind<KeyboardShortcut>("Keybinds", Id, DefaultKeybind(), $"Keybind for: {DisplayName}");
			Keybind = KeybindEntry.Value;
		}

		protected abstract KeyboardShortcut DefaultKeybind();

		public void Tick()
		{
			//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)
			KeyboardShortcut keybind = Keybind;
			if (((KeyboardShortcut)(ref keybind)).IsDown())
			{
				if (IsToggleType)
				{
					if (IsToggled)
					{
						Deactivate();
					}
					else
					{
						Activate();
					}
				}
				else
				{
					OnPressed();
				}
			}
			if (IsToggled)
			{
				OnActiveTick();
			}
		}

		protected virtual void Activate()
		{
			IsToggled = true;
			OnActivate();
		}

		public void Deactivate()
		{
			if (IsToggled)
			{
				IsToggled = false;
				OnDeactivate();
			}
		}

		protected virtual void OnActivate()
		{
		}

		protected virtual void OnDeactivate()
		{
		}

		protected virtual void OnActiveTick()
		{
		}

		protected virtual void OnPressed()
		{
		}

		public void SaveKeybind(KeyboardShortcut newBind)
		{
			//IL_0001: 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)
			Keybind = newBind;
			KeybindEntry.Value = newBind;
		}
	}
	public interface IPower
	{
		string Id { get; }

		string DisplayName { get; }

		string Description { get; }

		NetworkScope Scope { get; }

		bool IsToggled { get; }

		KeyboardShortcut Keybind { get; set; }

		bool RequiresTargetPlayer { get; }

		void Initialize(ConfigFile config);

		void Tick();

		void Deactivate();
	}
	public enum NetworkScope
	{
		LocalOnly,
		GameRpc,
		ModRelay,
		NetworkSpawn,
		HostRecommended
	}
	public static class GameHooks
	{
		private static readonly FieldInfo RigidbodyField = typeof(PlayerAvatar).GetField("rb", BindingFlags.Instance | BindingFlags.NonPublic);

		public static bool IsMultiplayer()
		{
			return SemiFunc.IsMultiplayer();
		}

		public static bool IsMasterClient()
		{
			return SemiFunc.IsMasterClient();
		}

		public static bool IsNotMasterClient()
		{
			return SemiFunc.IsNotMasterClient();
		}

		public static PlayerAvatar GetLocalPlayer()
		{
			return SemiFunc.PlayerGetLocal();
		}

		public static List<PlayerAvatar> GetAllPlayers()
		{
			return SemiFunc.PlayerGetAll();
		}

		public static Camera GetMainCamera()
		{
			return SemiFunc.MainCamera();
		}

		public static Rigidbody GetRigidbody(PlayerAvatar avatar)
		{
			if ((Object)(object)avatar == (Object)null)
			{
				return null;
			}
			Rigidbody component = ((Component)avatar).GetComponent<Rigidbody>();
			if ((Object)(object)component != (Object)null)
			{
				return component;
			}
			object? obj = (((object)RigidbodyField != null) ? RigidbodyField.GetValue(avatar) : null);
			return (Rigidbody)((obj is Rigidbody) ? obj : null);
		}

		public static IEnumerable<Collider> GetColliders(PlayerAvatar avatar)
		{
			if (!((Object)(object)avatar == (Object)null))
			{
				Collider[] componentsInChildren = ((Component)avatar).GetComponentsInChildren<Collider>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					yield return componentsInChildren[i];
				}
			}
		}
	}
}
namespace REPOPowers.Patches
{
	[HarmonyPatch(typeof(PlayerAvatar), "Start")]
	internal static class PlayerAvatar_Start_Patch
	{
		[HarmonyPostfix]
		private static void Postfix(PlayerAvatar __instance)
		{
			if ((Object)(object)((Component)__instance).GetComponent<PowerRelay>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<PowerRelay>();
			}
		}
	}
	[HarmonyPatch(typeof(PlayerAvatar), "PlayerDeath")]
	internal static class PlayerAvatar_Death_Patch
	{
		[HarmonyPostfix]
		private static void Postfix(PlayerAvatar __instance)
		{
			if ((Object)(object)__instance != (Object)null && (Object)(object)__instance.photonView != (Object)null && __instance.photonView.IsMine && (Object)(object)PowerManager.Instance != (Object)null)
			{
				PowerManager.Instance.DeactivateAll();
			}
		}
	}
}