using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Microsoft.CodeAnalysis;
using SSSGame;
using SandSailorStudio.Inventory;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("blacks7ar")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1")]
[assembly: AssemblyInformationalVersion("1.0.0+7a21b9c978b883e8b2d480de02b86cd91bf47696")]
[assembly: AssemblyProduct("FarmingTweaks")]
[assembly: AssemblyTitle("FarmingTweaks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 FarmingTweaks
{
[BepInPlugin("blacks7ar.FarmingTweaks", "FarmingTweaks", "1.0.1")]
public class Plugin : BasePlugin
{
[HarmonyPatch]
private static class Patch
{
private static readonly HashSet<string> ProcessedItems = new HashSet<string>();
private static readonly Dictionary<IntPtr, float> OriginalGrowthTime = new Dictionary<IntPtr, float>();
[HarmonyPostfix]
[HarmonyPatch(typeof(PlantableItemInfo), "CreateItem")]
private static void Start_Postfix(PlantableItemInfo __instance)
{
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Expected O, but got Unknown
try
{
if (!((Object)(object)__instance == (Object)null))
{
string name = ((ItemInfo)__instance).Name;
if (!ProcessedItems.Contains(name))
{
int spawnAmount = __instance.spawnAmount * _spawnAmount.Value;
__instance.spawnAmount = spawnAmount;
__instance.seedRequirementAmount = _seedAmount.Value;
ProcessedItems.Add(name);
}
}
}
catch (Exception ex)
{
ManualLogSource fLogger = FLogger;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(58, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Exception thrown while trying to patch PlantableItemInfo: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
}
fLogger.LogError(val);
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(FarmCrop), "Rpc_AddWeedsProgress")]
private static void RpcAddWeedsProgress_Prefix(ref float amount)
{
amount *= _weedingMultiplier.Value;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(FarmCrop), "AddWeedsProgress")]
private static void AddWeedsProgress_Prefix(ref float amount)
{
amount *= _weedingMultiplier.Value;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(FarmCrop), "Rpc_AddTillProgress")]
private static void RpcAddTillProgress_Prefix(ref int amount)
{
amount *= _tillingMultiplier.Value;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(FarmCrop), "AddTillProgress")]
private static void AddTillProgress_Prefix(ref int amount)
{
amount *= _tillingMultiplier.Value;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(FarmCrop), "Rpc_AddGrowthProgress")]
private static void RpcAddGrowthProgress_Prefix(ref int amount)
{
amount *= _growthFactorMultiplier.Value;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(FarmCrop), "AddGrowthProgress")]
private static void AddGrowthProgress_Prefix(ref int amount)
{
amount *= _growthFactorMultiplier.Value;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(FarmGridCellData), "AddHoursProgress")]
private static void AddHoursProgress_Prefix(FarmGridCellData __instance, ref int value)
{
value *= _growthFactorMultiplier.Value;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(FarmGridCellData), "get_NormalizedWeedsProgress")]
private static void NormalizedWeedsProgress_Prefix(FarmGridCellData __instance)
{
IntPtr pointer = ((Il2CppObjectBase)__instance).Pointer;
if (!OriginalGrowthTime.TryGetValue(pointer, out var value))
{
value = __instance._weedsGrowthTime;
OriginalGrowthTime[pointer] = value;
}
float weedsGrowthTime = value * _weedsGrowthMultiplier.Value;
__instance._weedsGrowthTime = weedsGrowthTime;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(FarmCropInteraction), "Touch")]
private static void Touch_Postfix(FarmCropInteraction __instance, bool touch)
{
//IL_0272: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Expected O, but got Unknown
//IL_001c: 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_0023: 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_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Expected O, but got Unknown
//IL_0058: 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_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Expected O, but got Unknown
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
bool flag = default(bool);
try
{
if (!touch || (Object)(object)__instance.farmCrop == (Object)null)
{
return;
}
Vector3Int cellCropTile = __instance.CellCropTile;
FarmGridCellData val = default(FarmGridCellData);
BepInExDebugLogInterpolatedStringHandler val2;
if (!__instance.TryGetFarmCellData(Vector3Int.op_Implicit(cellCropTile), ref val) || val == null)
{
ManualLogSource fLogger = FLogger;
val2 = new BepInExDebugLogInterpolatedStringHandler(22, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("No cell data for tile ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Vector3Int>(cellCropTile);
}
fLogger.LogDebug(val2);
return;
}
PlantableItemInfo plantedSeed = val._plantedSeed;
string text = ((plantedSeed != null) ? ((ItemInfo)plantedSeed).Name : null) ?? "(empty)";
FarmGridCellState cellState = val._cellState;
int age = val._age;
int hourProgress = val._hourProgress;
float currentWaterVolume = val._currentWaterVolume;
float maxWaterVolume = val._maxWaterVolume;
float currentWaterRatio = val.CurrentWaterRatio;
float weedsGrowthProgress = val._weedsGrowthProgress;
float weedsGrowthTime = val._weedsGrowthTime;
float currentCompostVolume = val._currentCompostVolume;
float maxCompostVolume = val._maxCompostVolume;
float currentCompostRatio = val.CurrentCompostRatio;
int remainingGrowthTime = val.RemainingGrowthTime;
ManualLogSource fLogger2 = FLogger;
val2 = new BepInExDebugLogInterpolatedStringHandler(140, 14, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\r\n[Farm Cell: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Vector3Int>(cellCropTile);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Plant: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" \r\nState: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((object)(FarmGridCellState)(ref cellState)).ToString());
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" Age: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(age);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" Hour Progress: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(hourProgress);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\r\nWater: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(currentWaterVolume, "F2");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" / ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(maxWaterVolume, "F2");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (ratio: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(currentWaterRatio, "F3");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") \r\nWeeds: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(weedsGrowthProgress, "F2");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" / ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(weedsGrowthTime, "F2");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" \r\nCompost: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(currentCompostVolume, "F2");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" / ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(maxCompostVolume, "F2");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (ratio: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(currentCompostRatio, "F3");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")\r\nRemaining Growth Time: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(remainingGrowthTime, "F2");
}
fLogger2.LogDebug(val2);
}
catch (Exception ex)
{
ManualLogSource fLogger3 = FLogger;
BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(48, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Exception occured while logging all crop cells: ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Exception>(ex);
}
fLogger3.LogError(val3);
}
}
}
private const string modGUID = "blacks7ar.FarmingTweaks";
public const string modName = "FarmingTweaks";
public const string modAuthor = "blacks7ar";
public const string modVersion = "1.0.1";
private static ManualLogSource FLogger;
private static ConfigEntry<int> _growthFactorMultiplier;
private static ConfigEntry<int> _spawnAmount;
private static ConfigEntry<int> _seedAmount;
private static ConfigEntry<float> _weedingMultiplier;
private static ConfigEntry<float> _weedsGrowthMultiplier;
private static ConfigEntry<int> _tillingMultiplier;
public override void Load()
{
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
FLogger = ((BasePlugin)this).Log;
_growthFactorMultiplier = ((BasePlugin)this).Config.Bind<int>("General", "Crop Growth Factor Multiplier", 3, "Multiplies crops growth factor by this amount every in-game hour. (Higher value, faster crop grows)");
_spawnAmount = ((BasePlugin)this).Config.Bind<int>("General", "Harvest Multiplier", 2, "Multiplies the amount you get from harvesting the crop.");
_seedAmount = ((BasePlugin)this).Config.Bind<int>("General", "Required Seed", 10, "Required amount of seed to plant.");
_weedingMultiplier = ((BasePlugin)this).Config.Bind<float>("General", "Weeding Speed Multiplier", 5f, "Affects how fast you weed the field. (Higher value, faster weeding speed)");
_tillingMultiplier = ((BasePlugin)this).Config.Bind<int>("General", "Tilling Speed Multiplier", 5, "Affects how fast you till the field. (Higher value, faster tiling speed)");
_weedsGrowthMultiplier = ((BasePlugin)this).Config.Bind<float>("General", "Weeds GrowthTime Multiplier", 3f, "Multiplies the total growth time of weeds. Multiplying it with a higher value would make the weeds grow slower.");
FLogger.LogInfo((object)"Mod loaded!");
new Harmony("blacks7ar.FarmingTweaks").PatchAll();
}
}
}