using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("XRayLuggage")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("XRayLuggage")]
[assembly: AssemblyTitle("XRayLuggage")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 CrateHighlighter
{
[BepInPlugin("com.gildmade.xrayluggage", "X-Ray Luggage", "1.33.0")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
private ConfigEntry<string> ColorSmall;
private ConfigEntry<string> ColorBig;
private ConfigEntry<string> ColorEpic;
private ConfigEntry<string> ColorAncient;
private ConfigEntry<string> ColorClown;
private ConfigEntry<float> MaxAlpha;
private ConfigEntry<float> MinAlpha;
private ConfigEntry<float> FadeStart;
private ConfigEntry<float> FadeEnd;
private ConfigEntry<float> LerpSpeed;
private readonly HashSet<GameObject> _processed = new HashSet<GameObject>();
private readonly Dictionary<GameObject, Material> _outlineMaterials = new Dictionary<GameObject, Material>();
private readonly Dictionary<GameObject, float> _currentAlphas = new Dictionary<GameObject, float>();
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"X-Ray Luggage v1.33 loaded successfully!");
CreateConfig();
((MonoBehaviour)this).StartCoroutine(ScanRoutine());
}
private void Update()
{
UpdateAlphaSmooth();
}
private void CreateConfig()
{
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Expected O, but got Unknown
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Expected O, but got Unknown
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Expected O, but got Unknown
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Expected O, but got Unknown
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Expected O, but got Unknown
ColorSmall = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "LuggageSmall", "00FF4CFF", "Color for small luggage (HEX RRGGBBAA)");
ColorBig = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "LuggageBig", "FFE600FF", "Color for big luggage (HEX RRGGBBAA)");
ColorEpic = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "LuggageEpic", "CC33FFFF", "Color for epic luggage (HEX RRGGBBAA)");
ColorAncient = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "LuggageAncient", "FF8000FF", "Color for ancient luggage (HEX RRGGBBAA)");
ColorClown = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "ClownLuggage", "FF0033FF", "Color for clown luggage (HEX RRGGBBAA)");
MaxAlpha = ((BaseUnityPlugin)this).Config.Bind<float>("Transparency", "MaxAlpha", 0.9f, new ConfigDescription("Transparency from far distance (0-1)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
MinAlpha = ((BaseUnityPlugin)this).Config.Bind<float>("Transparency", "MinAlpha", 0.1f, new ConfigDescription("Transparency at close distance (0-1)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
FadeStart = ((BaseUnityPlugin)this).Config.Bind<float>("Transparency", "FadeStart", 10f, new ConfigDescription("Distance where fade starts (meters)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f), Array.Empty<object>()));
FadeEnd = ((BaseUnityPlugin)this).Config.Bind<float>("Transparency", "FadeEnd", 3f, new ConfigDescription("Distance where fade ends (meters)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f), Array.Empty<object>()));
LerpSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Transparency", "LerpSpeed", 5f, new ConfigDescription("Smooth transition speed", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), Array.Empty<object>()));
}
private Color ParseHexColor(string hexString)
{
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: 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_00b6: 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)
try
{
hexString = hexString.Trim().Replace("#", "");
if (hexString.Length >= 6)
{
float num = (float)int.Parse(hexString.Substring(0, 2), NumberStyles.HexNumber) / 255f;
float num2 = (float)int.Parse(hexString.Substring(2, 2), NumberStyles.HexNumber) / 255f;
float num3 = (float)int.Parse(hexString.Substring(4, 2), NumberStyles.HexNumber) / 255f;
float num4 = 1f;
if (hexString.Length >= 8)
{
num4 = (float)int.Parse(hexString.Substring(6, 2), NumberStyles.HexNumber) / 255f;
}
return new Color(num, num2, num3, num4);
}
}
catch
{
}
return Color.white;
}
private Color GetColor(string type)
{
//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_00a6: Unknown result type (might be due to invalid IL or missing references)
if (1 == 0)
{
}
string text = type switch
{
"LuggageSmall" => ColorSmall.Value,
"LuggageBig" => ColorBig.Value,
"LuggageEpic" => ColorEpic.Value,
"LuggageAncient" => ColorAncient.Value,
"ClownLuggage" => ColorClown.Value,
_ => "FFFFFFFF",
};
if (1 == 0)
{
}
string hexString = text;
return ParseHexColor(hexString);
}
private Material CreateMaterial(Color color, float alpha)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_003d: 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_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Expected O, but got Unknown
//IL_00e4: 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_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_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Expected O, but got Unknown
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
Shader val = Shader.Find("Hidden/Internal-Colored");
Shader val2 = Shader.Find("UI/Default");
Shader val3 = Shader.Find("Universal Render Pipeline/Unlit");
Material val4;
if ((Object)(object)val != (Object)null)
{
val4 = new Material(val);
val4.SetColor("_Color", new Color(color.r, color.g, color.b, alpha));
val4.SetInt("_SrcBlend", 5);
val4.SetInt("_DstBlend", 10);
}
else if ((Object)(object)val2 != (Object)null)
{
val4 = new Material(val2);
val4.SetColor("_Color", new Color(color.r, color.g, color.b, alpha));
val4.SetTexture("_MainTex", (Texture)(object)Texture2D.whiteTexture);
val4.SetInt("unity_GUIZTest", 8);
}
else
{
val4 = new Material(val3);
val4.SetColor("_BaseColor", new Color(color.r, color.g, color.b, alpha));
val4.SetInt("_Surface", 1);
val4.EnableKeyword("_SURFACE_TYPE_TRANSPARENT");
}
((Object)val4).hideFlags = (HideFlags)61;
val4.SetInt("_Cull", 0);
val4.SetInt("_ZWrite", 0);
val4.SetInt("_ZTest", 8);
val4.renderQueue = 4000;
return val4;
}
private IEnumerator ScanRoutine()
{
yield return (object)new WaitForSeconds(3f);
while (true)
{
Scan();
yield return (object)new WaitForSeconds(2f);
}
}
private void Scan()
{
GameObject[] array = Object.FindObjectsByType<GameObject>((FindObjectsSortMode)0);
GameObject[] array2 = array;
foreach (GameObject val in array2)
{
if (!((Object)(object)val == (Object)null) && !_processed.Contains(val))
{
string text = MatchType(((Object)val).name);
if (text != null)
{
_processed.Add(val);
AttachOutline(val, text);
}
}
}
}
private static string MatchType(string raw)
{
string text = raw.ToLowerInvariant();
if (text.Contains("clown"))
{
return "ClownLuggage";
}
if (!text.Contains("luggage"))
{
return null;
}
if (text.Contains("ancient"))
{
return "LuggageAncient";
}
if (text.Contains("epic"))
{
return "LuggageEpic";
}
if (text.Contains("big"))
{
return "LuggageBig";
}
if (text.Contains("small"))
{
return "LuggageSmall";
}
return null;
}
private void AttachOutline(GameObject crate, string type)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
Renderer val = null;
Transform val2 = null;
foreach (Transform item in crate.transform)
{
Transform val3 = item;
if (((Object)val3).name.ToLowerInvariant() == "luggage")
{
val = ((Component)val3).GetComponent<Renderer>();
if ((Object)(object)val != (Object)null)
{
val2 = val3;
break;
}
}
}
if ((Object)(object)val == (Object)null)
{
val = crate.GetComponentInChildren<Renderer>();
val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform : crate.transform);
}
if ((Object)(object)val == (Object)null)
{
return;
}
Mesh val4 = null;
SkinnedMeshRenderer val5 = (SkinnedMeshRenderer)(object)((val is SkinnedMeshRenderer) ? val : null);
if (val5 != null)
{
val4 = val5.sharedMesh;
}
else
{
MeshFilter component = ((Component)val2).GetComponent<MeshFilter>();
if ((Object)(object)component != (Object)null)
{
val4 = component.sharedMesh;
}
}
if (!((Object)(object)val4 == (Object)null))
{
Color color = GetColor(type);
Material val6 = CreateMaterial(color, MaxAlpha.Value);
_outlineMaterials[crate] = val6;
_currentAlphas[crate] = MaxAlpha.Value;
CreateOutline(val2, val4, val6, 1.05f);
}
}
private void CreateOutline(Transform host, Mesh mesh, Material mat, float scale)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0029: 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)
GameObject val = new GameObject("Outline");
val.layer = 31;
val.transform.SetParent(host, false);
val.transform.localScale = Vector3.one * scale;
MeshFilter val2 = val.AddComponent<MeshFilter>();
val2.sharedMesh = mesh;
MeshRenderer val3 = val.AddComponent<MeshRenderer>();
((Renderer)val3).sharedMaterial = mat;
((Renderer)val3).shadowCastingMode = (ShadowCastingMode)0;
((Renderer)val3).receiveShadows = false;
((Renderer)val3).lightProbeUsage = (LightProbeUsage)0;
((Renderer)val3).reflectionProbeUsage = (ReflectionProbeUsage)0;
}
private void UpdateAlphaSmooth()
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
Camera main = Camera.main;
if ((Object)(object)main == (Object)null)
{
return;
}
foreach (KeyValuePair<GameObject, Material> outlineMaterial in _outlineMaterials)
{
GameObject key = outlineMaterial.Key;
Material value = outlineMaterial.Value;
if (!((Object)(object)key == (Object)null))
{
float num = Vector3.Distance(((Component)main).transform.position, key.transform.position);
float num2;
if (num >= FadeStart.Value)
{
num2 = MaxAlpha.Value;
}
else if (num <= FadeEnd.Value)
{
num2 = MinAlpha.Value;
}
else
{
float num3 = (num - FadeEnd.Value) / (FadeStart.Value - FadeEnd.Value);
num2 = Mathf.Lerp(MinAlpha.Value, MaxAlpha.Value, num3);
}
float num4 = _currentAlphas[key];
float num5 = Mathf.Lerp(num4, num2, Time.deltaTime * LerpSpeed.Value);
_currentAlphas[key] = num5;
Color color = value.GetColor("_Color");
color.a = num5;
value.SetColor("_Color", color);
}
}
}
}
}