Decompiled source of WILDCARDStuff v2.0.6

BepInEx/plugins/WildCardMod/LCWildCardMod.dll

Decompiled 4 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LCWildCardMod.Config;
using LCWildCardMod.Items;
using LCWildCardMod.NetcodePatcher;
using LCWildCardMod.Patches;
using LCWildCardMod.Utils;
using LethalCompanyInputUtils.Api;
using LethalLib.Extras;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Steamworks;
using TMPro;
using Unity.Netcode;
using Unity.Netcode.Components;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Audio;
using UnityEngine.InputSystem;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("LethalCompanyInputUtils")]
[assembly: IgnoresAccessChecksTo("LethalLib")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace LCWildCardMod
{
	[BepInPlugin("deB.WildCard", "WILDCARD Stuff", "2.0.6")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class WildCardMod : BaseUnityPlugin
	{
		public const string ModGUID = "deB.WildCard";

		public const string ModName = "WILDCARD Stuff";

		public const string ModVersion = "2.0.6";

		private static ReadOnlyDictionary<string, Type[]> publicHarmonies = null;

		private static ReadOnlyCollection<WildCardItem> publicScrapList = null;

		private static ReadOnlyCollection<WildCardSkin> publicSkinList = null;

		private static ReadOnlyCollection<WildCardMapObject> publicMapObjectList = null;

		private static readonly Dictionary<string, (Harmony, Type[])> harmonies = new Dictionary<string, (Harmony, Type[])>();

		internal static readonly List<WildCardItem> scrapList = new List<WildCardItem>();

		internal static readonly List<WildCardSkin> skinList = new List<WildCardSkin>();

		internal static readonly List<WildCardMapObject> mapObjectList = new List<WildCardMapObject>();

		private bool initialized = false;

		internal ManualLogSource Log => ((BaseUnityPlugin)this).Logger;

		internal static Dictionary<string, (Harmony, Type[])> Harmonies => harmonies;

		public static KeyBinds KeyBinds { get; private set; }

		public static WildCardMod Instance { get; private set; }

		public static WildCardConfig ModConfig { get; private set; }

		public static ReadOnlyDictionary<string, Type[]> HarmonyTypes
		{
			get
			{
				if (publicHarmonies == null)
				{
					publicHarmonies = new ReadOnlyDictionary<string, Type[]>(new Dictionary<string, Type[]>(Harmonies.Select((KeyValuePair<string, (Harmony, Type[])> x) => new KeyValuePair<string, Type[]>(x.Key, x.Value.Item2))));
				}
				return publicHarmonies;
			}
		}

		public static ReadOnlyCollection<WildCardItem> ScrapList
		{
			get
			{
				if (publicScrapList == null)
				{
					publicScrapList = new ReadOnlyCollection<WildCardItem>(scrapList);
				}
				return publicScrapList;
			}
		}

		public static ReadOnlyCollection<WildCardSkin> SkinList
		{
			get
			{
				if (publicSkinList == null)
				{
					publicSkinList = new ReadOnlyCollection<WildCardSkin>(skinList);
				}
				return publicSkinList;
			}
		}

		public static ReadOnlyCollection<WildCardMapObject> MapObjectList
		{
			get
			{
				if (publicMapObjectList == null)
				{
					publicMapObjectList = new ReadOnlyCollection<WildCardMapObject>(mapObjectList);
				}
				return publicMapObjectList;
			}
		}

		private void Awake()
		{
			Instance = this;
			KeyBinds = new KeyBinds();
			InitializeMethods();
			try
			{
				LoadFromBundle();
			}
			catch (Exception ex)
			{
				Log.LogError((object)"WILDCARD Stuff Failed to Load!");
				Log.LogError((object)ex);
				return;
			}
			if (AssetUpdate())
			{
				Log.LogInfo((object)"WILDCARD Stuff Successfully Loaded");
				initialized = true;
			}
		}

		internal bool AssetUpdate(AssetType toUpdate = AssetType.All)
		{
			bool result = true;
			try
			{
				InitializeAssets(toUpdate);
				HandleHarmony(toUpdate);
			}
			catch (Exception ex)
			{
				if (initialized)
				{
					Log.LogWarning((object)"WILDCARD Stuff Failed to Update Assets!");
					Log.LogWarning((object)ex);
				}
				else
				{
					Log.LogError((object)"WILDCARD Stuff Failed to Load!");
					Log.LogError((object)ex);
				}
				result = false;
			}
			return result;
		}

		private void InitializeMethods()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			for (int i = 0; i < types.Length; i++)
			{
				MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				for (int j = 0; j < methods.Length; j++)
				{
					object[] customAttributes = methods[j].GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methods[j].Invoke(null, null);
					}
				}
			}
		}

		private void LoadFromBundle()
		{
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "wildcardmod"));
			string[] allAssetNames = val.GetAllAssetNames();
			for (int i = 0; i < allAssetNames.Length; i++)
			{
				switch (allAssetNames[i].Substring(0, allAssetNames[i].LastIndexOf('/')))
				{
				case "assets/my creations/scrap items":
					scrapList.Add(val.LoadAsset<WildCardItem>(allAssetNames[i]));
					break;
				case "assets/my creations/skins":
					skinList.Add(val.LoadAsset<WildCardSkin>(allAssetNames[i]));
					break;
				case "assets/my creations/map objects":
					mapObjectList.Add(val.LoadAsset<WildCardMapObject>(allAssetNames[i]));
					break;
				default:
					Log.LogWarning((object)("\"" + allAssetNames[i] + "\" is not a known asset path, skipping."));
					break;
				}
			}
		}

		private void ModifyPrefab(GameObject toModify)
		{
			toModify.GetComponentInChildren<IWildCardBase>()?.Initialize();
			NetworkPrefabs.RegisterNetworkPrefab(toModify);
		}

		private void InitializeAssets(AssetType toUpdate)
		{
			if (!initialized)
			{
				ModConfig = new WildCardConfig(((BaseUnityPlugin)this).Config, scrapList, skinList, mapObjectList);
			}
			ModConfig.ResetReadonlyDicts();
			bool flag = toUpdate == AssetType.All;
			if (flag || toUpdate.HasFlag(AssetType.Scrap))
			{
				InitializeScraps();
			}
			if (flag || toUpdate.HasFlag(AssetType.Skin))
			{
				InitializeSkins();
			}
			if (flag || toUpdate.HasFlag(AssetType.MapObject))
			{
				InitializeMapObjects();
			}
		}

		private void InitializeScraps()
		{
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			publicScrapList = null;
			for (int i = 0; i < scrapList.Count; i++)
			{
				WildCardItem item = scrapList[i];
				string itemName = ((Item)item).itemName;
				bool enabled = item.enabled;
				item.enabled = ModConfig.ScrapEnabled[itemName];
				if (!item.enabled)
				{
					if (enabled)
					{
						if (ILifeSaver.IsLifeSaver(((Item)item).spawnPrefab, out var lifeSaver))
						{
							ILifeSaver.AllLifeSavers.Remove(lifeSaver.GetType().Name);
						}
						Items.RemoveScrapFromLevels((Item)(object)item, (LevelTypes)(-1), (string[])null);
						Items.scrapItems.Remove(((IEnumerable<ScrapItem>)Items.scrapItems).FirstOrDefault((Func<ScrapItem, bool>)((ScrapItem x) => (Object)(object)x.origItem == (Object)(object)item)));
						Log.LogInfo((object)("\"" + itemName + "\" scrap was disabled!"));
					}
				}
				else
				{
					if (enabled)
					{
						continue;
					}
					if (ILifeSaver.IsLifeSaver(((Item)item).spawnPrefab, out var lifeSaver2))
					{
						ILifeSaver.AllLifeSavers.Add(lifeSaver2.GetType().Name, new List<ILifeSaver>());
					}
					Dictionary<LevelTypes, int> dictionary = new Dictionary<LevelTypes, int>();
					Dictionary<string, int> dictionary2 = new Dictionary<string, int>();
					string[] array = ModConfig.ScrapSpawnWeights[itemName].Split(",");
					for (int num = 0; num < array.Length; num++)
					{
						string[] array2 = array[num].Split(':');
						if (array2.Length == 2 && int.TryParse(array2[1], out var result))
						{
							string text = array2[0];
							if (Enum.TryParse<LevelTypes>(text, out LevelTypes result2))
							{
								dictionary.Add(result2, result);
							}
							else
							{
								dictionary2.Add(text, result);
							}
						}
					}
					ModifyPrefab(((Item)item).spawnPrefab);
					Items.RegisterScrap((Item)(object)item, dictionary, dictionary2);
					Log.LogDebug((object)("\"" + itemName + "\" scrap was enabled!"));
				}
			}
		}

		private void InitializeSkins()
		{
			publicSkinList = null;
			for (int i = 0; i < skinList.Count; i++)
			{
				WildCardSkin wildCardSkin = skinList[i];
				string skinName = wildCardSkin.skinName;
				bool enabled = wildCardSkin.enabled;
				wildCardSkin.enabled = ModConfig.SkinEnabled[skinName];
				if (!wildCardSkin.enabled)
				{
					if (enabled)
					{
						Log.LogInfo((object)("\"" + skinName + "\" skin was disabled!"));
					}
				}
				else if (!enabled)
				{
					Log.LogDebug((object)("\"" + skinName + "\" skin was enabled!"));
				}
			}
		}

		private void InitializeMapObjects()
		{
			publicMapObjectList = null;
			WildCardProp oldMapObjectScrap = default(WildCardProp);
			WildCardProp mapObjectScrap = default(WildCardProp);
			for (int i = 0; i < mapObjectList.Count; i++)
			{
				WildCardMapObject mapObject = mapObjectList[i];
				string mapObjectName = mapObject.mapObjectName;
				bool enabled = mapObject.enabled;
				if (mapObject.autoHandle)
				{
					bool enabled2 = true;
					if (mapObject.configBools != null)
					{
						for (int j = 0; j < mapObject.configBools.Length; j++)
						{
							if ((ModConfig.ScrapEnabled.TryGetValue(mapObject.configBools[j], out var value) || ModConfig.SkinEnabled.TryGetValue(mapObject.configBools[j], out value) || ModConfig.MapObjectEnabled.TryGetValue(mapObject.configBools[j], out value)) && !value)
							{
								enabled2 = false;
								break;
							}
						}
					}
					mapObject.enabled = enabled2;
				}
				else
				{
					mapObject.enabled = ModConfig.MapObjectEnabled.TryGetValue(mapObjectName, out var value2) && value2;
				}
				if (!mapObject.enabled)
				{
					if (!enabled)
					{
						continue;
					}
					WildUtils.RemoveMapObject((IndoorMapHazardType)(object)mapObject, (LevelTypes)(-1));
					MapObjects.mapObjects.Remove(((IEnumerable<RegisteredMapObject>)MapObjects.mapObjects).FirstOrDefault((Func<RegisteredMapObject, bool>)((RegisteredMapObject x) => (Object)(object)x.indoorMapHazardType == (Object)(object)mapObject)));
					if (((IndoorMapHazardType)mapObject).prefabToSpawn.TryGetComponent<WildCardProp>(ref oldMapObjectScrap))
					{
						Items.plainItems.Remove(((IEnumerable<PlainItem>)Items.plainItems).FirstOrDefault((Func<PlainItem, bool>)((PlainItem x) => (Object)(object)x.item == (Object)(object)((GrabbableObject)oldMapObjectScrap).itemProperties)));
					}
					Log.LogInfo((object)("\"" + mapObjectName + "\" map object was disabled!"));
				}
				else if (!enabled)
				{
					ModifyPrefab(((IndoorMapHazardType)mapObject).prefabToSpawn);
					if (((IndoorMapHazardType)mapObject).prefabToSpawn.TryGetComponent<WildCardProp>(ref mapObjectScrap) && Items.plainItems.Find((PlainItem x) => (Object)(object)x.item == (Object)(object)((GrabbableObject)mapObjectScrap).itemProperties) == null)
					{
						ModifyPrefab(((GrabbableObject)mapObjectScrap).itemProperties.spawnPrefab);
						Items.RegisterItem(((GrabbableObject)mapObjectScrap).itemProperties);
					}
					WildUtils.RegisterMapObject((IndoorMapHazardType)(object)mapObject, (LevelTypes)(-1), mapObject.GetCurveFunc());
					Log.LogDebug((object)("\"" + mapObjectName + "\" map object was enabled!"));
				}
			}
		}

		private void HandleHarmony(AssetType toUpdate)
		{
			publicHarmonies = null;
			bool flag = toUpdate == AssetType.All;
			if (flag)
			{
				HarmonyHelper.TogglePatches("deB.WildCard", true, typeof(NecessaryPatches));
			}
			if (flag || toUpdate.HasFlag(AssetType.Scrap))
			{
				HarmonyHelper.TogglePatches("deB.WildCard.cojiro", ModConfig.ScrapEnabled.TryGetValue("Cojiro", out var value) && value, typeof(CojiroPatches));
				HarmonyHelper.TogglePatches("deB.WildCard.save", ILifeSaver.AnyEnabled, typeof(SavePatches));
				HarmonyHelper.TogglePatches("deB.WildCard.grace", ILifeSaver.AnyEnabled, typeof(EnemyAIGraceSavePatch));
			}
			if (flag || toUpdate.HasFlag(AssetType.Skin))
			{
				HarmonyHelper.TogglePatches("deB.WildCard.skins", WildCardSkin.AnyEnabled, typeof(SkinsPatches));
			}
			HarmonyHelper.TogglePatches("deB.WildCard.debug", ModConfig.Debug, typeof(DebugPatches));
		}
	}
}
namespace LCWildCardMod.Utils
{
	[CreateAssetMenu(menuName = "WildCard/Item", order = 1)]
	public class WildCardItem : Item
	{
		[Space(3f)]
		[Header("WildCardItem")]
		[Space(3f)]
		public bool defaultEnabled = true;

		public string defaultRarities = string.Empty;

		public bool usesButton = false;

		public bool enemyCanActivate = false;

		public bool enemyCanUseButton = false;

		public bool syncEnemyButton = false;

		internal bool enabled = false;
	}
	[CreateAssetMenu(menuName = "WildCard/Skin", order = 2)]
	public class WildCardSkin : ScriptableObject
	{
		public SkinType type;

		public string skinName;

		public string target;

		public bool skinEnabled;

		public int skinChance;

		public Mesh newMesh;

		public Material newMaterial;

		public AudioClip[] newAudioClips;

		public RuntimeAnimatorController newAnimationController;

		internal bool enabled = false;

		private static ManualLogSource Log => WildCardMod.Instance.Log;

		internal static bool AnyEnabled => WildCardMod.skinList.Any((WildCardSkin x) => x.enabled);

		internal static void SetSkin(EnemyAI enemy)
		{
			WildCardSkin randomSkin = GetRandomSkin(enemy.enemyType.enemyName, SkinType.Enemy);
			if (!((Object)(object)randomSkin == (Object)null))
			{
				string text = randomSkin.target;
				string text2 = text;
				if (text2 == "Earth Leviathan")
				{
					Log.LogDebug((object)("Skin \"" + randomSkin.skinName + "\" is being applied!"));
					Transform val = ((Component)enemy).transform.Find("MeshContainer");
					SkinnedMeshRenderer component = ((Component)val.Find("Renderer")).GetComponent<SkinnedMeshRenderer>();
					component.sharedMesh = randomSkin.newMesh;
					((Renderer)component).sharedMaterial = randomSkin.newMaterial;
					((Component)val.Find("Armature").Find("Bone").Find("Bone.001")
						.Find("Bone.003")
						.Find("Bone.002")
						.Find("ScanNode")).GetComponent<ScanNodeProperties>().headerText = randomSkin.skinName;
					SandWormAI component2 = ((Component)((Component)enemy).transform).GetComponent<SandWormAI>();
					component2.ambientRumbleSFX[0] = randomSkin.newAudioClips[0];
					component2.ambientRumbleSFX[1] = randomSkin.newAudioClips[0];
					component2.ambientRumbleSFX[2] = randomSkin.newAudioClips[0];
					AudioSource creatureSFX = ((EnemyAI)component2).creatureSFX;
					creatureSFX.volume *= 1.5f;
					component2.roarSFX[0] = randomSkin.newAudioClips[1];
					component2.roarSFX[1] = randomSkin.newAudioClips[2];
				}
				else
				{
					Log.LogError((object)("\"" + randomSkin.skinName + "\" did not match any known enemy type!"));
				}
			}
		}

		internal static void SetSkin(GrabbableObject item)
		{
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			WildCardSkin randomSkin = GetRandomSkin(item.itemProperties.itemName, SkinType.Item);
			if (!((Object)(object)randomSkin == (Object)null))
			{
				string text = randomSkin.target;
				string text2 = text;
				if (text2 == "Clown horn")
				{
					Log.LogDebug((object)("Skin \"" + randomSkin.skinName + "\" is being applied!"));
					Item val = Object.Instantiate<Item>(item.itemProperties);
					val.itemName = randomSkin.skinName;
					val.isConductiveMetal = false;
					val.grabSFX = randomSkin.newAudioClips[0];
					val.dropSFX = randomSkin.newAudioClips[1];
					val.toolTips[0] = "Squeeze : [LMB]";
					val.positionOffset = new Vector3(0.05f, 0.15f, -0.05f);
					item.useCooldown = 0.5f;
					MeshFilter component = val.spawnPrefab.GetComponent<MeshFilter>();
					component.mesh = randomSkin.newMesh;
					component.sharedMesh = randomSkin.newMesh;
					MeshFilter component2 = ((Component)((Component)item).transform).GetComponent<MeshFilter>();
					component2.mesh = randomSkin.newMesh;
					component2.sharedMesh = randomSkin.newMesh;
					MeshRenderer component3 = ((Component)((Component)item).transform).GetComponent<MeshRenderer>();
					((Renderer)component3).material = randomSkin.newMaterial;
					((Renderer)component3).sharedMaterial = randomSkin.newMaterial;
					((Component)((Component)item).transform.Find("ScanNode")).GetComponent<ScanNodeProperties>().headerText = randomSkin.skinName;
					Animator val2 = ((Component)item).gameObject.AddComponent<Animator>();
					val2.runtimeAnimatorController = randomSkin.newAnimationController;
					((Component)((Component)item).transform).GetComponent<NoisemakerProp>().triggerAnimator = val2;
					item.itemProperties = val;
				}
				else
				{
					Log.LogError((object)("\"" + randomSkin.skinName + "\" did not match any known item!"));
				}
			}
		}

		private static WildCardSkin GetRandomSkin(string target, SkinType type)
		{
			Random random = new Random(StartOfRound.Instance.randomMapSeed + 69);
			int num = 0;
			int num2 = 0;
			List<WildCardSkin> list = new List<WildCardSkin>();
			for (int i = 0; i < WildCardMod.skinList.Count; i++)
			{
				WildCardSkin wildCardSkin = WildCardMod.skinList[i];
				if (wildCardSkin.enabled && wildCardSkin.type == type && !(wildCardSkin.target != target))
				{
					list.Add(wildCardSkin);
				}
			}
			if (list.Count == 0)
			{
				return null;
			}
			for (int j = 0; j < list.Count; j++)
			{
				WildCardSkin wildCardSkin2 = list[j];
				string text = wildCardSkin2.skinName;
				int num3 = WildCardMod.ModConfig.SkinApplyChance[text];
				if (num3 <= 0)
				{
					Log.LogDebug((object)("Skin \"" + text + "\" was disabled!"));
					list.RemoveAt(j);
					j--;
				}
				else
				{
					Log.LogDebug((object)("Adding skin \"" + text + "\"'s chance weight!"));
					num2 += num3;
					num += 100 - num3;
				}
			}
			float num4 = (float)random.NextDouble();
			Log.LogDebug((object)"Rolling to see if a skin will be applied!");
			float num5 = 1f / (float)num;
			float num6 = 1f / (float)num2;
			if ((float)num * (num5 + num6) >= num4)
			{
				return null;
			}
			for (int num7 = list.Count - 1; num7 > 1; num7--)
			{
				int num8 = random.Next(num7 + 1);
				List<WildCardSkin> list2 = list;
				int index = num7;
				int index2 = num8;
				WildCardSkin value = list[num8];
				WildCardSkin value2 = list[num7];
				list2[index] = value;
				list[index2] = value2;
			}
			for (int k = 0; k < list.Count; k++)
			{
				WildCardSkin wildCardSkin3 = list[k];
				string text2 = wildCardSkin3.skinName;
				Log.LogDebug((object)("Rolling to see if \"" + text2 + "\" is selected!"));
				if ((float)WildCardMod.ModConfig.SkinApplyChance[text2] * num6 >= num4)
				{
					Log.LogDebug((object)("Skin \"" + text2 + "\" was selected!"));
					return wildCardSkin3;
				}
			}
			return null;
		}
	}
	[CreateAssetMenu(menuName = "WildCard/MapObject", order = 3)]
	public class WildCardMapObject : IndoorMapHazardType
	{
		public string mapObjectName;

		public List<SelectablePair<AnimationCurve>> levelCurves;

		public bool autoHandle;

		public string[] configBools;

		internal bool enabled = false;

		public Func<SelectableLevel, AnimationCurve> GetCurveFunc()
		{
			//IL_0021: 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_0037: 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_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)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			AnimationCurve curve = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
			{
				new Keyframe(0f, 0f),
				new Keyframe(0.5f, 1f),
				new Keyframe(1f, 2f)
			});
			if (levelCurves != null && (autoHandle || WildCardMod.ModConfig.DefaultMapObjectCurve[mapObjectName]))
			{
				return delegate(SelectableLevel val)
				{
					for (int i = 0; i < levelCurves.Count; i++)
					{
						SelectablePair<AnimationCurve> selectablePair = levelCurves[i];
						string id = selectablePair.id;
						if (!(id != ((Object)val).name))
						{
							curve = selectablePair.selectable;
							break;
						}
					}
					return curve;
				};
			}
			if (WildCardMod.ModConfig.MapObjectMinMax.TryGetValue(mapObjectName, out var value))
			{
				int x = ((Vector2Int)(ref value)).x;
				int y = ((Vector2Int)(ref value)).y;
				((Keyframe)(ref curve.keys[0])).value = x;
				((Keyframe)(ref curve.keys[1])).value = (float)(x + y) * 0.5f;
				((Keyframe)(ref curve.keys[2])).value = y;
			}
			return (SelectableLevel val) => curve;
		}
	}
	[Serializable]
	public class SelectLights : Selectable<Light>
	{
		[SerializeField]
		public bool enableOnSpawn = true;

		[SerializeField]
		public bool disableWhilePocketed = true;

		public SelectLights(int id, params Light[] arrayItems)
			: base(id, arrayItems)
		{
		}

		public override void Initialize(IWildCardBase wildCardBase)
		{
			base.Initialize(wildCardBase);
			Set(((Component)wildCardBase.Transform).GetComponentsInChildren<Light>());
		}

		public void EnableAll(bool networked = true)
		{
			for (int i = 0; i < base.Count; i++)
			{
				Enable(i, networked: false);
			}
			if (networked)
			{
				base.Base.SetLightEnabledNetworked(base.Id, enable: true);
			}
		}

		public void Enable(int index, bool networked = true)
		{
			if (InRange(index))
			{
				SetEnabled(index, enable: true);
				if (networked)
				{
					base.Base.SetLightEnabledNetworked(base.Id, enable: true, index);
				}
			}
		}

		public void DisableAll(bool networked = true)
		{
			for (int i = 0; i < base.Count; i++)
			{
				Disable(i, networked: false);
			}
			if (networked)
			{
				base.Base.SetLightEnabledNetworked(base.Id, enable: false);
			}
		}

		public void Disable(int index, bool networked = true)
		{
			if (InRange(index))
			{
				SetEnabled(index, enable: false);
				if (networked)
				{
					base.Base.SetLightEnabledNetworked(base.Id, enable: false, index);
				}
			}
		}

		private void SetEnabled(int index, bool enable)
		{
			if (InRange(index))
			{
				((Behaviour)base[index]).enabled = enable;
			}
		}
	}
	[Serializable]
	public class SelectRenderers : SelectableWithTextures<Renderer>
	{
		[SerializeField]
		public bool applyOnAwake = false;

		[SerializeField]
		public List<Mesh> meshes = null;

		[SerializeField]
		public bool enabled = true;

		[SerializeField]
		public ShadowCastingMode shadowMode = (ShadowCastingMode)1;

		[SerializeField]
		public MotionVectorGenerationMode motionMode = (MotionVectorGenerationMode)0;

		public SelectRenderers(int id, params Renderer[] arrayItems)
			: base(id, arrayItems)
		{
		}//IL_0017: 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)


		public override void Initialize(IWildCardBase wildCardBase)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Invalid comparison between Unknown and I4
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			base.Initialize(wildCardBase);
			for (int i = 0; i < base.Count; i++)
			{
				Renderer val = base[i];
				if ((int)val.motionVectorGenerationMode == 1)
				{
					val.motionVectorGenerationMode = motionMode;
				}
			}
		}

		public override void SetMaterialsTexture(int itemIndex, int textureIndex)
		{
			if (InRange(itemIndex) && InRangeTextures(textureIndex))
			{
				int num = base[itemIndex].materials.Length;
				for (int i = 0; i < num; i++)
				{
					SetMaterialTexture(itemIndex, i, textureIndex);
				}
			}
		}

		public override void SetMaterialTexture(int itemIndex, int materialIndex, int textureIndex)
		{
			if (InRange(itemIndex) && InRangeTextures(textureIndex))
			{
				Material[] materials = base[itemIndex].materials;
				if (materialIndex >= 0 && materialIndex < materials.Length)
				{
					materials[materialIndex].mainTexture = GetTexture(textureIndex);
				}
			}
		}

		public void AllApplyAll()
		{
			for (int i = 0; i < base.Count; i++)
			{
				ApplyAll(i);
			}
		}

		public void ApplyAll(int index)
		{
			if (InRange(index))
			{
				ApplySettings(index);
			}
		}

		public void AllApplySettings()
		{
			for (int i = 0; i < base.Count; i++)
			{
				ApplySettings(i);
			}
		}

		public void ApplySettings(int index)
		{
			//IL_0029: 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)
			if (InRange(index))
			{
				Renderer val = base[index];
				val.enabled = enabled;
				val.shadowCastingMode = shadowMode;
				val.motionVectorGenerationMode = motionMode;
			}
		}

		public void AllApplyMeshes(int index)
		{
			if (InRangeMeshes(index))
			{
				for (int i = 0; i < base.Count; i++)
				{
					ApplyMesh(i, index);
				}
			}
		}

		public void ApplyMesh(int index, int meshIndex)
		{
			Renderer val = base[index];
			Mesh sharedMesh = meshes[meshIndex];
			Renderer val2 = val;
			Renderer val3 = val2;
			MeshRenderer val4 = (MeshRenderer)(object)((val3 is MeshRenderer) ? val3 : null);
			if (val4 == null)
			{
				SkinnedMeshRenderer val5 = (SkinnedMeshRenderer)(object)((val3 is SkinnedMeshRenderer) ? val3 : null);
				if (val5 != null)
				{
					val5.sharedMesh = sharedMesh;
				}
			}
			else
			{
				((Component)val4).GetComponent<MeshFilter>().sharedMesh = sharedMesh;
			}
		}

		public void AddMeshes(params Mesh[] newMeshes)
		{
			foreach (Mesh item in newMeshes)
			{
				if (!meshes.Contains(item))
				{
					meshes.Add(item);
				}
			}
		}

		public void SetMeshes(params Mesh[] newMeshes)
		{
			meshes = newMeshes.ToList();
		}

		public void SetMesh(int index, Mesh newMesh)
		{
			if (InRangeMeshes(index))
			{
				meshes[index] = newMesh;
			}
		}

		public void RemoveMeshes(params Mesh[] toRemoveMeshes)
		{
			for (int i = 0; i < toRemoveMeshes.Length; i++)
			{
				meshes.Remove(toRemoveMeshes[i]);
			}
		}

		public void RemoveMeshes(int start, int count)
		{
			if (InRangeMeshes(start) && InRangeMeshes(start + count) && count > 0)
			{
				meshes.RemoveRange(start, count);
			}
		}

		public void RemoveMesh(int index)
		{
			if (InRangeMeshes(index))
			{
				RemoveMeshes(index, 1);
			}
		}

		public void ClearMeshes()
		{
			SetMeshes();
		}

		public bool InRangeMeshes(int index)
		{
			return index >= 0 && index < meshes.Count;
		}

		public int IndexOfMesh(Mesh mesh)
		{
			return meshes.IndexOf(mesh);
		}

		public void SetColours(float multiplier)
		{
			for (int i = 0; i < base.Count; i++)
			{
				SetColour(i, multiplier);
			}
		}

		public void SetColour(int index, float multiplier)
		{
			if (InRange(index))
			{
				int num = base[index].materials.Length;
				for (int i = 0; i < num; i++)
				{
					SetColourMaterial(index, i, multiplier);
				}
			}
		}

		public void SetColourMaterial(int index, int materialIndex, float multiplier)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			if (InRange(index))
			{
				Material[] materials = base[index].materials;
				if (materialIndex >= 0 && materialIndex < materials.Length)
				{
					Material obj = materials[materialIndex];
					obj.color *= multiplier;
				}
			}
		}

		public void SetColours(Color color, bool multiply = false)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < base.Count; i++)
			{
				SetColour(i, color, multiply);
			}
		}

		public void SetColour(int index, Color color, bool multiply = false)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (InRange(index))
			{
				int num = base[index].materials.Length;
				for (int i = 0; i < num; i++)
				{
					SetColourMaterial(index, i, color, multiply);
				}
			}
		}

		public void SetColourMaterial(int index, int materialIndex, Color color, bool multiply = false)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			if (!InRange(index))
			{
				return;
			}
			Material[] materials = base[index].materials;
			if (materialIndex >= 0 && materialIndex < materials.Length)
			{
				if (multiply)
				{
					Material obj = materials[materialIndex];
					obj.color *= color;
				}
				else
				{
					materials[materialIndex].color = color;
				}
			}
		}

		public void SetOffsets(Vector2 offset)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < base.Count; i++)
			{
				SetOffset(i, offset);
			}
		}

		public void SetOffset(int index, Vector2 offset)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (InRange(index))
			{
				int num = base[index].materials.Length;
				for (int i = 0; i < num; i++)
				{
					SetOffsetMaterial(index, i, offset);
				}
			}
		}

		public void SetOffsetMaterial(int index, int materialIndex, Vector2 offset)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (InRange(index))
			{
				Material[] materials = base[index].materials;
				if (materialIndex >= 0 && materialIndex < materials.Length)
				{
					materials[materialIndex].mainTextureOffset = offset;
				}
			}
		}
	}
	[Serializable]
	public class SelectParticles : SelectableWithTextures<Particles>
	{
		[SerializeField]
		public bool applyOnAwake = false;

		[SerializeField]
		public bool playOnAwake = false;

		[SerializeField]
		public bool looping = true;

		[SerializeField]
		public bool useGravity = true;

		[Min(0f)]
		[SerializeField]
		public float duration = 1f;

		[Min(0f)]
		[SerializeField]
		public float simulationSpeed = 1f;

		[Min(0f)]
		[SerializeField]
		public float minLife = 1f;

		[Min(0f)]
		[SerializeField]
		public float maxLife = 1f;

		[SerializeField]
		public float minGravity = 0f;

		[SerializeField]
		public float maxGravity = 0f;

		[Min(0f)]
		[SerializeField]
		public float minSize = 0.05f;

		[Min(0f)]
		[SerializeField]
		public float maxSize = 0.05f;

		[Range(-180f, 180f)]
		[SerializeField]
		public float minRotation = 0f;

		[Range(-180f, 180f)]
		[SerializeField]
		public float maxRotation = 0f;

		[Range(0f, 1f)]
		[SerializeField]
		public float flipAmount = 0f;

		[Min(1f)]
		[SerializeField]
		public int maxParticles = 5;

		[Min(0f)]
		[SerializeField]
		public float minTimeRate = 0f;

		[Min(0f)]
		[SerializeField]
		public float maxTimeRate = 0f;

		[Min(0f)]
		[SerializeField]
		public float minDistanceRate = 0f;

		[Min(0f)]
		[SerializeField]
		public float maxDistanceRate = 0f;

		[SerializeField]
		public List<BurstIntermediary> bursts = new List<BurstIntermediary>();

		public SelectParticles(int id, params ParticleSystem[] systems)
			: base(id, systems.Select((ParticleSystem x) => Particles.Create(x)).ToArray())
		{
		}

		public override void SetMaterialsTexture(int itemIndex, int textureIndex)
		{
			if (InRange(itemIndex) && InRangeTextures(textureIndex))
			{
				int num = ((Renderer)base[itemIndex].Renderer).materials.Length;
				for (int i = 0; i < num; i++)
				{
					SetMaterialTexture(itemIndex, i, textureIndex);
				}
			}
		}

		public override void SetMaterialTexture(int itemIndex, int materialIndex, int textureIndex)
		{
			if (InRange(itemIndex) && InRangeTextures(textureIndex))
			{
				Material[] materials = ((Renderer)base[itemIndex].Renderer).materials;
				if (materialIndex >= 0 && materialIndex < materials.Length)
				{
					materials[materialIndex].mainTexture = GetTexture(textureIndex);
				}
			}
		}

		public void AllApplyAll()
		{
			for (int i = 0; i < base.Count; i++)
			{
				ApplyAll(i);
			}
		}

		public void ApplyAll(int index)
		{
			if (InRange(index))
			{
				ApplySize(index);
				ApplyGravity(index);
				ApplyLifetime(index);
				ApplyRotation(index);
				ApplyEmission(index);
			}
		}

		public void SetColours(float multiplier)
		{
			for (int i = 0; i < base.Count; i++)
			{
				SetColour(i, multiplier);
			}
		}

		public void SetColour(int index, float multiplier)
		{
			if (InRange(index))
			{
				int num = ((Renderer)base[index].Renderer).materials.Length;
				for (int i = 0; i < num; i++)
				{
					SetColourMaterial(index, i, multiplier);
				}
			}
		}

		public void SetColourMaterial(int index, int materialIndex, float multiplier)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			if (InRange(index))
			{
				Material[] materials = ((Renderer)base[index].Renderer).materials;
				if (materialIndex >= 0 && materialIndex < materials.Length)
				{
					Material obj = materials[materialIndex];
					obj.color *= multiplier;
				}
			}
		}

		public void SetColours(Color color, bool multiply = false)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < base.Count; i++)
			{
				SetColour(i, color, multiply);
			}
		}

		public void SetColour(int index, Color color, bool multiply = false)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if (InRange(index))
			{
				int num = ((Renderer)base[index].Renderer).materials.Length;
				for (int i = 0; i < num; i++)
				{
					SetColourMaterial(index, i, color, multiply);
				}
			}
		}

		public void SetColourMaterial(int index, int materialIndex, Color color, bool multiply = false)
		{
			//IL_005c: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			if (!InRange(index))
			{
				return;
			}
			Material[] materials = ((Renderer)base[index].Renderer).materials;
			if (materialIndex >= 0 && materialIndex < materials.Length)
			{
				if (multiply)
				{
					Material obj = materials[materialIndex];
					obj.color *= color;
				}
				else
				{
					materials[materialIndex].color = color;
				}
			}
		}

		public void AllApplyEmission(bool replace, params BurstIntermediary[] newBursts)
		{
			if (replace)
			{
				SetBursts(newBursts);
			}
			else
			{
				AddBursts(newBursts);
			}
			AllApplyEmission();
		}

		public void AllApplyEmission()
		{
			for (int i = 0; i < base.Count; i++)
			{
				ApplyEmission(i);
			}
		}

		public void ApplyEmission(int index, bool replace, params BurstIntermediary[] newBursts)
		{
			if (InRange(index))
			{
				if (replace)
				{
					SetBursts(newBursts);
				}
				else
				{
					AddBursts(newBursts);
				}
				ApplyEmission(index);
			}
		}

		public void ApplyEmission(int index)
		{
			//IL_0025: 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_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_0042: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			if (InRange(index))
			{
				ParticleSystem system = base[index].System;
				MainModule main = system.main;
				((MainModule)(ref main)).maxParticles = maxParticles;
				EmissionModule emission = system.emission;
				MinMaxCurve rateOverTime = ((EmissionModule)(ref emission)).rateOverTime;
				MinMaxCurve rateOverDistance = ((EmissionModule)(ref emission)).rateOverDistance;
				if (Mathf.Approximately(minTimeRate, maxTimeRate))
				{
					((MinMaxCurve)(ref rateOverTime)).mode = (ParticleSystemCurveMode)0;
					((MinMaxCurve)(ref rateOverTime)).constant = minTimeRate;
					((EmissionModule)(ref emission)).rateOverTimeMultiplier = 1f;
				}
				else
				{
					((MinMaxCurve)(ref rateOverTime)).mode = (ParticleSystemCurveMode)3;
					((MinMaxCurve)(ref rateOverTime)).constantMin = minTimeRate;
					((MinMaxCurve)(ref rateOverTime)).constantMax = maxTimeRate;
				}
				if (Mathf.Approximately(minDistanceRate, maxDistanceRate))
				{
					((MinMaxCurve)(ref rateOverDistance)).mode = (ParticleSystemCurveMode)0;
					((MinMaxCurve)(ref rateOverDistance)).constant = minDistanceRate;
					((EmissionModule)(ref emission)).rateOverDistanceMultiplier = 1f;
				}
				else
				{
					((MinMaxCurve)(ref rateOverDistance)).mode = (ParticleSystemCurveMode)3;
					((MinMaxCurve)(ref rateOverDistance)).constantMin = minDistanceRate;
					((MinMaxCurve)(ref rateOverDistance)).constantMax = maxDistanceRate;
				}
				((EmissionModule)(ref emission)).rateOverTime = rateOverTime;
				((EmissionModule)(ref emission)).rateOverDistance = rateOverDistance;
				Burst[] array = (Burst[])(object)new Burst[bursts.Count];
				for (int i = 0; i < bursts.Count; i++)
				{
					array[i] = WildUtils.CreateBurst(bursts[i]);
				}
				((EmissionModule)(ref emission)).SetBursts(array);
			}
		}

		public void AddBursts(params BurstIntermediary[] newBursts)
		{
			foreach (BurstIntermediary item in newBursts)
			{
				if (!bursts.Contains(item))
				{
					bursts.Add(item);
				}
			}
		}

		public void SetBursts(params BurstIntermediary[] newBursts)
		{
			bursts = newBursts.ToList();
		}

		public void SetBurst(int index, BurstIntermediary newBurst)
		{
			if (InRangeBursts(index))
			{
				bursts[index] = newBurst;
			}
		}

		public void ReplaceBurst(int index, BurstIntermediary newBurst)
		{
			if (InRangeBursts(index))
			{
				bursts[index] = newBurst;
			}
		}

		public void RemoveBursts(params BurstIntermediary[] toRemoveBursts)
		{
			for (int i = 0; i < toRemoveBursts.Length; i++)
			{
				bursts.Remove(toRemoveBursts[i]);
			}
		}

		public void RemoveBursts(int start, int count)
		{
			if (InRangeBursts(start) && InRangeBursts(start + count) && count > 0)
			{
				bursts.RemoveRange(start, count);
			}
		}

		public void RemoveBurst(int index)
		{
			if (InRangeBursts(index))
			{
				RemoveBursts(index, 1);
			}
		}

		public void ClearBursts()
		{
			SetBursts();
		}

		public void AllApplyTiming()
		{
			for (int i = 0; i < base.Count; i++)
			{
				ApplyTiming(i);
			}
		}

		public void ApplyTiming(int index)
		{
			//IL_001e: 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)
			if (InRange(index))
			{
				MainModule main = base[index].System.main;
				((MainModule)(ref main)).loop = looping;
				((MainModule)(ref main)).duration = duration;
				((MainModule)(ref main)).simulationSpeed = simulationSpeed;
			}
		}

		public void AllApplyRotation()
		{
			for (int i = 0; i < base.Count; i++)
			{
				ApplyRotation(i);
			}
		}

		public void ApplyRotation(int index)
		{
			//IL_0021: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			if (InRange(index))
			{
				MainModule main = base[index].System.main;
				MinMaxCurve startRotation = ((MainModule)(ref main)).startRotation;
				if (Mathf.Approximately(minRotation, maxRotation))
				{
					((MinMaxCurve)(ref startRotation)).mode = (ParticleSystemCurveMode)0;
					((MinMaxCurve)(ref startRotation)).constant = minRotation;
					((MainModule)(ref main)).startRotationMultiplier = 1f;
				}
				else
				{
					((MinMaxCurve)(ref startRotation)).mode = (ParticleSystemCurveMode)3;
					((MinMaxCurve)(ref startRotation)).constantMin = minRotation;
					((MinMaxCurve)(ref startRotation)).constantMax = maxRotation;
				}
				((MainModule)(ref main)).flipRotation = flipAmount;
				((MainModule)(ref main)).startRotation = startRotation;
			}
		}

		public void AllApplyLifetime()
		{
			for (int i = 0; i < base.Count; i++)
			{
				ApplyLifetime(i);
			}
		}

		public void ApplyLifetime(int index)
		{
			//IL_0021: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			if (InRange(index))
			{
				MainModule main = base[index].System.main;
				MinMaxCurve startLifetime = ((MainModule)(ref main)).startLifetime;
				if (Mathf.Approximately(minLife, maxLife))
				{
					((MinMaxCurve)(ref startLifetime)).mode = (ParticleSystemCurveMode)0;
					((MinMaxCurve)(ref startLifetime)).constant = minLife;
					((MainModule)(ref main)).startLifetimeMultiplier = 1f;
				}
				else
				{
					((MinMaxCurve)(ref startLifetime)).mode = (ParticleSystemCurveMode)3;
					((MinMaxCurve)(ref startLifetime)).constantMin = minLife;
					((MinMaxCurve)(ref startLifetime)).constantMax = maxLife;
				}
				((MainModule)(ref main)).startLifetime = startLifetime;
			}
		}

		public void AllApplyGravity()
		{
			for (int i = 0; i < base.Count; i++)
			{
				ApplyGravity(i);
			}
		}

		public void ApplyGravity(int index)
		{
			//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_002b: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			if (InRange(index))
			{
				MainModule main = base[index].System.main;
				MinMaxCurve gravityModifier = ((MainModule)(ref main)).gravityModifier;
				float num = minGravity;
				float constantMax = maxGravity;
				if (!useGravity)
				{
					num = 0f;
					constantMax = 0f;
				}
				if (Mathf.Approximately(minGravity, maxGravity))
				{
					((MinMaxCurve)(ref gravityModifier)).mode = (ParticleSystemCurveMode)0;
					((MinMaxCurve)(ref gravityModifier)).constant = num;
					((MainModule)(ref main)).gravityModifierMultiplier = 1f;
				}
				else
				{
					((MinMaxCurve)(ref gravityModifier)).mode = (ParticleSystemCurveMode)3;
					((MinMaxCurve)(ref gravityModifier)).constantMin = num;
					((MinMaxCurve)(ref gravityModifier)).constantMax = constantMax;
				}
				((MainModule)(ref main)).gravityModifier = gravityModifier;
			}
		}

		public void AllApplySize()
		{
			for (int i = 0; i < base.Count; i++)
			{
				ApplySize(i);
			}
		}

		public void ApplySize(int index)
		{
			//IL_0021: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			if (InRange(index))
			{
				MainModule main = base[index].System.main;
				MinMaxCurve startSize = ((MainModule)(ref main)).startSize;
				if (Mathf.Approximately(minSize, maxSize))
				{
					((MinMaxCurve)(ref startSize)).mode = (ParticleSystemCurveMode)0;
					((MinMaxCurve)(ref startSize)).constant = minSize;
					((MainModule)(ref main)).startSizeMultiplier = 1f;
				}
				else
				{
					((MinMaxCurve)(ref startSize)).mode = (ParticleSystemCurveMode)3;
					((MinMaxCurve)(ref startSize)).constantMin = minSize;
					((MinMaxCurve)(ref startSize)).constantMax = maxSize;
				}
				((MainModule)(ref main)).startSize = startSize;
			}
		}

		public void PlayAll(bool restart = false, bool networked = true)
		{
			for (int i = 0; i < base.Count; i++)
			{
				Play(i, restart, networked: false);
			}
			if (networked)
			{
				base.Base.PlayParticlesNetworked(base.Id, restart);
			}
		}

		public void Play(int index, bool restart = false, bool networked = true)
		{
			if (InRange(index))
			{
				ParticleSystem system = base[index].System;
				if (restart)
				{
					system.Stop();
				}
				system.Play();
				if (networked)
				{
					base.Base.PlayParticlesNetworked(base.Id, restart, index);
				}
			}
		}

		public void StopAll(bool clear, bool networked = true)
		{
			for (int i = 0; i < base.Count; i++)
			{
				Stop(i, clear, networked: false);
			}
			if (networked)
			{
				base.Base.StopParticlesNetworked(base.Id, clear);
			}
		}

		public void Stop(int index, bool clear, bool networked = true)
		{
			if (InRange(index))
			{
				Particles particles = base[index];
				particles.System.Stop();
				if (clear)
				{
					particles.System.Clear();
				}
				if (networked)
				{
					base.Base.StopParticlesNetworked(base.Id, clear, index);
				}
			}
		}

		public void PauseAll(bool networked = true)
		{
			for (int i = 0; i < base.Count; i++)
			{
				Pause(i, networked: false);
			}
			if (networked)
			{
				base.Base.PauseParticlesNetworked(base.Id);
			}
		}

		public void Pause(int index, bool networked = true)
		{
			if (InRange(index))
			{
				base[index].System.Pause();
				if (networked)
				{
					base.Base.PauseParticlesNetworked(base.Id, index);
				}
			}
		}

		public void ClearAll(bool networked = true)
		{
			for (int i = 0; i < base.Count; i++)
			{
				Clear(i, networked: false);
			}
			if (networked)
			{
				base.Base.ClearParticlesNetworked(base.Id);
			}
		}

		public void Clear(int index, bool networked = true)
		{
			if (InRange(index))
			{
				base[index].System.Clear();
				if (networked)
				{
					base.Base.ClearParticlesNetworked(base.Id, index);
				}
			}
		}

		public void EmitAll(int count, bool networked = true)
		{
			for (int i = 0; i < base.Count; i++)
			{
				Emit(i, count, networked: false);
			}
			if (networked)
			{
				base.Base.EmitParticlesNetworked(base.Id, count);
			}
		}

		public void Emit(int index, int count, bool networked = true)
		{
			if (InRange(index))
			{
				base[index].System.Emit(count);
				if (networked)
				{
					base.Base.EmitParticlesNetworked(base.Id, count, index);
				}
			}
		}

		public bool AnyAlive()
		{
			for (int i = 0; i < base.Count; i++)
			{
				if (base[i].System.IsAlive())
				{
					return true;
				}
			}
			return false;
		}

		public bool InRangeBursts(int index)
		{
			return index >= 0 && index < bursts.Count;
		}

		public int IndexOfBurst(BurstIntermediary burst)
		{
			return bursts.IndexOf(burst);
		}
	}
	[Serializable]
	public class SelectAnimationParameters : SelectRepeater<RepeatingAnimation>
	{
		public SelectAnimationParameters(int id, AnimationHandler animationHandler)
			: base(id, animationHandler.Base.Random)
		{
			SetAnimator(animationHandler);
		}

		public SelectAnimationParameters(int id, NetworkAnimator networkAnimator)
			: this(id, AnimationHandler.Create(networkAnimator))
		{
		}

		public void SetAllValues(RepeatingAnimation.RandomAnimationType? type = null, params float?[] toChange)
		{
			for (int i = 0; i < base.Count; i++)
			{
				SetValues(i, type, toChange);
			}
		}

		public void SetValues(int index, RepeatingAnimation.RandomAnimationType? type = null, params float?[] toChange)
		{
			if (InRange(index))
			{
				base[index].SetValues(type, toChange);
			}
		}

		public void UpdateAllValues(params float?[] toChange)
		{
			for (int i = 0; i < base.Count; i++)
			{
				UpdateValues(i, toChange);
			}
		}

		public void UpdateValues(int index, params float?[] toChange)
		{
			if (InRange(index))
			{
				base[index].UpdateValues(toChange);
			}
		}

		public void DoAllAnimations(float? overrideValue = null)
		{
			for (int i = 0; i < base.Count; i++)
			{
				DoAnimation(i, overrideValue);
			}
		}

		public void DoAnimation(int index, float? overrideValue = null)
		{
			if (InRange(index))
			{
				base[index].DoAnimation(overrideValue);
			}
		}

		public void SetAnimator(AnimationHandler animator)
		{
			for (int i = 0; i < base.Count; i++)
			{
				base[i].SetAnimator(animator);
			}
		}
	}
	[Serializable]
	public abstract class SelectRepeater<T> : Selectable<T> where T : Repeater
	{
		[SerializeField]
		public bool playOnSpawn = false;

		[SerializeField]
		public bool clientsTick = false;

		public SelectRepeater(int id, Random random)
			: base(id, Array.Empty<T>())
		{
			SetRandom(random);
		}

		public void TickAll()
		{
			for (int i = 0; i < base.Count; i++)
			{
				Tick(i);
			}
		}

		public void Tick(int index)
		{
			if (InRange(index))
			{
				base[index].Tick();
			}
		}

		public void PauseAll()
		{
			for (int i = 0; i < base.Count; i++)
			{
				Pause(i);
			}
		}

		public void Pause(int index)
		{
			if (InRange(index))
			{
				base[index].Pause();
			}
		}

		public void ResumeAll()
		{
			for (int i = 0; i < base.Count; i++)
			{
				Resume(i);
			}
		}

		public void Resume(int index)
		{
			if (InRange(index))
			{
				base[index].Resume();
			}
		}

		public void SetFunctionAll(Func<bool> waitFor)
		{
			for (int i = 0; i < base.Count; i++)
			{
				SetFunction(i, waitFor);
			}
		}

		public void SetFunction(int index, Func<bool> waitFor)
		{
			if (InRange(index))
			{
				base[index].LoopWaitsFor = waitFor;
			}
		}

		public void PlayAll(bool resetTimer)
		{
			for (int i = 0; i < base.Count; i++)
			{
				Play(i, resetTimer);
			}
		}

		public void Play(int index, bool resetTimer)
		{
			if (InRange(index))
			{
				Repeater repeater = base[index];
				if (resetTimer)
				{
					repeater.ResetTimer();
				}
				repeater.TimerTrigger();
			}
		}

		public void PlayAll(Func<Repeater, bool> resetIf)
		{
			if (resetIf == null)
			{
				resetIf = (Repeater x) => false;
			}
			for (int num = 0; num < base.Count; num++)
			{
				Play(num, resetIf);
			}
		}

		public void Play(int index, Func<Repeater, bool> resetIf)
		{
			if (!InRange(index))
			{
				return;
			}
			Repeater repeater = base[index];
			if (resetIf == null)
			{
				resetIf = (Repeater x) => false;
			}
			if (resetIf(repeater))
			{
				repeater.ResetTimer();
			}
			repeater.TimerTrigger();
		}

		public void SetAllTimers(float? newMin = null, float? newMax = null, bool oneTime = false)
		{
			for (int i = 0; i < base.Count; i++)
			{
				SetTimer(i, newMin, newMax, oneTime);
			}
		}

		public void SetTimer(int index, float? newMin = null, float? newMax = null, bool oneTime = false)
		{
			if (InRange(index))
			{
				base[index].SetTimer(newMin, newMax, oneTime);
			}
		}

		public void ResetAllTimers(bool undoOneTime = true)
		{
			for (int i = 0; i < base.Count; i++)
			{
				ResetTimer(i, undoOneTime);
			}
		}

		public void ResetTimer(int index, bool undoOneTime = true)
		{
			if (InRange(index))
			{
				base[index].ResetTimer(undoOneTime);
			}
		}

		public void SetRandom(Random random)
		{
			for (int i = 0; i < base.Count; i++)
			{
				base[i].SetRandom(random);
			}
		}
	}
	[Serializable]
	public class SelectAudioClips : Selectable<AudioClip>
	{
		[SerializeField]
		public bool playOnSpawn = false;

		[SerializeField]
		private bool hudAudio = false;

		[SerializeField]
		private Transform audioParent = null;

		[SerializeField]
		private AnimationCurve customCurve = null;

		[SerializeField]
		private bool looping = false;

		[SerializeField]
		private bool clientsLoop = false;

		[SerializeField]
		private bool seamlessLoop = false;

		[Min(0f)]
		[SerializeField]
		private float minLoop = 0.5f;

		[Min(0f)]
		[SerializeField]
		private float maxLoop = 5f;

		[Min(0f)]
		[SerializeField]
		private float volumeMultiplier = 1f;

		[Min(0f)]
		[SerializeField]
		private float minVolume = 0.8f;

		[Min(0f)]
		[SerializeField]
		private float maxVolume = 1.2f;

		[Min(0f)]
		[SerializeField]
		private float pitchMultiplier = 1f;

		[Min(0f)]
		[SerializeField]
		private float minPitch = 0.75f;

		[Min(0f)]
		[SerializeField]
		private float maxPitch = 1.25f;

		[Min(0f)]
		[SerializeField]
		private float doppler = 1f;

		[Range(0f, 360f)]
		[SerializeField]
		private float spread = 0f;

		[SerializeField]
		public bool doWalkie = false;

		[SerializeField]
		public bool doAudible = false;

		[SerializeField]
		private bool audibleLoop = false;

		[SerializeField]
		private float minAudible = 2f;

		[SerializeField]
		private float maxAudible = 5f;

		[SerializeField]
		public bool trackTimesNearby = false;

		[Min(0f)]
		[SerializeField]
		private float audibleRange = 25f;

		[SerializeField]
		private bool doFar = false;

		[SerializeField]
		private bool vanillaOcclusion = false;

		[HideInInspector]
		[SerializeField]
		private AudioSource source = null;

		[HideInInspector]
		[SerializeField]
		private AudioSource farSource = null;

		[HideInInspector]
		[SerializeField]
		private bool loopCurrent = false;

		[HideInInspector]
		[SerializeField]
		private Vector2Int minMaxLoopRound;

		[HideInInspector]
		[SerializeField]
		private Vector2Int minMaxAudibleRound;

		[HideInInspector]
		[SerializeField]
		private float inverseVolumeMultiplier;

		[HideInInspector]
		[SerializeField]
		private Vector2Int minMaxVolumeRound;

		[HideInInspector]
		[SerializeField]
		private float inversePitchMultiplier;

		[HideInInspector]
		[SerializeField]
		private Vector2Int minMaxPitchRound;

		private float loopTime = 0f;

		private float audibleTime = 0f;

		private int timesNearby = 0;

		private Vector3 lastPlayedPosition = default(Vector3);

		private AudioClip lastClip = null;

		public bool HUDAudio => hudAudio;

		public bool Loops => looping && (clientsLoop || base.Base.IsServer);

		public float CloseRange
		{
			get
			{
				if (hudAudio)
				{
					return 0f;
				}
				return audibleRange;
			}
			private set
			{
				if (!hudAudio)
				{
					source.maxDistance = value;
					audibleRange = value;
					if (FarNoise)
					{
						FarRange = value * 3f;
					}
				}
			}
		}

		public float FarRange
		{
			get
			{
				if (hudAudio || (Object)(object)farSource == (Object)null)
				{
					return 0f;
				}
				return farSource.maxDistance;
			}
			private set
			{
				if (!hudAudio && !((Object)(object)farSource == (Object)null))
				{
					farSource.maxDistance = value;
				}
			}
		}

		public bool IsPlaying => (source.isPlaying && IndexOf(source.clip) != -1) || ((Object)(object)farSource != (Object)null && farSource.isPlaying && IndexOf(farSource.clip) != -1);

		public int TimesNearby
		{
			get
			{
				if (hudAudio)
				{
					return 0;
				}
				return timesNearby;
			}
			private set
			{
				if (!hudAudio)
				{
					timesNearby = value;
				}
			}
		}

		public Vector3 LastPosition
		{
			get
			{
				//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)
				return lastPlayedPosition;
			}
			private set
			{
				//IL_0002: 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)
				lastPlayedPosition = value;
			}
		}

		public AudioClip LastClip
		{
			get
			{
				if ((Object)(object)lastClip == (Object)null)
				{
					if (IsPlaying)
					{
						lastClip = source.clip;
					}
					else
					{
						lastClip = Random();
					}
				}
				return lastClip;
			}
			private set
			{
				lastClip = value;
			}
		}

		internal float ClipTime
		{
			get
			{
				return (float)source.timeSamples / (float)lastClip.frequency / source.clip.length;
			}
			set
			{
				source.time = value * source.clip.length;
				if (doFar && !((Object)(object)farSource != (Object)null))
				{
					farSource.time = value * farSource.clip.length;
				}
			}
		}

		internal bool FarNoise
		{
			get
			{
				if (!doFar || (Object)(object)farSource == (Object)null || !((Behaviour)farSource).enabled)
				{
					return false;
				}
				if ((Object)(object)GameNetworkManager.Instance == (Object)null)
				{
					return doFar;
				}
				PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
				return localPlayerController.isInsideFactory || (localPlayerController.spectatedPlayerScript?.isInsideFactory ?? false);
			}
			set
			{
				if (doFar && !((Object)(object)farSource == (Object)null))
				{
					((Behaviour)farSource).enabled = value;
				}
			}
		}

		public SelectAudioClips(int id, params AudioClip[] clips)
			: base(id, clips)
		{
		}//IL_0122: Unknown result type (might be due to invalid IL or missing references)


		public override void Initialize(IWildCardBase wildCardBase)
		{
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Expected O, but got Unknown
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Expected O, but got Unknown
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Expected O, but got Unknown
			loopCurrent = looping && !seamlessLoop;
			SetLoop(looping, minLoop, maxLoop);
			SetAudibleLoop(audibleLoop, minAudible, maxAudible);
			SetVolume(volumeMultiplier, minVolume, maxVolume);
			SetPitch(pitchMultiplier, minPitch, maxPitch);
			if (!hudAudio)
			{
				if ((Object)(object)audioParent == (Object)null)
				{
					audioParent = wildCardBase.Transform;
				}
				GameObject val = new GameObject($"{((Object)audioParent).name}_Audio_{base.Id}");
				val.transform.SetParent(audioParent);
				val.transform.localPosition = Vector3.zero;
				source = val.AddComponent<AudioSource>();
				source.playOnAwake = false;
				source.spatialBlend = 1f;
				source.rolloffMode = (AudioRolloffMode)2;
				Set3DSettings(doppler, spread, customCurve);
				if (vanillaOcclusion)
				{
					((Component)source).gameObject.AddComponent<OccludeAudio>();
				}
				else if (doFar)
				{
					GameObject val2 = new GameObject($"{((Object)audioParent).name}_FarAudio_{base.Id}");
					val2.transform.SetParent(audioParent);
					val2.transform.localPosition = Vector3.zero;
					farSource = val2.AddComponent<AudioSource>();
					farSource.playOnAwake = false;
					farSource.spatialBlend = 1f;
					farSource.rolloffMode = (AudioRolloffMode)2;
					farSource.SetCustomCurve((AudioSourceCurveType)0, new AnimationCurve((Keyframe[])(object)new Keyframe[3]
					{
						new Keyframe(0.2222f, 0f),
						new Keyframe(0.333f, 0.2f),
						new Keyframe(1f, 0f)
					}));
					farSource.spread = 75f;
					AudioReverbFilter val3 = val2.AddComponent<AudioReverbFilter>();
					val3.dryLevel = -5000f;
					val3.room = 0f;
					val3.roomHF = -3000f;
					val3.roomLF = -500f;
					val3.decayTime = 5f;
					val3.decayHFRatio = 2f;
					val3.reflectionsLevel = 0f;
					val3.reflectionsDelay = 0f;
					val3.reverbLevel = 1500f;
					val3.reverbDelay = 0f;
					val3.hfReference = 2000f;
					val3.lfReference = 500f;
					val3.diffusion = 100f;
					val3.density = 100f;
				}
				CloseRange = audibleRange;
			}
		}

		public void HUDOverride()
		{
			source = HUDManager.Instance.UIAudio;
		}

		public void SetMixer(AudioMixerGroup group)
		{
			if (!((Object)(object)source == (Object)null))
			{
				source.outputAudioMixerGroup = group;
				if (!((Object)(object)farSource == (Object)null))
				{
					farSource.outputAudioMixerGroup = group;
				}
			}
		}

		public void LoopTick()
		{
			if (loopCurrent)
			{
				if (loopTime > 0f)
				{
					loopTime -= Time.deltaTime;
				}
				else if (!IsPlaying)
				{
					float num = minLoop;
					if (!Mathf.Approximately(minLoop, maxLoop))
					{
						num = (float)base.Base.Random.Next(((Vector2Int)(ref minMaxLoopRound)).x, ((Vector2Int)(ref minMaxLoopRound)).y) * 0.01f;
					}
					loopTime = num;
					if (base.Count == 1)
					{
						RepeatClip(oneShot: false, !clientsLoop);
					}
					else
					{
						PlayRandomClip(oneShot: false, !clientsLoop);
					}
				}
			}
			if (hudAudio)
			{
				return;
			}
			if (!FarNoise)
			{
				FarRange = 0f;
			}
			else if (FarRange <= 0f)
			{
				FarRange = CloseRange * 3f;
			}
			if (audibleLoop)
			{
				if (audibleTime > 0f)
				{
					audibleTime -= Time.deltaTime;
				}
				else if (IsPlaying)
				{
					audibleTime = (float)base.Base.Random.Next(((Vector2Int)(ref minMaxAudibleRound)).x, ((Vector2Int)(ref minMaxAudibleRound)).y) * 0.01f;
					DogNoise(0.5f, 1f, !clientsLoop);
				}
			}
		}

		public void SetLoop(bool loop, float? loopMin = null, float? loopMax = null)
		{
			//IL_0093: 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)
			if (loopMin.HasValue)
			{
				minLoop = loopMin.Value;
			}
			if (loopMax.HasValue)
			{
				maxLoop = loopMax.Value;
			}
			minLoop = Mathf.Clamp(minLoop, 0f, maxLoop);
			maxLoop = Mathf.Clamp(maxLoop, minLoop, maxLoop);
			minMaxLoopRound = new Vector2Int(Mathf.RoundToInt(minLoop * 100f), Mathf.RoundToInt(maxLoop * 100f) + 1);
			if (seamlessLoop)
			{
				if ((Object)(object)source != (Object)null)
				{
					source.loop = loop;
					if (FarNoise)
					{
						farSource.loop = loop;
					}
				}
			}
			else
			{
				looping = loop;
			}
		}

		public void SetVolume(float? multiplier = null, float? volMin = null, float? volMax = null)
		{
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			if (multiplier.HasValue)
			{
				if ((Object)(object)source != (Object)null && IsPlaying)
				{
					AudioSource obj = source;
					obj.volume *= multiplier.Value * inverseVolumeMultiplier;
					if (FarNoise)
					{
						AudioSource obj2 = farSource;
						obj2.volume *= multiplier.Value * inverseVolumeMultiplier;
					}
				}
				volumeMultiplier = multiplier.Value;
				inverseVolumeMultiplier = 1f / volumeMultiplier;
			}
			if (volMin.HasValue)
			{
				minVolume = volMin.Value;
			}
			if (volMax.HasValue)
			{
				maxVolume = volMax.Value;
			}
			minVolume = Mathf.Clamp(minVolume, 0f, maxVolume);
			maxVolume = Mathf.Clamp(maxVolume, minVolume, maxVolume);
			minMaxVolumeRound = new Vector2Int(Mathf.RoundToInt(minVolume * 100f), Mathf.RoundToInt(maxVolume * 100f) + 1);
		}

		public void SetPitch(float? multiplier = null, float? pitchMin = null, float? pitchMax = null)
		{
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			if (multiplier.HasValue)
			{
				if ((Object)(object)source != (Object)null && IsPlaying)
				{
					AudioSource obj = source;
					obj.pitch *= multiplier.Value * inversePitchMultiplier;
					if (FarNoise)
					{
						AudioSource obj2 = farSource;
						obj2.pitch *= multiplier.Value * inversePitchMultiplier;
					}
				}
				pitchMultiplier = multiplier.Value;
				inversePitchMultiplier = 1f / pitchMultiplier;
			}
			if (pitchMin.HasValue)
			{
				minPitch = pitchMin.Value;
			}
			if (pitchMax.HasValue)
			{
				maxPitch = pitchMax.Value;
			}
			minPitch = Mathf.Clamp(minPitch, 0f, maxPitch);
			maxPitch = Mathf.Clamp(maxPitch, minPitch, maxPitch);
			minMaxPitchRound = new Vector2Int(Mathf.RoundToInt(minPitch * 100f), Mathf.RoundToInt(maxPitch * 100f) + 1);
		}

		public void SetAudibleLoop(bool loop, float? audibleMin = null, float? audibleMax = null)
		{
			//IL_009a: 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)
			audibleLoop = loop;
			if (audibleMin.HasValue)
			{
				minAudible = audibleMin.Value;
			}
			if (audibleMax.HasValue)
			{
				maxAudible = audibleMax.Value;
			}
			minAudible = Mathf.Clamp(minAudible, 0f, maxAudible);
			maxAudible = Mathf.Clamp(maxAudible, minAudible, maxAudible);
			minMaxAudibleRound = new Vector2Int(Mathf.RoundToInt(minAudible * 100f), Mathf.RoundToInt(maxAudible * 100f) + 1);
		}

		public void Set3DSettings(float? newDoppler = null, float? newSpread = null, AnimationCurve newCurve = null)
		{
			if (newDoppler.HasValue)
			{
				source.dopplerLevel = newDoppler.Value;
				doppler = newDoppler.Value;
			}
			if (newSpread.HasValue)
			{
				source.spread = newSpread.Value;
				spread = newSpread.Value;
			}
			if (newCurve != null && newCurve.keys.Length > 1)
			{
				source.SetCustomCurve((AudioSourceCurveType)0, newCurve);
				customCurve = newCurve;
			}
		}

		public bool PlayRandomOneshot(bool networked = true)
		{
			return PlayRandomClip(oneShot: true, networked);
		}

		public bool PlayRandomClip(bool oneShot = false, bool networked = true)
		{
			return PlayClip(RandomIndex(), oneShot, networked);
		}

		public bool PlayOneshot(int index, bool networked = true)
		{
			if (!InRange(index))
			{
				return false;
			}
			return PlayOneshot(base[index], networked);
		}

		public bool PlayOneshot(AudioClip clip, bool networked = true)
		{
			return PlayClip(clip, oneShot: true, networked);
		}

		public bool PlayClip(int index, bool oneShot = false, bool networked = true, float? volumeOverride = null, float? pitchOverride = null)
		{
			if (!InRange(index))
			{
				return false;
			}
			return PlayClip(base[index], oneShot, networked, volumeOverride, pitchOverride);
		}

		public bool PlayClip(AudioClip clip, bool oneShot = false, bool networked = true, float? volumeOverride = null, float? pitchOverride = null)
		{
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)source == (Object)null || (Object)(object)clip == (Object)null)
			{
				return false;
			}
			float num = volumeMultiplier;
			num = ((!volumeOverride.HasValue) ? (num * ((float)base.Base.Random.Next(((Vector2Int)(ref minMaxVolumeRound)).x, ((Vector2Int)(ref minMaxVolumeRound)).y) * 0.01f)) : volumeOverride.Value);
			if (num <= 0f)
			{
				return false;
			}
			LastClip = clip;
			float num2 = pitchMultiplier;
			num2 = ((!pitchOverride.HasValue) ? (num2 * ((float)base.Base.Random.Next(((Vector2Int)(ref minMaxPitchRound)).x, ((Vector2Int)(ref minMaxPitchRound)).y) * 0.01f)) : pitchOverride.Value);
			source.pitch = num2;
			source.loop = seamlessLoop;
			bool farNoise = FarNoise;
			if (farNoise)
			{
				farSource.pitch = num2;
				farSource.loop = seamlessLoop;
			}
			if (!seamlessLoop)
			{
				loopCurrent = Loops;
			}
			if (oneShot)
			{
				source.PlayOneShot(clip, num);
				if (farNoise)
				{
					farSource.PlayOneShot(clip, num);
				}
			}
			else
			{
				source.volume = num;
				source.clip = clip;
				source.Play();
				if (farNoise)
				{
					farSource.volume = num;
					farSource.clip = clip;
					farSource.Play();
				}
			}
			if (hudAudio)
			{
				return true;
			}
			if (networked)
			{
				base.Base.PlayClipNetworked(base.Id, IndexOf(clip), oneShot, num, num2);
			}
			if (trackTimesNearby)
			{
				TimesNearby++;
				if (Vector3.Distance(LastPosition, base.Base.Transform.position) > 2f)
				{
					TimesNearby = 0;
				}
			}
			else
			{
				TimesNearby = 0;
			}
			LastPosition = base.Base.Transform.position;
			if (doWalkie)
			{
				WalkieTalkie.TransmitOneShotAudio(source, clip, num);
			}
			if (!doAudible || CloseRange <= 0f)
			{
				return true;
			}
			DogNoise(num * 0.5f, num2, networked);
			return true;
		}

		public void DogNoise(float volume, float pitch, bool networked = true)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			if (base.Base is WildCardProp { isHeld: not false } wildCardProp && volume >= 0.3f)
			{
				wildCardProp.LastPlayerHeldBy.timeSinceMakingLoudNoise = 0f;
				flag = ((GrabbableObject)wildCardProp).isInElevator && StartOfRound.Instance.hangarDoorsClosed;
			}
			RoundManager.Instance.PlayAudibleNoise(LastPosition, CloseRange * Mathf.Max(0.5f, volume) * (1f + Mathf.Abs(pitch - 1f) * 0.5f), volume, TimesNearby, flag, 0);
			if (networked)
			{
				base.Base.DogNoiseNetworked(base.Id, volume, pitch);
			}
		}

		public void RepeatClip(bool oneShot = false, bool networked = true)
		{
			Stop(networked: false);
			PlayClip(LastClip, oneShot);
			if (networked)
			{
				base.Base.RepeatClipNetworked(base.Id, oneShot);
			}
		}

		public void Stop(bool networked = true)
		{
			if (Loops)
			{
				loopCurrent = false;
			}
			AudioSource obj = source;
			if (obj != null)
			{
				obj.Stop(true);
			}
			AudioSource obj2 = farSource;
			if (obj2 != null)
			{
				obj2.Stop(true);
			}
			if (networked)
			{
				base.Base.StopAudioNetworked(base.Id);
			}
		}

		public void SetPaused(bool pause, bool networked = true)
		{
			if (pause)
			{
				if (Loops)
				{
					loopCurrent = false;
				}
				AudioSource obj = source;
				if (obj != null)
				{
					obj.Pause();
				}
				AudioSource obj2 = farSource;
				if (obj2 != null)
				{
					obj2.Pause();
				}
			}
			else
			{
				if (Loops)
				{
					loopCurrent = true;
				}
				AudioSource obj3 = source;
				if (obj3 != null)
				{
					obj3.UnPause();
				}
				AudioSource obj4 = farSource;
				if (obj4 != null)
				{
					obj4.UnPause();
				}
			}
			if (networked)
			{
				base.Base.PauseAudioNetworked(base.Id, pause);
			}
		}

		public void SetMute(bool mute, bool networked = true)
		{
			if (mute)
			{
				Mute();
			}
			else
			{
				Unmute();
			}
			if (networked)
			{
				base.Base.MuteAudioNetworked(base.Id, mute);
			}
		}

		public void Mute()
		{
			if ((Object)(object)source != (Object)null)
			{
				source.mute = true;
			}
			if ((Object)(object)farSource != (Object)null)
			{
				farSource.mute = true;
			}
		}

		public void Unmute()
		{
			if ((Object)(object)source != (Object)null)
			{
				source.mute = false;
			}
			if ((Object)(object)farSource != (Object)null)
			{
				farSource.mute = false;
			}
		}
	}
	[Serializable]
	public class SelectModelVariants : SelectableWithWeights<GameObject>
	{
		[SerializeField]
		private Transform targetTransform = null;

		[SerializeField]
		private bool targetIsParent = false;

		[SerializeField]
		private string baseName = string.Empty;

		[SerializeField]
		private bool instantiateVariant = false;

		[SerializeField]
		public bool randomOnSpawn = false;

		[SerializeField]
		private bool perClient = false;

		[Min(0f)]
		[SerializeField]
		private int baseWeight = 0;

		private int currentVariant = -1;

		public int VariantIndex
		{
			get
			{
				return currentVariant;
			}
			set
			{
				if (InRange(value) || value == -1)
				{
					Switch(value, !perClient);
				}
			}
		}

		public GameObject Variant
		{
			get
			{
				GameObject val = null;
				if (InRange(currentVariant))
				{
					val = base[currentVariant].option;
				}
				return val ?? ((Component)targetTransform).gameObject;
			}
		}

		public SelectModelVariants(int id, params WeightedOption<GameObject>[] arrayItems)
			: base(id, arrayItems)
		{
		}

		public override void Initialize(IWildCardBase wildCardBase)
		{
			if ((Object)(object)targetTransform == (Object)null)
			{
				targetTransform = base.Base.Transform;
				targetIsParent = true;
			}
			if (baseWeight > 0)
			{
				Insert(0, new WeightedOption<GameObject>(baseName, ((Component)targetTransform).gameObject, baseWeight));
				currentVariant = 0;
				base.Base.Name = baseName;
			}
			base.Initialize(wildCardBase);
		}

		public bool Switch(int index, bool networked)
		{
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: 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_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			try
			{
				if (currentVariant == index)
				{
					return flag;
				}
				if (!InRange(index))
				{
					if (!targetIsParent)
					{
						if (InRange(currentVariant))
						{
							base[currentVariant].option.SetActive(false);
						}
						((Component)targetTransform).gameObject.SetActive(true);
						currentVariant = -1;
						flag = true;
					}
					return flag;
				}
				if (!instantiateVariant)
				{
					GameObject val = ((Component)targetTransform).gameObject;
					if (InRange(currentVariant))
					{
						val = base[currentVariant].option ?? val;
					}
					val.SetActive(false);
					GameObject val2 = base[index].option ?? ((Component)targetTransform).gameObject;
					val2.SetActive(true);
					currentVariant = index;
					flag = true;
					return flag;
				}
				Vector3 localPosition = targetTransform.localPosition;
				Quaternion localRotation = targetTransform.localRotation;
				Vector3 localScale = targetTransform.localScale;
				Transform parent = targetTransform;
				if (!targetIsParent)
				{
					parent = targetTransform.parent;
				}
				if (InRange(currentVariant) && (Object)(object)base[currentVariant].option != (Object)null)
				{
					Object.Destroy((Object)(object)base[currentVariant].option);
				}
				GameObject val3 = Object.Instantiate<GameObject>(base[index].option, parent);
				val3.transform.localPosition = localPosition;
				val3.transform.localRotation = localRotation;
				val3.transform.localScale = localScale;
				if (targetTransform == null)
				{
					targetTransform = val3.transform;
				}
				currentVariant = index;
				flag = true;
				return flag;
			}
			catch (Exception ex)
			{
				Debug.LogError((object)ex);
				return flag;
			}
			finally
			{
				if (flag)
				{
					string name = baseName;
					if (InRange(currentVariant))
					{
						name = base[currentVariant].name;
					}
					base.Base.Name = name;
					if (networked)
					{
						if (perClient)
						{
							base.Base.SetVariantNetworked(base.Id, RandomOptionIndex());
						}
						else
						{
							base.Base.SetVariantNetworked(base.Id, currentVariant);
						}
					}
				}
			}
		}

		public bool SwitchRandom(bool ignoreWeights = false, bool networked = true)
		{
			return Switch(RandomOptionIndex(ignoreWeights), networked);
		}
	}
	[Serializable]
	public abstract class SelectableWithWeights<T> : Selectable<WeightedOption<T>>
	{
		public int TotalWeight
		{
			get
			{
				int num = 0;
				for (int i = 0; i < base.Count; i++)
				{
					num += base[i].weight;
				}
				return num;
			}
		}

		public int[] Weights
		{
			get
			{
				int[] array = new int[base.Count];
				for (int i = 0; i < array.Length; i++)
				{
					array[i] = base[i].weight;
				}
				return array;
			}
		}

		public SelectableWithWeights(int id, params WeightedOption<T>[] arrayItems)
			: base(id, arrayItems)
		{
		}

		public override void Initialize(IWildCardBase wildCardBase)
		{
			Ratio();
		}

		public T RandomOption(bool ignoreWeights = false)
		{
			int index = RandomOptionIndex(ignoreWeights);
			if (!InRange(index))
			{
				return default(T);
			}
			return base[index].option;
		}

		public int RandomOptionIndex(bool ignoreWeights = false)
		{
			if (ignoreWeights)
			{
				return RandomIndex();
			}
			int num = base.Base.Random.Next(1, TotalWeight + 1);
			int num2 = 0;
			for (int i = 0; i < base.Count; i++)
			{
				WeightedOption<T> weightedOption = base[i];
				int weight = weightedOption.weight;
				if (weight != 0)
				{
					num2 += weight;
					if (num2 >= num)
					{
						return i;
					}
				}
			}
			return -1;
		}

		public void Equalize(bool ignoreZero = false)
		{
			for (int i = 0; i < base.Count; i++)
			{
				if (!ignoreZero || GetWeight(i) > 0)
				{
					SetWeight(i, 1);
				}
			}
		}

		public void SetWeight(int index, int weight)
		{
			if (InRange(index))
			{
				base[index].weight = weight;
			}
		}

		public int GetWeight(int index)
		{
			if (!InRange(index))
			{
				return 0;
			}
			return base[index].weight;
		}

		public void Ratio()
		{
			int num = Weights.GCD();
			if (num == 0)
			{
				return;
			}
			for (int i = 0; i < base.Count; i++)
			{
				if (base[i].weight < 0)
				{
					base[i].weight = 0;
				}
				base[i].weight /= num;
			}
		}
	}
	[Serializable]
	public abstract class SelectableWithTextures<T> : Selectable<T>
	{
		[SerializeField]
		private List<Texture> textures = new List<Texture>();

		public ReadOnlyCollection<Texture> Textures => new ReadOnlyCollection<Texture>(textures);

		public SelectableWithTextures(int id, params T[] arrayItems)
			: base(id, arrayItems)
		{
		}

		public abstract void SetMaterialsTexture(int itemIndex, int textureIndex);

		public abstract void SetMaterialTexture(int itemIndex, int materialIndex, int textureIndex);

		public void SetAllMaterialsTexture(int textureIndex)
		{
			for (int i = 0; i < base.Count; i++)
			{
				SetMaterialsTexture(i, textureIndex);
			}
		}

		public void SetAllMaterialsRandomTexture()
		{
			SetAllMaterialsTexture(RandomTextureIndex());
		}

		public void SetMaterialsRandomTexture(int itemIndex)
		{
			SetMaterialsTexture(itemIndex, RandomTextureIndex());
		}

		public void SetMaterialRandomTexture(int itemIndex, int materialIndex)
		{
			SetMaterialTexture(itemIndex, materialIndex, RandomTextureIndex());
		}

		public void AddTextures(params Texture[] newTextures)
		{
			foreach (Texture item in newTextures)
			{
				if (!textures.Contains(item))
				{
					textures.Add(item);
				}
			}
		}

		public void SetTextures(params Texture[] newTextures)
		{
			textures = newTextures.ToList();
		}

		public void SetTexture(int index, Texture newTexture)
		{
			if (InRangeTextures(index))
			{
				textures[index] = newTexture;
			}
		}

		public Texture GetTexture(int index)
		{
			if (!InRangeTextures(index))
			{
				return null;
			}
			return textures[index];
		}

		public void RemoveTextures(params Texture[] toRemoveTextures)
		{
			for (int i = 0; i < toRemoveTextures.Length; i++)
			{
				textures.Remove(toRemoveTextures[i]);
			}
		}

		public void RemoveTextures(int start, int count)
		{
			if (InRangeTextures(start) && InRangeTextures(start + count) && count > 0)
			{
				textures.RemoveRange(start, count);
			}
		}

		public void RemoveTexture(int index)
		{
			if (InRangeTextures(index))
			{
				RemoveTextures(index, 1);
			}
		}

		public void ClearTextures()
		{
			SetTextures();
		}

		public bool InRangeTextures(int index)
		{
			return index >= 0 && index < textures.Count;
		}

		public int IndexOfTexture(Texture texture)
		{
			return textures.IndexOf(texture);
		}

		public Texture RandomTexture()
		{
			if (textures.Count == 0)
			{
				return null;
			}
			return textures[RandomTextureIndex()];
		}

		public int RandomTextureIndex()
		{
			if (textures.Count == 0)
			{
				return 0;
			}
			return base.Base.Random.Next(0, textures.Count);
		}
	}
	[Serializable]
	public abstract class Selectable<T>
	{
		[SerializeField]
		private List<T> items = new List<T>();

		[HideInInspector]
		[SerializeField]
		private int id = 0;

		[HideInInspector]
		[SerializeField]
		internal bool initialized = false;

		private IWildCardBase wildCardBase = null;

		public int Id
		{
			get
			{
				return id;
			}
			internal set
			{
				id = value;
			}
		}

		public IWildCardBase Base => wildCardBase;

		public ReadOnlyCollection<T> Items => new ReadOnlyCollection<T>(items);

		public int Count
		{
			get
			{
				if (items == null)
				{
					return 0;
				}
				return items.Count;
			}
		}

		public T this[int index]
		{
			get
			{
				if (!InRange(index))
				{
					return default(T);
				}
				return items[index];
			}
			set
			{
				if (InRange(index))
				{
					items[index] = value;
				}
			}
		}

		public Selectable(int id, params T[] arrayItems)
		{
			Id = id;
			Set(arrayItems);
		}

		public virtual void Initialize(IWildCardBase wildCardBase)
		{
		}

		public void SetBase(IWildCardBase wildCardBase)
		{
			this.wildCardBase = wildCardBase;
			if (!initialized)
			{
				Initialize(wildCardBase);
				initialized = true;
			}
		}

		public T Random()
		{
			if (Count == 0)
			{
				return default(T);
			}
			return this[RandomIndex()];
		}

		public int RandomIndex()
		{
			if (Count == 0)
			{
				return 0;
			}
			return Base.Random.Next(0, Count);
		}

		public bool InRange(int index)
		{
			return index >= 0 && index < Count;
		}

		public void Add(params T[] newSelectables)
		{
			if (newSelectables != null)
			{
				Add(newSelectables.AsEnumerable());
			}
		}

		public void Add(IEnumerable<T> newSelectables)
		{
			if (newSelectables != null)
			{
				if (items == null)
				{
					Set(newSelectables);
				}
				else
				{
					items.AddRange(newSelectables);
				}
			}
		}

		public void Set(params T[] newSelectables)
		{
			if (newSelectables == null)
			{
				items?.Clear();
			}
			else
			{
				Set(newSelectables.AsEnumerable());
			}
		}

		public void Set(IEnumerable<T> newSelectables)
		{
			if (newSelectables == null)
			{
				items?.Clear();
			}
			else
			{
				items = newSelectables.ToList();
			}
		}

		public void Set(int index, T newSelectable)
		{
			if (InRange(index))
			{
				items[index] = newSelectable;
			}
		}

		public void Remove(params T[] toRemoveSelectables)
		{
			if (toRemoveSelectables != null && items != null)
			{
				Remove(toRemoveSelectables.AsEnumerable());
			}
		}

		public void Remove(IEnumerable<T> toRemoveSelectables)
		{
			if (toRemoveSelectables == null || items == null)
			{
				return;
			}
			for (int i = 0; i < Count; i++)
			{
				if (toRemoveSelectables.Contains(items[i]))
				{
					items.RemoveAt(i);
					i--;
				}
			}
		}

		public void Remove(int start, int count)
		{
			if (InRange(start) && InRange(start + count))
			{
				if (count == 1)
				{
					items.RemoveAt(start);
				}
				else
				{
					items.RemoveRange(start, count);
				}
			}
		}

		public void Remove(int index)
		{
			Remove(index, 1);
		}

		public void Insert(int index, T item)
		{
			if (item != null && items != null && InRange(index))
			{
				items.Insert(index, item);
			}
		}

		public void Insert(int index, params T[] toInsertSelectables)
		{
			if (toInsertSelectables != null && items != null && InRange(index))
			{
				Insert(index, toInsertSelectables.AsEnumerable());
			}
		}

		public void Insert(int index, IEnumerable<T> toInsertSelectables)
		{
			if (toInsertSelectables != null && items != null && InRange(index))
			{
				items.InsertRange(index, toInsertSelectables);
			}
		}

		public void Clear()
		{
			Set();
		}

		public int IndexOf(T selectable)
		{
			return items.IndexOf(selectable);
		}
	}
	public static class HarmonyHelper
	{
		internal static MethodInfo toString = AccessTools.Method(typeof(object), "ToString", (Type[])null, (Type[])null);

		internal static MethodInfo stringConcat3 = AccessTools.Method(typeof(string), "Concat", new Type[3]
		{
			typeof(string),
			typeof(string),
			typeof(string)
		}, (Type[])null);

		internal static MethodInfo logString = AccessTools.Method(typeof(HarmonyHelper), "LogString", new Type[1] { typeof(string) }, (Type[])null);

		internal static MethodInfo inequality = AccessTools.Method(typeof(Object), "op_Inequality", new Type[2]
		{
			typeof(Object),
			typeof(Object)
		}, (Type[])null);

		internal static MethodInfo mathfClamp3Int = AccessTools.Method(typeof(Mathf), "Clamp", new Type[3]
		{
			typeof(int),
			typeof(int),
			typeof(int)
		}, (Type[])null);

		internal static MethodInfo collision = AccessTools.Method(typeof(EnemyAI), "MeetsStandardPlayerCollisionConditions", new Type[3]
		{
			typeof(Collider),
			typeof(bool),
			typeof(bool)
		}, (Type[])null);

		internal static MethodInfo onCollision = AccessTools.Method(typeof(EnemyAI), "OnCollideWithPlayer", new Type[1] { typeof(Collider) }, (Type[])null);

		internal static MethodInfo exitDriver = AccessTools.Method(typeof(VehicleController), "ExitDriverSideSeat", (Type[])null, (Type[])null);

		internal static MethodInfo exitPassenger = AccessTools.Method(typeof(VehicleController), "ExitPassengerSideSeat", (Type[])null, (Type[])null);

		internal static MethodInfo savePlayer = AccessTools.Method(typeof(ILifeSaver), "TrySave", new Type[4]
		{
			typeof(PlayerControllerB),
			typeof(CauseOfDeath),
			typeof(Vector3),
			typeof(EnemyAI)
		}, (Type[])null);

		internal static MethodInfo savePlayerGrace = AccessTools.Method(typeof(ILifeSaver), "TrySaveGraceOnly", new Type[4]
		{
			typeof(PlayerControllerB),
			typeof(CauseOfDeath),
			typeof(Vector3),
			typeof(EnemyAI)
		}, (Type[])null);

		internal static MethodInfo savePlayerTrigger = AccessTools.Method(typeof(ILifeSaver), "TrySaveTriggerOnly", new Type[4]
		{
			typeof(PlayerControllerB),
			typeof(CauseOfDeath),
			typeof(Vector3),
			typeof(EnemyAI)
		}, (Type[])null);

		internal static MethodInfo killPlayer = AccessTools.Method(typeof(PlayerControllerB), "KillPlayer", new Type[6]
		{
			typeof(Vector3),
			typeof(bool),
			typeof(CauseOfDeath),
			typeof(int),
			typeof(Vector3),
			typeof(bool)
		}, (Type[])null);

		internal static MethodInfo damagePlayer = AccessTools.Method(typeof(PlayerControllerB), "DamagePlayer", new Type[7]
		{
			typeof(int),
			typeof(bool),
			typeof(bool),
			typeof(CauseOfDeath),
			typeof(int),
			typeof(bool),
			typeof(Vector3)
		}, (Type[])null);

		internal static MethodInfo makeInjured = AccessTools.Method(typeof(PlayerControllerB), "MakeCriticallyInjured", new Type[1] { typeof(bool) }, (Type[])null);

		internal static MethodInfo updateHealth = AccessTools.Method(typeof(HUDManager), "UpdateHealthUI", new Type[2]
		{
			typeof(int),
			typeof(bool)
		}, (Type[])null);

		internal static MethodInfo switchBehaviour = AccessTools.Method(typeof(EnemyAI), "SwitchToBehaviourState", new Type[1] { typeof(int) }, (Type[])null);

		internal static MethodInfo switchBehaviourLocal = AccessTools.Method(typeof(EnemyAI), "SwitchToBehaviourStateOnLocalClient", new Type[1] { typeof(int) }, (Type[])null);

		internal static MethodInfo allowDeath = AccessTools.Method(typeof(PlayerControllerB), "AllowPlayerDeath", (Type[])null, (Type[])null);

		internal static MethodInfo cancelSpecialAnim = AccessTools.Method(typeof(EnemyAI), "CancelSpecialAnimationWithPlayer", (Type[])null, (Type[])null);

		internal static MethodInfo beeKill = AccessTools.Method(typeof(RedLocustBees), "BeeKillPlayerOnLocalClient", new Type[1] { typeof(int) }, (Type[])null);

		internal static MethodInfo dogKill = AccessTools.Method(typeof(MouthDogAI), "KillPlayerServerRpc", new Type[1] { typeof(int) }, (Type[])null);

		internal static MethodInfo jesterKill = AccessTools.Method(typeof(JesterAI), "KillPlayerServerRpc", new Type[1] { typeof(int) }, (Type[])null);

		internal static MethodInfo dwellerKill = AccessTools.Method(typeof(CaveDwellerAI), "KillPlayerAnimationServerRpc", new Type[1] { typeof(int) }, (Type[])null);

		internal static MethodInfo bloomBurst = AccessTools.Method(typeof(CadaverBloomAI), "BurstForth", new Type[4]
		{
			typeof(PlayerControllerB),
			typeof(bool),
			typeof(Vector3),
			typeof(Vector3)
		}, (Type[])null);

		internal static MethodInfo foxCancelReel = AccessTools.Method(typeof(BushWolfEnemy), "CancelReelingPlayerIn", (Type[])null, (Type[])null);

		internal static MethodInfo cadaverCure = AccessTools.Method(typeof(CadaverGrowthAI), "CurePlayer", new Type[1] { typeof(int) }, (Type[])null);

		internal static MethodInfo cadaverCureRPC = AccessTools.Method(typeof(CadaverGrowthAI), "CurePlayerRpc", new Type[1] { typeof(int) }, (Type[])null);

		internal static MethodInfo giantStopKill = AccessTools.Method(typeof(ForestGiantAI), "StopKillAnimation", (Type[])null, (Type[])null);

		internal static MethodInfo ghostStopChase = AccessTools.Method(typeof(DressGirlAI), "StopChasing", (Type[])null, (Type[])null);

		internal static FieldInfo playerName = AccessTools.Field(typeof(PlayerControllerB), "playerUsername");

		internal static FieldInfo playerClientId = AccessTools.Field(typeof(PlayerControllerB), "playerClientId");

		internal static FieldInfo enemyType = AccessTools.Field(typeof(EnemyAI), "enemyType");

		internal static FieldInfo enemyName = AccessTools.Field(typeof(EnemyType), "enemyName");

		internal static FieldInfo foxInKill = AccessTools.Field(typeof(BushWolfEnemy), "inKillAnimation");

		internal static FieldInfo clingPlayer = AccessTools.Field(typeof(CentipedeAI), "clingingToPlayer");

		internal static FieldInfo timesSeenByPlayer = AccessTools.Field(typeof(DressGirlAI), "timesSeenByPlayer");

		internal static FieldInfo timesStared = AccessTools.Field(typeof(DressGirlAI), "timesStared");

		internal static FieldInfo couldNotStare = AccessTools.Field(typeof(DressGirlAI), "couldNotStareLastAttempt");

		internal static FieldInfo hauntingPlayer = AccessTools.Field(typeof(DressGirlAI), "hauntingPlayer");

		internal static FieldInfo maskHeldBy = AccessTools.Field(typeof(HauntedMaskItem), "previousPlayerHeldBy");

		internal static FieldInfo specialAnim = AccessTools.Field(typeof(EnemyAI), "inSpecialAnimationWithPlayer");

		internal static FieldInfo playerSinking = AccessTools.Field(typeof(PlayerControllerB), "sinkingValue");

		internal static FieldInfo playerHealth = AccessTools.Field(typeof(PlayerControllerB), "health");

		internal static FieldInfo giantPlayerStealth = AccessTools.Field(typeof(ForestGiantAI), "playerStealthMeters");

		private static readonly ReadOnlyDictionary<OpCode, int> stackChange = new ReadOnlyDictionary<OpCode, int>(new Dictionary<OpCode, int>
		{
			[OpCodes.Ldloc] = 1,
			[OpCodes.Ldloc_0] = 1,
			[OpCodes.Ldloc_1] = 1,
			[OpCodes.Ldloc_2] = 1,
			[OpCodes.Ldloc_3] = 1,
			[OpCodes.Ldloc_S] = 1,
			[OpCodes.Ldloca] = 1,
			[OpCodes.Ldloca_S] = 1,
			[OpCodes.Ldarg] = 1,
			[OpCodes.Ldarg_0] = 1,
			[OpCodes.Ldarg_1] = 1,
			[OpCodes.Ldarg_2] = 1,
			[OpCodes.Ldarg_3] = 1,
			[OpCodes.Ldarg_S] = 1,
			[OpCodes.Ldarga] = 1,
			[OpCodes.Ldarga_S] = 1,
			[OpCodes.Ldnull] = 1,
			[OpCodes.Ldobj] = 0,
			[OpCodes.Ldfld] = 0,
			[OpCodes.Ldsfld] = 1,
			[OpCodes.Ldflda] = 0,
			[OpCodes.Ldsflda] = 1,
			[OpCodes.Ldstr] = 1,
			[OpCodes.Ldtoken] = 1,
			[OpCodes.Ldftn] = 1,
			[OpCodes.Ldvirtftn] = 1,
			[OpCodes.Ldc_I4] = 1,
			[OpCodes.Ldc_I4_0] = 1,
			[OpCodes.Ldc_I4_1] = 1,
			[OpCodes.Ldc_I4_2] = 1,
			[OpCodes.Ldc_I4_3] = 1,
			[OpCodes.Ldc_I4_4] = 1,
			[OpCodes.Ldc_I4_5] = 1,
			[OpCodes.Ldc_I4_6] = 1,
			[OpCodes.Ldc_I4_7] = 1,
			[OpCodes.Ldc_I4_8] = 1,
			[OpCodes.Ldc_I4_M1] = 1,
			[OpCodes.Ldc_I4_S] = 1,
			[OpCodes.Ldc_I8] = 1,
			[OpCodes.Ldc_R4] = 1,
			[OpCodes.Ldc_R8] = 1,
			[OpCodes.Ldelem] = -1,
			[OpCodes.Ldelem_I] = -1,
			[OpCodes.Ldelem_I1] = -1,
			[OpCodes.Ldelem_I2] = -1,
			[OpCodes.Ldelem_I4] = -1,
			[OpCodes.Ldelem_I8] = -1,
			[OpCodes.Ldelem_R4] = -1,
			[OpCodes.Ldelem_R8] = -1,
			[OpCodes.Ldelem_U1] = -1,
			[OpCodes.Ldelem_U2] = -1,
			[OpCodes.Ldelem_U4] = -1,
			[OpCodes.Ldelem_Ref] = -1,
			[OpCodes.Ldelema] = -1,
			[OpCodes.Ldlen] = 0,
			[OpCodes.Ldind_I] = 1,
			[OpCodes.Ldind_I1] = 1,
			[OpCodes.Ldind_I2] = 1,
			[OpCodes.Ldind_I4] = 1,
			[OpCodes.Ldind_I8] = 1,
			[OpCodes.Ldind_R4] = 1,
			[OpCodes.Ldind_R8] = 1,
			[OpCodes.Ldind_Ref] = 1,
			[OpCodes.Ldind_U1] = 1,
			[OpCodes.Ldind_U2] = 1,
			[OpCodes.Ldind_U4] = 1,
			[OpCodes.Localloc] = 1,
			[OpCodes.Stloc] = -1,
			[OpCodes.Stloc_0] = -1,
			[OpCodes.Stloc_1] = -1,
			[OpCodes.Stloc_2] = -1,
			[OpCodes.Stloc_3] = -1,
			[OpCodes.Stloc_S] = -1,
			[OpCodes.Starg] = -1,
			[OpCodes.Starg_S] = -1,
			[OpCodes.Stfld] = -2,
			[OpCodes.Stsfld] = -1,
			[OpCodes.Stobj] = -2,
			[OpCodes.Stelem] = -3,
			[OpCodes.Stelem_I] = -3,
			[OpCodes.Stelem_I1] = -3,
			[OpCodes.Stelem_I2] = -3,
			[OpCodes.Stelem_I4] = -3,
			[OpCodes.Stelem_I8] = -3,
			[OpCodes.Stelem_R4] = -3,
			[OpCodes.Stelem_R8] = -3,
			[OpCodes.Stelem_Ref] = -2,
			[OpCodes.Stind_I] = -2,
			[OpCodes.Stind_I1] = -2,
			[OpCodes.Stind_I2] = -2,
			[OpCodes.Stind_I4] = -2,
			[OpCodes.Stind_I8] = -2,
			[OpCodes.Stind_R4] = -2,
			[OpCodes.Stind_Ref] = -2,
			[OpCodes.Initobj] = -1,
			[OpCodes.Newobj] = 1,
			[OpCodes.Initblk] = -1,
			[OpCodes.Newarr] = 1,
			[OpCodes.Add] = -1,
			[OpCodes.Add_Ovf] = -1,
			[OpCodes.Add_Ovf_Un] = -1,
			[OpCodes.Sub] = -1,
			[OpCodes.Sub_Ovf] = -1,
			[OpCodes.Sub_Ovf_Un] = -1,
			[OpCodes.Mul] = -1,
			[OpCodes.Mul_Ovf] = -1,
			[OpCodes.Mul_Ovf_Un] = -1,
			[OpCodes.Div] = -1,
			[OpCodes.Div_Un] = -1,
			[OpCodes.Rem] = -1,
			[OpCodes.Rem_Un] = -1,
			[OpCodes.Neg] = 0,
			[OpCodes.And] = -1,
			[OpCodes.Or] = 0,
			[OpCodes.Not] = 0,
			[OpCodes.Xor] = -1,
			[OpCodes.Ceq] = -1,
			[OpCodes.Clt] = -1,
			[OpCodes.Clt_Un] = -1,
			[OpCodes.Cgt] = -1,
			[OpCodes.Cgt_Un] = -1,
			[OpCodes.Br] = 0,
			[OpCodes.Br_S] = 0,
			[OpCodes.Brtrue] = -1,
			[OpCodes.Brtrue_S] = -1,
			[OpCodes.Brfalse] = -1,
			[OpCodes.Brfalse_S] = -1,
			[OpCodes.Beq] = -2,
			[OpCodes.Beq_S] = -2,
			[OpCodes.Blt] = -2,
			[OpCodes.Blt_S] = -2,
			[OpCodes.Ble] = -2,
			[OpCodes.Ble_S] = -2,
			[OpCodes.Bge] = -2,
			[OpCodes.Bge_S] = -2,
			[OpCodes.Bgt] = -2,
			[OpCodes.Bgt_S] = -2,
			[OpCodes.Bne_Un] = -2,
			[OpCodes.Bne_Un_S] = -2,
			[OpCodes.Blt_Un] = -2,
			[OpCodes.Blt_Un_S] = -2,
			[OpCodes.Ble_Un] = -2,
			[OpCodes.Ble_Un_S] = -2,
			[OpCodes.Bge_Un] = -2,
			[OpCodes.Bge_Un_S] = -2,
			[OpCodes.Bgt_Un] = -2,
			[OpCodes.Bgt_Un_S] = -2,
			[OpCodes.Switch] = -1,
			[OpCodes.Jmp] = 0,
			[OpCodes.Ret] = 0,
			[OpCodes.Leave] = 0,
			[OpCodes.Leave_S] = 0,
			[OpCodes.Refanytype] = 0,
			[OpCodes.Refanyval] = 0,
			[OpCodes.Mkrefany] = 0,
			[OpCodes.Castclass] = 0,
			[OpCodes.Box] = 0,
			[OpCodes.Unbox] = 0,
			[OpCodes.Unbox_Any] = 0,
			[OpCodes.Conv_I] = 0,
			[OpCodes.Conv_I1] = 0,
			[OpCodes.Conv_I2] = 0,
			[OpCodes.Conv_I4] = 0,
			[OpCodes.Conv_I8] = 0,
			[OpCodes.Conv_Ovf_I] = 0,
			[OpCodes.Conv_Ovf_I1] = 0,
			[OpCodes.Conv_Ovf_I2] = 0,
			[OpCodes.Conv_Ovf_I4] = 0,
			[OpCodes.Conv_Ovf_I8] = 0,
			[OpCodes.Conv_Ovf_I_Un] = 0,
			[OpCodes.Conv_Ovf_I1_Un] = 0,
			[OpCodes.Conv_Ovf_I2_Un] = 0,
			[OpCodes.Conv_Ovf_I4_Un] = 0,
			[OpCodes.Conv_Ovf_I8_Un] = 0,
			[OpCodes.Conv_U] = 0,
			[OpCodes.Conv_U1] = 0,
			[OpCodes.Conv_U2] = 0,
			[OpCodes.Conv_U4] = 0,
			[OpCodes.Conv_U8] = 0,
			[OpCodes.Conv_Ovf_U] = 0,
			[OpCodes.Conv_Ovf_U1] = 0,
			[OpCodes.Conv_Ovf_U2] = 0,
			[OpCodes.Conv_Ovf_U4] = 0,
			[OpCodes.Conv_Ovf_U8] = 0,
			[OpCodes.Conv_Ovf_U_Un] = 0,
			[OpCodes.Conv_Ovf_U1_Un] = 0,
			[OpCodes.Conv_Ovf_U2_Un] = 0,
			[OpCodes.Conv_Ovf_U4_Un] = 0,
			[OpCodes.Conv_Ovf_U8_Un] = 0,
			[OpCodes.Conv_R4] = 0,
			[OpCodes.Conv_R8] = 0,
			[OpCodes.Conv_R_Un] = 0,
			[OpCodes.Cpblk] = -2,
			[OpCodes.Cpobj] = -2,
			[OpCodes.Dup] = 1,
			[OpCodes.Nop] = 0,
			[OpCodes.Pop] = -1,
			[OpCodes.Shl] = -1,
			[OpCodes.Shr] = -1,
			[OpCodes.Shr_Un] = -1,
			[OpCodes.Sizeof] = 1,
			[OpCodes.Isinst] = 0,
			[OpCodes.Break] = 0,
			[OpCodes.Arglist] = 1,
			[OpCodes.Throw] = -1,
			[OpCodes.Rethrow] = 0,
			[OpCodes.Ckfinite] = -1,
			[OpCodes.Endfinally] = 0,
			[OpCodes.Endfilter] = 0
		});

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static void LogString(string toLog)
		{
			WildCardMod.Instance.Log.LogDebug((object)toLog);
		}

		public static void LogIL(this MethodBase patch, MethodBase patching, List<CodeInstruction> codes)
		{
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0440: Unknown result type (might be due to invalid IL or missing references)
			//IL_044b: Unknown result type (might be due to invalid IL or missing references)
			if (((MemberInfo)patch).GetCustomAttribute<HarmonyTranspiler>() == null)
			{
				return;
			}
			Dictionary<int, string> dictionary = new Dictionary<int, string> { [0] = "(" + patching.DeclaringType.FullName + ")" };
			ParameterInfo[] parameters = patching.GetParameters();
			List<string> list = new List<string>();
			for (int i = 0; i < parameters.Length; i++)
			{
				ParameterInfo parameterInfo = parameters[i];
				list.Add(parameterInfo.ParameterType.FullName + " " + parameterInfo.Name);
				dictionary.Add(i + 1, "(" + list[list.Count - 1] + ")");
			}
			StringBuilder stringBuilder = new StringBuilder("IL after patching ");
			stringBuilder.Append(patching.DeclaringType.FullName).Append('.').Append(patching.Name)
				.Append('(')
				.AppendJoin(", ", list)
				.Append(')')
				.Append(" with ")
				.Append(patch.DeclaringType.FullName)
				.Append('.')
				.Append(patch.Name)
				.AppendLine("\n");
			Dictionary<int, string> dictionary2 = new Dictionary<int, string>();
			LocalVariableInfo[] array = patching.GetMethodBody().LocalVariables.ToArray();
			foreach (LocalVariableInfo localVariableInfo in array)
			{
				dictionary2.Add(localVariableInfo.LocalIndex, "(" + localVariableInfo.LocalTy