using System;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using TMPro;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("DoublePrices")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DoublePrices")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("900bd92e-f823-461f-892f-69c2efeaf17f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace DoublePrices
{
[BepInPlugin("SupermarketTogether.plugins.DoublePrices", "double-prices", "1.1.0")]
public class DoublePricesPlugin : BaseUnityPlugin
{
private const string MyGUID = "SupermarketTogether.plugins.DoublePrices";
private const string PluginName = "double-prices";
private const string VersionString = "1.1.0";
public static string KeyboardShortcutDoublePriceKey = "Double price toggle";
public static string KeyboardShortcutRoundDownSwitchKey = "Round down switch";
public static string KeyboardShortcutRoundDownToggleKey = "Round down toggle";
public static string roundDownKey = "Round down";
public static string NearestFiveKey = "Round down to nearest 0.05";
public static string NearestTenKey = "Round down to nearest 0.10";
public static ConfigEntry<KeyboardShortcut> KeyboardShortcutDoublePrice;
public static ConfigEntry<KeyboardShortcut> KeyboardShortcutRoundDownSwitch;
public static ConfigEntry<KeyboardShortcut> KeyboardShortcutRoundDownToggle;
public static ConfigEntry<bool> roundDown;
public static ConfigEntry<bool> NearestFive;
public static ConfigEntry<bool> NearestTen;
private static readonly Harmony Harmony = new Harmony("SupermarketTogether.plugins.DoublePrices");
public static ManualLogSource Log = new ManualLogSource("double-prices");
public static bool doublePrice = true;
public static bool notify = false;
public static string notificationType;
private void Awake()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: 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)
KeyboardShortcutDoublePrice = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", KeyboardShortcutDoublePriceKey, new KeyboardShortcut((KeyCode)113, Array.Empty<KeyCode>()), (ConfigDescription)null);
roundDown = ((BaseUnityPlugin)this).Config.Bind<bool>("Round Down", roundDownKey, false, (ConfigDescription)null);
NearestFive = ((BaseUnityPlugin)this).Config.Bind<bool>("Round Down", NearestFiveKey, true, (ConfigDescription)null);
NearestTen = ((BaseUnityPlugin)this).Config.Bind<bool>("Round Down", NearestTenKey, false, (ConfigDescription)null);
KeyboardShortcutRoundDownSwitch = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Round Down Shortucts", KeyboardShortcutRoundDownSwitchKey, new KeyboardShortcut((KeyCode)113, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null);
KeyboardShortcutRoundDownToggle = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Round Down Shortucts", KeyboardShortcutRoundDownToggleKey, new KeyboardShortcut((KeyCode)113, (KeyCode[])(object)new KeyCode[2]
{
(KeyCode)306,
(KeyCode)304
}), (ConfigDescription)null);
((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: double-prices, VersionString: 1.1.0 is loading...");
Harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: double-prices, VersionString: 1.1.0 is loaded.");
Log = ((BaseUnityPlugin)this).Logger;
}
private void Update()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
KeyboardShortcut value = KeyboardShortcutDoublePrice.Value;
if (((KeyboardShortcut)(ref value)).IsDown())
{
doublePrice = !doublePrice;
notificationType = "priceToggle";
notify = true;
return;
}
value = KeyboardShortcutRoundDownSwitch.Value;
if (((KeyboardShortcut)(ref value)).IsDown())
{
if (NearestTen.Value)
{
NearestTen.Value = false;
NearestFive.Value = true;
}
else
{
NearestTen.Value = true;
NearestFive.Value = false;
}
notificationType = "roundDownSwitch";
notify = true;
}
else
{
value = KeyboardShortcutRoundDownToggle.Value;
if (((KeyboardShortcut)(ref value)).IsDown())
{
roundDown.Value = !roundDown.Value;
notificationType = "roundDownToggle";
notify = true;
}
}
}
private void ConfigSettingChanged(object sender, EventArgs e)
{
SettingChangedEventArgs val = (SettingChangedEventArgs)(object)((e is SettingChangedEventArgs) ? e : null);
if (val != null && (val.ChangedSetting.Definition.Key == NearestFiveKey || val.ChangedSetting.Definition.Key == NearestTenKey) && NearestTen.Value && NearestFive.Value)
{
NearestTen.Value = false;
}
}
}
}
namespace DoublePrices.Patches
{
[HarmonyPatch(typeof(PlayerNetwork))]
internal class DoublePrice
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
public static void doublePrice_Postfix(ref float ___pPrice, TextMeshProUGUI ___marketPriceTMP, ref TextMeshProUGUI ___yourPriceTMP)
{
if (!DoublePricesPlugin.doublePrice || !((Object)(object)___marketPriceTMP != (Object)null) || !float.TryParse(((TMP_Text)___marketPriceTMP).text.Substring(1).Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
{
return;
}
___pPrice = result * 2f;
if (DoublePricesPlugin.roundDown.Value)
{
if (DoublePricesPlugin.NearestTen.Value)
{
___pPrice = (float)(Math.Floor(___pPrice * 10f) / 10.0);
}
else
{
___pPrice = (float)(Math.Floor(___pPrice * 20f) / 20.0);
}
}
((TMP_Text)___yourPriceTMP).text = "$" + ___pPrice;
}
}
[HarmonyPatch(typeof(GameCanvas))]
internal class NotificationHandler
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
public static void NotificationHandler_Postfix(GameCanvas __instance, ref bool ___inCooldown)
{
if (DoublePricesPlugin.notify)
{
___inCooldown = false;
DoublePricesPlugin.notify = false;
string text = "`";
switch (DoublePricesPlugin.notificationType)
{
case "priceToggle":
text = text + "Double Price: " + (DoublePricesPlugin.doublePrice ? "ON" : "OFF");
break;
case "roundDownSwitch":
text = text + "Roudning to nearest " + (DoublePricesPlugin.NearestTen.Value ? "ten" : "five") + ((!DoublePricesPlugin.roundDown.Value) ? "\r\n(Currently disabled)" : "");
break;
case "roundDownToggle":
text = text + "Rounding has been " + (DoublePricesPlugin.roundDown.Value ? "enabled" : "disabled");
break;
}
__instance.CreateCanvasNotification(text);
}
}
}
[HarmonyPatch(typeof(LocalizationManager))]
internal class LocalizationHandler
{
[HarmonyPatch("GetLocalizationString")]
[HarmonyPrefix]
public static bool noLocalization_Prefix(ref string key, ref string __result)
{
if (key[0] == '`')
{
__result = key.Substring(1);
return false;
}
return true;
}
}
}
namespace DoublePrices.MonoBehaviours
{
internal class DoublePricesComponent : MonoBehaviour
{
public void Awake()
{
}
public void Start()
{
}
public void Update()
{
}
public void LateUpdate()
{
}
}
}