Decompiled source of ArtifactOfEgress v1.0.1

ArtifactOfGreed.dll

Decompiled a day 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 BepInEx;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using RoR2;
using RoR2.Navigation;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ArtifactOfGreed")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ArtifactOfGreed")]
[assembly: AssemblyTitle("ArtifactOfGreed")]
[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 ArtifactOfGreed
{
	public static class GreedArtifact
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_OnInteractionBegin <0>__TeleporterInteraction_OnInteractionBegin;
		}

		public static ArtifactDef ArtifactDef;

		public static void Initialize()
		{
			//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_009b: Expected O, but got Unknown
			ArtifactDef = ScriptableObject.CreateInstance<ArtifactDef>();
			ArtifactDef.cachedName = "ArtifactOfGreed";
			ArtifactDef.nameToken = "ARTIFACT_OF_GREED_NAME";
			ArtifactDef.descriptionToken = "ARTIFACT_OF_GREED_DESCRIPTION";
			ArtifactDef.smallIconSelectedSprite = LoadIcon("ArtifactOfGreed.Assets.icon_selected.png");
			ArtifactDef.smallIconDeselectedSprite = LoadIcon("ArtifactOfGreed.Assets.icon_deselected.png");
			Debug.Log((object)("Artifact registered: " + ContentAddition.AddArtifactDef(ArtifactDef)));
			object obj = <>O.<0>__TeleporterInteraction_OnInteractionBegin;
			if (obj == null)
			{
				hook_OnInteractionBegin val = TeleporterInteraction_OnInteractionBegin;
				<>O.<0>__TeleporterInteraction_OnInteractionBegin = val;
				obj = (object)val;
			}
			TeleporterInteraction.OnInteractionBegin += (hook_OnInteractionBegin)obj;
		}

		private static Sprite LoadIcon(string resourceName)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
			if (stream == null)
			{
				Debug.LogError((object)("No se encontro el recurso: " + resourceName));
				return null;
			}
			byte[] array = new byte[stream.Length];
			stream.Read(array, 0, array.Length);
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
			ImageConversion.LoadImage(val, array);
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
		}

		private static void TeleporterInteraction_OnInteractionBegin(orig_OnInteractionBegin orig, TeleporterInteraction self, Interactor activator)
		{
			bool isCharged = self.isCharged;
			orig.Invoke(self, activator);
			if (isCharged && (Object)(object)Run.instance != (Object)null && RunArtifactManager.instance.IsArtifactEnabled(ArtifactDef))
			{
				SpawnLegendaryItemOnMap();
			}
		}

		private static void SpawnLegendaryItemOnMap()
		{
			//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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_007c: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			List<PickupIndex> availableTier3DropList = Run.instance.availableTier3DropList;
			if (availableTier3DropList.Count == 0)
			{
				return;
			}
			PickupIndex val = Run.instance.treasureRng.NextElementUniform<PickupIndex>(availableTier3DropList);
			Vector3 zero = Vector3.zero;
			NodeGraph groundNodes = SceneInfo.instance.groundNodes;
			if ((Object)(object)groundNodes != (Object)null)
			{
				List<NodeIndex> activeNodesForHullMask = groundNodes.GetActiveNodesForHullMask((HullMask)1);
				if (activeNodesForHullMask.Count > 0)
				{
					groundNodes.GetNodePosition(activeNodesForHullMask[Random.Range(0, activeNodesForHullMask.Count)], ref zero);
				}
			}
			if (zero != Vector3.zero)
			{
				PickupDropletController.CreatePickupDroplet(val, zero + Vector3.up * 2f, Vector3.up * 20f);
				Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
				{
					baseToken = "<color=#e55b14>Something finds its way to the surface...</color>"
				});
			}
		}
	}
	public static class Language
	{
		public static void Initialize()
		{
			LanguageAPI.Add("ARTIFACT_OF_GREED_NAME", "Artifact of Egress");
			LanguageAPI.Add("ARTIFACT_OF_GREED_DESCRIPTION", "Activating the teleporter to leave the stage spawns a legendary item at a random location. Works with teleporters only, not portals.");
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.tunombre.artifactofgreed", "Artifact of Greed", "1.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Artifact of Greed loaded!");
			Language.Initialize();
			GreedArtifact.Initialize();
		}
	}
}