Decompiled source of RiskOfTraitors v2.0.1

RiskOfTraitors.dll

Decompiled a year ago
using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API.Networking;
using R2API.Networking.Interfaces;
using R2API.Utils;
using RoR2;
using RoR2.Networking;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;

[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("RiskOfTraitors")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RiskOfTraitors")]
[assembly: AssemblyTitle("RiskOfTraitors")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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 RiskOfTraitors
{
	public class AverageItems : MonoBehaviour
	{
		public void RedistributeItems()
		{
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Invalid comparison between Unknown and I4
			//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Expected I4, but got Unknown
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			Log.Info("Started RedistributeItems");
			int count = PlayerCharacterMasterController._instancesReadOnly.Count;
			int[] array = new int[count];
			int num = 0;
			int num2 = 0;
			int itemsBelowAverage = RiskOfTraitors.itemsBelowAverage;
			int itemsAboveAverage = RiskOfTraitors.itemsAboveAverage;
			bool enableItemAveraging = RiskOfTraitors.enableItemAveraging;
			bool removeLunarItems = RiskOfTraitors.removeLunarItems;
			Log.Info($"Player Count is: {count}");
			for (int i = 0; i < count; i++)
			{
				if ((Object)(object)PlayerCharacterMasterController._instancesReadOnly[i].master != (Object)null)
				{
					array[i] += PlayerCharacterMasterController._instancesReadOnly[i].master.inventory.GetTotalItemCountOfTier((ItemTier)0);
					array[i] += PlayerCharacterMasterController._instancesReadOnly[i].master.inventory.GetTotalItemCountOfTier((ItemTier)1);
					array[i] += PlayerCharacterMasterController._instancesReadOnly[i].master.inventory.GetTotalItemCountOfTier((ItemTier)2);
					array[i] += PlayerCharacterMasterController._instancesReadOnly[i].master.inventory.GetTotalItemCountOfTier((ItemTier)3);
					array[i] += PlayerCharacterMasterController._instancesReadOnly[i].master.inventory.GetTotalItemCountOfTier((ItemTier)4);
					array[i] += PlayerCharacterMasterController._instancesReadOnly[i].master.inventory.GetTotalItemCountOfTier((ItemTier)6);
					array[i] += PlayerCharacterMasterController._instancesReadOnly[i].master.inventory.GetTotalItemCountOfTier((ItemTier)7);
					array[i] += PlayerCharacterMasterController._instancesReadOnly[i].master.inventory.GetTotalItemCountOfTier((ItemTier)8);
					array[i] += PlayerCharacterMasterController._instancesReadOnly[i].master.inventory.GetTotalItemCountOfTier((ItemTier)9);
					num += array[i];
					Log.Info($"playerItemCount {i}: {array[i]}");
				}
				else
				{
					Log.Warning($"Player body at index {i} was null");
				}
			}
			num2 = num / count;
			Log.Info($"totalItemCount: {num}");
			Log.Info($"averageItemCount: {num2}");
			for (int j = 0; j < count; j++)
			{
				int totalItemCountOfTier = PlayerCharacterMasterController._instancesReadOnly[j].master.inventory.GetTotalItemCountOfTier((ItemTier)3);
				if (totalItemCountOfTier > 0 && removeLunarItems)
				{
					int num3 = 0;
					ItemIndex[] array2 = (ItemIndex[])(object)new ItemIndex[totalItemCountOfTier];
					foreach (ItemIndex item in PlayerCharacterMasterController.instances[j].master.inventory.itemAcquisitionOrder)
					{
						ItemDef itemDef = ItemCatalog.GetItemDef(item);
						if ((int)itemDef.tier == 3)
						{
							array2[num3] = (ItemIndex)(int)item;
							num3++;
							Log.Info($"Lunar item index {item} found in inventory of {PlayerCharacterMasterController.instances[j].GetDisplayName()}");
						}
					}
					for (int k = 0; k < totalItemCountOfTier; k++)
					{
						PlayerCharacterMasterController.instances[j].master.inventory.RemoveItem(array2[k], 1);
						Log.Info($"Successfully removed lunar item index: {array2[k]}");
					}
				}
				while (array[j] < num2 - itemsBelowAverage && enableItemAveraging)
				{
					Log.Info($"Giving item to player at index {j}");
					PlayerCharacterMasterController.instances[j].master.inventory.GiveRandomItems(1, false, false);
					array[j]++;
					Log.Info($"Player {j} new item count: {array[j]}");
				}
				while (array[j] > num2 + itemsAboveAverage && enableItemAveraging)
				{
					int num4 = Random.Range(0, PlayerCharacterMasterController.instances[j].master.inventory.itemAcquisitionOrder.Count);
					Log.Info($"Remove item index {num4} from player {PlayerCharacterMasterController.instances[j].GetDisplayName()}");
					PlayerCharacterMasterController.instances[j].master.inventory.RemoveItem(PlayerCharacterMasterController.instances[j].master.inventory.itemAcquisitionOrder[num4], 1);
					array[j]--;
				}
			}
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[R2APISubmoduleDependency(new string[] { "CommandHelper" })]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("MeatyJesus.RiskOfTraitors", "RiskOfTraitors", "2.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class RiskOfTraitors : BaseUnityPlugin
	{
		public const string PluginGUID = "MeatyJesus.RiskOfTraitors";

		public const string PluginAuthor = "MeatyJesus";

		public const string PluginName = "RiskOfTraitors";

		public const string PluginVersion = "2.0.0";

		public TeamComponent team;

		public TeleporterInteraction teleport;

		public CustomGUI score = null;

		public RoleDisplayUI roleDisplay = null;

		public SyncScoreString sync;

		public SyncTraitorTeam syncTraitor;

		public AverageItems averageItems;

		public static bool canDamageSelf = false;

		public static int itemsBelowAverage = 1;

		public static int itemsAboveAverage = 1;

		public static bool enableItemAveraging = true;

		public static bool removeLunarItems = false;

		public int playerCount;

		public int deadInnoCount;

		public int deadTraitorCount;

		public bool innocentWin = false;

		public bool traitorWin = false;

		public bool newGameStart = true;

		public bool wonByEliminatingAllTraitors = false;

		public bool sentInnoWinMessageAlready = false;

		public bool skippingRound = false;

		public int[] winsAsTraitor;

		public int[] winsAsInnocent;

		public int[] killsOnTraitors;

		public int[] killsOnInnocents;

		public int[] teamKills;

		public int[] randomNum;

		public static int maxRounds = 5;

		public int roundsPlayed = 0;

		public static int numTraitors = 1;

		public static int oldPlayerDamageMul = 0;

		public static int playerOutgoingDamageMul = 0;

		public static int oldEnemyDamageMul = 0;

		public static int enemyOutgoingDamageMul = 0;

		public static bool updatePlayerDamageMul = false;

		public static bool updateMonsterDamageMul = false;

		public const string imposterText = "<color=red>TRAITOR:</color> Eliminate all Innocent players to win.";

		public const string innoText = "<color=green>INNOCENT:</color> Escape via the teleporter to win, or eliminate all Traitors.";

		public static string scoreDataFromServer = "";

		public static string syncedScore = "Default Synced Score";

		public static string traitorTeamNames = "";

		public void Awake()
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			CommandHelper.AddToConsoleWhenReady();
			NetworkingAPI.RegisterMessageType<SyncScoreString>();
			NetworkingAPI.RegisterMessageType<SyncTraitorTeam>();
			GlobalEventManager.onCharacterDeathGlobal += GlobalEventManager_onCharacterDeathGlobal;
			Stage.onServerStageBegin += Stage_onServerStageBegin;
			Run.onServerGameOver += Run_onServerGameOver;
			CharacterBody.onBodyStartGlobal += BodyStartGlobal;
			HealthComponent.TakeDamage += new hook_TakeDamage(HealthComponent_TakeDamage);
			Run.onRunStartGlobal += Run_onRunStartGlobal;
			TeamComponent.onJoinTeamGlobal += TeamComponent_onJoinTeamGlobal;
			TeleporterInteraction.Start += new hook_Start(TeleporterInteraction_Start);
			Run.CCRunEnd += new hook_CCRunEnd(Run_CCRunEnd);
			Log.Info("Awake DONE LOADING RISK OF TRAITORS.");
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void ToggleLunarRemoval(ConCommandArgs args)
		{
			removeLunarItems = !removeLunarItems;
			ChatMessage.Send("<color=blue>Lunar item removal after each stage set to: <color=green>" + removeLunarItems + "</color></color>");
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void ToggleSelfDamage(ConCommandArgs args)
		{
			canDamageSelf = !canDamageSelf;
			ChatMessage.Send("<color=yellow>Self damage set to: <color=green>" + canDamageSelf + "</color></color>");
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void MaxRounds(ConCommandArgs args)
		{
			maxRounds = ((ConCommandArgs)(ref args)).GetArgInt(0);
			if (maxRounds < 1)
			{
				maxRounds = 1;
			}
			Log.Info($"Max rounds set to: {maxRounds}");
			ChatMessage.Send("<color=yellow>Max rounds set to: <color=green>" + maxRounds + "</color></color>");
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void PlayerDamage(ConCommandArgs args)
		{
			playerOutgoingDamageMul = ((ConCommandArgs)(ref args)).GetArgInt(0);
			if (playerOutgoingDamageMul < -99)
			{
				playerOutgoingDamageMul = -99;
			}
			Log.Info($"Player damage set to: {100f + (float)(100 * playerOutgoingDamageMul) * 0.01f}%");
			ChatMessage.Send("<color=yellow>Player damage set to: <color=green>" + (100f + (float)(100 * playerOutgoingDamageMul) * 0.01f) + "%</color></color>");
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void MonsterDamage(ConCommandArgs args)
		{
			enemyOutgoingDamageMul = ((ConCommandArgs)(ref args)).GetArgInt(0);
			if (enemyOutgoingDamageMul < -99)
			{
				enemyOutgoingDamageMul = -99;
			}
			Log.Info($"Enemy damage set to: {100f + (float)(100 * enemyOutgoingDamageMul) * 0.01f}%");
			ChatMessage.Send("<color=yellow>Enemy damage set to: <color=green>" + (100f + (float)(100 * enemyOutgoingDamageMul) * 0.01f) + "%</color></color>");
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void TraitorCount(ConCommandArgs args)
		{
			numTraitors = ((ConCommandArgs)(ref args)).GetArgInt(0);
			if (numTraitors <= 0)
			{
				numTraitors = 0;
			}
			ChatMessage.Send("<color=yellow>Next stage traitor count set to: <color=red>" + numTraitors + "</color></color>");
			Log.Info($"Traitor count set to: {numTraitors}");
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void AverageItemRange(ConCommandArgs args)
		{
			enableItemAveraging = ((ConCommandArgs)(ref args)).GetArgBool(0);
			itemsBelowAverage = ((ConCommandArgs)(ref args)).GetArgInt(1);
			itemsAboveAverage = ((ConCommandArgs)(ref args)).GetArgInt(2);
			if (enableItemAveraging)
			{
				ChatMessage.Send("<color=yellow>Min items below average set to: <color=green>" + itemsBelowAverage + "</color>, Max items above average set to: <color=green>" + itemsAboveAverage + "</color></color>");
				Log.Info($"Min items below average: {itemsBelowAverage}, Max items above average: {itemsAboveAverage}");
			}
			else
			{
				ChatMessage.Send("Item averaging each stage has been <color=red>disabled.</color>");
				Log.Info("Item averaging each stage has been disabled.");
			}
		}

		private void Run_onRunStartGlobal(Run obj)
		{
			roundsPlayed = 0;
			innocentWin = false;
			traitorWin = false;
			newGameStart = true;
		}

		private void HealthComponent_TakeDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((int)damageInfo.damageType != 1075905024)
				{
					CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
					if (((NetworkBehaviour)component).netId == ((NetworkBehaviour)self.body).netId && !canDamageSelf)
					{
						damageInfo.damage = 0f;
					}
				}
				else
				{
					Log.Info($"Damage type was {damageInfo.damageType}, skipping.");
				}
				orig.Invoke(self, damageInfo);
			}
			catch
			{
				orig.Invoke(self, damageInfo);
				Log.Info("Skipping damage check.");
			}
		}

		private void BodyStartGlobal(CharacterBody body)
		{
			if (body.isPlayerControlled)
			{
				float baseDamage = body.baseDamage;
				body.baseDamage *= 1f + (float)playerOutgoingDamageMul * 0.01f;
				Log.Info($"Player spawned with basedamage of {body.baseDamage} from old {baseDamage}");
			}
			else
			{
				body.baseDamage *= 1f + (float)enemyOutgoingDamageMul * 0.01f;
			}
		}

		private void Run_CCRunEnd(orig_CCRunEnd orig, ConCommandArgs args)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(args);
			roundsPlayed = 0;
			innocentWin = false;
			traitorWin = false;
			newGameStart = true;
		}

		private void TeleporterInteraction_Start(orig_Start orig, TeleporterInteraction self)
		{
			orig.Invoke(self);
			teleport = self;
			Log.Info("Teleporter has been initialized.");
			if (NetworkServer.active)
			{
				NetMessageExtensions.Send((INetMessage)(object)new SyncScoreString(scoreDataFromServer), (NetworkDestination)1);
				syncedScore = scoreDataFromServer;
				ChatMessage.Send("<color=#A040C0>Round <color=yellow>" + (roundsPlayed + 1) + "/" + maxRounds + "</color></color>");
			}
			score = new CustomGUI();
			score.Init();
			roleDisplay = new RoleDisplayUI();
			roleDisplay.Init();
		}

		private void TeamComponent_onJoinTeamGlobal(TeamComponent teamcomp, TeamIndex index)
		{
			team = teamcomp;
			teamcomp.hideAllyCardDisplay = true;
		}

		private void Run_onServerGameOver(Run run, GameEndingDef gameEnd)
		{
			roundsPlayed = 0;
			innocentWin = false;
			traitorWin = false;
			newGameStart = true;
		}

		public NetworkConnection GetNetworkConnectionFromPlayerControllerIndex(int index)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			PlayerCharacterMasterController val = PlayerCharacterMasterController.instances[index];
			for (int i = 0; i < NetworkServer.connections.Count; i++)
			{
				NetworkConnection val2 = NetworkServer.connections[i];
				if (val2.clientOwnedObjects.Contains(val.networkUserInstanceId))
				{
					Log.Info($"Match found in conn: {val2.clientOwnedObjects} for {val.networkUserInstanceId}");
					return val2;
				}
				Log.Warning($"No match found in conn: {val2.clientOwnedObjects} for {val.networkUserInstanceId}");
			}
			ChatMessage.Send("<color=orange>An error may have occurred. If you notice any gamebreaking bugs, have the host relaunch their game.</color>");
			return NetworkServer.connections[0];
		}

		private void SendMessageFromStringAndIndex(string message, int index)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			SimpleChatMessage val = new SimpleChatMessage();
			val.baseToken = "{0}";
			val.paramTokens = new string[1] { message };
			NetworkWriter val2 = new NetworkWriter();
			val2.StartMessage((short)59);
			val2.Write(((ChatMessageBase)val).GetTypeIndex());
			val2.Write((MessageBase)(object)val);
			val2.FinishMessage();
			GetNetworkConnectionFromPlayerControllerIndex(index).SendWriter(val2, QosChannelIndex.chat.intVal);
		}

		private int FindPlayerIndexFromBodyInstanceID(NetworkInstanceId playerBodyId)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < playerCount; i++)
			{
				NetworkUser val = NetworkUser.readOnlyInstancesList[i];
				if (val.master.bodyInstanceId == playerBodyId)
				{
					return i;
				}
			}
			return 0;
		}

		private void GlobalEventManager_onCharacterDeathGlobal(DamageReport report)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			int count = PlayerCharacterMasterController.instances.Count;
			bool flag = true;
			bool flag2 = true;
			int num = -1;
			int num2 = -1;
			for (int i = 0; i < count; i++)
			{
				_ = report.victimMaster.bodyInstanceId;
				if (report.victimMaster.bodyInstanceId == PlayerCharacterMasterController.instances[i].master.bodyInstanceId)
				{
					num = FindPlayerIndexFromBodyInstanceID(report.victimMaster.bodyInstanceId);
				}
				_ = report.attackerMaster.bodyInstanceId;
				if (report.attackerMaster.bodyInstanceId == PlayerCharacterMasterController.instances[i].master.bodyInstanceId)
				{
					num2 = FindPlayerIndexFromBodyInstanceID(report.attackerMaster.bodyInstanceId);
				}
			}
			string text = "Player <color=red>";
			string text2 = "Player <color=green>";
			if (num != -1)
			{
				text = text + PlayerCharacterMasterController.instances[num].GetDisplayName() + "</color> was a <color=red>Traitor!</color>";
				text2 = text2 + PlayerCharacterMasterController.instances[num].GetDisplayName() + "</color> was a <color=green>Innocent!</color>";
			}
			if (!report.victimMaster.IsDeadAndOutOfLivesServer() || num == -1 || traitorWin || innocentWin)
			{
				return;
			}
			for (int j = 0; j < randomNum.Length; j++)
			{
				NetworkUser val = NetworkUser.readOnlyInstancesList[randomNum[j]];
				if (!(report.victimMaster.bodyInstanceId == val.master.bodyInstanceId))
				{
					continue;
				}
				if (num2 != -1)
				{
					for (int k = 0; k < randomNum.Length; k++)
					{
						NetworkUser val2 = NetworkUser.readOnlyInstancesList[randomNum[k]];
						if (val2.master.bodyInstanceId == report.attackerMaster.bodyInstanceId)
						{
							flag2 = false;
							teamKills[num2]++;
							text = "<color=orange>(TEAMKILL)</color> " + text;
						}
					}
					if (flag2)
					{
						killsOnTraitors[num2]++;
					}
					SendMessageFromStringAndIndex(text, num2);
				}
				deadTraitorCount++;
				flag = false;
				if (deadTraitorCount >= randomNum.Length && !traitorWin)
				{
					DoInnocentWin();
				}
			}
			if (!flag)
			{
				return;
			}
			if (num2 != -1)
			{
				for (int l = 0; l < randomNum.Length; l++)
				{
					NetworkUser val3 = NetworkUser.readOnlyInstancesList[randomNum[l]];
					if (val3.master.bodyInstanceId == report.attackerMaster.bodyInstanceId)
					{
						killsOnInnocents[num2]++;
						flag2 = false;
					}
				}
				if (flag2)
				{
					teamKills[num2]++;
					text2 = "<color=orange>(TEAMKILL)</color> " + text2;
				}
				SendMessageFromStringAndIndex(text2, num2);
			}
			deadInnoCount++;
			if (deadInnoCount >= count - randomNum.Length && !innocentWin)
			{
				DoTraitorWin();
			}
		}

		public void DoTraitorWin()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			string text = "<color=red>Traitor team wins!</color> Traitors: <color=red>";
			for (int i = 0; i < randomNum.Length; i++)
			{
				NetworkUser val = NetworkUser.readOnlyInstancesList[randomNum[i]];
				text = text + val.masterController.GetDisplayName() + " ";
				winsAsTraitor[FindPlayerIndexFromBodyInstanceID(val.masterController.master.bodyInstanceId)]++;
			}
			text += "</color>";
			ChatMessage.Send(text);
			innocentWin = false;
			traitorWin = true;
			EndRoundWarpToNextStage();
		}

		public void DoInnocentWin()
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			innocentWin = true;
			traitorWin = false;
			wonByEliminatingAllTraitors = true;
			string text = "<color=green>Innocents win!</color> Traitors: <color=red>";
			for (int i = 0; i < randomNum.Length; i++)
			{
				NetworkUser val = NetworkUser.readOnlyInstancesList[randomNum[i]];
				text = text + val.masterController.GetDisplayName() + " ";
			}
			bool flag = true;
			for (int j = 0; j < playerCount; j++)
			{
				ReadOnlyCollection<NetworkUser> readOnlyInstancesList = NetworkUser.readOnlyInstancesList;
				for (int k = 0; k < randomNum.Length; k++)
				{
					if (readOnlyInstancesList[j].masterController.networkUserInstanceId == readOnlyInstancesList[randomNum[k]].masterController.networkUserInstanceId)
					{
						flag = false;
					}
				}
				if (flag)
				{
					winsAsInnocent[j]++;
				}
				flag = true;
			}
			text += "</color>";
			ChatMessage.Send(text);
			EndRoundWarpToNextStage();
		}

		public void EndRoundWarpToNextStage()
		{
			SceneDef sceneDef = SceneCatalog.GetSceneDef((SceneIndex)7);
			string baseSceneName = Run.instance.nextStageScene.baseSceneName;
			Log.Info("Next Stage Basename: " + baseSceneName);
			if (roundsPlayed >= maxRounds - 1)
			{
				ChatMessage.Send("Round limit of " + maxRounds + " reached. Game Over!");
				NetMessageExtensions.Send((INetMessage)(object)new SyncScoreString(scoreDataFromServer), (NetworkDestination)1);
				syncedScore = scoreDataFromServer;
				score = new CustomGUI();
				score.Init();
				Run.instance.BeginGameOver(GameEndingCatalog.gameEndingDefs[3]);
				return;
			}
			if (baseSceneName.Equals("moon2") || baseSceneName.Equals("golemplains") || baseSceneName.Equals("golemplains2") || baseSceneName.Equals("blackbeach") || baseSceneName.Equals("blackbeach2") || baseSceneName.Equals("snowyforest"))
			{
				Log.Info("I just pissed on the moon");
				switch (Random.Range(0, 4))
				{
				case 0:
					sceneDef = SceneCatalog.GetSceneDef((SceneIndex)7);
					break;
				case 1:
					sceneDef = SceneCatalog.GetSceneDef((SceneIndex)8);
					break;
				case 2:
					sceneDef = SceneCatalog.GetSceneDef((SceneIndex)15);
					break;
				case 3:
					sceneDef = SceneCatalog.GetSceneDef((SceneIndex)16);
					break;
				}
				Run.instance.nextStageScene = sceneDef;
				teleport.sceneExitController.destinationScene = sceneDef;
			}
			averageItems = new AverageItems();
			averageItems.RedistributeItems();
			teleport.sceneExitController.SetState((ExitState)1);
		}

		private void RoleDisplay()
		{
			if (traitorTeamNames.Equals(""))
			{
				roleDisplay.UpdateTextInnocent();
				roleDisplay.ToggleWindow();
			}
			else
			{
				roleDisplay.UpdateTextTraitor(traitorTeamNames);
				roleDisplay.ToggleWindow();
			}
		}

		private void Update()
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Invalid comparison between Unknown and I4
			if (PlayerCharacterMasterController.instances.Count != 0 && Input.GetKeyDown((KeyCode)283))
			{
				score.UpdateTextContent(syncedScore);
				score.ToggleWindow();
			}
			if (PlayerCharacterMasterController.instances.Count != 0 && Input.GetKeyDown((KeyCode)284))
			{
				RoleDisplay();
			}
			if (NetworkServer.active)
			{
				if ((Object)(object)teleport != (Object)null && deadTraitorCount < randomNum.Length && (int)teleport.sceneExitController.exitState == 1 && !wonByEliminatingAllTraitors && !sentInnoWinMessageAlready && deadInnoCount < playerCount - randomNum.Length && !skippingRound && !traitorWin)
				{
					InnocentWinByTeleport();
					sentInnoWinMessageAlready = true;
					EndRoundWarpToNextStage();
				}
				if (NetworkServer.active && Input.GetKeyDown((KeyCode)286))
				{
					ChatMessage.Send("<color=yellow>Host has forced a skip to the next stage.</color>");
					EndRoundWarpToNextStage();
					skippingRound = true;
				}
			}
		}

		private string BuildScoreText()
		{
			string text = "";
			for (int i = 0; i < playerCount; i++)
			{
				Log.Info($"Building string for index: {i}");
				string displayName = NetworkUser.readOnlyInstancesList[i].masterController.GetDisplayName();
				text = text + "Player " + (i + 1) + ": " + displayName + "\n\tInnocent wins: " + winsAsInnocent[i] + "\n\tTraitor wins: " + winsAsTraitor[i] + "\n\tTotal wins: " + (winsAsTraitor[i] + winsAsInnocent[i]) + "\n\tTraitors killed as Innocent: " + killsOnTraitors[i] + "\n\tInnocents killed as Traitor: " + killsOnInnocents[i] + "\n\tTeamkills: " + teamKills[i] + "\n \n";
				Log.Info($"Finished String For Index: {i}");
			}
			Log.Info("Finished building all strings.");
			return text;
		}

		private void Stage_onServerStageBegin(Stage stage)
		{
			playerCount = PlayerCharacterMasterController.instances.Count;
			if (newGameStart)
			{
				wonByEliminatingAllTraitors = false;
				winsAsInnocent = new int[playerCount];
				winsAsTraitor = new int[playerCount];
				teamKills = new int[playerCount];
				killsOnTraitors = new int[playerCount];
				killsOnInnocents = new int[playerCount];
				roundsPlayed = 0;
				for (int i = 0; i < playerCount; i++)
				{
					winsAsInnocent[i] = 0;
					winsAsTraitor[i] = 0;
					killsOnTraitors[i] = 0;
					killsOnInnocents[i] = 0;
					teamKills[i] = 0;
				}
			}
			else
			{
				Run instance = Run.instance;
				instance.stageClearCount--;
				roundsPlayed++;
			}
			scoreDataFromServer = BuildScoreText();
			wonByEliminatingAllTraitors = false;
			newGameStart = false;
			innocentWin = false;
			traitorWin = false;
			sentInnoWinMessageAlready = false;
			deadInnoCount = 0;
			deadTraitorCount = 0;
			skippingRound = false;
			if (playerCount <= numTraitors || numTraitors == 0)
			{
				ChatMessage.Send("<color=red>WARNING!!!</color> <color=orange>There must be at least one Traitor player. Adjust Traitor count with the console command 'a_traitor_count' and restart.</color>");
			}
			randomNum = new int[numTraitors];
			for (int j = 0; j < numTraitors; j++)
			{
				int randomVar = Random.Range(1, playerCount + 1);
				while (Array.Exists(randomNum, (int num) => num == randomVar) && playerCount > 1 && numTraitors > 1)
				{
					randomVar = Random.Range(1, playerCount + 1);
				}
				randomNum[j] = randomVar;
			}
			for (int k = 0; k < randomNum.Length; k++)
			{
				randomNum[k]--;
			}
			Log.Info("Finished assigning Traitors");
			SendRolesToAllPlayers();
			string text = "There are <color=red>" + randomNum.Length + "</color> Traitor(s).";
			ChatMessage.Send(text);
		}

		private void SendRolesToAllPlayers()
		{
			string text = "<color=yellow>Your team:</color><color=red> ";
			traitorTeamNames = "";
			string text2 = "";
			new SyncTraitorTeam(traitorTeamNames);
			for (int i = 0; i < randomNum.Length; i++)
			{
				NetworkUser val = NetworkUser.readOnlyInstancesList[randomNum[i]];
				text = text + val.masterController.GetDisplayName() + " ";
				text2 = text2 + val.masterController.GetDisplayName() + " ";
			}
			text += "</color>";
			Log.Info("Successfully built traitor team message");
			bool flag = true;
			for (int j = 0; j < playerCount; j++)
			{
				NetworkUser val2 = NetworkUser.readOnlyInstancesList[j];
				NetworkConnection networkConnectionFromPlayerControllerIndex = GetNetworkConnectionFromPlayerControllerIndex(j);
				Log.Info($"Player character: {j}, Connection ID: {networkConnectionFromPlayerControllerIndex.connectionId}");
				for (int k = 0; k < randomNum.Length; k++)
				{
					if (j == randomNum[k])
					{
						Log.Info($"Traitor character: {j}");
						SendMessageFromStringAndIndex("<color=red>TRAITOR:</color> Eliminate all Innocent players to win.", j);
						if (j == 0)
						{
							traitorTeamNames = text2;
						}
						else
						{
							NetMessageExtensions.Send((INetMessage)(object)new SyncTraitorTeam(text2), networkConnectionFromPlayerControllerIndex);
						}
						if (randomNum.Length >= 1)
						{
							SendMessageFromStringAndIndex(text, j);
						}
						flag = false;
					}
				}
				if (flag)
				{
					SendMessageFromStringAndIndex("<color=green>INNOCENT:</color> Escape via the teleporter to win, or eliminate all Traitors.", j);
					if (j != 0)
					{
						NetMessageExtensions.Send((INetMessage)(object)new SyncTraitorTeam(""), networkConnectionFromPlayerControllerIndex);
					}
				}
				flag = true;
			}
		}

		private void InnocentWinByTeleport()
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			innocentWin = true;
			traitorWin = false;
			string text = "<color=green>Innocents win!</color> Traitors: <color=red>";
			for (int i = 0; i < randomNum.Length; i++)
			{
				NetworkUser val = NetworkUser.readOnlyInstancesList[randomNum[i]];
				text = text + val.masterController.GetDisplayName() + " ";
			}
			bool flag = true;
			for (int j = 0; j < playerCount; j++)
			{
				NetworkUser val2 = NetworkUser.readOnlyInstancesList[j];
				for (int k = 0; k < randomNum.Length; k++)
				{
					NetworkUser val3 = NetworkUser.readOnlyInstancesList[randomNum[k]];
					if (val2.masterController.networkUserInstanceId == val3.masterController.networkUserInstanceId)
					{
						flag = false;
					}
				}
				if (flag)
				{
					Log.Info("Adding a win to player: " + val2.masterController.GetDisplayName());
					winsAsInnocent[j]++;
				}
				flag = true;
			}
			text += "</color>";
			ChatMessage.Send(text);
		}
	}
	public class SyncScoreString : INetMessage, ISerializableObject
	{
		private string networkSyncScoreString = "Default unsynced";

		public SyncScoreString()
		{
		}

		public SyncScoreString(string newString)
		{
			networkSyncScoreString = newString;
		}

		public void Deserialize(NetworkReader reader)
		{
			RiskOfTraitors.syncedScore = reader.ReadString();
		}

		public void OnReceived()
		{
			if (!NetworkServer.active)
			{
			}
		}

		public void Serialize(NetworkWriter writer)
		{
			writer.Write(networkSyncScoreString);
		}
	}
	public class SyncTraitorTeam : INetMessage, ISerializableObject
	{
		private string traitorTeam = "none";

		public SyncTraitorTeam()
		{
		}

		public SyncTraitorTeam(string traitorTeam)
		{
			this.traitorTeam = traitorTeam;
		}

		public void Deserialize(NetworkReader reader)
		{
			RiskOfTraitors.traitorTeamNames = reader.ReadString();
		}

		public void OnReceived()
		{
			if (NetworkServer.active)
			{
				Log.Info("SyncTraitorTeam: Host ran this. Skip.");
			}
		}

		public void Serialize(NetworkWriter writer)
		{
			writer.Write(traitorTeam);
		}
	}
	public class SyncPlayerMonsterDamage : INetMessage, ISerializableObject
	{
		private int oldPlayerDamageMul = 0;

		private int playerOutgoingDamageMul = 0;

		private int oldEnemyDamageMul = 0;

		private int enemyOutgoingDamageMul = 0;

		private bool updatePlayerMul = false;

		private bool updateEnemyMul = false;

		public SyncPlayerMonsterDamage()
		{
		}

		public SyncPlayerMonsterDamage(int oldPlayerMul, int curPlayerMul, int oldEnemyMul, int curEnemyMul, bool updatePlayerMul, bool updateEnemyMul)
		{
			oldPlayerDamageMul = oldPlayerMul;
			playerOutgoingDamageMul = curPlayerMul;
			oldEnemyDamageMul = oldEnemyMul;
			enemyOutgoingDamageMul = curEnemyMul;
			this.updatePlayerMul = updatePlayerMul;
			this.updateEnemyMul = updateEnemyMul;
		}

		public void Deserialize(NetworkReader reader)
		{
			RiskOfTraitors.oldPlayerDamageMul = reader.ReadInt32();
			RiskOfTraitors.playerOutgoingDamageMul = reader.ReadInt32();
			RiskOfTraitors.oldEnemyDamageMul = reader.ReadInt32();
			RiskOfTraitors.enemyOutgoingDamageMul = reader.ReadInt32();
			RiskOfTraitors.updatePlayerDamageMul = reader.ReadBoolean();
			RiskOfTraitors.updateMonsterDamageMul = reader.ReadBoolean();
		}

		public void OnReceived()
		{
			if (NetworkServer.active)
			{
				Log.Info("SyncTraitorTeam: Host ran this. Skip.");
				return;
			}
			Log.Info($"Received muls from server: {oldPlayerDamageMul}, {playerOutgoingDamageMul}, {oldEnemyDamageMul}, {enemyOutgoingDamageMul}");
		}

		public void Serialize(NetworkWriter writer)
		{
			writer.Write(oldPlayerDamageMul);
			writer.Write(playerOutgoingDamageMul);
			writer.Write(oldEnemyDamageMul);
			writer.Write(enemyOutgoingDamageMul);
			writer.Write(updatePlayerMul);
			writer.Write(updateEnemyMul);
		}
	}
	public class SyncWinningTeam : INetMessage, ISerializableObject
	{
		private bool didInnocentWin = true;

		private string traitorTeam = "";

		public SyncWinningTeam()
		{
		}

		public SyncWinningTeam(bool didInnocentWin, string traitorTeam)
		{
			this.didInnocentWin = didInnocentWin;
			this.traitorTeam = traitorTeam;
		}

		public void Deserialize(NetworkReader reader)
		{
			didInnocentWin = reader.ReadBoolean();
			traitorTeam = reader.ReadString();
		}

		public void OnReceived()
		{
			if (NetworkServer.active)
			{
				Log.Info("SyncTraitorTeam: Host ran this. Skip.");
			}
		}

		public void Serialize(NetworkWriter writer)
		{
			writer.Write(didInnocentWin);
			writer.Write(traitorTeam);
		}
	}
	public class RoleDisplayUI : MonoBehaviour
	{
		private GameObject canvas;

		public GameObject windowPanel;

		public Text roleText;

		public bool windowVisible = false;

		public void Init()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			canvas = new GameObject("Canvas", new Type[2]
			{
				typeof(Canvas),
				typeof(CanvasScaler)
			});
			canvas.GetComponent<Canvas>().renderMode = (RenderMode)0;
			windowPanel = new GameObject("WindowPanel");
			windowPanel.AddComponent<CanvasRenderer>();
			((Graphic)windowPanel.AddComponent<Image>()).color = new Color(0.1f, 0.1f, 0.15f, 0.9f);
			windowPanel.transform.SetParent(canvas.transform);
			windowPanel.GetComponent<RectTransform>().anchorMin = new Vector2(0.05f, 0.33f);
			windowPanel.GetComponent<RectTransform>().anchorMax = new Vector2(0.2f, 0.4f);
			windowPanel.GetComponent<RectTransform>().anchoredPosition = Vector2.zero;
			roleText = new GameObject("roleText").AddComponent<Text>();
			((Component)roleText).transform.SetParent(windowPanel.transform);
			((Graphic)roleText).rectTransform.anchorMin = new Vector2(0.01f, 1f);
			((Graphic)roleText).rectTransform.anchorMax = new Vector2(0.01f, 1f);
			((Graphic)roleText).rectTransform.pivot = new Vector2(0f, 1f);
			((Graphic)roleText).rectTransform.anchoredPosition = Vector2.zero;
			roleText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			((Graphic)roleText).color = Color.white;
			roleText.fontSize = 22;
			roleText.text = "Your text content here";
			roleText.horizontalOverflow = (HorizontalWrapMode)0;
			roleText.verticalOverflow = (VerticalWrapMode)1;
			RectTransform rectTransform = ((Graphic)roleText).rectTransform;
			Rect rect = windowPanel.GetComponent<RectTransform>().rect;
			float width = ((Rect)(ref rect)).width;
			rect = windowPanel.GetComponent<RectTransform>().rect;
			rectTransform.sizeDelta = new Vector2(width, ((Rect)(ref rect)).height);
			AdjustFontSizeToFit(roleText);
			windowPanel.SetActive(false);
		}

		private void AdjustFontSizeToFit(Text roleText)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			while (true)
			{
				float preferredHeight = roleText.preferredHeight;
				Rect rect = ((Graphic)roleText).rectTransform.rect;
				if (preferredHeight > ((Rect)(ref rect)).height && roleText.fontSize > 12)
				{
					int fontSize = roleText.fontSize;
					roleText.fontSize = fontSize - 1;
					continue;
				}
				break;
			}
		}

		public void UpdateTextTraitor(string traitorTeam)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			roleText.text = "Role: Traitor\n " + traitorTeam;
			((Graphic)roleText).color = Color.red;
			AdjustFontSizeToFit(roleText);
		}

		public void UpdateTextInnocent()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			roleText.text = "Role: Innocent";
			((Graphic)roleText).color = Color.green;
			AdjustFontSizeToFit(roleText);
		}

		public void ToggleWindow()
		{
			windowVisible = !windowVisible;
			windowPanel.SetActive(windowVisible);
		}
	}
	public class CustomGUI : MonoBehaviour
	{
		private GameObject canvas;

		public GameObject windowPanel;

		public Text textElement;

		public bool windowVisible = false;

		public void Init()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			canvas = new GameObject("Canvas", new Type[2]
			{
				typeof(Canvas),
				typeof(CanvasScaler)
			});
			canvas.GetComponent<Canvas>().renderMode = (RenderMode)0;
			windowPanel = new GameObject("WindowPanel");
			windowPanel.AddComponent<CanvasRenderer>();
			((Graphic)windowPanel.AddComponent<Image>()).color = new Color(0.1f, 0.1f, 0.15f, 0.9f);
			windowPanel.transform.SetParent(canvas.transform);
			windowPanel.GetComponent<RectTransform>().anchorMin = new Vector2(0.25f, 0.1f);
			windowPanel.GetComponent<RectTransform>().anchorMax = new Vector2(0.75f, 0.9f);
			windowPanel.GetComponent<RectTransform>().anchoredPosition = Vector2.zero;
			textElement = new GameObject("TextElement").AddComponent<Text>();
			((Component)textElement).transform.SetParent(windowPanel.transform);
			((Graphic)textElement).rectTransform.anchorMin = new Vector2(0.01f, 1f);
			((Graphic)textElement).rectTransform.anchorMax = new Vector2(0.01f, 1f);
			((Graphic)textElement).rectTransform.pivot = new Vector2(0f, 1f);
			((Graphic)textElement).rectTransform.anchoredPosition = Vector2.zero;
			textElement.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			((Graphic)textElement).color = Color.white;
			textElement.fontSize = 28;
			textElement.text = "Your text content here";
			textElement.horizontalOverflow = (HorizontalWrapMode)0;
			textElement.verticalOverflow = (VerticalWrapMode)1;
			RectTransform rectTransform = ((Graphic)textElement).rectTransform;
			Rect rect = windowPanel.GetComponent<RectTransform>().rect;
			float width = ((Rect)(ref rect)).width;
			rect = windowPanel.GetComponent<RectTransform>().rect;
			rectTransform.sizeDelta = new Vector2(width, ((Rect)(ref rect)).height);
			AdjustFontSizeToFit(textElement);
			windowPanel.SetActive(false);
		}

		private void AdjustFontSizeToFit(Text textElement)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			while (true)
			{
				float preferredHeight = textElement.preferredHeight;
				Rect rect = ((Graphic)textElement).rectTransform.rect;
				if (preferredHeight > ((Rect)(ref rect)).height && textElement.fontSize > 12)
				{
					int fontSize = textElement.fontSize;
					textElement.fontSize = fontSize - 1;
					continue;
				}
				break;
			}
		}

		public void UpdateTextContent(string newText)
		{
			textElement.text = newText;
			AdjustFontSizeToFit(textElement);
		}

		public void ToggleWindow()
		{
			windowVisible = !windowVisible;
			windowPanel.SetActive(windowVisible);
		}
	}
}