Decompiled source of PlantEasily v2.0.2
Advize_PlantEasily.dll
Decompiled 2 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; 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 BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Advize_PlantEasily")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Valheim Game Modification")] [assembly: AssemblyCopyright("Copyright © Advize 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("5eaff7d4-7661-4152-a841-ed19ba3b36f4")] [assembly: AssemblyFileVersion("2.0.2.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.0.2.0")] [module: UnverifiableCode] [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.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Advize_PlantEasily { internal sealed class ModConfig { internal class ConfigurationManagerAttributes { public string? Description; public int? Order; } private readonly ConfigFile Config; private readonly ConfigEntry<KeyboardShortcut> enableModKey; private readonly ConfigEntry<KeyboardShortcut> enableSnappingKey; private readonly ConfigEntry<KeyboardShortcut> toggleAutoReplantKey; private readonly ConfigEntry<KeyboardShortcut> increaseXKey; private readonly ConfigEntry<KeyboardShortcut> increaseYKey; private readonly ConfigEntry<KeyboardShortcut> decreaseXKey; private readonly ConfigEntry<KeyboardShortcut> decreaseYKey; private readonly ConfigEntry<KeyboardShortcut> keyboardModifierKey; private readonly ConfigEntry<KeyboardShortcut> gamepadModifierKey; private readonly ConfigEntry<KeyboardShortcut> keyboardHarvestModifierKey; private readonly ConfigEntry<bool> preventPartialPlanting; private readonly ConfigEntry<bool> preventInvalidPlanting; private readonly ConfigEntry<bool> useStamina; private readonly ConfigEntry<bool> useDurability; private readonly ConfigEntry<bool> modActive; private readonly ConfigEntry<bool> snapActive; private readonly ConfigEntry<int> rows; private readonly ConfigEntry<int> columns; private readonly ConfigEntry<bool> randomizeRotation; private readonly ConfigEntry<bool> enableDebugMessages; private readonly ConfigEntry<bool> globallyAlignGridDirections; private readonly ConfigEntry<bool> minimizeGridSpacing; private readonly ConfigEntry<GridSnappingStyle> gridSnappingStyle; private readonly ConfigEntry<bool> forceAltPlacement; private readonly ConfigEntry<float> extraCropSpacing; private readonly ConfigEntry<float> extraSaplingSpacing; private readonly ConfigEntry<bool> enableBulkHarvest; private readonly ConfigEntry<HarvestStyle> harvestStyle; private readonly ConfigEntry<float> harvestRadius; private readonly ConfigEntry<bool> replantOnHarvest; private readonly ConfigEntry<int> maxConcurrentPlacements; private readonly ConfigEntry<int> bulkPlantingBatchSize; private readonly ConfigEntry<float> defaultGridSpacing; private readonly ConfigEntry<bool> preventOverlappingPlacements; private readonly ConfigEntry<bool> showCost; private readonly ConfigEntry<CostDisplayStyle> costDisplayStyle; private readonly ConfigEntry<CostDisplayLocation> costDisplayLocation; private readonly ConfigEntry<bool> showHUDKeyHints; private readonly ConfigEntry<bool> showHoverKeyHints; private readonly ConfigEntry<bool> showHoverReplantHint; private readonly ConfigEntry<bool> showGhostsDuringPlacement; private readonly ConfigEntry<bool> showGridDirections; private readonly ConfigEntry<bool> highlightRootPlacementGhost; private readonly ConfigEntry<Color> rootGhostHighlightColor; private readonly ConfigEntry<Color> rowStartColor; private readonly ConfigEntry<Color> rowEndColor; private readonly ConfigEntry<Color> columnStartColor; private readonly ConfigEntry<Color> columnEndColor; internal KeyboardShortcut EnableModKey => enableModKey.Value; internal KeyboardShortcut EnableSnappingKey => enableSnappingKey.Value; internal KeyboardShortcut ToggleAutoReplantKey => toggleAutoReplantKey.Value; internal KeyCode IncreaseXKey { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = increaseXKey.Value; return ((KeyboardShortcut)(ref value)).MainKey; } } internal KeyCode IncreaseYKey { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = increaseYKey.Value; return ((KeyboardShortcut)(ref value)).MainKey; } } internal KeyCode DecreaseXKey { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = decreaseXKey.Value; return ((KeyboardShortcut)(ref value)).MainKey; } } internal KeyCode DecreaseYKey { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = decreaseYKey.Value; return ((KeyboardShortcut)(ref value)).MainKey; } } internal KeyCode KeyboardModifierKey { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = keyboardModifierKey.Value; return ((KeyboardShortcut)(ref value)).MainKey; } } internal KeyCode GamepadModifierKey { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = gamepadModifierKey.Value; return ((KeyboardShortcut)(ref value)).MainKey; } } internal KeyCode KeyboardHarvestModifierKey { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = keyboardHarvestModifierKey.Value; return ((KeyboardShortcut)(ref value)).MainKey; } } internal bool PreventPartialPlanting => preventPartialPlanting.Value; internal bool PreventInvalidPlanting => preventInvalidPlanting.Value; internal bool UseStamina => useStamina.Value; internal bool UseDurability => useDurability.Value; internal bool ModActive { get { return modActive.Value; } set { ((ConfigEntryBase)modActive).BoxedValue = value; } } internal bool SnapActive { get { return snapActive.Value; } set { ((ConfigEntryBase)snapActive).BoxedValue = value; } } internal int Rows { get { return Mathf.Max(rows.Value, 1); } set { ((ConfigEntryBase)rows).BoxedValue = Mathf.Max(value, 1); } } internal int Columns { get { return Mathf.Max(columns.Value, 1); } set { ((ConfigEntryBase)columns).BoxedValue = Mathf.Max(value, 1); } } internal bool RandomizeRotation => randomizeRotation.Value; internal bool EnableDebugMessages => enableDebugMessages.Value; internal bool GloballyAlignGridDirections => globallyAlignGridDirections.Value; internal bool MinimizeGridSpacing => minimizeGridSpacing.Value; internal GridSnappingStyle GridSnappingStyle => gridSnappingStyle.Value; internal bool ForceAltPlacement => forceAltPlacement.Value; internal float ExtraCropSpacing => extraCropSpacing.Value; internal float ExtraSaplingSpacing => extraSaplingSpacing.Value; internal bool EnableBulkHarvest => enableBulkHarvest.Value; internal HarvestStyle HarvestStyle => harvestStyle.Value; internal float HarvestRadius => harvestRadius.Value; internal bool ReplantOnHarvest { get { return replantOnHarvest.Value; } set { ((ConfigEntryBase)replantOnHarvest).BoxedValue = value; } } internal int MaxConcurrentPlacements => maxConcurrentPlacements.Value; internal int BulkPlantingBatchSize => bulkPlantingBatchSize.Value; internal float DefaultGridSpacing => defaultGridSpacing.Value; internal bool PreventOverlappingPlacements => preventOverlappingPlacements.Value; internal bool ShowCost => showCost.Value; internal CostDisplayStyle CostDisplayStyle => costDisplayStyle.Value; internal CostDisplayLocation CostDisplayLocation => costDisplayLocation.Value; internal bool ShowHUDKeyHints => showHUDKeyHints.Value; internal bool ShowHoverKeyHints => showHoverKeyHints.Value; internal bool ShowHoverReplantHint => showHoverReplantHint.Value; internal bool ShowGhostsDuringPlacement => showGhostsDuringPlacement.Value; internal bool ShowGridDirections => showGridDirections.Value; internal bool HighlightRootPlacementGhost => highlightRootPlacementGhost.Value; internal Color RootGhostHighlightColor => rootGhostHighlightColor.Value; internal Color RowStartColor => rowStartColor.Value; internal Color RowEndColor => rowEndColor.Value; internal Color ColumnStartColor => columnStartColor.Value; internal Color ColumnEndColor => columnEndColor.Value; internal ModConfig(ConfigFile configFile) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Expected O, but got Unknown //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Expected O, but got Unknown //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Expected O, but got Unknown //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Expected O, but got Unknown //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Expected O, but got Unknown //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Expected O, but got Unknown //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Expected O, but got Unknown //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Expected O, but got Unknown //IL_0491: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Expected O, but got Unknown //IL_04d2: Unknown result type (might be due to invalid IL or missing references) //IL_04dc: Expected O, but got Unknown //IL_0513: Unknown result type (might be due to invalid IL or missing references) //IL_051d: Expected O, but got Unknown //IL_0554: Unknown result type (might be due to invalid IL or missing references) //IL_055e: Expected O, but got Unknown //IL_0595: Unknown result type (might be due to invalid IL or missing references) //IL_059f: Expected O, but got Unknown //IL_070b: Unknown result type (might be due to invalid IL or missing references) //IL_0715: Expected O, but got Unknown //IL_0745: Unknown result type (might be due to invalid IL or missing references) //IL_074f: Expected O, but got Unknown //IL_077b: Unknown result type (might be due to invalid IL or missing references) //IL_0785: Expected O, but got Unknown //IL_07c0: Unknown result type (might be due to invalid IL or missing references) //IL_07ca: Expected O, but got Unknown //IL_0801: Unknown result type (might be due to invalid IL or missing references) //IL_080b: Expected O, but got Unknown //IL_0843: Unknown result type (might be due to invalid IL or missing references) //IL_084d: Expected O, but got Unknown //IL_0885: Unknown result type (might be due to invalid IL or missing references) //IL_088f: Expected O, but got Unknown //IL_08c7: Unknown result type (might be due to invalid IL or missing references) //IL_08d1: Expected O, but got Unknown //IL_0909: Unknown result type (might be due to invalid IL or missing references) //IL_0913: Expected O, but got Unknown //IL_094b: Unknown result type (might be due to invalid IL or missing references) //IL_0955: Expected O, but got Unknown //IL_098d: Unknown result type (might be due to invalid IL or missing references) //IL_0997: Expected O, but got Unknown //IL_09ce: Unknown result type (might be due to invalid IL or missing references) //IL_09d8: Expected O, but got Unknown //IL_0a0f: Unknown result type (might be due to invalid IL or missing references) //IL_0a19: Expected O, but got Unknown //IL_0a50: Unknown result type (might be due to invalid IL or missing references) //IL_0a5a: Expected O, but got Unknown //IL_0a70: Unknown result type (might be due to invalid IL or missing references) //IL_0a95: Unknown result type (might be due to invalid IL or missing references) //IL_0a9f: Expected O, but got Unknown //IL_0ab5: Unknown result type (might be due to invalid IL or missing references) //IL_0ada: Unknown result type (might be due to invalid IL or missing references) //IL_0ae4: Expected O, but got Unknown //IL_0afa: Unknown result type (might be due to invalid IL or missing references) //IL_0b1f: Unknown result type (might be due to invalid IL or missing references) //IL_0b29: Expected O, but got Unknown //IL_0b3f: Unknown result type (might be due to invalid IL or missing references) //IL_0b64: Unknown result type (might be due to invalid IL or missing references) //IL_0b6e: Expected O, but got Unknown //IL_0b84: Unknown result type (might be due to invalid IL or missing references) //IL_0ba9: Unknown result type (might be due to invalid IL or missing references) //IL_0bb3: Expected O, but got Unknown Config = configFile; configFile.SaveOnConfigSet = false; enableModKey = Config.Bind<KeyboardShortcut>("Controls", "EnableModKey", new KeyboardShortcut((KeyCode)289, Array.Empty<KeyCode>()), new ConfigDescription("Key to toggle on/off all mod features. See https://docs.unity3d.com/ScriptReference/KeyCode.html", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Description = "Key to toggle on/off all mod features.", Order = 10 } })); enableSnappingKey = Config.Bind<KeyboardShortcut>("Controls", "EnableSnappingKey", new KeyboardShortcut((KeyCode)291, Array.Empty<KeyCode>()), new ConfigDescription("Key to toggle on/off piece snapping functionality. See https://docs.unity3d.com/ScriptReference/KeyCode.html", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Description = "Key to toggle on/off piece snapping functionality.", Order = 9 } })); toggleAutoReplantKey = Config.Bind<KeyboardShortcut>("Controls", "ToggleAutoReplantKey", new KeyboardShortcut((KeyCode)287, Array.Empty<KeyCode>()), new ConfigDescription("Key to toggle on/off the [Harvesting]ReplantOnHarvest setting. See https://docs.unity3d.com/ScriptReference/KeyCode.html", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Description = "Key to toggle on/off the [Harvesting]ReplantOnHarvest setting.", Order = 8 } })); increaseXKey = Config.Bind<KeyboardShortcut>("Controls", "IncreaseXKey", new KeyboardShortcut((KeyCode)275, Array.Empty<KeyCode>()), new ConfigDescription("Key to increase number of grid columns. See https://docs.unity3d.com/ScriptReference/KeyCode.html", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Description = "Key to increase number of grid columns.", Order = 7 } })); increaseYKey = Config.Bind<KeyboardShortcut>("Controls", "IncreaseYKey", new KeyboardShortcut((KeyCode)273, Array.Empty<KeyCode>()), new ConfigDescription("Key to increase number of grid rows. See https://docs.unity3d.com/ScriptReference/KeyCode.html", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Description = "Key to increase number of grid rows.", Order = 6 } })); decreaseXKey = Config.Bind<KeyboardShortcut>("Controls", "DecreaseXKey", new KeyboardShortcut((KeyCode)276, Array.Empty<KeyCode>()), new ConfigDescription("Key to decrease number of grid columns. See https://docs.unity3d.com/ScriptReference/KeyCode.html", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Description = "Key to decrease number of grid columns.", Order = 5 } })); decreaseYKey = Config.Bind<KeyboardShortcut>("Controls", "DecreaseYKey", new KeyboardShortcut((KeyCode)274, Array.Empty<KeyCode>()), new ConfigDescription("Key to decrease number of grid rows. See https://docs.unity3d.com/ScriptReference/KeyCode.html", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Description = "Key to decrease number of grid rows.", Order = 4 } })); keyboardModifierKey = Config.Bind<KeyboardShortcut>("Controls", "KeyboardModifierKey", new KeyboardShortcut((KeyCode)305, Array.Empty<KeyCode>()), new ConfigDescription("Modifier key when using keyboard controls. See https://docs.unity3d.com/ScriptReference/KeyCode.html", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Description = "Modifier key when using keyboard controls.", Order = 3 } })); gamepadModifierKey = Config.Bind<KeyboardShortcut>("Controls", "GamepadModifierKey", new KeyboardShortcut((KeyCode)334, Array.Empty<KeyCode>()), new ConfigDescription("Modifier key when using gamepad controls. See https://docs.unity3d.com/ScriptReference/KeyCode.html", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Description = "Modifier key when using gamepad controls.", Order = 2 } })); keyboardHarvestModifierKey = Config.Bind<KeyboardShortcut>("Controls", "KeyboardHarvestModifierKey", new KeyboardShortcut((KeyCode)304, Array.Empty<KeyCode>()), new ConfigDescription("Modifier key to enable bulk harvest when using keyboard controls. See https://docs.unity3d.com/ScriptReference/KeyCode.html", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Description = "Modifier key to enable bulk harvest when using keyboard controls.", Order = 1 } })); preventPartialPlanting = Config.Bind<bool>("Difficulty", "PreventPartialPlanting", false, "Prevents placement of resources when any placement ghosts are invalid for any reason."); preventInvalidPlanting = Config.Bind<bool>("Difficulty", "PreventInvalidPlanting", true, "Prevents plants from being placed where they will be unable to grow."); useStamina = Config.Bind<bool>("Difficulty", "UseStamina", true, "Consume stamina for every piece placed."); useDurability = Config.Bind<bool>("Difficulty", "UseDurability", true, "Decrease durability of cultivator for every piece placed."); modActive = Config.Bind<bool>("General", "ModActive", true, new ConfigDescription("Enables all mod features.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 6 } })); snapActive = Config.Bind<bool>("General", "SnapActive", true, new ConfigDescription("Enables grid snapping feature.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 5 } })); rows = Config.Bind<int>("General", "Rows", 2, new ConfigDescription("Number of rows for planting grid aka height.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 4 } })); columns = Config.Bind<int>("General", "Columns", 2, new ConfigDescription("Number of columns for planting grid aka width.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 3 } })); randomizeRotation = Config.Bind<bool>("General", "RandomizeRotation", true, new ConfigDescription("Randomizes rotation of pieces once placed.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 2 } })); enableDebugMessages = Config.Bind<bool>("General", "EnableDebugMessages", false, new ConfigDescription("Enable mod debug messages in console.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 1 } })); globallyAlignGridDirections = Config.Bind<bool>("Grid", "GloballyAlignGridDirections", true, "When set to true, new grid placements will have their column and row directions align with the global grid."); minimizeGridSpacing = Config.Bind<bool>("Grid", "MinimizeGridSpacing", false, "Allows for tighter grids, but with varying spacing used between diverse/distinct plants. "); gridSnappingStyle = Config.Bind<GridSnappingStyle>("Grid", "GridSnappingStyle", GridSnappingStyle.Intelligent, "Determines grid snapping style. Intelligent will attempt to prevent a new grid from overlapping with an old one. Legacy will allow any orientation of new rows and columns."); forceAltPlacement = Config.Bind<bool>("Grid", "ForceAltPlacement", false, "When enabled, alternate placement mode for the cultivator is always used. Alternate placement mode allows free rotation when snapping to a single piece."); extraCropSpacing = Config.Bind<float>("Grid", "ExtraCropSpacing", 0f, "Adds extra spacing between crops. Accepts negative values to decrease spacing (not recommended)."); extraSaplingSpacing = Config.Bind<float>("Grid", "ExtraSaplingSpacing", 0f, "Adds extra spacing between saplings. Accepts negative values to decrease spacing (not recommended)."); enableBulkHarvest = Config.Bind<bool>("Harvesting", "EnableBulkHarvest", true, "Enables the ability to harvest multiple resources at once."); harvestStyle = Config.Bind<HarvestStyle>("Harvesting", "HarvestStyle", HarvestStyle.AllResources, "Determines bulk harvest style. LikeResources only harvests resources of the type you've interacted with. AllResources harvests all eligible resources."); harvestRadius = Config.Bind<float>("Harvesting", "HarvestRadius", 3f, "Determines radius used to search for resources when bulk harvesting."); replantOnHarvest = Config.Bind<bool>("Harvesting", "ReplantOnHarvest", false, new ConfigDescription("Enables automatic replanting of crops when harvested, provided you have the resources.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 4 } })); maxConcurrentPlacements = Config.Bind<int>("Performance", "MaxConcurrentPlacements", 500, new ConfigDescription("Maximum amount of pieces that can be placed at once with the cultivator.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 10000), Array.Empty<object>())); bulkPlantingBatchSize = Config.Bind<int>("Performance", "BulkPlantingBatchSize", 2, new ConfigDescription("This value determines how many concurrent pieces can be placed per frame. Increase to speed up planting. Reduce this value if the game hangs when placing too many pieces at once.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 10000), Array.Empty<object>())); defaultGridSpacing = Config.Bind<float>("Pickables", "DefaultGridSpacing", 1f, new ConfigDescription("Determines default distance/spacing between pickable resources when planting.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 1 } })); preventOverlappingPlacements = Config.Bind<bool>("Pickables", "PreventOverlappingPlacements", true, new ConfigDescription("Prevents placement of pickable resources on top of colliding obstructions.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 2 } })); showCost = Config.Bind<bool>("UI", "ShowCost", true, new ConfigDescription("Update resource cost in build UI.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 14 } })); costDisplayStyle = Config.Bind<CostDisplayStyle>("UI", "CostDisplayStyle", CostDisplayStyle.TotalCount, new ConfigDescription("Determines display style of the ShowCost setting. TotalCount shows total number of pieces to be placed. FullCost shows combined resoure cost of all pieces.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 13 } })); costDisplayLocation = Config.Bind<CostDisplayLocation>("UI", "CostDisplayLocation", CostDisplayLocation.RightSide, new ConfigDescription("Determines whether to prepend or append text to the resource cost in build UI. LeftSide or RightSide will prepend or append respectively.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 12 } })); showHUDKeyHints = Config.Bind<bool>("UI", "ShowHUDKeyHints", true, new ConfigDescription("Show KeyHints in build HUD.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 11 } })); showHoverKeyHints = Config.Bind<bool>("UI", "ShowHoverKeyHints", true, new ConfigDescription("Show KeyHints in hover text.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 10 } })); showHoverReplantHint = Config.Bind<bool>("UI", "ShowHoverReplantHint", true, new ConfigDescription("Show crop to be replanted upon harvest in hover text.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 9 } })); showGhostsDuringPlacement = Config.Bind<bool>("UI", "ShowGhostsDuringPlacement", true, new ConfigDescription("Show silhouettes of placement ghosts during placement.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 8 } })); showGridDirections = Config.Bind<bool>("UI", "ShowGridDirections", true, new ConfigDescription("Render lines indicating direction of rows and columns.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 7 } })); highlightRootPlacementGhost = Config.Bind<bool>("UI", "HighlightRootGhost", true, new ConfigDescription("Highlight the root placement ghost while bulk planting.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 6 } })); rootGhostHighlightColor = Config.Bind<Color>("UI", "RootGhostHighlightColor", Color.green, new ConfigDescription("Highlight color for root placement ghost when [UI]HighlightRootGhost is enabled.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 5 } })); rowStartColor = Config.Bind<Color>("UI", "RowStartColor", Color.blue, new ConfigDescription("Starting color for row direction when [UI]ShowGridDirections is enabled.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 4 } })); rowEndColor = Config.Bind<Color>("UI", "RowEndColor", Color.cyan, new ConfigDescription("Ending color for row direction when [UI]ShowGridDirections is enabled.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 3 } })); columnStartColor = Config.Bind<Color>("UI", "ColumnStartColor", Color.green, new ConfigDescription("Starting color for column direction when [UI]ShowGridDirections is enabled.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 2 } })); columnEndColor = Config.Bind<Color>("UI", "ColumnEndColor", Color.yellow, new ConfigDescription("Ending color for column direction when [UI]ShowGridDirections is enabled.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 1 } })); configFile.Save(); configFile.SaveOnConfigSet = true; rows.SettingChanged += PlantEasily.GridSizeChanged; columns.SettingChanged += PlantEasily.GridSizeChanged; maxConcurrentPlacements.SettingChanged += PlantEasily.GridSizeChanged; increaseXKey.SettingChanged += PlantEasily.KeybindsChanged; increaseYKey.SettingChanged += PlantEasily.KeybindsChanged; decreaseXKey.SettingChanged += PlantEasily.KeybindsChanged; decreaseYKey.SettingChanged += PlantEasily.KeybindsChanged; keyboardModifierKey.SettingChanged += PlantEasily.KeybindsChanged; gamepadModifierKey.SettingChanged += PlantEasily.KeybindsChanged; keyboardHarvestModifierKey.SettingChanged += PlantEasily.KeybindsChanged; showGridDirections.SettingChanged += delegate { GameObject gridRenderer = PlantEasily.gridRenderer; if (gridRenderer != null) { gridRenderer.SetActive(false); } }; rowStartColor.SettingChanged += PlantEasily.GridColorChanged; rowEndColor.SettingChanged += PlantEasily.GridColorChanged; columnStartColor.SettingChanged += PlantEasily.GridColorChanged; columnEndColor.SettingChanged += PlantEasily.GridColorChanged; } internal void BindPickableSpacingSettings() { Config.SaveOnConfigSet = false; Dictionary<string, float> dictionary = new Dictionary<string, float> { { "Pickable_Dandelion", 0.75f }, { "Pickable_Fiddlehead", 1f }, { "Pickable_Mushroom", 0.5f }, { "Pickable_Mushroom_blue", 0.5f }, { "Pickable_Mushroom_yellow", 0.5f }, { "Pickable_SmokePuff", 1f }, { "Pickable_Thistle", 0.75f }, { "BlueberryBush", 1.5f }, { "RaspberryBush", 1.5f }, { "CloudberryBush", 1f } }; foreach (PickableDB pickableRef in PlantEasily.pickableRefs) { float value; float num = (dictionary.TryGetValue(pickableRef.key, out value) ? value : DefaultGridSpacing); pickableRef.itemName = Localization.instance.Localize(pickableRef.Prefab.GetComponent<Pickable>().m_itemPrefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name); pickableRef.configEntry = Config.Bind<float>("Pickables", pickableRef.key + " GridSpacing", num, "Determines distance/spacing between " + pickableRef.itemName + " when planting."); pickableRef.configEntry.SettingChanged += PlantEasily.GridSpacingChanged; } dictionary.Clear(); Config.Save(); Config.SaveOnConfigSet = true; } } internal enum GridSnappingStyle { Intelligent, Legacy } internal enum HarvestStyle { LikeResources, AllResources } internal enum CostDisplayStyle { TotalCount, FullCost } internal enum CostDisplayLocation { LeftSide, RightSide } [HarmonyPatch] internal static class HoverTextPatches { private static string CurrentModifierKey { get { if (!ZInput.GamepadActive) { return PlantEasily.keyboardHarvestModifierKeyLocalized; } return PlantEasily.gamepadModifierKeyLocalized; } } private static string GetPrefabName(Pickable p) { return ((Object)p).name.Replace("(Clone)", ""); } [HarmonyPatch(typeof(Beehive), "GetHoverText")] private static void Postfix(Beehive __instance, ref string __result) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (PlantEasily.config.ModActive && PlantEasily.config.EnableBulkHarvest && PlantEasily.config.ShowHoverKeyHints) { bool num = !PrivateArea.CheckAccess(((Component)__instance).transform.position, 0f, false, false); bool flag = __instance.GetHoneyLevel() > 0; if (!num && flag) { string text = "\n[<b><color=yellow>" + CurrentModifierKey + "</color> + <color=yellow>$KEY_Use</color></b>] " + __instance.m_extractText + " (area)"; __result += Localization.instance.Localize(text); } } } [HarmonyPatch(typeof(Pickable), "GetHoverText")] private static void Postfix(Pickable __instance, ref string __result) { if (PlantEasily.config.ModActive && PlantEasily.config.EnableBulkHarvest && PlantEasily.config.ShowHoverKeyHints && !__instance.GetPicked() && __instance.GetEnabled != 0) { string text = "\n[<b><color=yellow>" + CurrentModifierKey + "</color> + <color=yellow>$KEY_Use</color></b>] $inventory_pickup (area)"; if (PlantEasily.config.ReplantOnHarvest && PlantEasily.config.ShowHoverReplantHint && PlantEasily.pickableNamesToReplantDB.ContainsKey(GetPrefabName(__instance))) { string text2 = (string.IsNullOrEmpty(PlantEasily.lastPlacementGhost) ? __instance.GetHoverName() : PlantEasily.pickableNamesToReplantDB[PlantEasily.lastPlacementGhost].pickable.GetHoverName()); text = text + "\nReplant as: <color=green>" + text2 + "</color>"; } __result += Localization.instance.Localize(text); } } } [HarmonyPatch] internal static class KeyHintPatches { private static GameObject keyboardHint; private static GameObject gamepadHint; private static readonly Dictionary<string, string> inputBindingPathToButtonDefNames = new Dictionary<string, string>(); internal static void UpdateKeyHintText() { if (Object.op_Implicit((Object)(object)keyboardHint)) { UpdateKeyboardHints(); } if (Object.op_Implicit((Object)(object)gamepadHint)) { UpdateGamepadHints(); } } [HarmonyPatch(typeof(KeyHints), "Start")] [HarmonyPostfix] private static void Start() { CreateKeyBoardHints(); } [HarmonyPatch(typeof(KeyHints), "ApplySettings")] [HarmonyPrefix] private static void ApplySettings() { UpdateKeyHintText(); } [HarmonyPatch(typeof(KeyHints), "SetGamePadBindings")] [HarmonyPostfix] private static void SetGamePadBindings() { if (!Object.op_Implicit((Object)(object)gamepadHint)) { CreateGamepadHints(); } UpdateGamepadHints(); } [HarmonyPatch(typeof(KeyHints), "UpdateHints")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> UpdateHintsTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: 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_0037: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(PlayerCustomizaton), "IsBarberGuiVisible", (Type[])null, (Type[])null), (string)null) }).ThrowIfInvalid("Could not patch KeyHints.UpdateHints() (BuildHUD Key Hints)").Advance(-2) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(KeyHintPatches), "SetKeyHintsActive", (Type[])null, (Type[])null)) }) .InstructionEnumeration(); } [HarmonyPatch(typeof(ZInput), "AddButton")] [HarmonyPrefix] private static void AddButton(string name, string path) { inputBindingPathToButtonDefNames[path] = name; } private static void CreateKeyBoardHints() { Transform val = KeyHints.m_instance.m_buildHints.transform.Find("Keyboard"); keyboardHint = Object.Instantiate<GameObject>(((Component)val.Find("Copy")).gameObject, val); ((Object)keyboardHint).name = "Resize Grid"; keyboardHint.transform.SetSiblingIndex(3); ((TMP_Text)((Component)keyboardHint.transform.GetChild(0)).GetComponent<TextMeshProUGUI>()).text = "Grid Size"; ((Component)keyboardHint.transform.GetChild(0)).GetComponent<LayoutElement>().preferredWidth = 75f; GameObject obj = Object.Instantiate<GameObject>(((Component)keyboardHint.transform.GetChild(1)).gameObject); Object.Instantiate<GameObject>(obj, keyboardHint.transform); Object.Instantiate<GameObject>(obj, keyboardHint.transform); Object.Instantiate<GameObject>(obj, keyboardHint.transform); UpdateKeyboardHints(); } private static void CreateGamepadHints() { Transform val = KeyHints.m_instance.m_buildHints.transform.Find("Gamepad"); gamepadHint = Object.Instantiate<GameObject>(((Component)(from x in ((Component)val).GetComponentsInChildren<Transform>() where ((Object)((Component)x).gameObject).name == "Text - Copy Alt1/2" select x).First()).gameObject, val); ((Object)gamepadHint).name = "Resize Grid"; gamepadHint.transform.SetSiblingIndex(3); } private static void UpdateKeyboardHints() { //IL_0005: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) PlantEasily.keyboardHarvestModifierKeyLocalized = KeyCodeToLocalizableString(PlantEasily.config.KeyboardHarvestModifierKey); ((TMP_Text)((Component)keyboardHint.transform.GetChild(1).GetChild(0)).GetComponent<TextMeshProUGUI>()).text = Localization.instance.Localize(KeyCodeToLocalizableString(PlantEasily.config.KeyboardModifierKey)); ((TMP_Text)((Component)keyboardHint.transform.GetChild(3).GetChild(0)).GetComponent<TextMeshProUGUI>()).text = Localization.instance.Localize(KeyCodeToLocalizableString(PlantEasily.config.DecreaseXKey)); ((TMP_Text)((Component)keyboardHint.transform.GetChild(4).GetChild(0)).GetComponent<TextMeshProUGUI>()).text = Localization.instance.Localize(KeyCodeToLocalizableString(PlantEasily.config.IncreaseYKey)); ((TMP_Text)((Component)keyboardHint.transform.GetChild(5).GetChild(0)).GetComponent<TextMeshProUGUI>()).text = Localization.instance.Localize(KeyCodeToLocalizableString(PlantEasily.config.IncreaseXKey)); ((TMP_Text)((Component)keyboardHint.transform.GetChild(6).GetChild(0)).GetComponent<TextMeshProUGUI>()).text = Localization.instance.Localize(KeyCodeToLocalizableString(PlantEasily.config.DecreaseYKey)); } private static string KeyCodeToLocalizableString(KeyCode keyCode) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) string text = ZInput.KeyCodeToPath(keyCode, false); string text2 = ZInput.instance.MapKeyFromPath(text); string text3 = text2.Substring(0, 1).ToLower() + text2.Substring(1); string value; string text4 = (inputBindingPathToButtonDefNames.TryGetValue(text, out value) ? value : ""); string text5 = ZInput.instance.GetBoundKeyString(text4, true); if (text3.EndsWith("Arrow")) { switch (text3) { case "upArrow": text5 = "↑"; break; case "rightArrow": text5 = "→"; break; case "downArrow": text5 = "↓"; break; case "leftArrow": text5 = "←"; break; } } string value2; if (text5 == "") { return ZInput.s_keyLocalizationMap.TryGetValue(text3, out value2) ? value2 : ZInput.KeyCodeToDisplayName(keyCode); } return text5; } private static void UpdateGamepadHints() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) string key = ZInput.KeyCodeToPath(PlantEasily.config.GamepadModifierKey, false); string text = inputBindingPathToButtonDefNames[key]; PlantEasily.gamepadModifierKeyLocalized = ZInput.instance.GetBoundKeyString(text, false); TextMeshProUGUI val = default(TextMeshProUGUI); if (gamepadHint.TryGetComponent<TextMeshProUGUI>(ref val)) { string[] array = new string[4] { "JoyDPadLeft", "JoyDPadUp", "JoyDPadRight", "JoyDPadDown" }; string full = ""; Array.ForEach(array, delegate(string gamepadKey) { full += ZInput.instance.GetBoundKeyString(gamepadKey, false); }); ((TMP_Text)val).text = "Resize Grid " + PlantEasily.gamepadModifierKeyLocalized + " + " + full; Localization.instance.Localize(((TMP_Text)val).transform); } } private static void SetKeyHintsActive() { bool active = PlantEasily.config.ShowHUDKeyHints && PlantEasily.HoldingCultivator; keyboardHint.SetActive(active); gamepadHint.SetActive(active); } } internal static class PlacementPatches { [HarmonyPatch(typeof(Player), "SetupPlacementGhost")] private static class PlayerSetupPlacementGhost { private static int placementRotation; private static void Prefix() { if (PlantEasily.config.ModActive && PlantEasily.HoldingCultivator) { placementRotation = Player.m_localPlayer.m_placeRotation; } } private static void Postfix(GameObject ___m_placementGhost, ref int ___m_placeRotation) { if (!PlantEasily.isPlanting) { PlantEasily.DestroyGhosts(); if (PlantEasily.config.ModActive && Object.op_Implicit((Object)(object)___m_placementGhost) && PlantEasily.HoldingCultivator && PlantEasily.IsPlantOrPickable(___m_placementGhost)) { ___m_placeRotation = placementRotation; PlantEasily.CreateGhosts(___m_placementGhost); } } } } [HarmonyPatch(typeof(Player), "UpdatePlacementGhost")] private static class PlayerUpdatePlacementGhost { private sealed class SnapPoint { internal Vector3 pos; internal Vector3 rowDir; internal Vector3 colDir; public SnapPoint(Vector3 p, Vector3 rd, Vector3 cd) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) pos = p; rowDir = rd; colDir = cd; base..ctor(); } } private static readonly Collider[] primaryObstructions = (Collider[])(object)new Collider[50]; private static readonly Collider[] secondaryObstructions = (Collider[])(object)new Collider[50]; private static Vector3 basePosition = Vector3.zero; private static Vector3 rowDirection = Vector3.zero; private static Vector3 columnDirection = Vector3.zero; private static Quaternion baseRotation = Quaternion.identity; private static Quaternion fixedRotation = Quaternion.identity; private static bool altPlacement; private static void UpdateGhosts(Vector3 playerPosition) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) altPlacement = PlantEasily.config.ForceAltPlacement || ((ZInput.IsNonClassicFunctionality() && ZInput.IsGamepadActive()) ? Player.m_localPlayer.m_altPlace : (ZInput.GetButton("AltPlace") || (ZInput.GetButton("JoyAltPlace") && !ZInput.GetButton("JoyRotate")))); basePosition = PlantEasily.placementGhost.transform.position; baseRotation = (fixedRotation = PlantEasily.placementGhost.transform.rotation); Vector3 eulerAngles = ((Quaternion)(ref fixedRotation)).eulerAngles; eulerAngles.y = Mathf.Round(eulerAngles.y / 90f) * 90f; ((Quaternion)(ref fixedRotation)).eulerAngles = eulerAngles; float pieceSpacing = PlantEasily.GetPieceSpacing(PlantEasily.placementGhost); ResetGridDirections(); if (!PlantEasily.config.SnapActive || !FindSnapPoints(pieceSpacing)) { if (PlantEasily.config.SnapActive) { ResetGridDirections(); } rowDirection = baseRotation * rowDirection * pieceSpacing; columnDirection = baseRotation * columnDirection * pieceSpacing; } void ResetGridDirections() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) rowDirection = (PlantEasily.config.GloballyAlignGridDirections ? Vector3.forward : Utils.DirectionXZ(basePosition - playerPosition)); columnDirection = Vector3.Cross(Vector3.up, rowDirection); } } private static bool FindSnapPoints(float pieceSpacing) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: 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_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) bool flag = false; bool flag2 = false; List<SnapPoint> list = new List<SnapPoint>(); Plant component = PlantEasily.placementGhost.GetComponent<Plant>(); int num = Physics.OverlapSphereNonAlloc(basePosition, pieceSpacing, primaryObstructions, PlantEasily.CollisionMask); int num2 = 0; for (int i = 0; i < num; i++) { if (flag2 && flag) { break; } Transform root = ((Component)primaryObstructions[i]).transform.root; if (!PlantEasily.IsPlantOrPickable(((Component)root).gameObject)) { continue; } if (++num2 > 8) { break; } float pieceSpacing2 = PlantEasily.GetPieceSpacing(((Component)root).gameObject); int num3 = Physics.OverlapSphereNonAlloc(root.position, pieceSpacing2, secondaryObstructions, PlantEasily.CollisionMask); int num4 = 0; for (int j = 0; j < num3; j++) { Transform root2 = ((Component)secondaryObstructions[j]).transform.root; if (!((Object)(object)root2 == (Object)(object)root) && PlantEasily.IsPlantOrPickable(((Component)root2).gameObject)) { if (++num4 > 8) { break; } if (Math.Round(Utils.DistanceXZ(root2.position, root.position), 2) <= Math.Round(pieceSpacing2, 2)) { flag2 = true; rowDirection = fixedRotation * Utils.DirectionXZ(root.position - root2.position) * pieceSpacing; columnDirection = Vector3.Cross(Vector3.up, rowDirection); flag = ValidateSnapPoints(list, root.position, component, gridDetected: true); break; } } } if (flag2 || flag) { continue; } rowDirection = Utils.DirectionXZ(basePosition - root.position) * pieceSpacing; if (!altPlacement) { float num5 = Mathf.Round(Vector3.Angle(Vector3.forward, rowDirection) / 22.5f) * 22.5f; if (Vector3.Angle(Vector3.right, rowDirection) > 90f) { num5 = 0f - num5; } rowDirection = fixedRotation * Quaternion.Euler(0f, num5, 0f) * Vector3.forward * pieceSpacing; } columnDirection = Vector3.Cross(Vector3.up, rowDirection); flag = ValidateSnapPoints(list, root.position, component, gridDetected: false); } if (flag) { SnapPoint snapPoint = list.OrderBy(delegate(SnapPoint o) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) Vector3 val2 = o.pos - basePosition; return ((Vector3)(ref val2)).sqrMagnitude; }).First(); Vector3 val = (PlantEasily.placementGhost.transform.position = snapPoint.pos); basePosition = val; if (PlantEasily.config.GridSnappingStyle == GridSnappingStyle.Intelligent) { rowDirection = snapPoint.rowDir; columnDirection = snapPoint.colDir; } return true; } return false; } private static bool ValidateSnapPoints(List<SnapPoint> snapPoints, Vector3 snapFromPos, Plant plant, bool gridDetected) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = new List<Vector3>(); int num = 16; if (gridDetected) { list.Add(snapFromPos + rowDirection); list.Add(snapFromPos - rowDirection); list.Add(snapFromPos + columnDirection); list.Add(snapFromPos - columnDirection); list.Add(snapFromPos + rowDirection - columnDirection); list.Add(snapFromPos + rowDirection + columnDirection); list.Add(snapFromPos - rowDirection - columnDirection); list.Add(snapFromPos - rowDirection + columnDirection); } else if (altPlacement) { list.Add(snapFromPos + rowDirection); list.Add(snapFromPos - rowDirection); } else { for (int i = 0; i < num; i++) { list.Add(snapFromPos + Quaternion.Euler(0f, 360f / (float)num * (float)i, 0f) * rowDirection); } } foreach (Vector3 item in list) { bool flag = false; bool flag2 = false; if (!PlantEasily.PositionHasCollisions(item) && (!Object.op_Implicit((Object)(object)plant) || PlantEasily.HasGrowSpace(plant, item))) { if (PlantEasily.config.GridSnappingStyle == GridSnappingStyle.Intelligent) { flag = PlantEasily.config.Rows > 1 && PlantEasily.PositionHasCollisions(item + rowDirection); flag2 = PlantEasily.config.Columns > 1 && PlantEasily.PositionHasCollisions(item + columnDirection); } snapPoints.Add(new SnapPoint(item, (!flag) ? rowDirection : (-rowDirection), (!flag2) ? columnDirection : (-columnDirection))); } } return snapPoints.Count > 0; } private static void CreateGrid(Player player) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: 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_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) Piece component = PlantEasily.placementGhost.GetComponent<Piece>(); int amount = component.m_resources[0].m_amount; int num = 0; if (PlantEasily.config.ShowGridDirections) { PlantEasily.gridRenderer.SetActive(PlantEasily.placementGhost.activeSelf); Vector3 val = basePosition + Vector3.up / 2f; PlantEasily.lineRenderers[0].SetPositions((Vector3[])(object)new Vector3[2] { val, val + rowDirection * (float)(PlantEasily.config.Rows - 1) }); PlantEasily.lineRenderers[1].SetPositions((Vector3[])(object)new Vector3[2] { val, val + columnDirection * (float)(PlantEasily.config.Columns - 1) }); } float y = default(float); for (int i = 0; i < PlantEasily.config.Rows; i++) { for (int j = 0; j < PlantEasily.config.Columns; j++) { int num2 = i * PlantEasily.config.Columns + j; if (num2 > PlantEasily.extraGhosts.Count) { break; } num += amount; component.m_resources[0].m_amount = num; GameObject val2 = ((num2 == 0) ? PlantEasily.placementGhost : PlantEasily.extraGhosts[num2 - 1]); Vector3 val3 = ((num2 == 0) ? basePosition : (basePosition + rowDirection * (float)i + columnDirection * (float)j)); Heightmap.GetHeight(val3, ref y); val3.y = y; val2.transform.position = val3; val2.transform.rotation = PlantEasily.placementGhost.transform.rotation; PlantEasily.Status placementStatus = PlantEasily.Status.Healthy; if (!player.m_noPlacementCost && !player.HaveRequirements(component, (RequirementMode)0)) { placementStatus = PlantEasily.Status.LackResources; } PlantEasily.SetPlacementGhostStatus(val2, num2, PlantEasily.CheckPlacementStatus(val2, placementStatus)); } } component.m_resources[0].m_amount = amount; } private static void Prefix(Player __instance) { if (PlantEasily.config.ModActive && Object.op_Implicit((Object)(object)PlantEasily.placementGhost) && (PlantEasily.ghostPlacementStatus.Count == 0 || (PlantEasily.extraGhosts.Count == 0 && (PlantEasily.config.Rows != 1 || PlantEasily.config.Columns != 1)))) { __instance.SetupPlacementGhost(); } } private static void Postfix(Player __instance) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) if (PlantEasily.config.ModActive && Object.op_Implicit((Object)(object)PlantEasily.placementGhost) && !PlantEasily.isPlanting) { for (int i = 0; i < PlantEasily.extraGhosts.Count; i++) { PlantEasily.extraGhosts[i].SetActive(PlantEasily.placementGhost.activeSelf); } UpdateGhosts(((Component)__instance).transform.position); CreateGrid(__instance); } } } [HarmonyPatch(typeof(Player), "TryPlacePiece")] private static class PlayerTryPlacePiece { private static bool Prefix(Player __instance, Piece piece, ref bool __result) { if (!PlantEasily.config.ModActive || !Object.op_Implicit((Object)(object)piece) || !PlantEasily.HoldingCultivator || !PlantEasily.IsPlantOrPickable(((Component)piece).gameObject)) { return true; } if (PlantEasily.config.PreventInvalidPlanting) { int num = (int)PlantEasily.CheckPlacementStatus(__instance.m_placementGhost); if (num > 1) { ((Character)__instance).Message((MessageType)2, PlantEasily.statusMessage[num], 0, (Sprite)null); return __result = false; } } if (PlantEasily.config.PreventPartialPlanting) { using IEnumerator<int> enumerator = (from i in PlantEasily.ghostPlacementStatus where i switch { PlantEasily.Status.LackResources => !__instance.m_noPlacementCost, PlantEasily.Status.Healthy => false, _ => true, } select i into v select (int)v).GetEnumerator(); if (enumerator.MoveNext()) { int current = enumerator.Current; ((Character)__instance).Message((MessageType)2, PlantEasily.statusMessage[current], 0, (Sprite)null); return __result = false; } } return true; } } [HarmonyPatch(typeof(Player), "PlacePiece")] private static class PlayerPlacePiece { private static int placementRotation; private static void Prefix(Player __instance) { placementRotation = __instance.m_placeRotation; } private static void Postfix(Player __instance, Piece piece) { if (!PlantEasily.config.ModActive || !Object.op_Implicit((Object)(object)piece) || !PlantEasily.HoldingCultivator || !PlantEasily.IsPlantOrPickable(((Component)piece).gameObject)) { return; } __instance.m_placeRotation = placementRotation; ItemData rightItem = ((Humanoid)__instance).GetRightItem(); int num = PlantEasily.extraGhosts.Count; for (int i = 0; i < PlantEasily.extraGhosts.Count; i++) { if (PlantEasily.ghostPlacementStatus[i + 1] != 0 && (PlantEasily.ghostPlacementStatus[i + 1] != PlantEasily.Status.LackResources || !__instance.m_noPlacementCost) && (PlantEasily.config.PreventInvalidPlanting || PlantEasily.ghostPlacementStatus[i + 1] <= PlantEasily.Status.LackResources)) { num--; } else { PlantEasily.currentValidGhosts.Add(PlantEasily.extraGhosts[i]); } } ((MonoBehaviour)PlantEasily.pluginInstance).StartCoroutine("BulkPlanting", (object)((Component)piece).gameObject); num = ((!__instance.m_noPlacementCost) ? num : 0); for (int j = 0; j < num; j++) { __instance.ConsumeResources(piece.m_resources, 0, -1, 1); if (PlantEasily.config.UseStamina) { ((Character)__instance).UseStamina(__instance.GetBuildStamina()); } if (PlantEasily.config.UseDurability && rightItem.m_shared.m_useDurability) { rightItem.m_durability -= __instance.GetPlaceDurability(rightItem); } } } } } [HarmonyPatch] internal static class InputPatches { [HarmonyPatch(typeof(Player), "UpdateBuildGuiInput")] private static void Prefix(Player __instance) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut val = PlantEasily.config.EnableModKey; if (((KeyboardShortcut)(ref val)).IsDown()) { PlantEasily.config.ModActive = !PlantEasily.config.ModActive; PlantEasily.Dbgl($"modActive was {!PlantEasily.config.ModActive} setting to {PlantEasily.config.ModActive}", forceLog: false, (LogLevel)16); ((Character)__instance).Message((MessageType)1, $"PlantEasily.ModActive: {PlantEasily.config.ModActive}", 0, (Sprite)null); if (PlantEasily.HoldingCultivator) { __instance.SetupPlacementGhost(); } } val = PlantEasily.config.EnableSnappingKey; if (((KeyboardShortcut)(ref val)).IsDown()) { PlantEasily.config.SnapActive = !PlantEasily.config.SnapActive; PlantEasily.Dbgl($"snapActive was {!PlantEasily.config.SnapActive} setting to {PlantEasily.config.SnapActive}", forceLog: false, (LogLevel)16); ((Character)__instance).Message((MessageType)1, $"PlantEasily.SnapActive: {PlantEasily.config.SnapActive}", 0, (Sprite)null); } val = PlantEasily.config.ToggleAutoReplantKey; if (((KeyboardShortcut)(ref val)).IsDown()) { PlantEasily.config.ReplantOnHarvest = !PlantEasily.config.ReplantOnHarvest; PlantEasily.Dbgl($"replantOnHarvest was {!PlantEasily.config.ReplantOnHarvest} setting to {PlantEasily.config.ReplantOnHarvest}", forceLog: false, (LogLevel)16); ((Character)__instance).Message((MessageType)1, $"PlantEasily.ReplantOnHarvest: {PlantEasily.config.ReplantOnHarvest}", 0, (Sprite)null); } if (ZInput.GetKey(PlantEasily.config.KeyboardModifierKey, false) || ZInput.GetKey(PlantEasily.config.GamepadModifierKey, false)) { if (ZInput.GetKeyDown(PlantEasily.config.IncreaseXKey, false) || ZInput.GetButtonDown("JoyDPadRight")) { PlantEasily.config.Columns++; } if (ZInput.GetKeyDown(PlantEasily.config.IncreaseYKey, false) || ZInput.GetButtonDown("JoyDPadUp")) { PlantEasily.config.Rows++; } if (ZInput.GetKeyDown(PlantEasily.config.DecreaseXKey, false) || ZInput.GetButtonDown("JoyDPadLeft")) { PlantEasily.config.Columns--; } if (ZInput.GetKeyDown(PlantEasily.config.DecreaseYKey, false) || ZInput.GetButtonDown("JoyDPadDown")) { PlantEasily.config.Rows--; } } } [HarmonyPatch(typeof(HotkeyBar), "Update")] [HarmonyPatch(typeof(Player), "StartGuardianPower")] private static void Prefix(ref bool __runOriginal) { __runOriginal = !PlantEasily.OverrideGamepadInput; } } [HarmonyPatch] internal static class InteractPatches { private static string GetPrefabName(Interactable i) { return ((object)i).ToString().Replace("(Clone) (Pickable)", ""); } [HarmonyPatch(typeof(Player), "Interact")] private static void Prefix(Player __instance, GameObject go, bool hold, bool alt) { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_011b: Unknown result type (might be due to invalid IL or missing references) if (!PlantEasily.config.ModActive || (!PlantEasily.config.EnableBulkHarvest && !PlantEasily.config.ReplantOnHarvest) || ((Character)__instance).InAttack() || ((Character)__instance).InDodge() || (hold && Time.time - __instance.m_lastHoverInteractTime < 0.2f)) { return; } Interactable componentInParent = go.GetComponentInParent<Interactable>(); if (componentInParent == null) { return; } if (Object.op_Implicit((Object)(object)((componentInParent is Pickable) ? componentInParent : null)) && PlantEasily.config.ReplantOnHarvest && PlantEasily.pickableNamesToReplantDB.ContainsKey(GetPrefabName(componentInParent))) { PlantEasily.instanceIDS.Add(((Object)(Pickable)componentInParent).GetInstanceID()); } if (!PlantEasily.config.EnableBulkHarvest || (!ZInput.GetKey(PlantEasily.config.KeyboardHarvestModifierKey, false) && !ZInput.GetKey(PlantEasily.config.GamepadModifierKey, false)) || (!Object.op_Implicit((Object)(object)((componentInParent is Pickable) ? componentInParent : null)) && !Object.op_Implicit((Object)(object)((componentInParent is Beehive) ? componentInParent : null)))) { return; } foreach (Interactable item in PlantEasily.FindResourcesInRadius(go)) { if (PlantEasily.config.ReplantOnHarvest && PlantEasily.pickableNamesToReplantDB.ContainsKey(GetPrefabName(item))) { PlantEasily.instanceIDS.Add(((Object)(Pickable)item).GetInstanceID()); } item.Interact((Humanoid)(object)__instance, hold, alt); } } [HarmonyPatch(typeof(Pickable), "SetPicked")] private static void Prefix(Pickable __instance, bool picked) { if (!PlantEasily.config.ModActive || !PlantEasily.config.ReplantOnHarvest || PlantEasily.instanceIDS.Count == 0 || !picked) { return; } int instanceID = ((Object)__instance).GetInstanceID(); if (PlantEasily.instanceIDS.Contains(instanceID)) { PlantEasily.instanceIDS.Remove(instanceID); Player localPlayer = Player.m_localPlayer; string key = (string.IsNullOrEmpty(PlantEasily.lastPlacementGhost) ? PlantEasily.pickableNamesToReplantDB[((Object)__instance).name.Replace("(Clone)", "")].plantName : PlantEasily.pickableNamesToReplantDB[PlantEasily.lastPlacementGhost].plantName); Piece component = PlantEasily.prefabRefs[key].GetComponent<Piece>(); if (localPlayer.HaveRequirements(component, (RequirementMode)0) || Player.m_localPlayer.m_noPlacementCost) { PlantEasily.PlacePiece(localPlayer, ((Component)__instance).gameObject, ((Component)component).gameObject); localPlayer.ConsumeResources(component.m_resources, 0, -1, 1); } } } } [HarmonyPatch(typeof(ZNetScene), "Awake")] internal static class ModInitPatches { private static List<GameObject> unfilteredPrefabs; [HarmonyPriority(800)] private static void Prefix(ZNetScene __instance) { unfilteredPrefabs = ((PlantEasily.prefabRefs.Count == 0) ? new List<GameObject>(__instance.m_prefabs) : null); if (unfilteredPrefabs == null) { return; } List<GameObject> list = new List<GameObject>(__instance.m_prefabs); Plant val = default(Plant); list.RemoveAll((GameObject go) => !go.TryGetComponent<Plant>(ref val) || val.m_grownPrefabs.Any((GameObject gp) => !Object.op_Implicit((Object)(object)gp.GetComponent<Pickable>()) || Object.op_Implicit((Object)(object)gp.GetComponent<Vine>()) || Object.op_Implicit((Object)(object)gp.GetComponent<TreeBase>()))); PlantEasily.Dbgl($"({list.Count}) vanilla crops detected", forceLog: false, (LogLevel)16); foreach (GameObject item in list) { ReplantDB replantDB = new ReplantDB(item); PlantEasily.pickableNamesToReplantDB.Add(((Object)replantDB.pickable).name, replantDB); } } [HarmonyPriority(0)] private static void Postfix(ZNetScene __instance) { if (unfilteredPrefabs == null) { return; } List<GameObject> list = new List<GameObject>(unfilteredPrefabs); list.RemoveAll((GameObject go) => !Object.op_Implicit((Object)(object)go.GetComponent<Pickable>()) || !Object.op_Implicit((Object)(object)go.GetComponent<Piece>())); list.ForEach(delegate(GameObject go) { PlantEasily.pickableRefs.Add(new PickableDB(((Object)go).name)); }); PlantEasily.Dbgl($"({list.Count}) plantable pickables detected", forceLog: false, (LogLevel)16); List<GameObject> list2 = __instance.m_prefabs.Except(unfilteredPrefabs).ToList(); Plant val = default(Plant); list2.RemoveAll((GameObject go) => !go.TryGetComponent<Plant>(ref val) || val.m_grownPrefabs.Any((GameObject gp) => !Object.op_Implicit((Object)(object)gp.GetComponent<Pickable>()) || Object.op_Implicit((Object)(object)gp.GetComponent<Vine>()) || Object.op_Implicit((Object)(object)gp.GetComponent<TreeBase>()))); PlantEasily.Dbgl($"({list2.Count}) modded crops detected", forceLog: false, (LogLevel)16); foreach (GameObject item in list2) { ReplantDB replantDB = new ReplantDB(item); PlantEasily.pickableNamesToReplantDB.Add(((Object)replantDB.pickable).name, replantDB); } PlantEasily.InitPrefabRefs(); unfilteredPrefabs.Clear(); } } [HarmonyPatch] internal static class UIPatches { [HarmonyPatch(typeof(InventoryGui), "SetupRequirement")] [HarmonyPriority(0)] private static void Postfix(Transform elementRoot, Requirement req) { if (PlantEasily.extraGhosts.Count >= 1 && PlantEasily.config.ShowCost) { TMP_Text component = ((Component)((Component)elementRoot).transform.Find("res_amount")).GetComponent<TMP_Text>(); int count = PlantEasily.ghostPlacementStatus.Count; string text = ((PlantEasily.config.CostDisplayStyle != 0) ? $"({req.m_amount * count})" : ((PlantEasily.config.CostDisplayLocation == CostDisplayLocation.LeftSide) ? $"{count}x" : $"x{count}")); component.text = ((PlantEasily.config.CostDisplayLocation == CostDisplayLocation.LeftSide) ? (text + component.text) : (component.text + text)); } } } [BepInPlugin("advize.PlantEasily", "PlantEasily", "2.0.2")] public sealed class PlantEasily : BaseUnityPlugin { internal enum Status { Healthy, LackResources, NotCultivated, WrongBiome, NoSpace, NoSun, Invalid, NoAttachPiece, TooHot, TooCold } public const string PluginID = "advize.PlantEasily"; public const string PluginName = "PlantEasily"; public const string Version = "2.0.2"; private static readonly ManualLogSource PELogger = new ManualLogSource(" PlantEasily"); internal static ModConfig config; internal static PlantEasily pluginInstance; internal static readonly Dictionary<string, GameObject> prefabRefs = new Dictionary<string, GameObject>(); internal static Dictionary<string, ReplantDB> pickableNamesToReplantDB = new Dictionary<string, ReplantDB>(); internal static List<PickableDB> pickableRefs = new List<PickableDB>(); internal static GameObject placementGhost; internal static string lastPlacementGhost = ""; internal static readonly List<GameObject> extraGhosts = new List<GameObject>(); internal static readonly List<GameObject> currentValidGhosts = new List<GameObject>(); internal static readonly List<Status> ghostPlacementStatus = new List<Status>(); internal static readonly List<int> instanceIDS = new List<int>(); internal static string keyboardHarvestModifierKeyLocalized; internal static string gamepadModifierKeyLocalized; internal static bool isPlanting = false; internal static GameObject gridRenderer; internal static List<LineRenderer> lineRenderers = new List<LineRenderer>(); internal static readonly int CollisionMask = LayerMask.GetMask(new string[6] { "Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "item" }); internal static readonly Dictionary<int, string> statusMessage = new Dictionary<int, string> { { 1, "$msg_missingrequirement" }, { 2, "$piece_plant_notcultivated" }, { 3, "$piece_plant_wrongbiome" }, { 4, "$piece_plant_nospace" }, { 5, "$piece_plant_nosun" }, { 6, "$msg_invalidplacement" }, { 7, "$piece_plant_nowall" }, { 8, "$piece_plant_toohot" }, { 9, "$piece_plant_toocold" } }; internal static bool HoldingCultivator { get { Player localPlayer = Player.m_localPlayer; return ((localPlayer == null) ? null : ((Humanoid)localPlayer).GetRightItem()?.m_shared.m_name) == "$item_cultivator"; } } internal static bool OverrideGamepadInput { get { //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)placementGhost)) { return ZInput.GetKey(config.GamepadModifierKey, false); } return false; } } public void Awake() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 Logger.Sources.Add((ILogSource)(object)PELogger); if ((int)SystemInfo.graphicsDeviceType == 4) { Dbgl("This mod is client-side only and is not needed on a dedicated server. Plugin patches will not be applied.", forceLog: true, (LogLevel)4); return; } config = new ModConfig(((BaseUnityPlugin)this).Config); pluginInstance = this; Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "advize.PlantEasily"); } internal static bool IsPlantOrPickable(GameObject go) { if (!Object.op_Implicit((Object)(object)go.GetComponent<Plant>())) { return Object.op_Implicit((Object)(object)go.GetComponent<Pickable>()); } return true; } internal static void GridSizeChanged(object sender, EventArgs e) { DestroyGhosts(); } internal static void KeybindsChanged(object sender, EventArgs e) { KeyHintPatches.UpdateKeyHintText(); } internal static void GridSpacingChanged(object sender, EventArgs e) { PickableDB.InitPickableSpacingConfig(); } internal static void GridColorChanged(object sender, EventArgs e) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)gridRenderer)) { lineRenderers[0].startColor = config.RowStartColor; lineRenderers[0].endColor = config.RowEndColor; lineRenderers[1].startColor = config.ColumnStartColor; lineRenderers[1].endColor = config.ColumnEndColor; } } internal static void DestroyGhosts() { if (extraGhosts.Count > 0) { foreach (GameObject extraGhost in extraGhosts) { Object.Destroy((Object)(object)extraGhost); } extraGhosts.Clear(); } ghostPlacementStatus.Clear(); GameObject obj = gridRenderer; if (obj != null) { obj.SetActive(false); } } internal static void CreateGhosts(GameObject rootGhost) { //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < config.Rows; i++) { for (int j = 0; j < config.Columns; j++) { if (i == 0 && j == 0) { placementGhost = rootGhost; lastPlacementGhost = (from kvp in pickableNamesToReplantDB where kvp.Value.plantName == ((Object)rootGhost).name select kvp.Key).FirstOrDefault(); ghostPlacementStatus.Add(Status.Healthy); continue; } if (extraGhosts.Count >= config.MaxConcurrentPlacements - 1) { return; } ZNetView.m_forceDisableInit = true; GameObject val = Object.Instantiate<GameObject>(rootGhost); ZNetView.m_forceDisableInit = false; ((Object)val).name = ((Object)rootGhost).name; int layer = LayerMask.NameToLayer("ghost"); Transform[] componentsInChildren = val.GetComponentsInChildren<Transform>(); for (int k = 0; k < componentsInChildren.Length; k++) { ((Component)componentsInChildren[k]).gameObject.layer = layer; } val.transform.position = rootGhost.transform.position; val.transform.localScale = rootGhost.transform.localScale; extraGhosts.Add(val); ghostPlacementStatus.Add(Status.Healthy); } } } internal static bool HasGrowSpace(Plant plant, Vector3 position) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return Physics.OverlapSphere(position, plant.m_growRadius, Plant.m_spaceMask).Length == 0; } internal static bool PositionHasCollisions(Vector3 position) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) return Physics.CheckCapsule(position, position + Vector3.up * 0.1f, Mathf.Epsilon, CollisionMask); } internal static float GetPieceSpacing(GameObject go) { float num = 0f; bool flag = false; Plant component = go.GetComponent<Plant>(); if (Object.op_Implicit((Object)(object)component)) { GameObject[] grownPrefabs = component.m_grownPrefabs; List<GameObject> list = new List<GameObject>(1 + grownPrefabs.Length); list.Add(go); list.AddRange(grownPrefabs); List<GameObject> list2 = list; flag = list2.Any((GameObject x) => Object.op_Implicit((Object)(object)x.GetComponent<TreeBase>())); if (config.MinimizeGridSpacing && !flag) { for (int i = 0; i < list2.Count; i++) { CapsuleCollider[] componentsInChildren = list2[i].GetComponentsInChildren<CapsuleCollider>(); foreach (CapsuleCollider val in componentsInChildren) { num = Mathf.Max(num, val.radius); } } } num += (flag ? config.ExtraSaplingSpacing : config.ExtraCropSpacing); } return (flag ? (component.m_growRadius * 2.2f) : ((component?.m_growRadius * (config.MinimizeGridSpacing ? 1.1f : 2f)) ?? PickableSnapRadius(go.GetComponent<Piece>()))) + num; } private static float PickableSnapRadius(Piece p) { if (p == null || !(p.m_harvestRadius > 0f)) { return config.DefaultGridSpacing; } return p.m_harvestRadius; } internal static void SetPlacementGhostStatus(GameObject ghost, int index, Status placementStatus) { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_0085: Unknown result type (might be due to invalid IL or missing references) ghost.GetComponent<Piece>().SetInvalidPlacementHeightlight(placementStatus != Status.Healthy); if (ghostPlacementStatus.Count <= index) { return; } ghostPlacementStatus[index] = placementStatus; if (index == 0 && placementStatus == Status.Healthy) { if (config.HighlightRootPlacementGhost && ghostPlacementStatus.Count > 1) { MaterialMan.instance.SetValue<Color>(ghost.gameObject, ShaderProps._Color, config.RootGhostHighlightColor); MaterialMan.instance.SetValue<Color>(ghost.gameObject, ShaderProps._EmissionColor, config.RootGhostHighlightColor * 0.7f); } Player.m_localPlayer.m_placementStatus = (PlacementStatus)0; } } internal static Status CheckPlacementStatus(GameObject ghost, Status placementStatus = Status.Healthy) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_005d: 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) //IL_0079: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Invalid comparison between Unknown and I4 //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Invalid comparison between Unknown and I4 //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Invalid comparison between Unknown and I4 Piece component = ghost.GetComponent<Piece>(); Plant component2 = ghost.GetComponent<Plant>(); Vector3 position = ghost.transform.position; Heightmap val = Heightmap.FindHeightmap(position); if ((Object)(object)val == (Object)null) { return Status.Invalid; } bool num = component2?.m_needCultivatedGround ?? component.m_cultivatedGroundOnly; Biome val2 = component2?.m_biome ?? component.m_onlyInBiome; Biome biome = val.GetBiome(position, 0.02f, false); if (num && Object.op_Implicit((Object)(object)val) && !val.IsCultivated(position)) { placementStatus = Status.NotCultivated; } if ((int)val2 != 0 && (biome & val2) == 0) { placementStatus = Status.WrongBiome; } if (Object.op_Implicit((Object)(object)component2)) { if (!HasGrowSpace(component2, position)) { placementStatus = Status.NoSpace; } if (component2.HaveRoof()) { placementStatus = Status.NoSun; } if ((double)component2.m_attachDistance > 0.0 && !component2.GetClosestAttachPosRot(ref component2.m_attachPos, ref component2.m_attachRot, ref component2.m_attachNormal)) { placementStatus = Status.NoAttachPiece; } if (!component2.m_tolerateHeat && (int)biome == 32 && !ShieldGenerator.IsInsideShield(position)) { placementStatus = Status.TooHot; } if (!component2.m_tolerateCold && ((int)biome == 64 || (int)biome == 4) && !ShieldGenerator.IsInsideShield(position)) { placementStatus = Status.TooCold; } } else if (config.PreventOverlappingPlacements && PositionHasCollisions(position)) { placementStatus = Status.NoSpace; } return placementStatus; } internal static List<Interactable> FindResourcesInRadius(GameObject rootInteractable) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) List<Interactable> list = new List<Interactable>(); Collider[] array = Physics.OverlapSphere(rootInteractable.transform.root.position, config.HarvestRadius, CollisionMask); foreach (Collider obj in array) { Pickable componentInParent = ((Component)obj).GetComponentInParent<Pickable>(); Beehive componentInParent2 = ((Component)obj).GetComponentInParent<Beehive>(); if (!Object.op_Implicit((Object)(object)componentInParent) && !Object.op_Implicit((Object)(object)componentInParent2)) { continue; } GameObject val = ((componentInParent != null) ? ((Component)componentInParent).gameObject : null) ?? ((Component)componentInParent2).gameObject; if ((Object)(object)val.transform.root != (Object)(object)rootInteractable.transform.root && (config.HarvestStyle != 0 || !(((Object)val.transform.root).name != ((Object)rootInteractable.transform.root).name)) && (!Object.op_Implicit((Object)(object)componentInParent2) || componentInParent2.GetHoneyLevel() >= 1)) { Interactable val2 = (Interactable)(object)componentInParent; Interactable item = (Interactable)(((object)val2) ?? ((object)componentInParent2)); if (!list.Contains(item)) { list.Add(item); } } } return list; } internal static void PlacePiece(Player player, GameObject go, GameObject piecePrefab) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) Vector3 position = go.transform.position; Quaternion val = (config.RandomizeRotation ? Quaternion.Euler(0f, 22.5f * (float)Random.Range(0, 16), 0f) : go.transform.rotation); go.SetActive(false); TerrainModifier.SetTriggerOnPlaced(true); GameObject obj = Object.Instantiate<GameObject>(piecePrefab, position, val); TerrainModifier.SetTriggerOnPlaced(false); obj.GetComponent<Piece>().SetCreator(player.GetPlayerID()); Game.instance.IncrementPlayerStat((PlayerStatType)2, 1f); ((Character)player).RaiseSkill((SkillType)106, 1f); } internal IEnumerator BulkPlanting(GameObject piecePrefab) { Player player = Player.m_localPlayer; isPlanting = true; int count = 0; if (config.ShowGhostsDuringPlacement) { extraGhosts.Except(currentValidGhosts).ToList().ForEach(delegate(GameObject ig) { Array.ForEach(ig.GetComponentsInChildren<Renderer>(), delegate(Renderer r) { r.enabled = false; }); }); currentValidGhosts.ForEach(delegate(GameObject vg) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) MaterialMan.instance.SetValue<Color>(vg, ShaderProps._Color, Color.gray); }); } else { extraGhosts.ForEach(delegate(GameObject eg) { Array.ForEach(eg.GetComponentsInChildren<Renderer>(), delegate(Renderer r) { r.enabled = false; }); }); } foreach (GameObject currentValidGhost in currentValidGhosts) { count++; PlacePiece(player, currentValidGhost, piecePrefab); if (count % config.BulkPlantingBatchSize == 0) { yield return null; } } currentValidGhosts.Clear(); isPlanting = false; player.SetupPlacementGhost(); } internal static void InitPrefabRefs() { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown Dbgl("InitPrefabRefs", forceLog: false, (LogLevel)16); foreach (string key in pickableNamesToReplantDB.Keys) { prefabRefs.Add(key, null); prefabRefs.Add(pickableNamesToReplantDB[key].plantName, null); } pickableRefs.ForEach(delegate(PickableDB s) { prefabRefs.Add(s.key, null); }); Object[] array = Resources.FindObjectsOfTypeAll(typeof(GameObject)); for (int i = 0; i < array.Length; i++) { GameObject val = (GameObject)array[i]; if (prefabRefs.ContainsKey(((Object)val).name)) { prefabRefs[((Object)val).name] = val; if (!prefabRefs.Any((KeyValuePair<string, GameObject> key) => !Object.op_Implicit((Object)(object)key.Value))) { Dbgl("Found all prefab references", forceLog: false, (LogLevel)16); break; } } } InitLineRenderers(); PickableDB.InitPickableSpacingConfig(); } private static void InitLineRenderers() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown Material material = Resources.FindObjectsOfTypeAll<Material>().First((Material m) => ((Obj