Decompiled source of SilyBunys v1.0.6

plugins/SilyBunys/AdelieLovelyPluginBunyItems.dll

Decompiled 2 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.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using R2API;
using RiskOfOptions;
using RiskOfOptions.Options;
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("AdelieLovelyPluginBunyItems")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+2a636ff4af892f31f1ca1d77a75e3ee199c31169")]
[assembly: AssemblyProduct("AdelieLovelyPluginBunyItems")]
[assembly: AssemblyTitle("AdelieLovelyPluginBunyItems")]
[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 AdelieLovelyPluginBunyItems
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("AdelieThePenguin.SilyBunys", "SilyBunys", "1.0.6")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class AdelieLovelyPluginBunyItems : BaseUnityPlugin
	{
		private AssetBundle bunyAssets;

		public const string PluginGUID = "AdelieThePenguin.SilyBunys";

		public const string PluginAuthor = "AdelieThePenguin";

		public const string PluginName = "SilyBunys";

		public const string PluginVersion = "1.0.6";

		private static ItemDef babyBuny;

		private static ItemDef coolBuny;

		private static ItemDef superBuny;

		private static ItemDef peeSyringe;

		public ConfigEntry<bool> toggleBaby;

		public ConfigEntry<bool> toggleCool;

		public ConfigEntry<bool> toggleSuper;

		public static PluginInfo PInfo { get; private set; }

		public void Awake()
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Expected O, but got Unknown
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Expected O, but got Unknown
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Expected O, but got Unknown
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Expected O, but got Unknown
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Expected O, but got Unknown
			PInfo = ((BaseUnityPlugin)this).Info;
			Log.Init(((BaseUnityPlugin)this).Logger);
			toggleBaby = ((BaseUnityPlugin)this).Config.Bind<bool>("baby buny spawning", "Item spawning setting for baby buny item", true, "toggle on if you want baby bunys to spawn baby bunys on the map. toggle off if you want it sent directly to your inventory. (less lag)");
			toggleCool = ((BaseUnityPlugin)this).Config.Bind<bool>("Cool Buny spawning", "Item spawning setting for Cool Buny item", true, "toggle on if you want Cool Bunys to spawn baby bunys and Cool Bunys on the map. toggle off if you want it sent directly to your inventory. (less lag)");
			toggleSuper = ((BaseUnityPlugin)this).Config.Bind<bool>("SUPER EPIC BUNY spawning", "Item spawning setting for Cool Buny item", false, "toggle on if you want SUPER EPIC BUNY to spawn bnuys instead of send straight to your inventory. If you do so you are insane maybe? (disabled by default)");
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(toggleBaby));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(toggleCool));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(toggleSuper));
			babyBuny = ScriptableObject.CreateInstance<ItemDef>();
			coolBuny = ScriptableObject.CreateInstance<ItemDef>();
			superBuny = ScriptableObject.CreateInstance<ItemDef>();
			string text = Path.Combine(Path.GetDirectoryName(PInfo.Location), "bunymodo");
			((BaseUnityPlugin)this).Logger.LogInfo((object)("path is: " + text));
			bunyAssets = AssetBundle.LoadFromFile(text);
			if (!Object.op_Implicit((Object)(object)bunyAssets))
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load AssetBundle at path: " + text));
				return;
			}
			string[] allAssetNames = bunyAssets.GetAllAssetNames();
			foreach (string text2 in allAssetNames)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Bundle asset: " + text2));
			}
			babyBuny.pickupIconSprite = bunyAssets.LoadAsset<Sprite>("assets/assets for bunymod/babybunyicon.png");
			babyBuny.pickupModelPrefab = bunyAssets.LoadAsset<GameObject>("assets/assets for bunymod/babybunypref.prefab");
			coolBuny.pickupIconSprite = bunyAssets.LoadAsset<Sprite>("assets/assets for bunymod/coolbunyicon.png");
			coolBuny.pickupModelPrefab = bunyAssets.LoadAsset<GameObject>("assets/assets for bunymod/coolbunypref.prefab");
			superBuny.pickupIconSprite = bunyAssets.LoadAsset<Sprite>("assets/assets for bunymod/epicbunyicon.png");
			superBuny.pickupModelPrefab = bunyAssets.LoadAsset<GameObject>("assets/assets for bunymod/epicbunypref.prefab");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"SilyBunys asset bundle loaded successfully.");
			((Object)babyBuny).name = "ADELIETHEPENGUIN_BABYBUNY";
			babyBuny.nameToken = "BABYBUNY_NAME";
			babyBuny.pickupToken = "BABYBUNY_PICKUP";
			babyBuny.descriptionToken = "BABYBUNY_DESC";
			babyBuny.loreToken = "BABYBUNY_LORE";
			((Object)coolBuny).name = "ADELIETHEPENGUIN_COOLBUNY";
			coolBuny.nameToken = "COOLBUNY_NAME";
			coolBuny.pickupToken = "COOLBUNY_PICKUP";
			coolBuny.descriptionToken = "COOLBUNY_DESC";
			coolBuny.loreToken = "COOLBUNY_LORE";
			((Object)superBuny).name = "ADELIETHEPENGUIN_SUPERBUNY";
			superBuny.nameToken = "SUPERBUNY_NAME";
			superBuny.pickupToken = "SUPERBUNY_PICKUP";
			superBuny.descriptionToken = "SUPERBUNY_DESC";
			superBuny.loreToken = "SUPERBUNY_LORE";
			babyBuny._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier1Def.asset").WaitForCompletion();
			coolBuny._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier2Def.asset").WaitForCompletion();
			superBuny._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier3Def.asset").WaitForCompletion();
			babyBuny.canRemove = true;
			coolBuny.canRemove = true;
			superBuny.canRemove = true;
			babyBuny.hidden = false;
			coolBuny.hidden = false;
			superBuny.hidden = false;
			ItemDisplayRuleDict val = new ItemDisplayRuleDict((ItemDisplayRule[])null);
			ItemAPI.Add(new CustomItem(babyBuny, val));
			ItemAPI.Add(new CustomItem(coolBuny, val));
			ItemAPI.Add(new CustomItem(superBuny, val));
			GlobalEventManager.onCharacterDeathGlobal += GlobalEventManager_onCharacterDeathGlobal;
			GlobalEventManager.onServerDamageDealt += GlobalEventManager_onServerDamageDealt;
			RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(ItemStatCalculator);
		}

		private void ItemStatCalculator(CharacterBody sender, StatHookEventArgs args)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			int itemCount = sender.inventory.GetItemCount(superBuny.itemIndex);
			int itemCount2 = sender.inventory.GetItemCount(coolBuny.itemIndex);
			int itemCount3 = sender.inventory.GetItemCount(babyBuny.itemIndex);
			if (sender.inventory.GetItemCount(superBuny.itemIndex) > 0 && itemCount3 > 0)
			{
				args.baseHealthAdd += (float)itemCount3;
				args.baseHealthAdd += (float)itemCount;
				args.baseHealthAdd += (float)itemCount2;
			}
		}

		private void GlobalEventManager_onServerDamageDealt(DamageReport report)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)report.attacker) || !Object.op_Implicit((Object)(object)report.attackerBody))
			{
				return;
			}
			CharacterBody attackerBody = report.attackerBody;
			if (!Object.op_Implicit((Object)(object)attackerBody.inventory))
			{
				return;
			}
			int itemCount = attackerBody.inventory.GetItemCount(superBuny.itemIndex);
			if (itemCount > 0 && Util.CheckRoll((float)itemCount, attackerBody.master))
			{
				Transform transform = report.victimBody.transform;
				if (!toggleSuper.Value)
				{
					attackerBody.inventory.GiveItem(babyBuny, 1);
				}
				else
				{
					PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(babyBuny.itemIndex), transform.position, transform.forward * 20f);
				}
			}
		}

		private void GlobalEventManager_onCharacterDeathGlobal(DamageReport report)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: 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_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)report.attacker) || !Object.op_Implicit((Object)(object)report.attackerBody))
			{
				return;
			}
			CharacterBody attackerBody = report.attackerBody;
			if (!Object.op_Implicit((Object)(object)attackerBody.inventory))
			{
				return;
			}
			int itemCount = attackerBody.inventory.GetItemCount(babyBuny.itemIndex);
			if (itemCount > 0 && Util.CheckRoll((float)itemCount, attackerBody.master))
			{
				Transform transform = report.victimBody.transform;
				if (toggleBaby.Value)
				{
					PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(babyBuny.itemIndex), transform.position, transform.forward * 20f);
				}
				else
				{
					attackerBody.inventory.GiveItem(babyBuny, 1);
				}
			}
			int itemCount2 = attackerBody.inventory.GetItemCount(coolBuny.itemIndex);
			if (itemCount2 > 0 && Util.CheckRoll((float)(10 * itemCount2), attackerBody.master))
			{
				Transform transform2 = report.victimBody.transform;
				if (toggleCool.Value)
				{
					PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(babyBuny.itemIndex), transform2.position, transform2.forward * 20f);
				}
				else
				{
					attackerBody.inventory.GiveItem(coolBuny, 1);
				}
			}
			if (itemCount2 > 0 && Util.CheckRoll((float)itemCount2, attackerBody.master))
			{
				Transform transform3 = report.victimBody.transform;
				if (toggleCool.Value)
				{
					PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(coolBuny.itemIndex), transform3.position, transform3.forward * 20f);
				}
				else
				{
					attackerBody.inventory.GiveItem(coolBuny, 1);
				}
			}
			int itemCount3 = attackerBody.inventory.GetItemCount(superBuny.itemIndex);
			if (itemCount3 <= 0)
			{
				return;
			}
			Transform transform4 = report.victimBody.transform;
			for (int i = 0; i < itemCount3; i++)
			{
				if (!toggleSuper.Value)
				{
					attackerBody.inventory.GiveItem(babyBuny, 1);
				}
				else
				{
					PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(babyBuny.itemIndex), transform4.position, transform4.forward * (20f + (float)itemCount3));
				}
			}
		}
	}
	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);
		}
	}
}