using System.Collections.Generic; using System.Diagnostics; using System.Linq; 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.Logging; using HarmonyLib; using TMPro; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("BetterPaycheck")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BetterPaycheck")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("7128c731-90f0-445c-bdb6-b647232ca42e")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace BetterPaycheck; [BepInPlugin("Swaggies.BetterPaycheck", "BetterPaycheck", "0.9.2")] public class Plugin : BaseUnityPlugin { private class SellingItem { public string name; public int value = -1; } private const string _guid = "Swaggies.BetterPaycheck"; private const string _name = "BetterPaycheck"; private const string _ver = "0.9.2"; private readonly Harmony harmony = new Harmony("Swaggies.BetterPaycheck"); private static Plugin Instance; private static ManualLogSource logginstein; private static float buyingRateToShow = 0f; private static readonly int sellingItemListLimit = 20; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } logginstein = Logger.CreateLogSource("Swaggies.BetterPaycheck"); harmony.PatchAll(typeof(Plugin)); logginstein.LogInfo((object)"BetterPaycheck up and running."); } [HarmonyPatch(typeof(HUDManager), "DisplayCreditsEarning")] [HarmonyPrefix] private static bool PaycheckPatch(ref GrabbableObject[] objectsSold) { List list = new List(); GrabbableObject[] array = objectsSold; foreach (GrabbableObject val in array) { SellingItem sellingItem = new SellingItem { name = val.itemProperties.itemName }; if (val.itemProperties.isScrap) { sellingItem.value = val.scrapValue; } else if (val.itemProperties.itemId == 14) { sellingItem.value = val.scrapValue; } list.Add(sellingItem); } buyingRateToShow = StartOfRound.Instance.companyBuyingRate; DisplayNewPaycheck(list.OrderByDescending((SellingItem o) => o.value).ToArray()); return false; } private static void DisplayNewPaycheck(SellingItem[] items) { //IL_0234: Unknown result type (might be due to invalid IL or missing references) string text = ""; int num = 0; for (int i = 0; i < items.Length; i++) { if (i == sellingItemListLimit - 1 && items.Length > sellingItemListLimit) { int num2 = Mathf.Clamp(items.Length - sellingItemListLimit + 1, 0, 999); int num3 = 0; for (int j = i; j < items.Length; j++) { if (items[j].value >= 0) { num3 += items[j].value; } } num += num3; string text2 = MaximizeStringLength($"...and {num2:n0} more", 22); string lineColorByScrapValue = GetLineColorByScrapValue(num3); string text3 = ThisCodeWasMade3YearsAgoBeforeIKnewAnythingImSorryAboutThis(num3); string text4 = "" + text3 + ""; text = text + "" + text2 + " = " + text4 + "\n"; break; } SellingItem sellingItem = items[i]; string text5 = MaximizeStringLength(sellingItem.name, 22); string lineColorByScrapValue2 = GetLineColorByScrapValue(sellingItem.value); string text6 = ThisCodeWasMade3YearsAgoBeforeIKnewAnythingImSorryAboutThis(sellingItem.value); string text7 = "" + text6 + ""; text = text + text5 + " = " + text7 + "\n"; if (sellingItem.value >= 0) { num += sellingItem.value; } } if (items.Length < 20) { for (int k = items.Length; k < 20; k++) { text += "\n."; } } string text8 = ThisCodeWasMade3YearsAgoBeforeIKnewAnythingImSorryAboutThis((int)((float)num * buyingRateToShow)); ((TMP_Text)HUDManager.Instance.moneyRewardsTotalText).text = "TOTAL: " + text8 + ""; ((TMP_Text)HUDManager.Instance.moneyRewardsListText).text = text; HUDManager.Instance.moneyRewardsAnimator.SetTrigger("showRewards"); HUDManager.Instance.rewardsContent.anchoredPosition = Vector2.zero; if (items.Length > 8) { if (HUDManager.Instance.scrollRewardTextCoroutine != null) { ((MonoBehaviour)HUDManager.Instance).StopCoroutine(HUDManager.Instance.scrollRewardTextCoroutine); } HUDManager.Instance.scrollRewardTextCoroutine = ((MonoBehaviour)HUDManager.Instance).StartCoroutine(HUDManager.Instance.scrollRewardsListText()); } } private static string GetLineColorByScrapValue(int value) { if (value >= 999999) { return "#ffffff"; } if (value >= 100000) { return "#50ffff"; } if (value >= 10000) { return "#2525ff"; } if (value >= 1000) { return "#5025ff"; } if (value >= 500) { return "#9925ff"; } if (value >= 300) { return "#ff25ff"; } if (value >= 200) { return "#ff25aa"; } if (value >= 150) { return "#ff2550"; } if (value >= 120) { return "#ff2525"; } if (value >= 100) { return "#ff5025"; } if (value >= 80) { return "#ff6925"; } if (value >= 60) { return "#ff9525"; } if (value >= 40) { return "#ffff25"; } if (value >= 25) { return "#50ff25"; } if (value >= 10) { return "#25ff50"; } if (value > 0) { return "#2550ff"; } return "#676767"; } private static string ThisCodeWasMade3YearsAgoBeforeIKnewAnythingImSorryAboutThis(int initialNumber) { if (initialNumber < 0) { return "N/A"; } initialNumber = Mathf.Clamp(initialNumber, 0, 2100000000); if ((double)initialNumber < 1000000.0) { return $"${initialNumber}"; } int num = 1; string text = "there was something very wrong with me 3 years ago, im sorry to anyone reading this now, i cant be bothered to fix it :("; float num2; if ((double)initialNumber >= 1000000000.0) { num2 = (float)initialNumber / 1E+09f; text = "B"; } else { num2 = (float)initialNumber / 1000000f; text = "M"; } if (num2 < 10f) { num = 100; } else if (num2 < 100f) { num = 10; } num2 = Mathf.Floor(num2 * (float)num) / (float)num; return num switch { 100 => $"${num2:0.00}{text}", 10 => $"${num2:0.0}{text}", _ => $"${num2}{text}", }; } private static string MaximizeStringLength(string text, int targetCharacterCount) { if (text.Length >= targetCharacterCount) { return ShortenString(text, targetCharacterCount); } string text2 = text; while (text2.Length < targetCharacterCount) { text2 += " "; } return text2; } private static string ShortenString(string text, int maxCharacterCount) { if (text.Length <= maxCharacterCount) { return text; } return new string(text.Take(maxCharacterCount - 1).ToArray()) + "…"; } }