Decompiled source of Free Bird Racing v1.0.0

FreeBirdRacing.dll

Decompiled 3 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using FreeBirdRacing.Patches;
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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("FreeBirdRacing")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FreeBirdRacing")]
[assembly: AssemblyTitle("FreeBirdRacing")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 FreeBirdRacing
{
	[BepInPlugin("themorningstar.freebirdracing", "Free Bird Racing", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "themorningstar.freebirdracing";

		internal static ManualLogSource Log;

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			try
			{
				new Harmony("themorningstar.freebirdracing").PatchAll(typeof(ArenaRacePatch));
				Log.LogInfo((object)"FreeBirdRacing: Harmony patches applied — ArenaRace will also play Free Bird.");
			}
			catch (Exception ex)
			{
				Log.LogError((object)("FreeBirdRacing: patch failed during Awake: " + ex));
			}
		}

		internal static AudioClip[] GetFreeBirdClips()
		{
			Type type = null;
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				if (assembly.GetName().Name == "Repo_Moding")
				{
					type = assembly.GetType("Repo_Moding.Plugin");
					break;
				}
			}
			if (type == null)
			{
				Log.LogWarning((object)"FreeBirdRacing: Could not find Repo_Moding assembly. Is Free_Bird installed?");
				return null;
			}
			FieldInfo field = type.GetField("free_bird", BindingFlags.Static | BindingFlags.Public);
			if (field == null)
			{
				Log.LogWarning((object)"FreeBirdRacing: Could not find 'free_bird' field on Repo_Moding.Plugin. Free_Bird version mismatch?");
				return null;
			}
			if (!(field.GetValue(null) is AudioClip[] array) || array.Length == 0)
			{
				Log.LogWarning((object)"FreeBirdRacing: free_bird AudioClip[] is null or empty. Free_Bird may not have loaded its bundle yet.");
				return null;
			}
			Log.LogInfo((object)$"FreeBirdRacing: Got {array.Length} clip(s) from Free_Bird mod.");
			return array;
		}
	}
}
namespace FreeBirdRacing.Patches
{
	public static class ArenaRacePatch
	{
		[HarmonyPatch(typeof(ArenaRace), "Awake")]
		[HarmonyPostfix]
		private static void PatchArenaRaceAwake(ArenaRace __instance)
		{
			AudioClip[] freeBirdClips = Plugin.GetFreeBirdClips();
			if (freeBirdClips == null)
			{
				Plugin.Log.LogWarning((object)"FreeBirdRacing: Skipping soundArenaRaceMusic replacement (no clips).");
				return;
			}
			__instance.soundArenaRaceMusic.Sounds = freeBirdClips;
			Plugin.Log.LogInfo((object)"FreeBirdRacing: soundArenaRaceMusic.Sounds replaced with Free Bird clips.");
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}