Decompiled source of GoldenBricks v1.1.2

GoldenBricks-IL2CPP.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using GoldenBricks;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppScheduleOne.ItemFramework;
using Il2CppScheduleOne.Product;
using Il2CppSystem;
using MelonLoader;
using MelonLoader.Preferences;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(global::GoldenBricks.GoldenBricks), "GoldenBricks", "1.1", "k073l", null)]
[assembly: MelonColor(1, 255, 215, 0)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("GoldenBricks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+de5514e74169d300153b0e12b84cb4c6cebdbc77")]
[assembly: AssemblyProduct("GoldenBricks")]
[assembly: AssemblyTitle("GoldenBricks")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace GoldenBricks;

public static class BuildInfo
{
	public const string Name = "GoldenBricks";

	public const string Description = "Updates the value of bricks and jars to reflect their capacity";

	public const string Author = "k073l";

	public const string Company = null;

	public const string Version = "1.1";

	public const string DownloadLink = null;
}
public class GoldenBricks : MelonMod
{
	[HarmonyPatch(typeof(ProductItemInstance), "GetMonetaryValue")]
	public static class ProductItemInstance_GetMonetaryValue_Patch
	{
		public static bool Prefix(ProductItemInstance __instance, ref float __result)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((ItemInstance)__instance).definition == (Object)null)
			{
				__result = 0f;
				return false;
			}
			try
			{
				IntPtr pointer = ((Il2CppObjectBase)((ItemInstance)__instance).definition).Pointer;
				ProductDefinition val = new ProductDefinition(pointer);
				float num = val.MarketValue * (float)((ItemInstance)__instance).Quantity;
				double value = _entries[((QualityItemInstance)__instance).Quality].Value;
				__result = num * (float)__instance.Amount * (float)value;
				return false;
			}
			catch (Exception ex)
			{
				string fullName = ((Object)((ItemInstance)__instance).definition).GetIl2CppType().FullName;
				MelonLogger.Warning("[Prefix:GetMonetaryValue] Forced cast to ProductDefinition failed. Actual type: " + fullName + ". Exception: " + ex.Message);
				__result = 0f;
				return false;
			}
		}
	}

	private static MelonPreferences_Category _category;

	private static MelonPreferences_Entry<double>[] _entries;

	private static readonly double[] _mults = new double[5] { 0.4, 0.8, 1.0, 1.2, 1.5 };

	private static Instance MelonLogger { get; set; }

	public override void OnInitializeMelon()
	{
		MelonLogger = ((MelonBase)this).LoggerInstance;
		MelonLogger.Msg("GoldenBricks initialized");
		_category = MelonPreferences.CreateCategory("GoldenBricksQualityMultipliers");
		string[] names = Enum.GetNames(typeof(EQuality));
		_entries = new MelonPreferences_Entry<double>[names.Length];
		for (int i = 0; i < names.Length; i++)
		{
			double num = ((i < _mults.Length) ? _mults[i] : 1.0);
			_entries[i] = _category.CreateEntry<double>(names[i], num, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		}
	}
}