Decompiled source of PeakThingsCameraMaterialPatch v1.2.1

plugins/com.github.MiiMii1205.PeakThingsCameraMaterialPatch.dll

Decompiled 9 hours 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 BepInEx;
using BepInEx.Logging;
using DG.Tweening;
using Evaisa.PeakThings;
using Evaisa.PeakThings.MonoBehaviours;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PEAKLib.Core;
using Peak;
using PeakThingsCameraMaterialPatch.Behaviour;
using PeakThingsCameraMaterialPatch.Patchers;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using UnityEngine.SceneManagement;
using Zorro.Core;
using pworld.Scripts.Extensions;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.MiiMii1205.PeakThingsCameraMaterialPatch")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.2.1.0")]
[assembly: AssemblyInformationalVersion("1.2.1")]
[assembly: AssemblyProduct("com.github.MiiMii1205.PeakThingsCameraMaterialPatch")]
[assembly: AssemblyTitle("PeakThingsCameraMaterialPatch")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.1.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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace PeakThingsCameraMaterialPatch
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.github.MiiMii1205.PeakThingsCameraMaterialPatch", "PeakThingsCameraMaterialPatch", "1.2.1")]
	public class Plugin : BaseUnityPlugin
	{
		private static Dictionary<string, Material> _newCameraMaterialList = new Dictionary<string, Material>();

		private static bool _initialized = false;

		private static readonly int BaseTexture = Shader.PropertyToID("_BaseTexture");

		private static readonly int BaseColor = Shader.PropertyToID("_BaseColor");

		private static readonly int Tint = Shader.PropertyToID("_Tint");

		private static readonly int BaseMap = Shader.PropertyToID("_BaseMap");

		private static bool _fogQuadInitialized = false;

		private static bool _windStormInitialized = false;

		private static bool _rainStormInitialized = false;

		private static bool _fogSphereInitialized = false;

		private static bool _antiFXInitialized = false;

		public const string Id = "com.github.MiiMii1205.PeakThingsCameraMaterialPatch";

		internal static ManualLogSource Log { get; private set; } = null;

		public static Material GetScreenMaterial => _newCameraMaterialList["_ScreenMat"];

		public static string Name => "PeakThingsCameraMaterialPatch";

		public static string Version => "1.2.1";

		private void Awake()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			BundleLoader.LoadBundleWithName((BaseUnityPlugin)(object)this, "camerafix.peakbundle", (Action<PeakBundle>)LoadCameraFixMaterials);
			new Harmony("com.github.MiiMii1205.PeakThingsCameraMaterialPatch").PatchAll(typeof(CameraPatcher));
			new Harmony("com.github.MiiMii1205.PeakThingsCameraMaterialPatch").PatchAll(typeof(CameraQuadPatcher));
			SceneManager.sceneLoaded += UpdateLayers;
			Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
		}

		private void UpdateLayers(Scene arg0, LoadSceneMode arg1)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			UniversalRendererData[] array = Resources.FindObjectsOfTypeAll<UniversalRendererData>();
			UniversalRendererData[] array2 = array;
			foreach (UniversalRendererData val in array2)
			{
				if ((LayerMask.op_Implicit(val.opaqueLayerMask) & 0x10000000) == 0)
				{
					val.opaqueLayerMask = LayerMask.op_Implicit(LayerMask.op_Implicit(val.opaqueLayerMask) | 0x10000000);
				}
				if ((LayerMask.op_Implicit(val.transparentLayerMask) & 0x10000000) == 0)
				{
					val.transparentLayerMask = LayerMask.op_Implicit(LayerMask.op_Implicit(val.transparentLayerMask) | 0x10000000);
				}
				if ((LayerMask.op_Implicit(val.prepassLayerMask) & 0x10000000) == 0)
				{
					val.prepassLayerMask = LayerMask.op_Implicit(LayerMask.op_Implicit(val.prepassLayerMask) | 0x10000000);
				}
				if ((LayerMask.op_Implicit(val.opaqueLayerMask) & 0x4000000) == 0)
				{
					val.opaqueLayerMask = LayerMask.op_Implicit(LayerMask.op_Implicit(val.opaqueLayerMask) | 0x4000000);
				}
				if ((LayerMask.op_Implicit(val.transparentLayerMask) & 0x4000000) == 0)
				{
					val.transparentLayerMask = LayerMask.op_Implicit(LayerMask.op_Implicit(val.transparentLayerMask) | 0x4000000);
				}
				if ((LayerMask.op_Implicit(val.prepassLayerMask) & 0x4000000) == 0)
				{
					val.prepassLayerMask = LayerMask.op_Implicit(LayerMask.op_Implicit(val.prepassLayerMask) | 0x4000000);
				}
			}
			PatchPeakThingsItems();
		}

		private void PatchPeakThingsItems()
		{
			if (!_initialized && PeakThings.Instance.prefabs.TryGetValue("CamcorderItem", out var value) && value != null)
			{
				Log.LogInfo((object)"Replacing the prefab's material.");
				if (PeakThings.Instance.prefabs.TryGetValue("TVSet", out var value2) && value2 != null)
				{
					Log.LogInfo((object)"Replacing TV materials.");
					ReplaceTVMaterials(value2);
				}
				if (PeakThings.Instance.prefabs.TryGetValue("TapeRecording", out var value3) && value3 != null)
				{
					Log.LogInfo((object)"Replacing tape materials.");
					ReplaceTapeMaterials(value3);
				}
				ReplaceCameraMaterials(value);
				OptimizePeakThingsItems();
			}
		}

		private void LoadCameraFixMaterials(PeakBundle obj)
		{
			_newCameraMaterialList.Add("Mat.3", LoadMaterial(obj, "NewCameraBody.mat"));
			_newCameraMaterialList.Add("Mat.2", LoadMaterial(obj, "NewCameraFrame.mat"));
			_newCameraMaterialList.Add("Mat.5", LoadMaterial(obj, "NewCameraRecord.mat"));
			_newCameraMaterialList.Add("Mat", LoadMaterial(obj, "NewCameraLens.mat"));
			_newCameraMaterialList.Add("Mat.4", LoadMaterial(obj, "NewCameraFlash.mat"));
			_newCameraMaterialList.Add("FindMeLight", LoadMaterial(obj, "NewCameraFindMe.mat"));
			_newCameraMaterialList.Add("_ScreenMat", LoadMaterial(obj, "NewCameraViewfinder.mat"));
			_newCameraMaterialList.Add("TV_Body", LoadMaterial(obj, "NewTVBody.mat"));
			_newCameraMaterialList.Add("Pillow1", LoadMaterial(obj, "NewPillow1.mat"));
			_newCameraMaterialList.Add("Pillow2", LoadMaterial(obj, "NewPillow2.mat"));
			_newCameraMaterialList.Add("Pillow3", LoadMaterial(obj, "NewPillow3.mat"));
			_newCameraMaterialList.Add("Pillow4", LoadMaterial(obj, "NewPillow4.mat"));
			_newCameraMaterialList.Add("Box", LoadMaterial(obj, "NewBox.mat"));
			_newCameraMaterialList.Add("Tape", LoadMaterial(obj, "NewTape.mat"));
			_newCameraMaterialList.Add("Material.001", LoadMaterial(obj, "NewTape.mat"));
			_newCameraMaterialList.Add("decal", LoadMaterial(obj, "NewTapeDecal.mat"));
			_newCameraMaterialList.Add("hamisdecal", LoadMaterial(obj, "NewTapeHamisDecal.mat"));
			Log.LogInfo((object)$"Loaded {_newCameraMaterialList.Count} materials.");
			if (PeakThings.Instance.prefabs.TryGetValue("CamcorderItem", out var value) && value != null)
			{
				PatchPeakThingsItems();
				return;
			}
			Log.LogInfo((object)"Waiting for the prefab to load...");
			BundleLoader.OnBundleLoaded += delegate
			{
				PatchPeakThingsItems();
			};
		}

		public static string CleanedName(string dirtyString)
		{
			return dirtyString.Replace("(Clone)", "").Replace("(Instanced)", "").Replace("(Instance)", "")
				.Trim();
		}

		private void ReplaceTVMaterials(GameObject tvSet)
		{
			Renderer[] componentsInChildren = tvSet.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				Material[] materials = val.materials;
				int j = 0;
				for (int num = materials.Length; j < num; j++)
				{
					Material val2 = materials[j];
					string text = CleanedName(((Object)val2).name);
					if (_newCameraMaterialList.TryGetValue(text, out Material value))
					{
						Texture texture = materials[j].GetTexture(BaseTexture);
						materials[j] = Object.Instantiate<Material>(value);
						materials[j].SetTexture(BaseTexture, texture);
					}
					else
					{
						Log.LogWarning((object)("Can't find material '" + text + "' in TV materials list. Skipping..."));
					}
				}
				Renderer val3 = val;
				Material[] array = materials;
				List<Material> list = new List<Material>(array.Length);
				Material[] array2 = array;
				foreach (Material item in array2)
				{
					list.Add(item);
				}
				val3.SetMaterials(list);
			}
		}

		private void ReplaceTapeMaterials(GameObject tape)
		{
			Item component = tape.GetComponent<Item>();
			Renderer[] componentsInChildren = tape.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				Material[] materials = val.materials;
				int j = 0;
				for (int num = materials.Length; j < num; j++)
				{
					Material val2 = materials[j];
					string text = CleanedName(((Object)val2).name);
					if (_newCameraMaterialList.TryGetValue(text, out Material value))
					{
						Texture val3 = null;
						if (materials[j].HasTexture(BaseTexture))
						{
							val3 = materials[j].GetTexture(BaseTexture);
						}
						else if (materials[j].HasTexture(BaseMap))
						{
							val3 = materials[j].GetTexture(BaseMap);
						}
						materials[j] = Object.Instantiate<Material>(value);
						if (Object.op_Implicit((Object)(object)val3))
						{
							materials[j].SetTexture(BaseTexture, val3);
						}
					}
					else
					{
						Log.LogWarning((object)("Can't find material '" + text + "' in Tape materials list. Skipping..."));
					}
				}
				Renderer val4 = val;
				Material[] array = materials;
				List<Material> list = new List<Material>(array.Length);
				Material[] array2 = array;
				foreach (Material item in array2)
				{
					list.Add(item);
				}
				val4.SetMaterials(list);
			}
		}

		private void OptimizePeakThingsItems()
		{
			Item val = default(Item);
			foreach (KeyValuePair<string, GameObject> prefab in PeakThings.Instance.prefabs)
			{
				if (!PeakThings.Instance.prefabs.TryGetValue(prefab.Key, out var value) || value == null || !value.TryGetComponent<Item>(ref val) || val == null)
				{
					continue;
				}
				PhotonCleanupHelper orAddComponent = ExtGameObject.GetOrAddComponent<PhotonCleanupHelper>(value);
				ItemOptimizer orAddComponent2 = ExtGameObject.GetOrAddComponent<ItemOptimizer>(value);
				orAddComponent2.item = val;
				HashSet<Renderer> hashSet = new HashSet<Renderer>();
				Renderer[] componentsInChildren = value.GetComponentsInChildren<Renderer>(true);
				foreach (Renderer val2 in componentsInChildren)
				{
					bool flag = (Object)(object)val.mainRenderer != (Object)(object)val2 && ((Object)val2).name != "Hand";
					bool flag2 = flag;
					if (flag2)
					{
						bool flag3 = ((val2 is MeshRenderer || val2 is SkinnedMeshRenderer) ? true : false);
						flag2 = flag3;
					}
					bool flag4 = flag2;
					if (flag4)
					{
						bool flag3;
						switch (((Object)val2.material.shader).name)
						{
						case "NickPost/Anti":
						case "GD/ScreenFog":
						case "GD/SphereFog":
						case "Screen_Scanline":
							flag3 = true;
							break;
						default:
							flag3 = false;
							break;
						}
						flag4 = !flag3;
					}
					if (flag4 && val2.material.HasColor(Tint))
					{
						hashSet.Add(val2);
					}
				}
				Item val3 = val;
				HashSet<Renderer> hashSet2 = hashSet;
				int num = 0;
				Renderer[] array = (Renderer[])(object)new Renderer[hashSet2.Count];
				foreach (Renderer item in hashSet2)
				{
					array[num] = item;
					num++;
				}
				val3.addtlRenderers = array;
				Log.LogInfo((object)("Optimized " + ((Object)val).name));
			}
		}

		public static void SetupCamera(VideoCamera vidc)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			Camera cam = MainCamera.instance.cam;
			UniversalAdditionalCameraData val = default(UniversalAdditionalCameraData);
			UniversalAdditionalCameraData val2 = default(UniversalAdditionalCameraData);
			if (cam != null && ((Component)cam).TryGetComponent<UniversalAdditionalCameraData>(ref val) && ((Component)vidc.m_camera).TryGetComponent<UniversalAdditionalCameraData>(ref val2))
			{
				vidc.m_camera.useOcclusionCulling = cam.useOcclusionCulling;
				val2.volumeLayerMask = val.volumeLayerMask;
				val2.volumeStack = val.volumeStack;
				val2.requiresColorOption = val.requiresColorOption;
				val2.requiresColorTexture = val.requiresColorTexture;
				val2.requiresDepthOption = val.requiresDepthOption;
				val2.requiresDepthTexture = val.requiresColorTexture;
				if (!_fogQuadInitialized)
				{
					InitializeFogQuad(vidc);
				}
				if (!_fogSphereInitialized)
				{
					InitializeFogSphere(vidc);
				}
				if (!_windStormInitialized)
				{
					InitializeWindStorm(vidc);
				}
				if (!_rainStormInitialized)
				{
					InitializeRainStorm(vidc);
				}
			}
		}

		private static void InitFogSphereCloner(VideoCameraQuad vidq, OrbFogHandler inst)
		{
			FogSphere component = ((Component)vidq).GetComponent<FogSphere>();
			FogSphere sphere = inst.sphere;
			FogSphereCloner orAddComponent = ExtGameObject.GetOrAddComponent<FogSphereCloner>(((Component)vidq).gameObject);
			orAddComponent.rend = ((Component)vidq).GetComponent<Renderer>();
			orAddComponent.toClone = sphere;
			Object.Destroy((Object)(object)component);
		}

		private static void UpgradeAntiFX(VideoCameraQuad vidq, GUIManager inst)
		{
			ScreenVFX component = ((Component)vidq).GetComponent<ScreenVFX>();
			AntiFXCloner orAddComponent = ExtGameObject.GetOrAddComponent<AntiFXCloner>(((Component)vidq).gameObject);
			orAddComponent.rend = component.renderer;
			orAddComponent.antiSVFX = inst.antiSVFX;
			Object.Destroy((Object)(object)component);
			((Component)component).gameObject.SetActive(true);
		}

		private static void UpdateCullingMasks(VideoCamera vcam)
		{
			if ((MainCamera.instance.cam.cullingMask & 0x4000000) == 0)
			{
				Camera cam = MainCamera.instance.cam;
				cam.cullingMask &= -67108865;
			}
			if ((vcam.m_camera.cullingMask & 0x4000000) != 0)
			{
				Camera camera = vcam.m_camera;
				camera.cullingMask |= 0x4000000;
			}
		}

		private static VideoCameraQuad UpgradeCameraQuad(GameObject quadHolder, VideoCamera vcam)
		{
			CameraQuad component = quadHolder.GetComponent<CameraQuad>();
			VideoCameraQuad orAddComponent = ExtGameObject.GetOrAddComponent<VideoCameraQuad>(quadHolder);
			orAddComponent.distance = component.distance;
			orAddComponent.vcam = vcam;
			((Component)orAddComponent).transform.SetParent(((Component)vcam.m_camera).transform, false);
			orAddComponent.cam = vcam.m_camera;
			GameObjectExtensions.SetLayerRecursivly(((Component)orAddComponent).gameObject, 26);
			Object.Destroy((Object)(object)component);
			return orAddComponent;
		}

		public static void InitializeFogSphere(VideoCamera? initialCamera = null)
		{
			if (_fogSphereInitialized)
			{
				return;
			}
			OrbFogHandler instance = Singleton<OrbFogHandler>.Instance;
			if (instance != null)
			{
				FogSphere val = instance.sphere ?? ((Component)instance).GetComponentInChildren<FogSphere>();
				CameraQuad val2 = default(CameraQuad);
				VideoCamera val3 = default(VideoCamera);
				if (val != null && ((Component)val).TryGetComponent<CameraQuad>(ref val2) && PeakThings.Instance.prefabs.TryGetValue("CamcorderItem", out var value) && value != null && value.TryGetComponent<VideoCamera>(ref val3) && val3 != null)
				{
					GameObject quadHolder = Object.Instantiate<GameObject>(((Component)val2).gameObject);
					VideoCameraQuad vidq = UpgradeCameraQuad(quadHolder, val3);
					InitFogSphereCloner(vidq, instance);
					if ((Object)(object)initialCamera != (Object)null)
					{
						GameObject quadHolder2 = Object.Instantiate<GameObject>(((Component)val2).gameObject);
						VideoCameraQuad vidq2 = UpgradeCameraQuad(quadHolder2, initialCamera);
						InitFogSphereCloner(vidq2, instance);
					}
					_fogSphereInitialized = true;
					return;
				}
			}
			Log.LogInfo((object)"Can't find any fog spheres. Waiting for any spheres to exists before instantiating...");
		}

		public static void InitializeFogQuad(VideoCamera? initialCamera = null)
		{
			if (_fogQuadInitialized)
			{
				return;
			}
			VideoCamera val = default(VideoCamera);
			if (PeakThings.Instance.prefabs.TryGetValue("CamcorderItem", out var value) && value != null && value.TryGetComponent<VideoCamera>(ref val) && val != null)
			{
				FogShaderParams val2 = Object.FindAnyObjectByType<FogShaderParams>();
				if (val2 != null)
				{
					GameObject quadHolder = Object.Instantiate<GameObject>(((Component)val2).gameObject);
					UpgradeCameraQuad(quadHolder, val);
					if ((Object)(object)initialCamera != (Object)null)
					{
						GameObject quadHolder2 = Object.Instantiate<GameObject>(((Component)val2).gameObject);
						UpgradeCameraQuad(quadHolder2, initialCamera);
					}
					_fogQuadInitialized = true;
					return;
				}
			}
			Log.LogInfo((object)"Can't find any fog quad. Waiting for any quads to exists before instantiating...");
		}

		public static void InitializeWindStorm(VideoCamera? initialCamera = null)
		{
			if (_windStormInitialized)
			{
				return;
			}
			RootsWind instance = RootsWind.instance;
			if (instance != null)
			{
				CameraQuad componentInChildren = ((Component)instance).GetComponentInChildren<CameraQuad>();
				VideoCamera val = default(VideoCamera);
				if (componentInChildren != null && PeakThings.Instance.prefabs.TryGetValue("CamcorderItem", out var value) && value != null && value.TryGetComponent<VideoCamera>(ref val) && val != null)
				{
					GameObject quadHolder = Object.Instantiate<GameObject>(((Component)componentInChildren).gameObject);
					UpgradeCameraQuad(quadHolder, val);
					if ((Object)(object)initialCamera != (Object)null)
					{
						GameObject quadHolder2 = Object.Instantiate<GameObject>(((Component)componentInChildren).gameObject);
						UpgradeCameraQuad(quadHolder2, initialCamera);
					}
					_windStormInitialized = true;
					return;
				}
			}
			Log.LogInfo((object)"Can't find any Wind quad. Waiting for any quads to exists before instantiating...");
		}

		public static void InitializeAntiFX(VideoCamera? initialCamera = null)
		{
			if (_antiFXInitialized)
			{
				return;
			}
			GUIManager instance = GUIManager.instance;
			if (instance != null)
			{
				ScreenVFX antiSVFX = instance.antiSVFX;
				VideoCamera val = default(VideoCamera);
				if (antiSVFX != null && PeakThings.Instance.prefabs.TryGetValue("CamcorderItem", out var value) && value != null && value.TryGetComponent<VideoCamera>(ref val) && val != null)
				{
					GameObject quadHolder = Object.Instantiate<GameObject>(((Component)antiSVFX).gameObject);
					VideoCameraQuad vidq = UpgradeCameraQuad(quadHolder, val);
					UpgradeAntiFX(vidq, instance);
					if ((Object)(object)initialCamera != (Object)null)
					{
						GameObject quadHolder2 = Object.Instantiate<GameObject>(((Component)antiSVFX).gameObject);
						VideoCameraQuad vidq2 = UpgradeCameraQuad(quadHolder2, initialCamera);
						UpgradeAntiFX(vidq2, instance);
					}
					_antiFXInitialized = true;
					return;
				}
			}
			Log.LogInfo((object)"Can't find any Wind quad. Waiting for any quads to exists before instantiating...");
		}

		public static void InitializeRainStorm(VideoCamera? initialCamera = null)
		{
			if (_rainStormInitialized)
			{
				return;
			}
			WindChillZone instance = WindChillZone.instance;
			if (instance != null && ((Object)instance).name == "RainStorm")
			{
				CameraQuad componentInChildren = ((Component)instance).GetComponentInChildren<CameraQuad>();
				VideoCamera val = default(VideoCamera);
				if (componentInChildren != null && PeakThings.Instance.prefabs.TryGetValue("CamcorderItem", out var value) && value != null && value.TryGetComponent<VideoCamera>(ref val) && val != null)
				{
					GameObject quadHolder = Object.Instantiate<GameObject>(((Component)componentInChildren).gameObject);
					UpgradeCameraQuad(quadHolder, val);
					if ((Object)(object)initialCamera != (Object)null)
					{
						GameObject quadHolder2 = Object.Instantiate<GameObject>(((Component)componentInChildren).gameObject);
						UpgradeCameraQuad(quadHolder2, initialCamera);
					}
					_rainStormInitialized = true;
					return;
				}
			}
			Log.LogInfo((object)"Can't find any rain quad. Waiting for any quads to exists before instantiating...");
		}

		private void ReplaceCameraMaterials(GameObject camera)
		{
			Item component = camera.GetComponent<Item>();
			VideoCamera component2 = camera.GetComponent<VideoCamera>();
			Renderer[] componentsInChildren = camera.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				Material[] materials = val.materials;
				int j = 0;
				for (int num = materials.Length; j < num; j++)
				{
					Material val2 = materials[j];
					string text = CleanedName(((Object)val2).name);
					if (_newCameraMaterialList.TryGetValue(text, out Material value))
					{
						materials[j] = Object.Instantiate<Material>(value);
					}
					else
					{
						Log.LogWarning((object)("Can't find material '" + text + "' in camera materials list. Skipping..."));
					}
				}
				Renderer val3 = val;
				Material[] array = materials;
				List<Material> list = new List<Material>(array.Length);
				Material[] array2 = array;
				foreach (Material item in array2)
				{
					list.Add(item);
				}
				val3.SetMaterials(list);
			}
			UniversalAdditionalCameraData component3 = ((Component)component2.m_camera).GetComponent<UniversalAdditionalCameraData>();
			component3.volumeTrigger = ((Component)component2.m_camera).transform.parent;
			BlipperController orAddComponent = ExtGameObject.GetOrAddComponent<BlipperController>(camera);
			orAddComponent.findMeLight = component2.findMeLight;
			orAddComponent.findCameraSounds = component2.findCameraSounds;
			orAddComponent.bleepInterval = component2.bleepInterval;
			orAddComponent.dontBeepUntil = component2.dontBeepUntil;
			((ItemComponent)orAddComponent).item = component;
			if (_newCameraMaterialList.TryGetValue("_ScreenMat", out Material value2))
			{
				((Component)camera.transform.GetChild(3).GetChild(1).GetChild(4)
					.GetChild(2)).GetComponent<Renderer>().material = Object.Instantiate<Material>(value2);
			}
			CameraBlipsController orAddComponent2 = ExtGameObject.GetOrAddComponent<CameraBlipsController>(((Component)camera.transform.GetChild(3).GetChild(1).GetChild(4)
				.GetChild(0)
				.GetChild(0)
				.GetChild(0)).gameObject);
			orAddComponent2.RendererToLightUp = ((Component)((Component)orAddComponent2).transform.parent).GetComponent<Renderer>();
			orAddComponent2.intensityAdjustments = CalculateIntensityAdjustments(orAddComponent2.RendererToLightUp.material);
			CameraBlipsController orAddComponent3 = ExtGameObject.GetOrAddComponent<CameraBlipsController>(((Component)camera.transform.GetChild(3).GetChild(1).GetChild(0)
				.GetChild(0)
				.GetChild(0)).gameObject);
			orAddComponent3.RendererToLightUp = ((Component)((Component)orAddComponent3).transform.parent).GetComponent<Renderer>();
			orAddComponent3.intensityAdjustments = CalculateIntensityAdjustments(orAddComponent3.RendererToLightUp.material);
			FindMeBlipsController orAddComponent4 = ExtGameObject.GetOrAddComponent<FindMeBlipsController>(((Component)camera.transform.GetChild(3).GetChild(1).GetChild(0)
				.GetChild(1)
				.GetChild(0)
				.GetChild(0)).gameObject);
			orAddComponent4.RendererToLightUp = ((Component)((Component)orAddComponent4).transform.parent).GetComponent<Renderer>();
			orAddComponent4.lightToCheck = ((Component)orAddComponent4).GetComponent<Light>();
			orAddComponent4.intensityAdjustments = CalculateIntensityAdjustments(orAddComponent3.RendererToLightUp.material);
			_initialized = true;
		}

		private float CalculateIntensityAdjustments(Material mat)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			Vector4 val = ExtColor.PToVec4(mat.GetColor(BaseColor));
			Vector3 val2 = new Vector3(val.x, val.y, val.z);
			float magnitude = ((Vector3)(ref val2)).magnitude;
			float num = Mathf.Max(1f - magnitude, 0f);
			return 1f + num;
		}

		private Material LoadMaterial(PeakBundle bundle, string matName)
		{
			Material val = bundle.LoadAsset<Material>(matName);
			Log.LogInfo((object)("Loaded material " + matName + "."));
			val.shader = Shader.Find(((Object)val.shader).name);
			return val;
		}
	}
}
namespace PeakThingsCameraMaterialPatch.Patchers
{
	public static class CameraPatcher
	{
		private static readonly int MainTex = Shader.PropertyToID("_MainTex");

		private static readonly int ScreenOn = Shader.PropertyToID("_ScreenOn");

		private static readonly int ScanLineDensity = Shader.PropertyToID("_ScanLineDensity");

		private static bool vignetteRenderingEnambled = false;

		[HarmonyPatch(typeof(VideoCamera), "CreateRenderTexture")]
		[HarmonyPostfix]
		public static void ScanlineViewfinderPatchPostfix(VideoCamera __instance)
		{
			Material val = Object.Instantiate<Material>(Plugin.GetScreenMaterial);
			val.SetTexture(MainTex, (Texture)(object)__instance.m_camera.targetTexture);
			((Component)((Component)__instance).transform.GetChild(3).GetChild(1).GetChild(4)
				.GetChild(2)).GetComponent<Renderer>().material = val;
		}

		[HarmonyPatch(typeof(VideoCamera), "Start")]
		[HarmonyPostfix]
		public static void VideoCameraStartPostfix(VideoCamera __instance)
		{
			Plugin.SetupCamera(__instance);
			if ((__instance.m_camera.cullingMask & 0x4000000) != 0)
			{
				Camera camera = __instance.m_camera;
				camera.cullingMask |= 0x4000000;
			}
		}

		[HarmonyPatch(typeof(FogShaderParams), "Start")]
		[HarmonyPrefix]
		public static void FogShaderStartPostfix(FogShaderParams __instance)
		{
			if (PeakThings.Instance.prefabs.TryGetValue("CamcorderItem", out var value) && value != null)
			{
				FogShaderParams componentInChildren = value.GetComponentInChildren<FogShaderParams>();
				if (componentInChildren != null && (Object)(object)componentInChildren != (Object)(object)__instance)
				{
					componentInChildren.fogTexture = __instance.fogTexture;
				}
			}
		}

		[HarmonyPatch(typeof(CameraCulling), "OnBeginCameraRendering")]
		[HarmonyPostfix]
		public static void BeginRenderingSkeletonFixPostFix(CameraCulling __instance, ScriptableRenderContext ctx, Camera cam)
		{
			if (!((Object)(object)cam == (Object)(object)__instance.targetCamera) || !((Object)(object)__instance.itemRef != (Object)null))
			{
				return;
			}
			Character holderCharacter = __instance.itemRef.holderCharacter;
			if (holderCharacter != null && holderCharacter.data.isSkeleton)
			{
				HideTheBody hideTheBody = holderCharacter.refs.hideTheBody;
				if (hideTheBody != null)
				{
					hideTheBody.SetShowing(holderCharacter.refs.customization.refs.skeletonRenderer, 0f);
				}
			}
		}

		[HarmonyPatch(typeof(CameraCulling), "OnEndCameraRendering")]
		[HarmonyPostfix]
		public static void EndRenderingSkeletonFixPostFix(CameraCulling __instance, ScriptableRenderContext ctx, Camera cam)
		{
			if (!((Object)(object)cam == (Object)(object)__instance.targetCamera) || !((Object)(object)__instance.itemRef != (Object)null))
			{
				return;
			}
			Character holderCharacter = __instance.itemRef.holderCharacter;
			if (holderCharacter != null && holderCharacter.data.isSkeleton)
			{
				HideTheBody hideTheBody = holderCharacter.refs.hideTheBody;
				if (hideTheBody != null)
				{
					hideTheBody.SetShowing(holderCharacter.refs.customization.refs.skeletonRenderer, hideTheBody.isShowing ? 0f : 1f);
				}
			}
		}

		[HarmonyPatch(typeof(TVController), "CreateRenderTexture")]
		[HarmonyPostfix]
		public static void ScanlineTVPatchPostfix(TVController __instance)
		{
			Material val = Object.Instantiate<Material>(Plugin.GetScreenMaterial);
			val.SetFloat(ScanLineDensity, 300f);
			val.SetFloat(ScreenOn, 0f);
			val.SetTexture(MainTex, (Texture)(object)__instance.renderTexture);
			Renderer val2 = default(Renderer);
			if (((Component)__instance).TryGetComponent<Renderer>(ref val2) && (Object)(object)val2 != (Object)null && val2.materials.Length > 1)
			{
				val2.SetMaterials(new List<Material>(2)
				{
					val2.materials[0],
					val
				});
			}
			else
			{
				Debug.LogWarning((object)"MeshRenderer or materials not found on TVController.");
			}
		}

		[HarmonyPatch(typeof(TVController), "RPC_SetTVPower")]
		[HarmonyPostfix]
		public static void ScanlineTVPowerPost(TVController __instance, bool on)
		{
			Renderer val = default(Renderer);
			if (((Component)__instance).TryGetComponent<Renderer>(ref val) && (Object)(object)val != (Object)null && val.materials.Length > 1)
			{
				ShortcutExtensions.DOFloat(val.materials[1], on ? 1f : 0f, ScreenOn, 1f);
			}
			else
			{
				Plugin.Log.LogWarning((object)"MeshRenderer or materials not found on TVController.");
			}
		}
	}
	public static class CameraQuadPatcher
	{
		[HarmonyPatch(typeof(GUIManager), "Start")]
		[HarmonyPostfix]
		public static void StartPostfix(GUIManager __instance)
		{
			Plugin.InitializeAntiFX();
		}

		[HarmonyPatch(typeof(RootsWind), "Awake")]
		[HarmonyPostfix]
		public static void AwakePostfix(RootsWind __instance)
		{
			Plugin.InitializeWindStorm();
		}

		[HarmonyPatch(typeof(WindChillZone), "Start")]
		[HarmonyPostfix]
		public static void StartPostfix(WindChillZone __instance)
		{
			if (((Object)__instance).name == "RainStorm")
			{
				Plugin.InitializeRainStorm();
			}
		}

		[HarmonyPatch(typeof(FogShaderParams), "Start")]
		[HarmonyPostfix]
		public static void StartPostfix(FogShaderParams __instance)
		{
			Plugin.InitializeFogQuad();
		}

		[HarmonyPatch(typeof(MainCamera), "Awake")]
		[HarmonyPostfix]
		public static void StartPostfix(MainCamera __instance)
		{
			if (__instance != null)
			{
				Camera cam = __instance.cam;
				if ((((cam != null) ? new int?(cam.cullingMask) : ((int?)null)) & 0x4000000) == 0)
				{
					return;
				}
			}
			Camera val = __instance?.cam;
			if ((Object)(object)val != (Object)null)
			{
				val.cullingMask &= -67108865;
			}
		}
	}
}
namespace PeakThingsCameraMaterialPatch.Behaviour
{
	public class AntiFXCloner : MonoBehaviour
	{
		public ScreenVFX? antiSVFX;

		public Renderer rend;

		private void Start()
		{
			if (antiSVFX == null)
			{
				antiSVFX = GUIManager.instance.antiSVFX;
			}
			if (rend == null)
			{
				rend = ((Component)this).GetComponent<Renderer>();
			}
			if ((Object)(object)antiSVFX != (Object)null)
			{
				rend.material = antiSVFX.renderer.sharedMaterial;
			}
		}

		private void LateUpdate()
		{
			if (Object.op_Implicit((Object)(object)rend))
			{
				if (!Object.op_Implicit((Object)(object)antiSVFX) && antiSVFX == null)
				{
					antiSVFX = GUIManager.instance.antiSVFX;
				}
				rend.material = antiSVFX.renderer.sharedMaterial;
				rend.enabled = ((Component)antiSVFX).gameObject.activeSelf;
			}
		}
	}
	public class BlipperController : ItemComponent
	{
		private float timeSinceBeep;

		public float bleepInterval = 1f;

		public float dontBeepUntil = 2f;

		public Light findMeLight;

		public float upLength = 0.2f;

		private float timeSinceHeld;

		public SFX_Instance findCameraSounds;

		private void Update()
		{
			DoFindMeBlipp();
		}

		private void DoFindMeBlipp()
		{
			//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: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			timeSinceBeep += Time.deltaTime;
			Vector3 val = base.item.Center();
			((Component)findMeLight).transform.position = val + Vector3.up * upLength;
			if (timeSinceBeep > bleepInterval * 0.5f)
			{
				((Behaviour)findMeLight).enabled = false;
			}
			if ((int)base.item.itemState == 0)
			{
				timeSinceHeld += Time.deltaTime;
				if (timeSinceHeld >= dontBeepUntil && timeSinceBeep > bleepInterval)
				{
					timeSinceBeep = 0f;
					findCameraSounds.Play(val);
					((Behaviour)findMeLight).enabled = true;
				}
			}
		}

		public override void OnInstanceDataSet()
		{
		}
	}
	public class CameraBlipsController : MonoBehaviour
	{
		private static readonly int Tint = Shader.PropertyToID("_Tint");

		public Renderer RendererToLightUp;

		public Color color = Color.white;

		public float intensityAdjustments;

		private void OnEnable()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			RendererToLightUp.material.SetColor(Tint, color * intensityAdjustments * 20f);
		}

		private void OnDisable()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			RendererToLightUp.material.SetColor(Tint, color);
		}
	}
	public class FindMeBlipsController : MonoBehaviour
	{
		private static readonly int Tint = Shader.PropertyToID("_Tint");

		public Light lightToCheck;

		public Renderer RendererToLightUp;

		public Color color = Color.white;

		public float intensityAdjustments;

		private bool isActive;

		private void Update()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			if (((Behaviour)lightToCheck).enabled != isActive)
			{
				RendererToLightUp.material.SetColor(Tint, color * (((Behaviour)lightToCheck).enabled ? (intensityAdjustments * 20f) : 1f));
				isActive = ((Behaviour)lightToCheck).enabled;
			}
		}
	}
	public class FogSphereCloner : MonoBehaviour
	{
		public FogSphere? toClone;

		public Renderer rend;

		private void Start()
		{
			if (toClone == null)
			{
				toClone = Singleton<OrbFogHandler>.Instance.sphere;
			}
			if (rend == null)
			{
				rend = ((Component)this).GetComponent<Renderer>();
			}
		}

		public void LateUpdate()
		{
			if (!Object.op_Implicit((Object)(object)toClone) && toClone == null)
			{
				toClone = Singleton<OrbFogHandler>.Instance.sphere;
			}
			if (Object.op_Implicit((Object)(object)toClone))
			{
				rend.SetPropertyBlock(toClone.mpb);
			}
		}
	}
	public class VideoCameraFogQuadCulling : MonoBehaviour
	{
		public Camera targetCamera;

		public VideoCameraQuad quadToCull;

		private void OnEnable()
		{
			RenderPipelineManager.beginCameraRendering += OnBeginCameraRendering;
			RenderPipelineManager.endCameraRendering += OnEndCameraRendering;
		}

		private void OnEndCameraRendering(ScriptableRenderContext ctx, Camera cam)
		{
			_ = (Object)(object)cam != (Object)(object)targetCamera;
		}

		private void OnBeginCameraRendering(ScriptableRenderContext ctx, Camera cam)
		{
			_ = (Object)(object)cam != (Object)(object)targetCamera;
		}

		private void OnDisable()
		{
			RenderPipelineManager.beginCameraRendering -= OnBeginCameraRendering;
			RenderPipelineManager.endCameraRendering -= OnEndCameraRendering;
		}
	}
	[DefaultExecutionOrder(100000)]
	public class VideoCameraQuad : MonoBehaviour
	{
		public float distance = 0.01f;

		public Camera cam;

		public VideoCamera vcam;

		private Vector3 flippedPoint1;

		private Vector3 flippedPoint2;

		private Vector3 flippedPoint3;

		private Vector3 worldPoint1;

		private Vector3 worldPoint2;

		private Vector3 worldPoint3;

		private Vector3 basePos;

		private float prevFieldOfView;

		public void Start()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			if (cam == null)
			{
				cam = ((Component)((Component)this).transform.parent).GetComponentInChildren<Camera>();
			}
			float num = cam.nearClipPlane + distance;
			worldPoint1 = cam.ViewportToWorldPoint(new Vector3(0f, 0f, num));
			worldPoint2 = cam.ViewportToWorldPoint(new Vector3(0f, 3f, num));
			worldPoint3 = cam.ViewportToWorldPoint(new Vector3(3f, 0f, num));
			basePos = ((Component)cam).transform.localPosition;
			((Component)cam).transform.position = vcam.flipPos.position;
			((Component)cam).transform.rotation = vcam.flipPos.rotation;
			flippedPoint1 = cam.ViewportToWorldPoint(new Vector3(0f, 0f, num));
			flippedPoint2 = cam.ViewportToWorldPoint(new Vector3(0f, 3f, num));
			flippedPoint3 = cam.ViewportToWorldPoint(new Vector3(3f, 0f, num));
			((Component)cam).transform.position = basePos;
			((Component)cam).transform.localRotation = Quaternion.identity;
		}

		public void LateUpdate()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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)
			if (cam == null)
			{
				cam = ((Component)((Component)this).transform.parent).GetComponentInChildren<Camera>();
			}
			float num;
			if (((Component)cam).transform.localRotation != Quaternion.identity)
			{
				num = Vector3.Distance(flippedPoint1, flippedPoint2);
				((Component)this).transform.localScale = new Vector3(Vector3.Distance(flippedPoint1, flippedPoint3), num, 1f);
			}
			num = Vector3.Distance(worldPoint1, worldPoint2);
			((Component)this).transform.localScale = new Vector3(Vector3.Distance(worldPoint1, worldPoint3), num, 1f);
			float num2 = cam.nearClipPlane + distance;
			((Component)this).transform.SetPositionAndRotation(((Component)cam).transform.position + ((Component)cam).transform.forward * num2, ((Component)cam).transform.rotation);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}