Decompiled source of LaundryApp v1.0.4

Mods/LaundryApp.dll

Decompiled 21 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppScheduleOne;
using Il2CppScheduleOne.DevUtilities;
using Il2CppScheduleOne.Money;
using Il2CppScheduleOne.Property;
using Il2CppScheduleOne.UI;
using Il2CppScheduleOne.UI.Phone;
using Il2CppScheduleOne.Variables;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LaundryApp;
using MelonLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Core), "Laundry App", "1.0.4", "DazUki", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: AssemblyMetadata("NexusModID", "1455")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("LaundryApp")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: AssemblyInformationalVersion("1.0.0+5b509edaea6d3aac898df690fd0aef6689bc54d7")]
[assembly: AssemblyProduct("LaundryApp")]
[assembly: AssemblyTitle("LaundryApp")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.4.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 LaundryApp
{
	public class Core : MelonMod
	{
		[CompilerGenerated]
		private sealed class <InitializeLaundryApp>d__8 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Core <>4__this;

			private int <maxWaitAttempts>5__2;

			private int <attempts>5__3;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <InitializeLaundryApp>d__8(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0097: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a1: Expected O, but got Unknown
				int num = <>1__state;
				Core core = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<maxWaitAttempts>5__2 = 100;
					<attempts>5__3 = 0;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (<attempts>5__3 < <maxWaitAttempts>5__2)
				{
					<attempts>5__3++;
					if (!PlayerSingleton<HomeScreen>.InstanceExists || !PlayerSingleton<AppsCanvas>.InstanceExists)
					{
						((MelonBase)core).LoggerInstance.Msg($"[Laundry_App] Waiting for Phone UI to be setup... (Attempt {<attempts>5__3})");
						<>2__current = (object)new WaitForSeconds(0.1f);
						<>1__state = 1;
						return true;
					}
				}
				if (<attempts>5__3 >= <maxWaitAttempts>5__2)
				{
					((MelonBase)core).LoggerInstance.Error("Phone UI did not initialize in time");
					return false;
				}
				try
				{
					((MelonBase)core).LoggerInstance.Msg("Phone UI is ready, creating Laundry App...");
					core._laundryApp = new LaundryApp();
					core._laundryApp.Initialize();
					((MelonBase)core).LoggerInstance.Msg("Laundry App initialized successfully");
				}
				catch (Exception ex)
				{
					((MelonBase)core).LoggerInstance.Error("Failed to initialize laundry app: " + ex.Message);
					((MelonBase)core).LoggerInstance.Error("Stack trace: " + ex.StackTrace);
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private bool _initialized;

		private LaundryApp _laundryApp;

		public static Core Instance { get; private set; }

		public override void OnInitializeMelon()
		{
			Instance = this;
			((MelonBase)this).LoggerInstance.Msg("Laundry App loaded!");
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			if (sceneName == "Menu")
			{
				_initialized = false;
				_laundryApp = null;
			}
			else if (sceneName == "Main" && !_initialized)
			{
				_initialized = true;
				MelonCoroutines.Start(InitializeLaundryApp());
			}
		}

		[IteratorStateMachine(typeof(<InitializeLaundryApp>d__8))]
		private IEnumerator InitializeLaundryApp()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <InitializeLaundryApp>d__8(0)
			{
				<>4__this = this
			};
		}

		public override void OnUpdate()
		{
			_laundryApp?.Update();
		}
	}
	public class LaundryApp
	{
		private readonly UI _ui;

		private BusinessView _businessView;

		private bool _isOpen;

		private float _lastRefreshTime;

		private string _lastAmount = "100";

		private float _lastAddButtonClickTime = -2f;

		private readonly List<Business> _ownedBusinesses = new List<Business>();

		public LaundryApp()
		{
			_ui = new UI();
		}

		public void Initialize()
		{
			_ui.Initialize();
			if ((Object)(object)_ui.HeaderText == (Object)null || (Object)(object)_ui.BusinessListContainer == (Object)null || (Object)(object)_ui.CircleSprite == (Object)null)
			{
				MelonLogger.Error("[LaundryApp] Failed to initialize - UI components are null");
				return;
			}
			_businessView = new BusinessView(_ui.HeaderText, _ui.BusinessListContainer, _ui.CircleSprite);
			RegisterEventHandlers();
			MelonLogger.Msg("[LaundryApp] App initialized");
		}

		private void RegisterEventHandlers()
		{
			_ui.RegisterIconClickHandler(OnAppIconClicked);
			OperationsView operationsView = _ui.OperationsView;
			if (operationsView != null)
			{
				Button startOperationButton = operationsView.StartOperationButton;
				if (startOperationButton != null)
				{
					((UnityEvent)startOperationButton.onClick).AddListener(UnityAction.op_Implicit((Action)OnStartOperationClicked));
				}
			}
			OperationsView operationsView2 = _ui.OperationsView;
			if (operationsView2 != null)
			{
				InputField amountInput = operationsView2.AmountInput;
				if (amountInput != null)
				{
					((UnityEvent<string>)(object)amountInput.onValueChanged).AddListener(UnityAction<string>.op_Implicit((Action<string>)OnAmountValueChanged));
				}
			}
			OperationsView operationsView3 = _ui.OperationsView;
			if (operationsView3 != null)
			{
				Dropdown businessDropdown = operationsView3.BusinessDropdown;
				if (businessDropdown != null)
				{
					((UnityEvent<int>)(object)businessDropdown.onValueChanged).AddListener(UnityAction<int>.op_Implicit((Action<int>)OnBusinessDropdownChanged));
				}
			}
			OperationsView operationsView4 = _ui.OperationsView;
			if (operationsView4 != null)
			{
				Button maxButton = operationsView4.MaxButton;
				if (maxButton != null)
				{
					((UnityEvent)maxButton.onClick).AddListener(UnityAction.op_Implicit((Action)OnMaxButtonClicked));
				}
			}
			GameInput.RegisterExitListener(ExitDelegate.op_Implicit((Action<ExitAction>)OnExitAction), 1);
			Phone instance = PlayerSingleton<Phone>.Instance;
			if ((Object)(object)instance != (Object)null)
			{
				instance.closeApps += Action.op_Implicit((Action)Close);
			}
		}

		private void OnAmountValueChanged(string val)
		{
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_ui.OperationsView?.AmountInput == (Object)null || (Object)(object)_ui.OperationsView?.StartOperationButton == (Object)null)
			{
				return;
			}
			if (string.IsNullOrEmpty(val))
			{
				_ui.OperationsView.AmountInput.text = _lastAmount;
				return;
			}
			Dropdown businessDropdown = _ui.OperationsView.BusinessDropdown;
			int num = ((businessDropdown != null) ? businessDropdown.value : (-1));
			if (int.TryParse(val, out var result) && num >= 0 && num < _ownedBusinesses.Count)
			{
				Business val2 = _ownedBusinesses[num];
				float num2 = val2.LaunderCapacity - val2.currentLaunderTotal;
				if ((float)result > num2 && num2 > 0f)
				{
					result = (int)num2;
					_ui.OperationsView.AmountInput.text = result.ToString();
					_lastAmount = result.ToString();
					return;
				}
			}
			_lastAmount = val;
			bool flag = true;
			if (num >= 0 && num < _ownedBusinesses.Count)
			{
				Business val3 = _ownedBusinesses[num];
				flag = val3.LaunderCapacity - val3.currentLaunderTotal > 0f;
			}
			MoneyManager instance = NetworkSingleton<MoneyManager>.Instance;
			bool flag2 = true;
			if ((Object)(object)instance != (Object)null && int.TryParse(val, out var result2))
			{
				flag2 = Mathf.FloorToInt(instance.cashBalance) >= result2;
			}
			int result3;
			bool flag3 = int.TryParse(val, out result3) && result3 >= 10 && flag && flag2;
			((Selectable)_ui.OperationsView.StartOperationButton).interactable = flag3;
			if ((Object)(object)((Selectable)_ui.OperationsView.StartOperationButton).image != (Object)null)
			{
				((Graphic)((Selectable)_ui.OperationsView.StartOperationButton).image).color = Color32.op_Implicit(flag3 ? Constants.BUTTON_BACKGROUND_COLOR : Constants.BUTTON_DISABLED_COLOR);
			}
		}

		private void OnAppIconClicked()
		{
			if (_isOpen)
			{
				Close();
			}
			else
			{
				Open();
			}
		}

		private void OnMaxButtonClicked()
		{
			if ((Object)(object)_ui?.OperationsView?.BusinessDropdown == (Object)null || (Object)(object)_ui?.OperationsView?.AmountInput == (Object)null)
			{
				return;
			}
			int value = _ui.OperationsView.BusinessDropdown.value;
			if (value < 0 || value >= _ownedBusinesses.Count)
			{
				return;
			}
			Business val = _ownedBusinesses[value];
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			float num = val.LaunderCapacity - val.currentLaunderTotal;
			if (!(num <= 0f))
			{
				float num2 = num;
				MoneyManager instance = NetworkSingleton<MoneyManager>.Instance;
				if ((Object)(object)instance != (Object)null && instance.cashBalance < num2)
				{
					num2 = instance.cashBalance;
				}
				_ui.OperationsView.AmountInput.text = Mathf.FloorToInt(num2).ToString();
			}
		}

		private void PopulateBusinessDropdown()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			if ((Object)(object)_ui.OperationsView?.BusinessDropdown == (Object)null)
			{
				return;
			}
			_ownedBusinesses.Clear();
			List<Business> ownedBusinesses = Business.OwnedBusinesses;
			List<OptionData> val = new List<OptionData>();
			for (int i = 0; i < ownedBusinesses.Count; i++)
			{
				Business val2 = ownedBusinesses[i];
				if ((Object)(object)val2 != (Object)null)
				{
					_ownedBusinesses.Add(val2);
					OptionData val3 = new OptionData();
					val3.text = ((Property)val2).PropertyName;
					val.Add(val3);
				}
			}
			_ui.OperationsView.BusinessDropdown.ClearOptions();
			_ui.OperationsView.BusinessDropdown.AddOptions(val);
			_ui.OperationsView.BusinessDropdown.value = 0;
			UpdateCapacityDisplay(0);
		}

		private void OnBusinessDropdownChanged(int index)
		{
			UpdateCapacityDisplay(index);
		}

		private void UpdateCapacityDisplay(int businessIndex)
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			if (businessIndex < 0 || businessIndex >= _ownedBusinesses.Count)
			{
				return;
			}
			Business val = _ownedBusinesses[businessIndex];
			if (val.LaunderCapacity - val.currentLaunderTotal <= 0f)
			{
				if ((Object)(object)_ui.OperationsView?.StartOperationButton != (Object)null)
				{
					((Selectable)_ui.OperationsView.StartOperationButton).interactable = false;
					if ((Object)(object)((Selectable)_ui.OperationsView.StartOperationButton).image != (Object)null)
					{
						((Graphic)((Selectable)_ui.OperationsView.StartOperationButton).image).color = Color32.op_Implicit(Constants.BUTTON_DISABLED_COLOR);
					}
				}
			}
			else if ((Object)(object)_ui.OperationsView?.AmountInput != (Object)null)
			{
				OnAmountValueChanged(_ui.OperationsView.AmountInput.text);
			}
		}

		private void OnStartOperationClicked()
		{
			if (Time.time - _lastAddButtonClickTime < 2f)
			{
				if ((Object)(object)_ui.OperationsView?.StartOperationButtonText != (Object)null)
				{
					_ui.OperationsView.StartOperationButtonText.text = "...";
				}
				return;
			}
			if ((Object)(object)_ui.OperationsView?.BusinessDropdown == (Object)null || (Object)(object)_ui.OperationsView?.AmountInput == (Object)null)
			{
				MelonLogger.Error("[LaundryApp] OperationsView components are null");
				return;
			}
			int value = _ui.OperationsView.BusinessDropdown.value;
			if (value < 0 || value >= _ownedBusinesses.Count)
			{
				MelonLogger.Warning("[LaundryApp] Invalid business selection");
				return;
			}
			Business val = _ownedBusinesses[value];
			if (!int.TryParse(_ui.OperationsView.AmountInput.text, out var result) || result < 10)
			{
				MelonLogger.Warning($"[LaundryApp] Invalid amount (min ${10})");
				return;
			}
			MoneyManager instance = NetworkSingleton<MoneyManager>.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				MelonLogger.Error("[LaundryApp] MoneyManager instance is null");
				return;
			}
			if (instance.cashBalance < (float)result)
			{
				MelonLogger.Warning($"[LaundryApp] Insufficient cash (${instance.cashBalance:F0})");
				return;
			}
			if (val.currentLaunderTotal + (float)result > val.LaunderCapacity)
			{
				float value2 = val.LaunderCapacity - val.currentLaunderTotal;
				MelonLogger.Warning($"[LaundryApp] Exceeds capacity (Max: ${value2:F0})");
				return;
			}
			try
			{
				instance.ChangeCashBalance((float)(-result), true, true);
				val.StartLaunderingOperation((float)result, 0);
				_lastAddButtonClickTime = Time.time;
				if ((Object)(object)_ui.OperationsView?.StartOperationButtonText != (Object)null)
				{
					_ui.OperationsView.StartOperationButtonText.text = "...";
				}
				VariableDatabase instance2 = NetworkSingleton<VariableDatabase>.Instance;
				if ((Object)(object)instance2 != (Object)null)
				{
					float value3 = instance2.GetValue<float>("LaunderingOperationsStarted");
					instance2.SetVariableValue("LaunderingOperationsStarted", (value3 + 1f).ToString(), true);
				}
				_businessView.RefreshBusinessList();
			}
			catch (Exception value4)
			{
				MelonLogger.Error($"[LaundryApp] Start Operation Failed: {value4}");
			}
		}

		public void Open()
		{
			if (!_isOpen && !((Object)(object)Phone.ActiveApp != (Object)null))
			{
				_isOpen = true;
				_ui.AppContainer.SetActive(true);
				Phone.ActiveApp = _ui.AppContainer;
				PlayerSingleton<HomeScreen>.Instance.SetIsOpen(false);
				PlayerSingleton<AppsCanvas>.Instance.SetIsOpen(true);
				PlayerSingleton<Phone>.Instance.SetIsHorizontal(false);
				PlayerSingleton<Phone>.Instance.SetLookOffsetMultiplier(1f);
				_businessView.RefreshBusinessList();
				PopulateBusinessDropdown();
			}
		}

		public void Close()
		{
			if (_isOpen)
			{
				_isOpen = false;
				_ui.AppContainer.SetActive(false);
				if ((Object)(object)Phone.ActiveApp == (Object)(object)_ui.AppContainer)
				{
					Phone.ActiveApp = null;
				}
				PlayerSingleton<HomeScreen>.Instance.SetIsOpen(true);
				PlayerSingleton<Phone>.Instance.SetIsHorizontal(false);
				PlayerSingleton<Phone>.Instance.SetLookOffsetMultiplier(1f);
			}
		}

		private void OnExitAction(ExitAction exit)
		{
			if (exit != null && !exit.Used && _isOpen && PlayerSingleton<Phone>.InstanceExists && PlayerSingleton<Phone>.Instance.IsOpen)
			{
				exit.Used = true;
				Close();
			}
		}

		public void Update()
		{
			if (!_isOpen)
			{
				return;
			}
			if (PlayerSingleton<Phone>.Instance.IsOpen && IsHoveringHomeButton() && GameInput.GetButtonDown((ButtonCode)0))
			{
				Close();
			}
			if (Time.time - _lastRefreshTime >= 0.1f)
			{
				_lastRefreshTime = Time.time;
				_businessView.RefreshBusinessList();
				if ((Object)(object)_ui.OperationsView?.BusinessDropdown != (Object)null)
				{
					UpdateCapacityDisplay(_ui.OperationsView.BusinessDropdown.value);
				}
			}
			if ((Object)(object)_ui.OperationsView?.StartOperationButtonText != (Object)null && _ui.OperationsView.StartOperationButtonText.text == "..." && Time.time - _lastAddButtonClickTime >= 2f)
			{
				_ui.OperationsView.StartOperationButtonText.text = "Add";
			}
		}

		private static bool IsHoveringHomeButton()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(Singleton<GameplayMenu>.Instance.OverlayCamera.ScreenPointToRay(Input.mousePosition), ref val, 2f, 1 << LayerMask.NameToLayer("Overlay")))
			{
				return ((Object)((Component)((RaycastHit)(ref val)).collider).gameObject).name == "Button";
			}
			return false;
		}
	}
	public static class Constants
	{
		public const float REFRESH_INTERVAL = 0.1f;

		public const int HEADER_FONT_SIZE = 48;

		public const int BUTTON_FONT_SIZE = 34;

		public const int MAX_BUTTON_FONT_SIZE = 28;

		public const int BUSINESS_NAME_FONT_SIZE = 44;

		public const int CAPACITY_FONT_SIZE = 36;

		public const int OPERATION_FONT_SIZE = 38;

		public const int MESSAGE_FONT_SIZE = 34;

		public const int DROPDOWN_FONT_SIZE = 26;

		public const int CAPTION_FONT_SIZE = 32;

		public const int INPUT_FONT_SIZE = 28;

		public const float BUSINESS_NAME_HEIGHT = 50f;

		public const float CAPACITY_HEIGHT = 40f;

		public const float OPERATION_HEIGHT = 50f;

		public const float BUSINESS_SPACING = 20f;

		public const float OPERATIONS_TOP_SPACING = 10f;

		public const float BUSINESS_INFO_PADDING = 8f;

		public const float CIRCLE_SIZE = 40f;

		public const float CIRCLE_LEFT_OFFSET = 100f;

		public const int CIRCLE_TEXTURE_SIZE = 64;

		public const float CIRCLE_TEXTURE_RADIUS = 30f;

		public static readonly Color32 BACKGROUND_COLOR = new Color32((byte)20, (byte)20, (byte)20, byte.MaxValue);

		public static readonly Color32 BUSINESS_BACKGROUND_COLOR = new Color32((byte)40, (byte)40, (byte)40, byte.MaxValue);

		public static readonly Color32 CIRCLE_BACKGROUND_COLOR = new Color32((byte)10, (byte)10, (byte)10, byte.MaxValue);

		public static readonly Color32 CIRCLE_FILL_COLOR = new Color32(byte.MaxValue, (byte)184, (byte)93, byte.MaxValue);

		public static readonly Color32 BUTTON_BACKGROUND_COLOR = new Color32(byte.MaxValue, (byte)184, (byte)93, byte.MaxValue);

		public static readonly Color32 MAX_BUTTON_BACKGROUND_COLOR = new Color32((byte)33, (byte)33, (byte)33, byte.MaxValue);

		public static readonly Color32 BUTTON_DISABLED_COLOR = new Color32(byte.MaxValue, (byte)103, (byte)93, byte.MaxValue);

		public static readonly Color32 BUTTON_TEXT_COLOR = new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue);

		public static readonly Color32 WHITE_TEXT_COLOR = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);

		public static readonly Color32 PLACEHOLDER_TEXT_COLOR = new Color32((byte)60, (byte)60, (byte)60, byte.MaxValue);

		public static readonly Color32 INPUT_BACKGROUND_COLOR = new Color32((byte)43, (byte)43, (byte)43, byte.MaxValue);

		public const string COLOR_LIGHT_GREEN = "#5EFF5E";

		public const string COLOR_LIGHT_ORANGE = "#FFB85D";

		public const string APP_NAME = "Laundry";

		public const string APP_TITLE = "Laundry Operations";

		public const string ICON_FILENAME = "LaundryApp_icon.png";

		public const string NO_BUSINESSES_MESSAGE = "No businesses available";

		public const string NO_OPERATIONS_MESSAGE = "No ongoing operations";

		public const int MIN_LAUNDER_AMOUNT = 10;

		public const string INPUT_PLACEHOLDER_TEXT = "Enter amount...";

		public const string ICON_OBJECT_NAME = "LaundryAppIcon";

		public const string CONTAINER_OBJECT_NAME = "LaundryApp";

		public const string DEALER_APP_NAME = "DealerManagement";

		public const string DELIVERY_APP_NAME = "Delivery";

		public const string PRODUCT_MANAGER_APP_NAME = "ProductManager";

		public const string COUNTEROFFER_APP_NAME = "Counteroffer";
	}
	public class UI
	{
		private GameObject _appContainer;

		private Text _headerText;

		private GameObject _businessListContainer;

		private Sprite _circleSprite;

		private GameObject _operationsFormContainer;

		public GameObject AppContainer => _appContainer;

		public Text HeaderText => _headerText;

		public GameObject BusinessListContainer => _businessListContainer;

		public Sprite CircleSprite => _circleSprite;

		public OperationsView OperationsView { get; private set; }

		public void Initialize()
		{
			CreateCircleSprite();
			CreateAppIcon();
			CreateAppUI();
		}

		private void CreateCircleSprite()
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(64, 64);
			Color[] array = (Color[])(object)new Color[4096];
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(32f, 32f);
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					float num = Vector2.Distance(new Vector2((float)j, (float)i), val2);
					array[i * 64 + j] = ((num <= 30f) ? Color.white : Color.clear);
				}
			}
			val.SetPixels(Il2CppStructArray<Color>.op_Implicit(array));
			val.Apply();
			_circleSprite = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f));
		}

		private void CreateAppIcon()
		{
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			HomeScreen instance = PlayerSingleton<HomeScreen>.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				MelonLogger.Error("[LaundryApp] HomeScreen not found");
				return;
			}
			RectTransform appIconContainer = instance.appIconContainer;
			GameObject appIconPrefab = instance.appIconPrefab;
			if ((Object)(object)appIconContainer == (Object)null || (Object)(object)appIconPrefab == (Object)null)
			{
				MelonLogger.Error("[LaundryApp] Icon container or prefab is null");
				return;
			}
			GameObject obj = Object.Instantiate<GameObject>(appIconPrefab, ((Component)appIconContainer).transform);
			((Object)obj).name = "LaundryAppIcon";
			Transform val = obj.transform.Find("Label");
			if ((Object)(object)val != (Object)null)
			{
				Text component = ((Component)val).GetComponent<Text>();
				if ((Object)(object)component != (Object)null)
				{
					component.text = "Laundry";
				}
			}
			Transform val2 = obj.transform.Find("Mask/Image");
			if ((Object)(object)val2 != (Object)null)
			{
				Image component2 = ((Component)val2).GetComponent<Image>();
				if ((Object)(object)component2 != (Object)null)
				{
					Sprite val3 = LoadIconSprite();
					if ((Object)(object)val3 != (Object)null)
					{
						component2.sprite = val3;
					}
					else
					{
						((Graphic)component2).color = Color32.op_Implicit(new Color32((byte)45, (byte)45, (byte)45, byte.MaxValue));
					}
				}
			}
			Transform val4 = obj.transform.Find("Notifications");
			if ((Object)(object)val4 != (Object)null)
			{
				((Component)val4).gameObject.SetActive(false);
			}
			MelonLogger.Msg("[LaundryApp] App icon created");
		}

		public void RegisterIconClickHandler(Action onClickHandler)
		{
			if (onClickHandler == null)
			{
				MelonLogger.Error("[LaundryApp] Icon click handler is null");
				return;
			}
			HomeScreen instance = PlayerSingleton<HomeScreen>.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				MelonLogger.Error("[LaundryApp] HomeScreen instance is null");
				return;
			}
			Transform val = ((Component)instance.appIconContainer).transform.Find("LaundryAppIcon");
			if ((Object)(object)val == (Object)null)
			{
				MelonLogger.Error("[LaundryApp] Icon transform not found");
				return;
			}
			Button component = ((Component)val).GetComponent<Button>();
			if ((Object)(object)component != (Object)null)
			{
				((UnityEventBase)component.onClick).RemoveAllListeners();
				((UnityEvent)component.onClick).AddListener(UnityAction.op_Implicit((Action)onClickHandler.Invoke));
			}
		}

		private void CreateAppUI()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			AppsCanvas instance = PlayerSingleton<AppsCanvas>.Instance;
			if (!((Object)(object)instance == (Object)null))
			{
				_appContainer = new GameObject("LaundryApp");
				_appContainer.transform.SetParent(((Component)instance.canvas).transform, false);
				Transform val = ((Component)instance.canvas).transform.Find("DealerManagement");
				if ((Object)(object)val != (Object)null)
				{
					RectTransform component = ((Component)val).GetComponent<RectTransform>();
					RectTransform obj = _appContainer.AddComponent<RectTransform>();
					obj.anchorMin = component.anchorMin;
					obj.anchorMax = component.anchorMax;
					obj.anchoredPosition = component.anchoredPosition;
					obj.sizeDelta = component.sizeDelta;
					obj.pivot = component.pivot;
					((Transform)obj).localScale = ((Transform)component).localScale;
					((Transform)obj).localRotation = ((Transform)component).localRotation;
				}
				else
				{
					RectTransform obj2 = _appContainer.AddComponent<RectTransform>();
					obj2.anchorMin = Vector2.zero;
					obj2.anchorMax = Vector2.one;
					obj2.offsetMin = Vector2.zero;
					obj2.offsetMax = Vector2.zero;
					MelonLogger.Warning("[LaundryApp] DealerManagement not found, using fallback RectTransform");
				}
				CreateBackground();
				CreateHeader();
				CreateOperationsFormContainer();
				CreateBusinessListContainer();
				_appContainer.SetActive(false);
				MelonLogger.Msg("[LaundryApp] App UI created");
			}
		}

		private void CreateBackground()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Background");
			val.transform.SetParent(_appContainer.transform, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchorMin = Vector2.zero;
			obj.anchorMax = Vector2.one;
			obj.offsetMin = Vector2.zero;
			obj.offsetMax = Vector2.zero;
			((Graphic)val.AddComponent<Image>()).color = Color32.op_Implicit(Constants.BACKGROUND_COLOR);
		}

		private void CreateHeader()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Header");
			val.transform.SetParent(_appContainer.transform, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0.05f, 0.85f);
			obj.anchorMax = new Vector2(0.95f, 0.95f);
			obj.offsetMin = Vector2.zero;
			obj.offsetMax = Vector2.zero;
			_headerText = val.AddComponent<Text>();
			_headerText.fontSize = 48;
			_headerText.alignment = (TextAnchor)1;
			((Graphic)_headerText).color = Color.white;
			_headerText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			_headerText.fontStyle = (FontStyle)1;
			_headerText.text = "Laundry Operations";
		}

		private void CreateOperationsFormContainer()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			_operationsFormContainer = new GameObject("OperationsForm");
			_operationsFormContainer.transform.SetParent(_appContainer.transform, false);
			RectTransform obj = _operationsFormContainer.AddComponent<RectTransform>();
			float num = 0.098148145f;
			obj.anchorMin = new Vector2(0.08f, 0.8185f);
			obj.anchorMax = new Vector2(0.92f, 0.8185f + num);
			obj.offsetMin = new Vector2(-11f, 0f);
			obj.offsetMax = new Vector2(-6f, 0f);
			OperationsView = new OperationsView(_operationsFormContainer);
		}

		private void CreateBusinessListContainer()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("BusinessListContainer");
			val.transform.SetParent(_appContainer.transform, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0.08f, 0.08f);
			obj.anchorMax = new Vector2(0.92f, 0.817f);
			obj.offsetMin = Vector2.zero;
			obj.offsetMax = Vector2.zero;
			_businessListContainer = val;
		}

		private static Sprite LoadIconSprite()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "LaundryApp", "LaundryApp_icon.png");
				if (!File.Exists(text))
				{
					MelonLogger.Warning("[LaundryApp] Icon not found at: " + text);
					return null;
				}
				byte[] array = File.ReadAllBytes(text);
				Texture2D val = new Texture2D(2, 2);
				ImageConversion.LoadImage(val, Il2CppStructArray<byte>.op_Implicit(array));
				if (((Texture)val).width == 2 && ((Texture)val).height == 2)
				{
					MelonLogger.Error("[LaundryApp] Failed to load image data into texture");
					return null;
				}
				Sprite result = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
				MelonLogger.Msg("[LaundryApp] Successfully loaded icon from " + text);
				return result;
			}
			catch (Exception ex)
			{
				MelonLogger.Error("[LaundryApp] Error loading icon: " + ex.Message);
				return null;
			}
		}
	}
	public class BusinessView
	{
		private readonly Text _headerText;

		private readonly GameObject _businessListContainer;

		private readonly Sprite _circleSprite;

		public BusinessView(Text headerText, GameObject businessListContainer, Sprite circleSprite)
		{
			_headerText = headerText ?? throw new ArgumentNullException("headerText");
			_businessListContainer = businessListContainer ?? throw new ArgumentNullException("businessListContainer");
			_circleSprite = circleSprite ?? throw new ArgumentNullException("circleSprite");
		}

		public bool RefreshBusinessList()
		{
			try
			{
				List<Business> ownedBusinesses = Business.OwnedBusinesses;
				ClearBusinessList();
				if (ownedBusinesses == null || ownedBusinesses.Count == 0)
				{
					DisplayNoBusinessesMessage();
					return false;
				}
				_headerText.text = "Laundry Operations";
				RenderBusinessList(ownedBusinesses);
				return true;
			}
			catch (Exception ex)
			{
				DisplayError(ex.Message);
				MelonLogger.Error("[LaundryApp] Error: " + ex.Message);
				return false;
			}
		}

		private void ClearBusinessList()
		{
			for (int num = _businessListContainer.transform.childCount - 1; num >= 0; num--)
			{
				Object.Destroy((Object)(object)((Component)_businessListContainer.transform.GetChild(num)).gameObject);
			}
		}

		private void DisplayNoBusinessesMessage()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			_headerText.text = "Laundry Operations";
			GameObject val = new GameObject("NoBusinesses");
			val.transform.SetParent(_businessListContainer.transform, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0f, 0.5f);
			obj.anchorMax = new Vector2(1f, 0.5f);
			obj.sizeDelta = new Vector2(0f, 50f);
			obj.anchoredPosition = new Vector2(0f, 20f);
			Text obj2 = val.AddComponent<Text>();
			obj2.text = "No businesses available";
			obj2.fontSize = 34;
			obj2.alignment = (TextAnchor)4;
			((Graphic)obj2).color = Color.white;
			obj2.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
		}

		private void DisplayError(string errorMessage)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			_headerText.text = "Laundry Operations";
			ClearBusinessList();
			GameObject val = new GameObject("Error");
			val.transform.SetParent(_businessListContainer.transform, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0f, 0.5f);
			obj.anchorMax = new Vector2(1f, 0.5f);
			obj.sizeDelta = new Vector2(0f, 50f);
			obj.anchoredPosition = new Vector2(0f, 20f);
			Text obj2 = val.AddComponent<Text>();
			obj2.text = "Error: " + errorMessage;
			obj2.fontSize = 34;
			obj2.alignment = (TextAnchor)4;
			((Graphic)obj2).color = Color.red;
			obj2.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
		}

		private void RenderBusinessList(List<Business> ownedBusinesses)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			float yOffset = 20f;
			for (int i = 0; i < ownedBusinesses.Count; i++)
			{
				Business val = ownedBusinesses[i];
				if (!((Object)(object)val == (Object)null))
				{
					GameObject val2 = CreateBusinessContainer(i, ref yOffset);
					float height = 0f;
					CreateBusinessInfo(val, val2, ref height);
					height += 10f;
					List<LaunderingOperation> launderingOperations = val.LaunderingOperations;
					CreateOperationsList(launderingOperations, val2, ref height);
					height += 20f;
					val2.GetComponent<RectTransform>().sizeDelta = new Vector2(0f, height);
					yOffset -= height;
				}
			}
		}

		private GameObject CreateBusinessContainer(int index, ref float yOffset)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			GameObject val = new GameObject($"Business_{index}");
			val.transform.SetParent(_businessListContainer.transform, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0f, 1f);
			obj.anchorMax = new Vector2(1f, 1f);
			obj.pivot = new Vector2(0.5f, 1f);
			obj.anchoredPosition = new Vector2(0f, yOffset);
			return val;
		}

		private void CreateBusinessInfo(Business business, GameObject parent, ref float height)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("BusinessInfo");
			val.transform.SetParent(parent.transform, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0f, 1f);
			obj.anchorMax = new Vector2(1f, 1f);
			obj.pivot = new Vector2(0.5f, 1f);
			obj.sizeDelta = new Vector2(0f, 106f);
			obj.anchoredPosition = new Vector2(0f, 0f - height);
			((Graphic)val.AddComponent<Image>()).color = Color32.op_Implicit(Constants.BUSINESS_BACKGROUND_COLOR);
			CreateBusinessName(((Property)business).PropertyName, val);
			CreateCapacityInfo(business, val);
			height += 106f;
		}

		private void CreateBusinessName(string propertyName, GameObject parent)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("BusinessName");
			val.transform.SetParent(parent.transform, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0f, 1f);
			obj.anchorMax = new Vector2(1f, 1f);
			obj.pivot = new Vector2(0.5f, 1f);
			obj.sizeDelta = new Vector2(0f, 50f);
			obj.anchoredPosition = new Vector2(0f, -8f);
			Text obj2 = val.AddComponent<Text>();
			obj2.text = propertyName;
			obj2.fontSize = 44;
			obj2.fontStyle = (FontStyle)1;
			obj2.alignment = (TextAnchor)4;
			((Graphic)obj2).color = Color.white;
			obj2.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
		}

		private void CreateCapacityInfo(Business business, GameObject parent)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Capacity");
			val.transform.SetParent(parent.transform, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0f, 1f);
			obj.anchorMax = new Vector2(1f, 1f);
			obj.pivot = new Vector2(0.5f, 1f);
			obj.sizeDelta = new Vector2(0f, 40f);
			obj.anchoredPosition = new Vector2(0f, -58f);
			Text obj2 = val.AddComponent<Text>();
			obj2.text = FormatCapacityString(business);
			obj2.fontSize = 36;
			obj2.alignment = (TextAnchor)4;
			((Graphic)obj2).color = Color.white;
			obj2.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			obj2.supportRichText = true;
		}

		private static string FormatCapacityString(Business business)
		{
			if (business.currentLaunderTotal >= business.LaunderCapacity)
			{
				string obj = $"<color={"#5EFF5E"}>${business.currentLaunderTotal:F0}</color>";
				string text = $"<color={"#5EFF5E"}>${business.LaunderCapacity:F0}</color>";
				string text2 = ((business.appliedLaunderLimit > 0f) ? $" (${business.appliedLaunderLimit:F0} left)" : "");
				return obj + " / " + text + text2;
			}
			if (business.currentLaunderTotal > 0f)
			{
				string obj2 = $"<color={"#FFB85D"}>${business.currentLaunderTotal:F0}</color>";
				string text3 = $"${business.LaunderCapacity:F0}";
				string text4 = ((business.appliedLaunderLimit > 0f) ? $" (<color={"#FFB85D"}>${business.appliedLaunderLimit:F0}</color> left)" : "");
				return obj2 + " / " + text3 + text4;
			}
			string obj3 = $"${business.currentLaunderTotal:F0}";
			string text5 = $"${business.LaunderCapacity:F0}";
			string text6 = ((business.appliedLaunderLimit > 0f) ? $" (<color={"#5EFF5E"}>${business.appliedLaunderLimit:F0}</color> left)" : "");
			return obj3 + " / " + text5 + text6;
		}

		private void CreateOperationsList(List<LaunderingOperation> operations, GameObject parent, ref float height)
		{
			bool flag = false;
			for (int i = 0; i < operations.Count; i++)
			{
				LaunderingOperation val = operations[i];
				if (val != null)
				{
					CreateOperationEntry(val, i, parent, height);
					height += 50f;
					flag = true;
				}
			}
			if (!flag)
			{
				CreatePlaceholderEntry(parent, height);
				height += 50f;
			}
		}

		private void CreatePlaceholderEntry(GameObject parent, float yOffset)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("PlaceholderOperation");
			val.transform.SetParent(parent.transform, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0f, 1f);
			obj.anchorMax = new Vector2(1f, 1f);
			obj.pivot = new Vector2(0.5f, 1f);
			obj.sizeDelta = new Vector2(0f, 50f);
			obj.anchoredPosition = new Vector2(0f, 0f - yOffset);
			Text obj2 = val.AddComponent<Text>();
			obj2.text = "No ongoing operations";
			obj2.fontSize = 38;
			obj2.alignment = (TextAnchor)4;
			((Graphic)obj2).color = Color32.op_Implicit(Constants.PLACEHOLDER_TEXT_COLOR);
			obj2.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
		}

		private void CreateOperationEntry(LaunderingOperation op, int index, GameObject parent, float yOffset)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			int num = op.completionTime_Minutes - op.minutesSinceStarted;
			int value = num / 60;
			int value2 = num % 60;
			GameObject val = new GameObject($"Operation_{index}");
			val.transform.SetParent(parent.transform, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0f, 1f);
			obj.anchorMax = new Vector2(1f, 1f);
			obj.pivot = new Vector2(0.5f, 1f);
			obj.sizeDelta = new Vector2(0f, 50f);
			obj.anchoredPosition = new Vector2(0f, 0f - yOffset);
			CreateProgressCircle(op, val);
			Text obj2 = val.AddComponent<Text>();
			obj2.text = $"${op.amount:F0} - {value}h {value2}m";
			obj2.fontSize = 38;
			obj2.alignment = (TextAnchor)4;
			((Graphic)obj2).color = Color.white;
			obj2.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			obj2.supportRichText = true;
		}

		private void CreateProgressCircle(LaunderingOperation op, GameObject parent)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("ProgressCircle");
			val.transform.SetParent(parent.transform, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0f, 0.5f);
			obj.anchorMax = new Vector2(0f, 0.5f);
			obj.pivot = new Vector2(0.5f, 0.5f);
			obj.sizeDelta = new Vector2(40f, 40f);
			obj.anchoredPosition = new Vector2(100f, 0f);
			CreateBackgroundCircle(val);
			CreateForegroundCircle(op, val);
		}

		private void CreateBackgroundCircle(GameObject parent)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("BackgroundCircle");
			val.transform.SetParent(parent.transform, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchorMin = Vector2.zero;
			obj.anchorMax = Vector2.one;
			obj.offsetMin = Vector2.zero;
			obj.offsetMax = Vector2.zero;
			Image obj2 = val.AddComponent<Image>();
			obj2.sprite = _circleSprite;
			((Graphic)obj2).color = Color32.op_Implicit(Constants.CIRCLE_BACKGROUND_COLOR);
		}

		private void CreateForegroundCircle(LaunderingOperation op, GameObject parent)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("ForegroundCircle");
			val.transform.SetParent(parent.transform, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchorMin = Vector2.zero;
			obj.anchorMax = Vector2.one;
			obj.offsetMin = Vector2.zero;
			obj.offsetMax = Vector2.zero;
			Image obj2 = val.AddComponent<Image>();
			obj2.sprite = _circleSprite;
			obj2.type = (Type)3;
			obj2.fillMethod = (FillMethod)4;
			obj2.fillOrigin = 2;
			obj2.fillClockwise = true;
			obj2.fillAmount = (float)op.minutesSinceStarted / (float)op.completionTime_Minutes;
			((Graphic)obj2).color = Color32.op_Implicit(Constants.CIRCLE_FILL_COLOR);
		}
	}
	public class OperationsView
	{
		private readonly GameObject _container;

		private Dropdown _businessDropdown;

		private InputField _amountInput;

		private Button _maxButton;

		private Button _startOperationButton;

		private Text _startOperationButtonText;

		public Dropdown BusinessDropdown => _businessDropdown;

		public InputField AmountInput => _amountInput;

		public Button MaxButton => _maxButton;

		public Button StartOperationButton => _startOperationButton;

		public Text StartOperationButtonText => _startOperationButtonText;

		public OperationsView(GameObject container)
		{
			_container = container ?? throw new ArgumentNullException("container");
			CreateForm();
		}

		private void CreateForm()
		{
			//IL_0057: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ad: Expected O, but got Unknown
			//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0506: Unknown result type (might be due to invalid IL or missing references)
			//IL_0510: Unknown result type (might be due to invalid IL or missing references)
			//IL_0522: Unknown result type (might be due to invalid IL or missing references)
			//IL_0527: Unknown result type (might be due to invalid IL or missing references)
			//IL_0555: Unknown result type (might be due to invalid IL or missing references)
			//IL_055a: Unknown result type (might be due to invalid IL or missing references)
			//IL_056d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0574: Unknown result type (might be due to invalid IL or missing references)
			//IL_057f: Unknown result type (might be due to invalid IL or missing references)
			//IL_058a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0594: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05db: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f7: Expected O, but got Unknown
			//IL_0616: Unknown result type (might be due to invalid IL or missing references)
			//IL_062e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0645: Unknown result type (might be due to invalid IL or missing references)
			//IL_0650: Unknown result type (might be due to invalid IL or missing references)
			//IL_065a: Unknown result type (might be due to invalid IL or missing references)
			//IL_066c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0671: Unknown result type (might be due to invalid IL or missing references)
			//IL_069f: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a6: Expected O, but got Unknown
			//IL_06c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0740: Unknown result type (might be due to invalid IL or missing references)
			//IL_0745: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			//IL_0440: Unknown result type (might be due to invalid IL or missing references)
			//IL_044c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0462: Unknown result type (might be due to invalid IL or missing references)
			//IL_046e: Unknown result type (might be due to invalid IL or missing references)
			Font builtinResource = Resources.GetBuiltinResource<Font>("Arial.ttf");
			float num = 0.02f;
			float num2 = 0.01f;
			GameObject val = FindAndCloneComponent<Dropdown>("Delivery");
			if ((Object)(object)val != (Object)null)
			{
				((Object)val).name = "BusinessDropdown";
				val.transform.SetParent(_container.transform, false);
				val.transform.localScale = Vector3.one;
				RectTransform component = val.GetComponent<RectTransform>();
				component.anchorMin = new Vector2(num, 0.25f);
				component.anchorMax = new Vector2(num + 0.42f, 0.75f);
				component.offsetMin = Vector2.zero;
				component.offsetMax = Vector2.zero;
				_businessDropdown = val.GetComponent<Dropdown>();
				_businessDropdown.ClearOptions();
				if ((Object)(object)_businessDropdown.captionText != (Object)null)
				{
					((Graphic)_businessDropdown.captionText).color = Color.white;
					_businessDropdown.captionText.resizeTextForBestFit = false;
					_businessDropdown.captionText.fontSize = 30;
				}
				if ((Object)(object)_businessDropdown.itemText != (Object)null)
				{
					((Graphic)_businessDropdown.itemText).color = Color.white;
					_businessDropdown.itemText.fontSize = 28;
				}
				num += 0.42f + num2;
			}
			else
			{
				MelonLogger.Warning("[LaundryApp] Failed to find Dropdown component for cloning");
			}
			GameObject val2 = FindAndCloneComponent<InputField>("ProductManager");
			if ((Object)(object)val2 == (Object)null)
			{
				val2 = FindAndCloneComponent<InputField>("Counteroffer");
			}
			if ((Object)(object)val2 != (Object)null)
			{
				((Object)val2).name = "AmountInput";
				val2.transform.SetParent(_container.transform, false);
				val2.transform.localScale = Vector3.one;
				RectTransform component2 = val2.GetComponent<RectTransform>();
				component2.anchorMin = new Vector2(num, 0.25f);
				component2.anchorMax = new Vector2(num + 0.28f, 0.75f);
				component2.offsetMin = Vector2.zero;
				component2.offsetMax = new Vector2(-2f, 0f);
				Image component3 = val2.GetComponent<Image>();
				if ((Object)(object)component3 != (Object)null)
				{
					component3.sprite = null;
					((Graphic)component3).color = Color32.op_Implicit(Constants.INPUT_BACKGROUND_COLOR);
				}
				_amountInput = val2.GetComponent<InputField>();
				((UnityEventBase)_amountInput.onValueChanged).RemoveAllListeners();
				((UnityEventBase)_amountInput.onEndEdit).RemoveAllListeners();
				_amountInput.text = "100";
				_amountInput.contentType = (ContentType)2;
				_amountInput.lineType = (LineType)0;
				if ((Object)(object)_amountInput.textComponent != (Object)null)
				{
					((Graphic)_amountInput.textComponent).color = Color.white;
					_amountInput.textComponent.fontSize = 62;
					_amountInput.textComponent.alignment = (TextAnchor)3;
					RectTransform component4 = ((Component)_amountInput.textComponent).GetComponent<RectTransform>();
					if ((Object)(object)component4 != (Object)null)
					{
						component4.anchorMin = Vector2.zero;
						component4.anchorMax = Vector2.one;
						component4.offsetMin = new Vector2(-20f, 0f);
						component4.offsetMax = Vector2.zero;
					}
				}
				Graphic placeholder = _amountInput.placeholder;
				Text val3 = (Text)(object)((placeholder is Text) ? placeholder : null);
				if (val3 != null)
				{
					((Graphic)val3).color = new Color(0.6f, 0.6f, 0.6f);
					val3.fontSize = 62;
					val3.text = "Enter amount...";
					val3.alignment = (TextAnchor)3;
					RectTransform component5 = ((Component)val3).GetComponent<RectTransform>();
					if ((Object)(object)component5 != (Object)null)
					{
						component5.anchorMin = Vector2.zero;
						component5.anchorMax = Vector2.one;
						component5.offsetMin = new Vector2(-20f, 0f);
						component5.offsetMax = Vector2.zero;
					}
				}
				Text[] array = Il2CppArrayBase<Text>.op_Implicit(((Component)_amountInput).GetComponentsInChildren<Text>(true));
				foreach (Text val4 in array)
				{
					if (val4.text.Contains("$"))
					{
						val4.text = "$";
						((Graphic)val4).color = Color.white;
						val4.fontSize = 62;
						val4.alignment = (TextAnchor)3;
						RectTransform component6 = ((Component)val4).GetComponent<RectTransform>();
						if ((Object)(object)component6 != (Object)null)
						{
							component6.anchorMin = Vector2.zero;
							component6.anchorMax = Vector2.one;
							component6.offsetMin = new Vector2(-40f, 0f);
							component6.offsetMax = Vector2.zero;
						}
						break;
					}
				}
				num += 0.28f + num2;
			}
			else
			{
				MelonLogger.Warning("[LaundryApp] Failed to find InputField component for cloning");
			}
			GameObject val5 = new GameObject("MaxButton");
			val5.transform.SetParent(_container.transform, false);
			val5.transform.localScale = Vector3.one;
			RectTransform obj = val5.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(num, 0.25f);
			obj.anchorMax = new Vector2(num + 0.13f, 0.75f);
			obj.offsetMin = Vector2.zero;
			obj.offsetMax = Vector2.zero;
			Image obj2 = val5.AddComponent<Image>();
			((Graphic)obj2).color = Color32.op_Implicit(Constants.MAX_BUTTON_BACKGROUND_COLOR);
			((Graphic)obj2).raycastTarget = true;
			_maxButton = val5.AddComponent<Button>();
			((Selectable)_maxButton).transition = (Transition)0;
			GameObject val6 = new GameObject("Text");
			val6.transform.SetParent(val5.transform, false);
			RectTransform obj3 = val6.AddComponent<RectTransform>();
			obj3.anchorMin = Vector2.zero;
			obj3.anchorMax = Vector2.one;
			obj3.offsetMin = Vector2.zero;
			obj3.offsetMax = Vector2.zero;
			num += 0.13f + num2;
			Text obj4 = val6.AddComponent<Text>();
			obj4.text = "Max";
			obj4.font = builtinResource;
			obj4.fontStyle = (FontStyle)1;
			obj4.fontSize = 30;
			obj4.alignment = (TextAnchor)4;
			((Graphic)obj4).color = Color32.op_Implicit(Constants.WHITE_TEXT_COLOR);
			((Graphic)obj4).raycastTarget = false;
			GameObject val7 = new GameObject("LaunderButton");
			val7.transform.SetParent(_container.transform, false);
			val7.transform.localScale = Vector3.one;
			RectTransform obj5 = val7.AddComponent<RectTransform>();
			obj5.anchorMin = new Vector2(num, 0.25f);
			obj5.anchorMax = new Vector2(num + 0.13f, 0.75f);
			obj5.offsetMin = Vector2.zero;
			obj5.offsetMax = Vector2.zero;
			Image obj6 = val7.AddComponent<Image>();
			((Graphic)obj6).color = Color32.op_Implicit(Constants.BUTTON_BACKGROUND_COLOR);
			((Graphic)obj6).raycastTarget = true;
			_startOperationButton = val7.AddComponent<Button>();
			((Selectable)_startOperationButton).transition = (Transition)0;
			GameObject val8 = new GameObject("Text");
			val8.transform.SetParent(val7.transform, false);
			RectTransform obj7 = val8.AddComponent<RectTransform>();
			obj7.anchorMin = Vector2.zero;
			obj7.anchorMax = Vector2.one;
			obj7.offsetMin = Vector2.zero;
			obj7.offsetMax = Vector2.zero;
			_startOperationButtonText = val8.AddComponent<Text>();
			_startOperationButtonText.text = "Add";
			_startOperationButtonText.font = builtinResource;
			_startOperationButtonText.fontStyle = (FontStyle)1;
			_startOperationButtonText.fontSize = 30;
			_startOperationButtonText.alignment = (TextAnchor)4;
			((Graphic)_startOperationButtonText).color = Color32.op_Implicit(Constants.BUTTON_TEXT_COLOR);
			((Graphic)_startOperationButtonText).raycastTarget = false;
		}

		private GameObject FindAndCloneComponent<T>(string preferredAppName) where T : Component
		{
			AppsCanvas instance = PlayerSingleton<AppsCanvas>.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				return null;
			}
			Transform val = ((Component)instance.canvas).transform.Find(preferredAppName);
			if ((Object)(object)val != (Object)null)
			{
				T componentInChildren = ((Component)val).GetComponentInChildren<T>(true);
				if ((Object)(object)componentInChildren != (Object)null)
				{
					return Object.Instantiate<GameObject>(((Component)componentInChildren).gameObject);
				}
			}
			int childCount = ((Component)instance.canvas).transform.childCount;
			for (int i = 0; i < childCount; i++)
			{
				T componentInChildren2 = ((Component)((Component)instance.canvas).transform.GetChild(i)).GetComponentInChildren<T>(true);
				if ((Object)(object)componentInChildren2 != (Object)null)
				{
					return Object.Instantiate<GameObject>(((Component)componentInChildren2).gameObject);
				}
			}
			return null;
		}
	}
}