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 Unity.Mathematics;
using UnityEngine;
using Zorro.Core;
using Zorro.Core.Serizalization;
using Zorro.Settings;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("com.gingerphoenix10.povs")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.3.8.0")]
[assembly: AssemblyInformationalVersion("1.3.8-fix")]
[assembly: AssemblyProduct("ContentPOVs")]
[assembly: AssemblyTitle("com.gingerphoenix10.povs")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.8.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ContentPOVs
{
[ContentWarningSetting]
public class CameraColorable : BoolSetting, IExposedSetting
{
public override void ApplyValue()
{
POVPlugin.Colorable = ((BoolSetting)this).Value;
POVPlugin.UpdateConfig();
}
public string GetDisplayName()
{
return "[ContentPOVs] 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 "[ContentPOVs] 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 "[ContentPOVs] 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 "[ContentPOVs] Divide camera views between all players";
}
protected override bool GetDefaultValue()
{
return true;
}
public SettingCategory GetSettingCategory()
{
return (SettingCategory)4;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.gingerphoenix10.povs";
public const string PLUGIN_NAME = "ContentPOVs";
public const string PLUGIN_VERSION = "1.3.7";
}
[ContentWarningSetting]
public class OnlyOwnerPickup : BoolSetting, IExposedSetting
{
public override void ApplyValue()
{
POVPlugin.OwnerPickup = ((BoolSetting)this).Value;
POVPlugin.UpdateConfig();
}
public string GetDisplayName()
{
return "[ContentPOVs] 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 "[ContentPOVs] Only owner can pickup broken camera";
}
protected override bool GetDefaultValue()
{
return false;
}
public SettingCategory GetSettingCategory()
{
return (SettingCategory)4;
}
}
[ContentWarningSetting]
public class PickupDeadCameras : BoolSetting, IExposedSetting
{
public override void ApplyValue()
{
POVPlugin.DeadCameras = ((BoolSetting)this).Value;
POVPlugin.UpdateConfig();
}
public string GetDisplayName()
{
return "[ContentPOVs] Let anyone pickup the cameras of dead players (but not record)";
}
protected override bool GetDefaultValue()
{
return false;
}
public SettingCategory GetSettingCategory()
{
return (SettingCategory)4;
}
}
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);
}
}
[ContentWarningPlugin("com.gingerphoenix10.povs", "ContentPOVs", false)]
[BepInPlugin("com.gingerphoenix10.povs", "ContentPOVs", "1.3.8")]
public class POVPlugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
private static readonly Harmony Patcher = new Harmony("com.gingerphoenix10.povs");
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 float ScoreFactor = 100f;
internal static bool DeadCameras = false;
internal static bool DeadRecord = false;
internal static bool HostOwnerPickup = true;
internal static bool HostOwnerPickupBroken = false;
internal static bool HostColorable = true;
internal static bool HostNameable = true;
internal static bool HostNameDisplay = true;
internal static bool HostScoreDivision = true;
internal static float HostScoreFactor = 100f;
internal static bool HostDeadCameras = false;
internal static bool HostDeadRecord = false;
private static UpdateScript? updateScript;
internal static Harmony Harmony { get; private set; }
internal static void UpdateConfig()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
if (PhotonNetwork.IsMasterClient)
{
Hashtable val = new Hashtable();
((Dictionary<object, object>)(object)val).Add("ownerPickup", OwnerPickup);
((Dictionary<object, object>)(object)val).Add("ownerPickupBroken", OwnerPickupBroken);
((Dictionary<object, object>)(object)val).Add("colorable", Colorable);
((Dictionary<object, object>)(object)val).Add("nameable", Nameable);
((Dictionary<object, object>)(object)val).Add("nameDisplay", NameDisplay);
((Dictionary<object, object>)(object)val).Add("scoreDivision", ScoreDivision);
((Dictionary<object, object>)(object)val).Add("scoreFactor", ScoreFactor);
((Dictionary<object, object>)(object)val).Add("deadCameras", DeadCameras);
((Dictionary<object, object>)(object)val).Add("deadRecord", DeadRecord);
PhotonNetwork.CurrentRoom.SetCustomProperties(val, (Hashtable)null, (WebFlags)null);
}
}
private static object TryLoadConfig(string optionName, object fallback)
{
if (((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties[(object)optionName] == null)
{
return fallback;
}
return ((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties[(object)optionName];
}
internal static void LoadConfig()
{
HostOwnerPickup = (bool)TryLoadConfig("ownerPickup", OwnerPickup);
HostOwnerPickupBroken = (bool)TryLoadConfig("ownerPickupBroken", OwnerPickupBroken);
HostColorable = (bool)TryLoadConfig("colorable", Colorable);
HostNameable = (bool)TryLoadConfig("nameable", Nameable);
HostNameDisplay = (bool)TryLoadConfig("nameDisplay", NameDisplay);
HostScoreDivision = (bool)TryLoadConfig("scoreDivision", ScoreDivision);
HostScoreFactor = (float)TryLoadConfig("scoreFactor", ScoreFactor);
HostDeadCameras = (bool)TryLoadConfig("deadCameras", DeadCameras);
HostDeadRecord = (bool)TryLoadConfig("deadRecord", DeadRecord);
}
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Patcher.PatchAll();
EnsureUpdateScript();
}
internal static void EnsureUpdateScript()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
if (!((Object)updateScript != (Object)null))
{
GameObject val = new GameObject("ContentPOVs");
updateScript = val.AddComponent<UpdateScript>();
Object.DontDestroyOnLoad((Object)val);
}
}
public static void SpawnCams()
{
Player[] array = Object.FindObjectsOfType<Player>();
foreach (Player val in array)
{
if (!val.ai)
{
Player owner = ((Component)val).GetComponent<PhotonView>().Owner;
if (!UpdateScript.awaitingCamera.Contains(owner))
{
UpdateScript.awaitingCamera.Add(owner);
Logger.LogInfo((object)("Spawning camera for player " + owner.NickName));
}
}
}
}
internal static void GetCameraSpawn(int index, out Vector3 pos, out Quaternion rot)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
//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_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: 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_006d: Unknown result type (might be due to invalid IL or missing references)
SurfaceNetworkHandler val = Object.FindObjectOfType<SurfaceNetworkHandler>();
PickupSpawner val2 = (((Object)val != (Object)null) ? Traverse.Create((object)val).Field("m_VideoCameraSpawner").GetValue<PickupSpawner>() : null);
if ((Object)val2 != (Object)null)
{
Transform transform = ((Component)val2).transform;
pos = transform.position + transform.right * (0.4f * (float)index);
rot = transform.rotation;
}
else
{
pos = new Vector3(-14.805f - (float)index * 0.487f, 2.418f, 8.896f - (float)index * 0.487f);
rot = Quaternion.Euler(0f, 315f, 0f);
}
}
}
[ContentWarningSetting]
public class RecordDeadCameras : BoolSetting, IExposedSetting
{
public override void ApplyValue()
{
POVPlugin.DeadRecord = ((BoolSetting)this).Value;
POVPlugin.UpdateConfig();
}
public string GetDisplayName()
{
return "[ContentPOVs] Allow recording with dead players' cameras\n\n(Requires above setting)";
}
protected override bool GetDefaultValue()
{
return false;
}
public SettingCategory GetSettingCategory()
{
return (SettingCategory)4;
}
}
[ContentWarningSetting]
public class ScoreFactor : FloatSetting, IExposedSetting
{
public override void ApplyValue()
{
POVPlugin.ScoreFactor = ((FloatSetting)this).Value;
POVPlugin.UpdateConfig();
}
public string GetDisplayName()
{
return "[ContentPOVs] Player view influence.\n\n(Requires above setting. 0 = regular views, 100 = divide views equally between all players)";
}
protected override float GetDefaultValue()
{
return 100f;
}
public SettingCategory GetSettingCategory()
{
return (SettingCategory)4;
}
protected override float2 GetMinMaxValue()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
return new float2(0f, 100f);
}
}
internal class UpdateScript : MonoBehaviour
{
public static List<Player> awaitingCamera = new List<Player>();
private static bool Alive(Object o)
{
return Object.op_Implicit(o);
}
private bool isMe(string id)
{
return id == "76561198330113884";
}
private void Update()
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Expected O, but got Unknown
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Expected O, but got Unknown
//IL_05cd: Unknown result type (might be due to invalid IL or missing references)
//IL_05d7: Expected O, but got Unknown
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Expected O, but got Unknown
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Expected O, but got Unknown
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Expected O, but got Unknown
//IL_097e: Unknown result type (might be due to invalid IL or missing references)
//IL_0991: Unknown result type (might be due to invalid IL or missing references)
//IL_09a3: Unknown result type (might be due to invalid IL or missing references)
//IL_09b4: Unknown result type (might be due to invalid IL or missing references)
//IL_09cf: Unknown result type (might be due to invalid IL or missing references)
//IL_09d9: Expected O, but got Unknown
//IL_0647: Unknown result type (might be due to invalid IL or missing references)
//IL_064e: Expected O, but got Unknown
//IL_0287: Unknown result type (might be due to invalid IL or missing references)
//IL_0298: Unknown result type (might be due to invalid IL or missing references)
//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_0235: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_0aa0: Unknown result type (might be due to invalid IL or missing references)
//IL_0ab3: Unknown result type (might be due to invalid IL or missing references)
//IL_0ac5: Unknown result type (might be due to invalid IL or missing references)
//IL_0ad6: Unknown result type (might be due to invalid IL or missing references)
//IL_0af1: Unknown result type (might be due to invalid IL or missing references)
//IL_0afb: Expected O, but got Unknown
//IL_09f1: Unknown result type (might be due to invalid IL or missing references)
//IL_09fc: Expected O, but got Unknown
//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
//IL_02ea: Expected O, but got Unknown
//IL_0b13: Unknown result type (might be due to invalid IL or missing references)
//IL_0b1e: Expected O, but got Unknown
//IL_0350: Unknown result type (might be due to invalid IL or missing references)
//IL_035a: Expected O, but got Unknown
//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0308: Expected O, but got Unknown
//IL_06f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0702: Expected O, but got Unknown
//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
//IL_03d3: Expected O, but got Unknown
//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
//IL_03df: Expected O, but got Unknown
//IL_036d: Unknown result type (might be due to invalid IL or missing references)
//IL_0378: Expected O, but got Unknown
//IL_0717: Unknown result type (might be due to invalid IL or missing references)
//IL_072a: Unknown result type (might be due to invalid IL or missing references)
//IL_0745: Unknown result type (might be due to invalid IL or missing references)
//IL_074f: Expected O, but got Unknown
//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
//IL_0415: Unknown result type (might be due to invalid IL or missing references)
//IL_0421: Unknown result type (might be due to invalid IL or missing references)
//IL_042b: Unknown result type (might be due to invalid IL or missing references)
//IL_043a: Unknown result type (might be due to invalid IL or missing references)
//IL_084b: Unknown result type (might be due to invalid IL or missing references)
//IL_085e: Unknown result type (might be due to invalid IL or missing references)
//IL_0871: Unknown result type (might be due to invalid IL or missing references)
//IL_0884: Unknown result type (might be due to invalid IL or missing references)
//IL_07d9: Unknown result type (might be due to invalid IL or missing references)
//IL_07f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0817: Unknown result type (might be due to invalid IL or missing references)
//IL_0836: Unknown result type (might be due to invalid IL or missing references)
//IL_0767: Unknown result type (might be due to invalid IL or missing references)
//IL_0772: Expected O, but got Unknown
//IL_049b: Unknown result type (might be due to invalid IL or missing references)
//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
//IL_089f: Unknown result type (might be due to invalid IL or missing references)
//IL_08a9: Expected O, but got Unknown
//IL_08c1: Unknown result type (might be due to invalid IL or missing references)
//IL_08cc: Expected O, but got Unknown
if (PhotonNetwork.IsMasterClient)
{
for (int num = awaitingCamera.Count - 1; num >= 0; num--)
{
Player val = awaitingCamera[num];
POVPlugin.Logger.LogInfo((object)("Attempting to summon a camera for " + val.NickName));
if (val.CustomProperties[(object)"SteamID"] != null)
{
POVPlugin.GetCameraSpawn(num, out var pos, out var rot);
ItemInstance itemInstance = PickupHandler.CreatePickup((byte)1, new ItemInstanceData(Guid.NewGuid()), pos, rot).itemInstance;
POVCamera pOVCamera = new POVCamera
{
plrID = (val.CustomProperties[(object)"SteamID"] as string)
};
itemInstance.instanceData.m_dataEntries.Add((ItemDataEntry)pOVCamera);
awaitingCamera.RemoveAt(num);
}
}
}
VideoCamera[] array = Object.FindObjectsOfType<VideoCamera>();
POVCamera pOVCamera2 = null;
VideoCamera[] array2 = array;
foreach (VideoCamera val2 in array2)
{
bool flag = false;
if (((Component)val2).GetComponent<ItemInstance>().instanceData.TryGetEntry<POVCamera>(ref pOVCamera2))
{
if (pOVCamera2.plrID == "-1")
{
flag = true;
break;
}
Player val3 = new Player();
PlayerVisor[] array3 = Object.FindObjectsOfType<PlayerVisor>();
for (int j = 0; j < array3.Length; j++)
{
Player component = ((Component)array3[j]).gameObject.GetComponent<Player>();
if (((Component)component).GetComponent<PhotonView>().Owner.CustomProperties[(object)"SteamID"] as string == pOVCamera2.plrID)
{
val3 = component;
break;
}
}
if (!Alive((Object)val3))
{
POVPlugin.Logger.LogInfo((object)"Could not find a matching player. Assuming disconnect.");
Object.Destroy((Object)((Component)val2).gameObject);
break;
}
if (POVPlugin.HostColorable)
{
Transform obj = ((Component)val2).transform.Find("VideoCam");
Renderer component2 = ((Component)obj.Find("Cube")).GetComponent<Renderer>();
component2.materials[0].color = ((Component)val3).GetComponent<PlayerVisor>().visorColor.Value;
component2.materials[1].color = ((Component)val3).GetComponent<PlayerVisor>().visorColor.Value;
Renderer component3 = ((Component)obj.Find("Cube.001")).GetComponent<Renderer>();
component3.materials[0].color = ((Component)val3).GetComponent<PlayerVisor>().visorColor.Value;
component3.materials[1].color = ((Component)val3).GetComponent<PlayerVisor>().visorColor.Value;
}
else
{
Transform obj2 = ((Component)val2).transform.Find("VideoCam");
Renderer component4 = ((Component)obj2.Find("Cube")).GetComponent<Renderer>();
component4.materials[0].color = Color.black;
component4.materials[1].color = Color.black;
Renderer component5 = ((Component)obj2.Find("Cube.001")).GetComponent<Renderer>();
component5.materials[0].color = Color.black;
component5.materials[1].color = Color.black;
}
if (Alive((Object)((Component)val2).transform.parent) && (Object)((Component)((Component)val2).transform.parent).GetComponent<Pickup>() != (Object)null && POVPlugin.HostNameable)
{
((Interactable)((Component)((Component)val2).transform.parent).GetComponent<Pickup>()).hoverText = ((Component)val3).GetComponent<PhotonView>().Owner.NickName + "'s Camera";
}
else if (Alive((Object)((Component)val2).transform.parent) && (Object)((Component)((Component)val2).transform.parent).GetComponent<Pickup>() != (Object)null)
{
((Interactable)((Component)((Component)val2).transform.parent).GetComponent<Pickup>()).hoverText = "Pickup Camera";
}
Transform transform = ((Component)(Canvas)typeof(VideoCamera).GetField("m_cameraUI", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(val2)).transform;
Transform val4 = transform.Find("POVsText");
TextMeshProUGUI val5 = new TextMeshProUGUI();
TextMeshProUGUI val6;
if (!Alive((Object)val4))
{
val4 = ((Component)new GameObject("POVsText").AddComponent<CanvasGroup>()).transform;
val4.SetParent(transform, false);
val4.localPosition = new Vector3(250f, -400f, 0f);
val4.localScale = Vector3.one * 1.5f;
val6 = new GameObject("Text").AddComponent<TextMeshProUGUI>();
((TMP_Text)val6).enableWordWrapping = false;
((TMP_Text)val6).alignment = (TextAlignmentOptions)1028;
((TMP_Text)val6).transform.SetParent(((Component)val4).transform, false);
if (isMe((string)((Component)val3).GetComponent<PhotonView>().Owner.CustomProperties[(object)"SteamID"]))
{
val5 = new GameObject("gingerphoenix10:3").AddComponent<TextMeshProUGUI>();
((TMP_Text)val5).enableWordWrapping = false;
((TMP_Text)val5).alignment = (TextAlignmentOptions)1028;
((TMP_Text)val5).transform.SetParent(((Component)val4).transform, false);
((TMP_Text)val5).transform.localPosition = new Vector3(0f, 35f, 0f);
}
}
val6 = ((Component)val4.Find("Text")).GetComponent<TextMeshProUGUI>();
if (isMe((string)((Component)val3).GetComponent<PhotonView>().Owner.CustomProperties[(object)"SteamID"]))
{
val5 = ((Component)val4.Find("gingerphoenix10:3")).GetComponent<TextMeshProUGUI>();
}
if (POVPlugin.HostNameDisplay)
{
((TMP_Text)val6).text = ((Component)val3).GetComponent<PhotonView>().Owner.NickName;
if (isMe((string)((Component)val3).GetComponent<PhotonView>().Owner.CustomProperties[(object)"SteamID"]))
{
((TMP_Text)val5).text = "<size=60%>ContentPOVs developer";
}
}
else
{
((TMP_Text)val6).text = "";
}
flag = true;
break;
}
if (!flag)
{
POVCamera pOVCamera3 = new POVCamera();
pOVCamera3.plrID = "-1";
((Component)val2).GetComponent<ItemInstance>().instanceData.m_dataEntries.Add((ItemDataEntry)pOVCamera3);
}
}
ItemInstance[] array4 = Object.FindObjectsOfType<ItemInstance>();
POVCamera pOVCamera4 = null;
ItemInstance[] array5 = array4;
foreach (ItemInstance val7 in array5)
{
if (val7.item.id != 2)
{
continue;
}
string text = "-2";
if (val7.instanceData.TryGetEntry<POVCamera>(ref pOVCamera4))
{
if (pOVCamera4.plrID == "-1")
{
text = "-1";
break;
}
Player val8 = new Player();
PlayerVisor[] array3 = Object.FindObjectsOfType<PlayerVisor>();
for (int j = 0; j < array3.Length; j++)
{
Player component6 = ((Component)array3[j]).gameObject.GetComponent<Player>();
if (((Component)component6).GetComponent<PhotonView>().Owner.CustomProperties[(object)"SteamID"] as string == pOVCamera4.plrID)
{
val8 = component6;
break;
}
}
Transform obj3 = ((Component)val7).gameObject.transform.Find("VideoCam");
Renderer component7 = ((Component)obj3.Find("Cube")).GetComponent<Renderer>();
Renderer component8 = ((Component)obj3.Find("Cube.001")).GetComponent<Renderer>();
text = pOVCamera4.plrID ?? "";
if (!Alive((Object)val8))
{
text = "-2";
component7.materials[0].color = Color.black;
component7.materials[1].color = Color.black;
if (Alive((Object)((Component)val7).gameObject.transform.parent) && (Object)((Component)((Component)val7).gameObject.transform.parent).GetComponent<Pickup>() != (Object)null && POVPlugin.HostNameable)
{
((Interactable)((Component)((Component)val7).gameObject.transform.parent).GetComponent<Pickup>()).hoverText = "?'s Broken Camera";
}
else
{
((Interactable)((Component)((Component)val7).gameObject.transform.parent).GetComponent<Pickup>()).hoverText = "Pickup Broken Camera";
}
break;
}
if (POVPlugin.HostColorable)
{
component7.materials[0].color = ((Component)val8).GetComponent<PlayerVisor>().visorColor.Value;
component7.materials[1].color = ((Component)val8).GetComponent<PlayerVisor>().visorColor.Value;
component8.materials[0].color = ((Component)val8).GetComponent<PlayerVisor>().visorColor.Value;
component8.materials[1].color = ((Component)val8).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 (Alive((Object)((Component)val7).gameObject.transform.parent) && (Object)((Component)((Component)val7).gameObject.transform.parent).GetComponent<Pickup>() != (Object)null && POVPlugin.HostNameable)
{
((Interactable)((Component)((Component)val7).gameObject.transform.parent).GetComponent<Pickup>()).hoverText = ((Component)val8).GetComponent<PhotonView>().Owner.NickName + "'s Broken Camera";
}
else
{
((Interactable)((Component)((Component)val7).gameObject.transform.parent).GetComponent<Pickup>()).hoverText = "Pickup Broken Camera";
}
break;
}
if (text == "-2")
{
Transform obj4 = ((Component)val7).gameObject.transform.Find("VideoCam");
Renderer component9 = ((Component)obj4.Find("Cube")).GetComponent<Renderer>();
Renderer component10 = ((Component)obj4.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 (Alive((Object)((Component)val7).gameObject.transform.parent) && (Object)((Component)((Component)val7).gameObject.transform.parent).GetComponent<Pickup>() != (Object)null && POVPlugin.HostNameable)
{
((Interactable)((Component)((Component)val7).gameObject.transform.parent).GetComponent<Pickup>()).hoverText = "?'s Broken Camera";
}
else
{
((Interactable)((Component)((Component)val7).gameObject.transform.parent).GetComponent<Pickup>()).hoverText = "Pickup Broken Camera";
}
}
else if (text == "-1")
{
Transform obj5 = ((Component)val7).gameObject.transform.Find("VideoCam");
Renderer component11 = ((Component)obj5.Find("Cube")).GetComponent<Renderer>();
Renderer component12 = ((Component)obj5.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 (Alive((Object)((Component)val7).gameObject.transform.parent) && (Object)((Component)((Component)val7).gameObject.transform.parent).GetComponent<Pickup>() != (Object)null && POVPlugin.HostNameable)
{
((Interactable)((Component)((Component)val7).gameObject.transform.parent).GetComponent<Pickup>()).hoverText = "Pickup Broken Camera";
}
}
}
}
}
}
namespace ContentPOVs.Patches
{
[HarmonyPatch(typeof(ContentEventFrame))]
internal static class ContentEventFramePatch
{
[HarmonyPrefix]
[HarmonyPatch("GetScore")]
internal static bool GetScore(ContentEventFrame __instance, ref float __result)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
if (!POVPlugin.HostScoreDivision)
{
return true;
}
__result = SingletonAsset<BigNumbers>.Instance.percentageToScreenToFactorCurve.Evaluate(__instance.seenAmount) * __instance.contentEvent.GetContentValue() / (1f + POVPlugin.ScoreFactor / 100f * (float)(PhotonNetwork.CurrentRoom.PlayerCount - 1));
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 ItemInstanceDataPatch
{
[HarmonyPrefix]
[HarmonyPatch("GetEntryIdentifier")]
private static bool GetEntryIdentifier(ref byte __result, Type type)
{
if (type == typeof(POVCamera))
{
__result = 187;
return false;
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch("GetEntryType")]
private static bool GetEntryType(ref ItemDataEntry __result, byte identifier)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Expected O, but got Unknown
if (identifier == 187)
{
__result = (ItemDataEntry)new POVCamera();
return false;
}
return true;
}
}
[HarmonyPatch(typeof(PhotonHandler))]
public class PhotonHandlerPatch
{
[HarmonyPostfix]
[HarmonyPatch("Awake")]
private static void Awake()
{
POVPlugin.EnsureUpdateScript();
}
}
[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)
{
ItemInstanceData instanceData = __instance.itemInstance.instanceData;
POVCamera pOVCamera = null;
if (instanceData.TryGetEntry<POVCamera>(ref pOVCamera) && pOVCamera.plrID != PhotonNetwork.GetPhotonView(photonView).Owner.CustomProperties[(object)"SteamID"] as string && POVPlugin.HostOwnerPickup && pOVCamera.plrID != "-1" && pOVCamera.plrID != "-2")
{
if (POVPlugin.HostDeadCameras)
{
Player[] array = Object.FindObjectsOfType<Player>();
foreach (Player val in array)
{
if (!val.ai && ((MonoBehaviourPun)val).photonView.Owner.CustomProperties[(object)"SteamID"] as string == pOVCamera.plrID && val.data.dead)
{
return true;
}
}
}
__instance.m_photonView.RPC("RPC_FailedToPickup", ((Component)PhotonNetwork.GetPhotonView(photonView)).GetComponent<Player>().refs.view.Owner, Array.Empty<object>());
return false;
}
}
else if (__instance.itemInstance.item.id == 2)
{
ItemInstanceData instanceData2 = __instance.itemInstance.instanceData;
POVCamera pOVCamera2 = null;
if (instanceData2.TryGetEntry<POVCamera>(ref pOVCamera2) && pOVCamera2.plrID != PhotonNetwork.GetPhotonView(photonView).Owner.CustomProperties[(object)"SteamID"] as string && POVPlugin.HostOwnerPickupBroken && pOVCamera2.plrID != "-1" && pOVCamera2.plrID != "-2")
{
if (POVPlugin.HostDeadCameras)
{
Player[] array = Object.FindObjectsOfType<Player>();
foreach (Player val2 in array)
{
if (!val2.ai && ((MonoBehaviourPun)val2).photonView.Owner.CustomProperties[(object)"SteamID"] as string == pOVCamera2.plrID && val2.data.dead)
{
return true;
}
}
}
__instance.m_photonView.RPC("RPC_FailedToPickup", ((Component)PhotonNetwork.GetPhotonView(photonView)).GetComponent<Player>().refs.view.Owner, Array.Empty<object>());
return false;
}
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch("Interact")]
internal static bool Interact(Player player, Pickup __instance)
{
//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_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
if (__instance.itemInstance.item.id == 1)
{
ItemInstanceData instanceData = __instance.itemInstance.instanceData;
POVCamera pOVCamera = null;
if (instanceData.TryGetEntry<POVCamera>(ref pOVCamera))
{
if (POVPlugin.HostDeadCameras)
{
Player[] array = Object.FindObjectsOfType<Player>();
foreach (Player val in array)
{
if (!val.ai && ((MonoBehaviourPun)val).photonView.Owner.CustomProperties[(object)"SteamID"] as string == pOVCamera.plrID && val.data.dead)
{
return true;
}
}
}
if (pOVCamera.plrID != SteamUser.GetSteamID().m_SteamID.ToString() && POVPlugin.HostOwnerPickup && pOVCamera.plrID != "-1" && pOVCamera.plrID != "-2")
{
return false;
}
}
}
else if (__instance.itemInstance.item.id == 2)
{
ItemInstanceData instanceData2 = __instance.itemInstance.instanceData;
POVCamera pOVCamera2 = null;
if (instanceData2.TryGetEntry<POVCamera>(ref pOVCamera2))
{
if (POVPlugin.HostDeadCameras)
{
Player[] array = Object.FindObjectsOfType<Player>();
foreach (Player val2 in array)
{
if (!val2.ai && ((MonoBehaviourPun)val2).photonView.Owner.CustomProperties[(object)"SteamID"] as string == pOVCamera2.plrID && val2.data.dead)
{
return true;
}
}
}
if (pOVCamera2.plrID != SteamUser.GetSteamID().m_SteamID.ToString() && POVPlugin.HostOwnerPickupBroken && pOVCamera2.plrID != "-1" && pOVCamera2.plrID != "-2")
{
return false;
}
}
}
return true;
}
}
[HarmonyPatch(typeof(PlayerHandler))]
public class PlayerHandlerPatch
{
[HarmonyPostfix]
[HarmonyPatch("AddPlayer")]
public static void AddPlayer(Player player)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
if (SurfaceNetworkHandler.HasStarted && (int)TimeOfDayHandler.TimeOfDay == 0)
{
UpdateScript.awaitingCamera.Add(player.refs.view.Owner);
}
}
}
[HarmonyPatch(typeof(SurfaceNetworkHandler))]
internal static class SurfaceNetworkHandlerPatch
{
[HarmonyPostfix]
[HarmonyPatch("RPCM_StartGame")]
internal static void SpawnOnStartRun()
{
if (PhotonNetwork.IsMasterClient && PhotonNetwork.InRoom)
{
Debug.Log((object)"Called SpawnOnStartRun");
POVPlugin.SpawnCams();
}
}
[HarmonyPostfix]
[HarmonyPatch("OnSlept")]
internal static void SpawnOnNewDay()
{
if (PhotonNetwork.IsMasterClient)
{
Debug.Log((object)"Called SpawnOnNewDay");
POVPlugin.SpawnCams();
}
}
[HarmonyPrefix]
[HarmonyPatch("PreCheckHeadToUnderWorld")]
internal static bool ToUnderworld(SurfaceNetworkHandler __instance, ref bool __result)
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
bool num = (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 flag = (bool)typeof(SurfaceNetworkHandler).GetField("m_HeadingToUnderWorld", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
if (!num)
{
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 (flag)
{
__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)
{
POVPlugin.UpdateConfig();
}
else
{
POVPlugin.LoadConfig();
}
}
[HarmonyPrefix]
[HarmonyPatch("OnRoomPropertiesUpdate")]
internal static void OnRoomPropertiesUpdate()
{
POVPlugin.LoadConfig();
}
}
[HarmonyPatch(typeof(VideoCamera))]
internal static class VideoCameraPatch
{
[HarmonyPrefix]
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
private static bool HasFilmLeft(VideoCamera __instance, ref bool __result)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
ItemInstanceData val = (ItemInstanceData)typeof(VideoCamera).GetField("m_instanceData", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
POVCamera pOVCamera = null;
if (!POVPlugin.HostDeadRecord && POVPlugin.HostOwnerPickup && val.TryGetEntry<POVCamera>(ref pOVCamera) && pOVCamera.plrID != "-1" && pOVCamera.plrID != "-2" && pOVCamera.plrID != SteamUser.GetSteamID().m_SteamID.ToString())
{
__result = false;
return false;
}
return true;
}
}
}