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 DarkSoulSnail;
using GameNetcodeStuff;
using HarmonyLib;
using ImmortalSnail;
using LCSoundTool;
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: AssemblyCompany("jaaj.DarkSoulSnail")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+dc8111b331b16e38a3ad6e3ff61b36912c65e465")]
[assembly: AssemblyProduct("DarkSoulSnail")]
[assembly: AssemblyTitle("jaaj.DarkSoulSnail")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[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.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_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_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: 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_0108: Unknown result type (might be due to invalid IL or missing references)
if (!DarkSoulSnailBase.configPlayWhenLookingAtSnail.Value && !DarkSoulSnailBase.configPlayWhenSnailSeeTarget.Value)
{
return;
}
PlayerControllerB targetPlayer = ((EnemyAI)SnailInstance).targetPlayer;
float num = Vector3.Distance(((Component)SnailInstance).transform.position, ((Component)targetPlayer).transform.position);
bool flag = num < (float)DarkSoulSnailBase.configDistance.Value;
if (DarkSoulSnailBase.configPlayWhenSnailSeeTarget.Value && !Physics.Linecast(((Component)SnailInstance).transform.position + Vector3.up * 0.5f, ((Component)targetPlayer.gameplayCamera).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault) && flag)
{
if (!((EnemyAI)SnailInstance).creatureSFX.isPlaying)
{
((EnemyAI)SnailInstance).creatureSFX.Play();
}
}
else if (GameNetworkManager.Instance.localPlayerController.HasLineOfSightToPosition(((Component)SnailInstance).transform.position, 70f, DarkSoulSnailBase.configDistance.Value, -1f))
{
if (!((EnemyAI)SnailInstance).creatureSFX.isPlaying)
{
((EnemyAI)SnailInstance).creatureSFX.Play();
}
}
else if (DarkSoulSnailBase.configPauseWhenNotLooking.Value)
{
((EnemyAI)SnailInstance).creatureSFX.Pause();
}
else
{
((EnemyAI)SnailInstance).creatureSFX.Stop();
}
}
}
namespace DarkSoulSnail
{
[BepInPlugin("org.jaaj.darksoulsnail", "DarkSoulSnail", "1.0.1")]
public class DarkSoulSnailBase : BaseUnityPlugin
{
private const string modGUID = "org.jaaj.darksoulsnail";
private const string modName = "DarkSoulSnail";
private const string modVersion = "1.0.1";
private readonly Harmony harmony = new Harmony("org.jaaj.darksoulsnail");
public static ConfigEntry<float> configVolume;
public static ConfigEntry<bool> configPlayWhenLookingAtSnail;
public static ConfigEntry<bool> configPlayWhenSnailSeeTarget;
public static ConfigEntry<int> configDistance;
public static ConfigEntry<bool> configPauseWhenNotLooking;
public static ConfigEntry<string> configAudioFile;
public static AudioClip bossMusic;
public static DarkSoulSnailBase PluginInstance { get; private set; }
public static ManualLogSource LoggerInstance { get; private set; }
private void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
if ((Object)PluginInstance == (Object)null)
{
PluginInstance = this;
}
LoggerInstance = ((BaseUnityPlugin)PluginInstance).Logger;
LoggerInstance.LogDebug((object)"Plugin DarkSoulSnail loaded successfully.");
configVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Volume", "MusicVolume", 1f, "Volume of the music. Must be between 0 and 1.");
configPlayWhenSnailSeeTarget = ((BaseUnityPlugin)this).Config.Bind<bool>("Looking Mechanic", "PlayWhenSnailSeeTargetedPlayer", false, "Player the music when the snail see the player.");
configPlayWhenLookingAtSnail = ((BaseUnityPlugin)this).Config.Bind<bool>("Looking Mechanic", "PlayWhenLookingAtSnail", true, "Play the music when the player is looking at the snail. Everything below this only works if one the two options is set to true.");
configDistance = ((BaseUnityPlugin)this).Config.Bind<int>("Looking Mechanic", "Distance", 20, "Play the music only when the player is looking at a certain distance of the snail (also used for snail seeing the player).");
configPauseWhenNotLooking = ((BaseUnityPlugin)this).Config.Bind<bool>("Looking Mechanic", "PauseWhenNotLooking", true, "Wether to pause the music when not looking at the snail or snail is not looking at player, or stop it and start it over again when looking again. true = Pause, false = Stop.");
configAudioFile = ((BaseUnityPlugin)this).Config.Bind<string>("Audio to play", "AudioFilePath", "bossMusic.wav", "Path to the audio file to play when looking at the snail.");
string directoryName = Path.GetDirectoryName(Path.GetFullPath(configAudioFile.Value, Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)));
string fileName = Path.GetFileName(configAudioFile.Value);
LoggerInstance.LogDebug((object)("AudioFile : " + fileName));
LoggerInstance.LogDebug((object)("AudioFilePath : " + directoryName));
bossMusic = SoundTool.GetAudioClip(directoryName, fileName);
LoggerInstance.LogDebug((object)$"Loaded bossMusic: {bossMusic}");
harmony.PatchAll();
LoggerInstance.LogInfo((object)"jaaj.DarkSoulSnail v1.0.0 has loaded!");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "jaaj.DarkSoulSnail";
public const string PLUGIN_NAME = "DarkSoulSnail";
public const string PLUGIN_VERSION = "1.0.1";
}
}
namespace DarkSoulSnail.Patches
{
[HarmonyPatch(typeof(SnailAI))]
internal class SnailAIPatch
{
private static ManualLogSource LoggerInstance = DarkSoulSnailBase.LoggerInstance;
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPatch(SnailAI __instance)
{
((EnemyAI)__instance).creatureSFX = ((Component)__instance).gameObject.AddComponent<AudioSource>();
((EnemyAI)__instance).creatureSFX.clip = DarkSoulSnailBase.bossMusic;
((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 (!DarkSoulSnailBase.configPlayWhenLookingAtSnail.Value)
{
((EnemyAI)__instance).creatureSFX.Play();
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}