Decompiled source of ComboSell v1.0.0

ComboSell.dll

Decompiled 11 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using TMPro;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("ComboSell")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("The company loves collecting, and will now pay more for sets of items")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e929f5920bf9735b6935446312988d66774d97bb")]
[assembly: AssemblyProduct("ComboSell")]
[assembly: AssemblyTitle("ComboSell")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ComboSell
{
	internal class ComboPricer
	{
		private List<GrabbableObject> rawObjects;

		private List<GrabbableObject> _sortedObjects;

		private ComboSettings settings;

		private List<GrabbableObject> sortedObjects
		{
			get
			{
				if (_sortedObjects == null || _sortedObjects.Count != rawObjects.Count)
				{
					_sortedObjects = rawObjects.ToList();
					_sortedObjects.Sort((GrabbableObject object1, GrabbableObject object2) => (((Object)object1.itemProperties).name != ((Object)object2.itemProperties).name) ? object1.scrapValue.CompareTo(object2.scrapValue) : ((Object)object1.itemProperties).name.CompareTo(((Object)object2.itemProperties).name));
				}
				return _sortedObjects;
			}
		}

		public ComboPricer(ref List<GrabbableObject> objects, ComboSettings settings)
		{
			this.settings = settings;
			rawObjects = objects;
		}

		public ComboResult processObjects()
		{
			Plugin.Debug("processObjects()");
			List<GrabbableObject> list = sortedObjects;
			List<GrabbableObject> list2 = new List<GrabbableObject>(list.Count);
			foreach (GrabbableObject item in list)
			{
				list2.Add(item);
			}
			List<GrabbableObject> unusedObjects = list2;
			List<ObjectCombo> list3 = new List<ObjectCombo>();
			List<ObjectCombo> list4 = new List<ObjectCombo>();
			if (settings.multiplesFirst)
			{
				Plugin.Debug("multiples first");
				list3 = processMultiples(ref unusedObjects);
				list4 = processSets(ref unusedObjects);
			}
			else
			{
				Plugin.Debug("sets first");
				list4 = processSets(ref unusedObjects);
				list3 = processMultiples(ref unusedObjects);
			}
			return new ComboResult(list3, list4, unusedObjects.ToList());
		}

		public List<ObjectCombo> processMultiples(ref List<GrabbableObject> unusedObjects)
		{
			Plugin.Debug("processMultiples([" + string.Join(", ", from obj in unusedObjects.ToList()
				select ((Object)obj.itemProperties).name) + "])");
			string[] array = (from obj in unusedObjects.ToList()
				select ((Object)obj.itemProperties).name).Distinct().ToArray();
			Plugin.Debug("uniques: [" + string.Join(", ", array.ToList()) + "]");
			List<ObjectCombo> list = new List<ObjectCombo>();
			int num = unusedObjects.Count - array.Length + 1;
			if (num > settings.maxMultiple)
			{
				num = settings.maxMultiple;
			}
			string[] array2 = array;
			foreach (string text in array2)
			{
				Plugin.Debug("Processing for multiples on unique " + text);
				if (settings.includeMultiples.Length != 0 && !settings.includeMultiples.Contains(text))
				{
					continue;
				}
				Plugin.Debug("Passes include");
				if (settings.excludeMultiples.Length != 0 && settings.excludeMultiples.Contains(text))
				{
					continue;
				}
				Plugin.Debug("Passes exclude");
				int num2 = 0;
				foreach (GrabbableObject unusedObject in unusedObjects)
				{
					if (((Object)unusedObject.itemProperties).name == text)
					{
						num2++;
					}
				}
				Plugin.Debug($"Found {num2} of item");
				if (num2 <= settings.minMultiple)
				{
					continue;
				}
				Plugin.Debug($"Found more than minMultiple({settings.minMultiple}) for '{text}'");
				do
				{
					int num3 = ((num2 > num) ? num : num2);
					num2 -= num3;
					Plugin.Debug($"leftToGet {num3}");
					if (num3 <= settings.minMultiple)
					{
						continue;
					}
					ObjectCombo objectCombo = new ObjectCombo(settings.getMultipleMultiplier(num3), ComboType.Mulitple, $"x{num3}");
					foreach (GrabbableObject item in unusedObjects.ToList())
					{
						if (num3 > 0 && ((Object)item.itemProperties).name == text)
						{
							objectCombo.addObject(item);
							unusedObjects.Remove(item);
							num3--;
							Plugin.Debug($"Adding object {text} to combo with new leftToGet {num3}");
						}
					}
					list.Add(objectCombo);
				}
				while (num2 >= num);
			}
			return list;
		}

		public List<ObjectCombo> processSets(ref List<GrabbableObject> unusedObjects)
		{
			Plugin.Debug("processSets([" + string.Join(", ", from obj in unusedObjects.ToList()
				select ((Object)obj.itemProperties).name) + "])");
			List<ObjectCombo> list = new List<ObjectCombo>();
			foreach (string key in settings.setMultipliers.Keys)
			{
				Plugin.Debug("Checking set name " + key);
				bool flag = true;
				while (flag)
				{
					Plugin.Debug("keepChecking while");
					List<GrabbableObject> list2 = new List<GrabbableObject>();
					string[] items = settings.setMultipliers[key].items;
					foreach (string text in items)
					{
						Plugin.Debug("Checking for item " + text);
						bool flag2 = false;
						foreach (GrabbableObject item in unusedObjects.ToList())
						{
							Plugin.Debug("Checking '" + ((Object)item.itemProperties).name + "' against '" + text + "'");
							if (((Object)item.itemProperties).name == text)
							{
								Plugin.Debug("Adding foundObject");
								list2.Add(item);
								flag2 = true;
								break;
							}
						}
						if (!flag2)
						{
							Plugin.Debug("Object not found");
							flag = false;
							break;
						}
					}
					if (!flag)
					{
						continue;
					}
					Plugin.Debug("Found all objects for '" + key + "'");
					ObjectCombo objectCombo = new ObjectCombo(settings.getSetMultiplier(key, list2.Count), ComboType.Set, key ?? "");
					foreach (GrabbableObject item2 in list2)
					{
						objectCombo.addObject(item2);
						unusedObjects.Remove(item2);
						unusedObjects.Remove(item2);
					}
					list.Add(objectCombo);
				}
			}
			return list;
		}
	}
	internal struct ComboResult
	{
		public List<ObjectCombo> multipleCombos { get; }

		public List<ObjectCombo> setCombos { get; }

		public List<GrabbableObject> otherObjects { get; }

		public ComboResult(List<ObjectCombo> multipleCombos, List<ObjectCombo> setCombos, List<GrabbableObject> otherObjects)
		{
			this.multipleCombos = multipleCombos ?? new List<ObjectCombo>();
			this.setCombos = setCombos ?? new List<ObjectCombo>();
			this.otherObjects = otherObjects ?? new List<GrabbableObject>();
		}
	}
	internal enum ComboType
	{
		Mulitple,
		Set
	}
	internal class ObjectCombo
	{
		private List<GrabbableObject> _objects;

		public readonly string name;

		public readonly ComboType type;

		public readonly float multiplier;

		public GrabbableObject[] objects => _objects.ToArray();

		public int totalValue
		{
			get
			{
				int num = 0;
				GrabbableObject[] array = objects;
				foreach (GrabbableObject val in array)
				{
					num += val.scrapValue;
				}
				return (int)((float)num * multiplier);
			}
		}

		public string itemNames => string.Join(", ", from obj in objects.ToList()
			select ((Object)obj.itemProperties).name);

		public string uniqueItemNames => string.Join(", ", (from obj in objects.ToList()
			select ((Object)obj.itemProperties).name).Distinct());

		public ObjectCombo(float multiplier, ComboType type, string name)
		{
			_objects = new List<GrabbableObject>();
			this.multiplier = multiplier;
			this.type = type;
			this.name = name;
		}

		public ObjectCombo(List<GrabbableObject> objects, float multiplier, ComboType type, string name)
		{
			_objects = objects;
			this.multiplier = multiplier;
			this.type = type;
			this.name = name;
		}

		public void addObject(GrabbableObject obj)
		{
			_objects.Add(obj);
		}
	}
	[Serializable]
	internal class ComboSettings
	{
		public static readonly string[] ItemNames = new string[68]
		{
			"Binoculars", "Boombox", "CardboardBox", "Flashlight", "Jetpack", "Key", "LockPicker", "LungApparatus", "MapDevice", "ProFlashlight",
			"Shovel", "StunGrenade", "ExtensionLadder", "TZPInhalant", "WalkieTalkie", "ZapGun", "7Ball", "Airhorn", "Bell", "BigBolt",
			"BottleBin", "Brush", "Candy", "CashRegister", "ChemicalJug", "ClownHorn", "Cog1", "Dentures", "DustPan", "EggBeater",
			"EnginePart1", "FancyCup", "FancyLamp", "FancyPainting", "FishTestProp", "FlashLaserPointer", "GoldBar", "Hairdryer", "MagnifyingGlass", "MetalSheet",
			"MoldPan", "Mug", "PerfumeBottle", "Phone", "PickleJar", "PillBottle", "Remote", "Ring", "RobotToy", "RubberDuck",
			"SodaCanRed", "SteeringWheel", "StopSign", "TeaKettle", "Toothpaste", "ToyCube", "RedLocustHive", "RadarBooster", "YieldSign", "Shotgun",
			"GunAmmo", "SprayPaint", "DiyFlashbang", "GiftBox", "Flask", "TragedyMask", "ComedyMask", "WhoopieCushion"
		};

		public bool removeUnknownNames;

		public bool multiplesFirst = true;

		public string[] includeMultiples = Array.Empty<string>();

		public string[] excludeMultiples = Array.Empty<string>();

		public int maxMultiple = 5;

		public int minMultiple = 2;

		public float defaultMultipleMultiplier = 0.2f;

		public float defaultSetMultiplier = 0.2f;

		public Dictionary<int, float> multipleMultipliers = new Dictionary<int, float>();

		public Dictionary<string, SetMultiplier> setMultipliers = new Dictionary<string, SetMultiplier>();

		public ComboSettings()
		{
		}

		public ComboSettings(bool removeUnknownNames)
		{
			this.removeUnknownNames = removeUnknownNames;
		}

		public float getMultipleMultiplier(int amount)
		{
			Plugin.Debug($"getMultipleMultiplier({amount})");
			if (multipleMultipliers.ContainsKey(amount))
			{
				Plugin.Debug($"multipleMultipliers contians the key, returning {multipleMultipliers[amount]}");
				return multipleMultipliers[amount];
			}
			float num = 1f + defaultMultipleMultiplier * (float)(amount - 1);
			Plugin.Debug($"multipleMultipliers doesnt contians the key, returning {num}");
			return num;
		}

		public float getSetMultiplier(string setName, int fallbackAmount)
		{
			Plugin.Debug("getMultipleMultiplier(" + setName + ")");
			if (setMultipliers.ContainsKey(setName))
			{
				Plugin.Debug($"setMultipliers contians the key, returning {setMultipliers[setName]}");
				return setMultipliers[setName].multiplier;
			}
			float num = 1f + defaultSetMultiplier * (float)(fallbackAmount - 1);
			Plugin.Debug($"setMultipliers doesnt contians the key, returning {num}");
			return num;
		}

		public void standardizeValues()
		{
			Plugin.Debug("standardizeValues()");
			Plugin.Debug("Valid item names: " + string.Join(", ", ItemNames));
			standardizeItemList(ref includeMultiples, ItemNames, "includeMultiples");
			Plugin.Debug("includeMultiples: [" + string.Join(", ", includeMultiples) + "]");
			standardizeItemList(ref excludeMultiples, ItemNames, "includeMultiples");
			Plugin.Debug("includeMultiples: [" + string.Join(", ", includeMultiples) + "]");
			Plugin.Debug("Checking minMultiple");
			if (minMultiple < 1)
			{
				Plugin.StaticLogger.LogWarning((object)$"minMultiple ({minMultiple}) cannot be lower than 1, defaulting to 1");
				minMultiple = 1;
			}
			Plugin.Debug("Checking maxMultiple");
			if (maxMultiple < minMultiple)
			{
				Plugin.StaticLogger.LogWarning((object)$"maxMultiple ({maxMultiple}) cannot be lower than minMultiple ({minMultiple}), defaulting to minMultiple ({minMultiple})");
				maxMultiple = minMultiple;
			}
			Plugin.Debug("Checking multipleMultipliers");
			int[] array = multipleMultipliers.Keys.ToArray();
			foreach (int num in array)
			{
				if (num < minMultiple || num > maxMultiple)
				{
					Plugin.StaticLogger.LogWarning((object)$"multiplier key ({num}) in multipleMultipliers is out of range of minMultiple ({minMultiple}) and maxMultiple ({maxMultiple}). Removing...");
					if (removeUnknownNames)
					{
						multipleMultipliers.Remove(num);
					}
				}
			}
			Plugin.Debug("Checking setMultipliers");
			string[] array2 = setMultipliers.Keys.ToArray();
			foreach (string text in array2)
			{
				SetMultiplier setMultiplier = setMultipliers[text];
				List<string> list = new List<string>();
				Plugin.Debug("Checking names in setMultiplers (" + text + ")");
				string[] items = setMultiplier.items;
				foreach (string text2 in items)
				{
					if (!ItemNames.Contains(text2))
					{
						list.Add(text2);
					}
				}
				if (list.Count > 0)
				{
					Plugin.StaticLogger.LogWarning((object)("Items " + string.Join(",", list) + " from setMultiplier " + text + " cannot be found in set of all items, see readme or turn on debug to see values"));
					if (removeUnknownNames)
					{
						setMultipliers.Remove(text);
					}
				}
			}
		}

		public void standardizeItemList(ref string[] listOfItems, string[] allItems, string logName)
		{
			Plugin.Debug(string.Format("standardizeItemList({0}, {1}, {2}) [{3}]", listOfItems.Length, allItems.Length, logName, string.Join(", ", listOfItems)));
			List<string> list = listOfItems.Distinct().ToList();
			if (list.Count != listOfItems.Length)
			{
				Plugin.StaticLogger.LogWarning((object)("Duplicates found and removed in " + logName + ", consider removing the duplicates"));
			}
			Plugin.Debug("Checking each in de-duped list");
			string[] array = list.ToArray();
			foreach (string text in array)
			{
				if (!allItems.Contains(text))
				{
					Plugin.StaticLogger.LogWarning((object)("Cannot find '" + text + "' from " + logName + " in set of all item names, see readme or turn on debug to see values"));
					if (removeUnknownNames)
					{
						list.Remove(text);
					}
				}
			}
			Plugin.Debug("Output list: [" + string.Join(", ", listOfItems) + "]");
			listOfItems = list.ToArray();
		}

		public static ComboSettings FromJson(string json, bool removeUnkownNames)
		{
			try
			{
				ComboSettings comboSettings = JsonConvert.DeserializeObject<ComboSettings>(json);
				comboSettings.removeUnknownNames = removeUnkownNames;
				comboSettings.standardizeValues();
				return comboSettings;
			}
			catch (Exception ex)
			{
				Plugin.StaticLogger.LogError((object)"Unable to load or standardize values for combo settings, please check config");
				Plugin.StaticLogger.LogError((object)ex);
				return new ComboSettings();
			}
		}
	}
	internal struct SetMultiplier
	{
		public string[] items;

		public float multiplier;
	}
	internal class CompanyCounterPatch
	{
		public static ComboSettings settings;

		[HarmonyPatch(typeof(DepositItemsDesk), "SellItemsOnServer")]
		[HarmonyPrefix]
		private static bool SellItemsOnServerPrefix(DepositItemsDesk __instance)
		{
			try
			{
				Plugin.Debug("SellItemsOnServerPrefix()");
				if (!((NetworkBehaviour)__instance).IsServer)
				{
					return false;
				}
				__instance.inSellingItemsAnimation = true;
				Plugin.Debug(string.Format("__instance.itemsOnCounter ({0})[{1}]", __instance.itemsOnCounter.Count, string.Join(", ", from obj in __instance.itemsOnCounter.ToList()
					select ((Object)obj.itemProperties).name)));
				GrabbableObject[] componentsInChildren = ((Component)__instance.deskObjectsContainer).GetComponentsInChildren<GrabbableObject>();
				Plugin.Debug(string.Format("componentsInChildren ({0})[{1}]", componentsInChildren.Length, string.Join(", ", from obj in componentsInChildren.ToList()
					select ((Object)obj.itemProperties).name)));
				List<GrabbableObject> objects = componentsInChildren.Where((GrabbableObject obj) => obj.itemProperties.isScrap).ToList();
				Plugin.Debug(string.Format("itemsToCalc2 ({0})[{1}]", objects.Count, string.Join(", ", from obj in objects.ToList()
					select ((Object)obj.itemProperties).name)));
				List<GrabbableObject> list = __instance.itemsOnCounter.Where((GrabbableObject obj) => obj.itemProperties.isScrap).ToList();
				Plugin.Debug(string.Format("itemsToCalc ({0})[{1}]", list.Count, string.Join(", ", from obj in list.ToList()
					select ((Object)obj.itemProperties).name)));
				ComboResult comboResult = new ComboPricer(ref objects, settings).processObjects();
				Plugin.Debug("Result info:");
				Plugin.Debug(string.Format("multipleCombos ({0})[{1}]", comboResult.multipleCombos.Count, string.Join(", ", comboResult.multipleCombos)));
				Plugin.Debug(string.Format("setCombos ({0})[{1}]", comboResult.setCombos.Count, string.Join(", ", comboResult.setCombos)));
				Plugin.Debug(string.Format("otherObjects ({0})[{1}]", comboResult.otherObjects.Count, string.Join(", ", comboResult.otherObjects)));
				int num = 0;
				Plugin.Debug($"totalValue start {num}");
				foreach (ObjectCombo multipleCombo in comboResult.multipleCombos)
				{
					Plugin.Debug($"combo {multipleCombo.name}, totalValue {multipleCombo.totalValue}, multiplier {multipleCombo.multiplier}, type {multipleCombo.type}, items [{multipleCombo.itemNames}]");
					num += multipleCombo.totalValue;
				}
				Plugin.Debug($"totalValue multiple {num}");
				foreach (ObjectCombo setCombo in comboResult.setCombos)
				{
					Plugin.Debug($"combo {setCombo.name}, totalValue {setCombo.totalValue}, multiplier {setCombo.multiplier}, type {setCombo.type}, items [{setCombo.itemNames}]");
					num += setCombo.totalValue;
				}
				Plugin.Debug($"totalValue set {num}");
				foreach (GrabbableObject otherObject in comboResult.otherObjects)
				{
					Plugin.Debug($"other object {((Object)otherObject.itemProperties).name}, scrapValue {otherObject.scrapValue}");
					num += otherObject.scrapValue;
				}
				Plugin.Debug($"totalValue other {num}");
				num = (int)((float)num * StartOfRound.Instance.companyBuyingRate);
				Terminal val = Object.FindObjectOfType<Terminal>();
				val.groupCredits += num;
				__instance.SellItemsClientRpc(num, val.groupCredits, __instance.itemsOnCounterAmount, StartOfRound.Instance.companyBuyingRate);
				__instance.SellAndDisplayItemProfits(num, val.groupCredits);
				return false;
			}
			catch (Exception ex)
			{
				Plugin.StaticLogger.LogError((object)"Error processing SellItemsOnServerPostfix, please report this with debug logs.");
				Plugin.StaticLogger.LogError((object)ex);
			}
			return true;
		}

		[HarmonyPatch(typeof(HUDManager), "DisplayCreditsEarning")]
		[HarmonyPostfix]
		private static void DisplayCreditsEarningPostfix(ref int creditsEarned, ref GrabbableObject[] objectsSold, ref int newGroupCredits, HUDManager __instance)
		{
			try
			{
				Plugin.Debug(string.Format("DisplayCreditsEarningPostfix({0}, [{1}], {2})", creditsEarned, string.Join(", ", from obj in objectsSold.ToList()
					select ((Object)obj.itemProperties).name), newGroupCredits));
				string text = "";
				List<GrabbableObject> objects = objectsSold.Where((GrabbableObject obj) => obj.itemProperties.isScrap).ToList();
				ComboResult comboResult = new ComboPricer(ref objects, settings).processObjects();
				Plugin.Debug("Result info:");
				Plugin.Debug(string.Format("multipleCombos ({0})[{1}]", comboResult.multipleCombos.Count, string.Join(", ", comboResult.multipleCombos)));
				Plugin.Debug(string.Format("setCombos ({0})[{1}]", comboResult.setCombos.Count, string.Join(", ", comboResult.setCombos)));
				Plugin.Debug(string.Format("otherObjects ({0})[{1}]", comboResult.otherObjects.Count, string.Join(", ", from obj in comboResult.otherObjects.ToList()
					select ((Object)obj.itemProperties).name)));
				if (comboResult.multipleCombos.Count > 0)
				{
					text += "Multiplier Combos \n";
				}
				Plugin.Debug("Processing text for multipleCombos");
				foreach (ObjectCombo multipleCombo in comboResult.multipleCombos)
				{
					Plugin.Debug($"combo {multipleCombo.name}, totalValue {multipleCombo.totalValue}, multiplier {multipleCombo.multiplier}, type {multipleCombo.type}, items [{multipleCombo.itemNames}]");
					int totalValue = multipleCombo.totalValue;
					text += $"{multipleCombo.uniqueItemNames} ({multipleCombo.name}) : {totalValue} (x{multipleCombo.multiplier}) \n";
				}
				if (comboResult.setCombos.Count > 0)
				{
					text += "Set Combos \n";
				}
				Plugin.Debug("Processing text for setCombos");
				foreach (ObjectCombo setCombo in comboResult.setCombos)
				{
					Plugin.Debug($"combo {setCombo.name}, totalValue {setCombo.totalValue}, multiplier {setCombo.multiplier}, type {setCombo.type}, items [{setCombo.itemNames}]");
					int totalValue2 = setCombo.totalValue;
					text += $"{setCombo.itemNames} ({setCombo.name}) : {totalValue2} (x{setCombo.multiplier}) \n";
				}
				if (comboResult.otherObjects.Count > 0)
				{
					text += "Regular Sales \n";
				}
				Plugin.Debug("Processing text for otherObjects");
				Item[] array = (from obj in comboResult.otherObjects.ToList()
					select obj.itemProperties).Distinct().ToArray();
				foreach (Item val in array)
				{
					Plugin.Debug("From uniques " + ((Object)val).name);
					int num = 0;
					int num2 = 0;
					foreach (GrabbableObject otherObject in comboResult.otherObjects)
					{
						Plugin.Debug("From otherObjects " + ((Object)otherObject.itemProperties).name);
						if ((Object)(object)otherObject.itemProperties == (Object)(object)val)
						{
							Plugin.Debug($"Adding scrap value for {((Object)val).name} of value {otherObject.scrapValue}");
							num += otherObject.scrapValue;
							num2++;
						}
					}
					text += $"{val.itemName} (x{num2}) : {num} \n";
				}
				((TMP_Text)__instance.moneyRewardsListText).text = text;
				((TMP_Text)__instance.moneyRewardsTotalText).text = $"TOTAL: ${creditsEarned}";
				__instance.moneyRewardsAnimator.SetTrigger("showRewards");
				__instance.rewardsScrollbar.value = 1f;
				if (text.Split('\n').Length > 8)
				{
					Plugin.Debug("Output text is greater than 8 lines");
					if (__instance.scrollRewardTextCoroutine != null)
					{
						((MonoBehaviour)__instance).StopCoroutine(__instance.scrollRewardTextCoroutine);
					}
					__instance.scrollRewardTextCoroutine = ((MonoBehaviour)__instance).StartCoroutine(__instance.scrollRewardsListText());
				}
			}
			catch (Exception ex)
			{
				Plugin.StaticLogger.LogError((object)"Error processing DisplayCreditsEarningPostfix, please report this with debug logs.");
				Plugin.StaticLogger.LogError((object)ex);
			}
		}
	}
	internal class DebugPatch
	{
		public static Random ScrapRandom = new Random();

		[HarmonyPatch(typeof(RoundManager), "InitializeRandomNumberGenerators")]
		[HarmonyPrefix]
		public static void InitializeRandomNumberGeneratorsPrefix(RoundManager __instance)
		{
			ScrapRandom = new Random(__instance.playersManager.randomMapSeed + 69);
		}

		[HarmonyPatch(typeof(QuickMenuManager), "Debug_SpawnItem")]
		[HarmonyPostfix]
		public static void Debug_SpawnItemPostfix(QuickMenuManager __instance)
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			if (Application.isEditor && NetworkManager.Singleton.IsConnectedClient && NetworkManager.Singleton.IsServer)
			{
				Plugin.Debug(string.Join(", ", from item in StartOfRound.Instance.allItemsList.itemsList.ToList()
					select ((Object)item).name));
				GameObject obj = Object.Instantiate<GameObject>(StartOfRound.Instance.allItemsList.itemsList[__instance.itemToSpawnId].spawnPrefab, __instance.debugEnemySpawnPositions[3].position, Quaternion.identity, StartOfRound.Instance.propsContainer);
				obj.GetComponent<GrabbableObject>().fallTime = 0f;
				obj.GetComponent<GrabbableObject>().scrapValue = ScrapRandom.Next(1, 100);
				obj.GetComponent<NetworkObject>().Spawn(false);
			}
		}
	}
	[BepInPlugin("ComboSell", "ComboSell", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static ManualLogSource StaticLogger;

		public static bool debug;

		private Harmony _harmony;

		private readonly string configPath = Path.Combine(Paths.ConfigPath, "combos.json");

		private void Awake()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			StaticLogger = ((BaseUnityPlugin)this).Logger;
			StaticLogger.LogInfo((object)"ComboSell loading...");
			ConfigFile();
			_harmony = new Harmony("ComboSell");
			if (debug)
			{
				_harmony.PatchAll(typeof(DebugPatch));
			}
			_harmony.PatchAll(typeof(CompanyCounterPatch));
			StaticLogger.LogInfo((object)"ComboSell loaded");
		}

		private void ConfigFile()
		{
			debug = ((BaseUnityPlugin)this).Config.Bind<bool>("Dev", "Debug", false, "Whether or not to enable debug logging and debug helpers").Value;
			ConfigEntry<bool> val = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Remove unknown items", false, "Whether or not to remove unknown item names when loading the config, this doesn't write to the json");
			if (!File.Exists(configPath))
			{
				CompanyCounterPatch.settings = new ComboSettings(val.Value);
				File.WriteAllText(configPath, JsonConvert.SerializeObject((object)CompanyCounterPatch.settings));
				return;
			}
			try
			{
				CompanyCounterPatch.settings = ComboSettings.FromJson(File.ReadAllText(configPath), val.Value);
			}
			catch (Exception ex)
			{
				StaticLogger.LogError((object)ex);
				CompanyCounterPatch.settings = new ComboSettings(val.Value);
			}
		}

		public static void Debug(string message)
		{
			if (debug)
			{
				StaticLogger.LogDebug((object)message);
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "ComboSell";

		public const string PLUGIN_NAME = "ComboSell";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}