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("NoCultivatorDust")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Azumatt")]
[assembly: AssemblyProduct("NoCultivatorDust")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")]
[assembly: AssemblyFileVersion("1.0.6")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.6.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 NoCultivatorDust
{
[HarmonyPatch(typeof(ZNetScene), "Awake")]
internal static class ZNetSceneAwakePatch
{
[HarmonyPriority(0)]
private static void Postfix(ZNetScene __instance)
{
PieceTable buildPieces = __instance.GetPrefab("Cultivator").GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces;
if ((Object)(object)buildPieces == (Object)null)
{
return;
}
Piece val = default(Piece);
foreach (GameObject piece in buildPieces.m_pieces)
{
GameObject prefab = ZNetScene.instance.GetPrefab(Utils.GetPrefabName(piece));
if ((Object)(object)prefab == (Object)null)
{
continue;
}
prefab.TryGetComponent<Piece>(ref val);
if (!((Object)(object)val == (Object)null))
{
val.m_placeEffect.m_effectPrefabs = val.m_placeEffect.m_effectPrefabs.Where((EffectData effect) => !((Object)effect.m_prefab).name.Contains("vfx")).ToArray();
NoCultivatorDustPlugin.NoCultivatorDustLogger.LogDebug((object)("Removed build dust from " + ((Object)piece.gameObject).name + " Current list of effect prefabs: " + string.Join("\n", val.m_placeEffect.m_effectPrefabs.Select((EffectData effect) => ((Object)effect.m_prefab).name))));
}
}
}
}
[HarmonyPatch(typeof(Player), "PlacePiece")]
internal static class PiecePlacePiecePatch
{
[HarmonyPriority(800)]
private static void Prefix(Player __instance, ref Piece piece)
{
string name = ((Object)((Component)piece).gameObject).name;
if (name.Contains("replant") || name.Contains("cultivate"))
{
NoCultivatorDustPlugin.NoCultivatorDustLogger.LogDebug((object)("Preventing cultivator 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();
NoCultivatorDustPlugin.NoCultivatorDustLogger.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))));
}
}
}
[BepInPlugin("Azumatt.NoCultivatorDust", "NoCultivatorDust", "1.0.6")]
public class NoCultivatorDustPlugin : BaseUnityPlugin
{
internal const string ModName = "NoCultivatorDust";
internal const string ModVersion = "1.0.6";
internal const string Author = "Azumatt";
private const string ModGUID = "Azumatt.NoCultivatorDust";
private readonly Harmony _harmony = new Harmony("Azumatt.NoCultivatorDust");
public static readonly ManualLogSource NoCultivatorDustLogger = Logger.CreateLogSource("NoCultivatorDust");
public void Awake()
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
_harmony.PatchAll(executingAssembly);
}
}
}