Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Whiteboard v1.2.0
com.github.zehsteam.Whiteboard.dll
Decompiled 7 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalLib.Extras; using LethalLib.Modules; using Microsoft.CodeAnalysis; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.InputSystem; using UnityEngine.UI; using com.github.zehsteam.Whiteboard.MonoBehaviours; using com.github.zehsteam.Whiteboard.NetcodePatcher; using com.github.zehsteam.Whiteboard.Patches; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Zehs")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright © 2025 Zehs")] [assembly: AssemblyDescription("[v73+] Adds a new whiteboard store item that you can write on!")] [assembly: AssemblyFileVersion("1.2.0.0")] [assembly: AssemblyInformationalVersion("1.2.0+3145e53019828a9f2df176ff3f0f786fbb2b9cdb")] [assembly: AssemblyProduct("Whiteboard")] [assembly: AssemblyTitle("com.github.zehsteam.Whiteboard")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace com.github.zehsteam.Whiteboard { public class ConfigManager { public ConfigEntry<bool> ExtendedLogging { get; private set; } public ConfigEntry<int> Price { get; private set; } public ConfigEntry<bool> HostOnly { get; private set; } public ConfigEntry<string> DefaultDisplayText { get; private set; } public ConfigManager() { BindConfigs(); SetupChangedEvents(); ClearUnusedEntries(); } private void BindConfigs() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown ConfigFile config = ((BaseUnityPlugin)Plugin.Instance).Config; ExtendedLogging = config.Bind<bool>("General Settings", "ExtendedLogging", false, "Enable extended logging."); Price = config.Bind<int>("Whiteboard Settings", "Price", 100, new ConfigDescription("The price of the whiteboard in the store.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>())); HostOnly = config.Bind<bool>("Whiteboard Settings", "HostOnly", false, "If enabled, only the host can edit the whiteboard."); DefaultDisplayText = config.Bind<string>("Whiteboard Settings", "DefaultDisplayText", "", "The default display text that shows on the whiteboard. Supports rich text tags."); } private void SetupChangedEvents() { Price.SettingChanged += Price_SettingChanged; HostOnly.SettingChanged += HostOnly_SettingChanged; } private void Price_SettingChanged(object sender, EventArgs e) { //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) if (Plugin.IsHostOrServer && (Object)(object)PluginNetworkBehaviour.Instance != (Object)null) { PluginNetworkBehaviour.Instance.SetWhiteboardUnlockablePriceClientRpc(Price.Value); } } private void HostOnly_SettingChanged(object sender, EventArgs e) { if (Plugin.IsHostOrServer && (Object)(object)WhiteboardBehaviour.Instance != (Object)null) { WhiteboardBehaviour.Instance.IsHostOnly.Value = HostOnly.Value; } } private void ClearUnusedEntries() { ConfigFile config = ((BaseUnityPlugin)Plugin.Instance).Config; PropertyInfo property = ((object)config).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic); Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(config, null); dictionary.Clear(); config.Save(); } } internal class Content { public static GameObject NetworkHandlerPrefab; public static UnlockableItemDef WhiteboardUnlockableItemDef; public static TerminalNode WhiteboardBuyTerminalNode; public static GameObject WhiteboardEditorCanvasPrefab; public static void Load() { LoadAssetsFromAssetBundle(); } private static void LoadAssetsFromAssetBundle() { try { string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location); string text = Path.Combine(directoryName, "whiteboard_assets"); AssetBundle val = AssetBundle.LoadFromFile(text); NetworkHandlerPrefab = val.LoadAsset<GameObject>("NetworkHandler"); NetworkHandlerPrefab.AddComponent<PluginNetworkBehaviour>(); WhiteboardUnlockableItemDef = val.LoadAsset<UnlockableItemDef>("Whiteboard"); WhiteboardBuyTerminalNode = val.LoadAsset<TerminalNode>("WhiteboardBuy"); WhiteboardEditorCanvasPrefab = val.LoadAsset<GameObject>("WhiteboardEditorCanvas"); Plugin.logger.LogInfo((object)"Successfully loaded assets from AssetBundle!"); } catch (Exception arg) { Plugin.logger.LogError((object)$"Failed to load assets from AssetBundle.\n\n{arg}"); } } } internal class NetworkUtils { public static int GetLocalClientId() { return (int)NetworkManager.Singleton.LocalClientId; } public static bool IsLocalClientId(int clientId) { return clientId == GetLocalClientId(); } } internal class PlayerUtils { public static int GetLocalPlayerId() { PlayerControllerB localPlayerScript = GetLocalPlayerScript(); if ((Object)(object)localPlayerScript == (Object)null) { return -1; } return (int)localPlayerScript.playerClientId; } public static bool IsLocalPlayerId(int playerId) { return playerId == GetLocalPlayerId(); } public static PlayerControllerB GetPlayerScript(int playerId) { try { return StartOfRound.Instance.allPlayerScripts[playerId]; } catch { return null; } } public static PlayerControllerB GetLocalPlayerScript() { return GameNetworkManager.Instance.localPlayerController; } public static bool IsLocalPlayerSpawned() { PlayerControllerB localPlayerScript = GetLocalPlayerScript(); if ((Object)(object)localPlayerScript == (Object)null) { return false; } return ((NetworkBehaviour)localPlayerScript).IsSpawned; } public static void SetControlsEnabled(bool value) { if (value) { EnableControls(); } else { DisableControls(); } } private static void EnableControls() { //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0266: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB localPlayerScript = GetLocalPlayerScript(); if (!((Object)(object)localPlayerScript == (Object)null)) { localPlayerScript.disableMoveInput = false; InputActionAsset actions = IngamePlayerSettings.Instance.playerInput.actions; MovementActions movement; try { movement = localPlayerScript.playerActions.Movement; ((MovementActions)(ref movement)).Look.performed += localPlayerScript.Look_performed; actions.FindAction("Jump", false).performed += localPlayerScript.Jump_performed; actions.FindAction("Crouch", false).performed += localPlayerScript.Crouch_performed; actions.FindAction("Interact", false).performed += localPlayerScript.Interact_performed; actions.FindAction("ItemSecondaryUse", false).performed += localPlayerScript.ItemSecondaryUse_performed; actions.FindAction("ItemTertiaryUse", false).performed += localPlayerScript.ItemTertiaryUse_performed; actions.FindAction("ActivateItem", false).performed += localPlayerScript.ActivateItem_performed; actions.FindAction("ActivateItem", false).canceled += localPlayerScript.ActivateItem_canceled; actions.FindAction("Discard", false).performed += localPlayerScript.Discard_performed; actions.FindAction("SwitchItem", false).performed += localPlayerScript.ScrollMouse_performed; actions.FindAction("InspectItem", false).performed += localPlayerScript.InspectItem_performed; actions.FindAction("SpeedCheat", false).performed += localPlayerScript.SpeedCheat_performed; actions.FindAction("Emote1", false).performed += localPlayerScript.Emote1_performed; actions.FindAction("Emote2", false).performed += localPlayerScript.Emote2_performed; localPlayerScript.isTypingChat = false; actions.FindAction("EnableChat", false).performed += HUDManager.Instance.EnableChat_performed; actions.FindAction("SubmitChat", false).performed += HUDManager.Instance.SubmitChat_performed; actions.FindAction("PingScan", false).performed += HUDManager.Instance.PingScan_performed; movement = localPlayerScript.playerActions.Movement; ((MovementActions)(ref movement)).Enable(); } catch (Exception arg) { Plugin.logger.LogError((object)$"Error while subscribing to input in PlayerController\n\n{arg}"); } movement = localPlayerScript.playerActions.Movement; ((MovementActions)(ref movement)).Enable(); } } private static void DisableControls() { //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0266: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB localPlayerScript = GetLocalPlayerScript(); if (!((Object)(object)localPlayerScript == (Object)null)) { localPlayerScript.disableMoveInput = true; InputActionAsset actions = IngamePlayerSettings.Instance.playerInput.actions; MovementActions movement; try { movement = localPlayerScript.playerActions.Movement; ((MovementActions)(ref movement)).Look.performed -= localPlayerScript.Look_performed; actions.FindAction("Jump", false).performed -= localPlayerScript.Jump_performed; actions.FindAction("Crouch", false).performed -= localPlayerScript.Crouch_performed; actions.FindAction("Interact", false).performed -= localPlayerScript.Interact_performed; actions.FindAction("ItemSecondaryUse", false).performed -= localPlayerScript.ItemSecondaryUse_performed; actions.FindAction("ItemTertiaryUse", false).performed -= localPlayerScript.ItemTertiaryUse_performed; actions.FindAction("ActivateItem", false).performed -= localPlayerScript.ActivateItem_performed; actions.FindAction("ActivateItem", false).canceled -= localPlayerScript.ActivateItem_canceled; actions.FindAction("Discard", false).performed -= localPlayerScript.Discard_performed; actions.FindAction("SwitchItem", false).performed -= localPlayerScript.ScrollMouse_performed; actions.FindAction("InspectItem", false).performed -= localPlayerScript.InspectItem_performed; actions.FindAction("SpeedCheat", false).performed -= localPlayerScript.SpeedCheat_performed; actions.FindAction("Emote1", false).performed -= localPlayerScript.Emote1_performed; actions.FindAction("Emote2", false).performed -= localPlayerScript.Emote2_performed; localPlayerScript.isTypingChat = true; actions.FindAction("EnableChat", false).performed -= HUDManager.Instance.EnableChat_performed; actions.FindAction("SubmitChat", false).performed -= HUDManager.Instance.SubmitChat_performed; actions.FindAction("PingScan", false).performed -= HUDManager.Instance.PingScan_performed; movement = localPlayerScript.playerActions.Movement; ((MovementActions)(ref movement)).Disable(); } catch (Exception arg) { Plugin.logger.LogError((object)$"Error while unsubscribing to input in PlayerController\n\n{arg}"); } movement = localPlayerScript.playerActions.Movement; ((MovementActions)(ref movement)).Disable(); } } } [BepInPlugin("com.github.zehsteam.Whiteboard", "Whiteboard", "1.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class Plugin : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("com.github.zehsteam.Whiteboard"); internal static Plugin Instance; internal static ManualLogSource logger; internal static ConfigManager ConfigManager; public static bool IsHostOrServer { get { if (!NetworkManager.Singleton.IsHost) { return NetworkManager.Singleton.IsServer; } return true; } } private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } logger = Logger.CreateLogSource("com.github.zehsteam.Whiteboard"); logger.LogInfo((object)"Whiteboard has awoken!"); harmony.PatchAll(typeof(GameNetworkManagerPatch)); harmony.PatchAll(typeof(StartOfRoundPatch)); harmony.PatchAll(typeof(HUDManagerPatch)); harmony.PatchAll(typeof(PlayerControllerBPatch)); harmony.PatchAll(typeof(ShipBuildModeManagerPatch)); ConfigManager = new ConfigManager(); Content.Load(); RegisterUnlockableItems(); NetcodePatcherAwake(); } private void NetcodePatcherAwake() { 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); } } } } private void RegisterUnlockableItems() { UnlockableHelper.RegisterUnlockable(Content.WhiteboardUnlockableItemDef, (StoreType)2, ConfigManager.Price.Value, Content.WhiteboardBuyTerminalNode); } public void SpawnWhiteboardEditorCanvas() { if (!((Object)(object)WhiteboardEditorBehaviour.Instance != (Object)null)) { Object.Instantiate<GameObject>(Content.WhiteboardEditorCanvasPrefab); logger.LogInfo((object)"Spawned WhiteboardEditorCanvas."); } } public void LogInfoExtended(object data) { if (ConfigManager.ExtendedLogging.Value) { logger.LogInfo(data); } } } [CreateAssetMenu(menuName = "Whiteboard/SpriteSheetData")] public class SpriteSheetData : ScriptableObject { [Header("Editor Buttons")] [Space(5f)] public bool ImportSpriteData; [Header("Data")] [Space(5f)] public TMP_SpriteAsset SpriteAsset; [TextArea(3, 20)] public string SpriteDataImportCode; public List<SpriteSheetItem> SpriteData = new List<SpriteSheetItem>(); public string GetAllSpritesText() { string text = string.Empty; foreach (SpriteSheetItem spriteDatum in SpriteData) { text = text + spriteDatum.GetText() + " "; } return text.Trim(); } public string GetParsedText(string text, bool matchCase = false) { string text2 = text; StringComparison comparisonType = (matchCase ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase); if (text2.Contains("<all>", comparisonType)) { text2 = text2.Replace("<all>", GetAllSpritesText(), comparisonType); } List<SpriteSheetItem> list = SpriteData.OrderBy((SpriteSheetItem _) => _.Name.Length).Reverse().ToList(); foreach (SpriteSheetItem item in list) { if (text2.Contains(item.Name, comparisonType)) { text2 = text2.Replace(item.Name, item.GetText(), comparisonType); } } return text2; } private void OnValidate() { if (ImportSpriteData) { ImportSpriteData = false; OnImportSpriteDataClicked(); } } private void OnImportSpriteDataClicked() { if (string.IsNullOrWhiteSpace(SpriteDataImportCode)) { LogError("Failed to import sprite data code. Sprite data import code is null or empty."); return; } string[] array = SpriteDataImportCode.Trim().Split(",", StringSplitOptions.RemoveEmptyEntries); if (array.Length == 0) { LogError("Failed to import sprite data code. Sprite data import code contains no entries."); return; } SpriteData = new List<SpriteSheetItem>(); for (int i = 0; i < array.Length; i++) { if (string.IsNullOrWhiteSpace(array[i])) { LogEntryError(i, "Entry is null or empty."); continue; } string[] array2 = array[i].Trim().Split(":", StringSplitOptions.RemoveEmptyEntries); if (array2.Length < 3) { LogEntryError(i, "Entry has less than 3 items."); continue; } string name = array2[0]; if (TryParseInt(i, array2[1], out var result) && TryParseInt(i, array2[2], out var result2)) { float result3 = 10f; if (array2.Length < 4 || TryParseFloat(i, array2[3], out result3)) { SpriteData.Add(new SpriteSheetItem(name, result, result2, result3)); } } } LogInfo("Finished importing sprite data from sprite data import code."); } private static bool TryParseInt(int entryIndex, string text, out int result) { if (!int.TryParse(text, out result)) { LogEntryError(entryIndex, "Could not parse \"" + text + "\" as an integer."); return false; } return true; } private static bool TryParseFloat(int entryIndex, string text, out float result) { if (!float.TryParse(text, out result)) { LogEntryError(entryIndex, "Could not parse \"" + text + "\" as a float."); return false; } return true; } private static void LogEntryError(int entryIndex, object data) { LogError($"Failed to import sprite data entry #{entryIndex}. " + data); } private static void LogInfo(object data) { Debug.Log((object)("[SpriteSheetData] " + data)); } private static void LogError(object data) { Debug.LogError((object)("[SpriteSheetData] " + data)); } } [Serializable] public class SpriteSheetItem { public string Name; public int Index; public int EndIndex; public float AnimationSpeed; public SpriteSheetItem(string name, int index, int endIndex, float animationSpeed) { Name = name; Index = index; EndIndex = endIndex; AnimationSpeed = animationSpeed; } public string GetText() { if (EndIndex > Index) { return $"<sprite anim=\"{Index},{EndIndex},{AnimationSpeed}\">"; } return $"<sprite={Index}>"; } } internal class UnlockableHelper { public static void RegisterUnlockable(UnlockableItemDef unlockableItemDef, StoreType storeType, int price, TerminalNode terminalNode) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) try { unlockableItemDef.unlockable.shopSelectionNode.itemCost = price; unlockableItemDef.unlockable.shopSelectionNode.terminalOptions[0].result.itemCost = price; } catch { } Utilities.FixMixerGroups(unlockableItemDef.unlockable.prefabObject); NetworkPrefabs.RegisterNetworkPrefab(unlockableItemDef.unlockable.prefabObject); Unlockables.RegisterUnlockable(unlockableItemDef, storeType, (TerminalNode)null, (TerminalNode)null, terminalNode, price); Plugin.logger.LogInfo((object)$"Registered \"{unlockableItemDef.unlockable.unlockableName}\" unlockable shop item with a price of ${price}."); } public static void UpdateUnlockablePrice(UnlockableItemDef unlockableItemDef, int price) { try { unlockableItemDef.unlockable.shopSelectionNode.itemCost = price; unlockableItemDef.unlockable.shopSelectionNode.terminalOptions[0].result.itemCost = price; } catch { } Unlockables.UpdateUnlockablePrice(unlockableItemDef.unlockable, price); Plugin.logger.LogInfo((object)$"Updated \"{unlockableItemDef.unlockable.unlockableName}\" unlockable shop item price to ${price}."); } } internal class Utils { public static void SetCursorLockState(bool value) { if (!IsQuickMenuOpen()) { Cursor.lockState = (CursorLockMode)(value ? 1 : 0); if (value) { Cursor.visible = false; } else if (!StartOfRound.Instance.localPlayerUsingController) { Cursor.visible = true; } } } public static string GetCurrentSaveFileName() { return GameNetworkManager.Instance.currentSaveFileName; } public static void SaveToCurrentSaveFile<T>(string key, T value) { ES3.Save<T>("com.github.zehsteam.Whiteboard." + key, value, GetCurrentSaveFileName()); } public static T LoadFromCurrentSaveFile<T>(string key, T defaultValue = default(T)) { return ES3.Load<T>("com.github.zehsteam.Whiteboard." + key, GetCurrentSaveFileName(), defaultValue); } public static bool KeyExistsInCurrentSaveFile(string key) { return ES3.KeyExists("com.github.zehsteam.Whiteboard." + key, GetCurrentSaveFileName()); } public static bool ArrayContains(string[] array, string value) { foreach (string text in array) { if (text.Equals(value, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } public static bool IsQuickMenuOpen() { PlayerControllerB localPlayerScript = PlayerUtils.GetLocalPlayerScript(); if ((Object)(object)localPlayerScript == (Object)null) { return false; } return localPlayerScript.quickMenuManager.isMenuOpen; } } [Serializable] public class WhiteboardData : INetworkSerializable { public string DisplayText; public string TextHexColor; public int FontSizeIndex; public int FontStyleIndex; public int FontFamilyIndex; public int HorizontalAlignmentIndex; public int VerticalAlignmentIndex; public WhiteboardData() { try { DisplayText = Plugin.ConfigManager.DefaultDisplayText.Value; } catch { } TextHexColor = "#000000"; FontSizeIndex = 7; } public WhiteboardData(string displayText) { DisplayText = displayText; TextHexColor = "#000000"; FontSizeIndex = 7; } public WhiteboardData(string displayText, string textHexColor, int fontSizeIndex, int fontStyleIndex, int fontFamilyIndex, int horizontalAlignmentIndex, int verticalAlignmentIndex) : this(displayText) { TextHexColor = textHexColor; FontSizeIndex = fontSizeIndex; FontStyleIndex = fontStyleIndex; FontFamilyIndex = fontFamilyIndex; HorizontalAlignmentIndex = horizontalAlignmentIndex; VerticalAlignmentIndex = verticalAlignmentIndex; } public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter { //IL_0026: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_006e: Unknown result type (might be due to invalid IL or missing references) //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) serializer.SerializeValue(ref DisplayText, false); serializer.SerializeValue(ref TextHexColor, false); ((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref FontSizeIndex, default(ForPrimitives)); ((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref FontStyleIndex, default(ForPrimitives)); ((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref FontFamilyIndex, default(ForPrimitives)); ((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref HorizontalAlignmentIndex, default(ForPrimitives)); ((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref VerticalAlignmentIndex, default(ForPrimitives)); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "com.github.zehsteam.Whiteboard"; public const string PLUGIN_NAME = "Whiteboard"; public const string PLUGIN_VERSION = "1.2.0"; } } namespace com.github.zehsteam.Whiteboard.Patches { [HarmonyPatch(typeof(GameNetworkManager))] internal class GameNetworkManagerPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartPatch() { AddNetworkPrefabs(); } private static void AddNetworkPrefabs() { AddNetworkPrefab(Content.NetworkHandlerPrefab); } private static void AddNetworkPrefab(GameObject prefab) { if ((Object)(object)prefab == (Object)null) { Plugin.logger.LogError((object)"Failed to add network prefab. GameObject is null."); return; } NetworkManager.Singleton.AddNetworkPrefab(prefab); Plugin.logger.LogInfo((object)("Registered \"" + ((Object)prefab).name + "\" network prefab.")); } } [HarmonyPatch(typeof(HUDManager))] internal class HUDManagerPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartPatch() { Plugin.Instance.SpawnWhiteboardEditorCanvas(); } [HarmonyPatch("OpenMenu_performed")] [HarmonyPrefix] private static void OpenMenu_performedPatch() { if (!((Object)(object)WhiteboardEditorBehaviour.Instance == (Object)null) && WhiteboardEditorBehaviour.Instance.IsWindowOpen) { WhiteboardEditorBehaviour.Instance.CloseWindow(); } } } [HarmonyPatch(typeof(PlayerControllerB))] internal class PlayerControllerBPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartPatch(ref PlayerControllerB __instance) { if (!((Object)(object)__instance != (Object)(object)PlayerUtils.GetLocalPlayerScript()) && (Object)(object)WhiteboardBehaviour.Instance != (Object)null) { WhiteboardBehaviour.Instance.SetWorldCanvasCamera(); } } [HarmonyPatch("KillPlayer")] [HarmonyPostfix] private static void KillPlayerPatch() { if (!((Object)(object)WhiteboardEditorBehaviour.Instance == (Object)null) && WhiteboardEditorBehaviour.Instance.IsWindowOpen) { WhiteboardEditorBehaviour.Instance.CloseWindow(); } } } [HarmonyPatch(typeof(ShipBuildModeManager))] internal class ShipBuildModeManagerPatch { [HarmonyPatch("PlayerMeetsConditionsToBuild")] [HarmonyPostfix] private static void PlayerMeetsConditionsToBuild(ref bool __result) { if (!((Object)(object)WhiteboardEditorBehaviour.Instance == (Object)null) && WhiteboardEditorBehaviour.Instance.IsWindowOpen) { __result = false; } } } [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatch { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void AwakePatch() { SpawnNetworkHandler(); } private static void SpawnNetworkHandler() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (Plugin.IsHostOrServer) { GameObject val = Object.Instantiate<GameObject>(Content.NetworkHandlerPrefab, Vector3.zero, Quaternion.identity); val.GetComponent<NetworkObject>().Spawn(false); } } [HarmonyPatch("OnClientConnect")] [HarmonyPrefix] private static void OnClientConnectPatch(ref ulong clientId) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) ClientRpcParams val = default(ClientRpcParams); val.Send = new ClientRpcSendParams { TargetClientIds = new <>z__ReadOnlySingleElementList<ulong>(clientId) }; ClientRpcParams clientRpcParams = val; PluginNetworkBehaviour.Instance.SetWhiteboardUnlockablePriceClientRpc(Plugin.ConfigManager.Price.Value, clientRpcParams); } [HarmonyPatch("ReviveDeadPlayers")] [HarmonyPostfix] private static void ReviveDeadPlayersPatch() { if (!((Object)(object)WhiteboardEditorBehaviour.Instance == (Object)null) && WhiteboardEditorBehaviour.Instance.IsWindowOpen) { PlayerControllerB localPlayerScript = PlayerUtils.GetLocalPlayerScript(); if (!((Object)(object)localPlayerScript == (Object)null)) { localPlayerScript.disableMoveInput = true; } } } } } namespace com.github.zehsteam.Whiteboard.MonoBehaviours { public class ColorPickerBehaviour : MonoBehaviour { public static ColorPickerBehaviour Instance; public GameObject ColorPickerWindowObject; public ColorPickerControlBehaviour ColorPickerControlBehaviour; public bool IsWindowOpen { get; private set; } private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } } private void Start() { CloseWindow(); } public void OpenWindow() { if (WhiteboardEditorBehaviour.Instance.IsWindowOpen && !IsWindowOpen) { IsWindowOpen = true; ColorPickerWindowObject.SetActive(true); ColorPickerControlBehaviour.SetColor(WhiteboardEditorBehaviour.Instance.TextHexColor); } } public void CloseWindow() { IsWindowOpen = false; ColorPickerWindowObject.SetActive(false); } public void OnConfirmButtonClicked() { WhiteboardEditorBehaviour.Instance.SetTextHexColor(ColorPickerControlBehaviour.GetHexColor()); CloseWindow(); } public void OnCancelButtonClicked() { CloseWindow(); } } public class ColorPickerControlBehaviour : MonoBehaviour { [SerializeField] private float _currentHue; [SerializeField] private float _currentSat; [SerializeField] private float _currentVal; [SerializeField] private RawImage _hueImage; [SerializeField] private RawImage _satValImage; [SerializeField] private RawImage _outputImage; [SerializeField] private Slider _hueSlider; [SerializeField] private TMP_InputField _hexColorInputField; [SerializeField] private SVImageControlBehaviour _svImageControlBehaviour; private Texture2D _hueTexture; private Texture2D _satValTexture; private Texture2D _outputTexture; private bool _updatedHexColorInputFieldInternally; private bool _initialized; private void Start() { Initialize(); } private void Initialize() { if (!_initialized) { _initialized = true; CreateHueImage(); CreateSatValImage(); CreateOutputImage(); UpdateOutputImage(); } } private void CreateHueImage() { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) _hueTexture = new Texture2D(1, 16); ((Texture)_hueTexture).wrapMode = (TextureWrapMode)1; ((Object)_hueTexture).name = "HueTexture"; for (int i = 0; i < ((Texture)_hueTexture).height; i++) { _hueTexture.SetPixel(0, i, Color.HSVToRGB((float)i / (float)((Texture)_hueTexture).height, 1f, 0.95f)); } _hueTexture.Apply(); _currentHue = 0f; _hueImage.texture = (Texture)(object)_hueTexture; } private void CreateSatValImage() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) _satValTexture = new Texture2D(16, 16); ((Texture)_satValTexture).wrapMode = (TextureWrapMode)1; ((Object)_satValTexture).name = "SatValTexture"; for (int i = 0; i < ((Texture)_satValTexture).height; i++) { for (int j = 0; j < ((Texture)_satValTexture).width; j++) { _satValTexture.SetPixel(j, i, Color.HSVToRGB(_currentHue, (float)j / (float)((Texture)_satValTexture).width, (float)i / (float)((Texture)_satValTexture).height)); } } _satValTexture.Apply(); _currentSat = 0f; _currentVal = 0f; _satValImage.texture = (Texture)(object)_satValTexture; } private void CreateOutputImage() { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) _outputTexture = new Texture2D(1, 16); ((Texture)_outputTexture).wrapMode = (TextureWrapMode)1; ((Object)_outputTexture).name = "OutputTexture"; Color val = Color.HSVToRGB(_currentHue, _currentSat, _currentVal); for (int i = 0; i < ((Texture)_outputTexture).height; i++) { _outputTexture.SetPixel(0, i, val); } _outputTexture.Apply(); _outputImage.texture = (Texture)(object)_outputTexture; } private void UpdateOutputImage() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) Color val = Color.HSVToRGB(_currentHue, _currentSat, _currentVal); for (int i = 0; i < ((Texture)_outputTexture).height; i++) { _outputTexture.SetPixel(0, i, val); } _outputTexture.Apply(); _updatedHexColorInputFieldInternally = true; _hexColorInputField.text = GetHexColor(); } public void SetSatVal(float saturation, float value) { _currentSat = saturation; _currentVal = value; UpdateOutputImage(); } public void UpdateSatValImage() { //IL_0045: Unknown result type (might be due to invalid IL or missing references) _currentHue = _hueSlider.value; for (int i = 0; i < ((Texture)_satValTexture).height; i++) { for (int j = 0; j < ((Texture)_satValTexture).width; j++) { _satValTexture.SetPixel(j, i, Color.HSVToRGB(_currentHue, (float)j / (float)((Texture)_satValTexture).width, (float)i / (float)((Texture)_satValTexture).height)); } } _satValTexture.Apply(); UpdateOutputImage(); } public void OnHexColorInputFieldValueChanged() { if (_updatedHexColorInputFieldInternally) { _updatedHexColorInputFieldInternally = false; } else if (_hexColorInputField.text.Length >= 6) { string hexColor = ((!_hexColorInputField.text.StartsWith("#")) ? ("#" + _hexColorInputField.text) : _hexColorInputField.text); UpdateColor(hexColor); } } private void UpdateColor(string hexColor) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) Color val = default(Color); if (ColorUtility.TryParseHtmlString(hexColor, ref val)) { Color.RGBToHSV(val, ref _currentHue, ref _currentSat, ref _currentVal); _hueSlider.value = _currentHue; UpdateOutputImage(); _svImageControlBehaviour.SetPickerLocation(_currentSat, _currentVal); } } public void SetColor(string hexColor) { Initialize(); _updatedHexColorInputFieldInternally = true; _hexColorInputField.text = hexColor; UpdateColor(hexColor); } public string GetHexColor() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) Color val = Color.HSVToRGB(_currentHue, _currentSat, _currentVal); return "#" + ColorUtility.ToHtmlStringRGB(val); } } internal class PluginNetworkBehaviour : NetworkBehaviour { public static PluginNetworkBehaviour Instance; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } } [ClientRpc] public void SetWhiteboardUnlockablePriceClientRpc(int price, 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) //IL_00ce: 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.IsServer || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(151062475u, clientRpcParams, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, price); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 151062475u, clientRpcParams, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; UnlockableHelper.UpdateUnlockablePrice(Content.WhiteboardUnlockableItemDef, price); } } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(151062475u, new RpcReceiveHandler(__rpc_handler_151062475), "SetWhiteboardUnlockablePriceClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_151062475(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int price = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref price); ClientRpcParams client = rpcParams.Client; target.__rpc_exec_stage = (__RpcExecStage)1; ((PluginNetworkBehaviour)(object)target).SetWhiteboardUnlockablePriceClientRpc(price, client); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "PluginNetworkBehaviour"; } } public class SVImageControlBehaviour : MonoBehaviour, IDragHandler, IEventSystemHandler, IPointerClickHandler { [SerializeField] private ColorPickerControlBehaviour _colorPickerControlBehaviour; [SerializeField] private Image _pickerImage; private RectTransform _rectTransform; private RectTransform _pickerTransform; private void Awake() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) _rectTransform = ((Component)this).GetComponent<RectTransform>(); _pickerTransform = ((Component)_pickerImage).GetComponent<RectTransform>(); ((Transform)_pickerTransform).localPosition = Vector2.op_Implicit(new Vector2(0f - _rectTransform.sizeDelta.x * 0.5f, 0f - _rectTransform.sizeDelta.y * 0.5f)); } private void UpdateColor(PointerEventData eventData) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Transform)_rectTransform).InverseTransformPoint(Vector2.op_Implicit(eventData.position)); float num = _rectTransform.sizeDelta.x * 0.5f; float num2 = _rectTransform.sizeDelta.y * 0.5f; val.x = Mathf.Clamp(val.x, 0f - num, num); val.y = Mathf.Clamp(val.y, 0f - num2, num2); float num3 = val.x + num; float num4 = val.y + num2; float saturation = num3 / _rectTransform.sizeDelta.x; float num5 = num4 / _rectTransform.sizeDelta.y; ((Transform)_pickerTransform).localPosition = val; ((Graphic)_pickerImage).color = Color.HSVToRGB(0f, 0f, 1f - num5); _colorPickerControlBehaviour.SetSatVal(saturation, num5); } public void OnDrag(PointerEventData eventData) { UpdateColor(eventData); } public void OnPointerClick(PointerEventData eventData) { UpdateColor(eventData); } public void SetPickerLocation(float saturation, float value) { //IL_0007: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) float num = saturation * _rectTransform.sizeDelta.x - _rectTransform.sizeDelta.x * 0.5f; float num2 = value * _rectTransform.sizeDelta.y - _rectTransform.sizeDelta.y * 0.5f; ((Transform)_pickerTransform).localPosition = Vector2.op_Implicit(new Vector2(num, num2)); ((Graphic)_pickerImage).color = Color.HSVToRGB(0f, 0f, 1f - value); Plugin.Instance.LogInfoExtended($"SetPickerLocation (saturation: {saturation}, value: {value}), (x: {num}, y: {num2})"); } } public class WhiteboardBehaviour : NetworkBehaviour { public static WhiteboardBehaviour Instance; public InteractTrigger InteractTrigger; public Canvas WorldCanvas; public TextMeshProUGUI WhiteboardText; public float[] FontSizeArray = Array.Empty<float>(); public FontStyles[] FontStyleArray = Array.Empty<FontStyles>(); public TMP_FontAsset[] FontAssetArray = Array.Empty<TMP_FontAsset>(); public SpriteSheetData EmotesSpriteSheetData; [HideInInspector] public NetworkVariable<bool> IsHostOnly = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public WhiteboardData Data { get; private set; } private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } Data = new WhiteboardData(); } private void Start() { if ((Object)(object)EmotesSpriteSheetData != (Object)null) { ((TMP_Text)WhiteboardText).spriteAsset = EmotesSpriteSheetData.SpriteAsset; } if (PlayerUtils.IsLocalPlayerSpawned()) { SetWorldCanvasCamera(); } if (Plugin.IsHostOrServer) { LoadData(); } else { RequestDataServerRpc(NetworkUtils.GetLocalClientId()); } } public override void OnNetworkSpawn() { NetworkVariable<bool> isHostOnly = IsHostOnly; isHostOnly.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Combine((Delegate?)(object)isHostOnly.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<bool>(OnIsHostOnlyChanged)); if (Plugin.IsHostOrServer) { IsHostOnly.Value = Plugin.ConfigManager.HostOnly.Value; } else if (IsHostOnly.Value) { InteractTrigger.interactable = false; } } public override void OnNetworkDespawn() { NetworkVariable<bool> isHostOnly = IsHostOnly; isHostOnly.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Remove((Delegate?)(object)isHostOnly.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<bool>(OnIsHostOnlyChanged)); if (!((Object)(object)WhiteboardEditorBehaviour.Instance == (Object)null) && WhiteboardEditorBehaviour.Instance.IsWindowOpen) { WhiteboardEditorBehaviour.Instance.CloseWindow(); } } private void OnIsHostOnlyChanged(bool previous, bool current) { if (!Plugin.IsHostOrServer) { InteractTrigger.interactable = !current; } } public void OnInteract() { if ((Object)(object)WhiteboardEditorBehaviour.Instance == (Object)null) { Plugin.logger.LogError((object)"Failed to open whiteboard editor window. WhiteboardEditorBehaviour instance was not found."); } else { WhiteboardEditorBehaviour.Instance.OpenWindow(); } } public void SetWorldCanvasCamera() { PlayerControllerB localPlayerScript = PlayerUtils.GetLocalPlayerScript(); if ((Object)(object)localPlayerScript == (Object)null) { Plugin.logger.LogWarning((object)"Failed to set whiteboard world canvas camera. Could not find the local player script or the local player is not spawned yet."); return; } WorldCanvas.worldCamera = localPlayerScript.gameplayCamera; Plugin.Instance.LogInfoExtended("Set whiteboard world canvas camera."); } private void LoadData() { if (Plugin.IsHostOrServer) { string displayText = Utils.LoadFromCurrentSaveFile("Whiteboard_DisplayText", Plugin.ConfigManager.DefaultDisplayText.Value); string textHexColor = Utils.LoadFromCurrentSaveFile("Whiteboard_TextHexColor", "#000000"); int fontSizeIndex = Utils.LoadFromCurrentSaveFile("Whiteboard_FontSizeIndex", 7); int fontStyleIndex = Utils.LoadFromCurrentSaveFile("Whiteboard_FontStyleIndex", 0); int fontFamilyIndex = Utils.LoadFromCurrentSaveFile("Whiteboard_FontFamilyIndex", 0); int horizontalAlignmentIndex = Utils.LoadFromCurrentSaveFile("Whiteboard_HorizontalAlignmentIndex", 0); int verticalAlignmentIndex = Utils.LoadFromCurrentSaveFile("Whiteboard_VerticalAlignmentIndex", 0); SetData(new WhiteboardData(displayText, textHexColor, fontSizeIndex, fontStyleIndex, fontFamilyIndex, horizontalAlignmentIndex, verticalAlignmentIndex)); } } private void SaveData() { if (Plugin.IsHostOrServer) { Utils.SaveToCurrentSaveFile("Whiteboard_DisplayText", Data.DisplayText); Utils.SaveToCurrentSaveFile("Whiteboard_TextHexColor", Data.TextHexColor); Utils.SaveToCurrentSaveFile("Whiteboard_FontSizeIndex", Data.FontSizeIndex); Utils.SaveToCurrentSaveFile("Whiteboard_FontStyleIndex", Data.FontStyleIndex); Utils.SaveToCurrentSaveFile("Whiteboard_FontFamilyIndex", Data.FontFamilyIndex); Utils.SaveToCurrentSaveFile("Whiteboard_HorizontalAlignmentIndex", Data.HorizontalAlignmentIndex); Utils.SaveToCurrentSaveFile("Whiteboard_VerticalAlignmentIndex", Data.VerticalAlignmentIndex); } } public void SetData(WhiteboardData data) { SetDataServerRpc(data, NetworkUtils.GetLocalClientId()); } [ServerRpc(RequireOwnership = false)] public void SetDataServerRpc(WhiteboardData data, int fromClientId) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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_0119: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2180141345u, val, (RpcDelivery)0); bool flag = data != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe<WhiteboardData>(ref data, default(ForNetworkSerializable)); } BytePacker.WriteValueBitPacked(val2, fromClientId); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2180141345u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; if (fromClientId == NetworkUtils.GetLocalClientId()) { Plugin.Instance.LogInfoExtended("Set the whiteboard data. Display text: \"" + data.DisplayText + "\"."); } else { if (Plugin.ConfigManager.HostOnly.Value) { Plugin.logger.LogWarning((object)$"Client #{fromClientId} tried to edit the whiteboard while HostOnly mode is enabled."); return; } Plugin.Instance.LogInfoExtended($"Client #{fromClientId} set the whiteboard data. Display text: \"{data.DisplayText}\"."); } SetDataClientRpc(data); SetDataOnLocalClient(data); } [ClientRpc] private void SetDataClientRpc(WhiteboardData data) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_010c: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2144233494u, val, (RpcDelivery)0); bool flag = data != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe<WhiteboardData>(ref data, default(ForNetworkSerializable)); } ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2144233494u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; if (!Plugin.IsHostOrServer) { SetDataOnLocalClient(data); } } } [ServerRpc(RequireOwnership = false)] public void RequestDataServerRpc(int toClientId) { //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) //IL_00ce: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0114: 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) 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(3228134666u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, toClientId); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3228134666u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; Plugin.Instance.LogInfoExtended($"Recieved request for whiteboard data from client #{toClientId}"); ClientRpcParams val3 = default(ClientRpcParams); val3.Send = new ClientRpcSendParams { TargetClientIds = new <>z__ReadOnlySingleElementList<ulong>((ulong)toClientId) }; ClientRpcParams clientRpcParams = val3; RequestDataClientRpc(Data, clientRpcParams); } } } [ClientRpc] private void RequestDataClientRpc(WhiteboardData data, 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_010c: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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.IsServer || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(4129067645u, clientRpcParams, (RpcDelivery)0); bool flag = data != null; ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val)).WriteValueSafe<WhiteboardData>(ref data, default(ForNetworkSerializable)); } ((NetworkBehaviour)this).__endSendClientRpc(ref val, 4129067645u, clientRpcParams, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; Plugin.Instance.LogInfoExtended("Recieved whiteboard data."); SetDataOnLocalClient(data); } } public void SetDataOnLocalClient(WhiteboardData data) { Data = data; SaveData(); UpdateWorldCanvas(); LogDataExtended(); } private void UpdateWorldCanvas() { UpdateWhiteboardText(); } private void UpdateWhiteboardText() { //IL_0136: 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) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) if (Data == null) { Plugin.logger.LogWarning((object)"WhiteboardData is null in WhiteboardBehaviour.UpdateWhiteboardText(); Setting WhiteboardData to default."); Data = new WhiteboardData(); } string text = string.Empty; if (!string.IsNullOrWhiteSpace(Data.TextHexColor)) { text = text + "<color=" + Data.TextHexColor + ">"; } text = ((!((Object)(object)EmotesSpriteSheetData != (Object)null)) ? (text + Data.DisplayText) : (text + EmotesSpriteSheetData.GetParsedText(Data.DisplayText))); if (Data.FontFamilyIndex == 2) { text = text.ToLower(); } ((TMP_Text)WhiteboardText).text = text; ((TMP_Text)WhiteboardText).fontSize = FontSizeArray[Data.FontSizeIndex]; ((TMP_Text)WhiteboardText).fontStyle = FontStyleArray[Data.FontStyleIndex]; ((TMP_Text)WhiteboardText).font = FontAssetArray[Data.FontFamilyIndex]; TextMeshProUGUI whiteboardText = WhiteboardText; ((TMP_Text)whiteboardText).horizontalAlignment = (HorizontalAlignmentOptions)(Data.HorizontalAlignmentIndex switch { 0 => 1, 1 => 2, 2 => 4, _ => 1, }); TextMeshProUGUI whiteboardText2 = WhiteboardText; ((TMP_Text)whiteboardText2).verticalAlignment = (VerticalAlignmentOptions)(Data.VerticalAlignmentIndex switch { 0 => 256, 1 => 512, 2 => 1024, _ => 256, }); } private void LogDataExtended() { string empty = string.Empty; empty = empty + "DisplayText: \n\"" + Data.DisplayText + "\"\n\n"; empty = empty + "TextHexColor: \"" + Data.TextHexColor + "\"\n"; empty += $"FontSizeIndex: {Data.FontSizeIndex}\n"; empty += $"FontStyleIndex: {Data.FontStyleIndex}\n"; empty += $"FontFamilyIndex: {Data.FontFamilyIndex}\n"; empty += $"HorizontalAlignmentIndex: {Data.HorizontalAlignmentIndex}\n"; empty += $"VerticalAlignmentIndex: {Data.VerticalAlignmentIndex}\n"; Plugin.Instance.LogInfoExtended("\n" + empty.Trim() + "\n\n"); } protected override void __initializeVariables() { if (IsHostOnly == null) { throw new Exception("WhiteboardBehaviour.IsHostOnly cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)IsHostOnly).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)IsHostOnly, "IsHostOnly"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)IsHostOnly); ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(2180141345u, new RpcReceiveHandler(__rpc_handler_2180141345), "SetDataServerRpc"); ((NetworkBehaviour)this).__registerRpc(2144233494u, new RpcReceiveHandler(__rpc_handler_2144233494), "SetDataClientRpc"); ((NetworkBehaviour)this).__registerRpc(3228134666u, new RpcReceiveHandler(__rpc_handler_3228134666), "RequestDataServerRpc"); ((NetworkBehaviour)this).__registerRpc(4129067645u, new RpcReceiveHandler(__rpc_handler_4129067645), "RequestDataClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_2180141345(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); WhiteboardData data = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe<WhiteboardData>(ref data, default(ForNetworkSerializable)); } int fromClientId = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref fromClientId); target.__rpc_exec_stage = (__RpcExecStage)1; ((WhiteboardBehaviour)(object)target).SetDataServerRpc(data, fromClientId); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2144233494(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); WhiteboardData dataClientRpc = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe<WhiteboardData>(ref dataClientRpc, default(ForNetworkSerializable)); } target.__rpc_exec_stage = (__RpcExecStage)1; ((WhiteboardBehaviour)(object)target).SetDataClientRpc(dataClientRpc); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3228134666(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int toClientId = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref toClientId); target.__rpc_exec_stage = (__RpcExecStage)1; ((WhiteboardBehaviour)(object)target).RequestDataServerRpc(toClientId); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_4129067645(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); WhiteboardData data = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe<WhiteboardData>(ref data, default(ForNetworkSerializable)); } ClientRpcParams client = rpcParams.Client; target.__rpc_exec_stage = (__RpcExecStage)1; ((WhiteboardBehaviour)(object)target).RequestDataClientRpc(data, client); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "WhiteboardBehaviour"; } } public class WhiteboardEditorBehaviour : MonoBehaviour { public static WhiteboardEditorBehaviour Instance; public GameObject EditorWindowObject; public TMP_InputField DisplayTextInputField; public GameObject HostOnlyObject; public Button HostOnlyButton; public GameObject HostOnlyCheckedObject; public Image TextColorPreviewImage; public TMP_Dropdown FontSizeDropdown; public TMP_Dropdown FontStyleDropdown; public TMP_Dropdown FontFamilyDropdown; public TMP_Dropdown HorizontalAlignmentDropdown; public TMP_Dropdown VerticalAlignmentDropdown; public const int DefaultFontSizeIndex = 7; public const string DefaultTextHexColor = "#000000"; public bool IsWindowOpen { get; private set; } public string TextHexColor { get; private set; } private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } } private void Start() { CloseWindow(); TextHexColor = "#000000"; } public void OpenWindow() { if ((Object)(object)WhiteboardBehaviour.Instance == (Object)null) { Plugin.logger.LogError((object)"Failed to open whiteboard editor window. Whiteboard instance was not found."); } else if (!Utils.IsQuickMenuOpen() && !IsWindowOpen) { HostOnlyObject.SetActive(Plugin.IsHostOrServer); if (Plugin.IsHostOrServer) { UpdateHostOnlyCheckbox(); } IsWindowOpen = true; EditorWindowObject.SetActive(true); SetDataToUI(WhiteboardBehaviour.Instance.Data); Utils.SetCursorLockState(value: false); PlayerUtils.SetControlsEnabled(value: false); } } public void CloseWindow() { if (ColorPickerBehaviour.Instance.IsWindowOpen) { ColorPickerBehaviour.Instance.CloseWindow(); } IsWindowOpen = false; EditorWindowObject.SetActive(false); Utils.SetCursorLockState(value: true); PlayerUtils.SetControlsEnabled(value: true); } public void OnConfirmButtonClicked() { if ((Object)(object)WhiteboardBehaviour.Instance == (Object)null) { Plugin.logger.LogError((object)"Failed to confirm whiteboard changes. Whiteboard instance was not found."); return; } WhiteboardBehaviour.Instance.SetData(GetDataFromUI()); CloseWindow(); } public void OnCancelButtonClicked() { CloseWindow(); } public void OnResetButtonClicked() { SetDataToUI(new WhiteboardData()); } public void OnHostOnlyButtonClicked() { if (Plugin.IsHostOrServer) { Plugin.ConfigManager.HostOnly.Value = !Plugin.ConfigManager.HostOnly.Value; UpdateHostOnlyCheckbox(); } } public void OnColorPickerButtonClicked() { if (!((Object)(object)ColorPickerBehaviour.Instance == (Object)null)) { ColorPickerBehaviour.Instance.OpenWindow(); } } private void UpdateHostOnlyCheckbox() { HostOnlyCheckedObject.SetActive(Plugin.ConfigManager.HostOnly.Value); } private WhiteboardData GetDataFromUI() { string text = DisplayTextInputField.text; string textHexColor = TextHexColor; int value = FontSizeDropdown.value; int value2 = FontStyleDropdown.value; int value3 = FontFamilyDropdown.value; int value4 = HorizontalAlignmentDropdown.value; int value5 = VerticalAlignmentDropdown.value; return new WhiteboardData(text, textHexColor, value, value2, value3, value4, value5); } private void SetDataToUI(WhiteboardData data) { if (data == null) { Plugin.logger.LogWarning((object)"WhiteboardData is null in WhiteboardEditorBehaviour.SetDataToUI(); Setting WhiteboardData to default."); data = new WhiteboardData(); } try { DisplayTextInputField.text = data.DisplayText; SetTextHexColor(data.TextHexColor); FontSizeDropdown.value = data.FontSizeIndex; FontStyleDropdown.value = data.FontStyleIndex; FontFamilyDropdown.value = data.FontFamilyIndex; HorizontalAlignmentDropdown.value = data.HorizontalAlignmentIndex; VerticalAlignmentDropdown.value = data.VerticalAlignmentIndex; } catch (Exception arg) { Plugin.logger.LogError((object)$"Failed to set whiteboard editor ui data.\n\n{arg}"); } } private void UpdateTextColorPreview() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) Color color = default(Color); if (ColorUtility.TryParseHtmlString(TextHexColor, ref color)) { ((Graphic)TextColorPreviewImage).color = color; } } public void SetTextHexColor(string newTextColorHex) { TextHexColor = newTextColorHex; UpdateTextColorPreview(); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } [CompilerGenerated] internal sealed class <>z__ReadOnlySingleElementList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T> { private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator<T> { object IEnumerator.Current => _item; T IEnumerator<T>.Current => _item; public Enumerator(T item) { _item = item; } bool IEnumerator.MoveNext() { if (!_moveNextCalled) { return _moveNextCalled = true; } return false; } void IEnumerator.Reset() { _moveNextCalled = false; } void IDisposable.Dispose() { } } int ICollection.Count => 1; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection<T>.Count => 1; T IReadOnlyList<T>.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } } int ICollection<T>.Count => 1; bool ICollection<T>.IsReadOnly => true; T IList<T>.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } set { throw new NotSupportedException(); } } public <>z__ReadOnlySingleElementList(T item) { _item = item; } IEnumerator IEnumerable.GetEnumerator() { return new Enumerator(_item); } void ICollection.CopyTo(Array array, int index) { array.SetValue(_item, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return EqualityComparer<T>.Default.Equals(_item, (T)value); } int IList.IndexOf(object value) { if (!EqualityComparer<T>.Default.Equals(_item, (T)value)) { return -1; } return 0; } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator<T> IEnumerable<T>.GetEnumerator() { return new Enumerator(_item); } void ICollection<T>.Add(T item) { throw new NotSupportedException(); } void ICollection<T>.Clear() { throw new NotSupportedException(); } bool ICollection<T>.Contains(T item) { return EqualityComparer<T>.Default.Equals(_item, item); } void ICollection<T>.CopyTo(T[] array, int arrayIndex) { array[arrayIndex] = _item; } bool ICollection<T>.Remove(T item) { throw new NotSupportedException(); } int IList<T>.IndexOf(T item) { if (!EqualityComparer<T>.Default.Equals(_item, item)) { return -1; } return 0; } void IList<T>.Insert(int index, T item) { throw new NotSupportedException(); } void IList<T>.RemoveAt(int index) { throw new NotSupportedException(); } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>(); } } } namespace com.github.zehsteam.Whiteboard.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }