using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using SuperFantasyKingdom; using SuperFantasyKingdom.Buildings; using SuperFantasyKingdom.Clickable; using SuperFantasyKingdom.Spawner; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("LoneBonfire")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.1.0")] [assembly: AssemblyInformationalVersion("1.1.1+69a66f8534d7ff9add067e6c8c5477822ddbe6ef")] [assembly: AssemblyProduct("Lone Bonfire")] [assembly: AssemblyTitle("LoneBonfire")] [assembly: AssemblyVersion("1.1.1.0")] [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 LoneBonfire { [BepInPlugin("ownly.lonebonfire", "Lone Bonfire", "1.1.1")] public class Plugin : BaseUnityPlugin { private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID).PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Lone Bonfire loaded: bonfire capped at one, +10% monsters per outpost built"); } } internal static class Bonfire { internal const float BonusPerOutpost = 0.1f; internal static BuildingType Type; internal static bool TypeKnown; internal static int CountPotentialOutposts(CityManager city) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 int num = city.GetOutposts().Count; BuildingSpotWorld[] array = Object.FindObjectsOfType(); for (int i = 0; i < array.Length; i++) { if ((int)array[i].size == 6) { num++; } } return num; } } [HarmonyPatch(typeof(BuildingOutpostDifficulty), "Awake")] internal static class Patch_LearnBonfireType { private static void Postfix(BuildingOutpostDifficulty __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) Bonfire.Type = ((Building)__instance).GetBuildingType(); Bonfire.TypeKnown = true; } } [HarmonyPatch(typeof(CityManager), "CanBuild")] internal static class Patch_CapBonfire { private static bool Prefix(CityManager __instance, BuildingType type, ref bool __result) { //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_0010: Unknown result type (might be due to invalid IL or missing references) if (!Bonfire.TypeKnown || type != Bonfire.Type || (Object)(object)__instance.GetBuilding(type) == (Object)null) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(Building), "GetDescription")] internal static class Patch_BonfireDescription { private static readonly Regex FirstNumber = new Regex("\\d+"); private static void Postfix(Building __instance, ref string __result) { try { CityManager instance = CityManager.Instance; if (__instance is BuildingOutpostDifficulty && !((Object)(object)instance == (Object)null) && !string.IsNullOrEmpty(__result)) { int num = Bonfire.CountPotentialOutposts(instance); string text = (Mathf.RoundToInt(10f) * num).ToString(); __result = (FirstNumber.IsMatch(__result) ? FirstNumber.Replace(__result, text, 1) : (__result + " (+" + text + "%)")); } } catch { } } } [HarmonyPatch(typeof(MonsterSpawner), "SetMonstersToSpawn")] internal static class Patch_ScaleWithOutposts { private static void Prefix(MonsterSpawner __instance) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) float num = 1f; CityManager instance = CityManager.Instance; if (Bonfire.TypeKnown && (Object)(object)instance != (Object)null && (Object)(object)instance.GetBuilding(Bonfire.Type) != (Object)null) { num = 1f + 0.1f * (float)Bonfire.CountPotentialOutposts(instance); } Traverse.Create((object)__instance).Field("m_MonsterAmountMultiplier").SetValue((object)num); } } }