Decompiled source of LaunderingStatus v1.0.1

Mods/LaunderingStatus.dll

Decompiled 3 weeks ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using MelonLoader;
using S1API.UI;
using ScheduleOne.DevUtilities;
using ScheduleOne.Property;
using UnityEngine;
using UnityEngine.UI;
using YahYah.Schedule1Mods.LaunderingStatus;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(ModMain), "LaunderingStatus", "1.0.1", "YahYah Game Studio", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LaunderingStatus")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+52e17de17b2f93b2a71d4873e564162e5ad22421")]
[assembly: AssemblyProduct("LaunderingStatus")]
[assembly: AssemblyTitle("LaunderingStatus")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace YahYah.Schedule1Mods.LaunderingStatus;

public class ModMain : MelonMod
{
	private GameObject _hud;

	private Text _label;

	public override void OnInitializeMelon()
	{
		MelonLogger.Msg("LaunderingStatus Initialized!");
	}

	public override void OnUpdate()
	{
		if ((Object)(object)NetworkSingleton<GameManager>.Instance == (Object)null)
		{
			return;
		}
		if ((Object)(object)_hud == (Object)null)
		{
			GameObject val = GameObject.Find("HUD");
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			MelonLogger.Msg("HUD found. Beginning rendering.");
			_hud = val;
			InstantiateUI();
		}
		List<LaunderingOperation> list = new List<LaunderingOperation>();
		foreach (Business ownedBusiness in Business.OwnedBusinesses)
		{
			list.AddRange(ownedBusiness.LaunderingOperations);
		}
		if (list.Count > 0)
		{
			_label.text = "Laundering Operations:\n";
			{
				foreach (LaunderingOperation item in list)
				{
					int num = item.completionTime_Minutes - item.minutesSinceStarted;
					int num2 = Mathf.FloorToInt((float)num / 60f);
					string arg = ((num2 > 0) ? string.Format("{0} hour{1} remaining", num2, (num2 > 1) ? "s" : "") : string.Format("{0} minute{1} remaining", num, (num > 1) ? "s" : ""));
					Text label = _label;
					label.text += $"{((Property)item.business).PropertyName}: ${item.amount:N0}, {arg}\n";
				}
				return;
			}
		}
		_label.text = string.Empty;
	}

	private void InstantiateUI()
	{
		//IL_002f: 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)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		_label = UIFactory.Text("Laundering Status Label", string.Empty, _hud.transform, 14, (TextAnchor)2, (FontStyle)1);
		((Graphic)_label).rectTransform.anchorMin = Vector2.one;
		((Graphic)_label).rectTransform.anchorMax = Vector2.one;
		((Graphic)_label).rectTransform.pivot = Vector2.one;
		((Graphic)_label).rectTransform.anchoredPosition = -Vector2.one * 10f;
		_label.horizontalOverflow = (HorizontalWrapMode)1;
		ContentSizeFitter obj = ((Component)Object.Instantiate<Text>(_label)).gameObject.AddComponent<ContentSizeFitter>();
		obj.verticalFit = (FitMode)2;
		obj.horizontalFit = (FitMode)2;
	}
}