Decompiled source of Pikmoons v3.0.2

BepInEx/plugins/PikMoons.dll

Decompiled 2 weeks ago
using System;
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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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: AssemblyCompany("PikMoons")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Plugin for PF1MIL's PikMoons.")]
[assembly: AssemblyFileVersion("3.0.2.0")]
[assembly: AssemblyInformationalVersion("3.0.2+3e48c2c6cceb6617a67c5f815d461ea99d169b39")]
[assembly: AssemblyProduct("PikMoons")]
[assembly: AssemblyTitle("PikMoons")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.0.2.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 PikMoons
{
	public class Config
	{
		public ConfigEntry<bool> PIKMIN_MUSIC { get; private set; }

		public ConfigEntry<float> MUSIC_VOLUME { get; private set; }

		public Config(ConfigFile cfg)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			cfg.SaveOnConfigSet = false;
			PIKMIN_MUSIC = cfg.Bind<bool>("Audio", "PikminMusic", true, "Enable Pikmin music and ambience.");
			MUSIC_VOLUME = cfg.Bind<float>("Audio", "MusicVolume", 1f, new ConfigDescription("Change volume of outdoor Pikmin music.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
			ClearOrphanedEntries(cfg);
			cfg.SaveOnConfigSet = true;
			cfg.Save();
		}

		private void ClearOrphanedEntries(ConfigFile config)
		{
			PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries");
			((Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(config))?.Clear();
		}
	}
	[BepInDependency("imabatby.lethallevelloader", "1.4.0")]
	[BepInPlugin("PF1MIL.PikMoons", "PikMoons", "3.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		internal const string GUID = "PF1MIL.PikMoons";

		internal const string PLUGIN_NAME = "PikMoons";

		internal const string VERSION = "3.0.2";

		internal static ManualLogSource? StaticLogger { get; private set; }

		public static Config Settings { get; private set; }

		private void Awake()
		{
			StaticLogger = ((BaseUnityPlugin)this).Logger;
			try
			{
				Settings = new Config(((BaseUnityPlugin)this).Config);
				ManualLogSource? staticLogger = StaticLogger;
				if (staticLogger != null)
				{
					staticLogger.LogInfo((object)"'PikMoons' loaded!");
				}
			}
			catch (Exception arg)
			{
				StaticLogger.LogError((object)string.Format("Error while initializing '{0}': {1}", "PikMoons", arg));
			}
		}
	}
}
namespace PikMoons.Behaviours
{
	public class ChangeSettings : MonoBehaviour
	{
		[SerializeField]
		private AudioSource? musicSource;

		private float defaultVolume = 1f;

		private void Start()
		{
			if ((Object)(object)musicSource != (Object)null)
			{
				defaultVolume = musicSource.volume;
				musicSource.mute = !Plugin.Settings.PIKMIN_MUSIC.Value;
				AudioSource? obj = musicSource;
				obj.volume *= Plugin.Settings.MUSIC_VOLUME.Value;
				Plugin.Settings.PIKMIN_MUSIC.SettingChanged += ChangeMusicMute;
				Plugin.Settings.MUSIC_VOLUME.SettingChanged += ChangeMusicVolume;
			}
		}

		private void OnDestroy()
		{
			Plugin.Settings.PIKMIN_MUSIC.SettingChanged -= ChangeMusicMute;
			Plugin.Settings.MUSIC_VOLUME.SettingChanged -= ChangeMusicVolume;
		}

		private void ChangeMusicMute(object sender, EventArgs args)
		{
			if ((Object)(object)musicSource != (Object)null)
			{
				SettingChangedEventArgs val = (SettingChangedEventArgs)(object)((args is SettingChangedEventArgs) ? args : null);
				if (val != null && val.ChangedSetting is ConfigEntry<bool> val2)
				{
					musicSource.mute = !val2.Value;
				}
			}
		}

		private void ChangeMusicVolume(object sender, EventArgs args)
		{
			if ((Object)(object)musicSource != (Object)null)
			{
				SettingChangedEventArgs val = (SettingChangedEventArgs)(object)((args is SettingChangedEventArgs) ? args : null);
				if (val != null && val.ChangedSetting is ConfigEntry<float> val2)
				{
					musicSource.volume = defaultVolume * val2.Value;
				}
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}