Decompiled source of DefaultSize v1.0.0

DefaultSize.DLL

Decompiled 5 months ago
using System;
using System.Diagnostics;
using System.Globalization;
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 BoplFixedMath;
using HarmonyLib;
using Steamworks.Data;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("DefaultSize")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Change the size all blobs start from each round!")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DefaultSize")]
[assembly: AssemblyTitle("DefaultSize")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace DefaultSize;

[BepInPlugin("me.antimality.DefaultSize", "DefaultSize", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	internal static ManualLogSource Log;

	private static Harmony harmony;

	internal static ConfigFile config;

	internal static ConfigEntry<float> defaultSizeSetting;

	private void Awake()
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		config = ((BaseUnityPlugin)this).Config;
		Log.LogInfo((object)"Plugin DefaultSize is loaded!");
		harmony = new Harmony("me.antimality.DefaultSize");
		defaultSizeSetting = config.Bind<float>("Settings", "Default player size", 3f, "Minimum is 0.01 (Lower would cap to minimum). The default game's max scale is 3.");
		if (defaultSizeSetting.Value < 0.01f)
		{
			defaultSizeSetting.Value = 0.01f;
			config.Save();
		}
		harmony.PatchAll(typeof(Patch));
	}

	private void OnDestroy()
	{
		harmony.UnpatchSelf();
	}
}
[HarmonyPatch]
public class Patch
{
	private static Fix defaultSize;

	[HarmonyPatch(typeof(GameSessionHandler), "SpawnPlayers")]
	[HarmonyPostfix]
	public static void ChangePlayerSize()
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		foreach (Player item in PlayerHandler.Get().PlayerList())
		{
			item.Scale = defaultSize;
		}
	}

	[HarmonyPatch(typeof(GameSession), "Init")]
	[HarmonyPostfix]
	public static void OnGameStart()
	{
		//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_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		if (GameLobby.isOnlineGame)
		{
			try
			{
				defaultSize = (Fix)float.Parse(((Lobby)(ref SteamManager.instance.currentLobby)).GetData("DefaultSize"), CultureInfo.InvariantCulture);
				return;
			}
			catch (FormatException)
			{
				defaultSize = Fix.One;
				Plugin.Log.LogError((object)"Host doesn't have DefaultSize mod. Disabling functionality.");
				return;
			}
		}
		defaultSize = (Fix)Plugin.defaultSizeSetting.Value;
	}

	[HarmonyPatch(typeof(SteamManager), "OnLobbyEnteredCallback")]
	[HarmonyPostfix]
	public static void OnEnterLobby(Lobby lobby)
	{
		if (SteamManager.LocalPlayerIsLobbyOwner)
		{
			((Lobby)(ref lobby)).SetData("DefaultSize", Plugin.defaultSizeSetting.Value.ToString());
		}
	}
}
public static class PluginInfo
{
	public const string PLUGIN_GUID = "DefaultSize";

	public const string PLUGIN_NAME = "DefaultSize";

	public const string PLUGIN_VERSION = "1.0.0";
}