using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Autodesk.Fbx")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")]
[assembly: IgnoresAccessChecksTo("Klattersynth")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("websocket-sharp")]
[assembly: AssemblyCompany("khalliv")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ShoppingListHUD")]
[assembly: AssemblyTitle("ShoppingListHUD")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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]
[Microsoft.CodeAnalysis.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;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.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 ShoppingListHUD
{
[HarmonyPatch(typeof(PlayerController))]
internal static class ExamplePlayerControllerPatch
{
[HarmonyPrefix]
[HarmonyPatch("Start")]
private static void Start_Prefix(PlayerController __instance)
{
ShoppingListHUD.Logger.LogDebug((object)$"{__instance} Start Prefix");
}
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void Start_Postfix(PlayerController __instance)
{
ShoppingListHUD.Logger.LogDebug((object)$"{__instance} Start Postfix");
}
}
[BepInPlugin("khalliv.ShoppingListHUD", "ShoppingListHUD", "1.0.2")]
public class ShoppingListHUD : BaseUnityPlugin
{
internal static ConfigEntry<float> PositionOffsetX;
internal static ConfigEntry<float> PositionOffsetY;
internal static ShoppingListHUD Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
private void Awake()
{
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Patch();
SetupConfigs();
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
}
internal void Patch()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_0026: Expected O, but got Unknown
if (Harmony == null)
{
Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
Harmony val2 = val;
Harmony = val;
}
Harmony.PatchAll(typeof(ShoppingListHUDPatches));
}
internal void Unpatch()
{
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
internal void CreateNetworkingObject()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
if ((Object)(object)ShoppingListHUD_Networking.instance == (Object)null)
{
GameObject val = new GameObject("ShoppingListHUDNetworking");
val.AddComponent<ShoppingListHUD_Networking>();
}
}
private void SetupConfigs()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected O, but got Unknown
PositionOffsetX = ((BaseUnityPlugin)this).Config.Bind<float>("General", "PositionX", 0f, new ConfigDescription("The X position for the Shopping List HUD", (AcceptableValueBase)null, Array.Empty<object>()));
PositionOffsetY = ((BaseUnityPlugin)this).Config.Bind<float>("General", "PositionY", 0f, new ConfigDescription("The Y position for the Shopping List HUD", (AcceptableValueBase)null, Array.Empty<object>()));
}
}
internal class ShoppingListHUDPatches
{
private const string header = "Shopping List";
internal static List<ShoppingListHUD_ItemData> shoppingListGroups = new List<ShoppingListHUD_ItemData>();
internal static int shoppingListCount = 0;
private static bool currentTextSet = false;
private static bool textResetToStatsUI = false;
private static string headerColor = ColorUtility.ToHtmlStringRGB(new Color(0.6f, 0.6f, 0.45f));
private static string weaponsColor = ColorUtility.ToHtmlStringRGB(new Color(1f, 0.53f, 0.53f));
internal static string countsText = "";
internal static string namesText = "";
private static Dictionary<string, string> textColorsDict = new Dictionary<string, string>
{
{
"HEALTH PACK",
ColorUtility.ToHtmlStringRGB(new Color(0.5f, 1f, 0.5f))
},
{
"UPGRADE",
ColorUtility.ToHtmlStringRGB(new Color(0.4f, 0.8f, 1f))
},
{
"CRYSTAL",
ColorUtility.ToHtmlStringRGB(new Color(1f, 1f, 0.3f))
},
{
"DRONE",
ColorUtility.ToHtmlStringRGB(new Color(0.78f, 0.49f, 1f))
},
{
"ORB",
ColorUtility.ToHtmlStringRGB(new Color(0.78f, 0.49f, 1f))
},
{
"TRACKER",
ColorUtility.ToHtmlStringRGB(new Color(1f, 0.71f, 0.95f))
},
{
"C.A.R.T",
ColorUtility.ToHtmlStringRGB(new Color(1f, 0.71f, 0.23f))
}
};
[HarmonyPatch(typeof(ShopManager), "ShopInitialize")]
[HarmonyPostfix]
private static void ShopManager_ShopInitialize_Postfix(ShopManager __instance)
{
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
if (!SemiFunc.RunIsShop())
{
((TMP_Text)StatsUI.instance.upgradesHeader).text = "UPGRADES";
((TMP_Text)StatsUI.instance.Text).rectTransform.sizeDelta = new Vector2(250f, 50f);
return;
}
((TMP_Text)StatsUI.instance.Text).rectTransform.sizeDelta = new Vector2(300f, 50f);
currentTextSet = false;
if (SemiFunc.IsMultiplayer() && (Object)(object)ShoppingListHUD_Networking.instance == (Object)null)
{
ShoppingListHUD.Instance.CreateNetworkingObject();
}
}
[HarmonyPatch(typeof(ShopManager), "ShopCheck")]
[HarmonyPostfix]
private static void ShopManager_ShopCheck_Postfix(ShopManager __instance)
{
if ((!SemiFunc.IsMultiplayer() || SemiFunc.IsMasterClient()) && SemiFunc.RunIsShop())
{
shoppingListGroups.Clear();
shoppingListCount = 0;
if ((Object)(object)ShoppingListHUD_Networking.instance != (Object)null)
{
ShoppingListHUD_Networking.instance.UpdateShoppingList(shoppingListCount, "", "");
}
}
}
[HarmonyPatch(typeof(ShopManager), "ShoppingListItemAdd")]
[HarmonyPostfix]
private static void ShoppingList_ShoppingListItemAdd_Postfix(ShopManager __instance)
{
if (!SemiFunc.IsMultiplayer() || SemiFunc.IsMasterClient())
{
currentTextSet = false;
}
}
[HarmonyPatch(typeof(ShopManager), "ShoppingListItemRemove")]
[HarmonyPostfix]
private static void ShoppingList_ShoppingListItemRemove_Postfix(ShopManager __instance)
{
if (!SemiFunc.IsMultiplayer() || SemiFunc.IsMasterClient())
{
currentTextSet = false;
}
}
[HarmonyPatch(typeof(StatsUI), "Update")]
[HarmonyPrefix]
private static bool StatsUI_Update_Prefix(StatsUI __instance)
{
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: 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)
if (!SemiFunc.RunIsShop())
{
return true;
}
bool flag = SemiFunc.IsMultiplayer() && SemiFunc.IsMasterClient();
if (__instance.showStatsTimer > 0f || ((SemiUI)__instance).showTimer > 0f)
{
OnMapOpenInShop();
return true;
}
textResetToStatsUI = false;
if (Mathf.Abs(((Component)__instance).transform.position.x - (61f + ShoppingListHUD.PositionOffsetX.Value)) > 0.1f || Mathf.Abs(((Component)__instance).transform.position.y - (255f + ShoppingListHUD.PositionOffsetY.Value)) > 0.1f)
{
((Component)__instance).transform.position = new Vector3(61f + ShoppingListHUD.PositionOffsetX.Value, 255f + ShoppingListHUD.PositionOffsetY.Value, 0f);
}
if (SemiFunc.IsMasterClientOrSingleplayer())
{
if (!currentTextSet)
{
currentTextSet = true;
UpdateShoppingList();
if (flag && (Object)(object)ShoppingListHUD_Networking.instance != (Object)null)
{
ShoppingListHUD_Networking.instance.UpdateShoppingList(shoppingListCount, countsText, namesText);
}
}
}
else if (!currentTextSet)
{
currentTextSet = true;
if (shoppingListCount > 0)
{
SetUITexts();
}
}
ToggleTextComponents(shoppingListCount > 0);
return false;
}
internal static void OnMapOpenInShop()
{
ResetTextToStatsUI();
((TMP_Text)StatsUI.instance.upgradesHeader).text = "UPGRADES";
ToggleTextComponents(state: true);
currentTextSet = false;
}
internal static void ToggleTextComponents(bool state)
{
StatsUI.instance.scanlineObject.SetActive(state);
((Component)StatsUI.instance.upgradesHeader).gameObject.SetActive(state);
((Behaviour)StatsUI.instance.upgradesHeader).enabled = true;
((Component)StatsUI.instance.textNumbers).gameObject.SetActive(state);
((Behaviour)StatsUI.instance.Text).enabled = state;
}
internal static void ResetTextToStatsUI()
{
if (!textResetToStatsUI)
{
StatsUI.instance.Fetch();
textResetToStatsUI = true;
}
}
private static void UpdateShoppingList(bool tryUpdateShoppingListGroups = true)
{
if (!TryUpdateShoppingListGroups())
{
return;
}
string text = "";
string text2 = "";
foreach (ShoppingListHUD_ItemData shoppingListGroup in shoppingListGroups)
{
text += $"<color=white>{shoppingListGroup.Count}x</color>\n";
string text3 = "";
foreach (KeyValuePair<string, string> item in textColorsDict)
{
if (shoppingListGroup.Name.IndexOf(item.Key, StringComparison.InvariantCultureIgnoreCase) >= 0)
{
text3 = item.Value;
}
}
if (text3 == "")
{
text3 = weaponsColor;
}
text2 += $"<color=#{text3}>{shoppingListGroup.Name}</color> <b><color=white>=</color> $<color=white>{shoppingListGroup.Cost}</color></b>\n";
}
countsText = text;
namesText = text2;
SetUITexts();
}
internal static void SetShoppingListCountFromRPC(int count)
{
shoppingListCount = count;
}
internal static void SetUITexts()
{
((TMP_Text)StatsUI.instance.upgradesHeader).text = ((shoppingListCount > 0) ? ("<color=#" + headerColor + ">Shopping List</color>") : "");
((TMP_Text)StatsUI.instance.textNumbers).text = countsText;
((TMP_Text)StatsUI.instance.Text).text = namesText;
}
private static bool TryUpdateShoppingListGroups()
{
shoppingListGroups.Clear();
if ((Object)(object)ShopManager.instance == (Object)null || ShopManager.instance.shoppingList == null || ShopManager.instance.shoppingList.Count == 0)
{
shoppingListCount = 0;
return false;
}
IOrderedEnumerable<ShoppingListHUD_ItemData> collection = from data in (from item in ShopManager.instance.shoppingList
group item by item.itemName).Select(delegate(IGrouping<string, ItemAttributes> @group)
{
ShoppingListHUD_ItemData result = default(ShoppingListHUD_ItemData);
result.Name = @group.Key;
result.Count = @group.Count();
result.Cost = @group.Sum((ItemAttributes item) => item.value) * 1000;
return result;
})
orderby (textColorsDict.Keys.ToList().FindIndex((string key) => data.Name.IndexOf(key, StringComparison.InvariantCultureIgnoreCase) >= 0) == -1) ? int.MaxValue : textColorsDict.Keys.ToList().FindIndex((string key) => data.Name.IndexOf(key, StringComparison.InvariantCultureIgnoreCase) >= 0), data.Name
select data;
shoppingListGroups.AddRange(collection);
shoppingListCount = shoppingListGroups.Count;
return true;
}
}
internal struct ShoppingListHUD_ItemData
{
public int Count;
public string Name;
public int Cost;
}
public class ShoppingListHUD_Networking : MonoBehaviourPunCallbacks
{
public static ShoppingListHUD_Networking instance;
private void Awake()
{
if ((Object)(object)instance == (Object)null)
{
instance = this;
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
}
else
{
Object.Destroy((Object)(object)((Component)this).gameObject);
}
((Component)this).gameObject.AddComponent<PhotonView>();
((MonoBehaviourPun)this).photonView.ViewID = 223307;
}
internal void UpdateShoppingList(int shoppingListCount, string counts, string names)
{
((MonoBehaviourPun)this).photonView.RPC("UpdateShoppingList_RPC", (RpcTarget)1, new object[3] { shoppingListCount, counts, names });
}
[PunRPC]
private void UpdateShoppingList_RPC(int shoppingListCount, string counts, string names)
{
ShoppingListHUDPatches.countsText = counts;
ShoppingListHUDPatches.namesText = names;
ShoppingListHUDPatches.SetShoppingListCountFromRPC(shoppingListCount);
ShoppingListHUDPatches.SetUITexts();
}
}
}