Decompiled source of CraigsCorner v0.0.0

CraigsCorner.dll

Decompiled 9 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using R2API.Utils;
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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("CraigsCorner")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CraigsCorner")]
[assembly: AssemblyTitle("CraigsCorner")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace CraigsCorner
{
	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 CraigsCorner.Items.Tier1
{
	[BepInPlugin("com.Craiglet.CraigsCorner", "CraigsCorner", "0.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class HikingBoot : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static StatHookEventHandler <>9__10_0;

			internal void <Hooks>b__10_0(CharacterBody sender, StatHookEventArgs args)
			{
				if (!((Object)(object)sender == (Object)null) && !((Object)(object)sender.inventory == (Object)null))
				{
					int itemCount = sender.inventory.GetItemCount(myItemDef);
					if (itemCount > 0)
					{
						args.moveSpeedMultAdd += 0.1f * (float)itemCount;
					}
				}
			}
		}

		public const string ModGUID = "com.Craiglet.CraigsCorner";

		public const string ModName = "CraigsCorner";

		public const string ModVer = "0.0.0";

		public static ItemDef myItemDef;

		public static AssetBundle MainAssets;

		public static PluginInfo pluginInfo { get; private set; }

		public void Awake()
		{
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Expected O, but got Unknown
			pluginInfo = ((BaseUnityPlugin)this).Info;
			Log.Init(((BaseUnityPlugin)this).Logger);
			myItemDef = ScriptableObject.CreateInstance<ItemDef>();
			((Object)myItemDef).name = "HIKING_BOOT";
			myItemDef.nameToken = "HIKING_BOOT_NAME";
			myItemDef.pickupToken = "HIKING_BOOT_PICKUP";
			myItemDef.descriptionToken = "HIKING_BOOT_DESC";
			myItemDef.loreToken = "HIKING_BOOT_LORE";
			myItemDef.tier = (ItemTier)0;
			MainAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(pluginInfo.Location), "hikingboot_assets"));
			myItemDef.pickupIconSprite = MainAssets.LoadAsset<Sprite>("HikingBootIcon.png");
			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));
			Hooks();
		}

		public void Hooks()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			object obj = <>c.<>9__10_0;
			if (obj == null)
			{
				StatHookEventHandler val = delegate(CharacterBody sender, StatHookEventArgs args)
				{
					if (!((Object)(object)sender == (Object)null) && !((Object)(object)sender.inventory == (Object)null))
					{
						int itemCount = sender.inventory.GetItemCount(myItemDef);
						if (itemCount > 0)
						{
							args.moveSpeedMultAdd += 0.1f * (float)itemCount;
						}
					}
				};
				<>c.<>9__10_0 = val;
				obj = (object)val;
			}
			RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj;
			HealthComponent.TakeDamage += new hook_TakeDamage(HealthComponent_TakeDamage);
		}

		private void HealthComponent_TakeDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
		{
			if (damageInfo != null && !damageInfo.rejected)
			{
				int count = GetCount(self.body);
				float health = self.health;
				if (count > 0)
				{
					int num = 2 * count;
					float damage = Mathf.Max(damageInfo.damage - (float)num, 1f);
					damageInfo.damage = damage;
				}
				orig.Invoke(self, damageInfo);
			}
		}

		public int GetCount(CharacterBody body)
		{
			if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.inventory))
			{
				return 0;
			}
			return body.inventory.GetItemCount(myItemDef);
		}
	}
}