Decompiled source of Oiia Cat Valuable with oiia features v1.2.1

Oiia_Cat_Valuable_with_Oiia_Features.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;

[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("FunkyFontanez")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Oiia_Cat_Valuable_with_Oiia_Features")]
[assembly: AssemblyTitle("Oiia_Cat_Valuable_with_Oiia_Features")]
[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;
		}
	}
}
namespace Oiia_Cat_Valuable_with_Oiia_Features
{
	public class OiiaCatTrap : Trap
	{
		[CompilerGenerated]
		private sealed class <RotateTrapLoop>d__9 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public OiiaCatTrap <>4__this;

			private Quaternion <currentRotation>5__1;

			private Vector3 <euler>5__2;

			private float <ySpin>5__3;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//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_0115: Unknown result type (might be due to invalid IL or missing references)
				//IL_011a: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				while (<>4__this.trapPlaying)
				{
					if ((Object)(object)<>4__this.rb != (Object)null)
					{
						<currentRotation>5__1 = <>4__this.rb.rotation;
						<euler>5__2 = ((Quaternion)(ref <currentRotation>5__1)).eulerAngles;
						<ySpin>5__3 = <>4__this.rotationSpeed * 360f * Time.deltaTime;
						<euler>5__2.y -= <ySpin>5__3;
						<euler>5__2.x = Mathf.LerpAngle(<euler>5__2.x, 0f, Time.deltaTime * <>4__this.lerpSpeed * 360f);
						<euler>5__2.z = Mathf.LerpAngle(<euler>5__2.z, 0f, Time.deltaTime * <>4__this.lerpSpeed * 360f);
						<>4__this.rb.MoveRotation(Quaternion.Euler(<euler>5__2));
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
				}
				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 UnityEvent? OiiaCatTimer;

		public SkinnedMeshRenderer? OiiaCatRenderer;

		public float rotationSpeed = 5.1121f;

		public float lerpSpeed = 0.25f;

		public Sound? LoopSound;

		private int muchkinBlendShapeIndex = -1;

		private bool trapPlaying;

		private Rigidbody? rb;

		private Coroutine? rotationCoroutine;

		[IteratorStateMachine(typeof(<RotateTrapLoop>d__9))]
		private IEnumerator RotateTrapLoop()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <RotateTrapLoop>d__9(0)
			{
				<>4__this = this
			};
		}

		private void SetTrapPlaying(bool active)
		{
			trapPlaying = active;
			if ((Object)(object)OiiaCatRenderer != (Object)null && muchkinBlendShapeIndex >= 0)
			{
				OiiaCatRenderer.SetBlendShapeWeight(muchkinBlendShapeIndex, active ? 100f : 0f);
			}
			if (active)
			{
				if (rotationCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(rotationCoroutine);
				}
				rotationCoroutine = ((MonoBehaviour)this).StartCoroutine(RotateTrapLoop());
			}
			else if (rotationCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(rotationCoroutine);
				rotationCoroutine = null;
			}
		}

		public override void Start()
		{
			((Trap)this).Start();
			if ((Object)(object)OiiaCatRenderer != (Object)null)
			{
				Mesh sharedMesh = OiiaCatRenderer.sharedMesh;
				muchkinBlendShapeIndex = sharedMesh.GetBlendShapeIndex("body.Muchkin1");
				if (muchkinBlendShapeIndex < 0)
				{
					Debug.LogWarning((object)"BlendShape 'body.Muchkin1' not found!");
				}
			}
			rb = ((Component)this).GetComponent<Rigidbody>();
		}

		public override void Update()
		{
			((Trap)this).Update();
			if (base.trapStart)
			{
				OiiaCatTrapActivated();
			}
			Sound? loopSound = LoopSound;
			if (loopSound != null)
			{
				loopSound.PlayLoop(trapPlaying, 0.9f, 0.9f, 1f);
			}
			if (base.trapActive && !trapPlaying)
			{
				SetTrapPlaying(active: true);
			}
		}

		public void TrapStop()
		{
			base.trapActive = false;
			SetTrapPlaying(active: false);
		}

		public void OiiaCatTrapActivated()
		{
			if (!base.trapTriggered)
			{
				UnityEvent? oiiaCatTimer = OiiaCatTimer;
				if (oiiaCatTimer != null)
				{
					oiiaCatTimer.Invoke();
				}
				base.trapActive = true;
				base.trapTriggered = true;
			}
		}
	}
	[BepInPlugin("FunkyFontanez.Oiia_Cat_Valuable_with_Oiia_Features", "Oiia_Cat_Valuable_with_Oiia_Features", "1.0")]
	public class Oiia_Cat_Valuable_with_Oiia_Features : BaseUnityPlugin
	{
		internal static Oiia_Cat_Valuable_with_Oiia_Features Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

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

		internal Harmony? Harmony { get; private set; }

		internal OiiaCatTrap? OiiaCatTrapInstance { get; private set; }

		private void Awake()
		{
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			OiiaCatTrapInstance = ((Component)this).gameObject.AddComponent<OiiaCatTrap>();
			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()
		{
		}
	}
}