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 DisplayPrices v1.0.0
DisplayPrices.dll
Decompiled 2 months agousing System; using System.Collections.Generic; using System.Diagnostics; 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 HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.UI; [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: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("McHorse")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+d09147cafb1dc5889918b1a5a8d5395d79ca40bf")] [assembly: AssemblyProduct("DisplayPrices")] [assembly: AssemblyTitle("DisplayPrices")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 DisplayPrices { public enum DisplayMode { Always, WhenKeyPressed } [BepInPlugin("McHorse.DisplayPrices", "DisplayPrices", "1.0")] public class DisplayPrices : BaseUnityPlugin { internal static DisplayPrices Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } internal ConfigEntry<int> VicinityRangeRadius { get; private set; } = null; internal ConfigEntry<DisplayMode> VicinityDisplayMode { get; private set; } = null; internal ConfigEntry<KeyCode> VicinityHeldKey { get; private set; } = null; internal ConfigEntry<bool> VicinityVisibleThroughWalls { get; private set; } = null; internal ConfigEntry<float> LabelColorR { get; private set; } = null; internal ConfigEntry<float> LabelColorG { get; private set; } = null; internal ConfigEntry<float> LabelColorB { get; private set; } = null; private void Awake() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown Instance = this; AcceptableValueRange<float> val = new AcceptableValueRange<float>(0f, 1f); VicinityRangeRadius = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Range radius", 10, new ConfigDescription("Distance (units) within which valuable labels are shown.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); VicinityDisplayMode = ((BaseUnityPlugin)this).Config.Bind<DisplayMode>("General", "Display mode", DisplayMode.Always, "Always = labels always visible in range. WhenKeyPressed = only while Held key is held."); VicinityHeldKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "Held key", (KeyCode)98, "Key that must be held to show labels when Display mode is WhenKeyPressed."); VicinityVisibleThroughWalls = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Visible through walls", true, "If true, labels are shown for valuables even through walls. If false, only when not blocked by walls."); LabelColorR = ((BaseUnityPlugin)this).Config.Bind<float>("Label", "R", 0f, new ConfigDescription("Label color red (0-1).", (AcceptableValueBase)(object)val, Array.Empty<object>())); LabelColorG = ((BaseUnityPlugin)this).Config.Bind<float>("Label", "G", 0.5f, new ConfigDescription("Label color green (0-1).", (AcceptableValueBase)(object)val, Array.Empty<object>())); LabelColorB = ((BaseUnityPlugin)this).Config.Bind<float>("Label", "B", 1f, new ConfigDescription("Label color blue (0-1).", (AcceptableValueBase)(object)val, Array.Empty<object>())); ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; ((Component)this).gameObject.AddComponent<VicinityValueDisplayManager>(); Patch(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } internal void Patch() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } public class VicinityValueDisplayManager : MonoBehaviour { private readonly Dictionary<int, GameObject> _entriesByInstanceId = new Dictionary<int, GameObject>(); private void Update() { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_00e1: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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_0150: 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_015b: 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_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0197: 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_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: 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_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.RunIsLevel()) { Cleanup(); } else { if ((Object)(object)DisplayPrices.Instance == (Object)null || (Object)(object)PlayerController.instance == (Object)null || (Object)(object)WorldSpaceUIParent.instance == (Object)null || (Object)(object)WorldSpaceUIParent.instance.valueLostPrefab == (Object)null) { return; } if (DisplayPrices.Instance.VicinityDisplayMode.Value == DisplayMode.Always || Input.GetKey(DisplayPrices.Instance.VicinityHeldKey.Value)) { float num = DisplayPrices.Instance.VicinityRangeRadius.Value; bool flag = !DisplayPrices.Instance.VicinityVisibleThroughWalls.Value; Vector3 position = ((Component)PlayerController.instance).transform.position; Vector3 val = position; if (flag) { Camera val2 = (((Object)(object)PhysGrabber.instance != (Object)null) ? PhysGrabber.instance.playerCamera : null); if ((Object)(object)val2 == (Object)null) { val2 = Camera.main; } if ((Object)(object)val2 != (Object)null) { val = ((Component)val2).transform.position; } } LayerMask val3 = (LayerMask)(flag ? SemiFunc.LayerMaskGetVisionObstruct() : default(LayerMask)); List<PhysGrabObject> list = SemiFunc.PhysGrabObjectAllValuablesWithinRange(num, val, false, default(LayerMask)); if (flag) { RaycastHit val7 = default(RaycastHit); for (int num2 = list.Count - 1; num2 >= 0; num2--) { PhysGrabObject val4 = list[num2]; if ((Object)(object)val4 == (Object)null || !SemiFunc.OnScreen(val4.centerPoint, 0.5f, 0.5f)) { list.RemoveAt(num2); } else { Vector3 val5 = val; Vector3 val6 = val4.centerPoint - val5; float magnitude = ((Vector3)(ref val6)).magnitude; if (!(magnitude < 0.01f)) { val6 /= magnitude; if (Physics.Raycast(val5, val6, ref val7, magnitude, LayerMask.op_Implicit(val3), (QueryTriggerInteraction)1)) { PhysGrabObject componentInParent = ((Component)((RaycastHit)(ref val7)).collider).GetComponentInParent<PhysGrabObject>(); if ((Object)(object)componentInParent != (Object)(object)val4) { list.RemoveAt(num2); } } } } } } HashSet<int> hashSet = new HashSet<int>(); PhysGrabObject val8 = null; if ((Object)(object)PhysGrabber.instance != (Object)null && PhysGrabber.instance.grabbed && (Object)(object)PhysGrabber.instance.grabbedPhysGrabObject != (Object)null) { val8 = PhysGrabber.instance.grabbedPhysGrabObject; } foreach (PhysGrabObject item in list) { if ((Object)(object)item == (Object)null || ((Object)(object)val8 != (Object)null && (Object)(object)item == (Object)(object)val8)) { continue; } ValuableObject component = ((Component)item).GetComponent<ValuableObject>(); if ((Object)(object)component == (Object)null || !component.dollarValueSet) { continue; } int instanceID = ((Object)item).GetInstanceID(); hashSet.Add(instanceID); if (!_entriesByInstanceId.TryGetValue(instanceID, out GameObject value) || (Object)(object)value == (Object)null) { GameObject val9 = Object.Instantiate<GameObject>(WorldSpaceUIParent.instance.valueLostPrefab, ((Component)WorldSpaceUIParent.instance).transform.position, ((Component)WorldSpaceUIParent.instance).transform.rotation, ((Component)WorldSpaceUIParent.instance).transform); WorldSpaceUIValueLost component2 = val9.GetComponent<WorldSpaceUIValueLost>(); if ((Object)(object)component2 != (Object)null) { Object.Destroy((Object)(object)component2); } VicinityValueEntry vicinityValueEntry = val9.AddComponent<VicinityValueEntry>(); vicinityValueEntry.worldPosition = item.centerPoint; vicinityValueEntry.value = (int)component.dollarValueCurrent; _entriesByInstanceId[instanceID] = val9; } else { VicinityValueEntry component3 = value.GetComponent<VicinityValueEntry>(); if ((Object)(object)component3 != (Object)null) { component3.worldPosition = item.centerPoint; component3.value = (int)component.dollarValueCurrent; } } } List<int> list2 = new List<int>(); foreach (int key in _entriesByInstanceId.Keys) { if (!hashSet.Contains(key)) { list2.Add(key); } else if ((Object)(object)_entriesByInstanceId[key] == (Object)null) { list2.Add(key); } } { foreach (int item2 in list2) { if (_entriesByInstanceId.TryGetValue(item2, out GameObject value2) && (Object)(object)value2 != (Object)null) { VicinityValueEntry component4 = value2.GetComponent<VicinityValueEntry>(); if ((Object)(object)component4 != (Object)null) { component4.BeginScaleOut(); } } _entriesByInstanceId.Remove(item2); } return; } } Cleanup(); } } private void OnDestroy() { Cleanup(); } private void Cleanup() { foreach (GameObject value in _entriesByInstanceId.Values) { if ((Object)(object)value != (Object)null) { Object.Destroy((Object)(object)value); } } _entriesByInstanceId.Clear(); } } public class VicinityValueEntry : MonoBehaviour { private const float IntroDuration = 0.2f; private const float OutroDuration = 0.2f; internal Vector3 worldPosition; internal int value; internal Vector3 positionOffset = new Vector3(0f, -0.05f, 0f); private RectTransform? _rect; private TextMeshProUGUI? _text; private Vector3 _targetScale; private float _introT; private bool _scaleOut; private float _scaleOutT; public void BeginScaleOut() { _scaleOut = true; _scaleOutT = 0f; } private void Start() { //IL_0095: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) _rect = ((Component)this).GetComponent<RectTransform>(); _text = ((Component)this).GetComponent<TextMeshProUGUI>(); if ((Object)(object)_text != (Object)null && (Object)(object)DisplayPrices.Instance != (Object)null) { float num = Mathf.Clamp01(DisplayPrices.Instance.LabelColorR.Value); float num2 = Mathf.Clamp01(DisplayPrices.Instance.LabelColorG.Value); float num3 = Mathf.Clamp01(DisplayPrices.Instance.LabelColorB.Value); ((Graphic)_text).color = new Color(num, num2, num3); } _targetScale = ((Component)this).transform.localScale; ((Component)this).transform.localScale = Vector3.zero; _introT = 0f; } private void Update() { //IL_0073: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00a6: 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_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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: 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_0144: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_rect == (Object)null || (Object)(object)_text == (Object)null) { return; } if (_scaleOut) { _scaleOutT += Time.deltaTime / 0.2f; _scaleOutT = Mathf.Clamp01(_scaleOutT); float num = _scaleOutT * _scaleOutT; ((Component)this).transform.localScale = _targetScale * (1f - num); _rect.anchoredPosition = Vector2.op_Implicit(SemiFunc.UIWorldToCanvasPosition(worldPosition) + positionOffset); if (_scaleOutT >= 1f) { Object.Destroy((Object)(object)((Component)this).gameObject); } } else { if (_introT < 1f) { _introT += Time.deltaTime / 0.2f; _introT = Mathf.Clamp01(_introT); float num2 = 1f - (1f - _introT) * (1f - _introT); ((Component)this).transform.localScale = _targetScale * num2; } _rect.anchoredPosition = Vector2.op_Implicit(SemiFunc.UIWorldToCanvasPosition(worldPosition) + positionOffset); ((TMP_Text)_text).text = "$" + SemiFunc.DollarGetString(value); } } } }