using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using Nameplates.Component;
using Photon.Realtime;
using Steamworks;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using Zorro.Core.CLI;
[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: AssemblyCompany("Nameplates")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+fd844156fc75ac346262dd4fba25311a8288fc9f")]
[assembly: AssemblyProduct("Nameplates")]
[assembly: AssemblyTitle("Nameplates")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
}
}
}
namespace Nameplates
{
internal static class Extensions
{
internal static Player Photon(this Player player)
{
return player.refs.view.Owner;
}
internal static Camera Camera(this MainCamera camera)
{
return ((Component)camera).GetComponent<Camera>();
}
internal static ulong SteamID(this Player player)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
CSteamID val = default(CSteamID);
SteamAvatarHandler.TryGetSteamIDForPlayer(player, ref val);
return val.m_SteamID;
}
}
internal class NameplateConfig
{
private static ConfigEntry<bool> _showNameplates;
private static ConfigEntry<bool> _displayHealth;
private static ConfigEntry<bool> _healthNewLine;
private static ConfigEntry<bool> _useHealthColors;
private static ConfigEntry<float> _fontSize;
private static ConfigEntry<float> _heightOffset;
public static bool ShowNameplates
{
get
{
return _showNameplates.Value;
}
set
{
_showNameplates.Value = value;
}
}
public static bool DisplayHealth
{
get
{
return _displayHealth.Value;
}
set
{
_displayHealth.Value = value;
}
}
public static bool HealthNewLine
{
get
{
return _healthNewLine.Value;
}
set
{
_healthNewLine.Value = value;
}
}
public static bool UseHealthColors
{
get
{
return _useHealthColors.Value;
}
set
{
_useHealthColors.Value = value;
}
}
public static float FontSize
{
get
{
return _fontSize.Value;
}
set
{
_fontSize.Value = value;
}
}
public static float HeightOffset
{
get
{
return _heightOffset.Value;
}
set
{
_heightOffset.Value = value;
}
}
internal static void Bind(ConfigFile config)
{
_showNameplates = config.Bind<bool>("General", "Show Nameplates", true, "Show nameplates above players");
_displayHealth = config.Bind<bool>("General", "Display Health", true, "Display player health in nameplates");
_healthNewLine = config.Bind<bool>("General", "Health on New Line", false, "Display player health on a new line");
_useHealthColors = config.Bind<bool>("General", "Use Health Colors", false, "Use colors to indicate player health");
_fontSize = config.Bind<float>("General", "Font Size", 1.5f, "Font size of the nameplate text");
_heightOffset = config.Bind<float>("General", "Height Offset", 0.5f, "How high above the players head the nameplate will be");
}
}
[ContentWarningPlugin("com.icyrelic.nameplates", "1.0.3", true)]
[BepInPlugin("com.icyrelic.nameplates", "Nameplates", "1.0.3")]
public class NameplateMod : BaseUnityPlugin
{
public const string ModGuid = "com.icyrelic.nameplates";
public const string ModName = "Nameplates";
public const string ModVersion = "1.0.3";
private List<Nameplate> nameplates = new List<Nameplate>();
private void Awake()
{
NameplateConfig.Bind(((BaseUnityPlugin)this).Config);
}
private void Update()
{
if (!NameplateConfig.ShowNameplates)
{
nameplates.ForEach(delegate(Nameplate x)
{
DestroyNameplate(x);
});
return;
}
nameplates.ToList().FindAll((Nameplate x) => x.isDestroyed || !PlayerHandler.instance.playersAlive.Any((Player p) => x.data.steamId == p.Photon().SteamID())).ForEach(delegate(Nameplate x)
{
DestroyNameplate(x);
});
PlayerHandler.instance.playersAlive.FindAll((Player p) => !HasNameplate(p) && !p.IsLocal).ForEach(delegate(Player p)
{
CreateNameplate(p);
});
}
private bool HasNameplate(Player p)
{
Player p2 = p;
return nameplates.ToList().Any((Nameplate x) => x.data.steamId == p2.Photon().SteamID());
}
private void DestroyNameplate(Nameplate np)
{
if (!np.isDestroyed)
{
Object.Destroy((Object)(object)((Component)np).gameObject);
}
nameplates.Remove(np);
}
private void CreateNameplate(Player p)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
GameObject val = new GameObject($"Nameplate-{p.Photon().SteamID()}");
NameplateData nameplateData = val.AddComponent<NameplateData>();
nameplateData.player = p;
nameplateData.steamId = p.Photon().SteamID();
nameplates.Add(val.AddComponent<Nameplate>());
}
}
internal class NP
{
[ConsoleCommand]
public static void ToggleDisplayHealth()
{
NameplateConfig.DisplayHealth = !NameplateConfig.DisplayHealth;
}
[ConsoleCommand]
public static void ToggleHealthNewLine()
{
NameplateConfig.HealthNewLine = !NameplateConfig.HealthNewLine;
}
[ConsoleCommand]
public static void ToggleNameplates()
{
NameplateConfig.ShowNameplates = !NameplateConfig.ShowNameplates;
}
[ConsoleCommand]
public static void ToggleUseColors()
{
NameplateConfig.UseHealthColors = !NameplateConfig.UseHealthColors;
}
[ConsoleCommand]
public static void SetFontSize(float size)
{
NameplateConfig.FontSize = size;
}
[ConsoleCommand]
public static void SetHeightOffset(float offset)
{
NameplateConfig.HeightOffset = offset;
}
}
}
namespace Nameplates.Component
{
internal class Nameplate : MonoBehaviour
{
public TextMeshPro tmp;
public NameplateData data;
public bool isDestroyed = false;
private void Awake()
{
data = ((Component)this).gameObject.GetComponent<NameplateData>();
tmp = ((Component)this).gameObject.AddComponent<TextMeshPro>();
((TMP_Text)tmp).alignment = (TextAlignmentOptions)514;
((Component)this).gameObject.transform.SetParent(data.player.refs.cameraPos);
}
private void Update()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
((Graphic)tmp).color = (NameplateConfig.UseHealthColors ? Color.Lerp(Color.red, Color.green, data.player.data.health / PlayerData.maxHealth) : Color.white);
((TMP_Text)tmp).fontSize = NameplateConfig.FontSize;
((TMP_Text)tmp).text = data.player.Photon().NickName;
if (NameplateConfig.DisplayHealth)
{
TextMeshPro obj = tmp;
((TMP_Text)obj).text = ((TMP_Text)obj).text + (NameplateConfig.HealthNewLine ? "\n" : " ");
TextMeshPro obj2 = tmp;
((TMP_Text)obj2).text = ((TMP_Text)obj2).text + $"({Math.Round(data.player.data.health / PlayerData.maxHealth * 100f)}%)";
}
Vector3 position = data.player.refs.cameraPos.position;
position.y += NameplateConfig.HeightOffset;
tmp.transform.position = position;
tmp.transform.LookAt(((Component)MainCamera.instance.Camera()).transform);
tmp.transform.Rotate(Vector3.up, 180f);
}
private void OnDestroy()
{
isDestroyed = true;
}
}
internal class NameplateData : MonoBehaviour
{
public Player player;
public ulong steamId;
}
}