using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using HarmonyLib;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("RadioBabyFace")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Adds the unused \"Baby Face\" to the radio")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+d5022b61f92387e20f27c0a33433bcae239a84c0")]
[assembly: AssemblyProduct("RadioBabyFace")]
[assembly: AssemblyTitle("RadioBabyFace")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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 RadioBabyFace
{
internal static class LobbyCompatibility
{
internal static void Init()
{
PluginHelper.RegisterPlugin("butterystancakes.lethalcompany.radiobabyface", Version.Parse("1.0.1"), (CompatibilityLevel)0, (VersionStrictness)0);
}
}
[BepInPlugin("butterystancakes.lethalcompany.radiobabyface", "Radio Baby Face", "1.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
internal const string PLUGIN_GUID = "butterystancakes.lethalcompany.radiobabyface";
internal const string PLUGIN_NAME = "Radio Baby Face";
internal const string PLUGIN_VERSION = "1.0.1";
internal static ManualLogSource Logger;
private const string GUID_LOBBY_COMPATIBILITY = "BMX.LobbyCompatibility";
private void Awake()
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
if (Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility"))
{
Logger.LogInfo((object)"CROSS-COMPATIBILITY - Lobby Compatibility detected");
LobbyCompatibility.Init();
}
new Harmony("butterystancakes.lethalcompany.radiobabyface").PatchAll();
Logger.LogInfo((object)"Radio Baby Face v1.0.1 loaded");
}
}
[HarmonyPatch]
internal class RadioBabyFacePatches
{
[HarmonyPatch(typeof(StartOfRound), "Awake")]
[HarmonyPostfix]
private static void StartOfRoundPostAwake()
{
Terminal obj = Object.FindAnyObjectByType<Terminal>();
object obj2;
if (obj == null)
{
obj2 = null;
}
else
{
BuyableVehicle? obj3 = ((IEnumerable<BuyableVehicle>)obj.buyableVehicles).FirstOrDefault((Func<BuyableVehicle, bool>)((BuyableVehicle buyableVehicle) => buyableVehicle.vehicleDisplayName == "Cruiser"));
if (obj3 == null)
{
obj2 = null;
}
else
{
GameObject vehiclePrefab = obj3.vehiclePrefab;
obj2 = ((vehiclePrefab != null) ? vehiclePrefab.GetComponent<VehicleController>() : null);
}
}
VehicleController val = (VehicleController)obj2;
if ((Object)(object)val != (Object)null && !val.radioClips.Any((AudioClip radioClip) => ((Object)radioClip).name.StartsWith("Radio_BabyFace")))
{
try
{
AssetBundle val2 = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "radiobabyface"));
val.radioClips = new List<AudioClip>(val.radioClips) { val2.LoadAsset<AudioClip>("Radio_BabyFace") }.ToArray();
val2.Unload(false);
Plugin.Logger.LogDebug((object)"Loaded \"Baby Face\" track into Cruiser radio");
}
catch
{
Plugin.Logger.LogError((object)"Encountered some error loading asset bundle. Did you install the plugin correctly?");
}
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "RadioBabyFace";
public const string PLUGIN_NAME = "RadioBabyFace";
public const string PLUGIN_VERSION = "1.0.1";
}
}