Decompiled source of Arena Balance v1.0.2

EmpressFairArena.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EmpressFairArena")]
[assembly: AssemblyTitle("EmpressFairArena")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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 ArenaBalanceMod
{
	[BepInPlugin("com.Empress.ArenaBalance", "Arena Balance", "1.0.0")]
	public class ArenaBalancePlugin : BaseUnityPlugin
	{
		private void Awake()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			new Harmony("com.Empress.ArenaBalance").PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Arena Balance Mod loaded safely.");
		}
	}
	[HarmonyPatch(typeof(Arena), "ArenaInitMultiplayer")]
	public static class ArenaInitPatch
	{
		[HarmonyPrefix]
		public static void Prefix(Arena __instance)
		{
			Debug.Log((object)"ArenaBalance: Modifying Arena Lists...");
			List<Item> source = Resources.FindObjectsOfTypeAll<Item>().ToList();
			List<Item> list = source.Where((Item item) => !item.disabled && (((Object)item).name.ToLower().Contains("valuable") || item.itemName.ToLower().Contains("valuable"))).ToList();
			Debug.Log((object)$"ArenaBalance: Found {list.Count} valuables to inject.");
			__instance.itemsMelee.RemoveAll((Item item) => item.itemName.ToLower().Contains("bat") || item.itemName.ToLower().Contains("sledge") || ((Object)item).name.ToLower().Contains("bat") || ((Object)item).name.ToLower().Contains("sledge"));
			if (list.Count > 0)
			{
				__instance.itemsMelee.AddRange(list);
			}
			while (__instance.itemsMelee.Count < 5 && __instance.itemsMelee.Count > 0)
			{
				__instance.itemsMelee.Add(__instance.itemsMelee[Random.Range(0, __instance.itemsMelee.Count)]);
			}
			__instance.itemsGuns.RemoveAll((Item item) => item.itemName.ToLower().Contains("gun") || item.itemName.ToLower().Contains("shotgun") || item.itemName.ToLower().Contains("rifle") || ((Object)item).name.ToLower().Contains("gun") || ((Object)item).name.ToLower().Contains("shotgun"));
			if (list.Count > 0)
			{
				__instance.itemsGuns.AddRange(list);
			}
			if (__instance.itemsGuns.Count < 3)
			{
				__instance.itemsGuns.AddRange(__instance.itemsMelee);
			}
			while (__instance.itemsGuns.Count < 3 && __instance.itemsGuns.Count > 0)
			{
				__instance.itemsGuns.Add(__instance.itemsGuns[Random.Range(0, __instance.itemsGuns.Count)]);
			}
			Debug.Log((object)"ArenaBalance: OP items removed and Valuables injected.");
		}
	}
}