Decompiled source of SuppressorInBazaar v1.2.1

SuppressorInBazaar.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using On.RoR2;
using RoR2;
using RoR2.Items;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SuppressorInBazaar")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SuppressorInBazaar")]
[assembly: AssemblyTitle("SuppressorInBazaar")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace SuppressorInBazaar;

[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("thebugreport.SuppressorInBazaar", "SuppressorInBazaar", "1.0.0")]
public class SuppressorInBazaar : BaseUnityPlugin
{
	public sealed class SuppressorUnit
	{
		public Vector3 position;

		public float offsetY;

		public Quaternion rotation = Quaternion.Euler(0f, 85f, 0f);
	}

	private ConfigEntry<bool> replaceVoidScrap;

	private ConfigEntry<string> amountOfSuppressors;

	private ConfigEntry<int> debugSuppressorToSpawn;

	private readonly int _debugSuppressorToSpawn = -1;

	public List<SuppressorUnit> suppressorPositions = new List<SuppressorUnit>
	{
		new SuppressorUnit
		{
			position = new Vector3(-140.7042f, -24.45994f, -20.14482f),
			rotation = Quaternion.Euler(0f, 85f, 0f),
			offsetY = -1.15f
		},
		new SuppressorUnit
		{
			position = new Vector3(-141.1033f, -25.3802f, -14.5926f),
			rotation = Quaternion.Euler(0f, 180f, 0f),
			offsetY = -0.8f
		},
		new SuppressorUnit
		{
			position = new Vector3(-142.7284f, -23.52035f, -24.3129f),
			rotation = Quaternion.Euler(0f, 5f, 0f),
			offsetY = -1.5f
		},
		new SuppressorUnit
		{
			position = new Vector3(-146.1029f, -23.8468f, -17.74881f),
			rotation = Quaternion.Euler(0f, 105f, 0f),
			offsetY = -1.5f
		},
		new SuppressorUnit
		{
			position = new Vector3(-123.1761f, -22.92046f, -0.2019209f),
			rotation = Quaternion.Euler(0f, 225f, 0f),
			offsetY = -1.4f
		},
		new SuppressorUnit
		{
			position = new Vector3(-70.04802f, -22.58818f, -22.26592f),
			rotation = Quaternion.Euler(0f, 280f, 0f),
			offsetY = -1.4f
		},
		new SuppressorUnit
		{
			position = new Vector3(-91.48799f, -22.65284f, -5.782152f),
			rotation = Quaternion.Euler(0f, 120f, 0f),
			offsetY = -1.5f
		},
		new SuppressorUnit
		{
			position = new Vector3(-62.53033f, -22.66195f, -59.45711f),
			rotation = Quaternion.Euler(0f, 275f, 0f),
			offsetY = -1.4f
		},
		new SuppressorUnit
		{
			position = new Vector3(-65.79401f, -22.75067f, -54.65296f),
			rotation = Quaternion.Euler(0f, 255f, 0f),
			offsetY = -1.4f
		},
		new SuppressorUnit
		{
			position = new Vector3(-63.60971f, -25.34011f, -74.19511f),
			rotation = Quaternion.Euler(0f, 295f, 0f),
			offsetY = -1.55f
		}
	};

	public void Awake()
	{
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Expected O, but got Unknown
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Expected O, but got Unknown
		amountOfSuppressors = ((BaseUnityPlugin)this).Config.Bind<string>("Settings", "Amount of Suppressors", "1-3", "How many Suppressors to spawn in the Bazaar. Use a single number or a range between two numbers (e.g. 1-3). Max amount is 9 (4-12 would convert into 4-9).");
		replaceVoidScrap = ((BaseUnityPlugin)this).Config.Bind<bool>("Compatibility", "Replace Void Scrap", true, "If true, Void Scrap produced from banished items will produce regular scrap instead. Turn off if you have another mod installed that uses void/suppressed scrap. Requires Restart.");
		debugSuppressorToSpawn = ((BaseUnityPlugin)this).Config.Bind<int>("Debug", "Debug Suppressor To Spawn", -1, "If set to a value >= 0, will spawn only the suppressor at that index for debugging purposes. Set to -1 to disable.");
		SceneCatalog.OnActiveSceneChanged += new hook_OnActiveSceneChanged(SceneCatalog_OnActiveSceneChanged);
		if (replaceVoidScrap.Value)
		{
			VoidSuppressorBehavior.RefreshItems += new hook_RefreshItems(VoidSuppressorBehavior_RefreshItems);
		}
	}

	private List<int> GetSuppressorCountList()
	{
		List<int> result = new List<int>();
		int num = Math.Max(0, suppressorPositions?.Count ?? 0);
		if (num == 0)
		{
			return result;
		}
		string text = amountOfSuppressors?.Value?.Trim() ?? "1";
		int minValue;
		int num2;
		int result4;
		if (text.Contains("-"))
		{
			string[] array = text.Split('-', StringSplitOptions.RemoveEmptyEntries);
			if (array.Length == 2 && int.TryParse(array[0].Trim(), out var result2) && int.TryParse(array[1].Trim(), out var result3))
			{
				result2 = Math.Max(0, Math.Min(result2, num));
				result3 = Math.Max(0, Math.Min(result3, num));
				minValue = Math.Min(result2, result3);
				num2 = Math.Max(result2, result3);
			}
			else
			{
				minValue = (num2 = 1);
			}
		}
		else if (int.TryParse(text, out result4))
		{
			result4 = Math.Max(0, Math.Min(result4, num));
			minValue = (num2 = result4);
		}
		else
		{
			minValue = (num2 = 1);
		}
		Random random = new Random();
		int count = random.Next(minValue, num2 + 1);
		List<int> list = Enumerable.Range(0, num).ToList();
		for (int num3 = list.Count - 1; num3 > 0; num3--)
		{
			int num4 = random.Next(0, num3 + 1);
			List<int> list2 = list;
			int index = num4;
			List<int> list3 = list;
			int index2 = num3;
			int value = list[num3];
			int value2 = list[num4];
			list2[index] = value;
			list3[index2] = value2;
		}
		return list.Take(count).ToList();
	}

	private void SceneCatalog_OnActiveSceneChanged(orig_OnActiveSceneChanged orig, Scene oldScene, Scene newScene)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		orig.Invoke(oldScene, newScene);
		if (((Scene)(ref newScene)).name != "bazaar" || !NetworkServer.active)
		{
			return;
		}
		if (debugSuppressorToSpawn.Value >= 0)
		{
			int value = debugSuppressorToSpawn.Value;
			if (value >= 0 && value < suppressorPositions.Count)
			{
				SuppressorUnit suppressorUnit = suppressorPositions[value];
				GameObject obj = Object.Instantiate<GameObject>(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/VoidSuppressor/VoidSuppressor.prefab").WaitForCompletion());
				Vector3 position = suppressorUnit.position;
				position.y += suppressorUnit.offsetY;
				obj.transform.position = position;
				obj.transform.rotation = suppressorUnit.rotation;
				NetworkServer.Spawn(obj);
				Debug.Log((object)$"[SuppressorInBazaar] Spawned debug suppressor at index {value} (position {position}).");
				return;
			}
		}
		List<int> suppressorCountList = GetSuppressorCountList();
		if (suppressorCountList == null || suppressorCountList.Count == 0)
		{
			return;
		}
		GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/VoidSuppressor/VoidSuppressor.prefab").WaitForCompletion();
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		foreach (int item in suppressorCountList)
		{
			if (item >= 0 && item < suppressorPositions.Count)
			{
				SuppressorUnit suppressorUnit2 = suppressorPositions[item];
				GameObject obj2 = Object.Instantiate<GameObject>(val);
				Vector3 position2 = suppressorUnit2.position;
				position2.y += suppressorUnit2.offsetY;
				obj2.transform.position = position2;
				obj2.transform.rotation = suppressorUnit2.rotation;
				NetworkServer.Spawn(obj2);
			}
		}
	}

	public void VoidSuppressorBehavior_RefreshItems(orig_RefreshItems orig, VoidSuppressorBehavior self)
	{
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: 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)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: 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_0127: 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_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Expected O, but got I4
		//IL_010a: Expected O, but got I4
		//IL_0145: Expected O, but got I4
		//IL_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca->IL00ca: Incompatible stack types: O vs I4
		//IL_00c8->IL00ca: Incompatible stack types: I4 vs O
		//IL_00c8->IL00ca: Incompatible stack types: O vs I4
		//IL_0105->IL0105: Incompatible stack types: O vs I4
		//IL_0103->IL0105: Incompatible stack types: I4 vs O
		//IL_0103->IL0105: Incompatible stack types: O vs I4
		//IL_0140->IL0140: Incompatible stack types: O vs I4
		//IL_013e->IL0140: Incompatible stack types: I4 vs O
		//IL_013e->IL0140: Incompatible stack types: O vs I4
		if (!NetworkServer.active)
		{
			Debug.LogWarning((object)"[Server] function 'System.Void RoR2.VoidSuppressorBehavior::RefreshItems()' called on client");
		}
		else
		{
			if (self.GetTimeUntilItemRefresh() > 0f)
			{
				return;
			}
			IList<PickupIndex> nextItemsToSuppress = self.GetNextItemsToSuppress();
			for (int num = nextItemsToSuppress.Count - 1; num >= 0; num--)
			{
				PickupIndex val = nextItemsToSuppress[num];
				if (SuppressedItemManager.HasItemBeenSuppressed(((PickupIndex)(ref val)).itemIndex))
				{
					nextItemsToSuppress.RemoveAt(num);
				}
			}
			int num2 = self.GetItemsSuppressedPerPurchase() - nextItemsToSuppress.Count;
			if (num2 > 0)
			{
				List<PickupIndex> list = null;
				PickupIndex item = PickupIndex.none;
				switch (self.GetPurchaseCount())
				{
				case 0:
				{
					list = new List<PickupIndex>(Run.instance.availableTier1DropList);
					ItemIndex itemIndex3 = Items.ScrapWhite.itemIndex;
					item = PickupCatalog.FindPickupIndex(itemIndex3);
					object obj3 = self;
					int num5;
					if (self.GetTransformItems())
					{
						obj3 = itemIndex3;
						num5 = (int)obj3;
					}
					else
					{
						num5 = -1;
						obj3 = num5;
						num5 = (int)obj3;
					}
					((VoidSuppressorBehavior)(object)num5).SetTransformItemIndex((ItemIndex)obj3);
					break;
				}
				case 1:
				{
					list = new List<PickupIndex>(Run.instance.availableTier2DropList);
					ItemIndex itemIndex2 = Items.ScrapGreen.itemIndex;
					item = PickupCatalog.FindPickupIndex(itemIndex2);
					object obj2 = self;
					int num4;
					if (self.GetTransformItems())
					{
						obj2 = itemIndex2;
						num4 = (int)obj2;
					}
					else
					{
						num4 = -1;
						obj2 = num4;
						num4 = (int)obj2;
					}
					((VoidSuppressorBehavior)(object)num4).SetTransformItemIndex((ItemIndex)obj2);
					break;
				}
				case 2:
				{
					list = new List<PickupIndex>(Run.instance.availableTier3DropList);
					ItemIndex itemIndex = Items.ScrapRed.itemIndex;
					item = PickupCatalog.FindPickupIndex(itemIndex);
					object obj = self;
					int num3;
					if (self.GetTransformItems())
					{
						obj = itemIndex;
						num3 = (int)obj;
					}
					else
					{
						num3 = -1;
						obj = num3;
						num3 = (int)obj;
					}
					((VoidSuppressorBehavior)(object)num3).SetTransformItemIndex((ItemIndex)obj);
					break;
				}
				}
				if (list != null && list.Count > 0)
				{
					list.Remove(item);
					foreach (PickupIndex item2 in nextItemsToSuppress)
					{
						list.Remove(item2);
					}
					object rng = self.GetRng();
					Xoroshiro128Plus val2 = (Xoroshiro128Plus)(((rng is Xoroshiro128Plus) ? rng : null) ?? ((object)(Xoroshiro128Plus)rng));
					Util.ShuffleList<PickupIndex>(list, val2);
					int num6 = list.Count - num2;
					if (num6 > 0)
					{
						list.RemoveRange(num2, num6);
					}
					foreach (PickupIndex item3 in list)
					{
						nextItemsToSuppress.Add(item3);
					}
				}
			}
			self.InvokeRefreshPickupDisplays();
			if (nextItemsToSuppress.Count != 0)
			{
				return;
			}
			if (self.GetPurchaseCount() < self.GetMaxPurchaseCount())
			{
				self.SetPurchaseCount(self.GetPurchaseCount() + 1);
				self.RefreshItems();
				return;
			}
			Transform symbolTransform = self.GetSymbolTransform();
			if ((Object)(object)symbolTransform != (Object)null)
			{
				((Component)symbolTransform).gameObject.SetActive(false);
			}
			self.GetPurchaseInteraction().SetAvailable(false);
			self.GetAnimator().SetBool(self.GetAnimatorIsAvailableName(), false);
		}
	}
}
public static class ReflectionExtensions
{
	private sealed class SyncListPickupIndexAdapter : IList<PickupIndex>, ICollection<PickupIndex>, IEnumerable<PickupIndex>, IEnumerable
	{
		[CompilerGenerated]
		private sealed class <GetEnumerator>d__19 : IEnumerator<PickupIndex>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private PickupIndex <>2__current;

			public SyncListPickupIndexAdapter <>4__this;

			private int <i>5__2;

			PickupIndex IEnumerator<PickupIndex>.Current
			{
				[DebuggerHidden]
				get
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <GetEnumerator>d__19(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				SyncListPickupIndexAdapter syncListPickupIndexAdapter = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<i>5__2 = 0;
					break;
				case 1:
					<>1__state = -1;
					<i>5__2++;
					break;
				}
				if (<i>5__2 < syncListPickupIndexAdapter.Count)
				{
					<>2__current = syncListPickupIndexAdapter[<i>5__2];
					<>1__state = 1;
					return true;
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private readonly object _target;

		private readonly Type _targetType;

		private readonly MethodInfo _getCount;

		private readonly MethodInfo _getItem;

		private readonly MethodInfo _add;

		private readonly MethodInfo _removeAt;

		private readonly MethodInfo _clear;

		public PickupIndex this[int index]
		{
			get
			{
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				return (PickupIndex)_getItem.Invoke(_target, new object[1] { index });
			}
			set
			{
				throw new NotSupportedException("Setting by index is not supported on SyncList adapter.");
			}
		}

		public int Count => Convert.ToInt32(_getCount.Invoke(_target, null));

		public bool IsReadOnly => false;

		public SyncListPickupIndexAdapter(object target)
		{
			_target = target ?? throw new ArgumentNullException("target");
			_targetType = target.GetType();
			_getCount = GetMethodInfo(_targetType, "get_Count");
			_getItem = GetMethodInfo(_targetType, "get_Item", typeof(int));
			_add = GetMethodInfo(_targetType, "Add", typeof(PickupIndex));
			_removeAt = GetMethodInfo(_targetType, "RemoveAt", typeof(int));
			try
			{
				_clear = GetMethodInfo(_targetType, "Clear");
			}
			catch
			{
				_clear = null;
			}
		}

		public void Add(PickupIndex item)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			_add.Invoke(_target, new object[1] { item });
		}

		public void Clear()
		{
			if (_clear != null)
			{
				_clear.Invoke(_target, null);
				return;
			}
			for (int num = Count - 1; num >= 0; num--)
			{
				RemoveAt(num);
			}
		}

		public bool Contains(PickupIndex item)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < Count; i++)
			{
				PickupIndex val = this[i];
				if (((PickupIndex)(ref val)).Equals(item))
				{
					return true;
				}
			}
			return false;
		}

		public void CopyTo(PickupIndex[] array, int arrayIndex)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < Count; i++)
			{
				array[arrayIndex + i] = this[i];
			}
		}

		[IteratorStateMachine(typeof(<GetEnumerator>d__19))]
		public IEnumerator<PickupIndex> GetEnumerator()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GetEnumerator>d__19(0)
			{
				<>4__this = this
			};
		}

		public int IndexOf(PickupIndex item)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < Count; i++)
			{
				PickupIndex val = this[i];
				if (((PickupIndex)(ref val)).Equals(item))
				{
					return i;
				}
			}
			return -1;
		}

		public void Insert(int index, PickupIndex item)
		{
			throw new NotSupportedException("Insert not supported on SyncList adapter.");
		}

		public bool Remove(PickupIndex item)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			int num = IndexOf(item);
			if (num >= 0)
			{
				RemoveAt(num);
				return true;
			}
			return false;
		}

		public void RemoveAt(int index)
		{
			_removeAt.Invoke(_target, new object[1] { index });
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			return GetEnumerator();
		}
	}

	private static readonly ConcurrentDictionary<(Type, string), FieldInfo> FieldCache = new ConcurrentDictionary<(Type, string), FieldInfo>();

	private static readonly ConcurrentDictionary<(Type, string), MethodInfo> MethodCache = new ConcurrentDictionary<(Type, string), MethodInfo>();

	private static FieldInfo GetFieldInfo(Type type, string name)
	{
		if (type == null)
		{
			throw new ArgumentNullException("type");
		}
		(Type, string) key = (type, name);
		if (FieldCache.TryGetValue(key, out var value))
		{
			return value;
		}
		Type type2 = type;
		while (type2 != null)
		{
			value = type2.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (value != null)
			{
				FieldCache[key] = value;
				return value;
			}
			type2 = type2.BaseType;
		}
		throw new MissingFieldException("Field '" + name + "' not found on type '" + type.FullName + "' or its base types.");
	}

	private static MethodInfo GetMethodInfo(Type type, string name, params Type[] parameters)
	{
		if (type == null)
		{
			throw new ArgumentNullException("type");
		}
		(Type, string) key = (type, name);
		if (MethodCache.TryGetValue(key, out var value))
		{
			return value;
		}
		Type type2 = type;
		while (type2 != null)
		{
			value = type2.GetMethod(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, parameters, null);
			if (value != null)
			{
				MethodCache[key] = value;
				return value;
			}
			type2 = type2.BaseType;
		}
		throw new MissingMethodException("Method '" + name + "' not found on type '" + type.FullName + "' or its base types.");
	}

	public static T GetPrivateField<T>(this object obj, string name)
	{
		if (obj == null)
		{
			throw new ArgumentNullException("obj");
		}
		return (T)GetFieldInfo(obj.GetType(), name).GetValue(obj);
	}

	public static void SetPrivateField<T>(this object obj, string name, T value)
	{
		if (obj == null)
		{
			throw new ArgumentNullException("obj");
		}
		GetFieldInfo(obj.GetType(), name).SetValue(obj, value);
	}

	public static IList<PickupIndex> GetNextItemsToSuppress(this VoidSuppressorBehavior self)
	{
		if ((Object)(object)self == (Object)null)
		{
			throw new ArgumentNullException("self");
		}
		object value = GetFieldInfo(((object)self).GetType(), "nextItemsToSuppress").GetValue(self);
		if (value == null)
		{
			return new List<PickupIndex>();
		}
		if (value is IList<PickupIndex> result)
		{
			return result;
		}
		return new SyncListPickupIndexAdapter(value);
	}

	public static void SetNextItemsToSuppress(this VoidSuppressorBehavior self, List<PickupIndex> value)
	{
		self.SetPrivateField("nextItemsToSuppress", value);
	}

	public static float GetTimeUntilItemRefresh(this VoidSuppressorBehavior self)
	{
		return self.GetPrivateField<float>("timeUntilItemRefresh");
	}

	public static void SetTimeUntilItemRefresh(this VoidSuppressorBehavior self, float value)
	{
		self.SetPrivateField("timeUntilItemRefresh", value);
	}

	public static int GetItemsSuppressedPerPurchase(this VoidSuppressorBehavior self)
	{
		return self.GetPrivateField<int>("itemsSuppressedPerPurchase");
	}

	public static bool GetTransformItems(this VoidSuppressorBehavior self)
	{
		return self.GetPrivateField<bool>("transformItems");
	}

	public static void SetTransformItems(this VoidSuppressorBehavior self, bool value)
	{
		self.SetPrivateField("transformItems", value);
	}

	public static ItemIndex GetTransformItemIndex(this VoidSuppressorBehavior self)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		return self.GetPrivateField<ItemIndex>("transformItemIndex");
	}

	public static void SetTransformItemIndex(this VoidSuppressorBehavior self, ItemIndex value)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		self.SetPrivateField<ItemIndex>("transformItemIndex", value);
	}

	public static int GetPurchaseCount(this VoidSuppressorBehavior self)
	{
		return self.GetPrivateField<int>("purchaseCount");
	}

	public static void SetPurchaseCount(this VoidSuppressorBehavior self, int value)
	{
		self.SetPrivateField("purchaseCount", value);
	}

	public static int GetMaxPurchaseCount(this VoidSuppressorBehavior self)
	{
		return self.GetPrivateField<int>("maxPurchaseCount");
	}

	public static object GetRng(this VoidSuppressorBehavior self)
	{
		return self.GetPrivateField<object>("rng");
	}

	public static Transform GetSymbolTransform(this VoidSuppressorBehavior self)
	{
		return self.GetPrivateField<Transform>("symbolTransform");
	}

	public static void SetSymbolTransform(this VoidSuppressorBehavior self, Transform value)
	{
		self.SetPrivateField<Transform>("symbolTransform", value);
	}

	public static PurchaseInteraction GetPurchaseInteraction(this VoidSuppressorBehavior self)
	{
		return self.GetPrivateField<PurchaseInteraction>("purchaseInteraction");
	}

	public static Animator GetAnimator(this VoidSuppressorBehavior self)
	{
		return self.GetPrivateField<Animator>("animator");
	}

	public static string GetAnimatorIsAvailableName(this VoidSuppressorBehavior self)
	{
		return self.GetPrivateField<string>("animatorIsAvailableName");
	}

	public static void InvokeRefreshPickupDisplays(this VoidSuppressorBehavior self)
	{
		if ((Object)(object)self == (Object)null)
		{
			throw new ArgumentNullException("self");
		}
		GetMethodInfo(((object)self).GetType(), "RefreshPickupDisplays").Invoke(self, null);
	}
}