Decompiled source of TunnyMod v0.0.2

TunnyMod.dll

Decompiled a year 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.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using RoR2;
using UnityEngine;

[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("TunnyMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+55547a3010a5cd50216d8b61286fb858c61afaa6")]
[assembly: AssemblyProduct("TunnyMod")]
[assembly: AssemblyTitle("TunnyMod")]
[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 TunnyMod
{
	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("Tunny.TunnyMod", "TunnyMod", "0.0.1")]
	public class TunnyMod : BaseUnityPlugin
	{
		public const string PluginGUID = "Tunny.TunnyMod";

		public const string PluginAuthor = "Tunny";

		public const string PluginName = "TunnyMod";

		public const string PluginVersion = "0.0.1";

		public static BuffDef itemWeightBuff;

		public static ConfigEntry<bool> multipleScalingTypes { get; set; }

		public static ConfigEntry<int> earlyGameItemNum { get; set; }

		public static ConfigEntry<int> midGameItemNum { get; set; }

		public void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			multipleScalingTypes = ((BaseUnityPlugin)this).Config.Bind<bool>("Scaling", "multipleScalingTypes", true, "Whether scaling is changed depending on the stage of the game");
			earlyGameItemNum = ((BaseUnityPlugin)this).Config.Bind<int>("Scaling", "earlyGameItemNum", 7, "Number of items (per player) that encompasses early game scaling. Only used if multipleScalingTypes is true.");
			midGameItemNum = ((BaseUnityPlugin)this).Config.Bind<int>("Scaling", "midGameItemNum", 30, "Number of items (per player) that encompasses mid game scaling. Only used if multipleScalingTypes is true.");
		}

		private void OnEnable()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			CharacterBody.RecalculateStats += new hook_RecalculateStats(CharacterBody_RecalculateStats);
		}

		private void OnDisable()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			CharacterBody.RecalculateStats += new hook_RecalculateStats(CharacterBody_RecalculateStats);
		}

		private void AddContent()
		{
			ContentAddition.AddBuffDef(itemWeightBuff);
		}

		private void ItemWeightBuffSetup()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			itemWeightBuff = ScriptableObject.CreateInstance<BuffDef>();
			((Object)itemWeightBuff).name = "Item Weight Buff";
			itemWeightBuff.canStack = true;
			itemWeightBuff.isCooldown = false;
			itemWeightBuff.isDebuff = true;
			itemWeightBuff.buffColor = Color.white;
			itemWeightBuff.iconSprite = Resources.Load<Sprite>("textures/itemicons/texFeatherIcon");
		}

		private void CharacterBody_RecalculateStats(orig_RecalculateStats orig, CharacterBody self)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Invalid comparison between Unknown and I4
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Invalid comparison between Unknown and I4
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			if ((int)self.teamComponent.teamIndex != 1 || !self.isPlayerControlled)
			{
				return;
			}
			int num = 0;
			int num2 = 0;
			float num3 = 0f;
			float num4 = 0f;
			float num5 = 0f;
			for (int i = 0; i < self.GetBuffCount(itemWeightBuff); i++)
			{
				self.RemoveBuff(itemWeightBuff);
			}
			GenericStaticEnumerable<ItemIndex, AllItemsEnumerator> allItems = ItemCatalog.allItems;
			AllItemsEnumerator enumerator = allItems.GetEnumerator();
			try
			{
				while (((AllItemsEnumerator)(ref enumerator)).MoveNext())
				{
					ItemIndex current = ((AllItemsEnumerator)(ref enumerator)).Current;
					if (!ItemCatalog.GetItemDef(current).hidden && (int)ItemCatalog.GetItemDef(current).tier != 5)
					{
						num += Util.GetItemCountForTeam((TeamIndex)1, current, true, true);
						num2 += self.inventory.GetItemCount(current);
					}
				}
			}
			finally
			{
				((IDisposable)(AllItemsEnumerator)(ref enumerator)).Dispose();
			}
			num3 = (float)num / (float)PlayerCharacterMasterController.instances.Count;
			num4 = (float)num2 / num3 * 100f;
			num5 = ((!multipleScalingTypes.Value) ? ((float)Math.Min(Math.Max(-0.0001 * Math.Pow(num4 - 100f, 3.0) + 1.0, 0.25), 2.1)) : ((num <= 7 * PlayerCharacterMasterController.instances.Count) ? ((float)Math.Min(Math.Max((double)((float)num2 - num3) / -6.6666 + 1.0, 0.25), 2.1)) : ((num < 30 * PlayerCharacterMasterController.instances.Count) ? ((float)Math.Min(Math.Max(((float)num2 - num3) / -20f + 1f, 0.25), 2.1)) : ((float)Math.Min(Math.Max(-0.0001 * Math.Pow(num4 - 100f, 3.0) + 1.0, 0.25), 2.1)))));
			self.moveSpeed *= num5;
			for (int j = 0; (float)j < num5 * 10f; j++)
			{
				self.AddBuff(itemWeightBuff);
			}
		}
	}
}