Decompiled source of ContentPOVs v1.1.0

plugins/com.gingerphoenix10.povs.dll

Decompiled a week 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 ContentSettings.API.Attributes;
using ContentSettings.API.Settings;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MyceliumNetworking;
using Photon.Pun;
using Photon.Realtime;
using ShopUtils;
using Steamworks;
using TMPro;
using UnityEngine;
using Zorro.Core;
using Zorro.Core.Serizalization;

[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.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+2f2e588ab03d4c4a99e866075799b181d7cd6423")]
[assembly: AssemblyProduct("ContentPOVs")]
[assembly: AssemblyTitle("com.gingerphoenix10.povs")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.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);
		}
	}
	[SettingRegister("ContentPOVs", null)]
	public class OnlyOwnerPickup : BoolSetting, ICustomSetting, 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;
		}
	}
	[SettingRegister("ContentPOVs", null)]
	public class OnlyOwnerPickupBroken : BoolSetting, ICustomSetting, 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;
		}
	}
	[SettingRegister("ContentPOVs", null)]
	public class CameraColorable : BoolSetting, ICustomSetting, 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;
		}
	}
	[SettingRegister("ContentPOVs", null)]
	public class CameraNameable : BoolSetting, ICustomSetting, 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;
		}
	}
	[SettingRegister("ContentPOVs", null)]
	public class CameraNameDisplay : BoolSetting, ICustomSetting, 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;
		}
	}
	[SettingRegister("ContentPOVs", null)]
	public class DivideScore : BoolSetting, ICustomSetting, 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;
		}
	}
	[ContentWarningPlugin("com.gingerphoenix10.povs", "ContentPOVs", true)]
	[BepInPlugin("com.gingerphoenix10.povs", "ContentPOVs", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class POVPlugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(SurfaceNetworkHandler))]
		internal static class SurfaceNetworkHandlerPatch
		{
			[HarmonyPostfix]
			[HarmonyPatch("RPCM_StartGame")]
			internal static void SpawnOnStartRun()
			{
				if (MyceliumNetwork.IsHost && PhotonNetwork.InRoom)
				{
					Logger.LogInfo((object)"Called SpawnOnStartRun");
					SpawnCams();
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch("OnSlept")]
			internal static void SpawnOnNewDay()
			{
				if (MyceliumNetwork.IsHost)
				{
					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;
			}
		}

		[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)MyceliumNetwork.PlayerCount;
				return false;
			}
		}

		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()
		{
			if (MyceliumNetwork.IsHost)
			{
				MyceliumNetwork.SetLobbyData("ownerPickup", (object)ownerPickup);
				MyceliumNetwork.SetLobbyData("ownerPickupBroken", (object)ownerPickupBroken);
				MyceliumNetwork.SetLobbyData("colorable", (object)colorable);
				MyceliumNetwork.SetLobbyData("nameable", (object)nameable);
				MyceliumNetwork.SetLobbyData("nameDisplay", (object)nameDisplay);
				MyceliumNetwork.SetLobbyData("scoreDivision", (object)scoreDivision);
				LoadConfig();
			}
		}

		internal static void LoadConfig()
		{
			host_ownerPickup = MyceliumNetwork.GetLobbyData<bool>("ownerPickup");
			host_ownerPickupBroken = MyceliumNetwork.GetLobbyData<bool>("ownerPickupBroken");
			host_colorable = MyceliumNetwork.GetLobbyData<bool>("colorable");
			host_nameable = MyceliumNetwork.GetLobbyData<bool>("nameable");
			host_nameDisplay = MyceliumNetwork.GetLobbyData<bool>("nameDisplay");
			host_scoreDivision = MyceliumNetwork.GetLobbyData<bool>("scoreDivision");
		}

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Patcher.PatchAll();
			Entries.RegisterEntry(typeof(POVCamera));
			MyceliumNetwork.RegisterLobbyDataKey("ownerPickup");
			MyceliumNetwork.RegisterLobbyDataKey("ownerPickupBroken");
			MyceliumNetwork.RegisterLobbyDataKey("colorable");
			MyceliumNetwork.RegisterLobbyDataKey("nameable");
			MyceliumNetwork.RegisterLobbyDataKey("nameDisplay");
			MyceliumNetwork.RegisterLobbyDataKey("scoreDivision");
			MyceliumNetwork.LobbyEntered += delegate
			{
				if (MyceliumNetwork.IsHost)
				{
					UpdateConfig();
				}
				else
				{
					LoadConfig();
				}
			};
			MyceliumNetwork.LobbyDataUpdated += delegate
			{
				if (!MyceliumNetwork.IsHost)
				{
					LoadConfig();
				}
			};
		}

		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_0688: Unknown result type (might be due to invalid IL or missing references)
			//IL_068f: Expected O, but got Unknown
			//IL_0a13: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a27: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a3b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a4f: 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_0b47: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b5b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b6f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b83: Unknown result type (might be due to invalid IL or missing references)
			//IL_0765: Unknown result type (might be due to invalid IL or missing references)
			//IL_0779: Unknown result type (might be due to invalid IL or missing references)
			//IL_08af: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_08eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0837: Unknown result type (might be due to invalid IL or missing references)
			//IL_0857: Unknown result type (might be due to invalid IL or missing references)
			//IL_0877: Unknown result type (might be due to invalid IL or missing references)
			//IL_0897: 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_04a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
			if (MyceliumNetwork.IsHost)
			{
				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;
					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;
						val10 = new GameObject("Text").AddComponent<TextMeshProUGUI>();
						((TMP_Text)val10).enableWordWrapping = false;
						((TMP_Text)val10).alignment = (TextAlignmentOptions)1028;
						((TMP_Text)val10).transform.SetParent(((Component)val9).transform, false);
					}
					val10 = ((Component)val9.Find("Text")).GetComponent<TextMeshProUGUI>();
					if (host_nameDisplay)
					{
						((TMP_Text)val10).text = ((Component)val4).GetComponent<PhotonView>().Owner.NickName;
					}
					else
					{
						((TMP_Text)val10).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 val11 in array3)
			{
				if (val11.item.id != 2)
				{
					continue;
				}
				string text = "-2";
				HashSet<ItemDataEntry> dataEntries2 = val11.instanceData.m_dataEntries;
				foreach (ItemDataEntry item2 in dataEntries2)
				{
					if (!(item2 is POVCamera pOVCamera4))
					{
						continue;
					}
					if (pOVCamera4.plrID == "-1")
					{
						text = "-1";
						break;
					}
					Player val12 = new Player();
					PlayerVisor[] array4 = Object.FindObjectsOfType<PlayerVisor>();
					foreach (PlayerVisor val13 in array4)
					{
						Player component6 = ((Component)val13).gameObject.GetComponent<Player>();
						if (((Component)component6).GetComponent<PhotonView>().Owner.CustomProperties[(object)"SteamID"] as string == pOVCamera4.plrID)
						{
							val12 = component6;
							break;
						}
					}
					Transform val14 = ((Component)val11).gameObject.transform.Find("VideoCam");
					Renderer component7 = ((Component)val14.Find("Cube")).GetComponent<Renderer>();
					Renderer component8 = ((Component)val14.Find("Cube.001")).GetComponent<Renderer>();
					text = pOVCamera4.plrID;
					if (!Object.op_Implicit((Object)(object)val12))
					{
						text = "-2";
						component7.materials[0].color = Color.black;
						component7.materials[1].color = Color.black;
						if (Object.op_Implicit((Object)(object)((Component)val11).gameObject.transform.parent) && (Object)(object)((Component)((Component)val11).gameObject.transform.parent).GetComponent<Pickup>() != (Object)null && host_nameable)
						{
							((Interactable)((Component)((Component)val11).gameObject.transform.parent).GetComponent<Pickup>()).hoverText = "?'s Broken Camera";
						}
						else
						{
							((Interactable)((Component)((Component)val11).gameObject.transform.parent).GetComponent<Pickup>()).hoverText = "Pickup Broken Camera";
						}
						break;
					}
					if (host_colorable)
					{
						component7.materials[0].color = ((Component)val12).GetComponent<PlayerVisor>().visorColor.Value;
						component7.materials[1].color = ((Component)val12).GetComponent<PlayerVisor>().visorColor.Value;
						component8.materials[0].color = ((Component)val12).GetComponent<PlayerVisor>().visorColor.Value;
						component8.materials[1].color = ((Component)val12).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)val11).gameObject.transform.parent) && (Object)(object)((Component)((Component)val11).gameObject.transform.parent).GetComponent<Pickup>() != (Object)null && host_nameable)
					{
						((Interactable)((Component)((Component)val11).gameObject.transform.parent).GetComponent<Pickup>()).hoverText = ((Component)val12).GetComponent<PhotonView>().Owner.NickName + "'s Broken Camera";
					}
					else
					{
						((Interactable)((Component)((Component)val11).gameObject.transform.parent).GetComponent<Pickup>()).hoverText = "Pickup Broken Camera";
					}
					break;
				}
				if (text == "-2")
				{
					Transform val15 = ((Component)val11).gameObject.transform.Find("VideoCam");
					Renderer component9 = ((Component)val15.Find("Cube")).GetComponent<Renderer>();
					Renderer component10 = ((Component)val15.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)val11).gameObject.transform.parent) && (Object)(object)((Component)((Component)val11).gameObject.transform.parent).GetComponent<Pickup>() != (Object)null && host_nameable)
					{
						((Interactable)((Component)((Component)val11).gameObject.transform.parent).GetComponent<Pickup>()).hoverText = "?'s Broken Camera";
					}
					else
					{
						((Interactable)((Component)((Component)val11).gameObject.transform.parent).GetComponent<Pickup>()).hoverText = "Pickup Broken Camera";
					}
				}
				else if (text == "-1")
				{
					Transform val16 = ((Component)val11).gameObject.transform.Find("VideoCam");
					Renderer component11 = ((Component)val16.Find("Cube")).GetComponent<Renderer>();
					Renderer component12 = ((Component)val16.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)val11).gameObject.transform.parent) && (Object)(object)((Component)((Component)val11).gameObject.transform.parent).GetComponent<Pickup>() != (Object)null && host_nameable)
					{
						((Interactable)((Component)((Component)val11).gameObject.transform.parent).GetComponent<Pickup>()).hoverText = "Pickup Broken Camera";
					}
				}
			}
		}

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

		public const string PLUGIN_NAME = "ContentPOVs";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}