Decompiled source of DineLegacy v1.1.0

DineLegacy.dll

Decompiled 2 months ago
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 Dawn;
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: AssemblyCompany("UnloadedHangar")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Adds billboards to several moons")]
[assembly: AssemblyFileVersion("1.3.6.0")]
[assembly: AssemblyInformationalVersion("1.0.7+75e95b7d38c16d78266d6b3452ddfb59cc4fbbc1")]
[assembly: AssemblyProduct("OutsideStructures")]
[assembly: AssemblyTitle("OutsideStructures")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.6.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 DineLegacy
{
	internal class Content
	{
		public static Object[] AssetsList;

		public static AssetBundle SceneAssetBundle;

		internal static string SceneAssetBundlePath;

		internal static SelectableLevel level;

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

		private static void LoadAssetsFromAssetBundle()
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			try
			{
				string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location);
				string text = Path.Combine(directoryName, "dinelegacymain");
				SceneAssetBundlePath = Path.Combine(directoryName, "dinelegacymainscene");
				AssetBundle val = AssetBundle.LoadFromFile(text);
				AssetsList = val.LoadAllAssets();
				List<AssetBundle> list = AssetBundle.GetAllLoadedAssetBundles().ToList();
				level = (SelectableLevel)AssetsList.ToList().Find((Object x) => ((object)x).GetType() == typeof(SelectableLevel));
				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}");
			}
		}
	}
	internal class MoonInjectionHandler : IMoonSceneInfo, INamespaced<IMoonSceneInfo>, INamespaced
	{
		private static bool HasFinishedInjection;

		public string SceneName => "Level6DineLegacy";

		public ProviderTable<int?, DawnMoonInfo, SpawnWeightContext> Weight => ProviderTable<int?, DawnMoonInfo, SpawnWeightContext>.Empty();

		public NamespacedKey<IMoonSceneInfo> TypedKey => NamespacedKey<IMoonSceneInfo>.From("DineLegacy", "MoonInjectionHandler");

		public NamespacedKey Key => NamespacedKey.From("DineLegacy", "MoonInjectionHandler");

		internal static void InjectMoonData()
		{
			try
			{
				Content.level.sceneName = "Level6DineLegacy";
				DawnLib.DefineMoon(NamespacedKey<DawnMoonInfo>.From("DineLegacy", "MoonInjectionHandler"), Content.level, (Action<MoonInfoBuilder>)delegate(MoonInfoBuilder info)
				{
					info.OverrideCost(600).AddScene(NamespacedKey<IMoonSceneInfo>.From("DineLegacy", "MoonInjectionHandler"), (AnimationClip)null, (AnimationClip)null, ProviderTable<int?, DawnMoonInfo, SpawnWeightContext>.Empty(), Content.SceneAssetBundlePath, "Assets/LethalCompany/Game/Scenes/Level6DineLegacy.unity");
				});
				HasFinishedInjection = true;
			}
			catch (Exception ex)
			{
				Plugin.logger.LogFatal((object)("Failed to inject moon data, this game instance is now tainted! Exception -> " + ex));
			}
			finally
			{
				if (HasFinishedInjection)
				{
					Plugin.logger.LogInfo((object)"Moon data injection complete!");
				}
			}
		}
	}
	[BepInPlugin("DineLegacy-UnloadedHangar", "DineLegacy", "1.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static class PluginInfo
		{
			public const string Guid = "DineLegacy-UnloadedHangar";

			public const string Name = "DineLegacy";

			public const string Ver = "1.1.0";
		}

		internal static Plugin Instance;

		internal static ManualLogSource logger;

		internal Harmony _harmony;

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