Decompiled source of NoHoeDust v1.0.5

NoHoeDust.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("NoHoeDust")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Azumatt")]
[assembly: AssemblyProduct("NoHoeDust")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")]
[assembly: AssemblyFileVersion("1.0.5")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 NoHoeDust
{
	[BepInPlugin("Azumatt.NoHoeDust", "NoHoeDust", "1.0.5")]
	public class NoHoeDustPlugin : BaseUnityPlugin
	{
		internal const string ModName = "NoHoeDust";

		internal const string ModVersion = "1.0.5";

		internal const string Author = "Azumatt";

		private const string ModGUID = "Azumatt.NoHoeDust";

		private readonly Harmony _harmony = new Harmony("Azumatt.NoHoeDust");

		public static readonly ManualLogSource NoHoeDustLogger = Logger.CreateLogSource("NoHoeDust");

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

		private void OnDestroy()
		{
			((BaseUnityPlugin)this).Config.Save();
		}
	}
	[HarmonyPatch(typeof(TerrainModifier), "OnPlaced")]
	[HarmonyPriority(700)]
	internal static class TerrainModifierAwakePatch
	{
		private static void Prefix(TerrainModifier __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			__instance.m_onPlacedEffect = new EffectList();
		}

		private static void Postfix(TerrainModifier __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			__instance.m_onPlacedEffect = new EffectList();
		}
	}
	[HarmonyPatch(typeof(TerrainOp), "OnPlaced")]
	[HarmonyPriority(700)]
	internal static class TerrainOpAwakePatch
	{
		private static void Prefix(TerrainOp __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			__instance.m_onPlacedEffect = new EffectList();
		}

		private static void Postfix(TerrainOp __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			__instance.m_onPlacedEffect = new EffectList();
		}
	}
	[HarmonyPatch(typeof(ZNetScene), "Awake")]
	internal static class ZNetSceneAwakePatch
	{
		[HarmonyPriority(0)]
		private static void Postfix(ZNetScene __instance)
		{
			NoHoeDustPlugin.NoHoeDustLogger.LogDebug((object)"ZNetScene Awake Postfix, turning off build dust");
			foreach (GameObject item in __instance.m_prefabs.Where((GameObject instanceMPrefab) => Object.op_Implicit((Object)(object)instanceMPrefab.GetComponent<Piece>())))
			{
				if (((Object)item).name.Contains("road") || ((Object)item).name.Contains("raise") || ((Object)item).name.Contains("paved"))
				{
					Piece component = item.GetComponent<Piece>();
					component.m_placeEffect.m_effectPrefabs = component.m_placeEffect.m_effectPrefabs.Where((EffectData effect) => !((Object)effect.m_prefab).name.Contains("vfx")).ToArray();
					NoHoeDustPlugin.NoHoeDustLogger.LogDebug((object)("Removed build dust from " + ((Object)item).name + " Current list of effect prefabs: " + string.Join("\n", component.m_placeEffect.m_effectPrefabs.Select((EffectData effect) => ((Object)effect.m_prefab).name))));
				}
			}
		}
	}
	[HarmonyPatch(typeof(Player), "PlacePiece")]
	internal static class PiecePlacePiecePatch
	{
		[HarmonyPriority(700)]
		private static void Prefix(Player __instance, ref Piece piece)
		{
			string name = ((Object)((Component)piece).gameObject).name;
			if (name.Contains("road") || name.Contains("raise") || name.Contains("path_") || name.Contains("paved"))
			{
				NoHoeDustPlugin.NoHoeDustLogger.LogDebug((object)("Preventing hoe dust from spawning " + name));
				piece.m_placeEffect.m_effectPrefabs = piece.m_placeEffect.m_effectPrefabs.Where((EffectData effect) => !((Object)effect.m_prefab).name.Contains("vfx")).ToArray();
				NoHoeDustPlugin.NoHoeDustLogger.LogDebug((object)("Removed build dust from " + name + " Current list of effect prefabs: " + string.Join("\n", piece.m_placeEffect.m_effectPrefabs.Select((EffectData effect) => ((Object)effect.m_prefab).name))));
			}
		}
	}
}