using System;
using System.Collections;
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 Fusion;
using HarmonyLib;
using LycansQoL.Patch;
using LycansQoL.RPC;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Scripting;
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(".NETFramework,Version=v4.6.2", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("LycansQoL")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a46291ae0eddc893f01dfbfa408e6bbea7c34d5d")]
[assembly: AssemblyProduct("LycansQoL")]
[assembly: AssemblyTitle("LycansQoL")]
[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;
}
}
}
[HarmonyPatch(typeof(LocalCameraHandler), "LateUpdate")]
internal class LocalCameraHandler_LateInitFix
{
private static void Prefix(LocalCameraHandler __instance, ref PlayerController ____localPlayer, ref float ____baseCameraOffset, Transform ___localCameraAnchorPoint)
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)__instance.LocalCamera == (Object)null) && ((Behaviour)__instance.LocalCamera).enabled && (!((Object)(object)____localPlayer != (Object)null) || !((Object)(object)__instance.PovPlayer != (Object)null)) && !((Object)(object)PlayerController.Local == (Object)null))
{
____baseCameraOffset = ___localCameraAnchorPoint.localPosition.y;
____localPlayer = PlayerController.Local;
AccessTools.PropertySetter(typeof(LocalCameraHandler), "PovPlayer")?.Invoke(__instance, new object[1] { PlayerController.Local });
((Component)__instance.LocalCamera).transform.parent = null;
if (PlayerPrefs.HasKey("SETTINGS_ROTATION_SPEED"))
{
float @float = PlayerPrefs.GetFloat("SETTINGS_ROTATION_SPEED");
AccessTools.Field(typeof(LocalCameraHandler), "_rotationSpeed")?.SetValue(__instance, @float);
}
}
}
}
[HarmonyPatch(typeof(GameManager), "OnPlayerJoined")]
internal class GameManager_OnPlayerJoined_Patch
{
private static void Postfix(GameManager __instance, NetworkRunner runner, PlayerRef playerRef, PlayerController playerControllerPrefab, Transform[] ___mapSpawns)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
if (runner.IsServer && NetworkBool.op_Implicit(GameManager.Instance.IsStarted))
{
}
}
}
[HarmonyPatch(typeof(VoiceSpeaker), "Update")]
internal class VoiceSpeaker_Update_Patch
{
private static bool Prefix(VoiceSpeaker __instance, ref AudioSource ____audioSource, ref PlayerController ____playerController)
{
if ((Object)(object)____audioSource == (Object)null)
{
____audioSource = ((Component)__instance).GetComponent<AudioSource>();
}
if ((Object)(object)____playerController == (Object)null)
{
____playerController = ((Component)__instance).GetComponentInParent<PlayerController>();
}
if ((Object)(object)PlayerController.Local == (Object)null || (Object)(object)____playerController == (Object)null || (Object)(object)____audioSource == (Object)null)
{
return false;
}
if ((Object)(object)____playerController == (Object)(object)PlayerController.Local)
{
return true;
}
return true;
}
}
namespace LycansQoL
{
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);
}
}
[BepInPlugin("RedTenZ.LycansQoL", "LycansQoL", "1.1.3")]
[BepInProcess("Lycans.exe")]
public class LycansQoL : BaseUnityPlugin
{
public const string PLUGIN_GUID = "RedTenZ.LycansQoL";
public const string PLUGIN_AUTHOR = "RedTenZ";
public const string PLUGIN_NAME = "LycansQoL";
public const string PLUGIN_VERSION = "1.1.3";
private void Awake()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
Log.Init(((BaseUnityPlugin)this).Logger);
Log.Info("Plugin LycansQoL version 1.1.3 loaded successfully!");
Harmony val = new Harmony("lycans.redtenzplugin");
val.PatchAll();
Log.Info("Harmony patches applied successfully!");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "LycansQoL";
public const string PLUGIN_NAME = "LycansQoL";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace LycansQoL.RPC
{
[NetworkBehaviourWeaved(20)]
public class CancelVoteRPC : NetworkBehaviour
{
[Rpc]
public unsafe static void Rpc_RequestCancelVote(NetworkRunner runner, int playerIndex)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Invalid comparison between Unknown and I4
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
try
{
if (NetworkBehaviourUtils.InvokeRpc)
{
NetworkBehaviourUtils.InvokeRpc = false;
}
else
{
if ((Object)(object)runner == (Object)null)
{
throw new ArgumentNullException("runner");
}
if ((int)runner.Stage == 4)
{
return;
}
if (runner.HasAnyActiveConnections())
{
int num = 24;
SimulationMessage* ptr = SimulationMessage.Allocate(runner.Simulation, num);
byte* data = SimulationMessage.GetData(ptr);
int num2 = RpcHeader.Write(RpcHeader.Create(NetworkBehaviourUtils.GetRpcStaticIndexOrThrow("System.Void LycansModTemplate.Patch.CancelVoteRPC::Rpc_RequestCancelVote(Fusion.NetworkRunner,System.Int32)")), data);
*(int*)(data + num2) = playerIndex;
num2 += 4;
((SimulationMessage)ptr).Offset = num2 * 8;
((SimulationMessage)ptr).SetStatic();
runner.SendRpc(ptr);
}
}
Execute(playerIndex);
}
catch (Exception ex)
{
string text = "Rpc_CancelVote error: ";
Log.Info(text + ex);
}
}
[NetworkRpcStaticWeavedInvoker("System.Void LycansModTemplate.Patch.CancelVoteRPC::Rpc_RequestCancelVote(Fusion.NetworkRunner,System.Int32)")]
[Preserve]
protected unsafe static void Rpc_RequestCancelVote_0040Invoker(NetworkRunner runner, SimulationMessage* message)
{
byte* data = SimulationMessage.GetData(message);
int num = (RpcHeader.ReadSize(data) + 3) & -4;
int playerIndex = *(int*)(data + num);
num += 4;
NetworkBehaviourUtils.InvokeRpc = true;
Rpc_RequestCancelVote(runner, playerIndex);
}
public static void Execute(int playerId)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
PlayerController player = PlayerRegistry.GetPlayer(PlayerRef.op_Implicit(playerId));
if (!((Object)(object)player == (Object)null) && player.IdVoted != -1)
{
if (((SimulationBehaviour)player).HasStateAuthority)
{
GameManager.Instance.gameUI.ShowSkipVote(true);
}
player.IdVoted = -1;
player.UpdateVoting(false);
}
}
}
[NetworkBehaviourWeaved(20)]
public class StartVoteRPC : NetworkBehaviour
{
private static readonly HashSet<int> _startGameVoters = new HashSet<int>();
internal static int GetReadyVotesCount()
{
return _startGameVoters.Count;
}
internal static void ResetStartGameVotes()
{
_startGameVoters.Clear();
int count = PlayerRegistry.Count;
int neededForMajority = ((count > 0) ? (count / 2 + 1) : 0);
UIReadyPlayerCountPatch.UpdateReadyCountUI(0, count, neededForMajority, localPlayerVoted: false);
}
[Rpc]
public unsafe static void Rpc_RequestStartVote(NetworkRunner runner, int playerIndex)
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Invalid comparison between Unknown and I4
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: 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_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Invalid comparison between Unknown and I4
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
try
{
if (NetworkBehaviourUtils.InvokeRpc)
{
NetworkBehaviourUtils.InvokeRpc = false;
}
else
{
if ((Object)(object)runner == (Object)null)
{
throw new ArgumentNullException("runner");
}
if ((int)runner.Stage == 4)
{
return;
}
if (runner.HasAnyActiveConnections())
{
int num = 24;
SimulationMessage* ptr = SimulationMessage.Allocate(runner.Simulation, num);
byte* data = SimulationMessage.GetData(ptr);
int num2 = RpcHeader.Write(RpcHeader.Create(NetworkBehaviourUtils.GetRpcStaticIndexOrThrow("System.Void LycansModTemplate.Patch.StartVoteRPC::Rpc_RequestStartVote(Fusion.NetworkRunner,System.Int32)")), data);
*(int*)(data + num2) = playerIndex;
num2 += 4;
((SimulationMessage)ptr).Offset = num2 * 8;
((SimulationMessage)ptr).SetStatic();
runner.SendRpc(ptr);
}
}
PlayerRef @ref;
if (!_startGameVoters.Contains(playerIndex))
{
_startGameVoters.Add(playerIndex);
@ref = PlayerController.Local.Ref;
if (playerIndex == ((PlayerRef)(ref @ref)).PlayerId)
{
PlayerController.Local.MovementAction = 1;
}
}
int count = PlayerRegistry.Count;
if (count > 0)
{
int num3 = count / 2 + 1;
HashSet<int> startGameVoters = _startGameVoters;
@ref = PlayerController.Local.Ref;
bool localPlayerVoted = startGameVoters.Contains(((PlayerRef)(ref @ref)).PlayerId);
UIReadyPlayerCountPatch.UpdateReadyCountUI(_startGameVoters.Count, count, num3, localPlayerVoted);
if (runner.IsServer && (int)GameManager.State.Current == 1 && !((Object)(object)GameManager.Instance == (Object)null) && !NetworkBool.op_Implicit(GameManager.Instance.IsStarted) && _startGameVoters.Count >= num3)
{
Log.Info("[StartVoteRPC] Majorité atteinte, lancement de la partie via GameManager.StartGame()");
GameManager.Instance.StartGame();
}
}
}
catch (Exception ex)
{
string text = "Rpc_StartVote error: ";
Log.Info(text + ex);
}
}
[NetworkRpcStaticWeavedInvoker("System.Void LycansModTemplate.Patch.StartVoteRPC::Rpc_RequestStartVote(Fusion.NetworkRunner,System.Int32)")]
[Preserve]
protected unsafe static void Rpc_RequestStartVote_0040Invoker(NetworkRunner runner, SimulationMessage* message)
{
byte* data = SimulationMessage.GetData(message);
int num = (RpcHeader.ReadSize(data) + 3) & -4;
int playerIndex = *(int*)(data + num);
num += 4;
NetworkBehaviourUtils.InvokeRpc = true;
Rpc_RequestStartVote(runner, playerIndex);
}
[Rpc]
public unsafe static void Rpc_ResetStartVoteCounter(NetworkRunner runner)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
if (runner.HasAnyActiveConnections())
{
int num = 8;
SimulationMessage* ptr = SimulationMessage.Allocate(runner.Simulation, num);
byte* data = SimulationMessage.GetData(ptr);
int num2 = RpcHeader.Write(RpcHeader.Create(NetworkBehaviourUtils.GetRpcStaticIndexOrThrow("System.Void LycansModTemplate.Patch.StartVoteRPC::Rpc_RequestResetStartVoteCounter(Fusion.NetworkRunner)")), data);
((SimulationMessage)ptr).Offset = num2 * 8;
((SimulationMessage)ptr).SetStatic();
runner.SendRpc(ptr);
}
_startGameVoters.Clear();
int count = PlayerRegistry.Count;
int neededForMajority = count / 2 + 1;
bool localPlayerVoted = false;
UIReadyPlayerCountPatch.UpdateReadyCountUI(0, count, neededForMajority, localPlayerVoted);
}
[NetworkRpcStaticWeavedInvoker("System.Void LycansModTemplate.Patch.StartVoteRPC::Rpc_RequestResetStartVoteCounter(Fusion.NetworkRunner)")]
[Preserve]
protected unsafe static void Rpc_RequestResetStartVoteCounter_0040Invoker(NetworkRunner runner, SimulationMessage* message)
{
NetworkBehaviourUtils.InvokeRpc = true;
Rpc_ResetStartVoteCounter(runner);
}
}
}
namespace LycansQoL.Patch
{
[HarmonyPatch(typeof(GameUI), "Awake")]
internal class GameVersionPatch
{
private static void Postfix(GameUI __instance)
{
TextMeshProUGUI value = Traverse.Create((object)__instance).Field<TextMeshProUGUI>("mmVersionText").Value;
((TMP_Text)value).text = ((TMP_Text)value).text + "\nLycansQoL 1.1.3";
}
}
[HarmonyPatch(typeof(PlayerController), "Interact")]
internal class InteractPatch
{
private static bool Prefix(PlayerController __instance, bool isPrimary)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Invalid comparison between Unknown and I4
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Invalid comparison between Unknown and I4
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
PlayerRef @ref;
if ((int)GameManager.State.Current == 4 && isPrimary)
{
TickTimer voteTimer = GameManager.Instance.VoteTimer;
float valueOrDefault = ((TickTimer)(ref voteTimer)).RemainingTime(((SimulationBehaviour)GameManager.Instance).Runner).GetValueOrDefault();
if (valueOrDefault > 10f && __instance.IdVoted != -1)
{
NetworkRunner runner = ((SimulationBehaviour)GameManager.Instance).Runner;
@ref = __instance.Ref;
CancelVoteRPC.Rpc_RequestCancelVote(runner, ((PlayerRef)(ref @ref)).PlayerId);
return false;
}
}
if ((int)GameManager.State.Current == 1 && isPrimary && !GameManager.Instance.gameUI.IsGameSettingMenuOpen && !GameManager.Instance.gameUI.IsSettingMenuOpen && !GameManager.Instance.previewCamera.IsPreviewCameraActive)
{
NetworkRunner runner2 = ((SimulationBehaviour)GameManager.Instance).Runner;
@ref = __instance.Ref;
StartVoteRPC.Rpc_RequestStartVote(runner2, ((PlayerRef)(ref @ref)).PlayerId);
}
return true;
}
}
[HarmonyPatch(typeof(Spawner), "OnConnectedToServer")]
internal static class OnConnectedToServerPatch
{
private static bool Prefix(Spawner __instance, NetworkRunner runner)
{
Log.Info($"OnConnectedToServer patché, SessionInfo.IsOpen = {runner.SessionInfo.IsOpen}");
return true;
}
}
[HarmonyPatch(typeof(PlayerController), "OnVoteChanged")]
internal class OnVoteChangedPatch
{
private static void Postfix(Changed<PlayerController> changed)
{
PlayerRegistry.Where((Predicate<PlayerController>)((PlayerController p) => !NetworkBool.op_Implicit(p.IsDead))).ToList().ForEach(delegate(PlayerController p)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
int count2 = PlayerRegistry.Where((Predicate<PlayerController>)delegate(PlayerController v)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
int idVoted = v.IdVoted;
PlayerRef @ref = p.Ref;
return idVoted == ((PlayerRef)(ref @ref)).PlayerId;
}).ToList().Count;
GameManager.Instance.gameUI.UpdatePlayerVotesCount(p.Ref, count2);
});
int count = PlayerRegistry.Where((Predicate<PlayerController>)((PlayerController p) => !NetworkBool.op_Implicit(p.IsDead) && p.IdVoted == -2)).ToList().Count;
GameManager.Instance.gameUI.UpdateSkippedVotesCount(count);
}
}
[HarmonyPatch(typeof(PlayerController), "Spawned")]
internal class PlayerController_Spawned_LateJoinUI
{
[CompilerGenerated]
private sealed class <>c__DisplayClass1_0
{
public GameUI ui;
internal void <InitLateJoinUI>b__0(PlayerController p)
{
ui.AddPlayerDisplay(p);
}
}
[CompilerGenerated]
private sealed class <InitLateJoinUI>d__1 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public PlayerController localPlayer;
private <>c__DisplayClass1_0 <>8__1;
private int <safety>5__2;
private GameManager <gm>5__3;
private MethodInfo <mUpdateDead>5__4;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <InitLateJoinUI>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>8__1 = null;
<gm>5__3 = null;
<mUpdateDead>5__4 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>8__1 = new <>c__DisplayClass1_0();
<safety>5__2 = 0;
break;
case 1:
<>1__state = -1;
break;
}
if (((Object)(object)GameManager.Instance == (Object)null || (Object)(object)GameManager.Instance.gameUI == (Object)null || PlayerRegistry.Count == 0) && <safety>5__2 < 180)
{
<safety>5__2++;
<>2__current = null;
<>1__state = 1;
return true;
}
<gm>5__3 = GameManager.Instance;
<>8__1.ui = <gm>5__3?.gameUI;
if ((Object)(object)<>8__1.ui == (Object)null)
{
return false;
}
<>8__1.ui.HidePlayMenu();
<>8__1.ui.ShowMainMenu(false);
<>8__1.ui.ShowPregameMenu(false);
<>8__1.ui.ShowGameMenu(true);
<>8__1.ui.ShowFixedMenu(true);
<>8__1.ui.ShowShortcutMenu(true);
<>8__1.ui.ShowSpectateMenu(false);
<>8__1.ui.ShowMeetingMenu(false);
<>8__1.ui.ShowTimer(false);
<>8__1.ui.ShowWolvesRecap(false);
<>8__1.ui.EnableRegionSetting(false);
<>8__1.ui.EnableQuitButtonSetting(true);
<>8__1.ui.EnableVolumesButtonSetting(true);
<>8__1.ui.UpdateCursor(false);
PlayerRegistry.ForEach((Action<PlayerController>)delegate(PlayerController p)
{
<>8__1.ui.AddPlayerDisplay(p);
});
if (NetworkBool.op_Implicit(localPlayer.IsDead))
{
<mUpdateDead>5__4 = AccessTools.Method(typeof(PlayerController), "UpdateDead", (Type[])null, (Type[])null);
<mUpdateDead>5__4?.Invoke(localPlayer, null);
<>8__1.ui.ShowSpectateMenu(true);
<mUpdateDead>5__4 = null;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static void Postfix(PlayerController __instance)
{
if (((SimulationBehaviour)__instance).Object.HasInputAuthority)
{
((MonoBehaviour)__instance).StartCoroutine(InitLateJoinUI(__instance));
}
}
[IteratorStateMachine(typeof(<InitLateJoinUI>d__1))]
private static IEnumerator InitLateJoinUI(PlayerController localPlayer)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <InitLateJoinUI>d__1(0)
{
localPlayer = localPlayer
};
}
}
[HarmonyPatch(typeof(GameManager), "StartGame")]
internal static class StartGamePatch
{
private static void Postfix(GameManager __instance)
{
StartVoteRPC.Rpc_ResetStartVoteCounter(((SimulationBehaviour)__instance).Runner);
}
}
[HarmonyPatch(typeof(GameUI), "Awake")]
internal static class UIReadyPlayerCountPatch
{
private static TextMeshProUGUI _readyPlayerCount;
private static TextMeshProUGUI _readyPlayerKey;
private static void Postfix(GameUI __instance, TextMeshProUGUI ___playerCount)
{
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)___playerCount == (Object)null)
{
return;
}
GameObject gameObject = ((Component)___playerCount).gameObject;
GameObject val = Object.Instantiate<GameObject>(gameObject, gameObject.transform.parent);
((Object)val).name = "ReadyPlayerCount";
_readyPlayerCount = val.GetComponent<TextMeshProUGUI>();
if (!((Object)(object)_readyPlayerCount == (Object)null))
{
RectTransform rectTransform = ((TMP_Text)_readyPlayerCount).rectTransform;
rectTransform.anchoredPosition += new Vector2(0f, 900f);
((Graphic)_readyPlayerCount).color = Color.red;
((TMP_Text)_readyPlayerCount).text = "Joueur prêt : 0/0";
GameObject val2 = Object.Instantiate<GameObject>(gameObject, gameObject.transform.parent);
((Object)val2).name = "ReadyPlayerKey";
_readyPlayerKey = val2.GetComponent<TextMeshProUGUI>();
if (!((Object)(object)_readyPlayerKey == (Object)null))
{
RectTransform rectTransform2 = ((TMP_Text)_readyPlayerKey).rectTransform;
rectTransform2.anchoredPosition += new Vector2(0f, 200f);
rectTransform2.sizeDelta = new Vector2(rectTransform2.sizeDelta.x + 300f, rectTransform2.sizeDelta.y);
((TMP_Text)_readyPlayerKey).text = "<sprite name=\"leftButton\"> - Voter pour démarrer";
}
}
}
internal static void UpdateReadyCountUI(int readyVotes, int totalPlayers, int neededForMajority, bool localPlayerVoted)
{
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)_readyPlayerCount == (Object)null))
{
((TMP_Text)_readyPlayerCount).text = $"Joueur prêt : {readyVotes}/{neededForMajority}";
if (localPlayerVoted)
{
((Graphic)_readyPlayerCount).color = Color.green;
}
else
{
((Graphic)_readyPlayerCount).color = Color.red;
}
}
}
}
[HarmonyPatch(typeof(GameUI), "UpdatePlayerCount")]
internal static class ReadyPlayerCount_OnPlayerCountChanged
{
private static void Postfix(int count)
{
int neededForMajority = ((count > 0) ? (count / 2 + 1) : 0);
int readyVotesCount = StartVoteRPC.GetReadyVotesCount();
UIReadyPlayerCountPatch.UpdateReadyCountUI(readyVotesCount, count, neededForMajority, localPlayerVoted: false);
}
}
}