Decompiled source of All In This Together v1.1.0

Mods/AllInThisTogether.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using AllInThisTogether;
using HarmonyLib;
using MelonLoader;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Class1), "All In This Together", "1.1", "TheMrEvil", null)]
[assembly: MelonGame("Alvios", "Vellum")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("AllInThisTogether")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+544948081db6e1830f328dcfd1726651c3bb6b50")]
[assembly: AssemblyProduct("AllInThisTogether")]
[assembly: AssemblyTitle("AllInThisTogether")]
[assembly: AssemblyVersion("1.0.0.0")]
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 AllInThisTogether
{
	public class Class1 : MelonMod
	{
		[HarmonyPatch(typeof(NetworkManager), "CreateNewGame")]
		private static class CreateNewGamePatch
		{
			private static void Prefix(ref RoomOptions options)
			{
				if (options != null)
				{
					int maxPlayers = options.MaxPlayers;
					options.MaxPlayers = UNLIMITED_PLAYERS;
					MelonLogger.Msg($"Player cap modified: {maxPlayers} -> {options.MaxPlayers}");
				}
			}
		}

		[HarmonyPatch(typeof(NetworkManager), "TryJoinRoom")]
		private static class TryJoinRoomPatch
		{
			private static void Prefix(string code)
			{
				MelonLogger.Msg("Attempting to join room: " + code + " (unlimited players mod active)");
			}
		}

		[HarmonyPatch(typeof(MainPanel), "CreatePublicRoom")]
		private static class CreatePublicRoomPatch
		{
			private static bool Prefix(MainPanel __instance)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Expected O, but got Unknown
				RoomOptions val = new RoomOptions();
				val.MaxPlayers = UNLIMITED_PLAYERS;
				val.IsVisible = true;
				NetworkManager.instance.CreateNewGame(val);
				try
				{
					Type typeFromHandle = typeof(AudioManager);
					MethodInfo method = typeFromHandle.GetMethod("PlayInterfaceSFX", new Type[3]
					{
						typeof(AudioClip),
						typeof(float),
						typeof(float)
					});
					FieldInfo field = typeof(MainPanel).GetField("StartSFX", BindingFlags.Instance | BindingFlags.NonPublic);
					if (field != null && method != null)
					{
						object value = field.GetValue(__instance);
						if (value != null)
						{
							method.Invoke(null, new object[3] { value, 1f, 0f });
						}
					}
				}
				catch (Exception ex)
				{
					MelonLogger.Warning("Could not play start SFX: " + ex.Message);
				}
				MelonLogger.Msg("Created public room with unlimited players!");
				return false;
			}
		}

		[HarmonyPatch(typeof(MainPanel), "CreatePrivateRoom")]
		private static class CreatePrivateRoomPatch
		{
			private static bool Prefix(MainPanel __instance)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Expected O, but got Unknown
				RoomOptions val = new RoomOptions();
				val.MaxPlayers = UNLIMITED_PLAYERS;
				val.IsVisible = false;
				NetworkManager.instance.CreateNewGame(val);
				MelonLogger.Msg("Created private room with unlimited players!");
				return false;
			}
		}

		[HarmonyPatch(typeof(MainPanel), "CreateOrJoinRandom")]
		private static class CreateOrJoinRandomPatch
		{
			private static void Postfix()
			{
				MelonLogger.Msg("CreateOrJoinRandom called - unlimited players mod active");
			}
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static class InkMultiplierPatch
		{
			private static bool Prefix(ref int __result)
			{
				int num = 4;
				if (PhotonNetwork.InRoom)
				{
					num = PhotonNetwork.CurrentRoom.PlayerCount switch
					{
						1 => 4, 
						2 => 2, 
						3 => 1, 
						4 => 1, 
						_ => 1, 
					};
				}
				__result = num;
				return false;
			}
		}

		private static readonly int UNLIMITED_PLAYERS = 250;

		public override void OnInitializeMelon()
		{
			((MelonBase)this).LoggerInstance.Msg("All In This Together mod loaded!");
			((MelonBase)this).LoggerInstance.Msg("Player cap upped to 250");
			((MelonBase)this).LoggerInstance.Msg("Font point system modified - 5+ players now get 1 font point each");
		}
	}
}