Decompiled source of LessGrindCombinedMod v1.0.0

half_craft_build_cost.dll

Decompiled 2 weeks ago
using System.Collections.Generic;
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("half_craft_build_cost")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("half_craft_build_cost")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("57154e6e-ba7a-43eb-8593-55e2a093a375")]
[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 LessGrindMod;

[BepInPlugin("com.lessgrind.combined", "LessGrindCombinedMod", "1.0.0")]
public class LessGrindCombinedPlugin : BaseUnityPlugin
{
	private void Awake()
	{
		Harmony.CreateAndPatchAll(typeof(LessGrindCombinedPlugin).Assembly, (string)null);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"LessGrind: ОБЪЕДИНЕННЫЙ МОД УСПЕШНО ЗАПУЩЕН!");
	}
}
[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
internal static class Patch_ObjectDB_CraftAndFood
{
	private static readonly Dictionary<string, int> OriginalAmounts = new Dictionary<string, int>();

	private static readonly Dictionary<string, int> OriginalAmountsPerLevel = new Dictionary<string, int>();

	private static void Postfix(ObjectDB __instance)
	{
		if ((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;
			}
			for (int i = 0; i < recipe.m_resources.Length; i++)
			{
				Requirement val = recipe.m_resources[i];
				if (val != null && !((Object)(object)val.m_resItem == (Object)null))
				{
					string key = $"{((Object)recipe).name}_{((Object)val.m_resItem).name}_{i}";
					if (!OriginalAmounts.ContainsKey(key))
					{
						OriginalAmounts[key] = val.m_amount;
						OriginalAmountsPerLevel[key] = val.m_amountPerLevel;
					}
					int num = OriginalAmounts[key];
					int num2 = OriginalAmountsPerLevel[key];
					if (num > 1)
					{
						val.m_amount = Mathf.Max(1, Mathf.FloorToInt((float)num * 0.5f));
					}
					if (num2 > 1)
					{
						val.m_amountPerLevel = Mathf.Max(1, Mathf.FloorToInt((float)num2 * 0.5f));
					}
				}
			}
		}
		Debug.Log((object)"LessGrind: Скидка 50% на КРАФТ жестко зафиксирована от оригинальных цен!");
	}
}
[HarmonyPatch(typeof(ZNetScene), "Awake")]
internal static class Patch_ZNetScene_Build
{
	private static readonly Dictionary<string, int> OriginalBuildAmounts = new Dictionary<string, int>();

	private static void Postfix(ZNetScene __instance)
	{
		if ((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;
			}
			for (int i = 0; i < component.m_resources.Length; i++)
			{
				Requirement val = component.m_resources[i];
				if (val != null && !((Object)(object)val.m_resItem == (Object)null))
				{
					string key = $"{((Object)prefab).name}_{((Object)val.m_resItem).name}_{i}";
					if (!OriginalBuildAmounts.ContainsKey(key))
					{
						OriginalBuildAmounts[key] = val.m_amount;
					}
					int num = OriginalBuildAmounts[key];
					if (num > 1)
					{
						val.m_amount = Mathf.Max(1, Mathf.FloorToInt((float)num * 0.5f));
					}
				}
			}
		}
		Debug.Log((object)"LessGrind: Скидка 50% на ПОСТРОЙКИ успешно зафиксирована!");
	}
}