Decompiled source of Y4NGZCore v1.0.13

Y4NGZCore.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Dawn;
using DunGen;
using DunGen.Graph;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.SceneManagement;
using UnityEngine.TextCore;
using UnityEngine.UI;
using Y4NGZCompany.Core;
using Y4NGZCompany.Experience.Scan;
using Y4NGZCompany.Experience.UITheme;
using Y4NGZCompany.Facility.Cameras.Placement;
using Y4NGZCompany.Facility.Interior.Placement;
using Y4NGZCompany.Facility.Interior.Placement.Authored;
using Y4NGZCompany.ShipSystems.ShipTerminal;
using Y4NGZCore;
using Y4NGZCore.Diagnostics;
using Y4NGZCore.Lifecycle;
using Y4NGZCore.Modules;
using Y4NGZCore.Modules.Hud;
using Y4NGZCore.Modules.Layout;
using Y4NGZCore.Modules.Monitor;
using Y4NGZCore.Modules.Net;
using Y4NGZCore.Modules.Quota;
using Y4NGZCore.Modules.Sales;
using Y4NGZCore.Modules.ShipSystems;
using Y4NGZCore.Runtime.Quota;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: InternalsVisibleTo("Y4NGZCompany")]
[assembly: InternalsVisibleTo("Y4NGZShipSystems")]
[assembly: InternalsVisibleTo("Y4NGZMonitorTakeover")]
[assembly: InternalsVisibleTo("Y4NGZUI")]
[assembly: InternalsVisibleTo("LethalCCTV")]
[assembly: InternalsVisibleTo("Y4NGZBloodFX")]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("DunGen")]
[assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")]
[assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")]
[assembly: IgnoresAccessChecksTo("EasyTextEffects")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.XR.CoreUtils")]
[assembly: IgnoresAccessChecksTo("Unity.XR.Management")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Y4NGZCore")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Shared Y4NGZ runtime services consumed by the other Y4NGZ plugin assemblies")]
[assembly: AssemblyFileVersion("1.0.13.0")]
[assembly: AssemblyInformationalVersion("1.0.13+77a6c65125ab6533403fa4a9aa6e18a0a3dd5103")]
[assembly: AssemblyProduct("Y4NGZCore")]
[assembly: AssemblyTitle("Y4NGZCore")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.13.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 Y4NGZCompany.ShipSystems
{
	internal static class MonitorPalette
	{
		internal static readonly Color UiAccent = new Color(0f, 1f, 0.05f, 1f);

		internal static readonly Color UiAccentDim = new Color(0f, 0.92f, 0.04f, 0.94f);

		internal static readonly Color UiAccentFaint = new Color(0f, 0.44f, 0.05f, 0.34f);

		internal static readonly Color MonitorLabel = new Color(0f, 0.84f, 0.9f, 1f);

		internal static readonly Color MonitorScanline = new Color(0f, 0f, 0f, 0.16f);

		internal static readonly Color MonitorScanBeam = new Color(0f, 1f, 0.18f, 0.075f);

		internal static readonly Color MonitorBackground = new Color(0.015f, 0.13f, 0.055f, 1f);

		internal static readonly Color MonitorBackplate = new Color(0.01f, 0.18f, 0.055f, 0.92f);
	}
	public static class ShipClock24h
	{
		public const string UnavailableText = "--:--";

		public static string GetShipTime24h()
		{
			TimeOfDay instance = TimeOfDay.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				return "--:--";
			}
			StartOfRound instance2 = StartOfRound.Instance;
			if ((Object)(object)instance2 != (Object)null && instance2.inShipPhase)
			{
				return "--:--";
			}
			int num = (int)(instance.normalizedTimeOfDay * (60f * (float)instance.numberOfHours)) + 360;
			if (num < 0)
			{
				return "--:--";
			}
			int num2 = num / 60;
			int num3 = num % 60;
			if (num2 >= 24)
			{
				return "00:00";
			}
			return $"{num2:00}:{num3:00}";
		}
	}
}
namespace Y4NGZCompany.ShipSystems.Rendering
{
	internal sealed class CameraRenderLease : IDisposable
	{
		internal Camera Camera { get; }

		internal string Effect { get; }

		internal bool IsOverlay { get; }

		internal FrameSettingsField Field { get; }

		internal bool Enabled { get; }

		internal int StartFrame { get; }

		internal bool IsActive { get; private set; }

		internal bool IsRevoked { get; private set; }

		internal CameraRenderLease(Camera camera, string effect, bool isOverlay, FrameSettingsField field, bool enabled)
		{
			//IL_0025: 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)
			Camera = camera;
			Effect = effect ?? string.Empty;
			IsOverlay = isOverlay;
			Field = field;
			Enabled = enabled;
			StartFrame = Time.frameCount;
			IsActive = true;
		}

		public void Dispose()
		{
			CameraRenderProfile.End(this);
		}

		internal void MarkEnded(bool revoked)
		{
			IsActive = false;
			if (revoked)
			{
				IsRevoked = true;
			}
		}
	}
	internal static class CameraRenderProfile
	{
		internal sealed class CameraState
		{
			internal Camera Camera;

			internal HDAdditionalCameraData Data;

			internal CameraRenderProfileOwner Owner;

			internal CameraRenderRole Role;

			internal bool CustomHeld;

			internal bool OriginalCustomRendering;

			internal FrameSettings SavedSettings;

			internal FrameSettingsOverrideMask SavedMask;

			internal int ProfileEpoch;

			internal int OverlayGeneration;

			internal readonly List<FieldState> Fields = new List<FieldState>(4);

			internal readonly List<CameraRenderLease> Leases = new List<CameraRenderLease>(2);

			internal readonly List<string> SuppressedOverlays = new List<string>(1);
		}

		internal sealed class FieldState
		{
			internal FrameSettingsField Field;

			internal bool OriginalEnabled;

			internal bool OriginalOverridden;

			internal bool HasProfile;

			internal bool ProfileEnabled;

			internal int ProfileEpoch;

			internal int LeaseCount;

			internal bool LeaseEnabled;
		}

		private static readonly FrameSettingsField[] UnlitFields;

		private static readonly FrameSettingsField[] UiCompositorFields;

		private static readonly FrameSettingsField[] FeedStrippedFields;

		private static readonly Dictionary<Camera, CameraState> States;

		private static readonly List<Camera> PruneBuffer;

		private static int _overlaySerial;

		internal static bool ApplyProfile(Camera camera, CameraRenderRole role)
		{
			FrameSettingsField[] array;
			switch (role)
			{
			case CameraRenderRole.Unlit:
				array = UnlitFields;
				break;
			case CameraRenderRole.UiCompositor:
				array = UiCompositorFields;
				break;
			default:
				return false;
			}
			CameraState cameraState = ResolveWithData(camera);
			if (cameraState == null || cameraState.Role == CameraRenderRole.Feed)
			{
				return false;
			}
			BeginProfile(cameraState, role);
			for (int i = 0; i < array.Length; i++)
			{
				SetProfileField(cameraState, array[i], enabled: false);
			}
			EndProfile(cameraState);
			return true;
		}

		internal static bool ApplyFeedProfile(Camera camera, bool shadowMaps, bool ambientOcclusion)
		{
			return ApplyFeedProfile(camera, shadowMaps, ambientOcclusion, volumetrics: false);
		}

		internal static bool ApplyFeedProfile(Camera camera, bool shadowMaps, bool ambientOcclusion, bool volumetrics)
		{
			CameraState cameraState = ResolveWithData(camera);
			if (cameraState == null)
			{
				return false;
			}
			BeginProfile(cameraState, CameraRenderRole.Feed);
			for (int num = cameraState.Leases.Count - 1; num >= 0; num--)
			{
				CameraRenderLease cameraRenderLease = cameraState.Leases[num];
				if (!cameraRenderLease.IsOverlay)
				{
					EndLease(cameraState, cameraRenderLease, revoked: true);
				}
			}
			for (int i = 0; i < FeedStrippedFields.Length; i++)
			{
				SetProfileField(cameraState, FeedStrippedFields[i], enabled: false);
			}
			SetProfileField(cameraState, (FrameSettingsField)20, shadowMaps);
			SetProfileField(cameraState, (FrameSettingsField)24, ambientOcclusion);
			SetProfileField(cameraState, (FrameSettingsField)28, volumetrics);
			EndProfile(cameraState);
			return true;
		}

		internal static void ReleaseProfile(Camera camera)
		{
			if (camera == null || !States.TryGetValue(camera, out var value))
			{
				return;
			}
			if (value.Role != CameraRenderRole.None)
			{
				value.ProfileEpoch++;
				value.Role = CameraRenderRole.None;
				for (int num = value.Fields.Count - 1; num >= 0; num--)
				{
					FieldState fieldState = value.Fields[num];
					if (fieldState.HasProfile)
					{
						fieldState.HasProfile = false;
						Write(value, fieldState);
					}
				}
				RelaxCustomRendering(value);
			}
			for (int num2 = value.Leases.Count - 1; num2 >= 0; num2--)
			{
				CameraRenderLease cameraRenderLease = value.Leases[num2];
				if (cameraRenderLease.IsOverlay)
				{
					EndLease(value, cameraRenderLease, revoked: false);
				}
			}
			value.SuppressedOverlays.Clear();
			RemoveIfIdle(value);
		}

		internal static CameraRenderRole RoleOf(Camera camera)
		{
			if (!((Object)(object)camera != (Object)null) || !States.TryGetValue(camera, out var value))
			{
				return CameraRenderRole.None;
			}
			return value.Role;
		}

		internal static bool IsFeed(Camera camera)
		{
			return RoleOf(camera) == CameraRenderRole.Feed;
		}

		internal static bool TryAcquireFrameSetting(Camera camera, FrameSettingsField field, bool enabled, string effect, out CameraRenderLease lease)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			lease = null;
			if ((Object)(object)camera == (Object)null || IsFeed(camera))
			{
				return false;
			}
			CameraState cameraState = ResolveWithData(camera);
			if (cameraState == null)
			{
				return false;
			}
			FieldState fieldState = FindField(cameraState, field);
			if (fieldState != null && fieldState.LeaseCount > 0 && fieldState.LeaseEnabled != enabled)
			{
				return false;
			}
			if (fieldState == null)
			{
				EnsureCustomRendering(cameraState);
				fieldState = AddField(cameraState, field);
			}
			fieldState.LeaseCount++;
			fieldState.LeaseEnabled = enabled;
			Write(cameraState, fieldState);
			lease = new CameraRenderLease(camera, effect, isOverlay: false, field, enabled);
			cameraState.Leases.Add(lease);
			return true;
		}

		internal static bool TryBeginOverlay(Camera camera, string effect, out CameraRenderLease lease)
		{
			lease = null;
			if ((Object)(object)camera == (Object)null)
			{
				return false;
			}
			CameraState value;
			CameraState cameraState = (States.TryGetValue(camera, out value) ? value : Resolve(camera, ((Component)camera).GetComponent<HDAdditionalCameraData>()));
			string text = effect ?? string.Empty;
			if (cameraState.SuppressedOverlays.Contains(text))
			{
				RemoveIfIdle(cameraState);
				return false;
			}
			lease = new CameraRenderLease(camera, text, isOverlay: true, (FrameSettingsField)0, enabled: false);
			cameraState.Leases.Add(lease);
			cameraState.OverlayGeneration = ++_overlaySerial;
			return true;
		}

		internal static int OverlayGeneration(Camera camera)
		{
			if (!((Object)(object)camera != (Object)null) || !States.TryGetValue(camera, out var value))
			{
				return 0;
			}
			return value.OverlayGeneration;
		}

		internal static CameraRenderLease NewestOverlay(Camera camera)
		{
			if ((Object)(object)camera == (Object)null || !States.TryGetValue(camera, out var value))
			{
				return null;
			}
			for (int num = value.Leases.Count - 1; num >= 0; num--)
			{
				CameraRenderLease cameraRenderLease = value.Leases[num];
				if (cameraRenderLease.IsOverlay && cameraRenderLease.IsActive)
				{
					return cameraRenderLease;
				}
			}
			return null;
		}

		internal static bool Revoke(CameraRenderLease lease)
		{
			if (lease == null || !lease.IsActive)
			{
				return false;
			}
			if (lease.Camera != null && States.TryGetValue(lease.Camera, out var value))
			{
				if (lease.IsOverlay && !value.SuppressedOverlays.Contains(lease.Effect))
				{
					value.SuppressedOverlays.Add(lease.Effect);
				}
				EndLease(value, lease, revoked: true);
				return true;
			}
			lease.MarkEnded(revoked: true);
			return true;
		}

		internal static void End(CameraRenderLease lease)
		{
			if (lease != null && lease.IsActive)
			{
				if (lease.Camera != null && States.TryGetValue(lease.Camera, out var value))
				{
					EndLease(value, lease, revoked: false);
				}
				else
				{
					lease.MarkEnded(revoked: false);
				}
			}
		}

		internal static void Forget(CameraRenderProfileOwner owner)
		{
			CameraState state = owner.State;
			owner.State = null;
			if (state != null)
			{
				for (int i = 0; i < state.Leases.Count; i++)
				{
					state.Leases[i].MarkEnded(revoked: false);
				}
				state.Leases.Clear();
				state.Fields.Clear();
				state.Data = null;
				if (States.TryGetValue(state.Camera, out var value) && value == state)
				{
					States.Remove(state.Camera);
				}
			}
		}

		private static CameraState ResolveWithData(Camera camera)
		{
			if ((Object)(object)camera == (Object)null)
			{
				return null;
			}
			CameraState value;
			HDAdditionalCameraData val = ((States.TryGetValue(camera, out value) && (Object)(object)value.Data != (Object)null) ? value.Data : ((Component)camera).GetComponent<HDAdditionalCameraData>());
			if (!((Object)(object)val == (Object)null))
			{
				return Resolve(camera, val);
			}
			return null;
		}

		private static CameraState Resolve(Camera camera, HDAdditionalCameraData data)
		{
			if (States.TryGetValue(camera, out var value))
			{
				if ((Object)(object)value.Data == (Object)null && (Object)(object)data != (Object)null)
				{
					value.Data = data;
				}
				return value;
			}
			Prune();
			value = new CameraState
			{
				Camera = camera,
				Data = data
			};
			CameraRenderProfileOwner cameraRenderProfileOwner = ((Component)camera).GetComponent<CameraRenderProfileOwner>();
			if ((Object)(object)cameraRenderProfileOwner == (Object)null)
			{
				cameraRenderProfileOwner = ((Component)camera).gameObject.AddComponent<CameraRenderProfileOwner>();
				((Object)cameraRenderProfileOwner).hideFlags = (HideFlags)2;
			}
			cameraRenderProfileOwner.State = value;
			value.Owner = cameraRenderProfileOwner;
			States[camera] = value;
			return value;
		}

		private static void Prune()
		{
			PruneBuffer.Clear();
			foreach (KeyValuePair<Camera, CameraState> state in States)
			{
				if ((Object)(object)state.Key == (Object)null)
				{
					PruneBuffer.Add(state.Key);
				}
			}
			for (int i = 0; i < PruneBuffer.Count; i++)
			{
				if (States.TryGetValue(PruneBuffer[i], out var value))
				{
					for (int j = 0; j < value.Leases.Count; j++)
					{
						value.Leases[j].MarkEnded(revoked: false);
					}
					States.Remove(PruneBuffer[i]);
				}
			}
			PruneBuffer.Clear();
		}

		private static void BeginProfile(CameraState state, CameraRenderRole role)
		{
			EnsureCustomRendering(state);
			state.Role = role;
			state.ProfileEpoch++;
		}

		private static void EnsureCustomRendering(CameraState state)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0058: Unknown result type (might be due to invalid IL or missing references)
			HDAdditionalCameraData data = state.Data;
			if (!state.CustomHeld && !((Object)(object)data == (Object)null))
			{
				state.CustomHeld = true;
				state.OriginalCustomRendering = data.customRenderingSettings;
				if (!state.OriginalCustomRendering)
				{
					state.SavedSettings = data.renderingPathCustomFrameSettings;
					state.SavedMask = data.renderingPathCustomFrameSettingsOverrideMask;
					data.renderingPathCustomFrameSettingsOverrideMask = default(FrameSettingsOverrideMask);
					data.customRenderingSettings = true;
				}
			}
		}

		private static void RelaxCustomRendering(CameraState state)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			if (state.CustomHeld && state.Role == CameraRenderRole.None && state.Fields.Count <= 0)
			{
				state.CustomHeld = false;
				HDAdditionalCameraData data = state.Data;
				if (!((Object)(object)data == (Object)null) && !state.OriginalCustomRendering)
				{
					data.renderingPathCustomFrameSettings = state.SavedSettings;
					data.renderingPathCustomFrameSettingsOverrideMask = state.SavedMask;
					data.customRenderingSettings = false;
				}
			}
		}

		private static void SetProfileField(CameraState state, FrameSettingsField field, bool enabled)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			FieldState fieldState = FindField(state, field) ?? AddField(state, field);
			fieldState.HasProfile = true;
			fieldState.ProfileEnabled = enabled;
			fieldState.ProfileEpoch = state.ProfileEpoch;
			Write(state, fieldState);
		}

		private static void EndProfile(CameraState state)
		{
			for (int num = state.Fields.Count - 1; num >= 0; num--)
			{
				FieldState fieldState = state.Fields[num];
				if (fieldState.HasProfile && fieldState.ProfileEpoch != state.ProfileEpoch)
				{
					fieldState.HasProfile = false;
					Write(state, fieldState);
				}
			}
		}

		private static void EndLease(CameraState state, CameraRenderLease lease, bool revoked)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			lease.MarkEnded(revoked);
			state.Leases.Remove(lease);
			if (!lease.IsOverlay)
			{
				FieldState fieldState = FindField(state, lease.Field);
				if (fieldState != null && fieldState.LeaseCount > 0)
				{
					fieldState.LeaseCount--;
					Write(state, fieldState);
				}
			}
			RelaxCustomRendering(state);
			RemoveIfIdle(state);
		}

		private static void RemoveIfIdle(CameraState state)
		{
			if (state.Role == CameraRenderRole.None && state.Fields.Count <= 0 && state.Leases.Count <= 0 && state.SuppressedOverlays.Count <= 0)
			{
				if (States.TryGetValue(state.Camera, out var value) && value == state)
				{
					States.Remove(state.Camera);
				}
				if ((Object)(object)state.Owner != (Object)null && state.Owner.State == state)
				{
					state.Owner.State = null;
				}
			}
		}

		private static FieldState FindField(CameraState state, FrameSettingsField field)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < state.Fields.Count; i++)
			{
				if (state.Fields[i].Field == field)
				{
					return state.Fields[i];
				}
			}
			return null;
		}

		private static FieldState AddField(CameraState state, FrameSettingsField field)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected I4, but got Unknown
			HDAdditionalCameraData data = state.Data;
			FieldState fieldState = new FieldState
			{
				Field = field,
				OriginalEnabled = ((Object)(object)data != (Object)null && ((FrameSettings)(ref data.renderingPathCustomFrameSettings)).IsEnabled(field)),
				OriginalOverridden = ((Object)(object)data != (Object)null && ((BitArray128)(ref data.renderingPathCustomFrameSettingsOverrideMask.mask))[(uint)(int)field])
			};
			state.Fields.Add(fieldState);
			return fieldState;
		}

		private static void Write(CameraState state, FieldState field)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected I4, but got Unknown
			bool flag;
			bool flag2;
			if (field.LeaseCount > 0)
			{
				flag = field.LeaseEnabled;
				flag2 = true;
			}
			else if (field.HasProfile)
			{
				flag = field.ProfileEnabled;
				flag2 = true;
			}
			else
			{
				flag = field.OriginalEnabled;
				flag2 = field.OriginalOverridden;
				state.Fields.Remove(field);
			}
			HDAdditionalCameraData data = state.Data;
			if (!((Object)(object)data == (Object)null))
			{
				((FrameSettings)(ref data.renderingPathCustomFrameSettings)).SetEnabled(field.Field, flag);
				((BitArray128)(ref data.renderingPathCustomFrameSettingsOverrideMask.mask))[(uint)(int)field.Field] = flag2;
			}
		}

		static CameraRenderProfile()
		{
			FrameSettingsField[] array = new FrameSettingsField[5];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			UnlitFields = (FrameSettingsField[])(object)array;
			FrameSettingsField[] array2 = new FrameSettingsField[19];
			RuntimeHelpers.InitializeArray(array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			UiCompositorFields = (FrameSettingsField[])(object)array2;
			FrameSettingsField[] array3 = new FrameSettingsField[16];
			RuntimeHelpers.InitializeArray(array3, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			FeedStrippedFields = (FrameSettingsField[])(object)array3;
			States = new Dictionary<Camera, CameraState>();
			PruneBuffer = new List<Camera>();
		}
	}
	[DisallowMultipleComponent]
	internal sealed class CameraRenderProfileOwner : MonoBehaviour
	{
		internal CameraRenderProfile.CameraState State;

		private void OnDestroy()
		{
			CameraRenderProfile.Forget(this);
		}
	}
	internal enum CameraRenderRole
	{
		None,
		Unlit,
		UiCompositor,
		Feed
	}
	internal enum OffscreenRigSlot
	{
		PowerFuel,
		MonitorRowCard,
		QuotaAnnouncement,
		ProfitQuotaPanel,
		DeadlinePanel,
		CctvVanillaMonitor,
		BatteryWarning,
		FuelChuteThruster
	}
	internal readonly struct OffscreenRigPlacement
	{
		internal string Name { get; }

		internal float CenterX { get; }

		internal float CenterY { get; }

		internal float HalfWidth { get; }

		internal float HalfHeight { get; }

		internal OffscreenRigPlacement(string name, float centerX, float centerY, float halfWidth, float halfHeight)
		{
			Name = name;
			CenterX = centerX;
			CenterY = centerY;
			HalfWidth = halfWidth;
			HalfHeight = halfHeight;
		}
	}
	internal static class OffscreenRigParking
	{
		internal const float ParkingHeight = -10000f;

		internal const float SlotOrigin = 8192f;

		internal const float SlotPitch = 4096f;

		internal const float MinimumClearance = 1024f;

		internal const float MaxHalfExtent = 1536f;

		internal static float SlotX(OffscreenRigSlot slot)
		{
			return 8192f + (float)slot * 4096f;
		}

		internal static bool Fits(float extentFromRootX, float extentFromRootY)
		{
			if (extentFromRootX > 0f && extentFromRootY > 0f && extentFromRootX <= 1536f)
			{
				return extentFromRootY <= 1536f;
			}
			return false;
		}

		internal static OffscreenRigPlacement[] CurrentPlacements()
		{
			return new OffscreenRigPlacement[8]
			{
				Place(OffscreenRigSlot.PowerFuel, 256f, 192f),
				Place(OffscreenRigSlot.MonitorRowCard, 416f, 96f),
				Place(OffscreenRigSlot.QuotaAnnouncement, 384f, 216f),
				Place(OffscreenRigSlot.ProfitQuotaPanel, 256f, 192f),
				Place(OffscreenRigSlot.DeadlinePanel, 256f, 192f),
				Place(OffscreenRigSlot.CctvVanillaMonitor, 1408f, 216f),
				Place(OffscreenRigSlot.BatteryWarning, 256f, 128f),
				Place(OffscreenRigSlot.FuelChuteThruster, 2f, 2f)
			};
		}

		private static OffscreenRigPlacement Place(OffscreenRigSlot slot, float halfWidth, float halfHeight)
		{
			return new OffscreenRigPlacement(slot.ToString(), SlotX(slot), -10000f, halfWidth, halfHeight);
		}

		internal static bool TryFindConflict(IReadOnlyList<OffscreenRigPlacement> placements, float minimumClearance, out string detail)
		{
			detail = null;
			if (placements == null)
			{
				return false;
			}
			for (int i = 0; i < placements.Count; i++)
			{
				for (int j = i + 1; j < placements.Count; j++)
				{
					OffscreenRigPlacement offscreenRigPlacement = placements[i];
					OffscreenRigPlacement offscreenRigPlacement2 = placements[j];
					float num = offscreenRigPlacement.HalfWidth + offscreenRigPlacement2.HalfWidth + minimumClearance;
					float num2 = offscreenRigPlacement.HalfHeight + offscreenRigPlacement2.HalfHeight + minimumClearance;
					float num3 = Math.Abs(offscreenRigPlacement.CenterX - offscreenRigPlacement2.CenterX);
					float num4 = Math.Abs(offscreenRigPlacement.CenterY - offscreenRigPlacement2.CenterY);
					if (!(num3 >= num) && !(num4 >= num2))
					{
						detail = "'" + offscreenRigPlacement.Name + "' and '" + offscreenRigPlacement2.Name + "' are not separated: " + $"x gap {num3:0.###} needs {num:0.###}, " + $"y gap {num4:0.###} needs {num2:0.###}";
						return true;
					}
				}
			}
			return false;
		}
	}
}
namespace Y4NGZCompany.ShipSystems.Rendering.Outlines
{
	public sealed class LinkedSet<T> : IEnumerable<T>, IEnumerable
	{
		private readonly LinkedList<T> _list = new LinkedList<T>();

		private readonly Dictionary<T, LinkedListNode<T>> _dictionary = new Dictionary<T, LinkedListNode<T>>();

		public int Count => _list.Count;

		public bool Add(T item)
		{
			if (_dictionary.ContainsKey(item))
			{
				return false;
			}
			LinkedListNode<T> value = _list.AddLast(item);
			_dictionary.Add(item, value);
			return true;
		}

		public bool Remove(T item)
		{
			if (!_dictionary.TryGetValue(item, out var value))
			{
				return false;
			}
			_dictionary.Remove(item);
			_list.Remove(value);
			return true;
		}

		public bool Contains(T item)
		{
			return _dictionary.ContainsKey(item);
		}

		public LinkedList<T>.Enumerator GetEnumerator()
		{
			return _list.GetEnumerator();
		}

		IEnumerator<T> IEnumerable<T>.GetEnumerator()
		{
			return _list.GetEnumerator();
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			return _list.GetEnumerator();
		}
	}
	[RequireComponent(typeof(Renderer))]
	public sealed class Outline : MonoBehaviour
	{
		private Material[] _sharedMaterials;

		public int color;

		public bool eraseRenderer;

		internal bool Highlighted;

		public Renderer Renderer { get; private set; }

		public SpriteRenderer SpriteRenderer { get; private set; }

		public SkinnedMeshRenderer SkinnedMeshRenderer { get; private set; }

		public MeshFilter MeshFilter { get; private set; }

		public Material[] SharedMaterials
		{
			get
			{
				if (_sharedMaterials == null && (Object)(object)Renderer != (Object)null)
				{
					_sharedMaterials = Renderer.sharedMaterials;
				}
				return (Material[])(((object)_sharedMaterials) ?? ((object)new Material[0]));
			}
		}

		private void Awake()
		{
			Renderer = ((Component)this).GetComponent<Renderer>();
			SkinnedMeshRenderer = ((Component)this).GetComponent<SkinnedMeshRenderer>();
			SpriteRenderer = ((Component)this).GetComponent<SpriteRenderer>();
			MeshFilter = ((Component)this).GetComponent<MeshFilter>();
		}

		private void OnEnable()
		{
			OutlineEffect.RegisterOutline(this);
		}

		private void OnDisable()
		{
			OutlineEffect.UnregisterOutline(this);
		}
	}
	internal enum OutlineCompositeStatus
	{
		None,
		Drawn,
		Inactive,
		NoLease,
		NoTargets,
		NoDepth,
		NoResources
	}
	internal static class OutlineDepthPull
	{
		internal const float Metres = 0.005f;

		internal static float ViewScale(float centreDepth, float depthExtent, float nearClip, float pullMetres)
		{
			if (!IsFinite(centreDepth) || !IsFinite(depthExtent) || !IsFinite(nearClip) || !IsFinite(pullMetres))
			{
				return 1f;
			}
			float num = Math.Max(centreDepth + Math.Abs(depthExtent), nearClip);
			if (!(num > 0f) || !(pullMetres > 0f) || pullMetres >= num)
			{
				return 1f;
			}
			return 1f - pullMetres / num;
		}

		private static bool IsFinite(float value)
		{
			if (!float.IsNaN(value))
			{
				return !float.IsInfinity(value);
			}
			return false;
		}
	}
	[DisallowMultipleComponent]
	[RequireComponent(typeof(Camera))]
	public sealed class OutlineEffect : MonoBehaviour
	{
		public sealed class Y4NGZHDRPOutlinePass : CustomPass
		{
			internal OutlineEffect Owner;

			public override void Execute(CustomPassContext ctx)
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: 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_007a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c4: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
				OutlineEffect owner = Owner;
				if ((Object)(object)owner == (Object)null || ctx.cmd == null || ctx.hdCamera == null)
				{
					return;
				}
				Camera camera = ctx.hdCamera.camera;
				if (!((Object)(object)camera == (Object)null) && !((Object)(object)camera != (Object)(object)owner.ResolveSourceCamera()) && owner.HasActiveOutlines())
				{
					int width = Mathf.Max(1, ctx.hdCamera.actualWidth);
					int height = Mathf.Max(1, ctx.hdCamera.actualHeight);
					owner.sourceCamera = camera;
					if (owner.RenderOutlineBuffer(ctx.cmd, null) && !((Object)(object)owner.outlineOverlayMaterial == (Object)null) && !((Object)(object)owner.renderTexture == (Object)null) && owner._outlineTextureValid)
					{
						owner.outlineOverlayMaterial.SetTexture(OutlineSourceId, (Texture)(object)owner.renderTexture);
						HDUtils.DrawFullScreen(ctx.cmd, owner.outlineOverlayMaterial, ctx.cameraColorBuffer, ctx.cameraDepthBuffer, (MaterialPropertyBlock)null, 0);
						owner.TraceHdrpComposite(width, height, depthTested: false);
					}
				}
			}
		}

		private static readonly HashSet<OutlineEffect> Instances = new HashSet<OutlineEffect>();

		internal bool HighlightedOnly;

		internal string LeaseName = "outline";

		internal bool DrawsSharedOutlines = true;

		internal bool DrawsDisabledTargets;

		internal bool ManualComposite;

		internal bool DepthTestAgainstDisplay;

		internal float LineTexels;

		private static string _pendingLeaseName;

		private static readonly Predicate<Renderer> IsDestroyedRenderer = (Renderer renderer) => (Object)(object)renderer == (Object)null;

		private readonly LinkedSet<Outline> _outlines = new LinkedSet<Outline>();

		private readonly OutlineTargetSet<Renderer> _targets = new OutlineTargetSet<Renderer>();

		private readonly List<Material> _materialBuffer = new List<Material>();

		private readonly List<Material> _sharedMaterialBuffer = new List<Material>();

		[Range(1f, 6f)]
		public float lineThickness = 1.25f;

		[Range(0f, 10f)]
		public float lineIntensity = 0.5f;

		[Range(0f, 1f)]
		public float fillAmount = 0.2f;

		public Color lineColor0 = Color.red;

		public Color lineColor1 = Color.green;

		public Color lineColor2 = Color.blue;

		public bool additiveRendering;

		public bool backfaceCulling = true;

		public Color fillColor = Color.blue;

		public bool useFillColor;

		public bool cornerOutlines;

		public bool addLinesBetweenColors;

		public bool scaleWithScreenSize = true;

		[Range(0f, 1f)]
		public float alphaCutoff = 0.5f;

		public bool flipY;

		public Camera sourceCamera;

		public bool autoEnableOutlines;

		public Camera outlineCamera;

		public Material outlineShaderMaterial;

		private Material outlineOverlayMaterial;

		public RenderTexture renderTexture;

		public RenderTexture extraRenderTexture;

		private Material _outline1Material;

		private Material _outline2Material;

		private Material _outline3Material;

		private Material _outlineEraseMaterial;

		private Shader _outlineShader;

		private Shader _outlineBufferShader;

		private Shader _outlineOverlayShader;

		private Shader _maskShader;

		private CommandBuffer _immediateCommandBuffer;

		private CommandBuffer _feedCommandBuffer;

		private GameObject _customPassVolumeObject;

		private CustomPassVolume _customPassVolume;

		private Y4NGZHDRPOutlinePass _customPass;

		private CameraRenderLease _renderLease;

		private bool _feedMode;

		private bool _renderNextFrame;

		private bool _pipelineCallbacksRegistered;

		private bool _outlineTextureValid;

		private float _nextHdrpTraceAt;

		private float _nextHdrpWarningAt;

		private OutlineCompositeStatus _maskRefusal;

		private bool _maskDepthPull;

		private Matrix4x4 _maskView;

		private Matrix4x4 _maskProjection;

		private float _maskNearClip;

		private static readonly int CompositeTempId = Shader.PropertyToID("_Y4NGZOutlineCompositeTemp");

		private static readonly int OutlineSourceId = Shader.PropertyToID("_OutlineSource");

		private static readonly string[] MaskPassNames = new string[4] { "ForwardOnly", "Forward", "SRPDefaultUnlit", "DepthForwardOnly" };

		public static OutlineEffect Instance { get; private set; }

		internal OutlineCompositeStatus LastCompositeStatus { get; private set; }

		internal int TargetCount => _targets.Count;

		private int SharedOutlineCount
		{
			get
			{
				if (!DrawsSharedOutlines)
				{
					return 0;
				}
				return _outlines.Count;
			}
		}

		internal static void RegisterOutline(Outline outline)
		{
			foreach (OutlineEffect instance in Instances)
			{
				if ((Object)(object)instance != (Object)null)
				{
					instance.AddOutline(outline);
				}
			}
		}

		internal static void UnregisterOutline(Outline outline)
		{
			foreach (OutlineEffect instance in Instances)
			{
				if ((Object)(object)instance != (Object)null)
				{
					instance.RemoveOutline(outline);
				}
			}
		}

		internal static OutlineEffect Attach(Camera camera, string leaseName)
		{
			if ((Object)(object)camera == (Object)null)
			{
				return null;
			}
			OutlineEffect outlineEffect = ((Component)camera).GetComponent<OutlineEffect>();
			if ((Object)(object)outlineEffect == (Object)null)
			{
				_pendingLeaseName = leaseName;
				try
				{
					outlineEffect = ((Component)camera).gameObject.AddComponent<OutlineEffect>();
				}
				finally
				{
					_pendingLeaseName = null;
				}
			}
			outlineEffect.LeaseName = leaseName;
			return outlineEffect;
		}

		internal static OutlineEffect AttachManualComposite(Camera camera, string leaseName)
		{
			if ((Object)(object)camera == (Object)null)
			{
				return null;
			}
			GameObject gameObject = ((Component)camera).gameObject;
			bool activeInHierarchy = gameObject.activeInHierarchy;
			if (activeInHierarchy)
			{
				gameObject.SetActive(false);
			}
			try
			{
				OutlineEffect outlineEffect = gameObject.GetComponent<OutlineEffect>();
				if ((Object)(object)outlineEffect == (Object)null)
				{
					outlineEffect = gameObject.AddComponent<OutlineEffect>();
				}
				outlineEffect.ManualComposite = true;
				outlineEffect.DrawsSharedOutlines = false;
				outlineEffect.LeaseName = leaseName;
				outlineEffect.sourceCamera = camera;
				return outlineEffect;
			}
			finally
			{
				if (activeInHierarchy)
				{
					gameObject.SetActive(true);
				}
			}
		}

		private void Awake()
		{
			if (_pendingLeaseName != null)
			{
				LeaseName = _pendingLeaseName;
			}
			Instances.Add(this);
			Instance = this;
		}

		private void Start()
		{
			CreateMaterialsIfNeeded();
			UpdateMaterialsPublicProperties();
			if ((Object)(object)sourceCamera == (Object)null)
			{
				sourceCamera = ((Component)this).GetComponent<Camera>() ?? Camera.main;
			}
			RecreateRenderTexturesIfNeeded();
			EnsureHdrpCustomPass();
		}

		private void OnEnable()
		{
			if ((Object)(object)GraphicsSettings.currentRenderPipeline != (Object)null)
			{
				AcquireRenderOwnership();
				EnsureHdrpCustomPass();
			}
			else
			{
				RegisterPipelineCallbacks();
			}
			if (!DrawsSharedOutlines)
			{
				return;
			}
			Outline[] array = Object.FindObjectsOfType<Outline>();
			for (int i = 0; i < array.Length; i++)
			{
				if ((Object)(object)array[i] != (Object)null && !_outlines.Contains(array[i]))
				{
					_outlines.Add(array[i]);
				}
			}
		}

		private void OnDisable()
		{
			UnregisterPipelineCallbacks();
			ReleaseRenderOwnership();
			if ((Object)(object)_customPassVolume != (Object)null)
			{
				((Behaviour)_customPassVolume).enabled = false;
			}
		}

		private void OnPreRender()
		{
			//IL_0017: 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_002c: Expected O, but got Unknown
			if (!((Object)(object)GraphicsSettings.currentRenderPipeline != (Object)null))
			{
				if (_immediateCommandBuffer == null)
				{
					_immediateCommandBuffer = new CommandBuffer
					{
						name = "Y4NGZ Outline Buffer"
					};
				}
				_immediateCommandBuffer.Clear();
				if (RenderOutlineBuffer(_immediateCommandBuffer, null))
				{
					Graphics.ExecuteCommandBuffer(_immediateCommandBuffer);
				}
			}
		}

		[ImageEffectOpaque]
		private void OnRenderImage(RenderTexture source, RenderTexture destination)
		{
			if ((Object)(object)outlineShaderMaterial == (Object)null || (Object)(object)renderTexture == (Object)null || !_outlineTextureValid)
			{
				Graphics.Blit((Texture)(object)source, destination);
				return;
			}
			outlineShaderMaterial.SetTexture("_OutlineSource", (Texture)(object)renderTexture);
			if (addLinesBetweenColors && (Object)(object)extraRenderTexture != (Object)null)
			{
				Graphics.Blit((Texture)(object)source, extraRenderTexture, outlineShaderMaterial, 0);
				outlineShaderMaterial.SetTexture("_OutlineSource", (Texture)(object)extraRenderTexture);
			}
			Graphics.Blit((Texture)(object)source, destination, outlineShaderMaterial, 1);
		}

		private void OnDestroy()
		{
			Instances.Remove(this);
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
			UnregisterPipelineCallbacks();
			ReleaseRenderOwnership();
			if ((Object)(object)_customPassVolumeObject != (Object)null)
			{
				Object.Destroy((Object)(object)_customPassVolumeObject);
				_customPassVolumeObject = null;
				_customPassVolume = null;
				_customPass = null;
			}
			if (_immediateCommandBuffer != null)
			{
				_immediateCommandBuffer.Release();
				_immediateCommandBuffer = null;
			}
			if (_feedCommandBuffer != null)
			{
				_feedCommandBuffer.Release();
				_feedCommandBuffer = null;
			}
			if ((Object)(object)renderTexture != (Object)null)
			{
				renderTexture.Release();
				Object.Destroy((Object)(object)renderTexture);
				renderTexture = null;
			}
			if ((Object)(object)extraRenderTexture != (Object)null)
			{
				extraRenderTexture.Release();
				Object.Destroy((Object)(object)extraRenderTexture);
				extraRenderTexture = null;
			}
			DestroyMaterials();
		}

		public void AddOutline(Outline outline)
		{
			if (!((Object)(object)outline == (Object)null) && DrawsSharedOutlines)
			{
				_outlines.Add(outline);
				EnsureHdrpCustomPass();
			}
		}

		public void RemoveOutline(Outline outline)
		{
			if ((Object)(object)outline != (Object)null)
			{
				_outlines.Remove(outline);
			}
		}

		internal void SetTarget(Renderer renderer, int channel)
		{
			_targets.Set(renderer, channel);
		}

		internal bool RemoveTarget(Renderer renderer)
		{
			return _targets.Remove(renderer);
		}

		internal void ClearTargets()
		{
			_targets.Clear();
		}

		internal void ApplyFeedStyle()
		{
			//IL_0022: 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)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			lineThickness = 1.35f;
			lineIntensity = 2.25f;
			fillAmount = 0f;
			lineColor0 = OutlinePalette.Hostile;
			lineColor1 = OutlinePalette.Item;
			lineColor2 = OutlinePalette.Player;
			additiveRendering = true;
			backfaceCulling = false;
			useFillColor = false;
			cornerOutlines = true;
			addLinesBetweenColors = false;
			autoEnableOutlines = false;
			UpdateMaterialsPublicProperties();
		}

		private bool HasActiveOutlines()
		{
			if (DrawsSharedOutlines && _outlines.Count > 0)
			{
				foreach (Outline outline in _outlines)
				{
					if ((Object)(object)outline != (Object)null && ((Behaviour)outline).enabled && (!HighlightedOnly || outline.Highlighted) && (Object)(object)outline.Renderer != (Object)null && (outline.Renderer.enabled || outline.Highlighted))
					{
						return true;
					}
				}
			}
			for (int i = 0; i < _targets.Count; i++)
			{
				Renderer target = _targets[i].Target;
				if ((Object)(object)target != (Object)null && (target.enabled || DrawsDisabledTargets))
				{
					return true;
				}
			}
			return false;
		}

		private bool UsesOverlay(Camera camera)
		{
			if (!ManualComposite)
			{
				return CameraRenderProfile.IsFeed(camera);
			}
			return true;
		}

		private void AcquireRenderOwnership()
		{
			Camera val = ResolveSourceCamera();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			_feedMode = UsesOverlay(val);
			if (_feedMode)
			{
				if ((Object)(object)_customPassVolume != (Object)null)
				{
					((Behaviour)_customPassVolume).enabled = false;
				}
				CameraRenderProfile.TryBeginOverlay(val, LeaseName, out _renderLease);
			}
			else
			{
				CameraRenderProfile.TryAcquireFrameSetting(val, (FrameSettingsField)6, enabled: true, LeaseName, out _renderLease);
			}
		}

		private void ReleaseRenderOwnership()
		{
			if (_renderLease != null)
			{
				_renderLease.Dispose();
			}
			_renderLease = null;
		}

		internal void RefreshRenderOwnership()
		{
			if (((Behaviour)this).isActiveAndEnabled && !((Object)(object)GraphicsSettings.currentRenderPipeline == (Object)null))
			{
				Camera val = ResolveSourceCamera();
				if (!((Object)(object)val == (Object)null) && (UsesOverlay(val) != _feedMode || _renderLease == null || !_renderLease.IsActive))
				{
					ReleaseRenderOwnership();
					AcquireRenderOwnership();
					EnsureHdrpCustomPass();
				}
			}
		}

		internal static bool CompositeFeedOverlay(Camera camera, RenderTexture display)
		{
			if ((Object)(object)camera == (Object)null || (Object)(object)display == (Object)null)
			{
				return false;
			}
			foreach (OutlineEffect instance in Instances)
			{
				if ((Object)(object)instance != (Object)null && instance._feedMode && (Object)(object)instance.sourceCamera == (Object)(object)camera)
				{
					return instance.Composite(display);
				}
			}
			return false;
		}

		internal bool Composite(RenderTexture display)
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)display == (Object)null)
			{
				LastCompositeStatus = OutlineCompositeStatus.NoResources;
				return false;
			}
			if (!((Behaviour)this).isActiveAndEnabled)
			{
				LastCompositeStatus = OutlineCompositeStatus.Inactive;
				return false;
			}
			if (_renderLease == null || !_renderLease.IsActive)
			{
				LastCompositeStatus = OutlineCompositeStatus.NoLease;
				return false;
			}
			if (!HasActiveOutlines())
			{
				LastCompositeStatus = OutlineCompositeStatus.NoTargets;
				return false;
			}
			RenderTexture val = (DepthTestAgainstDisplay ? display : null);
			if ((Object)(object)val != (Object)null && val.depth == 0)
			{
				LastCompositeStatus = OutlineCompositeStatus.NoDepth;
				return false;
			}
			if (_feedCommandBuffer == null)
			{
				_feedCommandBuffer = new CommandBuffer
				{
					name = "Y4NGZ Outline Composite"
				};
			}
			CommandBuffer feedCommandBuffer = _feedCommandBuffer;
			feedCommandBuffer.Clear();
			if (!RenderOutlineBuffer(feedCommandBuffer, val))
			{
				LastCompositeStatus = _maskRefusal;
				return false;
			}
			if ((Object)(object)outlineShaderMaterial == (Object)null || (Object)(object)renderTexture == (Object)null)
			{
				LastCompositeStatus = OutlineCompositeStatus.NoResources;
				return false;
			}
			outlineShaderMaterial.SetTexture(OutlineSourceId, (Texture)(object)renderTexture);
			feedCommandBuffer.GetTemporaryRT(CompositeTempId, ((Texture)display).width, ((Texture)display).height, 0, (FilterMode)1, display.format, (RenderTextureReadWrite)((!display.sRGB) ? 1 : 2));
			feedCommandBuffer.Blit((Texture)(object)display, RenderTargetIdentifier.op_Implicit(CompositeTempId));
			feedCommandBuffer.Blit(RenderTargetIdentifier.op_Implicit(CompositeTempId), RenderTargetIdentifier.op_Implicit((Texture)(object)display), outlineShaderMaterial, 1);
			feedCommandBuffer.ReleaseTemporaryRT(CompositeTempId);
			Graphics.ExecuteCommandBuffer(feedCommandBuffer);
			TraceHdrpComposite(((Texture)display).width, ((Texture)display).height, (Object)(object)val != (Object)null);
			LastCompositeStatus = OutlineCompositeStatus.Drawn;
			return true;
		}

		private bool MaskSharesDepth(RenderTexture depthSource)
		{
			if ((Object)(object)renderTexture != (Object)null && ((Texture)renderTexture).width == ((Texture)depthSource).width && ((Texture)renderTexture).height == ((Texture)depthSource).height)
			{
				return renderTexture.antiAliasing == depthSource.antiAliasing;
			}
			return false;
		}

		private void EnsureHdrpCustomPass()
		{
			//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_00a9: Expected O, but got Unknown
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)GraphicsSettings.currentRenderPipeline == (Object)null)
			{
				return;
			}
			Camera val = ResolveSourceCamera();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			if (UsesOverlay(val))
			{
				if ((Object)(object)_customPassVolume != (Object)null)
				{
					((Behaviour)_customPassVolume).enabled = false;
				}
				return;
			}
			if ((Object)(object)_customPassVolume != (Object)null && _customPass != null)
			{
				_customPass.Owner = this;
				_customPassVolume.targetCamera = val;
				((Behaviour)_customPassVolume).enabled = ((Behaviour)this).isActiveAndEnabled;
				return;
			}
			if ((Object)(object)_customPassVolumeObject == (Object)null)
			{
				_customPassVolumeObject = new GameObject("Y4NGZ_OutlineCustomPassVolume")
				{
					hideFlags = (HideFlags)61
				};
				Object.DontDestroyOnLoad((Object)(object)_customPassVolumeObject);
			}
			_customPassVolume = _customPassVolumeObject.GetComponent<CustomPassVolume>();
			if ((Object)(object)_customPassVolume == (Object)null)
			{
				_customPassVolume = _customPassVolumeObject.AddComponent<CustomPassVolume>();
			}
			_customPassVolume.isGlobal = true;
			_customPassVolume.priority = 1000f;
			_customPassVolume.injectionPoint = (CustomPassInjectionPoint)3;
			_customPassVolume.targetCamera = val;
			_customPassVolume.customPasses.Clear();
			CustomPass val2 = _customPassVolume.AddPassOfType(typeof(Y4NGZHDRPOutlinePass));
			_customPass = val2 as Y4NGZHDRPOutlinePass;
			if (_customPass == null)
			{
				if (Time.unscaledTime >= _nextHdrpWarningAt)
				{
					_nextHdrpWarningAt = Time.unscaledTime + 10f;
					ModuleLog.ShipSystems.LogWarning((object)("[Outline] " + LeaseName + " failed to register the HDRP custom pass; its outlines may be invisible."));
				}
				return;
			}
			((CustomPass)_customPass).name = "Y4NGZ Outline Composite";
			((CustomPass)_customPass).enabled = true;
			((CustomPass)_customPass).targetColorBuffer = (TargetBuffer)0;
			((CustomPass)_customPass).targetDepthBuffer = (TargetBuffer)0;
			((CustomPass)_customPass).clearFlags = (ClearFlag)0;
			_customPass.Owner = this;
			((Behaviour)_customPassVolume).enabled = ((Behaviour)this).isActiveAndEnabled;
			ModuleLog.ShipSystems.LogInfo((object)("[Outline] " + LeaseName + " HDRP custom pass registered for '" + ((Object)val).name + "'."));
		}

		private void TraceHdrpComposite(int width, int height, bool depthTested)
		{
			if (!(Time.unscaledTime < _nextHdrpTraceAt))
			{
				_nextHdrpTraceAt = Time.unscaledTime + 5f;
				ModuleLog.ShipSystems.LogInfo((object)string.Format("[Outline] {0} {1}{2} compositing {3} outline renderer(s) at {4}x{5}.", LeaseName, depthTested ? "depth-tested " : string.Empty, _feedMode ? "feed overlay" : "HDRP custom pass", SharedOutlineCount + _targets.Count, width, height));
			}
		}

		public void UpdateMaterialsPublicProperties()
		{
			if (CreateMaterialsIfNeeded() && !((Object)(object)outlineShaderMaterial == (Object)null))
			{
				float num = 1f;
				if (scaleWithScreenSize)
				{
					num = (float)Screen.height / 360f;
				}
				float thicknessScale = ((scaleWithScreenSize && num >= 1f) ? num : 1f);
				ApplyMaterialProperties(outlineShaderMaterial, thicknessScale, legacyComposite: true);
				if ((Object)(object)outlineOverlayMaterial != (Object)null)
				{
					ApplyMaterialProperties(outlineOverlayMaterial, thicknessScale, legacyComposite: false);
				}
				Shader.SetGlobalFloat("_OutlineAlphaCutoff", alphaCutoff);
			}
		}

		private void ApplyMaterialProperties(Material material, float thicknessScale, bool legacyComposite)
		{
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)material == (Object)null))
			{
				if (LineTexels > 0f)
				{
					int num = (((Object)(object)renderTexture != (Object)null) ? ((Texture)renderTexture).width : (((Object)(object)sourceCamera != (Object)null) ? sourceCamera.pixelWidth : Screen.width));
					int num2 = (((Object)(object)renderTexture != (Object)null) ? ((Texture)renderTexture).height : (((Object)(object)sourceCamera != (Object)null) ? sourceCamera.pixelHeight : Screen.height));
					material.SetFloat("_LineThicknessX", LineTexels / (float)Mathf.Max(1, num));
					material.SetFloat("_LineThicknessY", LineTexels / (float)Mathf.Max(1, num2));
				}
				else
				{
					material.SetFloat("_LineThicknessX", thicknessScale * (lineThickness / Mathf.Max(1f, (float)Screen.width)));
					material.SetFloat("_LineThicknessY", thicknessScale * (lineThickness / Mathf.Max(1f, (float)Screen.height)));
				}
				material.SetFloat("_LineIntensity", lineIntensity);
				material.SetColor("_LineColor1", legacyComposite ? (lineColor0 * lineColor0) : lineColor0);
				material.SetColor("_LineColor2", legacyComposite ? (lineColor1 * lineColor1) : lineColor1);
				material.SetColor("_LineColor3", legacyComposite ? (lineColor2 * lineColor2) : lineColor2);
				material.SetInt("_CornerOutlines", cornerOutlines ? 1 : 0);
				if (legacyComposite)
				{
					material.SetFloat("_FillAmount", fillAmount);
					material.SetColor("_FillColor", fillColor);
					material.SetFloat("_UseFillColor", useFillColor ? 1f : 0f);
					material.SetInt("_FlipY", flipY ? 1 : 0);
					material.SetInt("_Dark", (!additiveRendering) ? 1 : 0);
				}
			}
		}

		private void OnBeginCameraRendering(ScriptableRenderContext context, Camera camera)
		{
			if ((Object)(object)GraphicsSettings.currentRenderPipeline != (Object)null || (Object)(object)camera == (Object)null || (Object)(object)camera != (Object)(object)ResolveSourceCamera())
			{
				return;
			}
			CommandBuffer val = CommandBufferPool.Get("Y4NGZ Outline Buffer");
			try
			{
				if (RenderOutlineBuffer(val, null))
				{
					((ScriptableRenderContext)(ref context)).ExecuteCommandBuffer(val);
				}
			}
			finally
			{
				CommandBufferPool.Release(val);
			}
		}

		private void OnEndCameraRendering(ScriptableRenderContext context, Camera camera)
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)GraphicsSettings.currentRenderPipeline != (Object)null || (Object)(object)camera == (Object)null || (Object)(object)camera != (Object)(object)ResolveSourceCamera() || (Object)(object)outlineShaderMaterial == (Object)null || (Object)(object)renderTexture == (Object)null || !_outlineTextureValid)
			{
				return;
			}
			int num = Mathf.Max(1, camera.pixelWidth);
			int num2 = Mathf.Max(1, camera.pixelHeight);
			CommandBuffer val = CommandBufferPool.Get("Y4NGZ Outline Composite");
			try
			{
				outlineShaderMaterial.SetTexture("_OutlineSource", (Texture)(object)renderTexture);
				val.GetTemporaryRT(CompositeTempId, num, num2, 0, (FilterMode)1, (RenderTextureFormat)7);
				val.Blit(RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)2), RenderTargetIdentifier.op_Implicit(CompositeTempId), outlineShaderMaterial, 1);
				val.Blit(RenderTargetIdentifier.op_Implicit(CompositeTempId), RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)2));
				val.ReleaseTemporaryRT(CompositeTempId);
				((ScriptableRenderContext)(ref context)).ExecuteCommandBuffer(val);
			}
			finally
			{
				CommandBufferPool.Release(val);
			}
		}

		private bool RenderOutlineBuffer(CommandBuffer commandBuffer, RenderTexture depthSource)
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			_maskRefusal = OutlineCompositeStatus.NoResources;
			_maskDepthPull = false;
			if (commandBuffer == null)
			{
				return false;
			}
			if ((Object)(object)ResolveSourceCamera() == (Object)null)
			{
				return false;
			}
			_targets.RemoveAll(IsDestroyedRenderer);
			if (SharedOutlineCount + _targets.Count == 0)
			{
				if (!_renderNextFrame)
				{
					_maskRefusal = OutlineCompositeStatus.NoTargets;
					return false;
				}
				_renderNextFrame = false;
			}
			else
			{
				_renderNextFrame = true;
			}
			if (!CreateMaterialsIfNeeded())
			{
				return false;
			}
			RecreateRenderTexturesIfNeeded();
			UpdateMaterialsPublicProperties();
			if ((Object)(object)renderTexture == (Object)null)
			{
				return false;
			}
			if ((Object)(object)depthSource == (Object)null)
			{
				commandBuffer.SetRenderTarget(RenderTargetIdentifier.op_Implicit((Texture)(object)renderTexture));
				commandBuffer.SetViewport(new Rect(0f, 0f, (float)((Texture)renderTexture).width, (float)((Texture)renderTexture).height));
				commandBuffer.ClearRenderTarget(true, true, Color.clear);
				commandBuffer.SetViewProjectionMatrices(sourceCamera.worldToCameraMatrix, sourceCamera.projectionMatrix);
			}
			else
			{
				if (!MaskSharesDepth(depthSource) || !depthSource.IsCreated())
				{
					_maskRefusal = OutlineCompositeStatus.NoDepth;
					return false;
				}
				if (!renderTexture.IsCreated() && !renderTexture.Create())
				{
					return false;
				}
				commandBuffer.SetRenderTarget(RenderTargetIdentifier.op_Implicit(renderTexture.colorBuffer), RenderTargetIdentifier.op_Implicit(depthSource.depthBuffer));
				commandBuffer.SetViewport(new Rect(0f, 0f, (float)((Texture)renderTexture).width, (float)((Texture)renderTexture).height));
				commandBuffer.ClearRenderTarget(false, true, Color.clear);
				_maskView = sourceCamera.worldToCameraMatrix;
				_maskProjection = sourceCamera.projectionMatrix;
				_maskNearClip = sourceCamera.nearClipPlane;
				commandBuffer.SetViewProjectionMatrices(_maskView, _maskProjection);
				_maskDepthPull = true;
			}
			if (DrawsSharedOutlines)
			{
				foreach (Outline outline in _outlines)
				{
					DrawOutline(commandBuffer, outline);
				}
			}
			for (int i = 0; i < _targets.Count; i++)
			{
				DrawTarget(commandBuffer, _targets[i].Target, _targets[i].Channel);
			}
			_maskDepthPull = false;
			_outlineTextureValid = true;
			return true;
		}

		private void ApplyMaskDepthPull(CommandBuffer commandBuffer, Renderer renderer)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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_001a: 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)
			//IL_002b: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			if (_maskDepthPull)
			{
				Bounds bounds = renderer.bounds;
				Vector3 center = ((Bounds)(ref bounds)).center;
				Vector3 extents = ((Bounds)(ref bounds)).extents;
				float centreDepth = 0f - (_maskView.m20 * center.x + _maskView.m21 * center.y + _maskView.m22 * center.z + _maskView.m23);
				float depthExtent = Mathf.Abs(extents.x * _maskView.m20) + Mathf.Abs(extents.y * _maskView.m21) + Mathf.Abs(extents.z * _maskView.m22);
				float num = OutlineDepthPull.ViewScale(centreDepth, depthExtent, _maskNearClip, 0.005f);
				commandBuffer.SetViewProjectionMatrices(Matrix4x4.Scale(new Vector3(num, num, num)) * _maskView, _maskProjection);
			}
		}

		private Camera ResolveSourceCamera()
		{
			if ((Object)(object)sourceCamera == (Object)null)
			{
				sourceCamera = ((Component)this).GetComponent<Camera>() ?? Camera.main;
			}
			return sourceCamera;
		}

		private void RegisterPipelineCallbacks()
		{
			if (!_pipelineCallbacksRegistered)
			{
				RenderPipelineManager.beginCameraRendering += OnBeginCameraRendering;
				RenderPipelineManager.endCameraRendering += OnEndCameraRendering;
				_pipelineCallbacksRegistered = true;
			}
		}

		private void UnregisterPipelineCallbacks()
		{
			if (_pipelineCallbacksRegistered)
			{
				RenderPipelineManager.beginCameraRendering -= OnBeginCameraRendering;
				RenderPipelineManager.endCameraRendering -= OnEndCameraRendering;
				_pipelineCallbacksRegistered = false;
			}
		}

		private void DrawOutline(CommandBuffer commandBuffer, Outline outline)
		{
			if (!((Object)(object)outline == (Object)null) && !((Object)(object)outline.Renderer == (Object)null) && ((Behaviour)outline).enabled && (!HighlightedOnly || outline.Highlighted))
			{
				Material[] sharedMaterials = outline.SharedMaterials;
				if (sharedMaterials.Length != 0)
				{
					ApplyMaskDepthPull(commandBuffer, outline.Renderer);
				}
				for (int i = 0; i < sharedMaterials.Length; i++)
				{
					DrawMaskSubmesh(commandBuffer, outline.Renderer, outline.MeshFilter, outline.SkinnedMeshRenderer, outline.SpriteRenderer, ResolveBufferMaterial(outline, sharedMaterials[i]), i);
				}
			}
		}

		private void DrawTarget(CommandBuffer commandBuffer, Renderer renderer, int channel)
		{
			if (!((Object)(object)renderer == (Object)null) && (renderer.enabled || DrawsDisabledTargets))
			{
				renderer.GetSharedMaterials(_sharedMaterialBuffer);
				int count = _sharedMaterialBuffer.Count;
				_sharedMaterialBuffer.Clear();
				MeshFilter meshFilter = default(MeshFilter);
				((Component)renderer).TryGetComponent<MeshFilter>(ref meshFilter);
				SkinnedMeshRenderer skinned = (SkinnedMeshRenderer)(object)((renderer is SkinnedMeshRenderer) ? renderer : null);
				SpriteRenderer sprite = (SpriteRenderer)(object)((renderer is SpriteRenderer) ? renderer : null);
				Material materialFromId = GetMaterialFromId(channel);
				if (count > 0 && (Object)(object)materialFromId != (Object)null)
				{
					ApplyMaskDepthPull(commandBuffer, renderer);
				}
				for (int i = 0; i < count; i++)
				{
					DrawMaskSubmesh(commandBuffer, renderer, meshFilter, skinned, sprite, materialFromId, i);
				}
			}
		}

		private void DrawMaskSubmesh(CommandBuffer commandBuffer, Renderer renderer, MeshFilter meshFilter, SkinnedMeshRenderer skinned, SpriteRenderer sprite, Material material, int subMesh)
		{
			if ((Object)(object)material == (Object)null)
			{
				return;
			}
			if (material.HasProperty("_Culling"))
			{
				material.SetInt("_Culling", backfaceCulling ? 2 : 0);
			}
			if (material.HasProperty("_Cull"))
			{
				material.SetInt("_Cull", backfaceCulling ? 2 : 0);
			}
			int num = ResolveMaskMaterialPass(material);
			if ((Object)(object)meshFilter != (Object)null && (Object)(object)meshFilter.sharedMesh != (Object)null)
			{
				if (subMesh < meshFilter.sharedMesh.subMeshCount)
				{
					commandBuffer.DrawRenderer(renderer, material, subMesh, num);
				}
			}
			else if ((Object)(object)skinned != (Object)null && (Object)(object)skinned.sharedMesh != (Object)null)
			{
				if (subMesh < skinned.sharedMesh.subMeshCount)
				{
					commandBuffer.DrawRenderer(renderer, material, subMesh, num);
				}
			}
			else if ((Object)(object)sprite != (Object)null)
			{
				commandBuffer.DrawRenderer(renderer, material, subMesh, num);
			}
		}

		private Material ResolveBufferMaterial(Outline outline, Material sourceMaterial)
		{
			if ((Object)(object)outline == (Object)null)
			{
				return null;
			}
			if (!outline.eraseRenderer)
			{
				return GetMaterialFromId(outline.color);
			}
			return _outlineEraseMaterial;
		}

		private Material GetMaterialFromId(int id)
		{
			return (Material)(id switch
			{
				1 => _outline2Material, 
				2 => _outline3Material, 
				_ => _outline1Material, 
			});
		}

		private void EnsureOutlineCamera()
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			if ((Object)(object)sourceCamera == (Object)null || (Object)(object)outlineCamera != (Object)null)
			{
				return;
			}
			Camera[] componentsInChildren = ((Component)this).GetComponentsInChildren<Camera>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				if ((Object)(object)componentsInChildren[i] != (Object)null && ((Object)componentsInChildren[i]).name == "Outline Camera")
				{
					outlineCamera = componentsInChildren[i];
					((Behaviour)outlineCamera).enabled = false;
					return;
				}
			}
			GameObject val = new GameObject("Outline Camera");
			val.transform.SetParent(((Component)sourceCamera).transform, false);
			outlineCamera = val.AddComponent<Camera>();
			((Behaviour)outlineCamera).enabled = false;
		}

		private void RecreateRenderTexturesIfNeeded()
		{
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)sourceCamera == (Object)null)
			{
				return;
			}
			int num = Mathf.Max(1, sourceCamera.pixelWidth);
			int num2 = Mathf.Max(1, sourceCamera.pixelHeight);
			if ((Object)(object)renderTexture == (Object)null || ((Texture)renderTexture).width != num || ((Texture)renderTexture).height != num2)
			{
				if ((Object)(object)renderTexture != (Object)null)
				{
					renderTexture.Release();
					Object.Destroy((Object)(object)renderTexture);
				}
				if ((Object)(object)extraRenderTexture != (Object)null)
				{
					extraRenderTexture.Release();
					Object.Destroy((Object)(object)extraRenderTexture);
				}
				_outlineTextureValid = false;
				renderTexture = new RenderTexture(num, num2, 16, (RenderTextureFormat)0)
				{
					filterMode = (FilterMode)0,
					wrapMode = (TextureWrapMode)1
				};
				extraRenderTexture = ((!addLinesBetweenColors) ? ((RenderTexture)null) : new RenderTexture(num, num2, 16, (RenderTextureFormat)0)
				{
					filterMode = (FilterMode)0,
					wrapMode = (TextureWrapMode)1
				});
				if ((Object)(object)outlineCamera != (Object)null)
				{
					outlineCamera.targetTexture = renderTexture;
				}
			}
		}

		private bool CreateMaterialsIfNeeded()
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_outlineShader == (Object)null)
			{
				_outlineShader = OutlineRuntimeAssets.LoadShader("OutlineShader");
			}
			if ((Object)(object)_outlineBufferShader == (Object)null)
			{
				_outlineBufferShader = OutlineRuntimeAssets.LoadShader("OutlineBufferShader");
			}
			if ((Object)(object)_outlineOverlayShader == (Object)null)
			{
				_outlineOverlayShader = OutlineRuntimeAssets.LoadShader("Y4NGZOutlineOverlayShader");
			}
			if ((Object)(object)_outlineShader == (Object)null)
			{
				return false;
			}
			if ((Object)(object)GraphicsSettings.currentRenderPipeline != (Object)null && (Object)(object)_outlineOverlayShader == (Object)null)
			{
				return false;
			}
			if ((Object)(object)outlineShaderMaterial == (Object)null)
			{
				outlineShaderMaterial = new Material(_outlineShader)
				{
					hideFlags = (HideFlags)61
				};
			}
			if ((Object)(object)outlineOverlayMaterial == (Object)null && (Object)(object)_outlineOverlayShader != (Object)null)
			{
				outlineOverlayMaterial = new Material(_outlineOverlayShader)
				{
					hideFlags = (HideFlags)61
				};
			}
			if ((Object)(object)_outlineEraseMaterial == (Object)null)
			{
				_outlineEraseMaterial = CreateMaterial(new Color(0f, 0f, 0f, 0f));
			}
			if ((Object)(object)_outline1Material == (Object)null)
			{
				_outline1Material = CreateMaterial(new Color(1f, 0f, 0f, 1f));
			}
			if ((Object)(object)_outline2Material == (Object)null)
			{
				_outline2Material = CreateMaterial(new Color(0f, 1f, 0f, 1f));
			}
			if ((Object)(object)_outline3Material == (Object)null)
			{
				_outline3Material = CreateMaterial(new Color(0f, 0f, 1f, 1f));
			}
			if ((Object)(object)outlineShaderMaterial != (Object)null && ((Object)(object)GraphicsSettings.currentRenderPipeline == (Object)null || (Object)(object)outlineOverlayMaterial != (Object)null) && (Object)(object)_outlineEraseMaterial != (Object)null && (Object)(object)_outline1Material != (Object)null && (Object)(object)_outline2Material != (Object)null)
			{
				return (Object)(object)_outline3Material != (Object)null;
			}
			return false;
		}

		private Material CreateMaterial(Color emissionColor)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//IL_0033: Expected O, but got Unknown
			Shader val = ResolveMaskShader();
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			Material val2 = new Material(val)
			{
				hideFlags = (HideFlags)61,
				renderQueue = 2500
			};
			ConfigureMaskMaterial(val2, emissionColor);
			return val2;
		}

		private Shader ResolveMaskShader()
		{
			if ((Object)(object)_maskShader != (Object)null)
			{
				return _maskShader;
			}
			_maskShader = _outlineBufferShader;
			return _maskShader;
		}

		private static void ConfigureMaskMaterial(Material material, Color color)
		{
			//IL_0010: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)material == (Object)null))
			{
				SetColorIfPresent(material, "_Color", color);
				SetColorIfPresent(material, "_BaseColor", color);
				SetColorIfPresent(material, "_UnlitColor", color);
				SetColorIfPresent(material, "_EmissiveColor", color);
				SetFloatIfPresent(material, "_SurfaceType", 0f);
				SetFloatIfPresent(material, "_AlphaCutoffEnable", 0f);
				SetFloatIfPresent(material, "_ZWrite", 0f);
				SetFloatIfPresent(material, "_ZTestDepthEqualForOpaque", 8f);
				SetIntIfPresent(material, "_SrcBlend", 1);
				SetIntIfPresent(material, "_DstBlend", 0);
				SetIntIfPresent(material, "_Cull", 0);
				SetIntIfPresent(material, "_Culling", 0);
				material.DisableKeyword("_ALPHATEST_ON");
				material.DisableKeyword("_ALPHABLEND_ON");
				material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
			}
		}

		private static int ResolveMaskMaterialPass(Material material)
		{
			if ((Object)(object)material == (Object)null)
			{
				return 0;
			}
			string[] maskPassNames = MaskPassNames;
			for (int i = 0; i < maskPassNames.Length; i++)
			{
				int num = material.FindPass(maskPassNames[i]);
				if (num >= 0)
				{
					return num;
				}
			}
			return 0;
		}

		private static void SetColorIfPresent(Material material, string name, Color value)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			if (material.HasProperty(name))
			{
				material.SetColor(name, value);
			}
		}

		private static void SetFloatIfPresent(Material material, string name, float value)
		{
			if (material.HasProperty(name))
			{
				material.SetFloat(name, value);
			}
		}

		private static void SetIntIfPresent(Material material, string name, int value)
		{
			if (material.HasProperty(name))
			{
				material.SetInt(name, value);
			}
		}

		private void UpdateOutlineCameraFromSource()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)outlineCamera == (Object)null) && !((Object)(object)sourceCamera == (Object)null))
			{
				outlineCamera.CopyFrom(sourceCamera);
				outlineCamera.renderingPath = (RenderingPath)1;
				outlineCamera.backgroundColor = new Color(0f, 0f, 0f, 0f);
				outlineCamera.clearFlags = (CameraClearFlags)2;
				outlineCamera.rect = new Rect(0f, 0f, 1f, 1f);
				outlineCamera.cullingMask = 0;
				outlineCamera.targetTexture = renderTexture;
				((Behaviour)outlineCamera).enabled = false;
				outlineCamera.allowHDR = false;
			}
		}

		private void DestroyMaterials()
		{
			for (int i = 0; i < _materialBuffer.Count; i++)
			{
				if ((Object)(object)_materialBuffer[i] != (Object)null)
				{
					Object.Destroy((Object)(object)_materialBuffer[i]);
				}
			}
			_materialBuffer.Clear();
			if ((Object)(object)outlineShaderMaterial != (Object)null)
			{
				Object.Destroy((Object)(object)outlineShaderMaterial);
			}
			if ((Object)(object)outlineOverlayMaterial != (Object)null)
			{
				Object.Destroy((Object)(object)outlineOverlayMaterial);
			}
			if ((Object)(object)_outlineEraseMaterial != (Object)null)
			{
				Object.Destroy((Object)(object)_outlineEraseMaterial);
			}
			if ((Object)(object)_outline1Material != (Object)null)
			{
				Object.Destroy((Object)(object)_outline1Material);
			}
			if ((Object)(object)_outline2Material != (Object)null)
			{
				Object.Destroy((Object)(object)_outline2Material);
			}
			if ((Object)(object)_outline3Material != (Object)null)
			{
				Object.Destroy((Object)(object)_outline3Material);
			}
		}
	}
	internal static class OutlinePalette
	{
		internal static readonly Color Hostile = new Color(1f, 0.06f, 0.04f, 1f);

		internal static readonly Color Item = new Color(0.1f, 1f, 0.28f, 1f);

		internal static readonly Color Player = Color.white;
	}
	internal sealed class OutlineRendererSelector
	{
		private const int MapRadarLayer = 14;

		private const int MapOnlyLayer = 22;

		private static readonly string[] HelperPathNeedles = new string[7] { "scannode", "scan node", "mapdot", "map dot", "radar", "minimap", "shadow" };

		private static readonly string[] HelperMeshNeedles = new string[4] { "scannode", "mapdot", "radar", "minimap" };

		private static readonly string[] HelperMaterialNeedles = new string[7] { "scannode", "scan node", "mapdot", "map dot", "radar", "minimap", "shadow" };

		private static int _cullingMaskFrame = -1;

		private static int _cullingMask;

		private static readonly List<Component> ComponentBuffer = new List<Component>();

		private static readonly List<Material> MaterialBuffer = new List<Material>();

		private readonly HashSet<Renderer> _lodManagedRenderers = new HashSet<Renderer>();

		private readonly HashSet<Renderer> _activeLodRenderers = new HashSet<Renderer>();

		private readonly List<LODGroup> _lodGroupBuffer = new List<LODGroup>();

		private readonly List<Renderer> _rendererBuffer = new List<Renderer>();

		private GameObject _root;

		private Transform _rootTransform;

		private PlayerControllerB _targetPlayer;

		private EnemyAI _targetEnemy;

		private GrabbableObject _targetItem;

		internal void Bind(GameObject root)
		{
			_root = root;
			_rootTransform = (((Object)(object)root != (Object)null) ? root.transform : null);
			BindTargetComponents();
		}

		internal void Collect(Camera camera, bool includeDisabled, List<Renderer> into)
		{
			if (into == null)
			{
				return;
			}
			into.Clear();
			BindTargetComponents();
			RefreshLods(camera);
			if ((Object)(object)_root == (Object)null)
			{
				return;
			}
			_root.GetComponentsInChildren<Renderer>(false, _rendererBuffer);
			for (int i = 0; i < _rendererBuffer.Count; i++)
			{
				Renderer val = _rendererBuffer[i];
				if (IsCandidate(val, includeDisabled))
				{
					into.Add(val);
				}
			}
			_rendererBuffer.Clear();
		}

		private void BindTargetComponents()
		{
			if ((Object)(object)_root == (Object)null)
			{
				_targetPlayer = null;
				_targetEnemy = null;
				_targetItem = null;
			}
			else
			{
				_targetPlayer = _root.GetComponent<PlayerControllerB>();
				_targetEnemy = _root.GetComponent<EnemyAI>();
				_targetItem = _root.GetComponent<GrabbableObject>();
			}
		}

		internal void RefreshLods(Camera camera)
		{
			_lodManagedRenderers.Clear();
			_activeLodRenderers.Clear();
			if ((Object)(object)_root == (Object)null)
			{
				return;
			}
			_root.GetComponentsInChildren<LODGroup>(false, _lodGroupBuffer);
			for (int i = 0; i < _lodGroupBuffer.Count; i++)
			{
				LODGroup val = _lodGroupBuffer[i];
				if ((Object)(object)val == (Object)null || !val.enabled)
				{
					continue;
				}
				LOD[] lODs = val.GetLODs();
				int num = -1;
				for (int j = 0; j < lODs.Length; j++)
				{
					Renderer[] renderers = lODs[j].renderers;
					if (renderers == null)
					{
						continue;
					}
					bool flag = false;
					foreach (Renderer val2 in renderers)
					{
						if (!((Object)(object)val2 == (Object)null))
						{
							_lodManagedRenderers.Add(val2);
							flag = true;
						}
					}
					if (num < 0 && flag)
					{
						num = j;
					}
				}
				int num2 = ResolveActiveLodIndex(val, lODs, camera, num);
				if (num2 < 0 || num2 >= lODs.Length)
				{
					continue;
				}
				Renderer[] renderers2 = lODs[num2].renderers;
				if (renderers2 == null)
				{
					continue;
				}
				foreach (Renderer val3 in renderers2)
				{
					if ((Object)(object)val3 != (Object)null)
					{
						_activeLodRenderers.Add(val3);
					}
				}
			}
			_lodGroupBuffer.Clear();
		}

		private static int ResolveActiveLodIndex(LODGroup group, LOD[] lods, Camera camera, int fallbackLod)
		{
			if ((Object)(object)group == (Object)null || lods == null || lods.Length == 0)
			{
				return -1;
			}
			if ((Object)(object)camera == (Object)null)
			{
				return fallbackLod;
			}
			float num = CalculateRelativeScreenHeight(group, camera);
			int result = lods.Length - 1;
			for (int i = 0; i < lods.Length; i++)
			{
				if (num >= lods[i].screenRelativeTransitionHeight)
				{
					result = i;
					break;
				}
			}
			return result;
		}

		private static float CalculateRelativeScreenHeight(LODGroup group, Camera camera)
		{
			//IL_0021: 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)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)group == (Object)null || (Object)(object)camera == (Object)null)
			{
				return 1f;
			}
			Transform transform = ((Component)group).transform;
			Vector3 val = transform.TransformPoint(group.localReferencePoint);
			float num = Vector3.Distance(((Component)camera).transform.position, val);
			if (num <= 0.01f)
			{
				return 1f;
			}
			float num2 = Mathf.Max(0.01f, group.size * MaxAbsScale(transform.lossyScale));
			if (camera.orthographic)
			{
				return num2 / Mathf.Max(0.01f, camera.orthographicSize * 2f);
			}
			return num2 / (2f * num * Mathf.Tan(camera.fieldOfView * 0.5f * (MathF.PI / 180f))) * Mathf.Max(0.01f, QualitySettings.lodBias);
		}

		private static float MaxAbsScale(Vector3 scale)
		{
			//IL_0000: 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_0016: Unknown result type (might be due to invalid IL or missing references)
			return Mathf.Max(Mathf.Abs(scale.x), Mathf.Max(Mathf.Abs(scale.y), Mathf.Abs(scale.z)));
		}

		private static bool IsGameplayVisibleLayer(int layer)
		{
			if (layer < 0 || layer > 31)
			{
				return false;
			}
			int num = ResolveGameplayCullingMask();
			if (num != 0)
			{
				return (num & (1 << layer)) != 0;
			}
			if (layer != 14)
			{
				return layer != 22;
			}
			return false;
		}

		private static int ResolveGameplayCullingMask()
		{
			if (_cullingMaskFrame == Time.frameCount)
			{
				return _cullingMask;
			}
			_cullingMaskFrame = Time.frameCount;
			_cullingMask = 0;
			PlayerControllerB val = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.localPlayerController : null);
			if ((Object)(object)val == (Object)null && (Object)(object)GameNetworkManager.Instance != (Object)null)
			{
				val = GameNetworkManager.Instance.localPlayerController;
			}
			Camera val2 = (((Object)(object)val != (Object)null) ? val.gameplayCamera : null);
			if ((Object)(object)val2 != (Object)null)
			{
				_cullingMask = val2.cullingMask;
			}
			return _cullingMask;
		}

		internal bool IsCandidate(Renderer renderer, bool includeDisabled)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Invalid comparison between Unknown and I4
			if ((Object)(object)renderer == (Object)null || (!renderer.enabled && !includeDisabled))
			{
				return false;
			}
			if (renderer is ParticleSystemRenderer || renderer is LineRenderer || renderer is TrailRenderer)
			{
				return false;
			}
			if ((int)renderer.shadowCastingMode == 3)
			{
				return false;
			}
			if (!IsGameplayVisibleLayer(((Component)renderer).gameObject.layer))
			{
				return false;
			}
			return BelongsToTarget(renderer);
		}

		internal bool BelongsToTarget(Renderer renderer)
		{
			if ((Object)(object)renderer == (Object)null)
			{
				return false;
			}
			if ((Object)(object)_targetPlayer != (Object)null)
			{
				if ((Object)(object)((Component)renderer).GetComponentInParent<PlayerControllerB>() != (Object)(object)_targetPlayer)
				{
					return false;
				}
				if ((Object)(object)((Component)renderer).GetComponentInParent<EnemyAI>() != (Object)null)
				{
					return false;
				}
				if (!IsActiveLodRenderer(renderer) || IsHelperRenderer(renderer))
				{
					return false;
				}
				return (Object)(object)((Component)renderer).GetComponentInParent<GrabbableObject>() == (Object)null;
			}
			if ((Object)(object)_targetEnemy != (Object)null)
			{
				if ((Object)(object)((Component)renderer).GetComponentInParent<EnemyAI>() != (Object)(object)_targetEnemy)
				{
					return false;
				}
				if ((Object)(object)((Component)renderer).GetComponentInParent<PlayerControllerB>() != (Object)null)
				{
					return false;
				}
				if (!IsActiveLodRenderer(renderer) || IsHelperRenderer(renderer))
				{
					return false;
				}
				return (Object)(object)((Component)renderer).GetComponentInParent<GrabbableObject>() == (Object)null;
			}
			if ((Object)(object)_targetItem != (Object)null)
			{
				if ((Object)(object)((Component)renderer).GetComponentInParent<GrabbableObject>() == (Object)(object)_targetItem)
				{
					return IsActiveLodRenderer(renderer);
				}
				return false;
			}
			if ((Object)(object)_rootTransform != (Object)null && ((Component)renderer).transform.IsChildOf(_rootTransform))
			{
				return IsActiveLodRenderer(renderer);
			}
			return false;
		}

		private bool IsActiveLodRenderer(Renderer renderer)
		{
			if ((Object)(object)renderer == (Object)null)
			{
				return false;
			}
			if (_lodManagedRenderers.Count <= 0)
			{
				return true;
			}
			if (_lodManagedRenderers.Contains(renderer))
			{
				return _activeLodRenderers.Contains(renderer);
			}
			return true;
		}

		private static bool IsHelperRenderer(Renderer renderer)
		{
			if ((Object)(object)renderer == (Object)null)
			{
				return true;
			}
			if (ContainsAny(BuildTransformPath(((Component)renderer).transform).ToLowerInvariant(), HelperPathNeedles))
			{
				return true;
			}
			if (HasParentComponentNamed(((Component)renderer).transform, "ScanNodeProperties"))
			{
				return true;
			}
			if (ContainsAny(GetMeshName(renderer).ToLowerInvariant(), HelperMeshNeedles))
			{
				return true;
			}
			return ContainsAny(GetMaterialNames(renderer).ToLowerInvariant(), HelperMaterialNeedles);
		}

		private static string BuildTransformPath(Transform current)
		{
			if ((Object)(object)current == (Object)null)
			{
				return string.Empty;
			}
			string text = ((Object)current).name;
			Transform parent = current.parent;
			int num = 0;
			while ((Object)(object)parent != (Object)null && num++ < 48)
			{
				text = ((Object)parent).name + "/" + text;
				parent = parent.parent;
			}
			return text;
		}

		private static bool HasParentComponentNamed(Transform transform, string componentTypeName)
		{
			Transform val = transform;
			int num = 0;
			while ((Object)(object)val != (Object)null && num++ < 48)
			{
				((Component)val).GetComponents<Component>(ComponentBuffer);
				for (int i = 0; i < ComponentBuffer.Count; i++)
				{
					Component val2 = ComponentBuffer[i];
					if ((Object)(object)val2 != (Object)null && ((object)val2).GetType().Name == componentTypeName)
					{
						ComponentBuffer.Clear();
						return true;
					}
				}
				val = val.parent;
			}
			ComponentBuffer.Clear();
			return false;
		}

		private static string GetMeshName(Renderer renderer)
		{
			if ((Object)(object)renderer == (Object)null)
			{
				return string.Empty;
			}
			SkinnedMeshRenderer val = (SkinnedMeshRenderer)(object)((renderer is SkinnedMeshRenderer) ? renderer : null);
			if ((Object)(object)val != (Object)null && (Object)(object)val.sharedMesh != (Object)null)
			{
				return ((Object)val.sharedMesh).name;
			}
			MeshFilter component = ((Component)renderer).GetComponent<MeshFilter>();
			if (!((Object)(object)component != (Object)null) || !((Object)(object)component.sharedMesh != (Object)null))
			{
				return string.Empty;
			}
			return ((Object)component.sharedMesh).name;
		}

		private static string GetMaterialNames(Renderer renderer)
		{
			if ((Object)(object)renderer == (Object)null)
			{
				return string.Empty;
			}
			renderer.GetSharedMaterials(MaterialBuffer);
			if (MaterialBuffer.Count == 0)
			{
				return string.Empty;
			}
			string text = string.Empty;
			for (int i = 0; i < MaterialBuffer.Count; i++)
			{
				Material val = MaterialBuffer[i];
				if (!((Object)(object)val == (Object)null))
				{
					if (text.Length > 0)
					{
						text += " ";
					}
					text += ((Object)val).name;
				}
			}
			MaterialBuffer.Clear();
			return text;
		}

		private static bool ContainsAny(string value, string[] needles)
		{
			if (string.IsNullOrEmpty(value))
			{
				return false;
			}
			foreach (string value2 in needles)
			{
				if (!string.IsNullOrEmpty(value2) && value.Contains(value2))
				{
					return true;
				}
			}
			return false;
		}
	}
	internal static class OutlineRuntimeAssets
	{
		internal const string BundleName = "y4ngz-outlineeffect.bundle";

		internal const string OutlineShaderName = "OutlineShader";

		internal const string BufferShaderName = "OutlineBufferShader";

		internal const string OverlayShaderName = "Y4NGZOutlineOverlayShader";

		private static readonly Dictionary<string, Shader> ShaderCache = new Dictionary<string, Shader>();

		private static AssetBundle _bundle;

		private static bool _loadAttempted;

		internal static bool HasShaders()
		{
			Shader obj = LoadShader("OutlineShader");
			Shader val = LoadShader("OutlineBufferShader");
			Shader val2 = LoadShader("Y4NGZOutlineOverlayShader");
			if ((Object)(object)obj != (Object)null && (Object)(object)val != (Object)null)
			{
				return (Object)(object)val2 != (Object)null;
			}
			return false;
		}

		internal static Shader LoadShader(string shaderName)
		{
			if (string.IsNullOrWhiteSpace(shaderName))
			{
				return null;
			}
			if (ShaderCache.TryGetValue(shaderName, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			Shader val = Resources.Load<Shader>(shaderName);
			if ((Object)(object)val == (Object)null)
			{
				val = LoadShaderFromBundles(shaderName);
			}
			if ((Object)(object)val != (Object)null)
			{
				ShaderCache[shaderName] = val;
			}
			else
			{
				ModuleLog.ShipSystems.LogWarning((object)("[Outline] Shader '" + shaderName + "' could not be loaded. Missing y4ngz-outlineeffect.bundle?"));
			}
			return val;
		}

		private static Shader LoadShaderFromBundles(string shaderName)
		{
			foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles())
			{
				if (!((Object)(object)allLoadedAssetBundle == (Object)null))
				{
					Shader val = allLoadedAssetBundle.LoadAsset<Shader>(shaderName);
					if ((Object)(object)val != (Object)null)
					{
						return val;
					}
				}
			}
			EnsureBundleLoaded();
			if (!((Object)(object)_bundle != (Object)null))
			{
				return null;
			}
			return _bundle.LoadAsset<Shader>(shaderName);
		}

		private static void EnsureBundleLoaded()
		{
			if (_loadAttempted)
			{
				return;
			}
			_loadAttempted = true;
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty, "y4ngz-outlineeffect.bundle");
			if (!File.Exists(text))
			{
				ModuleLog.ShipSystems.LogWarning((object)("[Outline] Bundle is missing at " + text + "."));
				return;
			}
			_bundle = AssetBundle.LoadFromFile(text);
			if ((Object)(object)_bundle == (Object)null)
			{
				ModuleLog.ShipSystems.LogWarning((object)("[Outline] Failed to load outline bundle at " + text + "."));
			}
		}
	}
	internal sealed class OutlineTargetSet<T> where T : class
	{
		internal readonly struct Entry
		{
			internal readonly T Target;

			internal readonly int Channel;

			internal Entry(T target, int channel)
			{
				Target = target;
				Channel = channel;
			}
		}

		private readonly List<Entry> _entries = new List<Entry>();

		internal int Count => _entries.Count;

		internal Entry this[int index] => _entries[index];

		internal void Set(T target, int channel)
		{
			if (target != null)
			{
				int num = IndexOf(target);
				if (num >= 0)
				{
					_entries[num] = new Entry(target, channel);
				}
				else
				{
					_entries.Add(new Entry(target, channel));
				}
			}
		}

		internal bool Remove(T target)
		{
			int num = IndexOf(target);
			if (num < 0)
			{
				return false;
			}
			_entries.RemoveAt(num);
			return true;
		}

		internal void Clear()
		{
			_entries.Clear();
		}

		internal int RemoveAll(Predicate<T> match)
		{
			if (match == null)
			{
				return 0;
			}
			int num = 0;
			for (int i = 0; i < _entries.Count; i++)
			{
				Entry value = _entries[i];
				if (!match(value.Target))
				{
					_entries[num++] = value;
				}
			}
			int num2 = _entries.Count - num;
			if (num2 > 0)
			{
				_entries.RemoveRange(num, num2);
			}
			return num2;
		}

		private int IndexOf(T target)
		{
			if (target == null)
			{
				return -1;
			}
			for (int i = 0; i < _entries.Count; i++)
			{
				if (_entries[i].Target == target)
				{
					return i;
				}
			}
			return -1;
		}
	}
}
namespace Y4NGZCompany.ShipSystems.MonitorRow
{
	internal readonly struct MonitorRowTypewriterStep
	{
		internal int LineIndex { get; }

		internal int VisibleChars { get; }

		internal float DelaySeconds { get; }

		internal bool LineCompleted { get; }

		internal MonitorRowTypewriterStep(int lineIndex, int visibleChars, float delaySeconds, bool lineCompleted)
		{
			LineIndex = lineIndex;
			VisibleChars = visibleChars;
			DelaySeconds = delaySeconds;
			LineCompleted = lineCompleted;
		}
	}
	internal static class MonitorRowCeremonyMath
	{
		internal const float MinRenderStepSeconds = 1f / 15f;

		internal const float MaxTypingSecondsDefault = 20f;

		internal static MonitorRowTypewriterStep[] BuildTypewriterSchedule(string[] lines, float secondsPerChar, float minRenderStepSeconds, float maxTypingSeconds)
		{
			if (lines == null || lines.Length == 0)
			{
				return Array.Empty<MonitorRowTypewriterStep>();
			}
			secondsPerChar = Clamp(secondsPerChar, 0.001f, 1f);
			minRenderStepSeconds = Clamp(minRenderStepSeconds, 0.01f, 1f);
			if (maxTypingSeconds <= 0f)
			{
				maxTypingSeconds = 20f;
			}
			int num = 0;
			for (int i = 0; i < lines.Length; i++)
			{
				num += CountTypedCharacters(lines[i]);
			}
			float num2 = (float)num * secondsPerChar;
			float num3 = ((num2 > maxTypingSeconds) ? (secondsPerChar * (maxTypingSeconds / num2)) : secondsPerChar);
			int num4 = Math.Max