using System.Diagnostics;
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 HarmonyLib;
using TMPro;
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("BetterTotalScrap")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BetterTotalScrap")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5e6b4978-819a-443a-8472-53738afdbef2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace BetterTotalScrap;
[BepInPlugin("impulse.BetterTotalScrap", "BetterTotalScrap", "1.1.0")]
public class BetterTotalScrap : BaseUnityPlugin
{
private const string modGUID = "impulse.BetterTotalScrap";
private const string modName = "BetterTotalScrap";
private const string modVersion = "1.1.0";
private readonly Harmony harmony = new Harmony("impulse.BetterTotalScrap");
private void Awake()
{
harmony.PatchAll(typeof(HUDManagerPatch));
harmony.PatchAll(typeof(ShipleaveCalc));
}
}
public static class GlobalVariables
{
public static int RemainingScrapInLevel;
}
[HarmonyPatch(typeof(StartOfRound), "ShipLeave")]
public class ShipleaveCalc
{
[HarmonyPostfix]
public static void Postfix()
{
GlobalVariables.RemainingScrapInLevel = CalculateRemainingScrapInLevel();
}
public static int CalculateRemainingScrapInLevel()
{
GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
int num = 0;
for (int i = 0; i < array.Length; i++)
{
if (array[i].itemProperties.isScrap && !array[i].isInShipRoom && !array[i].isInElevator && !array[i].scrapPersistedThroughRounds)
{
num += array[i].scrapValue;
}
}
return num;
}
}
[HarmonyPatch(typeof(HUDManager), "FillEndGameStats")]
public class HUDManagerPatch
{
[HarmonyPostfix]
public static void FillEndGameStatsPostfix(HUDManager __instance, int scrapCollected)
{
float num = scrapCollected + GlobalVariables.RemainingScrapInLevel;
((TMP_Text)__instance.statsUIElements.quotaDenominator).text = num.ToString();
}
}