Decompiled source of Survival v1.1.7

plugins/SURVIVAL/net6/BoosterPack.dll

Decompiled 5 days 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
				};
			}
		}
	}
}

plugins/SURVIVAL/net6/ExtraWeaponCustomization.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using AK;
using Agents;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using CharacterDestruction;
using EndskApi.Api;
using EndskApi.Enums.EnemyKill;
using EndskApi.Information.EnemyKill;
using Enemies;
using ExtraWeaponCustomization.CustomWeapon;
using ExtraWeaponCustomization.CustomWeapon.KillTracker;
using ExtraWeaponCustomization.CustomWeapon.ObjectWrappers;
using ExtraWeaponCustomization.CustomWeapon.Properties;
using ExtraWeaponCustomization.CustomWeapon.Properties.Effects;
using ExtraWeaponCustomization.CustomWeapon.Properties.Effects.EEC_Explosion;
using ExtraWeaponCustomization.CustomWeapon.Properties.Effects.EEC_Explosion.Handlers;
using ExtraWeaponCustomization.CustomWeapon.Properties.Effects.FireRate;
using ExtraWeaponCustomization.CustomWeapon.Properties.Effects.Heal;
using ExtraWeaponCustomization.CustomWeapon.Properties.Effects.Triggers;
using ExtraWeaponCustomization.CustomWeapon.Properties.Traits;
using ExtraWeaponCustomization.CustomWeapon.Properties.Traits.CustomProjectile.Components;
using ExtraWeaponCustomization.CustomWeapon.Properties.Traits.CustomProjectile.Managers;
using ExtraWeaponCustomization.CustomWeapon.WeaponContext;
using ExtraWeaponCustomization.CustomWeapon.WeaponContext.Contexts;
using ExtraWeaponCustomization.Dependencies;
using ExtraWeaponCustomization.JSON;
using ExtraWeaponCustomization.JSON.Converters;
using ExtraWeaponCustomization.Networking;
using ExtraWeaponCustomization.Networking.Structs;
using ExtraWeaponCustomization.Patches;
using ExtraWeaponCustomization.Utils;
using FX_EffectSystem;
using GTFO.API;
using GTFO.API.JSON.Converters;
using GTFO.API.Utilities;
using GTFuckingXP.Extensions;
using GameData;
using Gear;
using HarmonyLib;
using Il2CppInterop.Runtime.Attributes;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using KillIndicatorFix;
using MTFO.API;
using Microsoft.CodeAnalysis;
using Player;
using SNetwork;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ExtraWeaponCustomization")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f67ed384f3c21e42e4d6acbf3d1ebfdfe8084fa4")]
[assembly: AssemblyProduct("ExtraWeaponCustomization")]
[assembly: AssemblyTitle("ExtraWeaponCustomization")]
[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 ExtraWeaponCustomization
{
	internal static class Configuration
	{
		private static readonly ConfigFile configFile;

		private static ConfigEntry<bool> ForceCreateTemplate { get; set; }

		public static bool ShowExplosionEffect { get; set; }

		public static bool PlayExplosionSFX { get; set; }

		public static float ExplosionSFXCooldown { get; set; }

		public static int ExplosionSFXShotOverride { get; set; }

		static Configuration()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			ShowExplosionEffect = true;
			PlayExplosionSFX = true;
			ExplosionSFXCooldown = 0.08f;
			ExplosionSFXShotOverride = 8;
			configFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "ExtraWeaponCustomization.cfg"), true);
			BindAll(configFile);
		}

		internal static void Init()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			LiveEdit.CreateListener(Paths.ConfigPath, "ExtraWeaponCustomization.cfg", false).FileChanged += new LiveEditEventHandler(OnFileChanged);
		}

		private static void OnFileChanged(LiveEditEventArgs _)
		{
			string text = "Explosion Settings";
			configFile.Reload();
			ShowExplosionEffect = (bool)configFile[text, "Show Effect"].BoxedValue;
			PlayExplosionSFX = (bool)configFile[text, "Play Sound"].BoxedValue;
			ExplosionSFXCooldown = (float)configFile[text, "SFX Cooldown"].BoxedValue;
			ExplosionSFXShotOverride = (int)configFile[text, "Shots to Override SFX Cooldown"].BoxedValue;
			CheckAndRefreshTemplate();
		}

		private static void BindAll(ConfigFile config)
		{
			string text = "Explosion Settings";
			ShowExplosionEffect = config.Bind<bool>(text, "Show Effect", ShowExplosionEffect, "Enables explosion visual FX.").Value;
			PlayExplosionSFX = config.Bind<bool>(text, "Play Sound", PlayExplosionSFX, "Enables explosion sound FX.").Value;
			ExplosionSFXCooldown = config.Bind<float>(text, "SFX Cooldown", ExplosionSFXCooldown, "Minimum cooldown between explosion sound effects, to prevent obnoxiously loud sounds.").Value;
			ExplosionSFXShotOverride = config.Bind<int>(text, "Shots to Override SFX Cooldown", ExplosionSFXShotOverride, "Amount of shots fired before another explosion visual effect is forced, regardless of cooldown.\nSmaller numbers let fast-firing weapons and shotguns spawn more effects in a short span of time.").Value;
			text = "Developer Tools";
			ForceCreateTemplate = config.Bind<bool>(text, "Force Create Template", false, "Creates the template file again.");
			CheckAndRefreshTemplate();
		}

		private static void CheckAndRefreshTemplate()
		{
			if (ForceCreateTemplate.Value)
			{
				ForceCreateTemplate.Value = false;
				CustomWeaponManager.Current.CreateTemplate();
				configFile.Save();
			}
		}
	}
	[BepInPlugin("Dinorush.ExtraWeaponCustomization", "ExtraWeaponCustomization", "1.8.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal sealed class EntryPoint : BasePlugin
	{
		public const string MODNAME = "ExtraWeaponCustomization";

		public override void Load()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			EWCLogger.Log("Loading ExtraWeaponCustomization");
			new Harmony("ExtraWeaponCustomization").PatchAll();
			Configuration.Init();
			LevelAPI.OnLevelCleanup += LevelAPI_OnLevelCleanup;
			AssetAPI.OnStartupAssetsLoaded += AssetAPI_OnStartupAssetsLoaded;
			EWCLogger.Log("Loaded ExtraWeaponCustomization");
		}

		private void LevelAPI_OnLevelCleanup()
		{
			CustomWeaponManager.Current.ResetCWCs();
			EWCProjectileManager.Reset();
		}

		private void AssetAPI_OnStartupAssetsLoaded()
		{
			ClassInjector.RegisterTypeInIl2Cpp<ExplosionEffectHandler>();
			ClassInjector.RegisterTypeInIl2Cpp<CustomWeaponComponent>();
			ClassInjector.RegisterTypeInIl2Cpp<EWCProjectileComponentBase>();
			ClassInjector.RegisterTypeInIl2Cpp<EWCProjectileComponentShooter>();
			ExplosionManager.Init();
			DOTDamageManager.Init();
			HealManager.Init();
			FireRateModManager.Init();
			KillAPIWrapper.Init();
			EWCProjectileManager.Init();
			CustomWeaponManager.Current.GetCustomWeaponData(0u);
		}
	}
}
namespace ExtraWeaponCustomization.Utils
{
	internal static class DamageableUtil
	{
		public static IDamageable? GetDamageableFromData(WeaponHitData data)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return GetDamageableFromRayHit(data.rayHit);
		}

		public static IDamageable? GetDamageableFromCollider(Collider collider)
		{
			GameObject gameObject = ((Component)collider).gameObject;
			if ((Object)(object)gameObject == (Object)null)
			{
				return null;
			}
			ColliderMaterial component = gameObject.GetComponent<ColliderMaterial>();
			IDamageable val = ((component != null) ? component.Damageable : null);
			if (val != null)
			{
				return val;
			}
			return gameObject.GetComponent<IDamageable>();
		}

		public static IDamageable? GetDamageableFromRayHit(RaycastHit rayHit)
		{
			return GetDamageableFromCollider(((RaycastHit)(ref rayHit)).collider);
		}
	}
	internal static class EWCLogger
	{
		private static ManualLogSource logger = Logger.CreateLogSource("ExtraWeaponCustomization");

		public static void Log(string format, params object[] args)
		{
			Log(string.Format(format, args));
		}

		public static void Log(string str)
		{
			if (logger != null)
			{
				logger.Log((LogLevel)8, (object)str);
			}
		}

		public static void Warning(string format, params object[] args)
		{
			Warning(string.Format(format, args));
		}

		public static void Warning(string str)
		{
			if (logger != null)
			{
				logger.Log((LogLevel)4, (object)str);
			}
		}

		public static void Error(string format, params object[] args)
		{
			Error(string.Format(format, args));
		}

		public static void Error(string str)
		{
			if (logger != null)
			{
				logger.Log((LogLevel)2, (object)str);
			}
		}

		public static void Debug(string format, params object[] args)
		{
			Debug(string.Format(format, args));
		}

		public static void Debug(string str)
		{
			if (logger != null)
			{
				logger.Log((LogLevel)32, (object)str);
			}
		}
	}
	internal static class FloatExtensions
	{
		public static float Map(this float orig, float fromMin, float fromMax, float toMin, float toMax)
		{
			if (fromMin == fromMax)
			{
				if (!(orig < fromMin))
				{
					return toMax;
				}
				return toMin;
			}
			orig = Mathf.Clamp(orig, fromMin, fromMax);
			return (orig - fromMin) / (fromMax - fromMin) * (toMax - toMin) + toMin;
		}
	}
	internal static class MTFOPartialDataUtil
	{
		public const string PLUGIN_GUID = "MTFO.Extension.PartialBlocks";

		public static JsonConverter? PersistentIDConverter { get; private set; }

		public static JsonConverter? LocalizedTextConverter { get; private set; }

		public static bool IsLoaded { get; private set; }

		public static bool Initialized { get; private set; }

		public static string PartialDataPath { get; private set; }

		public static string ConfigPath { get; private set; }

		static MTFOPartialDataUtil()
		{
			PersistentIDConverter = null;
			LocalizedTextConverter = null;
			IsLoaded = false;
			Initialized = false;
			PartialDataPath = string.Empty;
			ConfigPath = string.Empty;
			if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("MTFO.Extension.PartialBlocks", out var value))
			{
				return;
			}
			try
			{
				Assembly obj = ((value == null) ? null : value.Instance?.GetType()?.Assembly) ?? null;
				if ((object)obj == null)
				{
					throw new Exception("Assembly is Missing!");
				}
				Type[] types = obj.GetTypes();
				Type type = types.First((Type t) => t.Name == "PersistentIDConverter");
				if ((object)type == null)
				{
					throw new Exception("Unable to Find PersistentIDConverter Class");
				}
				Type type2 = types.First((Type t) => t.Name == "PartialDataManager");
				if ((object)type2 == null)
				{
					throw new Exception("Unable to Find PartialDataManager Class");
				}
				Type type3 = types.First((Type t) => t.Name == "LocalizedTextConverter") ?? throw new Exception("Unable to Find LocalizedTextConverter Class");
				PropertyInfo property = type2.GetProperty("Initialized", BindingFlags.Static | BindingFlags.Public);
				PropertyInfo property2 = type2.GetProperty("PartialDataPath", BindingFlags.Static | BindingFlags.Public);
				PropertyInfo? property3 = type2.GetProperty("ConfigPath", BindingFlags.Static | BindingFlags.Public);
				if ((object)property == null)
				{
					throw new Exception("Unable to Find Property: Initialized");
				}
				if ((object)property2 == null)
				{
					throw new Exception("Unable to Find Property: PartialDataPath");
				}
				if ((object)property3 == null)
				{
					throw new Exception("Unable to Find Field: ConfigPath");
				}
				Initialized = (bool)property.GetValue(null);
				PartialDataPath = (string)property2.GetValue(null);
				ConfigPath = (string)property3.GetValue(null);
				PersistentIDConverter = (JsonConverter)Activator.CreateInstance(type);
				LocalizedTextConverter = (JsonConverter)Activator.CreateInstance(type3);
				IsLoaded = true;
			}
			catch (Exception value2)
			{
				EWCLogger.Error($"Exception thrown while reading data from MTFO_Extension_PartialData:\n{value2}");
			}
		}
	}
	internal static class MTFOUtil
	{
		public const string PLUGIN_GUID = "com.dak.MTFO";

		public const BindingFlags PUBLIC_STATIC = BindingFlags.Static | BindingFlags.Public;

		public static string GameDataPath { get; private set; }

		public static string CustomPath { get; private set; }

		public static bool HasCustomContent { get; private set; }

		public static bool IsLoaded { get; private set; }

		static MTFOUtil()
		{
			GameDataPath = string.Empty;
			CustomPath = string.Empty;
			HasCustomContent = false;
			IsLoaded = false;
			if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("com.dak.MTFO", out var value))
			{
				return;
			}
			try
			{
				Assembly obj = ((value == null) ? null : value.Instance?.GetType()?.Assembly) ?? null;
				if ((object)obj == null)
				{
					throw new Exception("Assembly is Missing!");
				}
				Type obj2 = obj.GetTypes().First((Type t) => t.Name == "ConfigManager") ?? throw new Exception("Unable to Find ConfigManager Class");
				FieldInfo field = obj2.GetField("GameDataPath", BindingFlags.Static | BindingFlags.Public);
				FieldInfo field2 = obj2.GetField("CustomPath", BindingFlags.Static | BindingFlags.Public);
				FieldInfo? field3 = obj2.GetField("HasCustomContent", BindingFlags.Static | BindingFlags.Public);
				if ((object)field == null)
				{
					throw new Exception("Unable to Find Field: GameDataPath");
				}
				if ((object)field2 == null)
				{
					throw new Exception("Unable to Find Field: CustomPath");
				}
				if ((object)field3 == null)
				{
					throw new Exception("Unable to Find Field: HasCustomContent");
				}
				GameDataPath = (string)field.GetValue(null);
				CustomPath = (string)field2.GetValue(null);
				HasCustomContent = (bool)field3.GetValue(null);
				IsLoaded = true;
			}
			catch (Exception value2)
			{
				EWCLogger.Log($"Exception thrown while reading path from DataDumper (MTFO): \n{value2}");
			}
		}
	}
	internal static class StringExtensions
	{
		public static T ToEnum<T>(this string? value, T defaultValue) where T : struct
		{
			if (string.IsNullOrEmpty(value))
			{
				return defaultValue;
			}
			if (!Enum.TryParse<T>(value.Replace(" ", null), ignoreCase: true, out var result))
			{
				return defaultValue;
			}
			return result;
		}
	}
	internal static class WeaponHitExtensions
	{
		public static float Falloff(this WeaponHitData data, float additionalDist = 0f)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit rayHit = data.rayHit;
			return (((RaycastHit)(ref rayHit)).distance + additionalDist).Map(data.damageFalloff.x, data.damageFalloff.y, 1f, BulletWeapon.s_falloffMin);
		}
	}
}
namespace ExtraWeaponCustomization.Patches
{
	[HarmonyPatch]
	internal static class EnemyLimbPatches
	{
		private static float _cachedArmor;

		[HarmonyPatch(typeof(Dam_EnemyDamageLimb), "BulletDamage")]
		[HarmonyWrapSafe]
		[HarmonyPrefix]
		private static void Pre_BulletDamage(Dam_EnemyDamageLimb __instance)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			CustomWeaponComponent cachedHitCWC = WeaponPatches.CachedHitCWC;
			if (!((Object)(object)cachedHitCWC == (Object)null) && (int)__instance.m_type == 2)
			{
				_cachedArmor = __instance.m_armorDamageMulti;
				WeaponArmorContext weaponArmorContext = new WeaponArmorContext(_cachedArmor, cachedHitCWC.Weapon);
				cachedHitCWC.Invoke(weaponArmorContext);
				__instance.m_armorDamageMulti = weaponArmorContext.ArmorMulti;
			}
		}

		[HarmonyPatch(typeof(Dam_EnemyDamageLimb), "BulletDamage")]
		[HarmonyWrapSafe]
		[HarmonyPostfix]
		private static void Post_BulletDamage(Dam_EnemyDamageLimb __instance)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			if (!((Object)(object)WeaponPatches.CachedHitCWC == (Object)null) && (int)__instance.m_type == 2)
			{
				__instance.m_armorDamageMulti = _cachedArmor;
			}
		}

		[HarmonyPatch(typeof(Dam_EnemyDamageLimb), "MeleeDamage")]
		[HarmonyWrapSafe]
		[HarmonyPostfix]
		private static void Post_MeleeDamage(Dam_EnemyDamageLimb __instance, Agent sourceAgent)
		{
			if (sourceAgent.IsLocallyOwned)
			{
				KillTrackerManager.ClearHit(__instance.m_base.Owner);
			}
		}
	}
	[HarmonyPatch]
	internal static class PlayerInventoryPatches
	{
		[HarmonyPatch(typeof(PUI_Inventory), "SetSlotAmmo")]
		[HarmonyWrapSafe]
		[HarmonyPrefix]
		private static void SetAmmoUICallback(PUI_Inventory __instance, InventorySlot slot, ref int clipAbs, ref int inPackAbs, ref float inPackRel)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			if ((int)slot == 0)
			{
				return;
			}
			SNet_Player owner = __instance.m_owner;
			object obj;
			if (owner == null)
			{
				obj = null;
			}
			else
			{
				SNet_IPlayerAgent playerAgent = owner.PlayerAgent;
				if (playerAgent == null)
				{
					obj = null;
				}
				else
				{
					PlayerAgent obj2 = ((Il2CppObjectBase)playerAgent).TryCast<PlayerAgent>();
					if (obj2 == null)
					{
						obj = null;
					}
					else
					{
						FirstPersonItemHolder fPItemHolder = obj2.FPItemHolder;
						if (fPItemHolder == null)
						{
							obj = null;
						}
						else
						{
							ItemEquippable wieldedItem = fPItemHolder.WieldedItem;
							if (wieldedItem == null)
							{
								obj = null;
							}
							else
							{
								BulletWeapon obj3 = ((Il2CppObjectBase)wieldedItem).TryCast<BulletWeapon>();
								obj = ((obj3 != null) ? ((Component)obj3).GetComponent<CustomWeaponComponent>() : null);
							}
						}
					}
				}
			}
			CustomWeaponComponent customWeaponComponent = (CustomWeaponComponent)obj;
			if (!((Object)(object)customWeaponComponent == (Object)null))
			{
				PUI_InventoryItem val = __instance.m_inventorySlots[slot];
				WeaponPreAmmoUIContext weaponPreAmmoUIContext = new WeaponPreAmmoUIContext(customWeaponComponent.Weapon, clipAbs, inPackAbs, inPackRel, val.ShowAmmoClip, val.ShowAmmoPack, val.ShowAmmoTotalRel, val.ShowAmmoInfinite);
				customWeaponComponent.Invoke(weaponPreAmmoUIContext);
				clipAbs = weaponPreAmmoUIContext.Clip;
				inPackAbs = weaponPreAmmoUIContext.Reserve;
				inPackRel = weaponPreAmmoUIContext.TotalRel;
				val.ShowAmmoClip = weaponPreAmmoUIContext.ShowClip;
				val.ShowAmmoPack = weaponPreAmmoUIContext.ShowReserve;
				val.ShowAmmoTotalRel = weaponPreAmmoUIContext.ShowRel;
				val.ShowAmmoInfinite = weaponPreAmmoUIContext.ShowInfinite;
			}
		}

		[HarmonyPatch(typeof(PlayerBackpackManager), "ReceiveAmmoGive")]
		[HarmonyWrapSafe]
		[HarmonyPrefix]
		private static void AmmoPackCallback(ref pAmmoGive data)
		{
			SNet_Player val = default(SNet_Player);
			if (!((pPlayer)(ref data.targetPlayer)).TryGetPlayer(ref val))
			{
				return;
			}
			SNet_IPlayerAgent playerAgent = val.PlayerAgent;
			if ((Object)(object)((playerAgent != null) ? ((Il2CppObjectBase)playerAgent).TryCast<PlayerAgent>() : null) == (Object)null)
			{
				return;
			}
			BackpackItem val2 = default(BackpackItem);
			if (PlayerBackpackManager.TryGetItem(val, (InventorySlot)1, ref val2))
			{
				Item instance = val2.Instance;
				CustomWeaponComponent customWeaponComponent = ((instance != null) ? ((Component)instance).GetComponent<CustomWeaponComponent>() : null);
				if ((Object)(object)customWeaponComponent != (Object)null)
				{
					WeaponPreAmmoPackContext weaponPreAmmoPackContext = new WeaponPreAmmoPackContext(customWeaponComponent.Weapon, data.ammoStandardRel);
					customWeaponComponent.Invoke(weaponPreAmmoPackContext);
					data.ammoStandardRel = weaponPreAmmoPackContext.AmmoRel;
				}
			}
			BackpackItem val3 = default(BackpackItem);
			if (PlayerBackpackManager.TryGetItem(val, (InventorySlot)2, ref val3))
			{
				Item instance2 = val3.Instance;
				CustomWeaponComponent customWeaponComponent2 = ((instance2 != null) ? ((Component)instance2).GetComponent<CustomWeaponComponent>() : null);
				if ((Object)(object)customWeaponComponent2 != (Object)null)
				{
					WeaponPreAmmoPackContext weaponPreAmmoPackContext2 = new WeaponPreAmmoPackContext(customWeaponComponent2.Weapon, data.ammoSpecialRel);
					customWeaponComponent2.Invoke(weaponPreAmmoPackContext2);
					data.ammoSpecialRel = weaponPreAmmoPackContext2.AmmoRel;
				}
			}
		}

		[HarmonyPatch(typeof(PlayerBackpackManager), "ReceiveAmmoGive")]
		[HarmonyWrapSafe]
		[HarmonyPostfix]
		private static void PostAmmoPackCallback(ref pAmmoGive data)
		{
			SNet_Player val = default(SNet_Player);
			if (((pPlayer)(ref data.targetPlayer)).TryGetPlayer(ref val))
			{
				PlayerBackpack backpack = PlayerBackpackManager.GetBackpack(val);
				BackpackItem val2 = default(BackpackItem);
				if (backpack.TryGetBackpackItem((InventorySlot)1, ref val2))
				{
					Item instance = val2.Instance;
					CustomWeaponComponent customWeaponComponent = ((instance != null) ? ((Component)instance).GetComponent<CustomWeaponComponent>() : null);
					customWeaponComponent?.Invoke(new WeaponPostAmmoPackContext(backpack.AmmoStorage, customWeaponComponent.Weapon));
				}
				BackpackItem val3 = default(BackpackItem);
				if (backpack.TryGetBackpackItem((InventorySlot)2, ref val3))
				{
					Item instance2 = val3.Instance;
					CustomWeaponComponent customWeaponComponent2 = ((instance2 != null) ? ((Component)instance2).GetComponent<CustomWeaponComponent>() : null);
					customWeaponComponent2?.Invoke(new WeaponPostAmmoPackContext(backpack.AmmoStorage, customWeaponComponent2.Weapon));
				}
			}
		}

		[HarmonyPatch(typeof(PlayerInventoryLocal), "DoReload")]
		[HarmonyPatch(typeof(PlayerInventoryBase), "DoReload")]
		[HarmonyWrapSafe]
		[HarmonyPostfix]
		private static void ReloadCallback(PlayerInventoryBase __instance)
		{
			ItemEquippable wieldedItem = __instance.m_wieldedItem;
			object obj;
			if (wieldedItem == null)
			{
				obj = null;
			}
			else
			{
				BulletWeapon obj2 = ((Il2CppObjectBase)wieldedItem).TryCast<BulletWeapon>();
				obj = ((obj2 != null) ? ((Component)obj2).GetComponent<CustomWeaponComponent>() : null);
			}
			CustomWeaponComponent customWeaponComponent = (CustomWeaponComponent)obj;
			if (!((Object)(object)customWeaponComponent == (Object)null))
			{
				customWeaponComponent.Invoke(new WeaponPostReloadContext(customWeaponComponent.Weapon));
			}
		}

		[HarmonyPatch(typeof(PlayerAmmoStorage), "FillAllClips")]
		[HarmonyWrapSafe]
		[HarmonyPostfix]
		private static void PostFillAllClipsCallback(PlayerAmmoStorage __instance)
		{
			BackpackItem val = default(BackpackItem);
			if (__instance.m_playerBackpack.TryGetBackpackItem((InventorySlot)1, ref val))
			{
				Item instance = val.Instance;
				CustomWeaponComponent customWeaponComponent = ((instance != null) ? ((Component)instance).GetComponent<CustomWeaponComponent>() : null);
				customWeaponComponent?.Invoke(new WeaponPostAmmoInitContext(__instance, __instance.StandardAmmo, customWeaponComponent.Weapon));
			}
			BackpackItem val2 = default(BackpackItem);
			if (__instance.m_playerBackpack.TryGetBackpackItem((InventorySlot)2, ref val2))
			{
				Item instance2 = val2.Instance;
				CustomWeaponComponent customWeaponComponent2 = ((instance2 != null) ? ((Component)instance2).GetComponent<CustomWeaponComponent>() : null);
				customWeaponComponent2?.Invoke(new WeaponPostAmmoInitContext(__instance, __instance.SpecialAmmo, customWeaponComponent2.Weapon));
			}
		}
	}
	[HarmonyPatch]
	internal static class PlayerLocalPatches
	{
		[HarmonyPatch(typeof(PUI_LocalPlayerStatus), "UpdateHealth")]
		[HarmonyWrapSafe]
		[HarmonyPrefix]
		private static void UpdateHealth(PUI_LocalPlayerStatus __instance, float health, bool meleeBuffActive)
		{
			if (__instance.m_lastHealthVal <= 0.14f && health > 0.14f && __instance.m_warningRoutine != null)
			{
				__instance.m_healthWarningLooping = true;
			}
		}
	}
	[HarmonyPatch]
	internal static class ShotgunPatches
	{
		[HarmonyPatch(typeof(Shotgun), "Fire")]
		[HarmonyWrapSafe]
		[HarmonyPrefix]
		private static void Pre_Fire(Shotgun __instance)
		{
			WeaponRayPatches.CachedWeapon = (BulletWeapon?)(object)__instance;
		}

		[HarmonyPatch(typeof(Shotgun), "Fire")]
		[HarmonyWrapSafe]
		[HarmonyPostfix]
		private static void Post_Fire(Shotgun __instance)
		{
			WeaponRayPatches.CachedWeapon = null;
		}
	}
	[HarmonyPatch]
	internal static class WeaponArchetypePatches
	{
		[HarmonyPatch(typeof(BulletWeaponArchetype), "SetOwner")]
		[HarmonyWrapSafe]
		[HarmonyPostfix]
		private static void SetupCallback(BulletWeaponArchetype __instance, PlayerAgent owner)
		{
			if (!((Object)(object)owner == (Object)null))
			{
				CustomWeaponComponent component = ((Component)__instance.m_weapon).GetComponent<CustomWeaponComponent>();
				if (!((Object)(object)component == (Object)null))
				{
					component.OwnerInit();
				}
			}
		}

		[HarmonyPatch(typeof(BWA_Burst), "OnStartFiring")]
		[HarmonyPatch(typeof(BWA_Auto), "OnStartFiring")]
		[HarmonyPatch(typeof(BulletWeaponArchetype), "OnStartFiring")]
		[HarmonyWrapSafe]
		[HarmonyPrefix]
		private static bool StartFireCallback(BulletWeaponArchetype __instance)
		{
			BulletWeapon weapon = __instance.m_weapon;
			CustomWeaponComponent customWeaponComponent = ((weapon != null) ? ((Component)weapon).GetComponent<CustomWeaponComponent>() : null);
			if ((Object)(object)customWeaponComponent == (Object)null)
			{
				return true;
			}
			customWeaponComponent.CancelShot = false;
			WeaponPreStartFireContext weaponPreStartFireContext = new WeaponPreStartFireContext(__instance.m_weapon);
			customWeaponComponent.Invoke(weaponPreStartFireContext);
			customWeaponComponent.UpdateStoredFireRate(__instance);
			if (!weaponPreStartFireContext.Allow)
			{
				customWeaponComponent.StoreCancelShot();
			}
			return weaponPreStartFireContext.Allow;
		}

		[HarmonyPatch(typeof(BWA_Burst), "OnStartFiring")]
		[HarmonyPatch(typeof(BWA_Auto), "OnStartFiring")]
		[HarmonyPatch(typeof(BulletWeaponArchetype), "OnStartFiring")]
		[HarmonyWrapSafe]
		[HarmonyPostfix]
		private static void PostStartFireCallback(BulletWeaponArchetype __instance)
		{
			BulletWeapon weapon = __instance.m_weapon;
			CustomWeaponComponent customWeaponComponent = ((weapon != null) ? ((Component)weapon).GetComponent<CustomWeaponComponent>() : null);
			if (!((Object)(object)customWeaponComponent == (Object)null))
			{
				if (customWeaponComponent.ResetShotIfCancel(__instance))
				{
					customWeaponComponent.CancelShot = false;
					__instance.m_readyToFire = false;
				}
				else
				{
					customWeaponComponent.Invoke(new WeaponPostStartFireContext(__instance.m_weapon));
				}
			}
		}

		[HarmonyPatch(typeof(BWA_Auto), "OnFireShot")]
		[HarmonyPatch(typeof(BWA_Burst), "OnFireShot")]
		[HarmonyPatch(typeof(BWA_Semi), "OnFireShot")]
		[HarmonyWrapSafe]
		[HarmonyPrefix]
		private static bool PreFireCallback(BulletWeaponArchetype __instance)
		{
			BulletWeapon weapon = __instance.m_weapon;
			CustomWeaponComponent customWeaponComponent = ((weapon != null) ? ((Component)weapon).GetComponent<CustomWeaponComponent>() : null);
			if ((Object)(object)customWeaponComponent == (Object)null)
			{
				return true;
			}
			if (customWeaponComponent.CancelShot)
			{
				return false;
			}
			WeaponPreFireContext weaponPreFireContext = new WeaponPreFireContext(__instance.m_weapon);
			customWeaponComponent.Invoke(weaponPreFireContext);
			if (!weaponPreFireContext.Allow)
			{
				customWeaponComponent.StoreCancelShot();
			}
			return weaponPreFireContext.Allow;
		}

		[HarmonyPatch(typeof(BWA_Auto), "OnFireShot")]
		[HarmonyPatch(typeof(BWA_Burst), "OnFireShot")]
		[HarmonyPatch(typeof(BWA_Semi), "OnFireShot")]
		[HarmonyWrapSafe]
		[HarmonyPostfix]
		private static void PostFireCallback(BulletWeaponArchetype __instance)
		{
			BulletWeapon weapon = __instance.m_weapon;
			CustomWeaponComponent customWeaponComponent = ((weapon != null) ? ((Component)weapon).GetComponent<CustomWeaponComponent>() : null);
			if (!((Object)(object)customWeaponComponent == (Object)null) && !customWeaponComponent.CancelShot)
			{
				customWeaponComponent.Invoke(new WeaponPostFireContext(__instance.m_weapon));
			}
		}

		[HarmonyPatch(typeof(BulletWeaponArchetype), "PostFireCheck")]
		[HarmonyWrapSafe]
		[HarmonyPrefix]
		private static void PrePostFireCallback(BulletWeaponArchetype __instance)
		{
			BulletWeapon weapon = __instance.m_weapon;
			CustomWeaponComponent customWeaponComponent = ((weapon != null) ? ((Component)weapon).GetComponent<CustomWeaponComponent>() : null);
			if (!((Object)(object)customWeaponComponent == (Object)null))
			{
				customWeaponComponent.ResetShotIfCancel(__instance);
			}
		}

		[HarmonyPatch(typeof(BulletWeaponArchetype), "PostFireCheck")]
		[HarmonyWrapSafe]
		[HarmonyPostfix]
		private static void PostPostFireCallback(BulletWeaponArchetype __instance)
		{
			BulletWeapon weapon = __instance.m_weapon;
			CustomWeaponComponent customWeaponComponent = ((weapon != null) ? ((Component)weapon).GetComponent<CustomWeaponComponent>() : null);
			if (!((Object)(object)customWeaponComponent == (Object)null))
			{
				if (customWeaponComponent.CancelShot)
				{
					customWeaponComponent.CancelShot = false;
					return;
				}
				customWeaponComponent.UpdateStoredFireRate(__instance);
				customWeaponComponent.ModifyFireRate(__instance);
			}
		}

		[HarmonyPatch(typeof(BWA_Burst), "OnStopFiring")]
		[HarmonyPatch(typeof(BWA_Auto), "OnStopFiring")]
		[HarmonyPatch(typeof(BulletWeaponArchetype), "OnStopFiring")]
		[HarmonyWrapSafe]
		[HarmonyPostfix]
		private static void StopFiringCallback(BulletWeaponArchetype __instance)
		{
			BulletWeapon weapon = __instance.m_weapon;
			CustomWeaponComponent customWeaponComponent = ((weapon != null) ? ((Component)weapon).GetComponent<CustomWeaponComponent>() : null);
			if (!((Object)(object)customWeaponComponent == (Object)null))
			{
				customWeaponComponent.Invoke(new WeaponPostStopFiringContext(__instance.m_weapon));
				customWeaponComponent.CancelShot = true;
			}
		}
	}
	[HarmonyPatch]
	internal static class WeaponPatches
	{
		private static uint _lastSearchID;

		private static float _origHitDamage;

		private static float _origHitPrecision;

		public static CustomWeaponComponent? CachedHitCWC { get; private set; }

		[HarmonyPatch(typeof(BulletWeapon), "OnGearSpawnComplete")]
		[HarmonyWrapSafe]
		[HarmonyPostfix]
		private static void SetupCallback(BulletWeapon __instance)
		{
			CustomWeaponManager.Current.AddWeaponListener(__instance);
			CustomWeaponData customWeaponData = CustomWeaponManager.Current.GetCustomWeaponData(((GameDataBlockBase<ArchetypeDataBlock>)(object)((ItemEquippable)__instance).ArchetypeData).persistentID);
			if (customWeaponData != null && !((Object)(object)((Component)__instance).gameObject.GetComponent<CustomWeaponComponent>() != (Object)null))
			{
				((Component)__instance).gameObject.AddComponent<CustomWeaponComponent>().Register(customWeaponData);
			}
		}

		[HarmonyPatch(typeof(BulletWeapon), "OnWield")]
		[HarmonyWrapSafe]
		[HarmonyPostfix]
		private static void UpdateCurrentWeapon(BulletWeapon __instance)
		{
			CustomWeaponComponent component = ((Component)__instance).GetComponent<CustomWeaponComponent>();
			if (!((Object)(object)component == (Object)null))
			{
				component.Invoke(new WeaponWieldContext(__instance));
				component.RefreshSoundDelay();
				_lastSearchID = 0u;
			}
		}

		[HarmonyPatch(typeof(BulletWeapon), "BulletHit")]
		[HarmonyWrapSafe]
		[HarmonyPrefix]
		private static void HitCallback(ref WeaponHitData weaponRayData, bool doDamage, float additionalDis, uint damageSearchID, ref bool allowDirectionalBonus)
		{
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Invalid comparison between Unknown and I4
			CachedHitCWC = null;
			if (!allowDirectionalBonus || weaponRayData.vfxBulletHit != null || !doDamage || (!((Agent)weaponRayData.owner).IsLocallyOwned && (!SNet.IsMaster || !weaponRayData.owner.Owner.IsBot)))
			{
				return;
			}
			IDamageable damageableFromData = DamageableUtil.GetDamageableFromData(weaponRayData);
			IDamageable val = ((((damageableFromData != null) ? damageableFromData.GetBaseDamagable() : null) != null) ? damageableFromData.GetBaseDamagable() : damageableFromData);
			if (damageSearchID != 0 && val != null && val.TempSearchID == damageSearchID)
			{
				return;
			}
			ItemEquippable wieldedItem = weaponRayData.owner.Inventory.WieldedItem;
			CustomWeaponComponent customWeaponComponent = ((wieldedItem != null) ? ((Component)wieldedItem).GetComponent<CustomWeaponComponent>() : null);
			if ((Object)(object)customWeaponComponent == (Object)null)
			{
				Agent val2 = ((damageableFromData != null) ? damageableFromData.GetBaseAgent() : null);
				if ((Object)(object)val2 != (Object)null && (int)val2.Type == 1 && val2.Alive)
				{
					KillTrackerManager.ClearHit(((Il2CppObjectBase)val2).TryCast<EnemyAgent>());
				}
				return;
			}
			if (damageableFromData != null && damageSearchID != 0)
			{
				if (_lastSearchID != damageSearchID)
				{
					_lastSearchID = damageSearchID;
					_origHitDamage = weaponRayData.damage;
					_origHitPrecision = weaponRayData.precisionMulti;
				}
				weaponRayData.damage = _origHitDamage;
				weaponRayData.precisionMulti = _origHitPrecision;
			}
			ApplyEWCBulletHit(customWeaponComponent, damageableFromData, ref weaponRayData, additionalDis, damageSearchID != 0, ref _origHitDamage, ref allowDirectionalBonus);
		}

		public static void ApplyEWCBulletHit(CustomWeaponComponent cwc, IDamageable? damageable, ref WeaponHitData weaponRayData, float additionalDis, bool pierce, ref float pierceDamage, ref bool doBackstab)
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Invalid comparison between Unknown and I4
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			CachedHitCWC = cwc;
			if (damageable != null)
			{
				WeaponDamageContext weaponDamageContext = new WeaponDamageContext(weaponRayData.damage, weaponRayData.precisionMulti, damageable, cwc.Weapon);
				cwc.Invoke(weaponDamageContext);
				weaponRayData.damage = weaponDamageContext.Damage.Value;
				weaponRayData.precisionMulti = weaponDamageContext.Precision.Value;
				if (pierce)
				{
					WeaponPierceContext weaponPierceContext = new WeaponPierceContext(pierceDamage, damageable, cwc.Weapon);
					cwc.Invoke(weaponPierceContext);
					pierceDamage = weaponPierceContext.Value;
				}
			}
			Agent val = ((damageable != null) ? damageable.GetBaseAgent() : null);
			if ((Object)(object)val != (Object)null && (int)val.Type == 1 && val.Alive)
			{
				Dam_EnemyDamageLimb val2 = ((Il2CppObjectBase)damageable).TryCast<Dam_EnemyDamageLimb>();
				RaycastHit rayHit = weaponRayData.rayHit;
				Vector3 point = ((RaycastHit)(ref rayHit)).point;
				Vector3 fireDir = weaponRayData.fireDir;
				float num = val2.ApplyDamageFromBehindBonus(1f, point, ((Vector3)(ref fireDir)).normalized, 1f);
				WeaponBackstabContext weaponBackstabContext = new WeaponBackstabContext(cwc.Weapon);
				cwc.Invoke(weaponBackstabContext);
				WeaponPreHitEnemyContext weaponPreHitEnemyContext = new WeaponPreHitEnemyContext(weaponRayData, additionalDis, num.Map(1f, 2f, 1f, weaponBackstabContext.Value), val2, cwc.Weapon, DamageType.Bullet);
				cwc.Invoke(weaponPreHitEnemyContext);
				KillTrackerManager.RegisterHit(weaponPreHitEnemyContext);
				if (weaponBackstabContext.Value > 1f)
				{
					WeaponHitData obj = weaponRayData;
					obj.damage *= weaponPreHitEnemyContext.Backstab / num;
				}
				else
				{
					doBackstab = false;
				}
			}
			else
			{
				cwc.Invoke(new WeaponPreHitContext(weaponRayData, additionalDis, cwc.Weapon));
			}
		}
	}
	[HarmonyPatch]
	internal static class WeaponRayPatches
	{
		public static BulletWeapon? CachedWeapon;

		private static CustomWeaponComponent? _cachedCWC;

		[HarmonyTargetMethod]
		private static MethodBase FindWeaponRayFunc(Harmony harmony)
		{
			return AccessTools.Method(typeof(Weapon), "CastWeaponRay", new Type[4]
			{
				typeof(Transform),
				typeof(WeaponHitData).MakeByRefType(),
				typeof(Vector3),
				typeof(int)
			}, (Type[])null);
		}

		[HarmonyWrapSafe]
		[HarmonyPrefix]
		private static void PreRayCallback(ref WeaponHitData weaponRayData, Vector3 originPos, int altRayCastMask)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			if (altRayCastMask != -1)
			{
				return;
			}
			if ((Object)(object)CachedWeapon != (Object)null)
			{
				_cachedCWC = ((Component)CachedWeapon).GetComponent<CustomWeaponComponent>();
			}
			else
			{
				PlayerAgent owner = weaponRayData.owner;
				object cachedCWC;
				if (owner == null)
				{
					cachedCWC = null;
				}
				else
				{
					ItemEquippable wieldedItem = owner.Inventory.WieldedItem;
					cachedCWC = ((wieldedItem != null) ? ((Component)wieldedItem).GetComponent<CustomWeaponComponent>() : null);
				}
				_cachedCWC = (CustomWeaponComponent?)cachedCWC;
			}
			if (!((Object)(object)_cachedCWC == (Object)null))
			{
				_cachedCWC.Invoke(new WeaponPreRayContext(weaponRayData, originPos, _cachedCWC.Weapon));
			}
		}

		[HarmonyWrapSafe]
		[HarmonyPostfix]
		private static void PostRayCallback(ref WeaponHitData weaponRayData, Vector3 originPos, int altRayCastMask, ref bool __result)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (altRayCastMask == -1 && !((Object)(object)_cachedCWC == (Object)null))
			{
				WeaponPostRayContext weaponPostRayContext = new WeaponPostRayContext(weaponRayData, originPos, _cachedCWC.Weapon, __result);
				_cachedCWC.Invoke(weaponPostRayContext);
				__result = weaponPostRayContext.Result;
			}
		}
	}
	[HarmonyPatch]
	internal static class WeaponRecoilPatches
	{
		private static BulletWeapon? _cachedWeapon;

		private static CustomWeaponComponent? _cachedComponent;

		[HarmonyPatch(typeof(BulletWeapon), "OnWield")]
		[HarmonyWrapSafe]
		[HarmonyPostfix]
		private static void UpdateCurrentWeapon(BulletWeapon __instance)
		{
			PlayerAgent owner = ((Item)__instance).Owner;
			if (owner != null && ((Agent)owner).IsLocallyOwned)
			{
				_cachedWeapon = __instance;
				_cachedComponent = ((Component)__instance).GetComponent<CustomWeaponComponent>();
			}
		}

		[HarmonyAfter(new string[] { "Dinorush.ExtraRecoilData" })]
		[HarmonyPatch(typeof(FPS_RecoilSystem), "ApplyRecoil")]
		[HarmonyWrapSafe]
		[HarmonyPostfix]
		private static void PostApplyRecoilCallback(FPS_RecoilSystem __instance, bool resetSimilarity, RecoilDataBlock recoilData)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: 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)
			if (!((Object)(object)_cachedComponent == (Object)null))
			{
				WeaponRecoilContext weaponRecoilContext = new WeaponRecoilContext(_cachedWeapon);
				_cachedComponent.Invoke(weaponRecoilContext);
				if (weaponRecoilContext.Value != 1f)
				{
					Vector2 val = default(Vector2);
					((Vector2)(ref val))..ctor(__instance.recoilDir.x * (weaponRecoilContext.Value - 1f), __instance.recoilDir.y * (weaponRecoilContext.Value - 1f));
					Vector2 currentRecoilForce = __instance.currentRecoilForce;
					currentRecoilForce.x -= val.x * (1f - recoilData.worldToViewSpaceBlendVertical);
					currentRecoilForce.y -= val.y * (1f - recoilData.worldToViewSpaceBlendHorizontal);
					Vector2 currentRecoilForceVP = __instance.currentRecoilForceVP;
					currentRecoilForceVP.x -= val.x * recoilData.worldToViewSpaceBlendVertical;
					currentRecoilForceVP.y -= val.y * recoilData.worldToViewSpaceBlendHorizontal;
					Vector2 recoilDir = __instance.recoilDir;
					((Vector2)(ref recoilDir)).Set(__instance.recoilDir.x * weaponRecoilContext.Value, __instance.recoilDir.y * weaponRecoilContext.Value);
					__instance.currentRecoilForce = currentRecoilForce;
					__instance.currentRecoilForceVP = currentRecoilForceVP;
				}
			}
		}
	}
	[HarmonyPatch]
	internal static class WeaponSyncPatches
	{
		[HarmonyPatch(typeof(BulletWeaponSynced), "OnGearSpawnComplete")]
		[HarmonyWrapSafe]
		[HarmonyPostfix]
		private static void Post_SetupSynced(BulletWeaponSynced __instance)
		{
			CustomWeaponComponent component = ((Component)__instance).GetComponent<CustomWeaponComponent>();
			if (!((Object)(object)component == (Object)null))
			{
				component.SetToSync();
			}
		}

		[HarmonyPatch(typeof(ShotgunSynced), "Fire")]
		[HarmonyPatch(typeof(BulletWeaponSynced), "Fire")]
		[HarmonyWrapSafe]
		[HarmonyPostfix]
		private static void Post_FireSynced(BulletWeaponSynced __instance)
		{
			CustomWeaponComponent component = ((Component)__instance).GetComponent<CustomWeaponComponent>();
			if (!((Object)(object)component == (Object)null))
			{
				component.Invoke(new WeaponPreFireContextSync((BulletWeapon)(object)__instance));
				component.UpdateStoredFireRate(((BulletWeapon)__instance).m_archeType);
				component.ModifyFireRate(__instance);
				component.Invoke(new WeaponPostFireContextSync((BulletWeapon)(object)__instance));
			}
		}
	}
}
namespace ExtraWeaponCustomization.Networking
{
	public abstract class SyncedEvent<T> where T : struct
	{
		public delegate void ReceiveHandler(T packet);

		private bool _isSetup;

		public abstract string GUID { get; }

		public bool IsSetup => _isSetup;

		public string EventName { get; private set; } = string.Empty;


		public event ReceiveHandler? OnReceive;

		public event ReceiveHandler? OnReceiveLocal;

		public void Setup()
		{
			if (!_isSetup)
			{
				EventName = "EWC" + GUID;
				NetworkAPI.RegisterEvent<T>(EventName, (Action<ulong, T>)ReceiveClient_Callback);
				_isSetup = true;
			}
		}

		public void Send(T packetData, SNet_Player? target = null, SNet_ChannelType priority = 4)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)target != (Object)null)
			{
				NetworkAPI.InvokeEvent<T>(EventName, packetData, target, priority);
			}
			else
			{
				NetworkAPI.InvokeEvent<T>(EventName, packetData, priority);
			}
			ReceiveLocal_Callback(packetData);
		}

		private void ReceiveLocal_Callback(T packet)
		{
			ReceiveLocal(packet);
			this.OnReceiveLocal?.Invoke(packet);
		}

		private void ReceiveClient_Callback(ulong sender, T packet)
		{
			Receive(packet);
			this.OnReceive?.Invoke(packet);
		}

		protected virtual void ReceiveLocal(T packet)
		{
		}

		protected virtual void Receive(T packet)
		{
		}
	}
	public abstract class SyncedEventMasterOnly<T> : SyncedEvent<T> where T : struct
	{
		public void Send(T packet, SNet_ChannelType priority = 4)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (!SNet.IsMaster)
			{
				Send(packet, SNet.Master, priority);
			}
			else
			{
				Receive(packet);
			}
		}
	}
}
namespace ExtraWeaponCustomization.Networking.Structs
{
	public struct LowResColor
	{
		public byte r;

		public byte g;

		public byte b;

		public byte a;

		private static Color s_color = Color.black;

		public static implicit operator Color(LowResColor lowResColor)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			s_color.r = (float)(int)lowResColor.r / 255f;
			s_color.g = (float)(int)lowResColor.g / 255f;
			s_color.b = (float)(int)lowResColor.b / 255f;
			s_color.a = (float)(int)lowResColor.a / 255f;
			return s_color;
		}

		public static implicit operator LowResColor(Color color)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			LowResColor result = default(LowResColor);
			result.r = (byte)(color.r * 255f);
			result.g = (byte)(color.g * 255f);
			result.b = (byte)(color.b * 255f);
			result.a = (byte)(color.a * 255f);
			return result;
		}
	}
}
namespace ExtraWeaponCustomization.JSON
{
	internal static class CustomWeaponTemplate
	{
		internal static CustomWeaponData CreateTemplate()
		{
			return new CustomWeaponData
			{
				ArchetypeID = 0u,
				Name = "Example",
				Properties = new List<IWeaponProperty>
				{
					new AmmoMod(),
					new DamageMod(),
					new DamageModPerTarget(),
					new DamageOverTime(),
					new Explosive(),
					new FireRateMod(),
					new HealthMod(),
					new RecoilMod(),
					new Accelerate(),
					new AmmoCap(),
					new ArmorPierce(),
					new AutoAim(),
					new AutoTrigger(),
					new BackstabMulti(),
					new EnforceFireRate(),
					new HoldBurst(),
					new PierceMulti(),
					new Projectile(),
					new ReserveClip(),
					new ThickBullet(),
					new TumorMulti()
				}
			};
		}
	}
	public static class EWCJson
	{
		private static readonly JsonSerializerOptions _setting;

		static EWCJson()
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Expected O, but got Unknown
			_setting = new JsonSerializerOptions
			{
				ReadCommentHandling = JsonCommentHandling.Skip,
				IncludeFields = true,
				PropertyNameCaseInsensitive = true,
				WriteIndented = true,
				IgnoreReadOnlyProperties = true
			};
			_setting.Converters.Add(new JsonStringEnumConverter());
			_setting.Converters.Add(new WeaponPropertyConverter());
			_setting.Converters.Add(new TriggerConverter());
			_setting.Converters.Add(new TriggerCoordinatorConverter());
			_setting.Converters.Add((JsonConverter)new ColorConverter());
			if (MTFOPartialDataUtil.IsLoaded)
			{
				_setting.Converters.Add(MTFOPartialDataUtil.PersistentIDConverter);
				_setting.Converters.Add(MTFOPartialDataUtil.LocalizedTextConverter);
				EWCLogger.Log("PartialData support found!");
			}
			else
			{
				_setting.Converters.Add((JsonConverter)new LocalizedTextConverter());
			}
		}

		public static T? Deserialize<T>(string json)
		{
			return JsonSerializer.Deserialize<T>(json, _setting);
		}

		public static object? Deserialize(Type type, string json)
		{
			return JsonSerializer.Deserialize(json, type, _setting);
		}

		public static string Serialize<T>(T value)
		{
			return JsonSerializer.Serialize(value, _setting);
		}
	}
}
namespace ExtraWeaponCustomization.JSON.Converters
{
	public sealed class TriggerConverter : JsonConverter<ITrigger>
	{
		public override ITrigger? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			if (reader.TokenType == JsonTokenType.String)
			{
				return ITrigger.GetTrigger(reader.GetString());
			}
			if (reader.TokenType != JsonTokenType.StartObject)
			{
				throw new JsonException("Expected Trigger to be either a string or object");
			}
			ITrigger trigger = CreateTriggerInstance(reader);
			if (trigger == null)
			{
				return null;
			}
			while (reader.Read())
			{
				if (reader.TokenType == JsonTokenType.EndObject)
				{
					return trigger;
				}
				if (reader.TokenType != JsonTokenType.PropertyName)
				{
					throw new JsonException("Expected PropertyName token");
				}
				string @string = reader.GetString();
				reader.Read();
				trigger.DeserializeProperty(@string.ToLowerInvariant().Replace(" ", ""), ref reader, options);
			}
			throw new JsonException("Expected EndObject token");
		}

		public override void Write(Utf8JsonWriter writer, ITrigger? value, JsonSerializerOptions options)
		{
			writer.WriteStringValue(value?.Name ?? "Invalid");
		}

		private static ITrigger? CreateTriggerInstance(Utf8JsonReader reader)
		{
			if (reader.TokenType != JsonTokenType.StartObject)
			{
				return null;
			}
			while (reader.Read())
			{
				if (reader.TokenType == JsonTokenType.EndObject || reader.TokenType == JsonTokenType.StartObject)
				{
					throw new JsonException("Trigger object does not contain Name field.");
				}
				if (reader.TokenType == JsonTokenType.PropertyName && !(reader.GetString().ToLowerInvariant() != "name"))
				{
					reader.Read();
					return ITrigger.GetTrigger(reader.GetString() ?? throw new JsonException("Name field cannot be empty in trigger object."));
				}
			}
			return null;
		}
	}
	public sealed class TriggerCoordinatorConverter : JsonConverter<TriggerCoordinator>
	{
		public override TriggerCoordinator? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			TriggerCoordinator triggerCoordinator = new TriggerCoordinator();
			if (reader.TokenType == JsonTokenType.String)
			{
				ITrigger trigger = JsonSerializer.Deserialize<ITrigger>(ref reader, options);
				if (trigger != null)
				{
					triggerCoordinator.Activate.Add(trigger);
					return triggerCoordinator;
				}
				return null;
			}
			if (reader.TokenType != JsonTokenType.StartObject)
			{
				throw new JsonException("Expected Trigger Coordinator to be either a string or object");
			}
			ITrigger trigger2 = null;
			try
			{
				trigger2 = JsonSerializer.Deserialize<ITrigger>(ref reader, options);
			}
			catch (JsonException)
			{
			}
			if (trigger2 != null)
			{
				triggerCoordinator.Activate.Add(trigger2);
				return triggerCoordinator;
			}
			while (reader.Read())
			{
				if (reader.TokenType == JsonTokenType.EndObject)
				{
					if (triggerCoordinator.Activate.Count <= 0)
					{
						return null;
					}
					return triggerCoordinator;
				}
				if (reader.TokenType != JsonTokenType.PropertyName)
				{
					throw new JsonException("Expected PropertyName token");
				}
				string? @string = reader.GetString();
				reader.Read();
				switch (@string.ToLowerInvariant().Replace(" ", ""))
				{
				case "cap":
					triggerCoordinator.Cap = reader.GetUInt32();
					break;
				case "cooldown":
					triggerCoordinator.Cooldown = reader.GetSingle();
					break;
				case "chance":
					triggerCoordinator.Chance = reader.GetSingle();
					break;
				case "cooldownonapply":
					triggerCoordinator.CooldownOnApply = reader.GetSingle();
					break;
				case "activate":
				case "triggers":
				case "trigger":
				{
					triggerCoordinator.Activate = DeserializeTriggers(ref reader, options);
					List<ITrigger> activate = triggerCoordinator.Activate;
					if (activate == null || !activate.Any())
					{
						return null;
					}
					break;
				}
				case "apply":
					triggerCoordinator.Apply = DeserializeTriggers(ref reader, options);
					break;
				case "reset":
					triggerCoordinator.Reset = DeserializeTriggers(ref reader, options);
					break;
				}
			}
			throw new JsonException("Expected EndObject token");
		}

		private static List<ITrigger>? DeserializeTriggers(ref Utf8JsonReader reader, JsonSerializerOptions options)
		{
			if (reader.TokenType == JsonTokenType.String || reader.TokenType == JsonTokenType.StartObject)
			{
				ITrigger trigger = JsonSerializer.Deserialize<ITrigger>(ref reader, options);
				if (trigger == null)
				{
					return null;
				}
				return new List<ITrigger> { trigger };
			}
			if (reader.TokenType == JsonTokenType.StartArray)
			{
				List<ITrigger> list = new List<ITrigger>();
				reader.Read();
				while (reader.TokenType != JsonTokenType.EndArray)
				{
					ITrigger trigger2 = JsonSerializer.Deserialize<ITrigger>(ref reader, options);
					reader.Read();
					if (trigger2 == null)
					{
						return null;
					}
					list.Add(trigger2);
				}
				if (!list.Any())
				{
					return null;
				}
				return list;
			}
			throw new JsonException("Expected trigger or list of triggers when deserializing triggers for Coordinator");
		}

		public override void Write(Utf8JsonWriter writer, TriggerCoordinator? value, JsonSerializerOptions options)
		{
			writer.WriteStringValue(value?.Activate[0].Name ?? "Invalid");
		}
	}
	public sealed class WeaponPropertyConverter : JsonConverter<IWeaponProperty>
	{
		private static readonly string PropertyNamespace = typeof(IWeaponProperty).Namespace;

		public override IWeaponProperty? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			IWeaponProperty weaponProperty = CreatePropertyInstance(reader);
			if (weaponProperty == null)
			{
				return null;
			}
			while (reader.Read())
			{
				if (reader.TokenType == JsonTokenType.EndObject)
				{
					return weaponProperty;
				}
				if (reader.TokenType != JsonTokenType.PropertyName)
				{
					throw new JsonException("Expected PropertyName token");
				}
				string @string = reader.GetString();
				reader.Read();
				weaponProperty.DeserializeProperty(@string.ToLowerInvariant().Replace(" ", ""), ref reader, options);
			}
			throw new JsonException("Expected EndObject token");
		}

		public override void Write(Utf8JsonWriter writer, IWeaponProperty value, JsonSerializerOptions options)
		{
			value.Serialize(writer, options);
		}

		private static IWeaponProperty? CreatePropertyInstance(Utf8JsonReader reader)
		{
			if (reader.TokenType != JsonTokenType.StartObject)
			{
				return null;
			}
			while (reader.Read())
			{
				if (reader.TokenType == JsonTokenType.EndObject || reader.TokenType == JsonTokenType.StartObject)
				{
					throw new JsonException("Weapon property does not contain Name field.");
				}
				if (reader.TokenType == JsonTokenType.PropertyName && !(reader.GetString().ToLowerInvariant() != "name"))
				{
					reader.Read();
					string @string = reader.GetString();
					if (@string == null)
					{
						throw new JsonException("Name field cannot be empty in weapon property.");
					}
					@string = @string.Replace(" ", "");
					Type? obj = Type.GetType(PropertyNamespace + ".Effects." + @string, throwOnError: false, ignoreCase: true) ?? Type.GetType(PropertyNamespace + ".Traits." + @string, throwOnError: false, ignoreCase: true);
					if (obj == null)
					{
						throw new JsonException("Unable to find corresponding weapon property for \"" + @string + "\"");
					}
					return (IWeaponProperty)Activator.CreateInstance(obj);
				}
			}
			return null;
		}
	}
}
namespace ExtraWeaponCustomization.Dependencies
{
	internal static class EXPAPIWrapper
	{
		public const string PLUGIN_GUID = "Endskill.GTFuckingXP";

		private const string CacheKey = "EndskApi";

		private const string EnemyKillKey = "EnemyKillCallbacks";

		public static bool HasEXP => ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.ContainsKey("Endskill.GTFuckingXP");

		public static void ApplyMod(ref float damage)
		{
			if (HasEXP)
			{
				EXPDamageMod(ref damage);
			}
		}

		public static void RegisterDamage(EnemyAgent enemy, PlayerAgent? source, float damage, bool willKill)
		{
			if (HasEXP)
			{
				EXPDidDamage(enemy, source, damage, willKill);
			}
		}

		private static void EXPDamageMod(ref float damage)
		{
			damage *= CacheApiWrapper.GetActiveLevel().WeaponDamageMultiplier;
		}

		private static void EXPDidDamage(EnemyAgent enemy, PlayerAgent? source, float damage, bool willKill)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			if ((Object)(object)source == (Object)null)
			{
				return;
			}
			Dictionary<IntPtr, EnemyKillDistribution> instance = CacheApi.GetInstance<Dictionary<IntPtr, EnemyKillDistribution>>("EndskApi");
			if (!instance.TryGetValue(((Il2CppObjectBase)enemy).Pointer, out var value))
			{
				value = new EnemyKillDistribution(enemy);
				instance[((Il2CppObjectBase)enemy).Pointer] = value;
			}
			value.AddDamageDealtByPlayerAgent(source, damage);
			if (!willKill)
			{
				return;
			}
			value.LastHitDealtBy = source;
			value.lastHitType = (LastHitType)1;
			List<Action<EnemyKillDistribution>> list = default(List<Action<EnemyKillDistribution>>);
			if (!CacheApi.TryGetInformation<List<Action<EnemyKillDistribution>>>((object)"EnemyKillCallbacks", ref list, "EndskApi", false))
			{
				return;
			}
			foreach (Action<EnemyKillDistribution> item in list)
			{
				item(value);
			}
		}
	}
	public static class KillAPIWrapper
	{
		public const string PLUGIN_GUID = "randomuserhi.KillIndicatorFix";

		private const long MAX_DELAY = 500L;

		public static void Init()
		{
			Kill.OnKillIndicator = (Action<EnemyAgent, ItemEquippable, long>)Delegate.Combine(Kill.OnKillIndicator, new Action<EnemyAgent, ItemEquippable, long>(RunKillCallbacks));
		}

		public static void TagEnemy(EnemyAgent enemy, ItemEquippable? item = null, Vector3? localHitPosition = null)
		{
			Kill.TagEnemy(enemy, item, localHitPosition);
		}

		public static void RunKillCallbacks(EnemyAgent enemy, ItemEquippable? item, long delay)
		{
			if (delay > 500)
			{
				return;
			}
			WeaponPreHitEnemyContext killHitContext = KillTrackerManager.GetKillHitContext((Agent?)(object)enemy);
			if (killHitContext != null)
			{
				CustomWeaponComponent component = ((Component)killHitContext.Weapon).GetComponent<CustomWeaponComponent>();
				if (!((Object)(object)component == (Object)null))
				{
					component.Invoke(new WeaponPostKillContext(killHitContext));
				}
			}
		}
	}
}
namespace ExtraWeaponCustomization.CustomWeapon
{
	public sealed class CustomWeaponComponent : MonoBehaviour
	{
		private readonly ContextController _contextController;

		private AutoAim? _autoAim;

		private bool _ownerSet;

		private readonly HashSet<Type> _propertyTypes;

		private float _lastShotTimer;

		private float _lastBurstTimer;

		private float _lastFireRate;

		private readonly float _fireRate;

		private readonly float _burstDelay;

		public BulletWeapon Weapon { get; private set; }

		public bool CancelShot { get; set; }

		public float CurrentFireRate { get; private set; }

		public float CurrentBurstDelay { get; private set; }

		public CustomWeaponComponent(IntPtr value)
			: base(value)
		{
			_contextController = new ContextController();
			_propertyTypes = new HashSet<Type>();
			BulletWeapon component = ((Component)this).GetComponent<BulletWeapon>();
			if ((Object)(object)component == (Object)null)
			{
				throw new ArgumentException("Parent Object", "Custom Weapon Component was added to an object without a BulletWeapon component.");
			}
			Weapon = component;
			_fireRate = 1f / Math.Max(Weapon.m_archeType.ShotDelay(), 0.001953125f);
			_lastFireRate = _fireRate;
			CurrentFireRate = _fireRate;
			_burstDelay = Weapon.m_archeType.BurstDelay();
			CurrentBurstDelay = _burstDelay;
			_ownerSet = false;
		}

		public void OwnerInit()
		{
			if (!_ownerSet)
			{
				_autoAim?.OnEnable();
				_ownerSet = true;
			}
		}

		public void SetToSync()
		{
			Clear();
			_contextController.ChangeToSyncContexts();
			Register(CustomWeaponManager.Current.GetCustomWeaponData(((ItemEquippable)Weapon).ArchetypeID));
			_autoAim = null;
		}

		public void Update()
		{
			if (_ownerSet)
			{
				_autoAim?.Update();
			}
		}

		public void OnEnable()
		{
			if (_ownerSet)
			{
				_autoAim?.OnEnable();
			}
		}

		public void OnDisable()
		{
			if (_ownerSet)
			{
				_autoAim?.OnDisable();
			}
		}

		[HideFromIl2Cpp]
		public void Invoke<TContext>(TContext context) where TContext : IWeaponContext
		{
			_contextController.Invoke(context);
		}

		[HideFromIl2Cpp]
		public void Register(IWeaponProperty property)
		{
			if (property is AutoAim autoAim && _autoAim == null)
			{
				_autoAim = autoAim;
			}
			_contextController.Register(property);
			_propertyTypes.Add(property.GetType());
		}

		[HideFromIl2Cpp]
		public void Register(CustomWeaponData? data)
		{
			if (data == null)
			{
				return;
			}
			foreach (IWeaponProperty item in data.Properties.ConvertAll((IWeaponProperty property) => property.Clone()))
			{
				Register(item);
			}
			Invoke(new WeaponPostSetupContext(Weapon));
		}

		public void Clear()
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			Invoke(new WeaponClearContext(Weapon));
			_propertyTypes.Clear();
			_contextController.Clear();
			_autoAim = null;
			_ownerSet = false;
			CurrentFireRate = _fireRate;
			CurrentBurstDelay = _burstDelay;
			((ItemEquippable)Weapon).Sound.SetRTPCValue(GAME_PARAMETERS.FIREDELAY, 1f / CurrentFireRate);
		}

		[HideFromIl2Cpp]
		public bool HasProperty(Type type)
		{
			return _propertyTypes.Contains(type);
		}

		public void StoreCancelShot()
		{
			if (!CancelShot)
			{
				Invoke(new WeaponCancelFireContext(Weapon));
				CancelShot = true;
			}
		}

		public bool ResetShotIfCancel(BulletWeaponArchetype archetype)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Invalid comparison between Unknown and I4
			if (CancelShot)
			{
				archetype.m_fireHeld = false;
				archetype.m_nextShotTimer = _lastShotTimer;
				archetype.m_nextBurstTimer = _lastBurstTimer;
				CurrentFireRate = _lastFireRate;
				((ItemEquippable)Weapon).Sound.SetRTPCValue(GAME_PARAMETERS.FIREDELAY, 1f / CurrentFireRate);
				if ((int)archetype.m_archetypeData.FireMode == 1)
				{
					((Il2CppObjectBase)archetype).TryCast<BWA_Burst>().m_burstCurrentCount = 0;
				}
				return true;
			}
			return false;
		}

		public void UpdateStoredFireRate(BulletWeaponArchetype archetype)
		{
			_lastFireRate = CurrentFireRate;
			_lastShotTimer = archetype.m_nextShotTimer;
			_lastBurstTimer = archetype.m_nextBurstTimer;
			WeaponFireRateSetContext weaponFireRateSetContext = new WeaponFireRateSetContext(Weapon, _fireRate);
			Invoke(weaponFireRateSetContext);
			WeaponFireRateContext weaponFireRateContext = new WeaponFireRateContext(weaponFireRateSetContext.FireRate, Weapon);
			Invoke(weaponFireRateContext);
			if (CurrentFireRate != weaponFireRateContext.Value)
			{
				CurrentFireRate = Math.Clamp(weaponFireRateContext.Value, 0.001f, 512f);
				CurrentBurstDelay = _burstDelay * _fireRate / CurrentFireRate;
				RefreshSoundDelay();
			}
		}

		public void RefreshSoundDelay()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			((ItemEquippable)Weapon).Sound.SetRTPCValue(GAME_PARAMETERS.FIREDELAY, 1f / CurrentFireRate);
		}

		public void ModifyFireRate(BulletWeaponArchetype archetype)
		{
			archetype.m_nextShotTimer = Clock.Time + 1f / CurrentFireRate;
			if (archetype.BurstIsDone())
			{
				archetype.m_nextBurstTimer = Math.Max(Clock.Time + CurrentBurstDelay, archetype.m_nextShotTimer);
			}
		}

		public void ModifyFireRate(BulletWeaponSynced synced)
		{
			((BulletWeapon)synced).m_lastFireTime = Clock.Time + 1f / CurrentFireRate - ((ItemEquippable)Weapon).ArchetypeData.ShotDelay;
		}
	}
	public class CustomWeaponData
	{
		public const float MaxFireRate = 512f;

		public const float MinShotDelay = 0.001953125f;

		public uint ArchetypeID { get; set; }

		public string Name { get; set; } = string.Empty;


		public List<IWeaponProperty> Properties { get; set; } = new List<IWeaponProperty>();

	}
	public sealed class CustomWeaponManager
	{
		public static readonly CustomWeaponManager Current = new CustomWeaponManager();

		private readonly Dictionary<string, HashSet<uint>> _fileToIDs = new Dictionary<string, HashSet<uint>>();

		private readonly Dictionary<uint, CustomWeaponData> _customData = new Dictionary<uint, CustomWeaponData>();

		private readonly List<BulletWeapon> _listenCWs = new List<BulletWeapon>();

		private readonly LiveEditListener _liveEditListener;

		public string DEFINITION_PATH { get; private set; }

		public override string ToString()
		{
			return "Printing manager: " + _customData.ToString();
		}

		public void AddCustomWeaponData(CustomWeaponData? data, string file)
		{
			if (data != null)
			{
				_fileToIDs[file].Add(data.ArchetypeID);
				_customData[data.ArchetypeID] = data;
			}
		}

		private void FileChanged(LiveEditEventArgs e)
		{
			LiveEditEventArgs e2 = e;
			EWCLogger.Warning("LiveEdit File Changed: " + e2.FullPath);
			LiveEdit.TryReadFileContent(e2.FullPath, (Action<string>)delegate(string content)
			{
				ReadFileContent(e2.FullPath, content);
				PrintCustomIDs();
			});
		}

		private void FileDeleted(LiveEditEventArgs e)
		{
			EWCLogger.Warning("LiveEdit File Removed: " + e.FullPath);
			foreach (uint item in _fileToIDs[e.FullPath])
			{
				_customData.Remove(item);
			}
			for (int num = _listenCWs.Count - 1; num >= 0; num--)
			{
				if ((Object)(object)_listenCWs[num] != (Object)null)
				{
					((Component)_listenCWs[num]).GetComponent<CustomWeaponComponent>()?.Clear();
				}
				else
				{
					_listenCWs.RemoveAt(num);
				}
			}
			_fileToIDs.Remove(e.FullPath);
			PrintCustomIDs();
		}

		private void FileCreated(LiveEditEventArgs e)
		{
			LiveEditEventArgs e2 = e;
			EWCLogger.Warning("LiveEdit File Created: " + e2.FullPath);
			LiveEdit.TryReadFileContent(e2.FullPath, (Action<string>)delegate(string content)
			{
				ReadFileContent(e2.FullPath, content);
				PrintCustomIDs();
			});
		}

		private void ReadFileContent(string file, string content)
		{
			if (!_fileToIDs.ContainsKey(file))
			{
				_fileToIDs[file] = new HashSet<uint>();
			}
			HashSet<uint> hashSet = _fileToIDs[file];
			foreach (uint item in hashSet)
			{
				_customData.Remove(item);
			}
			hashSet.Clear();
			List<CustomWeaponData> list = null;
			try
			{
				list = EWCJson.Deserialize<List<CustomWeaponData>>(content);
			}
			catch (JsonException ex)
			{
				EWCLogger.Error("Error parsing custom weapon json " + file);
				EWCLogger.Error(ex.Message);
			}
			if (list == null)
			{
				return;
			}
			foreach (CustomWeaponData item2 in list)
			{
				if (item2 != null && _customData.ContainsKey(item2.ArchetypeID))
				{
					EWCLogger.Warning("Duplicate archetype ID " + item2.ArchetypeID + " found. Previous name: " + _customData[item2.ArchetypeID].Name + ", new name: " + item2.Name);
				}
				AddCustomWeaponData(item2, file);
			}
			ResetCWCs();
		}

		public CustomWeaponData? GetCustomWeaponData(uint ArchetypeID)
		{
			if (!_customData.ContainsKey(ArchetypeID))
			{
				return null;
			}
			return _customData[ArchetypeID];
		}

		public void AddWeaponListener(BulletWeapon weapon)
		{
			BulletWeapon weapon2 = weapon;
			if (!_listenCWs.Any((BulletWeapon listener) => ((Object)listener).GetInstanceID() == ((Object)weapon2).GetInstanceID()))
			{
				_listenCWs.Add(weapon2);
			}
		}

		internal void ResetCWCs()
		{
			for (int num = _listenCWs.Count - 1; num >= 0; num--)
			{
				if ((Object)(object)_listenCWs[num] != (Object)null)
				{
					CustomWeaponComponent customWeaponComponent = ((Component)_listenCWs[num]).GetComponent<CustomWeaponComponent>();
					customWeaponComponent?.Clear();
					CustomWeaponData customWeaponData = GetCustomWeaponData(((ItemEquippable)_listenCWs[num]).ArchetypeID);
					if (customWeaponData != null)
					{
						if ((Object)(object)customWeaponComponent == (Object)null)
						{
							customWeaponComponent = ((Component)_listenCWs[num]).gameObject.AddComponent<CustomWeaponComponent>();
						}
						customWeaponComponent.Register(customWeaponData);
					}
				}
				else
				{
					_listenCWs.RemoveAt(num);
				}
			}
		}

		internal void CreateTemplate()
		{
			string text = Path.Combine(DEFINITION_PATH, "Template.json");
			if (!Directory.Exists(DEFINITION_PATH))
			{
				EWCLogger.Log("No directory detected. Creating " + text);
				Directory.CreateDirectory(DEFINITION_PATH);
			}
			if (File.Exists(text))
			{
				EWCLogger.Error("Can't create template file (already exists)!");
				return;
			}
			StreamWriter streamWriter = File.CreateText(text);
			streamWriter.WriteLine(EWCJson.Serialize(new List<CustomWeaponData> { CustomWeaponTemplate.CreateTemplate() }));
			streamWriter.Flush();
			streamWriter.Close();
		}

		private void PrintCustomIDs()
		{
			StringBuilder stringBuilder = new StringBuilder("Found custom blocks for archetype IDs: ");
			stringBuilder.AppendJoin(", ", _customData.Keys.ToImmutableSortedSet());
			EWCLogger.Log(stringBuilder.ToString());
		}

		private CustomWeaponManager()
		{
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Expected O, but got Unknown
			DEFINITION_PATH = Path.Combine(MTFOPathAPI.CustomPath, "ExtraWeaponCustomization");
			if (!Directory.Exists(DEFINITION_PATH))
			{
				CreateTemplate();
			}
			else
			{
				EWCLogger.Log("Directory detected. " + DEFINITION_PATH);
			}
			foreach (string item in Directory.EnumerateFiles(DEFINITION_PATH, "*.json", SearchOption.AllDirectories))
			{
				string content = File.ReadAllText(item);
				ReadFileContent(item, content);
			}
			PrintCustomIDs();
			_liveEditListener = LiveEdit.CreateListener(DEFINITION_PATH, "*.json", true);
			_liveEditListener.FileCreated += new LiveEditEventHandler(FileCreated);
			_liveEditListener.FileChanged += new LiveEditEventHandler(FileChanged);
			_liveEditListener.FileDeleted += new LiveEditEventHandler(FileDeleted);
		}
	}
}
namespace ExtraWeaponCustomization.CustomWeapon.WeaponContext
{
	public sealed class ContextController
	{
		private interface IContextList
		{
			bool Add(IWeaponProperty property);

			bool Remove(IWeaponProperty property);

			void Clear();

			void Invoke(IWeaponContext context, List<Exception> exceptions);
		}

		private sealed class ContextList<TContext> : IContextList where TContext : IWeaponContext
		{
			private readonly List<IWeaponProperty<TContext>> _entries;

			private readonly IContextList? _baseContextList;

			private readonly ContextController _manager;

			internal ContextList(ContextController manager)
			{
				_entries = new List<IWeaponProperty<TContext>>();
				Type baseType = typeof(TContext).BaseType;
				if (baseType != null && manager._allContextLists.ContainsKey(baseType))
				{
					_baseContextList = manager._allContextLists[baseType];
				}
				_manager = manager;
				_manager._allContextLists.Add(typeof(TContext), this);
			}

			public bool Add(IWeaponProperty property)
			{
				IWeaponProperty<TContext> contextedProperty = property as IWeaponProperty<TContext>;
				if (contextedProperty == null)
				{
					return false;
				}
				if (_entries.Contains(contextedProperty))
				{
					return false;
				}
				if (!property.AllowStack && _entries.Any((IWeaponProperty<TContext> containedProperty) => containedProperty.GetType() == contextedProperty.GetType()))
				{
					return false;
				}
				_entries.Add(contextedProperty);
				return true;
			}

			public bool Remove(IWeaponProperty property)
			{
				if (property is IWeaponProperty<TContext> item)
				{
					return _entries.Remove(item);
				}
				return false;
			}

			public void Clear()
			{
				_entries.Clear();
			}

			public void Invoke(TContext context, List<Exception> exceptions)
			{
				foreach (IWeaponProperty<TContext> entry in _entries)
				{
					try
					{
						entry.Invoke(context);
					}
					catch (Exception item)
					{
						exceptions.Add(item);
					}
				}
				_baseContextList?.Invoke(context, exceptions);
			}

			void IContextList.Invoke(IWeaponContext context, List<Exception> exceptions)
			{
				if (context is TContext)
				{
					TContext context2 = (TContext)context;
					Invoke(context2, exceptions);
				}
			}
		}

		private readonly Dictionary<Type, IContextList> _allContextLists = new Dictionary<Type, IContextList>();

		public ContextController()
		{
			RegisterAllContexts();
		}

		public void Register(IWeaponProperty property)
		{
			if (property == null)
			{
				throw new ArgumentNullException("property");
			}
			foreach (IContextList value in _allContextLists.Values)
			{
				value.Add(property);
			}
		}

		public void Unregister(IWeaponProperty property)
		{
			foreach (IContextList value in _allContextLists.Values)
			{
				value.Remove(property);
			}
		}

		public void Clear()
		{
			foreach (IContextList value in _allContextLists.Values)
			{
				value.Clear();
			}
		}

		internal void Invoke<TContext>(TContext context) where TContext : IWeaponContext
		{
			if (!_allContextLists.TryGetValue(typeof(TContext), out IContextList value))
			{
				return;
			}
			List<Exception> list = new List<Exception>();
			value.Invoke(context, list);
			foreach (Exception item in list)
			{
				EWCLogger.Error(item.Message);
			}
		}

		internal void RegisterContext<TContext>() where TContext : IWeaponContext
		{
			_allContextLists.TryAdd(typeof(TContext), new ContextList<TContext>(this));
		}

		private void RegisterAllContexts()
		{
			RegisterContext<WeaponTriggerContext>();
			RegisterContext<WeaponDamageTypeContext>();
			RegisterContext<WeaponPostKillContext>();
			RegisterContext<WeaponPostFireContext>();
			RegisterContext<WeaponPreHitContext>();
			RegisterContext<WeaponPreHitEnemyContext>();
			RegisterContext<WeaponPostReloadContext>();
			RegisterContext<WeaponWieldContext>();
			RegisterContext<WeaponArmorContext>();
			RegisterContext<WeaponBackstabContext>();
			RegisterContext<WeaponCancelFireContext>();
			RegisterContext<WeaponDamageContext>();
			RegisterContext<WeaponPostAmmoInitContext>();
			RegisterContext<WeaponPreAmmoPackContext>();
			RegisterContext<WeaponPostAmmoPackContext>();
			RegisterContext<WeaponPreAmmoUIContext>();
			RegisterContext<WeaponFireRateContext>();
			RegisterContext<WeaponFireRateSetContext>();
			RegisterContext<WeaponPierceContext>();
			RegisterContext<WeaponPreFireContext>();
			RegisterContext<WeaponPreStartFireContext>();
			RegisterContext<WeaponPostStartFireContext>();
			RegisterContext<WeaponPreRayContext>();
			RegisterContext<WeaponPostRayContext>();
			RegisterContext<WeaponPostStopFiringContext>();
			RegisterContext<WeaponRecoilContext>();
			RegisterContext<WeaponClearContext>();
			RegisterContext<WeaponPostSetupContext>();
		}

		internal void ChangeToSyncContexts()
		{
			_allContextLists.Clear();
			RegisterContext<WeaponFireRateContext>();
			RegisterContext<WeaponFireRateSetContext>();
			RegisterContext<WeaponFireRateModContextSync>();
			RegisterContext<WeaponPreFireContextSync>();
			RegisterContext<WeaponPostFireContextSync>();
		}
	}
	public interface IWeaponContext
	{
		BulletWeapon Weapon { get; }
	}
}
namespace ExtraWeaponCustomization.CustomWeapon.WeaponContext.Contexts
{
	public class WeaponPostAmmoInitContext : IWeaponContext
	{
		public PlayerAmmoStorage AmmoStorage { get; set; }

		public InventorySlotAmmo SlotAmmo { get; set; }

		public BulletWeapon Weapon { get; }

		public WeaponPostAmmoInitContext(PlayerAmmoStorage ammoStorage, InventorySlotAmmo slotAmmo, BulletWeapon weapon)
		{
			AmmoStorage = ammoStorage;
			SlotAmmo = slotAmmo;
			Weapon = weapon;
		}
	}
	public class WeaponPostAmmoPackContext : IWeaponContext
	{
		public PlayerAmmoStorage AmmoStorage { get; set; }

		public BulletWeapon Weapon { get; }

		public WeaponPostAmmoPackContext(PlayerAmmoStorage ammoStorage, BulletWeapon weapon)
		{
			AmmoStorage = ammoStorage;
			Weapon = weapon;
		}
	}
	public class WeaponPreAmmoPackContext : IWeaponContext
	{
		public BulletWeapon Weapon { get; }

		public float AmmoRel { get; set; }

		public WeaponPreAmmoPackContext(BulletWeapon weapon, float ammoRel)
		{
			Weapon = weapon;
			AmmoRel = ammoRel;
		}
	}
	public class WeaponPreAmmoUIContext : IWeaponContext
	{
		public BulletWeapon Weapon { get; }

		public int Clip { get; set; }

		public int Reserve { get; set; }

		public float TotalRel { get; set; }

		public bool ShowClip { get; set; }

		public bool ShowReserve { get; set; }

		public bool ShowRel { get; set; }

		public bool ShowInfinite { get; set; }

		public WeaponPreAmmoUIContext(BulletWeapon weapon, int clip, int reserve, float totalRel, bool showClip, bool showReserve, bool showRel, bool showInfinite)
		{
			Weapon = weapon;
			Clip = clip;
			Reserve = reserve;
			TotalRel = totalRel;
			ShowClip = showClip;
			ShowReserve = showReserve;
			ShowRel = showRel;
			ShowInfinite = showInfinite;
		}
	}
	public sealed class WeaponArmorContext : IWeaponContext
	{
		public BulletWeapon Weapon { get; }

		public float ArmorMulti { get; set; }

		public WeaponArmorContext(float armor, BulletWeapon weapon)
		{
			ArmorMulti = armor;
			Weapon = weapon;
		}
	}
	public sealed class WeaponCancelFireContext : IWeaponContext
	{
		public BulletWeapon Weapon { get; }

		public WeaponCancelFireContext(BulletWeapon weapon)
		{
			Weapon = weapon;
		}
	}
	public sealed class WeaponPostRayContext : IWeaponContext
	{
		public WeaponHitData Data { get; }

		public BulletWeapon Weapon { get; }

		public Vector3 Position { get; }

		public bool Result { get; set; }

		public WeaponPostRayContext(WeaponHitData weaponHitData, Vector3 position, BulletWeapon weapon, bool result)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			Data = weaponHitData;
			Weapon = weapon;
			Position = position;
			Result = result;
		}
	}
	public sealed class WeaponPostStartFireContext : IWeaponContext
	{
		public BulletWeapon Weapon { get; }

		public WeaponPostStartFireContext(BulletWeapon weapon)
		{
			Weapon = weapon;
		}
	}
	public sealed class WeaponPostStopFiringContext : IWeaponContext
	{
		public BulletWeapon Weapon { get; }

		public WeaponPostStopFiringContext(BulletWeapon weapon)
		{
			Weapon = weapon;
		}
	}
	public sealed class WeaponPreFireContext : IWeaponContext
	{
		public BulletWeapon Weapon { get; }

		public bool Allow { get; set; }

		public WeaponPreFireContext(BulletWeapon weapon)
		{
			Weapon = weapon;
			Allow = true;
		}
	}
	public sealed class WeaponPreRayContext : IWeaponContext
	{
		public WeaponHitData Data { get; }

		public BulletWeapon Weapon { get; }

		public Vector3 Position { get; }

		public WeaponPreRayContext(WeaponHitData weaponHitData, Vector3 position, BulletWeapon weapon)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			Data = weaponHitData;
			Weapon = weapon;
			Position = position;
		}
	}
	public class WeaponPreStartFireContext : IWeaponContext
	{
		public BulletWeapon Weapon { get; }

		public bool Allow { get; set; }

		public WeaponPreStartFireContext(BulletWeapon weapon)
		{
			Weapon = weapon;
			Allow = true;
		}
	}
	public sealed class StackMod
	{
		private readonly float _value;

		private float _min;

		private float _addMod = 1f;

		private float _multMod = 1f;

		private float _overrideMod = -1f;

		public float Value => Math.Max(_min, _value * ((_overrideMod >= 0f) ? _overrideMod : (_addMod * _multMod)));

		public StackMod(float value, float min = 0f)
		{
			_value = value;
			_min = min;
		}

		public void SetMin(float min)
		{
			_min = min;
		}

		public void AddMod(float mod, StackType type)
		{
			switch (type)
			{
			case StackType.Override:
				_overrideMod = mod;
				break;
			case StackType.Add:
				_addMod += mod - 1f;
				break;
			case StackType.Multiply:
				_multMod *= mod;
				break;
			}
		}
	}
	internal class WeaponBackstabContext : WeaponStackModContext
	{
		public WeaponBackstabContext(BulletWeapon weapon)
			: base(2f, weapon)
		{
			_stackMod.SetMin(1f);
		}
	}
	public sealed class WeaponDamageContext : IWeaponContext
	{
		public BulletWeapon Weapon { get; }

		public IDamageable Damageable { get; }

		public StackMod Damage { get; }

		public StackMod Precision { get; }

		public WeaponDamageContext(float damage, float precision, IDamageable damageable, BulletWeapon weapon)
		{
			Weapon = weapon;
			Damage = new StackMod(damage);
			Precision = new StackMod(precision);
			Damageable = damageable;
		}
	}
	public class WeaponFireRateContext : WeaponStackModContext
	{
		public WeaponFireRateContext(float fireRate, BulletWeapon weapon)
			: base(fireRate, weapon)
		{
		}
	}
	public class WeaponFireRateSetContext : IWeaponContext
	{
		public BulletWeapon Weapon { get; }

		public float FireRate { get; set; }

		public WeaponFireRateSetContext(BulletWeapon weapon, float fireRate)
		{
			Weapon = weapon;
			FireRate = fireRate;
		}
	}
	public sealed class WeaponPierceContext : WeaponStackModContext
	{
		public IDamageable Damageable { get; }

		public WeaponPierceContext(float damage, IDamageable damageable, BulletWeapon weapon)
			: base(damage, weapon)
		{
			Damageable = damageable;
		}
	}
	public class WeaponRecoilContext : WeaponStackModContext
	{
		public WeaponRecoilContext(BulletWeapon weapon)
			: base(1f, weapon)
		{
			_stackMod.SetMin(float.MinValue);
		}
	}
	public abstract class WeaponStackModContext : IWeaponContext
	{
		protected readonly StackMod _stackMod;

		public BulletWeapon Weapon { get; }

		public float Value => _stackMod.Value;

		public WeaponStackModContext(float value, BulletWeapon weapon)
		{
			_stackMod = new StackMod(value);
			Weapon = weapon;
		}

		public void AddMod(float mod, StackType type)
		{
			_stackMod.AddMod(mod, type);
		}
	}
	public sealed class WeaponClearContext : IWeaponContext
	{
		public BulletWeapon Weapon { get; }

		public WeaponClearContext(BulletWeapon weapon)
		{
			Weapon = weapon;
		}
	}
	public sealed class WeaponPostSetupContext : IWeaponContext
	{
		public BulletWeapon Weapon { get; }

		public WeaponPostSetupContext(BulletWeapon weapon)
		{
			Weapon = weapon;
		}
	}
	public sealed class WeaponFireRateModContextSync : IWeaponContext
	{
		public float Mod { get; }

		public BulletWeapon Weapon { get; }

		public WeaponFireRateModContextSync(float mod, BulletWeapon weapon)
		{
			Mod = mod;
			Weapon = weapon;
		}
	}
	public sealed class WeaponPostFireContextSync : IWeaponContext
	{
		public BulletWeapon Weapon { get; }

		public WeaponPostFireContextSync(BulletWeapon weapon)
		{
			Weapon = weapon;
		}
	}
	public sealed class WeaponPreFireContextSync : IWeaponContext
	{
		public BulletWeapon Weapon { get; }

		public WeaponPreFireContextSync(BulletWeapon weapon)
		{
			Weapon = weapon;
		}
	}
	[Flags]
	public enum DamageType
	{
		Invalid = -1,
		Any = 0,
		Weakspot = 1,
		Bullet = 2,
		WeakspotBullet = 3,
		Explosive = 4,
		WeakspotExplosive = 5,
		DOT = 8,
		WeakspotDOT = 9
	}
	public abstract class WeaponDamageTypeContext : WeaponTriggerContext
	{
		public DamageType DamageType { get; protected set; }

		public WeaponDamageTypeContext(BulletWeapon weapon, DamageType flag)
			: base(weapon)
		{
			DamageType = flag;
		}
	}
	public sealed class WeaponPostFireContext : WeaponTriggerContext
	{
		public WeaponPostFireContext(BulletWeapon weapon)
			: base(weapon)
		{
		}
	}
	public sealed class WeaponPostKillContext : WeaponDamageTypeContext
	{
		public Vector3 Position { get; }

		public Vector3 Direction { get; }

		public Vector3 LocalPosition { get; }

		public EnemyAgent Enemy { get; }

		public float Falloff { get; }

		public float Backstab { get; }

		public WeaponPostKillContext(WeaponPreHitEnemyContext hitContext)
			: base(hitContext.Weapon, hitContext.DamageType)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			Enemy = ((Il2CppObjectBase)hitContext.Damageable.GetBaseAgent()).TryCast<EnemyAgent>();
			Position = hitContext.LocalPosition + Enemy.Position;
			Direction = hitContext.Direction;
			LocalPosition = hitContext.LocalPosition;
			Falloff = hitContext.Falloff;
			Backstab = hitContext.Backstab;
		}
	}
	public class WeaponPostReloadContext : WeaponTriggerContext
	{
		public WeaponPostReloadContext(BulletWeapon weapon)
			: base(weapon)
		{
		}
	}
	public class WeaponPreHitContext : WeaponDamageTypeContext
	{
		public Vector3 Position { get; }

		public Vector3 Direction { get; }

		public float Falloff { get; }

		public Vector3 LocalPosition { get; }

		public IDamageable? Damageable { get; }

		public WeaponPreHitContext(Vector3 position, Vector3 direction, float falloff, BulletWeapon weapon, IDamageable? damageable = null)
			: base(weapon, DamageType.Bullet)
		{
			//IL_000a: 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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			Position = position;
			Direction = direction;
			Falloff = falloff;
			Vector3? val = ((damageable != null) ? new Vector3?(damageable.GetBaseAgent().Position) : null);
			LocalPosition = (Vector3)(((??)(val.HasValue ? new Vector3?(position - val.GetValueOrDefault()) : null)) ?? Vector3.zero);
			Damageable = damageable;
		}

		public WeaponPreHitContext(WeaponHitData data, float additionalDist, BulletWeapon weapon, IDamageable? damageable = null)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit rayHit = data.rayHit;
			Vector3 point = ((RaycastHit)(ref rayHit)).point;
			Vector3 fireDir = data.fireDir;
			this..ctor(point, ((Vector3)(ref fireDir)).normalized, data.Falloff(additionalDist), weapon, damageable);
		}
	}
	public sealed class WeaponPreHitEnemyContext : WeaponPreHitContext
	{
		public float Damage { get; }

		public float Backstab { get; }

		public new IDamageable Damageable => base.Damageable;

		public WeaponPreHitEnemyContext(float damage, float falloff, float backstab, IDamageable damageable, Vector3 position, Vector3 direction, BulletWeapon weapon, DamageType flag = DamageType.Any)
			: base(position, direction, falloff, weapon, damageable)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			Damage = damage;
			IDamageable baseDamagable = damageable.GetBaseDamagable();
			Dam_EnemyDamageBase val = ((baseDamagable != null) ? ((Il2CppObjectBase)baseDamagable).TryCast<Dam_EnemyDamageBase>() : null);
			if ((Object)(object)val != (Object)null)
			{
				Damage = Math.Min(Damage, ((Dam_SyncedDamageBase)val).HealthMax);
			}
			Backstab = backstab;
			base.DamageType = flag;
		}

		public WeaponPreHitEnemyContext(WeaponHitData data, float additionalDist, float backstab, Dam_EnemyDamageLimb limb, BulletWeapon weapon, DamageType flag = DamageType.Any)
			: base(data, additionalDist, weapon, ((Il2CppObjectBase)limb).TryCast<IDamageable>())
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Invalid comparison between Unknown and I4
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Invalid comparison between Unknown and I4
			Backstab = backstab;
			Damage = data.damage * base.Falloff;
			Damage = limb.ApplyWeakspotAndArmorModifiers(Damage, data.precisionMulti);
			Damage *= Backstab;
			Damage = Math.Min(Damage, ((Dam_SyncedDamageBase)limb.m_base).HealthMax);
			if ((int)limb.DestructionType == 1)
			{
				Damage = Math.Min(Damage, limb.m_healthMax);
			}
			base.DamageType = flag;
			if ((int)limb.m_type == 1)
			{
				base.DamageType |= DamageType.Weakspot;
			}
		}
	}
	public abstract class WeaponTriggerContext : IWeaponContext
	{
		public BulletWeapon Weapon { get; }

		public WeaponTriggerContext(BulletWeapon weapon)
		{
			Weapon = weapon;
		}
	}
	public class WeaponWieldContext : WeaponTriggerContext
	{
		public WeaponWieldContext(BulletWeapon weapon)
			: base(weapon)
		{
		}
	}
}
namespace ExtraWeaponCustomization.CustomWeapon.Properties
{
	public interface IWeaponProperty
	{
		bool AllowStack { get; }

		IWeaponProperty Clone();

		void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options);

		void DeserializeProperty(string property, ref Utf8JsonReader reader, JsonSerializerOptions options);
	}
	public interface IWeaponProperty<TContext> : IWeaponProperty where TContext : IWeaponContext
	{
		void Invoke(TContext context);
	}
}
namespace ExtraWeaponCustomization.CustomWeapon.Properties.Traits
{
	public class AmmoCap : Trait, IWeaponProperty<WeaponPostSetupContext>, IWeaponProperty, IWeaponProperty<WeaponPostAmmoInitContext>, IWeaponProperty<WeaponPreAmmoPackContext>
	{
		private const float DefaultPackConv = 5f;

		public float AmmoCapRel { get; set; } = 1f;


		public float AmmopackRefillRel { get; set; }

		public float CostOfBullet { get; set; }

		public void Invoke(WeaponPostSetupContext context)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Invalid comparison between Unknown and I4
			if (AmmopackRefillRel > 0f)
			{
				PlayerDataBlock block = GameDataBlockBase<PlayerDataBlock>.GetBlock(1u);
				float num = 1f;
				AmmoType ammoType = ((ItemEquippable)context.Weapon).AmmoType;
				if ((int)ammoType != 0)
				{
					if ((int)ammoType == 1)
					{
						num = (float)block.AmmoSpecialMaxCap / (float)block.AmmoSpecialResourcePackMaxCap;
					}
				}
				else
				{
					num = (float)block.AmmoStandardMaxCap / (float)block.AmmoStandardResourcePackMaxCap;
				}
				AmmoCapRel = AmmopackRefillRel * 5f * num;
			}
			if (CostOfBullet > 0f)
			{
				AmmoCapRel = ((ItemEquippable)context.Weapon).ArchetypeData.CostOfBullet / CostOfBullet;
			}
		}

		public void Invoke(WeaponPostAmmoInitContext context)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			InventorySlotAmmo slotAmmo = context.SlotAmmo;
			slotAmmo.AmmoInPack = ((float)((ItemEquippable)context.Weapon).GetCurrentClip() * slotAmmo.CostOfBullet + slotAmmo.AmmoInPack) * AmmoCapRel;
			((ItemEquippable)context.Weapon).SetCurrentClip(context.AmmoStorage.GetClipBulletsFromPack(0, slotAmmo.AmmoType));
		}

		public void Invoke(WeaponPreAmmoPackContext context)
		{
			context.AmmoRel *= AmmoCapRel;
		}

		public override IWeaponProperty Clone()
		{
			return new AmmoCap
			{
				AmmoCapRel = AmmoCapRel,
				AmmopackRefillRel = AmmopackRefillRel,
				CostOfBullet = CostOfBullet
			};
		}

		public override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options)
		{
			writer.WriteStartObject();
			writer.WriteString("Name", "AmmoCap");
			writer.WriteNumber("AmmoCapRel", AmmoCapRel);
			writer.WriteNumber("AmmopackRefillRel", AmmopackRefillRel);
			writer.WriteNumber("CostOfBullet", CostOfBullet);
			writer.WriteEndObject();
		}

		public override void DeserializeProperty(string property, ref Utf8JsonReader reader, JsonSerializerOptions options)
		{
			if (property == null)
			{
				return;
			}
			switch (property.Length)
			{
			default:
				return;
			case 10:
			{
				char c = property[4];
				if (c != 'c')
				{
					if (c != 'r' || !(property == "ammorefill"))
					{
						return;
					}
					break;
				}
				if (!(property == "ammocaprel"))
				{
					return;
				}
				goto IL_0101;
			}
			case 6:
			{
				char c = property[0];
				if (c != 'c')
				{
					if (c != 'r' || !(property == "refill"))
					{
						return;
					}
					break;
				}
				if (!(property == "caprel"))
				{
					return;
				}
				goto IL_0101;
			}
			case 12:
				if (property == "costofbullet")
				{
					CostOfBullet = reader.GetSingle();
					AmmopackRefillRel = 0f;
				}
				return;
			case 7:
				if (!(property == "ammocap"))
				{
					return;
				}
				goto IL_0101;
			case 3:
				if (!(property == "cap"))
				{
					return;
				}
				goto IL_0101;
			case 13:
				if (!(property == "ammorefillrel"))
				{
					return;
				}
				break;
			case 9:
				if (!(property == "refillrel"))
				{
					return;
				}
				break;
			case 4:
			case 5:
			case 8:
			case 11:
				return;
				IL_0101:
				AmmoCapRel = reader.GetSingle();
				CostOfBullet = 0f;
				AmmopackRefillRel = 0f;
				return;
			}
			AmmopackRefillRel = reader.GetSingle();
			CostOfBullet = 0f;
		}
	}
	public sealed class ReserveClip : Trait, IWeaponProperty<WeaponPostAmmoPackContext>, IWeaponProperty, IWeaponProperty<WeaponPreAmmoUIContext>, IWeaponProperty<WeaponPostStartFireContext>, IWeaponProperty<WeaponPostFireContext>
	{
		public void Invoke(WeaponPostStartFireContext context)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Invalid comparison between Unknown and I4
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if ((int)((ItemEquippable)context.Weapon).ArchetypeData.FireMode == 1)
			{
				BWA_Burst obj = ((Il2CppObjectBase)context.Weapon.m_archeType).TryCast<BWA_Burst>();
				obj.m_burstCurrentCount = Math.Min(val2: ((ItemEquippable)context.Weapon).GetCurrentClip() + PlayerBackpackManager.GetBulletsInPack(((ItemEquippable)context.Weapon).AmmoType, ((Item)context.Weapon).Owner.Owner), val1: obj.m_burstMax);
			}
		}

		public void Invoke(WeaponPostAmmoPackContext context)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			BulletWeapon weapon = context.Weapon;
			if ((Object)(object)((Item)weapon).Owner.Inventory.WieldedItem != (Object)(object)context.Weapon)
			{
				((ItemEquippable)weapon).SetCurrentClip(context.AmmoStorage.GetClipBulletsFromPack(((ItemEquippable)weapon).GetCurrentClip(), ((ItemEquippable)weapon).AmmoType));
				((Weapon)weapon).m_wasOutOfAmmo = false;
			}
			else
			{
				((Item)weapon).Owner.Inventory.DoReload();
			}
		}

		public void Invoke(WeaponPostFireContext context)
		{
			((Item)context.Weapon).Owner.Inventory.DoReload();
		}

		public void Invoke(WeaponPreAmmoUIContext context)
		{
			context.Reserve += context.Clip;
			context.ShowClip = false;
		}

		public override IWeaponProperty Clone()
		{
			return new ReserveClip();
		}

		public override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options)
		{
			writer.WriteStartObject();
			writer.WriteString("Name", GetType().Name);
			writer.WriteEndObject();
		}

		public override void DeserializeProperty(string property, ref Utf8JsonReader reader, JsonSerializerOptions options)
		{
		}
	}
	public sealed class AutoAim : Trait, IWeaponProperty<WeaponPostSetupContext>, IWeaponProperty, IWeaponProperty<WeaponClearContext>, IWeaponProperty<WeaponPreStartFireContext>, IWeaponProperty<WeaponPreFireContext>, IWeaponProperty<WeaponPreRayContext>
	{
		private sealed class ColliderComparer : IComparer<Collider>
		{
			private Vector3 _forward;

			private Vector3 _position;

			public void Set(Vector3 forward, Vector3 position)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				_forward = forward;
				_position = position;
			}

			public int Compare(Collider? x, Collider? y)
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: 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_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)x == (Object)null)
				{
					return 1;
				}
				if ((Object)(object)y

plugins/SURVIVAL/net6/KillIndicatorFix.dll

Decompiled 5 days 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 System.Text;
using API;
using Agents;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Enemies;
using GameData;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using KillIndicatorFix.BepInEx;
using KillIndicatorFix.Patches;
using Microsoft.CodeAnalysis;
using Player;
using SNetwork;
using UnityEngine;
using UnityEngine.Analytics;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("KillIndicatorFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a713a64d1323e013d952ed587cc3e798e9167afe")]
[assembly: AssemblyProduct("KillIndicatorFix")]
[assembly: AssemblyTitle("KillIndicatorFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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;
		}
	}
}
internal static class BitHelper
{
	public const int SizeOfHalf = 2;

	public const int SizeOfVector3 = 12;

	public const int SizeOfQuaternion = 13;

	public const int SizeOfHalfVector3 = 6;

	public const int SizeOfHalfQuaternion = 7;

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	private static uint RotateLeft(uint value, int offset)
	{
		return (value << offset) | (value >> 32 - offset);
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	private static uint RotateRight(uint value, int offset)
	{
		return (value >> offset) | (value << 32 - offset);
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public static long ReverseEndianness(long value)
	{
		return (long)ReverseEndianness((ulong)value);
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public static int ReverseEndianness(int value)
	{
		return (int)ReverseEndianness((uint)value);
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public static short ReverseEndianness(short value)
	{
		return (short)ReverseEndianness((ushort)value);
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	private static ushort ReverseEndianness(ushort value)
	{
		return (ushort)((value >> 8) + (value << 8));
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	private static uint ReverseEndianness(uint value)
	{
		return RotateRight(value & 0xFF00FFu, 8) + RotateLeft(value & 0xFF00FF00u, 8);
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	private static ulong ReverseEndianness(ulong value)
	{
		return ((ulong)ReverseEndianness((uint)value) << 32) + ReverseEndianness((uint)(value >> 32));
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	private unsafe static void _WriteBytes(byte* source, int size, byte[] destination, ref int index)
	{
		int num = 0;
		while (num < size)
		{
			destination[index++] = source[num++];
		}
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public static void WriteBytes(byte value, byte[] destination, ref int index)
	{
		destination[index++] = value;
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public static void WriteBytes(bool value, byte[] destination, ref int index)
	{
		destination[index++] = (value ? ((byte)1) : ((byte)0));
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public unsafe static void WriteBytes(ulong value, byte[] destination, ref int index)
	{
		if (!BitConverter.IsLittleEndian)
		{
			value = ReverseEndianness(value);
		}
		_WriteBytes((byte*)(&value), 8, destination, ref index);
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public unsafe static void WriteBytes(uint value, byte[] destination, ref int index)
	{
		if (!BitConverter.IsLittleEndian)
		{
			value = ReverseEndianness(value);
		}
		_WriteBytes((byte*)(&value), 4, destination, ref index);
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public unsafe static void WriteBytes(ushort value, byte[] destination, ref int index)
	{
		if (!BitConverter.IsLittleEndian)
		{
			value = ReverseEndianness(value);
		}
		_WriteBytes((byte*)(&value), 2, destination, ref index);
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public unsafe static void WriteBytes(long value, byte[] destination, ref int index)
	{
		if (!BitConverter.IsLittleEndian)
		{
			value = ReverseEndianness(value);
		}
		_WriteBytes((byte*)(&value), 8, destination, ref index);
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public unsafe static void WriteBytes(int value, byte[] destination, ref int index)
	{
		if (!BitConverter.IsLittleEndian)
		{
			value = ReverseEndianness(value);
		}
		_WriteBytes((byte*)(&value), 4, destination, ref index);
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public unsafe static void WriteBytes(short value, byte[] destination, ref int index)
	{
		if (!BitConverter.IsLittleEndian)
		{
			value = ReverseEndianness(value);
		}
		_WriteBytes((byte*)(&value), 2, destination, ref index);
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public unsafe static void WriteBytes(float value, byte[] destination, ref int index)
	{
		int value2 = *(int*)(&value);
		if (!BitConverter.IsLittleEndian)
		{
			value2 = ReverseEndianness(value2);
		}
		_WriteBytes((byte*)(&value2), 4, destination, ref index);
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public static void WriteBytes(string value, byte[] destination, ref int index)
	{
		byte[] bytes = Encoding.UTF8.GetBytes(value);
		WriteBytes((ushort)bytes.Length, destination, ref index);
		Array.Copy(bytes, 0, destination, index, bytes.Length);
		index += bytes.Length;
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public static void WriteBytes(byte[] buffer, byte[] destination, ref int index)
	{
		WriteBytes((ushort)buffer.Length, destination, ref index);
		Array.Copy(buffer, 0, destination, index, buffer.Length);
		index += buffer.Length;
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public static void WriteHalf(float value, byte[] destination, ref int index)
	{
		WriteBytes(FloatToHalf(value), destination, ref index);
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	private unsafe static uint AsUInt(float x)
	{
		return *(uint*)(&x);
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	private unsafe static float AsFloat(uint x)
	{
		return *(float*)(&x);
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public static float HalfToFloat(ushort x)
	{
		int num = (x & 0x7C00) >> 10;
		int num2 = (x & 0x3FF) << 13;
		int num3 = (int)(AsUInt(num2) >> 23);
		return AsFloat((uint)(((x & 0x8000) << 16) | (Convert.ToInt32(num != 0) * ((num + 112 << 23) | num2)) | ((Convert.ToInt32(num == 0) & Convert.ToInt32(num2 != 0)) * ((num3 - 37 << 23) | ((num2 << 150 - num3) & 0x7FE000)))));
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public static ushort FloatToHalf(float x)
	{
		uint num = AsUInt(x) + 4096;
		uint num2 = (num & 0x7F800000) >> 23;
		uint num3 = num & 0x7FFFFFu;
		return (ushort)(((num & 0x80000000u) >> 16) | (Convert.ToInt32(num2 > 112) * (((num2 - 112 << 10) & 0x7C00) | (num3 >> 13))) | ((Convert.ToInt32(num2 < 113) & Convert.ToInt32(num2 > 101)) * ((8384512 + num3 >> (int)(125 - num2)) + 1 >> 1)) | (Convert.ToUInt32(num2 > 143) * 32767));
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public static byte ReadByte(byte[] source, ref int index)
	{
		return source[index++];
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public static bool ReadBool(byte[] source, ref int index)
	{
		return source[index++] != 0;
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public unsafe static ulong ReadULong(byte[] source, ref int index)
	{
		fixed (byte* ptr = source)
		{
			byte* num = ptr + index;
			index += 8;
			ulong num2 = *(ulong*)num;
			if (!BitConverter.IsLittleEndian)
			{
				num2 = ReverseEndianness(num2);
			}
			return num2;
		}
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public unsafe static long ReadLong(byte[] source, ref int index)
	{
		fixed (byte* ptr = source)
		{
			byte* num = ptr + index;
			index += 8;
			long num2 = *(long*)num;
			if (!BitConverter.IsLittleEndian)
			{
				num2 = ReverseEndianness(num2);
			}
			return num2;
		}
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public unsafe static uint ReadUInt(byte[] source, ref int index)
	{
		fixed (byte* ptr = source)
		{
			byte* num = ptr + index;
			index += 4;
			uint num2 = *(uint*)num;
			if (!BitConverter.IsLittleEndian)
			{
				num2 = ReverseEndianness(num2);
			}
			return num2;
		}
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public unsafe static int ReadInt(byte[] source, ref int index)
	{
		fixed (byte* ptr = source)
		{
			byte* num = ptr + index;
			index += 4;
			int num2 = *(int*)num;
			if (!BitConverter.IsLittleEndian)
			{
				num2 = ReverseEndianness(num2);
			}
			return num2;
		}
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public unsafe static ushort ReadUShort(byte[] source, ref int index)
	{
		fixed (byte* ptr = source)
		{
			byte* num = ptr + index;
			index += 2;
			ushort num2 = *(ushort*)num;
			if (!BitConverter.IsLittleEndian)
			{
				num2 = ReverseEndianness(num2);
			}
			return num2;
		}
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public unsafe static short ReadShort(byte[] source, ref int index)
	{
		fixed (byte* ptr = source)
		{
			byte* num = ptr + index;
			index += 2;
			short num2 = *(short*)num;
			if (!BitConverter.IsLittleEndian)
			{
				num2 = ReverseEndianness(num2);
			}
			return num2;
		}
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public static float ReadHalf(byte[] source, ref int index)
	{
		return HalfToFloat(ReadUShort(source, ref index));
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public unsafe static float ReadFloat(byte[] source, ref int index)
	{
		fixed (byte* ptr = source)
		{
			byte* ptr2 = ptr + index;
			index += 4;
			if (!BitConverter.IsLittleEndian)
			{
				int num = ReverseEndianness(*(int*)ptr2);
				return *(float*)(&num);
			}
			return *(float*)ptr2;
		}
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public static string ReadString(byte[] source, ref int index)
	{
		int num = ReadUShort(source, ref index);
		string @string = Encoding.UTF8.GetString(source, index, num);
		index += num;
		return @string;
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public static void WriteBytes(Vector3 value, byte[] destination, ref int index)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		WriteBytes(value.x, destination, ref index);
		WriteBytes(value.y, destination, ref index);
		WriteBytes(value.z, destination, ref index);
	}

	public static void WriteBytes(Quaternion value, byte[] destination, ref int index)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: 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_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: 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)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		float num = value.x;
		byte b = 0;
		if (value.y > num)
		{
			num = value.y;
			b = 1;
		}
		if (value.z > num)
		{
			num = value.z;
			b = 2;
		}
		if (value.w > num)
		{
			num = value.w;
			b = 3;
		}
		WriteBytes(b, destination, ref index);
		switch (b)
		{
		case 0:
			if (value.x >= 0f)
			{
				WriteBytes(value.y, destination, ref index);
				WriteBytes(value.z, destination, ref index);
				WriteBytes(value.w, destination, ref index);
			}
			else
			{
				WriteBytes(0f - value.y, destination, ref index);
				WriteBytes(0f - value.z, destination, ref index);
				WriteBytes(0f - value.w, destination, ref index);
			}
			break;
		case 1:
			if (value.y >= 0f)
			{
				WriteBytes(value.x, destination, ref index);
				WriteBytes(value.z, destination, ref index);
				WriteBytes(value.w, destination, ref index);
			}
			else
			{
				WriteBytes(0f - value.x, destination, ref index);
				WriteBytes(0f - value.z, destination, ref index);
				WriteBytes(0f - value.w, destination, ref index);
			}
			break;
		case 2:
			if (value.z >= 0f)
			{
				WriteBytes(value.x, destination, ref index);
				WriteBytes(value.y, destination, ref index);
				WriteBytes(value.w, destination, ref index);
			}
			else
			{
				WriteBytes(0f - value.x, destination, ref index);
				WriteBytes(0f - value.y, destination, ref index);
				WriteBytes(0f - value.w, destination, ref index);
			}
			break;
		case 3:
			if (value.w >= 0f)
			{
				WriteBytes(value.x, destination, ref index);
				WriteBytes(value.y, destination, ref index);
				WriteBytes(value.z, destination, ref index);
			}
			else
			{
				WriteBytes(0f - value.x, destination, ref index);
				WriteBytes(0f - value.y, destination, ref index);
				WriteBytes(0f - value.z, destination, ref index);
			}
			break;
		}
	}

	public static Vector3 ReadVector3(byte[] source, ref int index)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		return new Vector3(ReadFloat(source, ref index), ReadFloat(source, ref index), ReadFloat(source, ref index));
	}

	public static Quaternion ReadQuaternion(byte[] source, ref int index)
	{
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		byte b = ReadByte(source, ref index);
		float num = 0f;
		float num2 = 0f;
		float num3 = 0f;
		float num4 = 0f;
		switch (b)
		{
		case 0:
			num2 = ReadFloat(source, ref index);
			num3 = ReadFloat(source, ref index);
			num4 = ReadFloat(source, ref index);
			num = Mathf.Sqrt(1f - num2 * num2 - num3 * num3 - num4 * num4);
			break;
		case 1:
			num = ReadFloat(source, ref index);
			num3 = ReadFloat(source, ref index);
			num4 = ReadFloat(source, ref index);
			num2 = Mathf.Sqrt(1f - num * num - num3 * num3 - num4 * num4);
			break;
		case 2:
			num = ReadFloat(source, ref index);
			num2 = ReadFloat(source, ref index);
			num4 = ReadFloat(source, ref index);
			num3 = Mathf.Sqrt(1f - num * num - num2 * num2 - num4 * num4);
			break;
		case 3:
			num = ReadFloat(source, ref index);
			num2 = ReadFloat(source, ref index);
			num3 = ReadFloat(source, ref index);
			num4 = Mathf.Sqrt(1f - num * num - num2 * num2 - num3 * num3);
			break;
		}
		return new Quaternion(num, num2, num3, num4);
	}

	public static void WriteHalf(Vector3 value, byte[] destination, ref int index)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		WriteHalf(value.x, destination, ref index);
		WriteHalf(value.y, destination, ref index);
		WriteHalf(value.z, destination, ref index);
	}

	public static void WriteHalf(Quaternion value, byte[] destination, ref int index)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: 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_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: 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)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		float num = value.x;
		byte b = 0;
		if (value.y > num)
		{
			num = value.y;
			b = 1;
		}
		if (value.z > num)
		{
			num = value.z;
			b = 2;
		}
		if (value.w > num)
		{
			num = value.w;
			b = 3;
		}
		WriteBytes(b, destination, ref index);
		switch (b)
		{
		case 0:
			if (value.x >= 0f)
			{
				WriteHalf(value.y, destination, ref index);
				WriteHalf(value.z, destination, ref index);
				WriteHalf(value.w, destination, ref index);
			}
			else
			{
				WriteHalf(0f - value.y, destination, ref index);
				WriteHalf(0f - value.z, destination, ref index);
				WriteHalf(0f - value.w, destination, ref index);
			}
			break;
		case 1:
			if (value.y >= 0f)
			{
				WriteHalf(value.x, destination, ref index);
				WriteHalf(value.z, destination, ref index);
				WriteHalf(value.w, destination, ref index);
			}
			else
			{
				WriteHalf(0f - value.x, destination, ref index);
				WriteHalf(0f - value.z, destination, ref index);
				WriteHalf(0f - value.w, destination, ref index);
			}
			break;
		case 2:
			if (value.z >= 0f)
			{
				WriteHalf(value.x, destination, ref index);
				WriteHalf(value.y, destination, ref index);
				WriteHalf(value.w, destination, ref index);
			}
			else
			{
				WriteHalf(0f - value.x, destination, ref index);
				WriteHalf(0f - value.y, destination, ref index);
				WriteHalf(0f - value.w, destination, ref index);
			}
			break;
		case 3:
			if (value.w >= 0f)
			{
				WriteHalf(value.x, destination, ref index);
				WriteHalf(value.y, destination, ref index);
				WriteHalf(value.z, destination, ref index);
			}
			else
			{
				WriteHalf(0f - value.x, destination, ref index);
				WriteHalf(0f - value.y, destination, ref index);
				WriteHalf(0f - value.z, destination, ref index);
			}
			break;
		}
	}

	public static Vector3 ReadHalfVector3(byte[] source, ref int index)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		return new Vector3(ReadHalf(source, ref index), ReadHalf(source, ref index), ReadHalf(source, ref index));
	}

	public static Quaternion ReadHalfQuaternion(byte[] source, ref int index)
	{
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		byte b = ReadByte(source, ref index);
		float num = 0f;
		float num2 = 0f;
		float num3 = 0f;
		float num4 = 0f;
		switch (b)
		{
		case 0:
			num2 = ReadHalf(source, ref index);
			num3 = ReadHalf(source, ref index);
			num4 = ReadHalf(source, ref index);
			num = Mathf.Sqrt(1f - num2 * num2 - num3 * num3 - num4 * num4);
			break;
		case 1:
			num = ReadHalf(source, ref index);
			num3 = ReadHalf(source, ref index);
			num4 = ReadHalf(source, ref index);
			num2 = Mathf.Sqrt(1f - num * num - num3 * num3 - num4 * num4);
			break;
		case 2:
			num = ReadHalf(source, ref index);
			num2 = ReadHalf(source, ref index);
			num4 = ReadHalf(source, ref index);
			num3 = Mathf.Sqrt(1f - num * num - num2 * num2 - num4 * num4);
			break;
		case 3:
			num = ReadHalf(source, ref index);
			num2 = ReadHalf(source, ref index);
			num3 = ReadHalf(source, ref index);
			num4 = Mathf.Sqrt(1f - num * num - num2 * num2 - num3 * num3);
			break;
		}
		return new Quaternion(num, num2, num3, num4);
	}
}
namespace API
{
	internal static class APILogger
	{
		private static readonly ManualLogSource logger;

		static APILogger()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			logger = new ManualLogSource("Rand-API");
			Logger.Sources.Add((ILogSource)(object)logger);
		}

		private static string Format(string module, object msg)
		{
			return $"[{module}]: {msg}";
		}

		public static void Info(string module, object data)
		{
			logger.LogMessage((object)Format(module, data));
		}

		public static void Verbose(string module, object data)
		{
		}

		public static void Log(object data)
		{
			logger.LogDebug((object)Format("KillIndicatorFix", data));
		}

		public static void Debug(object data)
		{
			if (ConfigManager.Debug)
			{
				Log(data);
			}
		}

		public static void Warn(object data)
		{
			logger.LogWarning((object)Format("KillIndicatorFix", data));
		}

		public static void Error(object data)
		{
			logger.LogError((object)Format("KillIndicatorFix", data));
		}
	}
}
namespace KillIndicatorFix
{
	internal static class Utils
	{
		public const BindingFlags AnyBindingFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
	}
	public static class Kill
	{
		public static Action<EnemyAgent, ItemEquippable, long>? OnKillIndicator;

		private static void RegisterMethods(Type t)
		{
			foreach (MethodInfo item in from m in t.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
				where m.GetCustomAttribute<OnKillIndicator>() != null
				select m)
			{
				if (item.IsStatic)
				{
					try
					{
						string value = "OnKillIndicator";
						if (item.GetCustomAttribute<OnKillIndicator>() != null)
						{
							value = "OnKillIndicator";
							OnKillIndicator = (Action<EnemyAgent, ItemEquippable, long>)Delegate.Combine(OnKillIndicator, (Action<EnemyAgent, ItemEquippable, long>)item.CreateDelegate(typeof(Action<EnemyAgent, ItemEquippable, long>)));
						}
						APILogger.Debug($"Registered {value}: '{t.FullName}.{item.Name}'");
					}
					catch (Exception value2)
					{
						APILogger.Error($"Failed to register method: {value2}");
					}
				}
				else
				{
					APILogger.Error($"KillIndicatorFix attributes can only be applied to static methods. '{item}' is not static.");
				}
			}
		}

		public static void RegisterAll()
		{
			Type[] types = Assembly.GetCallingAssembly().GetTypes();
			for (int i = 0; i < types.Length; i++)
			{
				RegisterMethods(types[i]);
			}
		}

		public static void RegisterAll(Type type)
		{
			Type[] nestedTypes = type.GetNestedTypes(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (Type obj in nestedTypes)
			{
				RegisterMethods(obj);
				RegisterAll(obj);
			}
		}

		internal static void TriggerOnKillIndicator(EnemyAgent enemy, ItemEquippable item, long delay)
		{
			try
			{
				OnKillIndicator?.Invoke(enemy, item, delay);
			}
			catch (Exception value)
			{
				APILogger.Error($"TriggerOnKillIndicator: {value}");
			}
		}

		public static void TagEnemy(EnemyAgent enemy, ItemEquippable? item = null, Vector3? localHitPosition = null)
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			int instanceID = ((Object)enemy).GetInstanceID();
			long timestamp = ((DateTimeOffset)DateTime.Now).ToUnixTimeMilliseconds();
			if (!localHitPosition.HasValue)
			{
				localHitPosition = ((!KillIndicatorFix.Patches.Kill.taggedEnemies.ContainsKey(instanceID)) ? new Vector3?(((Agent)enemy).EyePosition - ((Component)enemy).transform.position) : new Vector3?(KillIndicatorFix.Patches.Kill.taggedEnemies[instanceID].localHitPosition));
			}
			if ((Object)(object)item == (Object)null)
			{
				item = PlayerManager.GetLocalPlayerAgent().Inventory.WieldedItem;
			}
			KillIndicatorFix.Patches.Kill.Tag value = new KillIndicatorFix.Patches.Kill.Tag(timestamp, localHitPosition.Value, item);
			if (KillIndicatorFix.Patches.Kill.taggedEnemies.ContainsKey(instanceID))
			{
				KillIndicatorFix.Patches.Kill.taggedEnemies[instanceID] = value;
			}
			else
			{
				KillIndicatorFix.Patches.Kill.taggedEnemies.Add(instanceID, value);
			}
		}
	}
	[AttributeUsage(AttributeTargets.Method)]
	public class OnKillIndicator : Attribute
	{
	}
}
namespace KillIndicatorFix.Patches
{
	[HarmonyPatch(typeof(GameDataInit))]
	internal class GameDataInit_Patches
	{
		[HarmonyPatch("Initialize")]
		[HarmonyWrapSafe]
		[HarmonyPostfix]
		public static void Initialize_Postfix()
		{
			Analytics.enabled = false;
		}
	}
	[HarmonyPatch]
	internal static class Kill
	{
		public struct Tag
		{
			public long timestamp;

			public Vector3 localHitPosition;

			public ItemEquippable item;

			public Tag(long timestamp, Vector3 localHitPosition, ItemEquippable item)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				this.timestamp = timestamp;
				this.localHitPosition = localHitPosition;
				this.item = item;
			}
		}

		public static Dictionary<int, Tag> taggedEnemies = new Dictionary<int, Tag>();

		internal static bool sentryShot = false;

		public static void OnRundownStart()
		{
			APILogger.Debug("OnRundownStart => Reset Trackers and Markers.");
			taggedEnemies.Clear();
		}

		[HarmonyPatch(typeof(EnemyBehaviour), "ChangeState", new Type[] { typeof(EB_States) })]
		[HarmonyPrefix]
		public static void OnDead(EnemyBehaviour __instance, EB_States state)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			if (SNet.IsMaster || __instance.m_currentStateName == state || (int)state != 19)
			{
				return;
			}
			APILogger.Debug("EnemyAppearance.OnDead");
			try
			{
				EnemyAgent enemyAgent = __instance.m_ai.m_enemyAgent;
				int instanceID = ((Object)enemyAgent).GetInstanceID();
				long num = ((DateTimeOffset)DateTime.Now).ToUnixTimeMilliseconds();
				if (!taggedEnemies.ContainsKey(instanceID))
				{
					return;
				}
				Tag tag = taggedEnemies[instanceID];
				if (tag.timestamp <= num)
				{
					APILogger.Debug($"Received kill update {num - tag.timestamp} milliseconds after tag.");
				}
				else
				{
					APILogger.Debug("Received kill update for enemy that was tagged in the future? Possibly long overflow...");
				}
				if (tag.timestamp <= num && num - tag.timestamp < ConfigManager.TagBufferPeriod)
				{
					if (!enemyAgent.Damage.DeathIndicatorShown)
					{
						APILogger.Debug("Client side marker was not shown, showing server side one.");
						KillIndicatorFix.Kill.TriggerOnKillIndicator(enemyAgent, tag.item, num - tag.timestamp);
						CrosshairGuiLayer crosshairLayer = GuiManager.CrosshairLayer;
						if (crosshairLayer != null)
						{
							crosshairLayer.ShowDeathIndicator(((Component)enemyAgent).transform.position + tag.localHitPosition);
						}
						enemyAgent.Damage.DeathIndicatorShown = true;
					}
					else
					{
						APILogger.Debug("Client side marker was shown, not showing server side one.");
					}
				}
				else
				{
					APILogger.Debug("Client was no longer interested in this enemy, marker will not be shown.");
				}
				taggedEnemies.Remove(instanceID);
			}
			catch
			{
				APILogger.Debug("Something went wrong.");
			}
		}

		[HarmonyPatch(typeof(SentryGunInstance_Firing_Bullets), "FireBullet")]
		[HarmonyPrefix]
		private static void Prefix_SentryGunFiringBullet(SentryGunInstance_Firing_Bullets __instance, bool doDamage, bool targetIsTagged)
		{
			if (doDamage)
			{
				sentryShot = true;
			}
		}

		[HarmonyPatch(typeof(SentryGunInstance_Firing_Bullets), "FireBullet")]
		[HarmonyPostfix]
		private static void Postfix_SentryGunFiringBullet()
		{
			sentryShot = false;
		}

		[HarmonyPatch(typeof(SentryGunInstance_Firing_Bullets), "UpdateFireShotgunSemi")]
		[HarmonyPrefix]
		private static void Prefix_ShotgunSentryFiring(SentryGunInstance_Firing_Bullets __instance, bool isMaster, bool targetIsTagged)
		{
			if (isMaster)
			{
				sentryShot = true;
			}
		}

		[HarmonyPatch(typeof(SentryGunInstance_Firing_Bullets), "UpdateFireShotgunSemi")]
		[HarmonyPostfix]
		private static void Postfix_ShotgunSentryFiring()
		{
			sentryShot = false;
		}

		[HarmonyPatch(typeof(Dam_EnemyDamageLimb), "BulletDamage")]
		[HarmonyPrefix]
		[HarmonyPriority(0)]
		public static void EnemyLimb_BulletDamage(Dam_EnemyDamageLimb __instance, float dam, Agent sourceAgent, Vector3 position, Vector3 direction, Vector3 normal, bool allowDirectionalBonus, float staggerMulti, float precisionMulti)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			if (!SNet.IsMaster || !sentryShot)
			{
				return;
			}
			PlayerAgent val = ((Il2CppObjectBase)sourceAgent).TryCast<PlayerAgent>();
			if ((Object)(object)val == (Object)null)
			{
				APILogger.Debug($"Could not find PlayerAgent, damage was done by agent of type: {sourceAgent.m_type}.");
			}
			else if (!val.Owner.IsBot && !sourceAgent.IsLocallyOwned)
			{
				Dam_EnemyDamageBase @base = __instance.m_base;
				EnemyAgent owner = @base.Owner;
				float num = dam;
				if (!@base.IsImortal)
				{
					num = __instance.ApplyWeakspotAndArmorModifiers(dam, precisionMulti);
					num = __instance.ApplyDamageFromBehindBonus(num, position, direction, 1f);
					bool willDie = ((Dam_SyncedDamageBase)@base).WillDamageKill(num);
					Network.SendHitIndicator((Agent)(object)owner, (byte)__instance.m_limbID, val, num > dam, willDie, position, __instance.m_armorDamageMulti < 1f);
				}
				else
				{
					Network.SendHitIndicator((Agent)(object)owner, (byte)__instance.m_limbID, val, num > dam, willDie: false, position, hitArmor: true);
				}
			}
		}

		[HarmonyPatch(typeof(Dam_PlayerDamageBase), "ReceiveBulletDamage")]
		[HarmonyPrefix]
		[HarmonyPriority(0)]
		public static void Player_BulletDamage(Dam_PlayerDamageBase __instance, pBulletDamageData data)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			Agent val = default(Agent);
			if (!SNet.IsMaster || !((pAgent)(ref data.source)).TryGet(ref val) || !sentryShot)
			{
				return;
			}
			PlayerAgent val2 = ((Il2CppObjectBase)val).TryCast<PlayerAgent>();
			if ((Object)(object)val2 == (Object)null)
			{
				APILogger.Debug($"Could not find PlayerAgent, damage was done by agent of type: {val.m_type}.");
			}
			else if (!val2.Owner.IsBot && !val.IsLocallyOwned)
			{
				PlayerAgent owner = __instance.Owner;
				if ((Object)(object)owner != (Object)(object)val2)
				{
					Network.SendHitIndicator((Agent)(object)owner, 0, val2, hitWeakspot: false, willDie: false, Vector3.zero);
				}
			}
		}

		[HarmonyPatch(typeof(Dam_EnemyDamageBase), "BulletDamage")]
		[HarmonyPrefix]
		[HarmonyPriority(0)]
		public static void BulletDamage(Dam_EnemyDamageBase __instance, float dam, Agent sourceAgent, Vector3 position, Vector3 direction, bool allowDirectionalBonus, int limbID, float precisionMulti)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: 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)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			if (SNet.IsMaster)
			{
				return;
			}
			PlayerAgent val = ((Il2CppObjectBase)sourceAgent).TryCast<PlayerAgent>();
			if ((Object)(object)val == (Object)null)
			{
				APILogger.Debug($"Could not find PlayerAgent, damage was done by agent of type: {sourceAgent.m_type}.");
			}
			else if (!val.Owner.IsBot)
			{
				EnemyAgent owner = __instance.Owner;
				int instanceID = ((Object)owner).GetInstanceID();
				long timestamp = ((DateTimeOffset)DateTime.Now).ToUnixTimeMilliseconds();
				float num = AgentModifierManager.ApplyModifier((Agent)(object)owner, (AgentModifier)7, Mathf.Clamp(dam, 0f, ((Dam_SyncedDamageBase)__instance).HealthMax));
				((Dam_SyncedDamageBase)__instance).Health = ((Dam_SyncedDamageBase)__instance).Health - num;
				Vector3 localHitPosition = position - ((Component)owner).transform.position;
				Tag value = new Tag(timestamp, localHitPosition, val.Inventory.WieldedItem);
				if (taggedEnemies.ContainsKey(instanceID))
				{
					taggedEnemies[instanceID] = value;
				}
				else
				{
					taggedEnemies.Add(instanceID, value);
				}
				APILogger.Debug($"{num} Bullet Damage done by {val.PlayerName}. IsBot: {val.Owner.IsBot}");
				APILogger.Debug($"Tracked current HP: {((Dam_SyncedDamageBase)__instance).Health}, [{((Object)owner).GetInstanceID()}]");
			}
		}

		[HarmonyPatch(typeof(Dam_EnemyDamageBase), "MeleeDamage")]
		[HarmonyPrefix]
		[HarmonyPriority(0)]
		public static void MeleeDamage(Dam_EnemyDamageBase __instance, float dam, Agent sourceAgent, Vector3 position, Vector3 direction, int limbID, float staggerMulti, float precisionMulti, float sleeperMulti, bool skipLimbDestruction, DamageNoiseLevel damageNoiseLevel)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			if (SNet.IsMaster)
			{
				return;
			}
			PlayerAgent val = ((Il2CppObjectBase)sourceAgent).TryCast<PlayerAgent>();
			if ((Object)(object)val == (Object)null)
			{
				APILogger.Debug($"Could not find PlayerAgent, damage was done by agent of type: {sourceAgent.m_type}.");
			}
			else if (!val.Owner.IsBot)
			{
				EnemyAgent owner = __instance.Owner;
				int instanceID = ((Object)owner).GetInstanceID();
				long timestamp = ((DateTimeOffset)DateTime.Now).ToUnixTimeMilliseconds();
				float num = AgentModifierManager.ApplyModifier((Agent)(object)owner, (AgentModifier)6, Mathf.Clamp(dam, 0f, ((Dam_SyncedDamageBase)__instance).DamageMax));
				if ((int)__instance.Owner.Locomotion.CurrentStateEnum == 14)
				{
					num *= sleeperMulti;
				}
				((Dam_SyncedDamageBase)__instance).Health = ((Dam_SyncedDamageBase)__instance).Health - num;
				Vector3 localHitPosition = position - ((Component)owner).transform.position;
				Tag value = new Tag(timestamp, localHitPosition, val.Inventory.WieldedItem);
				if (taggedEnemies.ContainsKey(instanceID))
				{
					taggedEnemies[instanceID] = value;
				}
				else
				{
					taggedEnemies.Add(instanceID, value);
				}
				APILogger.Debug($"Melee Damage: {num}");
				APILogger.Debug($"Tracked current HP: {((Dam_SyncedDamageBase)__instance).Health}, [{((Object)owner).GetInstanceID()}]");
			}
		}

		[HarmonyPatch(typeof(Dam_EnemyDamageLimb), "ShowHitIndicator")]
		[HarmonyPrefix]
		public static void ShowDeathIndicator(Dam_EnemyDamageLimb __instance, bool hitWeakspot, bool willDie, Vector3 position, bool hitArmor)
		{
			EnemyAgent owner = __instance.m_base.Owner;
			((Object)owner).GetInstanceID();
			((DateTimeOffset)DateTime.Now).ToUnixTimeMilliseconds();
			if (willDie && !__instance.m_base.DeathIndicatorShown)
			{
				PlayerAgent localPlayerAgent = PlayerManager.GetLocalPlayerAgent();
				ItemEquippable item = localPlayerAgent.Inventory.WieldedItem;
				BackpackItem val = default(BackpackItem);
				if (sentryShot && PlayerBackpackManager.TryGetItem(localPlayerAgent.Owner, (InventorySlot)3, ref val))
				{
					item = ((Il2CppObjectBase)val.Instance).Cast<ItemEquippable>();
				}
				KillIndicatorFix.Kill.TriggerOnKillIndicator(owner, item, 0L);
			}
		}
	}
	[HarmonyPatch]
	internal static class Network
	{
		private static byte msgtype = 173;

		private static uint magickey = 10992881u;

		private static ushort repKey = 65531;

		public static void SendHitIndicator(Agent target, byte limbID, PlayerAgent player, bool hitWeakspot, bool willDie, Vector3 position, bool hitArmor = false)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			if (SNet.IsMaster && !((Object)(object)player == (Object)(object)PlayerManager.GetLocalPlayerAgent()) && !player.Owner.IsBot)
			{
				SNet_ChannelType val = (SNet_ChannelType)0;
				SNet_SendGroup val2 = default(SNet_SendGroup);
				SNet_SendQuality val3 = default(SNet_SendQuality);
				int num = default(int);
				SNet.GetSendSettings(ref val, ref val2, ref val3, ref num);
				List<SNet_Player> val4 = new List<SNet_Player>(1);
				val4.Add(player.Owner);
				int index = 0;
				byte[] array = new byte[23];
				BitHelper.WriteBytes(repKey, array, ref index);
				BitHelper.WriteBytes(magickey, array, ref index);
				BitHelper.WriteBytes(msgtype, array, ref index);
				BitHelper.WriteBytes(12, array, ref index);
				BitHelper.WriteBytes((ushort)(target.m_replicator.Key + 1), array, ref index);
				BitHelper.WriteBytes(limbID, array, ref index);
				BitHelper.WriteBytes(hitWeakspot, array, ref index);
				BitHelper.WriteBytes(willDie, array, ref index);
				BitHelper.WriteHalf(position, array, ref index);
				BitHelper.WriteBytes(hitArmor, array, ref index);
				SNet.Core.SendBytes(Il2CppStructArray<byte>.op_Implicit(array), val3, num, val4);
				APILogger.Debug("Sent hit marker to " + player.PlayerName);
			}
		}

		[HarmonyPatch(typeof(SNet_Replication), "RecieveBytes")]
		[HarmonyWrapSafe]
		[HarmonyPrefix]
		private static bool RecieveBytes_Prefix(Il2CppStructArray<byte> bytes, uint size, ulong messagerID)
		{
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			if (size < 12)
			{
				return true;
			}
			ushort num = BitConverter.ToUInt16(Il2CppArrayBase<byte>.op_Implicit((Il2CppArrayBase<byte>)(object)bytes), 0);
			if (repKey == num)
			{
				if (BitConverter.ToUInt32(Il2CppArrayBase<byte>.op_Implicit((Il2CppArrayBase<byte>)(object)bytes), 2) != magickey)
				{
					APILogger.Debug("[Networking] Magic key is incorrect.");
					return true;
				}
				byte b = ((Il2CppArrayBase<byte>)(object)bytes)[6];
				if (b != msgtype)
				{
					APILogger.Debug($"[Networking] msg type is incorrect. {b} {msgtype}");
					return true;
				}
				int num2 = BitConverter.ToInt32(Il2CppArrayBase<byte>.op_Implicit((Il2CppArrayBase<byte>)(object)bytes), 7);
				byte[] array = new byte[num2];
				Array.Copy(Il2CppArrayBase<byte>.op_Implicit((Il2CppArrayBase<byte>)(object)bytes), 11, array, 0, num2);
				int index = 0;
				ushort keyPlusOne = BitHelper.ReadUShort(array, ref index);
				byte b2 = BitHelper.ReadByte(array, ref index);
				bool flag = BitHelper.ReadBool(array, ref index);
				bool flag2 = BitHelper.ReadBool(array, ref index);
				Vector3 val = BitHelper.ReadHalfVector3(array, ref index);
				bool flag3 = BitHelper.ReadBool(array, ref index);
				pReplicator pRep = default(pReplicator);
				pRep.keyPlusOne = keyPlusOne;
				pAgent val2 = default(pAgent);
				val2.pRep = pRep;
				Agent val3 = default(Agent);
				((pAgent)(ref val2)).TryGet(ref val3);
				EnemyAgent val4 = ((Il2CppObjectBase)val3).TryCast<EnemyAgent>();
				if ((Object)(object)val4 != (Object)null)
				{
					APILogger.Debug("Received hit indicator for enemy.");
					Dam_EnemyDamageLimb obj = ((Il2CppArrayBase<Dam_EnemyDamageLimb>)(object)val4.Damage.DamageLimbs)[(int)b2];
					Kill.sentryShot = true;
					obj.ShowHitIndicator(flag, flag2, val, flag3);
					Kill.sentryShot = false;
					return false;
				}
				if ((Object)(object)((Il2CppObjectBase)val3).TryCast<PlayerAgent>() != (Object)null)
				{
					APILogger.Debug("Received hit indicator for player.");
					GuiManager.CrosshairLayer.PopFriendlyTarget();
					return false;
				}
				APILogger.Debug("Received hit indicator packet but could not get player / enemy agent. This should not happen.");
				return false;
			}
			return true;
		}
	}
}
namespace KillIndicatorFix.BepInEx
{
	public static class ConfigManager
	{
		private static ConfigEntry<bool> debug;

		private static ConfigEntry<int> tagBufferPeriod;

		public static bool Debug => debug.Value;

		public static int TagBufferPeriod => tagBufferPeriod.Value;

		static ConfigManager()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			ConfigFile val = new ConfigFile(Path.Combine(Paths.ConfigPath, "KillIndicatorFix.cfg"), true);
			debug = val.Bind<bool>("Debug", "enable", false, "Enables debug messages when true.");
			tagBufferPeriod = val.Bind<int>("Settings", "TagBufferPeriod", 1000, "Indicates a lee-way period in milliseconds where a kill indicator will still be shown for a given enemy long after it has been tagged (shot at).");
		}
	}
	[BepInPlugin("randomuserhi.KillIndicatorFix", "KillIndicatorFix", "0.1.4")]
	internal class Entry : BasePlugin
	{
		private Harmony? harmony;

		public override void Load()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			APILogger.Debug("Loaded KillIndicatorFix 0.1.4");
			harmony = new Harmony("randomuserhi.KillIndicatorFix");
			harmony.PatchAll();
			APILogger.Debug("Debug is " + (ConfigManager.Debug ? "Enabled" : "Disabled"));
			RundownManager.OnExpeditionGameplayStarted += Action.op_Implicit((Action)KillIndicatorFix.Patches.Kill.OnRundownStart);
		}
	}
	public static class Module
	{
		public const string GUID = "randomuserhi.KillIndicatorFix";

		public const string Name = "KillIndicatorFix";

		public const string Version = "0.1.4";
	}
}

plugins/SURVIVAL/net6/LEGACY.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.ComponentModel.DataAnnotations;
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 System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using AIGraph;
using AK;
using Agents;
using AssetShards;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using BoosterImplants;
using CellMenu;
using ChainedPuzzles;
using EOSExt.Reactor.Managers;
using Enemies;
using ExtraObjectiveSetup;
using ExtraObjectiveSetup.BaseClasses;
using ExtraObjectiveSetup.Expedition.Gears;
using ExtraObjectiveSetup.ExtendedWardenEvents;
using ExtraObjectiveSetup.Instances;
using ExtraObjectiveSetup.Utils;
using FirstPersonItem;
using FloLib.Infos;
using FloLib.Networks.Replications;
using GTFO.API;
using GTFO.API.Utilities;
using GameData;
using Gear;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LEGACY.ExtraEvents;
using LEGACY.LegacyOverride;
using LEGACY.LegacyOverride.DummyVisual;
using LEGACY.LegacyOverride.DummyVisual.VisualGOAnimation;
using LEGACY.LegacyOverride.DummyVisual.VisualGOAnimation.AnimationConfig;
using LEGACY.LegacyOverride.DummyVisual.VisualSequenceType;
using LEGACY.LegacyOverride.ElevatorCargo;
using LEGACY.LegacyOverride.EnemyTagger;
using LEGACY.LegacyOverride.EventScan;
using LEGACY.LegacyOverride.ExpeditionIntelNotification;
using LEGACY.LegacyOverride.ExpeditionSuccessPage;
using LEGACY.LegacyOverride.FogBeacon;
using LEGACY.LegacyOverride.ForceFail;
using LEGACY.LegacyOverride.Music;
using LEGACY.LegacyOverride.ResourceStations;
using LEGACY.LegacyOverride.ThermalSightAdjustment;
using LEGACY.Utils;
using LEGACY.VanillaFix;
using LevelGeneration;
using Localization;
using MTFO.API;
using Microsoft.CodeAnalysis;
using Player;
using SNetwork;
using ScanPosOverride.JSON;
using ScanPosOverride.Managers;
using StateMachines;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("LEGACY")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LEGACY")]
[assembly: AssemblyTitle("LEGACY")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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;
		}
	}
}
[HarmonyPatch(typeof(PUI_Watermark), "UpdateWatermark")]
internal static class Patch_WatermarkUpdateWatermark
{
	private static void Postfix(PUI_Watermark __instance)
	{
		string value = "4.6.1+gitf831086-dirty-main".Remove("x.x.x".Length);
		((TMP_Text)__instance.m_watermarkText).SetText($"<color=red>MODDED</color> <color=orange>{value}</color>\n<color=#00ae9d>LEGACY</color> <color=orange>{"4.2.4"} STANDALONE</color>", true);
	}
}
namespace LEGACY
{
	internal static class Assets
	{
		public static GameObject CircleSensor { get; private set; }

		public static GameObject MovableSensor { get; private set; }

		public static GameObject OBSVisual { get; private set; }

		public static GameObject ObjectiveMarker { get; private set; }

		public static GameObject EventScan { get; private set; }

		internal static GameObject DummyScan { get; private set; }

		internal static GameObject DummySensor { get; private set; }

		internal static GameObject AmmoStation { get; private set; }

		internal static GameObject MediStation { get; private set; }

		internal static GameObject ToolStation { get; private set; }

		public static void Init()
		{
			CircleSensor = AssetAPI.GetLoadedAsset<GameObject>("Assets/SecuritySensor/CircleSensor.prefab");
			MovableSensor = AssetAPI.GetLoadedAsset<GameObject>("Assets/SecuritySensor/MovableSensor.prefab");
			OBSVisual = AssetAPI.GetLoadedAsset<GameObject>("Assets/SecuritySensor/OBSVisual.prefab");
			ObjectiveMarker = AssetAPI.GetLoadedAsset<GameObject>("Assets/SecuritySensor/ObjectiveMarker.prefab");
			EventScan = AssetAPI.GetLoadedAsset<GameObject>("Assets/EventObjects/EventScan.prefab");
			DummyScan = AssetAPI.GetLoadedAsset<GameObject>("Assets/DummyVisual/DummyScan.prefab");
			DummySensor = AssetAPI.GetLoadedAsset<GameObject>("Assets/DummyVisual/DummySensor.prefab");
			AmmoStation = AssetAPI.GetLoadedAsset<GameObject>("Assets/Misc/AmmoStation.prefab");
			MediStation = AssetAPI.GetLoadedAsset<GameObject>("Assets/Misc/MediStation.prefab");
			ToolStation = AssetAPI.GetLoadedAsset<GameObject>("Assets/Misc/ToolStation.prefab");
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInIncompatibility("GTFO.AWO")]
	[BepInPlugin("Inas.LEGACY", "LEGACY", "4.2.4")]
	public class EntryPoint : BasePlugin
	{
		public const string AUTHOR = "Inas";

		public const string RUNDOWN_NAME = "LEGACY";

		public const string VERSION = "4.2.4";

		public const bool TESTING = false;

		public const string TEST_STRING = "TESTING";

		private Harmony m_Harmony;

		public override void Load()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			m_Harmony = new Harmony("LEGACY");
			m_Harmony.PatchAll();
			LegacyOverrideManagers.Init();
			LegacyExtraEvents.Init();
			LEGACY.VanillaFix.Debugger.Current.Init();
			AssetAPI.OnAssetBundlesLoaded += Assets.Init;
			EventAPI.OnManagersSetup += delegate
			{
				AssetShardManager.OnStartupAssetsLoaded += Action.op_Implicit((Action)MainMenuGuiLayer.Current.PageRundownNew.SetupCustomTutorialButton);
			};
		}
	}
}
namespace LEGACY.Reactor
{
	[HarmonyPatch]
	internal class Patch_ReactorShutdown
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(LG_WardenObjective_Reactor), "OnStateChange")]
		private static void Post_OnStateChange(LG_WardenObjective_Reactor __instance, pReactorState oldState, pReactorState newState)
		{
			//IL_000a: 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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Invalid comparison between Unknown and I4
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected I4, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null || oldState.status == newState.status)
			{
				return;
			}
			WardenObjectiveDataBlock val = null;
			if (!WardenObjectiveManager.Current.TryGetActiveWardenObjectiveData(__instance.SpawnNode.LayerType, ref val) || val == null)
			{
				LegacyLogger.Error("Patch_ReactorShutdown: ");
				LegacyLogger.Error("Failed to get warden objective");
			}
			else if ((int)val.Type == 2 && !val.OnActivateOnSolveItem)
			{
				eWardenObjectiveEventTrigger val2 = (eWardenObjectiveEventTrigger)0;
				eReactorStatus status = newState.status;
				switch (status - 7)
				{
				default:
					return;
				case 0:
					val2 = (eWardenObjectiveEventTrigger)1;
					break;
				case 1:
					val2 = (eWardenObjectiveEventTrigger)2;
					break;
				case 2:
					val2 = (eWardenObjectiveEventTrigger)3;
					break;
				}
				_ = __instance.SpawnNode.LayerType;
				WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(val.EventsOnActivate, val2, false, 0f, (Il2CppStructArray<eWardenObjectiveEventType>)null);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(LG_WardenObjective_Reactor), "OnBuildDone")]
		private static void Pre_OnBuildDone_ChainedPuzzleMidObjectiveFix(LG_WardenObjective_Reactor __instance)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			WardenObjectiveDataBlock val = null;
			if (!WardenObjectiveManager.Current.TryGetActiveWardenObjectiveData(__instance.SpawnNode.LayerType, ref val) || val == null)
			{
				LegacyLogger.Error("Patch_ReactorShutdown: Failed to get warden objective");
			}
			else if (val.ChainedPuzzleMidObjective != 0)
			{
				__instance.m_chainedPuzzleAlignMidObjective = __instance.m_chainedPuzzleAlign;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(LG_WardenObjective_Reactor), "Update")]
		private static bool Pre_Update(LG_WardenObjective_Reactor __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Invalid comparison between Unknown and I4
			if ((int)__instance.m_currentState.status != 7)
			{
				return true;
			}
			if (!__instance.m_currentWaveData.HasVerificationTerminal)
			{
				return true;
			}
			__instance.SetGUIMessage(true, Text.Format(3000u, (Object[])(object)new Object[1] { Object.op_Implicit("<color=orange>" + __instance.m_currentWaveData.VerificationTerminalSerial + "</color>") }), (ePUIMessageStyle)3, false, "", "");
			return false;
		}
	}
	[HarmonyPatch]
	internal class Patch_ReactorStartup_ExtraEventsExecution
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(LG_WardenObjective_Reactor), "OnStateChange")]
		private static void Post_ExecuteOnNoneEventsOnDefenseStart(LG_WardenObjective_Reactor __instance, pReactorState oldState, pReactorState newState)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			if (oldState.status != newState.status && (int)newState.status == 3)
			{
				WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(__instance.m_currentWaveData.Events, (eWardenObjectiveEventTrigger)0, false, 0f, (Il2CppStructArray<eWardenObjectiveEventType>)null);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(LG_WardenObjective_Reactor), "OnBuildDone")]
		private static void Post_OnBuildDone(LG_WardenObjective_Reactor __instance)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Invalid comparison between Unknown and I4
			WardenObjectiveDataBlock db = default(WardenObjectiveDataBlock);
			if (!WardenObjectiveManager.Current.TryGetActiveWardenObjectiveData(__instance.SpawnNode.LayerType, ref db) || db == null)
			{
				LegacyLogger.Error("Patch_ReactorStartup_ExtraEventsExecution: ");
				LegacyLogger.Error("Failed to get warden objective");
			}
			else if ((int)db.Type == 1 && !db.OnActivateOnSolveItem)
			{
				ChainedPuzzleInstance chainedPuzzleToStartSequence = __instance.m_chainedPuzzleToStartSequence;
				chainedPuzzleToStartSequence.OnPuzzleSolved += Action.op_Implicit((Action)delegate
				{
					WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(db.EventsOnActivate, (eWardenObjectiveEventTrigger)0, true, 0f, (Il2CppStructArray<eWardenObjectiveEventType>)null);
				});
			}
		}
	}
	[HarmonyPatch]
	internal class Patch_ReactorStartup_OverwriteGUIBehaviour
	{
		private static HashSet<uint> ForceDisableLevels;

		[HarmonyPrefix]
		[HarmonyPatch(typeof(LG_WardenObjective_Reactor), "OnStateChange")]
		private static bool Pre_HideReactorMessageForInfiniteWave(LG_WardenObjective_Reactor __instance, pReactorState oldState, pReactorState newState)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Invalid comparison between Unknown and I4
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Invalid comparison between Unknown and I4
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected I4, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			if (oldState.status == newState.status)
			{
				return true;
			}
			if ((int)newState.status != 2 && (int)newState.status != 3 && (int)newState.status != 4)
			{
				return true;
			}
			if (ForceDisable())
			{
				if (oldState.stateCount != newState.stateCount)
				{
					__instance.OnStateCountUpdate(newState.stateCount);
				}
				if (oldState.stateProgress != newState.stateProgress)
				{
					__instance.OnStateProgressUpdate(newState.stateProgress);
				}
				__instance.ReadyForVerification = false;
				eReactorStatus status = newState.status;
				switch (status - 2)
				{
				case 0:
				{
					WardenObjectiveDataBlock val = null;
					if (!WardenObjectiveManager.Current.TryGetActiveWardenObjectiveData(__instance.SpawnNode.LayerType, ref val) || val == null)
					{
						LegacyLogger.Error("Patch_ReactorStartup_OverwriteGUIBehaviour: ");
						LegacyLogger.Error("Failed to get warden objective datablock");
						break;
					}
					__instance.m_lightCollection.SetMode(val.LightsOnDuringIntro);
					__instance.m_lightCollection.ResetUpdateValues(true);
					__instance.lcReset = true;
					__instance.m_lightsBlinking = false;
					__instance.m_spawnEnemies = false;
					__instance.m_progressUpdateEnabled = true;
					__instance.m_alarmCountdownPlayed = false;
					__instance.m_currentDuration = ((!newState.verifyFailed) ? __instance.m_currentWaveData.Warmup : __instance.m_currentWaveData.WarmupFail);
					WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(__instance.m_currentWaveData.Events, (eWardenObjectiveEventTrigger)1, false, 0f, (Il2CppStructArray<eWardenObjectiveEventType>)null);
					if (__instance.m_currentWaveCount == 1)
					{
						Debug.LogError(Object.op_Implicit("Reactor IDLE START"));
						__instance.m_sound.Post(EVENTS.REACTOR_POWER_LEVEL_1_LOOP, true);
						__instance.m_sound.SetRTPCValue(GAME_PARAMETERS.REACTOR_POWER, 0f);
					}
					else
					{
						Debug.LogError(Object.op_Implicit("Reactor REACTOR_POWER_DOWN"));
						__instance.m_sound.Post(EVENTS.REACTOR_POWER_LEVEL_2_TO_1_TRANSITION, true);
						__instance.m_sound.SetRTPCValue(GAME_PARAMETERS.REACTOR_POWER, 0f);
					}
					break;
				}
				case 1:
					__instance.m_lightCollection.ResetUpdateValues(true);
					__instance.lcReset = true;
					__instance.m_spawnEnemies = true;
					__instance.m_currentEnemyWaveIndex = 0;
					__instance.m_alarmCountdownPlayed = false;
					__instance.m_progressUpdateEnabled = true;
					__instance.m_currentDuration = __instance.m_currentWaveData.Wave;
					__instance.m_sound.Post(EVENTS.REACTOR_POWER_LEVEL_1_TO_3_TRANSITION, true);
					break;
				case 2:
					__instance.m_lightCollection.ResetUpdateValues(false);
					__instance.lcReset = true;
					__instance.m_spawnEnemies = false;
					__instance.m_progressUpdateEnabled = true;
					__instance.ReadyForVerification = true;
					Debug.Log(Object.op_Implicit("Wait for verify! newState.verifyFailed? " + newState.verifyFailed));
					__instance.m_currentDuration = ((!newState.verifyFailed) ? __instance.m_currentWaveData.Verify : __instance.m_currentWaveData.VerifyFail);
					WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(__instance.m_currentWaveData.Events, (eWardenObjectiveEventTrigger)2, false, 0f, (Il2CppStructArray<eWardenObjectiveEventType>)null);
					break;
				}
				__instance.m_currentState = newState;
				return false;
			}
			return true;
		}

		private static bool ForceDisable()
		{
			return ForceDisableLevels.Contains(RundownManager.ActiveExpedition.LevelLayoutData);
		}

		static Patch_ReactorStartup_OverwriteGUIBehaviour()
		{
			ForceDisableLevels = new HashSet<uint>();
			LevelLayoutDataBlock block = GameDataBlockBase<LevelLayoutDataBlock>.GetBlock("Legacy_L3E2_L1");
			if (block != null)
			{
				ForceDisableLevels.Add(((GameDataBlockBase<LevelLayoutDataBlock>)(object)block).persistentID);
			}
			block = GameDataBlockBase<LevelLayoutDataBlock>.GetBlock("Legacy_L1E1_L1");
			if (block != null)
			{
				ForceDisableLevels.Add(((GameDataBlockBase<LevelLayoutDataBlock>)(object)block).persistentID);
			}
		}
	}
}
namespace LEGACY.HardcodedBehaviours
{
	[HarmonyPatch]
	internal class Patch_PickupItem_Hardcoded
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(LG_Distribute_PickupItemsPerZone), "Build")]
		private static void Pre_LG_Distribute_PickupItemsPerZone(LG_Distribute_PickupItemsPerZone __instance)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Invalid comparison between Unknown and I4
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Invalid comparison between Unknown and I4
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Invalid comparison between Unknown and I4
			LevelLayoutDataBlock block = GameDataBlockBase<LevelLayoutDataBlock>.GetBlock("LAYOUT_O4_1_L1");
			if (block == null || RundownManager.ActiveExpedition.LevelLayoutData != ((GameDataBlockBase<LevelLayoutDataBlock>)(object)block).persistentID)
			{
				return;
			}
			eLocalZoneIndex localIndex = __instance.m_zone.LocalIndex;
			if ((int)localIndex != 1)
			{
				if ((int)localIndex == 5)
				{
					__instance.m_zonePlacementWeights.Start = 0f;
					__instance.m_zonePlacementWeights.Middle = 0f;
					__instance.m_zonePlacementWeights.End = 100000f;
				}
			}
			else if ((int)__instance.m_pickupType == 1)
			{
				__instance.m_zonePlacementWeights.Start = 100000f;
				__instance.m_zonePlacementWeights.Middle = 0f;
				__instance.m_zonePlacementWeights.End = 0f;
			}
		}
	}
}
namespace LEGACY.VanillaFix
{
	[HarmonyPatch]
	internal class Patch_FixScoutFreeze
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(ES_ScoutScream), "CommonUpdate")]
		private static bool Prefix_Debug(ES_ScoutScream __instance)
		{
			if (((AgentAI)((ES_Base)__instance).m_ai).Target == null)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch]
	internal class Patch_LG_SecurityDoor_Fix_EventsOnUnlockDoor_Powergenerator
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(LG_SecurityDoor), "OnSyncDoorStatusChange")]
		private static void Pre_OnSyncDoorStatusChange(LG_SecurityDoor __instance, pDoorState state, bool isRecall)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Invalid comparison between Unknown and I4
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			eDoorStatus status = state.status;
			if ((status - 4 <= 1 || (int)status == 9) && (int)__instance.m_lastState.status == 6 && !isRecall)
			{
				WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(__instance.LinkedToZoneData.EventsOnUnlockDoor, (eWardenObjectiveEventTrigger)0, true, 0f, (Il2CppStructArray<eWardenObjectiveEventType>)null);
			}
		}
	}
	[HarmonyPatch]
	internal class Patch_LockSecurityDoor_FixCustomText
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(LG_SecurityDoor_Locks), "Setup", new Type[] { typeof(LG_SecurityDoor) })]
		private static void Post_LG_SecurityDoor_Locks_Setup(LG_SecurityDoor door, LG_SecurityDoor_Locks __instance)
		{
			LocalizedText customText = door.LinkedToZoneData.ProgressionPuzzleToEnter.CustomText;
			__instance.m_lockedWithNoKeyInteractionText = customText;
		}
	}
	[HarmonyPatch]
	internal class Debugger
	{
		public static Debugger Current { get; private set; } = new Debugger();


		public bool DEBUGGING { get; private set; }

		private Debugger()
		{
		}

		internal void Init()
		{
			_ = DEBUGGING;
		}
	}
}
namespace LEGACY.Utils
{
	public delegate float EasingFunction(float t, float b, float c, float d);
	public delegate bool BoolCheck();
	internal static class CoroutineEase
	{
		private static IEnumerator DoEaseLocalScale(Transform trans, Vector3 startScale, Vector3 targetScale, float startTime, float duration, EasingFunction ease, Action onDone, BoolCheck checkAbort)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			bool doAbort = false;
			while (Clock.Time < startTime + duration && !doAbort)
			{
				doAbort = checkAbort?.Invoke() ?? false;
				float num = ease(Clock.Time - startTime, 0f, 1f, duration);
				trans.localScale = Vector3.Lerp(startScale, targetScale, num);
				yield return null;
			}
			trans.localScale = targetScale;
			if (!doAbort)
			{
				onDone?.Invoke();
			}
		}

		private static IEnumerator DoEaseLocalPos(Transform trans, Vector3 sourcePos, Vector3 targetPos, float startTime, float duration, EasingFunction ease, Action onDone, BoolCheck checkAbort)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			bool doAbort = false;
			while (Clock.Time < startTime + duration && !doAbort)
			{
				doAbort = checkAbort?.Invoke() ?? false;
				float num = ease(Clock.Time - startTime, 0f, 1f, duration);
				trans.localPosition = Vector3.Lerp(sourcePos, targetPos, num);
				yield return null;
			}
			trans.localPosition = targetPos;
			if (!doAbort)
			{
				onDone?.Invoke();
			}
		}

		private static IEnumerator DoEaseLocalRot(Transform trans, Vector3 sourceEuler, Vector3 targetEuler, float startTime, float duration, EasingFunction ease, Action onDone, BoolCheck checkAbort)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			bool doAbort = false;
			while (Clock.Time < startTime + duration && !doAbort)
			{
				doAbort = checkAbort?.Invoke() ?? false;
				float num = ease(Clock.Time - startTime, 0f, 1f, duration);
				trans.localEulerAngles = Vector3.Lerp(sourceEuler, targetEuler, num);
				yield return null;
			}
			trans.localEulerAngles = targetEuler;
			if (!doAbort)
			{
				onDone?.Invoke();
			}
		}

		internal static Coroutine EaseLocalScale(Transform trans, Vector3 startScale, Vector3 targetScale, float duration, EasingFunction ease = null, Action onDone = null, BoolCheck checkAbort = null)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			EasingFunction ease2 = ease ?? new EasingFunction(Easing.EaseOutExpo);
			return CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(DoEaseLocalScale(trans, startScale, targetScale, Clock.Time, duration, ease2, onDone, checkAbort)), (Action)null);
		}

		internal static Coroutine EaseLocalPos(Transform trans, Vector3 sourcePos, Vector3 targetPos, float duration, EasingFunction ease = null, Action onDone = null, BoolCheck checkAbort = null)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			EasingFunction ease2 = ease ?? new EasingFunction(Easing.EaseOutExpo);
			return CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(DoEaseLocalPos(trans, sourcePos, targetPos, Clock.Time, duration, ease2, onDone, checkAbort)), (Action)null);
		}

		internal static Coroutine EaseLocalRot(Transform trans, Vector3 sourceEuler, Vector3 targetEuler, float duration, EasingFunction ease = null, Action onDone = null, BoolCheck checkAbort = null)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			EasingFunction ease2 = ease ?? new EasingFunction(Easing.EaseOutExpo);
			return CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(DoEaseLocalRot(trans, sourceEuler, targetEuler, Clock.Time, duration, ease2, onDone, checkAbort)), (Action)null);
		}
	}
	public static class Helper
	{
		private static void ResetChild(iChainedPuzzleCore ICore)
		{
			CP_Bioscan_Core val = ((Il2CppObjectBase)ICore).TryCast<CP_Bioscan_Core>();
			if ((Object)(object)val != (Object)null)
			{
				((Il2CppObjectBase)val.m_spline).Cast<CP_Holopath_Spline>();
				((Il2CppObjectBase)val.PlayerScanner).Cast<CP_PlayerScanner>().ResetScanProgression(0f);
				val.Deactivate();
				return;
			}
			CP_Cluster_Core val2 = ((Il2CppObjectBase)ICore).TryCast<CP_Cluster_Core>();
			if ((Object)(object)val2 == (Object)null)
			{
				LegacyLogger.Error("ResetChild: found iChainedPuzzleCore that is neither CP_Bioscan_Core nor CP_Cluster_Core...");
				return;
			}
			((Il2CppObjectBase)val2.m_spline).Cast<CP_Holopath_Spline>();
			foreach (iChainedPuzzleCore item in (Il2CppArrayBase<iChainedPuzzleCore>)(object)val2.m_childCores)
			{
				ResetChild(item);
			}
			val2.Deactivate();
		}

		public static void ResetChainedPuzzle(ChainedPuzzleInstance chainedPuzzleInstance)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			if (chainedPuzzleInstance.Data.DisableSurvivalWaveOnComplete)
			{
				chainedPuzzleInstance.m_sound = new CellSoundPlayer(chainedPuzzleInstance.m_parent.position);
			}
			foreach (iChainedPuzzleCore item in (Il2CppArrayBase<iChainedPuzzleCore>)(object)chainedPuzzleInstance.m_chainedPuzzleCores)
			{
				ResetChild(item);
			}
			if (SNet.IsMaster)
			{
				pChainedPuzzleState state = chainedPuzzleInstance.m_stateReplicator.State;
				pChainedPuzzleState val = default(pChainedPuzzleState);
				val.status = (eChainedPuzzleStatus)0;
				val.currentSurvivalWave_EventID = state.currentSurvivalWave_EventID;
				val.isSolved = false;
				val.isActive = false;
				pChainedPuzzleState val2 = val;
				chainedPuzzleInstance.m_stateReplicator.InteractWithState(val2, new pChainedPuzzleInteraction
				{
					type = (eChainedPuzzleInteraction)2
				});
			}
		}

		public static List<T> ToManagedList<T>(this List<T> il2cppList)
		{
			List<T> list = new List<T>();
			Enumerator<T> enumerator = il2cppList.GetEnumerator();
			while (enumerator.MoveNext())
			{
				T current = enumerator.Current;
				list.Add(current);
			}
			return list;
		}

		public static bool TryGetComponent<T>(this GameObject obj, out T comp)
		{
			comp = obj.GetComponent<T>();
			return comp != null;
		}

		public static bool IsPlayerInLevel(PlayerAgent player)
		{
			//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_0012: Invalid comparison between Unknown and I4
			return (int)player.Owner.Load<pGameState>().gameState == 10;
		}

		public static ChainedPuzzleInstance GetChainedPuzzleForCommandOnTerminal(LG_ComputerTerminal terminal, string command)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected I4, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Invalid comparison between Unknown and I4
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Invalid comparison between Unknown and I4
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Invalid comparison between Unknown and I4
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Invalid comparison between Unknown and I4
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Invalid comparison between Unknown and I4
			uint num = 0u;
			if (terminal.SpawnNode.m_dimension.IsMainDimension)
			{
				LG_LayerType layerType = terminal.SpawnNode.LayerType;
				switch ((int)layerType)
				{
				case 0:
					num = RundownManager.ActiveExpedition.LevelLayoutData;
					break;
				case 1:
					num = RundownManager.ActiveExpedition.SecondaryLayout;
					break;
				case 2:
					num = RundownManager.ActiveExpedition.ThirdLayout;
					break;
				default:
					LegacyLogger.Error("Unimplemented layer type.");
					return null;
				}
			}
			else
			{
				num = terminal.SpawnNode.m_dimension.DimensionData.LevelLayoutData;
			}
			LevelLayoutDataBlock block = GameDataBlockBase<LevelLayoutDataBlock>.GetBlock(num);
			List<CustomTerminalCommand> val = null;
			List<LG_ComputerTerminal> terminalsSpawnedInZone = terminal.SpawnNode.m_zone.TerminalsSpawnedInZone;
			int num2 = terminalsSpawnedInZone.IndexOf(terminal);
			ExpeditionZoneData val2 = null;
			Enumerator<ExpeditionZoneData> enumerator = block.Zones.GetEnumerator();
			while (enumerator.MoveNext())
			{
				ExpeditionZoneData current = enumerator.Current;
				if (current.LocalIndex == terminal.SpawnNode.m_zone.LocalIndex)
				{
					val2 = current;
					break;
				}
			}
			if (val2 == null)
			{
				LegacyLogger.Error("Cannot find target zone data.");
				return null;
			}
			if (val2.TerminalPlacements.Count != terminalsSpawnedInZone.Count)
			{
				LegacyLogger.Error("The numbers of terminal placement and spawn, skipped for the zone terminal.");
				return null;
			}
			val = val2.TerminalPlacements[num2].UniqueCommands;
			if (val.Count == 0)
			{
				return null;
			}
			List<WardenObjectiveEventData> val3 = null;
			TERM_Command val4 = (TERM_Command)0;
			Enumerator<CustomTerminalCommand> enumerator2 = val.GetEnumerator();
			string text = default(string);
			string text2 = default(string);
			while (enumerator2.MoveNext())
			{
				CustomTerminalCommand current2 = enumerator2.Current;
				if (current2.Command == command)
				{
					val3 = current2.CommandEvents;
					if (!terminal.m_command.TryGetCommand(current2.Command, ref val4, ref text, ref text2))
					{
						LegacyLogger.Error("Cannot get TERM_COMMAND for command {0} on the specified terminal.");
					}
					break;
				}
			}
			if (val3 == null || (int)val4 == 0)
			{
				return null;
			}
			if ((int)val4 != 38 && (int)val4 != 39 && (int)val4 != 40 && (int)val4 != 41 && (int)val4 != 42)
			{
				return null;
			}
			ChainedPuzzleInstance val5 = null;
			for (int i = 0; i < val3.Count && (val3[i].ChainPuzzle == 0 || !terminal.TryGetChainPuzzleForCommand(val4, i, ref val5) || !((Object)(object)val5 != (Object)null)); i++)
			{
			}
			return val5;
		}

		public static bool TryGetZoneEntranceSecDoor(LG_Zone zone, out LG_SecurityDoor door)
		{
			if ((Object)(object)zone == (Object)null)
			{
				door = null;
				return false;
			}
			if ((Object)(object)zone.m_sourceGate == (Object)null)
			{
				door = null;
				return false;
			}
			if (zone.m_sourceGate.SpawnedDoor == null)
			{
				door = null;
				return false;
			}
			door = ((Il2CppObjectBase)zone.m_sourceGate.SpawnedDoor).TryCast<LG_SecurityDoor>();
			return (Object)(object)door != (Object)null;
		}

		internal static bool isSecDoorToZoneOpened(LG_Zone zone14)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Invalid comparison between Unknown and I4
			LG_SecurityDoor door = null;
			if (!TryGetZoneEntranceSecDoor(zone14, out door) || (Object)(object)door == (Object)null)
			{
				return false;
			}
			return (int)door.m_sync.GetCurrentSyncState().status == 10;
		}

		public static List<T> cast<T>(List<T> list)
		{
			List<T> list2 = new List<T>();
			Enumerator<T> enumerator = list.GetEnumerator();
			while (enumerator.MoveNext())
			{
				T current = enumerator.Current;
				list2.Add(current);
			}
			return list2;
		}

		private static eDimensionIndex GetCurrentDimensionIndex()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if (PlayerManager.PlayerAgentsInLevel.Count <= 0)
			{
				throw new Exception("? You don't have any player agent in level? How could that happen?");
			}
			return ((Agent)PlayerManager.PlayerAgentsInLevel[0]).DimensionIndex;
		}

		public static void GetMinLayerAndLocalIndex(out LG_LayerType MinLayer, out eLocalZoneIndex MinLocalIndex)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between I4 and Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between I4 and Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected I4, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected I4, but got Unknown
			MinLayer = (LG_LayerType)2;
			MinLocalIndex = (eLocalZoneIndex)20;
			Enumerator<PlayerAgent> enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator();
			while (enumerator.MoveNext())
			{
				PlayerAgent current = enumerator.Current;
				if (IsPlayerInLevel(current))
				{
					if ((int)MinLayer > (int)current.m_courseNode.LayerType)
					{
						MinLayer = (LG_LayerType)(int)current.m_courseNode.LayerType;
						MinLocalIndex = (eLocalZoneIndex)20;
					}
					if ((int)MinLocalIndex >= (int)current.m_courseNode.m_zone.LocalIndex)
					{
						MinLocalIndex = (eLocalZoneIndex)(int)current.m_courseNode.m_zone.LocalIndex;
					}
				}
			}
		}

		public static void GetMaxLayerAndLocalIndex(out LG_LayerType MaxLayer, out eLocalZoneIndex MaxLocalIndex)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Invalid comparison between I4 and Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Invalid comparison between I4 and Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected I4, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected I4, but got Unknown
			MaxLayer = (LG_LayerType)0;
			MaxLocalIndex = (eLocalZoneIndex)0;
			Enumerator<PlayerAgent> enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator();
			while (enumerator.MoveNext())
			{
				PlayerAgent current = enumerator.Current;
				if (IsPlayerInLevel(current))
				{
					if ((int)MaxLayer < (int)current.m_courseNode.LayerType)
					{
						MaxLayer = (LG_LayerType)(int)current.m_courseNode.LayerType;
						MaxLocalIndex = (eLocalZoneIndex)0;
					}
					if ((int)MaxLocalIndex < (int)current.m_courseNode.m_zone.LocalIndex)
					{
						MaxLocalIndex = (eLocalZoneIndex)(int)current.m_courseNode.m_zone.LocalIndex;
					}
				}
			}
		}

		public static int GetMinAreaIndex(LG_Zone zone)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)zone == (Object)null)
			{
				return -1;
			}
			LG_LayerType type = zone.m_layer.m_type;
			eLocalZoneIndex localIndex = zone.LocalIndex;
			GetCurrentDimensionIndex();
			int num = zone.m_areas.Count;
			Enumerator<PlayerAgent> enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator();
			while (enumerator.MoveNext())
			{
				PlayerAgent current = enumerator.Current;
				if (current.m_courseNode.LayerType != type || current.m_courseNode.m_zone.LocalIndex != localIndex)
				{
					continue;
				}
				int i = 0;
				for (List<LG_Area> areas = zone.m_areas; i < areas.Count; i++)
				{
					if (((Object)((Component)areas[i]).gameObject).GetInstanceID() == ((Object)((Component)current.m_courseNode.m_area).gameObject).GetInstanceID())
					{
						if (num > i)
						{
							num = i;
						}
						break;
					}
				}
			}
			return num;
		}

		public static LG_ComputerTerminal FindTerminal(eDimensionIndex dimensionIndex, LG_LayerType layerType, eLocalZoneIndex localIndex, int terminalIndex)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			LG_Zone val = null;
			if (!Builder.CurrentFloor.TryGetZoneByLocalIndex(dimensionIndex, layerType, localIndex, ref val) || (Object)(object)val == (Object)null)
			{
				LegacyLogger.Error($"FindTerminal: Didn't find LG_Zone {dimensionIndex}, {layerType}, {localIndex}");
				return null;
			}
			if (val.TerminalsSpawnedInZone == null || terminalIndex >= val.TerminalsSpawnedInZone.Count)
			{
				LegacyLogger.Error($"FindTerminal: Invalid terminal index {terminalIndex} - {((val.TerminalsSpawnedInZone != null) ? val.TerminalsSpawnedInZone.Count : 0)} terminals are spawned in {dimensionIndex}, {layerType}, {localIndex}");
				return null;
			}
			if (terminalIndex >= 0)
			{
				return val.TerminalsSpawnedInZone[terminalIndex];
			}
			return null;
		}

		public static AIG_NodeCluster GetNodeFromDimensionPosition(eDimensionIndex dimensionIndex, Vector3 position)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			AIG_GeomorphNodeVolume val = default(AIG_GeomorphNodeVolume);
			AIG_VoxelNodePillar val2 = default(AIG_VoxelNodePillar);
			AIG_INode val3 = default(AIG_INode);
			AIG_NodeCluster result = default(AIG_NodeCluster);
			if (!AIG_GeomorphNodeVolume.TryGetGeomorphVolume(0, dimensionIndex, position, ref val) || !((AIG_NodeVolume)val).m_voxelNodeVolume.TryGetPillar(position, ref val2) || !val2.TryGetVoxelNode(position.y, ref val3) || !AIG_NodeCluster.TryGetNodeCluster(val3.ClusterID, ref result))
			{
				LegacyLogger.Error("TryWarpTo : Position is not valid, try again inside an area.");
				return null;
			}
			return result;
		}
	}
	internal static class Json
	{
		private static readonly JsonSerializerOptions _setting;

		static Json()
		{
			_setting = new JsonSerializerOptions
			{
				ReadCommentHandling = JsonCommentHandling.Skip,
				IncludeFields = false,
				PropertyNameCaseInsensitive = true,
				WriteIndented = true,
				IgnoreReadOnlyProperties = true
			};
			_setting.Converters.Add(new JsonStringEnumConverter());
			_setting.Converters.Add(MTFOPartialDataUtil.PersistentIDConverter);
			_setting.Converters.Add(MTFOPartialDataUtil.LocalizedTextConverter);
		}

		public static T Deserialize<T>(string json)
		{
			return JsonSerializer.Deserialize<T>(json, _setting);
		}

		public static object Deserialize(Type type, string json)
		{
			return JsonSerializer.Deserialize(json, type, _setting);
		}

		public static string Serialize<T>(T value)
		{
			return JsonSerializer.Serialize(value, _setting);
		}

		public static void Load<T>(string filePath, out T config) where T : new()
		{
			config = Deserialize<T>(File.ReadAllText(filePath));
		}
	}
	internal static class LegacyLogger
	{
		private static ManualLogSource logger = Logger.CreateLogSource("LEGACYCore");

		public static void Log(string format, params object[] args)
		{
			Log(string.Format(format, args));
		}

		public static void Log(string str)
		{
			if (logger != null)
			{
				logger.Log((LogLevel)8, (object)str);
			}
		}

		public static void Warning(string format, params object[] args)
		{
			Warning(string.Format(format, args));
		}

		public static void Warning(string str)
		{
			if (logger != null)
			{
				logger.Log((LogLevel)4, (object)str);
			}
		}

		public static void Error(string format, params object[] args)
		{
			Error(string.Format(format, args));
		}

		public static void Error(string str)
		{
			if (logger != null)
			{
				logger.Log((LogLevel)2, (object)str);
			}
		}

		public static void Debug(string format, params object[] args)
		{
			Debug(string.Format(format, args));
		}

		public static void Debug(string str)
		{
			if (logger != null)
			{
				logger.Log((LogLevel)32, (object)str);
			}
		}
	}
	public class SpawnHibernateEnemiesEvent
	{
		public eWardenObjectiveEventTrigger Trigger { get; set; }

		public int Type { get; set; } = 170;


		public eDimensionIndex DimensionIndex { get; set; }

		public LG_LayerType Layer { get; set; }

		public eLocalZoneIndex LocalIndex { get; set; }

		public string WorldEventObjectFilter { get; set; } = "RANDOM";


		public uint EnemyID { get; set; }

		public int Count { get; set; } = 1;


		public float Delay { get; set; }

		public float Duration { get; set; } = 2f;

	}
	public class WeightedAreaSelector
	{
		private static readonly Dictionary<LG_Zone, WeightedAreaSelector> dict;

		private WeightedRandomBag<LG_Area> weightedRandomBag;

		public static WeightedAreaSelector Get(LG_Zone zone)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected I4, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			if (!dict.ContainsKey(zone))
			{
				WeightedAreaSelector weightedAreaSelector = new WeightedAreaSelector();
				Enumerator<LG_Area> enumerator = zone.m_areas.GetEnumerator();
				while (enumerator.MoveNext())
				{
					LG_Area current = enumerator.Current;
					float num = 0f;
					LG_AreaSize size = current.m_size;
					switch (size - 1)
					{
					case 4:
						num = 7f;
						break;
					case 0:
						num = 20f;
						break;
					case 1:
						num = 30f;
						break;
					case 2:
						num = 35f;
						break;
					case 3:
						num = 45f;
						break;
					default:
						LegacyLogger.Error($"Unhandled LG_AreaSize: {current.m_size}. Won't build.");
						return null;
					}
					weightedAreaSelector.AddEntry(current, num);
				}
				dict.Add(zone, weightedAreaSelector);
			}
			return dict[zone];
		}

		public static WeightedAreaSelector Get(eDimensionIndex eDimensionIndex, LG_LayerType layerType, eLocalZoneIndex localIndex)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			LG_Zone val = default(LG_Zone);
			if (!Builder.CurrentFloor.TryGetZoneByLocalIndex(eDimensionIndex, layerType, localIndex, ref val) || !Object.op_Implicit((Object)(object)val))
			{
				return null;
			}
			return Get(val);
		}

		private WeightedAreaSelector()
		{
			weightedRandomBag = new WeightedRandomBag<LG_Area>();
		}

		private void AddEntry(LG_Area area, float weight)
		{
			weightedRandomBag.AddEntry(area, weight);
		}

		public LG_Area GetRandom()
		{
			return weightedRandomBag.GetRandom();
		}

		private static void OnBuildDone()
		{
		}

		private static void Clear()
		{
			dict.Clear();
		}

		static WeightedAreaSelector()
		{
			dict = new Dictionary<LG_Zone, WeightedAreaSelector>();
			LevelAPI.OnLevelCleanup += dict.Clear;
		}
	}
	public class WeightedRandomBag<T>
	{
		private struct Entry
		{
			public double accumulatedWeight;

			public T item;
		}

		private List<Entry> entries = new List<Entry>();

		private double accumulatedWeight;

		private Random rand = new Random();

		public void AddEntry(T item, double weight)
		{
			if (weight <= 0.0)
			{
				LegacyLogger.Error("AddEntry: no non-positive weight pls.");
				return;
			}
			accumulatedWeight += weight;
			entries.Add(new Entry
			{
				item = item,
				accumulatedWeight = accumulatedWeight
			});
		}

		public T GetRandom()
		{
			double num = rand.NextDouble() * accumulatedWeight;
			foreach (Entry entry in entries)
			{
				if (entry.accumulatedWeight >= num)
				{
					return entry.item;
				}
			}
			return default(T);
		}
	}
}
namespace LEGACY.LegacyOverride
{
	internal class NavMarkerManager
	{
		private Dictionary<string, GameObject> markerVisuals = new Dictionary<string, GameObject>();

		private Dictionary<string, NavMarker> navMarkers = new Dictionary<string, NavMarker>();

		private List<GameObject> arbitraryNavMarkers = new List<GameObject>();

		public static NavMarkerManager Current { get; private set; } = new NavMarkerManager();


		private GameObject InstantiateMarkerVisual()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = Object.Instantiate<GameObject>(Assets.ObjectiveMarker);
			float num = 0.16216217f;
			Transform transform = obj.transform;
			transform.localPosition += Vector3.up * num;
			return obj;
		}

		public void EnableMarkerAt(string markerName, GameObject target, float scale)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			if (navMarkers.ContainsKey(markerName))
			{
				navMarkers[markerName].SetVisible(true);
			}
			else
			{
				NavMarker val = GuiManager.NavMarkerLayer.PrepareGenericMarker(target);
				if ((Object)(object)val != (Object)null)
				{
					val.SetColor(new Color(0.855f, 0.482f, 0.976f));
					val.SetStyle((eNavMarkerStyle)14);
					val.SetVisible(true);
					navMarkers[markerName] = val;
				}
				else
				{
					LegacyLogger.Error("EnableMarkerAt: got null nav marker");
				}
			}
			GameObject val2 = null;
			if (markerVisuals.ContainsKey(markerName))
			{
				val2 = markerVisuals[markerName];
			}
			else
			{
				val2 = InstantiateMarkerVisual();
				val2.transform.localScale = new Vector3(scale, scale, scale);
				val2.transform.SetPositionAndRotation(target.transform.position, Quaternion.identity);
				markerVisuals[markerName] = val2;
			}
			CoroutineManager.BlinkIn(val2, 0f);
			LegacyLogger.Debug("EnableMarker: marker " + markerName + " enabled");
		}

		public void EnableArbitraryMarkerAt(string markerName, Vector3 Position)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//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_006b: Unknown result type (might be due to invalid IL or missing references)
			if (navMarkers.ContainsKey(markerName))
			{
				navMarkers[markerName].SetVisible(true);
			}
			else
			{
				GameObject val = new GameObject(markerName);
				val.transform.SetPositionAndRotation(Position, Quaternion.identity);
				arbitraryNavMarkers.Add(val);
				NavMarker val2 = GuiManager.NavMarkerLayer.PrepareGenericMarker(val);
				if ((Object)(object)val2 != (Object)null)
				{
					val2.SetColor(new Color(0.855f, 0.482f, 0.976f));
					val2.SetStyle((eNavMarkerStyle)14);
					val2.SetVisible(true);
					navMarkers[markerName] = val2;
				}
				else
				{
					LegacyLogger.Error("EnableMarkerAt: got null nav marker");
				}
			}
			LegacyLogger.Debug("EnableMarker: marker " + markerName + " enabled");
		}

		internal (GameObject markerVisual, NavMarker navMakrer) GetMarkerVisuals(string markerName)
		{
			if (!markerVisuals.TryGetValue(markerName, out var value) || !navMarkers.TryGetValue(markerName, out var value2))
			{
				return (null, null);
			}
			return (value, value2);
		}

		public void DisableMakrer(string markerName)
		{
			if (navMarkers.ContainsKey(markerName))
			{
				navMarkers[markerName].SetVisible(false);
			}
			if (markerVisuals.ContainsKey(markerName))
			{
				GameObject val = markerVisuals[markerName];
				if (val.active)
				{
					CoroutineManager.BlinkOut(val, 0f);
				}
				LegacyLogger.Debug("DisableMakrer: marker " + markerName + " disabled");
			}
		}

		public void Clear()
		{
			foreach (GameObject value in markerVisuals.Values)
			{
				Object.Destroy((Object)(object)value);
			}
			arbitraryNavMarkers.ForEach((Action<GameObject>)Object.Destroy);
			markerVisuals.Clear();
			navMarkers.Clear();
			arbitraryNavMarkers.Clear();
		}

		private NavMarkerManager()
		{
			LevelAPI.OnBuildStart += Clear;
			LevelAPI.OnLevelCleanup += Clear;
		}
	}
	internal static class LegacyOverrideManagers
	{
		internal static readonly string LEGACY_CONFIG_PATH = Path.Combine(MTFOPathAPI.CustomPath, "LegacyOverride");

		internal static void Init()
		{
			ElevatorCargoOverrideManager.Current.Init();
			BigPickupFogBeaconSettingManager.Current.Init();
			EnemyTaggerSettingManager.Current.Init();
			ForceFailManager.Current.Init();
			((GenericExpeditionDefinitionManager<ExpeditionIntel>)ExpeditionIntelNotifier.Current).Init();
			((GenericExpeditionDefinitionManager<EventScanDefinition>)EventScanManager.Current).Init();
			((GenericExpeditionDefinitionManager<VisualGroupDefinition>)VisualManager.Current).Init();
			((GenericExpeditionDefinitionManager<MusicOverride>)MusicStateOverrider.Current).Init();
			((ZoneDefinitionManager<LevelSpawnedFogBeaconDefinition>)LevelSpawnedFogBeaconManager.Current).Init();
			((GenericExpeditionDefinitionManager<SuccessPageCustomization>)SuccessPageCustomizationManager.Current).Init();
			((GenericExpeditionDefinitionManager<ResourceStationDefinition>)ResourceStationManager.Current).Init();
			AssetShardManager.OnStartupAssetsLoaded += Action.op_Implicit((Action)delegate
			{
				((GenericDefinitionManager<TSADefinition>)TSAManager.Current).Init();
			});
		}
	}
}
namespace LEGACY.LegacyOverride.ThermalSightAdjustment
{
	public class TSADefinition
	{
		public float OffAimPixelZoom { get; set; } = 1f;


		public TSShader Shader { get; set; } = new TSShader();

	}
	internal class TSAManager : GenericDefinitionManager<TSADefinition>
	{
		private class PuzzleVisualWrapper
		{
			internal GameObject GO { get; set; }

			internal Renderer Renderer { get; set; }

			internal float Intensity { get; set; }

			internal float BehindWallIntensity { get; set; }

			internal void SetIntensity(float t)
			{
				if (GO.active)
				{
					if (Intensity > 0f)
					{
						Renderer.material.SetFloat("_Intensity", Intensity * t);
					}
					if (BehindWallIntensity > 0f)
					{
						Renderer.material.SetFloat("_BehindWallIntensity", BehindWallIntensity * t);
					}
				}
			}

			internal PuzzleVisualWrapper()
			{
			}
		}

		private const bool OUTPUT_THERMAL_SHADER_SETTINGS_ON_WIELD = false;

		private List<PuzzleVisualWrapper> PuzzleVisuals { get; } = new List<PuzzleVisualWrapper>();


		public static TSAManager Current { get; }

		protected override string DEFINITION_NAME => "ThermalSight";

		private Dictionary<uint, Renderer[]> InLevelGearThermals { get; } = new Dictionary<uint, Renderer[]>();


		private HashSet<uint> ModifiedInLevelGearThermals { get; } = new HashSet<uint>();


		private HashSet<uint> ThermalOfflineGears { get; } = new HashSet<uint>();


		public uint CurrentGearPID { get; private set; }

		internal void RegisterPuzzleVisual(CP_Bioscan_Core core)
		{
			Il2CppArrayBase<Renderer> componentsInChildren = ((Component)core).gameObject.GetComponentsInChildren<Renderer>(true);
			if (componentsInChildren == null)
			{
				return;
			}
			foreach (Renderer item2 in ((IEnumerable<Renderer>)componentsInChildren).Where((Renderer comp) => ((Object)((Component)comp).gameObject).name.Equals("Zone")).ToList())
			{
				GameObject gameObject = ((Component)item2).gameObject;
				float @float = item2.material.GetFloat("_Intensity");
				float float2 = item2.material.GetFloat("_BehindWallIntensity");
				PuzzleVisualWrapper item = new PuzzleVisualWrapper
				{
					GO = gameObject,
					Renderer = item2,
					Intensity = @float,
					BehindWallIntensity = float2
				};
				PuzzleVisuals.Add(item);
			}
		}

		private void AddOBSVisualRenderers()
		{
			foreach (GameObject oBSVisual in EnemyTaggerSettingManager.Current.OBSVisuals)
			{
				Renderer componentInChildren = oBSVisual.GetComponentInChildren<Renderer>();
				float @float = componentInChildren.material.GetFloat("_Intensity");
				float behindWallIntensity = -1f;
				PuzzleVisuals.Add(new PuzzleVisualWrapper
				{
					GO = oBSVisual,
					Renderer = componentInChildren,
					Intensity = @float,
					BehindWallIntensity = behindWallIntensity
				});
			}
		}

		internal void SetPuzzleVisualsIntensity(float t)
		{
			PuzzleVisuals.ForEach(delegate(PuzzleVisualWrapper v)
			{
				v.SetIntensity(t);
			});
		}

		private void CleanupPuzzleVisuals()
		{
			PuzzleVisuals.Clear();
		}

		protected override void FileChanged(LiveEditEventArgs e)
		{
			base.FileChanged(e);
			InitThermalOfflineGears();
			CleanupInLevelGearThermals(keepCurrentGear: true);
			TrySetThermalSightRenderer(CurrentGearPID);
		}

		public override void Init()
		{
			InitThermalOfflineGears();
		}

		private void InitThermalOfflineGears()
		{
			ThermalOfflineGears.Clear();
			foreach (PlayerOfflineGearDataBlock allBlock in GameDataBlockBase<PlayerOfflineGearDataBlock>.GetAllBlocks())
			{
				if (((GameDataBlockBase<PlayerOfflineGearDataBlock>)(object)allBlock).name.ToLowerInvariant().EndsWith("_t"))
				{
					ThermalOfflineGears.Add(((GameDataBlockBase<PlayerOfflineGearDataBlock>)(object)allBlock).persistentID);
				}
			}
			LegacyLogger.Debug($"Found OfflineGear with thermal sight, count: {ThermalOfflineGears.Count}");
		}

		private bool TryGetInLevelGearThermalRenderersFromItem(ItemEquippable item, uint gearPID, out Renderer[] renderers)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			renderers = null;
			if (item.GearIDRange == null)
			{
				return false;
			}
			if (gearPID == 0)
			{
				gearPID = ExpeditionGearManager.GetOfflineGearPID(item.GearIDRange);
			}
			if (gearPID == 0 || !IsGearWithThermal(gearPID))
			{
				return false;
			}
			bool flag = false;
			if (!InLevelGearThermals.ContainsKey(gearPID))
			{
				flag = true;
			}
			else
			{
				try
				{
					_ = ((Component)InLevelGearThermals[gearPID][0]).gameObject.transform.position;
					flag = false;
				}
				catch
				{
					ModifiedInLevelGearThermals.Remove(gearPID);
					flag = true;
				}
			}
			if (flag)
			{
				renderers = (from x in ((IEnumerable<Renderer>)((Component)item).GetComponentsInChildren<Renderer>(true))?.Where((Renderer x) => (Object)(object)x.sharedMaterial != (Object)null && (Object)(object)x.sharedMaterial.shader != (Object)null)
					where ((Object)x.sharedMaterial.shader).name.ToLower().Contains("Thermal".ToLower())
					select x).ToArray() ?? null;
				if (renderers != null)
				{
					if (renderers.Length != 1)
					{
						LegacyLogger.Warning(((Item)item).PublicName + " contains more than 1 thermal renderers!");
					}
					InLevelGearThermals[gearPID] = renderers;
					return true;
				}
				LegacyLogger.Debug(((Item)item).PublicName + ": thermal renderer not found");
				return false;
			}
			renderers = InLevelGearThermals[gearPID];
			return true;
		}

		internal bool TrySetThermalSightRenderer(uint gearPID = 0u)
		{
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Expected O, but got Unknown
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Expected O, but got Unknown
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			if (gearPID == 0)
			{
				gearPID = CurrentGearPID;
			}
			if (!IsGearWithThermal(gearPID))
			{
				return false;
			}
			if (ModifiedInLevelGearThermals.Contains(gearPID))
			{
				return true;
			}
			if (base.definitions.TryGetValue(gearPID, out var value) && InLevelGearThermals.TryGetValue(gearPID, out var value2))
			{
				TSShader shader = value.Definition.Shader;
				Renderer[] array = value2;
				foreach (Renderer val in array)
				{
					PropertyInfo[] properties = shader.GetType().GetProperties();
					foreach (PropertyInfo propertyInfo in properties)
					{
						Type type = Nullable.GetUnderlyingType(propertyInfo.PropertyType) ?? propertyInfo.PropertyType;
						string text = "_" + propertyInfo.Name;
						if (type == typeof(float))
						{
							val.material.SetFloat(text, (float)propertyInfo.GetValue(shader));
						}
						else if (type == typeof(EOSColor))
						{
							EOSColor val2 = (EOSColor)propertyInfo.GetValue(shader);
							val.material.SetVector(text, Color.op_Implicit(val2.ToUnityColor()));
						}
						else if (type == typeof(bool))
						{
							bool flag = (bool)propertyInfo.GetValue(shader);
							val.material.SetFloat(text, flag ? 1f : 0f);
						}
						else if (type == typeof(Vec4))
						{
							Vec4 val3 = (Vec4)propertyInfo.GetValue(shader);
							val.material.SetVector(text, val3.ToVector4());
						}
					}
				}
				ModifiedInLevelGearThermals.Add(gearPID);
				return true;
			}
			return false;
		}

		internal void OnPlayerItemWielded(FirstPersonItemHolder fpsItemHolder, ItemEquippable item)
		{
			if (item.GearIDRange == null)
			{
				CurrentGearPID = 0u;
				return;
			}
			CurrentGearPID = ExpeditionGearManager.GetOfflineGearPID(item.GearIDRange);
			TryGetInLevelGearThermalRenderersFromItem(item, CurrentGearPID, out var _);
			TrySetThermalSightRenderer(CurrentGearPID);
		}

		public bool IsGearWithThermal(uint gearPID)
		{
			return ThermalOfflineGears.Contains(gearPID);
		}

		private void CleanupInLevelGearThermals(bool keepCurrentGear = false)
		{
			if (!keepCurrentGear || !InLevelGearThermals.ContainsKey(CurrentGearPID))
			{
				InLevelGearThermals.Clear();
			}
			else
			{
				Renderer[] value = InLevelGearThermals[CurrentGearPID];
				InLevelGearThermals.Clear();
				InLevelGearThermals[CurrentGearPID] = value;
			}
			ModifiedInLevelGearThermals.Clear();
		}

		internal void SetCurrentThermalSightSettings(float t)
		{
			if (InLevelGearThermals.TryGetValue(CurrentGearPID, out var value) && base.definitions.TryGetValue(CurrentGearPID, out var value2))
			{
				Renderer[] array = value;
				foreach (Renderer obj in array)
				{
					float zoom = value2.Definition.Shader.Zoom;
					float offAimPixelZoom = value2.Definition.OffAimPixelZoom;
					float num = Mathf.Lerp(zoom, offAimPixelZoom, t);
					obj.material.SetFloat("_Zoom", num);
				}
			}
		}

		private void Clear()
		{
			CurrentGearPID = 0u;
			CleanupInLevelGearThermals();
			CleanupPuzzleVisuals();
		}

		private TSAManager()
		{
			LevelAPI.OnBuildStart += Clear;
			LevelAPI.OnLevelCleanup += Clear;
			LevelAPI.OnEnterLevel += AddOBSVisualRenderers;
		}

		static TSAManager()
		{
			Current = new TSAManager();
		}
	}
	public class TSShader
	{
		[JsonPropertyName("DistanceFalloff")]
		[Range(0.0, 1.0)]
		public float HeatFalloff { get; set; } = 0.01f;


		[Range(0.0, 1.0)]
		public float FogFalloff { get; set; } = 0.1f;


		[JsonPropertyName("PixelZoom")]
		[Range(0.0, 1.0)]
		public float Zoom { get; set; } = 0.8f;


		[JsonPropertyName("AspectRatioAdjust")]
		[Range(0.0, 2.0)]
		public float RatioAdjust { get; set; } = 1f;


		[Range(0.0, 1.0)]
		public float DistortionCenter { get; set; } = 0.5f;


		public float DistortionScale { get; set; } = 1f;


		public float DistortionSpeed { get; set; } = 1f;


		public float DistortionSignalSpeed { get; set; } = 0.025f;


		[Range(0.0, 1.0)]
		public float DistortionMin { get; set; } = 0.01f;


		[Range(0.0, 1.0)]
		public float DistortionMax { get; set; } = 0.4f;


		[JsonPropertyName("AmbientTemperature")]
		[Range(0.0, 1.0)]
		public float AmbientTemp { get; set; } = 0.15f;


		[JsonPropertyName("BackgroundTemperature")]
		[Range(0.0, 1.0)]
		public float BackgroundTemp { get; set; } = 0.05f;


		[Range(0.0, 10.0)]
		public float AlbedoColorFactor { get; set; } = 0.5f;


		[Range(0.0, 10.0)]
		public float AmbientColorFactor { get; set; } = 5f;


		public float OcclusionHeat { get; set; } = 0.5f;


		public float BodyOcclusionHeat { get; set; } = 2.5f;


		[Range(0.0, 1.0)]
		public float ScreenIntensity { get; set; } = 0.2f;


		[Range(0.0, 1.0)]
		public float OffAngleFade { get; set; } = 0.95f;


		[Range(0.0, 1.0)]
		public float Noise { get; set; } = 0.1f;


		[JsonPropertyName("MinShadowEnemyDistortion")]
		[Range(0.0, 1.0)]
		public float DistortionMinShadowEnemies { get; set; } = 0.2f;


		[JsonPropertyName("MaxShadowEnemyDistortion")]
		[Range(0.0, 1.0)]
		public float DistortionMaxShadowEnemies { get; set; } = 1f;


		[Range(0.0, 1.0)]
		public float DistortionSignalSpeedShadowEnemies { get; set; } = 1f;


		public float ShadowEnemyFresnel { get; set; } = 10f;


		[Range(0.0, 1.0)]
		public float ShadowEnemyHeat { get; set; } = 0.1f;


		public EOSColor ReticuleColorA { get; set; } = new EOSColor
		{
			r = 1f,
			g = 1f,
			b = 1f,
			a = 1f
		};


		public EOSColor ReticuleColorB { get; set; } = new EOSColor
		{
			r = 1f,
			g = 1f,
			b = 1f,
			a = 1f
		};


		public EOSColor ReticuleColorC { get; set; } = new EOSColor
		{
			r = 1f,
			g = 1f,
			b = 1f,
			a = 1f
		};


		[Range(0.0, 20.0)]
		public float SightDirt { get; set; }

		public bool LitGlass { get; set; }

		public bool ClipBorders { get; set; } = true;


		public Vec4 AxisX { get; set; } = new Vec4();


		public Vec4 AxisY { get; set; } = new Vec4();


		public Vec4 AxisZ { get; set; } = new Vec4();


		public bool Flip { get; set; } = true;


		[JsonPropertyName("Distance1")]
		[Range(0.0, 100.0)]
		public float ProjDist1 { get; set; } = 100f;


		[JsonPropertyName("Distance2")]
		[Range(0.0, 100.0)]
		public float ProjDist2 { get; set; } = 66f;


		[JsonPropertyName("Distance3")]
		[Range(0.0, 100.0)]
		public float ProjDist3 { get; set; } = 33f;


		[JsonPropertyName("Size1")]
		[Range(0.0, 3.0)]
		public float ProjSize1 { get; set; } = 1f;


		[JsonPropertyName("Size2")]
		[Range(0.0, 3.0)]
		public float ProjSize2 { get; set; } = 1f;


		[JsonPropertyName("Size3")]
		[Range(0.0, 3.0)]
		public float ProjSize3 { get; set; } = 1f;


		[JsonPropertyName("Zeroing")]
		[Range(-1.0, 1.0)]
		public float ZeroOffset { get; set; }
	}
}
namespace LEGACY.LegacyOverride.ResourceStations
{
	public sealed class ToolStation : ResourceStation
	{
		public override string ItemKey => $"Tool_Station_{base.SerialNumber}";

		protected override void SetupInteraction()
		{
			base.SetupInteraction();
			TextDataBlock block = GameDataBlockBase<TextDataBlock>.GetBlock("InGame.InteractionPrompt.ToolStation");
			Interact.InteractionMessage = ((block == null) ? "TOOL STATION" : Text.Get(((GameDataBlockBase<TextDataBlock>)(object)block).persistentID));
		}

		protected override void OnTriggerInteractionAction(PlayerAgent player)
		{
			PlayerAmmoStorage ammoStorage = PlayerBackpackManager.GetBackpack(player.Owner).AmmoStorage;
			float num = Math.Max(0f, Math.Min(def.SupplyUplimit.Tool - ammoStorage.ClassAmmo.RelInPack, def.SupplyEfficiency.Tool));
			player.GiveAmmoRel(player, 0f, 0f, num);
			player.Sound.Post(EVENTS.AMMOPACK_APPLY, true);
		}

		public static ToolStation Instantiate(ResourceStationDefinition def)
		{
			if (def.StationType != StationType.TOOL)
			{
				LegacyLogger.Error($"Trying to instantiate MediStation with def with 'StationType': {def.StationType}!");
				return null;
			}
			GameObject gO = Object.Instantiate<GameObject>(Assets.ToolStation);
			return new ToolStation(def, gO);
		}

		private ToolStation(ResourceStationDefinition def, GameObject GO)
			: base(def, GO)
		{
		}

		static ToolStation()
		{
		}
	}
	public sealed class MediStation : ResourceStation
	{
		public const float VANILLA_MAX_HEALTH = 25f;

		public override string ItemKey => $"Health_Station_{base.SerialNumber}";

		protected override void SetupInteraction()
		{
			base.SetupInteraction();
			TextDataBlock block = GameDataBlockBase<TextDataBlock>.GetBlock("InGame.InteractionPrompt.MediStation");
			Interact.InteractionMessage = ((block == null) ? "HEALTH STATION" : Text.Get(((GameDataBlockBase<TextDataBlock>)(object)block).persistentID));
		}

		protected override void OnTriggerInteractionAction(PlayerAgent player)
		{
			float health = ((Dam_SyncedDamageBase)player.Damage).Health;
			float num = def.SupplyUplimit.Medi * 25f;
			if (!(health >= num))
			{
				player.GiveHealth(player, Math.Min(def.SupplyEfficiency.Medi, (num - health) / 25f));
				player.Sound.Post(EVENTS.MEDPACK_APPLY, true);
			}
		}

		public static MediStation Instantiate(ResourceStationDefinition def)
		{
			if (def.StationType != 0)
			{
				LegacyLogger.Error($"Trying to instantiate MediStation with def with 'StationType': {def.StationType}!");
				return null;
			}
			GameObject gO = Object.Instantiate<GameObject>(Assets.MediStation);
			return new MediStation(def, gO);
		}

		private MediStation(ResourceStationDefinition def, GameObject GO)
			: base(def, GO)
		{
		}

		static MediStation()
		{
		}
	}
	public abstract class ResourceStation
	{
		public virtual GameObject GameObject { get; protected set; }

		public virtual GameObject InteractGO
		{
			get
			{
				GameObject gameObject = GameObject;
				return ((gameObject != null) ? ((Component)gameObject.transform.GetChild(3)).gameObject : null) ?? null;
			}
		}

		public virtual GameObject StationMarkerGO
		{
			get
			{
				GameObject gameObject = GameObject;
				return ((gameObject != null) ? ((Component)gameObject.transform.GetChild(2)).gameObject : null) ?? null;
			}
		}

		public virtual Interact_Timed Interact { get; protected set; }

		public virtual ResourceStationDefinition def { get; protected set; }

		public StateReplicator<RSStateStruct> StateReplicator { get; protected set; }

		public LG_GenericTerminalItem TerminalItem { get; protected set; }

		public AIG_CourseNode SpawnNode
		{
			get
			{
				return TerminalItem.SpawnNode;
			}
			set
			{
				TerminalItem.SpawnNode = value;
			}
		}

		protected int SerialNumber { get; private set; }

		public virtual string ItemKey => $"Resource_Station_{SerialNumber}";

		public virtual void Destroy()
		{
			Object.Destroy((Object)(object)GameObject);
			Interact = null;
			def = null;
		}

		protected virtual void OnTriggerInteractionAction(PlayerAgent player)
		{
		}

		protected virtual void OnInteractionSelected(PlayerAgent agent, bool selected)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (selected)
			{
				string text = Text.Format(827u, (Object[])(object)new Object[1] { Object.op_Implicit(InputMapper.GetBindingName(((Interact_Base)Interact).InputAction)) });
				TextDataBlock block = GameDataBlockBase<TextDataBlock>.GetBlock("InGame.OnAdditionalInteractionText.ResourceStation");
				string text2 = ((block == null) ? "TO REPLENISH" : Text.Get(((GameDataBlockBase<TextDataBlock>)(object)block).persistentID));
				GuiManager.InteractionLayer.SetInteractPrompt(Interact.InteractionMessage, text + text2, (ePUIMessageStyle)0);
			}
		}

		protected virtual void SetupInteraction()
		{
			Interact.InteractDuration = def.InteractDuration;
			Interact_Timed interact = Interact;
			interact.OnInteractionSelected += Action<PlayerAgent, bool>.op_Implicit((Action<PlayerAgent, bool>)OnInteractionSelected);
			Interact_Timed interact2 = Interact;
			interact2.OnInteractionTriggered += Action<PlayerAgent>.op_Implicit((Action<PlayerAgent>)OnTriggerInteractionAction);
		}

		protected virtual void SetupTerminalItem()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			LG_Zone val = default(LG_Zone);
			if (!Builder.CurrentFloor.TryGetZoneByLocalIndex(((GlobalZoneIndex)def).DimensionIndex, ((GlobalZoneIndex)def).LayerType, ((GlobalZoneIndex)def).LocalIndex, ref val) || (Object)(object)val == (Object)null)
			{
				LegacyLogger.Error("ResourceStation: Cannot find spawn node!");
				return;
			}
			if (def.AreaIndex < 0 || def.AreaIndex >= val.m_areas.Count)
			{
				LegacyLogger.Error("ResourceStation: Cannot find spawn node - Area index is invalid!");
				return;
			}
			TerminalItem.Setup(ItemKey, val.m_areas[def.AreaIndex].m_courseNode);
			if (SpawnNode != null)
			{
				TerminalItem.FloorItemLocation = SpawnNode.m_zone.NavInfo.GetFormattedText((LG_NavInfoFormat)7);
			}
			TerminalItem.FloorItemStatus = (eFloorInventoryObjectStatus)0;
		}

		protected virtual void OnStateChanged(RSStateStruct oldState, RSStateStruct newState, bool isRecall)
		{
		}

		protected virtual void SetupReplicator()
		{
		}

		protected ResourceStation(ResourceStationDefinition def, GameObject GO)
		{
			//IL_0025: 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)
			this.def = def;
			GameObject = GO;
			GameObject.transform.SetPositionAndRotation(def.Position.ToVector3(), def.Rotation.ToQuaternion());
			Interact = InteractGO.GetComponent<Interact_Timed>();
			SerialNumber = SerialGenerator.GetUniqueSerialNo();
			if ((Object)(object)Interact == (Object)null)
			{
				LegacyLogger.Error("ResourceStation: Interact Comp not found!");
			}
			else
			{
				SetupInteraction();
			}
			TerminalItem = GO.GetComponent<LG_GenericTerminalItem>();
			if ((Object)(object)TerminalItem == (Object)null)
			{
				LegacyLogger.Error("ResourceStation: TerminalItem not found!");
			}
			else
			{
				SetupTerminalItem();
			}
			SetupReplicator();
		}

		static ResourceStation()
		{
		}
	}
	public sealed class AmmoStation : ResourceStation
	{
		public override string ItemKey => $"Ammunition_Station_{base.SerialNumber}";

		protected override void SetupInteraction()
		{
			base.SetupInteraction();
			TextDataBlock block = GameDataBlockBase<TextDataBlock>.GetBlock("InGame.InteractionPrompt.AmmoStation");
			Interact.InteractionMessage = ((block == null) ? "AMMUNITION STATION" : Text.Get(((GameDataBlockBase<TextDataBlock>)(object)block).persistentID));
		}

		protected override void OnTriggerInteractionAction(PlayerAgent player)
		{
			PlayerAmmoStorage ammoStorage = PlayerBackpackManager.GetBackpack(player.Owner).AmmoStorage;
			float num = Math.Max(0f, Math.Min(def.SupplyUplimit.AmmoStandard - 1f * (float)ammoStorage.StandardAmmo.BulletClipSize / (float)ammoStorage.StandardAmmo.BulletsMaxCap - ammoStorage.StandardAmmo.RelInPack, def.SupplyEfficiency.AmmoStandard));
			float num2 = Math.Max(0f, Math.Min(def.SupplyUplimit.AmmoSpecial - 1f * (float)ammoStorage.SpecialAmmo.BulletClipSize / (float)ammoStorage.SpecialAmmo.BulletsMaxCap - ammoStorage.SpecialAmmo.RelInPack, def.SupplyEfficiency.AmmoSpecial));
			player.GiveAmmoRel(player, num, num2, 0f);
			player.Sound.Post(EVENTS.AMMOPACK_APPLY, true);
		}

		public static AmmoStation Instantiate(ResourceStationDefinition def)
		{
			if (def.StationType != StationType.AMMO)
			{
				LegacyLogger.Error($"Trying to instantiate AmmoStation with def with 'StationType': {def.StationType}!");
				return null;
			}
			GameObject gO = Object.Instantiate<GameObject>(Assets.AmmoStation);
			return new AmmoStation(def, gO);
		}

		private AmmoStation(ResourceStationDefinition def, GameObject GO)
			: base(def, GO)
		{
		}

		static AmmoStation()
		{
		}
	}
	public enum StationType
	{
		MEDI,
		AMMO,
		TOOL
	}
	public class SupplyUplimit
	{
		public float Medi { get; set; } = 0.6f;


		public float AmmoStandard { get; set; } = 1f;


		public float AmmoSpecial { get; set; } = 1f;


		public float Tool { get; set; }
	}
	public class SupplyEfficiency
	{
		public float Medi { get; set; } = 0.2f;


		public float AmmoStandard { get; set; } = 0.15f;


		public float AmmoSpecial { get; set; } = 0.15f;


		public float Tool { get; set; }
	}
	public class ResourceStationDefinition : GlobalZoneIndex
	{
		public int AreaIndex { get; set; }

		public string WorldEventObjectFilter { get; set; } = string.Empty;


		public StationType StationType { get; set; } = StationType.AMMO;


		public Vec3 Position { get; set; } = new Vec3();


		public Vec3 Rotation { get; set; } = new Vec3();


		public float InteractDuration { get; set; } = 2.5f;


		public SupplyEfficiency SupplyEfficiency { get; set; } = new SupplyEfficiency();


		public SupplyUplimit SupplyUplimit { get; set; } = new SupplyUplimit();


		public int AllowedUseTimePerCooldown { get; set; } = 3;


		public float CooldownTime { get; set; } = 5f;

	}
	public class ResourceStationManager : GenericExpeditionDefinitionManager<ResourceStationDefinition>
	{
		public static ResourceStationManager Current { get; private set; }

		protected override string DEFINITION_NAME => "ResourceStation";

		private Dictionary<string, ResourceStation> Stations { get; } = new Dictionary<string, ResourceStation>();


		private void Build(ResourceStationDefinition def)
		{
			if (Stations.ContainsKey(def.WorldEventObjectFilter))
			{
				LegacyLogger.Error("ResourceStationManager: WorldEventObjectFilter '" + def.WorldEventObjectFilter + "' is already used");
				return;
			}
			ResourceStation resourceStation = null;
			switch (def.StationType)
			{
			case StationType.MEDI:
				resourceStation = MediStation.Instantiate(def);
				break;
			case StationType.AMMO:
				resourceStation = AmmoStation.Instantiate(def);
				break;
			case StationType.TOOL:
				resourceStation = ToolStation.Instantiate(def);
				break;
			default:
				LegacyLogger.Error($"ResourceStation {def.StationType} is unimplemented");
				return;
			}
			if (resourceStation != null)
			{
				Stations[def.WorldEventObjectFilter] = resourceStation;
				LegacyLogger.Debug("ResourceStation '" + def.WorldEventObjectFilter + "' instantiated");
			}
		}

		private void BuildStations()
		{
			if (base.definitions.TryGetValue(base.CurrentMainLevelLayout, out var value))
			{
				value.Definitions.ForEach(Build);
			}
		}

		private void Clear()
		{
			foreach (ResourceStation value in Stations.Values)
			{
				value.Destroy();
			}
			Stations.Clear();
		}

		private ResourceStationManager()
		{
			LevelAPI.OnBuildStart += delegate
			{
				Clear();
			};
			LevelAPI.OnLevelCleanup += Clear;
			LevelAPI.OnBuildDone += BuildStations;
		}

		static ResourceStationManager()
		{
			Current = new ResourceStationManager();
		}
	}
	public struct RSStateStruct
	{
		public int RemainingUseTime;

		public float CurrentCooldownTime;

		public bool Enabled;

		public RSStateStruct()
		{
			RemainingUseTime = 0;
			CurrentCooldownTime = 0f;
			Enabled = false;
		}
	}
	public class RSTimer : MonoBehaviour
	{
		private float endTime;

		private bool hasOnGoingTimer;

		private Action OnTimerEnd;

		public float RemainingTime
		{
			get
			{
				if (!hasOnGoingTimer)
				{
					return 0f;
				}
				return Math.Max(endTime - Clock.Time, 0f);
			}
		}

		private static List<GameObject> TimerGOs { get; }

		private void Update()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			if ((int)GameStateManager.CurrentStateName == 10 && hasOnGoingTimer && !(Clock.Time < endTime))
			{
				endTime = 0f;
				hasOnGoingTimer = false;
				Action onTimerEnd = OnTimerEnd;
				OnTimerEnd = null;
				onTimerEnd?.Invoke();
			}
		}

		public void StartTimer(float time, Action onEnd = null)
		{
			if (time <= 0f)
			{
				LegacyLogger.Error("StartTimer: time is not positive!");
				return;
			}
			if (hasOnGoingTimer)
			{
				LegacyLogger.Error("StartTimer: this timer is yet ended!");
				return;
			}
			endTime = Clock.Time + time;
			OnTimerEnd = onEnd;
			hasOnGoingTimer = true;
		}

		private void OnDestroy()
		{
			endTime = 0f;
			hasOnGoingTimer = false;
			OnTimerEnd = null;
		}

		public static RSTimer Instantiate()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			GameObject val = new GameObject();
			RSTimer result = val.AddComponent<RSTimer>();
			TimerGOs.Add(val);
			return result;
		}

		public static void DestroyAll()
		{
			TimerGOs.ForEach((Action<GameObject>)Object.Destroy);
			TimerGOs.Clear();
		}

		private RSTimer()
		{
		}

		static RSTimer()
		{
			TimerGOs = new List<GameObject>();
			ClassInjector.RegisterTypeInIl2Cpp<RSTimer>();
			LevelAPI.OnBuildStart += DestroyAll;
			LevelAPI.OnLevelCleanup += DestroyAll;
		}
	}
}
namespace LEGACY.LegacyOverride.EnemyTargeting
{
	internal class EnemyTargetingPrioritizer : MonoBehaviour
	{
		public const float UPDATE_INTERVAL = 3f;

		private float nextUpdateTime = float.NaN;

		internal EnemyAgent enemy;

		private Dam_EnemyDamageBase damage
		{
			get
			{
				EnemyAgent obj = enemy;
				if (obj == null)
				{
					return null;
				}
				return obj.Damage;
			}
		}

		private AgentTarget target
		{
			get
			{
				EnemyAgent obj = enemy;
				if (obj == null)
				{
					return null;
				}
				return ((AgentAI)obj.AI).Target;
			}
		}

		private void Update()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Invalid comparison between Unknown and I4
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			if ((int)GameStateManager.CurrentStateName != 10 || !SNet.IsMaster)
			{
				return;
			}
			if (float.IsNaN(nextUpdateTime))
			{
				nextUpdateTime = Clock.Time + 3f;
			}
			else if (!(Clock.Time < nextUpdateTime) && !((Object)(object)enemy == (Object)null))
			{
				nextUpdateTime = Clock.Time + 3f;
				if ((int)((AgentAI)enemy.AI).Mode == 1 && target != null && !(((Il2CppObjectBase)target.m_agent.CourseNode).Pointer == ((Il2CppObjectBase)((Agent)enemy).CourseNode).Pointer) && PlayerManager.PlayerAgentsInLevel.Count > 1 && ((Agent)PlayerManager.PlayerAgentsInLevel[0]).CourseNode.m_dimension.DimensionIndex == ((Agent)enemy).CourseNode.m_dimension.DimensionIndex)
				{
					TryPrioritizeCloserTarget();
				}
			}
		}

		internal void TryPrioritizeCloserTarget()
		{
			_ = target;
			Agent val = null;
			Enumerator<PlayerAgent> enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator();
			while (enumerator.MoveNext())
			{
				PlayerAgent current = enumerator.Current;
				if (((Agent)current).Alive && ((Il2CppObjectBase)((Agent)current).CourseNode).Pointer == ((Il2CppObjectBase)((Agent)enemy).CourseNode).Pointer)
				{
					val = (Agent)(object)current;
					break;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator();
				while (enumerator.MoveNext())
				{
					PlayerAgent current2 = enumerator.Current;
					if (((Agent)current2).Alive && ((Il2CppObjectBase)((Agent)current2).CourseNode.m_zone).Pointer == ((Il2CppObjectBase)((Agent)enemy).CourseNode.m_zone).Pointer)
					{
						val = (Agent)(object)current2;
						break;
					}
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				((AgentAI)enemy.AI).SetTarget(val);
			}
		}

		private void OnDestroy()
		{
			enemy = null;
		}

		static EnemyTargetingPrioritizer()
		{
			ClassInjector.RegisterTypeInIl2Cpp<EnemyTargetingPrioritizer>();
		}
	}
}
namespace LEGACY.LegacyOverride.ElevatorCargo
{
	internal class ElevatorCargoOverrideManager
	{
		public static readonly ElevatorCargoOverrideManager Current;

		private Dictionary<uint, LevelElevatorCargo> elevatorCargos = new Dictionary<uint, LevelElevatorCargo>();

		private LiveEditListener liveEditListener;

		private static readonly string CONFIG_PATH;

		private void AddOverride(LevelElevatorCargo _override)
		{
			if (_override != null)
			{
				if (elevatorCargos.ContainsKey(_override.MainLevelLayout))
				{
					LegacyLogger.Warning("Replaced MainLevelLayout {0}", _override.MainLevelLayout);
					elevatorCargos[_override.MainLevelLayout] = _override;
				}
				else
				{
					elevatorCargos.Add(_override.MainLevelLayout, _override);
				}
			}
		}

		public void Init()
		{
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			if (!Directory.Exists(CONFIG_PATH))
			{
				Directory.CreateDirectory(CONFIG_PATH);
				StreamWriter streamWriter = File.CreateText(Path.Combine(CONFIG_PATH, "Template.json"));
				streamWriter.WriteLine(Json.Serialize(new LevelElevatorCargo()));
				streamWriter.Flush();
				streamWriter.Close();
				return;
			}
			foreach (string item in Directory.EnumerateFiles(CONFIG_PATH, "*.json", SearchOption.AllDirectories))
			{
				Json.Load<LevelElevatorCargo>(item, out var config);
				AddOverride(config);
			}
			liveEditListener = LiveEdit.CreateListener(CONFIG_PATH, "*.json", true);
			liveEditListener.FileChanged += new LiveEditEventHandler(FileChanged);
		}

		private void FileChanged(LiveEditEventArgs e)
		{
			LegacyLogger.Warning("LiveEdit File Changed: " + e.FullPath);
			LiveEdit.TryReadFileContent(e.FullPath, (Action<string>)delegate(string content)
			{
				LevelElevatorCargo @override = Json.Deserialize<LevelElevatorCargo>(content);
				AddOverride(@override);
			});
		}

		internal LevelElevatorCargo GetLevelElevatorCargoItems(uint MainLevelLayout)
		{
			if (!elevatorCargos.ContainsKey(MainLevelLayout))
			{
				return null;
			}
			return elevatorCargos[MainLevelLayout];
		}

		private ElevatorCargoOverrideManager()
		{
		}

		static ElevatorCargoOverrideManager()
		{
			CONFIG_PATH = Path.Combine(LegacyOverrideManagers.LEGACY_CONFIG_PATH, "ElevatorCargoOverride");
			Current = new ElevatorCargoOverrideManager();
		}
	}
	public enum ItemType
	{
		Consumable,
		BigPickup
	}
	public class ElevatorCargoItem
	{
		public uint ItemID { get; set; }

		public ItemType ItemType { get; set; }
	}
	public class LevelElevatorCargo
	{
		public uint MainLevelLayout { get; set; }

		public bool ForceDisable { get; set; }

		public List<ElevatorCargoItem> ElevatorCargoItems { get; set; } = new List<ElevatorCargoItem>();

	}
}
namespace LEGACY.LegacyOverride.Patches
{
	[HarmonyPatch]
	internal static class DynamicVisualAdjustment
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(FirstPersonItemHolder), "SetWieldedItem")]
		private static void Post_SetWieldedItem(FirstPersonItemHolder __instance, ItemEquippable item)
		{
			TSAManager.Current.OnPlayerItemWielded(__instance, item);
			TSAManager.Current.SetPuzzleVisualsIntensity(1f);
			TSAManager.Current.SetCurrentThermalSightSettings(1f);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(FPIS_Aim), "Update")]
		private static void Post_Aim_Update(FPIS_Aim __instance)
		{
			if (!((Object)(object)((FPItemState)__instance).Holder.WieldedItem == (Object)null))
			{
				float num = 1f - FirstPersonItemHolder.m_transitionDelta;
				if (!TSAManager.Current.IsGearWithThermal(TSAManager.Current.CurrentGearPID))
				{
					num = Math.Max(0.05f, num);
				}
				else
				{
					TSAManager.Current.SetCurrentThermalSightSettings(num);
				}
				TSAManager.Current.SetPuzzleVisualsIntensity(num);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CP_Bioscan_Core), "Setup")]
		private static void Post_CaptureBioscanVisual(CP_Bioscan_Core __instance)
		{
			TSAManager.Current.RegisterPuzzleVisual(__instance);
		}
	}
	[HarmonyPatch]
	internal static class ExpeditionSuccessPage
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(CM_PageExpeditionSuccess), "OnEnable")]
		private static void Post_CM_PageExpeditionSuccess_OnEnable(CM_PageExpeditionSuccess __instance)
		{
			if (!((Object)(object)__instance == (Object)null))
			{
				SuccessPageCustomization currentCustomization = SuccessPageCustomizationManager.Current.CurrentCustomization;
				if (currentCustomization != null)
				{
					((TMP_Text)__instance.m_header).SetText(LocalizedText.op_Implicit(currentCustomization.PageHeader), true);
					__instance.m_overrideSuccessMusic = currentCustomization.OverrideSuccessMusic;
					LegacyLogger.Warning("Post_CM_PageExpeditionSuccess_OnEnable: " + ((Object)currentCustomization.PageHeader).ToString());
				}
			}
		}
	}
	[HarmonyPatch]
	internal static class LevelSpawnFogBeacon_BugFix
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(HeavyFogRepellerGlobalState), "AttemptInteract")]
		private static void Post_HeavyFogRepellerGlobalState_AttemptInteract(HeavyFogRepellerGlobalState __instance)
		{
			LevelSpawnedFogBeaconSettings lSFBDef = LevelSpawnedFogBeaconManager.Current.GetLSFBDef(__instance);
			if (lSFBDef != null)
			{
				__instance.m_repellerSphere.Range = lSFBDef.Range;
			}
		}
	}
	[HarmonyPatch]
	internal class PrioritizeEnemyTargeting
	{
		private static bool s_patch = true;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(EnemyCourseNavigation), "UpdateTracking")]
		private static void UpdateTracking(EnemyCourseNavigation __instance)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Invalid comparison between Unknown and I4
			if (!s_patch)
			{
				return;
			}
			int count = PlayerManager.PlayerAgentsInLevel.Count;
			if (!SNet.IsMaster || count <= 1)
			{
				return;
			}
			EnemyAgent owner = __instance.m_owner;
			if ((int)((StateMachine<ES_Base>)(object)owner.Locomotion).m_currentState.m_stateEnum == 14 || ((Il2CppObjectBase)__instance.m_targetRef.m_agent.CourseNode).Pointer == ((Il2CppObjectBase)((Agent)owner).CourseNode).Pointer)
			{
				return;
			}
			PlayerAgent val = null;
			int num = Random.RandomRangeInt(0, count);
			for (int i = 0; i < count; i++)
			{
				PlayerAgent val2 = PlayerManager.PlayerAgentsInLevel[num];
				if (((Agent)val2).Alive && ((Il2CppObjectBase)((Agent)val2).CourseNode).Pointer == ((Il2CppObjectBase)((Agent)owner).CourseNode).Pointer)
				{
					val = val2;
					break;
				}
				num = (num + 1) % count;
			}
			if ((Object)(object)val != (Object)null)
			{
				s_patch = false;
				((AgentAI)owner.AI).SetTarget((Agent)(object)val);
				s_patch = true;
			}
		}
	}
	[HarmonyPatch]
	internal class RundownSelectionCustomization
	{
		private static uint r1TitleID;

		private static uint r2TitleID;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CM_PageRundown_New), "Setup")]
		private static void Post_CM_PageRundown_New(CM_PageRundown_New __instance)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			GameSetupDataBlock block = GameDataBlockBase<GameSetupDataBlock>.GetBlock(1u);
			if (block.RundownIdsToLoad.Count > 1 && block.RundownIdsToLoad.Count == 2)
			{
				((Il2CppArrayBase<Vector3>)(object)__instance.m_rundownSelectionPositions)[0] = new Vector3(-320f, 75f, 0f);
				((Il2CppArrayBase<Vector3>)(object)__instance.m_rundownSelectionPositions)[1] = new Vector3(320f, 0f, 0f);
				Vector3 zero = Vector3.zero;
				for (int i = block.RundownIdsToLoad.Count; i < ((Il2CppArrayBase<Vector3>)(object)__instance.m_rundownSelectionPositions).Count; i++)
				{
					zero = ((Il2CppArrayBase<Vector3>)(object)__instance.m_rundownSelectionPositions)[i];
					((Il2CppArrayBase<Vector3>)(object)__instance.m_rundownSelectionPositions)[i] = new Vector3(zero.x, -10000f, zero.z);
				}
				zero = __instance.m_textRundownHeaderTop.transform.position;
				__instance.m_textRundownHeaderTop.transform.position = new Vector3(zero.x, -350f, zero.z);
			}
		}

		private static void SetSelectionScale(CM_PageRundown_New p)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			GameSetupDataBlock block = GameDataBlockBase<GameSetupDataBlock>.GetBlock(1u);
			if (block.RundownIdsToLoad.Count > 1 && block.RundownIdsToLoad.Count == 2)
			{
				CM_RundownSelection obj = p.m_rundownSelections[0];
				CM_RundownSelection val = p.m_rundownSelections[1];
				((Component)obj).transform.localScale = new Vector3(2f, 2f, 2f) * 1.625f;
				((Component)val).transform.localScale = new Vector3(1.25f, 1.25f, 1.25f) * 1.5f;
				Transform transform = obj.m_rundownText.transform;
				Quaternion localRotation = (val.m_rundownText.transform.localRotation = Quaternion.AngleAxis(45f, Vector3.right));
				transform.localRotation = localRotation;
				obj.m_rundownText.transform.localPosition = Vector3.up * 60f + Vector3.right * 20f;
				val.m_rundownText.transform.localPosition = Vector3.up * 85f + Vector3.left * 25f;
				Transform transform2 = ((Component)obj).transform;
				localRotation = (((Component)val).transform.localRotation = Quaternion.AngleAxis(-45f, Vector3.right));
				transform2.localRotation = localRotation;
				((TMP_Text)obj.m_rundownText).text = ((r1TitleID != 0) ? Text.Get(r1TitleID) : "<size=50%><color=#00ae9d>[ LEGACY ]</color></size>");
				((TMP_Text)val.m_rundownText).text = ((r2TitleID != 0) ? Text.Get(r2TitleID) : "<size=80%><color=#009ad6>[ L-OMNI ]</color></size>");
				DestroyAltText(obj);
				DestroyAltText(val);
			}
			static void DestroyAltText(CM_RundownSelection s)
			{
				if ((Object)(object)s.m_altText != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)s.m_altText).gameObject);
					s.m_altText = null;
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CM_PageRundown_New), "UpdateRundownSelectionButton")]
		private static void Post_UpdateRundownSelectionButton(CM_PageRundown_New __instance)
		{
			InitTitle();
			SetSelectionScale(__instance);
		}

		private static void InitTitle()
		{
			if (r1TitleID == 0)
			{
				TextDataBlock block = GameDataBlockBase<TextDataBlock>.GetBlock("LEGACY_Title");
				if (block != null)
				{
					r1TitleID = ((GameDataBlockBase<TextDataBlock>)(object)block).persistentID;
				}
				block = GameDataBlockBase<TextDataBlock>.GetBlock("LEGACY-Omni_Title");
				if (block != nul

plugins/SURVIVAL/net6/PortalPuzzleChanger.dll

Decompiled 5 days 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.Text.Json;
using System.Text.Json.Serialization;
using AK;
using Agents;
using AssetShards;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using ChainedPuzzles;
using Enemies;
using FX_EffectSystem;
using GTFO.API;
using GTFO.API.Components;
using GTFO.API.JSON.Converters;
using GTFO.API.Wrappers;
using GameData;
using Gear;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using LevelGeneration;
using MTFO.Managers;
using Microsoft.CodeAnalysis;
using Player;
using PortalPuzzleChanger.ConfigFiles;
using PortalPuzzleChanger.GameScripts;
using PortalPuzzleChanger.Plugin;
using SNetwork;
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 = ".NET 6.0")]
[assembly: AssemblyCompany("PortalPuzzleChanger")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PortalPuzzleChanger")]
[assembly: AssemblyTitle("PortalPuzzleChanger")]
[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 PortalPuzzleChanger.Plugin
{
	[BepInPlugin("com.Breeze.PortalPuzzleChanger", "PortalPuzzleChanger", "0.0.1")]
	[BepInProcess("GTFO.exe")]
	internal class EntryPoint : BasePlugin
	{
		public static Dictionary<string, Sprite> CachedSprites;

		public static readonly JsonSerializerOptions SerializerOptions = new JsonSerializerOptions
		{
			ReadCommentHandling = JsonCommentHandling.Skip,
			PropertyNameCaseInsensitive = true,
			IncludeFields = true,
			AllowTrailingCommas = true,
			WriteIndented = true
		};

		public static ManualLogSource? LogSource { get; private set; }

		public static Harmony? m_Harmony { get; private set; }

		public override void Load()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			LogSource = ((BasePlugin)this).Log;
			m_Harmony = new Harmony("_PortalPuzzleChanger_");
			m_Harmony.PatchAll();
			SerializerOptions.Converters.Add((JsonConverter)new LocalizedTextConverter());
			SerializerOptions.Converters.Add((JsonConverter)new Vector3Converter());
			SerializerOptions.Converters.Add((JsonConverter)new Vector2Converter());
			SerializerOptions.Converters.Add((JsonConverter)new ColorConverter());
			PortalPuzzleChangerSetup.Load();
			EnemyTagChangerConfigSetup.Load();
			GrenadeLauncherConfigSetup.Load();
			ClassInjector.RegisterTypeInIl2Cpp<GrenadeProjectile>();
			AssetAPI.OnAssetBundlesLoaded += OnAssetsLoaded;
		}

		public void OnAssetsLoaded()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			List<EnemyTagChanger> list = EnemyTagChangerConfigSetup.EnabledConfigs.Values.ToList();
			for (int i = 0; i < list.Count; i++)
			{
				if (!string.IsNullOrEmpty(list[i].CustomImagePath))
				{
					Texture2D loadedAsset = AssetAPI.GetLoadedAsset<Texture2D>(list[i].CustomImagePath);
					Sprite val = Sprite.Create(loadedAsset, new Rect(0f, 0f, (float)((Texture)loadedAsset).width, (float)((Texture)loadedAsset).height), new Vector2(0.5f, 0.5f), 64f);
					((Object)val).hideFlags = (HideFlags)61;
					((Object)val).name = list[i].CustomImagePath;
					CachedSprites.Add(((Object)val).name, val);
					Debug("Created a sprite from path: " + list[i].CustomImagePath);
				}
			}
		}

		public static void Debug(string message)
		{
			LogSource.LogDebug((object)("[DEBUG] " + message));
		}

		public static void DebugWarning(string message)
		{
			LogSource.LogWarning((object)("[WARNING] " + message));
		}

		public static void DebugError(string message)
		{
			LogSource.LogError((object)("[ERROR] " + message));
		}
	}
	public class PortalPuzzleChangerSetup
	{
		public static Dictionary<uint, List<PortalEntry>> EnabledConfigs = new Dictionary<uint, List<PortalEntry>>();

		private static List<PortalChangerConfig>? Configs;

		public static string Name { get; } = "PortalPuzzleChanger.json";


		public static void Load()
		{
			string path = Path.Combine(ConfigManager.CustomPath, Name);
			if (File.Exists(path))
			{
				Configs = JsonSerializer.Deserialize<List<PortalChangerConfig>>(File.ReadAllText(path), EntryPoint.SerializerOptions);
				EntryPoint.Debug(Name + " has loaded successfully");
			}
			else
			{
				Configs = new List<PortalChangerConfig>
				{
					new PortalChangerConfig()
				};
				string contents = JsonSerializer.Serialize(Configs, EntryPoint.SerializerOptions);
				File.WriteAllText(path, contents);
				EntryPoint.DebugWarning(Name + " did not exist, creating it now");
			}
			EnabledConfigs.Clear();
			int count = Configs.Count;
			for (int i = 0; i < count; i++)
			{
				if (Configs[i].InternalEnabled)
				{
					EnabledConfigs.Add(Configs[i].MainLevelLayoutID, Configs[i].PortalEntries);
				}
			}
		}
	}
	public class EnemyTagChangerConfigSetup
	{
		public static Dictionary<uint, EnemyTagChanger> EnabledConfigs = new Dictionary<uint, EnemyTagChanger>();

		private static List<EnemyTagChanger>? Configs;

		public static string Name { get; } = "EnemyTags.json";


		public static void Load()
		{
			string path = Path.Combine(ConfigManager.CustomPath, Name);
			if (File.Exists(path))
			{
				Configs = JsonSerializer.Deserialize<List<EnemyTagChanger>>(File.ReadAllText(path), EntryPoint.SerializerOptions);
				EntryPoint.Debug(Name + " has loaded successfully");
			}
			else
			{
				Configs = new List<EnemyTagChanger>
				{
					new EnemyTagChanger()
				};
				string contents = JsonSerializer.Serialize(Configs, EntryPoint.SerializerOptions);
				File.WriteAllText(path, contents);
				EntryPoint.DebugWarning(Name + " did not exist, creating it now");
			}
			EnabledConfigs.Clear();
			int count = Configs.Count;
			for (int i = 0; i < count; i++)
			{
				if (Configs[i].internalEnabled)
				{
					EnabledConfigs.Add(Configs[i].EnemyID, Configs[i]);
				}
			}
		}
	}
	public class GrenadeLauncherConfigSetup
	{
		public static Dictionary<uint, GrenadeLauncherConfig> EnabledConfigs = new Dictionary<uint, GrenadeLauncherConfig>();

		private static List<GrenadeLauncherConfig>? Configs;

		public static string Name { get; } = "GrenadeLauncher.json";


		public static void Load()
		{
			string path = Path.Combine(ConfigManager.CustomPath, Name);
			if (File.Exists(path))
			{
				Configs = JsonSerializer.Deserialize<List<GrenadeLauncherConfig>>(File.ReadAllText(path), EntryPoint.SerializerOptions);
				EntryPoint.Debug(Name + " has loaded successfully");
			}
			else
			{
				Configs = new List<GrenadeLauncherConfig>
				{
					new GrenadeLauncherConfig()
				};
				string contents = JsonSerializer.Serialize(Configs, EntryPoint.SerializerOptions);
				File.WriteAllText(path, contents);
				EntryPoint.DebugWarning(Name + " did not exist, creating it now");
			}
			EnabledConfigs.Clear();
			int count = Configs.Count;
			for (int i = 0; i < count; i++)
			{
				if (Configs[i].internalEnabled)
				{
					EnabledConfigs.Add(Configs[i].PersistentID, Configs[i]);
				}
			}
		}
	}
}
namespace PortalPuzzleChanger.Patches
{
	[HarmonyPatch(typeof(LG_DimensionPortal), "Setup")]
	public static class DimensionPortalPatch
	{
		public static void Prefix(LG_DimensionPortal __instance)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			if (!PortalPuzzleChangerSetup.EnabledConfigs.ContainsKey(RundownManager.ActiveExpedition.LevelLayoutData))
			{
				return;
			}
			(eDimensionIndex, LG_LayerType, eLocalZoneIndex) original = (__instance.SpawnNode.m_dimension.DimensionIndex, __instance.SpawnNode.LayerType, __instance.SpawnNode.m_zone.LocalIndex);
			List<PortalEntry> list = PortalPuzzleChangerSetup.EnabledConfigs[RundownManager.ActiveExpedition.LevelLayoutData];
			foreach (PortalEntry item in list)
			{
				(eDimensionIndex, LG_LayerType, eLocalZoneIndex) comparingTo = (item.DimensionIndex, item.LayerType, item.ZoneIndex);
				if (DoesZoneMatch(original, comparingTo))
				{
					__instance.m_targetDimension = item.TargetDimension;
					__instance.m_targetZone = item.TargetZoneIndex;
					__instance.PortalChainPuzzle = item.PortalChainedPuzzleId;
					EntryPoint.Debug("Changing the ChainedPuzzleID on " + __instance.PublicName);
				}
			}
		}

		public static void Postfix(LG_DimensionPortal __instance)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			if (!PortalPuzzleChangerSetup.EnabledConfigs.ContainsKey(RundownManager.ActiveExpedition.LevelLayoutData))
			{
				return;
			}
			(eDimensionIndex, LG_LayerType, eLocalZoneIndex) original = (__instance.SpawnNode.m_dimension.DimensionIndex, __instance.SpawnNode.LayerType, __instance.SpawnNode.m_zone.LocalIndex);
			List<PortalEntry> list = PortalPuzzleChangerSetup.EnabledConfigs[RundownManager.ActiveExpedition.LevelLayoutData];
			foreach (PortalEntry item in list)
			{
				(eDimensionIndex, LG_LayerType, eLocalZoneIndex) comparingTo = (item.DimensionIndex, item.LayerType, item.ZoneIndex);
				if (DoesZoneMatch(original, comparingTo) && item.CreateTeamScanAsLast)
				{
					ChainedPuzzleInstance puzzleInstance = ChainedPuzzleManager.CreatePuzzleInstance(4u, __instance.SpawnNode.m_area, __instance.m_portalBioScanPoint.position, __instance.m_portalBioScanPoint);
					puzzleInstance.OnPuzzleSolved = __instance.m_portalChainPuzzleInstance.OnPuzzleSolved;
					__instance.m_portalChainPuzzleInstance.OnPuzzleSolved = Action.op_Implicit((Action)delegate
					{
						puzzleInstance.AttemptInteract((eChainedPuzzleInteraction)0);
					});
					EntryPoint.Debug("Adding team scan on " + __instance.PublicName);
				}
			}
		}

		private static bool DoesZoneMatch((eDimensionIndex, LG_LayerType, eLocalZoneIndex) original, (eDimensionIndex, LG_LayerType, eLocalZoneIndex) comparingTo)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			(eDimensionIndex, LG_LayerType, eLocalZoneIndex) tuple = original;
			(eDimensionIndex, LG_LayerType, eLocalZoneIndex) tuple2 = comparingTo;
			return tuple.Item1 == tuple2.Item1 && tuple.Item2 == tuple2.Item2 && tuple.Item3 == tuple2.Item3;
		}
	}
	[HarmonyPatch(typeof(HackingTool), "Setup")]
	public static class HackingToolTest
	{
		public static void Postfix(HackingTool __instance)
		{
		}
	}
	[HarmonyPatch(typeof(EnemyAgent), "SyncPlaceNavMarkerTag")]
	internal static class EnemyTagPatch
	{
		public static void Postfix(EnemyAgent __instance)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			if (EnemyTagChangerConfigSetup.EnabledConfigs.ContainsKey(__instance.EnemyDataID))
			{
				EnemyTagChanger enemyTagChanger = EnemyTagChangerConfigSetup.EnabledConfigs[__instance.EnemyDataID];
				NavMarker tagMarker = __instance.m_tagMarker;
				if (!string.IsNullOrEmpty(enemyTagChanger.CustomImagePath))
				{
					SpriteRenderer component = ((Component)tagMarker.m_enemySubObj).GetComponent<SpriteRenderer>();
					component.sprite = EntryPoint.CachedSprites[enemyTagChanger.CustomImagePath];
				}
				tagMarker.SetColor(enemyTagChanger.TagColor);
			}
		}
	}
	[HarmonyPatch(typeof(GrenadeBase), "Awake")]
	internal static class GrenadeBase_Setup
	{
		public static void Postfix(GrenadeBase __instance)
		{
			GrenadeProjectile grenadeProjectile = ((Component)__instance).gameObject.AddComponent<GrenadeProjectile>();
			((Behaviour)grenadeProjectile).enabled = true;
			grenadeProjectile.GrenadeBase = __instance;
		}
	}
	[HarmonyPatch(typeof(GrenadeBase), "GrenadeDelay")]
	internal static class GrenadeBase_GrenadeDelay
	{
		public static bool Prefix()
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(GrenadeBase), "Start")]
	internal static class GrenadeBase_Start
	{
		public static void Postfix(GrenadeBase __instance)
		{
			((MonoBehaviour)__instance).CancelInvoke("GrenadeDelay");
		}
	}
	[HarmonyPatch(typeof(BulletWeapon), "Fire")]
	internal static class BulletWeapon_Fire
	{
		public static void Prefix(BulletWeapon __instance)
		{
			if (GrenadeLauncherConfigSetup.EnabledConfigs.ContainsKey(((ItemEquippable)__instance).ArchetypeID))
			{
				GrenadeLauncherConfig config = GrenadeLauncherConfigSetup.EnabledConfigs[((ItemEquippable)__instance).ArchetypeID];
				GrenadeLauncherFire.Fire(__instance, config);
			}
		}
	}
	internal static class GrenadeLauncherFire
	{
		public static void Fire(BulletWeapon weapon, GrenadeLauncherConfig config)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			pItemData val = default(pItemData);
			val.itemID_gearCRC = 136u;
			Vector3 targetLookDir = ((Agent)((Item)weapon).Owner).TargetLookDir;
			Vector3 normalized = ((Vector3)(ref targetLookDir)).normalized;
			ItemReplicationManager.ThrowItem(val, (delItemCallback)null, (ItemMode)3, ((Component)((ItemEquippable)weapon).MuzzleAlign).transform.position, ((Component)((ItemEquippable)weapon).MuzzleAlign).transform.rotation, normalized * config.ShootForce, ((Component)weapon).transform.position, ((Agent)((Item)weapon).Owner).CourseNode, ((Item)weapon).Owner);
			((Weapon)weapon).MaxRayDist = 0f;
		}
	}
}
namespace PortalPuzzleChanger.GameScripts
{
	public class GrenadeProjectile : ConsumableInstance
	{
		public GrenadeBase GrenadeBase;

		private static FX_Pool explosionPool;

		private float damageRadiusHigh;

		private float damageRadiusLow;

		private float damageValueHigh;

		private float damageValueLow;

		private float explosionForce;

		private readonly int explosionTargetMask = LayerManager.MASK_EXPLOSION_TARGETS;

		private readonly int explosionBlockMask = LayerManager.MASK_EXPLOSION_BLOCKERS;

		private bool madeNoise = false;

		private bool collision = false;

		private bool addForce = false;

		private float decayTime;

		private Rigidbody rigidbody;

		private CellSoundPlayer cellSoundPlayer;

		public GrenadeProjectile(IntPtr hdl)
			: base(hdl)
		{
		}

		private void Awake()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			rigidbody = ((Component)this).GetComponent<Rigidbody>();
			cellSoundPlayer = new CellSoundPlayer();
			if (!Object.op_Implicit((Object)(object)explosionPool))
			{
				explosionPool = FX_Manager.GetEffectPool(AssetShardManager.GetLoadedAsset<GameObject>("Assets/AssetPrefabs/FX_Effects/FX_Tripmine.prefab", false));
			}
		}

		private void Start()
		{
			GrenadeLauncherConfig grenadeLauncherConfig = GrenadeLauncherConfigSetup.EnabledConfigs[((Item)GrenadeBase).Owner.Inventory.WieldedItem.ArchetypeID];
			damageRadiusHigh = grenadeLauncherConfig.MaximumDamageRange.Radius;
			damageRadiusLow = grenadeLauncherConfig.MinimumDamageRange.Radius;
			damageValueHigh = grenadeLauncherConfig.MaximumDamageRange.Damage;
			damageValueLow = grenadeLauncherConfig.MinimumDamageRange.Damage;
			explosionForce = grenadeLauncherConfig.ExplosionForce;
		}

		private void FixedUpdate()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			if (rigidbody.useGravity)
			{
				Vector3 val = ((Component)this).transform.position + rigidbody.velocity * Time.fixedDeltaTime;
			}
			else if (!madeNoise)
			{
				MakeNoise();
				((Component)this).transform.position = Vector3.down * 100f;
				madeNoise = true;
			}
		}

		private void Update()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (rigidbody.useGravity)
			{
				cellSoundPlayer.UpdatePosition(((Component)this).transform.position);
				if (collision)
				{
					DetonateSequence();
				}
			}
			else if (Time.time > decayTime)
			{
				((Item)GrenadeBase).ReplicationWrapper.Replicator.Despawn();
			}
		}

		private void OnCollisionEnter()
		{
			if (rigidbody.useGravity)
			{
				DetonateSequence();
			}
		}

		private void DetonateSequence()
		{
			//IL_001f: 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)
			Detonate();
			decayTime = Time.time + 10f;
			rigidbody.velocity = Vector3.zero;
			rigidbody.angularVelocity = Vector3.zero;
			rigidbody.useGravity = false;
		}

		private void Detonate()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			FX_EffectBase val = (FX_EffectBase)(object)explosionPool.AquireEffect();
			val.Play((FX_Trigger)null, ((Component)this).transform.position, Quaternion.LookRotation(Vector3.up));
			if (SNet.IsMaster)
			{
				DamageUtil.DoExplosionDamage(((Component)this).transform.position, damageRadiusHigh, damageValueHigh, explosionTargetMask, explosionBlockMask, addForce, explosionForce);
				DamageUtil.DoExplosionDamage(((Component)this).transform.position, damageRadiusLow, damageValueLow, explosionTargetMask, explosionBlockMask, addForce, explosionForce);
			}
		}

		private void MakeNoise()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Expected O, but got Unknown
			List<string> list = new List<string>();
			Il2CppReferenceArray<Collider> val = Physics.OverlapSphere(((Component)this).transform.position, 50f, LayerManager.MASK_ENEMY_DAMAGABLE);
			foreach (Collider item in (Il2CppArrayBase<Collider>)(object)val)
			{
				Dam_EnemyDamageLimb component = ((Component)item).GetComponent<Dam_EnemyDamageLimb>();
				if ((Object)(object)component == (Object)null)
				{
					continue;
				}
				EnemyAgent glueTargetEnemyAgent = component.GlueTargetEnemyAgent;
				if (!((Object)(object)glueTargetEnemyAgent == (Object)null) && !list.Contains(((Object)((Component)glueTargetEnemyAgent).gameObject).name))
				{
					list.Add(((Object)((Component)glueTargetEnemyAgent).gameObject).name);
					if (!Physics.Linecast(((Component)this).transform.position, ((Agent)glueTargetEnemyAgent).EyePosition, LayerManager.MASK_WORLD))
					{
						NM_NoiseData val2 = new NM_NoiseData
						{
							position = ((Agent)glueTargetEnemyAgent).EyePosition,
							node = ((Agent)glueTargetEnemyAgent).CourseNode,
							type = (NM_NoiseType)0,
							radiusMin = 0.01f,
							radiusMax = 100f,
							yScale = 1f,
							noiseMaker = null,
							raycastFirstNode = false,
							includeToNeightbourAreas = false
						};
						NoiseManager.MakeNoise(val2);
					}
				}
			}
			cellSoundPlayer.Post(EVENTS.FRAGGRENADEEXPLODE, true);
		}

		public override void OnDespawn()
		{
			((ItemWrapped)this).OnDespawn();
		}
	}
}
namespace PortalPuzzleChanger.ConfigFiles
{
	public class EnemyTagChanger
	{
		public bool internalEnabled { get; set; }

		public string internalName { get; set; }

		public uint EnemyID { get; set; }

		public Color TagColor { get; set; }

		public string CustomImagePath { get; set; }

		public EnemyTagChanger()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			internalEnabled = false;
			internalName = string.Empty;
			EnemyID = 0u;
			TagColor = Color.red;
			CustomImagePath = string.Empty;
		}
	}
	public class GrenadeLauncherConfig
	{
		public DamageMinMax MaximumDamageRange { get; set; }

		public DamageMinMax MinimumDamageRange { get; set; }

		public float ExplosionForce { get; set; }

		public float ShootForce { get; set; }

		public uint PersistentID { get; set; }

		public string internalName { get; set; }

		public bool internalEnabled { get; set; }

		public GrenadeLauncherConfig()
		{
			MaximumDamageRange = new DamageMinMax();
			MinimumDamageRange = new DamageMinMax();
			ExplosionForce = 1000f;
			PersistentID = 0u;
			internalName = string.Empty;
			internalEnabled = false;
		}
	}
	public class DamageMinMax
	{
		public float Radius { get; set; }

		public float Damage { get; set; }

		public DamageMinMax()
		{
			Radius = 0f;
			Damage = 0f;
		}
	}
	public class PortalChangerConfig
	{
		public uint MainLevelLayoutID { get; set; }

		public bool InternalEnabled { get; set; }

		public string? InternalName { get; set; }

		public List<PortalEntry> PortalEntries { get; set; }

		public PortalChangerConfig()
		{
			PortalEntries = new List<PortalEntry>
			{
				new PortalEntry()
			};
			InternalEnabled = false;
			InternalName = "Test";
			MainLevelLayoutID = 0u;
		}
	}
	public class PortalEntry
	{
		public eLocalZoneIndex ZoneIndex { get; set; }

		public LG_LayerType LayerType { get; set; }

		public eDimensionIndex DimensionIndex { get; set; }

		public eDimensionIndex TargetDimension { get; set; }

		public eLocalZoneIndex TargetZoneIndex { get; set; }

		public uint PortalChainedPuzzleId { get; set; }

		public bool CreateTeamScanAsLast { get; set; }

		public PortalEntry()
		{
			ZoneIndex = (eLocalZoneIndex)0;
			LayerType = (LG_LayerType)0;
			DimensionIndex = (eDimensionIndex)0;
			TargetDimension = (eDimensionIndex)1;
			TargetZoneIndex = (eLocalZoneIndex)0;
			PortalChainedPuzzleId = 4u;
			CreateTeamScanAsLast = false;
		}
	}
}

plugins/SURVIVAL/x64/Release/netstandard2.1/Oxygen.dll

Decompiled 5 days 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.Text.Json;
using System.Text.Json.Serialization;
using AK;
using Agents;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using GTFO.API;
using GTFO.API.Utilities;
using GameData;
using GameEvent;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using LevelGeneration;
using Localization;
using MTFO.Managers;
using Microsoft.CodeAnalysis;
using Oxygen.Components;
using Oxygen.Config;
using Oxygen.Utils;
using Oxygen.Utils.PartialData;
using Player;
using SNetwork;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Oxygen")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Oxygen")]
[assembly: AssemblyTitle("Oxygen")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 Oxygen
{
	[BepInPlugin("Inas.Oxygen", "Oxygen", "1.3.2")]
	[BepInProcess("GTFO.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BasePlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Action <0>__OnBuildDone;

			public static Action <1>__OnLevelCleanup;

			public static Action <2>__Setup;

			public static Action <3>__OnLevelCleanup;

			public static Action <4>__OnBuildStart;

			public static Action <5>__OnLevelCleanup;

			public static LiveEditEventHandler <6>__Listener_FileChanged1;
		}

		public const string MODNAME = "Oxygen";

		public const string AUTHOR = "Inas";

		public const string GUID = "Inas.Oxygen";

		public const string VERSION = "1.3.2";

		public static readonly string OXYGEN_CONFIG_PATH = Path.Combine(ConfigManager.CustomPath, "Oxygen");

		public static Dictionary<uint, OxygenBlock> lookup = new Dictionary<uint, OxygenBlock>();

		private static LiveEditListener listener = null;

		public override void Load()
		{
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Expected O, but got Unknown
			if (!Directory.Exists(OXYGEN_CONFIG_PATH))
			{
				Directory.CreateDirectory(OXYGEN_CONFIG_PATH);
				StreamWriter streamWriter = File.CreateText(Path.Combine(OXYGEN_CONFIG_PATH, "Template.json"));
				streamWriter.WriteLine(ConfigManager.Serialize(new OxygenConfig()));
				streamWriter.Flush();
				streamWriter.Close();
			}
			ClassInjector.RegisterTypeInIl2Cpp<AirManager>();
			LevelAPI.OnBuildDone += AirManager.OnBuildDone;
			LevelAPI.OnLevelCleanup += AirManager.OnLevelCleanup;
			ClassInjector.RegisterTypeInIl2Cpp<AirBar>();
			LevelAPI.OnBuildStart += AirBar.Setup;
			LevelAPI.OnLevelCleanup += AirBar.OnLevelCleanup;
			ClassInjector.RegisterTypeInIl2Cpp<AirPlane>();
			LevelAPI.OnBuildStart += AirPlane.OnBuildStart;
			LevelAPI.OnLevelCleanup += AirPlane.OnLevelCleanup;
			new Harmony("Inas.Oxygen").PatchAll();
			foreach (string item in Directory.EnumerateFiles(OXYGEN_CONFIG_PATH, "*.json", SearchOption.AllDirectories))
			{
				ConfigManager.Load<OxygenConfig>(item, out var config);
				foreach (OxygenBlock block in config.Blocks)
				{
					foreach (uint fogSetting in block.FogSettings)
					{
						if (!lookup.ContainsKey(fogSetting))
						{
							lookup.Add(fogSetting, block);
						}
					}
				}
			}
			listener = LiveEdit.CreateListener(OXYGEN_CONFIG_PATH, "*.json", true);
			LiveEditListener obj = listener;
			object obj2 = <>O.<6>__Listener_FileChanged1;
			if (obj2 == null)
			{
				LiveEditEventHandler val = Listener_FileChanged1;
				<>O.<6>__Listener_FileChanged1 = val;
				obj2 = (object)val;
			}
			obj.FileChanged += (LiveEditEventHandler)obj2;
		}

		private static void Listener_FileChanged1(LiveEditEventArgs e)
		{
			Log.Warning("LiveEdit File Changed: " + e.FullPath + ".");
			LiveEdit.TryReadFileContent(e.FullPath, (Action<string>)delegate(string content)
			{
				foreach (OxygenBlock block in ConfigManager.Deserialize<OxygenConfig>(content).Blocks)
				{
					foreach (uint fogSetting in block.FogSettings)
					{
						if (lookup.ContainsKey(fogSetting))
						{
							lookup.Remove(fogSetting);
						}
						lookup.Add(fogSetting, block);
						Log.Warning($"Replaced OxygenConfig for FogSetting: {fogSetting}.");
					}
				}
				if (GameStateManager.IsInExpedition)
				{
					AirManager.Current.UpdateAirConfig(AirManager.Current.FogSetting(), LiveEditForceUpdate: true);
				}
			});
		}
	}
}
namespace Oxygen.Utils
{
	internal static class Extension
	{
		public static T Instantiate<T>(this GameObject gameObject, string name) where T : Component
		{
			GameObject obj = Object.Instantiate<GameObject>(gameObject, gameObject.transform.parent, false);
			((Object)obj).name = name;
			return obj.GetComponent<T>();
		}
	}
	internal class LocalizedTextConverter : JsonConverter<LocalizedText>
	{
		public override bool HandleNull => false;

		public override LocalizedText Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			switch (reader.TokenType)
			{
			case JsonTokenType.String:
			{
				string @string = reader.GetString();
				return new LocalizedText
				{
					Id = 0u,
					UntranslatedText = @string
				};
			}
			case JsonTokenType.Number:
				return new LocalizedText
				{
					Id = reader.GetUInt32(),
					UntranslatedText = null
				};
			default:
				throw new JsonException($"LocalizedTextJson type: {reader.TokenType} is not implemented!");
			}
		}

		public override void Write(Utf8JsonWriter writer, LocalizedText value, JsonSerializerOptions options)
		{
			JsonSerializer.Serialize<LocalizedText>(writer, value, options);
		}
	}
	internal static class Log
	{
		private static ManualLogSource source;

		static Log()
		{
			source = Logger.CreateLogSource("Oxygen");
		}

		public static void Debug(object msg)
		{
			source.LogDebug(msg);
		}

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

		public static void Fatal(object msg)
		{
			source.LogFatal(msg);
		}

		public static void Info(object msg)
		{
			source.LogInfo(msg);
		}

		public static void Message(object msg)
		{
			source.LogMessage(msg);
		}

		public static void Warning(object msg)
		{
			source.LogWarning(msg);
		}
	}
}
namespace Oxygen.Utils.PartialData
{
	public static class MTFOPartialDataUtil
	{
		public const string PLUGIN_GUID = "MTFO.Extension.PartialBlocks";

		public static JsonConverter PersistentIDConverter { get; private set; }

		public static JsonConverter LocalizedTextConverter { get; private set; }

		public static bool IsLoaded { get; private set; }

		public static bool Initialized { get; private set; }

		public static string PartialDataPath { get; private set; }

		public static string ConfigPath { get; private set; }

		static MTFOPartialDataUtil()
		{
			PersistentIDConverter = null;
			LocalizedTextConverter = null;
			IsLoaded = false;
			Initialized = false;
			PartialDataPath = string.Empty;
			ConfigPath = string.Empty;
			if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("MTFO.Extension.PartialBlocks", out var value))
			{
				return;
			}
			try
			{
				Assembly obj = ((value == null) ? null : value.Instance?.GetType()?.Assembly) ?? null;
				if ((object)obj == null)
				{
					throw new Exception("Assembly is Missing!");
				}
				Type[] types = obj.GetTypes();
				Type type = types.First((Type t) => t.Name == "PersistentIDConverter");
				if ((object)type == null)
				{
					throw new Exception("Unable to Find PersistentIDConverter Class");
				}
				Type type2 = types.First((Type t) => t.Name == "LocalizedTextConverter");
				if ((object)type2 == null)
				{
					throw new Exception("Unable to Find LocalizedTextConverter Class");
				}
				Type obj2 = types.First((Type t) => t.Name == "PartialDataManager") ?? throw new Exception("Unable to Find PartialDataManager Class");
				PropertyInfo property = obj2.GetProperty("Initialized", BindingFlags.Static | BindingFlags.Public);
				PropertyInfo property2 = obj2.GetProperty("PartialDataPath", BindingFlags.Static | BindingFlags.Public);
				PropertyInfo? property3 = obj2.GetProperty("ConfigPath", BindingFlags.Static | BindingFlags.Public);
				if ((object)property == null)
				{
					throw new Exception("Unable to Find Property: Initialized");
				}
				if ((object)property2 == null)
				{
					throw new Exception("Unable to Find Property: PartialDataPath");
				}
				if ((object)property3 == null)
				{
					throw new Exception("Unable to Find Field: ConfigPath");
				}
				Initialized = (bool)property.GetValue(null);
				PartialDataPath = (string)property2.GetValue(null);
				ConfigPath = (string)property3.GetValue(null);
				PersistentIDConverter = (JsonConverter)Activator.CreateInstance(type);
				LocalizedTextConverter = (JsonConverter)Activator.CreateInstance(type2);
				IsLoaded = true;
			}
			catch (Exception value2)
			{
				Log.Error($"Exception thrown while reading data from MTFO_Extension_PartialData:\n{value2}");
			}
		}
	}
	public static class MTFOUtil
	{
		public const string PLUGIN_GUID = "com.dak.MTFO";

		public const BindingFlags PUBLIC_STATIC = BindingFlags.Static | BindingFlags.Public;

		public static string GameDataPath { get; private set; }

		public static string CustomPath { get; private set; }

		public static bool HasCustomContent { get; private set; }

		public static bool IsLoaded { get; private set; }

		static MTFOUtil()
		{
			GameDataPath = string.Empty;
			CustomPath = string.Empty;
			HasCustomContent = false;
			IsLoaded = false;
			if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("com.dak.MTFO", out var value))
			{
				return;
			}
			try
			{
				Assembly obj = ((value == null) ? null : value.Instance?.GetType()?.Assembly) ?? null;
				if ((object)obj == null)
				{
					throw new Exception("Assembly is Missing!");
				}
				Type obj2 = obj.GetTypes().First((Type t) => t.Name == "ConfigManager") ?? throw new Exception("Unable to Find ConfigManager Class");
				FieldInfo field = obj2.GetField("GameDataPath", BindingFlags.Static | BindingFlags.Public);
				FieldInfo field2 = obj2.GetField("CustomPath", BindingFlags.Static | BindingFlags.Public);
				FieldInfo? field3 = obj2.GetField("HasCustomContent", BindingFlags.Static | BindingFlags.Public);
				if ((object)field == null)
				{
					throw new Exception("Unable to Find Field: GameDataPath");
				}
				if ((object)field2 == null)
				{
					throw new Exception("Unable to Find Field: CustomPath");
				}
				if ((object)field3 == null)
				{
					throw new Exception("Unable to Find Field: HasCustomContent");
				}
				GameDataPath = (string)field.GetValue(null);
				CustomPath = (string)field2.GetValue(null);
				HasCustomContent = (bool)field3.GetValue(null);
				IsLoaded = true;
			}
			catch (Exception value2)
			{
				Log.Error($"Exception thrown while reading path from DataDumper (MTFO): \n{value2}");
			}
		}
	}
}
namespace Oxygen.Patches
{
	[HarmonyPatch]
	internal class Patches_Dam_PlayerDamageLocal
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveNoAirDamage")]
		public static bool Pre_ReceiveNoAirDamage(Dam_PlayerDamageLocal __instance, pMiniDamageData data)
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			float num = ((UFloat16)(ref data.damage)).Get(((Dam_SyncedDamageBase)__instance).HealthMax);
			((Dam_PlayerDamageBase)__instance).m_nextRegen = Clock.Time + ((Dam_PlayerDamageBase)__instance).Owner.PlayerData.healthRegenStartDelayAfterDamage;
			if (((Agent)((Dam_PlayerDamageBase)__instance).Owner).IsLocallyOwned)
			{
				DramaManager.CurrentState.OnLocalDamage(num);
				GameEventManager.PostEvent((eGameEvent)13, ((Dam_PlayerDamageBase)__instance).Owner, num, "", (Dictionary<string, string>)null);
			}
			else
			{
				DramaManager.CurrentState.OnTeammatesDamage(num);
			}
			if (((Dam_PlayerDamageBase)__instance).IgnoreAllDamage)
			{
				return false;
			}
			if (SNet.IsMaster && !((Dam_SyncedDamageBase)__instance).RegisterDamage(num))
			{
				((Dam_SyncedDamageBase)__instance).SendSetHealth(((Dam_SyncedDamageBase)__instance).Health);
			}
			__instance.Hitreact(((UFloat16)(ref data.damage)).Get(((Dam_SyncedDamageBase)__instance).HealthMax), Vector3.zero, true, false, false);
			return false;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveBulletDamage")]
		public static void Post_ReceiveBulletDamage()
		{
			AirManager.Current.ResetHealthToRegen();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveMeleeDamage")]
		public static void Post_ReceiveMeleeDamage()
		{
			AirManager.Current.ResetHealthToRegen();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveFireDamage")]
		public static void Post_ReceiveFireDamage()
		{
			AirManager.Current.ResetHealthToRegen();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveShooterProjectileDamage")]
		public static void Post_ReceiveShooterProjectileDamage()
		{
			AirManager.Current.ResetHealthToRegen();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveTentacleAttackDamage")]
		public static void Post_ReceiveTentacleAttackDamage()
		{
			AirManager.Current.ResetHealthToRegen();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceivePushDamage")]
		public static void Post_ReceivePushDamage()
		{
			AirManager.Current.ResetHealthToRegen();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveSetDead")]
		public static void Post_ReceiveSetDead()
		{
			AirManager.Current.ResetHealthToRegen();
		}
	}
	[HarmonyPatch(typeof(EnvironmentStateManager), "UpdateFog")]
	internal class EnvironmentStateManager_UpdateFog
	{
		public static void Prefix(EnvironmentStateManager __instance)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)AirManager.Current == (Object)null)
			{
				return;
			}
			FogState val = ((Il2CppArrayBase<FogState>)(object)__instance.m_stateReplicator.State.FogStates)[__instance.m_latestKnownLocalDimensionCreationIndex];
			if (val.FogDataID != 0)
			{
				AirManager.Current.UpdateAirConfig(val.FogDataID);
				if (!AirManager.Current.HasAirConfig())
				{
					AirManager.Current.StopInfectionLoop();
				}
			}
		}
	}
	[HarmonyPatch(typeof(FogRepeller_Sphere), "StartRepelling")]
	internal class FogRepeller_Sphere_StartRepelling
	{
		public static void Postfix(ref FogRepeller_Sphere __instance)
		{
			if (__instance.m_infectionShield != null)
			{
				EffectVolumeManager.UnregisterVolume((EffectVolume)(object)__instance.m_infectionShield);
				((EffectVolume)__instance.m_infectionShield).contents = (eEffectVolumeContents)0;
				EffectVolumeManager.RegisterVolume((EffectVolume)(object)__instance.m_infectionShield);
			}
		}
	}
	[HarmonyPatch(typeof(LocalPlayerAgentSettings), "UpdateBlendTowardsTargetFogSetting")]
	internal class LocalPlayerAgentSettings_UpdateBlendTowardsTargetFogSetting
	{
		public static void Postfix(LocalPlayerAgentSettings __instance, float amount)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			if (!AirManager.Current.HasAirConfig())
			{
				AirPlane.Current.Unregister();
			}
			else
			{
				if (__instance.m_targetFogSettings == null || !SNet.LocalPlayer.HasPlayerAgent)
				{
					return;
				}
				PlayerAgent localPlayerAgent = PlayerManager.GetLocalPlayerAgent();
				if ((Object)(object)localPlayerAgent.FPSCamera == (Object)null)
				{
					return;
				}
				AirPlane current = AirPlane.Current;
				if (!((Object)(object)current == (Object)null) && RundownManager.ExpeditionIsStarted)
				{
					float num = 0f;
					Dimension val = default(Dimension);
					if (Dimension.GetDimension(((Agent)localPlayerAgent).DimensionIndex, ref val))
					{
						num = val.GroundY;
					}
					PreLitVolume prelitVolume = localPlayerAgent.FPSCamera.PrelitVolume;
					((EffectVolume)current.airPlane).invert = (double)prelitVolume.m_densityHeightMaxBoost > (double)prelitVolume.m_fogDensity;
					((EffectVolume)current.airPlane).contents = (eEffectVolumeContents)1;
					((EffectVolume)current.airPlane).modification = (eEffectVolumeModification)0;
					((EffectVolume)current.airPlane).modificationScale = AirManager.Current.AirLoss();
					current.airPlane.lowestAltitude = prelitVolume.m_densityHeightAltitude + num;
					current.airPlane.highestAltitude = prelitVolume.m_densityHeightAltitude + prelitVolume.m_densityHeightRange + num;
					AirPlane.Current.Register();
				}
			}
		}
	}
	[HarmonyPatch]
	internal class Patch_PlayerAgent
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(PlayerAgent), "ReceiveModification")]
		public static void ReceiveModification(PlayerAgent __instance, ref EV_ModificationData data)
		{
			if (AirManager.Current.HasAirConfig())
			{
				if ((double)data.health != 0.0)
				{
					AirManager.Current.RemoveAir(data.health);
				}
				else
				{
					AirManager.Current.AddAir();
				}
				data.health = 0f;
			}
		}

		[HarmonyPostfix]
		[HarmonyWrapSafe]
		[HarmonyPatch(typeof(PlayerAgent), "Setup")]
		internal static void Post_Setup(PlayerAgent __instance)
		{
			if (((Agent)__instance).IsLocallyOwned)
			{
				AirManager.Setup(__instance);
			}
		}
	}
}
namespace Oxygen.Config
{
	public class ConfigManager
	{
		private static readonly JsonSerializerOptions s_SerializerOptions;

		public static T Deserialize<T>(string json)
		{
			return JsonSerializer.Deserialize<T>(json, s_SerializerOptions);
		}

		public static string Serialize<T>(T value)
		{
			return JsonSerializer.Serialize(value, s_SerializerOptions);
		}

		static ConfigManager()
		{
			s_SerializerOptions = new JsonSerializerOptions
			{
				AllowTrailingCommas = true,
				ReadCommentHandling = JsonCommentHandling.Skip,
				PropertyNameCaseInsensitive = true,
				WriteIndented = true
			};
			s_SerializerOptions.Converters.Add(new JsonStringEnumConverter());
			if (MTFOPartialDataUtil.IsLoaded && MTFOPartialDataUtil.Initialized)
			{
				s_SerializerOptions.Converters.Add(MTFOPartialDataUtil.PersistentIDConverter);
				s_SerializerOptions.Converters.Add(MTFOPartialDataUtil.LocalizedTextConverter);
				Log.Message("PartialData Support Found!");
			}
			else
			{
				s_SerializerOptions.Converters.Add(new LocalizedTextConverter());
			}
		}

		public static void Load<T>(string file, out T config) where T : new()
		{
			if (file.Length < ".json".Length)
			{
				config = default(T);
				return;
			}
			if (file.Substring(file.Length - ".json".Length) != ".json")
			{
				file += ".json";
			}
			file = File.ReadAllText(Path.Combine(ConfigManager.CustomPath, "Oxygen", file));
			config = Deserialize<T>(file);
		}
	}
	public class AirText
	{
		public float x { get; set; }

		public float y { get; set; }

		public LocalizedText Text { get; set; }
	}
	public class OxygenConfig
	{
		public List<OxygenBlock> Blocks { get; set; } = new List<OxygenBlock>
		{
			new OxygenBlock()
		};

	}
	public class OxygenBlock
	{
		public float AirLoss { get; set; }

		public float AirGain { get; set; } = 1f;


		public float DamageTime { get; set; } = 1f;


		public float DamageAmount { get; set; }

		public bool ShatterGlass { get; set; }

		public float ShatterAmount { get; set; }

		public float DamageThreshold { get; set; } = 0.1f;


		public bool AlwaysDisplayAirBar { get; set; }

		public float HealthRegenProportion { get; set; } = 1f;


		public float TimeToStartHealthRegen { get; set; } = 3f;


		public float TimeToCompleteHealthRegen { get; set; } = 5f;


		public AirText AirText { get; set; }

		public List<uint> FogSettings { get; set; } = new List<uint> { 0u };

	}
}
namespace Oxygen.Components
{
	public class AirBar : MonoBehaviour
	{
		public static AirBar Current;

		private TextMeshPro m_airText;

		private TextMeshPro m_airTextLocalization;

		private float m_airTextX;

		private float m_airTextY;

		private float m_airTextZ;

		private RectTransform m_air1;

		private RectTransform m_air2;

		private SpriteRenderer m_airBar1;

		private SpriteRenderer m_airBar2;

		private float m_airWidth = 100f;

		private float m_barHeightMin = 3f;

		private float m_barHeightMax = 9f;

		private Color m_airLow = new Color(0f, 0.5f, 0.5f);

		private Color m_airHigh = new Color(0f, 0.3f, 0.8f);

		public AirBar(IntPtr value)
			: base(value)
		{
		}//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)


		public static void Setup()
		{
			if ((Object)(object)Current == (Object)null)
			{
				Current = ((Component)GuiManager.Current.m_playerLayer.m_playerStatus).gameObject.AddComponent<AirBar>();
				Current.Init();
			}
		}

		private void Init()
		{
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)m_airText == (Object)null)
			{
				m_airText = ((Component)GuiManager.Current.m_playerLayer.m_playerStatus.m_healthText).gameObject.Instantiate<TextMeshPro>("AirText");
				TextMeshPro airText = m_airText;
				((TMP_Text)airText).fontSize = ((TMP_Text)airText).fontSize / 1.25f;
				m_airText.transform.Translate(0f, -30f, 0f);
			}
			if ((Object)(object)m_airTextLocalization == (Object)null)
			{
				m_airTextLocalization = ((Component)GuiManager.Current.m_playerLayer.m_playerStatus.m_pulseText).gameObject.Instantiate<TextMeshPro>("AirText Localization");
				((Behaviour)m_airTextLocalization).enabled = true;
				m_airTextLocalization.transform.Translate(300f - m_airWidth, -45f, 0f);
				m_airTextX = m_airTextLocalization.transform.position.x;
				m_airTextY = m_airTextLocalization.transform.position.y;
				m_airTextZ = m_airTextLocalization.transform.position.z;
			}
			if ((Object)(object)m_air1 == (Object)null)
			{
				m_air1 = ((Component)((Component)GuiManager.Current.m_playerLayer.m_playerStatus.m_health1).gameObject.transform.parent).gameObject.Instantiate<RectTransform>("AirFill Right");
				((Component)m_air1).transform.Translate(0f, -30f, 0f);
				SpriteRenderer component = ((Component)((Transform)m_air1).GetChild(0)).GetComponent<SpriteRenderer>();
				component.size = new Vector2(m_airWidth, component.size.y);
				m_airBar1 = ((Component)((Transform)m_air1).GetChild(1)).GetComponent<SpriteRenderer>();
				((Renderer)((Component)((Transform)m_air1).GetChild(2)).GetComponent<SpriteRenderer>()).enabled = false;
			}
			if ((Object)(object)m_air2 == (Object)null)
			{
				m_air2 = ((Component)((Component)GuiManager.Current.m_playerLayer.m_playerStatus.m_health2).gameObject.transform.parent).gameObject.Instantiate<RectTransform>("AirFill Left");
				((Component)m_air2).transform.Translate(0f, 30f, 0f);
				SpriteRenderer component2 = ((Component)((Transform)m_air2).GetChild(0)).GetComponent<SpriteRenderer>();
				component2.size = new Vector2(m_airWidth, component2.size.y);
				m_airBar2 = ((Component)((Transform)m_air2).GetChild(1)).GetComponent<SpriteRenderer>();
				((Renderer)((Component)((Transform)m_air2).GetChild(2)).GetComponent<SpriteRenderer>()).enabled = false;
			}
			UpdateAirBar(1f);
			SetVisible(vis: false);
		}

		public void UpdateAirBar(float air)
		{
			SetAirPercentageText(air);
			SetAirBar(m_airBar1, air);
			SetAirBar(m_airBar2, air);
		}

		private void SetAirBar(SpriteRenderer bar, float val)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			bar.size = new Vector2(val * m_airWidth, Mathf.Lerp(m_barHeightMin, m_barHeightMax, val));
			bar.color = Color.Lerp(m_airLow, m_airHigh, val);
		}

		private void SetAirPercentageText(float val)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			Color color = Color.Lerp(m_airLow, m_airHigh, val);
			((TMP_Text)m_airText).text = "O<size=75%>2</size>";
			((Graphic)m_airText).color = color;
			((TMP_Text)m_airText).ForceMeshUpdate(true, false);
			((Graphic)m_airTextLocalization).color = color;
			((TMP_Text)m_airTextLocalization).ForceMeshUpdate(true, false);
		}

		public void UpdateAirText(OxygenBlock config)
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			if (config != null)
			{
				string text = LocalizedText.op_Implicit(config.AirText.Text);
				float x = config.AirText.x;
				float y = config.AirText.y;
				((TMP_Text)m_airTextLocalization).text = text;
				((TMP_Text)m_airTextLocalization).ForceMeshUpdate(true, false);
				CoroutineManager.BlinkIn(((Component)m_airTextLocalization).gameObject, 0f);
				m_airTextLocalization.transform.SetPositionAndRotation(new Vector3(m_airTextX + x, m_airTextY + y, m_airTextZ), m_airTextLocalization.transform.rotation);
			}
		}

		public void SetVisible(bool vis)
		{
			((Component)m_airText).gameObject.SetActive(vis);
			((Component)m_airTextLocalization).gameObject.SetActive(vis);
			((Component)m_air1).gameObject.SetActive(vis);
			((Component)m_air2).gameObject.SetActive(vis);
		}

		public static void OnLevelCleanup()
		{
			if (!((Object)(object)Current == (Object)null))
			{
				Current.SetVisible(vis: false);
			}
		}
	}
	public class AirManager : MonoBehaviour
	{
		public static AirManager Current;

		public PlayerAgent m_playerAgent;

		private HUDGlassShatter m_hudGlass;

		private Dam_PlayerDamageBase Damage;

		public OxygenBlock config;

		private uint fogSetting;

		private FogSettingsDataBlock fogSettingDB;

		private float airAmount = 1f;

		private float damageTick;

		private float glassShatterAmount;

		private bool m_isInInfectionLoop;

		private bool isRegeningHealth;

		private float healthToRegen;

		private float healthRegenTick;

		private float tickUntilHealthRegenHealthStart;

		private readonly float regenHealthTickInterval = 0.25f;

		private float healthRegenAmountPerInterval;

		internal bool PlayerShouldCough;

		private readonly float CoughPerLoss = 0.1f;

		private float CoughLoss;

		public AirManager(IntPtr value)
			: base(value)
		{
		}

		public static void Setup(PlayerAgent playerAgent)
		{
			Current = ((Component)playerAgent).gameObject.AddComponent<AirManager>();
		}

		public static void OnBuildDone()
		{
			if (!((Object)(object)Current == (Object)null))
			{
				Current.m_playerAgent = PlayerManager.GetLocalPlayerAgent();
				Current.m_hudGlass = ((Component)Current.m_playerAgent.FPSCamera).GetComponent<HUDGlassShatter>();
				Current.Damage = ((Component)Current.m_playerAgent).gameObject.GetComponent<Dam_PlayerDamageBase>();
				Current.UpdateAirConfig(RundownManager.ActiveExpedition.Expedition.FogSettings);
				AirBar.Current.UpdateAirText(Current.config);
			}
		}

		public static void OnLevelCleanup()
		{
			if (!((Object)(object)Current == (Object)null))
			{
				if (Current.m_isInInfectionLoop)
				{
					Current.StopInfectionLoop();
				}
				Current.config = null;
				Current.fogSetting = 0u;
				Current.fogSettingDB = null;
				Current.airAmount = 0f;
				Current.damageTick = 0f;
				Current.glassShatterAmount = 0f;
				Current.healthToRegen = 0f;
				Current.m_playerAgent = null;
				Current.m_hudGlass = null;
				Current.Damage = null;
			}
		}

		private void Update()
		{
			if (!RundownManager.ExpeditionIsStarted)
			{
				return;
			}
			if (!HasAirConfig())
			{
				AirBar.Current.SetVisible(vis: false);
				return;
			}
			if (airAmount == 1f)
			{
				if (config.AlwaysDisplayAirBar)
				{
					AirBar.Current.SetVisible(vis: true);
				}
				else
				{
					AirBar.Current.SetVisible(vis: false);
				}
			}
			else
			{
				AirBar.Current.SetVisible(vis: true);
			}
			if (airAmount <= config.DamageThreshold)
			{
				damageTick += Time.deltaTime;
				if (damageTick > config.DamageTime && ((Agent)m_playerAgent).Alive)
				{
					AirDamage();
				}
				isRegeningHealth = false;
			}
			else if (healthToRegen > 0f)
			{
				tickUntilHealthRegenHealthStart += Time.deltaTime;
				if (tickUntilHealthRegenHealthStart > config.TimeToStartHealthRegen)
				{
					if (healthRegenAmountPerInterval == 0f)
					{
						healthRegenAmountPerInterval = healthToRegen * (regenHealthTickInterval / config.TimeToCompleteHealthRegen);
					}
					RegenHealth();
					if (!isRegeningHealth)
					{
						Damage.m_nextRegen = Clock.Time + config.TimeToStartHealthRegen + config.TimeToCompleteHealthRegen;
						isRegeningHealth = true;
					}
				}
			}
			else
			{
				isRegeningHealth = false;
			}
		}

		public void AddAir()
		{
			if (HasAirConfig())
			{
				float airGain = config.AirGain;
				airAmount = Mathf.Clamp01(airAmount + airGain);
				AirBar.Current.UpdateAirBar(airAmount);
				if (fogSettingDB.Infection <= 0f && m_isInInfectionLoop)
				{
					StopInfectionLoop();
				}
			}
		}

		public void RemoveAir(float amount)
		{
			if (HasAirConfig())
			{
				amount = config.AirLoss;
				airAmount = Mathf.Clamp01(airAmount - amount);
				AirBar.Current.UpdateAirBar(airAmount);
				if (fogSettingDB.Infection <= 0f && amount > 0f)
				{
					StartInfectionLoop();
				}
			}
		}

		public void AirDamage()
		{
			float health = ((Dam_SyncedDamageBase)Damage).Health;
			float damageAmount = config.DamageAmount;
			Damage.m_nextRegen = Clock.Time + config.TimeToStartHealthRegen;
			if (!(health <= 1f))
			{
				((Dam_SyncedDamageBase)Damage).NoAirDamage(damageAmount);
				if (config.ShatterGlass)
				{
					glassShatterAmount += config.ShatterAmount;
					m_hudGlass.SetGlassShatterProgression(glassShatterAmount);
				}
				damageTick = 0f;
				tickUntilHealthRegenHealthStart = 0f;
				healthRegenAmountPerInterval = 0f;
				healthToRegen += damageAmount * config.HealthRegenProportion;
				CoughLoss += damageAmount;
				if (CoughLoss > CoughPerLoss)
				{
					PlayerShouldCough = true;
					CoughLoss = 0f;
				}
			}
		}

		public void RegenHealth()
		{
			if (healthToRegen <= 0f)
			{
				return;
			}
			tickUntilHealthRegenHealthStart = config.TimeToStartHealthRegen;
			healthRegenTick += Time.deltaTime;
			if (healthRegenTick > regenHealthTickInterval)
			{
				float num = healthRegenAmountPerInterval;
				if (num >= healthToRegen)
				{
					num = healthToRegen;
					healthToRegen = 0f;
					tickUntilHealthRegenHealthStart = 0f;
					healthRegenAmountPerInterval = 0f;
					isRegeningHealth = false;
				}
				else
				{
					healthToRegen -= num;
				}
				((Dam_SyncedDamageBase)Damage).AddHealth(num, (Agent)(object)m_playerAgent);
				healthRegenTick = 0f;
			}
		}

		public void UpdateAirConfig(uint fogsetting, bool LiveEditForceUpdate = false)
		{
			if (fogsetting != 0 && (fogsetting != fogSetting || LiveEditForceUpdate))
			{
				if (Plugin.lookup.ContainsKey(fogsetting))
				{
					config = Plugin.lookup[fogsetting];
				}
				else if (Plugin.lookup.ContainsKey(0u))
				{
					config = Plugin.lookup[0u];
				}
				else
				{
					config = null;
					airAmount = 1f;
				}
				fogSetting = fogsetting;
				fogSettingDB = GameDataBlockBase<FogSettingsDataBlock>.GetBlock(fogsetting);
				if (GameStateManager.IsInExpedition)
				{
					AirBar.Current.UpdateAirText(config);
				}
			}
		}

		public void ResetHealthToRegen()
		{
			healthRegenTick = 0f;
			healthToRegen = 0f;
			tickUntilHealthRegenHealthStart = 0f;
		}

		public float AirLoss()
		{
			if (config != null)
			{
				return config.AirLoss;
			}
			return 0f;
		}

		public bool AlwaysDisplayAirBar()
		{
			if (config != null)
			{
				return config.AlwaysDisplayAirBar;
			}
			return false;
		}

		public uint FogSetting()
		{
			return fogSetting;
		}

		public float HealthToRegen()
		{
			return healthToRegen;
		}

		public string AirText()
		{
			return LocalizedText.op_Implicit((config == null) ? null : config.AirText.Text);
		}

		public float AirTextX()
		{
			if (config != null)
			{
				return config.AirText.x;
			}
			return 0f;
		}

		public float AirTextY()
		{
			if (config != null)
			{
				return config.AirText.y;
			}
			return 0f;
		}

		public bool HasAirConfig()
		{
			return config != null;
		}

		public void StartInfectionLoop()
		{
			if (!m_isInInfectionLoop)
			{
				m_playerAgent.Sound.Post(EVENTS.INFECTION_EFFECT_LOOP_START, true);
				m_isInInfectionLoop = true;
			}
		}

		public void StopInfectionLoop()
		{
			if (m_isInInfectionLoop)
			{
				if ((Object)(object)m_playerAgent != (Object)null && m_playerAgent.Sound != null)
				{
					m_playerAgent.Sound.Post(EVENTS.INFECTION_EFFECT_LOOP_STOP, true);
				}
				m_isInInfectionLoop = false;
			}
		}
	}
	public class AirPlane : MonoBehaviour
	{
		public static AirPlane Current;

		public EV_Plane airPlane;

		private bool isAirPlaneRegistered;

		public AirPlane(IntPtr value)
			: base(value)
		{
		}

		public static void OnBuildStart()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			if ((Object)(object)Current == (Object)null)
			{
				Current = ((Component)LocalPlayerAgentSettings.Current).gameObject.AddComponent<AirPlane>();
			}
			Current.airPlane = new EV_Plane();
			uint num = RundownManager.ActiveExpedition.Expedition.FogSettings;
			if (num == 0)
			{
				num = 21u;
			}
			OxygenBlock oxygenBlock = (Plugin.lookup.ContainsKey(num) ? Plugin.lookup[num] : ((!Plugin.lookup.ContainsKey(0u)) ? null : Plugin.lookup[0u]));
			FogSettingsDataBlock block = GameDataBlockBase<FogSettingsDataBlock>.GetBlock(num);
			((EffectVolume)Current.airPlane).invert = block.DensityHeightMaxBoost > block.FogDensity;
			((EffectVolume)Current.airPlane).contents = (eEffectVolumeContents)1;
			((EffectVolume)Current.airPlane).modification = (eEffectVolumeModification)0;
			Current.airPlane.lowestAltitude = block.DensityHeightAltitude;
			Current.airPlane.highestAltitude = block.DensityHeightAltitude + block.DensityHeightRange;
			if (oxygenBlock != null)
			{
				((EffectVolume)Current.airPlane).modificationScale = oxygenBlock.AirLoss;
				Current.Register();
			}
		}

		public static void OnLevelCleanup()
		{
			if (!((Object)(object)Current == (Object)null))
			{
				Current.Unregister();
				Current.isAirPlaneRegistered = false;
				Current.airPlane = null;
			}
		}

		public void Register()
		{
			if (airPlane != null && !isAirPlaneRegistered)
			{
				EffectVolumeManager.RegisterVolume((EffectVolume)(object)airPlane);
				isAirPlaneRegistered = true;
			}
		}

		public void Unregister()
		{
			if (airPlane != null && isAirPlaneRegistered)
			{
				EffectVolumeManager.UnregisterVolume((EffectVolume)(object)airPlane);
				isAirPlaneRegistered = false;
			}
		}
	}
}