using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using On.RoR2.UI;
using RoR2;
using RoR2.UI;
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: AssemblyTitle("ROR2ScrapCounterMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ROR2ScrapCounterMod")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("694c2c2d-060d-4ebc-9711-e35f9e3a5515")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ScrapMod;
[BepInPlugin("com.Mirakuru.Scrap_in_HUD_QoL", "Scrap_in_HUD_QoL", "2.0.2")]
public class ScrapCounterMod : BaseUnityPlugin
{
public class HUDWidget : MonoBehaviour
{
private class ScrapIconSlot
{
public GameObject GameObject;
public TextMeshProUGUI Text;
public ItemDef ItemDef;
public CanvasGroup Group;
}
private HUD _sourceHud;
private float _updateTimer;
private ScrapIconSlot _whiteSlot;
private ScrapIconSlot _regenSlot;
private ScrapIconSlot _greenSlot;
private ScrapIconSlot _yellowSlot;
private ScrapIconSlot _redSlot;
private void Awake()
{
//IL_0018: 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_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Expected O, but got Unknown
//IL_00f8: 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_013d: Unknown result type (might be due to invalid IL or missing references)
RectTransform val = ((Component)this).gameObject.AddComponent<RectTransform>();
val.anchorMin = new Vector2(1f, 0f);
val.anchorMax = new Vector2(1f, 0f);
val.pivot = new Vector2(1f, 0f);
val.anchoredPosition = new Vector2(-65f, 175f);
val.sizeDelta = new Vector2(0f, 120f);
HorizontalLayoutGroup val2 = ((Component)this).gameObject.AddComponent<HorizontalLayoutGroup>();
((HorizontalOrVerticalLayoutGroup)val2).childControlWidth = false;
((HorizontalOrVerticalLayoutGroup)val2).childControlHeight = false;
((HorizontalOrVerticalLayoutGroup)val2).spacing = 15f;
((LayoutGroup)val2).childAlignment = (TextAnchor)3;
((LayoutGroup)val2).padding = new RectOffset(0, 5, 0, 0);
ContentSizeFitter val3 = ((Component)this).gameObject.AddComponent<ContentSizeFitter>();
val3.horizontalFit = (FitMode)2;
val3.verticalFit = (FitMode)2;
Image val4 = ((Component)this).gameObject.AddComponent<Image>();
((Graphic)val4).color = new Color(0.6f, 0.6f, 0.6f, 0.02f);
Outline val5 = ((Component)this).gameObject.AddComponent<Outline>();
((Shadow)val5).effectColor = new Color(0.6f, 0.6f, 0.6f, 0.8f);
((Shadow)val5).effectDistance = new Vector2(2f, -2f);
_whiteSlot = CreateScrapIcon(Items.ScrapWhite, ((Component)this).transform);
if ((Object)(object)Items.RegeneratingScrap != (Object)null)
{
_regenSlot = CreateScrapIcon(Items.RegeneratingScrap, ((Component)this).transform);
}
_greenSlot = CreateScrapIcon(Items.ScrapGreen, ((Component)this).transform);
_yellowSlot = CreateScrapIcon(Items.ScrapYellow, ((Component)this).transform);
_redSlot = CreateScrapIcon(Items.ScrapRed, ((Component)this).transform);
}
public void Initialize(HUD hud)
{
_sourceHud = hud;
}
private void Update()
{
_updateTimer -= Time.deltaTime;
if (!(_updateTimer > 0f))
{
_updateTimer = 1f;
Inventory inventory = _sourceHud.targetMaster.inventory;
UpdateSingleSlot(_whiteSlot, inventory);
UpdateSingleSlot(_greenSlot, inventory);
UpdateSingleSlot(_redSlot, inventory);
UpdateSingleSlot(_yellowSlot, inventory);
UpdateSingleSlot(_regenSlot, inventory);
}
}
private void UpdateSingleSlot(ScrapIconSlot slot, Inventory inv)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if (slot != null)
{
int itemCount = inv.GetItemCount(slot.ItemDef.itemIndex);
if (itemCount == 0)
{
slot.Group.alpha = 0.3f;
}
else
{
slot.Group.alpha = 1f;
}
((TMP_Text)slot.Text).text = "x" + itemCount;
}
}
private ScrapIconSlot CreateScrapIcon(ItemDef itemDef, Transform parentContainer)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Expected O, but got Unknown
//IL_00ec: 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_012e: 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_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: 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)
if ((Object)(object)itemDef == (Object)null)
{
return null;
}
GameObject val = new GameObject(((Object)itemDef).name + "_Icon");
val.transform.SetParent(parentContainer);
val.SetActive(true);
CanvasGroup group = val.AddComponent<CanvasGroup>();
Image val2 = val.AddComponent<Image>();
val2.sprite = itemDef.pickupIconSprite;
RectTransform component = val.GetComponent<RectTransform>();
component.sizeDelta = new Vector2(96f, 96f);
((Transform)component).localScale = Vector3.one;
GameObject val3 = new GameObject("CountText");
val3.transform.SetParent(val.transform);
TextMeshProUGUI val4 = val3.AddComponent<TextMeshProUGUI>();
TMP_FontAsset val5 = Resources.Load<TMP_FontAsset>("TmpFonts/Bombardier");
if (Object.op_Implicit((Object)(object)val5))
{
((TMP_Text)val4).font = val5;
}
((TMP_Text)val4).text = "0";
((TMP_Text)val4).fontSize = 40f;
((Graphic)val4).color = Color.white;
((TMP_Text)val4).alignment = (TextAlignmentOptions)260;
((TMP_Text)val4).overflowMode = (TextOverflowModes)0;
((TMP_Text)val4).enableWordWrapping = false;
RectTransform component2 = val3.GetComponent<RectTransform>();
component2.anchorMin = Vector2.zero;
component2.anchorMax = Vector2.one;
component2.sizeDelta = Vector2.zero;
component2.offsetMin = Vector2.zero;
component2.offsetMax = new Vector2(0f, 0f);
((Transform)component2).localScale = Vector3.one;
return new ScrapIconSlot
{
GameObject = val,
Text = val4,
ItemDef = itemDef,
Group = group
};
}
}
public const string PluginGuid = "com.Mirakuru.Scrap_in_HUD_QoL";
public const string PluginName = "Scrap_in_HUD_QoL";
public const string PluginVersion = "2.0.2";
private void Awake()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
HUD.Awake += new hook_Awake(HudAwakeHook);
((ResourceAvailability)(ref ItemCatalog.availability)).CallWhenAvailable((Action)delegate
{
if (Object.op_Implicit((Object)(object)Items.ScrapWhite))
{
Items.ScrapWhite.hidden = true;
}
if (Object.op_Implicit((Object)(object)Items.ScrapGreen))
{
Items.ScrapGreen.hidden = true;
}
if (Object.op_Implicit((Object)(object)Items.ScrapRed))
{
Items.ScrapRed.hidden = true;
}
if (Object.op_Implicit((Object)(object)Items.ScrapYellow))
{
Items.ScrapYellow.hidden = true;
}
if ((Object)(object)Items.RegeneratingScrap != (Object)null)
{
Items.RegeneratingScrap.hidden = true;
}
if ((Object)(object)Items.RegeneratingScrapConsumed != (Object)null)
{
Items.RegeneratingScrapConsumed.hidden = true;
}
});
}
private void HudAwakeHook(orig_Awake orig, HUD self)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Expected O, but got Unknown
orig.Invoke(self);
GameObject val = new GameObject("MirakuruScrapWidget");
val.layer = LayerMask.NameToLayer("UI");
val.transform.SetParent(self.mainContainer.transform);
HUDWidget hUDWidget = val.AddComponent<HUDWidget>();
hUDWidget.Initialize(self);
}
}