Decompiled source of Billboards v1.0.7

Billboards.dll

Decompiled 3 hours ago
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 Billboards.Modules;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyCompany("UnloadedHangar")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Adds billboards to several moons")]
[assembly: AssemblyFileVersion("1.0.7.0")]
[assembly: AssemblyInformationalVersion("1.0.7+75e95b7d38c16d78266d6b3452ddfb59cc4fbbc1")]
[assembly: AssemblyProduct("Billboards")]
[assembly: AssemblyTitle("Billboards")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.7.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 Billboards
{
	internal class Content
	{
		public static GameObject[] AssetsList;

		public static void Load()
		{
			LoadAssetsFromAssetBundle();
		}

		private static void LoadAssetsFromAssetBundle()
		{
			try
			{
				string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location);
				string text = Path.Combine(directoryName, "bilboards");
				AssetBundle val = AssetBundle.LoadFromFile(text);
				AssetsList = val.LoadAllAssets<GameObject>();
				Plugin.logger.LogInfo((object)"Successfully loaded assets from AssetBundle!");
			}
			catch (Exception arg)
			{
				Plugin.logger.LogError((object)$"Error: failed to load assets from AssetBundle.\n\n{arg}");
			}
		}
	}
	[BepInPlugin("Billboards-UnloadedHangar", "Billboards", "1.0.7")]
	public class Plugin : BaseUnityPlugin
	{
		public static class PluginInfo
		{
			public const string Guid = "Billboards-UnloadedHangar";

			public const string Name = "Billboards";

			public const string Ver = "1.0.7";
		}

		internal static Plugin Instance;

		internal static ManualLogSource logger;

		private Harmony _harmony;

		private void Awake()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			logger = Logger.CreateLogSource("Billboards");
			logger.LogInfo((object)"Billboards has awoken!");
			Content.Load();
			NetcodePatcherAwake();
			_harmony = new Harmony("Billboards-UnloadedHangar");
			_harmony.PatchAll(typeof(PatchClass));
		}

		private void NetcodePatcherAwake()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			Type[] array2 = array;
			foreach (Type type in array2)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array3 = methods;
				MethodInfo[] array4 = array3;
				foreach (MethodInfo methodInfo in array4)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
}
namespace Billboards.Modules
{
	public class PatchClass
	{
		public static Scene TargetScene = SceneManager.GetSceneByName("SampleSceneRelay");

		[HarmonyPostfix]
		[HarmonyPatch(typeof(RoundManager), "FinishGeneratingNewLevelClientRpc")]
		private static void PatchObject()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			Scene sceneByName = SceneManager.GetSceneByName("SampleSceneRelay");
			if (!((Scene)(ref sceneByName)).isLoaded)
			{
				return;
			}
			Quaternion rotation;
			if (((object)RoundManager.Instance.currentLevel).ToString() == "ArtificeLevel (SelectableLevel)")
			{
				bool flag = true;
				try
				{
					GameObject obj = Content.AssetsList[0];
					Vector3 position = Content.AssetsList[0].transform.position;
					rotation = Content.AssetsList[0].transform.rotation;
					GameObject val = Object.Instantiate<GameObject>(obj, position, ((Quaternion)(ref rotation)).normalized, Content.AssetsList[0].transform.parent);
					Plugin.logger.LogDebug((object)"ArtificeBillboardSpawn");
					try
					{
						Content.AssetsList[0].SetActive(true);
						Content.AssetsList[1].SetActive(false);
						return;
					}
					catch (Exception arg)
					{
						Plugin.logger.LogError((object)$"ArtificeBillboardSpawn threw an error, destroy module {arg}");
						return;
					}
				}
				catch (Exception arg2)
				{
					Plugin.logger.LogError((object)$"ArtificeBillboardSpawn threw an error {arg2}");
					return;
				}
			}
			if (((object)RoundManager.Instance.currentLevel).ToString() == "AssuranceLevel (SelectableLevel)")
			{
				bool flag2 = true;
				try
				{
					GameObject obj2 = Content.AssetsList[1];
					Vector3 position2 = Content.AssetsList[1].transform.position;
					rotation = Content.AssetsList[1].transform.rotation;
					GameObject val2 = Object.Instantiate<GameObject>(obj2, position2, ((Quaternion)(ref rotation)).normalized, Content.AssetsList[1].transform.parent);
					Plugin.logger.LogDebug((object)"AssuranceBillboardSpawn");
					try
					{
						Content.AssetsList[0].SetActive(false);
						Content.AssetsList[1].SetActive(true);
						return;
					}
					catch (Exception arg3)
					{
						Plugin.logger.LogError((object)$"AssuranceBillboardSpawn threw an error {arg3}");
						return;
					}
				}
				catch (Exception arg4)
				{
					Plugin.logger.LogError((object)$"Something happened, idk what... {arg4}");
					return;
				}
			}
			try
			{
				Content.AssetsList[0].SetActive(false);
				Content.AssetsList[1].SetActive(false);
				Plugin.logger.LogWarning((object)"No compatible planet dettected, attemping to shutdown all billboard objects!");
			}
			catch (Exception arg5)
			{
				Plugin.logger.LogError((object)$"Failed to shutdown billboards objects with an exception: {arg5}");
			}
		}
	}
}