Decompiled source of Artifact Of Decay v1.0.0

ArtifactOfDecay.dll

Decompiled 2 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using R2API.Utils;
using RoR2;
using UnityEngine;

[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("ArtifactOfDecay")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+84555cf6069584531df4b4111ccf3a04bcfb7df8")]
[assembly: AssemblyProduct("ArtifactOfDecay")]
[assembly: AssemblyTitle("ArtifactOfDecay")]
[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 ArtifactOfDecay
{
	public class ArtifactOfDecay
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_OnInventoryChanged <0>__globalInventoryChangedHook;
		}

		public static ArtifactDef artifactDef = ScriptableObject.CreateInstance<ArtifactDef>();

		public static bool ArtifactEnabled => RunArtifactManager.instance.IsArtifactEnabled(artifactDef);

		public static void InitializeArtifact()
		{
			//IL_007c: 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)
			//IL_0087: Expected O, but got Unknown
			artifactDef.nameToken = "BRAQ_DECAY_ARTIFACT_NAME";
			artifactDef.cachedName = "BRAQ_DECAY_ARTIFACT";
			artifactDef.descriptionToken = "BRAQ_DECAY_ARTIFACT_DESCRIPTION";
			artifactDef.smallIconDeselectedSprite = ArtifactOfDecayPlugin.assets.LoadAsset<Sprite>("artifactOfDecayDisabled.png");
			artifactDef.smallIconSelectedSprite = ArtifactOfDecayPlugin.assets.LoadAsset<Sprite>("artifactOfDecayEnabled.png");
			ContentAddition.AddArtifactDef(artifactDef);
			object obj = <>O.<0>__globalInventoryChangedHook;
			if (obj == null)
			{
				hook_OnInventoryChanged val = globalInventoryChangedHook;
				<>O.<0>__globalInventoryChangedHook = val;
				obj = (object)val;
			}
			CharacterBody.OnInventoryChanged += (hook_OnInventoryChanged)obj;
		}

		private static void config()
		{
		}

		private static void globalInventoryChangedHook(orig_OnInventoryChanged orig, CharacterBody self)
		{
			//IL_005d: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			//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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Invalid comparison between Unknown and I4
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: 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)
			//IL_0104: 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_0110: 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_011b: Expected O, but got Unknown
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			if (!ArtifactEnabled)
			{
				return;
			}
			Inventory inventory = self.inventory;
			if (!Object.op_Implicit((Object)(object)inventory) || inventory.GetTotalTempItemCount() > 0)
			{
				return;
			}
			List<ItemIndex> list = new List<ItemIndex>();
			((ItemCollection)(ref inventory.permanentItemStacks)).GetNonZeroIndices(list);
			Util.ShuffleList<ItemIndex>(list);
			ItemIndex val = (ItemIndex)(-1);
			foreach (ItemIndex item in list)
			{
				ItemDef itemDef = ItemCatalog.GetItemDef(item);
				if ((int)itemDef.tier == 5)
				{
					continue;
				}
				val = itemDef.itemIndex;
				break;
			}
			if ((int)val != -1)
			{
				InventoryChangeScope val2 = default(InventoryChangeScope);
				((InventoryChangeScope)(ref val2))..ctor(inventory);
				try
				{
					inventory.GiveItemPermanent(val, -1);
					inventory.GiveItemTemp(val, 1f);
				}
				finally
				{
					((InventoryChangeScope)(ref val2)).Dispose();
				}
				if (Object.op_Implicit((Object)(object)self.master))
				{
					CustomOverrideInfo val3 = new CustomOverrideInfo
					{
						descriptionText = "BRAQ_PICKUP_NOTIFICATION_TRANSFORMED_TO_TEMPORARY",
						iconColor = Color.gray
					};
					CharacterMasterNotificationQueue.SendCustomNotification(self.master, val, val3);
				}
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Braquen.Artifact_Of_Decay", "Artifact_Of_Decay", "1.0.0")]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class ArtifactOfDecayPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "Braquen.Artifact_Of_Decay";

		public const string PluginAuthor = "Braquen";

		public const string PluginName = "Artifact_Of_Decay";

		public const string PluginVersion = "1.0.0";

		public static PluginInfo pluginInfo;

		internal static AssetBundle assets;

		public void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ArtifactOfDecay.assets.bundle"))
			{
				assets = AssetBundle.LoadFromStream(stream);
			}
			ArtifactOfDecay.InitializeArtifact();
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		[Conditional("DEBUG")]
		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
}