using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
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(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("BetterBagInventory")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1")]
[assembly: AssemblyProduct("BetterBagInventory")]
[assembly: AssemblyTitle("BetterBagInventory")]
[assembly: AssemblyVersion("1.1.1.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 BetterBagInventory
{
internal static class BagLayout
{
internal sealed class Entry
{
internal int Order;
internal float Weight;
internal double Area;
internal Rect Bounds;
}
internal static void Arrange(List<Entry> entries, List<Rect> gaps, float width, float height, float capacity)
{
//IL_003e: 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_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_03e4: 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_033d: Unknown result type (might be due to invalid IL or missing references)
//IL_0327: Unknown result type (might be due to invalid IL or missing references)
//IL_0342: Unknown result type (might be due to invalid IL or missing references)
gaps.Clear();
if (entries.Count == 0)
{
if (width > 0f && height > 0f)
{
gaps.Add(new Rect(0f, 0f, width, height));
}
return;
}
entries.Sort(delegate(Entry a, Entry b)
{
int num29 = b.Weight.CompareTo(a.Weight);
return (num29 != 0) ? num29 : a.Order.CompareTo(b.Order);
});
int num = 0;
double num2 = 0.0;
while (num < entries.Count && entries[num].Weight > 0f)
{
num2 += (double)entries[num++].Weight;
}
int num3 = entries.Count - num;
if (num3 > 0)
{
int num4 = Math.Min(num3, Math.Max(1, (int)(width / 28f)));
int num5 = (num3 - 1) / num4 + 1;
float num6 = Math.Min(height * 0.2f, 28 * num5);
height -= num6;
for (int num7 = 0; num7 < num3; num7++)
{
entries[num + num7].Bounds = new Rect((float)(num7 % num4) * width / (float)num4, height + (float)(num7 / num4) * num6 / (float)num5, width / (float)num4, num6 / (float)num5);
}
}
if (num == 0)
{
if (width > 0f && height > 0f)
{
gaps.Add(new Rect(0f, 0f, width, height));
}
return;
}
double num8 = (double)width * (double)height / Math.Max(num2, capacity);
double num9 = num2 * num8;
double num10 = Math.Min(width, Math.Max(num9 / (double)height, Math.Sqrt(num9)));
double num11 = num9 / num10;
double num12 = num10;
double num13 = num11;
for (int num14 = 0; num14 < num; num14++)
{
entries[num14].Area = (double)entries[num14].Weight * num8;
}
if (num <= 128 && PackSquares(entries, num, gaps, width, height))
{
return;
}
double num15 = 0.0;
double num16 = 0.0;
int num17 = 0;
while (num17 < num)
{
bool flag = num10 <= num11;
double num18 = (flag ? num10 : num11);
int num19 = num17 + 1;
double area = entries[num17].Area;
double num20 = area;
double num21 = Aspect(num18, area, area, num20);
for (; num19 < num; num19++)
{
double area2 = entries[num19].Area;
double num22 = Aspect(num18, area, area2, num20 + area2);
if (num22 > num21)
{
break;
}
num20 += area2;
num21 = num22;
}
double num23 = num20 / num18;
double num24 = 0.0;
for (int num25 = num17; num25 < num19; num25++)
{
double num26 = entries[num25].Area / num23;
entries[num25].Bounds = (flag ? new Rect((float)(num15 + num24), (float)num16, (float)num26, (float)num23) : new Rect((float)num15, (float)(num16 + num24), (float)num23, (float)num26));
num24 += num26;
}
if (flag)
{
num16 += num23;
num11 -= num23;
}
else
{
num15 += num23;
num10 -= num23;
}
num17 = num19;
}
gaps.Clear();
float num27 = Mathf.Clamp((float)num12, 0f, width);
float num28 = Mathf.Clamp((float)num13, 0f, height);
if (width - num27 > 0.0001f)
{
gaps.Add(new Rect(num27, 0f, width - num27, height));
}
if (height - num28 > 0.0001f)
{
gaps.Add(new Rect(0f, num28, num27, height - num28));
}
}
private static bool PackSquares(List<Entry> entries, int count, List<Rect> gaps, float width, float height)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//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_005e: 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_0143: 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_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: 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_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: 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)
//IL_0095: 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)
gaps.Clear();
gaps.Add(new Rect(0f, 0f, width, height));
Rect candidate = default(Rect);
Rect val3 = default(Rect);
for (int i = 0; i < count; i++)
{
float num = (float)Math.Sqrt(entries[i].Area);
int num2 = -1;
Rect val2;
for (int j = 0; j < gaps.Count; j++)
{
Rect val = gaps[j];
if (num2 >= 0)
{
float y = ((Rect)(ref val)).y;
val2 = gaps[num2];
if (y > ((Rect)(ref val2)).y)
{
continue;
}
float y2 = ((Rect)(ref val)).y;
val2 = gaps[num2];
if (y2 == ((Rect)(ref val2)).y)
{
float x = ((Rect)(ref val)).x;
val2 = gaps[num2];
if (x >= ((Rect)(ref val2)).x)
{
continue;
}
}
}
((Rect)(ref candidate))..ctor(((Rect)(ref val)).x, ((Rect)(ref val)).y, num, num);
if (!(((Rect)(ref candidate)).xMax > width) && !(((Rect)(ref candidate)).yMax > height) && ((!(num > ((Rect)(ref val)).width) && !(num > ((Rect)(ref val)).height)) || !OverlapsPlaced(candidate, entries, i)))
{
num2 = j;
}
}
if (num2 < 0)
{
return false;
}
val2 = gaps[num2];
float x2 = ((Rect)(ref val2)).x;
val2 = gaps[num2];
((Rect)(ref val3))..ctor(x2, ((Rect)(ref val2)).y, num, num);
entries[i].Bounds = val3;
SubtractTile(gaps, val3);
}
return true;
}
private static bool OverlapsPlaced(Rect candidate, List<Entry> entries, int placedCount)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < placedCount; i++)
{
if (((Rect)(ref candidate)).Overlaps(entries[i].Bounds))
{
return true;
}
}
return false;
}
private static void SubtractTile(List<Rect> gaps, Rect tile)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: 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_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
for (int num = gaps.Count - 1; num >= 0; num--)
{
Rect val = gaps[num];
if (((Rect)(ref val)).Overlaps(tile))
{
gaps.RemoveAt(num);
float num2 = Mathf.Max(((Rect)(ref val)).yMin, ((Rect)(ref tile)).yMin);
float num3 = Mathf.Min(((Rect)(ref val)).yMax, ((Rect)(ref tile)).yMax);
if (((Rect)(ref val)).yMin < num2)
{
gaps.Add(Rect.MinMaxRect(((Rect)(ref val)).xMin, ((Rect)(ref val)).yMin, ((Rect)(ref val)).xMax, num2));
}
if (num3 < ((Rect)(ref val)).yMax)
{
gaps.Add(Rect.MinMaxRect(((Rect)(ref val)).xMin, num3, ((Rect)(ref val)).xMax, ((Rect)(ref val)).yMax));
}
if (((Rect)(ref val)).xMin < ((Rect)(ref tile)).xMin)
{
gaps.Add(Rect.MinMaxRect(((Rect)(ref val)).xMin, num2, ((Rect)(ref tile)).xMin, num3));
}
if (((Rect)(ref tile)).xMax < ((Rect)(ref val)).xMax)
{
gaps.Add(Rect.MinMaxRect(((Rect)(ref tile)).xMax, num2, ((Rect)(ref val)).xMax, num3));
}
}
}
}
private static double Aspect(double side, double largest, double smallest, double sum)
{
double num = side / sum;
return Math.Max(largest * num * num, 1.0 / (smallest * num * num));
}
}
internal sealed class BagTile : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
{
private static readonly Color32[] TileColors = (Color32[])(object)new Color32[6]
{
new Color32((byte)48, (byte)67, (byte)70, byte.MaxValue),
new Color32((byte)75, (byte)62, (byte)50, byte.MaxValue),
new Color32((byte)62, (byte)66, (byte)81, byte.MaxValue),
new Color32((byte)64, (byte)71, (byte)52, byte.MaxValue),
new Color32((byte)78, (byte)56, (byte)61, byte.MaxValue),
new Color32((byte)50, (byte)66, (byte)81, byte.MaxValue)
};
internal readonly BagLayout.Entry Entry = new BagLayout.Entry();
private InvButton button;
private RectTransform root;
private Image background;
private TextMeshProUGUI weightText;
private Color baseColor;
private Vector2 iconArea;
private float displayedWeight = -1f;
internal bool BelongsTo(Container bag)
{
return Object.op_Implicit((Object)(object)button.refItem) && (Object)(object)((Component)button.refItem).transform.parent == (Object)(object)((Component)bag).transform;
}
internal void Bind(InvButton nativeButton, TMP_Text header, int order)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: 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)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: 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_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
//IL_028e: Unknown result type (might be due to invalid IL or missing references)
//IL_029a: Unknown result type (might be due to invalid IL or missing references)
//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0307: Unknown result type (might be due to invalid IL or missing references)
//IL_0315: 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)
button = nativeButton;
root = (RectTransform)((Component)this).transform;
Entry.Order = order;
uint num = 0u;
string text = button.refItem.id ?? "";
foreach (char c in text)
{
num = num * 31 + c;
}
baseColor = Color32.op_Implicit(TileColors[num % (uint)TileColors.Length]);
if (Object.op_Implicit((Object)(object)background))
{
((Graphic)background).color = baseColor;
return;
}
RectTransform obj = root;
RectTransform obj2 = root;
Vector2 val = default(Vector2);
((Vector2)(ref val))..ctor(0f, 1f);
obj2.anchorMax = val;
obj.anchorMin = val;
root.pivot = new Vector2(0.5f, 0.5f);
background = new GameObject("Tile surface", new Type[1] { typeof(Image) }).GetComponent<Image>();
((Component)background).transform.SetParent((Transform)(object)root, false);
((Component)background).transform.SetAsFirstSibling();
((Graphic)background).raycastTarget = false;
((Graphic)background).color = baseColor;
((Graphic)background).rectTransform.anchorMin = Vector2.zero;
((Graphic)background).rectTransform.anchorMax = Vector2.one;
weightText = new GameObject("Weight", new Type[1] { typeof(TextMeshProUGUI) }).GetComponent<TextMeshProUGUI>();
((TMP_Text)weightText).transform.SetParent((Transform)(object)root, false);
((TMP_Text)weightText).font = header.font;
((TMP_Text)weightText).fontSharedMaterial = header.fontSharedMaterial;
((TMP_Text)weightText).fontSize = 14f;
((TMP_Text)weightText).alignment = (TextAlignmentOptions)1028;
((Graphic)weightText).color = Color32.op_Implicit(new Color32((byte)237, (byte)240, (byte)232, byte.MaxValue));
((TMP_Text)weightText).enableWordWrapping = false;
((TMP_Text)weightText).overflowMode = (TextOverflowModes)3;
((Graphic)weightText).raycastTarget = false;
RectTransform rectTransform = ((TMP_Text)weightText).rectTransform;
rectTransform.anchorMin = Vector2.zero;
rectTransform.anchorMax = new Vector2(1f, 0f);
rectTransform.pivot = Vector2.zero;
rectTransform.offsetMin = new Vector2(4f, 4f);
rectTransform.offsetMax = new Vector2(-5f, 23f);
Image itemCond = button.itemCond;
itemCond.fillMethod = (FillMethod)0;
itemCond.fillOrigin = 0;
val = (((Graphic)itemCond).rectTransform.anchorMin = (((Graphic)itemCond).rectTransform.anchorMax = Vector2.zero));
((Graphic)itemCond).rectTransform.pivot = Vector2.zero;
}
internal bool RefreshWeight()
{
if (!Object.op_Implicit((Object)(object)button.refItem))
{
return false;
}
float num = button.refItem.totalWeight;
if (float.IsNaN(num) || float.IsInfinity(num) || num < 0f)
{
num = 0f;
}
float num2 = Mathf.Round(num * 100f) / 100f;
if (displayedWeight != num2)
{
displayedWeight = num2;
((TMP_Text)weightText).text = num2.ToString("0.##", CultureInfo.CurrentCulture) + "u";
}
bool result = Entry.Weight != num;
Entry.Weight = num;
return result;
}
internal void ApplyBounds()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: 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_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: 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_018e: 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)
Rect bounds = Entry.Bounds;
AlignToBounds();
float num = Mathf.Min(((Rect)(ref bounds)).width, ((Rect)(ref bounds)).height);
float num2 = Mathf.Min(1.5f, num * 0.05f);
((Graphic)background).rectTransform.offsetMin = new Vector2(num2, num2);
((Graphic)background).rectTransform.offsetMax = new Vector2(0f - num2, 0f - num2);
bool flag = ((Rect)(ref bounds)).width >= 38f && ((Rect)(ref bounds)).height >= 36f;
((Behaviour)weightText).enabled = flag;
((TMP_Text)weightText).fontSize = ((num < 54f) ? 11 : 14);
float num3 = (flag ? (((TMP_Text)weightText).fontSize + 5f) : 0f);
float num4 = Mathf.Min(9f, num * 0.11f);
iconArea = new Vector2(((Rect)(ref bounds)).width - 2f * num4, ((Rect)(ref bounds)).height - 2f * num4 - num3) * 0.88f;
Vector2 anchoredPosition = default(Vector2);
((Vector2)(ref anchoredPosition))..ctor(0f, num3 / 2f);
((Graphic)button.itemImg).rectTransform.anchoredPosition = anchoredPosition;
((Graphic)button.waterFill).rectTransform.anchoredPosition = anchoredPosition;
RectTransform rectTransform = ((Graphic)button.itemCond).rectTransform;
float num5 = Mathf.Min(5f, num * 0.1f);
rectTransform.anchoredPosition = new Vector2(num5, num5);
rectTransform.sizeDelta = new Vector2(Mathf.Min(27f, ((Rect)(ref bounds)).width * 0.24f), Mathf.Min(3f, ((Rect)(ref bounds)).height * 0.05f));
}
internal void AlignToBounds()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: 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)
//IL_0045: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
Rect bounds = Entry.Bounds;
Vector2 val = default(Vector2);
((Vector2)(ref val))..ctor(2f + ((Rect)(ref bounds)).center.x, -2f - ((Rect)(ref bounds)).center.y);
if (root.sizeDelta != ((Rect)(ref bounds)).size)
{
root.sizeDelta = ((Rect)(ref bounds)).size;
}
if (root.anchoredPosition != val)
{
root.anchoredPosition = val;
}
}
private void LateUpdate()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: 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_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: 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_00d0: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: 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_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: 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)
if (((Transform)root).localScale != Vector3.one)
{
((Transform)root).localScale = Vector3.one;
}
Image itemImg = button.itemImg;
if (!Object.op_Implicit((Object)(object)itemImg.sprite))
{
return;
}
Rect rect = itemImg.sprite.rect;
Vector2 size = ((Rect)(ref rect)).size;
if (!(size.x <= 0f) && !(size.y <= 0f))
{
Image waterFill = button.waterFill;
bool flag = ((Behaviour)waterFill).enabled && Object.op_Implicit((Object)(object)waterFill.sprite);
Vector2 val;
if (!flag)
{
val = size;
}
else
{
rect = waterFill.sprite.rect;
val = Vector2.Max(size, ((Rect)(ref rect)).size);
}
Vector2 val2 = val;
float num = Mathf.Min(iconArea.x / val2.x, iconArea.y / val2.y);
ScaleGraphic(itemImg, size * num);
if (flag)
{
rect = waterFill.sprite.rect;
ScaleGraphic(waterFill, ((Rect)(ref rect)).size * num);
}
}
}
private static void ScaleGraphic(Image image, Vector2 size)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: 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_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: 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)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: 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)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
RectTransform rectTransform = ((Graphic)image).rectTransform;
Rect rect = rectTransform.rect;
Vector2 size2 = ((Rect)(ref rect)).size;
if (!(size2.x <= 0f) && !(size2.y <= 0f))
{
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(size.x / size2.x, size.y / size2.y, 1f);
if (((Transform)rectTransform).localScale != val)
{
((Transform)rectTransform).localScale = val;
}
}
}
public void OnPointerEnter(PointerEventData data)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
((Graphic)background).color = Color.Lerp(baseColor, Color.white, 0.16f);
}
public void OnPointerExit(PointerEventData data)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
((Graphic)background).color = baseColor;
}
}
internal sealed class BagView : MonoBehaviour
{
private readonly List<BagTile> tiles = new List<BagTile>();
private readonly List<BagLayout.Entry> entries = new List<BagLayout.Entry>();
private readonly List<Rect> gaps = new List<Rect>();
private PlayerCamera owner;
private RectTransform surface;
private RectTransform menu;
private RectTransform backdrop;
private RectTransform header;
private Canvas canvas;
private TextMeshProUGUI bagName;
private Vector2 originalMenuSize;
private Vector2 originalSurfaceSize;
private Vector2 originalHeaderSize;
private Vector2 lastSize;
private float appliedWidth;
private float lastCapacity;
private float nextRefreshTime;
private void OnEnable()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
Canvas.preWillRenderCanvases += new WillRenderCanvases(AlignTiles);
}
private void OnDisable()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
Canvas.preWillRenderCanvases -= new WillRenderCanvases(AlignTiles);
}
private void AlignTiles()
{
//IL_0040: 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_0068: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)owner) || !Object.op_Implicit((Object)(object)owner.currentContainer))
{
return;
}
if (Object.op_Implicit((Object)(object)backdrop) && surface.anchoredPosition != backdrop.anchoredPosition)
{
surface.anchoredPosition = backdrop.anchoredPosition;
}
foreach (BagTile tile in tiles)
{
if (Object.op_Implicit((Object)(object)tile))
{
tile.AlignToBounds();
}
}
}
internal void Bind(PlayerCamera camera)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Expected O, but got Unknown
//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_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: 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)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)owner))
{
owner = camera;
surface = (RectTransform)((Component)this).transform;
menu = (RectTransform)camera.containerMenu.transform;
ref RectTransform reference = ref header;
Transform parent = ((TMP_Text)camera.containerText).transform.parent;
reference = (RectTransform)(object)((parent is RectTransform) ? parent : null);
foreach (RectTransform item in (Transform)menu)
{
RectTransform val = item;
if (((Component)val).CompareTag("ContainerBack") && (Object)(object)val != (Object)(object)surface && (Object)(object)val != (Object)(object)header)
{
backdrop = val;
}
}
Rect rect = menu.rect;
originalMenuSize = ((Rect)(ref rect)).size;
rect = surface.rect;
originalSurfaceSize = ((Rect)(ref rect)).size;
rect = header.rect;
originalHeaderSize = ((Rect)(ref rect)).size;
canvas = ((Component)surface).GetComponentInParent<Canvas>().rootCanvas;
if (Object.op_Implicit((Object)(object)backdrop))
{
SetUpHeader(camera);
}
}
Item val2 = default(Item);
if (Object.op_Implicit((Object)(object)bagName) && ((Component)camera.currentContainer).TryGetComponent<Item>(ref val2))
{
((TMP_Text)bagName).text = (string.IsNullOrEmpty(val2.label) ? val2.Stats.fullName : val2.label);
}
tiles.Clear();
entries.Clear();
BagTile bagTile = default(BagTile);
foreach (GameObject containerUnloadButton in camera.containerUnloadButtons)
{
InvButton component = containerUnloadButton.GetComponent<InvButton>();
if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.refItem))
{
if (!containerUnloadButton.TryGetComponent<BagTile>(ref bagTile))
{
bagTile = containerUnloadButton.AddComponent<BagTile>();
}
bagTile.Bind(component, (TMP_Text)(object)camera.containerText, tiles.Count);
tiles.Add(bagTile);
entries.Add(bagTile.Entry);
}
}
Refresh(force: true);
}
private void LateUpdate()
{
if (Object.op_Implicit((Object)(object)owner) && Object.op_Implicit((Object)(object)owner.currentContainer) && !(Time.unscaledTime < nextRefreshTime))
{
Refresh(force: false);
}
}
private void Refresh(bool force)
{
//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)
//IL_0027: 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_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: 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)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: 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_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: 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)
nextRefreshTime = Time.unscaledTime + 0.12f;
FitPanel();
Rect rect = surface.rect;
Vector2 val = ((Rect)(ref rect)).size - new Vector2(4f, 4f);
if (val.x <= 0f || val.y <= 0f)
{
return;
}
float num = owner.currentContainer.maxWeight;
if (float.IsNaN(num) || float.IsInfinity(num))
{
num = 0f;
}
bool flag = force || val != lastSize || num != lastCapacity;
foreach (BagTile tile in tiles)
{
if (!force && (!Object.op_Implicit((Object)(object)tile) || !tile.BelongsTo(owner.currentContainer)))
{
owner.RepopulateContainer();
return;
}
if (Object.op_Implicit((Object)(object)tile) && tile.RefreshWeight())
{
flag = true;
}
}
if (!flag)
{
return;
}
lastSize = val;
lastCapacity = num;
BagLayout.Arrange(entries, gaps, val.x, val.y, num);
foreach (BagTile tile2 in tiles)
{
if (Object.op_Implicit((Object)(object)tile2))
{
tile2.ApplyBounds();
}
}
}
private void FitPanel()
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Expected O, but got Unknown
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: 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)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: 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_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)backdrop) || !Object.op_Implicit((Object)(object)canvas) || originalMenuSize.x <= 0f)
{
return;
}
RectTransform radialMenu = owner.radialMenu;
Transform parent = ((Transform)radialMenu).parent;
RectTransform val = (RectTransform)((Component)canvas).transform;
Rect rect = val.rect;
Vector3 val2 = parent.InverseTransformPoint(((Transform)val).TransformPoint(new Vector3(((Rect)(ref rect)).xMax, 0f)));
float num = ((Transform)radialMenu).localPosition.x + ((Transform)menu).localPosition.x - originalMenuSize.x / 2f;
float num2 = val2.x - num - 8f;
float num3 = Mathf.Clamp(num2, originalMenuSize.x, originalMenuSize.x * 1.6f);
if (owner.tradeMenu.activeSelf)
{
num3 = originalMenuSize.x;
}
if (!(Mathf.Abs(num3 - appliedWidth) < 0.1f))
{
appliedWidth = num3;
float num4 = originalMenuSize.y * originalMenuSize.x / num3;
menu.pivot = new Vector2(originalMenuSize.x * 0.5f / num3, 0.5f);
Resize(menu, num3, num4);
float width = num3 + originalSurfaceSize.x - originalMenuSize.x;
Resize(surface, width, num4 + originalSurfaceSize.y - originalMenuSize.y);
RectTransform rect2 = backdrop;
rect = surface.rect;
float width2 = ((Rect)(ref rect)).width;
rect = surface.rect;
Resize(rect2, width2, ((Rect)(ref rect)).height);
Resize(header, num3 + originalHeaderSize.x - originalMenuSize.x, originalHeaderSize.y);
if (Object.op_Implicit((Object)(object)bagName))
{
((Behaviour)bagName).enabled = num3 >= 250f;
}
}
}
private void SetUpHeader(PlayerCamera camera)
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: 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_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: 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_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_024a: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
TextMeshProUGUI containerText = camera.containerText;
Transform obj = ((Transform)header).Find("BarBack");
RectTransform val = (RectTransform)(object)((obj is RectTransform) ? obj : null);
if (Object.op_Implicit((Object)(object)val))
{
RectTransform rectTransform = ((Graphic)camera.containerIcon).rectTransform;
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor(0f, 0.5f);
rectTransform.anchorMax = val2;
rectTransform.anchorMin = val2;
rectTransform.anchoredPosition = new Vector2(23f, 0f);
RectTransform rectTransform2 = ((TMP_Text)containerText).rectTransform;
((Vector2)(ref val2))..ctor(1f, 0.5f);
rectTransform2.anchorMax = val2;
rectTransform2.anchorMin = val2;
rectTransform2.pivot = new Vector2(1f, 0.5f);
rectTransform2.anchoredPosition = new Vector2(-8f, 8f);
((TMP_Text)containerText).alignment = (TextAlignmentOptions)516;
RectTransform[] array = (RectTransform[])(object)new RectTransform[2]
{
val,
((Graphic)camera.containerFill).rectTransform
};
foreach (RectTransform val3 in array)
{
val3.anchorMin = new Vector2(0f, 0.5f);
val3.anchorMax = new Vector2(1f, 0.5f);
val3.offsetMin = new Vector2(43f, -18f);
val3.offsetMax = new Vector2(-8f, -5f);
}
bagName = new GameObject("Bag name", new Type[1] { typeof(TextMeshProUGUI) }).GetComponent<TextMeshProUGUI>();
((TMP_Text)bagName).transform.SetParent((Transform)(object)header, false);
((TMP_Text)bagName).font = ((TMP_Text)containerText).font;
((TMP_Text)bagName).fontSharedMaterial = ((TMP_Text)containerText).fontSharedMaterial;
((TMP_Text)bagName).fontSize = ((TMP_Text)containerText).fontSize;
((TMP_Text)bagName).alignment = (TextAlignmentOptions)513;
((TMP_Text)bagName).overflowMode = (TextOverflowModes)1;
((TMP_Text)bagName).enableWordWrapping = false;
((Graphic)bagName).raycastTarget = false;
RectTransform rectTransform3 = ((TMP_Text)bagName).rectTransform;
rectTransform3.anchorMin = new Vector2(0f, 0.5f);
rectTransform3.anchorMax = new Vector2(1f, 0.5f);
rectTransform3.offsetMin = new Vector2(43f, -4f);
rectTransform3.offsetMax = new Vector2(-110f, 21f);
}
}
private static void Resize(RectTransform rect, float width, float height)
{
rect.SetSizeWithCurrentAnchors((Axis)0, width);
rect.SetSizeWithCurrentAnchors((Axis)1, height);
}
}
[BepInPlugin("casualtiesunknown.betterbaginventory", "Better Bag Inventory", "1.0.0")]
public sealed class Plugin : BaseUnityPlugin
{
private void Awake()
{
Harmony.CreateAndPatchAll(typeof(Plugin), ((BaseUnityPlugin)this).Info.Metadata.GUID);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerCamera), "RepopulateContainer")]
private static void OnContainerPopulated(PlayerCamera __instance)
{
if (Object.op_Implicit((Object)(object)__instance.currentContainer) && Object.op_Implicit((Object)(object)__instance.contPopulate))
{
GameObject contPopulate = __instance.contPopulate;
BagView bagView = default(BagView);
if (!contPopulate.TryGetComponent<BagView>(ref bagView))
{
bagView = contPopulate.AddComponent<BagView>();
}
bagView.Bind(__instance);
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PlayerCamera), "HandleWhileDragging")]
private static void RememberOpenMenu(PlayerCamera __instance, out bool __state)
{
__state = __instance.radialOpen;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerCamera), "HandleWhileDragging")]
private static void KeepBagOpenWhileDragging(PlayerCamera __instance, List<RaycastResult> uiCasts, bool __state)
{
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
if (!__state || __instance.radialOpen || !Object.op_Implicit((Object)(object)__instance.dragItem) || !Object.op_Implicit((Object)(object)__instance.currentContainer) || !__instance.containerMenu.activeInHierarchy || __instance.body.consciousness < 20f)
{
return;
}
Transform transform = __instance.containerMenu.transform;
foreach (RaycastResult uiCast in uiCasts)
{
RaycastResult current = uiCast;
if (Object.op_Implicit((Object)(object)((RaycastResult)(ref current)).gameObject) && ((RaycastResult)(ref current)).gameObject.transform.IsChildOf(transform))
{
__instance.radialOpen = true;
break;
}
}
}
}
}