Decompiled source of DevotionInventoryDisplay v1.0.1

DevotionInventoryDisplay.dll

Decompiled 4 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using On;
using On.RoR2.UI;
using RoR2;
using RoR2.UI;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("DevotionInventoryDisplay")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DevotionInventoryDisplay")]
[assembly: AssemblyTitle("DevotionInventoryDisplay")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace DevotionInventoryDisplay
{
	[BepInPlugin("com.Nuxlar.DevotionInventoryDisplay", "DevotionInventoryDisplay", "1.0.1")]
	public class DevotionInventoryDisplay : BaseUnityPlugin
	{
		private static Dictionary<CharacterMaster, Inventory> masterInventories = new Dictionary<CharacterMaster, Inventory>();

		public void Awake()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			ScoreboardController.Rebuild += new hook_Rebuild(AddLemurianInventory);
			DevotedLemurianController.Start += new hook_Start(GetLemInventory);
		}

		[SystemInitializer(new Type[] { typeof(ItemCatalog) })]
		private static void HideLemItems()
		{
			ItemDef[] itemDefs = ItemCatalog.itemDefs;
			foreach (ItemDef val in itemDefs)
			{
				if (val.nameToken == "ITEM_BOOSTDAMAGE_NAME" || val.nameToken == "ITEM_BOOSTHP_NAME")
				{
					val.hidden = true;
				}
			}
		}

		private void GetLemInventory(orig_Start orig, DevotedLemurianController self)
		{
			orig.Invoke(self);
			CharacterMaster ownerMaster = ((Component)self).gameObject.GetComponent<MinionOwnership>().ownerMaster;
			if (!((Object)(object)ownerMaster != (Object)null))
			{
				return;
			}
			masterInventories.TryGetValue(ownerMaster, out var value);
			if ((Object)(object)value == (Object)null)
			{
				Inventory component = ((Component)self).gameObject.GetComponent<Inventory>();
				if ((Object)(object)component != (Object)null)
				{
					masterInventories.Add(ownerMaster, component);
				}
			}
		}

		private void AddLemurianInventory(orig_Rebuild orig, ScoreboardController self)
		{
			orig.Invoke(self);
			if (!Object.op_Implicit((Object)(object)RunArtifactManager.instance) || !RunArtifactManager.instance.IsArtifactEnabled(Artifacts.Devotion))
			{
				return;
			}
			List<CharacterMaster> list = new List<CharacterMaster>();
			foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
			{
				list.Add(instance.master);
			}
			CharacterMaster master = LocalUserManager.readOnlyLocalUsersList.First().cachedMasterController.master;
			masterInventories.TryGetValue(master, out var value);
			if ((Object)(object)value != (Object)null)
			{
				list.Add(((Component)value).gameObject.GetComponent<CharacterMaster>());
			}
			self.SetStripCount(list.Count);
			for (int i = 0; i < list.Count; i++)
			{
				self.stripAllocator.elements[i].SetMaster(list[i]);
			}
		}
	}
}