Decompiled source of Observe v1.1.1

plugins/Marioalexsan.Observe.dll

Decompiled 2 weeks ago
using System;
using System.Buffers.Binary;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO.Compression;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AtlyssCommandLib.API;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CodeTalker;
using CodeTalker.Networking;
using CodeTalker.Packets;
using HarmonyLib;
using Homebrewery.Code.Component;
using Microsoft.CodeAnalysis;
using Mirror;
using Nessie.ATLYSS.EasySettings;
using UnityEngine;
using UnityEngine.Events;

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

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Marioalexsan.Observe
{
	public static class CameraChecks
	{
		private static bool _homebreweryIsFaulty;

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool IsUsingFreecam()
		{
			if (Chainloader.PluginInfos.ContainsKey("Homebrewery") && !_homebreweryIsFaulty)
			{
				try
				{
					if (HomebreweryFreecamActive())
					{
						return true;
					}
				}
				catch (Exception arg)
				{
					_homebreweryIsFaulty = true;
					ObservePlugin.Logger.LogWarning((object)"Failed to get Homebrewery's freecam state! Please report this to Observe's mod author!");
					ObservePlugin.Logger.LogWarning((object)$"Exception: {arg}");
				}
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private static bool HomebreweryFreecamActive()
		{
			return Object.op_Implicit((Object)(object)CameraDX._current) && CameraDX._current._freecam;
		}
	}
	internal static class Commands
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static CommandCallback <0>__ToggleOwl;

			public static CommandCallback <1>__ToggleVanilla;

			public static CommandCallback <2>__ToggleLookSpeed;
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static CommandCallback <>9__0_0;

			public static CommandCallback <>9__0_1;

			public static CommandCallback <>9__0_2;

			public static CommandCallback <>9__0_3;

			public static CommandCallback <>9__0_4;

			public static CommandCallback <>9__0_5;

			public static CommandCallback <>9__0_6;

			public static CommandCallback <>9__0_7;

			public static CommandCallback <>9__0_8;

			public static CommandCallback <>9__0_9;

			internal bool <RegisterCommands>b__0_0(Caller caller, string[] args)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				return LookCommand("default", caller, args);
			}

			internal bool <RegisterCommands>b__0_1(Caller caller, string[] args)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				return LookCommand("left", caller, args);
			}

			internal bool <RegisterCommands>b__0_2(Caller caller, string[] args)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				return LookCommand("right", caller, args);
			}

			internal bool <RegisterCommands>b__0_3(Caller caller, string[] args)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				return LookCommand("up", caller, args);
			}

			internal bool <RegisterCommands>b__0_4(Caller caller, string[] args)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				return LookCommand("down", caller, args);
			}

			internal bool <RegisterCommands>b__0_5(Caller caller, string[] args)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				return LookCommand("forward", caller, args);
			}

			internal bool <RegisterCommands>b__0_6(Caller caller, string[] args)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				return LookCommand("backward", caller, args);
			}

			internal bool <RegisterCommands>b__0_7(Caller caller, string[] args)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				return LookCommand("camera", caller, args);
			}

			internal bool <RegisterCommands>b__0_8(Caller caller, string[] args)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				return LookCommand("pose", caller, args);
			}

			internal bool <RegisterCommands>b__0_9(Caller caller, string[] args)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				return LookCommand("environment", caller, args);
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		internal static void RegisterCommands()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//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_008d: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			//IL_00f4: 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_00ff: Expected O, but got Unknown
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Expected O, but got Unknown
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Expected O, but got Unknown
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Expected O, but got Unknown
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Expected O, but got Unknown
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Expected O, but got Unknown
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Expected O, but got Unknown
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Expected O, but got Unknown
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Expected O, but got Unknown
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Expected O, but got Unknown
			CommandProvider val = new CommandProvider("observe", "Observe commands");
			CommandProvider.Root.RegisterProvider(val);
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				CommandCallback val2 = (Caller caller, string[] args) => LookCommand("default", caller, args);
				<>c.<>9__0_0 = val2;
				obj = (object)val2;
			}
			ModCommand val3 = val.RegisterCommand("default", "Look where your camera is looking", (CommandCallback)obj, (CommandOptions?)null);
			val.RegisterAlias("reset", val3);
			object obj2 = <>c.<>9__0_1;
			if (obj2 == null)
			{
				CommandCallback val4 = (Caller caller, string[] args) => LookCommand("left", caller, args);
				<>c.<>9__0_1 = val4;
				obj2 = (object)val4;
			}
			val.RegisterCommand("left", "Look to your left", (CommandCallback)obj2, (CommandOptions?)null);
			object obj3 = <>c.<>9__0_2;
			if (obj3 == null)
			{
				CommandCallback val5 = (Caller caller, string[] args) => LookCommand("right", caller, args);
				<>c.<>9__0_2 = val5;
				obj3 = (object)val5;
			}
			val.RegisterCommand("right", "Look to your right", (CommandCallback)obj3, (CommandOptions?)null);
			object obj4 = <>c.<>9__0_3;
			if (obj4 == null)
			{
				CommandCallback val6 = (Caller caller, string[] args) => LookCommand("up", caller, args);
				<>c.<>9__0_3 = val6;
				obj4 = (object)val6;
			}
			val.RegisterCommand("up", "Look up", (CommandCallback)obj4, (CommandOptions?)null);
			object obj5 = <>c.<>9__0_4;
			if (obj5 == null)
			{
				CommandCallback val7 = (Caller caller, string[] args) => LookCommand("down", caller, args);
				<>c.<>9__0_4 = val7;
				obj5 = (object)val7;
			}
			val.RegisterCommand("down", "Look down", (CommandCallback)obj5, (CommandOptions?)null);
			object obj6 = <>c.<>9__0_5;
			if (obj6 == null)
			{
				CommandCallback val8 = (Caller caller, string[] args) => LookCommand("forward", caller, args);
				<>c.<>9__0_5 = val8;
				obj6 = (object)val8;
			}
			val.RegisterCommand("forward", "Look forward", (CommandCallback)obj6, (CommandOptions?)null);
			object obj7 = <>c.<>9__0_6;
			if (obj7 == null)
			{
				CommandCallback val9 = (Caller caller, string[] args) => LookCommand("backward", caller, args);
				<>c.<>9__0_6 = val9;
				obj7 = (object)val9;
			}
			val.RegisterCommand("backward", "Look backward (might require Owl mode)", (CommandCallback)obj7, (CommandOptions?)null);
			object obj8 = <>c.<>9__0_7;
			if (obj8 == null)
			{
				CommandCallback val10 = (Caller caller, string[] args) => LookCommand("camera", caller, args);
				<>c.<>9__0_7 = val10;
				obj8 = (object)val10;
			}
			val.RegisterCommand("camera", "Look at the camera", (CommandCallback)obj8, (CommandOptions?)null);
			object obj9 = <>c.<>9__0_8;
			if (obj9 == null)
			{
				CommandCallback val11 = (Caller caller, string[] args) => LookCommand("pose", caller, args);
				<>c.<>9__0_8 = val11;
				obj9 = (object)val11;
			}
			val.RegisterCommand("pose", "Look relative to your current camera direction", (CommandCallback)obj9, (CommandOptions?)null);
			object obj10 = <>c.<>9__0_9;
			if (obj10 == null)
			{
				CommandCallback val12 = (Caller caller, string[] args) => LookCommand("environment", caller, args);
				<>c.<>9__0_9 = val12;
				obj10 = (object)val12;
			}
			val.RegisterCommand("environment", "Look in the far distance based on your current camera direction", (CommandCallback)obj10, (CommandOptions?)null);
			object obj11 = <>O.<0>__ToggleOwl;
			if (obj11 == null)
			{
				CommandCallback val13 = ToggleOwl;
				<>O.<0>__ToggleOwl = val13;
				obj11 = (object)val13;
			}
			val.RegisterCommand("owl", "Toggles Owl mode for yourself", (CommandCallback)obj11, (CommandOptions?)null);
			object obj12 = <>O.<1>__ToggleVanilla;
			if (obj12 == null)
			{
				CommandCallback val14 = ToggleVanilla;
				<>O.<1>__ToggleVanilla = val14;
				obj12 = (object)val14;
			}
			val.RegisterCommand("vanilla", "Toggles Vanilla Mode for yourself", (CommandCallback)obj12, (CommandOptions?)null);
			string text = "Available options are " + string.Join(", ", Enum.GetNames(typeof(LookSpeed))) + ".";
			object obj13 = <>O.<2>__ToggleLookSpeed;
			if (obj13 == null)
			{
				CommandCallback val15 = ToggleLookSpeed;
				<>O.<2>__ToggleLookSpeed = val15;
				obj13 = (object)val15;
			}
			val.RegisterCommand("speed", "Toggles look speed for yourself", text, (CommandCallback)obj13, (CommandOptions?)null);
		}

		private static bool ToggleOwl(Caller caller, string[] args)
		{
			//IL_0028: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			if (args.Length != 0)
			{
				return false;
			}
			bool flag = !ObservePlugin.OwlModeSetting.Value;
			ObservePlugin.OwlModeSetting.Value = flag;
			Utils.NotifyCaller(caller, "Owl Mode is now " + (flag ? "on" : "off") + ".", default(Color));
			return true;
		}

		private static bool ToggleVanilla(Caller caller, string[] args)
		{
			//IL_0028: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			if (args.Length != 0)
			{
				return false;
			}
			bool flag = !ObservePlugin.VanillaModeSetting.Value;
			ObservePlugin.VanillaModeSetting.Value = flag;
			Utils.NotifyCaller(caller, "Vanilla Mode is now " + (flag ? "on" : "off") + ".", default(Color));
			return true;
		}

		private static bool ToggleLookSpeed(Caller caller, string[] args)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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)
			if (args.Length != 1)
			{
				return false;
			}
			if (!Enum.TryParse<LookSpeed>(args[0], ignoreCase: true, out var result))
			{
				return false;
			}
			ObservePlugin.LookSpeedSetting.Value = result;
			Utils.NotifyCaller(caller, "Look speed is now " + result.ToString() + ".", default(Color));
			return true;
		}

		private static bool LookCommand(string lookDirection, Caller caller, string[] args)
		{
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: 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_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: 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)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			if (args.Length > 1)
			{
				return false;
			}
			switch (lookDirection)
			{
			case "left":
				ObservePlugin.SavedOverride = Quaternion.Euler(0f, -90f, 0f);
				ObservePlugin.LocalOverrideDirection = LookDirection.Pose;
				break;
			case "right":
				ObservePlugin.SavedOverride = Quaternion.Euler(0f, 90f, 0f);
				ObservePlugin.LocalOverrideDirection = LookDirection.Pose;
				break;
			case "up":
				ObservePlugin.SavedOverride = Quaternion.Euler(-80f, 0f, 0f);
				ObservePlugin.LocalOverrideDirection = LookDirection.Pose;
				break;
			case "down":
				ObservePlugin.SavedOverride = Quaternion.Euler(80f, 0f, 0f);
				ObservePlugin.LocalOverrideDirection = LookDirection.Pose;
				break;
			case "forward":
				ObservePlugin.SavedOverride = Quaternion.identity;
				ObservePlugin.LocalOverrideDirection = LookDirection.Pose;
				break;
			case "backward":
				ObservePlugin.SavedOverride = Quaternion.Euler(0f, 180f, 0f);
				ObservePlugin.LocalOverrideDirection = LookDirection.Pose;
				break;
			case "pose":
				ObservePlugin.SavedOverride = Quaternion.Inverse(((Component)Player._mainPlayer).transform.rotation) * ((Component)CameraFunction._current).transform.rotation;
				ObservePlugin.LocalOverrideDirection = LookDirection.Pose;
				break;
			case "environment":
				ObservePlugin.SavedOverride = ((Component)CameraFunction._current).transform.rotation;
				ObservePlugin.LocalOverrideDirection = LookDirection.Environment;
				break;
			case "camera":
				ObservePlugin.LocalOverrideDirection = LookDirection.Camera;
				break;
			default:
				ObservePlugin.LocalOverrideDirection = LookDirection.Default;
				break;
			}
			if (args.Length == 1)
			{
				if (!int.TryParse(args[0], out var result))
				{
					Utils.NotifyCaller(caller, "\"" + args[0] + "\" is not right! It should be a valid duration in seconds!", Color.red);
					return false;
				}
				ObservePlugin.LocalOverrideDirectionTime = TimeSpan.FromSeconds(result);
			}
			else
			{
				ObservePlugin.LocalOverrideDirectionTime = TimeSpan.FromDays(300.0);
			}
			return true;
		}
	}
	public enum LookDirection : byte
	{
		Default,
		Camera,
		Pose,
		Environment
	}
	internal class LookPacket : BinaryPacketBase
	{
		private const string Signature = "Marioalexsan.Observe.LookPacket";

		public Quaternion CameraRotation;

		public uint TargetNetId;

		public bool VanillaMode;

		public bool OwlMode;

		public LookSpeed LookSpeed;

		public LookDirection OverrideDirection;

		public bool IsValid = true;

		public static readonly LookPacket Instance = new LookPacket();

		public override string PacketSignature => "Marioalexsan.Observe.LookPacket";

		public override byte[] Serialize()
		{
			byte[] array = new byte[32];
			Span<byte> destination = array.AsSpan();
			BinaryPrimitives.TryWriteInt32LittleEndian(destination, BitConverter.SingleToInt32Bits(CameraRotation.x));
			ref Span<byte> reference = ref destination;
			BinaryPrimitives.TryWriteInt32LittleEndian(reference.Slice(4, reference.Length - 4), BitConverter.SingleToInt32Bits(CameraRotation.y));
			reference = ref destination;
			BinaryPrimitives.TryWriteInt32LittleEndian(reference.Slice(8, reference.Length - 8), BitConverter.SingleToInt32Bits(CameraRotation.z));
			reference = ref destination;
			BinaryPrimitives.TryWriteInt32LittleEndian(reference.Slice(12, reference.Length - 12), BitConverter.SingleToInt32Bits(CameraRotation.w));
			reference = ref destination;
			BinaryPrimitives.TryWriteUInt32LittleEndian(reference.Slice(16, reference.Length - 16), TargetNetId);
			reference = ref destination;
			BitConverter.TryWriteBytes(reference.Slice(20, reference.Length - 20), VanillaMode);
			reference = ref destination;
			BitConverter.TryWriteBytes(reference.Slice(21, reference.Length - 21), OwlMode);
			destination[22] = (byte)LookSpeed;
			destination[23] = (byte)OverrideDirection;
			return array;
		}

		public override void Deserialize(byte[] data)
		{
			if (data.Length < 32)
			{
				IsValid = false;
				return;
			}
			Span<byte> span = data.AsSpan();
			CameraRotation.x = BitConverter.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(span));
			ref Quaternion cameraRotation = ref CameraRotation;
			ref Span<byte> reference = ref span;
			cameraRotation.y = BitConverter.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(reference.Slice(4, reference.Length - 4)));
			ref Quaternion cameraRotation2 = ref CameraRotation;
			reference = ref span;
			cameraRotation2.z = BitConverter.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(reference.Slice(8, reference.Length - 8)));
			ref Quaternion cameraRotation3 = ref CameraRotation;
			reference = ref span;
			cameraRotation3.w = BitConverter.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(reference.Slice(12, reference.Length - 12)));
			reference = ref span;
			TargetNetId = BinaryPrimitives.ReadUInt32LittleEndian(reference.Slice(16, reference.Length - 16));
			reference = ref span;
			VanillaMode = BitConverter.ToBoolean(reference.Slice(20, reference.Length - 20));
			reference = ref span;
			OwlMode = BitConverter.ToBoolean(reference.Slice(21, reference.Length - 21));
			LookSpeed = (LookSpeed)span[22];
			OverrideDirection = (LookDirection)span[23];
		}
	}
	public enum LookSpeed : byte
	{
		Sloth = 1,
		VerySlow = 2,
		Slow = 3,
		Normal = 0,
		Fast = 4,
		VeryFast = 5,
		Caffeinated = 6
	}
	public static class LookSpeedExtensions
	{
		public static float MapToMultiplier(this LookSpeed speed)
		{
			if (1 == 0)
			{
			}
			float result = speed switch
			{
				LookSpeed.Sloth => 0.5f, 
				LookSpeed.VerySlow => 1.5f, 
				LookSpeed.Slow => 2.5f, 
				LookSpeed.Normal => 3.5f, 
				LookSpeed.Fast => 5.5f, 
				LookSpeed.VeryFast => 7.5f, 
				LookSpeed.Caffeinated => 18f, 
				_ => 3.5f, 
			};
			if (1 == 0)
			{
			}
			return result;
		}
	}
	[BepInPlugin("Marioalexsan.Observe", "Observe", "1.1.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class ObservePlugin : BaseUnityPlugin
	{
		private struct PlayerLookInfo
		{
			public Quaternion DesiredLookDirection;

			public PlayerRaceModel RaceModel;

			public Transform Head;

			public Quaternion LastHeadRotation;

			public bool OwlMode;

			public LookSpeed LookSpeed;

			public LookDirection OverrideDirection;

			public bool VanillaMode;
		}

		private struct SentPlayerInfo
		{
			public Quaternion DesiredLookDirection;

			public bool VanillaMode;

			public bool OwlMode;

			public LookSpeed LookSpeed;

			public DateTime Timestamp;

			public LookDirection OverrideDirection;
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__28_0;

			public static Predicate<Player> <>9__31_0;

			internal void <RegisterEasySettings>b__28_0()
			{
				Settings.ModTab.AddHeader("Observe");
				Settings.ModTab.AddToggle("Enabled", Enabled);
				Settings.ModTab.AddToggle("Ignore Camera (self)", VanillaModeSetting);
				Settings.ModTab.AddToggle("Enable Networking", EnableNetworking);
				Settings.ModTab.AddToggle("Owl Mode (full rotations)", OwlModeSetting);
				Settings.ModTab.AddToggle("Allow Owl Mode for others", AllowOwlModeForOthers);
				Settings.ModTab.AddDropdown<LookSpeed>("Look speed", LookSpeedSetting);
				Settings.ModTab.AddToggle("Hold head direction after strafing", HoldHeadDirectionAfterStrafing);
				Settings.ModTab.AddAdvancedSlider("Strafe hold head direction duration", HoldHeadDirectionAfterStrafingDuration, true);
			}

			internal bool <HandlePlayerCleanup>b__31_0(Player player)
			{
				return !Object.op_Implicit((Object)(object)player);
			}
		}

		private readonly Harmony _harmony = new Harmony("Marioalexsan.Observe");

		private readonly Dictionary<Player, PlayerLookInfo> _cachedPlayerData = new Dictionary<Player, PlayerLookInfo>();

		private readonly Dictionary<ulong, SentPlayerInfo> MultiplayerData = new Dictionary<ulong, SentPlayerInfo>();

		internal static ConfigEntry<bool> Enabled = null;

		internal static ConfigEntry<bool> VanillaModeSetting = null;

		internal static ConfigEntry<bool> EnableNetworking = null;

		internal static ConfigEntry<bool> OwlModeSetting = null;

		internal static ConfigEntry<bool> AllowOwlModeForOthers = null;

		internal static ConfigEntry<LookSpeed> LookSpeedSetting = null;

		internal static ConfigEntry<bool> HoldHeadDirectionAfterStrafing = null;

		internal static ConfigEntry<float> HoldHeadDirectionAfterStrafingDuration = null;

		private bool _lastSendEnableState = false;

		private bool _shouldSendCurrentState = false;

		private static TimeSpan RefreshDirectionAccumulator = TimeSpan.Zero;

		private static TimeSpan PacketSendCooldown = TimeSpan.Zero;

		internal static LookDirection LocalOverrideDirection = LookDirection.Default;

		internal static TimeSpan LocalOverrideDirectionTime = TimeSpan.Zero;

		internal static Quaternion SavedOverride = Quaternion.identity;

		internal static ManualLogSource Logger = null;

		internal static HashSet<Player> Players { get; } = new HashSet<Player>();


		public ObservePlugin()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable or disable mod functionality completely.");
			VanillaModeSetting = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "VanillaMode", false, "While active, makes your character's head act the same as in vanilla.");
			EnableNetworking = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableNetworking", true, "Enable sending/receiving camera directions to/from people with the mod installed.");
			OwlModeSetting = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "OwlMode", false, "Enables full range of rotation for your player's head. This might look pretty weird in some cases!");
			AllowOwlModeForOthers = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "AllowOwlModeForOthers", true, "Allow other players that use OwlMode to display their unconstrained head rotations.");
			LookSpeedSetting = ((BaseUnityPlugin)this).Config.Bind<LookSpeed>("Display", "LookSpeed", LookSpeed.Normal, "The speed at which your character reacts to changes in direction.");
			HoldHeadDirectionAfterStrafing = ((BaseUnityPlugin)this).Config.Bind<bool>("Controls", "HoldHeadDirectionAfterStrafing", true, "Enable to keep looking at the given direction after strafing as if you used \"/observe environment\".");
			HoldHeadDirectionAfterStrafingDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Controls", "HoldHeadDirectionAfterStrafingDuration", 4f, new ConfigDescription("How long to continue looking at the environment when HoldHeadDirectionAfterStrafing is enabled, in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 120f), Array.Empty<object>()));
		}

		private void Awake()
		{
			_harmony.PatchAll();
			if (Chainloader.PluginInfos.ContainsKey("EasySettings"))
			{
				RegisterEasySettings();
			}
			if (Chainloader.PluginInfos.ContainsKey("CodeTalker"))
			{
				RegisterCodeYapperListener();
			}
			if (Chainloader.PluginInfos.ContainsKey("Soggy_Pancake.CommandLib"))
			{
				RegisterCommandLibCommands();
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private void RegisterCodeYapperListener()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			try
			{
				CodeTalkerNetwork.RegisterBinaryListener<LookPacket>(new BinaryPacketListener(HandleNetworkSyncFromOthers));
			}
			catch (Exception arg)
			{
				Logger.LogWarning((object)"Failed to register network listener for CodeYapper! Please report this to the mod author!");
				Logger.LogWarning((object)$"Exception: {arg}");
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private void RegisterCommandLibCommands()
		{
			try
			{
				Commands.RegisterCommands();
			}
			catch (Exception arg)
			{
				Logger.LogWarning((object)"Failed to register commands for CommandLib! Please report this to the mod author!");
				Logger.LogWarning((object)$"Exception: {arg}");
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private void RegisterEasySettings()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//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_0026: Expected O, but got Unknown
			try
			{
				UnityEvent onInitialized = Settings.OnInitialized;
				object obj = <>c.<>9__28_0;
				if (obj == null)
				{
					UnityAction val = delegate
					{
						Settings.ModTab.AddHeader("Observe");
						Settings.ModTab.AddToggle("Enabled", Enabled);
						Settings.ModTab.AddToggle("Ignore Camera (self)", VanillaModeSetting);
						Settings.ModTab.AddToggle("Enable Networking", EnableNetworking);
						Settings.ModTab.AddToggle("Owl Mode (full rotations)", OwlModeSetting);
						Settings.ModTab.AddToggle("Allow Owl Mode for others", AllowOwlModeForOthers);
						Settings.ModTab.AddDropdown<LookSpeed>("Look speed", LookSpeedSetting);
						Settings.ModTab.AddToggle("Hold head direction after strafing", HoldHeadDirectionAfterStrafing);
						Settings.ModTab.AddAdvancedSlider("Strafe hold head direction duration", HoldHeadDirectionAfterStrafingDuration, true);
					};
					<>c.<>9__28_0 = val;
					obj = (object)val;
				}
				onInitialized.AddListener((UnityAction)obj);
				Settings.OnApplySettings.AddListener((UnityAction)delegate
				{
					((BaseUnityPlugin)this).Config.Save();
				});
			}
			catch (Exception arg)
			{
				Logger.LogWarning((object)"Failed to register settings for EasySettings! Please report this to the mod author!");
				Logger.LogWarning((object)$"Exception: {arg}");
			}
		}

		private void HandleNetworkSyncFromOthers(PacketHeader header, BinaryPacketBase packet)
		{
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			if (!EnableNetworking.Value || !(packet is LookPacket lookPacket) || !lookPacket.IsValid)
			{
				return;
			}
			bool flag = false;
			foreach (Player player in Players)
			{
				if (!Object.op_Implicit((Object)(object)player) || ((NetworkBehaviour)player).netId != lookPacket.TargetNetId || !(player._steamID == header.SenderID.ToString()))
				{
					continue;
				}
				flag = true;
				break;
			}
			if (flag)
			{
				MultiplayerData[lookPacket.TargetNetId] = new SentPlayerInfo
				{
					Timestamp = DateTime.UtcNow,
					DesiredLookDirection = lookPacket.CameraRotation,
					VanillaMode = lookPacket.VanillaMode,
					OwlMode = lookPacket.OwlMode,
					OverrideDirection = lookPacket.OverrideDirection,
					LookSpeed = lookPacket.LookSpeed
				};
			}
		}

		private void LateUpdate()
		{
			LocalOverrideDirectionTime -= TimeSpan.FromSeconds(Time.deltaTime);
			if (LocalOverrideDirectionTime < TimeSpan.Zero)
			{
				LocalOverrideDirectionTime = TimeSpan.Zero;
				LocalOverrideDirection = LookDirection.Default;
			}
			HandlePlayerCleanup();
			HandleLocalPlayerAndNetworkSyncToOthers();
			HandleOtherPlayers();
		}

		private void HandlePlayerCleanup()
		{
			foreach (Player player in Players)
			{
				if (!Object.op_Implicit((Object)(object)player))
				{
					MultiplayerData.Remove(((NetworkBehaviour)player).netId);
					_cachedPlayerData.Remove(player);
				}
			}
			Players.RemoveWhere((Player player) => !Object.op_Implicit((Object)(object)player));
		}

		private void HandleLocalPlayerAndNetworkSyncToOthers()
		{
			//IL_008b: 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_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)Player._mainPlayer) && _cachedPlayerData.TryGetValue(Player._mainPlayer, out var value))
			{
				if (_lastSendEnableState || EnableNetworking.Value)
				{
					bool flag = value.VanillaMode != VanillaModeSetting.Value;
					if (VanillaModeSetting.Value)
					{
						RefreshDirectionAccumulator -= TimeSpan.FromSeconds(Time.deltaTime);
					}
					else
					{
						float num = Quaternion.Angle(value.DesiredLookDirection, ((Component)CameraFunction._current).transform.rotation);
						RefreshDirectionAccumulator -= TimeSpan.FromSeconds((double)Time.deltaTime + (double)num * 3.0 / 30.0);
					}
					if (flag || RefreshDirectionAccumulator <= TimeSpan.Zero)
					{
						RefreshDirectionAccumulator = TimeSpan.FromSeconds(3.0);
						_shouldSendCurrentState = true;
					}
				}
				else
				{
					RefreshDirectionAccumulator = TimeSpan.Zero;
				}
				if (Player._mainPlayer._pMove._strafeToggle && HoldHeadDirectionAfterStrafing.Value)
				{
					LocalOverrideDirectionTime = TimeSpan.FromSeconds(HoldHeadDirectionAfterStrafingDuration.Value);
					LocalOverrideDirection = LookDirection.Environment;
					SavedOverride = ((Component)CameraFunction._current).transform.rotation;
				}
				value.DesiredLookDirection = GetMainPlayerTargetRotation(value.Head);
				value.VanillaMode = VanillaModeSetting.Value;
				value.OwlMode = OwlModeSetting.Value;
				value.LookSpeed = LookSpeedSetting.Value;
				value.OverrideDirection = LocalOverrideDirection;
				_cachedPlayerData[Player._mainPlayer] = value;
			}
			_lastSendEnableState = EnableNetworking.Value;
			PacketSendCooldown -= TimeSpan.FromSeconds(Time.deltaTime);
			if (PacketSendCooldown < TimeSpan.Zero)
			{
				PacketSendCooldown = TimeSpan.Zero;
			}
			if (!_shouldSendCurrentState || !(PacketSendCooldown <= TimeSpan.Zero))
			{
				return;
			}
			_shouldSendCurrentState = false;
			PacketSendCooldown = TimeSpan.FromMilliseconds(250.0);
			if (!Object.op_Implicit((Object)(object)Player._mainPlayer) || !_cachedPlayerData.TryGetValue(Player._mainPlayer, out var value2))
			{
				return;
			}
			LookPacket.Instance.CameraRotation = (VanillaModeSetting.Value ? Quaternion.identity : GetMainPlayerTargetRotation(value2.Head));
			LookPacket.Instance.TargetNetId = ((NetworkBehaviour)Player._mainPlayer).netId;
			LookPacket.Instance.VanillaMode = VanillaModeSetting.Value;
			LookPacket.Instance.OwlMode = OwlModeSetting.Value;
			LookPacket.Instance.LookSpeed = LookSpeedSetting.Value;
			LookPacket.Instance.OverrideDirection = LocalOverrideDirection;
			foreach (Player player in Players)
			{
				if ((Object)(object)player != (Object)(object)Player._mainPlayer)
				{
					CodeTalkerNetwork.SendNetworkPacket(player, (BinaryPacketBase)(object)LookPacket.Instance, (CompressionType)0, CompressionLevel.Fastest);
				}
			}
		}

		private void HandleOtherPlayers()
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			foreach (Player player in Players)
			{
				if (_cachedPlayerData.TryGetValue(player, out var value) && MultiplayerData.TryGetValue(((NetworkBehaviour)player).netId, out var value2))
				{
					if (value2.Timestamp + TimeSpan.FromSeconds(6.0) < DateTime.UtcNow)
					{
						value2.VanillaMode = true;
						MultiplayerData[((NetworkBehaviour)player).netId] = value2;
					}
					value.DesiredLookDirection = value2.DesiredLookDirection;
					value.VanillaMode = value2.VanillaMode;
					value.OwlMode = AllowOwlModeForOthers.Value && value2.OwlMode;
					value.LookSpeed = value2.LookSpeed;
					value.OverrideDirection = value2.OverrideDirection;
					_cachedPlayerData[player] = value;
				}
				ProcessPlayerHeadRotation(player);
			}
		}

		private void ProcessPlayerHeadRotation(Player player)
		{
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: 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_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Invalid comparison between Unknown and I4
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			if (!Enabled.Value || !Object.op_Implicit((Object)(object)player) || (!((Object)(object)player == (Object)(object)Player._mainPlayer) && !MultiplayerData.ContainsKey(((NetworkBehaviour)player).netId)))
			{
				return;
			}
			if (!_cachedPlayerData.TryGetValue(player, out var value))
			{
				PlayerRaceModel componentInChildren = ((Component)player).GetComponentInChildren<PlayerRaceModel>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					Transform headBone = GetHeadBone(componentInChildren);
					if ((Object)(object)headBone != (Object)null)
					{
						value = (_cachedPlayerData[player] = new PlayerLookInfo
						{
							DesiredLookDirection = ((Component)player).transform.rotation,
							RaceModel = componentInChildren,
							Head = headBone,
							LastHeadRotation = Quaternion.identity,
							VanillaMode = false,
							OwlMode = false,
							OverrideDirection = LookDirection.Default,
							LookSpeed = LookSpeed.Normal
						});
					}
				}
			}
			if ((Object)(object)value.Head == (Object)null)
			{
				return;
			}
			if (value.VanillaMode)
			{
				value.LastHeadRotation = Quaternion.identity;
				value.DesiredLookDirection = ((Component)player).transform.rotation;
				_cachedPlayerData[player] = value;
				return;
			}
			Transform transform = ((Component)player).transform;
			bool isLeftHanded = player._pVisual._playerAppearanceStruct._isLeftHanded;
			Quaternion desiredLookDirection = value.DesiredLookDirection;
			float num = Quaternion.Angle(transform.rotation, desiredLookDirection);
			bool flag = num >= 105f;
			bool flag2 = num >= 160f;
			Quaternion val = ((value.OverrideDirection != 0 || !flag2 || value.OwlMode) ? desiredLookDirection : GetDefaultModeBackwardLookDirection(value, player));
			Quaternion val2 = (value.OwlMode ? val : Quaternion.RotateTowards(value.Head.parent.rotation, val, 70f));
			Quaternion val3 = Quaternion.Slerp(value.LastHeadRotation, val2, Time.deltaTime * value.LookSpeed.MapToMultiplier());
			if (!value.OwlMode)
			{
				val3 = Quaternion.RotateTowards(value.Head.parent.rotation, val3, 70f);
			}
			value.Head.rotation = val3;
			value.LastHeadRotation = value.Head.rotation;
			if (isLeftHanded)
			{
				Quaternion rotation = value.Head.rotation;
				Quaternion rotation2 = value.Head.rotation;
				((Quaternion)(ref rotation2)).Set(rotation.x, 0f - rotation.y, 0f - rotation.z, rotation.w);
			}
			if (!value.OwlMode && value.OverrideDirection == LookDirection.Default && flag && !flag2 && (int)value.RaceModel._currentEyeCondition == 0)
			{
				float num2 = Quaternion.Angle(Quaternion.LookRotation(transform.right * -1f, transform.up), val);
				value.RaceModel.Set_EyeCondition((EyeCondition)((num2 <= 90f != isLeftHanded) ? 4 : 3), 0.15f);
			}
			_cachedPlayerData[player] = value;
		}

		private static Quaternion GetMainPlayerTargetRotation(Transform headTransform)
		{
			//IL_0088: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			Player mainPlayer = Player._mainPlayer;
			bool flag = CameraChecks.IsUsingFreecam() || (Object.op_Implicit((Object)(object)DialogManager._current) && DialogManager._current._isDialogEnabled);
			switch (LocalOverrideDirection)
			{
			case LookDirection.Camera:
				if (flag)
				{
					return headTransform.rotation;
				}
				return Quaternion.LookRotation(-((Component)CameraFunction._current).transform.forward, ((Component)mainPlayer).transform.up);
			case LookDirection.Pose:
				return headTransform.parent.rotation * SavedOverride;
			case LookDirection.Environment:
				return SavedOverride;
			default:
				if (flag)
				{
					return headTransform.rotation;
				}
				return ((Component)CameraFunction._current).transform.rotation;
			}
		}

		private static Quaternion GetDefaultModeBackwardLookDirection(PlayerLookInfo data, Player player)
		{
			//IL_0036: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: 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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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)
			//IL_002d: 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)
			if (false)
			{
				return Quaternion.LookRotation(-(data.DesiredLookDirection * Vector3.forward), ((Component)player).transform.up);
			}
			return ((Component)player).transform.rotation * Quaternion.Euler(0f, 90f, 0f);
		}

		internal static Transform? GetHeadBone(PlayerRaceModel raceModel)
		{
			Transform armatureTransform = raceModel._armatureTransform;
			object result;
			if (armatureTransform == null)
			{
				result = null;
			}
			else
			{
				Transform obj = armatureTransform.Find("Armature_character");
				if (obj == null)
				{
					result = null;
				}
				else
				{
					Transform obj2 = obj.Find("masterBone");
					if (obj2 == null)
					{
						result = null;
					}
					else
					{
						Transform obj3 = obj2.Find("hipCtrl");
						if (obj3 == null)
						{
							result = null;
						}
						else
						{
							Transform obj4 = obj3.Find("hip");
							if (obj4 == null)
							{
								result = null;
							}
							else
							{
								Transform obj5 = obj4.Find("lowBody");
								if (obj5 == null)
								{
									result = null;
								}
								else
								{
									Transform obj6 = obj5.Find("midBody");
									if (obj6 == null)
									{
										result = null;
									}
									else
									{
										Transform obj7 = obj6.Find("torso");
										if (obj7 == null)
										{
											result = null;
										}
										else
										{
											Transform obj8 = obj7.Find("neck");
											result = ((obj8 != null) ? obj8.Find("head") : null);
										}
									}
								}
							}
						}
					}
				}
			}
			return (Transform?)result;
		}
	}
	internal static class ModInfo
	{
		public const string GUID = "Marioalexsan.Observe";

		public const string NAME = "Observe";

		public const string VERSION = "1.1.1";
	}
}
namespace Marioalexsan.Observe.HarmonyPatches
{
	[HarmonyPatch(typeof(Player), "Update")]
	internal static class Trackplayers
	{
		private static void Postfix(Player __instance)
		{
			ObservePlugin.Players.Add(__instance);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}