using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;
[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("PlayerDistanceDisplay")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("My first plugin")]
[assembly: AssemblyTitle("PlayerDistanceDisplay")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace PlayerDistanceDisplay
{
[BepInPlugin("org.bepinex.plugins.welniany.playerdistancedisplay", "PlayerDistanceDisplay", "1.2.0.0")]
[BepInProcess("PEAK.exe")]
public class Plugin : BaseUnityPlugin
{
private void Awake()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogInfo((object)"PlayerDistanceDisplay loaded!");
GameObject val = new GameObject("PlayerDistanceDisplayManager");
Object.DontDestroyOnLoad((Object)(object)val);
val.AddComponent<PlayerDistanceDisplayManager>();
}
}
public class PlayerDistanceDisplayManager : MonoBehaviour
{
private class PlayerLabelData
{
public Transform target;
public string nick;
public float spawnTime;
public float distance;
public float nextDistanceUpdate;
public Vector3 screenPos;
public bool isActive;
}
public float labelAliveTime = 8f;
public float distanceUpdateInterval = 0.2f;
private Camera mainCamera;
private List<PlayerLabelData> labels = new List<PlayerLabelData>();
private bool labelsVisible = false;
private void Start()
{
mainCamera = Camera.main;
SceneManager.activeSceneChanged += OnSceneChanged;
}
private void OnDestroy()
{
SceneManager.activeSceneChanged -= OnSceneChanged;
}
private void OnSceneChanged(Scene oldScene, Scene newScene)
{
labels.Clear();
}
private void Update()
{
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: 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_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)mainCamera == (Object)null)
{
mainCamera = Camera.main;
}
labels.RemoveAll((PlayerLabelData label) => (Object)(object)label.target == (Object)null || !((Component)label.target).gameObject.activeInHierarchy);
if (Input.GetKeyDown((KeyCode)116))
{
labelsVisible = !labelsVisible;
if (labelsVisible)
{
ActivateLabels();
}
else
{
foreach (PlayerLabelData label in labels)
{
label.isActive = false;
}
}
}
if (!labelsVisible)
{
return;
}
foreach (PlayerLabelData label2 in labels)
{
if (label2.isActive)
{
if (Time.time > label2.nextDistanceUpdate)
{
label2.distance = Vector3.Distance(((Component)mainCamera).transform.position, label2.target.position);
label2.nextDistanceUpdate = Time.time + distanceUpdateInterval;
}
Vector3 val = label2.target.position + Vector3.up * 1.2f;
label2.screenPos = mainCamera.WorldToScreenPoint(val);
if (Time.time - label2.spawnTime > labelAliveTime)
{
label2.isActive = false;
}
}
}
}
private void ActivateLabels()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: 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_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: 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)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
int num = LayerMask.NameToLayer("Character");
Scene activeScene = SceneManager.GetActiveScene();
GameObject[] rootGameObjects = ((Scene)(ref activeScene)).GetRootGameObjects();
foreach (GameObject val in rootGameObjects)
{
if (val.layer != num)
{
continue;
}
Transform charLight = val.transform.Find("Scout/Misc/CharacterLight");
if (!((Object)(object)charLight == (Object)null))
{
PlayerLabelData playerLabelData = labels.Find((PlayerLabelData l) => (Object)(object)l.target == (Object)(object)charLight);
if (playerLabelData != null)
{
playerLabelData.isActive = true;
playerLabelData.spawnTime = Time.time;
Vector3 val2 = charLight.position + Vector3.up * 1.2f;
playerLabelData.screenPos = mainCamera.WorldToScreenPoint(val2);
playerLabelData.distance = Vector3.Distance(((Component)mainCamera).transform.position, charLight.position);
playerLabelData.nextDistanceUpdate = Time.time + distanceUpdateInterval;
}
else
{
string nick = ExtractDisplayName(((Object)val).name);
Vector3 val3 = charLight.position + Vector3.up * 1.2f;
Vector3 screenPos = mainCamera.WorldToScreenPoint(val3);
labels.Add(new PlayerLabelData
{
target = charLight,
nick = nick,
spawnTime = Time.time,
distance = Vector3.Distance(((Component)mainCamera).transform.position, charLight.position),
nextDistanceUpdate = Time.time + distanceUpdateInterval,
screenPos = screenPos,
isActive = true
});
}
}
}
}
private string ExtractDisplayName(string objName)
{
int num = objName.IndexOf('[');
int num2 = objName.LastIndexOf(':');
if (num != -1 && num2 != -1)
{
return objName.Substring(num + 1, num2 - num - 1).Trim();
}
return objName;
}
private void OnGUI()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: 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_003e: Expected O, but got Unknown
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Expected O, but got Unknown
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_0282: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: Expected O, but got Unknown
//IL_0287: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: Unknown result type (might be due to invalid IL or missing references)
//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
//IL_037d: Unknown result type (might be due to invalid IL or missing references)
//IL_0345: Unknown result type (might be due to invalid IL or missing references)
if (!labelsVisible)
{
return;
}
GUIStyle val = new GUIStyle(GUI.skin.label)
{
fontSize = 20,
fontStyle = (FontStyle)1,
alignment = (TextAnchor)4
};
Color white = Color.white;
val.normal.textColor = white;
val.hover.textColor = white;
val.active.textColor = white;
val.focused.textColor = white;
val.onNormal.textColor = white;
val.onHover.textColor = white;
val.onActive.textColor = white;
val.onFocused.textColor = white;
val.normal.background = null;
val.hover.background = null;
val.active.background = null;
val.focused.background = null;
val.onNormal.background = null;
val.onHover.background = null;
val.onActive.background = null;
val.onFocused.background = null;
GUIStyle val2 = new GUIStyle(val);
Color black = Color.black;
val2.normal.textColor = black;
val2.hover.textColor = black;
val2.active.textColor = black;
val2.focused.textColor = black;
val2.onNormal.textColor = black;
val2.onHover.textColor = black;
val2.onActive.textColor = black;
val2.onFocused.textColor = black;
val2.normal.background = null;
val2.hover.background = null;
val2.active.background = null;
val2.focused.background = null;
val2.onNormal.background = null;
val2.onHover.background = null;
val2.onActive.background = null;
val2.onFocused.background = null;
Rect val4 = default(Rect);
foreach (PlayerLabelData label in labels)
{
if (!label.isActive || label.screenPos.z <= 0f || label.distance < 10f || label.distance > 600f)
{
continue;
}
string text = $"{label.nick}: {label.distance:F0}m";
Vector2 val3 = val.CalcSize(new GUIContent(text));
float num = 12f;
float num2 = (float)Screen.height - label.screenPos.y;
((Rect)(ref val4))..ctor(label.screenPos.x - val3.x / 2f - num, num2 - val3.y / 2f - num / 2f, val3.x + num * 2f, val3.y + num);
for (int i = -1; i <= 1; i++)
{
for (int j = -1; j <= 1; j++)
{
if (i != 0 || j != 0)
{
GUI.Label(new Rect(((Rect)(ref val4)).x + (float)i, ((Rect)(ref val4)).y + (float)j, ((Rect)(ref val4)).width, ((Rect)(ref val4)).height), text, val2);
}
}
}
GUI.Label(val4, text, val);
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "PlayerDistanceDisplay";
public const string PLUGIN_NAME = "My first plugin";
public const string PLUGIN_VERSION = "1.0.0";
}
}