Decompiled source of BurningMemoryOfAnImmortalSnail JapesEdit v1.0.1

ItalicBlackbird.BurningMemoryOfAnImmortalSnail.dll

Decompiled 6 months ago
using System;
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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using ImmortalSnail;
using LCSoundTool;
using Microsoft.CodeAnalysis;
using SoThisIsImmortalSnail;
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("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("Snowlance.SoThisIsImmortalSnail")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+dc8111b331b16e38a3ad6e3ff61b36912c65e465")]
[assembly: AssemblyProduct("SoThisIsImmortalSnail")]
[assembly: AssemblyTitle("Snowlance.SoThisIsImmortalSnail")]
[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 SnailMusicController : MonoBehaviour
{
	public SnailAI SnailInstance;

	public void Update()
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		SoThisIsImmortalSnailBase.LoggerInstance.LogDebug((object)"SnailMusicController.Update");
		if (!SoThisIsImmortalSnailBase.configPlayWhenLookingAtSnail.Value)
		{
			return;
		}
		if (GameNetworkManager.Instance.localPlayerController.HasLineOfSightToPosition(((Component)SnailInstance).transform.position, 70f, SoThisIsImmortalSnailBase.configDistance.Value, -1f))
		{
			if (!((EnemyAI)SnailInstance).creatureSFX.isPlaying)
			{
				((EnemyAI)SnailInstance).creatureSFX.Play();
			}
		}
		else if (SoThisIsImmortalSnailBase.configPauseWhenNotLooking.Value)
		{
			((EnemyAI)SnailInstance).creatureSFX.Pause();
		}
		else
		{
			((EnemyAI)SnailInstance).creatureSFX.Stop();
		}
	}
}
namespace SoThisIsImmortalSnail
{
	[BepInPlugin("Snowlance.SoThisIsImmortalSnail", "SoThisIsImmortalSnail", "1.0.0")]
	public class SoThisIsImmortalSnailBase : BaseUnityPlugin
	{
		private const string modGUID = "Snowlance.SoThisIsImmortalSnail";

		private const string modName = "SoThisIsImmortalSnail";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Snowlance.SoThisIsImmortalSnail");

		public static ConfigEntry<float> configVolume;

		public static ConfigEntry<bool> configPlayWhenLookingAtSnail;

		public static ConfigEntry<int> configDistance;

		public static ConfigEntry<bool> configPauseWhenNotLooking;

		public static AudioClip christmasMusic;

		public static SoThisIsImmortalSnailBase PluginInstance { get; private set; }

		public static ManualLogSource LoggerInstance { get; private set; }

		private void Awake()
		{
			if ((Object)(object)PluginInstance == (Object)null)
			{
				PluginInstance = this;
			}
			LoggerInstance = ((BaseUnityPlugin)PluginInstance).Logger;
			LoggerInstance.LogDebug((object)"Plugin SoThisIsImmortalSnail loaded successfully.");
			configVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Volume", "MusicVolume", 1f, "Volume of the music. Must be between 0 and 1.");
			configPlayWhenLookingAtSnail = ((BaseUnityPlugin)this).Config.Bind<bool>("Looking Mechanic", "PlayWhenLookingAtSnail", true, "Play the music only when the player is looking at the snail. Everything below this only works if this is set to true.");
			configDistance = ((BaseUnityPlugin)this).Config.Bind<int>("Looking Mechanic", "Distance", 50, "Play the music only when the player is looking at a certain distance of the snail.");
			configPauseWhenNotLooking = ((BaseUnityPlugin)this).Config.Bind<bool>("Looking Mechanic", "PauseWhenNotLooking", true, "Wether to pause the music when not looking at the snail, or stop it and start it over again when looking again. true = Pause, false = Stop.");
			christmasMusic = SoundTool.GetAudioClip(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "christmasMusic.wav");
			LoggerInstance.LogDebug((object)$"Loaded christmasMusic: {christmasMusic}");
			harmony.PatchAll();
			LoggerInstance.LogInfo((object)"Snowlance.SoThisIsImmortalSnail v1.0.0 has loaded!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Snowlance.SoThisIsImmortalSnail";

		public const string PLUGIN_NAME = "SoThisIsImmortalSnail";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace SoThisIsImmortalSnail.Patches
{
	[HarmonyPatch(typeof(SnailAI))]
	internal class SnailAIPatch
	{
		private static ManualLogSource LoggerInstance = SoThisIsImmortalSnailBase.LoggerInstance;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch(SnailAI __instance)
		{
			((EnemyAI)__instance).creatureSFX = ((Component)__instance).gameObject.AddComponent<AudioSource>();
			((EnemyAI)__instance).creatureSFX.clip = SoThisIsImmortalSnailBase.christmasMusic;
			((EnemyAI)__instance).creatureSFX.loop = true;
			((EnemyAI)__instance).creatureSFX.volume = 1f;
			((EnemyAI)__instance).creatureSFX.spatialBlend = 1f;
			SnailMusicController snailMusicController = ((Component)__instance).gameObject.AddComponent<SnailMusicController>();
			snailMusicController.SnailInstance = __instance;
			if (!SoThisIsImmortalSnailBase.configPlayWhenLookingAtSnail.Value)
			{
				((EnemyAI)__instance).creatureSFX.Play();
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}