Decompiled source of RealEstateCruncherApp v1.0.8

RealEstateListingCruncherApp.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AssetBundleLoader;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using UniverseLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("RealEstateListingCruncherApp")]
[assembly: AssemblyConfiguration("IL2CPP")]
[assembly: AssemblyDescription("Adds a Real Estate sale application to in-game crunchers")]
[assembly: AssemblyFileVersion("1.0.5.0")]
[assembly: AssemblyInformationalVersion("1.0.5+437f193d7bdeb9a1af17f881c3503b14663800ac")]
[assembly: AssemblyProduct("RealEstateListingCruncherApp")]
[assembly: AssemblyTitle("RealEstateListingCruncherApp")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.5.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 RealEstateListingCruncherApp
{
	public class RealEstateCruncherAppContent : CruncherAppContent
	{
		public class CruncherForSaleContent : MonoBehaviour
		{
			private TextMeshProUGUI salesDataText;

			private TextMeshProUGUI descriptionText;

			private TextMeshProUGUI purchaseText;

			private RawImage previewImage;

			private Button purchaseButton;

			private Interactable interactable;

			private void Awake()
			{
				salesDataText = ((Component)((Component)this).transform.Find("Sales Data Text")).GetComponent<TextMeshProUGUI>();
				descriptionText = ((Component)((Component)this).transform.Find("Description")).GetComponent<TextMeshProUGUI>();
				purchaseText = ((Component)((Component)this).transform.Find("PurchaseButton/Text")).GetComponent<TextMeshProUGUI>();
				previewImage = ((Component)((Component)this).transform.Find("Photo/RawImage")).GetComponent<RawImage>();
				purchaseButton = ((Component)((Component)this).transform.Find("PurchaseButton")).GetComponent<Button>();
			}

			private void Start()
			{
				if (interactable == null)
				{
					((Component)this).gameObject.SetActive(false);
				}
			}

			public void UpdateContent(Interactable interactable)
			{
				this.interactable = interactable;
				((UnityEventBase)purchaseButton.onClick).RemoveAllListeners();
				if (interactable == null || !Object.op_Implicit((Object)(object)interactable.forSale) || (Object)(object)((NewGameLocation)interactable.forSale).thisAsAddress == (Object)null)
				{
					((Component)this).gameObject.SetActive(false);
				}
				else
				{
					((Component)this).gameObject.SetActive(true);
				}
				((TMP_Text)salesDataText).text = Strings.GetTextForComponent("600d4a18-7306-4871-a68e-e7764ae62f81", (Object)(object)interactable, (Human)null, (Human)null, "\n", false, (Object)null, (LinkSetting)2, (List<DataKey>)null);
				((TMP_Text)descriptionText).text = Strings.GetTextForComponent("3651e904-22e5-4093-9660-e59140ea6176", (Object)(object)interactable, (Human)null, (Human)null, "\n", false, (Object)null, (LinkSetting)0, Toolbox.Instance.allDataKeys);
				((TMP_Text)purchaseText).text = Strings.Get("evidence.generic", "Purchase", (Casing)0, false, false, false, (Human)null) + " " + CityControls._instance.cityCurrency + ((NewGameLocation)interactable.forSale).GetPrice(false);
				previewImage.texture = (Texture)(object)((Evidence)((NewGameLocation)interactable.forSale).evidenceEntry).GetPhoto(Toolbox.Instance.allDataKeys);
				Il2CppExtensions.AddListener((UnityEvent)(object)purchaseButton.onClick, (Action)delegate
				{
					if (GameplayController._instance.money >= ((NewGameLocation)interactable.forSale).GetPrice(false))
					{
						GameplayController._instance.AddMoney(-((NewGameLocation)interactable.forSale).GetPrice(false), true, "Property purchase");
						PlayerApartmentController._instance.BuyNewResidence(interactable.forSale.residence, false);
						((Component)this).GetComponentInParent<RealEstateCruncherAppContent>().UpdateSearch();
					}
				});
				((Behaviour)purchaseButton).enabled = GameplayController._instance.money >= ((NewGameLocation)interactable.forSale).GetPrice(false);
			}
		}

		public ComputerOSMultiSelect list;

		public CruncherForSaleContent forSaleController;

		public static Dictionary<string, Interactable> optionTextToSaleNote = new Dictionary<string, Interactable>();

		private ChangePage changePageDelegate;

		public override void Setup(ComputerController cc)
		{
			((CruncherAppContent)this).controller = cc;
			DoSetup();
		}

		public override void OnSetup()
		{
			DoSetup();
		}

		private void DoSetup()
		{
			Il2CppExtensions.AddListener((UnityEvent)(object)((IEnumerable<Button>)((Component)this).GetComponentsInChildren<Button>()).Where((Button button) => ((Object)button).name == "Exit").FirstOrDefault().onClick, (Action)delegate
			{
				((CruncherAppContent)this).controller.OnAppExit();
			});
			list = ((Component)this).GetComponentInChildren<ComputerOSMultiSelect>();
			changePageDelegate = ChangePage.op_Implicit((Action)UpdateSearch);
			ComputerOSMultiSelect obj = list;
			obj.OnChangePage += changePageDelegate;
			forSaleController = ((Component)((Component)this).transform.Find("ApartmentSaleContent")).gameObject.AddComponent<CruncherForSaleContent>();
			UpdateSearch();
		}

		private void OnDestroy()
		{
			ComputerOSMultiSelect obj = list;
			obj.OnChangePage -= changePageDelegate;
		}

		public override void PrintButton()
		{
		}

		public void UpdateSearch()
		{
			//IL_003e: 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_0051: Expected O, but got Unknown
			List<OSMultiOption> val = new List<OSMultiOption>();
			optionTextToSaleNote.Clear();
			Enumerator<NewAddress> enumerator = GameplayController.Instance.forSale.GetEnumerator();
			while (enumerator.MoveNext())
			{
				NewAddress current = enumerator.Current;
				if (current.saleNote != null)
				{
					OSMultiOption val2 = new OSMultiOption
					{
						text = ((Object)current).name
					};
					optionTextToSaleNote[val2.text] = current.saleNote;
					val.Add(val2);
				}
			}
			list.UpdateElements(val);
			list.usePages = val.Count > list.maxPerPage;
			foreach (ComputerOSMultiSelectElement selectionElement in ((Component)this).GetComponentsInChildren<ComputerOSMultiSelectElement>(true))
			{
				Il2CppExtensions.AddListener((UnityEvent)(object)((ComputerOSUIComponent)selectionElement).button.onClick, (Action)delegate
				{
					forSaleController.UpdateContent(optionTextToSaleNote[((TMP_Text)selectionElement.elementText).text]);
				});
			}
		}
	}
	internal class RealEstateListingCruncherHooks
	{
		[HarmonyPatch(typeof(MainMenuController), "Start")]
		public class MainMenuController_Start
		{
			private static bool hasInit;

			public static void Prefix()
			{
				if (hasInit)
				{
					return;
				}
				hasInit = true;
				AssetBundle val = BundleLoader.LoadBundle(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "realestatelistingcruncherappbundle"), false, true);
				CruncherAppPreset val2 = val.LoadAsset<CruncherAppPreset>("ForSale");
				val2.appContent[0].AddComponent<RealEstateCruncherAppContent>();
				foreach (InteractablePreset item in ((IEnumerable<InteractablePreset>)Resources.FindObjectsOfTypeAll<InteractablePreset>()).Where((InteractablePreset preset) => ((Object)preset).name.Contains("Cruncher")))
				{
					item.additionalApps.Insert(item.additionalApps.Count - 2, val2);
				}
				RealEstateListingCruncherPlugin.Logger.LogInfo((object)"Loading custom asset bundle complete");
			}
		}
	}
	[BepInPlugin("RealEstateListingCruncherApp", "RealEstateListingCruncherApp", "1.0.5")]
	public class RealEstateListingCruncherPlugin : BasePlugin
	{
		public static ManualLogSource Logger;

		public override void Load()
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Expected O, but got Unknown
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val;
			if (!((BasePlugin)this).Config.Bind<bool>("General", "Enabled", true, (ConfigDescription)null).Value)
			{
				ManualLogSource log = ((BasePlugin)this).Log;
				val = new BepInExInfoLogInterpolatedStringHandler(20, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("RealEstateListingCruncherApp");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is disabled.");
				}
				log.LogInfo(val);
				return;
			}
			Logger = ((BasePlugin)this).Log;
			ManualLogSource log2 = ((BasePlugin)this).Log;
			val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("RealEstateListingCruncherApp");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			log2.LogInfo(val);
			Harmony val2 = new Harmony("RealEstateListingCruncherApp");
			val2.PatchAll();
			ManualLogSource log3 = ((BasePlugin)this).Log;
			val = new BepInExInfoLogInterpolatedStringHandler(19, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("RealEstateListingCruncherApp");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is patched!");
			}
			log3.LogInfo(val);
			ClassInjector.RegisterTypeInIl2Cpp<RealEstateCruncherAppContent>();
			ClassInjector.RegisterTypeInIl2Cpp<RealEstateCruncherAppContent.CruncherForSaleContent>();
			ManualLogSource log4 = ((BasePlugin)this).Log;
			val = new BepInExInfoLogInterpolatedStringHandler(31, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("RealEstateListingCruncherApp");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" has added custom types!");
			}
			log4.LogInfo(val);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "RealEstateListingCruncherApp";

		public const string PLUGIN_NAME = "RealEstateListingCruncherApp";

		public const string PLUGIN_VERSION = "1.0.5";
	}
}