Decompiled source of SillyItems v1.4.0

SillyGlasses.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using On.RoR2;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Skills;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SillyGlasses")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SillyGlasses")]
[assembly: AssemblyCopyright("Copyright ©  2019")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("29a2bb13-7659-4aac-b40e-529c72d5a209")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: UnverifiableCode]
namespace SillyGlasses;

public class BootlegLimbMatcher : MonoBehaviour
{
	[Serializable]
	public struct LimbPair
	{
		public Transform originalTransform;

		public string targetChildLimb;

		public float originalLimbLength;

		[NonSerialized]
		public Transform targetTransform;
	}

	public bool scaleLimbs = true;

	private bool valid;

	public LimbPair[] limbPairs;

	private float distance;

	public void Init(LimbMatcher limbMatcher_, ChildLocator childLocator_, float distance_)
	{
		limbPairs = limbMatcher_.limbPairs;
		scaleLimbs = limbMatcher_.scaleLimbs;
		distance = distance_;
		SetChildLocator(childLocator_);
	}

	public void SetChildLocator(ChildLocator childLocator)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		valid = true;
		for (int i = 0; i < limbPairs.Length; i++)
		{
			LimbPair val = limbPairs[i];
			Transform val2 = childLocator.FindChild(val.targetChildLimb);
			if (!Object.op_Implicit((Object)(object)val2))
			{
				valid = false;
				break;
			}
			limbPairs[i].targetTransform = val2;
		}
	}

	private void LateUpdate()
	{
		UpdateLimbs();
	}

	private void UpdateLimbs()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: 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_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		if (!valid)
		{
			return;
		}
		for (int i = 0; i < limbPairs.Length; i++)
		{
			LimbPair val = limbPairs[i];
			Transform targetTransform = val.targetTransform;
			if (!Object.op_Implicit((Object)(object)targetTransform) || !Object.op_Implicit((Object)(object)val.originalTransform))
			{
				continue;
			}
			val.originalTransform.position = targetTransform.position + targetTransform.forward * distance;
			val.originalTransform.rotation = targetTransform.rotation;
			if (i < limbPairs.Length - 1)
			{
				float num = Vector3.Magnitude(limbPairs[i + 1].targetTransform.position - targetTransform.position);
				float originalLimbLength = val.originalLimbLength;
				if (scaleLimbs)
				{
					Vector3 localScale = val.originalTransform.localScale;
					localScale.y = num / originalLimbLength;
					val.originalTransform.localScale = localScale;
				}
			}
		}
	}
}
public class CharacterSwooceHandler : MonoBehaviour
{
	private bool _subscribedToEvents;

	private Dictionary<ItemIndex, int> _instantiatedSillyAmounts = new Dictionary<ItemIndex, int>();

	private Dictionary<ItemIndex, Transform> _instantiatedSillyParents = new Dictionary<ItemIndex, Transform>();

	private Dictionary<ItemIndex, List<Transform>> _extraParentsLists = new Dictionary<ItemIndex, List<Transform>>();

	private Dictionary<ItemIndex, List<ParentedPrefabDisplay>> _sillyParentedPrefabDisplays = new Dictionary<ItemIndex, List<ParentedPrefabDisplay>>();

	private CharacterModel _swoocedCharacterModel;

	private Inventory _swoocedCurrentInventory;

	private ChildLocator _swoocedChildLocator;

	private float _specialItemDistance;

	private MaterialPropertyBlock propertyStorage;

	public CharacterModel swoocedCharacterModel => _swoocedCharacterModel;

	private int _cfgMaxItems => Utils.Cfg_ItemStackMax;

	private float _cfgDistanceMultiplier => Utils.Cfg_ItemDistanceMultiplier;

	public void Init(float distance_)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		propertyStorage = new MaterialPropertyBlock();
		_specialItemDistance = distance_;
		_swoocedCharacterModel = ((Component)this).GetComponent<CharacterModel>();
		if (!Object.op_Implicit((Object)(object)_swoocedCharacterModel))
		{
			Object.Destroy((Object)(object)this);
			return;
		}
		if (!Object.op_Implicit((Object)(object)_swoocedCharacterModel.body))
		{
			Object.Destroy((Object)(object)this);
			return;
		}
		if (!Object.op_Implicit((Object)(object)_swoocedCharacterModel.body.inventory))
		{
			Object.Destroy((Object)(object)this);
			return;
		}
		_swoocedCurrentInventory = _swoocedCharacterModel.body.inventory;
		if (!Object.op_Implicit((Object)(object)_swoocedCurrentInventory))
		{
			Object.Destroy((Object)(object)this);
		}
		else
		{
			SubscribeToEvents(subscribing: true);
		}
	}

	private void Update()
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//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)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		if ((bool)Utils.Cfg_NoMaterialUpdate)
		{
			return;
		}
		Color val = Color.black;
		if (Object.op_Implicit((Object)(object)_swoocedCharacterModel) && Object.op_Implicit((Object)(object)_swoocedCharacterModel.body) && Object.op_Implicit((Object)(object)_swoocedCharacterModel.body.healthComponent))
		{
			float num = Mathf.Clamp01(1f - _swoocedCharacterModel.body.healthComponent.timeSinceLastHit / CharacterModel.hitFlashDuration);
			float num2 = Mathf.Pow(Mathf.Clamp01(1f - _swoocedCharacterModel.body.healthComponent.timeSinceLastHeal / CharacterModel.healFlashDuration), 0.5f);
			val = ((!(num2 > num)) ? (((_swoocedCharacterModel.body.healthComponent.shield > 0f) ? CharacterModel.hitFlashShieldColor : CharacterModel.hitFlashBaseColor) * num) : (CharacterModel.healFlashColor * num2));
		}
		foreach (List<ParentedPrefabDisplay> value in _sillyParentedPrefabDisplays.Values)
		{
			for (int i = 0; i < value.Count; i++)
			{
				ParentedPrefabDisplay val2 = value[i];
				ItemDisplay itemDisplay = ((ParentedPrefabDisplay)(ref val2)).itemDisplay;
				if (!((Object)(object)itemDisplay == (Object)null))
				{
					itemDisplay.SetVisibilityLevel(_swoocedCharacterModel.visibility);
					for (int j = 0; j < itemDisplay.rendererInfos.Length; j++)
					{
						Renderer renderer = itemDisplay.rendererInfos[j].renderer;
						renderer.GetPropertyBlock(propertyStorage);
						propertyStorage.SetColor(CommonShaderProperties._FlashColor, val);
						propertyStorage.SetFloat(CommonShaderProperties._Fade, _swoocedCharacterModel.fade);
						renderer.SetPropertyBlock(propertyStorage);
					}
				}
			}
		}
	}

	private void OnDestroy()
	{
		SubscribeToEvents(subscribing: false);
	}

	private void SubscribeToEvents(bool subscribing)
	{
		if (subscribing != _subscribedToEvents)
		{
			_subscribedToEvents = subscribing;
			if (subscribing)
			{
				SillyGlassesPlugin instance = SillyGlassesPlugin.instance;
				instance.enableDisableDisplayEvent = (SillyGlassesPlugin.EnableDisableDisplayEvent)Delegate.Combine(instance.enableDisableDisplayEvent, new SillyGlassesPlugin.EnableDisableDisplayEvent(onHookedEnableDisableDisplay));
			}
			else
			{
				SillyGlassesPlugin instance2 = SillyGlassesPlugin.instance;
				instance2.enableDisableDisplayEvent = (SillyGlassesPlugin.EnableDisableDisplayEvent)Delegate.Remove(instance2.enableDisableDisplayEvent, new SillyGlassesPlugin.EnableDisableDisplayEvent(onHookedEnableDisableDisplay));
			}
		}
	}

	public void onHookedEnableDisableDisplay(CharacterModel characterModel_, ItemIndex itemIndex_)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		if ((bool)Utils.Cfg_SlightlyUnstable)
		{
			onHookedEnableDisableDisplaySpooky(characterModel_, itemIndex_);
			return;
		}
		try
		{
			onHookedEnableDisableDisplaySpooky(characterModel_, itemIndex_);
		}
		catch (Exception arg)
		{
			if (!Utils.wegetit || (bool)Utils.Cfg_UseLogs)
			{
				Utils.wegetit = true;
				SillyGlassesPlugin.logger.LogError((object)$"WELP IT HAPPENED.\n\n[Please send this log to thetimesweeper]\n\n {arg}");
			}
		}
	}

	public void onHookedEnableDisableDisplaySpooky(CharacterModel characterModel_, ItemIndex itemIndex_)
	{
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: 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 (Object.op_Implicit((Object)(object)characterModel_) && !((Object)(object)((Component)characterModel_).gameObject != (Object)(object)((Component)this).gameObject) && Object.op_Implicit((Object)(object)characterModel_.itemDisplayRuleSet))
		{
			DisplayRuleGroup itemDisplayRuleGroup = characterModel_.itemDisplayRuleSet.GetItemDisplayRuleGroup(itemIndex_);
			PseudoInstantiateDisplayRuleGroup(characterModel_, itemDisplayRuleGroup, itemIndex_);
		}
	}

	private void PseudoInstantiateDisplayRuleGroup(CharacterModel characterModel_, DisplayRuleGroup displayRuleGroup_, ItemIndex itemIndex_)
	{
		//IL_0031: 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_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Invalid comparison between Unknown and I4
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: 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_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bf: 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_0401: 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_024a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02eb: Invalid comparison between Unknown and I4
		//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0320: Unknown result type (might be due to invalid IL or missing references)
		//IL_032c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_020f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		//IL_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0361: Unknown result type (might be due to invalid IL or missing references)
		//IL_038a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0392: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b4: 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_0377: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)_swoocedCurrentInventory) || (Object)(object)characterModel_ != (Object)(object)_swoocedCharacterModel || displayRuleGroup_.rules == null || displayRuleGroup_.rules.Length == 0 || (int)itemIndex_ == -1)
		{
			return;
		}
		if (!_instantiatedSillyAmounts.ContainsKey(itemIndex_))
		{
			_instantiatedSillyAmounts.Add(itemIndex_, 0);
		}
		int itemCount = _swoocedCurrentInventory.GetItemCount(itemIndex_);
		int num = _instantiatedSillyAmounts[itemIndex_];
		int num2 = num + ((itemCount > 0) ? 1 : 0);
		int num3 = itemCount - num2;
		if (itemCount == 1 && num3 >= 0)
		{
			return;
		}
		ParentedPrefabDisplay item;
		if (num3 < 0)
		{
			if (!_instantiatedSillyParents.ContainsKey(itemIndex_) || !((Object)(object)_instantiatedSillyParents[itemIndex_] != (Object)null))
			{
				return;
			}
			Object.Destroy((Object)(object)((Component)_instantiatedSillyParents[itemIndex_]).gameObject);
			_instantiatedSillyParents[itemIndex_] = null;
			_instantiatedSillyAmounts[itemIndex_] = 0;
			if (_extraParentsLists.ContainsKey(itemIndex_) && _extraParentsLists[itemIndex_] != null)
			{
				List<Transform> list = _extraParentsLists[itemIndex_];
				for (int num4 = list.Count - 1; num4 >= 0; num4--)
				{
					if (Object.op_Implicit((Object)(object)list[num4]))
					{
						Object.Destroy((Object)(object)((Component)list[num4]).gameObject);
					}
					list.RemoveAt(num4);
				}
			}
			if (!Utils.Cfg_NoMaterialUpdate && _sillyParentedPrefabDisplays.ContainsKey(itemIndex_))
			{
				for (int num5 = _sillyParentedPrefabDisplays[itemIndex_].Count - 1; num5 >= 0; num5--)
				{
					item = _sillyParentedPrefabDisplays[itemIndex_][num5];
					((ParentedPrefabDisplay)(ref item)).Undo();
				}
				_sillyParentedPrefabDisplays[itemIndex_].Clear();
			}
			PseudoInstantiateDisplayRuleGroup(characterModel_, displayRuleGroup_, itemIndex_);
			return;
		}
		if ((Object)(object)_swoocedChildLocator == (Object)null)
		{
			_swoocedChildLocator = ((Component)characterModel_).GetComponent<ChildLocator>();
		}
		for (int i = 0; i < num3; i++)
		{
			int num6 = num2 + i;
			if (_cfgMaxItems != -1 && num6 + 1 >= _cfgMaxItems)
			{
				break;
			}
			_instantiatedSillyAmounts[itemIndex_]++;
			for (int j = 0; j < displayRuleGroup_.rules.Length; j++)
			{
				ItemDisplayRule val = displayRuleGroup_.rules[j];
				if ((int)val.ruleType > 0)
				{
					continue;
				}
				Transform val2 = _swoocedChildLocator.FindChild(val.childName);
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				GameObject val3 = InstantiateSillyItem(val, _swoocedChildLocator, val2, num6, itemIndex_);
				if ((Object)(object)val3 == (Object)null)
				{
					continue;
				}
				if (!Utils.Cfg_NoMaterialUpdate)
				{
					if (!_sillyParentedPrefabDisplays.ContainsKey(itemIndex_))
					{
						_sillyParentedPrefabDisplays[itemIndex_] = new List<ParentedPrefabDisplay>();
					}
					List<ParentedPrefabDisplay> list2 = _sillyParentedPrefabDisplays[itemIndex_];
					item = default(ParentedPrefabDisplay);
					((ParentedPrefabDisplay)(ref item)).instance = val3;
					((ParentedPrefabDisplay)(ref item)).itemDisplay = val3.GetComponent<ItemDisplay>();
					item.itemIndex = itemIndex_;
					list2.Add(item);
				}
				Transform sillyParent = GetSillyParent(itemIndex_, val2);
				val3.transform.parent = sillyParent;
				if ((Object)(object)sillyParent == (Object)null)
				{
					Utils.Log("sillyParent is null \nwait how \nI should be pretty much covering all the bases there");
				}
			}
		}
	}

	private GameObject InstantiateSillyItem(ItemDisplayRule displayRule_, ChildLocator childLocator_, Transform bodyDisplayParent_, int instanceMult_, ItemIndex itemIndex_)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_015c: 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_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: 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_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		GameObject followerPrefab = displayRule_.followerPrefab;
		if ((Object)(object)followerPrefab == (Object)null)
		{
			return null;
		}
		Vector3 localPos = displayRule_.localPos;
		Quaternion localRotation = Quaternion.Euler(displayRule_.localAngles);
		Vector3 localScale = displayRule_.localScale;
		GameObject val = Object.Instantiate<GameObject>(followerPrefab.gameObject, bodyDisplayParent_);
		val.transform.localPosition = localPos;
		val.transform.localRotation = localRotation;
		val.transform.localScale = localScale;
		float num = (float)instanceMult_ * _cfgDistanceMultiplier * _specialItemDistance;
		Vector3 val2;
		Vector3 val3;
		if (!Utils.Cfg_OutwardStackType)
		{
			val2 = val.transform.forward * num;
		}
		else if (displayRule_.childName != "Head")
		{
			val3 = val.transform.position - bodyDisplayParent_.position;
			Vector3 normalized = ((Vector3)(ref val3)).normalized;
			val3 = Vector3.Cross(((Component)bodyDisplayParent_).transform.up, normalized);
			Vector3 normalized2 = ((Vector3)(ref val3)).normalized;
			val3 = Vector3.Cross(((Component)bodyDisplayParent_).transform.up, normalized2);
			normalized2 = ((Vector3)(ref val3)).normalized;
			val3 = (normalized - normalized2) * 0.5f;
			Vector3 normalized3 = ((Vector3)(ref val3)).normalized;
			val2 = normalized3 * num;
		}
		else
		{
			val3 = val.transform.position - bodyDisplayParent_.position;
			val2 = ((Vector3)(ref val3)).normalized * num;
		}
		Transform transform = val.transform;
		transform.position += val2;
		if ((bool)Utils.Cfg_UseLogs)
		{
			((Object)val).name = $"{((Object)val).name} {instanceMult_}";
		}
		LimbMatcher component = val.GetComponent<LimbMatcher>();
		if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)childLocator_))
		{
			val.AddComponent<BootlegLimbMatcher>().Init(component, childLocator_, num);
		}
		return val;
	}

	private Transform GetSillyParent(ItemIndex itemIndex_, Transform bodyDisplayParent_)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		Transform val = (_instantiatedSillyParents.ContainsKey(itemIndex_) ? _instantiatedSillyParents[itemIndex_] : null);
		if ((Object)(object)val == (Object)null)
		{
			Transform val2 = CreateNewParentedTransform("SillyItem_" + ((object)(ItemIndex)(ref itemIndex_)).ToString() + "_Parent", bodyDisplayParent_);
			_instantiatedSillyParents[itemIndex_] = val2;
			return val2;
		}
		if ((Object)(object)val != (Object)null && (Object)(object)val.parent == (Object)(object)bodyDisplayParent_)
		{
			return _instantiatedSillyParents[itemIndex_];
		}
		if ((Object)(object)val != (Object)null && (Object)(object)val.parent != (Object)(object)bodyDisplayParent_)
		{
			List<Transform> list = null;
			if (!_extraParentsLists.ContainsKey(itemIndex_))
			{
				_extraParentsLists[itemIndex_] = new List<Transform>();
			}
			list = _extraParentsLists[itemIndex_];
			Transform val3 = list.Find((Transform extra) => (Object)(object)bodyDisplayParent_ == (Object)(object)extra.parent);
			if ((Object)(object)val3 == (Object)null)
			{
				val3 = CreateNewParentedTransform("SillyItem_" + ((object)(ItemIndex)(ref itemIndex_)).ToString() + "_ExtraParent", bodyDisplayParent_);
				_extraParentsLists[itemIndex_].Add(val3);
			}
			return val3;
		}
		return null;
	}

	private Transform CreateNewParentedTransform(string name, Transform parent)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: 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)
		Transform transform = new GameObject(name).transform;
		transform.parent = parent;
		transform.localPosition = Vector3.one;
		transform.localRotation = Quaternion.identity;
		transform.localScale = Vector3.one;
		return transform;
	}

	private void ShowFunnyCube(Transform parent_, Vector3 displayRuleLocalPos_, Quaternion displayRuleLocalRotation_, float forwardDistance_)
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Expected O, but got Unknown
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Expected O, but got Unknown
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
		Type[] array = new Type[2]
		{
			typeof(MeshRenderer),
			typeof(MeshFilter)
		};
		GameObject val2 = new GameObject("bruh", array);
		val2.GetComponent<MeshFilter>().mesh = val.GetComponent<MeshFilter>().mesh;
		((Renderer)val2.GetComponent<MeshRenderer>()).material = new Material(((Renderer)val.GetComponent<MeshRenderer>()).material);
		val2.transform.parent = parent_;
		val2.transform.localPosition = displayRuleLocalPos_;
		val2.transform.localRotation = displayRuleLocalRotation_;
		val2.transform.localScale = new Vector3(0.169f, 0.01f, 0.1f);
		Transform transform = val2.transform;
		transform.position += val2.transform.forward * forwardDistance_;
		Object.Destroy((Object)(object)val);
	}

	private static void RunCheats()
	{
		if (!Utils.Cfg_PlantsForHire)
		{
		}
	}

	private void TestAddGlasses()
	{
		if ((Object)(object)_swoocedCurrentInventory != (Object)null)
		{
			_swoocedCurrentInventory.GiveItem((ItemIndex)Utils.Cfg_CheatItemBoring, 1);
		}
	}

	private void TestRemoveGlasses()
	{
		if ((Object)(object)_swoocedCurrentInventory != (Object)null)
		{
			_swoocedCurrentInventory.RemoveItem((ItemIndex)Utils.Cfg_CheatItemBoring, 1);
		}
	}
}
public class ConfigEntry
{
}
public class ConfigEntry<T> : ConfigEntry
{
	public ConfigEntry<T> ActualConfigEntry;

	public T DefaultValue;

	public T Value
	{
		get
		{
			if (ActualConfigEntry != null)
			{
				return ActualConfigEntry.Value;
			}
			return DefaultValue;
		}
	}

	public static implicit operator T(ConfigEntry<T> config)
	{
		return config.Value;
	}

	public ConfigEntry(T defaultValue)
	{
		ActualConfigEntry = null;
		DefaultValue = defaultValue;
	}

	public ConfigEntry(ConfigEntry<T> actualConfigEntry, T defaultValue)
	{
		ActualConfigEntry = actualConfigEntry;
		DefaultValue = defaultValue;
	}
}
public static class Config
{
	public static ConfigFile MyConfig = ((BaseUnityPlugin)SillyGlassesPlugin.instance).Config;

	private static List<string> disabledSections = new List<string>();

	private static bool enableAll = true;

	private static bool loadedIcon;

	public static void DisableSection(string section)
	{
		disabledSections.Add(section);
	}

	private static bool SectionDisabled(string section)
	{
		return disabledSections.Contains(section);
	}

	public static void ConfigureBody(CharacterBody bodyComponent, string section, string bodyInfoTitle = "")
	{
		if (string.IsNullOrEmpty(bodyInfoTitle))
		{
			bodyInfoTitle = ((Object)bodyComponent).name;
		}
		bodyComponent.baseMaxHealth = BindAndOptions(section, bodyInfoTitle + " Base Max Health", bodyComponent.baseMaxHealth, 0f, 1000f, "levelMaxHealth will be adjusted accordingly (baseMaxHealth * 0.3)", restartRequired: true).Value;
		bodyComponent.levelMaxHealth = Mathf.Round(bodyComponent.baseMaxHealth * 0.3f);
		bodyComponent.baseRegen = BindAndOptions(section, bodyInfoTitle + " Base Regen", bodyComponent.baseRegen, "levelRegen will be adjusted accordingly (baseRegen * 0.2)", restartRequired: true).Value;
		bodyComponent.levelRegen = bodyComponent.baseRegen * 0.2f;
		bodyComponent.baseArmor = BindAndOptions(section, bodyInfoTitle + " Armor", bodyComponent.baseArmor, "", restartRequired: true).Value;
		bodyComponent.baseDamage = BindAndOptions(section, bodyInfoTitle + " Base Damage", bodyComponent.baseDamage, "pretty much all survivors are 12. If you want to change damage, change damage of the moves instead.\nlevelDamage will be adjusted accordingly (baseDamage * 0.2)", restartRequired: true).Value;
		bodyComponent.levelDamage = bodyComponent.baseDamage * 0.2f;
		bodyComponent.baseJumpCount = BindAndOptions(section, bodyInfoTitle + " Jump Count", bodyComponent.baseJumpCount, "", restartRequired: true).Value;
	}

	public static void ConfigureSkillDef(SkillDef skillDef, string section, string skillTitle, bool cooldown = true, bool maxStock = true, bool rechargeStock = false)
	{
		if (cooldown)
		{
			skillDef.baseRechargeInterval = BindAndOptions(section, skillTitle + " cooldown", skillDef.baseRechargeInterval, 0f, 20f, "", restartRequired: true).Value;
		}
		if (maxStock)
		{
			skillDef.baseMaxStock = BindAndOptions(section, skillTitle + " stocks", skillDef.baseMaxStock, 0f, 100f, "", restartRequired: true).Value;
		}
		if (rechargeStock)
		{
			skillDef.rechargeStock = BindAndOptions(section, skillTitle + " recharge stocks", skillDef.baseMaxStock, 0f, 100f, "", restartRequired: true).Value;
		}
	}

	public static ConfigEntry<bool> CharacterEnableConfig(string section, string characterName, string description = "", bool enabledByDefault = true)
	{
		if (string.IsNullOrEmpty(description))
		{
			description = "Set to false to disable this character and as much of its code and content as possible";
		}
		return BindAndOptions(section, "Enable " + characterName, enabledByDefault, description, restartRequired: true);
	}

	public static ConfigEntry<T> BindAndOptionsSlider<T>(string section, string name, T defaultValue, float min = 0f, float max = 20f, string description = "", bool restartRequired = false)
	{
		return BindAndOptions(section, name, defaultValue, min, max, description, restartRequired);
	}

	public static ConfigEntry<T> BindAndOptions<T>(string section, string name, T defaultValue, string description = "", bool restartRequired = false)
	{
		return BindAndOptions(section, name, defaultValue, 0f, 20f, description, restartRequired);
	}

	public static ConfigEntry<T> BindAndOptions<T>(string section, string name, T defaultValue, float min, float max, string description = "", bool restartRequired = false)
	{
		if (string.IsNullOrEmpty(description))
		{
			description = name;
		}
		description += $"\nDefault: {defaultValue}";
		if (restartRequired)
		{
			description += "\n(restart required)";
		}
		if (!enableAll && SectionDisabled(section))
		{
			return new ConfigEntry<T>(null, defaultValue);
		}
		ConfigEntry<T> val = MyConfig.Bind<T>(section, name, defaultValue, description);
		if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"))
		{
			TryRegisterOption<T>(val, min, max, restartRequired);
		}
		return new ConfigEntry<T>(val, defaultValue);
	}

	public static ConfigEntry BindAndOptions(string section, string name, ValueType defaultValue, float min, float max, string description = "", bool restartRequired = false)
	{
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		if (defaultValue is float)
		{
			return BindAndOptions(section, name, (float)(object)defaultValue, min, max, description, restartRequired);
		}
		if (defaultValue is int)
		{
			return BindAndOptions(section, name, (int)(object)defaultValue, min, max, description, restartRequired);
		}
		if (defaultValue is bool)
		{
			return BindAndOptions(section, name, (bool)(object)defaultValue, min, max, description, restartRequired);
		}
		if (defaultValue is KeyboardShortcut)
		{
			return BindAndOptions<KeyboardShortcut>(section, name, (KeyboardShortcut)(object)defaultValue, min, max, description, restartRequired);
		}
		if (defaultValue == null)
		{
			Debug.LogError((object)$"defaultvalue was null somehow for {section}:{name} {defaultValue}");
		}
		Debug.LogError((object)$"Configuring a field with unsupported type {defaultValue.GetType()} for {section}:{name}");
		return null;
	}

	[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
	private static void TryRegisterOption<T>(ConfigEntry<T> entry, float min, float max, bool restartRequired)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Expected O, but got Unknown
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Expected O, but got Unknown
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: 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_007b: Expected O, but got Unknown
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Expected O, but got Unknown
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Expected O, but got Unknown
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Expected O, but got Unknown
		if (entry is ConfigEntry<float>)
		{
			ModSettingsManager.AddOption((BaseOption)new SliderOption(entry as ConfigEntry<float>, new SliderConfig
			{
				min = min,
				max = max,
				formatString = "{0:0.000}",
				restartRequired = restartRequired
			}));
		}
		if (entry is ConfigEntry<int>)
		{
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(entry as ConfigEntry<int>, new IntSliderConfig
			{
				min = (int)min,
				max = (int)max,
				restartRequired = restartRequired
			}));
		}
		if (entry is ConfigEntry<bool>)
		{
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry as ConfigEntry<bool>, restartRequired));
		}
		if (entry is ConfigEntry<KeyboardShortcut>)
		{
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(entry as ConfigEntry<KeyboardShortcut>, restartRequired));
		}
		if (!loadedIcon)
		{
			loadedIcon = true;
			try
			{
				ModSettingsManager.SetModIcon(ImgHandler.LoadSpriteFromModFolder("icon.png"));
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("error adding ROO mod icon\n" + ex));
			}
		}
	}

	public static bool GetKeyPressed(KeyboardShortcut entry)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		foreach (KeyCode modifier in ((KeyboardShortcut)(ref entry)).Modifiers)
		{
			if (!Input.GetKey(modifier))
			{
				return false;
			}
		}
		return Input.GetKeyDown(((KeyboardShortcut)(ref entry)).MainKey);
	}
}
public static class ImgHandler
{
	public static Sprite LoadSprite(string path, string name)
	{
		Texture2D texture2D = LoadTex2D(path, pointFilter: true);
		return CreateSprite(texture2D, name);
	}

	public static Texture2D LoadTex2D(string fullFilePath, bool pointFilter = false)
	{
		Texture2D val = LoadPNG(fullFilePath, pointFilter);
		if (pointFilter)
		{
			((Texture)val).filterMode = (FilterMode)0;
			val.Apply();
		}
		return val;
	}

	private static Sprite CreateSprite(Texture2D texture2D, string name)
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		((Object)texture2D).name = name;
		((Texture)texture2D).filterMode = (FilterMode)0;
		texture2D.Apply();
		Rect val = default(Rect);
		((Rect)(ref val))..ctor(0f, 0f, (float)((Texture)texture2D).width, (float)((Texture)texture2D).height);
		Sprite val2 = Sprite.Create(texture2D, val, new Vector2(0.5f, 0.5f), 16f);
		((Object)val2).name = name;
		return val2;
	}

	public static Texture2D LoadPNG(params string[] pathDirectories)
	{
		string text = pathDirectories[0];
		for (int i = 1; i < pathDirectories.Length; i++)
		{
			text = Path.Combine(text, pathDirectories[i]);
		}
		return LoadPNG(text);
	}

	public static Texture2D LoadPNG(string filePath, bool pointFilter = false)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Expected O, but got Unknown
		Texture2D val = new Texture2D(2, 2);
		byte[] array = File.ReadAllBytes(filePath);
		ImageConversion.LoadImage(val, array);
		((Texture)val).filterMode = (FilterMode)((!pointFilter) ? 1 : 0);
		val.Apply();
		return val;
	}

	internal static Sprite LoadSpriteFromModFolder(string fileName)
	{
		Texture2D texture2D = LoadTex2DFromPModFolder(fileName);
		return CreateSprite(texture2D, fileName);
	}

	internal static Texture2D LoadTex2DFromPModFolder(string fileName, bool pointFilter = false)
	{
		string fullFilePath = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)SillyGlassesPlugin.instance).Info.Location), fileName);
		return LoadTex2D(fullFilePath, pointFilter);
	}
}
public class Utils
{
	public static ConfigEntry<int> Cfg_ItemStackMax;

	public static ConfigEntry<bool> Cfg_OutwardStackType;

	public static ConfigEntry<float> Cfg_ItemDistanceMultiplier;

	public static ConfigEntry<float> Cfg_EngiTurretItemDistanceMultiplier;

	public static ConfigEntry<float> Cfg_ScavengerItemDistanceMultiplier;

	public static ConfigEntry<float> Cfg_BrotherItemDistanceMultiplier;

	public static ConfigEntry<bool> Cfg_NoMaterialUpdate;

	public static ConfigEntry<bool> Cfg_SlightlyUnstable;

	public static ConfigEntry<bool> Cfg_UseLogs;

	public static bool Cfg_PlantsForHire = false;

	public static int Cfg_CheatItem = 7;

	public static int Cfg_CheatItemBoring = 58;

	public static bool wegetit;

	public static void Log(string logString, bool chat = false)
	{
		if ((bool)Cfg_UseLogs)
		{
			SillyGlassesPlugin.logger.LogMessage((object)("[SillyLog] " + logString));
			if (chat)
			{
				Chat.AddMessage(logString);
			}
		}
	}
}
[BepInPlugin("com.TheTimeSweeper.SillyItem", "Silly Items", "1.4.0")]
public class SillyGlassesPlugin : BaseUnityPlugin
{
	public delegate void UpdateItemDisplayEvent(CharacterModel self, Inventory inventory);

	public delegate void EnableDisableDisplayEvent(CharacterModel self, ItemIndex itemIndex);

	public delegate void UpdateMaterialsEvent(CharacterModel self);

	public delegate void UpdateCameraEvent(CharacterModel self, CameraRigController cameraRig);

	public EnableDisableDisplayEvent enableDisableDisplayEvent;

	private string[] _turretGuyNames = new string[4] { "EngiBeamTurretBody", "EngiTurretBody", "EngiWalkerTurretBody", "TeslaTowerBody" };

	private string[] _scavGuyNames = new string[5] { "ScavBody", "ScavLunar1Body", "ScavLunar2Body", "ScavLunar3Body", "ScavLunar4Body" };

	private string[] _moonGuyNames = new string[5] { "BrotherBody", "BrotherGlassBody", "BrotherHauntBody", "BrotherHurtBody", "MithrixBody" };

	private int _currentRandomIndex;

	private int _spawnedRandomItems;

	private int _currentRedIndex;

	private int _spawnedRedItems;

	public static SillyGlassesPlugin instance;

	public static ManualLogSource logger;

	public void Awake()
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Expected O, but got Unknown
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Expected O, but got Unknown
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Expected O, but got Unknown
		instance = this;
		logger = ((BaseUnityPlugin)this).Logger;
		InitConfig();
		CharacterBody.OnInventoryChanged += new hook_OnInventoryChanged(InvChangedHook);
		CharacterModel.EnableItemDisplay += new hook_EnableItemDisplay(EnableItemDisplayHook);
		CharacterModel.DisableItemDisplay += new hook_DisableItemDisplay(DisableItemDisplayHook);
	}

	private void CharacterBody_Awake(orig_Awake orig, CharacterBody self)
	{
		orig.Invoke(self);
		float specialItemDistance = getSpecialItemDistance(self);
		ModelLocator modelLocator = self.modelLocator;
		if (!((Object)(object)((modelLocator != null) ? modelLocator.modelTransform : null) == (Object)null))
		{
			CharacterSwooceHandler characterSwooceHandler = ((Component)self.modelLocator.modelTransform).gameObject.AddComponent<CharacterSwooceHandler>();
			characterSwooceHandler.Init(specialItemDistance);
		}
	}

	private void InitConfig()
	{
		string section = "hope youre having a lovely day";
		Utils.Cfg_ItemStackMax = Config.BindAndOptions(section, "ItemStacksMax", -1, -1f, 100f, "Maximum item displays that can be spawned (-1 for infinite).");
		Utils.Cfg_OutwardStackType = Config.BindAndOptions(section, "Outward Stacking", defaultValue: false, "Makes item stacks outward from the bone it's attached to, rather than their object's forward facing direction.");
		Utils.Cfg_ItemDistanceMultiplier = Config.BindAndOptions(section, "ItemDistanceMultiplier", 0.048f, -5f, 5f, "The distance between extra displays that spawns.");
		Utils.Cfg_EngiTurretItemDistanceMultiplier = Config.BindAndOptions(section, "EngiTurretItemDistanceMultiplier", 1.5f, -20f, 20f, "Items are a little bigger on Engis Turrets. Spread them out a bit more.");
		Utils.Cfg_ScavengerItemDistanceMultiplier = Config.BindAndOptions(section, "ScavItemDistanceMultiplier", 6f, -20f, 20f, "Items are a also bigger on Scavengers I think");
		Utils.Cfg_BrotherItemDistanceMultiplier = Config.BindAndOptions(section, "BrotherItemDistanceMultiplier", 2f, -20f, 20f, "Big Spikes.");
		Utils.Cfg_NoMaterialUpdate = Config.BindAndOptions(section, "No Material Update", defaultValue: false, "Experimental: Disables item materials updating properly with invisibility, dither, and hit/heal flashes (bet you didn't notice those were a thing).\nIn my testing this had 0 effect on performance, but let me know if it helps you\nDoes not require restart, but does require respawn/stage transition");
		Utils.Cfg_SlightlyUnstable = Config.BindAndOptions(section, "Slightly Unstable Mode", defaultValue: false, "Removes a try catch from one of the common hooks. May reduce lag on inventory change, but there is a very low chance that this function breaks if your mod list is crazy enough. (2 years and I never had anyone report to me, but I am implementing this safety to try to be super duper safe)");
		Utils.Cfg_UseLogs = Config.BindAndOptions(section, "Output Logs", defaultValue: false, "because I keep forgetting to remove logs from my builds haha woops.\nIf you run into a big error in this mod, you can enable this to try to get that error more reliably. Otherwise, keep this off to reduce error text spam (therefore lag)");
		string text = "liar liar plants for hire";
		Utils.Cfg_PlantsForHire = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "Cheats", false, "Press f2 f3 f6 and f9 to rain items from the sky.").Value;
		Utils.Cfg_CheatItem = ((BaseUnityPlugin)this).Config.Bind<int>(text, "Cheat Item", 7, "Press f7 to spawn this item (glasses are 7)").Value;
		Utils.Cfg_CheatItemBoring = ((BaseUnityPlugin)this).Config.Bind<int>(text, "Cheat Item2", 58, "Press f11 and f10 to add/remove this item boringly (58 for magazines)").Value;
	}

	private void CharacterBody_Start(orig_Start orig, CharacterBody self)
	{
		orig.Invoke(self);
		float specialItemDistance = getSpecialItemDistance(self);
		ModelLocator modelLocator = self.modelLocator;
		if (!((Object)(object)((modelLocator != null) ? modelLocator.modelTransform : null) == (Object)null))
		{
			CharacterSwooceHandler characterSwooceHandler = ((Component)self.modelLocator.modelTransform).gameObject.AddComponent<CharacterSwooceHandler>();
			characterSwooceHandler.Init(specialItemDistance);
		}
	}

	private void InvChangedHook(orig_OnInventoryChanged orig, CharacterBody self)
	{
		float specialItemDistance = getSpecialItemDistance(self);
		if (!((Object)(object)self.modelLocator.modelTransform == (Object)null))
		{
			if ((Object)(object)((Component)self.modelLocator.modelTransform).gameObject.GetComponent<CharacterSwooceHandler>() == (Object)null)
			{
				CharacterSwooceHandler characterSwooceHandler = ((Component)self.modelLocator.modelTransform).gameObject.AddComponent<CharacterSwooceHandler>();
				characterSwooceHandler.Init(specialItemDistance);
			}
			orig.Invoke(self);
		}
	}

	private float getSpecialItemDistance(CharacterBody self)
	{
		//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_0008: 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_0044: Unknown result type (might be due to invalid IL or missing references)
		BodyIndex bodyIndex = self.bodyIndex;
		if (CheckNames(bodyIndex, _turretGuyNames))
		{
			return Utils.Cfg_EngiTurretItemDistanceMultiplier;
		}
		if (CheckNames(bodyIndex, _scavGuyNames))
		{
			return Utils.Cfg_ScavengerItemDistanceMultiplier;
		}
		if (CheckNames(bodyIndex, _moonGuyNames))
		{
			return Utils.Cfg_BrotherItemDistanceMultiplier;
		}
		return 1f;
	}

	private static bool CheckNames(BodyIndex index, string[] names)
	{
		//IL_0006: 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)
		for (int i = 0; i < names.Length; i++)
		{
			if (index == BodyCatalog.FindBodyIndex(names[i]))
			{
				return true;
			}
		}
		return false;
	}

	private void DisableItemDisplayHook(orig_DisableItemDisplay orig, CharacterModel self, ItemIndex itemIndex)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		orig.Invoke(self, itemIndex);
		enableDisableDisplayEvent?.Invoke(self, itemIndex);
	}

	private void EnableItemDisplayHook(orig_EnableItemDisplay orig, CharacterModel self, ItemIndex itemIndex)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		orig.Invoke(self, itemIndex);
		enableDisableDisplayEvent?.Invoke(self, itemIndex);
	}

	public void Update()
	{
	}

	private void TestSpawnItem(int item = -1)
	{
		List<PickupIndex> availableTier1DropList = Run.instance.availableTier1DropList;
		TestSpawnItem(availableTier1DropList, item);
	}

	private void TestSpawnItemRed()
	{
		List<PickupIndex> availableTier3DropList = Run.instance.availableTier3DropList;
		TestSpawnItem(availableTier3DropList, -1, random: false);
	}

	private void TestSpawnItem(List<PickupIndex> dropList, int item = -1, bool random = true)
	{
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: 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_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		Transform transform = PlayerCharacterMasterController.instances[0].master.GetBodyObject().transform;
		PickupIndex val = default(PickupIndex);
		if (item > -1)
		{
			((PickupIndex)(ref val))..ctor((ItemIndex)item);
		}
		else
		{
			if (dropList.Count < 0)
			{
				return;
			}
			if (random)
			{
				if (_spawnedRandomItems >= 3)
				{
					Utils.Log("treasureRNG broken", chat: true);
					_spawnedRandomItems = 1;
				}
				else
				{
					_spawnedRandomItems++;
				}
				val = dropList[_currentRandomIndex];
			}
			else
			{
				_spawnedRedItems++;
				if (_spawnedRedItems >= 3)
				{
					_currentRedIndex++;
					_spawnedRedItems = 0;
				}
				if (_currentRedIndex >= dropList.Count)
				{
					_currentRedIndex = 1;
				}
				val = dropList[_currentRedIndex];
			}
		}
		Vector3 insideUnitSphere = Random.insideUnitSphere;
		insideUnitSphere.y = Mathf.Abs(insideUnitSphere.y * 3f);
		insideUnitSphere /= 3f;
		PickupDropletController.CreatePickupDroplet(val, transform.position + Vector3.up * 69f, insideUnitSphere * 20f);
	}
}
public class SillyItemDisplayRules : List<SillyItemDisplayRule>
{
}
public enum SillyItemDisplayBehavior
{
	DEFAULT,
	DEFAULT_BOTH_WAYS,
	OUTWARD,
	SCATTER
}
public class SillyItemDisplayRule
{
	public string character;

	public ItemIndex item;

	public Vector3 defaultStackDirection = Vector3.forward;

	public float distanceMult = 1f;

	public SillyItemDisplayBehavior stackBehavior;
}