Decompiled source of Rosays Valuables v1.0.3

RosayValuablesAPI.dll

Decompiled 18 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using RosayValuablesAPI;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.UI;

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

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 AMCTrap : Trap
{
	[Header("Sepia Filter Settings")]
	public float sepiaIntensity = 1f;

	private bool sepiaAppliedLocal = false;

	public override void Start()
	{
		((Trap)this).Start();
	}

	public override void Update()
	{
		((Trap)this).Update();
		if (base.physGrabObject.grabbed && !sepiaAppliedLocal && base.physGrabObject.grabbedLocal)
		{
			PostProcessing.Instance.SetSepiaOverride(sepiaIntensity, 9999f, ((Component)this).gameObject);
			sepiaAppliedLocal = true;
		}
		if ((!base.physGrabObject.grabbed || !base.physGrabObject.grabbedLocal) && sepiaAppliedLocal)
		{
			PostProcessing.Instance.ClearSepiaOverride(((Component)this).gameObject);
			sepiaAppliedLocal = false;
		}
	}
}
public class AsciiUIManager : MonoBehaviour
{
	[CompilerGenerated]
	private sealed class <DelayedShow>d__7 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public AsciiUIManager <>4__this;

		private GameObject <container>5__1;

		private RawImage <raw>5__2;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <DelayedShow>d__7(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<container>5__1 = null;
			<raw>5__2 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(0.1f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<container>5__1 = GameObject.Find("UI/UI/Canvas/Render Texture Main");
				if ((Object)(object)<container>5__1 == (Object)null)
				{
					Debug.LogError((object)"[AsciiUIManager] Render Texture Main not found.");
					return false;
				}
				if ((Object)(object)<>4__this.uiInstance != (Object)null)
				{
					Debug.LogWarning((object)"[AsciiUIManager] Overlay already active.");
					return false;
				}
				<>4__this.uiInstance = Object.Instantiate<GameObject>(<>4__this.asciiUIPrefab, <container>5__1.transform);
				((Object)<>4__this.uiInstance).name = "Render Texture ASCII(Clone)";
				<>4__this.uiInstance.transform.SetSiblingIndex(0);
				<raw>5__2 = <>4__this.uiInstance.GetComponentInChildren<RawImage>();
				if ((Object)(object)<raw>5__2 == (Object)null)
				{
					Debug.LogWarning((object)"[AsciiUIManager] UI prefab has no RawImage component.");
					return false;
				}
				if ((Object)(object)RenderTextureMain.instance != (Object)null && (Object)(object)RenderTextureMain.instance.renderTexture != (Object)null)
				{
					<raw>5__2.texture = (Texture)(object)RenderTextureMain.instance.renderTexture;
					Debug.Log((object)"[AsciiUIManager] Assigned RenderTextureMain.instance.renderTexture.");
				}
				else
				{
					Debug.LogWarning((object)"[AsciiUIManager] RenderTextureMain.instance or renderTexture is null!");
				}
				<>4__this.overlayShown = true;
				Debug.Log((object)"[AsciiUIManager] Overlay shown.");
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	public static AsciiUIManager current;

	[Tooltip("Prefab for the ASCII UI to instantiate (must contain a RawImage)")]
	public GameObject asciiUIPrefab;

	private GameObject uiInstance;

	private bool overlayShown = false;

	private void Awake()
	{
		if ((Object)(object)current != (Object)null && (Object)(object)current != (Object)(object)this)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
			return;
		}
		current = this;
		Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
	}

	public void ShowOverlay()
	{
		if (overlayShown || (Object)(object)asciiUIPrefab == (Object)null)
		{
			Debug.LogWarning((object)"[AsciiUIManager] Overlay already shown or prefab missing.");
		}
		else
		{
			((MonoBehaviour)this).StartCoroutine(DelayedShow());
		}
	}

	public void HideOverlay()
	{
		if ((Object)(object)uiInstance != (Object)null)
		{
			Object.Destroy((Object)(object)uiInstance);
			uiInstance = null;
		}
		overlayShown = false;
		Debug.Log((object)"[AsciiUIManager] Overlay hidden.");
	}

	[IteratorStateMachine(typeof(<DelayedShow>d__7))]
	private IEnumerator DelayedShow()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <DelayedShow>d__7(0)
		{
			<>4__this = this
		};
	}
}
public class CATrap : Trap
{
	private bool reverseActiveLocal = false;

	public override void Start()
	{
		((Trap)this).Start();
	}

	public override void Update()
	{
		((Trap)this).Update();
		if (base.physGrabObject.grabbed && !reverseActiveLocal && base.physGrabObject.grabbedLocal)
		{
			PlayerControllerReverseTranspiler.EnableReverseControls();
			reverseActiveLocal = true;
		}
		if ((!base.physGrabObject.grabbed || !base.physGrabObject.grabbedLocal) && reverseActiveLocal)
		{
			PlayerControllerReverseTranspiler.DisableReverseControls();
			reverseActiveLocal = false;
		}
	}
}
public class ChessKnightTrap : Trap
{
	[Header("Hop Settings")]
	public float hopUpForce = 6f;

	public float hopForwardForce = 3f;

	public float minHopCooldown = 0.25f;

	[Header("Audio")]
	[SerializeField]
	public AudioSource? audioSource = null;

	[SerializeField]
	public AudioClip? hopSound = null;

	[Header("Enemy Investigate")]
	public float investigateRange = 7f;

	private Rigidbody? rb = null;

	private PhysGrabObjectImpactDetector? impactDetector = null;

	private float lastHopTime = -999f;

	public override void Start()
	{
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Expected O, but got Unknown
		((Trap)this).Start();
		rb = ((Component)this).GetComponent<Rigidbody>();
		impactDetector = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
		if ((Object)(object)audioSource == (Object)null)
		{
			audioSource = ((Component)this).GetComponent<AudioSource>();
		}
		if ((Object)(object)impactDetector != (Object)null)
		{
			impactDetector.onAllImpacts.AddListener(new UnityAction(OnAnyImpact));
		}
	}

	private void OnDestroy()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Expected O, but got Unknown
		if ((Object)(object)impactDetector != (Object)null)
		{
			impactDetector.onAllImpacts.RemoveListener(new UnityAction(OnAnyImpact));
		}
	}

	private void OnAnyImpact()
	{
		if (!(Time.time - lastHopTime < minHopCooldown) && (!SemiFunc.IsMultiplayer() || SemiFunc.IsMasterClient()))
		{
			lastHopTime = Time.time;
			if ((Object)(object)base.photonView != (Object)null)
			{
				base.photonView.RPC("RPCHop", (RpcTarget)0, Array.Empty<object>());
			}
		}
	}

	[PunRPC]
	public void RPCHop()
	{
		Hop();
	}

	private void Hop()
	{
		//IL_001c: 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_003e: 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_005f: 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)
		if (!((Object)(object)rb == (Object)null))
		{
			rb.velocity = Vector3.zero;
			rb.angularVelocity = Vector3.zero;
			rb.AddForce(Vector3.up * hopUpForce + ((Component)this).transform.forward * hopForwardForce, (ForceMode)1);
			if ((Object)(object)audioSource != (Object)null && (Object)(object)hopSound != (Object)null)
			{
				audioSource.PlayOneShot(hopSound);
			}
			base.enemyInvestigate = true;
			base.enemyInvestigateRange = investigateRange;
		}
	}
}
public class MirrorTrap : MonoBehaviour
{
	[Header("Mirror Trap")]
	public float lookThreshold = 5f;

	public float rampTime = 3f;

	public AudioSource? whisperSource;

	public AudioClip? crackSound;

	public float reverseDuration = 15f;

	public Collider? mirrorCollider;

	public float requiredDot = 0.97f;

	public LayerMask raycastMask;

	public float maxCheckDistance = 12f;

	[Header("PostProcessing")]
	public float vignetteIntensity = 0.5f;

	public float vignetteSmoothness = 0.6f;

	public Color vignetteColor = new Color(0.3f, 0.1f, 0.1f, 1f);

	[Header("Camera Shake")]
	public float maxShakeStrength = 1.5f;

	public float shakeTime = 0.2f;

	private float lookTimer = 0f;

	private bool trapTriggered = false;

	private bool reverseActive = false;

	private float reverseTimer = 0f;

	private Transform? playerCam = null;

	private GameObject? vignetteObj = null;

	private GameObject? saturationObj = null;

	private bool fadingPostFX = false;

	private float fadeOutTimer = 0f;

	private float fadeOutDuration = 1.25f;

	private void Start()
	{
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Expected O, but got Unknown
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Expected O, but got Unknown
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)whisperSource != (Object)null)
		{
			whisperSource.volume = 0f;
			if (!whisperSource.isPlaying)
			{
				whisperSource.Play();
			}
		}
		if (((LayerMask)(ref raycastMask)).value == 0)
		{
			int num = LayerMask.NameToLayer("RoomVolume");
			if (num != -1)
			{
				raycastMask = LayerMask.op_Implicit(~(1 << num));
			}
			else
			{
				raycastMask = LayerMask.op_Implicit(-1);
			}
		}
		vignetteObj = new GameObject("MirrorTrapVignette_" + ((Object)this).GetInstanceID());
		saturationObj = new GameObject("MirrorTrapSaturation_" + ((Object)this).GetInstanceID());
	}

	private void Update()
	{
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: 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_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_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_041d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0555: Unknown result type (might be due to invalid IL or missing references)
		//IL_0340: Unknown result type (might be due to invalid IL or missing references)
		PlayerAvatar instance = PlayerAvatar.instance;
		if ((Object)(object)instance == (Object)null || !instance.isLocal)
		{
			return;
		}
		playerCam = instance.localCameraTransform;
		if ((Object)(object)playerCam == (Object)null)
		{
			return;
		}
		Vector3 val;
		if (!((Object)(object)mirrorCollider != (Object)null))
		{
			val = ((Component)this).transform.position;
		}
		else
		{
			Bounds bounds = mirrorCollider.bounds;
			val = ((Bounds)(ref bounds)).center;
		}
		Vector3 val2 = val;
		Vector3 val3 = playerCam.position - val2;
		float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude;
		if (sqrMagnitude > maxCheckDistance * maxCheckDistance && !reverseActive)
		{
			FadeOutAllVisuals();
			return;
		}
		bool flag = false;
		val3 = val2 - playerCam.position;
		Vector3 normalized = ((Vector3)(ref val3)).normalized;
		float num = Vector3.Dot(playerCam.forward, normalized);
		bool flag2 = false;
		RaycastHit val4 = default(RaycastHit);
		if ((Object)(object)mirrorCollider != (Object)null && Physics.Raycast(playerCam.position, playerCam.forward, ref val4, 20f, LayerMask.op_Implicit(raycastMask)) && (Object)(object)((RaycastHit)(ref val4)).collider == (Object)(object)mirrorCollider)
		{
			flag2 = true;
		}
		if (num > requiredDot && flag2)
		{
			flag = true;
		}
		float num2 = Mathf.Clamp01(lookTimer / rampTime);
		if (flag && !trapTriggered)
		{
			lookTimer += Time.deltaTime;
			num2 = Mathf.Clamp01(lookTimer / rampTime);
			if ((Object)(object)whisperSource != (Object)null)
			{
				whisperSource.volume = num2;
			}
			if ((Object)(object)GameDirector.instance != (Object)null && (Object)(object)GameDirector.instance.CameraShake != (Object)null)
			{
				GameDirector.instance.CameraShake.Shake(maxShakeStrength * num2, shakeTime);
			}
			if ((Object)(object)PostProcessing.Instance != (Object)null)
			{
				PostProcessing.Instance.VignetteOverride(vignetteColor, Mathf.Lerp(0f, vignetteIntensity, num2), Mathf.Lerp(0.3f, vignetteSmoothness, num2), 2f, 2f, 0.2f, vignetteObj);
				PostProcessing.Instance.SaturationOverride(Mathf.Lerp(0f, -100f, num2), 2f, 2f, 0.2f, saturationObj);
			}
			if (lookTimer >= lookThreshold)
			{
				trapTriggered = true;
				if ((Object)(object)whisperSource != (Object)null)
				{
					whisperSource.volume = 0f;
					whisperSource.Stop();
				}
				if ((Object)(object)crackSound != (Object)null && (Object)(object)playerCam != (Object)null)
				{
					AudioSource.PlayClipAtPoint(crackSound, playerCam.position);
				}
				PlayerControllerReverseTranspiler.EnableReverseControls();
				reverseActive = true;
				reverseTimer = reverseDuration;
			}
		}
		else
		{
			lookTimer = Mathf.Max(lookTimer - Time.deltaTime * 2f, 0f);
			num2 = Mathf.Clamp01(lookTimer / rampTime);
			if ((Object)(object)whisperSource != (Object)null)
			{
				whisperSource.volume = num2;
			}
			if (!reverseActive && !fadingPostFX)
			{
				FadeOutAllVisuals(num2);
			}
		}
		if (reverseActive)
		{
			reverseTimer -= Time.deltaTime;
			if ((Object)(object)PostProcessing.Instance != (Object)null)
			{
				PostProcessing.Instance.VignetteOverride(vignetteColor, vignetteIntensity * 1.2f, vignetteSmoothness * 0.85f, 1f, 1f, 0.15f, vignetteObj);
				PostProcessing.Instance.SaturationOverride(-100f, 1f, 1f, 0.15f, saturationObj);
			}
			if ((Object)(object)GameDirector.instance != (Object)null && (Object)(object)GameDirector.instance.CameraShake != (Object)null)
			{
				GameDirector.instance.CameraShake.Shake(0.12f, 0.1f);
			}
			if (reverseTimer <= 0f)
			{
				PlayerControllerReverseTranspiler.DisableReverseControls();
				reverseActive = false;
				trapTriggered = false;
				fadingPostFX = true;
				fadeOutTimer = 0f;
			}
		}
		if (fadingPostFX)
		{
			fadeOutTimer += Time.deltaTime;
			float num3 = Mathf.Clamp01(fadeOutTimer / fadeOutDuration);
			float num4 = 1f - num3;
			if ((Object)(object)PostProcessing.Instance != (Object)null)
			{
				PostProcessing.Instance.VignetteOverride(vignetteColor, Mathf.Lerp(0f, vignetteIntensity * 1.2f, num4), Mathf.Lerp(0.3f, vignetteSmoothness * 0.85f, num4), 2f, 2f, 0.2f, vignetteObj);
				PostProcessing.Instance.SaturationOverride(Mathf.Lerp(0f, -100f, num4), 2f, 2f, 0.2f, saturationObj);
			}
			if (num3 >= 1f)
			{
				fadingPostFX = false;
				FadeOutAllVisuals();
			}
		}
	}

	private void FadeOutAllVisuals(float ramp = 0f)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)PostProcessing.Instance != (Object)null)
		{
			PostProcessing.Instance.VignetteOverride(vignetteColor, Mathf.Lerp(0f, vignetteIntensity, ramp), Mathf.Lerp(0.3f, vignetteSmoothness, ramp), 2f, 2f, 0.2f, vignetteObj);
			PostProcessing.Instance.SaturationOverride(Mathf.Lerp(0f, -100f, ramp), 2f, 2f, 0.2f, saturationObj);
		}
	}

	private void OnDisable()
	{
		if (reverseActive)
		{
			PlayerControllerReverseTranspiler.DisableReverseControls();
			reverseActive = false;
		}
		fadingPostFX = false;
		fadeOutTimer = 0f;
		FadeOutAllVisuals();
	}
}
public class NoiseTrap : Trap
{
	[Header("NoiseTrap Visuals")]
	public ParticleSystem? trapParticles;

	public AudioClip? loudSound;

	public float soundVolume = 1f;

	public float investigateRange = 50f;

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

	[Header("Camera Shake")]
	public float shakeStrength = 2.5f;

	public float shakeTime = 0.5f;

	public float minShakeDistance = 4f;

	public float maxShakeDistance = 12f;

	[Header("Trap Effect Timing")]
	public float particleDuration = 3f;

	public float soundDuration = 3f;

	private bool particlesActive = false;

	private bool soundActive = false;

	private float particleTimer = 0f;

	private float soundTimer = 0f;

	private bool shakeActive = false;

	private bool effectActive = false;

	private PhysGrabObject? physgrabObject;

	private bool wasGrabbedLastFrame = false;

	public override void Start()
	{
		((Trap)this).Start();
		if ((Object)(object)audioSource == (Object)null)
		{
			audioSource = ((Component)this).GetComponent<AudioSource>();
			if ((Object)(object)audioSource == (Object)null)
			{
				audioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
				audioSource.spatialBlend = 1f;
			}
		}
		physgrabObject = ((Component)this).GetComponent<PhysGrabObject>();
	}

	public override void Update()
	{
		//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
		((Trap)this).Update();
		bool flag = (Object)(object)physgrabObject != (Object)null && physgrabObject.grabbed;
		if (!effectActive && !base.trapTriggered && flag)
		{
			((Trap)this).TrapActivateSync();
			base.trapTriggered = true;
			base.trapStart = true;
			ActivateTrap();
			effectActive = true;
		}
		if (base.trapTriggered && !flag && wasGrabbedLastFrame && !effectActive)
		{
			base.trapTriggered = false;
			base.trapStart = false;
		}
		wasGrabbedLastFrame = flag;
		if (particlesActive && (Object)(object)trapParticles != (Object)null)
		{
			particleTimer += Time.deltaTime;
			if (particleTimer >= particleDuration)
			{
				trapParticles.Stop(true, (ParticleSystemStopBehavior)1);
				particlesActive = false;
			}
		}
		if (soundActive && (Object)(object)audioSource != (Object)null)
		{
			soundTimer += Time.deltaTime;
			if (soundTimer >= soundDuration)
			{
				audioSource.Stop();
				soundActive = false;
			}
		}
		if (shakeActive)
		{
			if ((Object)(object)GameDirector.instance != (Object)null && (Object)(object)GameDirector.instance.CameraImpact != (Object)null)
			{
				GameDirector.instance.CameraImpact.ShakeDistance(shakeStrength, minShakeDistance, maxShakeDistance, ((Component)this).transform.position, 0.2f);
			}
			if (!particlesActive && !soundActive)
			{
				shakeActive = false;
			}
		}
		if (effectActive && !particlesActive && !soundActive && !shakeActive && !flag)
		{
			effectActive = false;
			base.trapTriggered = false;
			base.trapStart = false;
		}
	}

	public void ActivateTrap()
	{
		if ((Object)(object)trapParticles != (Object)null)
		{
			trapParticles.Play();
			particlesActive = true;
			particleTimer = 0f;
		}
		if ((Object)(object)loudSound != (Object)null && (Object)(object)audioSource != (Object)null)
		{
			audioSource.PlayOneShot(loudSound, soundVolume);
			soundActive = true;
			soundTimer = 0f;
		}
		shakeActive = true;
		base.enemyInvestigate = true;
		base.enemyInvestigateRange = investigateRange;
	}
}
public class UIOverlayPickupTrap : Trap
{
	public GameObject asciiUIPrefab;

	private bool overlayAppliedLocal = false;

	public override void Start()
	{
		((Trap)this).Start();
	}

	public override void Update()
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Expected O, but got Unknown
		((Trap)this).Update();
		if (base.physGrabObject.grabbed && base.physGrabObject.grabbedLocal && !overlayAppliedLocal)
		{
			if ((Object)(object)AsciiUIManager.current == (Object)null)
			{
				GameObject val = new GameObject("AsciiUIManager");
				AsciiUIManager asciiUIManager = val.AddComponent<AsciiUIManager>();
				asciiUIManager.asciiUIPrefab = asciiUIPrefab;
				if ((Object)(object)asciiUIManager.asciiUIPrefab == (Object)null)
				{
					Debug.LogError((object)"[Trap] ASCII prefab was not assigned in the inspector.");
					return;
				}
				Debug.Log((object)"[Trap] AsciiUIManager created at runtime.");
			}
			AsciiUIManager.current?.ShowOverlay();
			overlayAppliedLocal = true;
		}
		if ((!base.physGrabObject.grabbed || !base.physGrabObject.grabbedLocal) && overlayAppliedLocal)
		{
			AsciiUIManager.current?.HideOverlay();
			overlayAppliedLocal = false;
		}
	}
}
public class WhoopeeCushionTrap : Trap
{
	[Header("Audio")]
	[SerializeField]
	public AudioSource? audioSource = null;

	[SerializeField]
	public AudioSource? fartAudioSource = null;

	[SerializeField]
	public AudioClip? fartSound = null;

	[SerializeField]
	public AudioClip? explosionSound = null;

	[Header("Explosion Settings")]
	public float explodeChance = 0.1f;

	public float explosionSize = 0.35f;

	public int explosionDamage = 120;

	public int explosionEnemyDamage = 200;

	public float explosionForceMulti = 1.2f;

	[Header("Enemy Investigate")]
	public float investigateRangeNormal = 15f;

	public float investigateRangeExplosion = 60f;

	private Rigidbody? rb = null;

	private PhysGrabObjectImpactDetector? impactDetector = null;

	private ParticleScriptExplosion? particleScriptExplosion = null;

	private float lastFartTime = -999f;

	public float fartCooldown = 0.2f;

	private bool hasExploded = false;

	public override void Start()
	{
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Expected O, but got Unknown
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Expected O, but got Unknown
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Expected O, but got Unknown
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: Expected O, but got Unknown
		((Trap)this).Start();
		rb = ((Component)this).GetComponent<Rigidbody>();
		impactDetector = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
		particleScriptExplosion = ((Component)this).GetComponent<ParticleScriptExplosion>();
		if ((Object)(object)audioSource == (Object)null)
		{
			audioSource = ((Component)this).GetComponent<AudioSource>();
		}
		if ((Object)(object)fartAudioSource == (Object)null && (Object)(object)((Component)this).transform.Find("FartAudioSource") != (Object)null)
		{
			fartAudioSource = ((Component)((Component)this).transform.Find("FartAudioSource")).GetComponent<AudioSource>();
		}
		if ((Object)(object)impactDetector != (Object)null)
		{
			impactDetector.onImpactMedium.RemoveListener(new UnityAction(OnMediumImpact));
			impactDetector.onImpactHeavy.RemoveListener(new UnityAction(OnHeavyImpact));
			impactDetector.onImpactMedium.AddListener(new UnityAction(OnMediumImpact));
			impactDetector.onImpactHeavy.AddListener(new UnityAction(OnHeavyImpact));
		}
	}

	private void OnDestroy()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Expected O, but got Unknown
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Expected O, but got Unknown
		if ((Object)(object)impactDetector != (Object)null)
		{
			impactDetector.onImpactMedium.RemoveListener(new UnityAction(OnMediumImpact));
			impactDetector.onImpactHeavy.RemoveListener(new UnityAction(OnHeavyImpact));
		}
	}

	private void OnMediumImpact()
	{
		TryActivateTrap("Medium");
	}

	private void OnHeavyImpact()
	{
		TryActivateTrap("Heavy");
	}

	private void TryActivateTrap(string impactType = "Any")
	{
		if (!hasExploded && !(Time.time - lastFartTime < fartCooldown) && (!SemiFunc.IsMultiplayer() || SemiFunc.IsMasterClient()))
		{
			lastFartTime = Time.time;
			if ((Object)(object)base.photonView != (Object)null)
			{
				base.photonView.RPC("RPCFartAndMaybeExplode", (RpcTarget)0, new object[1] { impactType });
			}
		}
	}

	public void TryTriggerByCollider()
	{
		if (!hasExploded && !(Time.time - lastFartTime < fartCooldown) && (!SemiFunc.IsMultiplayer() || SemiFunc.IsMasterClient()))
		{
			lastFartTime = Time.time;
			if ((Object)(object)base.photonView != (Object)null)
			{
				base.photonView.RPC("RPCFartAndMaybeExplode", (RpcTarget)0, new object[1] { "Trigger" });
			}
		}
	}

	[PunRPC]
	public void RPCFartAndMaybeExplode(string triggerType)
	{
		if (!hasExploded)
		{
			if ((Object)(object)fartAudioSource != (Object)null && (Object)(object)fartSound != (Object)null)
			{
				fartAudioSource.maxDistance = investigateRangeNormal;
				fartAudioSource.PlayOneShot(fartSound);
			}
			else if ((Object)(object)audioSource != (Object)null && (Object)(object)fartSound != (Object)null)
			{
				audioSource.maxDistance = investigateRangeNormal;
				audioSource.PlayOneShot(fartSound);
			}
			if (Random.value < explodeChance)
			{
				hasExploded = true;
				Explode();
			}
			else
			{
				base.enemyInvestigate = true;
				base.enemyInvestigateRange = investigateRangeNormal;
			}
		}
	}

	private void Explode()
	{
		//IL_005f: 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_006b: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)audioSource != (Object)null && (Object)(object)explosionSound != (Object)null)
		{
			audioSource.maxDistance = investigateRangeExplosion;
			audioSource.PlayOneShot(explosionSound);
		}
		if ((Object)(object)particleScriptExplosion != (Object)null)
		{
			Vector3 position = ((Component)this).transform.position;
			particleScriptExplosion.Spawn(position, explosionSize, explosionDamage, explosionEnemyDamage, explosionForceMulti, false, false, 1f);
		}
		base.enemyInvestigate = true;
		base.enemyInvestigateRange = investigateRangeExplosion;
		if ((Object)(object)base.physGrabObject != (Object)null)
		{
			base.physGrabObject.dead = true;
		}
	}
}
public class WhoopeeCushionTrigger : MonoBehaviour
{
	private WhoopeeCushionTrap? trap;

	private void Start()
	{
		trap = ((Component)this).GetComponentInParent<WhoopeeCushionTrap>();
	}

	private void OnTriggerEnter(Collider other)
	{
		PlayerController componentInParent = ((Component)other).GetComponentInParent<PlayerController>();
		PlayerAvatar componentInParent2 = ((Component)other).GetComponentInParent<PlayerAvatar>();
		PhysGrabObject componentInParent3 = ((Component)other).GetComponentInParent<PhysGrabObject>();
		bool flag = (Object)(object)componentInParent3 != (Object)null && componentInParent3.isEnemy;
		if ((Object)(object)componentInParent != (Object)null || (Object)(object)componentInParent2 != (Object)null || flag)
		{
			trap?.TryTriggerByCollider();
		}
	}
}
public class ZenithBlackHole : MonoBehaviourPun
{
	public SemiLaser semiLaser;

	public float pullRadius = 8f;

	public float pullStrength = 32f;

	public LayerMask pullLayerMask;

	public List<PhysGrabObject> ignoreObjects = new List<PhysGrabObject>();

	[Header("Pull Force Falloff")]
	public AnimationCurve pullFalloffCurve = AnimationCurve.EaseInOut(0f, 1f, 1f, 0.3f);

	[Header("Player Pull Settings")]
	[Tooltip("How much to scale the pull force for players (e.g., 0.5 = half strength)")]
	public float playerPullMultiplier = 0.5f;

	private void Start()
	{
		if ((Object)(object)semiLaser == (Object)null)
		{
			semiLaser = ((Component)this).GetComponentInParent<SemiLaser>();
		}
	}

	private void FixedUpdate()
	{
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: 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_016e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)semiLaser == (Object)null || (Object)(object)semiLaser.hitTransform == (Object)null || !((Component)semiLaser.hitTransform).gameObject.activeSelf || !SemiFunc.IsMasterClientOrSingleplayer())
		{
			return;
		}
		Vector3 position = semiLaser.hitTransform.position;
		Collider[] array = Physics.OverlapSphere(position, pullRadius, LayerMask.op_Implicit(pullLayerMask));
		Collider[] array2 = array;
		foreach (Collider val in array2)
		{
			Rigidbody attachedRigidbody = val.attachedRigidbody;
			if (!((Object)(object)attachedRigidbody != (Object)null))
			{
				continue;
			}
			PhysGrabObject component = ((Component)attachedRigidbody).GetComponent<PhysGrabObject>();
			if ((Object)(object)component != (Object)null && ignoreObjects.Contains(component))
			{
				continue;
			}
			float num = Vector3.Distance(position, attachedRigidbody.position);
			if (!(num < 0.2f))
			{
				float num2 = Mathf.Clamp01(num / pullRadius);
				float num3 = pullFalloffCurve.Evaluate(num2);
				float num4 = pullStrength * num3;
				if (((Component)val).CompareTag("Player") || (Object)(object)((Component)val).GetComponentInParent<PlayerAvatar>() != (Object)null)
				{
					num4 *= playerPullMultiplier;
				}
				Vector3 val2 = position - attachedRigidbody.position;
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				attachedRigidbody.AddForce(normalized * num4, (ForceMode)5);
			}
		}
	}

	private void OnDrawGizmosSelected()
	{
		//IL_0028: 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 ((Object)(object)semiLaser != (Object)null && (Object)(object)semiLaser.hitTransform != (Object)null)
		{
			Gizmos.color = Color.cyan;
			Gizmos.DrawWireSphere(semiLaser.hitTransform.position, pullRadius);
		}
	}
}
namespace RosayValuablesAPI
{
	[HarmonyPatch(typeof(PlayerController), "FixedUpdate")]
	public static class PlayerControllerReverseTranspiler
	{
		public static bool reverseMovementActive;

		public static void EnableReverseControls()
		{
			reverseMovementActive = true;
		}

		public static void DisableReverseControls()
		{
			reverseMovementActive = false;
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			FieldInfo fieldInfo = AccessTools.Field(typeof(PlayerController), "InputDirection");
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Stfld && fieldInfo.Equals(list[i].operand))
				{
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null));
					list.Insert(i + 2, CodeInstruction.Call(typeof(PlayerControllerReverseTranspiler), "MaybeReverseInputDirection", (Type[])null, (Type[])null));
					i += 2;
				}
			}
			return list;
		}

		public static void MaybeReverseInputDirection(PlayerController player)
		{
			//IL_001d: 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)
			if (reverseMovementActive && (Object)(object)player == (Object)(object)PlayerController.instance)
			{
				player.InputDirection = -player.InputDirection;
			}
		}
	}
	[HarmonyPatch]
	public static class PostProcessingSepiaPatch
	{
		private static bool sepiaOverrideActive = false;

		private static float sepiaOverrideLerp = 0f;

		private static float sepiaOverrideTimer = 0f;

		private static float sepiaOverrideSpeedIn;

		private static float sepiaOverrideSpeedOut;

		private static Color sepiaOverrideColor = new Color(0.44f, 0.36f, 0.18f);

		private static float sepiaOverrideIntensity = 1f;

		private static GameObject? sepiaOverrideObject = null;

		private static Color colorFilterOriginal;

		private static ColorGrading? colorGrading => ((Object)(object)PostProcessing.Instance != (Object)null) ? PostProcessing.Instance.colorGrading : null;

		[HarmonyPatch(typeof(PostProcessing), "Update")]
		[HarmonyPostfix]
		public static void PostProcessing_Update_Postfix(PostProcessing __instance)
		{
			//IL_001e: 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_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)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			if (!sepiaOverrideActive || !((Object)(object)colorGrading != (Object)null))
			{
				return;
			}
			Color value = Color.Lerp(colorFilterOriginal, sepiaOverrideColor, sepiaOverrideLerp * sepiaOverrideIntensity);
			if (sepiaOverrideTimer > 0f)
			{
				((ParameterOverride<Color>)(object)colorGrading.colorFilter).value = value;
				sepiaOverrideLerp += sepiaOverrideSpeedIn * Time.deltaTime;
				sepiaOverrideLerp = Mathf.Clamp01(sepiaOverrideLerp);
				sepiaOverrideTimer -= Time.deltaTime;
				return;
			}
			((ParameterOverride<Color>)(object)colorGrading.colorFilter).value = value;
			sepiaOverrideLerp -= sepiaOverrideSpeedOut * Time.deltaTime;
			if (sepiaOverrideLerp <= 0f)
			{
				((ParameterOverride<Color>)(object)colorGrading.colorFilter).value = colorFilterOriginal;
				sepiaOverrideActive = false;
				sepiaOverrideLerp = 0f;
			}
		}

		public static void SetSepiaOverride(float intensity, float duration, GameObject obj)
		{
			//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)
			if (!((Object)(object)colorGrading == (Object)null))
			{
				if (!sepiaOverrideActive || (Object)(object)obj != (Object)(object)sepiaOverrideObject)
				{
					colorFilterOriginal = ((ParameterOverride<Color>)(object)colorGrading.colorFilter).value;
					sepiaOverrideLerp = 0f;
				}
				sepiaOverrideActive = true;
				sepiaOverrideObject = obj;
				sepiaOverrideTimer = duration;
				sepiaOverrideSpeedIn = 4f;
				sepiaOverrideSpeedOut = 2f;
				sepiaOverrideIntensity = Mathf.Clamp01(intensity);
			}
		}

		public static void ClearSepiaOverride(GameObject obj)
		{
			if (sepiaOverrideActive && (Object)(object)sepiaOverrideObject == (Object)(object)obj)
			{
				sepiaOverrideTimer = 0f;
			}
		}
	}
	public static class PostProcessingExtensions
	{
		public static void SetSepiaOverride(this PostProcessing _, float intensity, float duration, GameObject obj)
		{
			PostProcessingSepiaPatch.SetSepiaOverride(intensity, duration, obj);
		}

		public static void ClearSepiaOverride(this PostProcessing _, GameObject obj)
		{
			PostProcessingSepiaPatch.ClearSepiaOverride(obj);
		}
	}
	[BepInPlugin("Rosay.RosayValuablesAPI", "RosayValuablesAPI", "1.0")]
	public class RosayValuablesAPI : BaseUnityPlugin
	{
		internal static RosayValuablesAPI Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		private void Awake()
		{
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Patch();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
		}

		internal void Patch()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0026: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			Harmony.PatchAll();
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void Update()
		{
		}
	}
}