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.Logging;
using CheatMenu.Cheats;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using SuperFantasyKingdom;
using SuperFantasyKingdom.Buildings;
using SuperFantasyKingdom.Jobs;
using SuperFantasyKingdom.Spawner;
using SuperFantasyKingdom.Tavern;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CheatMenu")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CheatMenu")]
[assembly: AssemblyTitle("CheatMenu")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 CheatMenu
{
[BepInPlugin("ilm.cheatmenu", "CheatMenu", "1.0.1")]
public class Plugin : BaseUnityPlugin
{
public const string PluginGuid = "ilm.cheatmenu";
public const string PluginName = "CheatMenu";
public const string PluginVersion = "1.0.1";
internal static ManualLogSource Log;
private void Awake()
{
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
GloryMultiplier.Bind(((BaseUnityPlugin)this).Config);
ProductionSpeed.Bind(((BaseUnityPlugin)this).Config);
ProductionYield.Bind(((BaseUnityPlugin)this).Config);
MovementSpeed.Bind(((BaseUnityPlugin)this).Config);
CoinMultiplier.Bind(((BaseUnityPlugin)this).Config);
FaithMultiplier.Bind(((BaseUnityPlugin)this).Config);
ExperienceMultiplier.Bind(((BaseUnityPlugin)this).Config);
StartingPopulation.Bind(((BaseUnityPlugin)this).Config);
new Harmony("ilm.cheatmenu").PatchAll();
Log.LogInfo((object)"CheatMenu 1.0.1 loaded");
}
}
}
namespace CheatMenu.Safety
{
internal static class LeaderboardBlocker
{
[HarmonyPatch]
private static class UpdateScore
{
private static IEnumerable<MethodBase> TargetMethods()
{
yield return AccessTools.DeclaredMethod(typeof(SteamLeaderboardManager), "UpdateScore", (Type[])null, (Type[])null);
Type type = AccessTools.TypeByName("SuperFantasyKingdom.XboxLiveLeaderboardManager");
if (type != null)
{
MethodInfo methodInfo = AccessTools.DeclaredMethod(type, "UpdateScore", (Type[])null, (Type[])null);
if ((object)methodInfo != null)
{
yield return methodInfo;
}
}
}
private static bool Prefix(int score)
{
Plugin.Log.LogInfo((object)$"Blocked leaderboard upload (score {score})");
return false;
}
}
}
}
namespace CheatMenu.Cheats
{
internal static class CoinMultiplier
{
[HarmonyPatch(typeof(ResourceManager), "AddResource", new Type[]
{
typeof(ResourceType),
typeof(int)
})]
private static class ResourceManager_AddResource
{
private static void Prefix(ResourceType resourceType, ref int amt)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Invalid comparison between Unknown and I4
if ((int)resourceType == 12 && amt > 0)
{
amt = Mathf.RoundToInt((float)amt * Multiplier.Value);
}
}
}
internal static ConfigEntry<float> Multiplier;
internal static void Bind(ConfigFile config)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
Multiplier = config.Bind<float>("Coins", "Multiplier", 1f, new ConfigDescription("Multiplier applied to all coins earned. 1 = vanilla.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
}
}
internal static class ExperienceMultiplier
{
[HarmonyPatch(typeof(UnitBase), "AddExperience")]
private static class UnitBase_AddExperience
{
private static void Prefix(ref int xp)
{
if (!s_Transferring && xp > 0)
{
xp = Mathf.RoundToInt((float)xp * Multiplier.Value);
}
}
}
[HarmonyPatch(typeof(BuildingElemental), "Callback")]
private static class BuildingElemental_Callback
{
private static void Prefix()
{
s_Transferring = true;
}
private static void Finalizer()
{
s_Transferring = false;
}
}
internal static ConfigEntry<float> Multiplier;
private static bool s_Transferring;
internal static void Bind(ConfigFile config)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
Multiplier = config.Bind<float>("Experience", "Multiplier", 1f, new ConfigDescription("Multiplier applied to all hero and unit XP earned. 1 = vanilla.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
}
}
internal static class FaithMultiplier
{
[HarmonyPatch(typeof(ResourceManager), "AddResource", new Type[]
{
typeof(ResourceType),
typeof(int)
})]
private static class ResourceManager_AddResource
{
private static void Prefix(ResourceType resourceType, ref int amt)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Invalid comparison between Unknown and I4
if ((int)resourceType == 13 && amt > 0)
{
amt = Mathf.RoundToInt((float)amt * Multiplier.Value);
}
}
}
internal static ConfigEntry<float> Multiplier;
internal static void Bind(ConfigFile config)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
Multiplier = config.Bind<float>("Faith", "Multiplier", 1f, new ConfigDescription("Multiplier applied to all faith earned. 1 = vanilla.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
}
}
internal static class GloryMultiplier
{
[HarmonyPatch(typeof(TavernStatistics), "OnStart")]
private static class TavernStatistics_OnStart
{
private static void Postfix(TavernStatistics __instance)
{
TavernGloryMultiplier.Invoke(__instance) *= Multiplier.Value;
}
}
[HarmonyPatch(typeof(WorldManager), "AddGlory")]
private static class WorldManager_AddGlory
{
private static void Prefix(ref int glory)
{
if (glory > 0)
{
glory = Mathf.RoundToInt((float)glory * Multiplier.Value);
}
}
}
internal static ConfigEntry<float> Multiplier;
private static readonly FieldRef<TavernStatistics, float> TavernGloryMultiplier = AccessTools.FieldRefAccess<TavernStatistics, float>("m_GloryMultiplier");
internal static void Bind(ConfigFile config)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
Multiplier = config.Bind<float>("Glory", "Multiplier", 1f, new ConfigDescription("Multiplier applied to all glory earned. 1 = vanilla.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
}
}
internal static class MovementSpeed
{
[HarmonyPatch]
private static class Worker_GetMoveSpeed
{
private static IEnumerable<MethodBase> TargetMethods()
{
yield return AccessTools.DeclaredMethod(typeof(Worker), "GetMoveSpeed", (Type[])null, (Type[])null);
yield return AccessTools.DeclaredMethod(typeof(King), "GetMoveSpeed", (Type[])null, (Type[])null);
yield return AccessTools.DeclaredMethod(typeof(Carrier), "GetMoveSpeed", (Type[])null, (Type[])null);
}
private static void Postfix(ref float __result)
{
__result *= Multiplier.Value;
}
}
internal static ConfigEntry<float> Multiplier;
internal static void Bind(ConfigFile config)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
Multiplier = config.Bind<float>("Movement", "SpeedMultiplier", 1f, new ConfigDescription("Movement speed multiplier for workers, carriers and the king. 1 = vanilla.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 20f), Array.Empty<object>()));
}
}
internal static class ProductionSpeed
{
[HarmonyPatch(typeof(BuildingCity), "GetWorkTimeMultiplier")]
private static class BuildingCity_GetWorkTimeMultiplier
{
private static void Postfix(ref float __result)
{
Scale(ref __result);
}
}
[HarmonyPatch(typeof(BuildingLaboratory), "GetGenerationDuration")]
private static class BuildingLaboratory_GetGenerationDuration
{
private static void Postfix(ref float __result)
{
Scale(ref __result);
}
}
[HarmonyPatch(typeof(BuildingHouseGenerate), "GetDuration")]
private static class BuildingHouseGenerate_GetDuration
{
private static void Postfix(ref float __result)
{
Scale(ref __result);
}
}
[HarmonyPatch(typeof(JobThicket), "GetDuration")]
private static class JobThicket_GetDuration
{
private static void Postfix(ref float __result)
{
Scale(ref __result);
}
}
[HarmonyPatch(typeof(JobForager), "GetDuration")]
private static class JobForager_GetDuration
{
private static void Postfix(ref float __result)
{
Scale(ref __result);
}
}
[HarmonyPatch(typeof(JobVein), "GetDuration")]
private static class JobVein_GetDuration
{
private static void Postfix(JobVein __instance, ref float __result)
{
if ((Object)(object)DepletableResource.Invoke((JobDepletable)(object)__instance) == (Object)null)
{
Scale(ref __result);
}
}
}
[HarmonyPatch]
private static class FixedDurationJobs_Reached
{
private static IEnumerable<MethodBase> TargetMethods()
{
Type[] array = new Type[5]
{
typeof(JobFisher),
typeof(JobGrow),
typeof(JobPlant),
typeof(JobGeologist),
typeof(JobGeneratingg)
};
foreach (Type type in array)
{
yield return AccessTools.DeclaredMethod(type, "Reached", new Type[1] { typeof(Vector3) }, (Type[])null);
}
}
private static void Postfix(ref float __result)
{
Scale(ref __result);
}
}
[HarmonyPatch(typeof(Train), "Awake")]
private static class Train_Awake
{
private static void Postfix(Train __instance)
{
TrainMoveSpeed.Invoke(__instance) *= Multiplier.Value;
}
}
[HarmonyPatch(typeof(Train), "Update")]
private static class Train_Update
{
private static void Prefix(Train __instance)
{
ref float reference = ref TrainWaitTimer.Invoke(__instance);
if (reference > 0f && Multiplier.Value > 1f)
{
reference = Mathf.Max(reference - Time.deltaTime * (Multiplier.Value - 1f), 0.0001f);
}
}
}
internal static ConfigEntry<float> Multiplier;
private static readonly FieldRef<JobDepletable, ResourceDeposit> DepletableResource = AccessTools.FieldRefAccess<JobDepletable, ResourceDeposit>("Resource");
private static readonly FieldRef<Train, float> TrainMoveSpeed = AccessTools.FieldRefAccess<Train, float>("moveSpeed");
private static readonly FieldRef<Train, float> TrainWaitTimer = AccessTools.FieldRefAccess<Train, float>("WaitTimer");
internal static void Bind(ConfigFile config)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
Multiplier = config.Bind<float>("Production", "SpeedMultiplier", 1f, new ConfigDescription("Production speed multiplier. 2 = work and generation finish in half the time. 1 = vanilla. Capped at 20: above that, mineshaft and quarry carts can no longer keep up with the miners and deliveries stall.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 20f), Array.Empty<object>()));
}
private static void Scale(ref float duration)
{
if (duration > 0f)
{
duration /= Multiplier.Value;
}
}
}
internal static class ProductionYield
{
[HarmonyPatch(typeof(Building), "Awake")]
private static class Building_Awake
{
private static void Postfix(Building __instance)
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
if (Multiplier.Value == 1f)
{
return;
}
BuildingResource val = (BuildingResource)(object)((__instance is BuildingResource) ? __instance : null);
if (val != null)
{
val.amount = Scale(val.amount);
}
BuildingCrafting val2 = (BuildingCrafting)(object)((__instance is BuildingCrafting) ? __instance : null);
if (val2 == null)
{
return;
}
List<CraftingRecipe> list = Recipes.Invoke(val2);
if (list != null)
{
for (int i = 0; i < list.Count; i++)
{
CraftingRecipe val3 = list[i];
val3.amount = Scale(val3.amount);
list[i] = val3;
}
}
}
}
[HarmonyPatch(typeof(BuildingCrafting), "DoCrafting")]
private static class BuildingCrafting_DoCrafting
{
private static bool Prefix(BuildingCrafting __instance, int recipeToCraft)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: 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_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
if (Multiplier.Value == 1f)
{
return true;
}
ResourceType product = Recipes.Invoke(__instance)[recipeToCraft].product;
int num = (((int)product == 12) ? 3 : (((int)product == 23) ? 1 : 0));
int num2 = num;
if (num2 == 0)
{
return true;
}
DroppedShardSpawner.Instance.Spawn(((BuildingCity)__instance).GetPosition(), Scale(num2), product, false);
return false;
}
}
internal static ConfigEntry<float> Multiplier;
private static readonly FieldRef<BuildingCrafting, List<CraftingRecipe>> Recipes = AccessTools.FieldRefAccess<BuildingCrafting, List<CraftingRecipe>>("recipes");
internal static void Bind(ConfigFile config)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
Multiplier = config.Bind<float>("Production", "YieldMultiplier", 1f, new ConfigDescription("Multiplier for resources produced per production cycle. Results are rounded and never drop below 1. 1 = vanilla.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 100f), Array.Empty<object>()));
}
private static int Scale(int amount)
{
if (amount <= 0)
{
return amount;
}
return Mathf.Max(1, Mathf.RoundToInt((float)amount * Multiplier.Value));
}
}
internal static class StartingPopulation
{
[HarmonyPatch(typeof(ResourceManager), "GiveStartingResources")]
private static class ResourceManager_GiveStartingResources
{
private static void Postfix(ResourceManager __instance)
{
if (ExtraWorkers.Value > 0)
{
__instance.AddResource((ResourceType)5, ExtraWorkers.Value);
}
if (ExtraCarriers.Value > 0)
{
__instance.AddResource((ResourceType)27, ExtraCarriers.Value);
}
}
}
internal static ConfigEntry<int> ExtraWorkers;
internal static ConfigEntry<int> ExtraCarriers;
internal static void Bind(ConfigFile config)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
ExtraWorkers = config.Bind<int>("StartingPopulation", "ExtraWorkers", 0, new ConfigDescription("Extra workers spawned at the castle when a new run starts, on top of the normal amount.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
ExtraCarriers = config.Bind<int>("StartingPopulation", "ExtraCarriers", 0, new ConfigDescription("Extra carriers spawned at the castle when a new run starts, on top of the normal amount.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
}
}
}