using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("ScrapVisbility")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ScrapVisbility")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("8a6853bd-bdc9-4741-95c7-5aa2c8c6a6f9")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace ScrapVisibility; [BepInPlugin("YourFurnace.ScrapVisibility", "ScrapVisibility", "1.8.3")] public class ScrapVisibility : BaseUnityPlugin { private const string modGUID = "YourFurnace.ScrapVisibility"; private const string modName = "ScrapVisibility"; private const string modVersion = "1.8.3"; private readonly Harmony harmony = new Harmony("YourFurnace.ScrapVisibility"); internal static ScrapVisibility Instance; internal static ManualLogSource Log; internal static ConfigEntry DisableManualRightClickScan; internal static ConfigEntry ShowModelGlow; internal static ConfigEntry ShowText; internal static ConfigEntry ShowLight; internal static ConfigEntry HideTextBehindWalls; internal static ConfigEntry MaxDistance; internal static ConfigEntry RefreshInterval; internal static ConfigEntry TintStrength; internal static ConfigEntry EmissionStrength; internal static ConfigEntry TextSize; internal static ConfigEntry TextHeightOffset; internal static ConfigEntry LightIntensity; internal static ConfigEntry LightRange; internal static ConfigEntry PulseSpeed; internal static ConfigEntry TextOcclusionPadding; internal static ConfigEntry ScreenEdgeMargin; internal static ConfigEntry TextVisibilityGraceTime; private static Transform textRoot; private float nextRefreshTime = 0f; internal static Transform GetTextRoot() { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_0055: 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) if ((Object)(object)textRoot != (Object)null) { return textRoot; } GameObject val = GameObject.Find("ScrapVisibility_TextRoot"); if ((Object)(object)val != (Object)null) { textRoot = val.transform; textRoot.position = Vector3.zero; textRoot.rotation = Quaternion.identity; textRoot.localScale = Vector3.one; return textRoot; } GameObject val2 = new GameObject("ScrapVisibility_TextRoot"); textRoot = val2.transform; textRoot.position = Vector3.zero; textRoot.rotation = Quaternion.identity; textRoot.localScale = Vector3.one; return textRoot; } private void Awake() { Instance = this; Log = ((BaseUnityPlugin)this).Logger; DisableManualRightClickScan = ((BaseUnityPlugin)this).Config.Bind("General", "Disable manual right click scan", true, "If true, normal right click scan is blocked."); ShowModelGlow = ((BaseUnityPlugin)this).Config.Bind("Display", "Show model glow", true, "Tints the real item model."); ShowText = ((BaseUnityPlugin)this).Config.Bind("Display", "Show 3D text", true, "Show item name and value above items."); ShowLight = ((BaseUnityPlugin)this).Config.Bind("Display", "Show apparatus style light", true, "Adds a real 3D point light to items."); HideTextBehindWalls = ((BaseUnityPlugin)this).Config.Bind("Display", "Hide text behind walls", true, "If true, text label hides when the item itself is blocked by walls."); MaxDistance = ((BaseUnityPlugin)this).Config.Bind("Visibility", "Max display distance", 120f, "Maximum distance for item highlights and labels."); RefreshInterval = ((BaseUnityPlugin)this).Config.Bind("Performance", "Refresh interval", 1f, "How often the mod searches for items."); TintStrength = ((BaseUnityPlugin)this).Config.Bind("Display", "Tint strength", 1f, "How strongly the model gets tinted."); EmissionStrength = ((BaseUnityPlugin)this).Config.Bind("Display", "Emission strength", 5.5f, "How strongly the material emission is pushed."); TextSize = ((BaseUnityPlugin)this).Config.Bind("Display", "Text size", 0.022f, "Base size of the 3D text above items."); TextHeightOffset = ((BaseUnityPlugin)this).Config.Bind("Display", "Text height offset", 0.38f, "How far above the item the text floats."); LightIntensity = ((BaseUnityPlugin)this).Config.Bind("Display", "Light intensity", 6f, "Base brightness of the apparatus style light."); LightRange = ((BaseUnityPlugin)this).Config.Bind("Display", "Light range", 6f, "Base range of the apparatus style light."); PulseSpeed = ((BaseUnityPlugin)this).Config.Bind("Display", "Pulse speed", 2.8f, "How fast the glow pulses."); TextOcclusionPadding = ((BaseUnityPlugin)this).Config.Bind("Display", "Text occlusion padding", 0.12f, "How much of the end of the ray to ignore when checking if the item is blocked."); ScreenEdgeMargin = ((BaseUnityPlugin)this).Config.Bind("Display", "Screen edge margin", 0.12f, "Extra margin around the screen so text still shows near the edge/peripheral view."); TextVisibilityGraceTime = ((BaseUnityPlugin)this).Config.Bind("Display", "Text visibility grace time", 0.2f, "How long text stays visible after one bad raycast. Helps stop flicker while moving."); harmony.PatchAll(); Log.LogInfo((object)"ScrapVisibility loaded. Stable neutral labels plus normal glow strength enabled."); } private void OnDestroy() { harmony.UnpatchSelf(); } private void Update() { if (!(Time.time < nextRefreshTime)) { nextRefreshTime = Time.time + Mathf.Max(0.2f, RefreshInterval.Value); AttachHighlightersToItems(); } } private void AttachHighlightersToItems() { GrabbableObject[] array = Object.FindObjectsOfType(); GrabbableObject[] array2 = array; foreach (GrabbableObject val in array2) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.itemProperties == (Object)null) && (Object)(object)((Component)val).GetComponent() == (Object)null) { ItemValueHighlighter itemValueHighlighter = ((Component)val).gameObject.AddComponent(); itemValueHighlighter.Init(val); } } } internal static Color GetDisplayColor(bool isScrap, int value) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) if (!isScrap) { return new Color(0.2f, 0.55f, 1f, 1f); } if (value >= 300) { return new Color(1f, 0.78f, 0.05f, 1f); } if (value >= 150) { return new Color(0.72f, 0.25f, 1f, 1f); } if (value >= 100) { return new Color(0.15f, 1f, 0.25f, 1f); } if (value >= 50) { return new Color(1f, 1f, 0.15f, 1f); } return new Color(1f, 0.45f, 0.05f, 1f); } } internal class ItemValueHighlighter : MonoBehaviour { private GrabbableObject item; private GameObject textObject; private TextMesh textMesh; private MeshRenderer textRenderer; private Material textMaterial; private GameObject lightObject; private Light glowLight; private readonly List targetRenderers = new List(); private readonly Dictionary blocks = new Dictionary(); private int lastValue = -999; private string lastName = ""; private Color lastColor = Color.white; private bool textVisible = true; private float lastGoodTextVisibleTime = 0f; private static readonly FieldInfo fieldIsHeld = AccessTools.Field(typeof(GrabbableObject), "isHeld"); private static readonly FieldInfo fieldIsPocketed = AccessTools.Field(typeof(GrabbableObject), "isPocketed"); private static readonly FieldInfo fieldIsHeldByEnemy = AccessTools.Field(typeof(GrabbableObject), "isHeldByEnemy"); private static readonly FieldInfo fieldPlayerHeldBy = AccessTools.Field(typeof(GrabbableObject), "playerHeldBy"); private static readonly FieldInfo fieldCurrentlyHeldObjectServer = AccessTools.Field(typeof(PlayerControllerB), "currentlyHeldObjectServer"); private static readonly FieldInfo fieldCurrentlyHeldObject = AccessTools.Field(typeof(PlayerControllerB), "currentlyHeldObject"); public void Init(GrabbableObject target) { item = target; CacheTargetRenderers(); CreateText(); CreateApparatusLight(); SetVisualsActive(active: false); } private void CacheTargetRenderers() { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown targetRenderers.Clear(); blocks.Clear(); Renderer[] componentsInChildren = ((Component)item).GetComponentsInChildren(true); Renderer[] array = componentsInChildren; foreach (Renderer val in array) { if (!((Object)(object)val == (Object)null)) { string lowerName = ((Object)((Component)val).gameObject).name.ToLowerInvariant(); if (!ShouldSkipRenderer(val, lowerName)) { targetRenderers.Add(val); blocks[val] = new MaterialPropertyBlock(); } } } } private bool ShouldSkipRenderer(Renderer renderer, string lowerName) { if ((Object)(object)renderer == (Object)null) { return true; } if (!renderer.enabled) { return true; } if (string.IsNullOrEmpty(lowerName)) { lowerName = ((Object)((Component)renderer).gameObject).name.ToLowerInvariant(); } string text = ((object)renderer).GetType().Name.ToLowerInvariant(); if (text.Contains("particle") || text.Contains("trail") || text.Contains("line")) { return true; } if (lowerName.Contains("scan") || lowerName.Contains("scannode") || lowerName.Contains("scan node") || lowerName.Contains("trigger") || lowerName.Contains("collider") || lowerName.Contains("collision") || lowerName.Contains("hitbox") || lowerName.Contains("interact") || lowerName.Contains("scrapvisibility") || lowerName.Contains("mapdot") || lowerName.Contains("radar") || lowerName.Contains("audio") || lowerName.Contains("sound") || lowerName.Contains("light") || lowerName.Contains("vfx") || lowerName.Contains("sfx")) { return true; } return false; } private void CreateText() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0039: 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_0048: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Expected O, but got Unknown //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Expected O, but got Unknown //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) textObject = new GameObject("ScrapVisibility_3DText"); textObject.transform.SetParent(ScrapVisibility.GetTextRoot(), false); textObject.transform.position = ((Component)this).transform.position + Vector3.up * 0.5f; textObject.transform.rotation = Quaternion.identity; textObject.transform.localScale = Vector3.one; textMesh = textObject.AddComponent(); textMesh.text = ""; textMesh.alignment = (TextAlignment)1; textMesh.anchor = (TextAnchor)4; textMesh.fontSize = 90; textMesh.characterSize = 0.022f; textMesh.color = Color.white; Font builtinResource = Resources.GetBuiltinResource("Arial.ttf"); if ((Object)(object)builtinResource != (Object)null) { textMesh.font = builtinResource; } textRenderer = textObject.GetComponent(); if ((Object)(object)textRenderer == (Object)null) { textRenderer = textObject.AddComponent(); } if ((Object)(object)textMesh.font != (Object)null && (Object)(object)textMesh.font.material != (Object)null) { textMaterial = new Material(textMesh.font.material); } else { Shader val = Shader.Find("GUI/Text Shader"); if ((Object)(object)val == (Object)null) { val = Shader.Find("Unlit/Transparent"); } if ((Object)(object)val == (Object)null) { val = Shader.Find("Sprites/Default"); } textMaterial = new Material(val); } ((Object)textMaterial).name = "ScrapVisibility_ReadableTextMaterial"; textMaterial.renderQueue = 3000; if (textMaterial.HasProperty("_Cull")) { textMaterial.SetInt("_Cull", 0); } if (textMaterial.HasProperty("_ZWrite")) { textMaterial.SetInt("_ZWrite", 0); } if (textMaterial.HasProperty("_Color")) { textMaterial.SetColor("_Color", Color.white); } if (textMaterial.HasProperty("_FaceColor")) { textMaterial.SetColor("_FaceColor", Color.white); } ((Renderer)textRenderer).sharedMaterial = textMaterial; ((Renderer)textRenderer).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)textRenderer).receiveShadows = false; } private void CreateApparatusLight() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) lightObject = new GameObject("ScrapVisibility_ApparatusStyleLight"); lightObject.transform.SetParent(((Component)this).transform, false); lightObject.transform.localPosition = Vector3.zero; glowLight = lightObject.AddComponent(); glowLight.type = (LightType)2; glowLight.color = Color.white; glowLight.intensity = 6f; glowLight.range = 6f; ((Behaviour)glowLight).enabled = false; glowLight.shadows = (LightShadows)1; glowLight.renderMode = (LightRenderMode)1; glowLight.cullingMask = -1; glowLight.bounceIntensity = 1.2f; } private void LateUpdate() { //IL_00fc: 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) //IL_013e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)item == (Object)null) { DestroySelf(); return; } if ((Object)(object)item.itemProperties == (Object)null) { ClearGlow(); SetVisualsActive(active: false); return; } PlayerControllerB localPlayer = GetLocalPlayer(); if ((Object)(object)localPlayer == (Object)null || !localPlayer.isPlayerControlled || localPlayer.isPlayerDead) { ClearGlow(); SetVisualsActive(active: false); return; } if (IsHeldByAnyone(localPlayer)) { ClearGlow(); SetVisualsActive(active: false); return; } if (!((Component)item).gameObject.activeInHierarchy) { ClearGlow(); SetVisualsActive(active: false); return; } if (!TryGetBounds(out var bounds)) { ClearGlow(); SetVisualsActive(active: false); return; } float num = Vector3.Distance(((Component)localPlayer).transform.position, ((Bounds)(ref bounds)).center); if (ScrapVisibility.MaxDistance != null && num > ScrapVisibility.MaxDistance.Value) { ClearGlow(); SetVisualsActive(active: false); } else { UpdateVisuals(bounds, num); SetVisualsActive(active: true); } } private PlayerControllerB GetLocalPlayer() { if ((Object)(object)GameNetworkManager.Instance == (Object)null) { return null; } return GameNetworkManager.Instance.localPlayerController; } private bool IsHeldByAnyone(PlayerControllerB localPlayer) { if (GetBoolField(fieldIsHeld)) { return true; } if (GetBoolField(fieldIsPocketed)) { return true; } if (GetBoolField(fieldIsHeldByEnemy)) { return true; } object objectField = GetObjectField(fieldPlayerHeldBy); if (objectField != null) { return true; } if ((Object)(object)localPlayer != (Object)null) { object playerObjectField = GetPlayerObjectField(localPlayer, fieldCurrentlyHeldObjectServer); object playerObjectField2 = GetPlayerObjectField(localPlayer, fieldCurrentlyHeldObject); if (playerObjectField == item || playerObjectField2 == item) { return true; } } Transform parent = ((Component)item).transform.parent; if ((Object)(object)parent != (Object)null) { string text = ((Object)parent).name.ToLowerInvariant(); if (text.Contains("player") || text.Contains("hand") || text.Contains("hold") || text.Contains("itemholder") || text.Contains("pocket")) { return true; } } return false; } private bool GetBoolField(FieldInfo field) { try { if (field == null) { return false; } object value = field.GetValue(item); if (value is bool) { return (bool)value; } } catch { } return false; } private object GetObjectField(FieldInfo field) { try { if (field == null) { return null; } return field.GetValue(item); } catch { } return null; } private object GetPlayerObjectField(PlayerControllerB player, FieldInfo field) { try { if (field == null || (Object)(object)player == (Object)null) { return null; } return field.GetValue(player); } catch { } return null; } private bool TryGetBounds(out Bounds bounds) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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) bounds = new Bounds(((Component)this).transform.position, Vector3.one * 0.25f); bool flag = false; foreach (Renderer targetRenderer in targetRenderers) { if ((Object)(object)targetRenderer == (Object)null) { continue; } string lowerName = ((Object)((Component)targetRenderer).gameObject).name.ToLowerInvariant(); if (!ShouldSkipRenderer(targetRenderer, lowerName) && ((Component)targetRenderer).gameObject.activeInHierarchy) { if (!flag) { bounds = targetRenderer.bounds; flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(targetRenderer.bounds); } } } return flag; } private void UpdateVisuals(Bounds bounds, float distance) { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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_00db: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) bool flag = (Object)(object)item.itemProperties != (Object)null && item.itemProperties.isScrap; int num = Mathf.Max(0, item.scrapValue); string text = "Item"; if ((Object)(object)item.itemProperties != (Object)null && !string.IsNullOrEmpty(item.itemProperties.itemName)) { text = item.itemProperties.itemName; } Color displayColor = ScrapVisibility.GetDisplayColor(flag, num); float num2 = 0.78f + Mathf.Sin(Time.time * GetPulseSpeed()) * 0.22f; Color tintColor = Color.Lerp(Color.white, displayColor, GetTintStrength()); tintColor.a = 1f; Color emissionColor = displayColor * GetEmissionStrength() * num2; emissionColor.a = 1f; ApplyGlow(tintColor, emissionColor); if (num != lastValue || text != lastName || displayColor != lastColor) { lastValue = num; lastName = text; lastColor = displayColor; if ((Object)(object)textMesh != (Object)null) { if (flag) { textMesh.text = text + "\n$" + num; } else { textMesh.text = text; } } } UpdateApparatusLight(bounds, flag, num, displayColor, num2); UpdateText(bounds, distance, displayColor); } private void UpdateApparatusLight(Bounds bounds, bool isScrap, int value, Color baseColor, float pulse) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)glowLight == (Object)null)) { float lightMultiplierForItem = GetLightMultiplierForItem(isScrap, value); ((Component)glowLight).transform.position = ((Bounds)(ref bounds)).center; glowLight.color = baseColor; glowLight.intensity = GetLightIntensity() * lightMultiplierForItem * pulse; glowLight.range = GetLightRange() * lightMultiplierForItem; glowLight.bounceIntensity = 1.5f + lightMultiplierForItem * 0.35f; } } private float GetLightMultiplierForItem(bool isScrap, int value) { if (!isScrap) { return 1.25f; } if (value >= 300) { return 2.25f; } if (value >= 150) { return 1.8f; } if (value >= 100) { return 1.45f; } if (value >= 50) { return 1.15f; } return 0.9f; } private void ApplyGlow(Color tintColor, Color emissionColor) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) if (ScrapVisibility.ShowModelGlow == null || !ScrapVisibility.ShowModelGlow.Value) { ClearGlow(); return; } foreach (Renderer targetRenderer in targetRenderers) { if (!((Object)(object)targetRenderer == (Object)null)) { MaterialPropertyBlock val = blocks[targetRenderer]; targetRenderer.GetPropertyBlock(val); val.SetColor("_Color", tintColor); val.SetColor("_BaseColor", tintColor); val.SetColor("_EmissionColor", emissionColor); val.SetColor("_EmissiveColor", emissionColor); targetRenderer.SetPropertyBlock(val); } } } private void ClearGlow() { foreach (Renderer targetRenderer in targetRenderers) { if (!((Object)(object)targetRenderer == (Object)null)) { targetRenderer.SetPropertyBlock((MaterialPropertyBlock)null); } } } private void UpdateText(Bounds bounds, float distance, Color color) { //IL_0069: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)textObject == (Object)null || (Object)(object)textMesh == (Object)null) { return; } Transform textRoot = ScrapVisibility.GetTextRoot(); if ((Object)(object)textObject.transform.parent != (Object)(object)textRoot) { textObject.transform.SetParent(textRoot, true); } textObject.transform.position = GetStableLabelPosition(bounds); Camera main = Camera.main; if ((Object)(object)main != (Object)null) { textObject.transform.rotation = ((Component)main).transform.rotation; } textVisible = IsObjectVisibleForText(bounds); textMesh.characterSize = GetTextSize(); textObject.transform.localScale = Vector3.one; textMesh.color = color; if ((Object)(object)textMaterial != (Object)null) { if (textMaterial.HasProperty("_Color")) { textMaterial.SetColor("_Color", color); } if (textMaterial.HasProperty("_FaceColor")) { textMaterial.SetColor("_FaceColor", color); } } } private Vector3 GetStableLabelPosition(Bounds bounds) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0027: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_00af: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Bounds)(ref bounds)).center; float num = Mathf.Clamp(((Bounds)(ref bounds)).size.y, 0.15f, 3f); float y = ((Bounds)(ref bounds)).max.y; float num2 = GetTextHeightOffset() + Mathf.Clamp(num * 0.15f, 0.04f, 0.3f); val.y = y + num2; if (float.IsNaN(val.x) || float.IsNaN(val.y) || float.IsNaN(val.z)) { val = ((Component)this).transform.position + Vector3.up * 0.6f; } return val; } private Vector3 GetParentScaleCompensatedLocalScale(float desiredWorldScale) { //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_0046: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) Transform val = (((Object)(object)textObject != (Object)null) ? textObject.transform.parent : null); if ((Object)(object)val == (Object)null) { return Vector3.one * desiredWorldScale; } Vector3 lossyScale = val.lossyScale; return new Vector3(desiredWorldScale / SafeSignedScale(lossyScale.x), desiredWorldScale / SafeSignedScale(lossyScale.y), desiredWorldScale / SafeSignedScale(lossyScale.z)); } private float SafeSignedScale(float value) { if (Mathf.Abs(value) < 0.001f) { return (value < 0f) ? (-0.001f) : 0.001f; } return value; } private bool IsObjectVisibleForText(Bounds bounds) { //IL_0045: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_005d: 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_006a: 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) //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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00a1: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_00ec: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011f: 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) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013d: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015c: 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_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: 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_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: 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_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0222: 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_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) if (ScrapVisibility.HideTextBehindWalls == null || !ScrapVisibility.HideTextBehindWalls.Value) { return true; } Camera main = Camera.main; if ((Object)(object)main == (Object)null) { return true; } Vector3 center = ((Bounds)(ref bounds)).center; Vector3 extents = ((Bounds)(ref bounds)).extents; Vector3[] array = (Vector3[])(object)new Vector3[15] { center, center + new Vector3(0f, extents.y, 0f), center - new Vector3(0f, extents.y, 0f), center + new Vector3(extents.x, 0f, 0f), center - new Vector3(extents.x, 0f, 0f), center + new Vector3(0f, 0f, extents.z), center - new Vector3(0f, 0f, extents.z), center + new Vector3(extents.x, extents.y, extents.z), center + new Vector3(0f - extents.x, extents.y, extents.z), center + new Vector3(extents.x, extents.y, 0f - extents.z), center + new Vector3(0f - extents.x, extents.y, 0f - extents.z), center + new Vector3(extents.x, 0f - extents.y, extents.z), center + new Vector3(0f - extents.x, 0f - extents.y, extents.z), center + new Vector3(extents.x, 0f - extents.y, 0f - extents.z), center + new Vector3(0f - extents.x, 0f - extents.y, 0f - extents.z) }; for (int i = 0; i < array.Length; i++) { if (PointIsOnScreenAndNotBlocked(main, array[i])) { lastGoodTextVisibleTime = Time.time; return true; } } float num = 0.2f; if (ScrapVisibility.TextVisibilityGraceTime != null) { num = Mathf.Clamp(ScrapVisibility.TextVisibilityGraceTime.Value, 0f, 1f); } if (Time.time - lastGoodTextVisibleTime < num) { return true; } return false; } private bool PointIsOnScreenAndNotBlocked(Camera cam, Vector3 targetPosition) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_00f0: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) Vector3 val = cam.WorldToViewportPoint(targetPosition); if (val.z <= 0f) { return false; } float num = 0.12f; if (ScrapVisibility.ScreenEdgeMargin != null) { num = Mathf.Clamp(ScrapVisibility.ScreenEdgeMargin.Value, 0f, 0.35f); } if (val.x < 0f - num || val.x > 1f + num) { return false; } if (val.y < 0f - num || val.y > 1f + num) { return false; } Vector3 position = ((Component)cam).transform.position; Vector3 val2 = targetPosition - position; float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude <= 0.05f) { return true; } Vector3 normalized = ((Vector3)(ref val2)).normalized; position += normalized * 0.25f; float num2 = 0.12f; if (ScrapVisibility.TextOcclusionPadding != null) { num2 = Mathf.Clamp(ScrapVisibility.TextOcclusionPadding.Value, 0.01f, 1f); } float num3 = Mathf.Max(0.05f, magnitude - num2); RaycastHit[] array = Physics.RaycastAll(position, normalized, num3, -1, (QueryTriggerInteraction)1); if (array == null || array.Length == 0) { return true; } Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance)); PlayerControllerB localPlayer = GetLocalPlayer(); for (int i = 0; i < array.Length; i++) { RaycastHit val3 = array[i]; if ((Object)(object)((RaycastHit)(ref val3)).collider == (Object)null) { continue; } Transform transform = ((Component)((RaycastHit)(ref val3)).collider).transform; if ((Object)(object)textObject != (Object)null && transform.IsChildOf(textObject.transform)) { continue; } if (transform.IsChildOf(((Component)item).transform)) { return true; } GrabbableObject componentInParent = ((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)(object)item) { return true; } if ((!((Object)(object)localPlayer != (Object)null) || !transform.IsChildOf(((Component)localPlayer).transform)) && !((Object)(object)componentInParent != (Object)null)) { string text = ((Object)transform).name.ToLowerInvariant(); if (!text.Contains("player") && !text.Contains("camera") && !text.Contains("hand") && !text.Contains("itemholder") && !text.Contains("held") && !text.Contains("helmet") && !text.Contains("scan") && !text.Contains("trigger")) { return false; } } } return true; } private void SetVisualsActive(bool active) { bool flag = active && textVisible && ScrapVisibility.ShowText != null && ScrapVisibility.ShowText.Value; bool enabled = active && ScrapVisibility.ShowLight != null && ScrapVisibility.ShowLight.Value; if ((Object)(object)textObject != (Object)null && textObject.activeSelf != flag) { textObject.SetActive(flag); } if ((Object)(object)glowLight != (Object)null) { ((Behaviour)glowLight).enabled = enabled; } } private float GetTintStrength() { if (ScrapVisibility.TintStrength == null) { return 1f; } return Mathf.Clamp01(ScrapVisibility.TintStrength.Value); } private float GetEmissionStrength() { if (ScrapVisibility.EmissionStrength == null) { return 5.5f; } return Mathf.Clamp(ScrapVisibility.EmissionStrength.Value, 0f, 12f); } private float GetPulseSpeed() { if (ScrapVisibility.PulseSpeed == null) { return 2.8f; } return Mathf.Max(0f, ScrapVisibility.PulseSpeed.Value); } private float GetLightIntensity() { if (ScrapVisibility.LightIntensity == null) { return 6f; } return Mathf.Clamp(ScrapVisibility.LightIntensity.Value, 0f, 30f); } private float GetLightRange() { if (ScrapVisibility.LightRange == null) { return 6f; } return Mathf.Clamp(ScrapVisibility.LightRange.Value, 0f, 20f); } private float GetTextSize() { if (ScrapVisibility.TextSize == null) { return 0.022f; } return Mathf.Clamp(ScrapVisibility.TextSize.Value, 0.005f, 0.14f); } private float GetTextHeightOffset() { if (ScrapVisibility.TextHeightOffset == null) { return 0.22f; } return Mathf.Clamp(ScrapVisibility.TextHeightOffset.Value, 0f, 2f); } private void DestroySelf() { ClearGlow(); if ((Object)(object)textObject != (Object)null) { Object.Destroy((Object)(object)textObject); textObject = null; } if ((Object)(object)lightObject != (Object)null) { Object.Destroy((Object)(object)lightObject); lightObject = null; } if ((Object)(object)textMaterial != (Object)null) { Object.Destroy((Object)(object)textMaterial); textMaterial = null; } Object.Destroy((Object)(object)this); } private void OnDestroy() { ClearGlow(); if ((Object)(object)textObject != (Object)null) { Object.Destroy((Object)(object)textObject); } if ((Object)(object)lightObject != (Object)null) { Object.Destroy((Object)(object)lightObject); } if ((Object)(object)textMaterial != (Object)null) { Object.Destroy((Object)(object)textMaterial); } } } [HarmonyPatch(typeof(HUDManager), "PingScan_performed")] internal static class DisableManualScannerPatch { private static bool Prefix() { if (ScrapVisibility.DisableManualRightClickScan != null && ScrapVisibility.DisableManualRightClickScan.Value) { return false; } return true; } }