Decompiled source of half crafting cost v1.0.1

update1_0.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
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("update1,0")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("update1,0")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ed4df949-be5c-47bc-b314-0d4667b8b3bd")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace update1_0;

[BepInPlugin("com.mansvards.lessgrind", "Less Grind Mod", "1.0.1")]
public class LessGrindPlugin : 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)"Mans pirmais modis ir veiksmīgi iedarbināts!");
		Harmony val = new Harmony("com.mansvards.lessgrind");
		val.PatchAll();
	}
}
[HarmonyPatch(typeof(ObjectDB), "Awake")]
internal static class Patch_ObjectDB_Awake
{
	private static bool isCostReduced;

	private static void Postfix(ObjectDB __instance)
	{
		if (isCostReduced || (Object)(object)__instance == (Object)null || __instance.m_recipes == null)
		{
			return;
		}
		foreach (Recipe recipe in __instance.m_recipes)
		{
			if ((Object)(object)recipe == (Object)null || recipe.m_resources == null)
			{
				continue;
			}
			Requirement[] resources = recipe.m_resources;
			foreach (Requirement val in resources)
			{
				if (val != null)
				{
					if (val.m_amount > 1)
					{
						val.m_amount = (int)Math.Max(1.0, (double)val.m_amount * 0.5);
					}
					if (val.m_amountPerLevel > 1)
					{
						val.m_amountPerLevel = (int)Math.Max(1.0, (double)val.m_amountPerLevel * 0.5);
					}
				}
			}
		}
		isCostReduced = true;
		Debug.Log((object)"LessGrind: Стоимость крафта успешно уменьшена на 50%!");
	}
}
[HarmonyPatch(typeof(ZNetScene), "Awake")]
internal static class Patch_ZNetScene_Awake
{
	private static bool isPiecesReduced;

	private static void Postfix(ZNetScene __instance)
	{
		if (isPiecesReduced || (Object)(object)__instance == (Object)null || __instance.m_prefabs == null)
		{
			return;
		}
		foreach (GameObject prefab in __instance.m_prefabs)
		{
			if ((Object)(object)prefab == (Object)null)
			{
				continue;
			}
			Piece component = prefab.GetComponent<Piece>();
			if (!((Object)(object)component != (Object)null) || component.m_resources == null)
			{
				continue;
			}
			Requirement[] resources = component.m_resources;
			foreach (Requirement val in resources)
			{
				if (val != null && val.m_amount > 1)
				{
					val.m_amount = (int)Math.Max(1.0, (double)val.m_amount * 0.5);
				}
			}
		}
		isPiecesReduced = true;
		Debug.Log((object)"LessGrind: Стоимость построек успешно уменьшена на 50%!");
	}
}