Decompiled source of StockOverview v1.0.3

StockOverview.dll

Decompiled a year ago
using System;
using System.Collections;
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 BepInEx;
using HarmonyLib;
using TerminalApi;
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("StockOverview")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StockOverview")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e51b9040-4911-42f8-8c25-b79b34a4965a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace StockOverview;

public static class PluginInfo
{
	public const string PLUGIN_NAME = "StockOverview";

	public const string PLUGIN_VERSION = "1.0.3";

	public const string PLUGIN_GUID = "squall4120.stockoverview";
}
[BepInPlugin("squall4120.stockoverview", "StockOverview", "1.0.3")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class StockOverview : BaseUnityPlugin
{
	private void Awake()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin StockOverview is loaded!");
		Harmony val = new Harmony("squall4120.stockoverview");
		val.PatchAll(Assembly.GetExecutingAssembly());
		TerminalNode val2 = TerminalApi.CreateTerminalNode("Scanning for scrap on ship...\n", true, "stockoverview");
		TerminalKeyword val3 = TerminalApi.CreateTerminalKeyword("stock", true, val2);
		TerminalApi.AddTerminalKeyword(val3);
	}

	public static string BuildOverview()
	{
		string displayText = "STOCK OVERVIEW\n\n";
		IEnumerable<GrabbableObject> source = from obj in GameObject.Find("/Environment/HangarShip").GetComponentsInChildren<GrabbableObject>()
			where ((Object)obj).name != "ClipboardManual" && ((Object)obj).name != "StickyNoteItem"
			select obj;
		string format = "Quantity of all items: {0}";
		string format2 = "Total value of all items: ${0:F0}";
		displayText = displayText + string.Format(format, source.Count()) + "\n";
		displayText = displayText + string.Format(format2, source.Sum((GrabbableObject item) => item.scrapValue)) + "\n";
		displayText += "____________________________\n\n";
		List<IGrouping<string, GrabbableObject>> list = (from item in source
			group item by item.itemProperties.itemName into @group
			orderby @group.Key
			select @group).ToList();
		string format3 = "{0} / x{1} / Total Value: ${2:F0}";
		string singleItem = "  {0} - Value: ${1:F0}";
		foreach (IGrouping<string, GrabbableObject> item in list)
		{
			displayText = displayText + string.Format(format3, item.Key, item.Count(), item.Sum((GrabbableObject item) => item.scrapValue)) + "\n";
			CollectionExtensions.Do<GrabbableObject>((IEnumerable<GrabbableObject>)item, (Action<GrabbableObject>)delegate(GrabbableObject item)
			{
				displayText = displayText + string.Format(singleItem, item.itemProperties.itemName, item.scrapValue) + "\n";
			});
			displayText += "\n";
		}
		return displayText;
	}
}
[HarmonyPatch(typeof(Terminal))]
[HarmonyPatch("RunTerminalEvents")]
public class RunTerminalEvents_Patch : MonoBehaviour
{
	private static IEnumerator PostfixCoroutine(Terminal __instance, TerminalNode node)
	{
		if (!string.IsNullOrWhiteSpace(node.terminalEvent) && !(node.terminalEvent != "stockoverview"))
		{
			node.displayText = StockOverview.BuildOverview();
		}
		yield break;
	}

	private static void Postfix(Terminal __instance, TerminalNode node)
	{
		((MonoBehaviour)__instance).StartCoroutine(PostfixCoroutine(__instance, node));
	}
}