Decompiled source of JoelsItems v1.1.0

JoelsItem.dll

Decompiled 4 months ago
using System;
using System.Diagnostics;
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 RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;

[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("JoelsItem")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("JoelsItem")]
[assembly: AssemblyTitle("JoelsItem")]
[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 ExamplePlugin
{
	internal static class Log
	{
		private static ManualLogSource _logSource;

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

		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);
		}
	}
}
namespace JoelsItems
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Joel.JoelsItem", "JoelsItem", "1.6.0")]
	public class ExamplePlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "Joel.JoelsItem";

		public const string PluginName = "JoelsItem";

		public const string PluginVersion = "1.6.0";

		public static ExamplePlugin instance;

		public static ManualLogSource Log;

		public static ItemDef myItemDef;

		private void Awake()
		{
			//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_00b2: 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_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Expected O, but got Unknown
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Expected O, but got Unknown
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Expected O, but got Unknown
			instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"Initializing Joel's Black Hole item...");
			myItemDef = ScriptableObject.CreateInstance<ItemDef>();
			((Object)myItemDef).name = "JoelsBlackHole";
			myItemDef.nameToken = "JOELS_BLACKHOLE_NAME";
			myItemDef.pickupToken = "JOELS_BLACKHOLE_PICKUP";
			myItemDef.descriptionToken = "JOELS_BLACKHOLE_DESC";
			myItemDef.loreToken = "JOELS_BLACKHOLE_LORE";
			myItemDef._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier2Def.asset").WaitForCompletion();
			myItemDef.pickupIconSprite = Resources.Load<Sprite>("Icons/BlackHole");
			myItemDef.pickupModelPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Mystery/PickupMystery.prefab").WaitForCompletion();
			myItemDef.canRemove = true;
			myItemDef.hidden = false;
			ItemDisplayRuleDict val = new ItemDisplayRuleDict((ItemDisplayRule[])null);
			ItemAPI.Add(new CustomItem(myItemDef, val));
			LanguageAPI.Add("JOELS_BLACKHOLE_NAME", "Joel's Black Hole");
			LanguageAPI.Add("JOELS_BLACKHOLE_PICKUP", "Deals 5% base damage per tick and pulls in nearby enemies.");
			LanguageAPI.Add("JOELS_BLACKHOLE_DESC", "Enemies within 10m are pulled toward you and take 5% of your base damage every 0.2 seconds.");
			LanguageAPI.Add("JOELS_BLACKHOLE_LORE", "??? What are you looking at?");
			foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
			{
				AttachBlackHoleEffect(instance.master.GetBody());
			}
			CharacterBody.Start += new hook_Start(CharacterBody_Start);
			CharacterMaster.OnBodyStart += new hook_OnBodyStart(CharacterMaster_OnBodyStart);
		}

		private void CharacterBody_Start(orig_Start orig, CharacterBody self)
		{
			orig.Invoke(self);
			AttachBlackHoleEffect(self);
		}

		private void AttachBlackHoleEffect(CharacterBody body)
		{
			if (!((Object)(object)body == (Object)null) && !((Object)(object)((Component)body).gameObject.GetComponent<BlackHoleEffect>() != (Object)null))
			{
				((Component)body).gameObject.AddComponent<BlackHoleEffect>();
			}
		}

		private void CharacterMaster_OnBodyStart(orig_OnBodyStart orig, CharacterMaster self, CharacterBody body)
		{
			orig.Invoke(self, body);
			if (!((Object)(object)self == (Object)null) && !((Object)(object)body == (Object)null) && (Object)(object)((Component)self).GetComponent<NetworkUser>() != (Object)null && (Object)(object)((Component)body).gameObject.GetComponent<F2ItemSpawner>() == (Object)null)
			{
				((Component)body).gameObject.AddComponent<F2ItemSpawner>();
			}
		}
	}
	public class BlackHoleEffect : MonoBehaviour
	{
		private CharacterBody body;

		private float tickInterval = 0.2f;

		private float tickTimer;

		private void Awake()
		{
			body = ((Component)this).GetComponent<CharacterBody>();
		}

		private void Update()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: 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_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Expected O, but got Unknown
			//IL_016f: 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_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: 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_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.inventory))
			{
				return;
			}
			int itemCount = body.inventory.GetItemCount(ExamplePlugin.myItemDef.itemIndex);
			if (itemCount <= 0)
			{
				return;
			}
			tickTimer -= Time.deltaTime;
			if (tickTimer > 0f)
			{
				return;
			}
			tickTimer = tickInterval;
			float num = 15f;
			float num2 = 5.05f;
			foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList)
			{
				if ((Object)(object)readOnlyInstances == (Object)null || !Object.op_Implicit((Object)(object)readOnlyInstances.healthComponent) || !readOnlyInstances.healthComponent.alive || (Object)(object)readOnlyInstances == (Object)(object)body || readOnlyInstances.teamComponent.teamIndex == body.teamComponent.teamIndex)
				{
					continue;
				}
				float num3 = Vector3.Distance(body.corePosition, readOnlyInstances.corePosition);
				if (!(num3 > num))
				{
					CharacterMotor characterMotor = readOnlyInstances.characterMotor;
					if ((Object)(object)characterMotor != (Object)null)
					{
						Vector3 val = body.corePosition - readOnlyInstances.corePosition;
						Vector3 normalized = ((Vector3)(ref val)).normalized;
						characterMotor.velocity += normalized * 20f * Time.deltaTime;
					}
					DamageInfo val2 = new DamageInfo
					{
						attacker = ((Component)body).gameObject,
						crit = body.RollCrit(),
						damage = body.baseDamage * num2,
						position = readOnlyInstances.corePosition,
						damageType = DamageTypeCombo.op_Implicit((DamageType)0)
					};
					readOnlyInstances.healthComponent.TakeDamage(val2);
				}
			}
		}
	}
	public class F2ItemSpawner : MonoBehaviour
	{
		private CharacterBody body;

		private void Awake()
		{
			body = ((Component)this).GetComponent<CharacterBody>();
		}

		private void Update()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown((KeyCode)283) && !((Object)(object)body == (Object)null) && !((Object)(object)body.inventory == (Object)null))
			{
				body.inventory.GiveItem(ExamplePlugin.myItemDef.itemIndex, 1);
				ExamplePlugin.Log.LogInfo((object)"Gave Joel's Black Hole to the player!");
			}
		}
	}
}