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 Store.Pump;
using UpgradeLib;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("MoreUpgrades")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MoreUpgrades")]
[assembly: AssemblyTitle("MoreUpgrades")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace MoreUpgrades;
[BepInPlugin("com.moreupgrades.roadsideresearch", "MoreUpgrades", "1.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
public const string GUID = "com.moreupgrades.roadsideresearch";
public const string Name = "MoreUpgrades";
public const string Version = "1.0.1";
internal static ManualLogSource Log;
internal static ConfigEntry<int> MaxTiers;
internal static ConfigEntry<float> BaseCostEcon;
internal static ConfigEntry<float> BaseCostResearch;
internal static ConfigEntry<float> CostMultiplier;
internal static readonly List<string> CustomerAttractionIds = new List<string>();
internal static readonly List<string> ShoppingBoostIds = new List<string>();
internal static readonly List<string> PriceToleranceIds = new List<string>();
internal static readonly List<string> StockDiscountIds = new List<string>();
internal static readonly List<string> TrashReductionIds = new List<string>();
internal static readonly List<string> FuelCapacityIds = new List<string>();
internal static readonly List<string> ResearchBoostIds = new List<string>();
internal static readonly List<string> SuspicionShieldIds = new List<string>();
internal static readonly List<string> SuspicionDecayIds = new List<string>();
internal static readonly List<string> CustomerSpendingIds = new List<string>();
private static readonly string[] RomanNumerals = new string[10] { "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X" };
public override void Load()
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_00b4: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: 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_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Expected O, but got Unknown
Log = ((BasePlugin)this).Log;
MaxTiers = ((BasePlugin)this).Config.Bind<int>("General", "MaxTiers", 5, new ConfigDescription("Number of upgrade tiers per tree", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>()));
BaseCostEcon = ((BasePlugin)this).Config.Bind<float>("General", "BaseCostEcon", 1000f, "Base cost for economy (money) upgrades");
BaseCostResearch = ((BasePlugin)this).Config.Bind<float>("General", "BaseCostResearch", 500f, "Base cost for research upgrades");
CostMultiplier = ((BasePlugin)this).Config.Bind<float>("General", "CostMultiplier", 1.8f, "Cost multiplier per tier");
RegisterAllTrees();
Harmony val = new Harmony("com.moreupgrades.roadsideresearch");
val.PatchAll(typeof(CustomerSpawnPatch));
val.PatchAll(typeof(ShoppingListPatch));
val.PatchAll(typeof(PriceTolerancePatch));
val.PatchAll(typeof(StockPricePatch));
val.PatchAll(typeof(TrashPatch));
val.PatchAll(typeof(FuelPatch));
val.PatchAll(typeof(ResearchPatch));
val.PatchAll(typeof(SuspicionGainPatch));
val.PatchAll(typeof(SuspicionLossPatch));
val.PatchAll(typeof(MarketPricePatch));
ManualLogSource log = Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(66, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("MoreUpgrades loaded! ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(MaxTiers.Value);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" tiers per tree across 10 upgrade categories.");
}
log.LogInfo(val2);
}
private void RegisterAllTrees()
{
int value = MaxTiers.Value;
float value2 = BaseCostEcon.Value;
float value3 = BaseCostResearch.Value;
float value4 = CostMultiplier.Value;
UpgradeAPI.RegisterTree(BuildTree("customer_attraction", "Customer Attraction", "W.E.E. Boost {0}", "Promo signs & attractions draw {0}% more customers.", (CostType)0, value2, value4, value, 15f, CustomerAttractionIds, "signs"));
UpgradeAPI.RegisterTree(BuildTree("shopping_boost", "Shopping Spree", "Cart Upgrade {0}", "Customers buy {0}% more items per visit.", (CostType)0, value2 * 1.2f, value4, value, 10f, ShoppingBoostIds, "shopping"));
UpgradeAPI.RegisterTree(BuildTree("customer_spending", "Premium Products", "Premium Products {0}", "Market prices increase by {0}%, boosting revenue per item.", (CostType)0, value2 * 0.8f, value4, value, 8f, CustomerSpendingIds, "store"));
UpgradeAPI.RegisterTree(BuildTree("price_tolerance", "Price Tolerance", "Loyalty Program {0}", "Customers tolerate {0}% higher markups before leaving.", (CostType)0, value2 * 1.5f, value4, value, 12f, PriceToleranceIds, "store"));
UpgradeAPI.RegisterTree(BuildTree("stock_discount", "Bulk Purchasing", "Supplier Deal {0}", "Wholesale stock costs reduced by {0}%.", (CostType)0, value2 * 1.3f, value4, value, 5f, StockDiscountIds, "store"));
UpgradeAPI.RegisterTree(BuildTree("trash_reduction", "Clean Station", "Tidy Town {0}", "Customer trash reduced by {0}%.", (CostType)0, value2 * 0.6f, value4, value, 10f, TrashReductionIds, "cleaning"));
UpgradeAPI.RegisterTree(BuildTree("fuel_capacity", "Fuel Storage", "Fuel Tank {0}", "Fuel storage capacity increased by {0}%.", (CostType)0, value2 * 0.7f, value4, value, 25f, FuelCapacityIds, "gas-pump"));
UpgradeAPI.RegisterTree(BuildTree("research_boost", "Data Mining", "Advanced Sensors {0}", "Research gained from observations increased by {0}%.", (CostType)1, value3, value4, value, 15f, ResearchBoostIds, "scanner"));
UpgradeAPI.RegisterTree(BuildTree("suspicion_shield", "Covert Operations", "Stealth Tech {0}", "Suspicion gained from alien activity reduced by {0}%.", (CostType)1, value3 * 1.2f, value4, value, 10f, SuspicionShieldIds, "camera"));
UpgradeAPI.RegisterTree(BuildTree("suspicion_decay", "Memory Wipe", "Brain Washer {0}", "Suspicion decays {0}% faster over time.", (CostType)1, value3 * 1.5f, value4, value, 15f, SuspicionDecayIds, "camera"));
}
private UpgradeDefinition BuildTree(string idPrefix, string title, string nameTemplate, string descTemplate, CostType costType, float baseCost, float costMult, int tiers, float pctPerTier, List<string> nodeIds, string vanillaIcon)
{
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: 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_0089: 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_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_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Expected O, but got Unknown
UpgradeDefinition val = null;
UpgradeDefinition val2 = null;
for (int i = 0; i < tiers; i++)
{
string text = $"{idPrefix}_{i + 1}";
nodeIds.Add(text);
int num = i + 1;
string arg = ((num <= RomanNumerals.Length) ? RomanNumerals[num - 1] : num.ToString());
float num2 = pctPerTier * (float)num;
UpgradeDefinition val3 = new UpgradeDefinition
{
Id = text,
Name = string.Format(nameTemplate, arg),
Description = string.Format(descTemplate, num2.ToString("F0")),
CostType = costType,
Cost = baseCost * (float)Math.Pow(costMult, i),
Category = (((int)costType == 0) ? "Station" : "Research"),
VanillaIconMatch = vanillaIcon
};
if (val == null)
{
val3.Title = title;
val = val3;
}
else
{
val2.Children.Add(val3);
}
val2 = val3;
}
return val;
}
internal static int CountPurchased(List<string> nodeIds)
{
int num = 0;
foreach (string nodeId in nodeIds)
{
if (UpgradeAPI.IsPurchased(nodeId))
{
num++;
}
}
return num;
}
}
[HarmonyPatch]
internal static class CustomerSpawnPatch
{
[HarmonyPatch(typeof(DifficultyManager), "get_CustomerSpawnMultiplier")]
[HarmonyPostfix]
public static void Boost(ref float __result)
{
int num = Plugin.CountPurchased(Plugin.CustomerAttractionIds);
if (num > 0)
{
__result *= 1f + 0.15f * (float)num;
}
}
}
[HarmonyPatch]
internal static class ShoppingListPatch
{
[HarmonyPatch(typeof(DifficultyManager), "get_ShoppingListMultiplier")]
[HarmonyPostfix]
public static void Boost(ref float __result)
{
int num = Plugin.CountPurchased(Plugin.ShoppingBoostIds);
if (num > 0)
{
__result *= 1f + 0.1f * (float)num;
}
}
}
[HarmonyPatch]
internal static class MarketPricePatch
{
[HarmonyPatch(typeof(DifficultyManager), "get_MarketPriceMultiplier")]
[HarmonyPostfix]
public static void Boost(ref float __result)
{
int num = Plugin.CountPurchased(Plugin.CustomerSpendingIds);
if (num > 0)
{
__result *= 1f + 0.08f * (float)num;
}
}
}
[HarmonyPatch]
internal static class PriceTolerancePatch
{
[HarmonyPatch(typeof(DifficultyManager), "get_PriceToleranceMultiplier")]
[HarmonyPostfix]
public static void Boost(ref float __result)
{
int num = Plugin.CountPurchased(Plugin.PriceToleranceIds);
if (num > 0)
{
__result *= 1f + 0.12f * (float)num;
}
}
}
[HarmonyPatch]
internal static class StockPricePatch
{
[HarmonyPatch(typeof(DifficultyManager), "get_StockPriceMultiplier")]
[HarmonyPostfix]
public static void Reduce(ref float __result)
{
int num = Plugin.CountPurchased(Plugin.StockDiscountIds);
if (num > 0)
{
float num2 = 1f - 0.05f * (float)num;
if (num2 < 0.25f)
{
num2 = 0.25f;
}
__result *= num2;
}
}
}
[HarmonyPatch]
internal static class TrashPatch
{
[HarmonyPatch(typeof(DifficultyManager), "get_TrashMultiplier")]
[HarmonyPostfix]
public static void Reduce(ref float __result)
{
int num = Plugin.CountPurchased(Plugin.TrashReductionIds);
if (num > 0)
{
float num2 = 1f - 0.1f * (float)num;
if (num2 < 0.1f)
{
num2 = 0.1f;
}
__result *= num2;
}
}
}
[HarmonyPatch]
internal static class FuelPatch
{
[HarmonyPatch(typeof(FuelInventory), "MaxFuel")]
[HarmonyPostfix]
public static void IncreaseFuel(ref float __result)
{
int num = Plugin.CountPurchased(Plugin.FuelCapacityIds);
if (num > 0)
{
__result *= 1f + 0.25f * (float)num;
}
}
}
[HarmonyPatch]
internal static class ResearchPatch
{
[HarmonyPatch(typeof(DifficultyManager), "get_ResearchMultiplier")]
[HarmonyPostfix]
public static void Boost(ref float __result)
{
int num = Plugin.CountPurchased(Plugin.ResearchBoostIds);
if (num > 0)
{
__result *= 1f + 0.15f * (float)num;
}
}
}
[HarmonyPatch]
internal static class SuspicionGainPatch
{
[HarmonyPatch(typeof(DifficultyManager), "get_SuspicionGainMultiplier")]
[HarmonyPostfix]
public static void Reduce(ref float __result)
{
int num = Plugin.CountPurchased(Plugin.SuspicionShieldIds);
if (num > 0)
{
float num2 = 1f - 0.1f * (float)num;
if (num2 < 0.1f)
{
num2 = 0.1f;
}
__result *= num2;
}
}
}
[HarmonyPatch]
internal static class SuspicionLossPatch
{
[HarmonyPatch(typeof(DifficultyManager), "get_SuspicionLossMultiplier")]
[HarmonyPostfix]
public static void Boost(ref float __result)
{
int num = Plugin.CountPurchased(Plugin.SuspicionDecayIds);
if (num > 0)
{
__result *= 1f + 0.15f * (float)num;
}
}
}