Decompiled source of half build cost v1.0.1

half_build_cost.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("half_build_cost")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("half_build_cost")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f5afba9a-d447-44d0-bf01-967c5610083e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace update1_0;

[BepInPlugin("com.mansvards.lessgrind", "Less Build Cost 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)"Būvniecības moduļa atvieglojumi tiek ielādēti...");
		Harmony val = new Harmony("com.mansvards.lessgrind");
		val.PatchAll();
	}
}
[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%!");
	}
}