Decompiled source of Lareins LessGreydwarfs v1.0.0

plugins\Lareins_LessGreydwarfs\Lareins_LessGreydwarfs.dll

Decompiled 2 hours ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Lareins_Core;
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("Lareins_LessGreydwarfs")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Lareins_LessGreydwarfs")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ad3b48a2-6ad9-4ded-bc3e-5830e16a38b7")]
[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 Lareins_LessGreydwarfs;

[BepInPlugin("com.lareins.lessgreydwarfs", "Lareins_LessGreydwarfs", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class LessGreydwarfsPlugin : BaseUnityPlugin
{
	public const string ModGUID = "com.lareins.lessgreydwarfs";

	public const string ModName = "Lareins_LessGreydwarfs";

	public const string ModVersion = "1.0.0";

	public static ConfigEntry<bool> ModAktif;

	public static ConfigEntry<int> AzaltmaYuzdesi;

	private void Awake()
	{
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		ModAktif = ((BaseUnityPlugin)this).Config.Bind<bool>("Genel", "ModAktif", true, "Boz cuce populasyonu azaltma sistemini acar/kapatir");
		AzaltmaYuzdesi = ((BaseUnityPlugin)this).Config.Bind<int>("Denge", "AzaltmaYuzdesi", 35, "Boz cuce dogum oranini yuzde kac azaltsin? (0 - 60)");
		CorePlugin.AyarEkle("Boz Cuce Kontrolu", "Mod Aktif", "Ormandaki boz cuce turlerinin dogum sikligini azaltir.", ModAktif);
		CorePlugin.AyarEkle("Boz Cuce Kontrolu", "Azaltma Orani (%)", "Boz cuce dogum azaltma yuzdesi (%0 - %60).", AzaltmaYuzdesi, 0, 60);
		new Harmony("com.lareins.lessgreydwarfs").PatchAll(typeof(LessGreydwarfsPlugin));
	}

	[HarmonyPatch(typeof(SpawnSystem), "Awake")]
	[HarmonyPostfix]
	private static void BozCuceAzalt(SpawnSystem __instance)
	{
		if (!ModAktif.Value || __instance.m_spawnLists == null)
		{
			return;
		}
		float num = (float)AzaltmaYuzdesi.Value / 100f;
		foreach (SpawnSystemList spawnList in __instance.m_spawnLists)
		{
			if (spawnList?.m_spawners == null)
			{
				continue;
			}
			foreach (SpawnData spawner in spawnList.m_spawners)
			{
				if ((Object)(object)spawner.m_prefab == (Object)null)
				{
					continue;
				}
				string name = ((Object)spawner.m_prefab).name;
				switch (name)
				{
				default:
					if (!(name == "Greyling"))
					{
						continue;
					}
					break;
				case "Greydwarf":
				case "Greydwarf_Elite":
				case "Greydwarf_Shaman":
					break;
				}
				spawner.m_maxSpawned = Mathf.Max(1, Mathf.RoundToInt((float)spawner.m_maxSpawned * (1f - num)));
				spawner.m_spawnChance *= 1f - num;
			}
		}
	}
}