Decompiled source of RandomTeams v2.0.2

random_teams.dll

Decompiled 4 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 BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using RWF;
using RWF.UI;
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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("random_teams")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3")]
[assembly: AssemblyProduct("Random Teams")]
[assembly: AssemblyTitle("random_teams")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.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 random_teams
{
	[BepInPlugin("random_teams", "Random Teams", "1.0.3")]
	public class RandomTeams : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(PrivateRoomCharacterSelectionInstance), "Update")]
		private class CharacterSelect_Update_Patch
		{
			private static void Postfix(ref PrivateRoomCharacterSelectionInstance __instance)
			{
				if ((Object)(object)PrivateRoomHandler.instance == (Object)null || PhotonNetwork.CurrentRoom == null || __instance.currentPlayer == null || !__instance.currentPlayer.IsMine || !PhotonNetwork.IsMasterClient)
				{
					return;
				}
				if (Input.GetKeyDown((KeyCode)49) || Input.GetKeyDown((KeyCode)50) || Input.GetKeyDown((KeyCode)51) || Input.GetKeyDown((KeyCode)52) || Input.GetKeyDown((KeyCode)53) || Input.GetKeyDown((KeyCode)54) || Input.GetKeyDown((KeyCode)55) || Input.GetKeyDown((KeyCode)56) || Input.GetKeyDown((KeyCode)57))
				{
					LobbyCharacter[] array = (from p in (from p in PhotonNetwork.CurrentRoom.Players.Values.ToList()
							select PhotonPlayerExtensions.GetProperty<LobbyCharacter[]>(p, "players")).SelectMany((LobbyCharacter[] p) => p)
						where p != null
						select p).ToArray();
					int num = 2;
					if (Input.GetKeyDown((KeyCode)49))
					{
						num = 1;
					}
					else if (Input.GetKeyDown((KeyCode)50))
					{
						num = 2;
					}
					else if (Input.GetKeyDown((KeyCode)51))
					{
						num = 3;
					}
					else if (Input.GetKeyDown((KeyCode)52))
					{
						num = 4;
					}
					else if (Input.GetKeyDown((KeyCode)53))
					{
						num = 5;
					}
					else if (Input.GetKeyDown((KeyCode)54))
					{
						num = 6;
					}
					else if (Input.GetKeyDown((KeyCode)55))
					{
						num = 7;
					}
					else if (Input.GetKeyDown((KeyCode)56))
					{
						num = 8;
					}
					else if (Input.GetKeyDown((KeyCode)57))
					{
						num = 9;
					}
					int num2 = -1;
					int num3 = 0;
					List<int> list = new List<int>(Enumerable.Range(0, RWFMod.MaxColorsHardLimit));
					list.Shuffle();
					array.Shuffle();
					LobbyCharacter[] array2 = array;
					foreach (LobbyCharacter val in array2)
					{
						num2++;
						if (num2 == num)
						{
							num2 = 0;
							num3++;
							if (num3 == RWFMod.MaxColorsHardLimit)
							{
								num3 = 0;
							}
						}
						__instance.SendRPC_ChangeIDToTeam(val.uniqueID, list[num3]);
					}
				}
				else if (Input.GetKeyDown((KeyCode)48))
				{
					LobbyCharacter[] array3 = (from p in (from p in PhotonNetwork.CurrentRoom.Players.Values.ToList()
							select PhotonPlayerExtensions.GetProperty<LobbyCharacter[]>(p, "players")).SelectMany((LobbyCharacter[] p) => p)
						where p != null
						select p).ToArray();
					LobbyCharacter[] array4 = array3;
					foreach (LobbyCharacter val2 in array4)
					{
						int colorID = Random.RandomRangeInt(0, RWFMod.MaxColorsHardLimit);
						__instance.SendRPC_ChangeIDToTeam(val2.uniqueID, colorID);
					}
				}
			}
		}

		internal static ManualLogSource Logger;

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Harmony val = new Harmony("ShadeSlayer.RandomTeams.Patch");
			val.PatchAll();
		}
	}
	public static class PrivateRoomCharacterSelectionInstance_Extensions
	{
		public static void SendRPC_ChangeIDToTeam(this PrivateRoomCharacterSelectionInstance instance, int uniqueID, int colorID)
		{
			LobbyCharacter val = PrivateRoomHandler.instance.FindLobbyCharacter(uniqueID);
			PhotonView component = PrivateRoomHandler.instance.versusDisplay.PlayerSelectorGO(val.uniqueID).GetComponent<PhotonView>();
			component.RPC("RPCA_ChangeTeam", (RpcTarget)0, new object[1] { colorID });
		}
	}
	public static class ListExtension
	{
		public static void Shuffle<T>(this IList<T> list)
		{
			int count = list.Count;
			int num = count - 1;
			for (int i = 0; i < num; i++)
			{
				int index = Random.Range(i, count);
				T value = list[i];
				list[i] = list[index];
				list[index] = value;
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "random_teams";

		public const string PLUGIN_NAME = "Random Teams";

		public const string PLUGIN_VERSION = "1.0.3";
	}
}