Decompiled source of No Grass v0.1.4

Plugins/VentureValheim.NoGrass.dll

Decompiled 7 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Valheim.SettingsGui;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("VentureValheim.NoGrass")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VentureValheim.NoGrass")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("51734AFC-6E30-4F21-9232-9B0190E81067")]
[assembly: AssemblyFileVersion("0.1.4")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.4.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace VentureValheim.NoGrass
{
	[BepInPlugin("com.orianaventure.mod.NoGrass", "NoGrass", "0.1.4")]
	public class NoGrassPlugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(GraphicsSettings), "Awake")]
		public static class Patch_GraphicsSettings_Awake
		{
			private static void Prefix(GraphicsSettings __instance)
			{
				__instance.m_vegetationSlider.minValue = 0f;
				__instance.m_vegetationSlider.value = PlatformPrefs.GetInt("ClutterQuality", 0);
			}
		}

		[HarmonyPatch(typeof(GraphicsSettings), "OnQualityChanged")]
		public static class Patch_GraphicsSettings_OnQualityChanged
		{
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				List<CodeInstruction> list = new List<CodeInstruction>(instructions);
				for (int i = 0; i < list.Count - 4; i++)
				{
					if (list[i].opcode == OpCodes.Ldfld && list[i].operand.ToString() == "UnityEngine.UI.Slider m_vegetationSlider" && list[i + 4].opcode == OpCodes.Sub)
					{
						list[i + 3].opcode = OpCodes.Nop;
						list[i + 4].opcode = OpCodes.Nop;
						break;
					}
				}
				return list.AsEnumerable();
			}
		}

		private const string ModName = "NoGrass";

		private const string ModVersion = "0.1.4";

		private const string Author = "com.orianaventure.mod";

		private const string ModGUID = "com.orianaventure.mod.NoGrass";

		private readonly Harmony HarmonyInstance = new Harmony("com.orianaventure.mod.NoGrass");

		public void Awake()
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			HarmonyInstance.PatchAll(executingAssembly);
		}
	}
}