using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Peak.UI;
using Photon.Pun;
using Photon.Realtime;
using Steamworks;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.atomic.profileviewer")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.2.0")]
[assembly: AssemblyInformationalVersion("0.1.2")]
[assembly: AssemblyProduct("com.atomic.profileviewer")]
[assembly: AssemblyTitle("ProfileViewer")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.2.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 BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace ProfileViewer
{
[BepInPlugin("com.atomic.profileviewer", "ProfileViewer", "0.1.2")]
public class Plugin : BaseUnityPlugin
{
public static Harmony harmony;
public const string Id = "com.atomic.profileviewer";
internal static ManualLogSource Log { get; private set; }
public static string Name => "ProfileViewer";
public static string Version => "0.1.2";
private void Awake()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
harmony = new Harmony("com.atomic.profileviewer");
harmony.PatchAll();
Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
}
public static CSteamID GetSteamId(Player player)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
if (player != null && !string.IsNullOrEmpty(player.UserId) && ulong.TryParse(player.UserId, out var result))
{
return new CSteamID(result);
}
return CSteamID.Nil;
}
public static Texture2D GetSteamAvatar(CSteamID steamID)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
int mediumFriendAvatar = SteamFriends.GetMediumFriendAvatar(steamID);
if (mediumFriendAvatar == -1)
{
return null;
}
uint num = default(uint);
uint num2 = default(uint);
SteamUtils.GetImageSize(mediumFriendAvatar, ref num, ref num2);
byte[] array = new byte[num * num2 * 4];
if (SteamUtils.GetImageRGBA(mediumFriendAvatar, array, (int)(num * num2 * 4)))
{
Texture2D val = new Texture2D((int)num, (int)num2, (TextureFormat)4, false);
val.LoadRawTextureData(array);
val.Apply();
return val;
}
return null;
}
public static Texture2D IconFromEmbeddedResource(string resourceName)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
Assembly assembly = typeof(Plugin).Assembly;
using Stream stream = assembly.GetManifestResourceStream(resourceName);
if (stream == null)
{
return null;
}
byte[] array = new byte[stream.Length];
stream.Read(array, 0, array.Length);
Texture2D val = new Texture2D(2, 2);
ImageConversion.LoadImage(val, array);
return val;
}
public static void CreateUI(AudioLevelSlider __instance)
{
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_0257: Expected O, but got Unknown
//IL_0280: Unknown result type (might be due to invalid IL or missing references)
//IL_029c: Unknown result type (might be due to invalid IL or missing references)
//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0318: Unknown result type (might be due to invalid IL or missing references)
//IL_035d: Unknown result type (might be due to invalid IL or missing references)
//IL_0364: Expected O, but got Unknown
//IL_0383: Unknown result type (might be due to invalid IL or missing references)
//IL_038f: Unknown result type (might be due to invalid IL or missing references)
//IL_039b: Unknown result type (might be due to invalid IL or missing references)
//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
Transform val = ((Component)__instance).transform.Find("IsNotLocal");
((HorizontalOrVerticalLayoutGroup)((Component)__instance).GetComponentInParent<VerticalLayoutGroup>()).spacing = 30f;
if (!((Object)(object)val == (Object)null))
{
((Component)val).gameObject.SetActive(true);
if (isModInstalled("lammas123.PEAKER"))
{
Transform parent = ((Component)__instance).transform.parent.parent;
((Behaviour)((Component)parent).GetComponent<Image>()).enabled = false;
((Behaviour)((Component)parent).GetComponent<Mask>()).enabled = false;
}
Transform val2 = val.Find("KickButton");
Transform val3 = val.Find("Slider");
if ((Object)(object)val2 != (Object)null)
{
((Component)val2).gameObject.SetActive(true);
}
if ((Object)(object)val3 != (Object)null)
{
((Component)val3).gameObject.SetActive(true);
}
ProfileController profileController = ((Component)__instance).GetComponent<ProfileController>();
if ((Object)(object)profileController == (Object)null)
{
profileController = ((Component)__instance).gameObject.AddComponent<ProfileController>();
}
if ((Object)(object)((Component)__instance).transform.Find("IsNotLocal/ProfileButton") != (Object)null)
{
HandleVisibility(__instance, val, val2, val3);
profileController.Refresh();
return;
}
Transform val4 = ((Component)__instance).transform.Find("NameLayout");
val2.localPosition += new Vector3(-60f, 15f, 0f);
Transform obj = val.Find("Percent");
obj.localPosition += new Vector3(40f, 5f, 0f);
Transform obj2 = val.Find("Icon");
obj2.localPosition += new Vector3(40f, 5f, 0f);
val4.localPosition += new Vector3(0f, 40f, 0f);
GameObject val5 = Object.Instantiate<GameObject>(((Component)val2).gameObject, val);
((Object)val5).name = "ProfileButton";
val5.SetActive(true);
GameObject val6 = Object.Instantiate<GameObject>(val5, val);
((Object)val6).name = "AddFriendButton";
val6.SetActive(true);
HandleVisibility(__instance, val, val2, val3);
CleanButton(val5, "ProfileViewer.Assets.Open-Profile.png");
CleanButton(val6, "ProfileViewer.Assets.Add-Friend.png");
GameObject val7 = new GameObject("ProfileFrame", new Type[4]
{
typeof(RectTransform),
typeof(Image),
typeof(Mask),
typeof(Outline)
});
val7.transform.SetParent(((Component)__instance).transform, false);
val7.transform.localScale = new Vector3(0.8f, 0.8f, 0.8f);
Outline component = val7.GetComponent<Outline>();
((Shadow)component).effectColor = ((Graphic)((Component)val4).GetComponentInChildren<TextMeshProUGUI>()).color;
((Shadow)component).effectDistance = new Vector2(4f, 3f);
RectTransform component2 = val7.GetComponent<RectTransform>();
component2.anchorMin = new Vector2(0f, 0.5f);
component2.anchorMax = new Vector2(0f, 0.5f);
component2.sizeDelta = new Vector2(100f, 100f);
((Transform)component2).localPosition = new Vector3(-232f, 19f, 0f);
val7.GetComponent<Image>().sprite = Resources.GetBuiltinResource<Sprite>("UI/Skin/Knob.psd");
GameObject val8 = new GameObject("ProfileAvatar", new Type[2]
{
typeof(RectTransform),
typeof(RawImage)
});
val8.transform.SetParent(val7.transform, false);
RectTransform component3 = val8.GetComponent<RectTransform>();
component3.anchorMin = Vector2.zero;
component3.anchorMax = Vector2.one;
component3.sizeDelta = Vector2.zero;
val8.transform.localRotation = Quaternion.Euler(180f, 0f, 0f);
profileController.profileButton = val5.GetComponent<Button>();
profileController.addButton = val6.GetComponent<Button>();
profileController.avatarDisplay = val8.GetComponent<RawImage>();
profileController.parentSlider = __instance;
profileController.Refresh();
}
}
private static void HandleVisibility(AudioLevelSlider instance, Transform local, Transform kickBtn, Transform slider)
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
Transform val = local.Find("ProfileButton");
Transform val2 = local.Find("AddFriendButton");
if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
{
return;
}
if (instance.player.IsLocal)
{
if ((Object)(object)kickBtn != (Object)null)
{
((Component)kickBtn).gameObject.SetActive(false);
}
if ((Object)(object)slider != (Object)null)
{
((Component)slider).gameObject.SetActive(false);
}
val.localPosition = kickBtn.localPosition;
}
else
{
bool isMasterClient = PhotonNetwork.LocalPlayer.IsMasterClient;
if ((Object)(object)kickBtn != (Object)null)
{
((Component)kickBtn).gameObject.SetActive(isMasterClient);
}
if ((Object)(object)slider != (Object)null)
{
((Component)slider).gameObject.SetActive(true);
}
if (isMasterClient)
{
val.localPosition = kickBtn.localPosition + new Vector3(-55f, 0f, 0f);
}
else
{
val.localPosition = kickBtn.localPosition;
}
}
val2.localPosition = val.localPosition + new Vector3(-55f, 0f, 0f);
}
private static void CleanButton(GameObject btn, string iconPath)
{
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)btn.GetComponent<KickButton>()))
{
Object.Destroy((Object)(object)btn.GetComponent<KickButton>());
}
if (Object.op_Implicit((Object)(object)btn.GetComponent<Animator>()))
{
Object.Destroy((Object)(object)btn.GetComponent<Animator>());
}
Transform val = btn.transform.Find("KickIcon");
Texture2D val2 = IconFromEmbeddedResource(iconPath);
((Component)val).GetComponent<Image>().sprite = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f));
((Component)val).gameObject.SetActive(true);
val.localScale = new Vector3(0.7f, 0.7f, 0.7f);
}
private static bool isModInstalled(string guid)
{
return Chainloader.PluginInfos.ContainsKey(guid);
}
}
public class ProfileController : MonoBehaviour
{
public AudioLevelSlider parentSlider;
public Button profileButton;
public Button addButton;
public RawImage avatarDisplay;
private CSteamID currentSteamID = CSteamID.Nil;
public void Refresh()
{
//IL_0021: 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_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Invalid comparison between Unknown and I4
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Expected O, but got Unknown
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Expected O, but got Unknown
if (parentSlider?.player != null)
{
currentSteamID = Plugin.GetSteamId(parentSlider.player);
Texture2D steamAvatar = Plugin.GetSteamAvatar(currentSteamID);
if ((Object)(object)steamAvatar != (Object)null)
{
avatarDisplay.texture = (Texture)(object)steamAvatar;
}
((UnityEventBase)profileButton.onClick).RemoveAllListeners();
((UnityEventBase)addButton.onClick).RemoveAllListeners();
SetupButtonSFX(((Component)profileButton).gameObject);
SetupButtonSFX(((Component)addButton).gameObject);
EFriendRelationship friendRelationship = SteamFriends.GetFriendRelationship(currentSteamID);
bool isLocal = parentSlider.player.IsLocal;
bool flag = (int)friendRelationship == 3;
((Component)addButton).gameObject.SetActive(!flag && !isLocal);
((UnityEvent)profileButton.onClick).AddListener((UnityAction)delegate
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
PlaySFX(((Component)profileButton).gameObject, "SFX Click");
SteamFriends.ActivateGameOverlayToUser("steamid", currentSteamID);
});
((UnityEvent)addButton.onClick).AddListener((UnityAction)delegate
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
PlaySFX(((Component)addButton).gameObject, "SFX Click");
SteamFriends.ActivateGameOverlayToUser("friendadd", currentSteamID);
((Component)addButton).gameObject.SetActive(false);
});
}
}
private void SetupButtonSFX(GameObject btnObj)
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: 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_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Expected O, but got Unknown
//IL_00b9: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Expected O, but got Unknown
GameObject btnObj2 = btnObj;
EventTrigger val = btnObj2.GetComponent<EventTrigger>() ?? btnObj2.AddComponent<EventTrigger>();
val.triggers.Clear();
Transform icon = btnObj2.transform.Find("KickIcon");
Vector3 normalScale = new Vector3(0.7f, 0.7f, 0.7f);
Vector3 hoverScale = new Vector3(0.8f, 0.8f, 0.8f);
Entry val2 = new Entry
{
eventID = (EventTriggerType)0
};
((UnityEvent<BaseEventData>)(object)val2.callback).AddListener((UnityAction<BaseEventData>)delegate
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
PlaySFX(btnObj2, "SFX Hover");
if ((Object)(object)icon != (Object)null)
{
icon.localScale = hoverScale;
}
});
val.triggers.Add(val2);
Entry val3 = new Entry
{
eventID = (EventTriggerType)1
};
((UnityEvent<BaseEventData>)(object)val3.callback).AddListener((UnityAction<BaseEventData>)delegate
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)icon != (Object)null)
{
icon.localScale = normalScale;
}
});
val.triggers.Add(val3);
}
private void PlaySFX(GameObject parent, string childName)
{
Transform val = parent.transform.Find(childName);
if ((Object)(object)val != (Object)null)
{
((Component)val).gameObject.SetActive(false);
((Component)val).gameObject.SetActive(true);
}
}
private void OnDestroy()
{
Button obj = profileButton;
if (obj != null)
{
((UnityEventBase)obj.onClick).RemoveAllListeners();
}
Button obj2 = addButton;
if (obj2 != null)
{
((UnityEventBase)obj2.onClick).RemoveAllListeners();
}
}
}
[HarmonyPatch]
public class Patches
{
[HarmonyPostfix]
[HarmonyPatch(typeof(AudioLevelSlider), "Init")]
public static void AudioLevelSliderInit(AudioLevelSlider __instance)
{
if (__instance.player != null)
{
Plugin.CreateUI(__instance);
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}