Decompiled source of Custom Boosters v1.2.0

BoosterPack.dll

Decompiled 7 months ago
using System;
using System.CodeDom.Compiler;
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.Text.Json;
using System.Text.Json.Serialization;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BoosterImplants;
using BoosterPack.Manager;
using BoosterPack.Models;
using BoosterPack.Patches;
using CellMenu;
using DropServer.BoosterImplants;
using GameData;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Threading.Tasks;
using Localization;
using MTFO.API;
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: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("BoosterPack")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+git465baee-dirty-master")]
[assembly: AssemblyProduct("BoosterPack")]
[assembly: AssemblyTitle("BoosterPack")]
[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 BoosterPack
{
	[BepInPlugin("Endskill.CustomBoosters", "CustomBoosters", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BepinExLoader : BasePlugin
	{
		public const string MODNAME = "CustomBoosters";

		public const string AUTHOR = "Endskill";

		public const string GUID = "Endskill.CustomBoosters";

		public const string VERSION = "1.0.0";

		public override void Load()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			LogManager.SetLogger(((BasePlugin)this).Log);
			LogManager._debugMessagesActive = ((BasePlugin)this).Config.Bind<bool>("Dev Settings", "DebugMessages", false, "This settings activates/deactivates debug messages in the console for this specific plugin.").Value;
			Harmony val = new Harmony("Endskill.CustomBoosters");
			val.PatchAll(typeof(PersistentInventoryManagerPatches));
			val.PatchAll(typeof(DropServerPatches));
			val.PatchAll(typeof(BoosterImplantInventoryItemPatches));
			val.PatchAll(typeof(CmPageLoadoutPatches));
			MTFOHotReloadAPI.OnHotReload += ScriptManager.HotReaload;
		}
	}
	public static class CacheApiWrapper
	{
		internal static BoosterImplantPlayerData _inv;

		public static bool UseCustomData { get; set; }

		public static BoosterImplantPlayerData Inventory
		{
			get
			{
				return _inv;
			}
			set
			{
				_inv = value;
			}
		}
	}
	internal static class LogManager
	{
		private static ManualLogSource logger;

		internal static bool _debugMessagesActive;

		internal static void SetLogger(ManualLogSource log)
		{
			logger = log;
		}

		public static void Verbose(object msg)
		{
			if (_debugMessagesActive)
			{
				logger.LogInfo(msg);
			}
		}

		public static void Debug(object msg)
		{
			if (_debugMessagesActive)
			{
				logger.LogDebug(msg);
			}
		}

		public static void Message(object msg)
		{
			if (_debugMessagesActive)
			{
				logger.LogMessage(msg);
			}
		}

		public static void Error(object msg)
		{
			logger.LogError(msg);
		}

		public static void Warn(object msg)
		{
			logger.LogWarning(msg);
		}
	}
	[GeneratedCode("VersionInfoGenerator", "2.0.0+git50a4b1a-master")]
	[CompilerGenerated]
	internal static class VersionInfo
	{
		public const string RootNamespace = "BoosterPack";

		public const string Version = "1.0.0";

		public const string VersionPrerelease = null;

		public const string VersionMetadata = "git465baee-dirty-master";

		public const string SemVer = "1.0.0+git465baee-dirty-master";

		public const string GitRevShort = "465baee-dirty";

		public const string GitRevLong = "465baeed0cd33374f3d2e30104b8e8fe99e66f59-dirty";

		public const string GitBranch = "master";

		public const string GitTag = null;

		public const bool GitIsDirty = true;
	}
}
namespace BoosterPack.Patches
{
	[HarmonyPatch(typeof(BoosterImplantInventoryItem))]
	public class BoosterImplantInventoryItemPatches
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPrefix]
		public static bool Prefix(ref bool __result)
		{
			__result = true;
			return false;
		}
	}
	[HarmonyPatch(typeof(CM_PageLoadout))]
	public static class CmPageLoadoutPatches
	{
		[HarmonyPatch("ProcessBoosterImplantEvents")]
		[HarmonyPrefix]
		public static bool ProcessBoosterImplantEventsPrefix()
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(DropServerManager))]
	public static class DropServerManagerPatches
	{
		private static PlayerInventoryData _cachedInventory;

		[HarmonyPatch("GetBoosterImplantPlayerDataAsync")]
		[HarmonyPrefix]
		public static bool GetBoosterImplantPlayerDataAsyncPrefix(ref Task<PlayerInventoryData> __result)
		{
			LogManager.Debug("Booster Patch");
			__result = GetInventory();
			return false;
		}

		[HarmonyPatch("GetInventoryPlayerDataAsync")]
		[HarmonyPrefix]
		public static bool GetInventoryPlayerDataAsyncPrefix(ref Task<PlayerInventoryData> __result)
		{
			LogManager.Debug("Inventar Patch");
			__result = GetInventory();
			return false;
		}

		private static Task<PlayerInventoryData> GetInventory()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_0058: Expected O, but got Unknown
			if (_cachedInventory != null)
			{
				return Task.FromResult<PlayerInventoryData>(_cachedInventory);
			}
			_cachedInventory = new PlayerInventoryData();
			_cachedInventory.BoosterData = new Nullable<BoosterImplantPlayerData>(new BoosterImplantPlayerData
			{
				Basic = new Category(),
				Advanced = new Category(),
				Specialized = new Category()
			});
			return Task.FromResult<PlayerInventoryData>(_cachedInventory);
		}
	}
	[HarmonyPatch(typeof(DropServerGameSession))]
	internal class DropServerPatches
	{
		[HarmonyPatch("ConsumeBoosters")]
		[HarmonyPrefix]
		public static bool ConsumeBoostersPrefix()
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(PersistentInventoryManager))]
	public class PersistentInventoryManagerPatches
	{
		private static uint _id = 9599u;

		[HarmonyPatch("UpdateBoosterImplants")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		public static bool UpdateBoosterImplantsPrefix(PersistentInventoryManager __instance)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Invalid comparison between Unknown and I4
			ScriptManager.Initialize();
			if (!CacheApiWrapper.UseCustomData)
			{
				CreateData();
			}
			BoosterImplant[] array = ((IEnumerable<BoosterImplantCategory>)BoosterImplantConstants.Categories).Select((BoosterImplantCategory c) => PersistentInventoryManager.GetActiveBoosterImplant((BoosterImplantCategory)c)).ToArray();
			UpdateBoosterImplantInventoryModelMock(__instance);
			if ((int)__instance.m_boosterImplantDirtyState == 0)
			{
				__instance.ClearPendingBoosterImplantTransactions();
			}
			else
			{
				PersistentInventoryManager.CleanupPendingBoosterImplantTransactions(__instance.m_boosterImplantPendingTransactions, __instance.m_boosterImplantInventory);
				PersistentInventoryManager.ApplyPendingBoosterImplantTransactionsToModel(__instance.m_boosterImplantInventory, __instance.m_boosterImplantPendingTransactions);
			}
			for (int i = 0; i < array.Length; i++)
			{
				if (PersistentInventoryManager.GetActiveBoosterImplant((BoosterImplantCategory)i) != array[i])
				{
					Action onActiveBoosterImplantsChanged = __instance.OnActiveBoosterImplantsChanged;
					if (onActiveBoosterImplantsChanged != null)
					{
						onActiveBoosterImplantsChanged.Invoke();
					}
					break;
				}
			}
			Action onBoosterImplantInventoryChanged = __instance.OnBoosterImplantInventoryChanged;
			if ((Delegate)(object)onBoosterImplantInventoryChanged == (Delegate)null)
			{
				return false;
			}
			onBoosterImplantInventoryChanged.Invoke();
			return false;
		}

		private static void CreateData()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			//IL_038b: Expected O, but got Unknown
			//IL_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Expected O, but got Unknown
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Expected O, but got Unknown
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Expected O, but got Unknown
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Expected I4, but got Unknown
			Il2CppArrayBase<BoosterImplantTemplateDataBlock> allBlocks = GameDataBlockBase<BoosterImplantTemplateDataBlock>.GetAllBlocks();
			Il2CppArrayBase<BoosterImplantEffectDataBlock> allBlocks2 = GameDataBlockBase<BoosterImplantEffectDataBlock>.GetAllBlocks();
			Il2CppArrayBase<BoosterImplantConditionDataBlock> allBlocks3 = GameDataBlockBase<BoosterImplantConditionDataBlock>.GetAllBlocks();
			List<BoosterImplantInventoryItem> list = new List<BoosterImplantInventoryItem>();
			List<BoosterImplantInventoryItem> list2 = new List<BoosterImplantInventoryItem>();
			List<BoosterImplantInventoryItem> list3 = new List<BoosterImplantInventoryItem>();
			foreach (BoosterImplantTemplateDataBlock item3 in allBlocks)
			{
				BoosterImplantInventoryItem val = new BoosterImplantInventoryItem();
				((BoosterImplantBase)val).Id = _id++;
				((BoosterImplantBase)val).TemplateId = ((GameDataBlockBase<BoosterImplantTemplateDataBlock>)(object)item3).persistentID;
				((BoosterImplantBase)val).UsesRemaining = 88;
				List<BoosterImplantEffect> list4 = new List<BoosterImplantEffect>();
				Enumerator<BoosterImplantEffectInstance> enumerator2 = item3.Effects.GetEnumerator();
				while (enumerator2.MoveNext())
				{
					BoosterImplantEffectInstance effect2 = enumerator2.Current;
					BoosterImplantEffectDataBlock val2 = ((IEnumerable<BoosterImplantEffectDataBlock>)allBlocks2).First((BoosterImplantEffectDataBlock x) => ((GameDataBlockBase<BoosterImplantEffectDataBlock>)(object)x).persistentID == effect2.BoosterImplantEffect);
					LogManager.Debug($"Effect has: {val2.BoosterEffectCategory}, Param: {effect2.MaxValue}");
					BoosterImplantEffect item = default(BoosterImplantEffect);
					item.Id = effect2.BoosterImplantEffect;
					item.Param = effect2.MaxValue;
					list4.Add(item);
				}
				bool flag = true;
				Enumerator<List<BoosterImplantEffectInstance>> enumerator3 = item3.RandomEffects.GetEnumerator();
				while (enumerator3.MoveNext())
				{
					List<BoosterImplantEffectInstance> current2 = enumerator3.Current;
					if (!flag)
					{
						continue;
					}
					flag = false;
					Enumerator<BoosterImplantEffectInstance> enumerator4 = current2.GetEnumerator();
					while (enumerator4.MoveNext())
					{
						BoosterImplantEffectInstance effect = enumerator4.Current;
						BoosterImplantEffectDataBlock val3 = ((IEnumerable<BoosterImplantEffectDataBlock>)allBlocks2).First((BoosterImplantEffectDataBlock x) => ((GameDataBlockBase<BoosterImplantEffectDataBlock>)(object)x).persistentID == effect.BoosterImplantEffect);
						LogManager.Debug($"Effect has: {val3.BoosterEffectCategory}, Param: {effect.MaxValue}");
						BoosterImplantEffect item2 = default(BoosterImplantEffect);
						item2.Id = effect.BoosterImplantEffect;
						item2.Param = effect.MaxValue;
						list4.Add(item2);
					}
				}
				((BoosterImplantBase)val).Effects = Il2CppStructArray<BoosterImplantEffect>.op_Implicit(list4.ToArray());
				foreach (BoosterImplantEffect item4 in (Il2CppArrayBase<BoosterImplantEffect>)(object)((BoosterImplantBase)val).Effects)
				{
					LogManager.Debug($"Effect2 has: {item4.Id}, Param: {item4.Param}");
				}
				((BoosterImplantBase)val).Conditions = new Il2CppStructArray<uint>(Il2CppArrayBase<uint>.op_Implicit(item3.Conditions?.ToArray()));
				BoosterImplantCategory implantCategory = item3.ImplantCategory;
				BoosterImplantCategory val4 = implantCategory;
				switch ((int)val4)
				{
				case 0:
					list.Add(val);
					break;
				case 1:
					list2.Add(val);
					break;
				case 2:
					list3.Add(val);
					break;
				}
			}
			Category val5 = new Category();
			Category val6 = new Category();
			Category val7 = new Category();
			val5.Inventory = new Il2CppReferenceArray<BoosterImplantInventoryItem>(list.ToArray());
			val6.Inventory = new Il2CppReferenceArray<BoosterImplantInventoryItem>(list2.ToArray());
			val7.Inventory = new Il2CppReferenceArray<BoosterImplantInventoryItem>(list3.ToArray());
			BoosterImplantPlayerData val8 = new BoosterImplantPlayerData();
			val8.Basic = val5;
			val8.Advanced = val6;
			val8.Specialized = val7;
			val8.New = Il2CppStructArray<uint>.op_Implicit(new uint[0]);
			CacheApiWrapper.Inventory = val8;
		}

		private static void UpdateBoosterImplantInventoryModelMock(PersistentInventoryManager instance)
		{
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Expected O, but got Unknown
			BoosterImplantPlayerData inventory = CacheApiWrapper.Inventory;
			BoosterImplantInventoryModel boosterImplantInventory = instance.m_boosterImplantInventory;
			boosterImplantInventory.New.Clear();
			int num = 0;
			while (true)
			{
				int num2 = num;
				uint[] array = Il2CppArrayBase<uint>.op_Implicit((Il2CppArrayBase<uint>)(object)inventory.New);
				int num3 = ((array != null) ? array.Length : 0);
				if (num2 < num3)
				{
					boosterImplantInventory.New.Add(((Il2CppArrayBase<uint>)(object)inventory.New)[num]);
					num++;
					continue;
				}
				break;
			}
			Category[] array2 = (Category[])(object)new Category[3] { inventory.Basic, inventory.Advanced, inventory.Specialized };
			int num4 = default(int);
			for (int i = 0; i < array2.Length; i++)
			{
				Category val = array2[i];
				Category val2 = ((Il2CppArrayBase<Category>)(object)boosterImplantInventory.Categories)[i];
				uint num5 = (boosterImplantInventory.FindPrepared((BoosterImplantCategory)i, ref num4) ? ((Il2CppArrayBase<Category>)(object)boosterImplantInventory.Categories)[i].Inventory[num4].InstanceId : uint.MaxValue);
				val2.Inventory.Clear();
				for (int j = 0; j < ((Il2CppArrayBase<BoosterImplantInventoryItem>)(object)val.Inventory).Length; j++)
				{
					try
					{
						BoosterImplantInventoryItem val3 = ((Il2CppArrayBase<BoosterImplantInventoryItem>)(object)val.Inventory)[j];
						foreach (BoosterImplantEffect item in (Il2CppArrayBase<BoosterImplantEffect>)(object)((BoosterImplantBase)val3).Effects)
						{
							LogManager.Debug($"testItem has: {item.Id} {item.Param}");
						}
						BoosterImplantInventoryItem val4 = new BoosterImplantInventoryItem(((Il2CppArrayBase<BoosterImplantInventoryItem>)(object)val.Inventory)[j]);
						val4.Prepared = val4.InstanceId == num5;
						val2.Inventory.Add(val4);
					}
					catch (Exception ex)
					{
						PersistentInventoryManager.LogError(ex.Message);
					}
				}
				val2.Currency = val.Currency;
				val2.Missed = val.Missed;
				val2.MissedAcknowledged = Mathf.Clamp(val2.MissedAcknowledged, val.MissedAck, val.Missed);
			}
		}
	}
}
namespace BoosterPack.Models
{
	public class ActivateableBoosterData
	{
		public bool UseCustomData { get; set; }

		public List<CustomBooster> CustomBoosters { get; set; }
	}
	public class CustomBooster
	{
		private List<CustomEffect> _effects;

		private List<CustomCondition> _conditions;

		public string PublicName { get; set; }

		public string Description { get; set; }

		public BoosterEffectCategory MainEffectType { get; set; }

		public BoosterImplantCategory ImplantCategory { get; set; }

		public List<CustomEffect> Effects
		{
			get
			{
				if (_effects == null)
				{
					_effects = new List<CustomEffect>();
				}
				return _effects;
			}
			set
			{
				_effects = value;
			}
		}

		public List<CustomCondition> Conditions
		{
			get
			{
				if (_conditions == null)
				{
					_conditions = new List<CustomCondition>();
				}
				return _conditions;
			}
			set
			{
				_conditions = value;
			}
		}
	}
	public class CustomCondition
	{
		public BoosterCondition Condition { get; set; }

		public string PublicShortName { get; set; }

		public string PublicName { get; set; }

		public string Description { get; set; }
	}
	public class CustomEffect
	{
		public AgentModifier Effect { get; set; }

		public string PublicShortName { get; set; }

		public string PublicName { get; set; }

		public string Description { get; set; }

		public string DescriptionNegative { get; set; }

		public BoosterEffectCategory EffectCategory { get; set; }

		public float Value { get; set; }
	}
}
namespace BoosterPack.Manager
{
	public class DataBlockManager
	{
		private uint _templateIds = 306783378u;

		private uint _effectIds = 306783378u;

		private uint _conditionIds = 306783378u;

		private uint _itemId = 306783378u;

		private uint _id = 536870911u;

		public List<BoosterImplantInventoryItem> Basic { get; }

		public List<BoosterImplantInventoryItem> Advanced { get; }

		public List<BoosterImplantInventoryItem> Special { get; }

		public DataBlockManager()
		{
			Basic = new List<BoosterImplantInventoryItem>();
			Advanced = new List<BoosterImplantInventoryItem>();
			Special = new List<BoosterImplantInventoryItem>();
		}

		public void CreateDataBlocksForBooster(CustomBooster booster)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_005c: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Expected O, but got Unknown
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Expected O, but got Unknown
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Expected O, but got Unknown
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Expected I4, but got Unknown
			BoosterImplantTemplateDataBlock val = new BoosterImplantTemplateDataBlock();
			((GameDataBlockBase<BoosterImplantTemplateDataBlock>)(object)val).name = GetUniqueName();
			((GameDataBlockBase<BoosterImplantTemplateDataBlock>)(object)val).persistentID = ++_templateIds;
			val.Deprecated = false;
			val.PublicName = GetTranslation(booster.PublicName);
			val.Description = GetTranslation(booster.Description);
			val.ImplantCategory = booster.ImplantCategory;
			val.MainEffectType = booster.MainEffectType;
			foreach (CustomEffect effect in booster.Effects)
			{
				BoosterImplantEffectDataBlock val2 = new BoosterImplantEffectDataBlock();
				((GameDataBlockBase<BoosterImplantEffectDataBlock>)(object)val2).name = GetUniqueName();
				val2.Effect = effect.Effect;
				val2.BoosterEffectCategory = effect.EffectCategory;
				val2.PublicShortName = GetTranslation(effect.PublicShortName);
				val2.PublicName = GetTranslation(effect.PublicName);
				val2.Description = GetTranslation(effect.Description);
				val2.DescriptionNegative = GetTranslation(effect.DescriptionNegative);
				((GameDataBlockBase<BoosterImplantEffectDataBlock>)(object)val2).persistentID = _effectIds++;
				BoosterImplantEffectInstance val3 = new BoosterImplantEffectInstance();
				val3.BoosterImplantEffect = ((GameDataBlockBase<BoosterImplantEffectDataBlock>)(object)val2).persistentID;
				val3.MinValue = effect.Value;
				val3.MaxValue = effect.Value;
				val.Effects.Add(val3);
				GameDataBlockBase<BoosterImplantEffectDataBlock>.AddBlock(val2, -1);
			}
			foreach (CustomCondition condition in booster.Conditions)
			{
				BoosterImplantConditionDataBlock val4 = new BoosterImplantConditionDataBlock();
				((GameDataBlockBase<BoosterImplantConditionDataBlock>)(object)val4).name = GetUniqueName();
				val4.Condition = condition.Condition;
				val4.PublicShortName = GetTranslation(condition.PublicShortName);
				val4.PublicName = GetTranslation(condition.PublicName);
				val4.Description = GetTranslation(condition.Description);
				((GameDataBlockBase<BoosterImplantConditionDataBlock>)(object)val4).persistentID = _conditionIds++;
				val.Conditions.Add(((GameDataBlockBase<BoosterImplantConditionDataBlock>)(object)val4).persistentID);
				GameDataBlockBase<BoosterImplantConditionDataBlock>.AddBlock(val4, -1);
			}
			GameDataBlockBase<BoosterImplantTemplateDataBlock>.AddBlock(val, -1);
			BoosterImplantInventoryItem val5 = new BoosterImplantInventoryItem();
			((BoosterImplantBase)val5).Id = _itemId++;
			((BoosterImplantBase)val5).TemplateId = ((GameDataBlockBase<BoosterImplantTemplateDataBlock>)(object)val).persistentID;
			((BoosterImplantBase)val5).UsesRemaining = 99;
			List<BoosterImplantEffect> list = new List<BoosterImplantEffect>();
			Enumerator<BoosterImplantEffectInstance> enumerator3 = val.Effects.GetEnumerator();
			while (enumerator3.MoveNext())
			{
				BoosterImplantEffectInstance current3 = enumerator3.Current;
				BoosterImplantEffect item = default(BoosterImplantEffect);
				item.Id = current3.BoosterImplantEffect;
				item.Param = current3.MaxValue;
				list.Add(item);
			}
			((BoosterImplantBase)val5).Effects = Il2CppStructArray<BoosterImplantEffect>.op_Implicit(list.ToArray());
			((BoosterImplantBase)val5).Conditions = new Il2CppStructArray<uint>(Il2CppArrayBase<uint>.op_Implicit(val.Conditions?.ToArray()));
			BoosterImplantCategory implantCategory = val.ImplantCategory;
			BoosterImplantCategory val6 = implantCategory;
			switch ((int)val6)
			{
			case 0:
				Basic.Add(val5);
				break;
			case 1:
				Advanced.Add(val5);
				break;
			case 2:
				Special.Add(val5);
				break;
			}
		}

		private LocalizedText GetTranslation(string booLocalization)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			LocalizedText val = new LocalizedText();
			val.UntranslatedText = booLocalization;
			return val;
		}

		private string GetUniqueName()
		{
			return $"CustomBoosters_{++_id}";
		}
	}
	public static class ScriptManager
	{
		private static bool _initialized;

		internal static void HotReaload()
		{
			_initialized = false;
			Initialize();
			PersistentInventoryManager.Current.UpdateBoosterImplants(ref CacheApiWrapper._inv);
		}

		public static void Initialize()
		{
			if (!_initialized)
			{
				_initialized = true;
				string text = Path.Combine(MTFOPathAPI.CustomPath, "CustomBoosters");
				if (!Directory.Exists(text))
				{
					Directory.CreateDirectory(text);
				}
				WriteEnumValues(text);
				text = Path.Combine(text, "CustomBoosters.json");
				WriteDefault(text);
				ActivateableBoosterData data = ReadData(text);
				PrepareForUseIngame(data);
			}
		}

		public static void PrepareForUseIngame(ActivateableBoosterData data)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			CacheApiWrapper.UseCustomData = data.UseCustomData;
			List<CustomBooster> customBoosters = data.CustomBoosters;
			DataBlockManager dataBlockManager = new DataBlockManager();
			foreach (CustomBooster item in customBoosters)
			{
				dataBlockManager.CreateDataBlocksForBooster(item);
			}
			Category val = new Category();
			Category val2 = new Category();
			Category val3 = new Category();
			val.Inventory = Il2CppReferenceArray<BoosterImplantInventoryItem>.op_Implicit(dataBlockManager.Basic.ToArray());
			val2.Inventory = Il2CppReferenceArray<BoosterImplantInventoryItem>.op_Implicit(dataBlockManager.Advanced.ToArray());
			val3.Inventory = Il2CppReferenceArray<BoosterImplantInventoryItem>.op_Implicit(dataBlockManager.Special.ToArray());
			BoosterImplantPlayerData val4 = new BoosterImplantPlayerData();
			val4.Basic = val;
			val4.Advanced = val2;
			val4.Specialized = val3;
			val4.New = Il2CppStructArray<uint>.op_Implicit(new uint[0]);
			CacheApiWrapper.Inventory = val4;
		}

		private static ActivateableBoosterData ReadData(string path)
		{
			JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions
			{
				IncludeFields = false,
				ReadCommentHandling = JsonCommentHandling.Skip,
				PropertyNameCaseInsensitive = true,
				WriteIndented = true
			};
			jsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
			return JsonSerializer.Deserialize<ActivateableBoosterData>(File.ReadAllText(path), jsonSerializerOptions) ?? ParseExistingDataBlocks();
		}

		private static void WriteDefault(string path)
		{
			if (!File.Exists(path))
			{
				JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions
				{
					IncludeFields = false,
					ReadCommentHandling = JsonCommentHandling.Skip,
					PropertyNameCaseInsensitive = true,
					WriteIndented = true
				};
				jsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
				File.WriteAllText(path, JsonSerializer.Serialize(ParseExistingDataBlocks(), jsonSerializerOptions));
			}
		}

		private static void WriteEnumValues(string dictionaryPath)
		{
			string path = Path.Combine(dictionaryPath, "MainEffectType.txt");
			if (!File.Exists(path))
			{
				File.WriteAllText(path, "==This file is auto-generated by CustomBoosters. It's not for editing==\n" + string.Join("\n", Enum.GetNames(typeof(BoosterEffectCategory))));
			}
			string path2 = Path.Combine(dictionaryPath, "EffectCategory.txt");
			if (!File.Exists(path2))
			{
				File.WriteAllText(path2, "==This file is auto-generated by CustomBoosters. It's not for editing==\n" + string.Join("\n", Enum.GetNames(typeof(BoosterEffectCategory))));
			}
			string path3 = Path.Combine(dictionaryPath, "ImplantCategory.txt");
			if (!File.Exists(path3))
			{
				File.WriteAllText(path3, "==This file is auto-generated by CustomBoosters. It's not for editing==\n" + string.Join("\n", Enum.GetNames(typeof(BoosterImplantCategory))));
			}
			string path4 = Path.Combine(dictionaryPath, "Effect.txt");
			if (!File.Exists(path4))
			{
				File.WriteAllText(path4, "==This file is auto-generated by CustomBoosters. It's not for editing==\n" + string.Join("\n", Enum.GetNames(typeof(AgentModifier))));
			}
			string path5 = Path.Combine(dictionaryPath, "Condition.txt");
			if (!File.Exists(path5))
			{
				File.WriteAllText(path5, "==This file is auto-generated by CustomBoosters. It's not for editing==\n" + string.Join("\n", Enum.GetNames(typeof(BoosterCondition))));
			}
		}

		private static ActivateableBoosterData ParseExistingDataBlocks()
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			ActivateableBoosterData activateableBoosterData = new ActivateableBoosterData();
			List<CustomBooster> list2 = (activateableBoosterData.CustomBoosters = new List<CustomBooster>());
			activateableBoosterData.UseCustomData = false;
			Il2CppArrayBase<BoosterImplantTemplateDataBlock> allBlocks = GameDataBlockBase<BoosterImplantTemplateDataBlock>.GetAllBlocks();
			Il2CppArrayBase<BoosterImplantEffectDataBlock> allBlocks2 = GameDataBlockBase<BoosterImplantEffectDataBlock>.GetAllBlocks();
			Il2CppArrayBase<BoosterImplantConditionDataBlock> allBlocks3 = GameDataBlockBase<BoosterImplantConditionDataBlock>.GetAllBlocks();
			foreach (BoosterImplantTemplateDataBlock temp in allBlocks)
			{
				CustomBooster customBooster = new CustomBooster();
				customBooster.PublicName = Text.Get(temp.PublicName.Id);
				customBooster.Description = Text.Get(temp.Description.Id);
				customBooster.MainEffectType = temp.MainEffectType;
				customBooster.ImplantCategory = temp.ImplantCategory;
				Enumerator<BoosterImplantEffectInstance> enumerator2 = temp.Effects.GetEnumerator();
				while (enumerator2.MoveNext())
				{
					BoosterImplantEffectInstance effect = enumerator2.Current;
					BoosterImplantEffectDataBlock effectDb2 = ((IEnumerable<BoosterImplantEffectDataBlock>)allBlocks2).First((BoosterImplantEffectDataBlock x) => ((GameDataBlockBase<BoosterImplantEffectDataBlock>)(object)x).persistentID == effect.BoosterImplantEffect);
					customBooster.Effects.Add(ParseEffect(effectDb2, effect.MaxValue));
				}
				if (temp.RandomEffects.Count > 0)
				{
					Enumerator<BoosterImplantEffectInstance> enumerator3 = temp.RandomEffects[0].GetEnumerator();
					while (enumerator3.MoveNext())
					{
						BoosterImplantEffectInstance effect2 = enumerator3.Current;
						BoosterImplantEffectDataBlock effectDb3 = ((IEnumerable<BoosterImplantEffectDataBlock>)allBlocks2).First((BoosterImplantEffectDataBlock x) => ((GameDataBlockBase<BoosterImplantEffectDataBlock>)(object)x).persistentID == effect2.BoosterImplantEffect);
						customBooster.Effects.Add(ParseEffect(effectDb3, effect2.MaxValue));
					}
				}
				Enumerator<uint> enumerator4 = temp.Conditions.GetEnumerator();
				while (enumerator4.MoveNext())
				{
					uint condition = enumerator4.Current;
					BoosterImplantConditionDataBlock conditionDb2 = ((IEnumerable<BoosterImplantConditionDataBlock>)allBlocks3).First((BoosterImplantConditionDataBlock x) => ((GameDataBlockBase<BoosterImplantConditionDataBlock>)(object)x).persistentID == condition);
					customBooster.Conditions.Add(ParseCondition(conditionDb2));
				}
				if (temp.RandomConditions.Count > 0)
				{
					BoosterImplantConditionDataBlock conditionDb3 = ((IEnumerable<BoosterImplantConditionDataBlock>)allBlocks3).First((BoosterImplantConditionDataBlock x) => ((GameDataBlockBase<BoosterImplantConditionDataBlock>)(object)x).persistentID == temp.RandomConditions[0]);
					customBooster.Conditions.Add(ParseCondition(conditionDb3));
				}
				list2.Add(customBooster);
			}
			return activateableBoosterData;
			static CustomCondition ParseCondition(BoosterImplantConditionDataBlock conditionDb)
			{
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				return new CustomCondition
				{
					PublicShortName = Text.Get(conditionDb.PublicShortName.Id),
					PublicName = Text.Get(conditionDb.PublicName.Id),
					Description = Text.Get(conditionDb.Description.Id),
					Condition = conditionDb.Condition
				};
			}
			static CustomEffect ParseEffect(BoosterImplantEffectDataBlock effectDb, float value)
			{
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				return new CustomEffect
				{
					PublicShortName = Text.Get(effectDb.PublicShortName.Id),
					PublicName = Text.Get(effectDb.PublicName.Id),
					Description = Text.Get(effectDb.Description.Id),
					DescriptionNegative = Text.Get(effectDb.DescriptionNegative.Id),
					Effect = effectDb.Effect,
					EffectCategory = effectDb.BoosterEffectCategory,
					Value = value
				};
			}
		}
	}
}