Decompiled source of DrawableWhiteboard v0.0.1

BepInEx/plugins/DrawableWhiteboard.dll

Decompiled 4 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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 Dawn;
using DrawableWhiteboard.Behaviours;
using DrawableWhiteboard.NetcodePatcher;
using GameNetcodeStuff;
using HarmonyLib;
using HatLib;
using HatLib.Tools;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("DrawableWhiteboard")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1")]
[assembly: AssemblyProduct("DrawableWhiteboard")]
[assembly: AssemblyTitle("DrawableWhiteboard")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[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 DrawableWhiteboard
{
	internal enum WhiteboardPointBudget
	{
		Points2K = 0x800,
		Points4K = 0x1000,
		Points8K = 0x2000,
		Points16K = 0x4000
	}
	internal static class ConfigManager
	{
		private const string DuskGUID = "MrHat.DrawableWhiteboard";

		private static readonly DuskConfigInjector Dusk = new DuskConfigInjector("MrHat.DrawableWhiteboard");

		internal static ConfigEntry<bool> DebugLogsEnabled { get; private set; } = null;

		internal static ConfigEntry<WhiteboardPointBudget> PointBudget { get; private set; } = null;

		internal static ConfigEntry<string> StartingColour { get; private set; } = null;

		internal static ConfigEntry<float> StartingBrushSize { get; private set; } = null;

		internal static void Bind()
		{
			PointBudget = Dusk.Bind<WhiteboardPointBudget>("Drawable Whiteboard Options", "Point Budget", WhiteboardPointBudget.Points4K, "The maximum number of 'points' the whiteboard remembers. Higher values allow more drawing, but use more network data and save space");
			StartingColour = Dusk.Bind<string>("Drawable Whiteboard Options", "Starting Colour", "000000", "The colour selected whenever you start using the whiteboard for the first time");
			StartingBrushSize = Dusk.Bind<float>("Drawable Whiteboard Options", "Starting Brush Size", 3f, "The brush size selected whenever you start using the whiteboard for the first time. Accepted values are between 1 to 20");
			DebugLogsEnabled = Dusk.Bind<bool>("Internal", "Enable Debug Logging", false, "Enables debug logging.");
		}
	}
	internal static class Log
	{
		internal static void Debug(string message)
		{
			if (ConfigManager.DebugLogsEnabled.Value)
			{
				Write((LogLevel)32, message);
			}
		}

		internal static void Info(string message)
		{
			Write((LogLevel)16, message);
		}

		internal static void Warn(string message)
		{
			Write((LogLevel)4, message);
		}

		internal static void Error(string message)
		{
			Write((LogLevel)2, message);
		}

		internal static void Fatal(string message)
		{
			Write((LogLevel)1, message);
		}

		private static void Write(LogLevel logLevel, string message)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			Plugin.mls.Log(logLevel, (object)message);
		}
	}
	internal static class Patches
	{
		[HarmonyPatch(typeof(PlayerControllerB), "Interact_performed")]
		[HarmonyPatch(typeof(PlayerControllerB), "ItemSecondaryUse_performed")]
		[HarmonyPatch(typeof(PlayerControllerB), "ItemTertiaryUse_performed")]
		[HarmonyPatch(typeof(PlayerControllerB), "QEItemInteract_performed")]
		[HarmonyPatch(typeof(PlayerControllerB), "ActivateItem_performed")]
		[HarmonyPatch(typeof(PlayerControllerB), "ActivateItem_canceled")]
		[HarmonyPatch(typeof(PlayerControllerB), "Discard_performed")]
		[HarmonyPatch(typeof(PlayerControllerB), "ScrollMouse_performed")]
		[HarmonyPatch(typeof(PlayerControllerB), "UseUtilitySlot_performed")]
		[HarmonyPatch(typeof(PlayerControllerB), "InspectItem_performed")]
		[HarmonyPatch(typeof(PlayerControllerB), "OpenMenu_performed")]
		[HarmonyPatch(typeof(PlayerControllerB), "Jump_performed")]
		[HarmonyPatch(typeof(PlayerControllerB), "Crouch_performed")]
		[HarmonyPatch(typeof(PlayerControllerB), "Emote1_performed")]
		[HarmonyPatch(typeof(PlayerControllerB), "Emote2_performed")]
		[HarmonyPatch(typeof(PlayerControllerB), "SetFreeCamera_performed")]
		[HarmonyPatch(typeof(PlayerControllerB), "SpeedCheat_performed")]
		[HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")]
		[HarmonyPatch(typeof(HUDManager), "EnableChat_performed")]
		[HarmonyPatch(typeof(HUDManager), "OpenMenu_performed")]
		[HarmonyPatch(typeof(HUDManager), "PingScan_performed")]
		[HarmonyPatch(typeof(QuickMenuManager), "OpenQuickMenu")]
		[HarmonyPatch(typeof(HUDManager), "HideHUD")]
		[HarmonyPatch(typeof(ShipBuildModeManager), "EnterBuildMode")]
		[HarmonyPrefix]
		private static bool BlockInputMegaPrefix()
		{
			return !DrawableWhiteboard.Behaviours.DrawableWhiteboard.IsOpen;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "TeleportPlayer")]
		[HarmonyPrefix]
		private static void TeleportPlayerPrefix(PlayerControllerB __instance)
		{
			if ((Object)(object)__instance == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				DrawableWhiteboard.Behaviours.DrawableWhiteboard.Instance?.StopUsingBoard(releaseBoard: true);
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "SetHoverTipAndCurrentInteractTrigger")]
		[HarmonyPostfix]
		private static void SetHoverTipAndCurrentInteractTriggerPrefix(PlayerControllerB __instance)
		{
			if ((Object)(object)__instance == (Object)(object)GameNetworkManager.Instance.localPlayerController && (Object)(object)DrawableWhiteboard.Behaviours.DrawableWhiteboard.Instance != (Object)null && (Object)(object)__instance.hoveringOverTrigger == (Object)(object)DrawableWhiteboard.Behaviours.DrawableWhiteboard.Instance.InteractTrigger && (__instance.isHoldingObject || (Object)(object)__instance.currentlyHeldObjectServer != (Object)null || __instance.twoHanded))
			{
				((TMP_Text)__instance.cursorTip).text = "[Hands full]";
			}
		}
	}
	[BepInPlugin("MrHat.DrawableWhiteboard.Internals", "DrawableWhiteboard", "0.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string modGUID = "MrHat.DrawableWhiteboard.Internals";

		public const string modName = "DrawableWhiteboard";

		public const string modVersion = "0.0.1";

		private readonly Harmony _harmony = new Harmony("MrHat.DrawableWhiteboard.Internals");

		internal static ManualLogSource mls;

		private void Awake()
		{
			mls = ((BaseUnityPlugin)this).Logger;
			InitialiseNetworkSerialisation();
			ConfigManager.Bind();
			_harmony.PatchAll(typeof(Patches));
			Log.Info("DrawableWhiteboard loaded");
		}

		private static void InitialiseNetworkSerialisation()
		{
			MethodInfo methodInfo = typeof(Plugin).Assembly.GetType("__GEN.NetworkVariableSerializationHelper")?.GetMethod("InitializeSerialization", BindingFlags.Static | BindingFlags.NonPublic);
			if (methodInfo == null)
			{
				Log.Fatal("Netcode serialization method was not found");
			}
			else
			{
				methodInfo.Invoke(null, null);
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "DrawableWhiteboard";

		public const string PLUGIN_NAME = "DrawableWhiteboard";

		public const string PLUGIN_VERSION = "0.0.1";
	}
}
namespace DrawableWhiteboard.Behaviours
{
	public class DrawableWhiteboard : NetworkBehaviour
	{
		private const float PointRate = 30f;

		private const float MinimumPointPixels = 3f;

		private const float RayDistance = 10f;

		private const int ToolSaveSize = 5;

		private const ulong NoDrawer = ulong.MaxValue;

		private static readonly NamespacedKey SaveKey = NamespacedKey.From("drawablewhiteboard", "drawable_whiteboard");

		private static readonly NamespacedKey ToolSaveKey = NamespacedKey.From("drawablewhiteboard", "drawable_whiteboard_tools");

		[Header("Whiteboard")]
		[SerializeField]
		private InteractTrigger interactTrigger = null;

		[SerializeField]
		private Transform cameraPosition = null;

		[SerializeField]
		private BoxCollider drawingCollider = null;

		[SerializeField]
		private DecalProjector drawingDecal = null;

		[SerializeField]
		private Material brushMaterial = null;

		[SerializeField]
		private WhiteboardHUDSettings HUDSettings = null;

		[Header("Drawing")]
		[SerializeField]
		private int textureWidth = 1024;

		[SerializeField]
		private int textureHeight = 512;

		[Header("Audio")]
		[SerializeField]
		private AudioSource markerAudioSource = null;

		private NetworkVariable<ulong> drawerClientId = null;

		private NetworkVariable<uint> rememberedColour = null;

		private NetworkVariable<byte> rememberedBrushRadius = null;

		private NetworkVariable<byte> rememberedEraserRadius = null;

		private NetworkList<WhiteboardPoint> points = null;

		private List<int> undoStarts = null;

		private AudioSource whiteboardAudio = null;

		private BoxCollider interactCollider = null;

		private InputAction exitAction = null;

		private RaycastHit[] drawingHits = null;

		private WhiteboardDrawingSurface drawingSurface = null;

		private WhiteboardPlayerSession? playerSession;

		private WhiteboardPoint lastMousePoint;

		private Color selectedBrushColour;

		private int pointBudget;

		private float selectedBrushRadius;

		private float selectedEraserRadius;

		private float resizeHeldTime;

		private float nextResizeTime;

		private int resizeDirection;

		private bool prefabReady;

		private bool newStroke = true;

		private bool newAction;

		private bool hasMousePoint;

		private bool saveDirty;

		private bool pointLimitLogged;

		private bool eraserSelected;

		private float nextPointTime;

		internal static DrawableWhiteboard? Instance;

		internal static bool IsOpen => Instance?.playerSession != null;

		internal InteractTrigger InteractTrigger => interactTrigger;

		internal Color SelectedBrushColour => selectedBrushColour;

		internal float SelectedToolRadius => eraserSelected ? selectedEraserRadius : selectedBrushRadius;

		internal bool EraserSelected => eraserSelected;

		private void Awake()
		{
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: 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)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: 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_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			WhiteboardPointBudget value = ConfigManager.PointBudget.Value;
			drawerClientId = new NetworkVariable<ulong>(ulong.MaxValue, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);
			pointBudget = (int)value;
			points = new NetworkList<WhiteboardPoint>();
			undoStarts = new List<int>();
			interactCollider = ((Component)interactTrigger).GetComponent<BoxCollider>();
			PlaceableShipObject componentInChildren = ((Component)((Component)this).transform.parent).GetComponentInChildren<PlaceableShipObject>(true);
			whiteboardAudio = ((Component)componentInChildren).GetComponent<AudioSource>();
			drawingHits = (RaycastHit[])(object)new RaycastHit[8];
			string text = ConfigManager.StartingColour.Value.Trim().TrimStart('#');
			Color val = default(Color);
			bool flag = text.Length != 6 || !ColorUtility.TryParseHtmlString("#" + text, ref val);
			bool flag2 = flag;
			if (!flag2)
			{
				bool flag3;
				switch (value)
				{
				case WhiteboardPointBudget.Points2K:
				case WhiteboardPointBudget.Points4K:
				case WhiteboardPointBudget.Points8K:
				case WhiteboardPointBudget.Points16K:
					flag3 = true;
					break;
				default:
					flag3 = false;
					break;
				}
				flag2 = !flag3;
			}
			if (flag2 || ConfigManager.StartingBrushSize.Value < HUDSettings.MinimumBrushRadius || ConfigManager.StartingBrushSize.Value > HUDSettings.MaximumBrushRadius)
			{
				Log.Error("Whiteboard config settings are invalid");
				((Behaviour)this).enabled = false;
				return;
			}
			exitAction = InputSystem.actions.FindAction("OpenMenu", true);
			Color32 val2 = Color32.op_Implicit(val);
			byte b = (byte)Mathf.RoundToInt(ConfigManager.StartingBrushSize.Value * 10f);
			uint num = (uint)((val2.r << 16) | (val2.g << 8) | val2.b);
			rememberedColour = new NetworkVariable<uint>(num, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);
			rememberedBrushRadius = new NetworkVariable<byte>(b, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);
			rememberedEraserRadius = new NetworkVariable<byte>(b, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);
			selectedBrushColour = val;
			selectedBrushRadius = ConfigManager.StartingBrushSize.Value;
			selectedEraserRadius = ConfigManager.StartingBrushSize.Value;
			drawingSurface = new WhiteboardDrawingSurface(drawingDecal, brushMaterial, textureWidth, textureHeight);
			if (!drawingSurface.Configure())
			{
				((Behaviour)this).enabled = false;
				return;
			}
			((UnityEvent<PlayerControllerB>)(object)interactTrigger.onInteract).AddListener((UnityAction<PlayerControllerB>)UseWhiteboard);
			Instance = this;
			DawnFindResource.OnFreeze<DawnUnlockableItemInfo>((Registry<DawnUnlockableItemInfo>)(object)LethalContent.Unlockables, (Action)AssignLoadedAssets);
			prefabReady = true;
		}

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			if (prefabReady)
			{
				NetworkVariable<ulong> obj = drawerClientId;
				obj.OnValueChanged = (OnValueChangedDelegate<ulong>)(object)Delegate.Combine((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<ulong>(DrawerChanged));
				if (((NetworkBehaviour)this).IsServer)
				{
					ReadBoardSave();
					((NetworkBehaviour)this).NetworkManager.OnClientDisconnectCallback += PlayerLeft;
					RoundEvents.OnGameSaved += WriteBoardSave;
				}
				((Collider)interactCollider).enabled = drawerClientId.Value == ulong.MaxValue;
				drawingSurface.Restart(points);
				if (drawerClientId.Value == ((NetworkBehaviour)this).NetworkManager.LocalClientId)
				{
					StartUsingBoard();
				}
			}
		}

		private void AssignLoadedAssets()
		{
			GameObject val = default(GameObject);
			if (!DawnFindResource.Resolve<DawnUnlockableItemInfo, GameObject>((Registry<DawnUnlockableItemInfo>)(object)LethalContent.Unlockables, NamespacedKey<DawnUnlockableItemInfo>.Vanilla("shower"), (Func<DawnUnlockableItemInfo, GameObject>)((DawnUnlockableItemInfo info) => info.UnlockableItem.prefabObject), "Shower prefab", ref val))
			{
				Log.Error("Whiteboard could not find the vanilla shower prefab");
				((Behaviour)this).enabled = false;
				return;
			}
			InteractTrigger componentInChildren = val.GetComponentInChildren<InteractTrigger>(true);
			PlaceableShipObject componentInChildren2 = val.GetComponentInChildren<PlaceableShipObject>(true);
			AudioSource val2 = default(AudioSource);
			((Component)componentInChildren2).TryGetComponent<AudioSource>(ref val2);
			interactTrigger.hoverIcon = componentInChildren.hoverIcon;
			whiteboardAudio.outputAudioMixerGroup = val2.outputAudioMixerGroup;
			markerAudioSource.outputAudioMixerGroup = val2.outputAudioMixerGroup;
			Log.Debug("Whiteboard assigned vanilla shower assets");
		}

		public override void OnNetworkDespawn()
		{
			if (prefabReady)
			{
				NetworkVariable<ulong> obj = drawerClientId;
				obj.OnValueChanged = (OnValueChangedDelegate<ulong>)(object)Delegate.Remove((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<ulong>(DrawerChanged));
				if (((NetworkBehaviour)this).IsServer)
				{
					((NetworkBehaviour)this).NetworkManager.OnClientDisconnectCallback -= PlayerLeft;
					RoundEvents.OnGameSaved -= WriteBoardSave;
				}
				if (playerSession != null)
				{
					StopUsingBoard();
				}
				((Collider)interactCollider).enabled = true;
			}
			((NetworkBehaviour)this).OnNetworkDespawn();
		}

		public override void OnDestroy()
		{
			if ((Object)(object)interactTrigger != (Object)null)
			{
				((UnityEvent<PlayerControllerB>)(object)interactTrigger.onInteract).RemoveListener((UnityAction<PlayerControllerB>)UseWhiteboard);
			}
			if (playerSession != null)
			{
				StopUsingBoard();
			}
			Instance = null;
			drawingSurface?.Release();
			((NetworkBehaviour)this).OnDestroy();
		}

		public void UseWhiteboard(PlayerControllerB player)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)this).IsSpawned && drawerClientId.Value == ulong.MaxValue && !((Object)(object)player == (Object)null) && !((Object)(object)player != (Object)(object)GameNetworkManager.Instance.localPlayerController) && !player.isPlayerDead)
			{
				RequestBoardRpc();
			}
		}

		private void Update()
		{
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0500: Unknown result type (might be due to invalid IL or missing references)
			//IL_0518: Unknown result type (might be due to invalid IL or missing references)
			//IL_0476: Unknown result type (might be due to invalid IL or missing references)
			//IL_047b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0766: Unknown result type (might be due to invalid IL or missing references)
			//IL_076c: Unknown result type (might be due to invalid IL or missing references)
			if (!prefabReady || !((NetworkBehaviour)this).IsSpawned)
			{
				return;
			}
			drawingSurface.DrawMissing(points);
			if (playerSession == null)
			{
				return;
			}
			PlayerControllerB player = playerSession.Player;
			if (player == null || player.isPlayerDead || !player.isPlayerControlled || (Object)(object)player.inAnimationWithEnemy != (Object)null || exitAction.WasPressedThisFrame())
			{
				StopUsingBoard(releaseBoard: true);
				return;
			}
			Keyboard current = Keyboard.current;
			if (current != null)
			{
				bool flag = ((ButtonControl)current.minusKey).isPressed || ((ButtonControl)current.numpadMinusKey).isPressed;
				bool flag2 = ((ButtonControl)current.equalsKey).isPressed || ((ButtonControl)current.numpadPlusKey).isPressed;
				int num = ((flag != flag2) ? ((!flag) ? 1 : (-1)) : 0);
				if (num != resizeDirection)
				{
					resizeDirection = num;
					resizeHeldTime = 0f;
					nextResizeTime = Time.unscaledTime + 0.35f;
					if (resizeDirection != 0)
					{
						ChangeBrushRadius(resizeDirection);
					}
				}
				else if (resizeDirection != 0)
				{
					resizeHeldTime += Time.unscaledDeltaTime;
					if (Time.unscaledTime >= nextResizeTime)
					{
						float num2 = Mathf.Lerp(5f, 20f, Mathf.Clamp01((resizeHeldTime - 0.35f) / 1.5f));
						ChangeBrushRadius(resizeDirection);
						nextResizeTime = Time.unscaledTime + 1f / num2;
					}
				}
			}
			Mouse current2 = Mouse.current;
			if (current2 == null)
			{
				EndStroke();
				return;
			}
			if (current != null && current.ctrlKey.isPressed && ((ButtonControl)current.zKey).wasPressedThisFrame && !playerSession.BlocksDrawing && !current2.leftButton.isPressed)
			{
				UndoWhiteboard();
			}
			if (current2.leftButton.wasPressedThisFrame)
			{
				EndStroke();
				newAction = true;
			}
			if (points.Count >= pointBudget)
			{
				EndStroke();
				return;
			}
			Vector2 val = ((InputControl<Vector2>)(object)((Pointer)current2).position).ReadValue();
			if (playerSession.BlocksDrawing || playerSession.HasPointer(val))
			{
				EndStroke();
				return;
			}
			bool isPressed = current2.leftButton.isPressed;
			bool wasReleasedThisFrame = current2.leftButton.wasReleasedThisFrame;
			if (!isPressed && !wasReleasedThisFrame)
			{
				EndStroke();
				return;
			}
			RectTransform rectTransform = ((Graphic)player.playerScreen).rectTransform;
			Canvas canvas = ((Graphic)player.playerScreen).canvas;
			Camera val2 = (((int)canvas.renderMode == 0) ? null : canvas.worldCamera);
			Vector2 val3 = default(Vector2);
			if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, val, val2, ref val3))
			{
				EndStroke();
				return;
			}
			Rect pixelAdjustedRect = ((Graphic)player.playerScreen).GetPixelAdjustedRect();
			Rect uvRect = player.playerScreen.uvRect;
			Vector2 val4 = default(Vector2);
			((Vector2)(ref val4))..ctor(((Rect)(ref uvRect)).x + Mathf.InverseLerp(((Rect)(ref pixelAdjustedRect)).xMin, ((Rect)(ref pixelAdjustedRect)).xMax, val3.x) * ((Rect)(ref uvRect)).width, ((Rect)(ref uvRect)).y + Mathf.InverseLerp(((Rect)(ref pixelAdjustedRect)).yMin, ((Rect)(ref pixelAdjustedRect)).yMax, val3.y) * ((Rect)(ref uvRect)).height);
			((Component)player.gameplayCamera).transform.SetPositionAndRotation(cameraPosition.position, cameraPosition.rotation);
			Ray val5 = player.gameplayCamera.ViewportPointToRay(Vector2.op_Implicit(val4));
			int num3 = Physics.RaycastNonAlloc(val5, drawingHits, 10f, 2048, (QueryTriggerInteraction)2);
			RaycastHit val6 = default(RaycastHit);
			bool flag3 = false;
			for (int i = 0; i < num3; i++)
			{
				if ((Object)(object)((RaycastHit)(ref drawingHits[i])).collider == (Object)(object)drawingCollider && ((Component)((RaycastHit)(ref drawingHits[i])).collider).CompareTag("DoNotSet"))
				{
					val6 = drawingHits[i];
					flag3 = true;
					break;
				}
			}
			if (!flag3)
			{
				EndStroke();
				return;
			}
			Vector3 val7 = ((Component)drawingCollider).transform.InverseTransformPoint(((RaycastHit)(ref val6)).point);
			float num4 = val7.x - drawingCollider.center.x;
			float num5 = val7.z - drawingCollider.center.z;
			float num6 = drawingCollider.size.x * 0.5f;
			float num7 = drawingCollider.size.z * 0.5f;
			if (Mathf.Abs(num4) > num6 || Mathf.Abs(num5) > num7)
			{
				EndStroke();
				return;
			}
			SetMarkerAudio(isPressed && !eraserSelected);
			float num8 = Mathf.InverseLerp(0f - num6, num6, num4);
			float num9 = Mathf.InverseLerp(0f - num7, num7, num5);
			WhiteboardPoint point = new WhiteboardPoint((ushort)Mathf.RoundToInt(num8 * 65535f), (ushort)Mathf.RoundToInt(num9 * 65535f), (byte)(eraserSelected ? 2 : 0), (byte)Mathf.RoundToInt(selectedBrushColour.r * 255f), (byte)Mathf.RoundToInt(selectedBrushColour.g * 255f), (byte)Mathf.RoundToInt(selectedBrushColour.b * 255f), (byte)Mathf.RoundToInt(SelectedToolRadius * 10f));
			float num10 = (float)(point.X - lastMousePoint.X) / 65535f * (float)drawingSurface.Width;
			float num11 = (float)(point.Y - lastMousePoint.Y) / 65535f * (float)drawingSurface.Height;
			float num12 = num10 * num10 + num11 * num11;
			bool flag4 = newStroke || !hasMousePoint;
			bool flag5 = isPressed && (flag4 || (Time.unscaledTime >= nextPointTime && num12 >= 9f));
			if (wasReleasedThisFrame && hasMousePoint && num12 >= 1f)
			{
				flag5 = true;
				flag4 = false;
			}
			if (flag5)
			{
				WhiteboardPoint previousPoint = lastMousePoint;
				bool flag6 = hasMousePoint;
				if (flag4)
				{
					point.Flags |= 1;
				}
				if (!drawingSurface.DrawLocal(point, previousPoint, !flag4 && flag6))
				{
					EndStroke();
					return;
				}
				lastMousePoint = point;
				hasMousePoint = true;
				newStroke = false;
				nextPointTime = Time.unscaledTime + 1f / 30f;
				SendPointRpc(point, newAction);
				newAction = false;
			}
			if (wasReleasedThisFrame)
			{
				newAction = false;
				EndStroke();
			}
		}

		private void LateUpdate()
		{
			playerSession?.KeepOpen(cameraPosition);
		}

		private void DrawerChanged(ulong _, ulong currentDrawer)
		{
			((Collider)interactCollider).enabled = currentDrawer == ulong.MaxValue;
			if (currentDrawer == ((NetworkBehaviour)this).NetworkManager.LocalClientId)
			{
				StartUsingBoard();
			}
			else if (playerSession != null)
			{
				StopUsingBoard();
			}
		}

		private void StartUsingBoard()
		{
			//IL_0079: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			if (playerSession != null)
			{
				return;
			}
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if (localPlayerController != null && !localPlayerController.isPlayerDead)
			{
				if (ShipBuildModeManager.Instance.InBuildMode)
				{
					ShipBuildModeManager.Instance.CancelBuildMode(true);
					Log.Debug("Build mode cancelled for whiteboard drawing");
				}
				uint value = rememberedColour.Value;
				selectedBrushColour = Color32.op_Implicit(new Color32((byte)(value >> 16), (byte)(value >> 8), (byte)value, byte.MaxValue));
				selectedBrushRadius = (float)(int)rememberedBrushRadius.Value / 10f;
				selectedEraserRadius = (float)(int)rememberedEraserRadius.Value / 10f;
				eraserSelected = false;
				resizeDirection = 0;
				resizeHeldTime = 0f;
				nextResizeTime = 0f;
				EndStroke();
				newAction = false;
				nextPointTime = 0f;
				playerSession = new WhiteboardPlayerSession(localPlayerController, cameraPosition, HUDSettings);
			}
		}

		internal void StopUsingBoard(bool releaseBoard = false)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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)
			//IL_0051: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			if (playerSession != null)
			{
				EndStroke();
				playerSession.Close();
				playerSession = null;
				newAction = false;
				if (releaseBoard && ((NetworkBehaviour)this).IsSpawned)
				{
					Color32 val = Color32.op_Implicit(selectedBrushColour);
					uint colourRgb = (uint)((val.r << 16) | (val.g << 8) | val.b);
					ReleaseBoardRpc(colourRgb, (byte)Mathf.RoundToInt(selectedBrushRadius * 10f), (byte)Mathf.RoundToInt(selectedEraserRadius * 10f));
				}
			}
		}

		internal void ChooseBrushColour(Color colour)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			selectedBrushColour = new Color(colour.r, colour.g, colour.b, 1f);
			EndStroke();
		}

		internal void ToggleDrawingTool()
		{
			EndStroke();
			eraserSelected = !eraserSelected;
			playerSession?.ShowToolRadius(SelectedToolRadius);
		}

		private void EndStroke()
		{
			SetMarkerAudio(drawing: false);
			newStroke = true;
			hasMousePoint = false;
		}

		private void SetMarkerAudio(bool drawing)
		{
			if (drawing)
			{
				if (!markerAudioSource.isPlaying)
				{
					markerAudioSource.timeSamples = Random.Range(0, markerAudioSource.clip.samples);
					markerAudioSource.Play();
				}
			}
			else if (markerAudioSource.isPlaying)
			{
				markerAudioSource.Stop();
			}
		}

		internal void UndoWhiteboard()
		{
			//IL_0012: 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)
			EndStroke();
			newAction = false;
			UndoRpc();
		}

		internal void ClearWhiteboard()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			EndStroke();
			ClearWhiteboardRpc();
		}

		internal void ExportWhiteboard()
		{
			string text = Path.Combine(Paths.PluginPath, "DrawableWhiteboard", "Exports");
			string text2 = Path.Combine(text, $"Whiteboard_{DateTime.Now:yyyy-MM-dd_HH-mm-ss-fff}.png");
			try
			{
				Directory.CreateDirectory(text);
				File.WriteAllBytes(text2, drawingSurface.ExportPng());
				Log.Info("Whiteboard exported to " + text2);
			}
			catch (Exception arg)
			{
				Log.Error($"Whiteboard export failed at {text2}: {arg}");
			}
		}

		private void ChangeBrushRadius(int direction)
		{
			float num = SelectedToolRadius + HUDSettings.BrushRadiusStep * (float)direction;
			float num2 = Mathf.Round(Mathf.Clamp(num, HUDSettings.MinimumBrushRadius, HUDSettings.MaximumBrushRadius) * 10f) / 10f;
			if (eraserSelected)
			{
				selectedEraserRadius = num2;
			}
			else
			{
				selectedBrushRadius = num2;
			}
			EndStroke();
			playerSession?.ShowToolRadius(SelectedToolRadius);
		}

		private void ReadBoardSave()
		{
			undoStarts.Clear();
			PersistentDataContainer currentContract = DawnLib.GetCurrentContract();
			if (currentContract == null)
			{
				Log.Error("Whiteboard could not find the contract save");
				return;
			}
			byte[] array = default(byte[]);
			if (!((DataContainer)currentContract).TryGet<byte[]>(SaveKey, ref array) || array == null || array.Length == 0)
			{
				points.Clear();
				saveDirty = false;
				return;
			}
			byte[] array2 = default(byte[]);
			if (((DataContainer)currentContract).TryGet<byte[]>(ToolSaveKey, ref array2) && array2 != null)
			{
				if (array2.Length != 5 || array2[3] < 10 || array2[3] > 200 || array2[4] < 10 || array2[4] > 200)
				{
					Log.Error("Whiteboard tool save is invalid");
				}
				else
				{
					rememberedColour.Value = (uint)((array2[0] << 16) | (array2[1] << 8) | array2[2]);
					rememberedBrushRadius.Value = array2[3];
					rememberedEraserRadius.Value = array2[4];
				}
			}
			if (array.Length % 9 != 0)
			{
				Log.Error("Whiteboard save has a bad point list");
				return;
			}
			int num = array.Length / 9;
			if (num > 16384)
			{
				Log.Error("Whiteboard save is over the point limit");
				return;
			}
			for (int i = 0; i < num; i++)
			{
				if (!WhiteboardPoint.ReadBytes(array, i * 9).HasValidSaveValues)
				{
					Log.Error("Whiteboard save has a bad point list");
					return;
				}
			}
			points.Clear();
			for (int j = 0; j < num; j++)
			{
				points.Add(WhiteboardPoint.ReadBytes(array, j * 9));
			}
			saveDirty = false;
			pointLimitLogged = num >= pointBudget;
			Log.Info($"Whiteboard loaded {num} points");
		}

		private void WriteBoardSave()
		{
			if (!saveDirty)
			{
				return;
			}
			PersistentDataContainer currentContract = DawnLib.GetCurrentContract();
			if (currentContract == null)
			{
				Log.Error("Whiteboard could not find the contract save");
				return;
			}
			byte[] array = new byte[points.Count * 9];
			uint value = rememberedColour.Value;
			byte[] array2 = new byte[5]
			{
				(byte)(value >> 16),
				(byte)(value >> 8),
				(byte)value,
				rememberedBrushRadius.Value,
				rememberedEraserRadius.Value
			};
			for (int i = 0; i < points.Count; i++)
			{
				points[i].WriteBytes(array, i * 9);
			}
			using (((DataContainer)currentContract).CreateEditContext())
			{
				((DataContainer)currentContract).Set<byte[]>(SaveKey, array);
				((DataContainer)currentContract).Set<byte[]>(ToolSaveKey, array2);
			}
			saveDirty = false;
		}

		private void PlayerLeft(ulong clientId)
		{
			if (drawerClientId.Value == clientId)
			{
				drawerClientId.Value = ulong.MaxValue;
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void RequestBoardRpc(RpcParams rpcParams = default(RpcParams))
		{
			//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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_005f: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: 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_015f: 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_0174: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1)
			{
				RpcAttributeParams val = default(RpcAttributeParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(2125262591u, rpcParams, val, (SendTo)2, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendRpc(ref val2, 2125262591u, rpcParams, val, (SendTo)2, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1)
			{
				return;
			}
			base.__rpc_exec_stage = (__RpcExecStage)0;
			if (drawerClientId.Value != ulong.MaxValue || (Object)(object)StartOfRound.Instance == (Object)null)
			{
				return;
			}
			ulong senderClientId = rpcParams.Receive.SenderClientId;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			PlayerControllerB val3 = null;
			for (int i = 0; i < allPlayerScripts.Length; i++)
			{
				if ((Object)(object)allPlayerScripts[i] != (Object)null && ((NetworkBehaviour)allPlayerScripts[i]).OwnerClientId == senderClientId && allPlayerScripts[i].isPlayerControlled)
				{
					val3 = allPlayerScripts[i];
					break;
				}
			}
			if (val3 != null && !val3.isPlayerDead)
			{
				float num = val3.grabDistance + 1f;
				Vector3 val4 = ((Component)val3).transform.position - ((Component)interactTrigger).transform.position;
				if (!(((Vector3)(ref val4)).sqrMagnitude > num * num))
				{
					drawerClientId.Value = senderClientId;
				}
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void ReleaseBoardRpc(uint colourRgb, byte brushRadiusTenths, byte eraserRadiusTenths, RpcParams rpcParams = default(RpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Invalid comparison between Unknown and I4
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_005f: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: 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)
			{
				RpcAttributeParams val = default(RpcAttributeParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(144928387u, rpcParams, val, (SendTo)2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, colourRgb);
				((FastBufferWriter)(ref val2)).WriteValueSafe<byte>(ref brushRadiusTenths, default(ForPrimitives));
				((FastBufferWriter)(ref val2)).WriteValueSafe<byte>(ref eraserRadiusTenths, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendRpc(ref val2, 144928387u, rpcParams, val, (SendTo)2, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1)
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				if (drawerClientId.Value == rpcParams.Receive.SenderClientId && brushRadiusTenths >= 10 && brushRadiusTenths <= 200 && eraserRadiusTenths >= 10 && eraserRadiusTenths <= 200)
				{
					rememberedColour.Value = colourRgb & 0xFFFFFF;
					rememberedBrushRadius.Value = brushRadiusTenths;
					rememberedEraserRadius.Value = eraserRadiusTenths;
					saveDirty = true;
					drawerClientId.Value = ulong.MaxValue;
				}
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void ClearWhiteboardRpc(RpcParams rpcParams = default(RpcParams))
		{
			//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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_005f: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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)
			{
				RpcAttributeParams val = default(RpcAttributeParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(3880346881u, rpcParams, val, (SendTo)2, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendRpc(ref val2, 3880346881u, rpcParams, val, (SendTo)2, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1)
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				if (drawerClientId.Value == rpcParams.Receive.SenderClientId)
				{
					points.Clear();
					undoStarts.Clear();
					pointLimitLogged = false;
					saveDirty = true;
				}
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void UndoRpc(RpcParams rpcParams = default(RpcParams))
		{
			//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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_005f: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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)
			{
				RpcAttributeParams val = default(RpcAttributeParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(1347974977u, rpcParams, val, (SendTo)2, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendRpc(ref val2, 1347974977u, rpcParams, val, (SendTo)2, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1)
			{
				return;
			}
			base.__rpc_exec_stage = (__RpcExecStage)0;
			if (drawerClientId.Value == rpcParams.Receive.SenderClientId && undoStarts.Count != 0)
			{
				int index = undoStarts.Count - 1;
				int num = undoStarts[index];
				undoStarts.RemoveAt(index);
				for (int num2 = points.Count - 1; num2 >= num; num2--)
				{
					points.RemoveAt(num2);
				}
				pointLimitLogged = false;
				saveDirty = true;
				Log.Debug("Whiteboard undid one action");
			}
		}

		[Rpc(/*Could not decode attribute arguments.*/)]
		private void SendPointRpc(WhiteboardPoint point, bool beginsAction, RpcParams rpcParams = default(RpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Invalid comparison between Unknown and I4
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_005f: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: 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)
			{
				RpcAttributeParams val = default(RpcAttributeParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(2760138617u, rpcParams, val, (SendTo)2, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<WhiteboardPoint>(ref point, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref beginsAction, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendRpc(ref val2, 2760138617u, rpcParams, val, (SendTo)2, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1)
			{
				return;
			}
			base.__rpc_exec_stage = (__RpcExecStage)0;
			if (drawerClientId.Value != rpcParams.Receive.SenderClientId)
			{
				return;
			}
			if (points.Count >= pointBudget)
			{
				if (!pointLimitLogged)
				{
					pointLimitLogged = true;
					Log.Info($"Whiteboard hit the {pointBudget} point limit");
				}
				return;
			}
			point.Flags &= 3;
			byte radiusTenths = point.RadiusTenths;
			if ((radiusTenths >= 10 && radiusTenths <= 200) || 1 == 0)
			{
				if (beginsAction)
				{
					undoStarts.Add(points.Count);
				}
				points.Add(point);
				uint value = (uint)((point.Red << 16) | (point.Green << 8) | point.Blue);
				if (point.Erases)
				{
					rememberedEraserRadius.Value = point.RadiusTenths;
				}
				else
				{
					rememberedColour.Value = value;
					rememberedBrushRadius.Value = point.RadiusTenths;
				}
				saveDirty = true;
			}
		}

		protected override void __initializeVariables()
		{
			if (drawerClientId == null)
			{
				throw new Exception("DrawableWhiteboard.drawerClientId cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)drawerClientId).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)drawerClientId, "drawerClientId");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)drawerClientId);
			if (rememberedColour == null)
			{
				throw new Exception("DrawableWhiteboard.rememberedColour cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)rememberedColour).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)rememberedColour, "rememberedColour");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)rememberedColour);
			if (rememberedBrushRadius == null)
			{
				throw new Exception("DrawableWhiteboard.rememberedBrushRadius cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)rememberedBrushRadius).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)rememberedBrushRadius, "rememberedBrushRadius");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)rememberedBrushRadius);
			if (rememberedEraserRadius == null)
			{
				throw new Exception("DrawableWhiteboard.rememberedEraserRadius cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)rememberedEraserRadius).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)rememberedEraserRadius, "rememberedEraserRadius");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)rememberedEraserRadius);
			if (points == null)
			{
				throw new Exception("DrawableWhiteboard.points cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)points).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)points, "points");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)points);
			((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
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(2125262591u, new RpcReceiveHandler(__rpc_handler_2125262591), "RequestBoardRpc");
			((NetworkBehaviour)this).__registerRpc(144928387u, new RpcReceiveHandler(__rpc_handler_144928387), "ReleaseBoardRpc");
			((NetworkBehaviour)this).__registerRpc(3880346881u, new RpcReceiveHandler(__rpc_handler_3880346881), "ClearWhiteboardRpc");
			((NetworkBehaviour)this).__registerRpc(1347974977u, new RpcReceiveHandler(__rpc_handler_1347974977), "UndoRpc");
			((NetworkBehaviour)this).__registerRpc(2760138617u, new RpcReceiveHandler(__rpc_handler_2760138617), "SendPointRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_2125262591(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)
			{
				RpcParams ext = rpcParams.Ext;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((DrawableWhiteboard)(object)target).RequestBoardRpc(ext);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_144928387(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				uint colourRgb = default(uint);
				ByteUnpacker.ReadValueBitPacked(reader, ref colourRgb);
				byte brushRadiusTenths = default(byte);
				((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref brushRadiusTenths, default(ForPrimitives));
				byte eraserRadiusTenths = default(byte);
				((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref eraserRadiusTenths, default(ForPrimitives));
				RpcParams ext = rpcParams.Ext;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((DrawableWhiteboard)(object)target).ReleaseBoardRpc(colourRgb, brushRadiusTenths, eraserRadiusTenths, ext);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3880346881(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)
			{
				RpcParams ext = rpcParams.Ext;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((DrawableWhiteboard)(object)target).ClearWhiteboardRpc(ext);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1347974977(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)
			{
				RpcParams ext = rpcParams.Ext;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((DrawableWhiteboard)(object)target).UndoRpc(ext);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2760138617(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_004a: 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)
			//IL_0059: 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_005f: 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_007c: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				WhiteboardPoint point = default(WhiteboardPoint);
				((FastBufferReader)(ref reader)).ReadValueSafe<WhiteboardPoint>(ref point, default(ForNetworkSerializable));
				bool beginsAction = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref beginsAction, default(ForPrimitives));
				RpcParams ext = rpcParams.Ext;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((DrawableWhiteboard)(object)target).SendPointRpc(point, beginsAction, ext);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "DrawableWhiteboard";
		}
	}
	public class WhiteboardColourWheel : MonoBehaviour, IPointerDownHandler, IEventSystemHandler, IDragHandler
	{
		[SerializeField]
		private RectTransform wheelRect = null;

		[SerializeField]
		private RectTransform selectionMarker = null;

		private float hue;

		private float saturation;

		private float brightness;

		public float Brightness => brightness;

		public event Action<Color>? ColourChanged;

		public void OnPointerDown(PointerEventData eventData)
		{
			MoveMarker(eventData);
		}

		public void OnDrag(PointerEventData eventData)
		{
			MoveMarker(eventData);
		}

		public void ChooseColour(Color colour)
		{
			//IL_0001: 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_0038: 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_004b: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			Color.RGBToHSV(colour, ref hue, ref saturation, ref brightness);
			float num = hue * MathF.PI * 2f;
			Rect rect = wheelRect.rect;
			float width = ((Rect)(ref rect)).width;
			rect = wheelRect.rect;
			float num2 = Mathf.Min(width, ((Rect)(ref rect)).height) * 0.5f;
			selectionMarker.anchoredPosition = num2 * saturation * new Vector2(Mathf.Cos(num), Mathf.Sin(num));
			this.ColourChanged?.Invoke(Color.HSVToRGB(hue, saturation, brightness));
		}

		public void ChangeBrightness(float value)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			brightness = Mathf.Clamp01(value);
			this.ColourChanged?.Invoke(Color.HSVToRGB(hue, saturation, brightness));
		}

		private void MoveMarker(PointerEventData eventData)
		{
			//IL_0008: 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_0031: 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_0045: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = default(Vector2);
			if (RectTransformUtility.ScreenPointToLocalPointInRectangle(wheelRect, eventData.position, eventData.pressEventCamera, ref val))
			{
				Rect rect = wheelRect.rect;
				float width = ((Rect)(ref rect)).width;
				rect = wheelRect.rect;
				float num = Mathf.Min(width, ((Rect)(ref rect)).height) * 0.5f;
				Vector2 val2 = Vector2.ClampMagnitude(val, num);
				selectionMarker.anchoredPosition = val2;
				saturation = Mathf.Clamp01(((Vector2)(ref val2)).magnitude / num);
				hue = Mathf.Repeat(Mathf.Atan2(val2.y, val2.x) / (MathF.PI * 2f), 1f);
				this.ColourChanged?.Invoke(Color.HSVToRGB(hue, saturation, brightness));
			}
		}
	}
	internal class WhiteboardDrawingSurface
	{
		private const int CircleSides = 12;

		private readonly DecalProjector drawingDecal;

		private readonly Material brushMaterial;

		private RenderTexture drawingTexture = null;

		private Material decalMaterialCopy = null;

		private Vector2[] circlePoints = null;

		private int brushColourId;

		private int drawnPointCount;

		private bool brushPassFailedLogged;

		internal int Width { get; }

		internal int Height { get; }

		internal WhiteboardDrawingSurface(DecalProjector drawingDecal, Material brushMaterial, int width, int height)
		{
			this.drawingDecal = drawingDecal;
			this.brushMaterial = brushMaterial;
			Width = width;
			Height = height;
		}

		internal bool Configure()
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: 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_00bf: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Expected O, but got Unknown
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			int num = Shader.PropertyToID("_BaseColorMap");
			brushColourId = Shader.PropertyToID("_BrushColor");
			Material material = drawingDecal.material;
			circlePoints = (Vector2[])(object)new Vector2[13];
			for (int i = 0; i <= 12; i++)
			{
				float num2 = MathF.PI * 2f * (float)i / 12f;
				circlePoints[i] = new Vector2(Mathf.Cos(num2), Mathf.Sin(num2));
			}
			drawingTexture = new RenderTexture(Width, Height, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2)
			{
				name = "Drawable whiteboard drawing",
				filterMode = (FilterMode)1,
				wrapMode = (TextureWrapMode)1,
				useMipMap = false,
				autoGenerateMips = false
			};
			if (!drawingTexture.Create())
			{
				Log.Error("Whiteboard drawing texture could not be made");
				return false;
			}
			decalMaterialCopy = new Material(material)
			{
				name = ((Object)material).name + " Whiteboard"
			};
			decalMaterialCopy.SetTexture(num, (Texture)(object)drawingTexture);
			decalMaterialCopy.SetColor("_BaseColor", Color.white);
			decalMaterialCopy.SetFloat("_DecalBlend", 1f);
			decalMaterialCopy.SetFloat("_AffectAlbedo", 1f);
			HDMaterial.ValidateMaterial(decalMaterialCopy);
			drawingDecal.material = decalMaterialCopy;
			drawingDecal.uvScale = Vector2.one;
			drawingDecal.uvBias = Vector2.zero;
			drawingDecal.fadeFactor = 1f;
			Clear();
			return true;
		}

		internal void Restart(NetworkList<WhiteboardPoint> points)
		{
			Clear();
			drawnPointCount = 0;
			DrawMissing(points);
		}

		internal void DrawMissing(NetworkList<WhiteboardPoint> points)
		{
			if (drawnPointCount > points.Count)
			{
				Clear();
				drawnPointCount = 0;
			}
			if (drawnPointCount == points.Count)
			{
				return;
			}
			RenderTexture active = RenderTexture.active;
			RenderTexture.active = drawingTexture;
			GL.PushMatrix();
			GL.LoadOrtho();
			while (drawnPointCount < points.Count)
			{
				int num = drawnPointCount;
				WhiteboardPoint point = points[num];
				if (!DrawPoint(point, (num > 0) ? points[num - 1] : default(WhiteboardPoint), num > 0 && !point.StartsStroke))
				{
					break;
				}
				drawnPointCount++;
			}
			GL.PopMatrix();
			((Texture)drawingTexture).IncrementUpdateCount();
			RenderTexture.active = active;
		}

		internal bool DrawLocal(WhiteboardPoint point, WhiteboardPoint previousPoint, bool drawLine)
		{
			RenderTexture active = RenderTexture.active;
			RenderTexture.active = drawingTexture;
			GL.PushMatrix();
			GL.LoadOrtho();
			bool flag = DrawPoint(point, previousPoint, drawLine);
			GL.PopMatrix();
			if (flag)
			{
				((Texture)drawingTexture).IncrementUpdateCount();
			}
			RenderTexture.active = active;
			return flag;
		}

		internal byte[] ExportPng()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			RenderTexture active = RenderTexture.active;
			Texture2D val = new Texture2D(Width, Height, (TextureFormat)4, false, false);
			try
			{
				RenderTexture.active = drawingTexture;
				val.ReadPixels(new Rect(0f, 0f, (float)Width, (float)Height), 0, 0, false);
				val.Apply(false);
				Color32[] pixels = val.GetPixels32();
				for (int i = 0; i < pixels.Length; i++)
				{
					int a = pixels[i].a;
					int num = 255 * (255 - a);
					pixels[i].r = (byte)((pixels[i].r * a + num) / 255);
					pixels[i].g = (byte)((pixels[i].g * a + num) / 255);
					pixels[i].b = (byte)((pixels[i].b * a + num) / 255);
					pixels[i].a = byte.MaxValue;
				}
				val.SetPixels32(pixels);
				val.Apply(false);
				return ImageConversion.EncodeToPNG(val);
			}
			finally
			{
				RenderTexture.active = active;
				Object.Destroy((Object)(object)val);
			}
		}

		internal void Release()
		{
			if ((Object)(object)drawingTexture != (Object)null)
			{
				drawingTexture.Release();
				Object.Destroy((Object)(object)drawingTexture);
			}
			if ((Object)(object)decalMaterialCopy != (Object)null)
			{
				Object.Destroy((Object)(object)decalMaterialCopy);
			}
		}

		private void Clear()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			RenderTexture active = RenderTexture.active;
			RenderTexture.active = drawingTexture;
			GL.Clear(true, true, Color.clear);
			((Texture)drawingTexture).IncrementUpdateCount();
			RenderTexture.active = active;
		}

		private bool DrawPoint(WhiteboardPoint point, WhiteboardPoint previousPoint, bool drawLine)
		{
			//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_0082: 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_00af: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			brushMaterial.SetColor(brushColourId, Color32.op_Implicit(new Color32(point.Red, point.Green, point.Blue, byte.MaxValue)));
			if (!brushMaterial.SetPass(point.Erases ? 1 : 0))
			{
				if (!brushPassFailedLogged)
				{
					brushPassFailedLogged = true;
					Log.Error("Whiteboard brush material pass could not be used");
				}
				return false;
			}
			GL.Begin(4);
			Vector2 val = PointUv(point);
			float radius = (float)(int)point.RadiusTenths / 10f;
			if (drawLine)
			{
				DrawLine(PointUv(previousPoint), val, radius);
			}
			else
			{
				DrawDot(val, radius);
			}
			GL.End();
			return true;
		}

		private void DrawLine(Vector2 start, Vector2 end, float radius)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_004e: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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)
			//IL_0091: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: 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_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(start.x * (float)Width, start.y * (float)Height);
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(end.x * (float)Width, end.y * (float)Height);
			Vector2 val3 = val2 - val;
			if (((Vector2)(ref val3)).sqrMagnitude <= 0.0001f)
			{
				DrawDot(end, radius);
				return;
			}
			Vector2 val4 = new Vector2(0f - val3.y, val3.x);
			Vector2 val5 = ((Vector2)(ref val4)).normalized * radius;
			Vector2 val6 = default(Vector2);
			((Vector2)(ref val6))..ctor(val5.x / (float)Width, val5.y / (float)Height);
			Vector2 val7 = start + val6;
			Vector2 val8 = start - val6;
			Vector2 val9 = end - val6;
			Vector2 val10 = end + val6;
			GL.Vertex3(val7.x, val7.y, 0f);
			GL.Vertex3(val8.x, val8.y, 0f);
			GL.Vertex3(val9.x, val9.y, 0f);
			GL.Vertex3(val7.x, val7.y, 0f);
			GL.Vertex3(val9.x, val9.y, 0f);
			GL.Vertex3(val10.x, val10.y, 0f);
			DrawDot(end, radius);
		}

		private void DrawDot(Vector2 center, float radius)
		{
			//IL_001d: 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_0049: 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)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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)
			float num = radius / (float)Width;
			float num2 = radius / (float)Height;
			for (int i = 0; i < 12; i++)
			{
				Vector2 val = center + new Vector2(circlePoints[i].x * num, circlePoints[i].y * num2);
				Vector2 val2 = center + new Vector2(circlePoints[i + 1].x * num, circlePoints[i + 1].y * num2);
				GL.Vertex3(center.x, center.y, 0f);
				GL.Vertex3(val.x, val.y, 0f);
				GL.Vertex3(val2.x, val2.y, 0f);
			}
		}

		private static Vector2 PointUv(WhiteboardPoint point)
		{
			//IL_001b: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			return new Vector2((float)(int)point.X / 65535f, (float)(int)point.Y / 65535f);
		}
	}
	public class WhiteboardHUD : MonoBehaviour
	{
		[Header("Toolbar")]
		[SerializeField]
		private Button colourButton = null;

		[SerializeField]
		private Button toolButton = null;

		[SerializeField]
		private Image toolButtonIcon = null;

		[SerializeField]
		private Button clearButton = null;

		[SerializeField]
		private Button undoButton = null;

		[SerializeField]
		private Button exportButton = null;

		[Header("Colour Popup")]
		[SerializeField]
		private GameObject colourPopup = null;

		[SerializeField]
		private WhiteboardColourWheel colourWheel = null;

		[SerializeField]
		private Slider brightnessSlider = null;

		[SerializeField]
		private Image colourPreview = null;

		[SerializeField]
		private Button closeColourButton = null;

		[Header("Clear Popup")]
		[SerializeField]
		private GameObject clearPopup = null;

		[SerializeField]
		private Button confirmClearButton = null;

		[SerializeField]
		private Button cancelClearButton = null;

		[Header("Cursor and Tips")]
		[SerializeField]
		private RectTransform cursorRect = null;

		[SerializeField]
		private Image cursorImage = null;

		private readonly List<RaycastResult> pointerHits = new List<RaycastResult>(8);

		private RectTransform hudRect = null;

		private Canvas hudCanvas = null;

		private DrawableWhiteboard whiteboard = null;

		private WhiteboardHUDSettings settings = null;

		private PointerEventData pointerData = null;

		private TextMeshProUGUI tooltipText = null;

		public bool BlocksDrawing => colourPopup.activeSelf || clearPopup.activeSelf;

		private void Awake()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Expected O, but got Unknown
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Expected O, but got Unknown
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Expected O, but got Unknown
			hudRect = (RectTransform)((Component)this).transform;
			hudCanvas = ((Component)this).GetComponentInParent<Canvas>();
			((UnityEvent)colourButton.onClick).AddListener(new UnityAction(OpenColourPopup));
			((UnityEvent)toolButton.onClick).AddListener(new UnityAction(ToggleTool));
			((UnityEvent)clearButton.onClick).AddListener(new UnityAction(OpenClearPopup));
			((UnityEvent)undoButton.onClick).AddListener(new UnityAction(Undo));
			((UnityEvent)exportButton.onClick).AddListener(new UnityAction(Export));
			((UnityEvent)closeColourButton.onClick).AddListener(new UnityAction(CloseColourPopup));
			((UnityEvent)confirmClearButton.onClick).AddListener(new UnityAction(ConfirmClear));
			((UnityEvent)cancelClearButton.onClick).AddListener(new UnityAction(CloseClearPopup));
			((UnityEvent<float>)(object)brightnessSlider.onValueChanged).AddListener((UnityAction<float>)ChangeBrightness);
			colourWheel.ColourChanged += ChangeColour;
		}

		private void LateUpdate()
		{
			//IL_0015: 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)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			if (Mouse.current != null)
			{
				Camera val = (((int)hudCanvas.renderMode == 0) ? null : hudCanvas.worldCamera);
				Vector2 anchoredPosition = default(Vector2);
				if (RectTransformUtility.ScreenPointToLocalPointInRectangle(hudRect, ((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).ReadValue(), val, ref anchoredPosition))
				{
					cursorRect.anchoredPosition = anchoredPosition;
				}
			}
		}

		public void Open(WhiteboardHUDSettings hudSettings)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			whiteboard = DrawableWhiteboard.Instance;
			settings = hudSettings;
			pointerData = new PointerEventData(EventSystem.current);
			TMP_FontAsset font = ((TMP_Text)HUDManager.Instance.controlTipLines[0]).font;
			TextMeshProUGUI[] componentsInChildren = ((Component)this).GetComponentsInChildren<TextMeshProUGUI>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				((TMP_Text)componentsInChildren[i]).font = font;
				((TMP_Text)componentsInChildren[i]).fontSharedMaterial = ((TMP_Asset)font).material;
				if (((Object)componentsInChildren[i]).name == "TooltipText")
				{
					tooltipText = componentsInChildren[i];
				}
			}
			RefreshToolVisuals();
			colourWheel.ChooseColour(whiteboard.SelectedBrushColour);
			brightnessSlider.SetValueWithoutNotify(colourWheel.Brightness);
		}

		public bool HasPointer(Vector2 screenPosition)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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)
			pointerData.position = screenPosition;
			pointerHits.Clear();
			EventSystem.current.RaycastAll(pointerData, pointerHits);
			for (int i = 0; i < pointerHits.Count; i++)
			{
				RaycastResult val = pointerHits[i];
				if (((RaycastResult)(ref val)).gameObject.transform.IsChildOf(((Component)this).transform))
				{
					return true;
				}
			}
			return false;
		}

		private void OpenColourPopup()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			clearPopup.SetActive(false);
			colourPopup.SetActive(true);
			colourWheel.ChooseColour(whiteboard.SelectedBrushColour);
			brightnessSlider.SetValueWithoutNotify(colourWheel.Brightness);
			RefreshCursorVisual();
		}

		private void CloseColourPopup()
		{
			colourPopup.SetActive(false);
			RefreshCursorVisual();
		}

		private void ToggleTool()
		{
			whiteboard.ToggleDrawingTool();
			RefreshToolVisuals();
			EventSystem.current.SetSelectedGameObject((GameObject)null);
		}

		private void OpenClearPopup()
		{
			colourPopup.SetActive(false);
			clearPopup.SetActive(true);
			RefreshCursorVisual();
		}

		private void ConfirmClear()
		{
			clearPopup.SetActive(false);
			RefreshCursorVisual();
			whiteboard.ClearWhiteboard();
		}

		private void CloseClearPopup()
		{
			clearPopup.SetActive(false);
			RefreshCursorVisual();
		}

		private void Undo()
		{
			whiteboard.UndoWhiteboard();
			EventSystem.current.SetSelectedGameObject((GameObject)null);
		}

		private void Export()
		{
			whiteboard.ExportWhiteboard();
			EventSystem.current.SetSelectedGameObject((GameObject)null);
		}

		private void ChangeBrightness(float value)
		{
			colourWheel.ChangeBrightness(value);
		}

		private void ChangeColour(Color colour)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)colourPreview).color = colour;
			whiteboard.ChooseBrushColour(colour);
		}

		internal void ShowToolRadius(float radius)
		{
			string arg = (whiteboard.EraserSelected ? "Eraser" : "Brush");
			((TMP_Text)tooltipText).text = $"{arg} size: {radius:F1} px    [-] Smaller    [+] Larger    [Ctrl+Z] Undo    [Esc] Exit";
		}

		private void RefreshToolVisuals()
		{
			toolButtonIcon.sprite = (whiteboard.EraserSelected ? settings.BrushIcon : settings.EraserIcon);
			ShowToolRadius(whiteboard.SelectedToolRadius);
			RefreshCursorVisual();
		}

		private void RefreshCursorVisual()
		{
			cursorImage.sprite = (BlocksDrawing ? settings.PopupCursor : (whiteboard.EraserSelected ? settings.EraserCursor : settings.BrushCursor));
		}
	}
	[CreateAssetMenu(menuName = "Drawable Whiteboard/HUD Settings", fileName = "WhiteboardHUDSettings")]
	public class WhiteboardHUDSettings : ScriptableObject
	{
		[Header("HUD")]
		[SerializeField]
		private WhiteboardHUD hudPrefab = null;

		[SerializeField]
		private Sprite brushIcon = null;

		[SerializeField]
		private Sprite eraserIcon = null;

		[Header("Cursors")]
		[SerializeField]
		private Sprite brushCursor = null;

		[SerializeField]
		private Sprite eraserCursor = null;

		[SerializeField]
		private Sprite popupCursor = null;

		[Header("Brush Size")]
		[SerializeField]
		private float minimumBrushRadius = 1f;

		[SerializeField]
		private float maximumBrushRadius = 20f;

		[SerializeField]
		private float brushRadiusStep = 0.1f;

		public WhiteboardHUD HUDPrefab => hudPrefab;

		public Sprite BrushIcon => brushIcon;

		public Sprite EraserIcon => eraserIcon;

		public Sprite BrushCursor => brushCursor;

		public Sprite EraserCursor => eraserCursor;

		public Sprite PopupCursor => popupCursor;

		public float MinimumBrushRadius => minimumBrushRadius;

		public float MaximumBrushRadius => maximumBrushRadius;

		public float BrushRadiusStep => brushRadiusStep;
	}
	internal class WhiteboardPlayerSession
	{
		private readonly HUDElement[] hiddenHUDElements;

		private readonly TextMeshProUGUI[] controlTipLines;

		private readonly float[] oldHUDAlphas;

		private readonly float[] oldHUDTargetAlphas;

		private readonly bool[] oldHUDInteractable;

		private readonly bool[] oldHUDBlocksRaycasts;

		private readonly Vector3 oldCameraLocalPosition;

		private readonly Quaternion oldCameraLocalRotation;

		private readonly CursorLockMode oldCursorLockMode;

		private readonly bool oldCursorVisible;

		private readonly bool oldDisableMoveInput;

		private readonly bool oldDisableLookInput;

		private readonly bool oldDisableInteract;

		private readonly bool oldVisorActive;

		private readonly bool oldArmsEnabled;

		private readonly bool oldPlayerModelEnabled;

		private readonly WhiteboardHUD hud;

		internal PlayerControllerB Player { get; }

		internal bool BlocksDrawing => hud.BlocksDrawing;

		internal WhiteboardPlayerSession(PlayerControllerB player, Transform cameraPosition, WhiteboardHUDSettings settings)
		{
			//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_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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			Player = player;
			oldDisableMoveInput = player.disableMoveInput;
			oldDisableLookInput = player.disableLookInput;
			oldDisableInteract = player.disableInteract;
			oldCameraLocalPosition = ((Component)player.gameplayCamera).transform.localPosition;
			oldCameraLocalRotation = ((Component)player.gameplayCamera).transform.localRotation;
			oldCursorLockMode = Cursor.lockState;
			oldCursorVisible = Cursor.visible;
			oldVisorActive = ((Component)player.localVisor).gameObject.activeSelf;
			oldArmsEnabled = ((Renderer)player.thisPlayerModelArms).enabled;
			oldPlayerModelEnabled = ((Renderer)player.thisPlayerModel).enabled;
			HUDManager instance = HUDManager.Instance;
			controlTipLines = instance.controlTipLines;
			hiddenHUDElements = (HUDElement[])(object)new HUDElement[6] { instance.Inventory, instance.Chat, instance.PlayerInfo, instance.InstabilityCounter, instance.Clock, instance.Compass };
			oldHUDAlphas = new float[hiddenHUDElements.Length];
			oldHUDTargetAlphas = new float[hiddenHUDElements.Length];
			oldHUDInteractable = new bool[hiddenHUDElements.Length];
			oldHUDBlocksRaycasts = new bool[hiddenHUDElements.Length];
			for (int i = 0; i < hiddenHUDElements.Length; i++)
			{
				CanvasGroup canvasGroup = hiddenHUDElements[i].canvasGroup;
				oldHUDAlphas[i] = canvasGroup.alpha;
				oldHUDTargetAlphas[i] = hiddenHUDElements[i].targetAlpha;
				oldHUDInteractable[i] = canvasGroup.interactable;
				oldHUDBlocksRaycasts[i] = canvasGroup.blocksRaycasts;
			}
			((Component)player.localVisor).gameObject.SetActive(false);
			((Renderer)player.thisPlayerModelArms).enabled = false;
			((Renderer)player.thisPlayerModel).enabled = false;
			KeepOpen(cameraPosition);
			hud = Object.Instantiate<WhiteboardHUD>(settings.HUDPrefab, instance.HUDContainer.transform.parent, false);
			((Object)hud).name = "Drawable whiteboard HUD";
			hud.Open(settings);
		}

		internal bool HasPointer(Vector2 screenPosition)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return hud.HasPointer(screenPosition);
		}

		internal void ShowToolRadius(float radius)
		{
			hud.ShowToolRadius(radius);
		}

		internal void KeepOpen(Transform cameraPosition)
		{
			//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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			Player.disableMoveInput = true;
			Player.disableLookInput = true;
			Player.disableInteract = true;
			Player.moveInputVector = Vector2.zero;
			((Component)Player.gameplayCamera).transform.SetPositionAndRotation(cameraPosition.position, cameraPosition.rotation);
			((Behaviour)Player.cursorIcon).enabled = false;
			((TMP_Text)Player.cursorTip).text = string.Empty;
			((Component)Player.localVisor).gameObject.SetActive(false);
			((Renderer)Player.thisPlayerModelArms).enabled = false;
			((Renderer)Player.thisPlayerModel).enabled = false;
			for (int i = 0; i < controlTipLines.Length; i++)
			{
				((TMP_Text)controlTipLines[i]).alpha = 0f;
			}
			Cursor.lockState = (CursorLockMode)0;
			Cursor.visible = false;
			for (int j = 0; j < hiddenHUDElements.Length; j++)
			{
				hiddenHUDElements[j].canvasGroup.alpha = 0f;
				hiddenHUDElements[j].targetAlpha = 0f;
				hiddenHUDElements[j].canvasGroup.interactable = false;
				hiddenHUDElements[j].canvasGroup.blocksRaycasts = false;
			}
		}

		internal void Close()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			Player.disableMoveInput = oldDisableMoveInput;
			Player.disableLookInput = oldDisableLookInput;
			Player.disableInteract = oldDisableInteract;
			((Component)Player.gameplayCamera).transform.SetLocalPositionAndRotation(oldCameraLocalPosition, oldCameraLocalRotation);
			((Component)Player.localVisor).gameObject.SetActive(oldVisorActive);
			((Renderer)Player.thisPlayerModelArms).enabled = oldArmsEnabled;
			((Renderer)Player.thisPlayerModel).enabled = oldPlayerModelEnabled;
			Player.hoveringOverTrigger = null;
			Player.previousHoveringOverTrigger = null;
			((Behaviour)Player.cursorIcon).enabled = false;
			((TMP_Text)Player.cursorTip).text = string.Empty;
			for (int i = 0; i < controlTipLines.Length; i++)
			{
				((TMP_Text)controlTipLines[i]).alpha = 1f;
			}
			Cursor.lockState = oldCursorLockMode;
			Cursor.visible = oldCursorVisible;
			if ((Object)(object)HUDManager.Instance != (Object)null)
			{
				for (int j = 0; j < hiddenHUDElements.Length; j++)
				{
					CanvasGroup canvasGroup = hiddenHUDElements[j].canvasGroup;
					canvasGroup.alpha = oldHUDAlphas[j];
					hiddenHUDElements[j].targetAlpha = oldHUDTargetAlphas[j];
					canvasGroup.interactable = oldHUDInteractable[j];
					canvasGroup.blocksRaycasts = oldHUDBlocksRaycasts[j];
				}
			}
			Object.Destroy((Object)(object)((Component)hud).gameObject);
		}
	}
	internal struct WhiteboardPoint : INetworkSerializable, IEquatable<WhiteboardPoint>
	{
		internal const int SaveSize = 9;

		internal const byte StrokeStartFlag = 1;

		internal const byte EraserFlag = 2;

		internal const byte PointFlags = 3;

		internal const byte MinimumRadiusTenths = 10;

		internal const byte MaximumRadiusTenths = 200;

		public ushort X;

		public ushort Y;

		public byte Flags;

		public byte Red;

		public byte Green;

		public byte Blue;

		public byte RadiusTenths;

		public readonly bool StartsStroke => (Flags & 1) != 0;

		public readonly bool Erases => (Flags & 2) != 0;

		public readonly bool HasValidSaveValues
		{
			get
			{
				int result;
				if ((Flags & -4) == 0)
				{
					byte radiusTenths = RadiusTenths;
					result = ((radiusTenths >= 10 && radiusTenths <= 200) ? 1 : 0);
				}
				else
				{
					result = 0;
				}
				return (byte)result != 0;
			}
		}

		public WhiteboardPoint(ushort x, ushort y, byte flags, byte red, byte green, byte blue, byte radiusTenths)
		{
			X = x;
			Y = y;
			Flags = flags;
			Red = red;
			Green = green;
			Blue = blue;
			RadiusTenths = radiusTenths;
		}

		public static WhiteboardPoint ReadBytes(byte[] bytes, int byteIndex)
		{
			ushort x = (ushort)(bytes[byteIndex] | (bytes[byteIndex + 1] << 8));
			ushort y = (ushort)(bytes[byteIndex + 2] | (bytes[byteIndex + 3] << 8));
			return new WhiteboardPoint(x, y, bytes[byteIndex + 4], bytes[byteIndex + 5], bytes[byteIndex + 6], bytes[byteIndex + 7], bytes[byteIndex + 8]);
		}

		public readonly void WriteBytes(byte[] bytes, int byteIndex)
		{
			bytes[byteIndex] = (byte)X;
			bytes[byteIndex + 1] = (byte)(X >> 8);
			bytes[byteIndex + 2] = (byte)Y;
			bytes[byteIndex + 3] = (byte)(Y >> 8);
			bytes[byteIndex + 4] = Flags;
			bytes[byteIndex + 5] = Red;
			bytes[byteIndex + 6] = Green;
			bytes[byteIndex + 7] = Blue;
			bytes[byteIndex + 8] = RadiusTenths;
		}

		public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			((BufferSerializer<ushort>*)(&serializer))->SerializeValue<ushort>(ref X, default(ForPrimitives));
			((BufferSerializer<ushort>*)(&serializer))->SerializeValue<ushort>(ref Y, default(ForPrimitives));
			serializer.SerializeValue(ref Flags);
			serializer.SerializeValue(ref Red);
			serializer.SerializeValue(ref Green);
			serializer.SerializeValue(ref Blue);
			serializer.SerializeValue(ref RadiusTenths);
		}

		public readonly bool Equals(WhiteboardPoint other)
		{
			return X == other.X && Y == other.Y && Flags == other.Flags && Red == other.Red && Green == other.Green && Blue == other.Blue && RadiusTenths == other.RadiusTenths;
		}

		public override readonly bool Equals(object? obj)
		{
			return obj is WhiteboardPoint other && Equals(other);
		}

		public override readonly int GetHashCode()
		{
			return HashCode.Combine(X, Y, Flags, Red, Green, Blue, RadiusTenths);
		}
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
			NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<byte>();
			NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<byte>();
			NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedINetworkSerializable<WhiteboardPoint>();
			NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<WhiteboardPoint>();
		}
	}
}
namespace DrawableWhiteboard.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}