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.Logging;
using HarmonyLib;
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.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RadioBabyFace")]
[assembly: AssemblyTitle("RadioBabyFace")]
[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 RadioBabyFace
{
[BepInPlugin("butterystancakes.lethalcompany.radiobabyface", "Radio Baby Face", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private const string PLUGIN_GUID = "butterystancakes.lethalcompany.radiobabyface";
private const string PLUGIN_NAME = "Radio Baby Face";
private const string PLUGIN_VERSION = "1.0.0";
internal static ManualLogSource Logger;
private void Awake()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
new Harmony("butterystancakes.lethalcompany.radiobabyface").PatchAll();
Logger.LogInfo((object)"Radio Baby Face v1.0.0 loaded");
}
}
[HarmonyPatch]
internal class RadioBabyFacePatches
{
[HarmonyPatch(typeof(Terminal), "Start")]
[HarmonyPostfix]
private static void TerminalPostStart(Terminal __instance)
{
BuyableVehicle? obj = ((IEnumerable<BuyableVehicle>)__instance.buyableVehicles).FirstOrDefault((Func<BuyableVehicle, bool>)((BuyableVehicle buyableVehicle) => buyableVehicle.vehicleDisplayName == "Cruiser"));
object obj2;
if (obj == null)
{
obj2 = null;
}
else
{
GameObject vehiclePrefab = obj.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.LogInfo((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.0";
}
}