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.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using MyDirtyHoe.ConsoleCommands;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("MyDirtyHoe")]
[assembly: AssemblyDescription("https://discord.gg/khjfYmQ4fX")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("MagicMike")]
[assembly: AssemblyProduct("MyDirtyHoe")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("1.2.4")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.4.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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;
}
}
}
public class KeyUtils
{
public static bool IgnoreKeyPresses(bool extra = false)
{
if (!extra)
{
if (!((Object)(object)ZNetScene.instance == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null) && !Minimap.IsOpen() && !Console.IsVisible() && !TextInput.IsVisible() && !ZNet.instance.InPasswordDialog())
{
Chat instance = Chat.instance;
if (instance == null || !instance.HasFocus())
{
return Menu.IsVisible();
}
}
return true;
}
if (!((Object)(object)ZNetScene.instance == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null) && !Minimap.IsOpen() && !Console.IsVisible() && !TextInput.IsVisible() && !ZNet.instance.InPasswordDialog())
{
Chat instance2 = Chat.instance;
if ((instance2 == null || !instance2.HasFocus()) && !StoreGui.IsVisible() && !InventoryGui.IsVisible() && !Menu.IsVisible())
{
TextViewer instance3 = TextViewer.instance;
if (instance3 == null)
{
return false;
}
return instance3.IsVisible();
}
}
return true;
}
public static bool CheckKeyDown(string value)
{
try
{
return Input.GetKeyDown(value.ToLower());
}
catch
{
return false;
}
}
public static bool CheckKeyHeld(string value, bool req = true)
{
try
{
return Input.GetKey(value.ToLower());
}
catch
{
return !req;
}
}
}
namespace MyDirtyHoe
{
public class Heightmap_Patches
{
[HarmonyPatch(typeof(TerrainComp))]
private static class Heightmap_Patch
{
[HarmonyTranspiler]
[HarmonyPatch("LevelTerrain")]
public static IEnumerable<CodeInstruction> TerrainCompLevelTerrainTranspiler(IEnumerable<CodeInstruction> instructions)
{
foreach (CodeInstruction instruction in instructions)
{
if (CodeInstructionExtensions.Is(instruction, OpCodes.Ldc_R4, (object)(-8f)))
{
yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Min", (Type[])null, (Type[])null));
}
else if (CodeInstructionExtensions.Is(instruction, OpCodes.Ldc_R4, (object)8f))
{
yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Max", (Type[])null, (Type[])null));
}
else
{
yield return instruction;
}
}
}
[HarmonyTranspiler]
[HarmonyPatch("RaiseTerrain")]
public static IEnumerable<CodeInstruction> TerrainCompRaiseTerrainTranspiler(IEnumerable<CodeInstruction> instructions)
{
foreach (CodeInstruction instruction in instructions)
{
if (CodeInstructionExtensions.Is(instruction, OpCodes.Ldc_R4, (object)(-8f)))
{
yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Min", (Type[])null, (Type[])null));
}
else if (CodeInstructionExtensions.Is(instruction, OpCodes.Ldc_R4, (object)8f))
{
yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Max", (Type[])null, (Type[])null));
}
else
{
yield return instruction;
}
}
}
[HarmonyTranspiler]
[HarmonyPatch("ApplyToHeightmap")]
public static IEnumerable<CodeInstruction> TerrainCompApplyToHeightmapTranspiler(IEnumerable<CodeInstruction> instructions)
{
int i = 0;
foreach (CodeInstruction instruction in instructions)
{
if (CodeInstructionExtensions.Is(instruction, OpCodes.Ldc_R4, (object)(-8f)))
{
yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Min", (Type[])null, (Type[])null));
}
else if (CodeInstructionExtensions.Is(instruction, OpCodes.Ldc_R4, (object)8f))
{
if (i == 0)
{
yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "MinAbs", (Type[])null, (Type[])null));
}
else
{
yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Max", (Type[])null, (Type[])null));
}
i++;
}
else
{
yield return instruction;
}
}
}
}
}
[BepInPlugin("MagicMike.MyDirtyHoe", "MyDirtyHoe", "1.2.4")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
internal class MyDirtyHoeMod : BaseUnityPlugin
{
internal enum Toggle
{
On = 1,
Off = 0
}
internal enum Shape
{
Circle,
Square
}
internal const string PluginName = "MyDirtyHoe";
internal const string PluginVersion = "1.2.4";
internal const string Author = "MagicMike";
private const string PluginGUID = "MagicMike.MyDirtyHoe";
public const string modLink = "https://discord.gg/khjfYmQ4fX";
public static MyDirtyHoeMod context;
private static readonly MyDirtyHoeMod _instance = new MyDirtyHoeMod();
public AssetBundle magicBundle;
private GameObject effectNoise;
private GameObject _gameObject;
private CustomItem _customItem;
private CustomPiece _customPiece;
private CustomPieceTable _customPieceTable;
private CustomStatusEffect _hoeStamina;
public EffectList buildHoe;
public EffectList buildCultivater;
public EffectList buildStone;
public static ConfigEntry<Toggle> modEnabled;
public static ConfigEntry<Toggle> enableSE;
public static ConfigEntry<Toggle> enableHeightmap;
public static ConfigEntry<Toggle> enableCommands;
public static ConfigEntry<Shape> toolShape;
public static ConfigEntry<bool> useScrollWheel;
public static ConfigEntry<string> scrollModKey;
public static ConfigEntry<string> increaseHotKey;
public static ConfigEntry<string> decreaseHotKey;
public static ConfigEntry<float> scrollWheelScale;
public static ConfigEntry<float> hotkeyScale;
public static ConfigEntry<float> hotKeyRadius;
public static ConfigEntry<float> toolRadius;
public static ConfigEntry<KeyCode> hotKey;
public static ConfigEntry<KeyCode> modKey;
public static ConfigEntry<float> MaxHeight;
public static ConfigEntry<float> MinHeight;
public static ConfigEntry<float> forestRadius;
public static ConfigEntry<float> pieceRadius;
public static ConfigEntry<bool> durabilityDrain;
public static ConfigEntry<bool> staminaUsage;
public static ConfigEntry<bool> resourceCosts;
public static ConfigEntry<bool> needWorkbench;
public static float lastOriginalRadius;
public static float lastModdedRadius;
public static float lastTotalDelta;
private Harmony harmony = new Harmony("MagicMike.MyDirtyHoe");
public static MyDirtyHoeMod Instance => _instance;
private MyDirtyHoeMod()
{
}//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
public static KeyCode GetHotKey()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
return hotKey.Value;
}
public static float GetHotKeyRadius()
{
return hotKeyRadius.Value;
}
public static KeyCode GetToolModKey()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
return modKey.Value;
}
public static float GetToolRadius()
{
return toolRadius.Value;
}
public static float Min()
{
return MinHeight.Value;
}
public static float MinAbs()
{
return Math.Abs(MinHeight.Value);
}
public static float Max()
{
return MaxHeight.Value;
}
private void Awake()
{
InitConfig();
if (modEnabled.Value == Toggle.On)
{
LoadAssets();
if (enableSE.Value == Toggle.On)
{
LoadStatusEffect();
}
if (enableCommands.Value == Toggle.On)
{
AddCommands();
}
LoadTable();
PrefabManager.OnVanillaPrefabsAvailable += LoadSFX;
PrefabManager.OnVanillaPrefabsAvailable += LoadPrefabs;
((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
((BaseUnityPlugin)this).Config.SettingChanged += delegate(object sender, SettingChangedEventArgs args)
{
SettingChanged(((BaseUnityPlugin)this).Config, args);
};
harmony = Harmony.CreateAndPatchAll(typeof(TerrainReset_Patches).Assembly, "MagicMike.MyDirtyHoe");
if (enableHeightmap.Value == Toggle.On)
{
harmony = Harmony.CreateAndPatchAll(typeof(Heightmap_Patches).Assembly, "MagicMike.MyDirtyHoe");
}
}
}
private void OnDestroy()
{
((BaseUnityPlugin)this).Config.Save();
}
private void Update()
{
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)Player.m_localPlayer) || !((Character)Player.m_localPlayer).InPlaceMode() || Hud.IsPieceSelectionVisible())
{
if (lastOriginalRadius != 0f)
{
lastOriginalRadius = 0f;
lastModdedRadius = 0f;
lastTotalDelta = 0f;
SetRadius(0f);
}
return;
}
if (useScrollWheel.Value && KeyUtils.CheckKeyHeld(scrollModKey.Value, req: false) && Input.mouseScrollDelta.y != 0f)
{
SetRadius(Input.mouseScrollDelta.y * scrollWheelScale.Value);
}
else if (KeyUtils.CheckKeyDown(increaseHotKey.Value))
{
SetRadius(hotkeyScale.Value);
}
else if (KeyUtils.CheckKeyDown(decreaseHotKey.Value))
{
SetRadius(0f - hotkeyScale.Value);
}
if (modEnabled.Value == Toggle.On && !TerrainReset_Patches.IgnoreKeyPresses() && TerrainReset_Patches.CheckKeyDown(GetHotKey()))
{
int num = TerrainReset_Patches.ResetTerrain(((Component)Player.m_localPlayer).transform.position, GetHotKeyRadius());
((Character)Player.m_localPlayer).Message((MessageType)2, $"{num} edits reset.", 0, (Sprite)null);
}
}
private void InitConfig()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Expected O, but got Unknown
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Expected O, but got Unknown
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Expected O, but got Unknown
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Expected O, but got Unknown
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Expected O, but got Unknown
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Expected O, but got Unknown
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Expected O, but got Unknown
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Expected O, but got Unknown
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Expected O, but got Unknown
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Expected O, but got Unknown
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Expected O, but got Unknown
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Expected O, but got Unknown
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Expected O, but got Unknown
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_021b: Expected O, but got Unknown
//IL_021b: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: Expected O, but got Unknown
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_025f: Expected O, but got Unknown
//IL_025f: Unknown result type (might be due to invalid IL or missing references)
//IL_0269: Expected O, but got Unknown
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: Unknown result type (might be due to invalid IL or missing references)
//IL_02a3: Expected O, but got Unknown
//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
//IL_02ad: Expected O, but got Unknown
//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
//IL_02da: Unknown result type (might be due to invalid IL or missing references)
//IL_02e7: Expected O, but got Unknown
//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
//IL_02f1: Expected O, but got Unknown
//IL_0327: Unknown result type (might be due to invalid IL or missing references)
//IL_032c: Unknown result type (might be due to invalid IL or missing references)
//IL_0339: Expected O, but got Unknown
//IL_0339: Unknown result type (might be due to invalid IL or missing references)
//IL_0343: Expected O, but got Unknown
//IL_0379: Unknown result type (might be due to invalid IL or missing references)
//IL_037e: Unknown result type (might be due to invalid IL or missing references)
//IL_038b: Expected O, but got Unknown
//IL_038b: Unknown result type (might be due to invalid IL or missing references)
//IL_0395: Expected O, but got Unknown
//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
//IL_03be: Unknown result type (might be due to invalid IL or missing references)
//IL_03cb: Expected O, but got Unknown
//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
//IL_03d5: Expected O, but got Unknown
//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0402: Unknown result type (might be due to invalid IL or missing references)
//IL_040f: Expected O, but got Unknown
//IL_040f: Unknown result type (might be due to invalid IL or missing references)
//IL_0419: Expected O, but got Unknown
//IL_0441: Unknown result type (might be due to invalid IL or missing references)
//IL_0446: Unknown result type (might be due to invalid IL or missing references)
//IL_044d: Unknown result type (might be due to invalid IL or missing references)
//IL_045a: Expected O, but got Unknown
//IL_045a: Unknown result type (might be due to invalid IL or missing references)
//IL_0464: Expected O, but got Unknown
//IL_048c: Unknown result type (might be due to invalid IL or missing references)
//IL_0491: Unknown result type (might be due to invalid IL or missing references)
//IL_0498: Unknown result type (might be due to invalid IL or missing references)
//IL_04a5: Expected O, but got Unknown
//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
//IL_04af: Expected O, but got Unknown
//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
//IL_04ea: Unknown result type (might be due to invalid IL or missing references)
//IL_04f1: Unknown result type (might be due to invalid IL or missing references)
//IL_04fe: Expected O, but got Unknown
//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0508: Expected O, but got Unknown
//IL_053e: Unknown result type (might be due to invalid IL or missing references)
//IL_0543: Unknown result type (might be due to invalid IL or missing references)
//IL_054a: Unknown result type (might be due to invalid IL or missing references)
//IL_0557: Expected O, but got Unknown
//IL_0557: Unknown result type (might be due to invalid IL or missing references)
//IL_0561: Expected O, but got Unknown
//IL_0585: Unknown result type (might be due to invalid IL or missing references)
//IL_058a: Unknown result type (might be due to invalid IL or missing references)
//IL_0591: Unknown result type (might be due to invalid IL or missing references)
//IL_059e: Expected O, but got Unknown
//IL_059e: Unknown result type (might be due to invalid IL or missing references)
//IL_05a8: Expected O, but got Unknown
//IL_05cc: Unknown result type (might be due to invalid IL or missing references)
//IL_05d1: Unknown result type (might be due to invalid IL or missing references)
//IL_05d8: Unknown result type (might be due to invalid IL or missing references)
//IL_05e5: Expected O, but got Unknown
//IL_05e5: Unknown result type (might be due to invalid IL or missing references)
//IL_05ef: Expected O, but got Unknown
//IL_0613: Unknown result type (might be due to invalid IL or missing references)
//IL_0618: Unknown result type (might be due to invalid IL or missing references)
//IL_061f: Unknown result type (might be due to invalid IL or missing references)
//IL_062c: Expected O, but got Unknown
//IL_062c: Unknown result type (might be due to invalid IL or missing references)
//IL_0636: Expected O, but got Unknown
//IL_065a: Unknown result type (might be due to invalid IL or missing references)
//IL_065f: Unknown result type (might be due to invalid IL or missing references)
//IL_0666: Unknown result type (might be due to invalid IL or missing references)
//IL_0673: Expected O, but got Unknown
//IL_0673: Unknown result type (might be due to invalid IL or missing references)
//IL_067d: Expected O, but got Unknown
context = this;
modEnabled = ((BaseUnityPlugin)this).Config.Bind<Toggle>("01 - General Settings", "Enable Dirty Hoe", Toggle.On, new ConfigDescription("Enable this plugin. (Logout required). [Admin Setting]", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true,
Order = 5
} }));
enableSE = ((BaseUnityPlugin)this).Config.Bind<Toggle>("01 - General Settings", "Enable Status Effect", Toggle.On, new ConfigDescription("Enable the status effect while using the hoe. (Restart required). [Admin Setting]", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true,
Order = 4
} }));
enableHeightmap = ((BaseUnityPlugin)this).Config.Bind<Toggle>("01 - General Settings", "Enable Heightmap Settings", Toggle.Off, new ConfigDescription("Enable the heightmap settings. (Restart required). [Admin Setting]", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true,
Order = 3
} }));
enableCommands = ((BaseUnityPlugin)this).Config.Bind<Toggle>("01 - General Settings", "Enable Console Commands", Toggle.Off, new ConfigDescription("Enable the console commands settings. (Restart required). [Admin Setting]", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true,
Order = 2
} }));
toolShape = ((BaseUnityPlugin)this).Config.Bind<Shape>("01 - General Settings", "Flatten Tool Shape", Shape.Square, new ConfigDescription("Use the Circle or Square shape when flattening terrain.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
Order = 1
} }));
useScrollWheel = ((BaseUnityPlugin)this).Config.Bind<bool>("02 - Hoe Radius", "Use Scroll Wheel", true, new ConfigDescription("Use scroll wheel to modify radius. (Logout required).", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
Order = 6
} }));
scrollWheelScale = ((BaseUnityPlugin)this).Config.Bind<float>("02 - Hoe Radius", "Scroll Wheel Scale", 0.2f, new ConfigDescription("Scroll wheel change scale. (Logout required)", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
Order = 5
} }));
scrollModKey = ((BaseUnityPlugin)this).Config.Bind<string>("02 - Hoe Radius", "Scroll ModKey", "left ctrl", new ConfigDescription("Modifer key to allow scroll wheel change. (Logout required).", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
Order = 4
} }));
increaseHotKey = ((BaseUnityPlugin)this).Config.Bind<string>("02 - Hoe Radius", "Increase HotKey", "", new ConfigDescription("Hotkey to increase radius. (Logout required).", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
Order = 3
} }));
decreaseHotKey = ((BaseUnityPlugin)this).Config.Bind<string>("02 - Hoe Radius", "Decrease HotKey", "", new ConfigDescription("Hotkey to decrease radius. (Logout required).", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
Order = 2
} }));
hotkeyScale = ((BaseUnityPlugin)this).Config.Bind<float>("02 - Hoe Radius", "Hotkey Scale", 0.2f, new ConfigDescription("Change the hotkey scale. (Logout required)", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
Order = 1
} }));
hotKeyRadius = ((BaseUnityPlugin)this).Config.Bind<float>("03 - Terrain Reset", "Hot Key Radius", 150f, new ConfigDescription("Reset radius for hotkey command. (Logout required)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 150f), new object[1] { (object)new ConfigurationManagerAttributes
{
Order = 4
} }));
toolRadius = ((BaseUnityPlugin)this).Config.Bind<float>("03 - Terrain Reset", "Tool Radius", 0f, new ConfigDescription("Reset radius for tool. Set to 0 to use the tool's actual radius. (Logout required)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f), new object[1] { (object)new ConfigurationManagerAttributes
{
Order = 3
} }));
hotKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("03 - Terrain Reset", "Hot Key", (KeyCode)0, new ConfigDescription("Hotkey to reset terrain. (Logout required).", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
Order = 2
} }));
modKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("03 - Terrain Reset", "Mod Key", (KeyCode)308, new ConfigDescription("Modifier key to reset terrain when using tools. (Logout required).", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
Order = 1
} }));
MaxHeight = ((BaseUnityPlugin)this).Config.Bind<float>("04 - Heightmap", "Max Height", 200f, new ConfigDescription("How high you can stack up relative to the heightmap's original position. (Logout required). [Admin Setting]", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true,
Order = 2
} }));
MinHeight = ((BaseUnityPlugin)this).Config.Bind<float>("04 - Heightmap", "Min Height", -200f, new ConfigDescription("How far you can dig down relative to the heightmap's original position. (Logout required). [Admin Setting]", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true,
Order = 1
} }));
forestRadius = ((BaseUnityPlugin)this).Config.Bind<float>("05 - Removal Settings", "Forest Remove Radius", 20f, new ConfigDescription("Radius to set when using the remove_forestry console command. Please be very careful with this! (Logout required). [Admin Setting]", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true,
Order = 2
} }));
pieceRadius = ((BaseUnityPlugin)this).Config.Bind<float>("05 - Removal Settings", "Piece Remove Radius", 20f, new ConfigDescription("Radius to set when using the remove_pieces console command. Please be very careful with this! (Logout required). [Admin Setting]", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true,
Order = 1
} }));
durabilityDrain = ((BaseUnityPlugin)this).Config.Bind<bool>("06 - Misc Settings", "Enable Durability Drain", false, new ConfigDescription("Enable durability drain for the hoe. [Admin Setting]", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true,
Order = 4
} }));
staminaUsage = ((BaseUnityPlugin)this).Config.Bind<bool>("06 - Misc Settings", "Enable Stamina Usage", false, new ConfigDescription("Enable stamina usage for the hoe. [Admin Setting]", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true,
Order = 3
} }));
resourceCosts = ((BaseUnityPlugin)this).Config.Bind<bool>("06 - Misc Settings", "Enable Resource Costs", false, new ConfigDescription("Enable resource costs for the hoe. Only applies to raising terrain and paving terrain. [Admin Setting]", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true,
Order = 2
} }));
needWorkbench = ((BaseUnityPlugin)this).Config.Bind<bool>("06 - Misc Settings", "Workbench Requirement", false, new ConfigDescription("Enable requirement of stone-cutter workbench for paving terrain. [Admin Setting]", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true,
Order = 1
} }));
}
private void SettingChanged(ConfigFile sender, SettingChangedEventArgs args)
{
InitConfig();
bool square = true;
if (toolShape.Value == Shape.Circle)
{
square = false;
}
PrefabManager.Instance.GetPrefab("mm_flatten").GetComponent<TerrainOp>().m_settings.m_square = square;
PrefabManager.Instance.GetPrefab("mm_cultivate_flatten").GetComponent<TerrainOp>().m_settings.m_square = square;
PrefabManager.Instance.GetPrefab("mm_paved_flatten").GetComponent<TerrainOp>().m_settings.m_square = square;
GameObject prefab = PrefabManager.Instance.GetPrefab("DirtyHoe");
if (durabilityDrain.Value)
{
prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_useDurabilityDrain = 1f;
}
else
{
prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_useDurabilityDrain = 0f;
}
if (staminaUsage.Value)
{
prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_attack.m_attackStamina = 5f;
}
else
{
prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_attack.m_attackStamina = 0f;
}
GameObject prefab2 = PrefabManager.Instance.GetPrefab("mm_paved_smooth");
GameObject prefab3 = PrefabManager.Instance.GetPrefab("mm_paved_flatten");
GameObject prefab4 = PrefabManager.Instance.GetPrefab("mm_paint_paved");
CraftingStation prefab5 = Cache.GetPrefab<CraftingStation>("piece_stonecutter");
if (needWorkbench.Value)
{
prefab2.GetComponent<Piece>().m_craftingStation = prefab5;
prefab3.GetComponent<Piece>().m_craftingStation = prefab5;
prefab4.GetComponent<Piece>().m_craftingStation = prefab5;
}
else
{
prefab2.GetComponent<Piece>().m_craftingStation = null;
prefab3.GetComponent<Piece>().m_craftingStation = null;
prefab4.GetComponent<Piece>().m_craftingStation = null;
}
}
public void LoadAssets()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
try
{
magicBundle = AssetUtils.LoadAssetBundleFromResources("mydirtyhoe", Assembly.GetExecutingAssembly());
effectNoise = magicBundle.LoadAsset<GameObject>("sfx_Potion_stamina_Start");
CustomPrefab val = new CustomPrefab(effectNoise, false);
PrefabManager.Instance.AddPrefab(val);
}
catch (Exception ex)
{
Logger.LogError((object)("Exception caught while loading bundle: " + ex.Message));
}
}
public void LoadStatusEffect()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
SE_Stats val = magicBundle.LoadAsset<SE_Stats>("SE_Hoe_Stamina");
_hoeStamina = new CustomStatusEffect((StatusEffect)(object)val, false);
ItemManager.Instance.AddStatusEffect(_hoeStamina);
}
private void LoadTable()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
_gameObject = magicBundle.LoadAsset<GameObject>("_DirtyHoePieceTable");
GameObject gameObject = _gameObject;
PieceTableConfig val = new PieceTableConfig();
val.CanRemovePieces = false;
val.UseCategories = false;
val.UseCustomCategories = true;
val.CustomCategories = new string[1] { "Paint" };
_customPieceTable = new CustomPieceTable(gameObject, val);
PieceManager.Instance.AddPieceTable(_customPieceTable);
LoadHoeTool();
}
private void LoadHoeTool()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Expected O, but got Unknown
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Expected O, but got Unknown
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Expected O, but got Unknown
_gameObject = magicBundle.LoadAsset<GameObject>("DirtyHoe");
GameObject gameObject = _gameObject;
ItemConfig val = new ItemConfig();
val.Amount = 1;
val.CraftingStation = "piece_workbench";
val.RepairStation = "piece_workbench";
val.MinStationLevel = 1;
val.Requirements = (RequirementConfig[])(object)new RequirementConfig[2]
{
new RequirementConfig
{
Item = "Wood",
Amount = 1,
AmountPerLevel = 1
},
new RequirementConfig
{
Item = "Stone",
Amount = 1,
AmountPerLevel = 1
}
};
_customItem = new CustomItem(gameObject, true, val);
if (durabilityDrain.Value)
{
_gameObject.GetComponent<ItemDrop>().m_itemData.m_shared.m_useDurabilityDrain = 1f;
}
if (staminaUsage.Value)
{
_gameObject.GetComponent<ItemDrop>().m_itemData.m_shared.m_attack.m_attackStamina = 5f;
}
if (enableSE.Value == Toggle.On)
{
_gameObject.GetComponent<ItemDrop>().m_itemData.m_shared.m_equipStatusEffect = _hoeStamina.StatusEffect;
}
ItemManager.Instance.AddItem(_customItem);
}
private void LoadSFX()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Expected O, but got Unknown
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Expected O, but got Unknown
try
{
GameObject prefab = Cache.GetPrefab<GameObject>("sfx_build_hoe");
GameObject prefab2 = Cache.GetPrefab<GameObject>("sfx_build_cultivator");
GameObject prefab3 = Cache.GetPrefab<GameObject>("sfx_build_hammer_stone");
EffectList val = new EffectList();
val.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
{
new EffectData
{
m_prefab = prefab
}
};
buildHoe = val;
val = new EffectList();
val.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
{
new EffectData
{
m_prefab = prefab2
}
};
buildCultivater = val;
val = new EffectList();
val.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
{
new EffectData
{
m_prefab = prefab3
}
};
buildStone = val;
}
catch (Exception ex)
{
Logger.LogError((object)("Error while running OnVanillaLoad SFX: " + ex.Message));
}
finally
{
Logger.LogMessage((object)"Loading Dirty Hoe SFX...");
PrefabManager.OnVanillaPrefabsAvailable -= LoadSFX;
}
}
private void LoadPrefabs()
{
try
{
AddSmooth();
AddFlatten();
AddLower();
AddRaise();
AddCultivateSmooth();
AddCultivateFlatten();
AddHoePavedSmooth();
AddHoePavedFlatten();
AddHoeDirtPath();
AddPaintDirt();
AddPaintCultivate();
AddPaintPaved();
AddPaintGrass();
}
catch (Exception ex)
{
Logger.LogError((object)("Error while running OnVanillaLoad Prefabs: " + ex.Message));
}
finally
{
Logger.LogMessage((object)"Loading Dirty Hoe Prefabs...");
PrefabManager.OnVanillaPrefabsAvailable -= LoadPrefabs;
}
}
private void AddCommands()
{
CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new RemoveForestry());
CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new RemovePieces());
}
public static bool IsHeadless()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Invalid comparison between Unknown and I4
return (int)SystemInfo.graphicsDeviceType == 4;
}
private void AddSmooth()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
_gameObject = magicBundle.LoadAsset<GameObject>("mm_smooth");
_customPiece = new CustomPiece(_gameObject, true, new PieceConfig
{
PieceTable = "_DirtyHoePieceTable",
Category = "Misc"
});
_gameObject.GetComponent<Piece>().m_placeEffect = buildHoe;
PieceManager.Instance.AddPiece(_customPiece);
}
private void AddFlatten()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
_gameObject = magicBundle.LoadAsset<GameObject>("mm_flatten");
_customPiece = new CustomPiece(_gameObject, true, new PieceConfig
{
PieceTable = "_DirtyHoePieceTable",
Category = "Misc"
});
_gameObject.GetComponent<Piece>().m_placeEffect = buildHoe;
if (toolShape.Value == Shape.Circle)
{
_gameObject.GetComponent<TerrainOp>().m_settings.m_square = false;
}
else
{
_gameObject.GetComponent<TerrainOp>().m_settings.m_square = true;
}
PieceManager.Instance.AddPiece(_customPiece);
}
private void AddLower()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
_gameObject = magicBundle.LoadAsset<GameObject>("mm_lower");
_customPiece = new CustomPiece(_gameObject, true, new PieceConfig
{
PieceTable = "_DirtyHoePieceTable",
Category = "Misc"
});
_gameObject.GetComponent<Piece>().m_placeEffect = buildStone;
PieceManager.Instance.AddPiece(_customPiece);
}
private void AddRaise()
{
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Expected O, but got Unknown
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Expected O, but got Unknown
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Expected O, but got Unknown
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Expected O, but got Unknown
_gameObject = magicBundle.LoadAsset<GameObject>("mm_raise");
if (resourceCosts.Value)
{
GameObject gameObject = _gameObject;
PieceConfig val = new PieceConfig();
val.PieceTable = "_DirtyHoePieceTable";
val.Category = "Misc";
val.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
{
new RequirementConfig
{
Item = "Stone",
Amount = 2
}
};
_customPiece = new CustomPiece(gameObject, true, val);
}
else
{
_customPiece = new CustomPiece(_gameObject, true, new PieceConfig
{
PieceTable = "_DirtyHoePieceTable",
Category = "Misc"
});
}
_gameObject.GetComponent<Piece>().m_placeEffect = buildHoe;
PieceManager.Instance.AddPiece(_customPiece);
}
private void AddCultivateSmooth()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
_gameObject = magicBundle.LoadAsset<GameObject>("mm_cultivate_smooth");
_customPiece = new CustomPiece(_gameObject, true, new PieceConfig
{
PieceTable = "_DirtyHoePieceTable",
Category = "Misc"
});
_gameObject.GetComponent<Piece>().m_placeEffect = buildCultivater;
PieceManager.Instance.AddPiece(_customPiece);
}
private void AddCultivateFlatten()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
_gameObject = magicBundle.LoadAsset<GameObject>("mm_cultivate_flatten");
_customPiece = new CustomPiece(_gameObject, true, new PieceConfig
{
PieceTable = "_DirtyHoePieceTable",
Category = "Misc"
});
_gameObject.GetComponent<Piece>().m_placeEffect = buildCultivater;
if (toolShape.Value == Shape.Circle)
{
_gameObject.GetComponent<TerrainOp>().m_settings.m_square = false;
}
else
{
_gameObject.GetComponent<TerrainOp>().m_settings.m_square = true;
}
PieceManager.Instance.AddPiece(_customPiece);
}
private void AddHoePavedSmooth()
{
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Expected O, but got Unknown
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Expected O, but got Unknown
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Expected O, but got Unknown
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Expected O, but got Unknown
_gameObject = magicBundle.LoadAsset<GameObject>("mm_paved_smooth");
if (resourceCosts.Value)
{
GameObject gameObject = _gameObject;
PieceConfig val = new PieceConfig();
val.PieceTable = "_DirtyHoePieceTable";
val.Category = "Misc";
val.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
{
new RequirementConfig
{
Item = "Stone",
Amount = 1
}
};
_customPiece = new CustomPiece(gameObject, true, val);
}
else
{
_customPiece = new CustomPiece(_gameObject, true, new PieceConfig
{
PieceTable = "_DirtyHoePieceTable",
Category = "Misc"
});
}
_gameObject.GetComponent<Piece>().m_placeEffect = buildHoe;
PieceManager.Instance.AddPiece(_customPiece);
}
private void AddHoePavedFlatten()
{
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Expected O, but got Unknown
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Expected O, but got Unknown
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Expected O, but got Unknown
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Expected O, but got Unknown
_gameObject = magicBundle.LoadAsset<GameObject>("mm_paved_flatten");
if (resourceCosts.Value)
{
GameObject gameObject = _gameObject;
PieceConfig val = new PieceConfig();
val.PieceTable = "_DirtyHoePieceTable";
val.Category = "Misc";
val.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
{
new RequirementConfig
{
Item = "Stone",
Amount = 1
}
};
_customPiece = new CustomPiece(gameObject, true, val);
}
else
{
_customPiece = new CustomPiece(_gameObject, true, new PieceConfig
{
PieceTable = "_DirtyHoePieceTable",
Category = "Misc"
});
}
_gameObject.GetComponent<Piece>().m_placeEffect = buildHoe;
if (toolShape.Value == Shape.Circle)
{
_gameObject.GetComponent<TerrainOp>().m_settings.m_square = false;
}
else
{
_gameObject.GetComponent<TerrainOp>().m_settings.m_square = true;
}
PieceManager.Instance.AddPiece(_customPiece);
}
private void AddHoeDirtPath()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
_gameObject = magicBundle.LoadAsset<GameObject>("mm_dirt_path");
_customPiece = new CustomPiece(_gameObject, true, new PieceConfig
{
PieceTable = "_DirtyHoePieceTable",
Category = "Misc"
});
_gameObject.GetComponent<Piece>().m_placeEffect = buildHoe;
PieceManager.Instance.AddPiece(_customPiece);
}
private void AddPaintDirt()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
_gameObject = magicBundle.LoadAsset<GameObject>("mm_paint_dirt");
_customPiece = new CustomPiece(_gameObject, true, new PieceConfig
{
PieceTable = "_DirtyHoePieceTable",
Category = "Paint"
});
_gameObject.GetComponent<Piece>().m_placeEffect = buildCultivater;
PieceManager.Instance.AddPiece(_customPiece);
}
private void AddPaintCultivate()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
_gameObject = magicBundle.LoadAsset<GameObject>("mm_paint_cultivate");
_customPiece = new CustomPiece(_gameObject, true, new PieceConfig
{
PieceTable = "_DirtyHoePieceTable",
Category = "Paint"
});
_gameObject.GetComponent<Piece>().m_placeEffect = buildCultivater;
PieceManager.Instance.AddPiece(_customPiece);
}
private void AddPaintPaved()
{
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Expected O, but got Unknown
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Expected O, but got Unknown
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Expected O, but got Unknown
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Expected O, but got Unknown
_gameObject = magicBundle.LoadAsset<GameObject>("mm_paint_paved");
if (resourceCosts.Value)
{
GameObject gameObject = _gameObject;
PieceConfig val = new PieceConfig();
val.PieceTable = "_DirtyHoePieceTable";
val.Category = "Paint";
val.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
{
new RequirementConfig
{
Item = "Stone",
Amount = 1
}
};
_customPiece = new CustomPiece(gameObject, true, val);
}
else
{
_customPiece = new CustomPiece(_gameObject, true, new PieceConfig
{
PieceTable = "_DirtyHoePieceTable",
Category = "Paint"
});
}
_gameObject.GetComponent<Piece>().m_placeEffect = buildCultivater;
PieceManager.Instance.AddPiece(_customPiece);
}
private void AddPaintGrass()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
_gameObject = magicBundle.LoadAsset<GameObject>("mm_paint_grass");
_customPiece = new CustomPiece(_gameObject, true, new PieceConfig
{
PieceTable = "_DirtyHoePieceTable",
Category = "Paint"
});
_gameObject.GetComponent<Piece>().m_placeEffect = buildCultivater;
PieceManager.Instance.AddPiece(_customPiece);
}
private void SetRadius(float delta)
{
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
Traverse obj = Traverse.Create((object)Player.m_localPlayer).Field("m_buildPieces");
object obj2;
if (obj == null)
{
obj2 = null;
}
else
{
PieceTable value = obj.GetValue<PieceTable>();
obj2 = ((value != null) ? value.GetSelectedPiece() : null);
}
Piece val = (Piece)obj2;
if (val == null)
{
return;
}
TerrainOp val2 = ((val != null) ? ((Component)val).gameObject.GetComponent<TerrainOp>() : null);
if ((Object)(object)val2 == (Object)null)
{
return;
}
float num = 0f;
float num2 = Mathf.Max(lastModdedRadius + delta, 0f);
lastTotalDelta += delta;
if (lastOriginalRadius == 0f)
{
if (val2.m_settings.m_level && num < val2.m_settings.m_levelRadius)
{
num = val2.m_settings.m_levelRadius;
num2 = Mathf.Max(val2.m_settings.m_levelRadius + delta, 0f);
}
if (val2.m_settings.m_raise && num < val2.m_settings.m_raiseRadius)
{
num = val2.m_settings.m_raiseRadius;
num2 = Mathf.Max(val2.m_settings.m_raiseRadius + delta, 0f);
}
if (val2.m_settings.m_smooth && num < val2.m_settings.m_smoothRadius)
{
num = val2.m_settings.m_smoothRadius;
num2 = Mathf.Max(val2.m_settings.m_smoothRadius + delta, 0f);
}
if (val2.m_settings.m_paintCleared && num < val2.m_settings.m_paintRadius)
{
num = val2.m_settings.m_paintRadius;
num2 = Mathf.Max(val2.m_settings.m_paintRadius + delta, 0f);
}
lastOriginalRadius = num;
}
lastModdedRadius = num2;
if (lastOriginalRadius > 0f && lastModdedRadius > 0f)
{
GameObject value2 = Traverse.Create((object)Player.m_localPlayer).Field("m_placementGhost").GetValue<GameObject>();
Transform val3 = ((value2 != null) ? value2.transform.Find("_GhostOnly") : null);
if ((Object)(object)val3 != (Object)null)
{
val3.localScale = new Vector3(lastModdedRadius / lastOriginalRadius, lastModdedRadius / lastOriginalRadius, lastModdedRadius / lastOriginalRadius);
}
}
}
}
public class TerrainReset_Patches
{
[HarmonyPatch(typeof(TerrainOp), "Awake")]
private static class TerrainOp_Patch
{
private static void Prefix(TerrainOp __instance)
{
if (__instance.m_settings.m_level)
{
Settings settings = __instance.m_settings;
settings.m_levelRadius += MyDirtyHoeMod.lastTotalDelta;
}
if (__instance.m_settings.m_raise)
{
Settings settings2 = __instance.m_settings;
settings2.m_raiseRadius += MyDirtyHoeMod.lastTotalDelta;
}
if (__instance.m_settings.m_smooth)
{
Settings settings3 = __instance.m_settings;
settings3.m_smoothRadius += MyDirtyHoeMod.lastTotalDelta;
}
if (__instance.m_settings.m_paintCleared)
{
Settings settings4 = __instance.m_settings;
settings4.m_paintRadius += MyDirtyHoeMod.lastTotalDelta;
}
}
}
[HarmonyPatch(typeof(ZNetScene), "Awake")]
private static class SFXFix
{
private static void Postfix()
{
GameObject prefab = ZNetScene.instance.GetPrefab("sfx_Potion_stamina_Start");
try
{
prefab.GetComponentInChildren<AudioSource>().outputAudioMixerGroup = AudioMan.instance.m_ambientMixer;
}
catch
{
Logger.LogError((object)"AudioMan.instance.m_ambientMixer could not be assigned on outputAudioMixerGroup");
}
}
}
[HarmonyPatch(typeof(TerrainComp), "ApplyOperation")]
private static class Patch_TerrainComp_ApplyOperation
{
private static bool Prefix(TerrainOp modifier)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
if (MyDirtyHoeMod.modEnabled.Value == MyDirtyHoeMod.Toggle.On && CheckKeyHeld(MyDirtyHoeMod.GetToolModKey()))
{
ResetTerrain(((Component)modifier).transform.position, (MyDirtyHoeMod.GetToolRadius() > 0f) ? MyDirtyHoeMod.GetToolRadius() : modifier.GetRadius());
return false;
}
return true;
}
}
[HarmonyPatch(typeof(TerrainOp), "OnPlaced")]
private static class Patch_TerrainOp_OnPlaced
{
private static bool Prefix()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
if (MyDirtyHoeMod.modEnabled.Value == MyDirtyHoeMod.Toggle.On && CheckKeyHeld(MyDirtyHoeMod.GetToolModKey()))
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Terminal), "InitTerminal")]
private static class Patch_Terminal_InitTerminal
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static ConsoleEvent <>9__1_0;
internal void <Postfix>b__1_0(ConsoleEventArgs args)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
float result;
if (args.Length < 2)
{
args.Context.AddString("Syntax: resetterrain [radius]");
}
else if (float.TryParse(args[1], out result))
{
int num = ResetTerrain(((Component)Player.m_localPlayer).transform.position, result);
args.Context.AddString($"{num} edits reset.");
}
else
{
args.Context.AddString("Invalid command, syntax: resetterrain [radius as a float]");
}
}
}
[HarmonyPriority(800)]
private static void Prefix(out bool __state)
{
__state = Terminal.m_terminalInitialized;
}
private static void Postfix(bool __state)
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: 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_0044: Expected O, but got Unknown
if (__state || MyDirtyHoeMod.modEnabled.Value != MyDirtyHoeMod.Toggle.On)
{
return;
}
Logger.LogInfo((object)"Adding Terminal Command \"resetterrain\".");
try
{
object obj = <>c.<>9__1_0;
if (obj == null)
{
ConsoleEvent val = delegate(ConsoleEventArgs args)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
float result;
if (args.Length < 2)
{
args.Context.AddString("Syntax: resetterrain [radius]");
}
else if (float.TryParse(args[1], out result))
{
int num = ResetTerrain(((Component)Player.m_localPlayer).transform.position, result);
args.Context.AddString($"{num} edits reset.");
}
else
{
args.Context.AddString("Invalid command, syntax: resetterrain [radius as a float]");
}
};
<>c.<>9__1_0 = val;
obj = (object)val;
}
new ConsoleCommand("resetterrain", "[name] [radius]", (ConsoleEvent)obj, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
}
catch (Exception ex)
{
Logger.LogWarning((object)"Error, could not add terminal command. This can happen when two mods add the same command. The rest of this mod should work as expected.");
Logger.LogWarning((object)ex);
}
}
}
private static readonly TerrainReset_Patches _instance = new TerrainReset_Patches();
public static TerrainReset_Patches Instance => _instance;
private TerrainReset_Patches()
{
}
public static bool IgnoreKeyPresses()
{
if (!((Object)(object)ZNetScene.instance == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null) && !Minimap.IsOpen() && !Console.IsVisible() && !TextInput.IsVisible() && !ZNet.instance.InPasswordDialog() && (!((Object)(object)Chat.instance != (Object)null) || !Chat.instance.HasFocus()) && !StoreGui.IsVisible() && !InventoryGui.IsVisible() && !Menu.IsVisible())
{
if ((Object)(object)TextViewer.instance != (Object)null)
{
return TextViewer.instance.IsVisible();
}
return false;
}
return true;
}
public static bool CheckKeyDown(KeyCode value)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
return ZInput.GetKeyDown(value, true);
}
public static bool CheckKeyHeld(KeyCode value)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
return ZInput.GetKey(value, true);
}
public static int ResetTerrain(Vector3 center, float radius)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0203: Unknown result type (might be due to invalid IL or missing references)
int num = 0;
List<Heightmap> list = new List<Heightmap>();
Heightmap.FindHeightmap(center, radius + 100f, list);
foreach (TerrainModifier allInstance in TerrainModifier.GetAllInstances())
{
Vector3 position = ((Component)allInstance).transform.position;
ZNetView component = ((Component)allInstance).GetComponent<ZNetView>();
if ((Object)(object)component == (Object)null || !component.IsValid() || !(Utils.DistanceXZ(position, center) <= radius))
{
continue;
}
if (!component.IsOwner())
{
component.ClaimOwnership();
}
num++;
foreach (Heightmap item in list)
{
if (item.TerrainVSModifier(allInstance))
{
item.Poke(true);
}
}
component.Destroy();
}
using (List<Heightmap>.Enumerator enumerator3 = list.GetEnumerator())
{
int num2 = default(int);
int num3 = default(int);
int num4 = default(int);
int num5 = default(int);
while (enumerator3.MoveNext())
{
TerrainComp val = TerrainComp.FindTerrainCompiler(((Component)enumerator3.Current).transform.position);
if (!Object.op_Implicit((Object)(object)val))
{
continue;
}
if (!val.m_nview.IsOwner())
{
val.m_nview.ClaimOwnership();
}
if (!val.m_initialized)
{
continue;
}
enumerator3.Current.WorldToVertex(center, ref num2, ref num3);
enumerator3.Current.WorldToVertexMask(center, ref num4, ref num5);
bool flag = false;
int num6 = val.m_width + 1;
for (int i = 0; i < num6; i++)
{
for (int j = 0; j < num6; j++)
{
int num7 = i * num6 + j;
if (CoordDistance(num2, num3, j, i) <= radius && val.m_modifiedHeight[num7])
{
num++;
flag = true;
val.m_modifiedHeight[num7] = false;
val.m_levelDelta[num7] = 0f;
val.m_smoothDelta[num7] = 0f;
}
if (CoordDistance(num4, num5, j, i) <= radius && val.m_modifiedPaint[num7])
{
flag = true;
val.m_modifiedPaint[num7] = false;
val.m_paintMask[num7] = Color.clear;
}
}
}
if (flag)
{
val.Save();
enumerator3.Current.Poke(true);
}
}
}
if ((Object)(object)ClutterSystem.instance != (Object)null)
{
ClutterSystem.instance.ResetGrass(center, radius);
}
return num;
}
private static float CoordDistance(float x, float y, float rx, float ry)
{
float num = x - rx;
float num2 = y - ry;
return Mathf.Sqrt(num * num + num2 * num2);
}
}
}
namespace MyDirtyHoe.ConsoleCommands
{
public class RemoveForestry : ConsoleCommand
{
public override string Name => "remove_forestry";
public override string Help => "removes trees, shrubs, rocks etc in a " + MyDirtyHoeMod.forestRadius.Value + "m radius";
public override void Run(string[] args)
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Invalid comparison between Unknown and I4
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Invalid comparison between Unknown and I4
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
Game.instance.GetPlayerProfile().GetPlayerID();
Player localPlayer = Player.m_localPlayer;
TreeBase[] array = Object.FindObjectsOfType<TreeBase>();
Destructible[] array2 = Object.FindObjectsOfType<Destructible>();
Pickable[] array3 = Object.FindObjectsOfType<Pickable>();
for (int i = 0; i < array.Length; i++)
{
if (Vector3.Distance(((Component)array[i]).transform.position, ((Component)localPlayer).transform.position) < MyDirtyHoeMod.forestRadius.Value)
{
((Component)array[i]).GetComponent<ZNetView>().Destroy();
}
}
for (int j = 0; j < array2.Length; j++)
{
if (((int)array2[j].m_destructibleType == 2 || (int)array2[j].m_destructibleType == 1) && Vector3.Distance(((Component)array2[j]).transform.position, ((Component)localPlayer).transform.position) < MyDirtyHoeMod.forestRadius.Value)
{
((Component)array2[j]).GetComponent<ZNetView>().Destroy();
}
}
for (int k = 0; k < array3.Length; k++)
{
if (Vector3.Distance(((Component)array3[k]).transform.position, ((Component)localPlayer).transform.position) < MyDirtyHoeMod.forestRadius.Value)
{
((Component)array3[k]).GetComponent<ZNetView>().Destroy();
}
}
}
}
public class RemovePieces : ConsoleCommand
{
public static List<Vector3> treeRadiuses = new List<Vector3>();
public static List<Piece> sPieces = new List<Piece>();
public override string Name => "remove_pieces";
public override string Help => "removes all structures around the player in a " + MyDirtyHoeMod.pieceRadius.Value + "m radius";
public override void Run(string[] args)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
Piece[] array = Object.FindObjectsOfType<Piece>();
Game.instance.GetPlayerProfile().GetPlayerID();
Player localPlayer = Player.m_localPlayer;
GetNearbySPieces();
for (int i = 0; i < array.Length; i++)
{
if (array[i].IsCreator() && Vector3.Distance(((Component)array[i]).transform.position, ((Component)localPlayer).transform.position) < MyDirtyHoeMod.pieceRadius.Value)
{
((Component)array[i]).GetComponent<ZNetView>().Destroy();
}
}
}
private static void GetNearbySPieces()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
Player localPlayer = Player.m_localPlayer;
sPieces.Clear();
Piece.GetAllPiecesInRadius(((Component)localPlayer).transform.position, MyDirtyHoeMod.pieceRadius.Value, sPieces);
sPieces = sPieces.Where((Piece p) => (int)p.m_category > 0).ToList();
foreach (Piece sPiece in sPieces)
{
sPiece.SetCreator(Game.instance.GetPlayerProfile().GetPlayerID());
}
}
}
}