using 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 Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.AI; using UnityEngine.Rendering; 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: AssemblyCompany("ExtractionTrail")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.3.0.0")] [assembly: AssemblyInformationalVersion("1.3.0")] [assembly: AssemblyProduct("ExtractionTrail")] [assembly: AssemblyTitle("ExtractionTrail")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ExtractionTrail { public enum TargetMode { ExtractionPoint, Truck, Cart } [BepInPlugin("com.repo.extractiontrail", "Extraction Trail", "1.5.0")] public class Plugin : BaseUnityPlugin { public static ManualLogSource Log; public static ConfigEntry ColorExtraction; public static ConfigEntry ColorTruck; public static ConfigEntry ColorCart; public static ConfigEntry DotSize; public static ConfigEntry DotSpeed; public static ConfigEntry DotCount; public static ConfigEntry ToggleKeyStr; public static ConfigEntry NavNextKeyStr; public static ConfigEntry NavPrevKeyStr; public static ConfigEntry ToastPosX; public static ConfigEntry ToastPosY; public static KeyCode ToggleKey { get; private set; } = (KeyCode)285; public static KeyCode NavNextKey { get; private set; } = (KeyCode)286; public static KeyCode NavPrevKey { get; private set; } = (KeyCode)287; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; ColorExtraction = ((BaseUnityPlugin)this).Config.Bind("1. Visuals", "ExtractionColor", "#00FFFF", "Hex color."); ColorTruck = ((BaseUnityPlugin)this).Config.Bind("1. Visuals", "TruckColor", "#00FF00", "Hex color."); ColorCart = ((BaseUnityPlugin)this).Config.Bind("1. Visuals", "CartColor", "#FFFF00", "Hex color."); DotSize = ((BaseUnityPlugin)this).Config.Bind("1. Visuals", "DotSize", 0.25f, "Size."); DotSpeed = ((BaseUnityPlugin)this).Config.Bind("1. Visuals", "DotSpeed", 4f, "Speed."); DotCount = ((BaseUnityPlugin)this).Config.Bind("1. Visuals", "DotCount", 30, "Count."); ToggleKeyStr = ((BaseUnityPlugin)this).Config.Bind("2. Controls", "Toggle Key", "F4", "Wł/Wył ścieżkę."); NavNextKeyStr = ((BaseUnityPlugin)this).Config.Bind("2. Controls", "Next Target", "F5", "Następny cel (Extraction → Truck → Cart 1 → Cart 2 → ...)."); NavPrevKeyStr = ((BaseUnityPlugin)this).Config.Bind("2. Controls", "Prev Target", "F6", "Poprzedni cel."); ToggleKeyStr.SettingChanged += delegate { ParseKeys(); }; NavNextKeyStr.SettingChanged += delegate { ParseKeys(); }; NavPrevKeyStr.SettingChanged += delegate { ParseKeys(); }; ParseKeys(); ToastPosX = ((BaseUnityPlugin)this).Config.Bind("3. UI", "ToastPosX", 25f, "X."); ToastPosY = ((BaseUnityPlugin)this).Config.Bind("3. UI", "ToastPosY", -243f, "Y."); ((Component)this).gameObject.AddComponent(); } private void ParseKeys() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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) if (Enum.TryParse(ToggleKeyStr.Value, ignoreCase: true, out KeyCode result)) { ToggleKey = result; } if (Enum.TryParse(NavNextKeyStr.Value, ignoreCase: true, out KeyCode result2)) { NavNextKey = result2; } if (Enum.TryParse(NavPrevKeyStr.Value, ignoreCase: true, out KeyCode result3)) { NavPrevKey = result3; } } } public class TrailManager : MonoBehaviour { private bool isEnabled = false; private GameObject[] dots; private Material dotMaterial; private NavMeshPath currentPath; private float pathLength; private float[] pathDistances; private float offset = 0f; private float updateTimer = 0f; private int cachedDotCount = 0; private bool isDraggingToast = false; private Text toastText; private RectTransform toastRect; private CanvasGroup toastCanvasGroup; private float toastTimer = 0f; private NavMeshAgent _pathAgent; private Vector3[] _smoothedCorners = (Vector3[])(object)new Vector3[0]; private TargetMode _currentMode = TargetMode.ExtractionPoint; private int _cartIndex = 0; private List _mainCarts = new List(); private void Start() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown currentPath = new NavMeshPath(); InitializeDots(); BuildToastUI(); InitPathAgent(); } private void InitPathAgent() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown GameObject val = new GameObject("ET_PathAgent"); Object.DontDestroyOnLoad((Object)(object)val); ((Object)val).hideFlags = (HideFlags)61; _pathAgent = val.AddComponent(); _pathAgent.radius = 0.2f; _pathAgent.height = 2f; _pathAgent.agentTypeID = 0; _pathAgent.updatePosition = false; _pathAgent.updateRotation = false; _pathAgent.obstacleAvoidanceType = (ObstacleAvoidanceType)0; _pathAgent.isStopped = true; } private void InitializeDots() { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) if (dots != null) { GameObject[] array = dots; foreach (GameObject val in array) { if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } } } int num = (cachedDotCount = Plugin.DotCount.Value); dots = (GameObject[])(object)new GameObject[num]; Shader val2 = Shader.Find("Sprites/Default") ?? Shader.Find("Standard"); dotMaterial = new Material(val2); for (int j = 0; j < num; j++) { GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)0); Object.Destroy((Object)(object)val3.GetComponent()); ((Renderer)val3.GetComponent()).material = dotMaterial; ((Renderer)val3.GetComponent()).shadowCastingMode = (ShadowCastingMode)0; val3.transform.localScale = Vector3.one * Plugin.DotSize.Value; val3.SetActive(false); val3.transform.SetParent(((Component)this).transform); dots[j] = val3; } } private void BuildToastUI() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("ExtractionTrailToastCanvas"); Object.DontDestroyOnLoad((Object)(object)val); Canvas val2 = val.AddComponent(); val2.renderMode = (RenderMode)0; val2.sortingOrder = 200; GameObject val3 = new GameObject("ToastText"); val3.transform.SetParent(val.transform, false); toastRect = val3.AddComponent(); toastCanvasGroup = val3.AddComponent(); toastCanvasGroup.alpha = 0f; toastRect.anchorMin = new Vector2(0f, 1f); toastRect.anchorMax = new Vector2(0f, 1f); toastRect.pivot = new Vector2(0f, 1f); toastRect.sizeDelta = new Vector2(400f, 80f); toastRect.anchoredPosition = new Vector2(Plugin.ToastPosX.Value, Plugin.ToastPosY.Value); toastText = val3.AddComponent(); toastText.font = Resources.GetBuiltinResource("LegacyRuntime.ttf"); toastText.fontSize = 16; toastText.fontStyle = (FontStyle)1; ((Graphic)toastText).color = Color.white; ((Shadow)val3.AddComponent()).effectColor = Color.black; } private void ShowToast() { string text = (isEnabled ? "ON" : "OFF"); string text2; if (_currentMode == TargetMode.Cart) { int count = _mainCarts.Count; text2 = ((count > 0) ? $"CART {_cartIndex + 1}/{count}" : "CART (brak)"); } else { text2 = _currentMode.ToString().ToUpper(); } toastText.text = "TRAIL: " + text + "\nTARGET: " + text2 + ""; toastTimer = 3f; } private void Update() { //IL_0177: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)toastRect != (Object)null) { if (Input.GetKey((KeyCode)308)) { if (Input.GetMouseButtonDown(0) && RectTransformUtility.RectangleContainsScreenPoint(toastRect, Vector2.op_Implicit(Input.mousePosition))) { isDraggingToast = true; } } else { isDraggingToast = false; } if (Input.GetMouseButtonUp(0) && isDraggingToast) { ((ConfigEntryBase)Plugin.ToastPosX).ConfigFile.Save(); isDraggingToast = false; } if (isDraggingToast) { Plugin.ToastPosX.Value = Input.mousePosition.x; Plugin.ToastPosY.Value = Input.mousePosition.y - (float)Screen.height; } toastRect.anchoredPosition = new Vector2(Plugin.ToastPosX.Value, Plugin.ToastPosY.Value); toastCanvasGroup.alpha = Mathf.MoveTowards(toastCanvasGroup.alpha, (toastTimer > 0f) ? 1f : 0f, Time.deltaTime * 3f); if (toastTimer > 0f) { toastTimer -= Time.deltaTime; } } if (Plugin.DotCount.Value != cachedDotCount) { InitializeDots(); } if (Input.GetKeyDown(Plugin.ToggleKey)) { isEnabled = !isEnabled; ShowToast(); if (!isEnabled) { HideDots(); } } if (Input.GetKeyDown(Plugin.NavNextKey)) { AdvanceTarget(1); updateTimer = 10f; } if (Input.GetKeyDown(Plugin.NavPrevKey)) { AdvanceTarget(-1); updateTimer = 10f; } if (!isEnabled) { return; } string value = Plugin.ColorExtraction.Value; if (_currentMode == TargetMode.Truck) { value = Plugin.ColorTruck.Value; } if (_currentMode == TargetMode.Cart) { value = Plugin.ColorCart.Value; } Color color = default(Color); if (ColorUtility.TryParseHtmlString(value, ref color)) { dotMaterial.color = color; } updateTimer += Time.deltaTime; if (updateTimer > 0.5f) { updateTimer = 0f; if (!IsLevelActive()) { currentPath.ClearCorners(); HideDots(); } else { UpdatePath(); } } AnimateDots(); } private bool IsLevelActive() { LevelGenerator @static = Access.GetStatic(typeof(LevelGenerator), "Instance"); return (Object)(object)@static != (Object)null && Access.Get(@static, "Generated") && (Object)(object)Access.GetStatic(typeof(RoundDirector), "instance") != (Object)null; } private void AdvanceTarget(int dir) { RefreshCartList(); int count = _mainCarts.Count; int num = 2 + count; int num2 = ((_currentMode != 0) ? ((_currentMode == TargetMode.Truck) ? 1 : (2 + _cartIndex)) : 0); num2 = (num2 + dir + num) % num; switch (num2) { case 0: _currentMode = TargetMode.ExtractionPoint; _cartIndex = 0; break; case 1: _currentMode = TargetMode.Truck; _cartIndex = 0; break; default: _currentMode = TargetMode.Cart; _cartIndex = num2 - 2; break; } ShowToast(); } private void RefreshCartList() { _mainCarts.Clear(); Type type = Type.GetType("PhysGrabCart, Assembly-CSharp"); if (type == null || !(Object.FindObjectsOfType(type) is MonoBehaviour[] array)) { return; } MonoBehaviour[] array2 = array; foreach (MonoBehaviour val in array2) { if (!((Object)(object)((Component)val).gameObject.GetComponent("Item") != (Object)null) && !((Object)(object)((Component)((Component)val).transform.root).GetComponentInChildren() != (Object)null)) { _mainCarts.Add(val); } } if (_cartIndex >= _mainCarts.Count) { _cartIndex = Mathf.Max(0, _mainCarts.Count - 1); } } private void UpdatePath() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0240: 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) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Expected O, but got Unknown //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: 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_01e8: Unknown result type (might be due to invalid IL or missing references) PlayerController @static = Access.GetStatic(typeof(PlayerController), "instance"); if ((Object)(object)@static == (Object)null) { return; } PlayerAvatar val = Access.Get(@static, "playerAvatarScript"); if ((Object)(object)val == (Object)null) { return; } Vector3 val2 = Access.Get(val, "LastNavmeshPosition"); if (val2 == Vector3.zero) { return; } RefreshCartList(); Vector3 pos = Vector3.zero; bool flag = false; RoundDirector static2 = Access.GetStatic(typeof(RoundDirector), "instance"); switch (_currentMode) { case TargetMode.ExtractionPoint: { if ((Object)(object)static2 != (Object)null && Access.Get(static2, "allExtractionPointsCompleted")) { flag = TryGetTruckPosition(out pos); break; } ExtractionPoint val4 = (((Object)(object)static2 != (Object)null) ? Access.Get(static2, "extractionPointCurrent") : null); if ((Object)(object)val4 != (Object)null) { pos = ((Component)val4).transform.position; flag = true; } break; } case TargetMode.Truck: flag = TryGetTruckPosition(out pos); break; case TargetMode.Cart: if (_mainCarts.Count > 0) { MonoBehaviour val3 = _mainCarts[_cartIndex]; if ((Object)(object)val3 != (Object)null) { pos = ((Component)val3).transform.position; flag = true; } } break; } if (flag) { bool flag2 = false; if ((Object)(object)_pathAgent != (Object)null) { NavMeshHit val5 = default(NavMeshHit); if ((!_pathAgent.isOnNavMesh || Vector3.Distance(((Component)_pathAgent).transform.position, val2) > 1f) && NavMesh.SamplePosition(val2, ref val5, 2f, -1)) { _pathAgent.Warp(((NavMeshHit)(ref val5)).position); } if (_pathAgent.isOnNavMesh) { flag2 = _pathAgent.CalculatePath(pos, currentPath) && currentPath.corners.Length >= 2; } } if (!flag2) { flag2 = NavMesh.CalculatePath(val2, pos, -1, currentPath) && currentPath.corners.Length >= 2; } if (flag2) { FilterPitCorners(); currentPath.corners.CopyTo(currentPath.corners, 0); if (currentPath.corners.Length >= 2) { Vector3[] array = SmoothPath(currentPath.corners); if (array.Length >= 2) { NavMeshPath val6 = new NavMeshPath(); NavMesh.CalculatePath(array[0], array[^1], -1, val6); _smoothedCorners = array; CalculatePathDistancesFromCorners(array); } else { currentPath.ClearCorners(); pathLength = 0f; } } else { currentPath.ClearCorners(); pathLength = 0f; } } else { currentPath.ClearCorners(); pathLength = 0f; } } else { currentPath.ClearCorners(); pathLength = 0f; } } private bool TryGetTruckPosition(out Vector3 pos) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) pos = Vector3.zero; LevelGenerator @static = Access.GetStatic(typeof(LevelGenerator), "Instance"); LevelPoint val = (((Object)(object)@static != (Object)null) ? Access.Get(@static, "LevelPathTruck") : null); if ((Object)(object)val != (Object)null) { pos = ((Component)val).transform.position; return true; } return false; } private void FilterPitCorners() { //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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_0037: 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_0095: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) Vector3[] corners = currentPath.corners; List list = new List(); for (int i = 0; i < corners.Length; i++) { Vector3 val = corners[i] + Vector3.up * 0.3f; if (Physics.Raycast(val, Vector3.down, 5f, LayerMask.GetMask(new string[1] { "Default" })) || i == 0) { list.Add(corners[i]); continue; } break; } NavMeshPath val2 = new NavMeshPath(); if (list.Count >= 2) { NavMesh.CalculatePath(list[0], list[list.Count - 1], -1, val2); if (val2.corners.Length >= 2) { currentPath = val2; } } } private void CalculatePathDistances() { //IL_004b: 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) pathDistances = new float[currentPath.corners.Length]; pathDistances[0] = 0f; pathLength = 0f; for (int i = 1; i < currentPath.corners.Length; i++) { pathLength += Vector3.Distance(currentPath.corners[i - 1], currentPath.corners[i]); pathDistances[i] = pathLength; } _smoothedCorners = currentPath.corners; } private void CalculatePathDistancesFromCorners(Vector3[] corners) { //IL_0037: 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) pathDistances = new float[corners.Length]; pathDistances[0] = 0f; pathLength = 0f; for (int i = 1; i < corners.Length; i++) { pathLength += Vector3.Distance(corners[i - 1], corners[i]); pathDistances[i] = pathLength; } _smoothedCorners = corners; } private static Vector3[] SmoothPath(Vector3[] corners) { //IL_0023: 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_004d: 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) if (corners == null || corners.Length <= 2) { return corners; } List list = new List { corners[0] }; int num = 0; NavMeshHit val = default(NavMeshHit); while (num < corners.Length - 1) { int num2 = num + 1; for (int num3 = corners.Length - 1; num3 > num + 1; num3--) { if (!NavMesh.Raycast(corners[num], corners[num3], ref val, -1)) { num2 = num3; break; } } list.Add(corners[num2]); num = num2; } return list.ToArray(); } private void AnimateDots() { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) Vector3[] smoothedCorners = _smoothedCorners; if (smoothedCorners == null || smoothedCorners.Length < 2 || pathLength <= 0.5f) { HideDots(); return; } offset += Time.deltaTime * Plugin.DotSpeed.Value; float num = pathLength / (float)dots.Length; for (int i = 0; i < dots.Length; i++) { float num2 = ((float)i * num + offset) % pathLength; if (num2 < 0f) { num2 += pathLength; } dots[i].transform.position = GetPositionOnPath(num2, smoothedCorners); dots[i].SetActive(true); float num3 = Plugin.DotSize.Value; if (num2 < 2f) { num3 *= num2 / 2f; } else if (num2 > pathLength - 2f) { num3 *= (pathLength - num2) / 2f; } dots[i].transform.localScale = Vector3.one * num3; } } private Vector3 GetPositionOnPath(float dist, Vector3[] pts) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0072: Unknown result type (might be due to invalid IL or missing references) for (int i = 1; i < pts.Length; i++) { if (dist <= pathDistances[i]) { float num = pathDistances[i] - pathDistances[i - 1]; return Vector3.Lerp(pts[i - 1], pts[i], (dist - pathDistances[i - 1]) / num); } } return pts[^1]; } private void HideDots() { if (dots == null) { return; } GameObject[] array = dots; foreach (GameObject val in array) { if ((Object)(object)val != (Object)null) { val.SetActive(false); } } } } public static class Access { public static T Get(object inst, string n) { FieldInfo fieldInfo = inst?.GetType().GetField(n, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); return (fieldInfo != null) ? ((T)fieldInfo.GetValue(inst)) : default(T); } public static T GetStatic(Type t, string n) { FieldInfo field = t.GetField(n, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); return (field != null) ? ((T)field.GetValue(null)) : default(T); } } }