using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using Microsoft.CodeAnalysis;
using MonitorLabels.BaseClasses;
using MonitorLabels.Components;
using MonitorLabels.Components.Tools;
using MonitorLabels.Constants;
using MonitorLabels.Dependencies.LethalConfig;
using MonitorLabels.ExtensionMethods;
using MonitorLabels.Structs;
using MonitorLabels.Utils;
using MonitorLabels.Utils.ModUtils;
using TMPro;
using Unity.Netcode;
using UnityEngine;
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("DannyVD")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Adds a label to the icons on the monitor for players, radar boosters, enemies and scrap")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyInformationalVersion("2.0.0+0bbf54eabf9e2f14bfcf5bd92e03759ea900af7d")]
[assembly: AssemblyProduct("MonitorLabels")]
[assembly: AssemblyTitle("MonitorLabels")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.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 MonitorLabels
{
public static class AIMapLabelManager
{
public static readonly Dictionary<Type, CustomLabelData> CustomAINames = new Dictionary<Type, CustomLabelData>();
public static bool TryAddNewAI(Type type, CustomLabelData labelData)
{
return CustomAINames.TryAdd(type, labelData);
}
public static bool TryAddNewAI(Type type, string label, bool showLabel = true)
{
return CustomAINames.TryAdd(type, new CustomLabelData(label, showLabel));
}
public static void SetAI(Type type, CustomLabelData customLabelData)
{
CustomAINames[type] = customLabelData;
}
public static void SetAI(Type type, string label, bool showLabel = true)
{
SetAI(type, new CustomLabelData(label, showLabel));
}
public static void RemoveAI(Type type)
{
CustomAINames.Remove(type);
}
public static void AddLabelToAI(EnemyAI enemyAI)
{
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: 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_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
bool showLabel;
string aILabel = GetAILabel(enemyAI, out showLabel);
if (!showLabel)
{
return;
}
Transform mapDot = MapLabelUtil.GetMapDot(((Component)enemyAI).transform);
if (mapDot == null)
{
LoggerUtil.LogWarning("Child MapDot cannot be found for enemy: " + ((Object)((Component)enemyAI).gameObject).name);
return;
}
if (enemyAI is SandSpiderAI)
{
Vector3 localScale = mapDot.localScale;
float num = Mathf.Max(new float[3] { localScale.x, localScale.y, localScale.z });
mapDot.localScale = new Vector3(num, num, num);
}
TMP_Text obj = MapLabelUtil.AddLabelObject(((Component)mapDot).gameObject, ConfigUtil.EnemyLabelOffset.Value);
((Graphic)obj).color = ConfigUtil.EnemyLabelColour.Value;
obj.text = aILabel;
}
public static void UpdateAILabel(EnemyAI enemyAI)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
Transform mapDot = MapLabelUtil.GetMapDot(((Component)enemyAI).transform);
if (mapDot == null)
{
return;
}
MapLabelUtil.GetRadarLabel(mapDot, out var label);
if (label != null)
{
if (!ConfigUtil.ShowLabelOnDeadEnemies.Value)
{
Object.Destroy((Object)(object)((Component)label).gameObject);
}
else
{
((Graphic)label).color = ConfigUtil.DeadEnemyLabelColour.Value;
}
}
}
private static string GetAILabel(EnemyAI enemyAI, out bool showLabel)
{
showLabel = true;
if (!(enemyAI is BaboonBirdAI))
{
if (!(enemyAI is BlobAI))
{
if (!(enemyAI is CentipedeAI))
{
if (!(enemyAI is CrawlerAI))
{
if (!(enemyAI is DocileLocustBeesAI))
{
if (!(enemyAI is DoublewingAI))
{
if (!(enemyAI is DressGirlAI))
{
if (!(enemyAI is FlowermanAI))
{
if (!(enemyAI is ForestGiantAI))
{
if (!(enemyAI is HoarderBugAI))
{
if (!(enemyAI is JesterAI))
{
if (!(enemyAI is LassoManAI))
{
if (!(enemyAI is MaskedPlayerEnemy))
{
if (!(enemyAI is MouthDogAI))
{
if (!(enemyAI is NutcrackerEnemyAI))
{
if (!(enemyAI is PufferAI))
{
if (!(enemyAI is SandSpiderAI))
{
if (!(enemyAI is SandWormAI))
{
if (!(enemyAI is SpringManAI))
{
if (!(enemyAI is TestEnemy))
{
if (!(enemyAI is ButlerEnemyAI))
{
if (!(enemyAI is RadMechAI))
{
if (enemyAI is FlowerSnakeEnemy)
{
if (ConfigUtil.HideLabelOnSomeEnemies.Value)
{
showLabel = false;
}
return ConfigUtil.FlowerSnakeLabel.Value;
}
return GetUnknownAILabel(enemyAI, out showLabel);
}
return ConfigUtil.RadMechLabel.Value;
}
return ConfigUtil.ButlerLabel.Value;
}
return "Obunga";
}
return ConfigUtil.CoilHeadLabel.Value;
}
if (ConfigUtil.HideLabelOnSomeEnemies.Value)
{
showLabel = false;
}
return ConfigUtil.SandWormLabel.Value;
}
return ConfigUtil.SpiderLabel.Value;
}
return ConfigUtil.SporeLizardLabel.Value;
}
return ConfigUtil.NutCrackerLabel.Value;
}
return ConfigUtil.DogLabel.Value;
}
return ConfigUtil.MaskedLabel.Value;
}
return "Lasso";
}
return ConfigUtil.JesterLabel.Value;
}
return ConfigUtil.HoarderBugLabel.Value;
}
return ConfigUtil.ForestGiantLabel.Value;
}
return ConfigUtil.BrackenLabel.Value;
}
showLabel = false;
return "Girl";
}
if (ConfigUtil.HideLabelOnSomeEnemies.Value)
{
showLabel = false;
}
return ConfigUtil.ManticoilLabel.Value;
}
showLabel = false;
return "Bees";
}
return ConfigUtil.CrawlerLabel.Value;
}
return ConfigUtil.CentipedeLabel.Value;
}
return ConfigUtil.BlobLabel.Value;
}
return ConfigUtil.BaboonHawkLabel.Value;
}
private static string GetUnknownAILabel(EnemyAI enemyAISubclassInstance, out bool showLabel)
{
foreach (KeyValuePair<Type, CustomLabelData> customAIName in CustomAINames)
{
if (customAIName.Key.IsInstanceOfType(enemyAISubclassInstance))
{
showLabel = customAIName.Value.ShowLabel;
return customAIName.Value.Label;
}
}
showLabel = true;
string value = ConfigUtil.UnknownLabel.Value;
if (!value.Equals(string.Empty))
{
return value;
}
return MapLabelUtil.RemoveCloneFromString(((Object)((Component)enemyAISubclassInstance).gameObject).name).InsertSpaceBeforeCapitals();
}
}
[BepInPlugin("DannyVD.mods.LethalCompany.MonitorLabels", "MonitorLabels", "2.0.0")]
[BepInProcess("Lethal Company.exe")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class MonitorLabelsPlugin : BaseUnityPlugin
{
public const string GUID = "DannyVD.mods.LethalCompany.MonitorLabels";
public const string PLUGIN_NAME = "MonitorLabels";
public const string PLUGIN_VERSION = "2.0.0";
public const string DEPENDENCY_STRING = "DannyVD-MonitorLabels-2.0.0";
private void Awake()
{
ConfigUtil.Initialize(((BaseUnityPlugin)this).Config);
ConfigUtil.ReadConfig();
LoggerUtil.Initialize(ConfigUtil.LoggingLevel, ((BaseUnityPlugin)this).Logger);
LoggerUtil.Log((LogLevel)16, "Plugin DannyVD-MonitorLabels-2.0.0 is loaded!");
PatchUtil.PatchFunctions();
DependencyUtils.CheckDependencies();
}
}
internal static class ObjectLabelManager
{
internal static void TryAddLabelToScrap(GrabbableObject item)
{
Transform radarIcon = item.radarIcon;
if (!((Object)(object)radarIcon == (Object)null))
{
AddLabelToScrap(item, ((Component)radarIcon).gameObject);
}
}
internal static void UpdateScrapLabel(GrabbableObject item)
{
UpdateItemSlotLabel(item, null, null);
}
internal static void UpdateItemSlotLabel(GrabbableObject item, GrabbableObject firstToolInItemSlots, GrabbableObject firstToolInUseInItemSlots)
{
Transform radarIcon = item.radarIcon;
if ((Object)(object)radarIcon == (Object)null)
{
return;
}
ContinuouslyUpdateToolLabel component = ((Component)item).GetComponent<ContinuouslyUpdateToolLabel>();
if (!((Object)(object)component != (Object)null) || !component.IsUpdating)
{
MapLabelUtil.GetRadarLabel(radarIcon, out var label);
if (label != null)
{
SetScrapLabel(item, label, firstToolInItemSlots, firstToolInUseInItemSlots);
}
}
}
internal static void SetScrapLabel(GrabbableObject item, TMP_Text radarLabel, GrabbableObject firstToolInItemSlots = null, GrabbableObject firstToolInUseInItemSlots = null)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
radarLabel.text = GetScrapLabelString(item, out var labelColour, firstToolInItemSlots, firstToolInUseInItemSlots);
((Graphic)radarLabel).color = labelColour;
}
private static void AddLabelToScrap(GrabbableObject item, GameObject radarParent)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
bool isScrap = item.itemProperties.isScrap;
TMP_Text val = MapLabelUtil.AddLabelObject(radarParent, isScrap ? ConfigUtil.ScrapLabelOffset.Value : ConfigUtil.ToolLabelOffset.Value, continuouslyUpdateRotationAndOffset: false);
if (isScrap)
{
val.fontSize *= ConfigUtil.ScrapLabelScaleFactor.Value;
}
else
{
val.fontSize = ConfigUtil.ToolLabelFontSize.Value;
}
SetScrapLabel(item, val);
if (item.itemProperties.requiresBattery && ConfigUtil.ShowBatteryChargeOnLabel.Value)
{
((Component)item).gameObject.AddComponent<ContinuouslyUpdateToolLabel>().Initialize(item, val);
}
}
private static string GetScrapLabelString(GrabbableObject item, out Color labelColour, GrabbableObject firstToolInItemSlots, GrabbableObject firstToolInUseInItemSlots)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0249: Unknown result type (might be due to invalid IL or missing references)
//IL_024e: Unknown result type (might be due to invalid IL or missing references)
//IL_0224: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: 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_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0274: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)item == (Object)null)
{
labelColour = Color.white;
return string.Empty;
}
bool flag = !item.itemProperties.isScrap;
int scrapValue = item.scrapValue;
if (item.isHeld)
{
if (flag && (Object)(object)item.playerHeldBy != (Object)null)
{
labelColour = ConfigUtil.CarriedToolLabelColour.Value;
GrabbableObject currentlyHeldObjectServer = item.playerHeldBy.currentlyHeldObjectServer;
bool flag2 = (Object)(object)currentlyHeldObjectServer != (Object)null && !currentlyHeldObjectServer.itemProperties.isScrap;
if (item.isPocketed && ConfigUtil.HideToolLabelIfPocketed.Value)
{
if (!item.isBeingUsed || !ConfigUtil.ShowToolIfInUseAndNoOtherToolHeld.Value || flag2)
{
return string.Empty;
}
if (ConfigUtil.OnlyShow1PocketedLabel.Value)
{
GrabbableObject val = ((IEnumerable<GrabbableObject>)item.playerHeldBy.ItemSlots).FirstOrDefault((Func<GrabbableObject, bool>)((GrabbableObject grabbableObject) => (Object)(object)grabbableObject != (Object)null && grabbableObject.isBeingUsed));
if ((Object)(object)item != (Object)(object)val)
{
return string.Empty;
}
}
}
else if (item.isPocketed && ConfigUtil.OnlyShow1PocketedLabel.Value)
{
if (flag2 && !ConfigUtil.HideToolLabelIfInHand.Value)
{
return string.Empty;
}
if (ConfigUtil.ShowToolIfInUseAndNoOtherToolHeld.Value)
{
if ((Object)(object)firstToolInUseInItemSlots != (Object)null)
{
if ((Object)(object)firstToolInUseInItemSlots != (Object)(object)item)
{
return string.Empty;
}
}
else if ((Object)(object)firstToolInItemSlots != (Object)(object)item)
{
return string.Empty;
}
}
else if ((Object)(object)item != (Object)(object)firstToolInItemSlots)
{
return string.Empty;
}
}
else if (!item.isPocketed && ConfigUtil.HideToolLabelIfInHand.Value)
{
return string.Empty;
}
}
else if (flag)
{
labelColour = ConfigUtil.CarriedToolLabelColour.Value;
if (ConfigUtil.HideToolLabelIfInHand.Value)
{
return string.Empty;
}
}
else
{
labelColour = ConfigUtil.CarriedScrapLabelColour.Value;
if (ConfigUtil.HideScrapLabelIfCarried.Value)
{
return string.Empty;
}
}
}
else if (item.isInShipRoom)
{
if (flag)
{
labelColour = ConfigUtil.InShipToolLabelColour.Value;
if (ConfigUtil.HideToolLabelIfOnShip.Value)
{
return string.Empty;
}
}
else
{
labelColour = ConfigUtil.InShipScrapLabelColour.Value;
if (ConfigUtil.HideScrapLabelIfOnShip.Value)
{
return string.Empty;
}
}
}
else if (flag)
{
labelColour = ConfigUtil.ToolLabelColour.Value;
}
else
{
labelColour = ((scrapValue >= ConfigUtil.HighValueScrapThreshold.Value) ? ConfigUtil.HighValueScrapLabelColour.Value : ConfigUtil.ScrapLabelColour.Value);
}
if (TryGetCustomLabel(item, out var label))
{
return label;
}
return GetFormattedScrapLabel(item, scrapValue, flag);
}
private static bool TryGetCustomLabel(GrabbableObject item, out string label)
{
label = string.Empty;
if (ConfigUtil.HideScrapLabelOnNutcracker.Value && item is ShotgunItem && item.isHeldByEnemy)
{
return true;
}
return false;
}
private static string GetFormattedScrapLabel(GrabbableObject item, int scrapValue, bool isTool)
{
string scrapName = GetScrapName(item);
if (isTool)
{
string arg = string.Empty;
if (item.itemProperties.requiresBattery && ConfigUtil.ShowBatteryChargeOnLabel.Value && item.insertedBattery != null)
{
float num = (item.insertedBattery.empty ? 0f : item.insertedBattery.charge);
arg = string.Format(ConfigUtil.ToolBatteryStringFormat.Value, num);
}
return string.Format(ConfigUtil.ToolLabelStringFormat.Value, scrapName, arg);
}
return string.Format(ConfigUtil.ScrapLabelStringFormat.Value, scrapName, scrapValue);
}
private static string GetScrapName(GrabbableObject item)
{
Item itemProperties = item.itemProperties;
if (Object.op_Implicit((Object)(object)itemProperties) && !string.IsNullOrEmpty(itemProperties.itemName))
{
return itemProperties.itemName;
}
ScanNodeProperties componentInChildren = ((Component)item).GetComponentInChildren<ScanNodeProperties>();
if (Object.op_Implicit((Object)(object)componentInChildren))
{
return componentInChildren.headerText;
}
return MapLabelUtil.RemoveCloneFromString(((Object)((Component)item).gameObject).name).InsertSpaceBeforeCapitals();
}
}
internal static class Patches
{
[HarmonyPatch(typeof(ManualCameraRenderer), "Awake")]
[HarmonyPostfix]
[HarmonyPriority(200)]
private static void ManualCameraRendererAwakePatch(ManualCameraRenderer __instance)
{
LoggerUtil.LogDebug("ManualCameraRenderer.Awake patch run");
NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager;
if (!((Object)(object)networkManager == (Object)null) && networkManager.IsListening)
{
RadarTargetLabelManager.UpdateLabels();
if (__instance.mapCamera != null)
{
((Component)__instance.mapCamera).gameObject.AddComponent<MapCameraRotationObserver>();
}
}
}
[HarmonyPatch(typeof(ManualCameraRenderer), "AddTransformAsTargetToRadar")]
[HarmonyPostfix]
[HarmonyPriority(200)]
private static void ManualCameraRendererAddTransformAsTargetToRadarPatch()
{
LoggerUtil.LogDebug("ManualCameraRenderer.AddTransformAsTargetToRadar patch run");
RadarTargetLabelManager.UpdateLabels();
}
[HarmonyPatch(typeof(ManualCameraRenderer), "updateMapTarget")]
[HarmonyPostfix]
[HarmonyPriority(200)]
private static void ManualCameraRendererUpdateMapTargetPatch(int setRadarTargetIndex, bool calledFromRPC = true)
{
if (calledFromRPC)
{
LoggerUtil.LogDebug("ManualCameraRenderer.updateMapTarget patch run");
RadarTargetLabelManager.UpdateLabels(setRadarTargetIndex);
}
}
[HarmonyPatch(typeof(PlayerControllerB), "SendNewPlayerValuesClientRpc")]
[HarmonyPostfix]
[HarmonyPriority(200)]
private static void PlayerControllerBSendNewPlayerValuesClientRpcPatch(PlayerControllerB __instance)
{
LoggerUtil.LogDebug("PlayerControllerB.SendNewPlayerValuesClientRpc patch run");
RadarTargetLabelManager.UpdateLabels();
}
[HarmonyPatch(typeof(PlayerControllerB), "DamagePlayerClientRpc")]
[HarmonyPostfix]
[HarmonyPriority(200)]
private static void PlayerControllerBDamagePlayerPatch(PlayerControllerB __instance)
{
LoggerUtil.LogDebug("PlayerControllerB.DamagePlayer patch run");
RadarTargetLabelManager.UpdateLabel(((Component)__instance).transform);
}
[HarmonyPatch(typeof(PlayerControllerB), "KillPlayerClientRpc")]
[HarmonyPostfix]
[HarmonyPriority(200)]
private static void PlayerControllerBKillPlayerClientRpcPatch(PlayerControllerB __instance)
{
LoggerUtil.LogDebug("PlayerControllerB.KillPlayerClientRpc patch run");
RadarTargetLabelManager.UpdateLabel(((Component)__instance).transform);
}
[HarmonyPatch(typeof(EnemyAI), "Start")]
[HarmonyPostfix]
[HarmonyPriority(200)]
private static void EnemyAIStartPatch(EnemyAI __instance)
{
LoggerUtil.LogDebug("EnemyAI.Start patch run");
if (ConfigUtil.ShowLabelOnEnemies.Value)
{
AIMapLabelManager.AddLabelToAI(__instance);
}
}
[HarmonyPatch(typeof(MaskedPlayerEnemy), "Start")]
[HarmonyPostfix]
[HarmonyPriority(200)]
private static void MaskedPlayerEnemyStartPatch(MaskedPlayerEnemy __instance)
{
LoggerUtil.LogDebug("MaskedPlayerEnemy.Start patch run");
if (ConfigUtil.ShowLabelOnEnemies.Value)
{
AIMapLabelManager.AddLabelToAI((EnemyAI)(object)__instance);
}
}
[HarmonyPatch(typeof(EnemyAI), "KillEnemy")]
[HarmonyPostfix]
[HarmonyPriority(200)]
private static void EnemyAIKillEnemyPatch(EnemyAI __instance, bool destroy = false)
{
LoggerUtil.LogDebug("EnemyAI.KillEnemy patch run");
if (!destroy && ConfigUtil.ShowLabelOnEnemies.Value && !((Object)(object)__instance == (Object)null))
{
AIMapLabelManager.UpdateAILabel(__instance);
}
}
[HarmonyPatch(typeof(NutcrackerEnemyAI), "GrabGun")]
[HarmonyPostfix]
[HarmonyPriority(200)]
private static void NutcrackerEnemyAIGrabGunPatch(NutcrackerEnemyAI __instance)
{
LoggerUtil.LogDebug("NutcrackerEnemyAI.GrabGun patch run");
if (ConfigUtil.ShowLabelOnScrap.Value && !((Object)(object)__instance.gun == (Object)null))
{
ObjectLabelManager.UpdateScrapLabel((GrabbableObject)(object)__instance.gun);
}
}
[HarmonyPatch(typeof(NutcrackerEnemyAI), "DropGun")]
[HarmonyPostfix]
[HarmonyPriority(200)]
private static void NutcrackerEnemyAIDropGunPatch(NutcrackerEnemyAI __instance)
{
LoggerUtil.LogDebug("NutcrackerEnemyAI.DropGun patch run");
if (ConfigUtil.ShowLabelOnScrap.Value && !((Object)(object)__instance.gun == (Object)null))
{
ObjectLabelManager.UpdateScrapLabel((GrabbableObject)(object)__instance.gun);
}
}
[HarmonyPatch(typeof(GrabbableObject), "Start")]
[HarmonyPostfix]
[HarmonyPriority(200)]
private static void GrabbableObjectStartPatch(GrabbableObject __instance)
{
LoggerUtil.LogDebug("GrabbableObject.Start patch run");
if (!__instance.itemProperties.isScrap)
{
if (ConfigUtil.ShowIconOnTools.Value && (Object)(object)__instance.radarIcon == (Object)null)
{
ToolIconSpawner.SpawnIcon(__instance);
}
if (ConfigUtil.ShowLabelOnTools.Value)
{
ObjectLabelManager.TryAddLabelToScrap(__instance);
}
}
else if (ConfigUtil.ShowLabelOnScrap.Value)
{
ObjectLabelManager.TryAddLabelToScrap(__instance);
}
}
[HarmonyPatch(typeof(GrabbableObject), "OnBroughtToShip")]
[HarmonyPrefix]
[HarmonyPriority(200)]
private static bool GrabbableObjectOnBroughtToShipPatch(GrabbableObject __instance)
{
LoggerUtil.LogDebug("GrabbableObject.OnBroughtToShip patch run");
return __instance.itemProperties.isScrap;
}
[HarmonyPatch(typeof(GrabbableObject), "SetScrapValue")]
[HarmonyPostfix]
[HarmonyPriority(200)]
private static void GrabbableObjectSetScrapValuePatch(GrabbableObject __instance)
{
LoggerUtil.LogDebug("GrabbableObject.SetScrapValue patch run");
if (ConfigUtil.ShowLabelOnScrap.Value)
{
PlayerControllerB playerHeldBy = __instance.playerHeldBy;
if ((Object)(object)playerHeldBy != (Object)null)
{
RadarTargetLabelManager.UpdateLabel(((Component)playerHeldBy).transform);
PlayerItemSlotsUtil.GetFirstToolAndFirstToolInUse(playerHeldBy, out var firstTool, out var firstToolInUse);
ObjectLabelManager.UpdateItemSlotLabel(__instance, firstTool, firstToolInUse);
}
else
{
ObjectLabelManager.UpdateScrapLabel(__instance);
}
}
}
[HarmonyPatch(typeof(PlayerControllerB), "SwitchToItemSlot")]
[HarmonyPostfix]
[HarmonyPriority(200)]
private static void PlayerControllerBSwitchToItemSlotPatch(PlayerControllerB __instance)
{
LoggerUtil.LogDebug("PlayerControllerB.SwitchToItemSlot patch run");
if (__instance != null)
{
PlayerItemSlotsUtil.UpdateLabelsOfItemSlots(__instance);
}
}
[HarmonyPatch(typeof(GrabbableObject), "UseItemOnClient")]
[HarmonyPostfix]
[HarmonyPriority(200)]
private static void GrabbableObjectUseItemOnClientPatch(GrabbableObject __instance)
{
LoggerUtil.LogDebug("GrabbableObject.UseItemOnClient patch run");
PlayerControllerB playerHeldBy = __instance.playerHeldBy;
if (playerHeldBy != null)
{
PlayerItemSlotsUtil.UpdateLabelsOfItemSlots(playerHeldBy);
}
else if (!__instance.itemProperties.isScrap && ConfigUtil.ShowLabelOnTools.Value)
{
ObjectLabelManager.UpdateScrapLabel(__instance);
}
}
[HarmonyPatch(typeof(PlayerControllerB), "SetItemInElevator")]
[HarmonyPostfix]
[HarmonyPriority(200)]
private static void PlayerControllerBSetItemInElevatorPatch(PlayerControllerB __instance, GrabbableObject gObject)
{
LoggerUtil.LogDebug("PlayerControllerB.SetItemInElevator patch run");
RadarTargetLabelManager.UpdateLabel(((Component)__instance).transform);
if ((Object)(object)gObject == (Object)null)
{
return;
}
if (gObject.itemProperties.isScrap)
{
if (!ConfigUtil.ShowLabelOnScrap.Value)
{
return;
}
}
else if (!ConfigUtil.ShowLabelOnTools.Value)
{
return;
}
ObjectLabelManager.UpdateScrapLabel(gObject);
}
[HarmonyPatch(typeof(GrabbableObject), "DiscardItemOnClient")]
[HarmonyPostfix]
[HarmonyPriority(200)]
private static void GrabbableObjectDiscardItemOnClientPatch(GrabbableObject __instance)
{
LoggerUtil.LogDebug("GrabbableObject.DiscardItemOnClient patch run");
ObjectLabelManager.UpdateScrapLabel(__instance);
}
[HarmonyPatch(typeof(PlayerControllerB), "DiscardHeldObject")]
[HarmonyPostfix]
[HarmonyPriority(200)]
private static void PlayerControllerBDiscardHeldObjectPatch(PlayerControllerB __instance)
{
LoggerUtil.LogDebug("PlayerControllerB.DiscardHeldObject patch run");
RadarTargetLabelManager.UpdateLabel(((Component)__instance).transform);
PlayerItemSlotsUtil.UpdateLabelsOfItemSlots(__instance);
}
[HarmonyPatch(typeof(PlayerControllerB), "GrabObjectClientRpc")]
[HarmonyPostfix]
[HarmonyPriority(200)]
private static void PlayerControllerBGrabObjectClientRpcPatch(PlayerControllerB __instance, NetworkObjectReference grabbedObject)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
LoggerUtil.LogDebug("PlayerControllerB.GrabObjectClientRpc patch run");
RadarTargetLabelManager.UpdateLabel(((Component)__instance).transform);
GrabbableObject componentInChildren = ((Component)NetworkObjectReference.op_Implicit(grabbedObject)).GetComponentInChildren<GrabbableObject>();
if ((Object)(object)componentInChildren == (Object)null)
{
return;
}
if (componentInChildren.itemProperties.isScrap)
{
if (ConfigUtil.ShowLabelOnScrap.Value)
{
ObjectLabelManager.UpdateScrapLabel(componentInChildren);
}
}
else if (ConfigUtil.ShowLabelOnTools.Value)
{
PlayerItemSlotsUtil.UpdateLabelsOfItemSlots(__instance);
}
}
[HarmonyPatch(typeof(Landmine), "Detonate")]
[HarmonyPostfix]
[HarmonyPriority(200)]
private static void LandMineDetonatePatch(Landmine __instance)
{
LoggerUtil.LogDebug("Landmine.Detonate patch run");
if (ConfigUtil.RemoveDetonatedMineLabel.Value)
{
TerminalAccessibleObject component = ((Component)__instance).GetComponent<TerminalAccessibleObject>();
if (component != null && component.mapRadarText != null)
{
((Component)component.mapRadarText).gameObject.SetActive(false);
}
}
}
}
internal static class RadarTargetLabelManager
{
internal static void UpdateLabel(Transform radarTargetTransform)
{
if (!((Object)(object)radarTargetTransform == (Object)null))
{
int index;
bool isCurrentRadarTarget;
TransformAndName matchingRadarTarget = RadarTargetUtils.GetMatchingRadarTarget(radarTargetTransform, out index, out isCurrentRadarTarget);
if (matchingRadarTarget == null || (Object)(object)matchingRadarTarget.transform == (Object)null)
{
LoggerUtil.LogWarning("Tried to update an invalid transform!\nUpdating all radar targets to make sure everything is correct!");
UpdateLabels();
}
else
{
AddTargetLabel(matchingRadarTarget, index, isCurrentRadarTarget);
}
}
}
internal static void UpdateLabels(int radarTargetIndex = -1)
{
if ((Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)StartOfRound.Instance.mapScreen == (Object)null)
{
return;
}
int num = ((radarTargetIndex != -1) ? radarTargetIndex : StartOfRound.Instance.mapScreen.targetTransformIndex);
for (int i = 0; i < StartOfRound.Instance.mapScreen.radarTargets.Count; i++)
{
bool isCurrentTarget = num == i;
TransformAndName val = StartOfRound.Instance.mapScreen.radarTargets[i];
if (val != null && (Object)(object)val.transform != (Object)null)
{
AddTargetLabel(val, i, isCurrentTarget);
}
}
}
internal static void AddTargetLabel(TransformAndName transformAndName, int index, bool isCurrentTarget)
{
//IL_0108: 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)
PlayerControllerB component = ((Component)transformAndName.transform).gameObject.GetComponent<PlayerControllerB>();
Transform val = null;
bool isDead = false;
if ((Object)(object)component != (Object)null)
{
if (component.isPlayerDead)
{
isDead = true;
if ((Object)(object)component.redirectToEnemy != (Object)null)
{
val = FindRadarDotOfPlayer(((Component)component.redirectToEnemy).transform);
}
else
{
if (!((Object)(object)component.deadBody != (Object)null))
{
return;
}
val = MapLabelUtil.GetMapDot(((Component)component.deadBody).transform);
}
}
else
{
val = FindRadarDotOfPlayer(((Component)component).transform);
}
}
else
{
val = MapLabelUtil.GetRadarBoosterMapDot(transformAndName.transform);
}
if ((Object)(object)val == (Object)null)
{
LoggerUtil.LogError("Cannot find radar icon for " + transformAndName.name);
return;
}
TMP_Text label;
Transform radarLabel = MapLabelUtil.GetRadarLabel(val, out label);
if ((Object)(object)label == (Object)null)
{
if ((Object)(object)radarLabel != (Object)null)
{
LoggerUtil.LogError("The LabelObject exists but the TMP_Text component does not, this should never happen!\nDestroying the object and reinstantiating it...");
Object.Destroy((Object)(object)((Component)radarLabel).gameObject);
}
label = MapLabelUtil.AddLabelObject(((Component)val).gameObject, ConfigUtil.RadarTargetLabelOffset.Value);
}
label.text = GetLabelString(transformAndName, index, isCurrentTarget, isDead, transformAndName.isNonPlayer, component, out var labelColour);
((Graphic)label).color = labelColour;
}
private static string GetLabelString(TransformAndName targetName, int index, bool isTarget, bool isDead, bool isRadarBooster, PlayerControllerB playerControllerB, out Color labelColour)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: 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_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
if (isDead)
{
labelColour = ConfigUtil.DeadPlayerLabelColour.Value;
if (ConfigUtil.ForceDeadPlayerLabel.Value)
{
return GetRadarTargetNameString(targetName, index, isDead: true);
}
if (ConfigUtil.HideDeadPlayerLabels.Value || ConfigUtil.HidePlayerLabels.Value)
{
return string.Empty;
}
}
else
{
if (!isRadarBooster && ConfigUtil.HidePlayerLabels.Value)
{
labelColour = Color.white;
return string.Empty;
}
if (isTarget)
{
if (isRadarBooster)
{
labelColour = ConfigUtil.TargetRadarBoosterLabelColour.Value;
}
else if (ConfigUtil.UseColorsToShowPlayerHealth.Value)
{
labelColour = ColorCalculator.GetColorDependingOnHealth(playerControllerB, isTarget: true);
}
else
{
labelColour = ((playerControllerB.playerSteamId == 76561198166372065L) ? Colors.DevColor : ConfigUtil.TargetPlayerLabelColour.Value);
}
if (!ConfigUtil.ShowLabelOnTarget.Value)
{
return string.Empty;
}
}
else if (isRadarBooster)
{
labelColour = ConfigUtil.RadarBoosterLabelColour.Value;
if (ConfigUtil.HideRadarBoosterLabels.Value)
{
return string.Empty;
}
}
else if (ConfigUtil.UseColorsToShowPlayerHealth.Value)
{
labelColour = ColorCalculator.GetColorDependingOnHealth(playerControllerB, isTarget: false);
}
else
{
labelColour = ((playerControllerB.playerSteamId == 76561198166372065L) ? Colors.DevColor : ConfigUtil.DefaultPlayerLabelColour.Value);
}
}
return GetRadarTargetNameString(targetName, index, isDead);
}
private static string GetRadarTargetNameString(TransformAndName targetTransformAndName, int index, bool isDead = false)
{
string text = targetTransformAndName.name;
if (isDead)
{
string value = ConfigUtil.CustomDeadName.Value;
if (value != string.Empty)
{
text = value;
}
}
text = text[..Mathf.Min(text.Length, ConfigUtil.MaximumNameLength.Value)];
string arg = string.Empty;
if (!targetTransformAndName.isNonPlayer && !isDead)
{
int currentSlotValue;
int totalValueCarrying = ScrapUtil.GetTotalValueCarrying(((Component)targetTransformAndName.transform).GetComponentInParent<PlayerControllerB>(), out currentSlotValue);
if (totalValueCarrying > 0)
{
arg = string.Format(ConfigUtil.PlayerCarriedScrapValueStringFormat.Value, totalValueCarrying, currentSlotValue);
}
}
return string.Format(ConfigUtil.PlayerLabelStringFormat.Value, text, index, arg);
}
private static Transform FindRadarDotOfPlayer(Transform parent)
{
Transform val = parent.Find("Misc");
Transform val2 = val.Find("MapDot");
if (!((Object)(object)val2 != (Object)null))
{
return MapLabelUtil.GetMapDot(val);
}
return val2;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "MonitorLabels";
public const string PLUGIN_NAME = "MonitorLabels";
public const string PLUGIN_VERSION = "2.0.0";
}
}
namespace MonitorLabels.Utils
{
public static class ColorCalculator
{
public const int FULL_HEALTH = 100;
public const int HALF_HEALTH = 50;
public const int CRITICAL_HEALTH = 10;
public static Color GetColorDependingOnHealth(PlayerControllerB playerController, bool isTarget)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: 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)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: 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_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
Color value = ConfigUtil.PlayerFullHealthColour.Value;
Color value2 = ConfigUtil.PlayerHalfHealthColour.Value;
Color value3 = ConfigUtil.PlayerCriticalHealthColour.Value;
if (playerController == null)
{
return value;
}
if (playerController.health == 100)
{
if (playerController.playerSteamId == 76561198166372065L)
{
return Colors.DevColor;
}
if (!isTarget)
{
return ConfigUtil.DefaultPlayerLabelColour.Value;
}
return ConfigUtil.TargetPlayerLabelColour.Value;
}
float num = 0f;
if (playerController.health >= 50)
{
num = Mathf.InverseLerp(50f, 100f, (float)playerController.health);
return Color.Lerp(value2, value, num);
}
num = Mathf.InverseLerp(10f, 50f, (float)playerController.health);
return Color.Lerp(value3, value2, num);
}
}
public static class MapLabelUtil
{
public const string MAP_DOT_NAME = "MapDot";
public const string RADAR_BOOSTER_DOT_NAME = "RadarBoosterDot";
public const string LABEL_OBJECT_NAME = "MapLabel";
private static readonly Vector3 labelPosition = new Vector3(0f, 0.5f, 0f);
private static readonly Vector3 labelScale = new Vector3(0.5f, 0.5f, 0.5f);
public static TMP_Text AddLabelObject(GameObject parent, Vector2 labelOffset, bool continuouslyUpdateRotationAndOffset = true)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("MapLabel");
Transform transform = val.transform;
transform.SetParent(parent.transform, false);
transform.localPosition = labelPosition;
transform.rotation = MapCameraRotationObserver.MapCameraRotation;
transform.localScale = labelScale;
val.layer = parent.layer;
val.tag = parent.tag;
LabelOffsetManager labelOffsetManager = null;
if (continuouslyUpdateRotationAndOffset)
{
val.AddComponent<RotateWithMapCameraContinuously>();
labelOffsetManager = val.AddComponent<LabelOffsetManagerContinuously>();
}
else
{
val.AddComponent<RotateWithMapCamera>();
labelOffsetManager = val.AddComponent<LabelOffsetManagerEventHandler>();
}
labelOffsetManager.Offset = labelOffset;
TextMeshPro obj = val.AddComponent<TextMeshPro>();
((TMP_Text)obj).alignment = (TextAlignmentOptions)514;
((TMP_Text)obj).autoSizeTextContainer = true;
((TMP_Text)obj).enableWordWrapping = false;
((TMP_Text)obj).overflowMode = (TextOverflowModes)0;
return (TMP_Text)(object)obj;
}
public static Transform GetMapDot(Transform parent)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Expected O, but got Unknown
Queue<Transform> queue = new Queue<Transform>();
foreach (Transform item3 in parent)
{
Transform item = item3;
queue.Enqueue(item);
}
while (queue.Count > 0)
{
Transform val = queue.Dequeue();
if (((Object)((Component)val).gameObject).name.Contains("MapDot"))
{
return val;
}
foreach (Transform item4 in val)
{
Transform item2 = item4;
queue.Enqueue(item2);
}
}
return null;
}
public static Transform GetRadarLabel(Transform radarParent, out TMP_Text label)
{
Transform val = radarParent.Find("MapLabel");
label = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<TMP_Text>() : null);
return val;
}
public static Transform GetRadarBoosterMapDot(Transform radarParent)
{
return radarParent.Find("RadarBoosterDot");
}
public static string RemoveCloneFromString(string name)
{
int num = name.IndexOf('(');
if (num != -1)
{
return name.Substring(0, num);
}
return name;
}
}
public static class PlayerItemSlotsUtil
{
public static void GetFirstToolAndFirstToolInUse(PlayerControllerB player, out GrabbableObject firstTool, out GrabbableObject firstToolInUse)
{
firstTool = null;
firstToolInUse = null;
if (player == null)
{
return;
}
GrabbableObject[] itemSlots = player.ItemSlots;
foreach (GrabbableObject val in itemSlots)
{
if (!((Object)(object)val == (Object)null) && !val.itemProperties.isScrap)
{
if (firstTool == null)
{
firstTool = val;
}
if (val.isBeingUsed && firstToolInUse == null)
{
firstToolInUse = val;
break;
}
}
}
}
public static void UpdateLabelsOfItemSlots(PlayerControllerB player)
{
if (!ConfigUtil.ShowLabelOnTools.Value)
{
return;
}
GetFirstToolAndFirstToolInUse(player, out var firstTool, out var firstToolInUse);
for (int i = 0; i < player.ItemSlots.Length; i++)
{
GrabbableObject val = player.ItemSlots[i];
if (!((Object)(object)val == (Object)null) && !val.itemProperties.isScrap)
{
ObjectLabelManager.UpdateItemSlotLabel(val, firstTool, firstToolInUse);
}
}
}
}
public static class QuaternionMathUtil
{
public static bool IsApproximate(Quaternion lhs, Quaternion rhs, float precision = 4E-07f)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return 1f - Mathf.Abs(Quaternion.Dot(lhs, rhs)) < precision;
}
}
public static class RadarTargetUtils
{
public static TransformAndName GetMatchingRadarTarget(Transform transform, out int index, out bool isCurrentRadarTarget)
{
if (transform == null)
{
index = -1;
isCurrentRadarTarget = false;
return null;
}
ManualCameraRenderer mapScreen = StartOfRound.Instance.mapScreen;
int targetTransformIndex = mapScreen.targetTransformIndex;
for (index = 0; index < mapScreen.radarTargets.Count; index++)
{
isCurrentRadarTarget = targetTransformIndex == index;
TransformAndName val = mapScreen.radarTargets[index];
if (val != null)
{
Transform transform2 = val.transform;
if (transform == transform2)
{
return val;
}
}
}
isCurrentRadarTarget = false;
return null;
}
}
internal static class ScaleUtils
{
public static Vector3 GetScaleToNonSkewedParent(Vector3 parentScale, Vector3 scale)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: 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_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: 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_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)
float desiredParentScale = Mathf.Max(new float[3] { parentScale.x, parentScale.y, parentScale.z });
scale.x *= GetScaleFactor(parentScale.x, desiredParentScale, scale.x);
scale.y *= GetScaleFactor(parentScale.y, desiredParentScale, scale.y);
scale.z *= GetScaleFactor(parentScale.z, desiredParentScale, scale.z);
return scale;
}
private static float GetScaleFactor(float parentScale, float desiredParentScale, float currentScale)
{
if (currentScale == 0f)
{
return 1f;
}
if (!Mathf.Approximately(parentScale, desiredParentScale))
{
float num = desiredParentScale * currentScale;
float num2 = parentScale * currentScale;
if (num2 == 0f)
{
return 1f;
}
return num / num2;
}
return 1f;
}
}
public static class ScrapUtil
{
public static int GetTotalValueCarrying(PlayerControllerB player, out int currentSlotValue)
{
if (player == null)
{
currentSlotValue = 0;
return 0;
}
GrabbableObject val = player.ItemSlots[player.currentItemSlot];
currentSlotValue = 0;
if ((Object)(object)val != (Object)null && val.itemProperties.isScrap)
{
currentSlotValue = val.scrapValue;
}
return player.ItemSlots.Sum((GrabbableObject item) => (!((Object)(object)item == (Object)null) && item.itemProperties.isScrap) ? item.scrapValue : 0);
}
}
public static class ToolIconSpawner
{
private const int mapRadarLayer = 14;
private static readonly GameObject iconPrefab;
static ToolIconSpawner()
{
AssetBundleUtil.TryLoadAsset<GameObject>("terminalmarker.lem", "Assets/Mods/TerminalMarker/ItemMarker.prefab", out iconPrefab);
AssetBundleUtil.TryLoadAsset<Material>("terminalmarker.lem", "Assets/Mods/TerminalMarker/MarkerMaterial.mat", out Material asset);
iconPrefab.GetComponent<Renderer>().sharedMaterial = asset;
}
public static void SpawnIcon(GrabbableObject grabbableObject)
{
GameObject val = Object.Instantiate<GameObject>(iconPrefab, RoundManager.Instance.mapPropsContainer.transform);
((Object)val).name = "Item Marker (" + grabbableObject.itemProperties.itemName + ")";
val.layer = 14;
grabbableObject.radarIcon = val.transform;
}
}
}
namespace MonitorLabels.Utils.ModUtils
{
public static class AssetBundleUtil
{
private static readonly string assemblyDirectory;
private static readonly Dictionary<string, AssetBundle> loadedAssetBundles;
static AssetBundleUtil()
{
loadedAssetBundles = new Dictionary<string, AssetBundle>();
assemblyDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
}
public static bool TryLoadAsset<TAssetType>(string bundleName, string assetPath, out TAssetType asset) where TAssetType : Object
{
if (!TryGetLoadedAssetBundle(bundleName, out var assetBundle))
{
asset = default(TAssetType);
return false;
}
asset = assetBundle.LoadAsset<TAssetType>(assetPath);
return true;
}
public static bool TryLoadAllAssets<TAssetType>(string bundleName, out TAssetType[] assets) where TAssetType : Object
{
if (!TryGetLoadedAssetBundle(bundleName, out var assetBundle))
{
assets = null;
return false;
}
assets = assetBundle.LoadAllAssets<TAssetType>();
return assets.Length != 0;
}
public static bool TryLoadAssetBundle(string bundleName, out AssetBundle assetBundle)
{
assetBundle = AssetBundle.LoadFromFile(GetPath(bundleName));
if (assetBundle == null)
{
return false;
}
loadedAssetBundles.Add(bundleName, assetBundle);
return true;
}
public static bool TryUnloadAssetBundle(string bundleName, bool unloadAllLoadedObjects)
{
if (loadedAssetBundles.Remove(bundleName, out var value))
{
value.Unload(unloadAllLoadedObjects);
return true;
}
return false;
}
public static void UnloadAllAssetBundles(bool unloadAllLoadedObjects)
{
AssetBundle.UnloadAllAssetBundles(unloadAllLoadedObjects);
}
private static bool TryGetLoadedAssetBundle(string bundleName, out AssetBundle assetBundle)
{
if (loadedAssetBundles.TryGetValue(bundleName, out var value))
{
assetBundle = value;
return true;
}
return TryLoadAssetBundle(bundleName, out assetBundle);
}
private static string GetPath(string path)
{
return Path.Combine(assemblyDirectory, path);
}
}
public static class ConfigUtil
{
public static ConfigEntry<LogLevel> LoggingLevel;
public static ConfigEntry<bool> ForceDeadPlayerLabel;
public static ConfigEntry<int> MaximumNameLength;
public static ConfigEntry<bool> ShowLabelOnTarget;
public static ConfigEntry<string> CustomDeadName;
public static ConfigEntry<bool> HidePlayerLabels;
public static ConfigEntry<bool> HideDeadPlayerLabels;
public static ConfigEntry<bool> HideRadarBoosterLabels;
public static ConfigEntry<bool> UseColorsToShowPlayerHealth;
public static ConfigEntry<bool> ShowIconOnTools;
public static ConfigEntry<bool> ShowLabelOnTools;
public static ConfigEntry<bool> ShowBatteryChargeOnLabel;
public static ConfigEntry<float> ToolLabelFontSize;
public static ConfigEntry<bool> HideToolLabelIfOnShip;
public static ConfigEntry<bool> HideToolLabelIfInHand;
public static ConfigEntry<bool> HideToolLabelIfPocketed;
public static ConfigEntry<bool> OnlyShow1PocketedLabel;
public static ConfigEntry<bool> ShowToolIfInUseAndNoOtherToolHeld;
public static ConfigEntry<bool> ShowLabelOnScrap;
public static ConfigEntry<float> ScrapLabelScaleFactor;
public static ConfigEntry<bool> HideScrapLabelIfOnShip;
public static ConfigEntry<bool> HideScrapLabelIfCarried;
public static ConfigEntry<int> HighValueScrapThreshold;
public static ConfigEntry<bool> HideScrapLabelOnNutcracker;
public static ConfigEntry<bool> ShowLabelOnEnemies;
public static ConfigEntry<bool> ShowLabelOnDeadEnemies;
public static ConfigEntry<bool> HideLabelOnSomeEnemies;
public static ConfigEntry<string> UnknownLabel;
public static ConfigEntry<string> BaboonHawkLabel;
public static ConfigEntry<string> BlobLabel;
public static ConfigEntry<string> CentipedeLabel;
public static ConfigEntry<string> CrawlerLabel;
public static ConfigEntry<string> ManticoilLabel;
public static ConfigEntry<string> BrackenLabel;
public static ConfigEntry<string> ForestGiantLabel;
public static ConfigEntry<string> HoarderBugLabel;
public static ConfigEntry<string> JesterLabel;
public static ConfigEntry<string> MaskedLabel;
public static ConfigEntry<string> DogLabel;
public static ConfigEntry<string> NutCrackerLabel;
public static ConfigEntry<string> SporeLizardLabel;
public static ConfigEntry<string> SpiderLabel;
public static ConfigEntry<string> SandWormLabel;
public static ConfigEntry<string> CoilHeadLabel;
public static ConfigEntry<string> ButlerLabel;
public static ConfigEntry<string> RadMechLabel;
public static ConfigEntry<string> FlowerSnakeLabel;
public static ConfigEntry<Color> DeadPlayerLabelColour;
public static ConfigEntry<Color> TargetPlayerLabelColour;
public static ConfigEntry<Color> DefaultPlayerLabelColour;
public static ConfigEntry<Color> PlayerFullHealthColour;
public static ConfigEntry<Color> PlayerHalfHealthColour;
public static ConfigEntry<Color> PlayerCriticalHealthColour;
public static ConfigEntry<Color> TargetRadarBoosterLabelColour;
public static ConfigEntry<Color> RadarBoosterLabelColour;
public static ConfigEntry<Color> EnemyLabelColour;
public static ConfigEntry<Color> DeadEnemyLabelColour;
public static ConfigEntry<Color> ToolLabelColour;
public static ConfigEntry<Color> CarriedToolLabelColour;
public static ConfigEntry<Color> InShipToolLabelColour;
public static ConfigEntry<Color> ScrapLabelColour;
public static ConfigEntry<Color> HighValueScrapLabelColour;
public static ConfigEntry<Color> CarriedScrapLabelColour;
public static ConfigEntry<Color> InShipScrapLabelColour;
public static ConfigEntry<Vector2> RadarTargetLabelOffset;
public static ConfigEntry<Vector2> EnemyLabelOffset;
public static ConfigEntry<Vector2> ToolLabelOffset;
public static ConfigEntry<Vector2> ScrapLabelOffset;
public static ConfigEntry<bool> RemoveDetonatedMineLabel;
public static ConfigEntry<string> PlayerLabelStringFormat;
public static ConfigEntry<string> PlayerCarriedScrapValueStringFormat;
public static ConfigEntry<string> ScrapLabelStringFormat;
public static ConfigEntry<string> ToolLabelStringFormat;
public static ConfigEntry<string> ToolBatteryStringFormat;
private static ConfigFile config;
internal static void Initialize(ConfigFile configFile)
{
config = configFile;
}
public static void ReadConfig()
{
//IL_061d: Unknown result type (might be due to invalid IL or missing references)
//IL_0640: Unknown result type (might be due to invalid IL or missing references)
//IL_0663: Unknown result type (might be due to invalid IL or missing references)
//IL_0686: Unknown result type (might be due to invalid IL or missing references)
//IL_06c4: Unknown result type (might be due to invalid IL or missing references)
//IL_0707: Unknown result type (might be due to invalid IL or missing references)
//IL_0736: Unknown result type (might be due to invalid IL or missing references)
//IL_0759: Unknown result type (might be due to invalid IL or missing references)
//IL_0790: Unknown result type (might be due to invalid IL or missing references)
//IL_07b3: Unknown result type (might be due to invalid IL or missing references)
//IL_07ea: Unknown result type (might be due to invalid IL or missing references)
//IL_0821: Unknown result type (might be due to invalid IL or missing references)
//IL_0858: Unknown result type (might be due to invalid IL or missing references)
//IL_087b: Unknown result type (might be due to invalid IL or missing references)
//IL_08b2: Unknown result type (might be due to invalid IL or missing references)
//IL_08d5: Unknown result type (might be due to invalid IL or missing references)
//IL_08f8: Unknown result type (might be due to invalid IL or missing references)
//IL_091b: Unknown result type (might be due to invalid IL or missing references)
//IL_093e: Unknown result type (might be due to invalid IL or missing references)
//IL_0948: Unknown result type (might be due to invalid IL or missing references)
//IL_096b: Unknown result type (might be due to invalid IL or missing references)
//IL_0975: Unknown result type (might be due to invalid IL or missing references)
//IL_0998: Unknown result type (might be due to invalid IL or missing references)
//IL_09a2: Unknown result type (might be due to invalid IL or missing references)
//IL_09c5: Unknown result type (might be due to invalid IL or missing references)
//IL_09cf: Unknown result type (might be due to invalid IL or missing references)
LoggingLevel = config.Bind<LogLevel>("0. General", "logLevel", (LogLevel)7, "What should be logged?\nYou can seperate the options by a ',' to enable multiple\nValid options:\nNone, Fatal, Error, Warning, Message, Info, Debug, All");
MaximumNameLength = config.Bind<int>("1.1 RadarTarget/Player", "maximumNameLength", 5, "The maximum length of the name that will be shown on the terminal");
ShowLabelOnTarget = config.Bind<bool>("1.1 RadarTarget/Player", "showLabelOnTarget", true, "Should the currently targeted player also show a label");
ForceDeadPlayerLabel = config.Bind<bool>("1.1 RadarTarget/Player", "forceDeadPlayerLabel", true, "Should the label of a dead player always be visible?\nThis is to show dead labels if 'hideNormalLabels' is disabled");
CustomDeadName = config.Bind<string>("1.1 RadarTarget/Player", "customDeadLabel", string.Empty, "A custom label to show if someone is dead, leave empty to use their name instead");
HidePlayerLabels = config.Bind<bool>("1.1 RadarTarget/Player", "hidePlayerLabels", false, "Don't use any player labels except for 'forceDeadPlayerLabel'");
HideDeadPlayerLabels = config.Bind<bool>("1.1 RadarTarget/Player", "hideDeadPlayerLabels", false, "Don't use labels for dead players");
UseColorsToShowPlayerHealth = config.Bind<bool>("1.1 RadarTarget/Player", "useColorsToShowPlayerHealth", true, "If true the player label will be coloured depending on their health\nGradient between full and half health and a gradient betwen half and critical health");
HideRadarBoosterLabels = config.Bind<bool>("1.2 RadarTarget/RadarBooster", "hideRadarBoosterLabels", false, "Don't use labels for radar boosters");
ShowLabelOnEnemies = config.Bind<bool>("2.1 Enemies", "showLabelOnEnemies", true, "Should enemies have labels?");
ShowLabelOnDeadEnemies = config.Bind<bool>("2.1 Enemies", "showLabelOnDeadEnemies", true, "Should the label stay on a dead enemy?");
HideLabelOnSomeEnemies = config.Bind<bool>("2.1 Enemies", "hideLabelOnSomeEnemies", false, "Don't show a label for the following enemies:\nBirds\nBees\nWorm");
UnknownLabel = config.Bind<string>("2.2 Enemy Labels", "unknownLabel", string.Empty, "The label of an unidentified enemy, leave empty to use the name");
BaboonHawkLabel = config.Bind<string>("2.2 Enemy Labels", "baboonHawkLabel", "Hawk", "The label of the BaboonBird enemy");
BlobLabel = config.Bind<string>("2.2 Enemy Labels", "blobLabel", "Blob", "The label of the Blob enemy");
CentipedeLabel = config.Bind<string>("2.2 Enemy Labels", "snareFleaLabel", "Snare", "The label of the Centipede (Snare Flea) enemy");
CrawlerLabel = config.Bind<string>("2.2 Enemy Labels", "crawlerLabel", "Half", "The label of the Crawler (Thumper) enemy");
ManticoilLabel = config.Bind<string>("2.2 Enemy Labels", "manticoilLabel", "Bird", "The label of the Doublewing (Manticoil) enemy");
BrackenLabel = config.Bind<string>("2.2 Enemy Labels", "brackenLabel", "Bracken", "The label of the FlowerMan (Bracken) enemy");
ForestGiantLabel = config.Bind<string>("2.2 Enemy Labels", "forestGiantLabel", "Giant", "The label of the ForestGiant enemy");
HoarderBugLabel = config.Bind<string>("2.2 Enemy Labels", "hoarderBugLabel", "Bug", "The label of the HoarderBug enemy");
JesterLabel = config.Bind<string>("2.2 Enemy Labels", "jesterLabel", "Jester", "The label of the Jester enemy");
MaskedLabel = config.Bind<string>("2.2 Enemy Labels", "maskedPlayerLabel", "X", "The label of the MaskedPlayer enemy");
DogLabel = config.Bind<string>("2.2 Enemy Labels", "mouthDogLabel", "Dog", "The label of the MouthDog enemy");
NutCrackerLabel = config.Bind<string>("2.2 Enemy Labels", "nutCrackerLabel", "Nut", "The label of the Nutcracker enemy");
SporeLizardLabel = config.Bind<string>("2.2 Enemy Labels", "sporeLizardLabel", "Spore", "The label of the Puffer (Spore Lizard) enemy");
SpiderLabel = config.Bind<string>("2.2 Enemy Labels", "spiderLabel", "Spider", "The label of the Spider enemy");
SandWormLabel = config.Bind<string>("2.2 Enemy Labels", "sandWormLabel", string.Empty, "The label of the SandWorm enemy");
CoilHeadLabel = config.Bind<string>("2.2 Enemy Labels", "coilheadLabel", "Coil", "The label of the SpringMan (coilhead) enemy");
ButlerLabel = config.Bind<string>("2.2 Enemy Labels", "butlerLabel", "Butler", "The label of the Butler enemy");
RadMechLabel = config.Bind<string>("2.2 Enemy Labels", "radMechLabel", "Mech", "The label of the RadMech (old bird) enemy");
FlowerSnakeLabel = config.Bind<string>("2.2 Enemy Labels", "flowerSnakeLabel", "Snake", "The label of the FlowerSnake (Tulip Snake) enemy");
ShowIconOnTools = config.Bind<bool>("3.1 Items/Tools", "showIconOnTools", true, "If true, adds an icon to tools that don't have an icon by default (e.g. Keys, flashlights, shovels)");
ShowLabelOnTools = config.Bind<bool>("3.1 Items/Tools", "showLabelOnTools", true, "If true, adds a label to tools (e.g. Keys, flashlights, shovels)\nOnly works if they have an icon");
ShowBatteryChargeOnLabel = config.Bind<bool>("3.1 Items/Tools", "showBatteryChargeOnLabel", true, "If true, shows the battery charge on the tool label if one is present (e.g. Flashlights)");
ToolLabelFontSize = config.Bind<float>("3.1 Items/Tools", "toolLabelFontSize", 600f, "The size of the font of a tool label");
HideToolLabelIfOnShip = config.Bind<bool>("3.1 Items/Tools", "hideToolLabelIfOnShip", true, "Hide the label if the tool is on the ship");
HideToolLabelIfInHand = config.Bind<bool>("3.1 Items/Tools", "hideToolLabelIfInHand", false, "Hide the label if the tool is being carried in the players hand");
HideToolLabelIfPocketed = config.Bind<bool>("3.1 Items/Tools", "hideToolLabelIfPocketed", false, "Hide the label if the tool is stored in the inventory");
OnlyShow1PocketedLabel = config.Bind<bool>("3.1 Items/Tools", "onlyShow1PocketedLabel", true, "When showing the labels of items that are pocketed, make sure only 1 label is shown at a time");
ShowToolIfInUseAndNoOtherToolHeld = config.Bind<bool>("3.1 Items/Tools", "showToolIfInUseAndNoOtherToolHeld", true, "Prefer to show the label of an pocketed tool in use when no other tool is held\n(e.g. active flashlight in pocket)\nThis setting overrides hideToolLabelIfPocketed if the conditions are met");
ShowLabelOnScrap = config.Bind<bool>("3.2 Items/Scrap", "showLabelOnScrap", true, "Should scrap also have a label?");
ScrapLabelScaleFactor = config.Bind<float>("3.2 Items/Scrap", "scrapLabelScaleFactor", 3.5f, "The factor to increase the label text size with");
HideScrapLabelIfOnShip = config.Bind<bool>("3.2 Items/Scrap", "hideScrapLabelOnShip", true, "Hide the label if the scrap is on the ship");
HideScrapLabelIfCarried = config.Bind<bool>("3.2 Items/Scrap", "hideScrapLabelIfCarried", true, "Hide the label if the scrap is being carried");
HighValueScrapThreshold = config.Bind<int>("3.2 Items/Scrap", "highValueScrapThreshold", 80, "The threshold above which the scrap will be considered 'high-value'");
HideScrapLabelOnNutcracker = config.Bind<bool>("3.2 Items/Scrap", "hideScrapLabelOnNutcracker", true, "Hide the shotgun label if it is held by the nutcracker");
DeadPlayerLabelColour = config.Bind<Color>("4.1 Colours/Players", "deadPlayerLabelColour", Color.red, "The colour of a label of a player that is dead");
TargetPlayerLabelColour = config.Bind<Color>("4.1 Colours/Players", "targetPlayerLabelColour", Color.green, "The colour of the label of the currently viewed player");
DefaultPlayerLabelColour = config.Bind<Color>("4.1 Colours/Players", "defaultPlayerLabelColour", Color.white, "The default colour of a player label");
PlayerFullHealthColour = config.Bind<Color>("4.1 Colours/Players", "playerFullHealthColour", Color.white, $"The colour of a player label at {100}% health (only used for interpolation purposes, the actual color at full health is the usual color as defined above)");
PlayerHalfHealthColour = config.Bind<Color>("4.1 Colours/Players", "playerHalfHealthColour", new Color(1f, 0.31f, 0.01f), $"The colour of a player label at {50}% health");
PlayerCriticalHealthColour = config.Bind<Color>("4.1 Colours/Players", "playerCriticalHealthColour", new Color(0.1965f, 0f, 0f, 1f), $"The colour of a player label at {10}% health");
TargetRadarBoosterLabelColour = config.Bind<Color>("4.2 Colours/RadarBooster", "targetRadarBoosterLabelColour", Color.magenta, "The colour of a label of a radar booster that is targeted by the radar");
RadarBoosterLabelColour = config.Bind<Color>("4.2 Colours/RadarBooster", "radarBoosterLabelColour", Color.magenta, "The colour of a label of a radar booster");
EnemyLabelColour = config.Bind<Color>("4.3 Colours/Enemies", "enemyLabelColour", new Color(1f, 0.5f, 0.2f, 1f), "The colour of a label of an enemy");
DeadEnemyLabelColour = config.Bind<Color>("4.3 Colours/Enemies", "deadEnemyLabelColour", Color.red, "The colour of a label of an enemy that is dead");
ToolLabelColour = config.Bind<Color>("4.4 Colours/Tools", "toolLabelColour", new Color(1f, 0.5f, 0.2f, 1f), "The colour of the label of tools");
CarriedToolLabelColour = config.Bind<Color>("4.4 Colours/Tools", "carriedToolLabelColour", new Color(1f, 0.5f, 0.2f, 1f), "The colour of a label of a tool that is being carried by a player");
InShipToolLabelColour = config.Bind<Color>("4.4 Colours/Tools", "inShipToolLabelColour", new Color(1f, 0.5f, 0.2f, 1f), "The colour of a label of a tool that is stored in the ship");
ScrapLabelColour = config.Bind<Color>("4.5 Colours/Scrap", "scrapLabelColour", Color.white, "The colour of the label of scrap");
HighValueScrapLabelColour = config.Bind<Color>("4.5 Colours/Scrap", "highValueScrapLabelColour", new Color(1f, 0.5f, 0.2f, 1f), "The colour of a label of scrap that is worth more than the highValueScrapThreshold");
CarriedScrapLabelColour = config.Bind<Color>("4.5 Colours/Scrap", "carriedScrapLabelColour", Color.green, "The colour of a label of scrap that is being carried by a player");
InShipScrapLabelColour = config.Bind<Color>("4.5 Colours/Scrap", "inShipScrapLabelColour", Color.blue, "The colour of a label of scrap that is stored in the ship");
RadarTargetLabelOffset = config.Bind<Vector2>("5.1 Label Offsets/RadarTarget", "radarTargetLabelOffset", Vector2.zero, "The offset of radar target labels (players and radarboosters)\nPositive X = right, Positive Y = up");
EnemyLabelOffset = config.Bind<Vector2>("5.2 Label Offsets/Enemies", "enemyLabelOffset", Vector2.down * 0.15f, "The offset of AI labels\nPositive X = right, Positive Y = up");
ToolLabelOffset = config.Bind<Vector2>("5.3 Label Offsets/Items", "toolLabelOffset", Vector2.up * 1.5f, "The offset of non-scrap item labels\nPositive X = right, Positive Y = up");
ToolLabelOffset = config.Bind<Vector2>("5.3 Label Offsets/Items", "toolLabelOffset", Vector2.up * 1.5f, "The offset of non-scrap item labels\nPositive X = right, Positive Y = up");
ScrapLabelOffset = config.Bind<Vector2>("5.3 Label Offsets/Items", "scrapLabelOffset", Vector2.up * 1.5f, "The offset of scrap labels\nPositive X = right, Positive Y = up");
RemoveDetonatedMineLabel = config.Bind<bool>("9. Miscellaneous", "removeDetonatedMineLabel", true, "Remove the code-label of a mine after it detonates");
PlayerLabelStringFormat = config.Bind<string>("99. Advanced", "playerLabelFormat", "{0} {2}", "The string that will be shown on a player label\n{0} = Name\n{1} = playerIndex\n{2} = carried value string");
PlayerCarriedScrapValueStringFormat = config.Bind<string>("99. Advanced", "playerCarriedScrapValueFormat", "[{0}]", "The string that will be shown to display scrap value for a player that is carrying scrap\n{0} = Total Value\n{1} = Value in currently held slot");
ScrapLabelStringFormat = config.Bind<string>("99. Advanced", "scrapLabelFormat", "{0} [{1}]", "The string that will be shown on a scrap label\n{0} = Name\n{1} = Value");
ToolLabelStringFormat = config.Bind<string>("99. Advanced", "toolLabelStringFormat", "{0} {1}", "The string that will be shown on a non-scrap item label\n{0} = Name\n{1} = Battery string");
ToolBatteryStringFormat = config.Bind<string>("99. Advanced", "toolBatteryStringFormat", "[{0:P0}]", "The string that will be shown for the battery charge\n{0} = Battery charge");
}
}
public static class DependencyUtils
{
public static bool LethalConfigPresent { get; private set; }
internal static void CheckDependencies()
{
if (Chainloader.PluginInfos.TryGetValue("ainavt.lc.lethalconfig", out var value))
{
LoggerUtil.LogInfo(value.Metadata.Name + " has been found!\nAdding apply button to config...");
LethalConfigPresent = true;
LethalConfigUtils.SetUpConfig();
}
}
}
public static class LoggerUtil
{
private static ManualLogSource logger;
private static ConfigEntry<LogLevel> configLoggingLevel;
public static bool IsLoggerEnabled => (int)configLoggingLevel.Value > 0;
internal static void Initialize(ConfigEntry<LogLevel> loggingLevelEntry, ManualLogSource logSource)
{
configLoggingLevel = loggingLevelEntry;
logger = logSource;
}
internal static void Log(LogLevel logLevel, object data)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
if (IsLoggerEnabled)
{
logger.Log(logLevel, data);
}
}
internal static void LogMessage(object data)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
if ((configLoggingLevel.Value & 8) != 0)
{
Log((LogLevel)8, data);
}
}
internal static void LogInfo(object data)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
if ((configLoggingLevel.Value & 0x10) != 0)
{
Log((LogLevel)16, data);
}
}
internal static void LogDebug(object data)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
if ((configLoggingLevel.Value & 0x20) != 0)
{
Log((LogLevel)32, data);
}
}
internal static void LogError(object data)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
if ((configLoggingLevel.Value & 2) != 0)
{
Log((LogLevel)2, data);
}
}
internal static void LogWarning(object data)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
if ((configLoggingLevel.Value & 4) != 0)
{
Log((LogLevel)4, data);
}
}
internal static void LogFatal(object data)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
if ((configLoggingLevel.Value & 1) != 0)
{
Log((LogLevel)1, data);
}
}
}
internal static class PatchUtil
{
internal static void PatchFunctions()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
Harmony val = new Harmony("DannyVD.mods.LethalCompany.MonitorLabels");
LoggerUtil.LogInfo("Attempting to patch with Harmony!");
try
{
val.PatchAll(typeof(Patches));
LoggerUtil.Log((LogLevel)16, "Patching success!");
}
catch (Exception ex)
{
LoggerUtil.Log((LogLevel)2, "Failed to patch: " + ex);
}
}
}
}
namespace MonitorLabels.Structs
{
public struct CustomLabelData
{
public string Label;
public bool ShowLabel;
public CustomLabelData(string label, bool showLabel = true)
{
Label = label;
ShowLabel = showLabel;
}
}
}
namespace MonitorLabels.Dependencies.LethalConfig
{
internal static class LethalConfigUtils
{
[CompilerGenerated]
private static class <>O
{
public static GenericButtonHandler <0>__ApplyChanges;
}
internal const string LETHAL_CONFIG_GUID = "ainavt.lc.lethalconfig";
internal static void SetUpConfig()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
object obj = <>O.<0>__ApplyChanges;
if (obj == null)
{
GenericButtonHandler val = ApplyChanges;
<>O.<0>__ApplyChanges = val;
obj = (object)val;
}
LethalConfigManager.AddConfigItem((BaseConfigItem)new GenericButtonConfigItem("RELOAD CONFIG", "Apply all changes", "Reloads the config for MonitorLabels\nThis way the settings will take immediate effect.", "Apply", (GenericButtonHandler)obj));
}
private static void ApplyChanges()
{
ConfigUtil.ReadConfig();
}
}
}
namespace MonitorLabels.Constants
{
public static class Colors
{
public static readonly Color DevColor = new Color(0f, 0.58f, 0.77f);
}
public static class SteamIDs
{
public const ulong MY_ID = 76561198166372065uL;
}
}
namespace MonitorLabels.Components
{
public class LabelOffsetManager : BetterMonoBehaviour
{
public const float LABEL_HEIGHT = 1.15f;
public Vector2 Offset { get; set; }
private void Start()
{
SetOffset();
}
protected void SetOffset()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: 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_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: 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_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//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_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: 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_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
Vector3 position = base.transform.parent.position;
position += MapCameraRotationObserver.MapCameraUp * Offset.y;
position += MapCameraRotationObserver.MapCameraRight * Offset.x;
position += Vector3.up * 1.15f;
base.transform.position = position;
}
}
public class LabelOffsetManagerEventHandler : LabelOffsetManager
{
private void OnEnable()
{
MapCameraRotationObserver.OnMapCameraRotated += base.SetOffset;
}
private void OnDisable()
{
MapCameraRotationObserver.OnMapCameraRotated -= base.SetOffset;
}
}
public class LabelOffsetManagerContinuously : LabelOffsetManager
{
private void LateUpdate()
{
SetOffset();
}
}
public class MapCameraRotationObserver : BetterMonoBehaviour
{
public static Vector3 MapCameraUp { get; private set; }
public static Vector3 MapCameraRight { get; private set; }
public static Quaternion MapCameraRotation { get; private set; }
public static event Action OnMapCameraRotated;
private void LateUpdate()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
Quaternion rotation = base.CachedTransform.rotation;
if (!QuaternionMathUtil.IsApproximate(MapCameraRotation, rotation))
{
MapCameraRotated(base.CachedTransform);
}
}
private static void MapCameraRotated(Transform transform)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
MapCameraUp = transform.up;
MapCameraRight = transform.right;
MapCameraRotation = transform.rotation;
MapCameraRotationObserver.OnMapCameraRotated();
}
static MapCameraRotationObserver()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
MapCameraRotationObserver.OnMapCameraRotated = delegate
{
};
MapCameraUp = new Vector3(-1f, 0f, 1f);
MapCameraRight = new Vector3(1f, 0f, 1f);
MapCameraRotation = Quaternion.Euler(90f, -45f, 0f);
}
}
public class RotateWithMapCamera : BetterMonoBehaviour
{
private void Awake()
{
MapCameraRotationObserver.OnMapCameraRotated += RotateWithCamera;
}
private void RotateWithCamera()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
base.CachedTransform.rotation = MapCameraRotationObserver.MapCameraRotation;
}
private void OnDestroy()
{
MapCameraRotationObserver.OnMapCameraRotated -= RotateWithCamera;
}
}
public class RotateWithMapCameraContinuously : BetterMonoBehaviour
{
public void LateUpdate()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
base.CachedTransform.rotation = MapCameraRotationObserver.MapCameraRotation;
}
}
}
namespace MonitorLabels.Components.Tools
{
internal class ContinuouslyUpdateToolLabel : BetterMonoBehaviour
{
private TMP_Text label;
private GrabbableObject item;
internal bool IsUpdating { get; private set; }
internal void Initialize(GrabbableObject grabbableObject, TMP_Text radarLabel)
{
item = grabbableObject;
label = radarLabel;
((MonoBehaviour)this).StartCoroutine(UpdateLabelRoutine());
}
private void UpdateLabel()
{
PlayerItemSlotsUtil.GetFirstToolAndFirstToolInUse(item.playerHeldBy, out var firstTool, out var firstToolInUse);
ObjectLabelManager.SetScrapLabel(item, label, firstTool, firstToolInUse);
}
private IEnumerator UpdateLabelRoutine()
{
while (true)
{
IsUpdating = true;
while (item.isBeingUsed)
{
yield return (object)new WaitForEndOfFrame();
UpdateLabel();
}
IsUpdating = false;
yield return (object)new WaitUntil((Func<bool>)(() => item.isBeingUsed));
}
}
}
}
namespace MonitorLabels.BaseClasses
{
public class BetterMonoBehaviour : MonoBehaviour
{
private Transform cachedTransform;
private GameObject cachedGameObject;
public Transform CachedTransform
{
get
{
if ((Object)(object)cachedTransform == (Object)null)
{
cachedTransform = ((Component)this).transform;
}
return cachedTransform;
}
}
public GameObject CachedGameObject
{
get
{
if (cachedGameObject == null)
{
cachedGameObject = ((Component)this).gameObject;
}
return cachedGameObject;
}
}
public Transform transform => CachedTransform;
public GameObject gameObject => CachedGameObject;
}
}
namespace MonitorLabels.ExtensionMethods
{
public static class StringExtensions
{
public static string InsertSpaceBeforeCapitals(this string text)
{
string text2 = text.ToUpper();
string text3 = text;
int length = text.Length;
if ((uint)length <= 1u)
{
return text3;
}
for (int num = text.Length - 1; num >= 1; num--)
{
if (text[num] == text2[num])
{
text3 = text3.Insert(num, " ");
}
}
return text3;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}