using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("Intel")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Intel")]
[assembly: AssemblyTitle("Intel")]
[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 RecipeViewerMod
{
[BepInPlugin("com.modify.intel", "Intel", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private Rect windowrect;
private bool backpackopen;
private bool traderopen;
private bool stylesinitialized;
private bool itemsinitialized;
private GameObject backpackui;
private GameObject traderui;
private Vector2 scrollposition;
private Vector2 detailscrollposition;
private string searchtext = "";
private string lastsearchtext = "";
private readonly List<InventoryItem> items = new List<InventoryItem>();
private readonly List<InventoryItem> filtereditems = new List<InventoryItem>();
private readonly Dictionary<InventoryItem, string> cachednames = new Dictionary<InventoryItem, string>();
private readonly Dictionary<InventoryItem, string> cachedrequirements = new Dictionary<InventoryItem, string>();
private readonly Dictionary<InventoryItem, string> cachedrawvalues = new Dictionary<InventoryItem, string>();
private readonly Dictionary<InventoryItem, string> cacheddescriptions = new Dictionary<InventoryItem, string>();
private readonly Dictionary<InventoryItem, string> cachedarrayvalues = new Dictionary<InventoryItem, string>();
private InventoryItem selecteditem;
private GUIStyle windowstyle;
private GUIStyle titleStyle;
private GUIStyle searchStyle;
private GUIStyle itemButtonStyle;
private GUIStyle selectedButtonStyle;
private GUIStyle nameStyle;
private GUIStyle descriptionStyle;
private GUIStyle valueStyle;
private GUIStyle sectionStyle;
private GUIStyle iconStyle;
private float menudetecttimer;
private float activetimer;
private const float MENUCHECKRATE = 0.25f;
private const float ACTIVECHECKRATE = 0.05f;
private const float WINDOWWIDTH = 500f;
private const float RIGHTOFFSET = 20f;
private const float LEFTOFFSET = 20f;
private const float TOPOFFSET = 60f;
private const int GRIDCOLUMNS = 5;
private const float ITEMHEIGHT = 76f;
private void Start()
{
//IL_002a: 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)
windowrect = new Rect((float)Screen.width - 500f - 20f, 60f, 500f, (float)Screen.height - 120f);
((MonoBehaviour)this).Invoke("InitializeItems", 2f);
}
private void Update()
{
float unscaledDeltaTime = Time.unscaledDeltaTime;
activetimer += unscaledDeltaTime;
if (activetimer >= 0.05f)
{
activetimer = 0f;
UpdateKnownMenus();
}
menudetecttimer += unscaledDeltaTime;
if (menudetecttimer >= 0.25f)
{
menudetecttimer = 0f;
DiscoverMenus();
}
}
private void UpdateKnownMenus()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: 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)
//IL_0098: 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_0057: 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_0062: Unknown result type (might be due to invalid IL or missing references)
Scene scene;
if ((Object)(object)backpackui != (Object)null)
{
scene = backpackui.scene;
if (((Scene)(ref scene)).IsValid())
{
bool activeInHierarchy = backpackui.activeInHierarchy;
if (backpackopen && !activeInHierarchy)
{
backpackopen = false;
scrollposition = Vector2.zero;
detailscrollposition = Vector2.zero;
}
else
{
backpackopen = activeInHierarchy;
}
goto IL_007f;
}
}
backpackopen = false;
goto IL_007f;
IL_007f:
if ((Object)(object)traderui != (Object)null)
{
scene = traderui.scene;
if (((Scene)(ref scene)).IsValid())
{
traderopen = traderui.activeInHierarchy;
return;
}
}
traderopen = false;
}
private void DiscoverMenus()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: 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_004e: Unknown result type (might be due to invalid IL or missing references)
Scene scene;
if (!((Object)(object)backpackui == (Object)null))
{
scene = backpackui.scene;
if (((Scene)(ref scene)).IsValid())
{
goto IL_0035;
}
}
FindBackpackUI();
goto IL_0035;
IL_0035:
if (!((Object)(object)traderui == (Object)null))
{
scene = traderui.scene;
if (((Scene)(ref scene)).IsValid())
{
return;
}
}
FindTraderUI();
}
private void FindBackpackUI()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
try
{
GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
foreach (GameObject val in array)
{
if ((Object)(object)val == (Object)null)
{
continue;
}
Scene scene = val.scene;
if (((Scene)(ref scene)).IsValid() && !(((Object)val).name != "Backpack"))
{
string path = GetPath(val.transform);
if (path.IndexOf("InventoryNew", StringComparison.OrdinalIgnoreCase) >= 0 && path.IndexOf("CraftingLayout", StringComparison.OrdinalIgnoreCase) >= 0)
{
backpackui = val;
backpackopen = val.activeInHierarchy;
break;
}
}
}
}
catch
{
}
}
private void FindTraderUI()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
try
{
GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
foreach (GameObject val in array)
{
if (!((Object)(object)val == (Object)null))
{
Scene scene = val.scene;
if (((Scene)(ref scene)).IsValid() && val.activeInHierarchy && IsTraderObject(val))
{
traderui = val;
traderopen = true;
break;
}
}
}
}
catch
{
}
}
private bool IsTraderObject(GameObject obj)
{
string text = ((Object)obj).name.ToLowerInvariant();
switch (text)
{
default:
if (!(text == "merchant ui"))
{
string text2 = GetPath(obj.transform).ToLowerInvariant();
if (text2.Contains("/trader/") || text2.Contains("/trader ui/") || text2.Contains("/traderui/") || text2.Contains("/shop/") || text2.Contains("/shop ui/") || text2.Contains("/shopui/") || text2.Contains("/trade/") || text2.Contains("/trade ui/") || text2.Contains("/tradeui/") || text2.Contains("/merchant/") || text2.Contains("/merchant ui/") || text2.Contains("/merchantui/"))
{
return true;
}
return false;
}
goto case "trader";
case "trader":
case "traders":
case "traderui":
case "trader ui":
case "shop":
case "shopui":
case "shop ui":
case "trade":
case "tradeui":
case "trade ui":
case "merchant":
case "merchantui":
return true;
}
}
private string GetPath(Transform transform)
{
string text = ((Object)transform).name;
Transform parent = transform.parent;
while ((Object)(object)parent != (Object)null)
{
text = ((Object)parent).name + "/" + text;
parent = parent.parent;
}
return text;
}
private void InitializeItems()
{
try
{
ItemManager instance = ItemManager.Instance;
if ((Object)(object)instance == (Object)null)
{
((MonoBehaviour)this).Invoke("InitializeItems", 2f);
return;
}
FieldInfo field = typeof(ItemManager).GetField("allItems", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
if (field == null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"Intel could not find ItemManager.allItems");
return;
}
object value = field.GetValue(instance);
if (!(value is IDictionary dictionary))
{
((BaseUnityPlugin)this).Logger.LogError((object)"Intel could not read ItemManager.allItems");
return;
}
HashSet<InventoryItem> hashSet = new HashSet<InventoryItem>();
foreach (object key in dictionary.Keys)
{
object? obj = dictionary[key];
InventoryItem val = (InventoryItem)((obj is InventoryItem) ? obj : null);
if (!((Object)(object)val == (Object)null) && !hashSet.Contains(val))
{
hashSet.Add(val);
items.Add(val);
}
}
items.Sort((InventoryItem a, InventoryItem b) => string.Compare(a.name, b.name, StringComparison.OrdinalIgnoreCase));
CacheAllItemData();
RebuildFilteredItems();
if (items.Count > 0)
{
selecteditem = items[0];
}
itemsinitialized = true;
((BaseUnityPlugin)this).Logger.LogInfo((object)("Intel loaded " + items.Count + " items"));
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)("Intel initialization error: " + ex));
}
}
private void CacheAllItemData()
{
for (int i = 0; i < items.Count; i++)
{
InventoryItem val = items[i];
if (!((Object)(object)val == (Object)null))
{
cachednames[val] = val.name;
cacheddescriptions[val] = val.description;
cachedrequirements[val] = GetRequirements(val.requirements);
cachedrawvalues[val] = BuildRawValues(val);
}
}
}
private void RebuildFilteredItems()
{
filtereditems.Clear();
if (string.IsNullOrWhiteSpace(searchtext))
{
filtereditems.AddRange(items);
return;
}
string value = searchtext.Trim().ToLowerInvariant();
for (int i = 0; i < items.Count; i++)
{
InventoryItem val = items[i];
if (!((Object)(object)val == (Object)null) && cachednames.TryGetValue(val, out var value2) && value2 != null && value2.ToLowerInvariant().Contains(value))
{
filtereditems.Add(val);
}
}
}
private void CreateStyles()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Expected O, but got Unknown
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Expected O, but got Unknown
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Expected O, but got Unknown
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Expected O, but got Unknown
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Expected O, but got Unknown
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Expected O, but got Unknown
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Expected O, but got Unknown
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Expected O, but got Unknown
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Expected O, but got Unknown
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Expected O, but got Unknown
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Expected O, but got Unknown
if (!stylesinitialized)
{
windowstyle = new GUIStyle(GUI.skin.window);
windowstyle.padding = new RectOffset(12, 12, 12, 12);
titleStyle = new GUIStyle(GUI.skin.label);
titleStyle.fontSize = 21;
titleStyle.fontStyle = (FontStyle)1;
searchStyle = new GUIStyle(GUI.skin.textField);
searchStyle.fontSize = 15;
searchStyle.padding = new RectOffset(10, 10, 7, 7);
itemButtonStyle = new GUIStyle(GUI.skin.button);
itemButtonStyle.fontSize = 10;
itemButtonStyle.alignment = (TextAnchor)7;
itemButtonStyle.padding = new RectOffset(3, 3, 3, 3);
selectedButtonStyle = new GUIStyle(itemButtonStyle);
selectedButtonStyle.fontStyle = (FontStyle)1;
nameStyle = new GUIStyle(GUI.skin.label);
nameStyle.fontSize = 18;
nameStyle.fontStyle = (FontStyle)1;
descriptionStyle = new GUIStyle(GUI.skin.label);
descriptionStyle.fontSize = 12;
descriptionStyle.wordWrap = true;
valueStyle = new GUIStyle(GUI.skin.label);
valueStyle.fontSize = 11;
valueStyle.wordWrap = true;
sectionStyle = new GUIStyle(GUI.skin.label);
sectionStyle.fontSize = 13;
sectionStyle.fontStyle = (FontStyle)1;
iconStyle = new GUIStyle(GUI.skin.label);
iconStyle.alignment = (TextAnchor)4;
stylesinitialized = true;
}
}
private void OnGUI()
{
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Expected O, but got Unknown
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
if (backpackopen && itemsinitialized)
{
if (!stylesinitialized)
{
CreateStyles();
}
if (searchtext != lastsearchtext)
{
lastsearchtext = searchtext;
RebuildFilteredItems();
scrollposition = Vector2.zero;
}
float num = Mathf.Clamp((float)Screen.height - 120f, 500f, 900f);
float num2 = ((!traderopen) ? ((float)Screen.width - 500f - 20f) : 20f);
windowrect = new Rect(num2, 60f, 500f, num);
windowrect = GUI.Window(92841, windowrect, new WindowFunction(DrawWindow), "Intel", windowstyle);
}
}
private void DrawWindow(int id)
{
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: 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_00df: Unknown result type (might be due to invalid IL or missing references)
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
GUILayout.Label("Intel", titleStyle, Array.Empty<GUILayoutOption>());
GUILayout.Space(4f);
searchtext = GUILayout.TextField(searchtext, searchStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) });
GUILayout.Space(6f);
float num = Mathf.Clamp(((Rect)(ref windowrect)).height * 0.43f, 190f, 360f);
scrollposition = GUILayout.BeginScrollView(scrollposition, false, true, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num) });
DrawItemGrid(num);
GUILayout.EndScrollView();
GUILayout.Space(6f);
DrawSelectedItem();
GUILayout.EndVertical();
GUI.DragWindow(new Rect(0f, 0f, 500f, 30f));
}
private void DrawItemGrid(float viewportheight)
{
float num = ((Rect)(ref windowrect)).width - 25f;
float width = num / 5f;
int num2 = Mathf.CeilToInt((float)filtereditems.Count / 5f);
float y = scrollposition.y;
float num3 = scrollposition.y + viewportheight;
for (int i = 0; i < num2; i++)
{
float num4 = (float)i * 76f;
float num5 = num4 + 76f;
bool drawicon = num5 > y && num4 < num3;
GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(76f) });
for (int j = 0; j < 5; j++)
{
int num6 = i * 5 + j;
if (num6 >= filtereditems.Count)
{
GUILayout.FlexibleSpace();
}
else
{
DrawItemButton(filtereditems[num6], width, drawicon);
}
}
GUILayout.EndHorizontal();
}
}
private void DrawItemButton(InventoryItem item, float width, bool drawicon)
{
//IL_002a: 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_0030: 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_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
GUIStyle val = (((Object)(object)item == (Object)(object)selecteditem) ? selectedButtonStyle : itemButtonStyle);
Rect rect = GUILayoutUtility.GetRect(width - 4f, 76f);
if (GUI.Button(rect, GUIContent.none, val) && (Object)(object)selecteditem != (Object)(object)item)
{
selecteditem = item;
detailscrollposition = Vector2.zero;
}
if (drawicon)
{
Rect rect2 = default(Rect);
((Rect)(ref rect2))..ctor(((Rect)(ref rect)).x + 5f, ((Rect)(ref rect)).y + 3f, ((Rect)(ref rect)).width - 10f, 50f);
DrawSprite(item.sprite, rect2);
}
if (!cachednames.TryGetValue(item, out var value))
{
value = item.name;
}
GUI.Label(new Rect(((Rect)(ref rect)).x + 3f, ((Rect)(ref rect)).y + 55f, ((Rect)(ref rect)).width - 6f, 18f), value, val);
}
private void DrawSelectedItem()
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)selecteditem == (Object)null))
{
GUILayout.BeginVertical(GUI.skin.box, Array.Empty<GUILayoutOption>());
GUILayout.Label(selecteditem.name, nameStyle, Array.Empty<GUILayoutOption>());
float num = Mathf.Max(150f, ((Rect)(ref windowrect)).height * 0.38f);
detailscrollposition = GUILayout.BeginScrollView(detailscrollposition, false, true, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num) });
DrawItemDetails(selecteditem);
GUILayout.EndScrollView();
GUILayout.EndVertical();
}
}
private void DrawItemDetails(InventoryItem item)
{
//IL_0036: 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)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_0372: Unknown result type (might be due to invalid IL or missing references)
//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
//IL_0499: Unknown result type (might be due to invalid IL or missing references)
//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
Rect rect = GUILayoutUtility.GetRect(80f, 80f, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width(80f),
GUILayout.Height(80f)
});
DrawSprite(item.sprite, rect);
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
DrawValue("ID", item.id);
DrawValue("Name", item.name);
DrawValue("Type", item.type);
DrawValue("Tier", item.tier);
DrawValue("Rarity", item.rarity);
DrawValue("Tag", item.tag);
GUILayout.EndVertical();
GUILayout.EndHorizontal();
GUILayout.Space(6f);
if (cacheddescriptions.TryGetValue(item, out var value) && !string.IsNullOrEmpty(value))
{
DrawSection("Description");
GUILayout.Label(value, descriptionStyle, Array.Empty<GUILayoutOption>());
GUILayout.Space(6f);
}
DrawSection("Inventory");
DrawValue("Stackable", item.stackable);
DrawValue("Amount", item.amount);
DrawValue("Max", item.max);
DrawSection("Combat");
DrawValue("Attack Damage", item.attackDamage);
DrawValue("Attack Speed", item.attackSpeed);
DrawValue("Attack Range", item.attackRange);
DrawValue("Sharpness", item.sharpness);
DrawValue("Resource Damage", item.resourceDamage);
DrawValue("Swing FX", item.swingFx);
DrawValue("Attack Types", ArrayToString(item.attackTypes));
DrawSection("Survival");
DrawValue("Heal", item.heal);
DrawValue("Hunger", item.hunger);
DrawValue("Stamina", item.stamina);
DrawValue("Armor", item.armor);
DrawSection("Crafting");
DrawValue("Craftable", item.craftable);
DrawValue("Craft Amount", item.craftAmount);
DrawValue("Unlock With First Requirement Only", item.unlockWithFirstRequirementOnly);
DrawValue("Station Requirement", GetItemName(item.stationRequirement));
if (cachedrequirements.TryGetValue(item, out var value2))
{
DrawValue("Requirements", value2);
}
DrawSection("Building");
DrawValue("Buildable", item.buildable);
DrawValue("Grid", item.grid);
DrawValue("Build Rotation", item.buildRotation);
DrawSection("Processing");
DrawValue("Processable", item.processable);
DrawValue("Process Type", item.processType);
DrawValue("Processed Item", GetItemName(item.processedItem));
DrawValue("Process Time", item.processTime);
DrawSection("Fuel");
DrawValue("Fuel", GetObjectName((Object)(object)item.fuel));
DrawSection("Visual");
DrawValue("Sprite", GetObjectName((Object)(object)item.sprite));
DrawValue("Material", GetObjectName((Object)(object)item.material));
DrawValue("Mesh", GetObjectName((Object)(object)item.mesh));
DrawValue("Prefab", GetObjectName((Object)(object)item.prefab));
DrawValue("Scale", item.scale);
DrawValue("Rotation Offset", item.rotationOffset);
DrawValue("Position Offset", item.positionOffset);
DrawSection("Components");
DrawValue("Bow Component", GetObjectName((Object)(object)item.bowComponent));
DrawValue("Armor Component", GetObjectName((Object)(object)item.armorComponent));
DrawSection("Raw Values");
if (cachedrawvalues.TryGetValue(item, out var value3))
{
GUILayout.Label(value3, valueStyle, Array.Empty<GUILayoutOption>());
}
}
private void DrawSection(string text)
{
GUILayout.Label(text, sectionStyle, Array.Empty<GUILayoutOption>());
}
private void DrawValue(string name, object value)
{
GUILayout.Label(name + ": " + ValueToString(value), valueStyle, Array.Empty<GUILayoutOption>());
}
private string BuildRawValues(InventoryItem item)
{
try
{
FieldInfo[] fields = typeof(InventoryItem).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
List<string> list = new List<string>(fields.Length);
foreach (FieldInfo fieldInfo in fields)
{
try
{
object value = fieldInfo.GetValue(item);
list.Add(fieldInfo.Name + ": " + ValueToString(value));
}
catch
{
}
}
return string.Join("\n", list.ToArray());
}
catch
{
return "Unable to read fields.";
}
}
private string GetRequirements(Array requirements)
{
if (requirements == null)
{
return "None";
}
if (requirements.Length == 0)
{
return "None";
}
List<string> list = new List<string>(requirements.Length);
foreach (object requirement in requirements)
{
if (requirement == null)
{
list.Add("null");
continue;
}
Type type = requirement.GetType();
FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
List<string> list2 = new List<string>(fields.Length);
foreach (FieldInfo fieldInfo in fields)
{
try
{
object value = fieldInfo.GetValue(requirement);
list2.Add(fieldInfo.Name + "=" + ValueToString(value));
}
catch
{
}
}
if (list2.Count > 0)
{
list.Add(string.Join(", ", list2.ToArray()));
}
else
{
list.Add(requirement.ToString());
}
}
return string.Join(" | ", list.ToArray());
}
private string ValueToString(object value)
{
if (value == null)
{
return "null";
}
if (value is Array array)
{
return ArrayToString(array);
}
Object val = (Object)((value is Object) ? value : null);
if (val != (Object)null)
{
return val.name;
}
return value.ToString();
}
private string GetItemName(InventoryItem item)
{
if ((Object)(object)item == (Object)null)
{
return "None";
}
return item.name;
}
private string GetObjectName(Object obj)
{
if (obj == (Object)null)
{
return "None";
}
return obj.name;
}
private string ArrayToString(Array array)
{
if (array == null)
{
return "None";
}
if (array.Length == 0)
{
return "None";
}
List<string> list = new List<string>(array.Length);
foreach (object item in array)
{
if (item == null)
{
list.Add("null");
continue;
}
Object val = (Object)((item is Object) ? item : null);
if (val != (Object)null)
{
list.Add(val.name);
}
else
{
list.Add(item.ToString());
}
}
return string.Join(", ", list.ToArray());
}
private void DrawSprite(Sprite sprite, Rect rect)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: 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_0090: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)sprite == (Object)null))
{
Texture2D texture = sprite.texture;
if (!((Object)(object)texture == (Object)null))
{
Rect textureRect = sprite.textureRect;
Rect val = default(Rect);
((Rect)(ref val))..ctor(((Rect)(ref textureRect)).x / (float)((Texture)texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)texture).height, ((Rect)(ref textureRect)).width / (float)((Texture)texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)texture).height);
((Rect)(ref val)).y = 1f - ((Rect)(ref val)).y - ((Rect)(ref val)).height;
GUI.DrawTextureWithTexCoords(rect, (Texture)(object)texture, val, true);
}
}
}
}
}