Decompiled source of GrowthNectarRework v1.1.6

plugins/GrowthNectarRework/NectarRework.dll

Decompiled 2 weeks 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 IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using R2API;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;

[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("NectarRework")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+7b455530891bf15681fcffe337b0570142350e48")]
[assembly: AssemblyProduct("NectarRework")]
[assembly: AssemblyTitle("NectarRework")]
[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 NectarRework
{
	internal class CustomItems
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_OnInventoryChanged <0>__CharacterBody_OnInventoryChanged;

			public static Action <1>__OnLoad;
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Func<Instruction, bool> <>9__4_1;

			public static Func<Instruction, bool> <>9__4_2;

			public static Manipulator <>9__4_0;

			internal void <OverrideDefaultBehavior>b__4_0(ILContext il)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Expected O, but got Unknown
				//IL_0085: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
				ILCursor val = new ILCursor(il);
				if (val.TryGotoNext(new Func<Instruction, bool>[2]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 53),
					(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0)
				}))
				{
					Log.Info("[GrowthNectarRework]: IL Hook succeeded");
					val.Index += 1;
					Log.Info($"[GrowthNectarRework]: OpCode before: {val.Next.OpCode}");
					val.Remove();
					val.Emit(OpCodes.Ldc_I4, 999999);
					Log.Info($"[GrowthNectarRework]: operand after: {val.Next.Operand}");
					Log.Info($"[GrowthNectarRework]: OpCode after: {val.Next.Operand}");
				}
				else
				{
					Log.Info("[GrowthNectarRework]: IL Hook failed");
				}
			}

			internal bool <OverrideDefaultBehavior>b__4_1(Instruction x)
			{
				return ILPatternMatchingExt.MatchLdloc(x, 53);
			}

			internal bool <OverrideDefaultBehavior>b__4_2(Instruction x)
			{
				return ILPatternMatchingExt.MatchLdcI4(x, 0);
			}
		}

		public static ItemDef ItemOrganicAllyBuff;

		public static ItemDef ItemWispName;

		public static void Init()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			CreateOrganicAllyBuff();
			CreateWispNameItem();
			OverrideDefaultBehavior();
			AddLanguageTokens();
			object obj = <>O.<0>__CharacterBody_OnInventoryChanged;
			if (obj == null)
			{
				hook_OnInventoryChanged val = CharacterBody_OnInventoryChanged;
				<>O.<0>__CharacterBody_OnInventoryChanged = val;
				obj = (object)val;
			}
			CharacterBody.OnInventoryChanged += (hook_OnInventoryChanged)obj;
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnLoad));
		}

		private static void OnLoad()
		{
			ItemDef boostAllStats = Items.BoostAllStats;
			ItemTag[] array = new ItemTag[4];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			boostAllStats.tags = (ItemTag[])(object)array;
		}

		private static void OverrideDefaultBehavior()
		{
			//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__4_0;
			if (obj == null)
			{
				Manipulator val = delegate(ILContext il)
				{
					//IL_0002: Unknown result type (might be due to invalid IL or missing references)
					//IL_0008: Expected O, but got Unknown
					//IL_0085: Unknown result type (might be due to invalid IL or missing references)
					//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
					ILCursor val2 = new ILCursor(il);
					if (val2.TryGotoNext(new Func<Instruction, bool>[2]
					{
						(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 53),
						(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0)
					}))
					{
						Log.Info("[GrowthNectarRework]: IL Hook succeeded");
						val2.Index += 1;
						Log.Info($"[GrowthNectarRework]: OpCode before: {val2.Next.OpCode}");
						val2.Remove();
						val2.Emit(OpCodes.Ldc_I4, 999999);
						Log.Info($"[GrowthNectarRework]: operand after: {val2.Next.Operand}");
						Log.Info($"[GrowthNectarRework]: OpCode after: {val2.Next.Operand}");
					}
					else
					{
						Log.Info("[GrowthNectarRework]: IL Hook failed");
					}
				};
				<>c.<>9__4_0 = val;
				obj = (object)val;
			}
			CharacterBody.RecalculateStats += (Manipulator)obj;
		}

		private static void CharacterBody_OnInventoryChanged(orig_OnInventoryChanged orig, CharacterBody self)
		{
			if (NetworkServer.active)
			{
				self.AddItemBehavior<OrganicAllyBuff>(self.inventory.GetItemCount(ItemOrganicAllyBuff));
				self.AddItemBehavior<GrowthNectarV2>(self.inventory.GetItemCount(Items.BoostAllStats));
			}
			orig.Invoke(self);
		}

		private static void CreateOrganicAllyBuff()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			ItemDef val = new ItemDef();
			((Object)val).name = "OrganicAllyBuff";
			val._itemTierDef = null;
			val.deprecatedTier = (ItemTier)5;
			val.pickupModelPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Mystery/PickupMystery.prefab").WaitForCompletion();
			val.pickupIconSprite = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/Common/MiscIcons/texMysteryIcon.png").WaitForCompletion();
			val.nameToken = "ITEM_ORGANICALLYBUFF_NAME";
			val.pickupToken = "ITEM_ORGANICALLYBUFF_PICKUP";
			val.descriptionToken = "ITEM_ORGANICALLYBUFF_DESC";
			val.loreToken = "ITEM_ORGANICALLYBUFF_LORE";
			ItemTag[] array = new ItemTag[5];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			val.tags = (ItemTag[])(object)array;
			val.canRemove = false;
			val.hidden = true;
			ItemOrganicAllyBuff = val;
			ItemDisplayRuleDict val2 = new ItemDisplayRuleDict((ItemDisplayRule[])null);
			CustomItem val3 = new CustomItem(ItemOrganicAllyBuff, val2);
			ItemAPI.Add(val3);
		}

		private static void CreateWispNameItem()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			ItemDef val = new ItemDef();
			((Object)val).name = "GuardianWispName";
			val._itemTierDef = null;
			val.deprecatedTier = (ItemTier)5;
			val.pickupModelPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Mystery/PickupMystery.prefab").WaitForCompletion();
			val.pickupIconSprite = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/Common/MiscIcons/texMysteryIcon.png").WaitForCompletion();
			val.nameToken = "ITEM_GUARDIANWISP_NAME";
			val.pickupToken = "ITEM_GUARDIANWISP_PICKUP";
			val.descriptionToken = "ITEM_GUARDIANWISP_DESC";
			val.loreToken = "ITEM_GUARDIANWISP_LORE";
			ItemTag[] array = new ItemTag[5];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			val.tags = (ItemTag[])(object)array;
			val.canRemove = false;
			val.hidden = true;
			ItemWispName = val;
			ItemDisplayRuleDict val2 = new ItemDisplayRuleDict((ItemDisplayRule[])null);
			CustomItem val3 = new CustomItem(ItemWispName, val2);
			ItemAPI.Add(val3);
		}

		private static void AddLanguageTokens()
		{
			LanguageAPI.Add("ITEM_BOOSTALLSTATS_PICKUP", "Summon a <style=cIsUtility>Guardian Wisp</style>. All <style=cIsUtility>organic</style> allies are <style=cIsDamage>stronger</style> and <style=cIsDamage>Elite</style>.");
			LanguageAPI.Add("ITEM_BOOSTALLSTATS_DESC", "Gain an allied <style=cIsUtility>Guardian Wisp</style> that respawns every 30 seconds. All <style=cIsUtility>ORGANIC</style> allies will gain <style=cIsDamage>+200%</style> <style=cStack>(+200% per stack)</style> damage and <style=cIsUtility>+150%</style> <style=cStack>(+150% per stack)</style> health and a random <style=cIsDamage>Elite</style> status.\r\n");
		}
	}
	public class GrowthNectarV2 : ItemBehavior
	{
		private readonly EquipmentDef[] POSSIBLE_ELITE_EQUIPMENTS = (EquipmentDef[])(object)new EquipmentDef[4]
		{
			Elites.Lightning.eliteEquipmentDef,
			Elites.Ice.eliteEquipmentDef,
			Elites.Fire.eliteEquipmentDef,
			Elites.Earth.eliteEquipmentDef
		};

		private int previousStack;

		private CharacterSpawnCard droneSpawnCard;

		private Xoroshiro128Plus rng;

		private DirectorPlacementRule placementRule;

		private CharacterBody summonedWispBody;

		private const float spawnRetryDelay = 1f;

		private const float spawnCooldown = 30f;

		private float spawnTimer = 0f;

		private DeployableSlot wispDeployable;

		public int GetWishDeployableSlotLimit(CharacterMaster self, int deployableCountMultiplier)
		{
			return deployableCountMultiplier;
		}

		private void Awake()
		{
			((ResourceAvailability)(ref GameModeCatalog.availability)).CallWhenAvailable((Action)PostLoad);
			((Behaviour)this).enabled = false;
		}

		public void PostLoad()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			wispDeployable = DeployableAPI.RegisterDeployableSlot(new GetDeployableSameSlotLimit(GetWishDeployableSlotLimit));
		}

		private void OnEnable()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			ulong num = Run.instance.seed ^ (ulong)Run.instance.stageClearCount;
			rng = new Xoroshiro128Plus(num);
			droneSpawnCard = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)"RoR2/Base/GreaterWisp/cscGreaterWisp.asset").WaitForCompletion();
			placementRule = new DirectorPlacementRule
			{
				placementMode = (PlacementMode)1,
				minDistance = 3f,
				maxDistance = 40f,
				spawnOnTarget = ((Component)this).transform
			};
			UpdateAllMinions(base.body.inventory.GetItemCount(Items.BoostAllStats));
			MasterSummon.onServerMasterSummonGlobal += OnServerMasterSummonGlobal;
		}

		private void OnDisable()
		{
			MasterSummon.onServerMasterSummonGlobal -= OnServerMasterSummonGlobal;
			UpdateAllMinions(0);
		}

		private void FixedUpdate()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			if (previousStack != base.stack)
			{
				UpdateAllMinions(base.stack);
			}
			CharacterMaster master = base.body.master;
			if (!Object.op_Implicit((Object)(object)master))
			{
				return;
			}
			int deployableCount = master.GetDeployableCount(wispDeployable);
			if (deployableCount < 1)
			{
				spawnTimer -= Time.fixedDeltaTime;
				if (spawnTimer <= 0f)
				{
					TrySpawnDrone();
				}
			}
		}

		private void TrySpawnDrone()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			if (!base.body.master.IsDeployableLimited(wispDeployable))
			{
				spawnTimer = 1f;
				DirectorSpawnRequest val = new DirectorSpawnRequest((SpawnCard)(object)droneSpawnCard, placementRule, rng);
				val.summonerBodyObject = ((Component)this).gameObject;
				val.onSpawnedServer = OnSummonedSpawned;
				DirectorCore.instance.TrySpawnObject(val);
			}
		}

		private void OnSummonedSpawned(SpawnResult spawnResult)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			spawnTimer = 30f;
			GameObject spawnedInstance = spawnResult.spawnedInstance;
			if (!Object.op_Implicit((Object)(object)spawnedInstance))
			{
				return;
			}
			CharacterMaster component = spawnedInstance.GetComponent<CharacterMaster>();
			if (Object.op_Implicit((Object)(object)component))
			{
				summonedWispBody = component.GetBody();
				component.inventory.GiveItem(Items.Hoof, 3);
				component.inventory.GiveItem(Items.Syringe, 2);
				component.inventory.GiveItem(CustomItems.ItemWispName, 1);
				Deployable val = ((Component)component).GetComponent<Deployable>();
				if (!Object.op_Implicit((Object)(object)val))
				{
					val = ((Component)component).gameObject.AddComponent<Deployable>();
					val.onUndeploy = new UnityEvent();
					val.onUndeploy.AddListener(new UnityAction(component.TrueKill));
				}
				if (Object.op_Implicit((Object)(object)val))
				{
					base.body.master.AddDeployable(val, wispDeployable);
				}
			}
		}

		private void OnServerMasterSummonGlobal(MasterSummonReport summonReport)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)base.body) || !Object.op_Implicit((Object)(object)base.body.master) || !((Object)(object)base.body.master == (Object)(object)summonReport.leaderMasterInstance))
			{
				return;
			}
			CharacterMaster summonMasterInstance = summonReport.summonMasterInstance;
			if (Object.op_Implicit((Object)(object)summonMasterInstance))
			{
				CharacterBody body = summonMasterInstance.GetBody();
				if (Object.op_Implicit((Object)(object)body))
				{
					UpdateMinionInventory(body, summonMasterInstance.inventory, base.stack);
				}
			}
		}

		private void UpdateAllMinions(int newStack)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)base.body))
			{
				return;
			}
			CharacterBody body = base.body;
			if (!Object.op_Implicit((Object)(object)((body != null) ? body.master : null)))
			{
				return;
			}
			MinionGroup val = MinionGroup.FindGroup(((NetworkBehaviour)base.body.master).netId);
			if (val == null)
			{
				return;
			}
			MinionOwnership[] members = val.members;
			MinionOwnership[] array = members;
			foreach (MinionOwnership val2 in array)
			{
				if (!Object.op_Implicit((Object)(object)val2))
				{
					continue;
				}
				CharacterMaster component = ((Component)val2).GetComponent<CharacterMaster>();
				if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.inventory))
				{
					CharacterBody body2 = component.GetBody();
					if (Object.op_Implicit((Object)(object)body2))
					{
						UpdateMinionInventory(body2, component.inventory, newStack);
					}
				}
			}
			previousStack = newStack;
		}

		private void ResetMinionInventory(Inventory minionInventory)
		{
			minionInventory.ResetItem(CustomItems.ItemOrganicAllyBuff);
		}

		private void UpdateMinionInventory(CharacterBody minionBody, Inventory minionInventory, int newStack)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Invalid comparison between Unknown and I4
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Invalid comparison between Unknown and I4
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)minionInventory))
			{
				ResetMinionInventory(minionInventory);
				return;
			}
			if (newStack <= 0)
			{
				ResetMinionInventory(minionInventory);
				return;
			}
			BodyFlags bodyFlags = minionBody.bodyFlags;
			if ((bodyFlags & 2) > 0)
			{
				ResetMinionInventory(minionInventory);
				return;
			}
			int itemCount = minionInventory.GetItemCount(CustomItems.ItemOrganicAllyBuff);
			if (itemCount < base.stack)
			{
				int num = base.stack - itemCount;
				minionInventory.GiveItem(CustomItems.ItemOrganicAllyBuff, num);
			}
			else if (itemCount > base.stack)
			{
				int num2 = itemCount - base.stack;
				minionInventory.GiveItem(CustomItems.ItemOrganicAllyBuff, num2);
				Log.Info($"Buff stack: {minionInventory.GetItemCount(CustomItems.ItemOrganicAllyBuff)}");
			}
			if ((bodyFlags & 0x2000) <= 0 && !minionBody.isElite)
			{
				Random random = new Random();
				EquipmentDef val = POSSIBLE_ELITE_EQUIPMENTS[random.Next(0, POSSIBLE_ELITE_EQUIPMENTS.Length)];
				minionInventory.SetEquipmentIndex(val.equipmentIndex);
			}
		}
	}
	public class Hooks
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static StatHookEventHandler <0>__RecalculateStatsAPI_GetStatCoefficients;

			public static hook_GetBestBodyName <1>__Util_GetBestBodyName;
		}

		private const float EXTR_HEALTH_MULTIPLIER = 1.5f;

		private const float EXTR_DAMAGE_MULTIPLIER = 2f;

		internal static void Init()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			object obj = <>O.<0>__RecalculateStatsAPI_GetStatCoefficients;
			if (obj == null)
			{
				StatHookEventHandler val = RecalculateStatsAPI_GetStatCoefficients;
				<>O.<0>__RecalculateStatsAPI_GetStatCoefficients = val;
				obj = (object)val;
			}
			RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj;
			object obj2 = <>O.<1>__Util_GetBestBodyName;
			if (obj2 == null)
			{
				hook_GetBestBodyName val2 = Util_GetBestBodyName;
				<>O.<1>__Util_GetBestBodyName = val2;
				obj2 = (object)val2;
			}
			Util.GetBestBodyName += (hook_GetBestBodyName)obj2;
		}

		public static void RecalculateStatsAPI_GetStatCoefficients(CharacterBody sender, StatHookEventArgs args)
		{
			if (Object.op_Implicit((Object)(object)sender.inventory))
			{
				int itemCount = sender.inventory.GetItemCount(CustomItems.ItemOrganicAllyBuff);
				if (itemCount > 0)
				{
					args.healthMultAdd += 1.5f * (float)itemCount;
					args.damageMultAdd += 2f * (float)itemCount;
				}
			}
		}

		private static string Util_GetBestBodyName(orig_GetBestBodyName orig, GameObject bodyObject)
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			string result = orig.Invoke(bodyObject);
			CharacterBody val = null;
			if (Object.op_Implicit((Object)(object)bodyObject))
			{
				val = bodyObject.GetComponent<CharacterBody>();
			}
			if ((Object)(object)val != (Object)null)
			{
				int itemCount = val.inventory.GetItemCount(CustomItems.ItemWispName);
				if (itemCount <= 0)
				{
					return result;
				}
				string text = "Guardian Wisp";
				if (val.isElite)
				{
					BuffIndex[] eliteBuffIndices = BuffCatalog.eliteBuffIndices;
					BuffIndex[] array = eliteBuffIndices;
					foreach (BuffIndex val2 in array)
					{
						if (val.HasBuff(val2))
						{
							text = Language.GetStringFormatted(BuffCatalog.GetBuffDef(val2).eliteDef.modifierToken, new object[1] { text });
						}
					}
				}
				return text;
			}
			return result;
		}
	}
	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);
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("royal.GrowthNectarRework", "GrowthNectarRework", "1.0.0")]
	public class Main : BaseUnityPlugin
	{
		public const string PluginGUID = "royal.GrowthNectarRework";

		public const string PluginAuthor = "royal";

		public const string PluginName = "GrowthNectarRework";

		public const string PluginVersion = "1.0.0";

		public void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			CustomItems.Init();
			Hooks.Init();
		}
	}
	public class OrganicAllyBuff : ItemBehavior
	{
		private void Awake()
		{
			((Behaviour)this).enabled = false;
		}
	}
}