Decompiled source of No Grass v0.1.5

Plugins/VentureValheim.NoGrass.dll

Decompiled 3 days 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 UnityEngine;
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.5")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.5.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.5")]
	public class NoGrassPlugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(GraphicsSettings), "Initialize")]
		public static class Patch_GraphicsSettings_Initialize
		{
			private static void Postfix(GraphicsSettings __instance)
			{
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				QualitySliderData val = __instance.m_qualitySliders.Where((QualitySliderData x) => (int)x.m_setting == 32).FirstOrDefault();
				if ((Object)(object)val.m_slider != (Object)null)
				{
					val.m_slider.minValue = 0f;
					val.m_slider.value = PlatformPrefs.GetInt("ClutterQuality", 0);
				}
			}
		}

		[HarmonyPatch(typeof(GraphicsSettings), "GetDisplayValue")]
		public static class Patch_GraphicsSettings_GetDisplayValue
		{
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Expected O, but got Unknown
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Expected O, but got Unknown
				return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[2]
				{
					new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Sub, (object)null, (string)null)
				}).ThrowIfInvalid("Could not patch GraphicsSettings.GetDisplayValue").RemoveInstructions(2)
					.InstructionEnumeration();
			}
		}

		private const string ModName = "NoGrass";

		private const string ModVersion = "0.1.5";

		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);
		}
	}
}