using 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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.zehsteam.Whiteboard")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Adds a new whiteboard store item that you can write on!")]
[assembly: AssemblyFileVersion("1.1.4.0")]
[assembly: AssemblyInformationalVersion("1.1.4+5bcbfa114228d0849c0387bc44b6461ec716f56d")]
[assembly: AssemblyProduct("Whiteboard")]
[assembly: AssemblyTitle("com.github.zehsteam.Whiteboard")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.4.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>();
NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>();
}
}
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_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: 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_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
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_0281: Unknown result type (might be due to invalid IL or missing references)
//IL_0286: 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_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: 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_0281: Unknown result type (might be due to invalid IL or missing references)
//IL_0286: 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_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: 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.1.4")]
[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 => NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer;
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 = false;
[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_005b: 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_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: 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_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: 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_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: 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.1.4";
}
}
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_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: 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_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0046: Unknown result type (might be due to invalid IL or missing references)
ClientRpcParams val = default(ClientRpcParams);
val.Send = new ClientRpcSendParams
{
TargetClientIds = new <>z__ReadOnlyArray<ulong>(new ulong[1] { 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 = null;
public ColorPickerControlBehaviour ColorPickerControlBehaviour = null;
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 = 0f;
[SerializeField]
private RawImage _hueImage;
[SerializeField]
private RawImage _satValImage;
[SerializeField]
private RawImage _outputImage = null;
[SerializeField]
private Slider _hueSlider = null;
[SerializeField]
private TMP_InputField _hexColorInputField = null;
[SerializeField]
private SVImageControlBehaviour _svImageControlBehaviour = null;
private Texture2D _hueTexture;
private Texture2D _satValTexture;
private Texture2D _outputTexture = null;
private bool _updatedHexColorInputFieldInternally = false;
private bool _initialized = false;
private void Start()
{
Initialize();
}
private void Initialize()
{
if (!_initialized)
{
_initialized = true;
CreateHueImage();
CreateSatValImage();
CreateOutputImage();
UpdateOutputImage();
}
}
private void CreateHueImage()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
//IL_0053: 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_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_0064: 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_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: 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)
_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_0013: 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_0026: 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_0048: 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_000e: 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_0013: 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_001e: 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)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(151062475u, clientRpcParams, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val, price);
((NetworkBehaviour)this).__endSendClientRpc(ref val, 151062475u, clientRpcParams, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
UnlockableHelper.UpdateUnlockablePrice(Content.WhiteboardUnlockableItemDef, price);
}
}
}
protected override void __initializeVariables()
{
((NetworkBehaviour)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_PluginNetworkBehaviour()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(151062475u, new RpcReceiveHandler(__rpc_handler_151062475));
}
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)2;
((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_002a: 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_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: 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_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_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_001e: 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_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: 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_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: 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)
//IL_00d1: 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_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: 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_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: 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)
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 = null;
public TextMeshProUGUI WhiteboardText = null;
public float[] FontSizeArray = Array.Empty<float>();
public FontStyles[] FontStyleArray = Array.Empty<FontStyles>();
public TMP_FontAsset[] FontAssetArray = Array.Empty<TMP_FontAsset>();
public SpriteSheetData EmotesSpriteSheetData = null;
[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_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;
}
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_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 != 2 && (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 == 2 && (networkManager.IsClient || networkManager.IsHost) && !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_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_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))
{
Plugin.Instance.LogInfoExtended($"Recieved request for whiteboard data from client #{toClientId}");
ClientRpcParams val3 = default(ClientRpcParams);
val3.Send = new ClientRpcSendParams
{
TargetClientIds = new <>z__ReadOnlyArray<ulong>(new ulong[1] { (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_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 != 2 && (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 == 2 && (networkManager.IsClient || networkManager.IsHost))
{
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_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: 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_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: 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;
int horizontalAlignmentIndex = Data.HorizontalAlignmentIndex;
if (1 == 0)
{
}
HorizontalAlignmentOptions horizontalAlignment = (HorizontalAlignmentOptions)(horizontalAlignmentIndex switch
{
0 => 1,
1 => 2,
2 => 4,
_ => 1,
});
if (1 == 0)
{
}
((TMP_Text)whiteboardText).horizontalAlignment = horizontalAlignment;
TextMeshProUGUI whiteboardText2 = WhiteboardText;
int verticalAlignmentIndex = Data.VerticalAlignmentIndex;
if (1 == 0)
{
}
VerticalAlignmentOptions verticalAlignment = (VerticalAlignmentOptions)(verticalAlignmentIndex switch
{
0 => 256,
1 => 512,
2 => 1024,
_ => 256,
});
if (1 == 0)
{
}
((TMP_Text)whiteboardText2).verticalAlignment = verticalAlignment;
}
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();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_WhiteboardBehaviour()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(2180141345u, new RpcReceiveHandler(__rpc_handler_2180141345));
NetworkManager.__rpc_func_table.Add(2144233494u, new RpcReceiveHandler(__rpc_handler_2144233494));
NetworkManager.__rpc_func_table.Add(3228134666u, new RpcReceiveHandler(__rpc_handler_3228134666));
NetworkManager.__rpc_func_table.Add(4129067645u, new RpcReceiveHandler(__rpc_handler_4129067645));
}
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)2;
((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)2;
((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 = null;
public TMP_InputField DisplayTextInputField = null;
public GameObject HostOnlyObject = null;
public Button HostOnlyButton = null;
public GameObject HostOnlyCheckedObject = null;
public Image TextColorPreviewImage = null;
public TMP_Dropdown FontSizeDropdown = null;
public TMP_Dropdown FontStyleDropdown = null;
public TMP_Dropdown FontFamilyDropdown = null;
public TMP_Dropdown HorizontalAlignmentDropdown = null;
public TMP_Dropdown VerticalAlignmentDropdown = null;
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_0019: 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)
{
}
}
}
internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
int ICollection.Count => _items.Length;
bool ICollection.IsSynchronized => false;
object ICollection.SyncRoot => this;
object IList.this[int index]
{
get
{
return _items[index];
}
set
{
throw new NotSupportedException();
}
}
bool IList.IsFixedSize => true;
bool IList.IsReadOnly => true;
int IReadOnlyCollection<T>.Count => _items.Length;
T IReadOnlyList<T>.this[int index] => _items[index];
int ICollection<T>.Count => _items.Length;
bool ICollection<T>.IsReadOnly => true;
T IList<T>.this[int index]
{
get
{
return _items[index];
}
set
{
throw new NotSupportedException();
}
}
public <>z__ReadOnlyArray(T[] items)
{
_items = items;
}
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable)_items).GetEnumerator();
}
void ICollection.CopyTo(Array array, int index)
{
((ICollection)_items).CopyTo(array, index);
}
int IList.Add(object value)
{
throw new NotSupportedException();
}
void IList.Clear()
{
throw new NotSupportedException();
}
bool IList.Contains(object value)
{
return ((IList)_items).Contains(value);
}
int IList.IndexOf(object value)
{
return ((IList)_items).IndexOf(value);
}
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 ((IEnumerable<T>)_items).GetEnumerator();
}
void ICollection<T>.Add(T item)
{
throw new NotSupportedException();
}
void ICollection<T>.Clear()
{
throw new NotSupportedException();
}
bool ICollection<T>.Contains(T item)
{
return ((ICollection<T>)_items).Contains(item);
}
void ICollection<T>.CopyTo(T[] array, int arrayIndex)
{
((ICollection<T>)_items).CopyTo(array, arrayIndex);
}
bool ICollection<T>.Remove(T item)
{
throw new NotSupportedException();
}
int IList<T>.IndexOf(T item)
{
return ((IList<T>)_items).IndexOf(item);
}
void IList<T>.Insert(int index, T item)
{
throw new NotSupportedException();
}
void IList<T>.RemoveAt(int index)
{
throw new NotSupportedException();
}
}
namespace com.github.zehsteam.Whiteboard.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}