using System;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("KroesSupermarketMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("KroesSupermarketMod")]
[assembly: AssemblyTitle("KroesSupermarketMod")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace KroesSupermarketMod
{
[BepInPlugin("com.chris.kroes.supermarket", "Kroes Supermarket", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private const string GUID = "com.chris.kroes.supermarket";
private const string NAME = "Kroes Supermarket";
private const string VERSION = "1.0.0";
internal static ManualLogSource mls;
internal static Harmony harmony = new Harmony("com.chris.kroes.supermarket");
internal static Plugin instance;
private void Awake()
{
if ((Object)(object)instance == (Object)null)
{
instance = this;
}
mls = ((BaseUnityPlugin)this).Logger;
harmony.PatchAll();
mls.LogInfo((object)"Loaded succesfully");
}
}
}
namespace KroesSupermarketMod.Patches
{
[HarmonyPatch(typeof(PlayerNetwork))]
internal class PriceGunPatch
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
public static void doublePrice_Postfix(ref float ___pPrice, TextMeshProUGUI ___marketPriceTMP, TextMeshProUGUI ___yourPriceTMP)
{
if (!((Object)(object)___marketPriceTMP == (Object)null) && !string.IsNullOrEmpty(((TMP_Text)___marketPriceTMP).text) && float.TryParse(((TMP_Text)___marketPriceTMP).text.Substring(1).Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
{
___pPrice = result * 2f;
if ((Object)(object)___yourPriceTMP != (Object)null)
{
((TMP_Text)___yourPriceTMP).text = "$" + ___pPrice.ToString("F2", CultureInfo.InvariantCulture);
}
}
}
}
[HarmonyPatch(typeof(GameData))]
internal class CustomFranchisePointsPatch
{
private static int lastKnownExp = -1;
[HarmonyPatch("Update")]
[HarmonyPostfix]
public static void Update_Postfix(GameData __instance, int ___gameFranchiseExperience)
{
if (lastKnownExp == -1)
{
lastKnownExp = ___gameFranchiseExperience;
}
else if (___gameFranchiseExperience != lastKnownExp)
{
int num = lastKnownExp;
lastKnownExp = ___gameFranchiseExperience;
AccessTools.Method(typeof(GameData), "UpdateFranchisePoints", (Type[])null, (Type[])null)?.Invoke(__instance, new object[2] { num, ___gameFranchiseExperience });
}
}
[HarmonyPatch("UpdateFranchisePoints")]
[HarmonyPrefix]
public static bool Prefix(GameData __instance, TextMeshProUGUI ___UIFranchisePointsOBJ, int ___gameFranchiseExperience, int ___gameFranchisePoints)
{
if ((Object)(object)___UIFranchisePointsOBJ == (Object)null)
{
return false;
}
float levelProgress = GetLevelProgress(___gameFranchiseExperience);
int num = 8;
int num2 = Mathf.FloorToInt(Mathf.Clamp01(levelProgress) * (float)num);
int count = num - num2;
string arg = new string('█', num2);
string arg2 = new string('█', count);
string text = $"{___gameFranchisePoints} <color=green>{arg}</color><color=white>{arg2}</color>";
((TMP_Text)___UIFranchisePointsOBJ).text = text;
return false;
}
private static float GetLevelProgress(int currentExp)
{
int num = 0;
for (int i = 1; (float)i < float.PositiveInfinity; i++)
{
num += i * 100;
if (num > currentExp)
{
float num2 = currentExp - (num - i * 100);
float num3 = i * 100;
return num2 / num3;
}
}
return 0f;
}
}
[HarmonyPatch(typeof(NPC_Info))]
internal class CustomVoiceLinesPatch
{
private static readonly string[] CustomVoiceLines = new string[5] { "Kanker!", "Het is de echter gangster, Klaas!", "Ik ben vergeten in m'n bed te pissen...", "What stays in Kos stays in Kos.", "Waar bemoei jij je mee?!" };
[HarmonyPatch("UserCode_RPCNotificationAboveHead__String__String")]
[HarmonyPrefix]
public static bool Prefix(NPC_Info __instance, GameObject ___messagePrefab)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: 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_0030: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)___messagePrefab == (Object)null)
{
return false;
}
GameObject val = Object.Instantiate<GameObject>(___messagePrefab, ((Component)__instance).transform.position + Vector3.up * 1.8f, Quaternion.identity);
string text = CustomVoiceLines[Random.Range(0, CustomVoiceLines.Length)];
((TMP_Text)val.GetComponent<TextMeshPro>()).text = text;
val.SetActive(true);
return false;
}
}
}