Decompiled source of Bowling v2.0.0

BepInEx\plugins\Omniscye-Bowling\Omni.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib;
using REPOLib.Modules;
using REPOLib.Objects.Sdk;
using TMPro;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.Video;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Empress")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Empress Bowling for REPO")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyInformationalVersion("2.0.0")]
[assembly: AssemblyProduct("Empress Bowling")]
[assembly: AssemblyTitle("Omni")]
[assembly: AssemblyVersion("2.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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;
		}
	}
}
public class VHSShaderOnItemGrab : MonoBehaviour
{
	[Header("VHS Shader")]
	public MonoBehaviour vhsShaderPrefab;

	private bool effectApplied;

	private PhysGrabObject physGrabObject;

	private void Start()
	{
		physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
	}

	private void Update()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Expected O, but got Unknown
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Expected O, but got Unknown
		if (effectApplied || (Object)physGrabObject == (Object)null || !physGrabObject.grabbed)
		{
			return;
		}
		foreach (PhysGrabber item in physGrabObject.playerGrabbing)
		{
			if ((Object)(item?.playerAvatar) != (Object)null)
			{
				AttachVHSShader(item.playerAvatar);
			}
		}
		effectApplied = true;
	}

	private void AttachVHSShader(PlayerAvatar player)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Expected O, but got Unknown
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Expected O, but got Unknown
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Expected O, but got Unknown
		CharacterController componentInChildren = ((Component)player).GetComponentInChildren<CharacterController>(true);
		if ((Object)componentInChildren == (Object)null)
		{
			Debug.LogWarning((object)"Character Controller not found under player.");
			return;
		}
		Transform val = ((Component)componentInChildren).transform.Find("Top Camera");
		if ((Object)val == (Object)null)
		{
			Debug.LogWarning((object)"Top Camera not found.");
		}
		else if ((Object)((Component)val).GetComponent(((object)vhsShaderPrefab).GetType()) == (Object)null)
		{
			((Component)val).gameObject.AddComponent(((object)vhsShaderPrefab).GetType());
		}
	}
}
[RequireComponent(typeof(Renderer))]
public class AudioReactiveMaterial : MonoBehaviour
{
	[Header("Audio Settings")]
	public AudioSource audioSource;

	public float sensitivity = 15f;

	[Header("Materials")]
	public Material idleMaterial;

	public Material activeMaterial;

	private Renderer rend;

	private float[] samples = new float[64];

	private void Start()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		rend = ((Component)this).GetComponent<Renderer>();
		if ((Object)idleMaterial != (Object)null)
		{
			rend.material = idleMaterial;
		}
	}

	private void Update()
	{
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Expected O, but got Unknown
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Expected O, but got Unknown
		if (Mathf.Clamp01(GetAudioVolume() * sensitivity) > 0.1f)
		{
			if ((Object)activeMaterial != (Object)null)
			{
				rend.material = activeMaterial;
			}
		}
		else if ((Object)idleMaterial != (Object)null)
		{
			rend.material = idleMaterial;
		}
	}

	private float GetAudioVolume()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		if ((Object)audioSource == (Object)null)
		{
			return 0f;
		}
		audioSource.GetOutputData(samples, 0);
		float num = 0f;
		for (int i = 0; i < samples.Length; i++)
		{
			num += Mathf.Abs(samples[i]);
		}
		return num / (float)samples.Length;
	}
}
public class OmniscyeBowlingGameManager : MonoBehaviourPun, IPunObservable
{
	[Header("Empress Pins")]
	public GameObject[] pins;

	[Header("Empress Score Display")]
	public TextMeshProUGUI scoreText;

	public TextMeshProUGUI[] frameScoreTexts = (TextMeshProUGUI[])(object)new TextMeshProUGUI[10];

	[Header("Pin Detection Settings")]
	public float tippedAngleThreshold = 30f;

	[Header("Ball Reset Settings")]
	public Rigidbody ballRb;

	public Transform resetPosition;

	public Transform stopPoint;

	public Transform pinZoneStart;

	public Transform throwStart;

	public float resetDelay = 3f;

	public float maxThrowTime = 10f;

	public float ballStoppedThreshold = 0.05f;

	[Header("Death Mechanic")]
	public int deathScoreThreshold = 50;

	public HurtCollider playerKillCollider;

	[Header("Reward")]
	public GameObject rewardPrefab;

	public Transform rewardSpawnPoint;

	private bool isResetting;

	private bool ballInPinZone;

	private bool throwActive;

	private float ballStoppedTime;

	private float strayStoppedTime;

	private int pinsKnockedOver;

	private int throwCount;

	private int currentFrame;

	private const float MinThrowSpeed = 1f;

	private const float ThrowStopTime = 2f;

	private const float StrayResetTime = 4f;

	private const float HomeRadius = 2.5f;

	private static AudioClip winClip;

	private static bool winClipRequested;

	private PhysGrabObject ballGrab;

	private List<int> throws = new List<int>();

	private Coroutine throwTimeoutCoroutine;

	private Dictionary<GameObject, Vector3> originalUpDirections = new Dictionary<GameObject, Vector3>();

	private Dictionary<GameObject, Vector3> originalPositions = new Dictionary<GameObject, Vector3>();

	private Dictionary<GameObject, Quaternion> originalRotations = new Dictionary<GameObject, Quaternion>();

	private void Start()
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Expected O, but got Unknown
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Expected O, but got Unknown
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Expected O, but got Unknown
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Expected O, but got Unknown
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Expected O, but got Unknown
		if (!winClipRequested)
		{
			winClipRequested = true;
			((MonoBehaviour)this).StartCoroutine(LoadWinClip());
		}
		GameObject[] array = pins;
		foreach (GameObject val in array)
		{
			originalUpDirections[val] = val.transform.up;
			originalPositions[val] = val.transform.position;
			originalRotations[val] = val.transform.rotation;
		}
		if ((Object)ballRb != (Object)null)
		{
			ballGrab = ((Component)ballRb).GetComponent<PhysGrabObject>();
			if ((Object)ballGrab == (Object)null)
			{
				ballGrab = ((Component)ballRb).GetComponentInParent<PhysGrabObject>();
			}
			if ((Object)ballGrab == (Object)null)
			{
				ballGrab = ((Component)ballRb).GetComponentInChildren<PhysGrabObject>();
			}
		}
		SanitizeObservedTransforms(((MonoBehaviourPun)this).photonView);
		if ((Object)ballRb != (Object)null)
		{
			SanitizeObservedTransforms(((Component)ballRb).GetComponentInParent<PhotonView>());
		}
		((TMP_Text)scoreText).text = "Pins Knocked Over: 0";
		for (int j = 0; j < frameScoreTexts.Length; j++)
		{
			if ((Object)frameScoreTexts[j] != (Object)null)
			{
				((TMP_Text)frameScoreTexts[j]).text = $"Frame {j + 1}: ";
			}
		}
	}

	private void Update()
	{
		if (!SemiFunc.IsMasterClientOrSingleplayer() || isResetting)
		{
			return;
		}
		if (IsBallHeld())
		{
			ballStoppedTime = 0f;
			strayStoppedTime = 0f;
			return;
		}
		CheckBallPosition();
		if (throwActive)
		{
			if (ballInPinZone)
			{
				TrackPins();
			}
			CheckIfBallStopped();
		}
		else
		{
			CheckIfBallStray();
		}
	}

	private bool IsBallHeld()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		if ((Object)ballGrab != (Object)null)
		{
			return ballGrab.grabbed;
		}
		return false;
	}

	private void CheckIfBallStopped()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		Vector3 velocity = ballRb.velocity;
		if (((Vector3)(ref velocity)).magnitude < ballStoppedThreshold)
		{
			ballStoppedTime += Time.deltaTime;
			if (ballStoppedTime >= 2f)
			{
				FinishThrow();
			}
		}
		else
		{
			ballStoppedTime = 0f;
		}
	}

	private void CheckIfBallStray()
	{
		//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)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		if (Vector3.Distance(((Component)ballRb).transform.position, resetPosition.position) <= 2.5f)
		{
			strayStoppedTime = 0f;
			return;
		}
		Vector3 velocity = ballRb.velocity;
		if (((Vector3)(ref velocity)).magnitude < ballStoppedThreshold)
		{
			strayStoppedTime += Time.deltaTime;
			if (strayStoppedTime >= 4f)
			{
				strayStoppedTime = 0f;
				RecoverBall();
			}
		}
		else
		{
			strayStoppedTime = 0f;
		}
	}

	private void CheckBallPosition()
	{
		//IL_000b: 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)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: 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_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		float x = ((Component)ballRb).transform.position.x;
		if (!throwActive)
		{
			bool num = x >= throwStart.position.x && ballRb.velocity.x >= 1f;
			int num2;
			if (x >= pinZoneStart.position.x)
			{
				Vector3 velocity = ballRb.velocity;
				num2 = ((((Vector3)(ref velocity)).magnitude >= 1f) ? 1 : 0);
			}
			else
			{
				num2 = 0;
			}
			bool flag = (byte)num2 != 0;
			if (num || flag)
			{
				BeginThrow(flag);
			}
		}
		else
		{
			if (!ballInPinZone && x >= pinZoneStart.position.x)
			{
				ballInPinZone = true;
			}
			if (x >= stopPoint.position.x)
			{
				FinishThrow();
			}
		}
	}

	private void BeginThrow(bool alreadyInPinZone)
	{
		throwActive = true;
		ballInPinZone = alreadyInPinZone;
		ballStoppedTime = 0f;
		strayStoppedTime = 0f;
		if (throwTimeoutCoroutine != null)
		{
			((MonoBehaviour)this).StopCoroutine(throwTimeoutCoroutine);
		}
		throwTimeoutCoroutine = ((MonoBehaviour)this).StartCoroutine(ThrowTimeoutCheck());
	}

	private IEnumerator ThrowTimeoutCheck()
	{
		yield return (object)new WaitForSeconds(maxThrowTime);
		if (throwActive)
		{
			FinishThrow();
		}
	}

	private void FinishThrow()
	{
		if (!isResetting)
		{
			throwActive = false;
			ballInPinZone = false;
			if (throwTimeoutCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(throwTimeoutCoroutine);
				throwTimeoutCoroutine = null;
			}
			((MonoBehaviour)this).StartCoroutine(ResetBallAfterDelay());
		}
	}

	private void TrackPins()
	{
		int num = CountKnockedPins();
		if (num != pinsKnockedOver)
		{
			pinsKnockedOver = num;
			if (!SemiFunc.IsMultiplayer())
			{
				UpdateScoreRPC(pinsKnockedOver);
				return;
			}
			((MonoBehaviourPun)this).photonView.RPC("UpdateScoreRPC", (RpcTarget)3, new object[1] { pinsKnockedOver });
		}
	}

	private int CountKnockedPins()
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Expected O, but got Unknown
		int num = 0;
		GameObject[] array = pins;
		foreach (GameObject val in array)
		{
			Renderer component = val.GetComponent<Renderer>();
			if ((Object)component != (Object)null && component.enabled && IsPinKnockedOver(val))
			{
				num++;
			}
		}
		return num;
	}

	private bool IsPinKnockedOver(GameObject pin)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		if (!originalUpDirections.ContainsKey(pin))
		{
			return false;
		}
		return Vector3.Angle(originalUpDirections[pin], pin.transform.up) > tippedAngleThreshold;
	}

	private IEnumerator ResetBallAfterDelay()
	{
		isResetting = true;
		yield return (object)new WaitForSeconds(resetDelay);
		int num = CountKnockedPins();
		if (!SemiFunc.IsMultiplayer())
		{
			ResetBallRPC(num);
		}
		else
		{
			((MonoBehaviourPun)this).photonView.RPC("ResetBallRPC", (RpcTarget)3, new object[1] { num });
		}
		isResetting = false;
	}

	[PunRPC]
	private void UpdateScoreRPC(int score)
	{
		((TMP_Text)scoreText).text = "Pins Knocked Over: " + score;
	}

	[PunRPC]
	private void ResetBallRPC(int finalThrowScore)
	{
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Expected O, but got Unknown
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Expected O, but got Unknown
		throws.Add(finalThrowScore);
		throwCount++;
		if (currentFrame < 10 && (Object)frameScoreTexts[currentFrame] != (Object)null)
		{
			if (throwCount % 2 == 1)
			{
				if (finalThrowScore == 10)
				{
					((TMP_Text)frameScoreTexts[currentFrame]).text = $"Frame {currentFrame + 1}: STRIKE (10)";
					throwCount++;
					currentFrame++;
					ResetPins();
				}
				else
				{
					((TMP_Text)frameScoreTexts[currentFrame]).text = $"Frame {currentFrame + 1}: {finalThrowScore}";
					HideKnockedPins();
				}
			}
			else
			{
				List<int> list = throws;
				int num = list[list.Count - 2];
				if (num + finalThrowScore >= 10)
				{
					((TMP_Text)frameScoreTexts[currentFrame]).text = $"Frame {currentFrame + 1}: {num} / SPARE";
				}
				else
				{
					((TMP_Text)frameScoreTexts[currentFrame]).text = $"Frame {currentFrame + 1}: {num} / {finalThrowScore}";
				}
				ResetPins();
				currentFrame++;
			}
		}
		if (currentFrame >= 10)
		{
			if (CalculateTotalScore() < deathScoreThreshold)
			{
				TriggerPlayerDeath();
			}
			else
			{
				SpawnRewardPrefab();
				PlayWinSound();
			}
			currentFrame = 0;
			throwCount = 0;
			throws.Clear();
			for (int i = 0; i < frameScoreTexts.Length; i++)
			{
				if ((Object)frameScoreTexts[i] != (Object)null)
				{
					((TMP_Text)frameScoreTexts[i]).text = $"Frame {i + 1}: ";
				}
			}
			ResetPins();
		}
		PlaceBallHome();
		pinsKnockedOver = 0;
		((TMP_Text)scoreText).text = "Pins Knocked Over: 0";
	}

	private void PlaceBallHome()
	{
		//IL_0006: 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)
		//IL_003d: 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)
		ballRb.velocity = Vector3.zero;
		ballRb.angularVelocity = Vector3.zero;
		ballRb.isKinematic = true;
		((Component)ballRb).transform.position = resetPosition.position;
		((Component)ballRb).transform.rotation = resetPosition.rotation;
		ballRb.isKinematic = false;
	}

	private void RecoverBall()
	{
		if (!SemiFunc.IsMultiplayer())
		{
			RecoverBallRPC();
		}
		else
		{
			((MonoBehaviourPun)this).photonView.RPC("RecoverBallRPC", (RpcTarget)3, Array.Empty<object>());
		}
	}

	[PunRPC]
	private void RecoverBallRPC()
	{
		PlaceBallHome();
	}

	private void SpawnRewardPrefab()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Expected O, but got Unknown
		if ((Object)rewardPrefab != (Object)null)
		{
			PhotonView component = rewardPrefab.GetComponent<PhotonView>();
			if ((Object)component != (Object)null)
			{
				if (SemiFunc.IsMultiplayer())
				{
					((MonoBehaviourPun)this).photonView.RPC("EnableRewardRPC", (RpcTarget)3, new object[1] { component.ViewID });
				}
				else
				{
					rewardPrefab.SetActive(true);
				}
			}
			else
			{
				Debug.LogWarning((object)"[Empress Bowling] Reward prefab is missing PhotonView.");
			}
		}
		else
		{
			Debug.LogWarning((object)"[Empress Bowling] Reward prefab not assigned.");
		}
	}

	[PunRPC]
	private void EnableRewardRPC(int viewID)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Expected O, but got Unknown
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Expected O, but got Unknown
		PhotonView val = PhotonView.Find(viewID);
		if ((Object)val != (Object)null && (Object)((Component)val).gameObject != (Object)null)
		{
			((Component)val).gameObject.SetActive(true);
		}
		else
		{
			Debug.LogWarning((object)"[Empress Bowling] Could not find reward PhotonView by ViewID.");
		}
	}

	private void ResetPins()
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: 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_0052: Expected O, but got Unknown
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Expected O, but got Unknown
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Expected O, but got Unknown
		GameObject[] array = pins;
		foreach (GameObject val in array)
		{
			val.transform.position = originalPositions[val];
			val.transform.rotation = originalRotations[val];
			Rigidbody component = val.GetComponent<Rigidbody>();
			if (Object.op_Implicit((Object)component))
			{
				component.velocity = Vector3.zero;
				component.angularVelocity = Vector3.zero;
			}
			Renderer component2 = val.GetComponent<Renderer>();
			Collider component3 = val.GetComponent<Collider>();
			if (Object.op_Implicit((Object)component2))
			{
				component2.enabled = true;
			}
			if (Object.op_Implicit((Object)component3))
			{
				component3.enabled = true;
			}
		}
		pinsKnockedOver = 0;
	}

	private void HideKnockedPins()
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Expected O, but got Unknown
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Expected O, but got Unknown
		GameObject[] array = pins;
		foreach (GameObject val in array)
		{
			if (IsPinKnockedOver(val))
			{
				Renderer component = val.GetComponent<Renderer>();
				Collider component2 = val.GetComponent<Collider>();
				if (Object.op_Implicit((Object)component))
				{
					component.enabled = false;
				}
				if (Object.op_Implicit((Object)component2))
				{
					component2.enabled = false;
				}
			}
		}
	}

	private int CalculateTotalScore()
	{
		int num = 0;
		foreach (int @throw in throws)
		{
			num += @throw;
		}
		return num;
	}

	private void TriggerPlayerDeath()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Expected O, but got Unknown
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Expected O, but got Unknown
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Expected O, but got Unknown
		if ((Object)playerKillCollider == (Object)null)
		{
			Debug.LogError((object)"[Empress Bowling] No HurtCollider assigned for player death!");
			return;
		}
		PlayerAvatar[] array = Object.FindObjectsOfType<PlayerAvatar>();
		foreach (PlayerAvatar val in array)
		{
			if ((Object)val != (Object)null && (Object)val.playerHealth != (Object)null)
			{
				int num = ((!((Object)playerKillCollider.enemyHost != (Object)null)) ? (-1) : 0);
				val.playerHealth.Hurt(BowlingGameAccess.Health(val.playerHealth), false, num, false);
			}
		}
	}

	private void PlayWinSound()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Expected O, but got Unknown
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Expected O, but got Unknown
		//IL_0039: 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_003e: 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)
		if (!((Object)winClip == (Object)null))
		{
			Vector3 val = (((Object)rewardSpawnPoint != (Object)null) ? rewardSpawnPoint.position : ((Component)this).transform.position);
			AudioSource.PlayClipAtPoint(winClip, val, 0.3f);
		}
	}

	private IEnumerator LoadWinClip()
	{
		string text = ResolveWinClipPath();
		if (string.IsNullOrEmpty(text))
		{
			yield break;
		}
		string absoluteUri = new Uri(text).AbsoluteUri;
		UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(absoluteUri, (AudioType)14);
		try
		{
			yield return request.SendWebRequest();
			if ((int)request.result == 1)
			{
				AudioClip content = DownloadHandlerAudioClip.GetContent(request);
				if ((Object)content != (Object)null)
				{
					winClip = content;
				}
			}
		}
		finally
		{
			((IDisposable)request)?.Dispose();
		}
	}

	private static string ResolveWinClipPath()
	{
		try
		{
			string directoryName = Path.GetDirectoryName(typeof(OmniscyeBowlingGameManager).Assembly.Location);
			string text = ((directoryName != null) ? Path.Combine(directoryName, "Empress-Win.ogg") : null);
			if (!string.IsNullOrEmpty(text) && File.Exists(text))
			{
				return text;
			}
			return Directory.GetFiles(Paths.PluginPath, "Empress-Win.ogg", SearchOption.AllDirectories).FirstOrDefault();
		}
		catch
		{
			return null;
		}
	}

	public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
	{
	}

	private static void SanitizeObservedTransforms(PhotonView view)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		if ((Object)view == (Object)null || view.ObservedComponents == null)
		{
			return;
		}
		for (int num = view.ObservedComponents.Count - 1; num >= 0; num--)
		{
			if (view.ObservedComponents[num] is Transform)
			{
				view.ObservedComponents.RemoveAt(num);
			}
		}
	}
}
public class ChasingSkullValuable : Trap
{
	[Header("Chase Settings")]
	public float forceStrength = 50f;

	public float maxSpeed = 15f;

	public float detectionRange = 30f;

	public float playerKnockbackForce = 25f;

	[Header("Physics")]
	public Rigidbody rb;

	private PlayerAvatar targetPlayer;

	protected override void Start()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		((Trap)this).Start();
		if ((Object)rb == (Object)null)
		{
			rb = ((Component)this).GetComponent<Rigidbody>();
		}
	}

	protected override void Update()
	{
		((Trap)this).Update();
		if (!base.physGrabObject.grabbed)
		{
			FindPlayerTarget();
			ChaseTarget();
		}
		else
		{
			targetPlayer = null;
		}
	}

	private void FindPlayerTarget()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//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)
		if ((Object)targetPlayer != (Object)null && !BowlingGameAccess.IsDisabled(targetPlayer))
		{
			return;
		}
		float num = detectionRange;
		PlayerAvatar val = null;
		foreach (PlayerAvatar item in SemiFunc.PlayerGetList())
		{
			if (!BowlingGameAccess.IsDisabled(item))
			{
				float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)item).transform.position);
				if (num2 < num)
				{
					num = num2;
					val = item;
				}
			}
		}
		targetPlayer = val;
	}

	private void ChaseTarget()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: 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_0040: 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_0048: 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_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)targetPlayer == (Object)null) && !BowlingGameAccess.IsDisabled(targetPlayer))
		{
			Vector3 val = ((Component)targetPlayer).transform.position - ((Component)this).transform.position;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			val = rb.velocity;
			if (((Vector3)(ref val)).magnitude < maxSpeed)
			{
				rb.AddForce(normalized * forceStrength, (ForceMode)5);
			}
		}
	}

	private void OnCollisionEnter(Collision collision)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		//IL_003c: 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_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: 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_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			PlayerAvatar componentInParent = ((Component)collision.collider).GetComponentInParent<PlayerAvatar>();
			if ((Object)componentInParent != (Object)null && !BowlingGameAccess.IsDisabled(componentInParent))
			{
				BowlingGameAccess.Tumble(componentInParent).TumbleRequest(true, false);
				Vector3 val = ((Component)componentInParent).transform.position - ((Component)this).transform.position;
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				BowlingGameAccess.Tumble(componentInParent).TumbleForce(normalized * playerKnockbackForce);
				BowlingGameAccess.Tumble(componentInParent).TumbleOverrideTime(1.5f);
			}
		}
	}
}
public class CoasterSeatCarrier : MonoBehaviour
{
	[Tooltip("Child under the cart where the player sits (must be parented)")]
	public Transform seatPoint;

	[Header("Grab & Follow Settings")]
	[Tooltip("How close the player must be to latch on")]
	public float grabDistance = 1f;

	[Tooltip("Spring stiffness for position follow")]
	public float positionStiffness = 10f;

	[Tooltip("Spring stiffness for rotation follow")]
	public float rotationStiffness = 0.2f;

	private PlayerAvatar playerTarget;

	private void FixedUpdate()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Expected O, but got Unknown
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: 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_012b: 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_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: 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_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: 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)
		if ((Object)playerTarget == (Object)null)
		{
			foreach (PlayerAvatar item in SemiFunc.PlayerGetList())
			{
				if (!BowlingGameAccess.IsDisabled(item) && Vector3.Distance(seatPoint.position, ((Component)item).transform.position) <= grabDistance)
				{
					playerTarget = item;
					break;
				}
			}
		}
		if ((Object)playerTarget != (Object)null && !BowlingGameAccess.IsDisabled(playerTarget))
		{
			Rigidbody val = BowlingGameAccess.TumbleRigidbody(playerTarget);
			if (!BowlingGameAccess.IsTumbling(playerTarget))
			{
				BowlingGameAccess.Tumble(playerTarget).TumbleRequest(true, false);
			}
			BowlingGameAccess.Tumble(playerTarget).TumbleOverrideTime(1f);
			playerTarget.FallDamageResetSet(0.1f);
			Vector3 val2 = SemiFunc.PhysFollowPosition(((Component)BowlingGameAccess.Tumble(playerTarget)).transform.position, seatPoint.position, val.velocity, positionStiffness);
			val.AddForce(val2 * (positionStiffness * Time.fixedDeltaTime), (ForceMode)1);
			Vector3 val3 = SemiFunc.PhysFollowRotation(((Component)BowlingGameAccess.Tumble(playerTarget)).transform, seatPoint.rotation, val, rotationStiffness);
			val.AddTorque(val3 * Time.fixedDeltaTime, (ForceMode)1);
		}
	}
}
[RequireComponent(typeof(Renderer))]
public class CubeWalk : MonoBehaviour
{
	[Header("Flip Settings")]
	public float flipDelay = 0.5f;

	[Header("Audio Settings")]
	public AudioSource audioSource;

	public float sensitivity = 15f;

	[Header("Materials")]
	public Material blackMaterial;

	public Material redMaterial;

	private Vector3 pivot;

	private bool isFlipping;

	private Vector3 rotationAxis = new Vector3(0f, 0f, -1f);

	private Renderer rend;

	private float[] samples = new float[64];

	private void Start()
	{
		//IL_0007: 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_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: 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_005e: Unknown result type (might be due to invalid IL or missing references)
		pivot = ((Component)this).transform.position + new Vector3(((Component)this).transform.localScale.x / 2f, (0f - ((Component)this).transform.localScale.y) / 2f, ((Component)this).transform.localScale.z / 2f);
		rend = ((Component)this).GetComponent<Renderer>();
		rend.material = blackMaterial;
		((MonoBehaviour)this).StartCoroutine(FlipRight());
	}

	private void Update()
	{
		if (Mathf.Clamp01(GetAudioVolume() * sensitivity) > 0.1f)
		{
			rend.material = redMaterial;
		}
		else
		{
			rend.material = blackMaterial;
		}
	}

	private float GetAudioVolume()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		if ((Object)audioSource == (Object)null)
		{
			return 0f;
		}
		audioSource.GetOutputData(samples, 0);
		float num = 0f;
		for (int i = 0; i < samples.Length; i++)
		{
			num += Mathf.Abs(samples[i]);
		}
		return num / (float)samples.Length;
	}

	private IEnumerator FlipRight()
	{
		while (true)
		{
			yield return (object)new WaitForSeconds(flipDelay);
			if (!isFlipping)
			{
				isFlipping = true;
				((MonoBehaviour)this).StartCoroutine(PerformFlip());
			}
		}
	}

	private IEnumerator PerformFlip()
	{
		float rotationAmount = 90f;
		float rotationSpeed = rotationAmount / flipDelay * Time.deltaTime;
		float totalRotation = 0f;
		while (totalRotation < rotationAmount)
		{
			float num = Mathf.Min(rotationSpeed, rotationAmount - totalRotation);
			((Component)this).transform.RotateAround(pivot, rotationAxis, num);
			totalRotation += num;
			yield return null;
		}
		Vector3 eulerAngles = default(Vector3);
		((Vector3)(ref eulerAngles))..ctor(Mathf.Round(((Component)this).transform.eulerAngles.x / 90f) * 90f, Mathf.Round(((Component)this).transform.eulerAngles.y / 90f) * 90f, Mathf.Round(((Component)this).transform.eulerAngles.z / 90f) * 90f);
		((Component)this).transform.eulerAngles = eulerAngles;
		pivot = ((Component)this).transform.position + new Vector3(((Component)this).transform.localScale.x / 2f, (0f - ((Component)this).transform.localScale.y) / 2f, ((Component)this).transform.localScale.z / 2f);
		isFlipping = false;
	}
}
public class CursedFollowCat : MonoBehaviourPun
{
	public float followDistance = 50f;

	public float moveForce = 20f;

	public float rotationForce = 5f;

	public float toppleAngleThreshold = 45f;

	public float resetAfterSeconds = 5f;

	private PlayerAvatar playerTarget;

	private Rigidbody rb;

	private float toppleTimer;

	private void Start()
	{
		rb = ((Component)this).GetComponent<Rigidbody>();
	}

	private void FixedUpdate()
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Expected O, but got Unknown
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			AcquirePlayerTarget();
			if ((Object)playerTarget != (Object)null && !BowlingGameAccess.IsDisabled(playerTarget))
			{
				FollowPlayer();
			}
			CheckForTopple();
		}
	}

	private void AcquirePlayerTarget()
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		float num = followDistance;
		playerTarget = null;
		foreach (PlayerAvatar item in SemiFunc.PlayerGetList())
		{
			if (!BowlingGameAccess.IsDisabled(item))
			{
				float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)item).transform.position);
				if (num2 <= num)
				{
					num = num2;
					playerTarget = item;
				}
			}
		}
	}

	private void FollowPlayer()
	{
		//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_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_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: 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)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		Vector3 position = ((Component)playerTarget).transform.position;
		Vector3 val = SemiFunc.PhysFollowPosition(rb.position, position, rb.velocity, moveForce);
		rb.AddForce(val * (moveForce * Time.fixedDeltaTime), (ForceMode)1);
		Vector3 val2 = SemiFunc.PhysFollowRotation(((Component)rb).transform, Quaternion.LookRotation(position - ((Component)this).transform.position), rb, rotationForce);
		rb.AddTorque(val2 * Time.fixedDeltaTime, (ForceMode)1);
	}

	private void CheckForTopple()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		if (Vector3.Angle(((Component)this).transform.up, Vector3.up) > toppleAngleThreshold)
		{
			toppleTimer += Time.fixedDeltaTime;
			if (toppleTimer >= resetAfterSeconds)
			{
				ResetUpright();
				toppleTimer = 0f;
			}
		}
		else
		{
			toppleTimer = 0f;
		}
	}

	private void ResetUpright()
	{
		//IL_0011: 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_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		((Component)this).transform.rotation = Quaternion.Euler(0f, ((Component)this).transform.eulerAngles.y, 0f);
		rb.angularVelocity = Vector3.zero;
		rb.velocity = Vector3.zero;
	}
}
public class CursedBlackHoleOrbValuable : Trap
{
	[Header("Black Hole Settings")]
	public float blackHoleRange = 20f;

	public float pullForce = 100f;

	protected override void Update()
	{
		((Trap)this).Update();
		if (base.physGrabObject.grabbed && SemiFunc.IsMasterClientOrSingleplayer())
		{
			ApplyContinuousPull();
		}
	}

	private void ApplyContinuousPull()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: 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_0056: Expected O, but got Unknown
		//IL_0056: Expected O, but got Unknown
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
		Vector3 position = ((Component)this).transform.position;
		foreach (PlayerAvatar item in SemiFunc.PlayerGetList())
		{
			bool flag = false;
			foreach (PhysGrabber item2 in base.physGrabObject.playerGrabbing)
			{
				if ((Object)item2.playerAvatar == (Object)item)
				{
					flag = true;
					break;
				}
			}
			if (!flag && !BowlingGameAccess.IsDisabled(item))
			{
				float num = Vector3.Distance(position, ((Component)item).transform.position);
				if (num <= blackHoleRange)
				{
					Vector3 val = position - ((Component)item).transform.position;
					Vector3 normalized = ((Vector3)(ref val)).normalized;
					BowlingGameAccess.Tumble(item).TumbleRequest(true, false);
					float num2 = Mathf.Clamp01(1f - num / blackHoleRange);
					float num3 = pullForce * num2;
					BowlingGameAccess.Tumble(item).TumbleForce(normalized * num3);
					BowlingGameAccess.Tumble(item).TumbleOverrideTime(0.2f);
				}
			}
		}
	}
}
public class CursedRollerValuable : MonoBehaviour
{
	[Header("Patrol Settings")]
	public float moveForce = 15f;

	public float rotationForce = 5f;

	public float wanderInterval = 5f;

	public float wanderRadius = 10f;

	[Header("Coaster Settings")]
	public Transform seatPoint;

	public float grabDistance = 1f;

	public float positionStiffness = 10f;

	public float rotationStiffness = 0.2f;

	public float latchDuration = 5f;

	public float tossForce = 30f;

	public float regrabCooldown = 5f;

	private PlayerAvatar playerTarget;

	private Rigidbody rb;

	private float wanderTimer;

	private Vector3 randomWanderTarget;

	private float latchTimer;

	private float regrabTimer;

	private void Start()
	{
		rb = ((Component)this).GetComponent<Rigidbody>();
		SetRandomWanderTarget();
	}

	private void FixedUpdate()
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Expected O, but got Unknown
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Expected O, but got Unknown
		//IL_006a: 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)
		if (!SemiFunc.IsMasterClientOrSingleplayer())
		{
			return;
		}
		if (regrabTimer > 0f)
		{
			regrabTimer -= Time.fixedDeltaTime;
		}
		if ((Object)playerTarget == (Object)null && regrabTimer <= 0f)
		{
			foreach (PlayerAvatar item in SemiFunc.PlayerGetList())
			{
				if (!BowlingGameAccess.IsDisabled(item) && Vector3.Distance(seatPoint.position, ((Component)item).transform.position) <= grabDistance)
				{
					playerTarget = item;
					latchTimer = 0f;
					break;
				}
			}
		}
		if ((Object)playerTarget != (Object)null)
		{
			CarryPlayer();
			latchTimer += Time.fixedDeltaTime;
			if (latchTimer >= latchDuration)
			{
				TossPlayer();
				playerTarget = null;
				latchTimer = 0f;
				regrabTimer = regrabCooldown;
				SetRandomWanderTarget();
			}
		}
		else
		{
			wanderTimer += Time.fixedDeltaTime;
			if (wanderTimer >= wanderInterval)
			{
				wanderTimer = 0f;
				SetRandomWanderTarget();
			}
			MoveToWanderTarget();
		}
	}

	private void CarryPlayer()
	{
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: 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_0081: 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_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
		Rigidbody val = BowlingGameAccess.TumbleRigidbody(playerTarget);
		if (!BowlingGameAccess.IsTumbling(playerTarget))
		{
			BowlingGameAccess.Tumble(playerTarget).TumbleRequest(true, false);
		}
		BowlingGameAccess.Tumble(playerTarget).TumbleOverrideTime(1f);
		playerTarget.FallDamageResetSet(0.1f);
		Vector3 val2 = SemiFunc.PhysFollowPosition(((Component)BowlingGameAccess.Tumble(playerTarget)).transform.position, seatPoint.position, val.velocity, positionStiffness);
		val.AddForce(val2 * (positionStiffness * Time.fixedDeltaTime), (ForceMode)1);
		Vector3 val3 = SemiFunc.PhysFollowRotation(((Component)BowlingGameAccess.Tumble(playerTarget)).transform, seatPoint.rotation, val, rotationStiffness);
		val.AddTorque(val3 * Time.fixedDeltaTime, (ForceMode)1);
	}

	private void TossPlayer()
	{
		//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)
		//IL_001b: 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_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)
		//IL_0046: 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)
		Vector3 val = ((Component)playerTarget).transform.position - ((Component)this).transform.position;
		Vector3 normalized = ((Vector3)(ref val)).normalized;
		BowlingGameAccess.Tumble(playerTarget).TumbleRequest(true, false);
		BowlingGameAccess.Tumble(playerTarget).TumbleForce(normalized * tossForce);
		BowlingGameAccess.Tumble(playerTarget).TumbleOverrideTime(1f);
	}

	private void SetRandomWanderTarget()
	{
		//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_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_001d: 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_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: 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)
		Vector2 val = Random.insideUnitCircle * wanderRadius;
		randomWanderTarget = ((Component)this).transform.position + new Vector3(val.x, 0f, val.y);
	}

	private void MoveToWanderTarget()
	{
		//IL_0006: 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)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//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_002e: 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_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: 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_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: 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)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = SemiFunc.PhysFollowPosition(rb.position, randomWanderTarget, rb.velocity, moveForce);
		rb.AddForce(val * (moveForce * Time.fixedDeltaTime), (ForceMode)1);
		Vector3 val2 = SemiFunc.PhysFollowRotation(((Component)rb).transform, Quaternion.LookRotation(randomWanderTarget - ((Component)this).transform.position), rb, rotationForce);
		rb.AddTorque(val2 * Time.fixedDeltaTime, (ForceMode)1);
	}
}
public class GreedyVendingTrap : MonoBehaviourPun
{
	private ItemToggle itemToggle;

	private bool warned;

	private bool recentlyPressed;

	public AudioClip warningClip;

	public AudioSource audioSource;

	public Animator warningAnimator;

	public string animationTriggerName = "Warn";

	public float cooldown = 0.5f;

	private Rigidbody anchorBody;

	private Vector3 anchorLocalPosition;

	private Quaternion anchorLocalRotation;

	private bool anchorReady;

	private void Start()
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Expected O, but got Unknown
		itemToggle = ((Component)this).GetComponent<ItemToggle>();
		anchorBody = ((Component)this).GetComponent<Rigidbody>();
		anchorLocalPosition = ((Component)this).transform.localPosition;
		anchorLocalRotation = ((Component)this).transform.localRotation;
		if ((Object)anchorBody != (Object)null)
		{
			anchorBody.constraints = (RigidbodyConstraints)126;
		}
		anchorReady = true;
	}

	private void LateUpdate()
	{
		//IL_0010: 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_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Expected O, but got Unknown
		//IL_0051: 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)
		if (anchorReady)
		{
			((Component)this).transform.localPosition = anchorLocalPosition;
			((Component)this).transform.localRotation = anchorLocalRotation;
			if ((Object)anchorBody != (Object)null && !anchorBody.isKinematic)
			{
				anchorBody.velocity = Vector3.zero;
				anchorBody.angularVelocity = Vector3.zero;
			}
		}
	}

	private void Update()
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Expected O, but got Unknown
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Expected O, but got Unknown
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Expected O, but got Unknown
		if (!BowlingGameAccess.ToggleImpulse(itemToggle) || recentlyPressed)
		{
			return;
		}
		((MonoBehaviour)this).StartCoroutine(PressCooldown());
		if (!warned)
		{
			warned = true;
			if ((Object)warningClip != (Object)null && (Object)audioSource != (Object)null)
			{
				audioSource.PlayOneShot(warningClip);
			}
			if ((Object)warningAnimator != (Object)null)
			{
				warningAnimator.SetTrigger(animationTriggerName);
			}
		}
		else
		{
			KillAllPlayers();
		}
	}

	private IEnumerator PressCooldown()
	{
		recentlyPressed = true;
		yield return (object)new WaitForSeconds(cooldown);
		recentlyPressed = false;
	}

	private void KillAllPlayers()
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Expected O, but got Unknown
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Expected O, but got Unknown
		PlayerAvatar[] array = Object.FindObjectsOfType<PlayerAvatar>();
		foreach (PlayerAvatar val in array)
		{
			if ((Object)val != (Object)null && (Object)val.playerHealth != (Object)null)
			{
				int num = -1;
				val.playerHealth.Hurt(BowlingGameAccess.Health(val.playerHealth), false, num, false);
			}
		}
	}
}
[RequireComponent(typeof(Collider))]
public class KinematicCoasterMover : MonoBehaviour
{
	[Header("Waypoints & Timing")]
	public Transform waypointRoot;

	public float speed = 5f;

	public float startDelay = 10f;

	public bool loop = true;

	public float rotationSpeed = 5f;

	[Header("Mesh Import Rotation Correction (tweak in Inspector)")]
	public Vector3 meshEulerOffset = new Vector3(-90f, 180f, -0.085f);

	private Transform[] waypoints;

	private int idx;

	private float delayTimer;

	private bool started;

	private Quaternion originalRotation;

	private Quaternion meshOffsetQuat;

	private static readonly Regex regex = new Regex("Waypoint_(\\d+)$");

	private void Awake()
	{
		//IL_0007: 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)
		//IL_00ba: 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_00c4: 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)
		originalRotation = ((Component)this).transform.rotation;
		waypoints = (from t in ((Component)waypointRoot).GetComponentsInChildren<Transform>(true)
			where regex.IsMatch(((Object)t).name)
			select new
			{
				t = t,
				i = int.Parse(regex.Match(((Object)t).name).Groups[1].Value)
			} into x
			orderby x.i
			select x.t).ToArray();
		meshOffsetQuat = Quaternion.Euler(meshEulerOffset);
		idx = 0;
		delayTimer = startDelay;
		started = false;
		if (waypoints.Length != 0)
		{
			((Component)this).transform.position = waypoints[0].position;
		}
	}

	private void Update()
	{
		//IL_0033: 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_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: 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_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: 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_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: 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)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		if (waypoints == null || waypoints.Length == 0)
		{
			return;
		}
		if (!started)
		{
			delayTimer -= Time.deltaTime;
			((Component)this).transform.rotation = originalRotation;
			if (delayTimer <= 0f)
			{
				started = true;
			}
			return;
		}
		if (idx == 0 && ((Component)this).transform.rotation == originalRotation && waypoints.Length > 1)
		{
			Vector3 val = waypoints[1].position - waypoints[0].position;
			Quaternion rotation = Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up) * meshOffsetQuat;
			((Component)this).transform.rotation = rotation;
		}
		Vector3 position = waypoints[idx].position;
		Vector3 val2 = position - ((Component)this).transform.position;
		float num = speed * Time.deltaTime;
		if (((Vector3)(ref val2)).magnitude <= num)
		{
			((Component)this).transform.position = position;
			AdvanceIndex();
			return;
		}
		Transform transform = ((Component)this).transform;
		transform.position += ((Vector3)(ref val2)).normalized * num;
		Quaternion val3 = Quaternion.LookRotation(((Vector3)(ref val2)).normalized, Vector3.up) * meshOffsetQuat;
		((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, val3, rotationSpeed * Time.deltaTime);
	}

	private void AdvanceIndex()
	{
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		idx++;
		if (idx >= waypoints.Length)
		{
			if (loop)
			{
				idx = 0;
				delayTimer = startDelay;
				started = false;
				((Component)this).transform.rotation = originalRotation;
			}
			else
			{
				((Behaviour)this).enabled = false;
			}
		}
	}

	private void OnDrawGizmos()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: 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)
		if (!((Object)waypointRoot == (Object)null))
		{
			Vector3[] array = (from t in ((Component)waypointRoot).GetComponentsInChildren<Transform>(true)
				where regex.IsMatch(((Object)t).name)
				select new
				{
					p = t.position,
					i = int.Parse(regex.Match(((Object)t).name).Groups[1].Value)
				} into x
				orderby x.i
				select x.p).ToArray();
			Gizmos.color = Color.cyan;
			for (int num = 0; num + 1 < array.Length; num++)
			{
				Gizmos.DrawLine(array[num], array[num + 1]);
			}
		}
	}
}
public class CursedMusicBoxValuable : Trap
{
	[Header("Audio")]
	public Sound cursedMusicSound;

	[Header("Spin Settings")]
	public float spinForce = 50f;

	public float tumbleForce = 15f;

	public float spinInterval = 0.2f;

	[Header("Visual Effects")]
	public ParticleSystem curseSparks;

	public Light curseLight;

	[Header("Animator")]
	public Animator cursedAnimator;

	public string holdBoolParameter = "IsHeld";

	[Header("Camera Shake")]
	public float cameraShakeTime = 0.2f;

	public float cameraShakeStrength = 3f;

	public Vector2 cameraShakeBounds = new Vector2(1.5f, 5f);

	private float spinTimer;

	private Rigidbody rb;

	private bool soundPlaying;

	protected override void Start()
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Expected O, but got Unknown
		((Trap)this).Start();
		rb = ((Component)this).GetComponent<Rigidbody>();
		if ((Object)curseLight != (Object)null)
		{
			((Behaviour)curseLight).enabled = false;
		}
	}

	protected override void Update()
	{
		((Trap)this).Update();
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			CheckForGrabTumble();
		}
		HandleGrabAnimation();
	}

	private void CheckForGrabTumble()
	{
		if (Time.frameCount % 15 != 0 && base.physGrabObject.grabbed)
		{
			ActivateCurseEffects();
			{
				foreach (PhysGrabber item in base.physGrabObject.playerGrabbing)
				{
					SpinAndTumblePlayer(item.playerAvatar);
				}
				return;
			}
		}
		StopCurseEffects();
	}

	private void ActivateCurseEffects()
	{
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Expected O, but got Unknown
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Expected O, but got Unknown
		if (!soundPlaying)
		{
			cursedMusicSound.Play(base.physGrabObject.centerPoint, 1f, 1f, 1f, 1f);
			soundPlaying = true;
		}
		if ((Object)curseLight != (Object)null)
		{
			((Behaviour)curseLight).enabled = true;
		}
		if ((Object)curseSparks != (Object)null && !curseSparks.isPlaying)
		{
			curseSparks.Play();
		}
	}

	private void StopCurseEffects()
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Expected O, but got Unknown
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Expected O, but got Unknown
		if (soundPlaying)
		{
			cursedMusicSound.Stop();
			soundPlaying = false;
		}
		if ((Object)curseLight != (Object)null)
		{
			((Behaviour)curseLight).enabled = false;
		}
		if ((Object)curseSparks != (Object)null && curseSparks.isPlaying)
		{
			curseSparks.Stop();
		}
	}

	private void SpinAndTumblePlayer(PlayerAvatar player)
	{
		//IL_0047: 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_0062: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		spinTimer += Time.deltaTime;
		if (spinTimer >= spinInterval)
		{
			spinTimer = 0f;
			BowlingGameAccess.Tumble(player).TumbleRequest(true, false);
			BowlingGameAccess.Tumble(player).TumbleForce(((Component)player).transform.forward * tumbleForce);
			BowlingGameAccess.Tumble(player).TumbleTorque(Vector3.up * spinForce);
			BowlingGameAccess.Tumble(player).TumbleOverrideTime(2f);
			BowlingGameAccess.Tumble(player).ImpactHurtSet(1f, 5);
			GameDirector.instance.CameraShake.ShakeDistance(cameraShakeStrength, 3f, 8f, ((Component)this).transform.position, cameraShakeTime);
			GameDirector.instance.CameraImpact.ShakeDistance(cameraShakeStrength, cameraShakeBounds.x, cameraShakeBounds.y, ((Component)this).transform.position, cameraShakeTime);
		}
	}

	private void HandleGrabAnimation()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		if (!((Object)cursedAnimator == (Object)null))
		{
			bool grabbed = base.physGrabObject.grabbed;
			cursedAnimator.SetBool(holdBoolParameter, grabbed);
		}
	}
}
public class NetworkedProximityTrigger : MonoBehaviourPun
{
	[Header("Trigger Settings")]
	public float triggerDistance = 2f;

	public float deactivateAfterSeconds = 49f;

	public bool retriggerable;

	[Header("Actions")]
	public VideoPlayer videoPlayer;

	public AudioSource externalAudioSource;

	[Header("Audio Control")]
	public bool startAudioOnActivate;

	public bool stopAudioOnDeactivate;

	public GameObject[] objectsToToggle;

	[Header("Animator Settings")]
	public Animator targetAnimator;

	public string triggerParameterName = "Activate";

	private bool isActive;

	private bool hasTriggered;

	private float timer;

	private PlayerAvatar playerTarget;

	private void FixedUpdate()
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Expected O, but got Unknown
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Expected O, but got Unknown
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		if (hasTriggered)
		{
			return;
		}
		if ((Object)playerTarget == (Object)null)
		{
			foreach (PlayerAvatar item in SemiFunc.PlayerGetList())
			{
				if (!BowlingGameAccess.IsDisabled(item) && Vector3.Distance(((Component)this).transform.position, ((Component)item).transform.position) <= triggerDistance)
				{
					playerTarget = item;
					break;
				}
			}
		}
		if (!((Object)playerTarget != (Object)null) || BowlingGameAccess.IsDisabled(playerTarget))
		{
			return;
		}
		if (!isActive)
		{
			TriggerActivate();
			return;
		}
		timer += Time.fixedDeltaTime;
		if (timer >= deactivateAfterSeconds)
		{
			TriggerDeactivate();
			hasTriggered = true;
		}
	}

	private void TriggerActivate()
	{
		if (SemiFunc.IsMultiplayer())
		{
			((MonoBehaviourPun)this).photonView.RPC("ActivateTrigger", (RpcTarget)3, Array.Empty<object>());
		}
		else
		{
			ActivateTrigger();
		}
	}

	private void TriggerDeactivate()
	{
		if (SemiFunc.IsMultiplayer())
		{
			((MonoBehaviourPun)this).photonView.RPC("DeactivateTrigger", (RpcTarget)3, Array.Empty<object>());
		}
		else
		{
			DeactivateTrigger();
		}
	}

	[PunRPC]
	private void ActivateTrigger()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Expected O, but got Unknown
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Expected O, but got Unknown
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Expected O, but got Unknown
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Expected O, but got Unknown
		if (isActive)
		{
			return;
		}
		isActive = true;
		timer = 0f;
		if ((Object)videoPlayer != (Object)null)
		{
			videoPlayer.Play();
		}
		if (startAudioOnActivate && (Object)externalAudioSource != (Object)null && !externalAudioSource.isPlaying)
		{
			externalAudioSource.Play();
		}
		GameObject[] array = objectsToToggle;
		foreach (GameObject val in array)
		{
			if ((Object)val != (Object)null)
			{
				val.SetActive(true);
			}
		}
		if ((Object)targetAnimator != (Object)null && !string.IsNullOrEmpty(triggerParameterName))
		{
			targetAnimator.SetTrigger(triggerParameterName);
		}
	}

	[PunRPC]
	private void DeactivateTrigger()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Expected O, but got Unknown
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Expected O, but got Unknown
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Expected O, but got Unknown
		if (!isActive)
		{
			return;
		}
		isActive = false;
		playerTarget = null;
		if ((Object)videoPlayer != (Object)null)
		{
			videoPlayer.Stop();
		}
		if (stopAudioOnDeactivate && (Object)externalAudioSource != (Object)null)
		{
			externalAudioSource.Stop();
		}
		GameObject[] array = objectsToToggle;
		foreach (GameObject val in array)
		{
			if ((Object)val != (Object)null)
			{
				val.SetActive(false);
			}
		}
	}
}
public class PlayerWallBlocker : Trap
{
	[Header("Push Settings")]
	public float blockRange = 2f;

	public float pushForce = 30f;

	protected override void Update()
	{
		((Trap)this).Update();
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			PushBackNearbyPlayers();
		}
	}

	private void PushBackNearbyPlayers()
	{
		//IL_0026: 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_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: 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_005e: 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_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		foreach (PlayerAvatar item in SemiFunc.PlayerGetList())
		{
			if (!BowlingGameAccess.IsDisabled(item) && Vector3.Distance(((Component)this).transform.position, ((Component)item).transform.position) <= blockRange)
			{
				Vector3 val = ((Component)item).transform.position - ((Component)this).transform.position;
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				normalized.y = 0f;
				BowlingGameAccess.TumbleRigidbody(item).AddForce(normalized * pushForce * Time.deltaTime, (ForceMode)2);
			}
		}
	}
}
public class TeleportGlitchValuable : Trap
{
	[Header("Teleport Settings")]
	public float teleportForce = 150f;

	public float teleportInterval = 2f;

	private float teleportTimer;

	protected override void Update()
	{
		((Trap)this).Update();
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			CheckForGrabTeleport();
		}
	}

	private void CheckForGrabTeleport()
	{
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Expected O, but got Unknown
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Expected O, but got Unknown
		if (base.physGrabObject.grabbed)
		{
			teleportTimer += Time.deltaTime;
			if (!(teleportTimer >= teleportInterval))
			{
				return;
			}
			teleportTimer = 0f;
			{
				foreach (PhysGrabber item in base.physGrabObject.playerGrabbing)
				{
					if ((Object)item != (Object)null && (Object)item.playerAvatar != (Object)null)
					{
						ApplyTeleportEffect(item.playerAvatar);
					}
				}
				return;
			}
		}
		teleportTimer = 0f;
	}

	private void ApplyTeleportEffect(PlayerAvatar player)
	{
		//IL_000d: 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_0019: 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)
		BowlingGameAccess.Tumble(player).TumbleRequest(true, false);
		Vector3 up = Vector3.up;
		BowlingGameAccess.Tumble(player).TumbleForce(up * teleportForce);
		BowlingGameAccess.Tumble(player).TumbleOverrideTime(1.5f);
	}
}
internal static class BowlingGameAccess
{
	private static readonly FieldInfo PlayerDisabledField = AccessTools.Field(typeof(PlayerAvatar), "isDisabled");

	private static readonly FieldInfo PlayerTumbleField = AccessTools.Field(typeof(PlayerAvatar), "tumble");

	private static readonly FieldInfo PlayerHealthField = AccessTools.Field(typeof(PlayerHealth), "health");

	private static readonly FieldInfo ItemToggleImpulseField = AccessTools.Field(typeof(ItemToggle), "toggleImpulse");

	private static readonly FieldInfo TumbleRigidbodyField = AccessTools.Field(typeof(PlayerTumble), "rb");

	private static readonly FieldInfo TumbleActiveField = AccessTools.Field(typeof(PlayerTumble), "isTumbling");

	internal static bool IsDisabled(PlayerAvatar player)
	{
		if (!((Object)(object)player == (Object)null) && !(PlayerDisabledField == null))
		{
			return (bool)PlayerDisabledField.GetValue(player);
		}
		return true;
	}

	internal static PlayerTumble Tumble(PlayerAvatar player)
	{
		if (!((Object)(object)player == (Object)null) && !(PlayerTumbleField == null))
		{
			object? value = PlayerTumbleField.GetValue(player);
			return (PlayerTumble)((value is PlayerTumble) ? value : null);
		}
		return null;
	}

	internal static int Health(PlayerHealth playerHealth)
	{
		if (!((Object)(object)playerHealth == (Object)null) && !(PlayerHealthField == null))
		{
			return (int)PlayerHealthField.GetValue(playerHealth);
		}
		return 0;
	}

	internal static bool ToggleImpulse(ItemToggle itemToggle)
	{
		if ((Object)(object)itemToggle != (Object)null && ItemToggleImpulseField != null)
		{
			return (bool)ItemToggleImpulseField.GetValue(itemToggle);
		}
		return false;
	}

	internal static Rigidbody TumbleRigidbody(PlayerAvatar player)
	{
		PlayerTumble val = Tumble(player);
		if (!((Object)(object)val == (Object)null) && !(TumbleRigidbodyField == null))
		{
			object? value = TumbleRigidbodyField.GetValue(val);
			return (Rigidbody)((value is Rigidbody) ? value : null);
		}
		return null;
	}

	internal static bool IsTumbling(PlayerAvatar player)
	{
		PlayerTumble val = Tumble(player);
		if ((Object)(object)val != (Object)null && TumbleActiveField != null)
		{
			return (bool)TumbleActiveField.GetValue(val);
		}
		return false;
	}
}
namespace Empress.REPO.Bowling
{
	[BepInPlugin("Omniscye.Bowling", "Empress Bowling", "2.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class EmpressBowlingPlugin : BaseUnityPlugin
	{
		internal const string PluginGuid = "Omniscye.Bowling";

		internal const string PluginName = "Empress Bowling";

		internal const string PluginVersion = "2.0.0";

		internal static ManualLogSource EmpressLog { get; private set; }

		private void Awake()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			EmpressLog = ((BaseUnityPlugin)this).Logger;
			GameObject gameObject = ((Component)this).gameObject;
			((Object)gameObject).hideFlags = (HideFlags)(((Object)gameObject).hideFlags | 0x23);
			new Harmony("Omniscye.Bowling").PatchAll();
			BowlingLogSilencer.Install();
			BundleLoader.OnAllBundlesLoaded += BowlingLevelCompatibility.RepairRegisteredLevel;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Empress Bowling v2.0.0 loaded.");
		}

		private void OnDestroy()
		{
			BundleLoader.OnAllBundlesLoaded -= BowlingLevelCompatibility.RepairRegisteredLevel;
		}
	}
	internal static class BowlingLevelCompatibility
	{
		private const string BundleFileName = "Bowling.repobundle";

		private const string LevelName = "Level - Bowling";

		private const string StartRoomName = "Star Room - Bowlingy";

		private static readonly string[] ContentListFields = new string[12]
		{
			"_modulesNormal1", "_modulesPassage1", "_modulesDeadEnd1", "_modulesExtraction1", "_modulesNormal2", "_modulesPassage2", "_modulesDeadEnd2", "_modulesExtraction2", "_modulesNormal3", "_modulesPassage3",
			"_modulesDeadEnd3", "_modulesExtraction3"
		};

		private static readonly string[] LoadingGraphicFields = new string[3] { "LoadingGraphic01", "LoadingGraphic02", "LoadingGraphic03" };

		private static AssetBundle _bundle;

		private static GameObject _startRoom;

		private static Sprite _loadingSprite;

		private static bool _loggedRepair;

		internal static void PrepareLevelContent(LevelContent content)
		{
			if ((Object)(object)content == (Object)null || !IsBowlingLevel(content.Level))
			{
				return;
			}
			AssetBundle val = ((Content)content).Bundle ?? GetBundle();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			_bundle = val;
			GameObject startRoom = GetStartRoom(val);
			if ((Object)(object)startRoom == (Object)null)
			{
				ManualLogSource empressLog = EmpressBowlingPlugin.EmpressLog;
				if (empressLog != null)
				{
					empressLog.LogError((object)"Empress Bowling could not restore its start room from Bowling.repobundle.");
				}
				return;
			}
			SetContentList(content, "_startRooms", new List<GameObject> { startRoom });
			string[] contentListFields = ContentListFields;
			foreach (string fieldName in contentListFields)
			{
				SetContentList(content, fieldName, new List<GameObject>());
			}
			EnsureLevelData(content.Level);
			CacheLoadingSprite(val);
		}

		internal static void RepairRegisteredLevel()
		{
			Level val = FindBowlingLevel();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			EnsureLevelData(val);
			EnsureLoadingGraphics(val);
			if (val.StartRooms == null || val.StartRooms.Count == 0)
			{
				GameObject startRoom = GetStartRoom(GetBundle());
				if (startRoom != null)
				{
					val.StartRooms = RegisterStartRoom(val, startRoom);
				}
			}
			if (!_loggedRepair && val.StartRooms != null && val.StartRooms.Count > 0)
			{
				_loggedRepair = true;
				ManualLogSource empressLog = EmpressBowlingPlugin.EmpressLog;
				if (empressLog != null)
				{
					empressLog.LogInfo((object)"Empress Bowling repaired Level - Bowling with its original start room.");
				}
			}
		}

		internal static void PrepareCurrentLevel()
		{
			Level val = (((Object)(object)LevelGenerator.Instance != (Object)null) ? LevelGenerator.Instance.Level : null);
			if (!IsBowlingLevel(val) && (Object)(object)RunManager.instance != (Object)null)
			{
				val = RunManager.instance.levelCurrent;
			}
			if (!IsBowlingLevel(val))
			{
				return;
			}
			EnsureLevelData(val);
			EnsureLoadingGraphics(val);
			if (val.StartRooms == null || val.StartRooms.Count == 0)
			{
				GameObject startRoom = GetStartRoom(GetBundle());
				if (startRoom != null)
				{
					val.StartRooms = RegisterStartRoom(val, startRoom);
				}
			}
		}

		internal static void ApplyLoadingSprite(LoadingUI loadingUI)
		{
			if (!((Object)(object)loadingUI == (Object)null) && IsCurrentBowlingLevel())
			{
				CacheLoadingSprite(GetBundle());
				if (!((Object)(object)_loadingSprite == (Object)null))
				{
					ApplySprite(loadingUI.loadingGraphic01);
					ApplySprite(loadingUI.loadingGraphic02);
					ApplySprite(loadingUI.loadingGraphic03);
				}
			}
		}

		internal static bool IsBowlingLevel(Level level)
		{
			if ((Object)(object)level != (Object)null)
			{
				if (!string.Equals(((Object)level).name, "Level - Bowling", StringComparison.OrdinalIgnoreCase) && (string.IsNullOrWhiteSpace(((Object)level).name) || ((Object)level).name.IndexOf("Bowling", StringComparison.OrdinalIgnoreCase) < 0))
				{
					if (!string.IsNullOrWhiteSpace(level.NarrativeName))
					{
						return level.NarrativeName.IndexOf("Bowling", StringComparison.OrdinalIgnoreCase) >= 0;
					}
					return false;
				}
				return true;
			}
			return false;
		}

		internal static bool IsCurrentBowlingLevel()
		{
			if (!IsBowlingLevel(((Object)(object)LevelGenerator.Instance != (Object)null) ? LevelGenerator.Instance.Level : null))
			{
				return IsBowlingLevel(((Object)(object)RunManager.instance != (Object)null) ? RunManager.instance.levelCurrent : null);
			}
			return true;
		}

		private static Level FindBowlingLevel()
		{
			if (Levels.AllLevels != null)
			{
				foreach (Level allLevel in Levels.AllLevels)
				{
					if (IsBowlingLevel(allLevel))
					{
						return allLevel;
					}
				}
			}
			if ((Object)(object)RunManager.instance != (Object)null && RunManager.instance.levels != null)
			{
				foreach (Level level in RunManager.instance.levels)
				{
					if (IsBowlingLevel(level))
					{
						return level;
					}
				}
			}
			return null;
		}

		private static AssetBundle GetBundle()
		{
			if ((Object)(object)_bundle != (Object)null)
			{
				return _bundle;
			}
			foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles())
			{
				try
				{
					if (allLoadedAssetBundle.GetAllAssetNames().Any((string name) => name.IndexOf("bowling", StringComparison.OrdinalIgnoreCase) >= 0))
					{
						_bundle = allLoadedAssetBundle;
						return _bundle;
					}
				}
				catch
				{
				}
			}
			string text = Directory.GetFiles(Paths.PluginPath, "Bowling.repobundle", SearchOption.AllDirectories).FirstOrDefault();
			if (!string.IsNullOrWhiteSpace(text))
			{
				_bundle = AssetBundle.LoadFromFile(text);
			}
			return _bundle;
		}

		private static GameObject GetStartRoom(AssetBundle bundle)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_startRoom != (Object)null)
			{
				return _startRoom;
			}
			if ((Object)(object)bundle == (Object)null)
			{
				return null;
			}
			bundle.LoadAllAssets<Object>();
			StartRoom[] array = Resources.FindObjectsOfTypeAll<StartRoom>();
			foreach (StartRoom val in array)
			{
				if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)null))
				{
					Scene scene = ((Component)val).gameObject.scene;
					if (!((Scene)(ref scene)).IsValid() && (Object)(object)((Component)val).transform.parent == (Object)null && string.Equals(((Object)((Component)val).gameObject).name, "Star Room - Bowlingy", StringComparison.OrdinalIgnoreCase))
					{
						_startRoom = ((Component)val).gameObject;
						return _startRoom;
					}
				}
			}
			return null;
		}

		private static void SetContentList(LevelContent content, string fieldName, List<GameObject> value)
		{
			AccessTools.Field(typeof(LevelContent), fieldName)?.SetValue(content, value);
		}

		private static void EnsureLevelData(Level level)
		{
			if ((Object)(object)level == (Object)null)
			{
				return;
			}
			Level val = level;
			if (val.ValuablePresets == null)
			{
				val.ValuablePresets = new List<LevelValuables>();
			}
			val = level;
			if (val.AmbiencePresets == null)
			{
				val.AmbiencePresets = new List<LevelAmbience>();
			}
			level.ModuleAmount = 1;
			level.ModulesSpecialAmount = 0;
			level.HasEnemies = false;
			val = level;
			if (val.StartRooms == null)
			{
				val.StartRooms = new List<PrefabRef>();
			}
			val = level;
			if (val.ModulesNormal1 == null)
			{
				val.ModulesNormal1 = new List<PrefabRef>();
			}
			val = level;
			if (val.ModulesPassage1 == null)
			{
				val.ModulesPassage1 = new List<PrefabRef>();
			}
			val = level;
			if (val.ModulesDeadEnd1 == null)
			{
				val.ModulesDeadEnd1 = new List<PrefabRef>();
			}
			val = level;
			if (val.ModulesExtraction1 == null)
			{
				val.ModulesExtraction1 = new List<PrefabRef>();
			}
			val = level;
			if (val.ModulesNormal2 == null)
			{
				val.ModulesNormal2 = new List<PrefabRef>();
			}
			val = level;
			if (val.ModulesPassage2 == null)
			{
				val.ModulesPassage2 = new List<PrefabRef>();
			}
			val = level;
			if (val.ModulesDeadEnd2 == null)
			{
				val.ModulesDeadEnd2 = new List<PrefabRef>();
			}
			val = level;
			if (val.ModulesExtraction2 == null)
			{
				val.ModulesExtraction2 = new List<PrefabRef>();
			}
			val = level;
			if (val.ModulesNormal3 == null)
			{
				val.ModulesNormal3 = new List<PrefabRef>();
			}
			val = level;
			if (val.ModulesPassage3 == null)
			{
				val.ModulesPassage3 = new List<PrefabRef>();
			}
			val = level;
			if (val.ModulesDeadEnd3 == null)
			{
				val.ModulesDeadEnd3 = new List<PrefabRef>();
			}
			val = level;
			if (val.ModulesExtraction3 == null)
			{
				val.ModulesExtraction3 = new List<PrefabRef>();
			}
			if (level.ValuablePresets.Count == 0 && (Object)(object)ValuablePresets.GenericValuablePreset != (Object)null)
			{
				level.ValuablePresets.Add(ValuablePresets.GenericValuablePreset);
			}
			if (level.AmbiencePresets.Count == 0)
			{
				LevelAmbience val2 = FindFallbackAmbience(level);
				if ((Object)(object)val2 != (Object)null)
				{
					level.AmbiencePresets.Add(val2);
				}
			}
			EnsureLoadingGraphics(level);
		}

		private static List<PrefabRef> RegisterStartRoom(Level level, GameObject startRoom)
		{
			string text = "Level/" + ((Object)level).name + "/StartRoom/" + ((Object)startRoom).name;
			if (NetworkPrefabs.PrefabRefs.TryGetValue(text, out var value) && value != null)
			{
				return new List<PrefabRef> { value };
			}
			Utilities.FixAudioMixerGroups(startRoom);
			PrefabRef val = NetworkPrefabs.RegisterNetworkPrefab(text, startRoom);
			if (val != null)
			{
				return new List<PrefabRef> { val };
			}
			return new List<PrefabRef>();
		}

		private static void EnsureLoadingGraphics(Level level)
		{
			string[] loadingGraphicFields = LoadingGraphicFields;
			foreach (string text in loadingGraphicFields)
			{
				FieldInfo fieldInfo = AccessTools.Field(typeof(Level), text);
				if (!(fieldInfo == null))
				{
					object obj = fieldInfo.GetValue(level);
					if (obj == null)
					{
						obj = Activator.CreateInstance(fieldInfo.FieldType);
						fieldInfo.SetValue(level, obj);
					}
					ClearPrefabRef(obj);
				}
			}
		}

		private static void ClearPrefabRef(object prefabRef)
		{
			if (prefabRef != null)
			{
				AccessTools.Field(prefabRef.GetType(), "prefabName")?.SetValue(prefabRef, null);
				AccessTools.Field(prefabRef.GetType(), "resourcePath")?.SetValue(prefabRef, null);
				AccessTools.Field(prefabRef.GetType(), "bundle")?.SetValue(prefabRef, null);
			}
		}

		private static LevelAmbience FindFallbackAmbience(Level bowlingLevel)
		{
			if ((Object)(object)RunManager.instance == (Object)null || RunManager.instance.levels == null)
			{
				return null;
			}
			foreach (Level level in RunManager.instance.levels)
			{
				if (!((Object)(object)level == (Object)null) && !((Object)(object)level == (Object)(object)bowlingLevel) && !IsBowlingLevel(level) && level.AmbiencePresets != null && level.AmbiencePresets.Count > 0 && (Object)(object)level.AmbiencePresets[0] != (Object)null)
				{
					return level.AmbiencePresets[0];
				}
			}
			return null;
		}

		private static void CacheLoadingSprite(AssetBundle bundle)
		{
			if ((Object)(object)_loadingSprite != (Object)null)
			{
				return;
			}
			_loadingSprite = LoadExternalLoadingSprite();
			if (!((Object)(object)_loadingSprite != (Object)null) && !((Object)(object)bundle == (Object)null))
			{
				bundle.LoadAllAssets<Object>();
				_loadingSprite = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite sprite) => (Object)(object)sprite != (Object)null && string.Equals(((Object)sprite).name, "OMNISI", StringComparison.OrdinalIgnoreCase)));
			}
		}

		private static Sprite LoadExternalLoadingSprite()
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				string directoryName = Path.GetDirectoryName(typeof(BowlingLevelCompatibility).Assembly.Location);
				string text = ((directoryName != null) ? Path.Combine(directoryName, "Empress.png") : null);
				if (string.IsNullOrEmpty(text) || !File.Exists(text))
				{
					text = Directory.GetFiles(Paths.PluginPath, "Empress.png", SearchOption.AllDirectories).FirstOrDefault();
				}
				if (string.IsNullOrEmpty(text) || !File.Exists(text))
				{
					return null;
				}
				Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false)
				{
					name = "EmpressLoadingGraphic"
				};
				if (!ImageConversion.LoadImage(val, File.ReadAllBytes(text)))
				{
					return null;
				}
				((Texture)val).wrapMode = (TextureWrapMode)1;
				return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
			}
			catch
			{
				return null;
			}
		}

		private static void ApplySprite(Image image)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)image == (Object)null))
			{
				image.sprite = _loadingSprite;
				((Graphic)image).color = Color.white;
				image.preserveAspect = true;
			}
		}
	}
	internal sealed class BowlingLogSilencer : ILogHandler
	{
		private static readonly string[] DropSubstrings = new string[3] { "Missing room volume", "PrefabRef failed to load", "missing ambience preset" };

		private readonly ILogHandler _inner;

		private BowlingLogSilencer(ILogHandler inner)
		{
			_inner = inner;
		}

		internal static void Install()
		{
			if (!(Debug.unityLogger.logHandler is BowlingLogSilencer))
			{
				Debug.unityLogger.logHandler = (ILogHandler)(object)new BowlingLogSilencer(Debug.unityLogger.logHandler);
			}
		}

		public void LogFormat(LogType logType, Object context, string format, params object[] args)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			if ((int)logType != 0 || !ShouldDrop(format, args))
			{
				_inner.LogFormat(logType, context, format, args);
			}
		}

		public void LogException(Exception exception, Object context)
		{
			if (!IsSilencedException(exception))
			{
				_inner.LogException(exception, context);
			}
		}

		private static bool ShouldDrop(string format, object[] args)
		{
			try
			{
				if (!ContainsDropString(format) && !ArgsContainDropString(args))
				{
					return false;
				}
				return BowlingLevelCompatibility.IsCurrentBowlingLevel();
			}
			catch
			{
				return false;
			}
		}

		private static bool IsSilencedException(Exception exception)
		{
			try
			{
				if (exception == null || exception.StackTrace == null)
				{
					return false;
				}
				if (exception.StackTrace.IndexOf("PlayerNameChecker", StringComparison.Ordinal) < 0)
				{
					return false;
				}
				return BowlingLevelCompatibility.IsCurrentBowlingLevel();
			}
			catch
			{
				return false;
			}
		}

		private static bool ArgsContainDropString(object[] args)
		{
			if (args == null)
			{
				return false;
			}
			foreach (object obj in args)
			{
				if (obj != null && ContainsDropString(obj.ToString()))
				{
					return true;
				}
			}
			return false;
		}

		private static bool ContainsDropString(string value)
		{
			if (string.IsNullOrEmpty(value))
			{
				return false;
			}
			string[] dropSubstrings = DropSubstrings;
			foreach (string value2 in dropSubstrings)
			{
				if (value.IndexOf(value2, StringComparison.OrdinalIgnoreCase) >= 0)
				{
					return true;
				}
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(Levels), "RegisterLevel")]
	internal static class BowlingRegisterLevelPatch
	{
		[HarmonyPrefix]
		private static void Prefix(LevelContent levelContent)
		{
			BowlingLevelCompatibility.PrepareLevelContent(levelContent);
		}
	}
	[HarmonyPatch(typeof(LevelGenerator), "StartRoomGeneration")]
	internal static class BowlingStartRoomGenerationPatch
	{
		[HarmonyPrefix]
		private static void Prefix()
		{
			BowlingLevelCompatibility.PrepareCurrentLevel();
		}
	}
	[HarmonyPatch(typeof(LoadingUI), "LevelAnimationStart")]
	internal static class BowlingLoadingPatch
	{
		[HarmonyPrefix]
		private static void Prefix()
		{
			BowlingLevelCompatibility.PrepareCurrentLevel();
		}

		[HarmonyPostfix]
		private static void Postfix(LoadingUI __instance)
		{
			BowlingLevelCompatibility.ApplyLoadingSprite(__instance);
		}
	}
	[HarmonyPatch(typeof(PlayerNameChecker), "Update")]
	internal static class BowlingPlayerNameSilencer
	{
		[HarmonyFinalizer]
		private static Exception Finalizer(Exception __exception)
		{
			if (__exception == null || !BowlingLevelCompatibility.IsCurrentBowlingLevel())
			{
				return __exception;
			}
			return null;
		}
	}
}
namespace NWH.DWP2.DefaultWater
{
	[ExecuteInEditMode]
	[RequireComponent(typeof(WaterBase))]
	public class Displace : MonoBehaviour
	{
		public void Awake()
		{
			if (((Behaviour)this).enabled)
			{
				OnEnable();
			}
			else
			{
				OnDisable();
			}
		}

		public void OnEnable()
		{
			Shader.EnableKeyword("WATER_VERTEX_DISPLACEMENT_ON");
			Shader.DisableKeyword("WATER_VERTEX_DISPLACEMENT_OFF");
		}

		public void OnDisable()
		{
			Shader.EnableKeyword("WATER_VERTEX_DISPLACEMENT_OFF");
			Shader.DisableKeyword("WATER_VERTEX_DISPLACEMENT_ON");
		}
	}
	[ExecuteInEditMode]
	[RequireComponent(typeof(WaterBase))]
	public class GerstnerDisplace : Displace
	{
	}
	public class MeshContainer
	{
		public Mesh mesh;

		public Vector3[] vertices;

		public Vector3[] normals;

		public MeshContainer(Mesh m)
		{
			mesh = m;
			vertices = m.vertices;
			normals = m.normals;
		}

		public void Update()
		{
			mesh.vertices = vertices;
			mesh.normals = normals;
		}
	}
	[ExecuteInEditMode]
	[RequireComponent(typeof(WaterBase))]
	public class PlanarReflection : MonoBehaviour
	{
		public LayerMask reflectionMask;

		public bool reflectSkybox;

		public Color clearColor = Color.grey;

		public string reflectionSampler = "_ReflectionTex";

		public float clipPlaneOffset = 0.07f;

		private Vector3 m_Oldpos;

		private Camera m_ReflectionCamera;

		private Material m_SharedMaterial;

		private Dictionary<Camera, bool> m_HelperCameras;

		public void Start()
		{
			m_SharedMaterial = ((WaterBase)(object)((Component)this).gameObject.GetComponent(typeof(WaterBase))).sharedMaterial;
		}

		public void LateUpdate()
		{
			if (m_HelperCameras != null)
			{
				m_HelperCameras.Clear();
			}
		}

		private Camera CreateReflectionCameraFor(Camera cam)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			string text = ((Object)((Component)this).gameObject).name + "Reflection" + ((Object)cam).name;
			GameObject val = GameObject.Find(text);
			if (!Object.op_Implicit((Object)val))
			{
				val = new GameObject(text, new Type[1] { typeof(Camera) });
			}
			if (!Object.op_Implicit((Object)val.GetComponent(typeof(Camera))))
			{
				val.AddComponent(typeof(Camera));
			}
			Camera component = val.GetComponent<Camera>();
			component.backgroundColor = clearColor;
			component.clearFlags = (CameraClearFlags)(reflectSkybox ? 1 : 2);
			SetStandardCameraParameter(component, reflectionMask);
			if (!Object.op_Implicit((Object)component.targetTexture))
			{
				component.targetTexture = CreateTextureFor(cam);
			}
			return component;
		}

		private void SetStandardCameraParameter(Camera cam, LayerMask mask)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			cam.cullingMask = LayerMask.op_Implicit(mask) & ~(1 << LayerMask.NameToLayer("Water"));
			cam.backgroundColor = Color.black;
			((Behaviour)cam).enabled = false;
		}

		private RenderTexture CreateTextureFor(Camera cam)
		{
			//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_0034: Expected O, but got Unknown
			return new RenderTexture(Mathf.FloorToInt((float)cam.pixelWidth * 0.5f), Mathf.FloorToInt((float)cam.pixelHeight * 0.5f), 24)
			{
				hideFlags = (HideFlags)52
			};
		}

		public void RenderHelpCameras(Camera currentCam)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			if (m_HelperCameras == null)
			{
				m_HelperCameras = new Dictionary<Camera, bool>();
			}
			if (!m_HelperCameras.ContainsKey(currentCam))
			{
				m_HelperCameras.Add(currentCam, value: false);
			}
			if (!m_HelperCameras[currentCam])
			{
				if (!Object.op_Implicit((Object)m_ReflectionCamera))
				{
					m_ReflectionCamera = CreateReflectionCameraFor(currentCam);
				}
				RenderReflectionFor(currentCam, m_ReflectionCamera);
				m_HelperCameras[currentCam] = true;
			}
		}

		public void WaterTileBeingRendered(Transform tr, Camera currentCam)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			RenderHelpCameras(currentCam);
			if (Object.op_Implicit((Object)m_ReflectionCamera) && Object.op_Implicit((Object)m_SharedMaterial))
			{
				m_SharedMaterial.SetTexture(reflectionSampler, (Texture)m_ReflectionCamera.targetTexture);
			}
		}

		public void OnEnable()
		{
			Shader.EnableKeyword("WATER_REFLECTIVE");
			Shader.DisableKeyword("WATER_SIMPLE");
		}

		public void OnDisable()
		{
			Shader.EnableKeyword("WATER_SIMPLE");
			Shader.DisableKeyword("WATER_REFLECTIVE");
		}

		private void RenderReflectionFor(Camera cam, Camera reflectCamera)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: 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_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: 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_016a: 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_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: 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_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: 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_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: 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)
			//IL_01c8: 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_01cf: 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_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)