Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ValuableGlow v1.0.2
ValuableGlow.dll
Decompiled 2 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ValuableGlow")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ValuableGlow")] [assembly: AssemblyTitle("ValuableGlow")] [assembly: AssemblyVersion("1.0.0.0")] [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 ValuableGlow { public enum GlowStyle { EmissionAndLight, EmissionOnly, LightOnly } public enum ColorMode { ByValue, Fixed, Rainbow } [BepInPlugin("mrbalera01.ValuableGlow", "ValuableGlow", "1.0.0")] public class ValuableGlowPlugin : BaseUnityPlugin { public const string Guid = "mrbalera01.ValuableGlow"; public const string Name = "ValuableGlow"; public const string Version = "1.0.0"; internal static ManualLogSource Log; internal static ConfigEntry<bool> GlowValuables; internal static ConfigEntry<bool> GlowItems; internal static ConfigEntry<bool> GlowOtherGrabbables; internal static ConfigEntry<GlowStyle> Style; internal static ConfigEntry<ColorMode> Mode; internal static ConfigEntry<string> FixedColor; internal static ConfigEntry<string> LowColor; internal static ConfigEntry<string> MidColor; internal static ConfigEntry<string> HighColor; internal static ConfigEntry<string> ItemColor; internal static ConfigEntry<string> OtherColor; internal static ConfigEntry<float> MidThreshold; internal static ConfigEntry<float> HighThreshold; internal static ConfigEntry<float> EmissionIntensity; internal static ConfigEntry<float> LightIntensity; internal static ConfigEntry<float> LightRange; internal static ConfigEntry<float> TintStrength; internal static ConfigEntry<float> FallbackTint; internal static ConfigEntry<bool> Pulse; internal static ConfigEntry<float> PulseSpeed; internal static ConfigEntry<float> PulseAmount; internal static ConfigEntry<float> RainbowSpeed; internal static ConfigEntry<float> LightMaxDistance; internal static ConfigEntry<float> ScanInterval; private float _timer; private void Awake() { //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Expected O, but got Unknown //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Expected O, but got Unknown //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Expected O, but got Unknown //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Expected O, but got Unknown //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Expected O, but got Unknown //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; GlowValuables = ((BaseUnityPlugin)this).Config.Bind<bool>("1. Targets", "GlowValuables", true, "Светятся ценные предметы (то, что сдаётся на квоту)."); GlowItems = ((BaseUnityPlugin)this).Config.Bind<bool>("1. Targets", "GlowItems", true, "Светятся предметы-инструменты (оружие, аптечки, батарейки и т.д.)."); GlowOtherGrabbables = ((BaseUnityPlugin)this).Config.Bind<bool>("1. Targets", "GlowOtherGrabbables", false, "Светится вообще всё, что можно схватить (бочки, ящики, мебель)."); Style = ((BaseUnityPlugin)this).Config.Bind<GlowStyle>("2. Look", "Style", GlowStyle.EmissionAndLight, "EmissionAndLight / EmissionOnly / LightOnly"); Mode = ((BaseUnityPlugin)this).Config.Bind<ColorMode>("2. Look", "ColorMode", ColorMode.ByValue, "ByValue - цвет зависит от стоимости; Fixed - один цвет; Rainbow - радуга."); FixedColor = ((BaseUnityPlugin)this).Config.Bind<string>("2. Look", "FixedColor", "#00FFAA", "Цвет для режима Fixed (HEX)."); LowColor = ((BaseUnityPlugin)this).Config.Bind<string>("2. Look", "LowValueColor", "#4DFF4D", "Дешёвые ценности (HEX)."); MidColor = ((BaseUnityPlugin)this).Config.Bind<string>("2. Look", "MidValueColor", "#FFD21F", "Средние ценности (HEX)."); HighColor = ((BaseUnityPlugin)this).Config.Bind<string>("2. Look", "HighValueColor", "#FF2E63", "Дорогие ценности (HEX)."); ItemColor = ((BaseUnityPlugin)this).Config.Bind<string>("2. Look", "ItemColor", "#3DA5FF", "Цвет предметов-инструментов (HEX)."); OtherColor = ((BaseUnityPlugin)this).Config.Bind<string>("2. Look", "OtherGrabbableColor", "#BBBBBB", "Цвет прочих предметов (HEX)."); MidThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("2. Look", "MidValueThreshold", 2000f, "Со скольких $ ценность считается средней."); HighThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("2. Look", "HighValueThreshold", 8000f, "Со скольких $ ценность считается дорогой."); EmissionIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("3. Glow", "EmissionIntensity", 1.5f, new ConfigDescription("Яркость свечения самого предмета.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); LightIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("3. Glow", "LightIntensity", 1.2f, new ConfigDescription("Яркость ореола (источника света).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); LightRange = ((BaseUnityPlugin)this).Config.Bind<float>("3. Glow", "LightRange", 2.5f, new ConfigDescription("Радиус ореола в метрах.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 15f), Array.Empty<object>())); TintStrength = ((BaseUnityPlugin)this).Config.Bind<float>("3. Glow", "TintStrength", 0f, new ConfigDescription("Насколько перекрашивать сам предмет в цвет свечения (0 = не менять).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); FallbackTint = ((BaseUnityPlugin)this).Config.Bind<float>("3. Glow", "FallbackTint", 0.65f, new ConfigDescription("Если у материала предмета нет канала свечения, предмет просто перекрашивается в цвет свечения с этой силой (0 = не перекрашивать).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); Pulse = ((BaseUnityPlugin)this).Config.Bind<bool>("3. Glow", "Pulse", true, "Пульсация свечения."); PulseSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("3. Glow", "PulseSpeed", 2.5f, "Скорость пульсации."); PulseAmount = ((BaseUnityPlugin)this).Config.Bind<float>("3. Glow", "PulseAmount", 0.35f, new ConfigDescription("Глубина пульсации.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); RainbowSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("3. Glow", "RainbowSpeed", 0.3f, "Скорость смены цветов в режиме Rainbow."); LightMaxDistance = ((BaseUnityPlugin)this).Config.Bind<float>("4. Performance", "LightMaxDistance", 25f, "Ореол-источник света включается только ближе этой дистанции (метры)."); ScanInterval = ((BaseUnityPlugin)this).Config.Bind<float>("4. Performance", "ScanInterval", 1.5f, "Как часто искать новые предметы (секунды)."); ((BaseUnityPlugin)this).Logger.LogInfo((object)"ValuableGlow 1.0.0 loaded"); } private void Update() { _timer -= Time.unscaledDeltaTime; if (!(_timer > 0f)) { _timer = Mathf.Max(0.25f, ScanInterval.Value); Scan(); } } private static void Scan() { if (GlowValuables.Value) { ValuableObject[] array = Object.FindObjectsOfType<ValuableObject>(); foreach (ValuableObject val in array) { Attach(((Component)val).gameObject, GlowMarker.Kind.Valuable, val); } } if (!GlowItems.Value && !GlowOtherGrabbables.Value) { return; } PhysGrabObject[] array2 = Object.FindObjectsOfType<PhysGrabObject>(); foreach (PhysGrabObject val2 in array2) { if (!((Object)(object)((Component)val2).GetComponent<ValuableObject>() != (Object)null)) { bool flag = (Object)(object)((Component)val2).GetComponent<ItemAttributes>() != (Object)null; if (flag && GlowItems.Value) { Attach(((Component)val2).gameObject, GlowMarker.Kind.Item, null); } else if (!flag && GlowOtherGrabbables.Value) { Attach(((Component)val2).gameObject, GlowMarker.Kind.Other, null); } } } } private static void Attach(GameObject go, GlowMarker.Kind kind, ValuableObject val) { if (!((Object)(object)go.GetComponent<GlowMarker>() != (Object)null)) { go.AddComponent<GlowMarker>().Setup(kind, val); } } internal static Color ParseColor(string hex, Color fallback) { //IL_000c: 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) Color result = default(Color); if (!ColorUtility.TryParseHtmlString(hex, ref result)) { return fallback; } return result; } } public class GlowMarker : MonoBehaviour { public enum Kind { Valuable, Item, Other } private class MatInfo { public Material Mat; public int EmissionId = -1; public int BaseId = -1; public Color BaseColor = Color.white; } private Kind _kind; private ValuableObject _val; private Light _light; private readonly List<MatInfo> _mats = new List<MatInfo>(); private static readonly HashSet<string> _loggedShaders = new HashSet<string>(); private float _phase; private static readonly string[] EmissionNames = new string[6] { "_EmissionColor", "_EmissiveColor", "_Emission", "_EmissionColour", "_GlowColor", "_Glow" }; private static readonly string[] BaseNames = new string[5] { "_BaseColor", "_Color", "_MainColor", "_Tint", "_TintColor" }; private static FieldInfo _valueField; private static bool _valueFieldSearched; private static int FindProp(Material m, string[] names, string containsA, string containsB, bool excludeEmission) { string[] array = names; foreach (string text in array) { if (m.HasProperty(text)) { return Shader.PropertyToID(text); } } try { array = m.GetPropertyNames((MaterialPropertyType)2); foreach (string text2 in array) { string text3 = text2.ToLowerInvariant(); bool flag = text3.Contains("emi") || text3.Contains("glow"); if (!(excludeEmission && flag) && (text3.Contains(containsA) || (containsB != null && text3.Contains(containsB)))) { return Shader.PropertyToID(text2); } } } catch { } return -1; } public void Setup(Kind kind, ValuableObject val) { //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Expected O, but got Unknown //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) _kind = kind; _val = val; _phase = Random.value * 6.28f; Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true); foreach (Renderer val2 in componentsInChildren) { if (val2 is ParticleSystemRenderer || val2 is TrailRenderer || val2 is LineRenderer) { continue; } Material[] materials = val2.materials; foreach (Material val3 in materials) { if ((Object)(object)val3 == (Object)null) { continue; } MatInfo matInfo = new MatInfo { Mat = val3 }; matInfo.EmissionId = FindProp(val3, EmissionNames, "emi", "glow", excludeEmission: false); matInfo.BaseId = FindProp(val3, BaseNames, "color", "tint", excludeEmission: true); if (matInfo.EmissionId != -1) { val3.EnableKeyword("_EMISSION"); val3.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)0; } if (matInfo.BaseId != -1) { matInfo.BaseColor = val3.GetColor(matInfo.BaseId); } string text = (((Object)(object)val3.shader != (Object)null) ? ((Object)val3.shader).name : "null"); if (_loggedShaders.Add(text)) { string text2 = ""; try { text2 = string.Join(", ", val3.GetPropertyNames((MaterialPropertyType)2)); } catch { } ValuableGlowPlugin.Log.LogInfo((object)$"Shader '{text}': emission={matInfo.EmissionId != -1}, base={matInfo.BaseId != -1}, vector props: {text2}"); } if (matInfo.EmissionId != -1 || matInfo.BaseId != -1) { _mats.Add(matInfo); } } } GameObject val4 = new GameObject("ValuableGlowLight"); val4.transform.SetParent(((Component)this).transform, false); val4.transform.localPosition = Vector3.zero; _light = val4.AddComponent<Light>(); _light.type = (LightType)2; _light.shadows = (LightShadows)0; ((Behaviour)_light).enabled = false; } private static float ReadValue(ValuableObject v) { if ((Object)(object)v == (Object)null) { return 0f; } if (!_valueFieldSearched) { _valueFieldSearched = true; BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; Type typeFromHandle = typeof(ValuableObject); string[] array = new string[3] { "dollarValueCurrent", "dollarValueOverride", "dollarValueOriginal" }; foreach (string name in array) { FieldInfo field = typeFromHandle.GetField(name, bindingAttr); if (field != null && (field.FieldType == typeof(float) || field.FieldType == typeof(int))) { _valueField = field; break; } } if (_valueField == null) { ValuableGlowPlugin.Log.LogWarning((object)"Value field not found. Fields of ValuableObject:"); FieldInfo[] fields = typeFromHandle.GetFields(bindingAttr); foreach (FieldInfo fieldInfo in fields) { ValuableGlowPlugin.Log.LogWarning((object)(" " + fieldInfo.FieldType.Name + " " + fieldInfo.Name)); } } else { ValuableGlowPlugin.Log.LogInfo((object)("Using value field: " + _valueField.Name)); } } if (_valueField == null) { return 0f; } try { return Convert.ToSingle(_valueField.GetValue(v)); } catch { return 0f; } } private Color PickColor() { //IL_004a: 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) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_008b: 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_00eb: 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_00d6: 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) switch (ValuableGlowPlugin.Mode.Value) { case ColorMode.Rainbow: return Color.HSVToRGB((Time.time * ValuableGlowPlugin.RainbowSpeed.Value + _phase) % 1f, 0.85f, 1f); case ColorMode.Fixed: return ValuableGlowPlugin.ParseColor(ValuableGlowPlugin.FixedColor.Value, Color.cyan); default: { if (_kind == Kind.Item) { return ValuableGlowPlugin.ParseColor(ValuableGlowPlugin.ItemColor.Value, Color.blue); } if (_kind == Kind.Other) { return ValuableGlowPlugin.ParseColor(ValuableGlowPlugin.OtherColor.Value, Color.gray); } float num = ReadValue(_val); if (num >= ValuableGlowPlugin.HighThreshold.Value) { return ValuableGlowPlugin.ParseColor(ValuableGlowPlugin.HighColor.Value, Color.red); } if (num >= ValuableGlowPlugin.MidThreshold.Value) { return ValuableGlowPlugin.ParseColor(ValuableGlowPlugin.MidColor.Value, Color.yellow); } return ValuableGlowPlugin.ParseColor(ValuableGlowPlugin.LowColor.Value, Color.green); } } } private void Update() { //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) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0176: 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_0186: 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_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_0113: Unknown result type (might be due to invalid IL or missing references) GlowStyle value = ValuableGlowPlugin.Style.Value; Color val = PickColor(); float num = 1f; if (ValuableGlowPlugin.Pulse.Value) { num = 1f + Mathf.Sin(Time.time * ValuableGlowPlugin.PulseSpeed.Value + _phase) * ValuableGlowPlugin.PulseAmount.Value; } bool num2 = value != GlowStyle.LightOnly; Color val2 = (num2 ? (val * (ValuableGlowPlugin.EmissionIntensity.Value * num)) : Color.black); float value2 = ValuableGlowPlugin.TintStrength.Value; float num3 = (num2 ? Mathf.Max(value2, ValuableGlowPlugin.FallbackTint.Value) : value2); for (int i = 0; i < _mats.Count; i++) { MatInfo matInfo = _mats[i]; if (!((Object)(object)matInfo.Mat == (Object)null)) { if (matInfo.EmissionId != -1) { matInfo.Mat.SetColor(matInfo.EmissionId, val2); } if (matInfo.BaseId != -1) { float num4 = ((matInfo.EmissionId != -1) ? value2 : num3); matInfo.Mat.SetColor(matInfo.BaseId, Color.Lerp(matInfo.BaseColor, val, num4)); } } } if ((Object)(object)_light != (Object)null) { bool flag = value != GlowStyle.EmissionOnly; bool flag2 = true; Camera main = Camera.main; if ((Object)(object)main != (Object)null) { float value3 = ValuableGlowPlugin.LightMaxDistance.Value; Vector3 val3 = ((Component)main).transform.position - ((Component)this).transform.position; flag2 = ((Vector3)(ref val3)).sqrMagnitude < value3 * value3; } ((Behaviour)_light).enabled = flag && flag2; if (((Behaviour)_light).enabled) { _light.color = val; _light.range = ValuableGlowPlugin.LightRange.Value; _light.intensity = ValuableGlowPlugin.LightIntensity.Value * num; } } } private void OnDestroy() { foreach (MatInfo mat in _mats) { if ((Object)(object)mat.Mat != (Object)null) { Object.Destroy((Object)(object)mat.Mat); } } } } }