Decompiled source of HiddenCards v0.0.2

plugins/HiddenCards.dll

Decompiled 10 months ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using HiddenCards;
using ModdingUtils.Utils;
using Photon.Pun;
using TMPro;
using UnboundLib;
using UnboundLib.GameModes;
using UnboundLib.Networking;
using UnboundLib.Utils.UI;
using UnityEngine;
using UnityEngine.Events;

[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("HiddenCards")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HiddenCards")]
[assembly: AssemblyTitle("HiddenCards")]
[assembly: AssemblyVersion("1.0.0.0")]
[HarmonyPatch(typeof(CardChoice))]
public class UniqueCardChoicePatch
{
	[HarmonyPatch("SpawnUniqueCard")]
	[HarmonyPostfix]
	public static void SpawnUniqueCard_Patch(ref GameObject __result, int ___pickrID, PickerType ___pickerType, Vector3 pos, Quaternion rot)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Invalid comparison between Unknown and I4
		if ((int)___pickerType == 0)
		{
			Player val = PlayerManager.instance.GetPlayersInTeam(___pickrID)[0];
		}
		else
		{
			Player val = PlayerManager.instance.players[___pickrID];
		}
		if (HC.tempEnable)
		{
			NetworkingManager.RPC(typeof(UniqueCardChoicePatch), "RPC_HideHiddenCards", new object[2]
			{
				__result.GetComponent<PhotonView>().ViewID,
				___pickrID
			});
		}
	}

	[UnboundRPC]
	public static void RPC_HideHiddenCards(int targetCardID, int pickID)
	{
		GameObject gameObject = ((Component)PhotonNetwork.GetPhotonView(targetCardID)).gameObject;
		Player val = PlayerManager.instance.players.Where((Player p) => p.data.view.IsMine).First();
		Player val2 = PlayerManager.instance.players.Where((Player p) => p.playerID == pickID).First();
		if (val.teamID != val2.teamID)
		{
			((Component)gameObject.transform.GetChild(0).GetChild(0).GetChild(0)).gameObject.SetActive(false);
			((Behaviour)((Component)gameObject.transform.GetChild(0).GetChild(0).GetChild(1)).GetComponent<CanvasGroup>()).enabled = false;
		}
	}
}
namespace HiddenCards;

[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.ancientkoala.rounds.hiddencards", "Hidden Cards", "0.0.2")]
[BepInProcess("Rounds.exe")]
public class HC : BaseUnityPlugin
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static UnityAction <>9__10_0;

		public static Func<Player, bool> <>9__11_0;

		internal void <Start>b__10_0()
		{
		}

		internal bool <Update>b__11_0(Player p)
		{
			return p.data.view.IsMine;
		}
	}

	private const string ModId = "com.ancientkoala.rounds.hiddencards";

	private const string ModName = "Hidden Cards";

	public const string Version = "0.0.2";

	public const string ModInitials = "HC";

	public static HC instance;

	private bool gameGoing = false;

	public static ConfigEntry<bool> hiddenOn;

	public static bool tempEnable = true;

	private void EnableCardsAction(bool val)
	{
		hiddenOn.Value = val;
	}

	private void NewGUI(GameObject menu)
	{
		MenuHandler.CreateToggle(hiddenOn.Value, "Hidden Mode", menu, (UnityAction<bool>)EnableCardsAction, 60, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
	}

	private void Start()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//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_003d: Expected O, but got Unknown
		Harmony val = new Harmony("com.ancientkoala.rounds.hiddencards");
		val.PatchAll();
		instance = this;
		object obj = <>c.<>9__10_0;
		if (obj == null)
		{
			UnityAction val2 = delegate
			{
			};
			<>c.<>9__10_0 = val2;
			obj = (object)val2;
		}
		Unbound.RegisterMenu("Hidden Cards", (UnityAction)obj, (Action<GameObject>)NewGUI, (GameObject)null);
		hiddenOn = ((BaseUnityPlugin)this).Config.Bind<bool>("HC", "enabled hidden", true, (ConfigDescription)null);
		GameModeManager.AddHook("GameStart", (Func<IGameModeHandler, IEnumerator>)GameStart);
		GameModeManager.AddHook("GameEnd", (Func<IGameModeHandler, IEnumerator>)GameEnd);
	}

	private void Update()
	{
		if (!tempEnable || !gameGoing)
		{
			return;
		}
		int teamID = PlayerManager.instance.players.Where((Player p) => p.data.view.IsMine).First().teamID;
		foreach (Player player in PlayerManager.instance.players)
		{
			if (player.teamID != teamID)
			{
				CardBarUtils.instance.PlayersCardBar(player.playerID).ClearBar();
			}
		}
	}

	private IEnumerator GameStart(IGameModeHandler gm)
	{
		gameGoing = true;
		if (PhotonNetwork.IsMasterClient)
		{
			tempEnable = hiddenOn.Value;
			NetworkingManager.RPC_Others(typeof(HC), "RPC_SyncSettings", new object[1] { hiddenOn.Value });
		}
		yield return null;
	}

	private IEnumerator GameEnd(IGameModeHandler gm)
	{
		gameGoing = false;
		yield return null;
	}

	[UnboundRPC]
	private static void RPC_SyncSettings(bool isEnabled)
	{
		tempEnable = isEnabled;
	}
}