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.3.1
BepInEx/plugins/com.github.zehsteam.Whiteboard.dll
Decompiled 2 weeks 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 System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalConfig; using LethalConfig.ConfigItems; using LethalConfig.ConfigItems.Options; using LethalLib.Extras; using LethalLib.Modules; using Microsoft.CodeAnalysis; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; using com.github.zehsteam.Whiteboard.Dependencies.LethalConfigMod; using com.github.zehsteam.Whiteboard.Extensions; using com.github.zehsteam.Whiteboard.Helpers; using com.github.zehsteam.Whiteboard.Managers; using com.github.zehsteam.Whiteboard.MonoBehaviours; using com.github.zehsteam.Whiteboard.NetcodePatcher; using com.github.zehsteam.Whiteboard.Objects; using com.github.zehsteam.Whiteboard.Patches; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Zehs")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright © 2026 Zehs")] [assembly: AssemblyDescription("Adds a new whiteboard store item that you can write on!")] [assembly: AssemblyFileVersion("1.3.1.0")] [assembly: AssemblyInformationalVersion("1.3.1+dd419132f9c9093cf0ddc27d17d9763f65d63536")] [assembly: AssemblyProduct("Whiteboard")] [assembly: AssemblyTitle("com.github.zehsteam.Whiteboard")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] [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 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 { internal static class Assets { public static readonly string AssetBundleFileName = "whiteboard_assets"; public static GameObject PluginNetworkHandlerPrefab; public static GameObject WhiteboardEditorCanvasPrefab; public static UnlockableItemDef WhiteboardUnlockableItemDef; public static TerminalNode WhiteboardBuyTerminalNode; public static AssetBundle AssetBundle { get; private set; } public static bool IsLoaded { get; private set; } public static void Load() { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string text = Path.Combine(directoryName, AssetBundleFileName); if (!File.Exists(text)) { Logger.LogFatal("Failed to load assets. AssetBundle file could not be found at path \"" + text + "\". Make sure the \"" + AssetBundleFileName + "\" file is in the same folder as the mod's DLL file."); } else { AssetBundle = AssetBundle.LoadFromFile(text); if ((Object)(object)AssetBundle == (Object)null) { Logger.LogFatal("Failed to load assets. AssetBundle is null."); return; } OnAssetBundleLoaded(AssetBundle); IsLoaded = true; } } private static void OnAssetBundleLoaded(AssetBundle assetBundle) { PluginNetworkHandlerPrefab = LoadAsset<GameObject>("PluginNetworkHandler", assetBundle); PluginNetworkHandlerPrefab.AddComponent<PluginNetworkHandler>(); WhiteboardEditorCanvasPrefab = LoadAsset<GameObject>("WhiteboardEditorCanvas", assetBundle); WhiteboardUnlockableItemDef = LoadAsset<UnlockableItemDef>("Whiteboard", assetBundle); WhiteboardBuyTerminalNode = LoadAsset<TerminalNode>("WhiteboardBuy", assetBundle); } private static T LoadAsset<T>(string name, AssetBundle assetBundle) where T : Object { if (string.IsNullOrWhiteSpace(name)) { Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" from AssetBundle. Name is null or whitespace."); return default(T); } if ((Object)(object)assetBundle == (Object)null) { Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. AssetBundle is null."); return default(T); } T val = assetBundle.LoadAsset<T>(name); if ((Object)(object)val == (Object)null) { Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. No asset found with that type and name."); return default(T); } return val; } private static bool TryLoadAsset<T>(string name, AssetBundle assetBundle, out T asset) where T : Object { asset = LoadAsset<T>(name, assetBundle); return (Object)(object)asset != (Object)null; } } internal static class Logger { public static ManualLogSource ManualLogSource { get; private set; } public static bool IsExtendedLoggingEnabled => ConfigManager.Misc_ExtendedLogging?.Value ?? false; public static void Initialize(ManualLogSource manualLogSource) { ManualLogSource = manualLogSource; } public static void LogDebug(object data) { Log((LogLevel)32, data); } public static void LogInfo(object data, bool extended = false) { Log((LogLevel)16, data, extended); } public static void LogMessage(object data, bool extended = false) { Log((LogLevel)8, data, extended); } public static void LogWarning(object data, bool extended = false) { Log((LogLevel)4, data, extended); } public static void LogError(object data, bool extended = false) { Log((LogLevel)2, data, extended); } public static void LogFatal(object data, bool extended = false) { Log((LogLevel)1, data, extended); } public static void Log(LogLevel logLevel, object data, bool extended = false) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (!extended || IsExtendedLoggingEnabled) { ManualLogSource manualLogSource = ManualLogSource; if (manualLogSource != null) { manualLogSource.Log(logLevel, data); } } } } [BepInPlugin("com.github.zehsteam.Whiteboard", "Whiteboard", "1.3.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class Plugin : BaseUnityPlugin { private readonly Harmony _harmony = new Harmony("com.github.zehsteam.Whiteboard"); internal static Plugin Instance { get; private set; } private void Awake() { Instance = this; Logger.Initialize(Logger.CreateLogSource("com.github.zehsteam.Whiteboard")); Logger.LogInfo("Whiteboard has awoken!"); _harmony.PatchAll(typeof(GameNetworkManager_Patches)); _harmony.PatchAll(typeof(StartOfRound_Patches)); _harmony.PatchAll(typeof(HUDManager_Patches)); _harmony.PatchAll(typeof(PlayerControllerB_Patches)); _harmony.PatchAll(typeof(ShipBuildModeManager_Patches)); ConfigManager.Initialize(((BaseUnityPlugin)this).Config); Assets.Load(); RegisterUnlockableItems(); NetworkUtils.NetcodePatcherAwake(); } private void RegisterUnlockableItems() { UnlockableHelper.RegisterUnlockable(Assets.WhiteboardUnlockableItemDef, (StoreType)2, ConfigManager.Whiteboard_Price.Value, Assets.WhiteboardBuyTerminalNode); } } 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.3.1"; } } namespace com.github.zehsteam.Whiteboard.Patches { [HarmonyPatch(typeof(GameNetworkManager))] internal static class GameNetworkManager_Patches { [HarmonyPatch("Start")] [HarmonyPostfix] private static void Start_Patch() { AddNetworkPrefabs(); } private static void AddNetworkPrefabs() { AddNetworkPrefab(Assets.PluginNetworkHandlerPrefab); } private static void AddNetworkPrefab(GameObject prefab) { if ((Object)(object)prefab == (Object)null) { Logger.LogError("Failed to add network prefab. GameObject is null."); return; } NetworkManager.Singleton.AddNetworkPrefab(prefab); Logger.LogInfo("Registered \"" + ((Object)prefab).name + "\" network prefab."); } [HarmonyPatch("SaveGameValues")] [HarmonyPostfix] private static void SaveGameValues_Patch() { com.github.zehsteam.Whiteboard.MonoBehaviours.Whiteboard.Instance?.SaveData(); } } [HarmonyPatch(typeof(HUDManager))] internal static class HUDManager_Patches { [HarmonyPatch("Start")] [HarmonyPostfix] private static void Start_Patch() { WhiteboardEditor.Spawn(); } [HarmonyPatch("OpenMenu_performed")] [HarmonyPrefix] private static void OpenMenu_performed_Patch() { if (!((Object)(object)WhiteboardEditor.Instance == (Object)null) && WhiteboardEditor.Instance.IsWindowOpen) { WhiteboardEditor.Instance.CloseWindow(); } } [HarmonyPatch("EnableChat_performed")] [HarmonyPrefix] private static bool EnableChat_performed_Patch() { if ((Object)(object)WhiteboardEditor.Instance == (Object)null) { return true; } return !WhiteboardEditor.Instance.IsWindowOpen; } [HarmonyPatch("SubmitChat_performed")] [HarmonyPrefix] private static bool SubmitChat_performed_Patch() { if ((Object)(object)WhiteboardEditor.Instance == (Object)null) { return true; } return !WhiteboardEditor.Instance.IsWindowOpen; } } [HarmonyPatch(typeof(PlayerControllerB))] internal static class PlayerControllerB_Patches { [HarmonyPatch("Start")] [HarmonyPostfix] private static void Start_Patch(ref PlayerControllerB __instance) { if (PlayerUtils.IsLocalPlayer(__instance)) { com.github.zehsteam.Whiteboard.MonoBehaviours.Whiteboard.Instance?.SetWorldCanvasCamera(); } } [HarmonyPatch("KillPlayer")] [HarmonyPostfix] private static void KillPlayer_Patch() { if (!((Object)(object)WhiteboardEditor.Instance == (Object)null) && WhiteboardEditor.Instance.IsWindowOpen) { WhiteboardEditor.Instance.CloseWindow(); } } } [HarmonyPatch(typeof(ShipBuildModeManager))] internal static class ShipBuildModeManager_Patches { [HarmonyPatch("PlayerMeetsConditionsToBuild")] [HarmonyPostfix] private static void PlayerMeetsConditionsToBuild_Patch(ref bool __result) { if (!((Object)(object)WhiteboardEditor.Instance == (Object)null) && WhiteboardEditor.Instance.IsWindowOpen) { __result = false; } } } [HarmonyPatch(typeof(StartOfRound))] internal static class StartOfRound_Patches { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void Awake_Patch() { SpawnPluginNetworkHandler(); } private static void SpawnPluginNetworkHandler() { //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 (NetworkUtils.IsServer) { GameObject val = Object.Instantiate<GameObject>(Assets.PluginNetworkHandlerPrefab, Vector3.zero, Quaternion.identity); val.GetComponent<NetworkObject>().Spawn(false); } } [HarmonyPatch("OnClientConnect")] [HarmonyPrefix] private static void OnClientConnect_Patch(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; PluginNetworkHandler.Instance?.SetWhiteboardUnlockablePrice_ClientRpc(ConfigManager.Whiteboard_Price.Value, clientRpcParams); } [HarmonyPatch("ReviveDeadPlayers")] [HarmonyPostfix] private static void ReviveDeadPlayers_Patch() { if (!((Object)(object)WhiteboardEditor.Instance == (Object)null) && WhiteboardEditor.Instance.IsWindowOpen) { PlayerUtils.SetControlsEnabled(value: false); } } } } namespace com.github.zehsteam.Whiteboard.Objects { [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}>"; } } [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() { DisplayText = ConfigManager.Whiteboard_DefaultDisplayText?.Value; 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)); } } } namespace com.github.zehsteam.Whiteboard.MonoBehaviours { public class ColorPicker : MonoBehaviour { [SerializeField] private GameObject _colorPickerWindowObject; [SerializeField] private ColorPickerControl _colorPickerControl; public static ColorPicker Instance { get; private set; } public bool IsWindowOpen { get; private set; } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; } } private void Start() { CloseWindow(); } public void OpenWindow() { if (WhiteboardEditor.Instance.IsWindowOpen && !IsWindowOpen) { IsWindowOpen = true; _colorPickerWindowObject.SetActive(true); _colorPickerControl.SetColor(WhiteboardEditor.Instance.TextHexColor); } } public void CloseWindow() { IsWindowOpen = false; _colorPickerWindowObject.SetActive(false); } public void OnConfirmButtonClicked() { WhiteboardEditor.Instance.SetTextHexColor(_colorPickerControl.GetHexColor()); CloseWindow(); } public void OnCancelButtonClicked() { CloseWindow(); } } public class ColorPickerControl : 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 SVImageControl _SVImageControl; 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(); _SVImageControl.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 PluginNetworkHandler : NetworkBehaviour { public static PluginNetworkHandler Instance { get; private set; } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; } } public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { if (((NetworkBehaviour)this).IsServer) { ((NetworkBehaviour)this).NetworkObject.Despawn(true); } } else { Instance = this; } } [ClientRpc] public void SetWhiteboardUnlockablePrice_ClientRpc(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(232834626u, clientRpcParams, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, price); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 232834626u, clientRpcParams, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; UnlockableHelper.UpdateUnlockablePrice(Assets.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(232834626u, new RpcReceiveHandler(__rpc_handler_232834626), "SetWhiteboardUnlockablePrice_ClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_232834626(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; ((PluginNetworkHandler)(object)target).SetWhiteboardUnlockablePrice_ClientRpc(price, client); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "PluginNetworkHandler"; } } public class SVImageControl : MonoBehaviour, IDragHandler, IEventSystemHandler, IPointerClickHandler { [SerializeField] private ColorPickerControl _colorPickerControl; [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_0034: 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) //IL_0055: 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) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: 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_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) if (_rectTransform == null) { _rectTransform = ((Component)this).GetComponent<RectTransform>(); } if (_pickerTransform == null) { _pickerTransform = ((Component)_pickerImage).GetComponent<RectTransform>(); } Vector2 val = default(Vector2); RectTransformUtility.ScreenPointToLocalPointInRectangle(_rectTransform, eventData.position, eventData.pressEventCamera, ref val); float x = val.x; Rect rect = _rectTransform.rect; float num = (0f - ((Rect)(ref rect)).width) * 0.5f; rect = _rectTransform.rect; float num2 = Mathf.Clamp(x, num, ((Rect)(ref rect)).width * 0.5f); float y = val.y; rect = _rectTransform.rect; float num3 = (0f - ((Rect)(ref rect)).height) * 0.5f; rect = _rectTransform.rect; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(num2, Mathf.Clamp(y, num3, ((Rect)(ref rect)).height * 0.5f)); float x2 = val2.x; rect = _rectTransform.rect; float num4 = x2 + ((Rect)(ref rect)).width * 0.5f; rect = _rectTransform.rect; float saturation = num4 / ((Rect)(ref rect)).width; float y2 = val2.y; rect = _rectTransform.rect; float num5 = y2 + ((Rect)(ref rect)).height * 0.5f; rect = _rectTransform.rect; float num6 = num5 / ((Rect)(ref rect)).height; ((Transform)_pickerTransform).localPosition = Vector2.op_Implicit(val2); ((Graphic)_pickerImage).color = Color.HSVToRGB(0f, 0f, 1f - num6); _colorPickerControl.SetSatVal(saturation, num6); } public void OnDrag(PointerEventData eventData) { UpdateColor(eventData); } public void OnPointerClick(PointerEventData eventData) { UpdateColor(eventData); } public void SetPickerLocation(float saturation, float value) { //IL_0034: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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) //IL_0069: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if (_rectTransform == null) { _rectTransform = ((Component)this).GetComponent<RectTransform>(); } if (_pickerTransform == null) { _pickerTransform = ((Component)_pickerImage).GetComponent<RectTransform>(); } Rect rect = _rectTransform.rect; float num = saturation * ((Rect)(ref rect)).width; rect = _rectTransform.rect; float num2 = num - ((Rect)(ref rect)).width * 0.5f; rect = _rectTransform.rect; float num3 = value * ((Rect)(ref rect)).height; rect = _rectTransform.rect; float num4 = num3 - ((Rect)(ref rect)).height * 0.5f; ((Transform)_pickerTransform).localPosition = Vector2.op_Implicit(new Vector2(num2, num4)); ((Graphic)_pickerImage).color = Color.HSVToRGB(0f, 0f, 1f - value); Logger.LogInfo(string.Format("[{0}] {1}: (saturation: {2}, value: {3}), (x: {4}, y: {5})", "SVImageControl", "SetPickerLocation", saturation, value, num2, num4), extended: true); } } public class Whiteboard : NetworkBehaviour { [SerializeField] private InteractTrigger _interactTrigger; [SerializeField] private Canvas _worldCanvas; [SerializeField] private TextMeshProUGUI _whiteboardText; [SerializeField] private TMP_FontAsset[] _fontAssetArray = Array.Empty<TMP_FontAsset>(); [SerializeField] private SpriteSheetData _emotesSpriteSheetData; [HideInInspector] public NetworkVariable<bool> IsHostOnly = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public static Whiteboard Instance { get; private set; } public WhiteboardData Data { get; private set; } public static float[] FontSizeArray { get; private set; } public static FontStyles[] FontStyleArray { get; private set; } static Whiteboard() { int num = 36; float num2 = 0.05f; float num3 = 0.01f; List<float> list = new List<float>(); for (int i = 0; i < num; i++) { list.Add(num2 + num3 * (float)i); } FontSizeArray = list.ToArray(); FontStyles[] array = new FontStyles[5]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); FontStyleArray = (FontStyles[])(object)array; } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } Instance = this; Data = new WhiteboardData(); } private void Start() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_emotesSpriteSheetData != (Object)null) { ((TMP_Text)_whiteboardText).spriteAsset = _emotesSpriteSheetData.SpriteAsset; } if (NetworkUtils.IsServer) { LoadData(); } else { RequestData_ServerRpc(); } } 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 (NetworkUtils.IsServer) { IsHostOnly.Value = ConfigManager.Whiteboard_HostOnlyEdit.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)WhiteboardEditor.Instance == (Object)null) && WhiteboardEditor.Instance.IsWindowOpen) { WhiteboardEditor.Instance.CloseWindow(); } } private void OnIsHostOnlyChanged(bool previous, bool current) { if (!NetworkUtils.IsServer) { _interactTrigger.interactable = !current; } } public void OnInteract() { if ((Object)(object)WhiteboardEditor.Instance == (Object)null) { Logger.LogError("Failed to open whiteboard editor window. WhiteboardEditorBehaviour instance was not found."); } else { WhiteboardEditor.Instance.OpenWindow(); } } public void SetWorldCanvasCamera() { if (!PlayerUtils.TryGetLocalPlayerScript(out var playerScript)) { Logger.LogWarning("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 = playerScript.gameplayCamera; Logger.LogInfo("Set whiteboard world canvas camera.", extended: true); } public void LoadData() { if (NetworkUtils.IsServer) { if (!GameSaveFileHelper.IsSaveFileCreated()) { SetData(new WhiteboardData()); return; } string displayText = GameSaveFileHelper.Load("Whiteboard_DisplayText", ConfigManager.Whiteboard_DefaultDisplayText.Value); string textHexColor = GameSaveFileHelper.Load("Whiteboard_TextHexColor", "#000000"); int fontSizeIndex = GameSaveFileHelper.Load("Whiteboard_FontSizeIndex", 7); int fontStyleIndex = GameSaveFileHelper.Load("Whiteboard_FontStyleIndex", 0); int fontFamilyIndex = GameSaveFileHelper.Load("Whiteboard_FontFamilyIndex", 0); int horizontalAlignmentIndex = GameSaveFileHelper.Load("Whiteboard_HorizontalAlignmentIndex", 0); int verticalAlignmentIndex = GameSaveFileHelper.Load("Whiteboard_VerticalAlignmentIndex", 0); SetData(new WhiteboardData(displayText, textHexColor, fontSizeIndex, fontStyleIndex, fontFamilyIndex, horizontalAlignmentIndex, verticalAlignmentIndex)); } } public void SaveData() { if (NetworkUtils.IsServer && GameSaveFileHelper.IsSaveFileCreated()) { GameSaveFileHelper.Save("Whiteboard_DisplayText", Data.DisplayText); GameSaveFileHelper.Save("Whiteboard_TextHexColor", Data.TextHexColor); GameSaveFileHelper.Save("Whiteboard_FontSizeIndex", Data.FontSizeIndex); GameSaveFileHelper.Save("Whiteboard_FontStyleIndex", Data.FontStyleIndex); GameSaveFileHelper.Save("Whiteboard_FontFamilyIndex", Data.FontFamilyIndex); GameSaveFileHelper.Save("Whiteboard_HorizontalAlignmentIndex", Data.HorizontalAlignmentIndex); GameSaveFileHelper.Save("Whiteboard_VerticalAlignmentIndex", Data.VerticalAlignmentIndex); } } public void SetData(WhiteboardData data) { SetData_ServerRpc(data, NetworkUtils.LocalClientId); } [ServerRpc(RequireOwnership = false)] public void SetData_ServerRpc(WhiteboardData data, ulong senderClientId) { //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(3156790211u, 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, senderClientId); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3156790211u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; if (NetworkUtils.IsLocalClientId(senderClientId)) { Logger.LogInfo("Set the whiteboard data. Display text: \"" + data.DisplayText + "\"", extended: true); } else { if (ConfigManager.Whiteboard_HostOnlyEdit.Value) { Logger.LogWarning($"Client #{senderClientId} tried to edit the whiteboard while HostOnly mode is enabled."); return; } Logger.LogInfo($"Client #{senderClientId} set the whiteboard data. Display text: \"{data.DisplayText}\".", extended: true); } SetData_ClientRpc(data); SetData_Local(data); } [ClientRpc] private void SetData_ClientRpc(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(2251786617u, 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, 2251786617u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; if (!NetworkUtils.IsServer) { SetData_Local(data); } } } [ServerRpc(RequireOwnership = false)] public void RequestData_ServerRpc(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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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_0116: 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(612770970u, serverRpcParams, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val, 612770970u, serverRpcParams, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; ulong senderClientId = serverRpcParams.Receive.SenderClientId; Logger.LogInfo($"Recieved request for whiteboard data from client #{senderClientId}", extended: true); ClientRpcParams val2 = default(ClientRpcParams); val2.Send = new ClientRpcSendParams { TargetClientIds = new <>z__ReadOnlySingleElementList<ulong>(senderClientId) }; ClientRpcParams clientRpcParams = val2; RequestData_ClientRpc(Data, clientRpcParams); } } } [ClientRpc] private void RequestData_ClientRpc(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(3830325673u, 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, 3830325673u, clientRpcParams, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; Logger.LogInfo("Recieved whiteboard data.", extended: true); SetData_Local(data); } } public void SetData_Local(WhiteboardData data) { Data = data; SaveData(); UpdateWorldCanvas(); LogDataExtended(); } private void UpdateWorldCanvas() { UpdateWhiteboardText(); } private void UpdateWhiteboardText() { //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0138: 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_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) if (Data == null) { Logger.LogWarning("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() { if (Logger.IsExtendedLoggingEnabled) { 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"; Logger.LogInfo("\n" + empty.Trim() + "\n\n", extended: true); } } protected override void __initializeVariables() { if (IsHostOnly == null) { throw new Exception("Whiteboard.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(3156790211u, new RpcReceiveHandler(__rpc_handler_3156790211), "SetData_ServerRpc"); ((NetworkBehaviour)this).__registerRpc(2251786617u, new RpcReceiveHandler(__rpc_handler_2251786617), "SetData_ClientRpc"); ((NetworkBehaviour)this).__registerRpc(612770970u, new RpcReceiveHandler(__rpc_handler_612770970), "RequestData_ServerRpc"); ((NetworkBehaviour)this).__registerRpc(3830325673u, new RpcReceiveHandler(__rpc_handler_3830325673), "RequestData_ClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_3156790211(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)); } ulong senderClientId = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref senderClientId); target.__rpc_exec_stage = (__RpcExecStage)1; ((Whiteboard)(object)target).SetData_ServerRpc(data, senderClientId); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2251786617(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 data_ClientRpc = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe<WhiteboardData>(ref data_ClientRpc, default(ForNetworkSerializable)); } target.__rpc_exec_stage = (__RpcExecStage)1; ((Whiteboard)(object)target).SetData_ClientRpc(data_ClientRpc); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_612770970(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { ServerRpcParams server = rpcParams.Server; target.__rpc_exec_stage = (__RpcExecStage)1; ((Whiteboard)(object)target).RequestData_ServerRpc(server); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3830325673(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; ((Whiteboard)(object)target).RequestData_ClientRpc(data, client); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "Whiteboard"; } } public class WhiteboardEditor : MonoBehaviour { [SerializeField] private GameObject _editorWindowObject; [SerializeField] private TMP_InputField _displayTextInputField; [SerializeField] private GameObject _hostOnlyObject; [SerializeField] private Button _hostOnlyButton; [SerializeField] private GameObject _hostOnlyCheckedObject; [SerializeField] private Image _textColorPreviewImage; [SerializeField] private TMP_Dropdown _fontSizeDropdown; [SerializeField] private TMP_Dropdown _fontStyleDropdown; [SerializeField] private TMP_Dropdown _fontFamilyDropdown; [SerializeField] private TMP_Dropdown _horizontalAlignmentDropdown; [SerializeField] private TMP_Dropdown _verticalAlignmentDropdown; public const int DefaultFontSizeIndex = 7; public const string DefaultTextHexColor = "#000000"; public static WhiteboardEditor Instance { get; private set; } public bool IsWindowOpen { get; private set; } public string TextHexColor { get; private set; } public static void Spawn() { if (!((Object)(object)Instance != (Object)null)) { Object.Instantiate<GameObject>(Assets.WhiteboardEditorCanvasPrefab); Logger.LogInfo("Spawned WhiteboardEditorCanvas."); } } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; } } private void Start() { CloseWindow(); TextHexColor = "#000000"; InitializeFontSizeDropdown(); InitializeFontStyleDropdown(); } private void InitializeFontSizeDropdown() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown _fontSizeDropdown.ClearOptions(); List<OptionData> list = new List<OptionData>(); int num = Whiteboard.FontSizeArray.Length; int num2 = 5; for (int i = 0; i < num; i++) { list.Add(new OptionData($"{num2 + i}")); } _fontSizeDropdown.AddOptions(list); } private void InitializeFontStyleDropdown() { //IL_001e: 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_0037: Expected O, but got Unknown _fontStyleDropdown.ClearOptions(); List<OptionData> list = new List<OptionData>(); FontStyles[] fontStyleArray = Whiteboard.FontStyleArray; for (int i = 0; i < fontStyleArray.Length; i++) { FontStyles val = fontStyleArray[i]; list.Add(new OptionData(((object)(FontStyles)(ref val)).ToString())); } _fontStyleDropdown.AddOptions(list); } public void OpenWindow() { if ((Object)(object)Whiteboard.Instance == (Object)null) { Logger.LogError("Failed to open whiteboard editor window. Whiteboard instance was not found."); } else if (!PlayerUtils.IsQuickMenuOpen() && !IsWindowOpen) { _hostOnlyObject.SetActive(NetworkUtils.IsServer); if (NetworkUtils.IsServer) { UpdateHostOnlyCheckbox(); } IsWindowOpen = true; _editorWindowObject.SetActive(true); SetUIFromData(Whiteboard.Instance.Data); PlayerUtils.SetCursorLockState(value: false); PlayerUtils.SetControlsEnabled(value: false); _displayTextInputField.ActivateInputField(); } } public void CloseWindow() { if (ColorPicker.Instance.IsWindowOpen) { ColorPicker.Instance.CloseWindow(); } IsWindowOpen = false; _editorWindowObject.SetActive(false); PlayerUtils.SetCursorLockState(value: true); PlayerUtils.SetControlsEnabled(value: true); } public void OnConfirmButtonClicked() { if ((Object)(object)Whiteboard.Instance == (Object)null) { Logger.LogError("Failed to confirm whiteboard changes. Whiteboard instance was not found."); return; } Whiteboard.Instance.SetData(GetDataFromUI()); CloseWindow(); } public void OnCancelButtonClicked() { CloseWindow(); } public void OnResetButtonClicked() { SetUIFromData(new WhiteboardData()); } public void OnHostOnlyButtonClicked() { if (NetworkUtils.IsServer) { ConfigManager.Whiteboard_HostOnlyEdit.Value = !ConfigManager.Whiteboard_HostOnlyEdit.Value; UpdateHostOnlyCheckbox(); } } public void OnColorPickerButtonClicked() { if (!((Object)(object)ColorPicker.Instance == (Object)null)) { ColorPicker.Instance.OpenWindow(); } } private void UpdateHostOnlyCheckbox() { _hostOnlyCheckedObject.SetActive(ConfigManager.Whiteboard_HostOnlyEdit.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 SetUIFromData(WhiteboardData data) { if (data == null) { Logger.LogWarning("WhiteboardData is null in WhiteboardEditor.SetUIFromData() 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) { Logger.LogError($"Failed to set whiteboard editor ui data. {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 com.github.zehsteam.Whiteboard.Managers { internal static class ConfigManager { public static ConfigFile ConfigFile { get; private set; } public static ConfigEntry<bool> Misc_ExtendedLogging { get; private set; } public static ConfigEntry<int> Whiteboard_Price { get; private set; } public static ConfigEntry<bool> Whiteboard_HostOnlyEdit { get; private set; } public static ConfigEntry<string> Whiteboard_DefaultDisplayText { get; private set; } public static void Initialize(ConfigFile configFile) { ConfigFile = configFile; BindConfigs(); } private static void BindConfigs() { ConfigHelper.SkipAutoGen(); Misc_ExtendedLogging = ConfigHelper.Bind("Misc", "ExtendedLogging", defaultValue: false, "Enable extended logging."); Whiteboard_Price = ConfigHelper.Bind("Whiteboard", "Price", 100, "The price of the whiteboard in the store.", requiresRestart: false, (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 500)); Whiteboard_HostOnlyEdit = ConfigHelper.Bind("Whiteboard", "HostOnlyEdit", defaultValue: false, "If enabled, only the host can edit the whiteboard."); Whiteboard_DefaultDisplayText = ConfigHelper.Bind("Whiteboard", "DefaultDisplayText", "", "The default display text that shows on the whiteboard. Supports rich text tags."); Whiteboard_Price.SettingChanged += delegate { Whiteboard_Price_SettingChanged(); }; Whiteboard_HostOnlyEdit.SettingChanged += delegate { Whiteboard_HostOnly_SettingChanged(); }; } private static void Whiteboard_Price_SettingChanged() { //IL_001e: 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) if (NetworkUtils.IsServer) { PluginNetworkHandler.Instance?.SetWhiteboardUnlockablePrice_ClientRpc(Whiteboard_Price.Value); } } private static void Whiteboard_HostOnly_SettingChanged() { if (NetworkUtils.IsServer) { com.github.zehsteam.Whiteboard.MonoBehaviours.Whiteboard instance = com.github.zehsteam.Whiteboard.MonoBehaviours.Whiteboard.Instance; if (instance != null) { instance.IsHostOnly.Value = Whiteboard_HostOnlyEdit.Value; } } } } } namespace com.github.zehsteam.Whiteboard.Helpers { internal static class ConfigHelper { public static void SkipAutoGen() { if (LethalConfigProxy.IsInstalled) { LethalConfigProxy.SkipAutoGen(); } } public static void AddButton(string section, string name, string buttonText, string description, Action callback) { if (LethalConfigProxy.IsInstalled) { LethalConfigProxy.AddButton(section, name, buttonText, description, callback); } } public static ConfigEntry<T> Bind<T>(string section, string key, T defaultValue, string description, bool requiresRestart = false, AcceptableValueBase acceptableValues = null, Action<T> settingChanged = null, ConfigFile configFile = null) { if (configFile == null) { configFile = ConfigManager.ConfigFile; } ConfigEntry<T> configEntry = configFile.Bind(section, key, defaultValue, description, acceptableValues); if (settingChanged != null) { configEntry.SettingChanged += delegate { settingChanged?.Invoke(configEntry.Value); }; } if (LethalConfigProxy.IsInstalled) { LethalConfigProxy.AddConfig<T>(configEntry, requiresRestart); } return configEntry; } } internal static class GameSaveFileHelper { private static string GetCurrentSaveFilePath() { if ((Object)(object)GameNetworkManager.Instance == (Object)null) { Logger.LogWarning("GameSaveFileHelper: GetCurrentSaveFilePath() GameNetworkManager instance is null. Returning an empty string."); return string.Empty; } return GameNetworkManager.Instance.currentSaveFileName; } public static bool IsSaveFileCreated() { return ES3.FileExists(GetCurrentSaveFilePath()); } public static bool KeyExists(string key) { if (!NetworkUtils.IsServer) { return false; } return ES3.KeyExists(key, GetCurrentSaveFilePath()); } public static T Load<T>(string key, T defaultValue = default(T)) { if (!NetworkUtils.IsServer) { return defaultValue; } if (TryLoad<T>(key, out var value)) { return value; } return defaultValue; } public static bool TryLoad<T>(string key, out T value) { if (!NetworkUtils.IsServer) { value = default(T); return false; } value = ES3.Load<T>(key, GetCurrentSaveFilePath()); return value != null; } public static bool Save<T>(string key, T value) { if (!NetworkUtils.IsServer) { return false; } ES3.Save<T>(key, value, GetCurrentSaveFilePath()); return true; } } internal static class NetworkUtils { private static readonly FieldInfo _rpcExecStageField = AccessTools.Field(typeof(NetworkBehaviour), "__rpc_exec_stage"); public static bool IsConnected { get { NetworkManager singleton = NetworkManager.Singleton; if (singleton == null) { return false; } return singleton.IsConnectedClient; } } public static bool IsServer { get { NetworkManager singleton = NetworkManager.Singleton; if (singleton == null) { return false; } return singleton.IsServer; } } public static ulong LocalClientId { get { NetworkManager singleton = NetworkManager.Singleton; if (singleton == null) { return 0uL; } return singleton.LocalClientId; } } public static int ConnectedPlayerCount => GameNetworkManager.Instance?.connectedPlayers ?? 0; public static bool IsLocalClientId(ulong clientId) { return clientId == LocalClientId; } public static bool HasClient(ulong clientId) { if ((Object)(object)NetworkManager.Singleton == (Object)null) { return false; } return NetworkManager.Singleton.ConnectedClients.ContainsKey(clientId); } public static bool IsNetworkPrefab(GameObject prefab) { if ((Object)(object)prefab == (Object)null) { return false; } if ((Object)(object)NetworkManager.Singleton == (Object)null) { return false; } IReadOnlyList<NetworkPrefab> prefabs = NetworkManager.Singleton.NetworkConfig.Prefabs.Prefabs; return prefabs.Any((NetworkPrefab x) => (Object)(object)x.Prefab == (Object)(object)prefab); } public static void NetcodePatcherAwake() { try { Assembly executingAssembly = Assembly.GetExecutingAssembly(); IEnumerable<Type> loadableTypes = executingAssembly.GetLoadableTypes(); foreach (Type item in loadableTypes) { MethodInfo[] methods = item.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array = methods; foreach (MethodInfo methodInfo in array) { try { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { try { methodInfo.Invoke(null, null); } catch (TargetInvocationException ex) { Logger.LogWarning("[NetworkUtils] Failed to invoke method " + methodInfo.Name + ": " + ex.Message); } } } catch (Exception ex2) { Logger.LogWarning("[NetworkUtils] Error processing method " + methodInfo.Name + " in type " + item.Name + ": " + ex2.Message); } } } } catch (Exception ex3) { Logger.LogError("[NetworkUtils] Failed to run NetcodePatcherAwake: " + ex3.Message); } } public static bool IsExecutingRPCMethod(NetworkBehaviour networkBehaviour) { if ((Object)(object)networkBehaviour == (Object)null) { return false; } NetworkManager networkManager = networkBehaviour.NetworkManager; if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening) { return false; } if (_rpcExecStageField == null) { Logger.LogError("[NetworkUtils] IsExecutingRPCMethod: Failed to find \"__rpc_exec_stage\" field."); return false; } object value = _rpcExecStageField.GetValue(networkBehaviour); int num = (int)value; if (num != 0) { return num == 1; } return true; } } internal static class PlayerUtils { public static PlayerControllerB LocalPlayerScript => GameNetworkManager.Instance?.localPlayerController ?? null; public static PlayerControllerB[] AllPlayerScripts => StartOfRound.Instance?.allPlayerScripts ?? Array.Empty<PlayerControllerB>(); public static PlayerControllerB[] ConnectedPlayerScripts => AllPlayerScripts.Where(IsConnected).ToArray(); public static PlayerControllerB[] AlivePlayerScripts => ConnectedPlayerScripts.Where((PlayerControllerB x) => !x.isPlayerDead).ToArray(); public static PlayerControllerB[] DeadPlayerScripts => ConnectedPlayerScripts.Where((PlayerControllerB x) => x.isPlayerDead).ToArray(); public static bool TryGetLocalPlayerScript(out PlayerControllerB playerScript) { playerScript = LocalPlayerScript; return (Object)(object)playerScript != (Object)null; } public static bool IsLocalPlayer(PlayerControllerB playerScript) { if ((Object)(object)playerScript == (Object)null) { return false; } return (Object)(object)playerScript == (Object)(object)LocalPlayerScript; } public static bool IsConnected(PlayerControllerB playerScript) { if ((Object)(object)playerScript == (Object)null) { return false; } if (!playerScript.isPlayerControlled) { return playerScript.isPlayerDead; } return true; } public static PlayerControllerB GetPlayerScriptByClientId(ulong clientId) { return ((IEnumerable<PlayerControllerB>)ConnectedPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB playerScript) => playerScript.actualClientId == clientId)); } public static bool TryGetPlayerScriptByClientId(ulong clientId, out PlayerControllerB playerScript) { playerScript = GetPlayerScriptByClientId(clientId); return (Object)(object)playerScript != (Object)null; } public static PlayerControllerB GetPlayerScriptByPlayerId(int playerId) { if (playerId < 0 || playerId > ConnectedPlayerScripts.Length - 1) { return null; } return ConnectedPlayerScripts[playerId]; } public static bool TryGetPlayerScriptByPlayerId(int playerId, out PlayerControllerB playerScript) { playerScript = GetPlayerScriptByPlayerId(playerId); return (Object)(object)playerScript != (Object)null; } public static PlayerControllerB GetPlayerScriptByUsername(string username) { PlayerControllerB[] source = ConnectedPlayerScripts.OrderBy((PlayerControllerB x) => x.playerUsername.Length).ToArray(); PlayerControllerB val = ((IEnumerable<PlayerControllerB>)source).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB x) => x.playerUsername.Equals(username, StringComparison.OrdinalIgnoreCase))); if (val == null) { val = ((IEnumerable<PlayerControllerB>)source).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB x) => x.playerUsername.StartsWith(username, StringComparison.OrdinalIgnoreCase))); } if (val == null) { val = ((IEnumerable<PlayerControllerB>)source).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB x) => x.playerUsername.Contains(username, StringComparison.OrdinalIgnoreCase))); } return val; } public static bool TryGetPlayerScriptByUsername(string username, out PlayerControllerB playerScript) { playerScript = GetPlayerScriptByUsername(username); return (Object)(object)playerScript != (Object)null; } public static PlayerControllerB GetRandomPlayerScript(PlayerControllerB[] playerScripts, bool excludeLocal = false) { if (playerScripts == null || playerScripts.Length == 0) { return null; } PlayerControllerB[] array = playerScripts.Where((PlayerControllerB playerScript) => !excludeLocal || !IsLocalPlayer(playerScript)).ToArray(); if (array.Length == 0) { return null; } return array[Random.Range(0, array.Length)]; } public static bool TryGetRandomPlayerScript(PlayerControllerB[] playerScripts, out PlayerControllerB playerScript, bool excludeLocal = false) { playerScript = GetRandomPlayerScript(playerScripts, excludeLocal); return (Object)(object)playerScript != (Object)null; } public static void SetCursorLockState(bool value) { if (IsQuickMenuOpen()) { return; } Cursor.lockState = (CursorLockMode)(value ? 1 : 0); if (value) { Cursor.visible = false; return; } StartOfRound instance = StartOfRound.Instance; if (instance == null || !instance.localPlayerUsingController) { Cursor.visible = true; } } public static bool IsQuickMenuOpen() { if (!TryGetLocalPlayerScript(out var playerScript)) { return false; } return playerScript.quickMenuManager.isMenuOpen; } public static void SetControlsEnabled(bool value) { if (TryGetLocalPlayerScript(out var playerScript)) { bool isTypingChat = (playerScript.disableMoveInput = (playerScript.disableLookInput = !value)); playerScript.isTypingChat = isTypingChat; } } } internal static 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); Logger.LogInfo($"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); Logger.LogInfo($"Updated \"{unlockableItemDef.unlockable.unlockableName}\" unlockable shop item price to ${price}."); } } internal static class Utils { public static string GetPluginDirectoryPath() { return Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location); } public static string GetConfigDirectoryPath() { return Paths.ConfigPath; } public static string GetPluginPersistentDataPath() { return Path.Combine(Application.persistentDataPath, "Whiteboard"); } public static ConfigFile CreateConfigFile(BaseUnityPlugin plugin, string path, string name = null, bool saveOnInit = false) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown BepInPlugin metadata = MetadataHelper.GetMetadata((object)plugin); if (name == null) { name = metadata.GUID; } name += ".cfg"; return new ConfigFile(Path.Combine(path, name), saveOnInit, metadata); } public static ConfigFile CreateLocalConfigFile(BaseUnityPlugin plugin, string name = null, bool saveOnInit = false) { return CreateConfigFile(plugin, GetConfigDirectoryPath(), name, saveOnInit); } public static ConfigFile CreateGlobalConfigFile(BaseUnityPlugin plugin, string name = null, bool saveOnInit = false) { string pluginPersistentDataPath = GetPluginPersistentDataPath(); if (name == null) { name = "global"; } return CreateConfigFile(plugin, pluginPersistentDataPath, name, saveOnInit); } public static bool RollPercentChance(float percent) { if (percent <= 0f) { return false; } if (percent >= 100f) { return true; } return Random.value * 100f <= percent; } } } namespace com.github.zehsteam.Whiteboard.Extensions { internal static class AssemblyExtensions { public static IEnumerable<Type> GetLoadableTypes(this Assembly assembly) { if (assembly == null) { return Array.Empty<Type>(); } try { return assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { return ex.Types.Where((Type type) => type != null); } } } internal static class ConfigFileExtensions { public static ConfigEntry<T> Bind<T>(this ConfigFile configFile, string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown if (acceptableValues == null) { return configFile.Bind<T>(section, key, defaultValue, description); } return configFile.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, Array.Empty<object>())); } } internal static class StringExtensions { public static bool IsHexColor(this string value) { return Regex.IsMatch(value, "^#?([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$"); } } } namespace com.github.zehsteam.Whiteboard.Dependencies.LethalConfigMod { internal static class LethalConfigProxy { public const string PLUGIN_GUID = "ainavt.lc.lethalconfig"; public static bool IsInstalled => Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"); [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void SkipAutoGen() { LethalConfigManager.SkipAutoGen(); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static object AddConfig<T>(ConfigEntry<T> configEntry, bool requiresRestart = false) { //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown if (typeof(T).IsEnum) { MethodInfo methodInfo = AccessTools.Method(typeof(LethalConfigProxy), "AddEnumDropdown", (Type[])null, (Type[])null); MethodInfo methodInfo2 = methodInfo.MakeGenericMethod(typeof(T)); object? obj = methodInfo2.Invoke(null, new object[2] { configEntry, requiresRestart }); return (obj is BaseConfigItem) ? obj : null; } AcceptableValueBase acceptableValues = ((ConfigEntryBase)configEntry).Description.AcceptableValues; if (acceptableValues != null) { if (acceptableValues is AcceptableValueRange<float> || acceptableValues is AcceptableValueRange<int>) { return AddConfigSlider<T>(configEntry, requiresRestart); } if (acceptableValues is AcceptableValueList<string>) { return AddConfigDropdown<T>(configEntry, requiresRestart); } } if (configEntry is ConfigEntry<string> val && IsConfigEntryForHexColor(val)) { return AddConfigItem((BaseConfigItem)new HexColorInputFieldConfigItem(val, requiresRestart)); } if (!(configEntry is ConfigEntry<int> val2)) { if (!(configEntry is ConfigEntry<float> val3)) { if (!(configEntry is ConfigEntry<bool> val4)) { if (configEntry is ConfigEntry<string> val5) { return AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(val5, requiresRestart)); } throw new NotSupportedException($"Unsupported type: {typeof(T)}"); } return AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(val4, requiresRestart)); } return AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(val3, requiresRestart)); } return AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(val2, requiresRestart)); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static object AddButton(string section, string name, string buttonText, string description, Action callback) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown BaseConfigItem configItem = (BaseConfigItem)new GenericButtonConfigItem(section, name, description, buttonText, (GenericButtonHandler)delegate { callback?.Invoke(); }); return AddConfigItem(configItem); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static BaseConfigItem AddConfigSlider<T>(ConfigEntry<T> configEntry, bool requiresRestart = false) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown if (!(configEntry is ConfigEntry<float> val)) { if (configEntry is ConfigEntry<int> val2) { return AddConfigItem((BaseConfigItem)new IntSliderConfigItem(val2, requiresRestart)); } throw new NotSupportedException($"Slider not supported for type: {typeof(T)}"); } return AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(val, requiresRestart)); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static BaseConfigItem AddConfigDropdown<T>(ConfigEntry<T> configEntry, bool requiresRestart = false) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown if (configEntry is ConfigEntry<string> val) { return AddConfigItem((BaseConfigItem)new TextDropDownConfigItem(val, requiresRestart)); } throw new NotSupportedException($"Dropdown not supported for type: {typeof(T)}"); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static BaseConfigItem AddEnumDropdown<T>(ConfigEntry<T> configEntry, bool requiresRestart = false) where T : Enum { return AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<T>(configEntry, requiresRestart)); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static bool IsConfigEntryForHexColor(ConfigEntry<string> configEntry) { if (!(((ConfigEntryBase)configEntry).DefaultValue is string value)) { return false; } return value.IsHexColor(); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static BaseConfigItem AddConfigItem(BaseConfigItem configItem) { LethalConfigManager.AddConfigItem(configItem); return configItem; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } 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 { } }