Decompiled source of CosyValuables v1.0.1

CosyValuables.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using REPOLib;
using REPOLib.Modules;
using UnityEngine;

[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("Wexop")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f82867a66bab5efdd3a7b5d39116f0980eec79de")]
[assembly: AssemblyProduct("CosyValuables")]
[assembly: AssemblyTitle("CosyValuables")]
[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 CosyValuables
{
	[BepInPlugin("Wexop.CosyValuables", "CosyValuables", "1.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		internal static Plugin 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;
			LoadValuables();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
		}

		private void LoadValuables()
		{
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "cozyvaluables");
			BundleLoader.LoadBundle(text, (Action<AssetBundle>)delegate(AssetBundle assetBundle)
			{
				GameObject val = assetBundle.LoadAsset<GameObject>("Assets/REPO/Mods/CozyValuables/CozyCoffee.prefab");
				Valuables.RegisterValuable(val);
				GameObject val2 = assetBundle.LoadAsset<GameObject>("Assets/REPO/Mods/CozyValuables/Aquarium.prefab");
				Valuables.RegisterValuable(val2);
				GameObject val3 = assetBundle.LoadAsset<GameObject>("Assets/REPO/Mods/CozyValuables/Candles.prefab");
				Valuables.RegisterValuable(val3);
				GameObject val4 = assetBundle.LoadAsset<GameObject>("Assets/REPO/Mods/CozyValuables/GreenCandles.prefab");
				Valuables.RegisterValuable(val4);
				GameObject val5 = assetBundle.LoadAsset<GameObject>("Assets/REPO/Mods/CozyValuables/DiscoBall.prefab");
				Valuables.RegisterValuable(val5);
			}, false);
		}
	}
}
namespace CosyValuables.Scripts
{
	public class DiscoBall : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <onPlayingSong>d__6 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public DiscoBall <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitUntil((Func<bool>)(() => !<>4__this.audioSource.isPlaying));
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this.audioSource.Stop();
					<>4__this.audioSource.clip = null;
					<>4__this.isPlaying = false;
					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();
			}
		}

		private static readonly int Play = Animator.StringToHash("play");

		public AudioSource audioSource;

		public AudioClip clip;

		public Animator animator;

		private bool isPlaying = false;

		private bool isDestroy = false;

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

		public void OnImpact()
		{
			if (!isDestroy)
			{
				if (isPlaying)
				{
					audioSource.Stop();
					audioSource.clip = null;
					isPlaying = false;
					((MonoBehaviour)this).StartCoroutine(onPlayingSong());
				}
				else
				{
					audioSource.PlayOneShot(clip);
					isPlaying = true;
				}
				animator.SetBool(Play, isPlaying);
			}
		}

		public void OnDestroy()
		{
			audioSource.Stop();
			audioSource.clip = null;
			isPlaying = false;
			isDestroy = true;
		}
	}
}