using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CustomMod.Patches;
using HarmonyLib;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("CheaperJetpack")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CheaperJetpack")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("343367ad-483e-4e50-b3e5-94256bea2b0f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace CustomMod
{
[BepInPlugin("Chris.LTC.CustomMod", "CustomMod", "1.0.0.0")]
public class Plugin : BaseUnityPlugin
{
private const string MOD_GUID = "Chris.LTC.CustomMod";
private const string MOD_NAME = "CustomMod";
private const string MOD_VERSION = "1.0.0.0";
internal static ManualLogSource LogSource;
internal static ConfigEntry<string> CustomItemPrices;
private void Awake()
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
LogSource = ((BaseUnityPlugin)this).Logger;
CustomItemPrices = ((BaseUnityPlugin)this).Config.Bind<string>("Settings", "CustomItemPrices", "Jetpack:100", "Enter custom prices for store items, one per line. Format: itemName:price");
Harmony val = new Harmony("Chris.LTC.CustomMod");
val.PatchAll(typeof(Plugin));
val.PatchAll(typeof(TerminalSetItemSalesPatch));
LogSource.LogInfo((object)"CustomMod loaded.");
}
public static void Log(string message)
{
LogSource.LogInfo((object)message);
}
}
}
namespace CustomMod.Patches
{
[HarmonyPatch(typeof(Terminal))]
public static class TerminalSetItemSalesPatch
{
[HarmonyPatch("SetItemSales")]
[HarmonyPostfix]
public static void Postfix(ref Item[] ___buyableItemsList)
{
string value = Plugin.CustomItemPrices.Value;
string[] array = value.Split(new char[2] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
Dictionary<string, int> dictionary = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
string[] array2 = array;
foreach (string text in array2)
{
string text2 = text.Trim();
if (string.IsNullOrEmpty(text2))
{
continue;
}
string[] array3 = text2.Split(new char[1] { ':' });
if (array3.Length >= 2)
{
string text3 = array3[0].Trim();
if (int.TryParse(array3[1].Trim(), out var result))
{
dictionary[text3] = result;
continue;
}
Plugin.LogSource.LogWarning((object)("Could not parse price for item '" + text3 + "' in config line: '" + text + "'"));
}
else
{
Plugin.LogSource.LogWarning((object)("Invalid config line: '" + text + "'. Expected format: itemName:price"));
}
}
Item[] array4 = ___buyableItemsList;
foreach (Item val in array4)
{
if (dictionary.TryGetValue(val.itemName, out var value2))
{
val.creditsWorth = value2;
Plugin.Log($"Set price for '{val.itemName}' to {value2}");
}
}
}
}
}