using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("NoDeepWood")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+79816d06a614fea8a479a05b38642dfb74d7c5ec")]
[assembly: AssemblyProduct("NoDeepWood")]
[assembly: AssemblyTitle("NoDeepWood")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace NoDeepWood
{
[BepInPlugin("stonewards.nodeepwood", "NoDeepWood", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public const string PluginGuid = "stonewards.nodeepwood";
public const string PluginName = "NoDeepWood";
public const string PluginVersion = "1.0.0";
internal const string WoodItemId = "WOODENPLANK";
internal static ManualLogSource Log;
internal static readonly HashSet<ETerrainMaterialType> BlockedLayers = new HashSet<ETerrainMaterialType>();
internal static bool LoggedFirstBlock;
private ConfigEntry<string> _blockedLayers;
private void Awake()
{
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
_blockedLayers = ((BaseUnityPlugin)this).Config.Bind<string>("General", "BlockedLayers", "ROCK_3,ROCK_4", "Terrain layers that no longer spawn wood, comma separated. Layers from top to bottom: DIRT, ROCK_1, ROCK_2, ROCK_3, ROCK_4.");
_blockedLayers.SettingChanged += delegate
{
ReloadLayers();
};
ReloadLayers();
new Harmony("stonewards.nodeepwood").PatchAll(typeof(Plugin).Assembly);
Log.LogInfo((object)"NoDeepWood 1.0.0 loaded");
}
private void ReloadLayers()
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
BlockedLayers.Clear();
string[] array = _blockedLayers.Value.Split(',');
for (int i = 0; i < array.Length; i++)
{
string text = array[i].Trim();
if (text.Length != 0)
{
if (Enum.TryParse<ETerrainMaterialType>(text, ignoreCase: true, out ETerrainMaterialType result))
{
BlockedLayers.Add(result);
}
else
{
Log.LogWarning((object)("Unknown terrain layer in BlockedLayers: " + text));
}
}
}
Log.LogInfo((object)("No wood from: " + string.Join(", ", BlockedLayers)));
}
}
[HarmonyPatch(typeof(DigMatterProfileSO), "GetRandomResource")]
internal static class GetRandomResourcePatch
{
private static void Postfix(DigMatterProfileSO __instance, ref (ItemDataSO, int) __result)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
ItemDataSO item = __result.Item1;
if (!((Object)(object)item == (Object)null) && item.isScrapItem && !((Object)(object)item.itemProduced == (Object)null) && !(item.itemProduced.itemID != "WOODENPLANK") && Plugin.BlockedLayers.Contains(__instance.terrainType))
{
__result = (null, 0);
if (!Plugin.LoggedFirstBlock)
{
Plugin.LoggedFirstBlock = true;
Plugin.Log.LogInfo((object)$"Blocked wood spawn in {__instance.terrainType}; further blocks are not logged");
}
}
}
}
}