using System;
using System.Diagnostics;
using System.Linq;
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.Logging;
using EquinoxsModUtils;
using EquinoxsModUtils.Additions;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("PlanterCoreClusters")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PlanterCoreClusters")]
[assembly: AssemblyTitle("PlanterCoreClusters")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace PlanterCoreClusters
{
[BepInPlugin("com.equinox.PlanterCoreClusters", "PlanterCoreClusters", "3.0.5")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class PlanterCoreClustersPlugin : BaseUnityPlugin
{
private const string MyGUID = "com.equinox.PlanterCoreClusters";
private const string PluginName = "PlanterCoreClusters";
private const string VersionString = "3.0.5";
private static readonly Harmony Harmony = new Harmony("com.equinox.PlanterCoreClusters");
public static ManualLogSource Log;
public static string coreBoostGrowingName = "Core Boost (Growing)";
public static ConfigEntry<float> perClusterBoost;
private void Awake()
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Expected O, but got Unknown
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: 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_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"PluginName: PlanterCoreClusters, VersionString: 3.0.5 is loading...");
perClusterBoost = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Boost Per Cluster", 5f, new ConfigDescription("Speed boost percentage per Core Cluster (default 5%).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), Array.Empty<object>()));
Harmony.PatchAll();
Harmony.CreateAndPatchAll(typeof(PlanterInstancePatch), (string)null);
EMUAdditions.AddNewUnlock(new NewUnlockDetails
{
category = (TechCategory)5,
coreTypeNeeded = (CoreType)2,
coreCountNeeded = 100,
description = "Increases speed of all Planters by configurable % per Core Cluster (default 5%).",
displayName = coreBoostGrowingName,
requiredTier = (ResearchTier)2,
treePosition = 0
}, false);
Events.GameDefinesLoaded += OnGameDefinesLoaded;
Log.LogInfo((object)"PluginName: PlanterCoreClusters, VersionString: 3.0.5 is loaded.");
}
private void OnGameDefinesLoaded()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
Unlock unlockByName = Unlocks.GetUnlockByName("Core Boost (Smelting)", false);
Unlock unlockByName2 = Unlocks.GetUnlockByName("Core Boost (Threshing)", false);
Unlock unlockByName3 = Unlocks.GetUnlockByName("Planter", false);
Unlocks.UpdateUnlockTier(coreBoostGrowingName, unlockByName.requiredTier, false);
Unlocks.UpdateUnlockTreePosition(coreBoostGrowingName, unlockByName2.treePosition, false);
Unlocks.UpdateUnlockSprite(coreBoostGrowingName, unlockByName3.sprite, false);
}
}
internal class PlanterInstancePatch
{
private static Unlock coreBoostGrowing;
private static bool techUnlocked;
[HarmonyPatch(typeof(PlanterInstance), "SimUpdate")]
[HarmonyPrefix]
private static void ApplyCoreBoost(PlanterInstance __instance)
{
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: 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_00e1: 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)
if ((Object)(object)coreBoostGrowing == (Object)null)
{
coreBoostGrowing = Unlocks.GetUnlockByName(PlanterCoreClustersPlugin.coreBoostGrowingName, false);
}
if (!techUnlocked)
{
techUnlocked = TechTreeState.instance.IsUnlockActive(((UniqueIdScriptableObject)coreBoostGrowing).uniqueId);
if (!techUnlocked)
{
return;
}
}
if (TechTreeState.instance.freeCores == 0)
{
return;
}
float num = (float)TechTreeState.instance.freeCores * PlanterCoreClustersPlugin.perClusterBoost.Value * 0.0001f;
num += 1f;
for (int i = 0; i < __instance.plantSlots.Count(); i++)
{
if (__instance.plantSlots[i].growthProgress > __instance.plantSlots[i].totalGrowthDuration)
{
__instance.plantSlots[i].growthProgress = __instance.plantSlots[i].totalGrowthDuration;
}
int plantId = __instance.plantSlots[i].plantId;
if (plantId != -1)
{
SaveState.GetResInfoFromId(plantId);
if (__instance.plantSlots[i].totalGrowthDuration == 120f)
{
float totalGrowthDuration = Mathf.Max(120f / num, 1E-07f);
__instance.plantSlots[i].totalGrowthDuration = totalGrowthDuration;
}
continue;
}
break;
}
}
}
}