Decompiled source of BenGoop v1.0.1

plugins\BenGoop.dll

Decompiled 3 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MyceliumNetworking;
using Photon.Pun;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using UnityEngine.Video;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("BenGoop")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("BenGoop")]
[assembly: AssemblyTitle("BenGoop")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BenGoop
{
	public class GhostZombeWrapper : MonoBehaviour
	{
		private const float LifeTime = 16f;

		private const float WalkSpeed = 0.6f;

		private Player? _target;

		private PhotonView? _photonView;

		private Bot? _bot;

		private Animator? _animator;

		private Collider[] _colliders = (Collider[])(object)new Collider[0];

		private Collider[] _playerColliders = (Collider[])(object)new Collider[0];

		private float _aliveTime;

		private float _nextGoal;

		private float _nextNoHitCheck;

		private float _nextDiagnostic;

		private Vector3 _goal;

		private bool _counted;

		private bool _ready;

		private static readonly List<GhostZombeWrapper> Living = new List<GhostZombeWrapper>();

		public static GhostZombeWrapper? Oldest
		{
			get
			{
				if (Living.Count <= 0)
				{
					return null;
				}
				return Living[0];
			}
		}

		public void Setup(Player? target, float scale)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			_target = (Player?)(((Object)(object)target != (Object)null) ? ((object)target) : ((object)Player.localPlayer));
			((Component)this).transform.localScale = Vector3.one * scale;
			DoNotHarm();
			((Component)this).transform.position = SnapToGround(((Component)this).transform.position);
		}

		private void DoNotHarm()
		{
			_animator = ((Component)this).GetComponentInChildren<Animator>(true);
			_colliders = ((Component)this).GetComponentsInChildren<Collider>(true);
			if (_colliders.Length == 0)
			{
				Collider[] colliders = (Collider[])(object)new BoxCollider[1] { ((Component)this).gameObject.AddComponent<BoxCollider>() };
				_colliders = colliders;
			}
			NavMeshAgent[] componentsInChildren = ((Component)this).GetComponentsInChildren<NavMeshAgent>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				((Behaviour)componentsInChildren[i]).enabled = false;
			}
		}

		private void Start()
		{
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			TripEffect.GhostSpawned();
			_counted = true;
			_aliveTime = 0f;
			Living.Add(this);
			_photonView = ((Component)this).GetComponent<PhotonView>();
			_bot = ((Component)this).GetComponentInChildren<Bot>(true);
			Pacify();
			RefreshNoHit();
			HoldWalkCycle();
			CollectAndRegisterVoice();
			AttachLight();
			_ready = true;
			Debug.Log((object)("[BenGoop] GHOST init bot=" + ((Object)(object)_bot != (Object)null) + " animator=" + ((Object)(object)_animator != (Object)null) + " colliders=" + _colliders.Length + " pos=" + ((object)((Component)this).transform.position/*cast due to .constrained prefix*/).ToString()));
		}

		private void Pacify()
		{
			if (!((Object)(object)_bot == (Object)null))
			{
				_bot.targetPlayer = null;
				_bot.aggro = false;
				_bot.attacking = false;
				_bot.syncData.sprint = false;
			}
		}

		private void HoldWalkCycle()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_bot != (Object)null)
			{
				_bot.syncData.movementInput = new Vector2(0f, 0.85f);
			}
			if ((Object)(object)_animator != (Object)null)
			{
				try
				{
					_animator.SetInteger("Movement Type", 1);
				}
				catch
				{
				}
			}
		}

		private void RefreshNoHit()
		{
			if ((Object)(object)_target != (Object)null)
			{
				_playerColliders = ((Component)_target).GetComponentsInChildren<Collider>(true);
			}
			Collider[] colliders = _colliders;
			foreach (Collider val in colliders)
			{
				if ((Object)(object)val == (Object)null || !val.enabled)
				{
					continue;
				}
				Collider[] playerColliders = _playerColliders;
				foreach (Collider val2 in playerColliders)
				{
					if (!((Object)(object)val2 == (Object)null) && !val2.isTrigger && !val.isTrigger && !val2.isTrigger)
					{
						Physics.IgnoreCollision(val, val2, true);
					}
				}
			}
		}

		private void AttachLight()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("GhostLight");
			val.transform.SetParent(((Component)this).transform, false);
			val.transform.localPosition = new Vector3(0f, 1.4f, 0f);
			Light obj = val.AddComponent<Light>();
			obj.type = (LightType)2;
			obj.intensity = 20f;
			obj.range = 12f;
			obj.color = new Color(0.95f, 0.95f, 1f);
			obj.shadows = (LightShadows)0;
		}

		private void Update()
		{
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: 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_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: 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)
			if (!_ready)
			{
				return;
			}
			_aliveTime += Time.deltaTime;
			if (_aliveTime > 16f)
			{
				Despawn();
				return;
			}
			Player target = _target;
			if ((Object)(object)target == (Object)null || target.refs == null || (Object)(object)target.refs.headPos == (Object)null)
			{
				return;
			}
			Pacify();
			HoldWalkCycle();
			Vector3 position = target.refs.headPos.position;
			if (Time.time >= _nextNoHitCheck)
			{
				_nextNoHitCheck = Time.time + 2f;
				RefreshNoHit();
			}
			if (Time.time >= _nextGoal)
			{
				_nextGoal = Time.time + Random.Range(3f, 5f);
				_goal = SnapToGround(position + RingDir() * Random.Range(4f, 8f));
			}
			Vector3 val = _goal - ((Component)this).transform.position;
			val.y = 0f;
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (magnitude > 0.3f)
			{
				if (magnitude > 0.001f)
				{
					Quaternion val2 = Quaternion.LookRotation(val);
					((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, val2, Time.deltaTime * 3f);
				}
				Vector3 val3 = ((Vector3)(ref val)).normalized * (0.6f * Time.deltaTime);
				((Component)this).transform.position = ((Component)this).transform.position + new Vector3(val3.x, 0f, val3.z);
			}
			else if (Time.time >= _nextGoal)
			{
				_nextGoal = Time.time + 0.5f;
			}
			Vector3 val4 = SnapToGround(((Component)this).transform.position);
			((Component)this).transform.position = new Vector3(((Component)this).transform.position.x, Mathf.Max(((Component)this).transform.position.y, val4.y), ((Component)this).transform.position.z);
			if (!(_aliveTime > 2f) || !(Time.time >= _nextDiagnostic))
			{
				return;
			}
			_nextDiagnostic = Time.time + 3f;
			string text = "?";
			int num = -1;
			if ((Object)(object)_animator != (Object)null)
			{
				try
				{
					num = _animator.GetInteger("Movement Type");
				}
				catch
				{
				}
				AnimatorStateInfo currentAnimatorStateInfo = _animator.GetCurrentAnimatorStateInfo(0);
				text = (_animator.HasState(0, ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).shortNameHash) ? ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).shortNameHash.ToString() : "unknown");
			}
			SkinnedMeshRenderer componentInChildren = ((Component)this).GetComponentInChildren<SkinnedMeshRenderer>(true);
			Vector3 val5;
			if (!((Object)(object)componentInChildren != (Object)null))
			{
				val5 = Vector3.zero;
			}
			else
			{
				Bounds bounds = ((Renderer)componentInChildren).bounds;
				val5 = ((Bounds)(ref bounds)).size;
			}
			Vector3 val6 = val5;
			Debug.Log((object)$"[BenGoop] GHOST age={_aliveTime:F1} movType={num} state={text} boundsH={val6.y:F1} distToHead={Vector3.Distance(((Component)this).transform.position, position):F1} pos={((Component)this).transform.position} scale={((Component)this).transform.localScale.x}");
		}

		private static Vector3 RingDir()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: 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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Random.onUnitSphere;
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude < 0.001f)
			{
				val = Vector3.right;
			}
			return ((Vector3)(ref val)).normalized;
		}

		private void Despawn()
		{
			_ready = false;
			if ((Object)(object)_photonView != (Object)null)
			{
				PhotonNetwork.Destroy(_photonView);
			}
			else
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		private void OnDestroy()
		{
			Living.Remove(this);
			if (_counted)
			{
				_counted = false;
				TripEffect.GhostDespawned();
			}
		}

		public void DespawnNow()
		{
			if (_ready)
			{
				Despawn();
			}
		}

		private static Vector3 SnapToGround(Vector3 pos)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(pos + Vector3.up * 3f, Vector3.down, ref val, 30f) && ((RaycastHit)(ref val)).normal.y > 0.5f)
			{
				return new Vector3(pos.x, ((RaycastHit)(ref val)).point.y, pos.z);
			}
			return pos;
		}

		private void CollectAndRegisterVoice()
		{
			try
			{
				List<AudioClip> list = new List<AudioClip>();
				SFX_PlayOneShot[] componentsInChildren = ((Component)this).GetComponentsInChildren<SFX_PlayOneShot>(true);
				foreach (SFX_PlayOneShot val in componentsInChildren)
				{
					if ((Object)(object)val == (Object)null)
					{
						continue;
					}
					AddClips(list, val.sfx);
					if (val.sfxs != null)
					{
						SFX_Instance[] sfxs = val.sfxs;
						foreach (SFX_Instance s in sfxs)
						{
							AddClips(list, s);
						}
					}
				}
				AudioSource[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<AudioSource>(true);
				foreach (AudioSource val2 in componentsInChildren2)
				{
					if ((Object)(object)val2 != (Object)null && (Object)(object)val2.clip != (Object)null && !list.Contains(val2.clip))
					{
						list.Add(val2.clip);
					}
				}
				if (list.Count == 0)
				{
					SFX_Instance[] sfxs = Resources.FindObjectsOfTypeAll<SFX_Instance>();
					foreach (SFX_Instance val3 in sfxs)
					{
						if ((Object)(object)val3 != (Object)null && !string.IsNullOrEmpty(((Object)val3).name) && ((Object)val3).name.ToLowerInvariant().Contains("zombe"))
						{
							AddClips(list, val3);
						}
					}
				}
				if (list.Count > 0)
				{
					TripEffect.RegisterZombeVoices(list);
					Debug.Log((object)("[BenGoop] Zombe voice registered: " + list.Count + " clips"));
				}
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[BenGoop] Zombe voice lookup failed: " + ex.Message));
			}
		}

		private static void AddClips(List<AudioClip> clips, SFX_Instance s)
		{
			if ((Object)(object)s == (Object)null || s.clips == null)
			{
				return;
			}
			AudioClip[] clips2 = s.clips;
			foreach (AudioClip val in clips2)
			{
				if ((Object)(object)val != (Object)null && !clips.Contains(val))
				{
					clips.Add(val);
				}
			}
		}
	}
	public class GoopItemRegistry : MonoBehaviour
	{
		private float _nextSyncBroadcast;

		public static GoopItemRegistry? Instance { get; private set; }

		public static void Configure(GameObject host)
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = host.AddComponent<GoopItemRegistry>();
			}
		}

		private void Update()
		{
			GoopItemFactory.EnsureRegistered();
			if ((Object)(object)GoopItemFactory.BenGoop != (Object)null && Time.time >= _nextSyncBroadcast)
			{
				_nextSyncBroadcast = Time.time + 5f;
				MyceliumNetwork.RPC(3910472083u, "SyncBenGoopItem", (ReliableType)1, new object[2]
				{
					GoopItemFactory.BenGoop.PersistentID.ToString(),
					GoopItemFactory.BenGoop.id
				});
			}
		}
	}
	public static class GoopItemFactory
	{
		private static readonly Guid PersistentGuid = Guid.Parse("4f2e9f1a-7fae-4b4f-b0d3-8c9d4a0e5f02");

		private static byte? pendingSyncedId;

		private static Texture2D _whiteTex;

		public static Item? BenGoop { get; private set; }

		public static void ApplySyncedRegistration(string guid, byte itemId)
		{
			if (!Guid.TryParse(guid, out var result) || result != PersistentGuid)
			{
				return;
			}
			if ((Object)(object)BenGoop != (Object)null)
			{
				if (BenGoop.id != itemId)
				{
					Debug.Log((object)("[BenGoop] Item id synced over network: " + BenGoop.id + " -> " + itemId));
					BenGoop.id = itemId;
				}
			}
			else
			{
				pendingSyncedId = itemId;
			}
		}

		public static void EnsureRegistered()
		{
			if ((Object)(object)BenGoop != (Object)null)
			{
				bool flag = false;
				try
				{
					Item val = default(Item);
					flag = ItemDatabase.TryGetItemFromPersistentID(PersistentGuid, ref val) && (Object)(object)val == (Object)(object)BenGoop;
				}
				catch (Exception ex)
				{
					Debug.LogError((object)("[BenGoop] Could not validate item in database: " + ex));
				}
				if (flag && (Object)(object)BenGoop.itemObject == (Object)null)
				{
					Debug.LogWarning((object)"[BenGoop] itemObject missing, rebuilding prefab...");
					RebuildPrefab();
					Debug.Log((object)("[BenGoop] Rebuilt prefab: " + (((Object)(object)BenGoop.itemObject != (Object)null) ? ((Object)BenGoop.itemObject).name : "STILL NULL")));
				}
				if (flag)
				{
					return;
				}
				BenGoop = null;
			}
			try
			{
				ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance;
				if ((Object)(object)instance == (Object)null || (instance.lastLoadedItems.Count == 0 && ((DatabaseAsset<ItemDatabase, Item>)(object)instance).Objects.Count == 0))
				{
					return;
				}
				Item benGoop = default(Item);
				if (ItemDatabase.TryGetItemFromPersistentID(PersistentGuid, ref benGoop))
				{
					BenGoop = benGoop;
					return;
				}
				Item val2 = FindGooBallItem(instance);
				if ((Object)(object)val2 == (Object)null)
				{
					Debug.LogError((object)("[BenGoop] Could not find the GooBall item to clone (database has " + instance.lastLoadedItems.Count + " loaded items)!"));
					return;
				}
				BenGoop = BuildClone(val2);
				((DatabaseAsset<ItemDatabase, Item>)(object)instance).AddRuntimeEntry(BenGoop);
				Debug.Log((object)("[BenGoop] Registered item " + BenGoop.displayName + " with id " + BenGoop.id));
			}
			catch (Exception ex2)
			{
				Debug.LogError((object)("[BenGoop] Failed to register Ben Goop item: " + ex2));
				BenGoop = null;
			}
			if ((Object)(object)BenGoop != (Object)null && pendingSyncedId.HasValue && BenGoop.id != pendingSyncedId.Value)
			{
				Debug.Log((object)("[BenGoop] Applied network-synced item id: " + pendingSyncedId.Value));
				BenGoop.id = pendingSyncedId.Value;
			}
			pendingSyncedId = null;
		}

		private static Item FindGooBallItem(ItemDatabase database)
		{
			foreach (Item lastLoadedItem in database.lastLoadedItems)
			{
				if (!((Object)(object)lastLoadedItem == (Object)null) && !((Object)(object)lastLoadedItem.itemObject == (Object)null) && (Object)(object)lastLoadedItem.itemObject.GetComponentInChildren<ItemGooBall>(true) != (Object)null)
				{
					return lastLoadedItem;
				}
			}
			foreach (Item @object in ((DatabaseAsset<ItemDatabase, Item>)(object)database).Objects)
			{
				if (!((Object)(object)@object == (Object)null) && !((Object)(object)@object.itemObject == (Object)null) && (Object)(object)@object.itemObject.GetComponentInChildren<ItemGooBall>(true) != (Object)null)
				{
					return @object;
				}
			}
			return null;
		}

		private static Item BuildClone(Item source)
		{
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Expected O, but got Unknown
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Expected O, but got Unknown
			GameObject val = BuildPrefab(source);
			Debug.Log((object)("[BenGoop] Clone built: renderers=" + val.GetComponentsInChildren<Renderer>(true).Length + " ItemInstance=" + ((Object)(object)val.GetComponent<ItemInstance>() != (Object)null) + " HandGizmo=" + ((Object)(object)val.GetComponentInChildren<HandGizmo>(true) != (Object)null) + " children=" + val.transform.childCount + " gooBall=" + ((Object)(object)val.GetComponent<ItemGooBall>() != (Object)null)));
			Item obj = Object.Instantiate<Item>(source);
			((Object)obj).name = "ItemBenGoop";
			obj.PersistentID = PersistentGuid;
			obj.displayName = "Ben Goop";
			obj.itemObject = val;
			obj.itemType = (ItemType)1;
			obj.spawnable = false;
			obj.purchasable = false;
			obj.toolBudgetCost = 0;
			obj.budgetCost = 0;
			obj.Tooltips = new List<ItemKeyTooltip>
			{
				new ItemKeyTooltip("{key} Consume", (IMKbPromptProvider)new HardcodedPrompt(ControllerGlyphs.GetSprite(0)), new List<GlyphType> { (GlyphType)2 })
			};
			return obj;
		}

		private static GameObject BuildPrefab(Item source)
		{
			//IL_00e5: 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_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: 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_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(source.itemObject);
			((Object)val).name = "BenGoop";
			Object.DontDestroyOnLoad((Object)(object)val);
			ItemGooBall component = val.GetComponent<ItemGooBall>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			Material val2 = null;
			Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(true);
			Renderer[] array = componentsInChildren;
			foreach (Renderer val3 in array)
			{
				if ((Object)(object)val3 != (Object)null && (Object)(object)val3.sharedMaterial != (Object)null)
				{
					val2 = val3.sharedMaterial;
					break;
				}
			}
			if ((Object)(object)val2 != (Object)null && (Object)(object)val2.shader != (Object)null)
			{
				Debug.Log((object)("[BenGoop] sources shader=" + ((Object)val2.shader).name + " surface=" + val2.GetFloat("_Surface") + " color=" + ((object)val2.GetColor("_BaseColor")/*cast due to .constrained prefix*/).ToString() + " queue=" + val2.renderQueue));
			}
			array = componentsInChildren;
			foreach (Renderer val4 in array)
			{
				if ((Object)(object)val4 != (Object)null)
				{
					Object.Destroy((Object)(object)val4);
				}
			}
			MeshFilter[] componentsInChildren2 = val.GetComponentsInChildren<MeshFilter>(true);
			foreach (MeshFilter val5 in componentsInChildren2)
			{
				if ((Object)(object)val5 != (Object)null)
				{
					Object.Destroy((Object)(object)val5);
				}
			}
			GameObject val6 = new GameObject("BenGoopSlimeMesh");
			val6.transform.SetParent(val.transform, false);
			val6.transform.localPosition = new Vector3(0f, 0.02f, 0f);
			val6.AddComponent<MeshFilter>().sharedMesh = BuildGoopMesh();
			((Renderer)val6.AddComponent<MeshRenderer>()).sharedMaterial = CreateGooMaterial(val2);
			Transform[] componentsInChildren3 = val.GetComponentsInChildren<Transform>(true);
			foreach (Transform val7 in componentsInChildren3)
			{
				if (!((Object)(object)val7 == (Object)null) && !((Object)(object)val7 == (Object)(object)val.transform))
				{
					string name = ((Object)val7).name;
					if (name == "Light" || name == "SFX" || name.StartsWith("SFX", StringComparison.OrdinalIgnoreCase))
					{
						((Component)val7).gameObject.SetActive(false);
					}
				}
			}
			if ((Object)(object)val.GetComponent<ItemInstance>() == (Object)null)
			{
				val.AddComponent<ItemInstance>();
			}
			if ((Object)(object)val.GetComponent<BenGoopBehaviour>() == (Object)null)
			{
				val.AddComponent<BenGoopBehaviour>();
			}
			return val;
		}

		private static Mesh BuildGoopMesh()
		{
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Expected O, but got Unknown
			float num = Random.value * 100f;
			Vector3[] array = (Vector3[])(object)new Vector3[825];
			Vector2[] array2 = (Vector2[])(object)new Vector2[array.Length];
			for (int i = 0; i <= 24; i++)
			{
				float num2 = (float)Math.PI * (float)i / 24f;
				for (int j = 0; j <= 32; j++)
				{
					float num3 = (float)Math.PI * 2f * (float)j / 32f;
					float num4 = Mathf.Sin(num2);
					float num5 = 0.3f * (1f + 0.16f * Mathf.Sin(num2 * 7f + num * 0.31f) * Mathf.Sin(num3 * 5f) + 0.11f * Mathf.Sin(num2 * 11f + num * 0.73f) * Mathf.Sin(num3 * 9f + num) + 0.08f * Mathf.Sin((num2 + num3) * 6f + num * 1.7f));
					int num6 = i * 33 + j;
					array[num6] = new Vector3(num4 * Mathf.Cos(num3) * num5, Mathf.Cos(num2) * num5 * 0.82f, num4 * Mathf.Sin(num3) * num5);
					array2[num6] = new Vector2((float)j / 32f, (float)i / 24f);
				}
			}
			int[] array3 = new int[4608];
			int num7 = 0;
			for (int k = 0; k < 24; k++)
			{
				for (int l = 0; l < 32; l++)
				{
					int num8 = k * 33 + l;
					int num9 = num8 + 32 + 1;
					array3[num7++] = num8 + 1;
					array3[num7++] = num9;
					array3[num7++] = num8;
					array3[num7++] = num9 + 1;
					array3[num7++] = num9;
					array3[num7++] = num8 + 1;
				}
			}
			Mesh val = new Mesh
			{
				name = "BenGoopSlime",
				vertices = array,
				uv = array2,
				triangles = array3
			};
			val.RecalculateNormals();
			val.RecalculateBounds();
			return val;
		}

		private static Material CreateGooMaterial(Material source)
		{
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Expected O, but got Unknown
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: 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_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)source != (Object)null && (Object)(object)source.shader != (Object)null)
			{
				Material val = new Material(source);
				val.SetFloat("_Surface", 0f);
				val.DisableKeyword("_SURFACE_TYPE_TRANSPARENT");
				val.DisableKeyword("_BLENDMODE_ALPHA");
				val.DisableKeyword("_BLENDMODE_PRE_MULTIPLY");
				val.SetFloat("_AlphaClip", 0f);
				val.DisableKeyword("_ALPHATEST_ON");
				val.SetFloat("_Mode", 0f);
				val.DisableKeyword("_ALPHABLEND_ON");
				val.DisableKeyword("_ALPHAPREMULTIPLY_ON");
				val.SetOverrideTag("RenderType", "Opaque");
				val.renderQueue = 2000;
				Color val2 = default(Color);
				((Color)(ref val2))..ctor(0.18f, 0.19f, 0.21f, 1f);
				val.SetColor("_BaseColor", val2);
				val.SetColor("_Color", val2);
				if ((Object)(object)_whiteTex == (Object)null)
				{
					_whiteTex = new Texture2D(1, 1);
					_whiteTex.SetPixel(0, 0, Color.white);
					_whiteTex.Apply();
				}
				val.SetTexture("_BaseMap", (Texture)(object)_whiteTex);
				val.SetTexture("_MainTex", (Texture)(object)_whiteTex);
				val.SetFloat("_Smoothness", 0.25f);
				val.SetFloat("_Glossiness", 0.25f);
				val.SetFloat("_Metallic", 0f);
				val.DisableKeyword("_EMISSION");
				val.SetColor("_EmissionColor", Color.black);
				Debug.Log((object)("[BenGoop] sludge material cloned from " + ((Object)source.shader).name + " opaque, grey, queue=" + val.renderQueue + " alpha=" + val.GetColor("_BaseColor").a));
				return val;
			}
			Shader val3 = Shader.Find("Universal Render Pipeline/Lit");
			if ((Object)(object)val3 != (Object)null)
			{
				Material val4 = new Material(val3);
				val4.SetFloat("_Surface", 0f);
				val4.DisableKeyword("_SURFACE_TYPE_TRANSPARENT");
				val4.SetOverrideTag("RenderType", "Opaque");
				val4.renderQueue = 3000;
				val4.SetFloat("_AlphaClip", 0f);
				val4.DisableKeyword("_ALPHATEST_ON");
				val4.SetColor("_BaseColor", new Color(0.18f, 0.19f, 0.21f, 1f));
				val4.SetFloat("_Smoothness", 0.25f);
				val4.SetFloat("_Metallic", 0f);
				val4.DisableKeyword("_EMISSION");
				val4.SetColor("_EmissionColor", Color.black);
				return val4;
			}
			Material val5 = new Material(Shader.Find("Standard"));
			val5.SetOverrideTag("RenderType", "Opaque");
			val5.renderQueue = 3000;
			val5.SetFloat("_Mode", 0f);
			val5.DisableKeyword("_ALPHATEST_ON");
			val5.DisableKeyword("_ALPHABLEND_ON");
			val5.DisableKeyword("_ALPHAPREMULTIPLY_ON");
			val5.SetColor("_Color", new Color(0.18f, 0.19f, 0.21f, 1f));
			val5.SetFloat("_Glossiness", 0.25f);
			val5.SetFloat("_Metallic", 0f);
			val5.DisableKeyword("_EMISSION");
			return val5;
		}

		public unsafe static string SpawnGoopFromButt(Player monster)
		{
			//IL_00e1: 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_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: 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_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Expected O, but got Unknown
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				EnsureRegistered();
				if ((Object)(object)BenGoop == (Object)null)
				{
					return "Ben Goop not registered yet - can't drop from the Zombe.";
				}
				Item val = default(Item);
				ItemDatabase.TryGetItemFromID(BenGoop.id, ref val);
				if ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)BenGoop)
				{
					EnsureUniqueId();
					ItemDatabase.TryGetItemFromID(BenGoop.id, ref val);
					if ((Object)(object)val != (Object)(object)BenGoop)
					{
						return "Ben Goop id issue - no pickups this zap.";
					}
				}
				if ((Object)(object)monster == (Object)null || monster.refs == null || (Object)(object)monster.refs.ragdoll == (Object)null)
				{
					return "Zombe invalid.";
				}
				Bodypart bodypart = monster.refs.ragdoll.GetBodypart((BodypartType)0);
				if ((Object)(object)bodypart == (Object)null || (Object)(object)bodypart.rig == (Object)null)
				{
					return "Zombe has no hip to spawn from.";
				}
				Vector3 val2 = bodypart.rig.position + new Vector3(0f, -0.05f, 0f) + Random.insideUnitSphere * 0.08f;
				Vector3 val3 = new Vector3(0f, 1.4f, 0f) + Random.insideUnitSphere * 0.9f;
				PickupHandler.CreatePickup(BenGoop.id, new ItemInstanceData(Guid.NewGuid()), val2, Random.rotation, val3, Random.onUnitSphere * 3f);
				Vector3 val4 = val2;
				Debug.Log((object)("[BenGoop] Shocked Zombe dropped a Ben Goop from its butt at " + ((object)(*(Vector3*)(&val4))/*cast due to .constrained prefix*/).ToString()));
				return "The Zombe pooped a Ben Goop! go pick it up!";
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[BenGoop] SpawnGoopFromButt failed: " + ex));
				return null;
			}
		}

		private static void RebuildPrefab()
		{
			try
			{
				ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance;
				if (!((Object)(object)instance == (Object)null))
				{
					Item val = FindGooBallItem(instance);
					if ((Object)(object)val == (Object)null)
					{
						Debug.LogError((object)"[BenGoop] RebuildPrefab could not find the GooBall item");
					}
					else
					{
						BenGoop.itemObject = BuildPrefab(val);
					}
				}
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[BenGoop] RebuildPrefab failed: " + ex));
			}
		}

		public static string SpawnGoop()
		{
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Expected O, but got Unknown
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Expected O, but got Unknown
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				EnsureRegistered();
				if ((Object)(object)BenGoop == (Object)null)
				{
					int num = 0;
					int num2 = 0;
					try
					{
						ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance;
						if ((Object)(object)instance != (Object)null)
						{
							num = instance.lastLoadedItems.Count;
							num2 = ((DatabaseAsset<ItemDatabase, Item>)(object)instance).Objects.Count;
						}
					}
					catch
					{
					}
					return "Ben Goop not ready yet (item DB has " + num + " / " + num2 + " entries). Waiting to auto-register...";
				}
				Player localPlayer = Player.localPlayer;
				if ((Object)(object)localPlayer == (Object)null)
				{
					return "Ben Goop: no local player yet.";
				}
				if (localPlayer.data == null || localPlayer.refs == null || (Object)(object)localPlayer.refs.headPos == (Object)null)
				{
					return "Ben Goop: player not ready yet.";
				}
				if (!PhotonNetwork.InRoom)
				{
					return "Ben Goop: you must be in a world first (join or start a dive), then press F5.";
				}
				Vector3 val = localPlayer.refs.headPos.position + localPlayer.data.lookDirection * 1.5f;
				val.y = headerHeight(val, localPlayer);
				Item val2 = default(Item);
				ItemDatabase.TryGetItemFromID(BenGoop.id, ref val2);
				Debug.Log((object)("[BenGoop] spawn id=" + BenGoop.id + " itemObject=" + (((Object)(object)BenGoop.itemObject != (Object)null) ? ((Object)BenGoop.itemObject).name : "NULL") + " lookup=" + (((Object)(object)val2 != (Object)null) ? ((Object)val2).name : "NULL") + " lookupItemObject=" + (((Object)(object)val2 != (Object)null && (Object)(object)val2.itemObject != (Object)null) ? ((Object)val2.itemObject).name : "NULL")));
				if ((Object)(object)val2 != (Object)null && (Object)(object)val2 != (Object)(object)BenGoop)
				{
					Debug.LogWarning((object)("[BenGoop] Item id " + BenGoop.id + " collides with '" + ((Object)val2).name + "', remapping..."));
					EnsureUniqueId();
				}
				ItemInstanceData val3 = new ItemInstanceData(Guid.NewGuid());
				if (PhotonNetwork.IsMasterClient)
				{
					byte[] array = val3.Serialize(true);
					ItemInstanceData val4 = new ItemInstanceData(Guid.Empty);
					val4.Deserialize(array);
					PickupHandler.CreatePickup(BenGoop.id, val4, val, Quaternion.identity);
				}
				else
				{
					localPlayer.RequestCreatePickup(BenGoop, val3, val, Quaternion.identity);
				}
				if ((Object)(object)MainCamera.instance != (Object)null)
				{
					MainCamera.instance.Flick();
				}
				return "Ben Goop dropped in front of you. Pick it up, then click to eat it!";
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[BenGoop] SpawnGoop failed: " + ex));
				for (Exception innerException = ex.InnerException; innerException != null; innerException = innerException.InnerException)
				{
					Debug.LogError((object)("[BenGoop]   inner: " + innerException));
				}
				return "Ben Goop spawn failed: " + ex;
			}
		}

		private static float headerHeight(Vector3 pos, Player player)
		{
			//IL_000b: 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)
			float num = player.refs.headPos.position.y - 1.1f;
			return Mathf.Max(pos.y, num);
		}

		private static void EnsureUniqueId()
		{
			if ((Object)(object)BenGoop == (Object)null)
			{
				return;
			}
			try
			{
				ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance;
				if ((Object)(object)instance == (Object)null)
				{
					return;
				}
				HashSet<int> hashSet = new HashSet<int>();
				foreach (Item @object in ((DatabaseAsset<ItemDatabase, Item>)(object)instance).Objects)
				{
					if ((Object)(object)@object != (Object)null)
					{
						hashSet.Add(@object.id);
					}
				}
				if (!hashSet.Contains(BenGoop.id))
				{
					return;
				}
				for (int i = 1; i < 255; i++)
				{
					if (!hashSet.Contains(i))
					{
						int id = BenGoop.id;
						BenGoop.id = (byte)i;
						Debug.Log((object)("[BenGoop] Reassigned item id " + id + " -> " + i));
						return;
					}
				}
				Debug.LogError((object)"[BenGoop] No free item id available (all 255 taken)");
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[BenGoop] EnsureUniqueId failed: " + ex));
			}
		}
	}
	public class BenGoopBehaviour : ItemInstanceBehaviour
	{
		private bool eaten;

		public override void ConfigItem(ItemInstanceData data, PhotonView playerView)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			try
			{
				StashAbleEntry val = default(StashAbleEntry);
				if (!data.TryGetEntry<StashAbleEntry>(ref val))
				{
					data.AddDataEntry((ItemDataEntry)new StashAbleEntry
					{
						isStashAble = true
					});
				}
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[BenGoop] ConfigItem entry setup failed: " + ex.Message));
			}
		}

		private void Update()
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (eaten)
				{
					return;
				}
				Player localPlayer = Player.localPlayer;
				PlayerInventory val = default(PlayerInventory);
				if ((Object)(object)localPlayer == (Object)null || localPlayer.data == null || (!((Object)(object)localPlayer.data.currentItem == (Object)(object)base.itemInstance) && !base.isHeldByMe) || localPlayer.HasLockedInput() || !localPlayer.input.clickWasPressed || !localPlayer.TryGetInventory(ref val))
				{
					return;
				}
				int selectedItemSlot = localPlayer.data.selectedItemSlot;
				ItemDescriptor val2 = default(ItemDescriptor);
				if (val.TryGetItemInSlot(selectedItemSlot, ref val2) && !((Object)(object)val2.item != (Object)(object)base.itemInstance.item))
				{
					eaten = true;
					ItemDescriptor val3 = default(ItemDescriptor);
					if (val.TryRemoveItemFromSlot(selectedItemSlot, ref val3))
					{
						Debug.Log((object)"[BenGoop] You ate the Ben Goop. Welcome to the trip.");
						TripEffect.StartTrip(localPlayer);
						BenGoopPlugin.Trip?.AddStumble();
					}
					else
					{
						eaten = false;
						Debug.LogWarning((object)("[BenGoop] Could not remove the Ben Goop from slot " + selectedItemSlot));
					}
				}
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[BenGoop] BenGoopBehaviour update failed: " + ex));
			}
		}
	}
	[BepInPlugin("BenContentWarning.BenGoop", "Ben Goop", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[ContentWarningPlugin("BenContentWarning.BenGoop", "1.0.1", false)]
	public class BenGoopPlugin : BaseUnityPlugin
	{
		public const uint ModId = 3910472083u;

		private static Harmony? _harmony;

		private KeyCode spawnKey = (KeyCode)286;

		private KeyCode testKey = (KeyCode)288;

		private static string statusText = "";

		private static float statusShownAt;

		public static BenGoopPlugin? Instance { get; private set; }

		public static TripEffect? Trip { get; private set; }

		private void Awake()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_00be: 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)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			Trip = new GameObject("BenGoopTrip").AddComponent<TripEffect>();
			Object.DontDestroyOnLoad((Object)(object)((Component)Trip).gameObject);
			GoopItemRegistry.Configure(((Component)this).gameObject);
			MyceliumNetwork.RegisterNetworkObject((object)this, 3910472083u, 0);
			try
			{
				_harmony = new Harmony("BenContentWarning.BenGoop.ShockGoop");
				_harmony.PatchAll();
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Harmony patches applied (Zombe shock stick goop).");
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Harmony patch failed: " + ex));
			}
			if (Enum.TryParse<KeyCode>(((BaseUnityPlugin)this).Config.Bind<string>("General", "SpawnKey", "F5", "Key that spawns a Ben Goop in front of the player.").Value, out KeyCode result))
			{
				spawnKey = result;
			}
			if (Enum.TryParse<KeyCode>(((BaseUnityPlugin)this).Config.Bind<string>("General", "TestKey", "F7", "Key that instantly starts the trip effect (testing).").Value, out KeyCode result2))
			{
				testKey = result2;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Ben Goop loaded! Press " + ((object)Unsafe.As<KeyCode, KeyCode>(ref spawnKey)/*cast due to .constrained prefix*/).ToString() + " to spawn a Ben Goop, " + ((object)Unsafe.As<KeyCode, KeyCode>(ref testKey)/*cast due to .constrained prefix*/).ToString() + " to instantly trip."));
		}

		private void OnDestroy()
		{
			MyceliumNetwork.DeregisterNetworkObject((object)this, 3910472083u, 0);
		}

		private void OnGUI()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_0050: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			if (!string.IsNullOrEmpty(statusText))
			{
				if (Time.realtimeSinceStartup - statusShownAt > 4f)
				{
					statusText = "";
					return;
				}
				GUIStyle val = new GUIStyle(GUI.skin.label)
				{
					fontSize = 20,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)4
				};
				val.normal.textColor = Color.yellow;
				GUI.Label(new Rect(((float)Screen.width - 720f) / 2f, (float)Screen.height * 0.34f, 720f, 40f), statusText, val);
			}
		}

		private void Update()
		{
			//IL_0001: 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)
			if (Input.GetKeyDown(spawnKey))
			{
				ShowToast(GoopItemFactory.SpawnGoop());
			}
			if (Input.GetKeyDown(testKey))
			{
				if ((Object)(object)Trip != (Object)null)
				{
					Trip.TestTrip();
				}
				else
				{
					ShowToast("Ben Goop plugin init failed (Trip is null).");
				}
			}
		}

		public static void ShowToast(string message)
		{
			statusText = message;
			statusShownAt = Time.realtimeSinceStartup;
			Debug.Log((object)("[BenGoop] " + message));
		}

		[CustomRPC]
		public void NotifyTripStarted(int trippingViewId, RPCInfo info)
		{
			if (PhotonNetwork.IsMasterClient && (Object)(object)Trip != (Object)null)
			{
				Trip.StartSpawningFor(trippingViewId);
			}
		}

		[CustomRPC]
		public void SyncBenGoopItem(string guid, byte itemId, RPCInfo info)
		{
			GoopItemFactory.ApplySyncedRegistration(guid, itemId);
		}

		[CustomRPC]
		public void NotifyTripStopped(int trippingViewId, RPCInfo info)
		{
			if (PhotonNetwork.IsMasterClient && (Object)(object)Trip != (Object)null)
			{
				Trip.StopSpawningFor(trippingViewId);
			}
		}

		internal static void HandleTasedZombe(PlayerRagdoll ragdoll)
		{
			try
			{
				if ((Object)(object)ragdoll == (Object)null || !PhotonNetwork.IsMasterClient)
				{
					return;
				}
				Player componentInParent = ((Component)ragdoll).GetComponentInParent<Player>();
				if (!((Object)(object)componentInParent == (Object)null) && componentInParent.ai && ((Object)componentInParent).name.Contains("Zombe", StringComparison.OrdinalIgnoreCase))
				{
					string text = GoopItemFactory.SpawnGoopFromButt(componentInParent);
					if (!string.IsNullOrEmpty(text))
					{
						Debug.Log((object)("[BenGoop] " + text));
					}
				}
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[BenGoop] HandleTasedZombe failed: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(PlayerRagdoll), "TaseShock")]
	internal static class Patch_ZombeShockGoop
	{
		private static void Postfix(PlayerRagdoll __instance)
		{
			try
			{
				BenGoopPlugin.HandleTasedZombe(__instance);
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[BenGoop] TaseShock postfix failed: " + ex));
			}
		}
	}
	public class TripEffect : MonoBehaviour
	{
		public float Duration = 300f;

		private const float OutroDuration = 6f;

		private const float MediaFadeTime = 8f;

		private const float MasterGhostInterval = 2f;

		private const int MaxGhosts = 4;

		private static TripEffect? _instance;

		internal static readonly List<AudioClip> ZombeVoices = new List<AudioClip>();

		private bool _localTripping;

		private Player? _tripper;

		private float _startTime;

		private float _baseFov;

		private AudioSource? _tripVoiceSource;

		private float _nextTripVoice;

		private Volume? _volume;

		private ChromaticAberration? _chromatic;

		private LensDistortion? _lensDist;

		private Vignette? _vignette;

		private ColorAdjustments? _color;

		private FilmGrain? _grain;

		private SplitToning? _splitTone;

		private ChannelMixer? _channelMixer;

		private WhiteBalance? _whiteBalance;

		private LiftGammaGain? _liftGammaGain;

		private float _nextShake;

		private float _nextSpike;

		private float _nextStumble;

		private float _nextSlam = 6f;

		private float _lastVisualSlam = -10f;

		private float _spikeRoll;

		private float _spikeRollTime;

		private float _nextGhostSpawn = 1f;

		private float _nextKillOldest;

		private VideoPlayer? _videoPlayer;

		private RenderTexture? _videoRT;

		private AudioSource? _musicSource;

		private AudioClip? _musicClip;

		private string? _assetsDir;

		private RenderTexture? _afterImageRT;

		private int _afterImageW;

		private int _afterImageH;

		private float _nextAfterImage;

		private RenderTexture? _afterImageRT2;

		private int _afterImageW2;

		private int _afterImageH2;

		private float _nextAfterImage2;

		public static int ActiveGhosts { get; private set; }

		public static bool LocalTripping
		{
			get
			{
				if ((Object)(object)_instance != (Object)null)
				{
					return _instance._localTripping;
				}
				return false;
			}
		}

		internal static void RegisterZombeVoices(IEnumerable<AudioClip> clips)
		{
			if (clips == null)
			{
				return;
			}
			foreach (AudioClip clip in clips)
			{
				if ((Object)(object)clip != (Object)null && !ZombeVoices.Contains(clip))
				{
					ZombeVoices.Add(clip);
				}
			}
		}

		public static void GhostSpawned()
		{
			ActiveGhosts++;
		}

		public static void GhostDespawned()
		{
			if (ActiveGhosts > 0)
			{
				ActiveGhosts--;
			}
		}

		private void Awake()
		{
			_instance = this;
			RenderPipelineManager.endCameraRendering += OnEndCameraRendering;
			PreloadMedia();
		}

		private void PreloadMedia()
		{
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Expected O, but got Unknown
			try
			{
				VideoPlayer[] components = ((Component)this).gameObject.GetComponents<VideoPlayer>();
				foreach (VideoPlayer val in components)
				{
					if ((Object)(object)_videoPlayer == (Object)null)
					{
						_videoPlayer = val;
					}
					else
					{
						Object.Destroy((Object)(object)val);
					}
				}
				AudioSource[] components2 = ((Component)this).gameObject.GetComponents<AudioSource>();
				foreach (AudioSource val2 in components2)
				{
					if ((Object)(object)_musicSource == (Object)null && (Object)(object)val2.clip == (Object)null)
					{
						_musicSource = val2;
					}
					else if ((Object)(object)_musicSource != (Object)(object)val2)
					{
						Object.Destroy((Object)(object)val2);
					}
				}
				string text = AssetsDir();
				if (!string.IsNullOrEmpty(text))
				{
					string text2 = Path.Combine(text, "Drugs.mp4");
					if (File.Exists(text2) && (Object)(object)_videoPlayer == (Object)null)
					{
						_videoPlayer = ((Component)this).gameObject.AddComponent<VideoPlayer>();
						_videoPlayer.playOnAwake = false;
						_videoPlayer.isLooping = true;
						_videoPlayer.audioOutputMode = (VideoAudioOutputMode)0;
						_videoPlayer.renderMode = (VideoRenderMode)2;
						_videoPlayer.prepareCompleted += new EventHandler(OnVideoPrepared);
						_videoPlayer.url = "file:///" + text2.Replace('\\', '/');
						_videoPlayer.Prepare();
						Debug.Log((object)"[BenGoop] Preloading Drugs.mp4 (decoded in the menu, so the trip starts smoothly)");
					}
					string path = Path.Combine(text, "TrippingMusic.mp3");
					if ((Object)(object)_musicClip == (Object)null && File.Exists(path))
					{
						((MonoBehaviour)this).StartCoroutine(PreloadMusic(path));
					}
				}
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[BenGoop] Trip media preload failed: " + ex));
			}
		}

		private void OnDestroy()
		{
			RenderPipelineManager.endCameraRendering -= OnEndCameraRendering;
			if ((Object)(object)_afterImageRT != (Object)null)
			{
				_afterImageRT.Release();
				_afterImageRT = null;
			}
			if ((Object)(object)_afterImageRT2 != (Object)null)
			{
				_afterImageRT2.Release();
				_afterImageRT2 = null;
			}
			if ((Object)(object)_videoRT != (Object)null)
			{
				_videoRT.Release();
				_videoRT = null;
			}
			_instance = null;
		}

		public static void StartTrip(Player player)
		{
			if (!((Object)(object)_instance == (Object)null) && !((Object)(object)player == (Object)null))
			{
				_instance.BeginLocalTrip(player);
				if (PhotonNetwork.InRoom)
				{
					MyceliumNetwork.RPC(3910472083u, "NotifyTripStarted", (ReliableType)1, new object[1] { player.refs.view.ViewID });
				}
			}
		}

		public void TestTrip()
		{
			Player localPlayer = Player.localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				BenGoopPlugin.ShowToast("Ben Goop: no local player yet.");
				return;
			}
			StartTrip(localPlayer);
			AddStumble();
			BenGoopPlugin.ShowToast("TRIPPING (test) - effects on for ~" + (int)Duration + "s");
		}

		private void BeginLocalTrip(Player player)
		{
			_tripper = player;
			_startTime = Time.time;
			_localTripping = true;
			_nextShake = Time.time + 4f;
			_nextSpike = Time.time + 8f;
			_nextStumble = Time.time + 5f;
			_nextGhostSpawn = Time.time + 1.5f;
			_nextKillOldest = Time.time + 10f;
			_nextAfterImage = Time.time;
			_nextAfterImage2 = Time.time;
			SetupVolume();
			StartMedia();
			if ((Object)(object)MainCamera.instance != (Object)null)
			{
				_baseFov = MainCamera.instance.baseFOV;
			}
		}

		private string? AssetsDir()
		{
			if (_assetsDir != null)
			{
				return _assetsDir;
			}
			try
			{
				string location = typeof(BenGoopPlugin).Assembly.Location;
				_assetsDir = (string.IsNullOrEmpty(location) ? "" : (Path.GetDirectoryName(location) ?? ""));
			}
			catch
			{
				_assetsDir = "";
			}
			return _assetsDir;
		}

		private void StartMedia()
		{
			string text = AssetsDir();
			if (string.IsNullOrEmpty(text))
			{
				Debug.LogWarning((object)"[BenGoop] Could not resolve plugin dir - skipping trip media");
				return;
			}
			StartVideo(Path.Combine(text, "Drugs.mp4"));
			string path = Path.Combine(text, "TrippingMusic.mp3");
			if ((Object)(object)_musicClip != (Object)null)
			{
				EnsureMusicSource();
				_musicSource.clip = _musicClip;
				_musicSource.Play();
				Debug.Log((object)"[BenGoop] TrippingMusic started (cached)");
			}
			else if (File.Exists(path))
			{
				((MonoBehaviour)this).StartCoroutine(LoadMusic(path));
			}
		}

		private void StartVideo(string path)
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			try
			{
				if (!File.Exists(path))
				{
					Debug.LogWarning((object)("[BenGoop] Missing Drugs.mp4 next to BenGoop.dll (" + path + ")"));
					return;
				}
				if ((Object)(object)_videoPlayer == (Object)null)
				{
					_videoPlayer = ((Component)this).gameObject.AddComponent<VideoPlayer>();
					_videoPlayer.playOnAwake = false;
					_videoPlayer.isLooping = true;
					_videoPlayer.audioOutputMode = (VideoAudioOutputMode)0;
					_videoPlayer.renderMode = (VideoRenderMode)2;
					_videoPlayer.prepareCompleted += new EventHandler(OnVideoPrepared);
				}
				_videoPlayer.url = "file:///" + path.Replace('\\', '/');
				if (_videoPlayer.isPrepared)
				{
					EnsureVideoTexture();
				}
				else
				{
					_videoPlayer.Prepare();
				}
				_videoPlayer.Play();
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[BenGoop] Video start failed: " + ex));
			}
		}

		private void OnVideoPrepared(VideoPlayer vp)
		{
			try
			{
				Debug.Log((object)("[BenGoop] Drugs.mp4 prepared (" + vp.length.ToString("F1") + "s) - trip stays " + Duration.ToString("F0") + "s"));
				EnsureVideoTexture();
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[BenGoop] Video prepare failed: " + ex));
			}
		}

		private void EnsureVideoTexture()
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			if ((Object)(object)_videoPlayer == (Object)null)
			{
				return;
			}
			int num = (int)((_videoPlayer.width != 0) ? _videoPlayer.width : 1280);
			int num2 = (int)((_videoPlayer.height != 0) ? _videoPlayer.height : 720);
			if ((Object)(object)_videoRT == (Object)null || ((Texture)_videoRT).width != num || ((Texture)_videoRT).height != num2)
			{
				if ((Object)(object)_videoRT != (Object)null)
				{
					_videoRT.Release();
				}
				_videoRT = new RenderTexture(num, num2, 0, (RenderTextureFormat)0);
				((Object)_videoRT).name = "BenGoop Drugs";
			}
			_videoPlayer.targetTexture = _videoRT;
		}

		private IEnumerator LoadMusic(string path)
		{
			IEnumerator e = LoadMusicClip(path, autoplay: true);
			while (e.MoveNext())
			{
				yield return e.Current;
			}
		}

		private IEnumerator PreloadMusic(string path)
		{
			IEnumerator e = LoadMusicClip(path, autoplay: false);
			while (e.MoveNext())
			{
				yield return e.Current;
			}
		}

		private IEnumerator LoadMusicClip(string path, bool autoplay)
		{
			UnityWebRequest uwr = UnityWebRequestMultimedia.GetAudioClip("file:///" + path.Replace('\\', '/'), (AudioType)13);
			try
			{
				uwr.SendWebRequest();
				while (!uwr.isDone)
				{
					yield return null;
				}
				if ((int)uwr.result != 1)
				{
					Debug.LogWarning((object)("[BenGoop] Music load failed: " + uwr.error));
					yield break;
				}
				_musicClip = DownloadHandlerAudioClip.GetContent(uwr);
				if (autoplay)
				{
					EnsureMusicSource();
					_musicSource.clip = _musicClip;
					_musicSource.Play();
					Debug.Log((object)"[BenGoop] TrippingMusic started");
				}
				else
				{
					Debug.Log((object)"[BenGoop] TrippingMusic preloaded (cached for the trip)");
				}
			}
			finally
			{
				((IDisposable)uwr)?.Dispose();
			}
		}

		private void EnsureMusicSource()
		{
			if (!((Object)(object)_musicSource != (Object)null))
			{
				_musicSource = ((Component)this).gameObject.AddComponent<AudioSource>();
				_musicSource.spatialBlend = 0f;
				_musicSource.loop = true;
				_musicSource.playOnAwake = false;
				_musicSource.volume = 0.8f;
			}
		}

		public void StartSpawningFor(int trippingViewId)
		{
		}

		public void StopSpawningFor(int trippingViewId)
		{
		}

		private void Update()
		{
			UpdateLocalGhostSpawner();
			if (!_localTripping)
			{
				return;
			}
			float num = Time.time - _startTime;
			float power;
			if (num < Duration)
			{
				float num2 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(num / (Duration * 0.18f)));
				float num3 = 1f - Mathf.SmoothStep(0f, 1f, Mathf.Clamp01((num - Duration * 0.7f) / (Duration * 0.3f)));
				power = Mathf.Pow(num2 * num3, 1.35f);
			}
			else
			{
				if (!(num < Duration + 6f))
				{
					EndTrip();
					return;
				}
				power = 0.35f * Mathf.Lerp(1f, 0f, (num - Duration) / 6f);
			}
			if ((Object)(object)_tripper == (Object)null || _tripper.data == null || _tripper.data.dead)
			{
				EndTrip();
				return;
			}
			UpdateDistortion(power);
			UpdateRandomEvents(power);
			UpdateTripVoice(num);
		}

		private void UpdateTripVoice(float elapsed)
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//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)
			if (Time.time < _nextTripVoice)
			{
				return;
			}
			_nextTripVoice = Time.time + Random.Range(3f, 9f);
			if (ZombeVoices.Count == 0)
			{
				return;
			}
			Player tripper = _tripper;
			if ((Object)(object)tripper == (Object)null || tripper.refs == null || (Object)(object)tripper.refs.headPos == (Object)null)
			{
				return;
			}
			EnsureTripVoiceSource();
			try
			{
				((Component)_tripVoiceSource).transform.position = tripper.refs.headPos.position + Random.onUnitSphere * Random.Range(3f, 11f);
				_tripVoiceSource.clip = ZombeVoices[Random.Range(0, ZombeVoices.Count)];
				_tripVoiceSource.pitch = Random.Range(0.8f, 1.2f);
				_tripVoiceSource.Play();
			}
			catch
			{
			}
		}

		private void EnsureTripVoiceSource()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			if (!((Object)(object)_tripVoiceSource != (Object)null))
			{
				GameObject val = new GameObject("BenGoopTripVoice");
				_tripVoiceSource = val.AddComponent<AudioSource>();
				_tripVoiceSource.spatialBlend = 1f;
				_tripVoiceSource.playOnAwake = false;
				_tripVoiceSource.volume = 0.85f;
				_tripVoiceSource.minDistance = 1f;
				_tripVoiceSource.maxDistance = 45f;
				AudioEchoFilter obj = val.AddComponent<AudioEchoFilter>();
				obj.delay = 0.4f;
				obj.decayRatio = 0.45f;
				obj.dryMix = 0.85f;
				obj.wetMix = 0.55f;
			}
		}

		private void LateUpdate()
		{
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: 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)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			if (!_localTripping)
			{
				return;
			}
			Camera val = (((Object)(object)MainCamera.instance != (Object)null) ? MainCamera.instance.cam : null);
			if ((Object)(object)val != (Object)null)
			{
				float num = _baseFov * (1f + 0.16f * GetCurrentPower() * Mathf.Sin(Time.time * 2.7f));
				val.fieldOfView = Mathf.Lerp(val.fieldOfView, num, Time.deltaTime * 6f);
			}
			if ((Object)(object)MainCamera.instance != (Object)null)
			{
				float currentPower = GetCurrentPower();
				float num2 = Mathf.Sin(Time.time * 1.6f) * 4.5f * currentPower;
				if (Time.time >= _nextSpike && currentPower > 0.4f)
				{
					_spikeRoll = ((Random.value < 0.5f) ? (-1f) : 1f) * Random.Range(80f, 170f);
					_spikeRollTime = Time.time;
					_nextSpike = Time.time + Random.Range(10f, 22f);
				}
				if (Time.time - _spikeRollTime < 0.9f)
				{
					num2 += _spikeRoll * Mathf.Sin((Time.time - _spikeRollTime) / 0.9f * (float)Math.PI);
				}
				Transform transform = ((Component)MainCamera.instance).transform;
				transform.rotation *= Quaternion.Euler(0f, 0f, num2);
				float num3 = 0.06f * currentPower;
				Transform transform2 = ((Component)MainCamera.instance).transform;
				transform2.position += ((Component)MainCamera.instance).transform.right * Mathf.Sin(Time.time * 0.31f) * num3;
				Transform transform3 = ((Component)MainCamera.instance).transform;
				transform3.position += ((Component)MainCamera.instance).transform.up * Mathf.Sin(Time.time * 0.47f + 1.3f) * num3 * 0.6f;
			}
		}

		private float GetCurrentPower()
		{
			if (!_localTripping)
			{
				return 0f;
			}
			float num = Time.time - _startTime;
			if (num < Duration)
			{
				float num2 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(num / (Duration * 0.18f)));
				float num3 = 1f - Mathf.SmoothStep(0f, 1f, Mathf.Clamp01((num - Duration * 0.7f) / (Duration * 0.3f)));
				return Mathf.Pow(num2 * num3, 1.35f);
			}
			if (num < Duration + 6f)
			{
				return 0.35f * Mathf.Lerp(1f, 0f, (num - Duration) / 6f);
			}
			return 0f;
		}

		private void SetupVolume()
		{
			Camera val = (((Object)(object)MainCamera.instance != (Object)null) ? MainCamera.instance.cam : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			if ((Object)(object)_volume == (Object)null)
			{
				_volume = ((Component)val).GetComponent<Volume>() ?? ((Component)val).gameObject.AddComponent<Volume>();
				_volume.isGlobal = true;
				_volume.priority = 1000f;
				if ((Object)(object)_volume.profile == (Object)null)
				{
					_volume.profile = ScriptableObject.CreateInstance<VolumeProfile>();
				}
				try
				{
					_chromatic = _volume.profile.Add<ChromaticAberration>(true);
				}
				catch
				{
					_chromatic = null;
				}
				try
				{
					_lensDist = _volume.profile.Add<LensDistortion>(true);
				}
				catch
				{
					_lensDist = null;
				}
				try
				{
					_vignette = _volume.profile.Add<Vignette>(true);
				}
				catch
				{
					_vignette = null;
				}
				try
				{
					_color = _volume.profile.Add<ColorAdjustments>(true);
				}
				catch
				{
					_color = null;
				}
				try
				{
					_grain = _volume.profile.Add<FilmGrain>(true);
				}
				catch
				{
					_grain = null;
				}
				try
				{
					_splitTone = _volume.profile.Add<SplitToning>(true);
				}
				catch
				{
					_splitTone = null;
				}
				try
				{
					_channelMixer = _volume.profile.Add<ChannelMixer>(true);
				}
				catch
				{
					_channelMixer = null;
				}
				try
				{
					_whiteBalance = _volume.profile.Add<WhiteBalance>(true);
				}
				catch
				{
					_whiteBalance = null;
				}
				try
				{
					_liftGammaGain = _volume.profile.Add<LiftGammaGain>(true);
				}
				catch
				{
					_liftGammaGain = null;
				}
			}
			if ((Object)(object)_volume != (Object)null)
			{
				((Behaviour)_volume).enabled = true;
			}
		}

		private void UpdateDistortion(float power)
		{
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_054c: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b8: Unknown result type (might be due to invalid IL or missing references)
			float time = Time.time;
			float num = Mathf.Sin(time * 0.37f);
			float num2 = Mathf.Sin(time * 1.19f);
			float num3 = Mathf.Sin(time * 0.73f + 1.7f);
			float num4 = Mathf.Sin(time * 2.11f);
			float num5 = Mathf.Sin(time * 0.23f);
			float num6 = (num + num2 + num4) / 3f;
			if ((Object)(object)_chromatic != (Object)null)
			{
				float num7 = Mathf.Sin(time * 7f);
				float num8 = 0f;
				if (time >= _lastVisualSlam && time - _lastVisualSlam < 0.35f)
				{
					num8 = 0.8f;
				}
				((VolumeParameter<float>)(object)_chromatic.intensity).Override((0.08f + 0.65f * power * (0.55f + 0.45f * num7) + num8 * 0.6f * power) * (1f + Mathf.Abs(num2) * 0.4f));
			}
			if ((Object)(object)_lensDist != (Object)null)
			{
				float num9 = num3 * (0.65f + 0.35f * num2);
				float num10 = 0f;
				if (time >= _lastVisualSlam && time - _lastVisualSlam < 0.5f)
				{
					num10 = -0.55f;
				}
				((VolumeParameter<float>)(object)_lensDist.intensity).Override((0.22f + 0.85f * power * Mathf.Abs(num9)) * Mathf.Sign(num9) + num10 * power);
				((VolumeParameter<float>)(object)_lensDist.scale).Override(1f + 0.35f * power * Mathf.Sin(time * 0.9f + num4) + 0.1f * power);
			}
			if ((Object)(object)_vignette != (Object)null)
			{
				float num11 = 0.5f + 0.5f * Mathf.Sin(time * 0.8f);
				((VolumeParameter<float>)(object)_vignette.intensity).Override(0.55f * power + 0.5f * power * num11 + 0.12f * power * (1f + num6));
				((VolumeParameter<float>)(object)_vignette.smoothness).Override(0.55f + 0.3f * power);
			}
			if ((Object)(object)_color != (Object)null)
			{
				float num12 = num3 * 75f * power + num5 * 45f * power + time * 6f * power;
				float num13 = 1f + 1.1f * power * (0.6f + 0.4f * num);
				((VolumeParameter<float>)(object)_color.hueShift).Override(num12);
				((VolumeParameter<float>)(object)_color.saturation).Override(num13);
				((VolumeParameter<float>)(object)_color.contrast).Override(1.12f + 0.22f * power + 0.1f * power * num4);
				((VolumeParameter<float>)(object)_color.postExposure).Override(0.35f * power * (0.5f + 0.5f * num2));
			}
			if ((Object)(object)_splitTone != (Object)null)
			{
				Color val = Color.Lerp(new Color(0.3f, 0.9f, 1f), new Color(1f, 0.3f, 0.8f), 0.5f + 0.5f * num3);
				Color val2 = Color.Lerp(new Color(1f, 0.85f, 0.3f), new Color(0.8f, 0.4f, 1f), 0.5f + 0.5f * num);
				((VolumeParameter<Color>)(object)_splitTone.shadows).Override(val * power);
				((VolumeParameter<Color>)(object)_splitTone.highlights).Override(val2 * power);
				((VolumeParameter<float>)(object)_splitTone.balance).Override(0.3f * power * num4);
			}
			if ((Object)(object)_channelMixer != (Object)null)
			{
				((VolumeParameter<float>)(object)_channelMixer.redOutGreenIn).Override(0.28f * power * (0.5f + 0.5f * num2));
				((VolumeParameter<float>)(object)_channelMixer.redOutBlueIn).Override(0.35f * power * (0.5f + 0.5f * num4));
				((VolumeParameter<float>)(object)_channelMixer.greenOutRedIn).Override(0.22f * power * (0.5f + 0.5f * num3));
				((VolumeParameter<float>)(object)_channelMixer.greenOutBlueIn).Override(0.25f * power * (0.5f + 0.5f * num));
				((VolumeParameter<float>)(object)_channelMixer.blueOutRedIn).Override(0.3f * power * (0.5f + 0.5f * num5));
				((VolumeParameter<float>)(object)_channelMixer.blueOutGreenIn).Override(0.3f * power * (0.5f + 0.5f * num2));
			}
			if ((Object)(object)_whiteBalance != (Object)null)
			{
				((VolumeParameter<float>)(object)_whiteBalance.temperature).Override(18f * power * (0.5f + 0.5f * num3));
				((VolumeParameter<float>)(object)_whiteBalance.tint).Override(22f * power * (0.5f + 0.5f * num));
			}
			if ((Object)(object)_liftGammaGain != (Object)null)
			{
				((VolumeParameter<Vector4>)(object)_liftGammaGain.lift).Override(new Vector4(0.04f * power * (0.5f + 0.5f * num5), -0.02f * power * (0.5f + 0.5f * num2), 0.05f * power * (0.5f + 0.5f * num3), 0f));
				((VolumeParameter<Vector4>)(object)_liftGammaGain.gain).Override(new Vector4(1.02f + 0.06f * power * (0.5f + 0.5f * num4), 1.02f + 0.06f * power * (0.5f + 0.5f * num), 1.02f + 0.05f * power * (0.5f + 0.5f * num2), 1f));
			}
			if ((Object)(object)_grain != (Object)null)
			{
				((VolumeParameter<float>)(object)_grain.intensity).Override(0.4f * power + 0.25f * power * (1f - num6));
				((VolumeParameter<float>)(object)_grain.response).Override(0.6f + power * (1f + num));
			}
		}

		private void UpdateRandomEvents(float power)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (power > 0.45f && Time.time > _nextShake)
			{
				try
				{
					if ((Object)(object)GamefeelHandler.instance != (Object)null)
					{
						GamefeelHandler.instance.perlin.AddShake(((Component)MainCamera.instance).transform.position, 0.3f + Random.value * 0.5f, 0.25f, 15f, 50f);
					}
				}
				catch
				{
				}
				_nextShake = Time.time + Random.Range(2.5f, 6f);
			}
			if (power > 0.5f && Time.time > _nextStumble)
			{
				AddStumble();
				_nextStumble = Time.time + Random.Range(4f, 9f);
			}
			if (power > 0.55f && Time.time > _nextSlam)
			{
				_lastVisualSlam = Time.time;
				_nextSlam = Time.time + Random.Range(6f, 15f);
			}
		}

		public void AddStumble()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_tripper == (Object)null || _tripper.data == null || _tripper.data.fallTime > 0f)
			{
				return;
			}
			Vector2 val = Random.insideUnitCircle * Random.Range(0.4f, 1f);
			Vector3 val2 = new Vector3(val.x, Random.Range(-0.15f, 0.3f), val.y);
			Vector3 normalized = ((Vector3)(ref val2)).normalized;
			try
			{
				_tripper.refs.ragdoll.AddForce(normalized * Random.Range(7f, 13f), (ForceMode)5);
			}
			catch
			{
			}
		}

		private void EndTrip()
		{
			_localTripping = false;
			ActiveGhosts = 0;
			if ((Object)(object)_videoPlayer != (Object)null)
			{
				_videoPlayer.Stop();
				_videoPlayer.url = "";
			}
			if ((Object)(object)_musicSource != (Object)null)
			{
				_musicSource.Stop();
			}
			if ((Object)(object)_tripVoiceSource != (Object)null)
			{
				_tripVoiceSource.Stop();
				Object.Destroy((Object)(object)((Component)_tripVoiceSource).gameObject);
				_tripVoiceSource = null;
			}
			if ((Object)(object)_volume != (Object)null)
			{
				((Behaviour)_volume).enabled = false;
			}
			if ((Object)(object)_tripper != (Object)null && _tripper.refs != null && PhotonNetwork.InRoom)
			{
				int viewID = _tripper.refs.view.ViewID;
				MyceliumNetwork.RPC(3910472083u, "NotifyTripStopped", (ReliableType)1, new object[1] { viewID });
			}
			Camera val = (((Object)(object)MainCamera.instance != (Object)null) ? MainCamera.instance.cam : null);
			if ((Object)(object)val != (Object)null && _baseFov > 1f)
			{
				val.fieldOfView = Mathf.Lerp(val.fieldOfView, _baseFov, Time.deltaTime * 8f);
			}
			_tripper = null;
		}

		private unsafe void UpdateLocalGhostSpawner()
		{
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: 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_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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_0162: 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_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			if (!_localTripping || Time.time < _nextGhostSpawn)
			{
				return;
			}
			_nextGhostSpawn = Time.time + 2f;
			if (Time.time >= _nextKillOldest)
			{
				_nextKillOldest = Time.time + 10f;
				GhostZombeWrapper oldest = GhostZombeWrapper.Oldest;
				if ((Object)(object)oldest != (Object)null)
				{
					oldest.DespawnNow();
				}
			}
			if (ActiveGhosts >= 4)
			{
				return;
			}
			Player tripper = _tripper;
			if ((Object)(object)tripper == (Object)null || tripper.refs == null || (Object)(object)tripper.refs.headPos == (Object)null)
			{
				return;
			}
			int num = 1;
			Vector3 val = ((tripper.data != null) ? tripper.data.lookDirection : tripper.refs.headPos.forward);
			for (int i = 0; i < num; i++)
			{
				if (ActiveGhosts >= 4)
				{
					break;
				}
				Vector3 val2 = Vector3.zero;
				float num2 = -1f;
				bool flag = false;
				Vector3 val4;
				for (int j = 0; j < 12; j++)
				{
					Vector3 onUnitSphere = Random.onUnitSphere;
					onUnitSphere.y = Mathf.Clamp(onUnitSphere.y, -0.15f, 0.5f);
					float num3 = Random.Range(7f, 14f);
					Vector3 val3 = tripper.refs.headPos.position + onUnitSphere * num3;
					val4 = val3 - tripper.refs.headPos.position;
					float num4 = Vector3.Angle(val, ((Vector3)(ref val4)).normalized);
					if (num4 > num2)
					{
						num2 = num4;
						val2 = val3;
					}
					if (num4 >= 70f)
					{
						val2 = val3;
						flag = true;
						break;
					}
				}
				if (!flag)
				{
					continue;
				}
				try
				{
					GameObject val5 = PhotonNetwork.Instantiate("Zombe", val2, Quaternion.identity, (byte)0, (object[])null);
					if ((Object)(object)val5 == (Object)null)
					{
						Debug.LogWarning((object)"[BenGoop] Zombe instantiate returned null - prefab not registered?");
						continue;
					}
					GhostZombeWrapper ghostZombeWrapper = val5.GetComponent<GhostZombeWrapper>();
					if ((Object)(object)ghostZombeWrapper == (Object)null)
					{
						ghostZombeWrapper = val5.AddComponent<GhostZombeWrapper>();
					}
					ghostZombeWrapper.Setup(tripper, Random.Range(0.6f, 0.7f));
					val4 = val2;
					Debug.Log((object)("[BenGoop] GHOST spawn pos=" + ((object)(*(Vector3*)(&val4))/*cast due to .constrained prefix*/).ToString() + " active=" + val5.activeSelf));
				}
				catch (Exception ex)
				{
					Debug.LogError((object)("[BenGoop] Failed to spawn ghost Ben: " + ex));
				}
			}
		}

		private void OnEndCameraRendering(ScriptableRenderContext ctx, Camera cam)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			if (_localTripping && !((Object)(object)cam == (Object)null) && !((Object)(object)MainCamera.instance == (Object)null) && !((Object)(object)cam != (Object)(object)MainCamera.instance.cam))
			{
				DoAfterImageCapture(ctx, 0.11f, ref _nextAfterImage, ref _afterImageRT, ref _afterImageW, ref _afterImageH, "BenGoop AfterImage");
				DoAfterImageCapture(ctx, 0.21f, ref _nextAfterImage2, ref _afterImageRT2, ref _afterImageW2, ref _afterImageH2, "BenGoop AfterImage 2");
			}
		}

		private void DoAfterImageCapture(ScriptableRenderContext ctx, float interval, ref float nextCapture, ref RenderTexture rt, ref int rtW, ref int rtH, string rtName)
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			if (Time.time < nextCapture)
			{
				return;
			}
			nextCapture = Time.time + interval;
			try
			{
				Texture globalTexture = Shader.GetGlobalTexture("_CameraColorTexture");
				if ((Object)(object)globalTexture == (Object)null)
				{
					return;
				}
				int num = Mathf.Max(2, Screen.width / 4);
				int num2 = Mathf.Max(2, Screen.height / 4);
				if ((Object)(object)rt == (Object)null || rtW != num || rtH != num2)
				{
					if ((Object)(object)rt != (Object)null)
					{
						rt.Release();
					}
					rt = new RenderTexture(num, num2, 0, (RenderTextureFormat)0);
					((Object)rt).name = rtName;
					rtW = num;
					rtH = num2;
				}
				int num3 = Shader.PropertyToID("_BenGoopAfterTmp");
				CommandBuffer val = new CommandBuffer();
				val.name = "BenGoop AfterImage";
				val.GetTemporaryRT(num3, num, num2, 0, (FilterMode)1);
				val.Blit(globalTexture, RenderTargetIdentifier.op_Implicit(num3));
				val.Blit(RenderTargetIdentifier.op_Implicit(num3), RenderTargetIdentifier.op_Implicit((Texture)(object)rt));
				val.ReleaseTemporaryRT(num3);
				((ScriptableRenderContext)(ref ctx)).ExecuteCommandBuffer(val);
				((ScriptableRenderContext)(ref ctx)).Submit();
				val.Release();
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[BenGoop] AfterImage capture failed: " + ex));
			}
		}

		private void OnGUI()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			if (!_localTripping || (Object)(object)_afterImageRT == (Object)null || (int)Event.current.type != 7)
			{
				return;
			}
			float currentPower = GetCurrentPower();
			if (currentPower <= 0.01f)
			{
				return;
			}
			float num = 0.45f * Mathf.Clamp01(currentPower * 1.25f) * (0.92f + 0.08f * Mathf.Sin(Time.time * 3.3f));
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(0f, 0f, (float)Screen.width, (float)Screen.height);
			GUI.DrawTexture(val, (Texture)(object)_afterImageRT, (ScaleMode)0, true, 0f, new Color(1f, 1f, 1f, num), 0f, 0f);
			if ((Object)(object)_afterImageRT2 != (Object)null)
			{
				float num2 = 0.3f * Mathf.Clamp01(currentPower * 1.25f) * (0.92f + 0.08f * Mathf.Sin(Time.time * 2.1f));
				GUI.DrawTexture(val, (Texture)(object)_afterImageRT2, (ScaleMode)0, true, 0f, new Color(1f, 1f, 1f, num2), 0f, 0f);
			}
			if ((Object)(object)_videoRT != (Object)null && (Object)(object)_videoPlayer != (Object)null && _videoPlayer.isPlaying)
			{
				float num3 = Time.time - _startTime;
				float num4 = Mathf.Max(1f, Duration * 0.8f);
				float num5 = Mathf.Clamp01(num3 / num4);
				float num6 = 1f - Mathf.Clamp01((num3 - num4) / Mathf.Max(1f, Duration - num4));
				float num7 = Mathf.Clamp(0.65f * num5 * num6, 0f, 0.65f);
				float num8 = 1.7777778f;
				if (_videoPlayer.width != 0 && _videoPlayer.height != 0)
				{
					num8 = (float)_videoPlayer.width / (float)_videoPlayer.height;
				}
				float num9 = (float)Screen.width / (float)Screen.height;
				float num10 = Screen.width;
				float num11 = Screen.height;
				if (num9 > num8)
				{
					num11 = (float)Screen.width / num8;
				}
				else
				{
					num10 = (float)Screen.height * num8;
				}
				GUI.DrawTexture(new Rect(((float)Screen.width - num10) * 0.5f, ((float)Screen.height - num11) * 0.5f, num10, num11), (Texture)(object)_videoRT, (ScaleMode)0, false, 0f, new Color(1f, 1f, 1f, num7), 0f, 0f);
				if ((Object)(object)_musicSource != (Object)null)
				{
					_musicSource.volume = Mathf.Max(0f, 0.8f * num6);
				}
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}