using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
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("1.9.2.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.9.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<bool> enableDebugMessages;
private readonly ConfigEntry<int> rows;
private readonly ConfigEntry<int> columns;
private readonly ConfigEntry<bool> modActive;
private readonly ConfigEntry<bool> snapActive;
private readonly ConfigEntry<bool> preventPartialPlanting;
private readonly ConfigEntry<bool> preventInvalidPlanting;
private readonly ConfigEntry<bool> randomizeRotation;
private readonly ConfigEntry<bool> useStamina;
private readonly ConfigEntry<bool> useDurability;
private readonly ConfigEntry<float> extraCropSpacing;
private readonly ConfigEntry<float> extraSaplingSpacing;
private readonly ConfigEntry<GridSnappingStyle> gridSnappingStyle;
private readonly ConfigEntry<bool> standardizeGridRotations;
private readonly ConfigEntry<bool> minimizeGridSpacing;
private readonly ConfigEntry<bool> globallyAlignGridDirections;
private readonly ConfigEntry<int> maxConcurrentPlacements;
private readonly ConfigEntry<float> pickableSnapRadius;
private readonly ConfigEntry<float> berryBushSnapRadius;
private readonly ConfigEntry<float> mushroomSnapRadius;
private readonly ConfigEntry<float> flowerSnapRadius;
private readonly ConfigEntry<bool> preventOverlappingPlacements;
private readonly ConfigEntry<bool> enableBulkHarvest;
private readonly ConfigEntry<HarvestStyle> harvestStyle;
private readonly ConfigEntry<float> harvestRadius;
private readonly ConfigEntry<bool> replantOnHarvest;
private readonly ConfigEntry<KeyboardShortcut> enableModKey;
private readonly ConfigEntry<KeyboardShortcut> enableSnappingKey;
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<KeyboardShortcut> toggleAutoReplantKey;
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;
internal bool EnableDebugMessages => enableDebugMessages.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 ModActive
{
get
{
return modActive.Value;
}
set
{
((ConfigEntryBase)modActive).BoxedValue = value;
}
}
internal bool SnapActive
{
get
{
return snapActive.Value;
}
set
{
((ConfigEntryBase)snapActive).BoxedValue = value;
}
}
internal float PickableSnapRadius => pickableSnapRadius.Value;
internal float BerryBushSnapRadius => berryBushSnapRadius.Value;
internal float MushroomSnapRadius => mushroomSnapRadius.Value;
internal float FlowerSnapRadius => flowerSnapRadius.Value;
internal bool PreventOverlappingPlacements => preventOverlappingPlacements.Value;
internal bool PreventPartialPlanting => preventPartialPlanting.Value;
internal bool PreventInvalidPlanting => preventInvalidPlanting.Value;
internal bool RandomizeRotation => randomizeRotation.Value;
internal bool UseStamina => useStamina.Value;
internal bool UseDurability => useDurability.Value;
internal float ExtraCropSpacing => extraCropSpacing.Value;
internal float ExtraSaplingSpacing => extraSaplingSpacing.Value;
internal GridSnappingStyle GridSnappingStyle => gridSnappingStyle.Value;
internal bool StandardizeGridRotations => standardizeGridRotations.Value;
internal bool MinimizeGridSpacing => minimizeGridSpacing.Value;
internal bool GloballyAlignGridDirections => globallyAlignGridDirections.Value;
internal int MaxConcurrentPlacements => maxConcurrentPlacements.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 KeyboardShortcut EnableModKey => enableModKey.Value;
internal KeyboardShortcut EnableSnappingKey => enableSnappingKey.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 KeyboardShortcut ToggleAutoReplantKey => toggleAutoReplantKey.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 ModConfig(ConfigFile configFile)
{
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Expected O, but got Unknown
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Expected O, but got Unknown
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Expected O, but got Unknown
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Expected O, but got Unknown
//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
//IL_02e3: Expected O, but got Unknown
//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
//IL_03b8: Expected O, but got Unknown
//IL_0456: Unknown result type (might be due to invalid IL or missing references)
//IL_0460: Expected O, but got Unknown
//IL_0480: Unknown result type (might be due to invalid IL or missing references)
//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
//IL_04ae: Expected O, but got Unknown
//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
//IL_04fc: Expected O, but got Unknown
//IL_051c: Unknown result type (might be due to invalid IL or missing references)
//IL_0540: Unknown result type (might be due to invalid IL or missing references)
//IL_054a: Expected O, but got Unknown
//IL_056a: Unknown result type (might be due to invalid IL or missing references)
//IL_058e: Unknown result type (might be due to invalid IL or missing references)
//IL_0598: Expected O, but got Unknown
//IL_05b8: Unknown result type (might be due to invalid IL or missing references)
//IL_05dc: Unknown result type (might be due to invalid IL or missing references)
//IL_05e6: Expected O, but got Unknown
//IL_0606: Unknown result type (might be due to invalid IL or missing references)
//IL_062a: Unknown result type (might be due to invalid IL or missing references)
//IL_0634: Expected O, but got Unknown
//IL_0654: Unknown result type (might be due to invalid IL or missing references)
//IL_0678: Unknown result type (might be due to invalid IL or missing references)
//IL_0682: Expected O, but got Unknown
//IL_06a2: Unknown result type (might be due to invalid IL or missing references)
//IL_06c6: Unknown result type (might be due to invalid IL or missing references)
//IL_06d0: Expected O, but got Unknown
//IL_06f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0714: Unknown result type (might be due to invalid IL or missing references)
//IL_071e: Expected O, but got Unknown
//IL_073a: Unknown result type (might be due to invalid IL or missing references)
//IL_075e: Unknown result type (might be due to invalid IL or missing references)
//IL_0768: Expected O, but got Unknown
//IL_079f: Unknown result type (might be due to invalid IL or missing references)
//IL_07a9: Expected O, but got Unknown
Config = configFile;
configFile.SaveOnConfigSet = false;
enableDebugMessages = Config.Bind<bool>("General", "EnableDebugMessages", false, "Enable mod debug messages in console.");
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 = 8
}
}));
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 = 7
}
}));
modActive = Config.Bind<bool>("General", "ModActive", true, new ConfigDescription("Enables all mod features.", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 10
}
}));
snapActive = Config.Bind<bool>("General", "SnapActive", true, new ConfigDescription("Enables grid snapping feature.", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 9
}
}));
preventPartialPlanting = Config.Bind<bool>("General", "PreventPartialPlanting", true, "Prevents placement of resources when any placement ghosts are invalid for any reason.");
preventInvalidPlanting = Config.Bind<bool>("General", "PreventInvalidPlanting", true, "Prevents plants from being placed where they will be unable to grow.");
randomizeRotation = Config.Bind<bool>("General", "RandomizeRotation", true, "Randomizes rotation of pieces once placed.");
useStamina = Config.Bind<bool>("General", "UseStamina", true, "Consume stamina for every piece placed.");
useDurability = Config.Bind<bool>("General", "UseDurability", true, "Decrease durability of cultivator for every piece placed.");
extraCropSpacing = Config.Bind<float>("General", "ExtraCropSpacing", 0f, "Adds extra spacing between crops. Accepts negative values to decrease spacing (not recommended).");
extraSaplingSpacing = Config.Bind<float>("General", "ExtraSaplingSpacing", 0f, "Adds extra spacing between saplings. Accepts negative values to decrease spacing (not recommended).");
gridSnappingStyle = Config.Bind<GridSnappingStyle>("General", "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.");
standardizeGridRotations = Config.Bind<bool>("General", "StandardizeGridRotations", true, "When set to true, this setting will prevent the diagonal snapping of new grids to existing grids.");
minimizeGridSpacing = Config.Bind<bool>("General", "MinimizeGridSpacing", false, "Allows for tighter grids, but with varying spacing used between diverse/distinct plants. ");
globallyAlignGridDirections = Config.Bind<bool>("General", "GloballyAlignGridDirections", true, "When set to true, new grid placements will have their column and row directions align with the global grid.");
maxConcurrentPlacements = Config.Bind<int>("General", "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>()));
pickableSnapRadius = Config.Bind<float>("Pickables", "PickableSnapRadius", 1f, "Determines default distance/spacing between pickable resources when planting.");
berryBushSnapRadius = Config.Bind<float>("Pickables", "BerryBushSnapRadius", 1.5f, "Determines distance/spacing between berry bushes when planting.");
mushroomSnapRadius = Config.Bind<float>("Pickables", "MushroomSnapRadius", 0.5f, "Determines distance/spacing between mushrooms when planting.");
flowerSnapRadius = Config.Bind<float>("Pickables", "FlowerSnapRadius", 1f, "Determines distance/spacing between flowers when planting.");
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 = 5
}
}));
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
}
}));
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."
}
}));
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."
}
}));
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."
}
}));
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."
}
}));
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."
}
}));
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."
}
}));
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."
}
}));
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."
}
}));
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."
}
}));
toggleAutoReplantKey = Config.Bind<KeyboardShortcut>("Controls", "ToggleAutoReplantKey", new KeyboardShortcut((KeyCode)0, 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."
}
}));
showCost = Config.Bind<bool>("UI", "ShowCost", true, new ConfigDescription("Update resource cost in build UI.", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 3
}
}));
costDisplayStyle = Config.Bind<CostDisplayStyle>("UI", "CostDisplayStyle", CostDisplayStyle.TotalCount, "Determines display style of the ShowCost setting. TotalCount shows total number of pieces to be placed. FullCost shows combined resoure cost of all pieces.");
costDisplayLocation = Config.Bind<CostDisplayLocation>("UI", "CostDisplayLocation", CostDisplayLocation.RightSide, "Determines whether to prepend or append text to the resource cost in build UI. LeftSide or RightSide will prepend or append respectively.");
showHUDKeyHints = Config.Bind<bool>("UI", "ShowHUDKeyHints", true, "Show KeyHints in build HUD.");
showHoverKeyHints = Config.Bind<bool>("UI", "ShowHoverKeyHints", true, "Show KeyHints in hover text.");
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;
keyboardHarvestModifierKey.SettingChanged += PlantEasily.KeybindsChanged;
keyboardModifierKey.SettingChanged += PlantEasily.KeybindsChanged;
gamepadModifierKey.SettingChanged += PlantEasily.KeybindsChanged;
}
}
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;
}
}
[HarmonyPatch(typeof(Beehive), "GetHoverText")]
private static void Postfix(Beehive __instance, ref string __result)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
if (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.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)";
__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)
{
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 SnapPosition
{
internal Vector3 rowDirection;
internal Vector3 columnDirection;
internal Vector3 position;
internal SnapPosition(Vector3 rd, Vector3 cd, Vector3 p)
{
//IL_0007: 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_000e: 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_0015: 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)
rowDirection = rd;
columnDirection = cd;
position = p;
}
}
private static readonly Collider[] primaryObstructions = (Collider[])(object)new Collider[50];
private static readonly Collider[] secondaryObstructions = (Collider[])(object)new Collider[50];
private static bool FindSnapPoints(List<SnapPosition> snapPoints, Collider collider, Vector3 rowDirection, Vector3 columnDirection, Plant plant)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//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_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: 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_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: 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_0061: 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_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
Vector3[] array = (Vector3[])(object)new Vector3[4]
{
((Component)collider).transform.position + rowDirection,
((Component)collider).transform.position + columnDirection,
((Component)collider).transform.position - rowDirection,
((Component)collider).transform.position - columnDirection
};
foreach (Vector3 val in array)
{
bool flag = false;
bool flag2 = false;
if (PlantEasily.PositionHasCollisions(val) || (Object.op_Implicit((Object)(object)plant) && !PlantEasily.HasGrowSpace(plant, val)))
{
continue;
}
if (PlantEasily.config.GridSnappingStyle == GridSnappingStyle.Intelligent)
{
if (PlantEasily.config.Rows > 1 && PlantEasily.PositionHasCollisions(val + rowDirection))
{
flag = true;
}
if (PlantEasily.config.Columns > 1 && PlantEasily.PositionHasCollisions(val + columnDirection))
{
flag2 = true;
}
}
snapPoints.Add(new SnapPosition((!flag) ? rowDirection : (-rowDirection), (!flag2) ? columnDirection : (-columnDirection), val));
}
return snapPoints.Count > 0;
}
private static void Prefix(Player __instance, GameObject ___m_placementGhost)
{
if (PlantEasily.config.ModActive && Object.op_Implicit((Object)(object)___m_placementGhost) && PlantEasily.HoldingCultivator && PlantEasily.IsPlantOrPickable(___m_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, ref GameObject ___m_placementGhost, ref int ___m_placementStatus)
{
//IL_0065: 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_0076: 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_007c: 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_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: 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_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: 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_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_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0401: Unknown result type (might be due to invalid IL or missing references)
//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
//IL_0363: Unknown result type (might be due to invalid IL or missing references)
//IL_0368: Unknown result type (might be due to invalid IL or missing references)
//IL_0369: Unknown result type (might be due to invalid IL or missing references)
//IL_0370: Unknown result type (might be due to invalid IL or missing references)
//IL_0372: Unknown result type (might be due to invalid IL or missing references)
//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
//IL_03da: Unknown result type (might be due to invalid IL or missing references)
//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_0385: Unknown result type (might be due to invalid IL or missing references)
//IL_038a: Unknown result type (might be due to invalid IL or missing references)
//IL_038e: Unknown result type (might be due to invalid IL or missing references)
//IL_0393: Unknown result type (might be due to invalid IL or missing references)
//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0300: Unknown result type (might be due to invalid IL or missing references)
//IL_0306: Unknown result type (might be due to invalid IL or missing references)
//IL_030b: Unknown result type (might be due to invalid IL or missing references)
//IL_031b: Unknown result type (might be due to invalid IL or missing references)
//IL_031d: Unknown result type (might be due to invalid IL or missing references)
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
//IL_0267: Unknown result type (might be due to invalid IL or missing references)
//IL_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_0273: Unknown result type (might be due to invalid IL or missing references)
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
//IL_027a: Unknown result type (might be due to invalid IL or missing references)
//IL_027f: Unknown result type (might be due to invalid IL or missing references)
//IL_0290: Unknown result type (might be due to invalid IL or missing references)
//IL_028d: Unknown result type (might be due to invalid IL or missing references)
//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
//IL_0494: Unknown result type (might be due to invalid IL or missing references)
//IL_0499: Unknown result type (might be due to invalid IL or missing references)
//IL_049e: Unknown result type (might be due to invalid IL or missing references)
//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_0293: Unknown result type (might be due to invalid IL or missing references)
//IL_0299: 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_04bf: Unknown result type (might be due to invalid IL or missing references)
//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
//IL_04db: Unknown result type (might be due to invalid IL or missing references)
//IL_04f0: 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_02ac: Unknown result type (might be due to invalid IL or missing references)
//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
if (!PlantEasily.config.ModActive || !Object.op_Implicit((Object)(object)___m_placementGhost) || !PlantEasily.HoldingCultivator || !PlantEasily.IsPlantOrPickable(___m_placementGhost))
{
return;
}
for (int i = 0; i < PlantEasily.extraGhosts.Count; i++)
{
PlantEasily.extraGhosts[i].SetActive(___m_placementGhost.activeSelf);
}
Vector3 basePosition = ___m_placementGhost.transform.position;
Quaternion rotation;
Quaternion val = (rotation = ___m_placementGhost.transform.rotation);
if (PlantEasily.config.StandardizeGridRotations)
{
Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles;
eulerAngles.x = Mathf.Round(eulerAngles.x / 90f) * 90f;
eulerAngles.y = Mathf.Round(eulerAngles.y / 90f) * 90f;
eulerAngles.z = Mathf.Round(eulerAngles.z / 90f) * 90f;
((Quaternion)(ref rotation)).eulerAngles = eulerAngles;
}
float pieceSpacing = PlantEasily.GetPieceSpacing(___m_placementGhost);
Vector3 val2 = (PlantEasily.config.GloballyAlignGridDirections ? Vector3.forward : Utils.DirectionXZ(basePosition - ((Component)__instance).transform.position));
Vector3 val3 = Vector3.Cross(Vector3.up, val2);
bool flag = false;
if (PlantEasily.config.SnapActive)
{
List<SnapPosition> snapPoints = new List<SnapPosition>();
Plant component = ___m_placementGhost.GetComponent<Plant>();
int num = Physics.OverlapSphereNonAlloc(___m_placementGhost.transform.position, pieceSpacing, primaryObstructions, PlantEasily.CollisionMask);
int num2 = 0;
for (int j = 0; j < num; j++)
{
if (!PlantEasily.IsPlantOrPickable(((Component)((Component)primaryObstructions[j]).transform.root).gameObject))
{
continue;
}
num2++;
if (num2 > 8)
{
break;
}
int num3 = Physics.OverlapSphereNonAlloc(___m_placementGhost.transform.position, pieceSpacing, secondaryObstructions, PlantEasily.CollisionMask);
int num4 = 0;
for (int k = 0; k < num3; k++)
{
if (PlantEasily.IsPlantOrPickable(((Component)((Component)secondaryObstructions[j]).transform.root).gameObject) && !((Object)(object)((Component)secondaryObstructions[j]).transform.root == (Object)(object)((Component)primaryObstructions[j]).transform.root))
{
num4++;
if (num4 > 8)
{
break;
}
val2 = Utils.DirectionXZ(((Component)secondaryObstructions[j]).transform.position - ((Component)primaryObstructions[j]).transform.position);
val3 = Vector3.Cross(Vector3.up, val2);
val2 = (PlantEasily.config.StandardizeGridRotations ? rotation : val) * val2 * pieceSpacing;
val3 = (PlantEasily.config.StandardizeGridRotations ? rotation : val) * val3 * pieceSpacing;
flag = FindSnapPoints(snapPoints, primaryObstructions[j], val2, val3, component);
}
}
if (!flag)
{
val2 = val * val2 * pieceSpacing;
val3 = val * val3 * pieceSpacing;
flag = FindSnapPoints(snapPoints, primaryObstructions[j], val2, val3, component);
}
}
if (flag)
{
SnapPosition snapPosition = snapPoints.OrderBy(delegate(SnapPosition o)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
float num7 = snapPoints.Min((SnapPosition m) => Utils.DistanceXZ(m.position, o.position));
Vector3 val7 = o.position - basePosition;
return num7 + ((Vector3)(ref val7)).magnitude;
}).First();
Vector3 val4 = (___m_placementGhost.transform.position = snapPosition.position);
basePosition = val4;
if (PlantEasily.config.GridSnappingStyle == GridSnappingStyle.Intelligent)
{
val2 = snapPosition.rowDirection;
val3 = snapPosition.columnDirection;
}
}
}
if (!flag)
{
if (PlantEasily.config.SnapActive)
{
val2 = (PlantEasily.config.GloballyAlignGridDirections ? Vector3.forward : Utils.DirectionXZ(basePosition - ((Component)__instance).transform.position));
val3 = Vector3.Cross(Vector3.up, val2);
}
val2 = val * val2 * pieceSpacing;
val3 = val * val3 * pieceSpacing;
}
Piece component2 = ___m_placementGhost.GetComponent<Piece>();
int amount = component2.m_resources[0].m_amount;
int num5 = 0;
float y = default(float);
for (int l = 0; l < PlantEasily.config.Rows; l++)
{
for (int n = 0; n < PlantEasily.config.Columns; n++)
{
bool flag2 = n == 0 && l == 0;
int num6 = l * PlantEasily.config.Columns + n;
if (num6 > PlantEasily.extraGhosts.Count)
{
break;
}
num5 += amount;
component2.m_resources[0].m_amount = num5;
GameObject val5 = (flag2 ? ___m_placementGhost : PlantEasily.extraGhosts[num6 - 1]);
Vector3 val6 = (flag2 ? basePosition : (basePosition + val2 * (float)l + val3 * (float)n));
Heightmap.GetHeight(val6, ref y);
val6.y = y;
val5.transform.position = val6;
val5.transform.rotation = ___m_placementGhost.transform.rotation;
PlantEasily.Status placementStatus = PlantEasily.Status.Healthy;
if (!__instance.m_noPlacementCost && !__instance.HaveRequirements(component2, (RequirementMode)0))
{
placementStatus = PlantEasily.Status.LackResources;
}
PlantEasily.SetPlacementGhostStatus(val5, num6, PlantEasily.CheckPlacementStatus(val5, placementStatus), ref ___m_placementStatus);
}
}
component2.m_resources[0].m_amount = amount;
}
}
[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.PlacePiece(__instance, PlantEasily.extraGhosts[i], piece);
}
}
((Character)__instance).RaiseSkill((SkillType)106, (float)num);
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.pickablesToPlants.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.pickablesToPlants.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;
Piece component = PlantEasily.prefabRefs[PlantEasily.pickablesToPlants[((Object)__instance).name.Replace("(Clone)", "")]].GetComponent<Piece>();
if (localPlayer.HaveRequirements(component, (RequirementMode)0) || Player.m_localPlayer.m_noPlacementCost)
{
PlantEasily.PlacePiece(localPlayer, ((Component)__instance).gameObject, component);
localPlayer.ConsumeResources(component.m_resources, 0, -1, 1);
}
}
}
}
[HarmonyPatch(typeof(ObjectDB), "Awake")]
internal static class ModInitPatches
{
private static void Postfix()
{
PlantEasily.InitPrefabRefs();
}
}
[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", "1.9.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 = "1.9.2";
private static readonly ManualLogSource PELogger = new ManualLogSource(" PlantEasily");
internal static ModConfig config;
internal static readonly Dictionary<string, GameObject> prefabRefs = new Dictionary<string, GameObject>();
internal static GameObject placementGhost;
internal static readonly List<GameObject> extraGhosts = 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 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 readonly Dictionary<string, string> pickablesToPlants = new Dictionary<string, string>
{
{ "Pickable_SeedOnion", "sapling_seedonion" },
{ "Pickable_Onion", "sapling_onion" },
{ "Pickable_Turnip", "sapling_turnip" },
{ "Pickable_Barley", "sapling_barley" },
{ "Pickable_Mushroom_JotunPuffs", "sapling_jotunpuffs" },
{ "Pickable_Carrot", "sapling_carrot" },
{ "Pickable_SeedCarrot", "sapling_seedcarrot" },
{ "Pickable_Flax", "sapling_flax" },
{ "Pickable_Mushroom_Magecap", "sapling_magecap" },
{ "Pickable_SeedTurnip", "sapling_seedturnip" }
};
private static readonly string[] berries = new string[3] { "RaspberryBush", "BlueberryBush", "CloudberryBush" };
private static readonly string[] mushrooms = new string[4] { "Pickable_Mushroom", "Pickable_Mushroom_yellow", "Pickable_Mushroom_blue", "Pickable_SmokePuff" };
private static readonly string[] flowers = new string[3] { "Pickable_Dandelion", "Pickable_Thistle", "Pickable_Fiddlehead" };
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
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
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);
new Harmony("advize.PlantEasily").PatchAll();
}
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 DestroyGhosts()
{
if (extraGhosts.Count > 0)
{
foreach (GameObject extraGhost in extraGhosts)
{
Object.Destroy((Object)(object)extraGhost);
}
extraGhosts.Clear();
}
ghostPlacementStatus.Clear();
}
internal static void CreateGhosts(GameObject rootGhost)
{
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: 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;
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 / 2f, 0.0001f, 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(((Object)go).name))) + num;
}
private static float PickableSnapRadius(string name)
{
if (berries.Contains(name))
{
return config.BerryBushSnapRadius;
}
if (mushrooms.Contains(name))
{
return config.MushroomSnapRadius;
}
if (flowers.Contains(name))
{
return config.FlowerSnapRadius;
}
return config.PickableSnapRadius;
}
internal static void SetPlacementGhostStatus(GameObject ghost, int index, Status placementStatus, ref int m_placementStatus)
{
ghost.GetComponent<Piece>().SetInvalidPlacementHeightlight(placementStatus != Status.Healthy);
if (ghostPlacementStatus.Count > index)
{
ghostPlacementStatus[index] = placementStatus;
if (index == 0 && placementStatus == Status.Healthy)
{
m_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, Piece piece)
{
//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)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: 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_0050: 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)
GameObject gameObject = ((Component)piece).gameObject;
Vector3 position = go.transform.position;
Quaternion val = (config.RandomizeRotation ? Quaternion.Euler(0f, 22.5f * (float)Random.Range(0, 16), 0f) : go.transform.rotation);
TerrainModifier.SetTriggerOnPlaced(true);
GameObject obj = Object.Instantiate<GameObject>(gameObject, position, val);
TerrainModifier.SetTriggerOnPlaced(false);
obj.GetComponent<Piece>().SetCreator(player.GetPlayerID());
Game.instance.IncrementPlayerStat((PlayerStatType)2, 1f);
if (!((Character)player).InPlaceMode())
{
((Character)player).RaiseSkill((SkillType)106, 1f);
}
}
internal static void InitPrefabRefs()
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Expected O, but got Unknown
Dbgl("InitPrefabRefs", forceLog: false, (LogLevel)16);
if (prefabRefs.Count > 0)
{
return;
}
foreach (string value in pickablesToPlants.Values)
{
prefabRefs.Add(value, 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;
}
}
}
}
internal static void Dbgl(string message, bool forceLog = false, LogLevel level = 16)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Invalid comparison between Unknown and I4
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Invalid comparison between Unknown and I4
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected I4, but got Unknown
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Invalid comparison between Unknown and I4
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Invalid comparison between Unknown and I4
if (!forceLog && !config.EnableDebugMessages)
{
return;
}
if ((int)level <= 8)
{
switch (level - 1)
{
case 1:
PELogger.LogError((object)message);
return;
case 3:
PELogger.LogWarning((object)message);
return;
case 0:
PELogger.LogFatal((object)message);
return;
case 2:
return;
}
if ((int)level == 8)
{
PELogger.LogMessage((object)message);
}
}
else if ((int)level != 16)
{
if ((int)level == 32)
{
PELogger.LogDebug((object)message);
}
}
else
{
PELogger.LogInfo((object)message);
}
}
}
}