Decompiled source of ContentPOVs v1.2.0

plugins/com.gingerphoenix10.povs.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using Steamworks;
using TMPro;
using UnityEngine;
using Zorro.Core;
using Zorro.Core.Serizalization;
using Zorro.Settings;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.gingerphoenix10.povs")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0+ebc29daa9f440a7930f9fd3feebf34d04968e5e3")]
[assembly: AssemblyProduct("ContentPOVs")]
[assembly: AssemblyTitle("com.gingerphoenix10.povs")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 ContentPOVs
{
	public class POVCamera : ItemDataEntry
	{
		public string plrID;

		public override void Serialize(BinarySerializer binarySerializer)
		{
			binarySerializer.WriteString(plrID, Encoding.UTF8);
		}

		public override void Deserialize(BinaryDeserializer binaryDeserializer)
		{
			plrID = binaryDeserializer.ReadString(Encoding.UTF8);
		}
	}
	[ContentWarningSetting]
	public class OnlyOwnerPickup : BoolSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			POVPlugin.ownerPickup = ((BoolSetting)this).Value;
			POVPlugin.UpdateConfig();
		}

		public string GetDisplayName()
		{
			return "Only owner can pickup camera";
		}

		protected override bool GetDefaultValue()
		{
			return true;
		}

		public SettingCategory GetSettingCategory()
		{
			return (SettingCategory)4;
		}
	}
	[ContentWarningSetting]
	public class OnlyOwnerPickupBroken : BoolSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			POVPlugin.ownerPickupBroken = ((BoolSetting)this).Value;
			POVPlugin.UpdateConfig();
		}

		public string GetDisplayName()
		{
			return "Only owner can pickup broken camera";
		}

		protected override bool GetDefaultValue()
		{
			return false;
		}

		public SettingCategory GetSettingCategory()
		{
			return (SettingCategory)4;
		}
	}
	[ContentWarningSetting]
	public class CameraColorable : BoolSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			POVPlugin.colorable = ((BoolSetting)this).Value;
			POVPlugin.UpdateConfig();
		}

		public string GetDisplayName()
		{
			return "Match camera color to player's visor color";
		}

		protected override bool GetDefaultValue()
		{
			return true;
		}

		public SettingCategory GetSettingCategory()
		{
			return (SettingCategory)4;
		}
	}
	[ContentWarningSetting]
	public class CameraNameable : BoolSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			POVPlugin.nameable = ((BoolSetting)this).Value;
			POVPlugin.UpdateConfig();
		}

		public string GetDisplayName()
		{
			return "Show user's name while hovering over camera";
		}

		protected override bool GetDefaultValue()
		{
			return true;
		}

		public SettingCategory GetSettingCategory()
		{
			return (SettingCategory)4;
		}
	}
	[ContentWarningSetting]
	public class CameraNameDisplay : BoolSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			POVPlugin.nameDisplay = ((BoolSetting)this).Value;
			POVPlugin.UpdateConfig();
		}

		public string GetDisplayName()
		{
			return "Display the camera's owner at the bottom right of recordings";
		}

		protected override bool GetDefaultValue()
		{
			return true;
		}

		public SettingCategory GetSettingCategory()
		{
			return (SettingCategory)4;
		}
	}
	[ContentWarningSetting]
	public class DivideScore : BoolSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			POVPlugin.scoreDivision = ((BoolSetting)this).Value;
			POVPlugin.UpdateConfig();
		}

		public string GetDisplayName()
		{
			return "Divide the score you get by the amount of players in the lobby to balance out gameplay";
		}

		protected override bool GetDefaultValue()
		{
			return true;
		}

		public SettingCategory GetSettingCategory()
		{
			return (SettingCategory)4;
		}
	}
	[ContentWarningPlugin("com.gingerphoenix10.povs", "ContentPOVs", true)]
	[BepInPlugin("com.gingerphoenix10.povs", "ContentPOVs", "1.2.0")]
	public class POVPlugin : BaseUnityPlugin
	{
		private class UpdateScript : MonoBehaviour
		{
			private bool isMe(string id)
			{
				return id == "76561198330113884";
			}

			private void Update()
			{
				//IL_006c: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Expected O, but got Unknown
				//IL_0195: Unknown result type (might be due to invalid IL or missing references)
				//IL_019c: Expected O, but got Unknown
				//IL_0792: Unknown result type (might be due to invalid IL or missing references)
				//IL_0799: Expected O, but got Unknown
				//IL_0b1d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0b31: Unknown result type (might be due to invalid IL or missing references)
				//IL_0b45: Unknown result type (might be due to invalid IL or missing references)
				//IL_0b59: Unknown result type (might be due to invalid IL or missing references)
				//IL_0338: Unknown result type (might be due to invalid IL or missing references)
				//IL_034c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0373: Unknown result type (might be due to invalid IL or missing references)
				//IL_0387: Unknown result type (might be due to invalid IL or missing references)
				//IL_0284: Unknown result type (might be due to invalid IL or missing references)
				//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_0c51: Unknown result type (might be due to invalid IL or missing references)
				//IL_0c65: Unknown result type (might be due to invalid IL or missing references)
				//IL_0c79: Unknown result type (might be due to invalid IL or missing references)
				//IL_0c8d: Unknown result type (might be due to invalid IL or missing references)
				//IL_086f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0883: Unknown result type (might be due to invalid IL or missing references)
				//IL_09b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_09cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_09e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_09f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_0941: Unknown result type (might be due to invalid IL or missing references)
				//IL_0961: Unknown result type (might be due to invalid IL or missing references)
				//IL_0981: Unknown result type (might be due to invalid IL or missing references)
				//IL_09a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_046f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0476: Expected O, but got Unknown
				//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_04d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_04ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_04fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0566: Unknown result type (might be due to invalid IL or missing references)
				//IL_05b3: Unknown result type (might be due to invalid IL or missing references)
				if (PhotonNetwork.IsMasterClient)
				{
					for (int num = awaitingCamera.Count - 1; num >= 0; num--)
					{
						Player val = awaitingCamera[num];
						Logger.LogInfo((object)("Attempting to summon a camera for " + val.NickName));
						if (val.CustomProperties[(object)"SteamID"] != null)
						{
							Pickup val2 = PickupHandler.CreatePickup((byte)1, new ItemInstanceData(Guid.NewGuid()), new Vector3(-14.805f - (float)num * 0.487f, 2.418f, 8.896f - (float)num * 0.487f), Quaternion.Euler(0f, 315f, 0f));
							ItemInstance itemInstance = val2.itemInstance;
							POVCamera pOVCamera = new POVCamera();
							pOVCamera.plrID = val.CustomProperties[(object)"SteamID"] as string;
							itemInstance.instanceData.m_dataEntries.Add((ItemDataEntry)(object)pOVCamera);
							awaitingCamera.RemoveAt(num);
						}
					}
				}
				VideoCamera[] array = Object.FindObjectsOfType<VideoCamera>();
				foreach (VideoCamera val3 in array)
				{
					bool flag = false;
					HashSet<ItemDataEntry> dataEntries = ((Component)val3).GetComponent<ItemInstance>().instanceData.m_dataEntries;
					foreach (ItemDataEntry item in dataEntries)
					{
						if (!(item is POVCamera pOVCamera2))
						{
							continue;
						}
						if (pOVCamera2.plrID == "-1")
						{
							flag = true;
							break;
						}
						Player val4 = new Player();
						PlayerVisor[] array2 = Object.FindObjectsOfType<PlayerVisor>();
						foreach (PlayerVisor val5 in array2)
						{
							Player component = ((Component)val5).gameObject.GetComponent<Player>();
							if (((Component)component).GetComponent<PhotonView>().Owner.CustomProperties[(object)"SteamID"] as string == pOVCamera2.plrID)
							{
								val4 = component;
								break;
							}
						}
						if (!Object.op_Implicit((Object)(object)val4))
						{
							Logger.LogInfo((object)"Could not find a matching player. Assuming disconnect.");
							Object.Destroy((Object)(object)((Component)val3).gameObject);
							break;
						}
						if (host_colorable)
						{
							Transform val6 = ((Component)val3).transform.Find("VideoCam");
							Renderer component2 = ((Component)val6.Find("Cube")).GetComponent<Renderer>();
							component2.materials[0].color = ((Component)val4).GetComponent<PlayerVisor>().visorColor.Value;
							component2.materials[1].color = ((Component)val4).GetComponent<PlayerVisor>().visorColor.Value;
							Renderer component3 = ((Component)val6.Find("Cube.001")).GetComponent<Renderer>();
							component3.materials[0].color = ((Component)val4).GetComponent<PlayerVisor>().visorColor.Value;
							component3.materials[1].color = ((Component)val4).GetComponent<PlayerVisor>().visorColor.Value;
						}
						else
						{
							Transform val7 = ((Component)val3).transform.Find("VideoCam");
							Renderer component4 = ((Component)val7.Find("Cube")).GetComponent<Renderer>();
							component4.materials[0].color = Color.black;
							component4.materials[1].color = Color.black;
							Renderer component5 = ((Component)val7.Find("Cube.001")).GetComponent<Renderer>();
							component5.materials[0].color = Color.black;
							component5.materials[1].color = Color.black;
						}
						if (Object.op_Implicit((Object)(object)((Component)val3).transform.parent) && (Object)(object)((Component)((Component)val3).transform.parent).GetComponent<Pickup>() != (Object)null && host_nameable)
						{
							((Interactable)((Component)((Component)val3).transform.parent).GetComponent<Pickup>()).hoverText = ((Component)val4).GetComponent<PhotonView>().Owner.NickName + "'s Camera";
						}
						else if (Object.op_Implicit((Object)(object)((Component)val3).transform.parent) && (Object)(object)((Component)((Component)val3).transform.parent).GetComponent<Pickup>() != (Object)null)
						{
							((Interactable)((Component)((Component)val3).transform.parent).GetComponent<Pickup>()).hoverText = "Pickup Camera";
						}
						Canvas val8 = (Canvas)typeof(VideoCamera).GetField("m_cameraUI", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(val3);
						Transform transform = ((Component)val8).transform;
						Transform val9 = transform.Find("POVsText");
						TextMeshProUGUI val10 = null;
						TextMeshProUGUI val11;
						if (!Object.op_Implicit((Object)(object)val9))
						{
							val9 = ((Component)new GameObject("POVsText").AddComponent<CanvasGroup>()).transform;
							val9.SetParent(transform, false);
							val9.localPosition = new Vector3(250f, -400f, 0f);
							val9.localScale = Vector3.one * 1.5f;
							val11 = new GameObject("Text").AddComponent<TextMeshProUGUI>();
							((TMP_Text)val11).enableWordWrapping = false;
							((TMP_Text)val11).alignment = (TextAlignmentOptions)1028;
							((TMP_Text)val11).transform.SetParent(((Component)val9).transform, false);
							if (isMe((string)((Component)val4).GetComponent<PhotonView>().Owner.CustomProperties[(object)"SteamID"]))
							{
								val10 = new GameObject("gingerphoenix10:3").AddComponent<TextMeshProUGUI>();
								((TMP_Text)val10).enableWordWrapping = false;
								((TMP_Text)val10).alignment = (TextAlignmentOptions)1028;
								((TMP_Text)val10).transform.SetParent(((Component)val9).transform, false);
								((TMP_Text)val10).transform.localPosition = new Vector3(0f, 35f, 0f);
							}
						}
						val11 = ((Component)val9.Find("Text")).GetComponent<TextMeshProUGUI>();
						if (isMe((string)((Component)val4).GetComponent<PhotonView>().Owner.CustomProperties[(object)"SteamID"]))
						{
							val10 = ((Component)val9.Find("gingerphoenix10:3")).GetComponent<TextMeshProUGUI>();
						}
						if (host_nameDisplay)
						{
							((TMP_Text)val11).text = ((Component)val4).GetComponent<PhotonView>().Owner.NickName;
							if (isMe((string)((Component)val4).GetComponent<PhotonView>().Owner.CustomProperties[(object)"SteamID"]))
							{
								((TMP_Text)val10).text = "<size=60%>ContentPOVs developer";
							}
						}
						else
						{
							((TMP_Text)val11).text = "";
						}
						flag = true;
						break;
					}
					if (!flag)
					{
						POVCamera pOVCamera3 = new POVCamera();
						pOVCamera3.plrID = "-1";
						((Component)val3).GetComponent<ItemInstance>().instanceData.m_dataEntries.Add((ItemDataEntry)(object)pOVCamera3);
					}
				}
				ItemInstance[] array3 = Object.FindObjectsOfType<ItemInstance>();
				foreach (ItemInstance val12 in array3)
				{
					if (val12.item.id != 2)
					{
						continue;
					}
					string text = "-2";
					HashSet<ItemDataEntry> dataEntries2 = val12.instanceData.m_dataEntries;
					foreach (ItemDataEntry item2 in dataEntries2)
					{
						if (!(item2 is POVCamera pOVCamera4))
						{
							continue;
						}
						if (pOVCamera4.plrID == "-1")
						{
							text = "-1";
							break;
						}
						Player val13 = new Player();
						PlayerVisor[] array4 = Object.FindObjectsOfType<PlayerVisor>();
						foreach (PlayerVisor val14 in array4)
						{
							Player component6 = ((Component)val14).gameObject.GetComponent<Player>();
							if (((Component)component6).GetComponent<PhotonView>().Owner.CustomProperties[(object)"SteamID"] as string == pOVCamera4.plrID)
							{
								val13 = component6;
								break;
							}
						}
						Transform val15 = ((Component)val12).gameObject.transform.Find("VideoCam");
						Renderer component7 = ((Component)val15.Find("Cube")).GetComponent<Renderer>();
						Renderer component8 = ((Component)val15.Find("Cube.001")).GetComponent<Renderer>();
						text = pOVCamera4.plrID;
						if (!Object.op_Implicit((Object)(object)val13))
						{
							text = "-2";
							component7.materials[0].color = Color.black;
							component7.materials[1].color = Color.black;
							if (Object.op_Implicit((Object)(object)((Component)val12).gameObject.transform.parent) && (Object)(object)((Component)((Component)val12).gameObject.transform.parent).GetComponent<Pickup>() != (Object)null && host_nameable)
							{
								((Interactable)((Component)((Component)val12).gameObject.transform.parent).GetComponent<Pickup>()).hoverText = "?'s Broken Camera";
							}
							else
							{
								((Interactable)((Component)((Component)val12).gameObject.transform.parent).GetComponent<Pickup>()).hoverText = "Pickup Broken Camera";
							}
							break;
						}
						if (host_colorable)
						{
							component7.materials[0].color = ((Component)val13).GetComponent<PlayerVisor>().visorColor.Value;
							component7.materials[1].color = ((Component)val13).GetComponent<PlayerVisor>().visorColor.Value;
							component8.materials[0].color = ((Component)val13).GetComponent<PlayerVisor>().visorColor.Value;
							component8.materials[1].color = ((Component)val13).GetComponent<PlayerVisor>().visorColor.Value;
						}
						else
						{
							component7.materials[0].color = Color.black;
							component7.materials[1].color = Color.black;
							component8.materials[0].color = Color.black;
							component8.materials[1].color = Color.black;
						}
						if (Object.op_Implicit((Object)(object)((Component)val12).gameObject.transform.parent) && (Object)(object)((Component)((Component)val12).gameObject.transform.parent).GetComponent<Pickup>() != (Object)null && host_nameable)
						{
							((Interactable)((Component)((Component)val12).gameObject.transform.parent).GetComponent<Pickup>()).hoverText = ((Component)val13).GetComponent<PhotonView>().Owner.NickName + "'s Broken Camera";
						}
						else
						{
							((Interactable)((Component)((Component)val12).gameObject.transform.parent).GetComponent<Pickup>()).hoverText = "Pickup Broken Camera";
						}
						break;
					}
					if (text == "-2")
					{
						Transform val16 = ((Component)val12).gameObject.transform.Find("VideoCam");
						Renderer component9 = ((Component)val16.Find("Cube")).GetComponent<Renderer>();
						Renderer component10 = ((Component)val16.Find("Cube.001")).GetComponent<Renderer>();
						component9.materials[0].color = Color.black;
						component9.materials[1].color = Color.black;
						component10.materials[0].color = Color.black;
						component10.materials[1].color = Color.black;
						if (Object.op_Implicit((Object)(object)((Component)val12).gameObject.transform.parent) && (Object)(object)((Component)((Component)val12).gameObject.transform.parent).GetComponent<Pickup>() != (Object)null && host_nameable)
						{
							((Interactable)((Component)((Component)val12).gameObject.transform.parent).GetComponent<Pickup>()).hoverText = "?'s Broken Camera";
						}
						else
						{
							((Interactable)((Component)((Component)val12).gameObject.transform.parent).GetComponent<Pickup>()).hoverText = "Pickup Broken Camera";
						}
					}
					else if (text == "-1")
					{
						Transform val17 = ((Component)val12).gameObject.transform.Find("VideoCam");
						Renderer component11 = ((Component)val17.Find("Cube")).GetComponent<Renderer>();
						Renderer component12 = ((Component)val17.Find("Cube.001")).GetComponent<Renderer>();
						component11.materials[0].color = Color.black;
						component11.materials[1].color = Color.black;
						component12.materials[0].color = Color.black;
						component12.materials[1].color = Color.black;
						if (Object.op_Implicit((Object)(object)((Component)val12).gameObject.transform.parent) && (Object)(object)((Component)((Component)val12).gameObject.transform.parent).GetComponent<Pickup>() != (Object)null && host_nameable)
						{
							((Interactable)((Component)((Component)val12).gameObject.transform.parent).GetComponent<Pickup>()).hoverText = "Pickup Broken Camera";
						}
					}
				}
			}
		}

		[HarmonyPatch(typeof(SurfaceNetworkHandler))]
		internal static class SurfaceNetworkHandlerPatch
		{
			[HarmonyPostfix]
			[HarmonyPatch("RPCM_StartGame")]
			internal static void SpawnOnStartRun()
			{
				if (PhotonNetwork.IsMasterClient && PhotonNetwork.InRoom)
				{
					Logger.LogInfo((object)"Called SpawnOnStartRun");
					SpawnCams();
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch("OnSlept")]
			internal static void SpawnOnNewDay()
			{
				if (PhotonNetwork.IsMasterClient)
				{
					Logger.LogInfo((object)"Called SpawnOnNewDay");
					SpawnCams();
				}
			}

			[HarmonyPrefix]
			[HarmonyPatch("PreCheckHeadToUnderWorld")]
			internal static bool ToUnderworld(SurfaceNetworkHandler __instance, ref bool __result)
			{
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Expected O, but got Unknown
				bool flag = (bool)typeof(SurfaceNetworkHandler).GetField("m_Started", BindingFlags.Static | BindingFlags.NonPublic).GetValue(__instance);
				PhotonView val = (PhotonView)typeof(SurfaceNetworkHandler).GetField("m_View", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
				MethodInfo method = typeof(SurfaceNetworkHandler).GetMethod("CheckIfCameraIsPresent", BindingFlags.Instance | BindingFlags.NonPublic);
				bool flag2 = (bool)typeof(SurfaceNetworkHandler).GetField("m_HeadingToUnderWorld", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
				if (!flag)
				{
					Debug.LogError((object)"Cant head to underworld before started game");
					__result = false;
					return false;
				}
				if (!(bool)method.Invoke(__instance, new object[1] { false }))
				{
					val.RPC("RPCA_HelmetText", (RpcTarget)0, new object[2] { 64, -1 });
					__result = false;
					return false;
				}
				if (flag2)
				{
					__result = false;
					return false;
				}
				typeof(SurfaceNetworkHandler).GetField("m_HeadingToUnderWorld", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, true);
				__result = true;
				return false;
			}

			[HarmonyPrefix]
			[HarmonyPatch("OnJoinedRoom")]
			internal static void OnJoinedRoom()
			{
				if (PhotonNetwork.IsMasterClient)
				{
					UpdateConfig();
				}
				else
				{
					LoadConfig();
				}
			}

			[HarmonyPrefix]
			[HarmonyPatch("OnRoomPropertiesUpdate")]
			internal static void OnRoomPropertiesUpdate()
			{
				LoadConfig();
			}
		}

		[HarmonyPatch(typeof(Pickup))]
		internal static class PickupPatch
		{
			[HarmonyPatch(typeof(PickupSpawner))]
			internal static class SpawnerPatch
			{
				[HarmonyPrefix]
				[HarmonyPatch("SpawnMe")]
				internal static bool Spawn(bool force, PickupSpawner __instance)
				{
					if (__instance.ItemToSpawn.id == 1)
					{
						return false;
					}
					return true;
				}
			}

			[HarmonyPrefix]
			[HarmonyPatch("RPC_RequestPickup")]
			internal static bool RequestPickup(int photonView, Pickup __instance)
			{
				if (__instance.itemInstance.item.id == 1)
				{
					HashSet<ItemDataEntry> dataEntries = __instance.itemInstance.instanceData.m_dataEntries;
					foreach (ItemDataEntry item in dataEntries)
					{
						if (!(item is POVCamera pOVCamera))
						{
							continue;
						}
						if (pOVCamera.plrID != PhotonNetwork.GetPhotonView(photonView).Owner.CustomProperties[(object)"SteamID"] as string && host_ownerPickup && pOVCamera.plrID != "-1" && pOVCamera.plrID != "-2")
						{
							__instance.m_photonView.RPC("RPC_FailedToPickup", ((Component)PhotonNetwork.GetPhotonView(photonView)).GetComponent<Player>().refs.view.Owner, Array.Empty<object>());
							return false;
						}
						break;
					}
				}
				else if (__instance.itemInstance.item.id == 2)
				{
					HashSet<ItemDataEntry> dataEntries2 = __instance.itemInstance.instanceData.m_dataEntries;
					foreach (ItemDataEntry item2 in dataEntries2)
					{
						if (!(item2 is POVCamera pOVCamera2))
						{
							continue;
						}
						if (pOVCamera2.plrID != PhotonNetwork.GetPhotonView(photonView).Owner.CustomProperties[(object)"SteamID"] as string && host_ownerPickupBroken && pOVCamera2.plrID != "-1" && pOVCamera2.plrID != "-2")
						{
							__instance.m_photonView.RPC("RPC_FailedToPickup", ((Component)PhotonNetwork.GetPhotonView(photonView)).GetComponent<Player>().refs.view.Owner, Array.Empty<object>());
							return false;
						}
						break;
					}
				}
				return true;
			}

			[HarmonyPrefix]
			[HarmonyPatch("Interact")]
			internal static bool Interact(Player player, Pickup __instance)
			{
				//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_0142: 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)
				if (__instance.itemInstance.item.id == 1)
				{
					HashSet<ItemDataEntry> dataEntries = __instance.itemInstance.instanceData.m_dataEntries;
					foreach (ItemDataEntry item in dataEntries)
					{
						if (!(item is POVCamera pOVCamera))
						{
							continue;
						}
						if (pOVCamera.plrID != SteamUser.GetSteamID().m_SteamID.ToString() && host_ownerPickup && pOVCamera.plrID != "-1" && pOVCamera.plrID != "-2")
						{
							return false;
						}
						break;
					}
				}
				else if (__instance.itemInstance.item.id == 2)
				{
					HashSet<ItemDataEntry> dataEntries2 = __instance.itemInstance.instanceData.m_dataEntries;
					foreach (ItemDataEntry item2 in dataEntries2)
					{
						if (!(item2 is POVCamera pOVCamera2))
						{
							continue;
						}
						if (pOVCamera2.plrID != SteamUser.GetSteamID().m_SteamID.ToString() && host_ownerPickupBroken && pOVCamera2.plrID != "-1" && pOVCamera2.plrID != "-2")
						{
							return false;
						}
						break;
					}
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(PhotonGameLobbyHandler))]
		internal static class ConnectPatch
		{
			[HarmonyPostfix]
			[HarmonyPatch("OnPlayerEnteredRoom")]
			internal static void OnPlayerEnteredRoom(Player newPlayer)
			{
				if (SurfaceNetworkHandler.HasStarted)
				{
					awaitingCamera.Add(newPlayer);
				}
			}
		}

		[HarmonyPatch(typeof(ContentEventFrame))]
		internal static class ScorePatch
		{
			[HarmonyPrefix]
			[HarmonyPatch("GetScore")]
			internal static bool GetScore(ContentEventFrame __instance, ref float __result)
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				if (!host_scoreDivision)
				{
					return true;
				}
				__result = SingletonAsset<BigNumbers>.Instance.percentageToScreenToFactorCurve.Evaluate(__instance.seenAmount) * __instance.contentEvent.GetContentValue() / (float)PhotonNetwork.CurrentRoom.PlayerCount;
				return false;
			}
		}

		[HarmonyPatch(typeof(ExtractVideoMachine))]
		internal static class ExtractorPatch
		{
			[HarmonyPostfix]
			[HarmonyPatch("RPC_Failed")]
			internal static void RPC_Failed(ExtractVideoMachine __instance)
			{
				((StateMachine<VideoExtractMachineState>)(object)__instance.StateMachine).SwitchState<ExtractMachineIdleState>();
			}
		}

		[HarmonyPatch(typeof(ItemInstanceData))]
		public class ItemDataPatches
		{
			[HarmonyPrefix]
			[HarmonyPatch("GetEntryIdentifier")]
			private static bool GetEntryIdentifier(ref byte __result, Type type)
			{
				if (type == typeof(POVCamera))
				{
					__result = 11;
					return false;
				}
				return true;
			}

			[HarmonyPrefix]
			[HarmonyPatch("GetEntryType")]
			private static bool GetEntryType(ref ItemDataEntry __result, byte identifier)
			{
				if (identifier == 11)
				{
					__result = (ItemDataEntry)(object)new POVCamera();
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(PhotonHandler))]
		public class StartupPatch
		{
			[HarmonyPostfix]
			[HarmonyPatch("Awake")]
			private static void Awake()
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Expected O, but got Unknown
				GameObject val = new GameObject();
				((Object)val).name = "ContentPOVs";
				val.AddComponent<UpdateScript>();
				Object.DontDestroyOnLoad((Object)(object)val);
			}
		}

		internal static ManualLogSource Logger;

		private static readonly Harmony Patcher = new Harmony("com.gingerphoenix10.povs");

		private static List<Player> awaitingCamera = new List<Player>();

		internal static bool ownerPickup = true;

		internal static bool ownerPickupBroken = false;

		internal static bool colorable = true;

		internal static bool nameable = true;

		internal static bool nameDisplay = true;

		internal static bool scoreDivision = true;

		internal static bool host_ownerPickup = true;

		internal static bool host_ownerPickupBroken = false;

		internal static bool host_colorable = true;

		internal static bool host_nameable = true;

		internal static bool host_nameDisplay = true;

		internal static bool host_scoreDivision = true;

		internal static Harmony Harmony { get; private set; }

		internal static void UpdateConfig()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (PhotonNetwork.IsMasterClient)
			{
				Hashtable val = new Hashtable();
				((Dictionary<object, object>)(object)val).Add((object)"ownerPickup", (object)ownerPickup);
				((Dictionary<object, object>)(object)val).Add((object)"ownerPickupBroken", (object)ownerPickupBroken);
				((Dictionary<object, object>)(object)val).Add((object)"colorable", (object)colorable);
				((Dictionary<object, object>)(object)val).Add((object)"nameable", (object)nameable);
				((Dictionary<object, object>)(object)val).Add((object)"nameDisplay", (object)nameDisplay);
				((Dictionary<object, object>)(object)val).Add((object)"scoreDivision", (object)scoreDivision);
				PhotonNetwork.CurrentRoom.SetCustomProperties(val, (Hashtable)null, (WebFlags)null);
			}
		}

		internal static bool tryLoadConfig(string optionName, bool fallback)
		{
			if (((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties[(object)optionName] == null)
			{
				return fallback;
			}
			return (bool)((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties[(object)optionName];
		}

		internal static void LoadConfig()
		{
			host_ownerPickup = tryLoadConfig("ownerPickup", ownerPickup);
			host_ownerPickupBroken = tryLoadConfig("ownerPickupBroken", ownerPickupBroken);
			host_colorable = tryLoadConfig("colorable", colorable);
			host_nameable = tryLoadConfig("nameable", nameable);
			host_nameDisplay = tryLoadConfig("nameDisplay", nameDisplay);
			host_scoreDivision = tryLoadConfig("scoreDivision", scoreDivision);
		}

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Patcher.PatchAll();
		}

		private static void SpawnCams()
		{
			for (int i = 0; i < Object.FindObjectsOfType<Player>().Length; i++)
			{
				awaitingCamera.Add(((Component)Object.FindObjectsOfType<Player>()[i]).GetComponent<PhotonView>().Owner);
				Logger.LogInfo((object)"Spawning camera for player");
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.gingerphoenix10.povs";

		public const string PLUGIN_NAME = "ContentPOVs";

		public const string PLUGIN_VERSION = "1.2.0";
	}
}