using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PlayerMapNumbers")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Adds player map numbers")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+e0f27b3cb06d3582d43d1bfdea6e3f19571d71c5")]
[assembly: AssemblyProduct("PlayerMapNumbers")]
[assembly: AssemblyTitle("PlayerMapNumbers")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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 PlayerMapNumbers
{
[BepInPlugin("PlayerMapNumbers", "PlayerMapNumbers", "0.1.0")]
public class Plugin : BaseUnityPlugin
{
public static ManualLogSource StaticLogger;
private void Awake()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin PlayerMapNumbers is loaded!");
StaticLogger = ((BaseUnityPlugin)this).Logger;
Harmony val = new Harmony("PlayerMapNumbers");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Attempting to patch with Harmony!");
try
{
val.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Patching success!");
}
catch (Exception ex)
{
StaticLogger.LogError((object)("Failed to patch: " + ex));
}
}
public static void AddTargetNumber(GameObject target, int number)
{
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Expected O, but got Unknown
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
StaticLogger.LogInfo((object)$"Adding index {number}");
GameObject val = null;
PlayerControllerB component = target.GetComponent<PlayerControllerB>();
if ((Object)(object)component != (Object)null && component.isPlayerDead)
{
StaticLogger.LogInfo((object)"Dead");
if ((Object)(object)component.redirectToEnemy != (Object)null)
{
Transform obj = ((Component)component.redirectToEnemy).transform.Find("Misc");
object obj2;
if (obj == null)
{
obj2 = null;
}
else
{
Transform obj3 = obj.Find("MapDot");
obj2 = ((obj3 != null) ? ((Component)obj3).gameObject : null);
}
val = (GameObject)obj2;
}
else if ((Object)(object)component.deadBody != (Object)null)
{
StaticLogger.LogInfo((object)"Has body");
Transform obj4 = ((Component)component.deadBody).transform.Find("MapDot");
val = ((obj4 != null) ? ((Component)obj4).gameObject : null);
}
}
else
{
StaticLogger.LogInfo((object)"Not Dead");
Transform obj5 = target.transform.Find("Misc");
object obj6;
if (obj5 == null)
{
obj6 = null;
}
else
{
Transform obj7 = obj5.Find("MapDot");
obj6 = ((obj7 != null) ? ((Component)obj7).gameObject : null);
}
val = (GameObject)obj6;
}
if ((Object)(object)val == (Object)null)
{
StaticLogger.LogInfo((object)"Maybe Radar Booster");
Transform obj8 = target.transform.Find("RadarBoosterDot");
val = ((obj8 != null) ? ((Component)obj8).gameObject : null);
}
if ((Object)(object)val == (Object)null)
{
StaticLogger.LogWarning((object)"No parent findable");
return;
}
Transform obj9 = val.transform.Find("TargetNumberLabel");
GameObject val2 = ((obj9 != null) ? ((Component)obj9).gameObject : null);
TextMeshPro val3;
if ((Object)(object)val2 == (Object)null)
{
val2 = new GameObject();
val2.transform.SetParent(val.transform, false);
val2.transform.SetLocalPositionAndRotation(new Vector3(0f, 0.5f, 0f), Quaternion.Euler(new Vector3(90f, 0f, 0f)));
val2.transform.localScale = Vector3.one / 2f;
val2.layer = val.layer;
((Object)val2).name = "TargetNumberLabel";
val2.AddComponent<KeepNorth>();
val3 = val2.AddComponent<TextMeshPro>();
((TMP_Text)val3).alignment = (TextAlignmentOptions)514;
((TMP_Text)val3).autoSizeTextContainer = true;
((TMP_Text)val3).maxVisibleLines = 1;
((TMP_Text)val3).maxVisibleWords = 1;
}
else
{
val3 = ((Component)val2.transform).GetComponent<TextMeshPro>();
}
((TMP_Text)val3).text = (1 + number).ToString();
}
public static void UpdateNumbers()
{
if ((Object)(object)StartOfRound.Instance?.mapScreen == (Object)null)
{
return;
}
for (int i = 0; i < StartOfRound.Instance.mapScreen.radarTargets.Count; i++)
{
TransformAndName val = StartOfRound.Instance.mapScreen.radarTargets[i];
if ((Object)(object)val.transform != (Object)null)
{
StaticLogger.LogInfo((object)$"Name: {val.name} index: {i} isNonPlayer: {val.isNonPlayer}");
AddTargetNumber(((Component)val.transform).gameObject, i);
}
}
}
}
public class KeepNorth : MonoBehaviour
{
public void Awake()
{
}
public void Update()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
((Component)this).gameObject.transform.rotation = Quaternion.Euler(90f, -45f, 0f);
}
}
[HarmonyPatch(typeof(ManualCameraRenderer), "Awake")]
public static class ManualCameraRendererAwakePatch
{
public static void Postfix(ManualCameraRenderer __instance)
{
Plugin.StaticLogger.LogInfo((object)"ManualCameraRendererAwakePatch patch run");
NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager;
if (!((Object)(object)networkManager == (Object)null) && networkManager.IsListening)
{
Plugin.UpdateNumbers();
}
}
}
[HarmonyPatch(typeof(ManualCameraRenderer), "RemoveTargetFromRadar")]
public static class ManualCameraRendererRemoveTargetFromRadarPatch
{
public static void Postfix(ManualCameraRenderer __instance, Transform removeTransform)
{
Plugin.StaticLogger.LogInfo((object)"ManualCameraRendererRemoveTargetFromRadarPatch patch run");
Plugin.UpdateNumbers();
}
}
[HarmonyPatch(typeof(ManualCameraRenderer), "AddTransformAsTargetToRadar")]
public static class ManualCameraRendererAddTransformAsTargetToRadarPatch
{
public static void Postfix(ManualCameraRenderer __instance, Transform newTargetTransform, string targetName, bool isNonPlayer)
{
Plugin.StaticLogger.LogInfo((object)"ManualCameraRendererAddTransformAsTargetToRadarPatch patch run");
Plugin.UpdateNumbers();
}
}
[HarmonyPatch(typeof(PlayerControllerB), "SendNewPlayerValuesClientRpc")]
public static class SendNewPlayerValuesClientRpcPatch
{
public static void Postfix(PlayerControllerB __instance, ref ulong[] playerSteamIds)
{
Plugin.StaticLogger.LogInfo((object)"SendNewPlayerValuesClientRpcPatch patch run");
Plugin.UpdateNumbers();
}
}
[HarmonyPatch(typeof(PlayerControllerB), "SendNewPlayerValuesServerRpc")]
public static class SendNewPlayerValuesServerRpcPatch
{
public static void Postfix(PlayerControllerB __instance, ulong newPlayerSteamId)
{
Plugin.StaticLogger.LogInfo((object)"SendNewPlayerValuesServerRpcPatch patch run");
Plugin.UpdateNumbers();
}
}
[HarmonyPatch(typeof(PlayerControllerB), "SpawnDeadBody")]
public static class SpawnDeadBodyPatch
{
public static void Postfix(PlayerControllerB __instance)
{
Plugin.StaticLogger.LogInfo((object)"SpawnDeadBodyPatch patch run");
Plugin.UpdateNumbers();
}
}
[HarmonyPatch(typeof(PlayerControllerB), "KillPlayerServerRpc")]
public static class KillPlayerServerRpcPatch
{
public static void Postfix(PlayerControllerB __instance)
{
Plugin.StaticLogger.LogInfo((object)"KillPlayerServerRpcPatch patch run");
Plugin.UpdateNumbers();
}
}
[HarmonyPatch(typeof(PlayerControllerB), "KillPlayerClientRpc")]
public static class KillPlayerClientRpcPatch
{
public static void Postfix(PlayerControllerB __instance)
{
Plugin.StaticLogger.LogInfo((object)"KillPlayerClientRpcPatch patch run");
Plugin.UpdateNumbers();
}
}
[HarmonyPatch(typeof(Terminal), "ParsePlayerSentence")]
public static class TerminalParsePlayerSentencePatch
{
private static string RemovePunctuation(string s)
{
StringBuilder stringBuilder = new StringBuilder();
foreach (char c in s)
{
if (!char.IsPunctuation(c))
{
stringBuilder.Append(c);
}
}
return stringBuilder.ToString().ToLower();
}
public static void Postfix(Terminal __instance, ref TerminalNode __result)
{
Plugin.StaticLogger.LogInfo((object)"TerminalParsePlayerSentence patch run");
if (!((Object)(object)__result == (Object)(object)__instance.terminalNodes.specialNodes[10]))
{
return;
}
Plugin.StaticLogger.LogInfo((object)"Extended Parse");
string[] array = RemovePunctuation(__instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded)).Split(" ", StringSplitOptions.RemoveEmptyEntries);
if (array.Length != 1 || !int.TryParse(array[0], out var result))
{
return;
}
Plugin.StaticLogger.LogInfo((object)"Number Found");
int num = result - 1;
if (num < StartOfRound.Instance.mapScreen.radarTargets.Count)
{
Plugin.StaticLogger.LogInfo((object)"Valid Number");
PlayerControllerB component = ((Component)StartOfRound.Instance.mapScreen.radarTargets[num].transform).gameObject.GetComponent<PlayerControllerB>();
if (!((Object)(object)component != (Object)null) || component.isPlayerControlled || component.isPlayerDead || !((Object)(object)component.redirectToEnemy == (Object)null))
{
StartOfRound.Instance.mapScreen.SwitchRadarTargetAndSync(num);
Plugin.StaticLogger.LogInfo((object)"Updated Target");
__result = __instance.terminalNodes.specialNodes[20];
}
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "PlayerMapNumbers";
public const string PLUGIN_NAME = "PlayerMapNumbers";
public const string PLUGIN_VERSION = "0.1.0";
}
}