using System;
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.Configuration;
using BepInEx.Logging;
using Fusion;
using LycansUpPlayer.Patchs;
using LycansUpPlayer.Utils;
using Microsoft.CodeAnalysis;
using On;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Localization;
using UnityEngine.Localization.Components;
using UnityEngine.Localization.Settings;
using UnityEngine.Localization.Tables;
using UnityEngine.SceneManagement;
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("LycansUpPlayer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+b444b339a1e5e0a10e5a27469002b89b3152c254")]
[assembly: AssemblyProduct("LycansUpPlayer")]
[assembly: AssemblyTitle("LycansUpPlayer")]
[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 LycansUpPlayer
{
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("nm-qm.lycans-up-player", "LycansUpPlayer", "1.0.0")]
[BepInProcess("Lycans.exe")]
public class LycansUpPlayerPlugin : BaseUnityPlugin
{
public static Settings settings;
public const string PLUGIN_GUID = "nm-qm.lycans-up-player";
public const string PLUGIN_AUTHOR = "NM & QM";
public const string PLUGIN_NAME = "LycansUpPlayer";
public const string PLUGIN_FOLDER = "LycansUpPlayer";
public const string PLUGIN_VERSION = "1.0.0";
private int maxPlayers = 2;
private void Awake()
{
Log.Init(((BaseUnityPlugin)this).Logger);
Log.Info("LycansUpPlayer v1.0.0 loaded");
settings = new Settings(((BaseUnityPlugin)this).Config);
GameSettingsMenuPatch.Hook();
LycansUpPlayerUI.Hook();
}
private void Update()
{
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "LycansUpPlayer";
public const string PLUGIN_NAME = "LycansUpPlayer";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace LycansUpPlayer.Utils
{
public class Settings
{
private readonly ConfigEntry<int> playerCount = config.Bind<int>("General", "PlayerCount", 10, "Nombres de joueurs acceptés");
public Settings(ConfigFile config)
{
}
public int getDefaultPlayerCount()
{
return (int)((ConfigEntryBase)playerCount).DefaultValue;
}
public int getPlayerCount()
{
return playerCount.Value;
}
public void setPlayerCount(int value)
{
playerCount.Value = value;
}
}
}
namespace LycansUpPlayer.Patchs
{
public class GameSettingsMenuPatch
{
[CompilerGenerated]
private static class <>O
{
public static hook_Start <0>__GameManager_Start;
}
public static void Hook()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
RegisterTranslations();
object obj = <>O.<0>__GameManager_Start;
if (obj == null)
{
hook_Start val = GameManager_Start;
<>O.<0>__GameManager_Start = val;
obj = (object)val;
}
GameManager.Start += (hook_Start)obj;
}
private static void RegisterTranslations()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
StringTable table = ((LocalizedDatabase<StringTable, StringTableEntry>)(object)LocalizationSettings.StringDatabase).GetTable(TableReference.op_Implicit("UI Text"), LocalizationSettings.AvailableLocales.GetLocale(LocaleIdentifier.op_Implicit("en")));
StringTable table2 = ((LocalizedDatabase<StringTable, StringTableEntry>)(object)LocalizationSettings.StringDatabase).GetTable(TableReference.op_Implicit("UI Text"), LocalizationSettings.AvailableLocales.GetLocale(LocaleIdentifier.op_Implicit("fr")));
((DetailedLocalizationTable<StringTableEntry>)(object)table).AddEntry("LUP_LABEL", "Player Count Increase");
((DetailedLocalizationTable<StringTableEntry>)(object)table2).AddEntry("LUP_LABEL", "Augmentation du nombre de joueurs");
((DetailedLocalizationTable<StringTableEntry>)(object)table).AddEntry("LUP_PLAYER_COUNT", "Player Count");
((DetailedLocalizationTable<StringTableEntry>)(object)table2).AddEntry("LUP_PLAYER_COUNT", "Nombre de joueurs");
LocalizationSettings.Instance.OnSelectedLocaleChanged += delegate
{
RegisterTranslations();
};
}
private static void GameManager_Start(orig_Start orig, GameManager self)
{
orig.Invoke(self);
Log.Info("GameManager_Start");
Settings gameSettingsMenu = LycansUpPlayerPlugin.settings;
int playerCount = gameSettingsMenu.getPlayerCount();
AddSection(self.gameUI, "LUP_LABEL");
AddSlider(self.gameUI, "LUP_PLAYER_COUNT", delegate(int value)
{
gameSettingsMenu.setPlayerCount(value);
Log.Info($"Player count set to {value}");
}, playerCount, gameSettingsMenu.getDefaultPlayerCount());
MakeSettingsMenuScrollable(self.gameUI);
}
private static void AddSection(GameUI gameUi, string label)
{
Transform val = Object.Instantiate<Transform>(gameUi.settingsMenu.transform.Find("LayoutGroup/Body/TaskPanel/Holder/SettingsGroup/GraphicsTitle"), gameUi.gameSettingsMenu.transform.Find("LayoutGroup/Body/TaskPanel/Holder/LayoutGroup"));
((Component)val).GetComponentInChildren<LocalizeStringEvent>().SetEntry(label);
}
private static void AddSlider(GameUI gameUi, string label, UnityAction<int> onValueChangedListener, int initialValue, int defaultValue)
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Expected O, but got Unknown
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Expected O, but got Unknown
Transform val = CreateSettingsEntry(gameUi, "MasterVolumeSetting", label);
Slider slider = ((Component)val).GetComponentInChildren<Slider>();
slider.wholeNumbers = true;
slider.minValue = 1f;
slider.maxValue = 15f;
slider.onValueChanged = new SliderEvent();
((UnityEvent<float>)(object)slider.onValueChanged).AddListener((UnityAction<float>)delegate(float value)
{
onValueChangedListener.Invoke((int)value);
});
GameSettingsUI.ResetSettings += (hook_ResetSettings)delegate(orig_ResetSettings orig, GameSettingsUI self)
{
orig.Invoke(self);
slider.SetValueWithoutNotify((float)defaultValue);
onValueChangedListener.Invoke(defaultValue);
};
slider.SetValueWithoutNotify((float)initialValue);
}
private static void AddToggle(GameUI gameUi, string label, UnityAction<bool> onValueChangedListener, bool initialValue, bool defaultValue)
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Expected O, but got Unknown
Transform val = CreateSettingsEntry(gameUi, "VSyncSettings", label);
Toggle toggle = ((Component)val).GetComponentInChildren<Toggle>();
toggle.onValueChanged = new ToggleEvent();
((UnityEvent<bool>)(object)toggle.onValueChanged).AddListener(onValueChangedListener);
GameSettingsUI.ResetSettings += (hook_ResetSettings)delegate(orig_ResetSettings orig, GameSettingsUI self)
{
orig.Invoke(self);
toggle.SetIsOnWithoutNotify(defaultValue);
onValueChangedListener.Invoke(defaultValue);
};
toggle.SetIsOnWithoutNotify(initialValue);
}
private static Transform CreateSettingsEntry(GameUI gameUi, string originalEntry, string label)
{
Transform val = Object.Instantiate<Transform>(gameUi.settingsMenu.transform.Find("LayoutGroup/Body/TaskPanel/Holder/SettingsGroup/" + originalEntry), gameUi.gameSettingsMenu.transform.Find("LayoutGroup/Body/TaskPanel/Holder/LayoutGroup"));
((Component)val).GetComponentInChildren<LocalizeStringEvent>().SetEntry(label);
return val;
}
private static void MakeSettingsMenuScrollable(GameUI gameUi)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Expected O, but got Unknown
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Expected O, but got Unknown
Transform val = gameUi.gameSettingsMenu.transform.Find("LayoutGroup/Body/TaskPanel/Holder");
((Component)((Component)val).gameObject.AddComponent<Image>()).GetComponent<RectTransform>().sizeDelta = new Vector2(-20f, -10f);
((Component)val).gameObject.AddComponent<Mask>().showMaskGraphic = false;
val.Find("QuitButton").SetParent(val.parent);
Transform val2 = val.Find("LayoutGroup");
GameObject val3 = new GameObject("ScrollView");
val3.transform.SetParent(val);
val3.transform.SetAsFirstSibling();
ScrollRect val4 = val3.AddComponent<ScrollRect>();
val4.vertical = true;
val4.horizontal = false;
val4.movementType = (MovementType)2;
val4.content = ((Component)val2).GetComponent<RectTransform>();
val4.viewport = ((Component)val).GetComponent<RectTransform>();
val2.SetParent(val3.transform);
((Component)val2).gameObject.AddComponent<ContentSizeFitter>();
((Component)val2).GetComponent<ContentSizeFitter>().verticalFit = (FitMode)1;
foreach (Transform item in val2)
{
Transform val5 = item;
((Component)val5).GetComponent<LayoutElement>().minHeight = 40f;
}
}
}
public class LycansUpPlayerUI
{
[CompilerGenerated]
private static class <>O
{
public static hook_ShowPlayMenu <0>__OnShowPlayMenu;
public static hook_ShowMainMenu <1>__OnShowMainMenu;
}
private const string REGION_DEFAULT = "us";
private const string SETTINGS_SERVER_REGION = "SETTINGS_SERVER_REGION";
private const string MAIN_MENU_PATH = "GameUI/Canvas/MainMenu/LayoutGroup/Body/LayoutGroup/ActionsContainer/LayoutGroup/";
private const string PLAY_MENU_PATH = "GameUI/Canvas/PlayMenu/LayoutGroup/Body/TaskPanel/Holder/LayoutGroup/";
public static void Hook()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: 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
object obj = <>O.<0>__OnShowPlayMenu;
if (obj == null)
{
hook_ShowPlayMenu val = OnShowPlayMenu;
<>O.<0>__OnShowPlayMenu = val;
obj = (object)val;
}
GameUI.ShowPlayMenu += (hook_ShowPlayMenu)obj;
object obj2 = <>O.<1>__OnShowMainMenu;
if (obj2 == null)
{
hook_ShowMainMenu val2 = OnShowMainMenu;
<>O.<1>__OnShowMainMenu = val2;
obj2 = (object)val2;
}
GameUI.ShowMainMenu += (hook_ShowMainMenu)obj2;
}
private static void OnShowMainMenu(orig_ShowMainMenu orig, GameUI self, bool active)
{
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Expected O, but got Unknown
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Expected O, but got Unknown
Log.Info("OnShowMainMenu");
orig.Invoke(self, active);
int maxPlayers = 20;
GameObject val = GameObject.Find("GameUI/Canvas/MainMenu/LayoutGroup/Body/LayoutGroup/ActionsContainer/LayoutGroup/HostButton");
GameObject val2 = GameObject.Find("GameUI/Canvas/MainMenu/LayoutGroup/Body/LayoutGroup/ActionsContainer/LayoutGroup/JoinButton");
if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
{
Log.Error("Host or Join button not found in Main Menu");
return;
}
Button hostBtn = val.GetComponent<Button>();
Button joinBtn = val2.GetComponent<Button>();
((UnityEventBase)hostBtn.onClick).RemoveAllListeners();
((UnityEvent)hostBtn.onClick).AddListener((UnityAction)delegate
{
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
Log.Info("Starting host session...");
((Selectable)hostBtn).interactable = false;
((Selectable)joinBtn).interactable = false;
NetworkRunnerHandler val3 = Object.FindFirstObjectByType<NetworkRunnerHandler>();
if ((Object)(object)val3 == (Object)null)
{
Log.Error("NetworkRunnerHandler instance not found");
}
else
{
string text = RoomCode.Create(5);
string text2 = (PlayerPrefs.HasKey("SETTINGS_SERVER_REGION") ? PlayerPrefs.GetString("SETTINGS_SERVER_REGION") : "us");
Scene activeScene = SceneManager.GetActiveScene();
val3.StartSession((GameMode)4, text, SceneRef.op_Implicit(((Scene)(ref activeScene)).buildIndex), text2, SteamAuth.Instance.InitToken(), maxPlayers, "Default", true);
}
});
GameUI.UpdatePlayerCount += (hook_UpdatePlayerCount)delegate(orig_UpdatePlayerCount orig, GameUI self, int count)
{
((TMP_Text)self.playerCount).text = $"{count}/{maxPlayers}";
};
}
private static void OnShowPlayMenu(orig_ShowPlayMenu orig, GameUI self)
{
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Expected O, but got Unknown
Log.Info("OnShowPlayMenu");
orig.Invoke(self);
GameObject val = GameObject.Find("GameUI/Canvas/PlayMenu/LayoutGroup/Body/TaskPanel/Holder/LayoutGroup/JoinButton");
if ((Object)(object)val == (Object)null)
{
Log.Error("Join button not found in Play Menu");
return;
}
Button codeJoinBtn = val.GetComponent<Button>();
((UnityEventBase)codeJoinBtn.onClick).RemoveAllListeners();
((UnityEvent)codeJoinBtn.onClick).AddListener((UnityAction)delegate
{
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: 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)
TMP_InputField component = GameObject.Find("GameUI/Canvas/MainMenu/LayoutGroup/Body/LayoutGroup/ActionsContainer/LayoutGroup/CodeInput").GetComponent<TMP_InputField>();
if ((Object)(object)component == (Object)null)
{
Log.Error("CodeInput field not found");
}
else
{
string text = component.text;
if (!string.IsNullOrWhiteSpace(text))
{
Log.Info("Joining session " + text + "...");
((Selectable)codeJoinBtn).interactable = false;
NetworkRunnerHandler val2 = Object.FindFirstObjectByType<NetworkRunnerHandler>();
if ((Object)(object)val2 == (Object)null)
{
Log.Error("NetworkRunnerHandler instance not found");
}
else
{
string text2 = (PlayerPrefs.HasKey("SETTINGS_SERVER_REGION") ? PlayerPrefs.GetString("SETTINGS_SERVER_REGION") : "us");
Scene activeScene = SceneManager.GetActiveScene();
val2.StartSession((GameMode)5, text, SceneRef.op_Implicit(((Scene)(ref activeScene)).buildIndex), text2, SteamAuth.Instance.InitToken(), 1, "Default", true);
}
}
}
});
}
}
}