Decompiled source of More Syringes v1.0.1

plugins/Gems.MoreSyringes/MoreSyringes.dll

Decompiled 3 weeks ago
using System;
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 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("ExamplePlugin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ExamplePlugin")]
[assembly: AssemblyTitle("ExamplePlugin")]
[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
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Gems.MoreSyringes", "MoreSyringes", "1.0.0")]
	public class ExamplePlugin : BaseUnityPlugin
	{
		public const string PluginAuthor = "Gems";

		public const string PluginName = "MoreSyringes";

		public const string PluginVersion = "1.0.0";

		public const string PluginGUID = "Gems.MoreSyringes";

		private static ItemDef myItemDef;

		public void Awake()
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Expected O, but got Unknown
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Expected O, but got Unknown
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Expected O, but got Unknown
			myItemDef = ScriptableObject.CreateInstance<ItemDef>();
			((Object)myItemDef).name = "MEGASYRINGE_NAME";
			myItemDef.nameToken = "MEGASYRINGE_NAME";
			myItemDef.pickupToken = "MEGASYRINGE_PICKUP";
			myItemDef.descriptionToken = "MEGASYRINGE_DESC";
			myItemDef.loreToken = "MEGASYRINGE_LORE";
			myItemDef.deprecatedTier = (ItemTier)2;
			string path = Path.Combine(Paths.PluginPath, "Gems.MoreSyringes", "mega_syringe_icon.png");
			byte[] array = File.ReadAllBytes(path);
			Texture2D val = new Texture2D(64, 64, (TextureFormat)5, false);
			ImageConversion.LoadImage(val, array);
			myItemDef.pickupIconSprite = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
			myItemDef.pickupModelPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Syringe/DisplaySyringe.prefab").WaitForCompletion();
			myItemDef.canRemove = true;
			myItemDef.hidden = false;
			ItemDisplayRuleDict val2 = new ItemDisplayRuleDict((ItemDisplayRule[])null);
			ItemAPI.Add(new CustomItem(myItemDef, val2));
			RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(ApplyMegaSyringeStats);
		}

		private void ApplyMegaSyringeStats(CharacterBody body, StatHookEventArgs args)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)body == (Object)null) && !((Object)(object)body.inventory == (Object)null))
			{
				int itemCount = body.inventory.GetItemCount(myItemDef.itemIndex);
				if (itemCount > 0)
				{
					args.attackSpeedMultAdd += 1f * (float)itemCount;
					args.moveSpeedMultAdd += 0.2f * (float)itemCount;
				}
			}
		}
	}
	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);
		}
	}
}