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.Logging;
using GameNetcodeStuff;
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("CentipedeCatLaugh")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+7cf34a313fab0d96ea30b18cf99550982ff43dff")]
[assembly: AssemblyProduct("My first plugin")]
[assembly: AssemblyTitle("CentipedeCatLaugh")]
[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;
}
}
}
namespace CentipedeCatLaugh
{
[BepInPlugin("frare.CentipedeCatLaugh", "Centipede laughing cat grab", "1.2.0")]
public class CentipedeCatLaughBase : BaseUnityPlugin
{
internal const string PLUGIN_GUID = "frare.CentipedeCatLaugh";
internal const string PLUGIN_NAME = "Centipede laughing cat grab";
internal const string PLUGIN_VERSION = "1.2.0";
internal static CentipedeCatLaughBase Instance;
internal ManualLogSource logger;
private readonly Harmony harmony = new Harmony("frare.CentipedeCatLaugh");
public static float LocalPlayerClipVolume { get; private set; }
public static float OtherPlayerClipVolume { get; private set; }
public static AudioClip SnareClip { get; private set; }
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
logger = Logger.CreateLogSource("frare.CentipedeCatLaugh");
logger.LogInfo((object)"Mod started! :)");
LoadAssets();
LoadFromConfig();
harmony.PatchAll();
logger.LogInfo((object)"Mod finished loading!");
}
private void LoadAssets()
{
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(directoryName, "modaudio"));
if ((Object)(object)val == (Object)null)
{
logger.LogError((object)"Failed to load custom audio");
return;
}
string text = val.GetAllAssetNames()[0];
SnareClip = val.LoadAsset<AudioClip>(text);
if ((Object)(object)SnareClip == (Object)null)
{
logger.LogError((object)"Failed to load custom audio");
}
else
{
logger.LogDebug((object)"Custom audio loaded!");
}
}
private void LoadFromConfig()
{
LocalPlayerClipVolume = ((BaseUnityPlugin)this).Config.Bind<float>("General", "SelfGrabbedVolume", 1f, "Volume that the clip will play when YOU are grabbed\n0 is muted, 1 is default, 1.5 is 150% the clip's original volume, etc.").Value;
OtherPlayerClipVolume = ((BaseUnityPlugin)this).Config.Bind<float>("General", "OtherGrabbedVolume", 1.5f, "Volume that the clip will play when OTHERS are grabbed\n0 is muted, 1 is default, 1.5 is 150% the clip's original volume, etc.").Value;
}
public static void LogMessage(string message, LogLevel logLevel = 32)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
Instance.logger.Log(logLevel, (object)message);
}
}
}
namespace CentipedeCatLaugh.Patches
{
[HarmonyPatch(typeof(CentipedeAI))]
internal static class CentipedeAIPatch
{
[HarmonyPatch("ClingToPlayer")]
[HarmonyPostfix]
internal static void ClingToPlayerPostfix(ref CentipedeAI __instance, PlayerControllerB playerScript)
{
CentipedeCatLaughBase.LogMessage("Patching \"CentipedeAI ClingToPlayer\"... for gameObject " + ((Object)((Component)__instance).gameObject).name, (LogLevel)32);
bool flag = (Object)(object)playerScript == (Object)(object)GameNetworkManager.Instance.localPlayerController;
float num = (flag ? CentipedeCatLaughBase.LocalPlayerClipVolume : CentipedeCatLaughBase.OtherPlayerClipVolume);
((EnemyAI)__instance).creatureSFX.PlayOneShot(CentipedeCatLaughBase.SnareClip, num);
CentipedeCatLaughBase.LogMessage(string.Format("Playing audio clip for {0} at volume {1}", flag ? "local player" : "other player", num), (LogLevel)32);
CentipedeCatLaughBase.LogMessage("Done!", (LogLevel)32);
}
}
}