Decompiled source of WerewolvesCompany v0.2.1
plugins/WerewolvesCompany/WerewolvesCompany.dll
Decompiled 4 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalCompanyInputUtils.Api; using Microsoft.CodeAnalysis; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.SceneManagement; using UnityEngine.UI; using WerewolvesCompany.Managers; using WerewolvesCompany.NetcodePatcher; using WerewolvesCompany.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("WerewolvesCompany")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+f971688a9d949f77250ae4d7e22021e08afc4efe")] [assembly: AssemblyProduct("WerewolvesCompany")] [assembly: AssemblyTitle("WerewolvesCompany")] [assembly: AssemblyVersion("1.0.0.0")] [module: NetcodePatchedAssembly] internal class <Module> { static <Module>() { NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<float>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<float>(); } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } public class InputsClass : LcInputActions { [InputAction(/*Could not decode attribute arguments.*/)] public InputAction MainRoleActionKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction SecondaryRoleActionKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction PopUpRoleActionKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction DistributeRolesKey { get; set; } } namespace WerewolvesCompany { [BepInPlugin("doep.WerewolvesCompany", "WerewolvesCompany", "0.2.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private const string GUID = "doep.WerewolvesCompany"; private const string NAME = "WerewolvesCompany"; private const string VERSION = "0.2.1"; internal static InputsClass InputActionsInstance; private readonly Harmony harmony = new Harmony("doep.WerewolvesCompany"); public static Plugin Instance; public GameObject netManagerPrefab; public ManualLogSource logger; public ManualLogSource logdebug; public ManualLogSource logupdate; public Random rng; public static ConfigEntry<float> config_DefaultInteractRange; public static ConfigEntry<float> config_DefaultActionCoolDown; public static ConfigEntry<float> config_DefaultStartOfRoundActionCoolDown; public static ConfigEntry<float> config_WerewolfInteractRange; public static ConfigEntry<float> config_WerewolfActionCoolDown; public static ConfigEntry<float> config_WerewolfStartOfRoundActionCoolDown; public static ConfigEntry<float> config_VillagerInteractRange; public static ConfigEntry<float> config_VillagerActionCoolDown; public static ConfigEntry<float> config_VillagerStartOfRoundActionCoolDown; public static ConfigEntry<float> config_WitchInteractRange; public static ConfigEntry<float> config_WitchActionCoolDown; public static ConfigEntry<float> config_WitchStartOfRoundActionCoolDown; public static ConfigEntry<float> config_SeerInteractRange; public static ConfigEntry<float> config_SeerActionCoolDown; public static ConfigEntry<float> config_SeerStartOfRoundActionCoolDown; public static ConfigEntry<float> config_WildBoyInteractRange; public static ConfigEntry<float> config_WildBoyActionCoolDown; public static ConfigEntry<float> config_WildboyStartOfRoundActionCoolDown; private void ConfigSetup() { config_DefaultInteractRange = ((BaseUnityPlugin)this).Config.Bind<float>("Default Interact Range", "Value", 1f, "How far the player can use his Action on another player."); config_DefaultActionCoolDown = ((BaseUnityPlugin)this).Config.Bind<float>("Default Role Action Cooldown", "Value", 120f, "How often can a player use his action (in seconds)."); config_DefaultStartOfRoundActionCoolDown = ((BaseUnityPlugin)this).Config.Bind<float>("Default Start of Round Role Action Cooldown", "Value", 120f, "How soon after the start of a round has started a player can use his action (in seconds)."); config_WerewolfInteractRange = ((BaseUnityPlugin)this).Config.Bind<float>("Werewolf Kill Range", "Value", 1f, "How far a Werewolf can kill another player."); config_WerewolfActionCoolDown = ((BaseUnityPlugin)this).Config.Bind<float>("Werewolf Kill Cooldown", "Value", 120f, "How often a Werewolf can kill another player (in seconds)."); config_WerewolfStartOfRoundActionCoolDown = ((BaseUnityPlugin)this).Config.Bind<float>("Werewolf Kill Cooldown at the start of a round", "Value", 120f, "How soon after the start of a round a Werewolf can Kill someone (in seconds)."); config_VillagerInteractRange = ((BaseUnityPlugin)this).Config.Bind<float>("Villager Interact Range", "Value", 1f, "Unused -- How far the player can use his Action on another player"); config_VillagerActionCoolDown = ((BaseUnityPlugin)this).Config.Bind<float>("Villager PatPat Cooldown", "Value", 0f, "Unused -- How often can a Villager use his action (in seconds)."); config_VillagerStartOfRoundActionCoolDown = ((BaseUnityPlugin)this).Config.Bind<float>("Villager PatPat Cooldown at the start of a round", "Value", 0f, "How soon after a round has started a Villager can PatPat another villager (in seconds)."); config_WitchInteractRange = ((BaseUnityPlugin)this).Config.Bind<float>("Witch Interact Range", "Value", 1f, "How far a Witch can use a potion on another."); config_WitchActionCoolDown = ((BaseUnityPlugin)this).Config.Bind<float>("Witch Potion Cooldown", "Value", 9999f, "How often a Witch can use each potion (in seconds)."); config_WitchStartOfRoundActionCoolDown = ((BaseUnityPlugin)this).Config.Bind<float>("Witch Potion Cooldown at the start of a round", "Value", 120f, "How soon after a round has started a Witch can use her potions (in seconds)."); config_SeerInteractRange = ((BaseUnityPlugin)this).Config.Bind<float>("Seer Seer Range", "Value", 10f, "How far the Seer can seer another player role."); config_SeerActionCoolDown = ((BaseUnityPlugin)this).Config.Bind<float>("Seer Seer Cooldown", "Value", 120f, "How often the Seer can seer another player role (in seconds)."); config_SeerStartOfRoundActionCoolDown = ((BaseUnityPlugin)this).Config.Bind<float>("Seer Seer Cooldown at the start of a round", "Value", 120f, "How soon after a round has started a Seer can seer a player role (in seconds)."); config_WildBoyInteractRange = ((BaseUnityPlugin)this).Config.Bind<float>("Wild Boy Idolize Range", "Value", 30f, "How far the Wild Boy can idolize another player."); config_WildBoyActionCoolDown = ((BaseUnityPlugin)this).Config.Bind<float>("Wild Boy Idolize Cooldown", "Value", 9999f, "How often the Wild Boy can idolize another player (in seconds)."); config_WildboyStartOfRoundActionCoolDown = ((BaseUnityPlugin)this).Config.Bind<float>("Wild Boy Idolize Cooldown at the start of a round", "Value", 0f, "How soon after a round has started a WildBoy can idolize another player (in seconds)."); } private void Awake() { //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Expected O, but got Unknown logger = Logger.CreateLogSource("doep.WerewolvesCompany"); logdebug = Logger.CreateLogSource("doep.WerewolvesCompany -- debug"); logupdate = Logger.CreateLogSource("doep.WerewolvesCompany -- update"); logger.LogInfo((object)"Plugin is initializing..."); Logger.Sources.Remove((ILogSource)(object)logdebug); Logger.Sources.Remove((ILogSource)(object)logupdate); Type[] types = Assembly.GetExecutingAssembly().GetTypes(); Type[] array = types; foreach (Type type in array) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array2 = methods; foreach (MethodInfo methodInfo in array2) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } } Instance = this; logdebug.LogInfo((object)"Setting up the config"); ConfigSetup(); logdebug.LogInfo((object)"Harmony patching"); harmony.PatchAll(); logdebug.LogInfo((object)"Initiate the random generator"); rng = new Random(); logdebug.LogInfo((object)"Creating the roles manager"); string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "netcodemod"); AssetBundle val = AssetBundle.LoadFromFile(text); netManagerPrefab = val.LoadAsset<GameObject>("Assets/WerewolvesCompany/RolesManager.prefab"); netManagerPrefab.AddComponent<RolesManager>(); logger.LogInfo((object)"Plugin.Awake() is creating ModManager."); GameObject val2 = new GameObject("ModManager"); val2.AddComponent<ModManager>(); Object.DontDestroyOnLoad((Object)(object)val2); Instance.logger.LogInfo((object)"ModManager GameObject created."); } private void RunChecks() { References.CheckIndividualRefInt(); } public void InitiateInputsSystem() { InputActionsInstance = new InputsClass(); } } public class ModManager : MonoBehaviour { public ManualLogSource logger = Plugin.Instance.logger; public ManualLogSource logdebug = Plugin.Instance.logdebug; public static ModManager Instance { get; private set; } private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); SceneManager.sceneLoaded += OnSceneLoaded; logger.LogInfo((object)"ModManager: Awake() called. Initialization started."); logger.LogInfo((object)"Manually initializing the ModManager"); Start(); logger.LogInfo((object)"ModManager setup is complete."); } else { Object.Destroy((Object)(object)((Component)this).gameObject); } } private void Start() { InitializeHUD(); InitializeCooldownManager(); } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { logdebug.LogInfo((object)("Scene loaded: " + ((Scene)(ref scene)).name + ". Reinitializing HUD components...")); InitializeHUD(); InitializeCooldownManager(); } private void InitializeRolesManager() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if ((Object)(object)Object.FindObjectOfType<RolesManager>() == (Object)null) { GameObject val = new GameObject("RolesManager"); val.AddComponent<RolesManager>(); logger.LogInfo((object)"RolesManager has been recreated."); } } private void InitializeHUD() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if ((Object)(object)Object.FindObjectOfType<RoleHUD>() == (Object)null) { GameObject val = new GameObject("RoleHUD"); val.AddComponent<RoleHUD>(); logdebug.LogInfo((object)"RoleHUD has been recreated."); } } private void InitializeCooldownManager() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if ((Object)(object)Object.FindObjectOfType<CooldownManager>() == (Object)null) { GameObject val = new GameObject("CooldownManager"); val.AddComponent<CooldownManager>(); logdebug.LogInfo((object)"CooldownManager has been recreated."); } } } internal class References { public static List<Role> GetAllRoles() { List<Role> list = new List<Role>(); list.Add(new Werewolf()); list.Add(new Villager()); list.Add(new Witch()); list.Add(new Seer()); list.Add(new WildBoy()); return list; } public static void CheckIndividualRefInt() { bool flag = true; List<Role> allRoles = GetAllRoles(); List<int> list = new List<int>(); foreach (Role item in allRoles) { if (list.Contains(item.refInt)) { flag = false; break; } list.Add(item.refInt); } if (!flag) { throw new Exception("There are duplicates RefInts within the roles"); } } public static Dictionary<int, Role> references() { List<Role> allRoles = GetAllRoles(); Dictionary<int, Role> dictionary = new Dictionary<int, Role>(); foreach (Role item in allRoles) { dictionary.Add(item.refInt, item); } return dictionary; } public static Role GetRoleByName(string roleName) { foreach (KeyValuePair<int, Role> item in references()) { Role value = item.Value; if (value.roleName.ToLower() == roleName.ToLower()) { return value; } } foreach (KeyValuePair<int, Role> item2 in references()) { Role value2 = item2.Value; if (value2.terminalName.ToLower() == roleName.ToLower()) { return value2; } } throw new Exception("No corresponding role found. This should have been caught earlier."); } } internal class Role { public ManualLogSource logger = Plugin.Instance.logger; public ManualLogSource logdebug = Plugin.Instance.logdebug; public RolesManager rolesManager = Utils.GetRolesManager(); public float currentMainActionCooldown; public float currentSecondaryActionCooldown; public float baseMainActionCooldown; public float baseSecondaryActionCooldown; public bool isImmune = false; public virtual string roleName { get; } public string terminalName => roleName.Replace(" ", "_"); public virtual int refInt { get; } public virtual string winCondition { get; } public virtual string roleDescription { get; set; } public virtual string rolePopUp => winCondition + " " + roleDescription; public virtual Sprite roleIcon => null; public ulong? targetInRangeId { get; set; } public string? targetInRangeName { get; set; } public virtual string mainActionKey => "Z"; public virtual string secondaryActionKey => "V"; public virtual string mainActionName => "Main Action Name"; public virtual string secondaryActionName => "Secondary Action Name"; public virtual string mainActionText => mainActionName + " " + targetInRangeName; public virtual string mainActionTooltip => ("[" + mainActionKey + "] " + mainActionText + " " + GetCurrentMainActionCooldownText()).Trim(); public virtual string secondaryActionText => secondaryActionName + " " + targetInRangeName; public virtual string secondaryActionTooltip => ("[" + secondaryActionKey + "] " + secondaryActionText + " " + GetCurrentSecondaryActionCooldownText()).Trim(); public virtual string roleActionText => GetRoleActionText(); public virtual NetworkVariable<float> interactRange => rolesManager.DefaultInteractRange; public virtual NetworkVariable<float> baseActionCooldown => rolesManager.DefaultActionCoolDown; public virtual NetworkVariable<float> startOfRoundActionCooldown => rolesManager.DefaultStartOfRoundActionCoolDown; public bool IsMainActionOnCooldown => currentMainActionCooldown > 0f; public bool IsSecondaryActionOnCooldown => currentSecondaryActionCooldown > 0f; public Role() { baseMainActionCooldown = baseActionCooldown.Value; baseSecondaryActionCooldown = baseActionCooldown.Value; currentMainActionCooldown = startOfRoundActionCooldown.Value; currentSecondaryActionCooldown = startOfRoundActionCooldown.Value; } public string GetRoleActionText() { if (secondaryActionText.Contains("Secondary Action Name")) { return mainActionTooltip; } return mainActionTooltip + "\n" + secondaryActionTooltip; } public void DisplayRolePopUp() { logdebug.LogInfo((object)"Display the role PopUp"); HUDManager.Instance.DisplayTip("You are a " + roleName, rolePopUp, false, false, "LC_Tip1"); } public virtual bool IsLocallyAllowedToPerformMainAction() { return !IsMainActionOnCooldown && targetInRangeId.HasValue; } public virtual bool IsLocallyAllowedToPerformSecondaryAction() { return !IsSecondaryActionOnCooldown && targetInRangeId.HasValue; } public virtual bool IsAllowedToPerformMainAction() { return true; } public virtual bool IsAllowedToPerformSecondaryAction() { return true; } public void GenericPerformMainAction() { //IL_005d: 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) bool flag = false; try { PerformMainAction(); flag = true; } catch (Exception ex) { HUDManager.Instance.DisplayTip("Error", "Failed to perform my Main Action", false, false, "LC_Tip1"); logger.LogError((object)"Failed to perform my role action"); logger.LogError((object)ex); } if (flag) { rolesManager.SuccessFullyPerformedMainActionServerRpc(); } } public void GenericPerformSecondaryAction() { //IL_005d: 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) bool flag = false; try { PerformSecondaryAction(); flag = true; } catch (Exception ex) { HUDManager.Instance.DisplayTip("Error", "Failed to perform my Secondary Action", false, false, "LC_Tip1"); logger.LogError((object)"Failed to perform my secondary action"); logger.LogError((object)ex); } if (flag) { rolesManager.SuccessFullyPerformedSecondaryActionServerRpc(); } } public virtual void PerformMainAction() { logger.LogInfo((object)(roleName + " has no main action.")); } public virtual void PerformSecondaryAction() { logger.LogInfo((object)(roleName + " has no secondary action.")); } public void SetMainActionOnCooldown() { currentMainActionCooldown = baseMainActionCooldown; } public void SetSecondaryActionOnCooldown() { currentSecondaryActionCooldown = baseSecondaryActionCooldown; } public void UpdateCooldowns(float deltaTime) { currentMainActionCooldown -= deltaTime; currentSecondaryActionCooldown -= deltaTime; } private string GetCurrentMainActionCooldownText() { if (currentMainActionCooldown <= 0f) { return ""; } return $"({(int)currentMainActionCooldown}s)"; } private string GetCurrentSecondaryActionCooldownText() { if (currentSecondaryActionCooldown <= 0f) { return ""; } return $"({(int)currentSecondaryActionCooldown}s)"; } public virtual void NotifyMainActionSuccess(string targetPlayerName) { HUDManager.Instance.DisplayTip(roleName, "Main action success", false, false, "LC_Tip1"); } public virtual void NotifySecondaryActionSuccess(string targetPlayerName) { HUDManager.Instance.DisplayTip(roleName, "Secondary action success", false, false, "LC_Tip1"); } public virtual void NotifyMainActionFailed(string targetPlayerName) { HUDManager.Instance.DisplayTip(roleName, "Main action failed", false, false, "LC_Tip1"); } public virtual void NotifySecondaryActionFailed(string targetPlayerName) { HUDManager.Instance.DisplayTip(roleName, "Secondary action failed", false, false, "LC_Tip1"); } public virtual void NotifyMainActionSuccess(string targetPlayerName, Role role) { } public virtual void NotifyMainActionSuccess(ulong targetId) { } public ulong GrabTargetPlayer() { if (!targetInRangeId.HasValue) { logger.LogError((object)"targetInRange is null. It should have been caught earlier. Halting execution"); throw new Exception("targetInRange should not be null at this point"); } return targetInRangeId.Value; } } internal class Werewolf : Role { public override string roleName => "Werewolf"; public override int refInt => 0; public override string winCondition => "You win by killing all Villagers"; public override string roleDescription => "You have the ability to kill other players"; public override string mainActionName => "Kill"; public override NetworkVariable<float> interactRange => rolesManager.WerewolfInteractRange; public override NetworkVariable<float> baseActionCooldown => rolesManager.WerewolfActionCoolDown; public override NetworkVariable<float> startOfRoundActionCooldown => rolesManager.WerewolfStartOfRoundActionCoolDown; public override void PerformMainAction() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) logger.LogInfo((object)("The " + roleName + " is hunting!")); ulong num = GrabTargetPlayer(); logger.LogInfo((object)("Killing " + rolesManager.GetPlayerById(num).playerUsername + ".")); rolesManager.WerewolfKillPlayerServerRpc(num); } public override void NotifyMainActionSuccess(string targetPlayerName) { logger.LogInfo((object)("Successfully killed " + targetPlayerName + ".")); HUDManager.Instance.DisplayTip(roleName ?? "", "You killed " + targetPlayerName + ".", false, false, "LC_Tip1"); } public override void NotifyMainActionFailed(string targetPlayerName) { logger.LogInfo((object)("Failed to kill " + targetPlayerName + ", he was immune")); HUDManager.Instance.DisplayTip(roleName ?? "", targetPlayerName + " was immune", false, false, "LC_Tip1"); } } internal class Villager : Role { public override string roleName => "Villager"; public override int refInt => 1; public override string winCondition => "You win by killing the Werewolves."; public override string roleDescription => "You do not have any special ability."; public override string roleActionText => ""; public override NetworkVariable<float> interactRange => rolesManager.VillagerInteractRange; public override NetworkVariable<float> baseActionCooldown => rolesManager.VillagerActionCoolDown; public override NetworkVariable<float> startOfRoundActionCooldown => rolesManager.VillagerStartOfRoundActionCoolDown; public override void PerformMainAction() { logger.LogInfo((object)("The " + roleName + " is staying safe.")); HUDManager.Instance.DisplayTip(roleName ?? "", "*pat pat*", false, false, "LC_Tip1"); } } internal class Witch : Role { public override string roleName => "Witch"; public override int refInt => 2; public override string winCondition => "You win by killing the Werewolves."; public override string roleDescription => "You have the ability to protect one player, and kill another one."; public override string mainActionName => "Poison"; public override string secondaryActionName => "Protect"; public override NetworkVariable<float> interactRange => rolesManager.WitchInteractRange; public override NetworkVariable<float> baseActionCooldown => rolesManager.WitchActionCoolDown; public override NetworkVariable<float> startOfRoundActionCooldown => rolesManager.WitchStartOfRoundActionCoolDown; public override void PerformMainAction() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) logger.LogInfo((object)("The " + roleName + " is poisoning someone.")); ulong targetId = GrabTargetPlayer(); rolesManager.WitchPoisonPlayerServerRpc(targetId); } public override void PerformSecondaryAction() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) logger.LogInfo((object)("The " + roleName + " is immunising someone.")); ulong targetId = GrabTargetPlayer(); rolesManager.WitchImmunizePlayerServerRpc(targetId); } public override void NotifyMainActionSuccess(string targetPlayerName) { logger.LogInfo((object)("Successfully poisoned " + targetPlayerName + ".")); HUDManager.Instance.DisplayTip(roleName ?? "", "You poisoned " + targetPlayerName + ".", false, false, "LC_Tip1"); } public override void NotifySecondaryActionSuccess(string targetPlayerName) { logger.LogInfo((object)("Successfully immunized " + targetPlayerName + ".")); HUDManager.Instance.DisplayTip(roleName ?? "", "You immunized " + targetPlayerName + ".", false, false, "LC_Tip1"); } } internal class Seer : Role { public override string roleName => "Seer"; public override int refInt => 3; public override string winCondition => "You win by killing the Werewolves."; public override string roleDescription => "You have the ability to see a player's role."; public override string mainActionName => "Seer role"; public override string mainActionText => "Seer " + base.targetInRangeName + "'s role"; public override NetworkVariable<float> interactRange => rolesManager.SeerInteractRange; public override NetworkVariable<float> baseActionCooldown => rolesManager.SeerActionCooldown; public override NetworkVariable<float> startOfRoundActionCooldown => rolesManager.SeerStartOfRoundActionCoolDown; public override void PerformMainAction() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) logger.LogInfo((object)("The " + roleName + " is omniscient.")); logger.LogInfo((object)"Looking the role of someone"); ulong targetId = GrabTargetPlayer(); rolesManager.CheckRoleServerRpc(targetId); } public override void NotifyMainActionSuccess(string targetPlayerName, Role role) { logdebug.LogInfo((object)"Displaying Checked role on HUD"); HUDManager.Instance.DisplayTip("Dear " + roleName, targetPlayerName + " is a " + role.roleName, false, false, "LC_Tip1"); } } internal class WildBoy : Role { public string _roleDescription = "You can idolize a player. If he dies, you become a werewolf."; public ulong? idolizedId; public override string roleName => "Wild Boy"; public override int refInt => 4; public override string winCondition => "For now, you win with the village."; public override string roleDescription { get { return _roleDescription; } set { _roleDescription = value; } } public override string mainActionName => "Idolize"; public override NetworkVariable<float> interactRange => rolesManager.WildBoyInteractRange; public override NetworkVariable<float> baseActionCooldown => rolesManager.WildBoyActionCoolDown; public override NetworkVariable<float> startOfRoundActionCooldown => rolesManager.WildBoyStartOfRoundActionCoolDown; public override void PerformMainAction() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) logger.LogInfo((object)("The " + roleName + " is loitering.")); logger.LogInfo((object)"Idolizing someone"); ulong targetId = GrabTargetPlayer(); rolesManager.IdolizeServerRpc(targetId); } public override void NotifyMainActionSuccess(ulong targetId) { logdebug.LogInfo((object)"I am running the Idolization Confirmation"); idolizedId = targetId; logdebug.LogInfo((object)"I have set my idolization mentor"); string playerUsername = rolesManager.GetPlayerById(targetId).playerUsername; roleDescription = "You have idolized " + playerUsername + ". If he dies, you become a werewolf."; logdebug.LogInfo((object)"Displaying Idolization on HUD"); HUDManager.Instance.DisplayTip("Dear " + roleName, "You have idolized " + playerUsername + ". If he dies, you will become a werewolf.", false, false, "LC_Tip1"); } public void BecomeWerewolf() { HUDManager.Instance.DisplayTip("Dear " + roleName, "Your mentor " + rolesManager.GetPlayerById(idolizedId.Value).playerUsername + " is dead. You have become a werewolf.", false, false, "LC_Tip1"); rolesManager.myRole = new Werewolf(); } } internal static class Utils { public static ManualLogSource logger = Plugin.Instance.logger; public static ManualLogSource logdebug = Plugin.Instance.logdebug; public static void PrintDictionary<T1, T2>(Dictionary<T1, T2> dictionary) { foreach (KeyValuePair<T1, T2> item in dictionary) { logdebug.LogInfo((object)$"{item.Key} > {item.Value}"); } } public static ClientRpcParams BuildClientRpcParams(ulong targetId) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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) ClientRpcParams result = default(ClientRpcParams); result.Send = new ClientRpcSendParams { TargetClientIds = new ulong[1] { targetId } }; return result; } public static PlayerControllerB GetLocalPlayerControllerB() { return StartOfRound.Instance?.localPlayerController; } public static RolesManager GetRolesManager() { return Object.FindObjectOfType<RolesManager>(); } } } namespace WerewolvesCompany.UI { internal class RoleHUD : MonoBehaviour { public RoleHUD Instance; public RolesManager rolesManager = Utils.GetRolesManager(); public ManualLogSource logger = Plugin.Instance.logger; public ManualLogSource logdebug = Plugin.Instance.logdebug; public ManualLogSource logupdate = Plugin.Instance.logupdate; public Canvas canvas; public Text roleText; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); } else { logger.LogInfo((object)"Duplicate detected, delted the just-created RoleHUD"); Object.Destroy((Object)(object)((Component)this).gameObject); } logger.LogInfo((object)"Manually Starting the RoleHUD"); Start(); } private void Start() { } private void Update() { if ((Object)(object)rolesManager == (Object)null) { rolesManager = Utils.GetRolesManager(); } } private void OnDestroy() { } private void CreateRoleHUD() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_0105: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) canvas = new GameObject("RoleHUDCanvas").AddComponent<Canvas>(); canvas.renderMode = (RenderMode)0; Object.DontDestroyOnLoad((Object)(object)((Component)canvas).gameObject); GameObject val = new GameObject("RoleContainer"); val.transform.SetParent(((Component)canvas).transform); HorizontalLayoutGroup val2 = val.AddComponent<HorizontalLayoutGroup>(); ((LayoutGroup)val2).childAlignment = (TextAnchor)1; ((HorizontalOrVerticalLayoutGroup)val2).spacing = 10f; ((LayoutGroup)val2).padding = new RectOffset(10, 10, 10, 10); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0.5f, 1f); component.anchorMax = new Vector2(0.5f, 1f); component.pivot = new Vector2(0.5f, 1f); component.anchoredPosition = new Vector2(0f, -5f); component.sizeDelta = new Vector2(500f, 200f); GameObject val3 = new GameObject("RoleText"); val3.transform.SetParent(val.transform); roleText = val3.AddComponent<Text>(); roleText.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); roleText.text = "Role: Unknown"; roleText.alignment = (TextAnchor)1; roleText.fontSize = 24; ((Graphic)roleText).color = Color.white; RectTransform component2 = ((Component)roleText).GetComponent<RectTransform>(); component2.sizeDelta = new Vector2(500f, 200f); component2.anchorMin = new Vector2(0.5f, 1f); component2.anchorMax = new Vector2(0.5f, 1f); component2.anchoredPosition = new Vector2(0f, 0f); component2.pivot = new Vector2(0.5f, 1f); } public void UpdateRoleDisplay() { if ((Object)(object)canvas == (Object)null) { CreateRoleHUD(); } if (rolesManager.myRole == null) { roleText.text = ""; return; } Role myRole = rolesManager.myRole; if ((Object)(object)roleText != (Object)null) { string text = myRole.roleName + "\n" + myRole.roleActionText.Replace(" ", " "); roleText.text = text; } } public void UpdateToolTip() { PlayerControllerB localPlayerControllerB = Utils.GetLocalPlayerControllerB(); if (((TMP_Text)localPlayerControllerB.cursorTip).text.Contains(rolesManager.myRole.mainActionName)) { ((TMP_Text)localPlayerControllerB.cursorTip).text = ""; } if (rolesManager.myRole.targetInRangeId.HasValue) { ((TMP_Text)localPlayerControllerB.cursorTip).text = rolesManager.myRole.roleActionText; } } } } namespace WerewolvesCompany.Patches { [HarmonyPatch(typeof(GameNetworkManager))] internal class GameNetworkManagerPatcher { [HarmonyPostfix] [HarmonyPatch("Start")] private static void AddToPrefabs(ref GameNetworkManager __instance) { ((Component)__instance).GetComponent<NetworkManager>().AddNetworkPrefab(Plugin.Instance.netManagerPrefab); } } [HarmonyPatch(typeof(PlayerControllerB))] internal class PlayerControllerBPatcher { public static ManualLogSource logger = Plugin.Instance.logger; public static ManualLogSource logdebug = Plugin.Instance.logdebug; public static ManualLogSource logupdate = Plugin.Instance.logupdate; private static RolesManager rolesManager = Utils.GetRolesManager(); private static RoleHUD roleHUD = Object.FindObjectOfType<RoleHUD>(); [HarmonyPostfix] [HarmonyPatch("Start")] private static void InitiateRole() { Role role = new Werewolf(); } [HarmonyPostfix] [HarmonyPatch("LateUpdate")] private static void LateUpdate(PlayerControllerB __instance) { if (((NetworkBehaviour)__instance).IsOwner && rolesManager.myRole != null) { PlayerControllerB val = rolesManager.CheckForPlayerInRange(((NetworkBehaviour)__instance).NetworkObjectId, logupdate); if ((Object)(object)val == (Object)null) { rolesManager.myRole.targetInRangeId = null; rolesManager.myRole.targetInRangeName = null; } else { rolesManager.myRole.targetInRangeId = val.playerClientId; rolesManager.myRole.targetInRangeName = val.playerUsername; } roleHUD.UpdateRoleDisplay(); roleHUD.UpdateToolTip(); } } [HarmonyPostfix] [HarmonyPatch("KillPlayer")] private static void OnDeathNotifyServerOfDeath(PlayerControllerB __instance) { rolesManager.OnSomebodyDeathServerRpc(__instance.playerClientId); } } [HarmonyPatch(typeof(PlayerInput))] internal class PlayerInputPatcher { public static ManualLogSource logger = Plugin.Instance.logger; public static ManualLogSource logdebug = Plugin.Instance.logdebug; public static ManualLogSource logupdate = Plugin.Instance.logupdate; [HarmonyPostfix] [HarmonyPatch("InitializeActions")] private static void IntializeCustomKeybinds() { logger.LogInfo((object)"Setting up keybinds"); Plugin.Instance.InitiateInputsSystem(); } } [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatcher { public static ManualLogSource logger = Plugin.Instance.logger; public static ManualLogSource logdebug = Plugin.Instance.logdebug; private static RolesManager rolesManager => Utils.GetRolesManager(); [HarmonyPostfix] [HarmonyPatch("Start")] private static void spawnNetManager(StartOfRound __instance) { if (((NetworkBehaviour)__instance).IsHost) { GameObject val = Object.Instantiate<GameObject>(Plugin.Instance.netManagerPrefab); val.GetComponent<NetworkObject>().Spawn(false); } } [HarmonyPostfix] [HarmonyPatch("StartGame")] private static void SendPlayersTheirRole(StartOfRound __instance) { if (((NetworkBehaviour)__instance).IsHost || ((NetworkBehaviour)__instance).IsServer) { logger.LogInfo((object)"Providing roles"); rolesManager.BuildAndSendRoles(); } } } [HarmonyPatch] internal class TerminalPatcher { public static Terminal terminalInstance; public static bool initializedTerminalNodes = false; public static ManualLogSource logger = Plugin.Instance.logger; public static ManualLogSource logdebug = Plugin.Instance.logdebug; public static ManualLogSource logupdate = Plugin.Instance.logupdate; private static RolesManager rolesManager => Utils.GetRolesManager(); public static List<Role> availableRoles => References.GetAllRoles(); [HarmonyPostfix] [HarmonyPatch(typeof(Terminal), "Awake")] private static void InitializeTerminal(Terminal __instance) { terminalInstance = __instance; initializedTerminalNodes = false; EditExistingTerminalNodes(); } private static void EditExistingTerminalNodes() { logdebug.LogInfo((object)"Editting existing terminal nodes"); initializedTerminalNodes = true; foreach (TerminalNode specialNode in terminalInstance.terminalNodes.specialNodes) { if (((Object)specialNode).name == "Start" && !specialNode.displayText.Contains("[WerwolvesCompany]")) { logdebug.LogInfo((object)"Editting Start node"); string text = "Type \"Help\" for a list of commands."; int num = specialNode.displayText.IndexOf(text); if (num != -1) { num += text.Length; string value = "\n\n[Werewolves Company]\nType \"Werewolves\" for a list of commands."; specialNode.displayText = specialNode.displayText.Insert(num, value); } else { logger.LogError((object)"Failed to add werewolves tip to terminal. Maybe an update broke it?"); } } else if (((Object)specialNode).name == "HelpCommands" && !specialNode.displayText.Contains(">WEREWOLVES")) { logdebug.LogInfo((object)"Editting HelpCommands node"); string value2 = "[numberOfItemsOnRoute]"; int num2 = specialNode.displayText.IndexOf(value2); if (num2 != -1) { string value3 = ">WEREWOLVES\nFor a list of Werewolves commands.\n\n"; specialNode.displayText = specialNode.displayText.Insert(num2, value3); } } } } [HarmonyPostfix] [HarmonyPatch(typeof(Terminal), "BeginUsingTerminal")] private static void OnBeginUsingTerminal(Terminal __instance) { logdebug.LogInfo((object)"I just started using the terminal"); if (!initializedTerminalNodes) { EditExistingTerminalNodes(); } } [HarmonyPrefix] [HarmonyPatch(typeof(Terminal), "ParsePlayerSentence")] private static bool ParsePlayerSentence(ref TerminalNode __result, Terminal __instance) { if (__instance.screenText.text.Length <= 0) { logdebug.LogInfo((object)"Apparently the text length was negative?"); return true; } string text = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded).ToLower(); string[] array = text.Split(' '); logdebug.LogInfo((object)("Parsing sentence " + text)); logdebug.LogInfo((object)("Input: " + text + ", with args: " + array.ToString() + " of length " + array.Length)); if (!text.StartsWith("werewolves") && !text.StartsWith("wc")) { logdebug.LogInfo((object)"Not a werewolves command"); return true; } if (text.StartsWith("werewolves") || text.StartsWith("wc")) { logdebug.LogInfo((object)"werewolves command was invoked"); if (array.Length == 1) { logger.LogInfo((object)"Loading WerewolvesCompany Terminal's home menu"); __result = BuildTerminalNodeHome(); } else if (array[1].ToLower() == "add") { for (int i = 2; i < array.Length; i++) { string text2 = array[i]; if (!RoleIsAvailable(text2)) { logger.LogInfo((object)("Cannot add the role " + text2 + ", it is not part of the available roles")); __result = BuildRoleNotAvailableNode(text2); } else { AddNewRole(text2); logger.LogInfo((object)("Added role " + text2 + " to the current roles")); __result = BuildTerminalNodeHome(); } } } else { if (!(array[1].ToLower() == "delete") && !(array[1].ToLower() == "del")) { if (array[1].ToLower() == "debug") { __result = BuildTerminalNodeDebug(); if (array.Length == 2) { return false; } if (array[2].ToLower() == "cd") { rolesManager.ResetAllCooldownsServerRpc(); } if (array[2].ToLower() == "distrib" || array[2].ToLower() == "distribute") { rolesManager.BuildAndSendRoles(); } if (array[2].ToLower() == "reset") { rolesManager.ResetRolesServerRpc(); } return false; } return true; } if (array.Length > 3) { logger.LogInfo((object)"Can only delete roles one at a time"); __result = BuilDeleteRolesOnceAtATimeNode(); return false; } for (int j = 2; j < array.Length; j++) { string text3 = array[j]; if (!RoleIsInPlay(text3)) { logger.LogInfo((object)("Cannot delete the role " + text3 + ", it is not part of the current roles")); __result = BuildRoleNotInPlayNode(text3); } else { DeleteRole(text3); logger.LogInfo((object)("Removed role " + text3 + " from the current roles")); __result = BuildTerminalNodeHome(); } } } return false; } logdebug.LogInfo((object)"Not a werewolf command, pass."); return true; } private static void AddNewRole(string roleName) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) Role roleByName = References.GetRoleByName(roleName); logger.LogInfo((object)("Adding role " + roleByName.roleName + " to the list")); rolesManager.currentRolesSetup.Add(roleByName); rolesManager.UpdateCurrentRolesServerRpc(rolesManager.WrapRolesList(rolesManager.currentRolesSetup)); } private static void DeleteRole(string roleName) { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < rolesManager.currentRolesSetup.Count; i++) { logdebug.LogInfo((object)("Checking " + roleName + " against " + rolesManager.currentRolesSetup[i].terminalName)); if (rolesManager.currentRolesSetup[i].terminalName.ToLower() == roleName.ToLower()) { logger.LogInfo((object)("Delete role " + rolesManager.currentRolesSetup[i].terminalName.ToLower() + " from the list")); rolesManager.currentRolesSetup.RemoveAt(i); rolesManager.UpdateCurrentRolesServerRpc(rolesManager.WrapRolesList(rolesManager.currentRolesSetup)); return; } } throw new Exception("Role " + roleName + " not found in the list of current roles. This shoud have been caught earlier."); } private static void RemoveRole(string roleName) { } private static TerminalNode BuildTerminalNodeDebug() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown return new TerminalNode { displayText = "[Werewolves Company]\n\n------------------------------\nDebug commands\n------------------------------\nwc debug -> show this page\nwc debug cd -> set all players cooldowns to 0\nwc debug distrib -> distribute roles\nwc debug reset -> reset all players roles to their initial state\n\n", clearPreviousText = true, acceptAnything = false }; } private static TerminalNode BuildTerminalNodeHome() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) TerminalNode result = new TerminalNode { displayText = "[Werewolves Company]\n\n------------------------------\n[[[availableRoles]]]\n------------------------------\n[[[currentRolesSetup]]]\n\n", clearPreviousText = true, acceptAnything = false }; rolesManager.QueryCurrentRolesServerRpc(); return result; } private static TerminalNode BuildRoleNotAvailableNode(string roleName) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown return new TerminalNode { displayText = "[Werewolves Company]\n\n------------------------------\nThe role '" + roleName + "' is not available\n\n", clearPreviousText = true, acceptAnything = false }; } private static TerminalNode BuildRoleNotInPlayNode(string roleName) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown return new TerminalNode { displayText = "[Werewolves Company]\n\n------------------------------\nThe role '" + roleName + "' is not part of the current roles\n\n", clearPreviousText = true, acceptAnything = false }; } private static TerminalNode BuilDeleteRolesOnceAtATimeNode() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown return new TerminalNode { displayText = "[Werewolves Company]\n\n------------------------------\nPlease remove roles one at a time\n\n", clearPreviousText = true, acceptAnything = false }; } [HarmonyPrefix] [HarmonyPatch(typeof(Terminal), "TextPostProcess")] private static void TextPostProcess(ref string modifiedDisplayText, TerminalNode node) { logdebug.LogInfo((object)"I just started text post processing"); if (modifiedDisplayText.Length <= 0) { return; } string text = "[[[availableRoles]]]"; if (modifiedDisplayText.Contains(text)) { int num = modifiedDisplayText.IndexOf(text); int num2 = num + text.Length; string oldValue = modifiedDisplayText.Substring(num, num2 - num); string text2 = ""; text2 += "Available Roles:\n"; foreach (Role availableRole in availableRoles) { text2 = text2 + availableRole.terminalName + "\n"; } modifiedDisplayText = modifiedDisplayText.Replace(oldValue, text2); } string text3 = "[[[currentRolesSetup]]]"; if (!modifiedDisplayText.Contains(text3)) { return; } int num3 = modifiedDisplayText.IndexOf(text3); int num4 = num3 + text3.Length; string oldValue2 = modifiedDisplayText.Substring(num3, num4 - num3); string text4 = ""; text4 += "Current Roles Setup:\n"; foreach (Role item in rolesManager.currentRolesSetup) { text4 = text4 + item.terminalName + "\n"; } text4 += "\nRemaining slots will be filled with Villagers\n\n"; text4 += "Add roles -> werewolves add role_name\n"; text4 += "Delete roles -> werewolves del role_name\n\n"; modifiedDisplayText = modifiedDisplayText.Replace(oldValue2, text4); } private static bool RoleIsAvailable(string roleName) { foreach (Role availableRole in availableRoles) { if (availableRole.terminalName.ToLower() == roleName.ToLower()) { return true; } } return false; } private static bool RoleIsInPlay(string roleName) { foreach (Role item in rolesManager.currentRolesSetup) { if (item.terminalName.ToLower() == roleName.ToLower()) { return true; } } return false; } } } namespace WerewolvesCompany.Managers { public class CooldownManager : MonoBehaviour { public CooldownManager Instance; public ManualLogSource logger = Plugin.Instance.logger; public ManualLogSource logdebug = Plugin.Instance.logdebug; private RolesManager rolesManager = Utils.GetRolesManager(); private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); } else { logger.LogInfo((object)"Duplicate detected, delted the just-created CooldownManager"); Object.Destroy((Object)(object)((Component)this).gameObject); } } public void Update() { if (!((Object)(object)rolesManager == (Object)null) && rolesManager.myRole != null) { rolesManager.myRole.UpdateCooldowns(Time.deltaTime); } } } public class NetworkManagerWerewolvesCompany : NetworkBehaviour { public static NetworkManagerWerewolvesCompany Instance; public ManualLogSource logger = Plugin.Instance.logger; public ManualLogSource logdebug = Plugin.Instance.logdebug; private void Awake() { Instance = this; } [ServerRpc(RequireOwnership = false)] public void SimpleTipDisplayServerRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: 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_006d: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1605714106u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1605714106u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { SimpleTipDisplayClientRpc(); } } } [ClientRpc] public void SimpleTipDisplayClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: 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_006d: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2263611962u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2263611962u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { logdebug.LogInfo((object)"Displaying a simple tip"); HUDManager.Instance.DisplayTip("Test Header", "Test Text", false, false, "LC_Tip1"); logdebug.LogInfo((object)"Displayed a simple tip"); } } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } [RuntimeInitializeOnLoadMethod] internal static void InitializeRPCS_NetworkManagerWerewolvesCompany() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown NetworkManager.__rpc_func_table.Add(1605714106u, new RpcReceiveHandler(__rpc_handler_1605714106)); NetworkManager.__rpc_func_table.Add(2263611962u, new RpcReceiveHandler(__rpc_handler_2263611962)); } private static void __rpc_handler_1605714106(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((NetworkManagerWerewolvesCompany)(object)target).SimpleTipDisplayServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2263611962(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)2; ((NetworkManagerWerewolvesCompany)(object)target).SimpleTipDisplayClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "NetworkManagerWerewolvesCompany"; } } internal class RolesManager : NetworkBehaviour { public RolesManager Instance; public ManualLogSource logger = Plugin.Instance.logger; public ManualLogSource logdebug = Plugin.Instance.logdebug; public ManualLogSource logupdate = Plugin.Instance.logupdate; public Random rng = Plugin.Instance.rng; public Dictionary<ulong, Role> allRoles; public List<Role> currentRolesSetup = new List<Role>(); public NetworkVariable<float> DefaultInteractRange = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<float> DefaultActionCoolDown = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<float> DefaultStartOfRoundActionCoolDown = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<float> WerewolfInteractRange = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<float> WerewolfActionCoolDown = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<float> WerewolfStartOfRoundActionCoolDown = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<float> VillagerInteractRange = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<float> VillagerActionCoolDown = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<float> VillagerStartOfRoundActionCoolDown = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<float> WitchInteractRange = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<float> WitchActionCoolDown = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<float> WitchStartOfRoundActionCoolDown = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<float> SeerInteractRange = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<float> SeerActionCooldown = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<float> SeerStartOfRoundActionCoolDown = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<float> WildBoyInteractRange = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<float> WildBoyActionCoolDown = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<float> WildBoyStartOfRoundActionCoolDown = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public Role? myRole { get; set; } public override void OnNetworkSpawn() { logger.LogInfo((object)"Setup Keybinds CallBacks"); SetupKeybindCallbacks(); if (((NetworkBehaviour)this).IsServer) { MakeDefaultRoles(); DefaultInteractRange.Value = Plugin.config_DefaultInteractRange.Value; DefaultActionCoolDown.Value = Plugin.config_DefaultActionCoolDown.Value; DefaultStartOfRoundActionCoolDown.Value = Plugin.config_DefaultStartOfRoundActionCoolDown.Value; WerewolfInteractRange.Value = Plugin.config_WerewolfInteractRange.Value; WerewolfActionCoolDown.Value = Plugin.config_WerewolfActionCoolDown.Value; WerewolfStartOfRoundActionCoolDown.Value = Plugin.config_WerewolfStartOfRoundActionCoolDown.Value; VillagerInteractRange.Value = Plugin.config_VillagerInteractRange.Value; VillagerActionCoolDown.Value = Plugin.config_VillagerActionCoolDown.Value; VillagerStartOfRoundActionCoolDown.Value = Plugin.config_VillagerStartOfRoundActionCoolDown.Value; WitchInteractRange.Value = Plugin.config_WitchInteractRange.Value; WitchActionCoolDown.Value = Plugin.config_WitchActionCoolDown.Value; WitchStartOfRoundActionCoolDown.Value = Plugin.config_WitchStartOfRoundActionCoolDown.Value; SeerInteractRange.Value = Plugin.config_SeerInteractRange.Value; SeerActionCooldown.Value = Plugin.config_SeerActionCoolDown.Value; SeerStartOfRoundActionCoolDown.Value = Plugin.config_SeerStartOfRoundActionCoolDown.Value; WildBoyInteractRange.Value = Plugin.config_WildBoyInteractRange.Value; WildBoyActionCoolDown.Value = Plugin.config_WildBoyActionCoolDown.Value; WildBoyStartOfRoundActionCoolDown.Value = Plugin.config_WildboyStartOfRoundActionCoolDown.Value; } } private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); } else { logdebug.LogInfo((object)"Duplicate detected, delted the just-created RolesManager"); Object.Destroy((Object)(object)((Component)this).gameObject); } } private void SetupKeybindCallbacks() { Plugin.InputActionsInstance.MainRoleActionKey.performed += OnRoleMainKeyPressed; Plugin.InputActionsInstance.SecondaryRoleActionKey.performed += OnRoleSecondaryKeyPressed; Plugin.InputActionsInstance.PopUpRoleActionKey.performed += OnPopUpRoleActionKeyPressed; Plugin.InputActionsInstance.DistributeRolesKey.performed += OnDistributeRolesKeyPressed; } public void OnRoleMainKeyPressed(CallbackContext keyContext) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) if (myRole != null && myRole.roleName != null && ((CallbackContext)(ref keyContext)).performed) { if (!myRole.IsLocallyAllowedToPerformMainAction()) { logdebug.LogInfo((object)"I am not locally allowed to perform my Main Action"); return; } logdebug.LogInfo((object)("Pressed the key, performing main action for my role " + myRole.roleName)); PerformMainActionServerRpc(); } } public void OnRoleSecondaryKeyPressed(CallbackContext keyContext) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) if (myRole != null && myRole.roleName != null && ((CallbackContext)(ref keyContext)).performed) { if (!myRole.IsLocallyAllowedToPerformSecondaryAction()) { logdebug.LogInfo((object)"I am not locally allowed to perform my Secondary Action"); return; } logdebug.LogInfo((object)("Pressed the key, performing secondary action for my role " + myRole.roleName)); PerformSecondaryActionServerRpc(); } } public void OnPopUpRoleActionKeyPressed(CallbackContext keyContext) { DisplayMyRolePopUp(); } public void OnDistributeRolesKeyPressed(CallbackContext keyContext) { if (((NetworkBehaviour)this).IsHost && ((CallbackContext)(ref keyContext)).performed) { BuildAndSendRoles(); } } public override void OnDestroy() { ((NetworkBehaviour)this).OnDestroy(); logger.LogError((object)(((Object)this).name + " has been destroyed!")); } private void Update() { if (myRole != null) { myRole.UpdateCooldowns(Time.deltaTime); } } public PlayerControllerB? CheckForPlayerInRange(ulong myId, ManualLogSource mls) { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) if (myRole == null) { throw new Exception("myRole is null in CheckForPlayerInRange. This should have been caught earlier."); } mls.LogInfo((object)$"My clientId is {myId}"); mls.LogInfo((object)"Grab the PlayerControllerB"); GameObject playerByNetworkId = GetPlayerByNetworkId(myId); PlayerControllerB component = playerByNetworkId.GetComponent<PlayerControllerB>(); mls.LogInfo((object)"Grab the Camera"); Camera gameplayCamera = component.gameplayCamera; mls.LogInfo((object)"Grab the layer"); int num = 1 << playerByNetworkId.layer; mls.LogInfo((object)"Cast rays"); Vector3 forward = ((Component)gameplayCamera).transform.forward; Vector3 normalized = ((Vector3)(ref forward)).normalized; RaycastHit[] array = Physics.RaycastAll(((Component)gameplayCamera).transform.position, normalized, myRole.interactRange.Value, num); RaycastHit[] array2 = array; for (int i = 0; i < array2.Length; i++) { RaycastHit val = array2[i]; if ((Object)(object)((Component)((RaycastHit)(ref val)).transform).gameObject != (Object)(object)playerByNetworkId) { return ((Component)((RaycastHit)(ref val)).transform).GetComponent<PlayerControllerB>(); } } return null; } private static GameObject GetPlayerByNetworkId(ulong playerId) { if (NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(playerId, out var value)) { return ((Component)value).gameObject; } return null; } public PlayerControllerB GetPlayerById(ulong playerId) { GameObject[] allPlayerObjects = StartOfRound.Instance.allPlayerObjects; GameObject[] array = allPlayerObjects; foreach (GameObject val in array) { if (playerId == val.GetComponent<PlayerControllerB>().playerClientId) { return val.GetComponent<PlayerControllerB>(); } } logger.LogError((object)"Could not find the desired player"); throw new Exception("Could not find the player"); } public void BuildAndSendRoles() { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) logger.LogInfo((object)"Roles generation has started"); Dictionary<ulong, Role> dictionary = BuildFinalRolesFromScratch(); logger.LogInfo((object)"Roles generation has finished"); logdebug.LogInfo((object)$"{dictionary}"); logger.LogInfo((object)"Sending roles to each player"); foreach (KeyValuePair<ulong, Role> item in dictionary) { logdebug.LogInfo((object)$"Trying to send role {item.Value} to player id {item.Key}"); ClientRpcParams val = Utils.BuildClientRpcParams(item.Key); logdebug.LogInfo((object)$"Using ClientRpcParams: {val}"); Utils.PrintDictionary(dictionary); logdebug.LogInfo((object)$"{item.Value.refInt}"); logdebug.LogInfo((object)"Invoking the SendRoleClientRpc method"); logger.LogInfo((object)$"Sent role to player: {GetPlayerById(item.Key).playerUsername} with id {item.Key}"); SendRoleClientRpc(item.Value.refInt, val); } logger.LogInfo((object)"Finished sending roles to each player"); allRoles = dictionary; logdebug.LogInfo((object)"Stored all roles in RolesManager."); } public void MakeDefaultRoles() { currentRolesSetup = References.GetAllRoles(); } public List<Role> GenerateRoles() { return GenerateRoles(GameNetworkManager.Instance.connectedPlayers); } public List<Role> GenerateRoles(int totalPlayers) { List<Role> list = new List<Role>(); for (int i = 0; i < currentRolesSetup.Count; i++) { list.Add(currentRolesSetup[i]); } for (int j = currentRolesSetup.Count; j < totalPlayers; j++) { list.Add(new Villager()); } for (int num = list.Count - 1; num >= totalPlayers; num--) { list.RemoveAt(list.Count - 1); } return list; } public void ShuffleRoles(List<Role> roles) { int num = roles.Count; while (num > 1) { num--; int index = rng.Next(num + 1); Role value = roles[index]; roles[index] = roles[num]; roles[num] = value; } } public Dictionary<ulong, Role> BuildFinalRolesFromScratch() { logdebug.LogInfo((object)"Getting the list of all connected players"); int connectedPlayers = GameNetworkManager.Instance.connectedPlayers; GameObject[] allPlayerObjects = StartOfRound.Instance.allPlayerObjects; string text = $"Found {connectedPlayers} players : "; for (int i = 0; i < connectedPlayers; i++) { string playerUsername = allPlayerObjects[i].GetComponent<PlayerControllerB>().playerUsername; text += playerUsername; } logdebug.LogInfo((object)text); logdebug.LogInfo((object)"Generate the roles"); List<Role> list = GenerateRoles(); logdebug.LogInfo((object)"Shuffle the roles"); ShuffleRoles(list); logdebug.LogInfo((object)"Get the list of players client Ids"); List<ulong> list2 = new List<ulong>(); for (int j = 0; j < connectedPlayers; j++) { GameObject val = allPlayerObjects[j]; ulong playerClientId = val.GetComponent<PlayerControllerB>().playerClientId; string playerUsername2 = val.GetComponent<PlayerControllerB>().playerUsername; logdebug.LogInfo((object)("Added playerName " + playerUsername2 + " with id " + playerClientId + " to the list")); list2.Add(playerClientId); } logdebug.LogInfo((object)"Associate each client Id with a role"); Dictionary<ulong, Role> dictionary = new Dictionary<ulong, Role>(); for (int k = 0; k < connectedPlayers; k++) { logdebug.LogInfo((object)$"{list2[k]} {list[k]}"); dictionary.Add(list2[k], list[k]); } return dictionary; } public void DisplayMyRolePopUp() { if (myRole != null) { logger.LogInfo((object)"Displaying my role tooltip"); logdebug.LogInfo((object)"Grabbing my Role"); myRole.DisplayRolePopUp(); } } [ClientRpc] public void SendRoleClientRpc(int roleInt, ClientRpcParams clientRpcParams = default(ClientRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2336793474u, clientRpcParams, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, roleInt); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 2336793474u, clientRpcParams, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { logdebug.LogInfo((object)"Received my role"); Role role = References.references()[roleInt]; logdebug.LogInfo((object)$"I was given the role {role} with name {role.roleName} and refInt {role.refInt}"); myRole = role; logdebug.LogInfo((object)"I have succesfully set my own role"); DisplayMyRolePopUp(); logdebug.LogInfo((object)"I have successfully displayed my Role tooltip"); string playerUsername = GameNetworkManager.Instance.localPlayerController.playerUsername; string roleName = myRole.roleName; logdebug.LogInfo((object)"Trying to update HUD"); RoleHUD roleHUD = Object.FindObjectOfType<RoleHUD>(); if ((Object)(object)roleHUD != (Object)null) { logger.LogInfo((object)"Update the HUD with the role"); roleHUD.UpdateRoleDisplay(); } else { logger.LogError((object)"Could not find the RoleHUD"); } logdebug.LogInfo((object)("I am player " + playerUsername + " and I have fully completed and received the role " + roleName)); } } [ServerRpc(RequireOwnership = false)] public void QueryCurrentRolesServerRpc(ServerRpcParams serverRpcParams = default(ServerRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: 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_006d: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(4101041483u, serverRpcParams, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val, 4101041483u, serverRpcParams, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams clientRpcParams = Utils.BuildClientRpcParams(serverRpcParams.Receive.SenderClientId); UpdateCurrentRolesSetupClientRpc(WrapRolesList(currentRolesSetup), clientRpcParams); } } } [ServerRpc(RequireOwnership = false)] public void UpdateCurrentRolesServerRpc(string newRolesSetup, ServerRpcParams serverRpcParams = default(ServerRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Invalid comparison between Unknown and I4 //IL_005f: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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_00ba: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3433003308u, serverRpcParams, (RpcDelivery)0); bool flag = newRolesSetup != null; ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val)).WriteValueSafe(newRolesSetup, false); } ((NetworkBehaviour)this).__endSendServerRpc(ref val, 3433003308u, serverRpcParams, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { UpdateCurrentRolesSetupClientRpc(newRolesSetup); } } [ClientRpc] private void UpdateCurrentRolesSetupClientRpc(string upstreamRolesSetup, ClientRpcParams clientRpcParams = default(ClientRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Invalid comparison between Unknown and I4 //IL_005f: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(247243216u, clientRpcParams, (RpcDelivery)0); bool flag = upstreamRolesSetup != null; ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val)).WriteValueSafe(upstreamRolesSetup, false); } ((NetworkBehaviour)this).__endSendClientRpc(ref val, 247243216u, clientRpcParams, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { logger.LogInfo((object)"The roles setup was modified."); currentRolesSetup = UnwrapRolesList(upstreamRolesSetup); } } public string WrapRolesList(List<Role> roles) { string text = ""; foreach (Role role in roles) { text += $"{role.refInt}\n"; } return text; } public List<Role> UnwrapRolesList(string rolesRefInts) { List<Role> list = new List<Role>(); logdebug.LogInfo((object)"Trying to split the list into individual string-ints"); string[] array = rolesRefInts.Split('\n'); logdebug.LogInfo((object)"Successfully splt the string"); string[] array2 = array; foreach (string text in array2) { if (!(text == "")) { list.Add(References.references()[Convert.ToInt32(text)]); } } return list; } [ServerRpc(RequireOwnership = false)] public void ResetAllCooldownsServerRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: 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_006d: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(4126093892u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4126093892u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { ResetAllCooldownsClientRpc(); } } } [ClientRpc] private void ResetAllCooldownsClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: 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_006d: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3627704532u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3627704532u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && myRole != null) { myRole.currentMainActionCooldown = 0f; myRole.currentSecondaryActionCooldown = 0f; HUDManager.Instance.DisplayTip("Admin", "Cooldowns set to 0", false, false, "LC_Tip1"); logger.LogInfo((object)"Cooldowns set to 0"); } } } [ServerRpc(RequireOwnership = false)] public void ResetRolesServerRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: 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_006d: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(395443189u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 395443189u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { ResetRolesClientRpc(); } } } [ClientRpc] public void ResetRolesClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: 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_006d: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2287241231u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2287241231u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && myRole != null) { logger.LogInfo((object)"Resetting my role to its intial state"); myRole = References.GetRoleByName(myRole.roleName); HUDManager.Instance.DisplayTip("Admin", "Role reset to its initial state", false, false, "LC_Tip1"); } } } [ServerRpc(RequireOwnership = false)] public void PerformMainActionServerRpc(ServerRpcParams serverRpcParams = default(ServerRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: 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_006d: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0137: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(416037121u, serverRpcParams, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val, 416037121u, serverRpcParams, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { ulong senderClientId = serverRpcParams.Receive.SenderClientId; Role role = allRoles[senderClientId]; logdebug.LogInfo((object)$"Received action request from Player Id : {senderClientId}"); ClientRpcParams val2 = default(ClientRpcParams); val2.Send = new ClientRpcSendParams { TargetClientIds = new ulong[1] { senderClientId } }; ClientRpcParams clientRpcParams = val2; if (role.IsAllowedToPerformMainAction()) { PerformMainActionClientRpc(clientRpcParams); } else { CannotPerformThisActionYetClientRpc(clientRpcParams); } } } [ClientRpc] public void PerformMainActionClientRpc(ClientRpcParams clientRpcParams = default(ClientRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: 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_006d: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1602386815u, clientRpcParams, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 1602386815u, clientRpcParams, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { myRole.GenericPerformMainAction(); } } } [ClientRpc] public void CannotPerformThisActionYetClientRpc(ClientRpcParams clientRpcParams = default(ClientRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: 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_006d: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(678349947u, clientRpcParams, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 678349947u, clientRpcParams, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { HUDManager.Instance.DisplayTip(myRole.roleName ?? "", "You cannot perform this action.", false, false, "LC_Tip1"); } } } [ServerRpc(RequireOwnership = false)] public void SuccessFullyPerformedMainActionServerRpc(ServerRpcParams serverRpcParams = default(ServerRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: 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_006d: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(2249334015u, serverRpcParams, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val, 2249334015u, serverRpcParams, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { logdebug.LogInfo((object)$"Setting Player Id = {serverRpcParams.Receive.SenderClientId} main action on cooldown"); ulong senderClientId = serverRpcParams.Receive.SenderClientId; allRoles[senderClientId].SetMainActionOnCooldown(); ClientRpcParams val2 = default(ClientRpcParams); val2.Send = new ClientRpcSendParams { TargetClientIds = new ulong[1] { senderClientId } }; ClientRpcParams clientRpcParams = val2; logdebug.LogInfo((object)"Sending the caller the order to set his main action on cooldown"); SuccessFullyPerformedMainActionClientRpc(clientRpcParams); } } } [ClientRpc] public void SuccessFullyPerformedMainActionClientRpc(ClientRpcParams clientRpcParams = default(ClientRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: 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_006d: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(72376834u, clientRpcParams, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 72376834u, clientRpcParams, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { logdebug.LogInfo((object)"Setting my main action on cooldown"); myRole.SetMainActionOnCooldown(); } } } [ServerRpc(RequireOwnership = false)] public void PerformSecondaryActionServerRpc(ServerRpcParams serverRpcParams = default(ServerRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: 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_006d: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0137: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(2702871959u, serverRpcParams, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val, 2702871959u, serverRpcParams, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { ulong senderClientId = serverRpcParams.Receive.SenderClientId; Role role = allRoles[senderClientId]; logdebug.LogInfo((object)$"Received secondary action request from Player Id : {senderClientId}"); ClientRpcParams val2 = default(ClientRpcParams); val2.Send = new ClientRpcSendParams { TargetClientIds = new ulong[1] { senderClientId } }; ClientRpcParams clientRpcParams = val2; if (role.IsAllowedToPerformSecondaryAction()) { PerformSecondaryActionClientRpc(clientRpcParams); } else { CannotPerformThisActionYetClientRpc(clientRpcParams); } } } [ClientRpc] public void PerformSecondaryActionClientRpc(ClientRpcParams clientRpcParams = default(ClientRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: 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_006d: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1557479801u, clientRpcParams, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 1557479801u, clientRpcParams, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { myRole.GenericPerformSecondaryAction(); } } } [ServerRpc(RequireOwnership = false)] public void SuccessFullyPerformedSecondaryActionServerRpc(ServerRpcParams serverRpcParams = default(ServerRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4