Decompiled source of ExpeditionUnlock v1.0.0

ExpeditionUnlock.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using GameData;
using HarmonyLib;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ExpeditionUnlock")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ExpeditionUnlock")]
[assembly: AssemblyTitle("ExpeditionUnlock")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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;
		}
	}
}
namespace ExpeditionUnlock
{
	public class UnlockedExpedition
	{
		public int rundown;

		public char tier;

		public int expeditionIndex;

		public UnlockedExpedition(int rundown, char tier, int expedition)
		{
			this.rundown = rundown;
			this.tier = tier;
			expeditionIndex = expedition;
		}

		public UnlockedExpedition()
		{
		}
	}
	[HarmonyPatch]
	internal static class Patch
	{
		public static uint[] rundownsDataBlockPersistentID = new uint[8] { 32u, 33u, 34u, 37u, 38u, 41u, 31u, 35u };

		[HarmonyPatch(typeof(GameDataInit), "Initialize")]
		[HarmonyPostfix]
		public static void MyPatch(GameDataInit __instance)
		{
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Expected O, but got Unknown
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Expected O, but got Unknown
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Expected O, but got Unknown
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Expected O, but got Unknown
			List<UnlockedExpedition> list = new List<UnlockedExpedition>();
			string[] array = Plugin.unlockExpeditionsInput.Value.Split('|', StringSplitOptions.TrimEntries);
			for (int i = 0; i < array.Length; i++)
			{
				string text = array[i].Trim('[', ']');
				string[] array2 = text.Split(',', StringSplitOptions.RemoveEmptyEntries);
				UnlockedExpedition unlockedExpedition = new UnlockedExpedition();
				if (!int.TryParse(array2[0], out var result))
				{
					continue;
				}
				unlockedExpedition.rundown = result;
				if (char.TryParse(array2[1], out var result2))
				{
					unlockedExpedition.tier = result2;
					if (int.TryParse(array2[2], out var result3))
					{
						unlockedExpedition.expeditionIndex = result3;
						list.Add(unlockedExpedition);
					}
				}
			}
			bool flag = default(bool);
			foreach (UnlockedExpedition item in list)
			{
				RundownDataBlock block = GameDataBlockBase<RundownDataBlock>.GetBlock(rundownsDataBlockPersistentID[item.rundown - 1]);
				List<ExpeditionInTierData> val = null;
				int num = -1;
				if (block != null)
				{
					switch (item.tier)
					{
					case 'A':
						val = block.TierA;
						num = 0;
						break;
					case 'B':
						val = block.TierB;
						num = 1;
						break;
					case 'C':
						val = block.TierC;
						num = 2;
						break;
					case 'D':
						val = block.TierD;
						num = 3;
						break;
					case 'E':
						val = block.TierE;
						num = 4;
						break;
					}
				}
				else
				{
					ManualLogSource l = Plugin.L;
					BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(36, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("DataBlock for Rundown ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(item.rundown);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" Doesn't Exist");
					}
					l.LogError(val2);
				}
				if (val == null || val.Count == 0 || num < 0)
				{
					ManualLogSource l2 = Plugin.L;
					BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(28, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Rundown ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(item.rundown);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" Tier ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<char>(item.tier);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" Doesn't Exist");
					}
					l2.LogError(val2);
					continue;
				}
				int num2 = item.expeditionIndex - 1;
				if (val.Count >= num2)
				{
					ManualLogSource l3 = Plugin.L;
					BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(23, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Unlocked Expendition: R");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(item.rundown);
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<char>(item.tier);
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(item.expeditionIndex);
					}
					l3.LogInfo(val3);
					val[num2].Accessibility = (eExpeditionAccessibility)2;
				}
				else
				{
					ManualLogSource l4 = Plugin.L;
					BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(27, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Expedition Doesn't Exist: R");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(item.rundown);
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<char>(item.tier);
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(item.expeditionIndex);
					}
					l4.LogError(val2);
				}
			}
		}
	}
	[BepInPlugin("INF.ExpeditionUnlock", "ExpeditionUnlock", "1.0.0")]
	public class Plugin : BasePlugin
	{
		public static ManualLogSource L;

		public static ConfigEntry<string> unlockExpeditionsInput;

		public override void Load()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			L = ((BasePlugin)this).Log;
			unlockExpeditionsInput = ((BasePlugin)this).Config.Bind<string>("General", "Unlocked Expeditions", "", "List of expeditions to force unlock");
			new Harmony("INF.ExpeditionUnlock").PatchAll();
			((BasePlugin)this).Log.LogInfo((object)"ExpeditionUnlock is loaded!");
		}
	}
}