Decompiled source of Crawlspace2MP v1.2.5

BepInEx/patchers/Crawlspace2MP/Crawlspace2MP.Preload.dll

Decompiled 2 weeks 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 Microsoft.CodeAnalysis;
using Mono.Cecil;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Crawlspace2MP.Preload")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a08bf8fc47e5706e97f9ed13fe1997c62060d02f")]
[assembly: AssemblyProduct("Crawlspace2MP.Preload")]
[assembly: AssemblyTitle("Crawlspace2MP.Preload")]
[assembly: AssemblyVersion("1.0.0.0")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Crawlspace2MP.Preloader
{
	public static class SteamAPIPatcher
	{
		public static IEnumerable<string> TargetDLLs { get; } = Array.Empty<string>();


		public static void Initialize()
		{
			try
			{
				string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
				string text = null;
				try
				{
					text = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
				}
				catch (Exception ex)
				{
					Log("Could not get game dir from process: " + ex.Message);
				}
				if (text == null)
				{
					text = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(directoryName)));
				}
				Log("SteamAPIPatcher initializing...");
				Log("Patcher directory: " + directoryName);
				Log("Game directory: " + text);
				string[] array = new string[2] { "steam_api64.dll", "steam_appid.txt" };
				foreach (string text2 in array)
				{
					string text3 = Path.Combine(directoryName, text2);
					string text4 = Path.Combine(text, text2);
					if (!File.Exists(text3))
					{
						Log("  " + text2 + ": Not found in patcher folder, skipping");
						continue;
					}
					if (File.Exists(text4))
					{
						FileInfo fileInfo = new FileInfo(text3);
						FileInfo fileInfo2 = new FileInfo(text4);
						if (fileInfo.Length == fileInfo2.Length)
						{
							Log("  " + text2 + ": Already exists and matches, skipping");
							continue;
						}
						Log("  " + text2 + ": Exists but different, updating...");
					}
					try
					{
						File.Copy(text3, text4, overwrite: true);
						Log("  " + text2 + ": Copied successfully!");
					}
					catch (Exception ex2)
					{
						Log("  " + text2 + ": Failed to copy - " + ex2.Message);
					}
				}
				Log("SteamAPIPatcher complete!");
			}
			catch (Exception arg)
			{
				Log($"SteamAPIPatcher error: {arg}");
			}
		}

		public static void Patch(AssemblyDefinition assembly)
		{
		}

		private static void Log(string message)
		{
			Console.WriteLine("[SteamAPIPatcher] " + message);
		}
	}
}

BepInEx/plugins/Crawlspace2MP/Crawlspace2MP.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Logging;
using Epic.OnlineServices.Achievements;
using Epic.OnlineServices.AntiCheatClient;
using Epic.OnlineServices.AntiCheatCommon;
using Epic.OnlineServices.AntiCheatServer;
using Epic.OnlineServices.Auth;
using Epic.OnlineServices.Connect;
using Epic.OnlineServices.CustomInvites;
using Epic.OnlineServices.Ecom;
using Epic.OnlineServices.Friends;
using Epic.OnlineServices.IntegratedPlatform;
using Epic.OnlineServices.KWS;
using Epic.OnlineServices.Leaderboards;
using Epic.OnlineServices.Lobby;
using Epic.OnlineServices.Logging;
using Epic.OnlineServices.Metrics;
using Epic.OnlineServices.Mods;
using Epic.OnlineServices.P2P;
using Epic.OnlineServices.Platform;
using Epic.OnlineServices.PlayerDataStorage;
using Epic.OnlineServices.Presence;
using Epic.OnlineServices.ProgressionSnapshot;
using Epic.OnlineServices.RTC;
using Epic.OnlineServices.RTCAdmin;
using Epic.OnlineServices.RTCAudio;
using Epic.OnlineServices.RTCData;
using Epic.OnlineServices.Reports;
using Epic.OnlineServices.Sanctions;
using Epic.OnlineServices.Sessions;
using Epic.OnlineServices.Stats;
using Epic.OnlineServices.TitleStorage;
using Epic.OnlineServices.UI;
using Epic.OnlineServices.UserInfo;
using GorillaLocomotion;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Steamworks;
using Steamworks.Data;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.Video;
using UnityEngine.XR;
using UnityEngine.XR.Interaction.Toolkit;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Crawlspace2MP")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a08bf8fc47e5706e97f9ed13fe1997c62060d02f")]
[assembly: AssemblyProduct("Crawlspace2MP")]
[assembly: AssemblyTitle("Crawlspace2MP")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : System.Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Crawlspace2MP
{
	public class ActorRecorder
	{
		public struct Frame
		{
			public Vector3 HeadPos;

			public Quaternion HeadRot;

			public Vector3 LeftHandPos;

			public Quaternion LeftHandRot;

			public Vector3 RightHandPos;

			public Quaternion RightHandRot;

			public float LeftGrip;

			public float LeftTrigger;

			public float RightGrip;

			public float RightTrigger;
		}

		public class Recording
		{
			public List<Frame> Frames = new List<Frame>();

			public string Name;

			public float FrameInterval;
		}

		public class Actor
		{
			public string Name;

			public Recording Recording;

			public RemotePlayer Visual;

			public int CurrentFrame;

			public float FrameTimer;

			public bool IsPlaying;

			public bool IsLooping;
		}

		private Recording _currentRecording;

		private float _recordTimer;

		private const float RECORD_INTERVAL = 0.033f;

		private int _nextActorId = 1;

		public bool IsRecording { get; private set; }

		public List<Recording> Recordings { get; } = new List<Recording>();


		public List<Actor> Actors { get; } = new List<Actor>();


		public void StartRecording()
		{
			_currentRecording = new Recording
			{
				Name = $"Recording {Recordings.Count + 1}",
				FrameInterval = 0.033f,
				Frames = new List<Frame>()
			};
			_recordTimer = 0f;
			IsRecording = true;
			Plugin.Log.LogInfo((object)"[Actor] Recording started");
		}

		public void StopRecording()
		{
			if (IsRecording)
			{
				IsRecording = false;
				if (_currentRecording.Frames.Count > 0)
				{
					Recordings.Add(_currentRecording);
					Plugin.Log.LogInfo((object)$"[Actor] Recording saved: '{_currentRecording.Name}' ({_currentRecording.Frames.Count} frames, {(float)_currentRecording.Frames.Count * 0.033f:F1}s)");
				}
				else
				{
					Plugin.Log.LogWarning((object)"[Actor] Recording discarded (no frames)");
				}
				_currentRecording = null;
			}
		}

		public void CaptureFrame()
		{
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: 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_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: 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_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: 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_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_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//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_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: 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_00e3: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: 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_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			if (!IsRecording || _currentRecording == null)
			{
				return;
			}
			_recordTimer += Time.deltaTime;
			if (_recordTimer < 0.033f)
			{
				return;
			}
			_recordTimer -= 0.033f;
			BackpackControl val = Object.FindObjectOfType<BackpackControl>();
			Camera main = Camera.main;
			Transform val2 = null;
			Transform val3 = null;
			Transform val4 = null;
			if ((Object)(object)val != (Object)null)
			{
				if ((Object)(object)val.cam != (Object)null)
				{
					val2 = val.cam.transform;
				}
				if ((Object)(object)val.leftHand != (Object)null)
				{
					val3 = val.leftHand.transform;
				}
				if ((Object)(object)val.rightHand != (Object)null)
				{
					val4 = val.rightHand.transform;
				}
			}
			Vector3 position;
			Quaternion rotation;
			Vector3 leftHandPos;
			Quaternion leftHandRot;
			Vector3 rightHandPos;
			Quaternion rightHandRot;
			if ((Object)(object)val2 != (Object)null && (Object)(object)val3 != (Object)null && (Object)(object)val4 != (Object)null)
			{
				position = val2.position;
				rotation = val2.rotation;
				leftHandPos = val3.position;
				leftHandRot = val3.rotation;
				rightHandPos = val4.position;
				rightHandRot = val4.rotation;
			}
			else
			{
				if (!((Object)(object)main != (Object)null))
				{
					return;
				}
				position = ((Component)main).transform.position;
				rotation = ((Component)main).transform.rotation;
				leftHandPos = position + ((Component)main).transform.right * -0.3f + ((Component)main).transform.forward * 0.2f;
				leftHandRot = rotation;
				rightHandPos = position + ((Component)main).transform.right * 0.3f + ((Component)main).transform.forward * 0.2f;
				rightHandRot = rotation;
			}
			float leftGrip = 0f;
			float leftTrigger = 0f;
			float rightGrip = 0f;
			float rightTrigger = 0f;
			if ((Object)(object)val != (Object)null)
			{
				try
				{
					InputActionProperty val5;
					if ((Object)(object)val.controllerLeft != (Object)null)
					{
						val5 = val.controllerLeft.selectActionValue;
						leftGrip = ((InputActionProperty)(ref val5)).action.ReadValue<float>();
						val5 = val.controllerLeft.uiPressActionValue;
						leftTrigger = ((InputActionProperty)(ref val5)).action.ReadValue<float>();
					}
					if ((Object)(object)val.controllerRight != (Object)null)
					{
						val5 = val.controllerRight.selectActionValue;
						rightGrip = ((InputActionProperty)(ref val5)).action.ReadValue<float>();
						val5 = val.controllerRight.uiPressActionValue;
						rightTrigger = ((InputActionProperty)(ref val5)).action.ReadValue<float>();
					}
				}
				catch
				{
				}
			}
			_currentRecording.Frames.Add(new Frame
			{
				HeadPos = position,
				HeadRot = rotation,
				LeftHandPos = leftHandPos,
				LeftHandRot = leftHandRot,
				RightHandPos = rightHandPos,
				RightHandRot = rightHandRot,
				LeftGrip = leftGrip,
				LeftTrigger = leftTrigger,
				RightGrip = rightGrip,
				RightTrigger = rightTrigger
			});
		}

		public Actor SpawnActor(Recording recording, bool loop = true)
		{
			RemotePlayer visual = new RemotePlayer(-100 - _nextActorId);
			Actor actor = new Actor
			{
				Name = $"Actor {_nextActorId} ({recording.Name})",
				Recording = recording,
				Visual = visual,
				CurrentFrame = 0,
				FrameTimer = 0f,
				IsPlaying = true,
				IsLooping = loop
			};
			_nextActorId++;
			Actors.Add(actor);
			if (recording.Frames.Count > 0)
			{
				ApplyFrame(actor, recording.Frames[0]);
			}
			Plugin.Log.LogInfo((object)("[Actor] Spawned: '" + actor.Name + "'"));
			return actor;
		}

		public void RemoveActor(Actor actor)
		{
			actor.Visual?.Destroy();
			Actors.Remove(actor);
			Plugin.Log.LogInfo((object)("[Actor] Removed: '" + actor.Name + "'"));
		}

		public void RemoveAllActors()
		{
			for (int num = Actors.Count - 1; num >= 0; num--)
			{
				Actors[num].Visual?.Destroy();
			}
			Actors.Clear();
			Plugin.Log.LogInfo((object)"[Actor] All actors removed");
		}

		public void DeleteRecording(Recording recording)
		{
			for (int num = Actors.Count - 1; num >= 0; num--)
			{
				if (Actors[num].Recording == recording)
				{
					Actors[num].Visual?.Destroy();
					Actors.RemoveAt(num);
				}
			}
			Recordings.Remove(recording);
			Plugin.Log.LogInfo((object)("[Actor] Deleted recording: '" + recording.Name + "'"));
		}

		public void ToggleActor(Actor actor)
		{
			actor.IsPlaying = !actor.IsPlaying;
			if (actor.IsPlaying)
			{
				actor.CurrentFrame = 0;
				actor.FrameTimer = 0f;
			}
		}

		public void Update()
		{
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: 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_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			foreach (Actor actor in Actors)
			{
				if (!actor.IsPlaying || actor.Recording.Frames.Count == 0)
				{
					continue;
				}
				actor.FrameTimer += Time.deltaTime;
				if (actor.FrameTimer >= actor.Recording.FrameInterval)
				{
					actor.FrameTimer -= actor.Recording.FrameInterval;
					actor.CurrentFrame++;
					if (actor.CurrentFrame >= actor.Recording.Frames.Count)
					{
						if (!actor.IsLooping)
						{
							actor.CurrentFrame = actor.Recording.Frames.Count - 1;
							actor.IsPlaying = false;
							continue;
						}
						actor.CurrentFrame = 0;
					}
				}
				int index = (actor.CurrentFrame + 1) % actor.Recording.Frames.Count;
				float num = actor.FrameTimer / actor.Recording.FrameInterval;
				Frame frame = actor.Recording.Frames[actor.CurrentFrame];
				Frame frame2 = actor.Recording.Frames[index];
				Frame frame3 = default(Frame);
				frame3.HeadPos = Vector3.Lerp(frame.HeadPos, frame2.HeadPos, num);
				frame3.HeadRot = Quaternion.Slerp(frame.HeadRot, frame2.HeadRot, num);
				frame3.LeftHandPos = Vector3.Lerp(frame.LeftHandPos, frame2.LeftHandPos, num);
				frame3.LeftHandRot = Quaternion.Slerp(frame.LeftHandRot, frame2.LeftHandRot, num);
				frame3.RightHandPos = Vector3.Lerp(frame.RightHandPos, frame2.RightHandPos, num);
				frame3.RightHandRot = Quaternion.Slerp(frame.RightHandRot, frame2.RightHandRot, num);
				frame3.LeftGrip = Mathf.Lerp(frame.LeftGrip, frame2.LeftGrip, num);
				frame3.LeftTrigger = Mathf.Lerp(frame.LeftTrigger, frame2.LeftTrigger, num);
				frame3.RightGrip = Mathf.Lerp(frame.RightGrip, frame2.RightGrip, num);
				frame3.RightTrigger = Mathf.Lerp(frame.RightTrigger, frame2.RightTrigger, num);
				Frame frame4 = frame3;
				ApplyFrame(actor, frame4);
			}
		}

		private void ApplyFrame(Actor actor, Frame frame)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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_005b: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			if (actor.Visual != null)
			{
				Vector3 bodyPos = frame.HeadPos - Vector3.up * 0.5f;
				Quaternion bodyRot = Quaternion.Euler(0f, ((Quaternion)(ref frame.HeadRot)).eulerAngles.y, 0f);
				actor.Visual.SetTargets(isStanding: true, bodyPos, bodyRot, frame.HeadPos, frame.HeadRot, frame.LeftHandPos, frame.LeftHandRot, frame.RightHandPos, frame.RightHandRot, frame.LeftGrip, frame.LeftTrigger, frame.RightGrip, frame.RightTrigger);
				actor.Visual.UpdateInterpolation();
			}
		}

		public void Cleanup()
		{
			if (IsRecording)
			{
				StopRecording();
			}
			RemoveAllActors();
			Recordings.Clear();
		}
	}
	public class PlayerSync
	{
		public class RemoteBatteryState
		{
			public float Charge;

			public int LocationID;

			public bool InBackpack;

			public bool LeftHolding;

			public bool RightHolding;
		}

		private class PendingPuzzleInit
		{
			public bool[] ActiveStates;

			public int[] PresetIDs;

			public bool[] CompletedStates;

			public int[][] BlockStates;

			public int TotalCompleted;

			public int RequiredPuzzles;
		}

		private const byte PACKET_PLAYER_POSITION = 1;

		private const byte PACKET_FLASHLIGHT = 2;

		private const byte PACKET_SCENE_CHANGE = 3;

		private const byte PACKET_NIGHT_SELECTED = 4;

		private const byte PACKET_TV_SYNC = 5;

		private const byte PACKET_PAINTING_SYNC = 6;

		private const byte PACKET_PAINTING_FLASH = 7;

		private const byte PACKET_MONSTER_SYNC = 8;

		private const byte PACKET_JEFF_FLASH = 9;

		private const byte PACKET_BATTERY_SYNC = 10;

		private const byte PACKET_PAINTING_ENTITY = 11;

		private const byte PACKET_PUZZLE_INIT = 12;

		private const byte PACKET_PUZZLE_COMPLETE = 13;

		private const byte PACKET_PUZZLE_BLOCK = 14;

		private const byte PACKET_CLOWN_HONK = 15;

		private const byte PACKET_VENT_SOUND = 16;

		private const byte PACKET_CLOWN_STATE = 25;

		private const byte PACKET_CLOWN_ATTACK = 26;

		private const byte PACKET_SMILE_TRIGGER = 27;

		private const byte PACKET_VENT_DOOR = 28;

		private const byte PACKET_PAINTING_DEATH = 29;

		private const byte PACKET_END_PROGRESS = 40;

		private const byte PACKET_INTERACTION_LOCK = 17;

		private const byte PACKET_EXIT_DOOR_PROGRESS = 18;

		private const byte PACKET_CRANK_SYNC = 19;

		private const byte PACKET_DEATH_GHOST = 20;

		private const byte PACKET_VERSION_CHECK = 21;

		private const byte PACKET_PING = 22;

		private const byte PACKET_PONG = 23;

		private const byte PACKET_HOST_MIGRATION = 24;

		private const byte PACKET_EAR_COVERING = 41;

		private const byte PACKET_TARGETED_KILL = 42;

		private Dictionary<int, RemotePlayer> _remotePlayers = new Dictionary<int, RemotePlayer>();

		private bool _remotePlayerCoveringEars;

		private Dictionary<int, string> _peerVersions = new Dictionary<int, string>();

		private Dictionary<int, float> _peerPings = new Dictionary<int, float>();

		private Dictionary<int, float> _pendingPings = new Dictionary<int, float>();

		private float _lastPingTime;

		private const float PING_INTERVAL = 2f;

		private Vector3 _levelSpawnPoint = Vector3.zero;

		private Quaternion _levelSpawnRotation = Quaternion.identity;

		private bool _spawnPointCaptured;

		private HashSet<int> _connectedPeerIds = new HashSet<int>();

		private bool _localIsGhost;

		private bool _pendingGhostTeleport;

		private bool _pendingHomeLoad;

		private float _pendingHomeLoadTimer;

		private string _ghostSceneToReload;

		public static bool IsGhostSceneReload = false;

		private Player _gorillaPlayer;

		private MoveTypeController _moveController;

		private HandControl _handControl;

		private Camera _mainCamera;

		private Transform _playerTransform;

		private Transform _ovrLeftHand;

		private Transform _ovrRightHand;

		private Transform _ovrHead;

		private float _syncInterval = 0.033f;

		private float _lastSyncTime;

		private Flashlight _localFlashlight;

		private FlashlightControl _localFlashlightControl;

		private bool _lastFlashlightState;

		private string _lastScene = "";

		public static bool IsLoadingFromSync = false;

		private int _lastNightSelected = -1;

		private VideoPlayer _tvVideoPlayer;

		private float _lastTvSyncTime;

		private float _tvSyncInterval = 5f;

		private paintingControl _paintingControl;

		private float _lastPaintingSyncTime;

		private float _paintingSyncInterval = 1f;

		private sparkyBrain _sparky;

		private jeffBrain _jeff;

		private SmileBrain _smile;

		private henryBrain _henry;

		private mapEnBrain _harold;

		private clownRandom _clown;

		private float _lastMonsterSyncTime;

		private float _monsterSyncInterval = 0.1f;

		private bool _hostDiedInLevel;

		private float _lastBatterySyncTime;

		private float _batterySyncInterval = 0.1f;

		private int _lastBatteryLocationID = -999;

		private bool _lastBatteryInBackpack;

		private float _lastBatteryCharge = -1f;

		private bool _lastLeftHolding;

		private bool _lastRightHolding;

		private Dictionary<int, RemoteBatteryState> _remoteBatteryStates = new Dictionary<int, RemoteBatteryState>();

		private crankControl _crankControl;

		private float _lastCrankSyncTime;

		private float _crankSyncInterval = 0.2f;

		private float _lastCrankCharge = -1f;

		private bool _lastCrankHasBattery;

		private static Dictionary<string, int> _interactionLocks = new Dictionary<string, int>();

		private static Dictionary<string, float> _lockTimestamps = new Dictionary<string, float>();

		private const float LOCK_TIMEOUT = 5f;

		private float _lastLockCleanupTime;

		private HashSet<string> _localActiveLocks = new HashSet<string>();

		private float _sceneLoadDelayTimer;

		private const float SCENE_LOAD_DELAY = 0.5f;

		private PuzzleMaster _puzzleMaster;

		private bool _puzzleInitSent;

		private PendingPuzzleInit _savedGhostPuzzleState;

		private LeaveDoorControl _leaveDoor;

		private int _lastDoorLeaveTimer;

		private float _lastDoorSyncTime;

		private bool _exitDoorFullyCharged;

		private PacketWriter _writer = new PacketWriter(1024);

		private INetworkTransport _steam;

		private bool _recreateRemotePlayersNextFrame;

		private int _updateCount;

		private int _sendCount;

		private string _pendingSceneLoad;

		private bool _isReceivingPaintingFlash;

		private bool _isReceivingJeffFlash;

		private float _lastTargetedKillTime;

		private Quaternion _lastCrankRotation = Quaternion.identity;

		private bool _remoteCrankHasBattery;

		private float _remoteCrankChargeTarget;

		private float _remoteCrankChargeDisplay;

		private Quaternion _remoteCrankRotTarget = Quaternion.identity;

		private Quaternion _remoteCrankRotDisplay = Quaternion.identity;

		private int _lastTotalCompletedPuzzles = -1;

		private PendingPuzzleInit _pendingPuzzleInit;

		private bool _puzzleInitStartWaited;

		private bool _puzzleInitApplied;

		private float _puzzleInitReapplyTimer;

		private const float PUZZLE_INIT_REAPPLY_DURATION = 3f;

		private bool[] _puzzleInitCompletedStates;

		private bool[] _puzzleInitActiveStates;

		private HashSet<int> _completedPuzzleIDs = new HashSet<int>();

		private bool _isReceivingPuzzleBlock;

		private bool _isReceivingHonk;

		private clownRandom _clownRandom;

		private bool _isReceivingVentSound;

		public bool DebugForceGhostOnDeath;

		private bool _pendingGhostPuzzleRestore;

		private int _ghostPuzzleRestoreFrames;

		private GameObject _ghostVisionLight;

		private float _ghostTeleportDelay;

		private Dictionary<int, float> _ventDoorTimers = new Dictionary<int, float>();

		private EndControl _endControl;

		private int _lastEndImageID = -1;

		private float _lastEndBarFill = -1f;

		private bool _lastEarCoveringState;

		public bool IsAnyPlayerCoveringEars
		{
			get
			{
				if (!earMaster.isCoveringEars)
				{
					return _remotePlayerCoveringEars;
				}
				return true;
			}
		}

		public float AveragePing
		{
			get
			{
				if (_peerPings.Count <= 0)
				{
					return -1f;
				}
				return GetAveragePing();
			}
		}

		public bool IsLocalGhost => _localIsGhost;

		public bool IsDyingThisFrame { get; set; }

		public bool ShouldControlMonsters
		{
			get
			{
				if (_steam != null)
				{
					if (!_steam.IsHost)
					{
						return _hostDiedInLevel;
					}
					return true;
				}
				return false;
			}
		}

		public bool IsReceivingPaintingFlash => _isReceivingPaintingFlash;

		public bool IsReceivingJeffFlash => _isReceivingJeffFlash;

		public bool RemoteHasBatteryInCrank => _remoteCrankHasBattery;

		public float RemoteCrankChargeDisplay => _remoteCrankChargeDisplay;

		public Quaternion RemoteCrankRotationDisplay => _remoteCrankRotDisplay;

		public bool PuzzleInitApplied
		{
			get
			{
				if (!_puzzleInitApplied)
				{
					return _pendingPuzzleInit != null;
				}
				return true;
			}
		}

		public bool IsReceivingPuzzleBlock => _isReceivingPuzzleBlock;

		public bool IsReceivingHonk => _isReceivingHonk;

		public bool IsReceivingVentSound => _isReceivingVentSound;

		public event Action<int, string> OnVersionMismatch;

		public event Action OnBecameHost;

		public float GetPing(int peerId)
		{
			if (!_peerPings.TryGetValue(peerId, out var value))
			{
				return -1f;
			}
			return value;
		}

		private float GetAveragePing()
		{
			if (_peerPings.Count == 0)
			{
				return -1f;
			}
			float num = 0f;
			foreach (float value in _peerPings.Values)
			{
				num += value;
			}
			return num / (float)_peerPings.Count;
		}

		public static bool IsLockedByOther(string interactionId)
		{
			if (_interactionLocks.TryGetValue(interactionId, out var value))
			{
				if (_lockTimestamps.TryGetValue(interactionId, out var value2) && Time.time - value2 > 5f)
				{
					_interactionLocks.Remove(interactionId);
					_lockTimestamps.Remove(interactionId);
					return false;
				}
				return value != -1;
			}
			return false;
		}

		public static bool IsLockedByUs(string interactionId)
		{
			if (_interactionLocks.TryGetValue(interactionId, out var value))
			{
				return value == -1;
			}
			return false;
		}

		public void RefreshLock(string interactionId)
		{
			if (_interactionLocks.TryGetValue(interactionId, out var value) && value != -1)
			{
				if (_lockTimestamps.TryGetValue(interactionId, out var value2) && Time.time - value2 > 5f)
				{
					_interactionLocks[interactionId] = -1;
					_lockTimestamps[interactionId] = Time.time;
					_localActiveLocks.Add(interactionId);
					SendInteractionLock(interactionId, locked: true);
				}
				return;
			}
			bool num = !_interactionLocks.ContainsKey(interactionId) || _interactionLocks[interactionId] != -1;
			_interactionLocks[interactionId] = -1;
			_lockTimestamps[interactionId] = Time.time;
			if (num)
			{
				_localActiveLocks.Add(interactionId);
				SendInteractionLock(interactionId, locked: true);
			}
		}

		public bool TryAcquireLock(string interactionId)
		{
			if (IsLockedByOther(interactionId))
			{
				return false;
			}
			RefreshLock(interactionId);
			return true;
		}

		public void ReleaseLock(string interactionId)
		{
			if (_interactionLocks.TryGetValue(interactionId, out var value) && value == -1)
			{
				_interactionLocks.Remove(interactionId);
				_lockTimestamps.Remove(interactionId);
				_localActiveLocks.Remove(interactionId);
				SendInteractionLock(interactionId, locked: false);
			}
		}

		private void CleanupExpiredLocks()
		{
			if (Time.time - _lastLockCleanupTime < 1f)
			{
				return;
			}
			_lastLockCleanupTime = Time.time;
			List<string> list = new List<string>();
			foreach (KeyValuePair<string, float> lockTimestamp in _lockTimestamps)
			{
				if (Time.time - lockTimestamp.Value > 10f)
				{
					list.Add(lockTimestamp.Key);
				}
			}
			foreach (string item in list)
			{
				_interactionLocks.Remove(item);
				_lockTimestamps.Remove(item);
				_localActiveLocks.Remove(item);
			}
		}

		public void ClearAllLocks()
		{
			_interactionLocks.Clear();
			_lockTimestamps.Clear();
			_localActiveLocks.Clear();
		}

		public void Initialize(INetworkTransport steam)
		{
			_steam = steam;
			_steam.OnPeerConnected += OnPeerConnected;
			_steam.OnPeerDisconnected += OnPeerDisconnected;
			_steam.OnDataReceived += OnDataReceived;
			SceneManager.sceneLoaded += OnSceneLoaded;
			Plugin.Log.LogInfo((object)"PlayerSync initialized (Steam)");
		}

		private void OnPeerConnected(int peerId)
		{
			Plugin.Log.LogInfo((object)$"Peer connected: {peerId}");
			_connectedPeerIds.Add(peerId);
			if (!_remotePlayers.ContainsKey(peerId))
			{
				RemotePlayer value = new RemotePlayer(peerId);
				_remotePlayers[peerId] = value;
				Plugin.Log.LogInfo((object)$"Created remote player for peer {peerId}");
			}
			SendVersionCheck(peerId);
			SendBatterySync();
		}

		private void OnPeerDisconnected(int peerId)
		{
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			Plugin.Log.LogInfo((object)$"Peer disconnected: {peerId}");
			_connectedPeerIds.Remove(peerId);
			_peerVersions.Remove(peerId);
			_peerPings.Remove(peerId);
			_pendingPings.Remove(peerId);
			if (_remotePlayers.TryGetValue(peerId, out var value))
			{
				value.Destroy();
				_remotePlayers.Remove(peerId);
			}
			MPManager.Instance?.Spectate?.StopReceiving();
			MPManager.Instance?.Spectate?.StopSending();
			if (_localIsGhost && _remotePlayers.Count == 0)
			{
				Scene activeScene = SceneManager.GetActiveScene();
				if (((Scene)(ref activeScene)).name.Contains("Night") && !_pendingHomeLoad)
				{
					Plugin.Log.LogInfo((object)"[Ghost] All peers disconnected - scheduling Home load");
					_pendingHomeLoad = true;
					_pendingHomeLoadTimer = 1f;
				}
			}
		}

		private void OnDataReceived(int peerId, PacketReader reader)
		{
			if (reader.AvailableBytes >= 1)
			{
				byte @byte = reader.GetByte();
				switch (@byte)
				{
				case 1:
					HandlePositionPacket(peerId, reader);
					break;
				case 2:
					HandleFlashlightPacket(peerId, reader);
					break;
				case 3:
					HandleSceneChangePacket(reader);
					break;
				case 4:
					HandleNightSelectedPacket(reader);
					break;
				case 5:
					HandleTvSyncPacket(reader);
					break;
				case 6:
					HandlePaintingSyncPacket(reader);
					break;
				case 7:
					HandlePaintingFlashPacket(reader);
					break;
				case 8:
					HandleMonsterSyncPacket(reader);
					break;
				case 9:
					HandleJeffFlashPacket();
					break;
				case 10:
					HandleBatterySync(peerId, reader);
					break;
				case 11:
					HandlePaintingEntity(reader);
					break;
				case 12:
					HandlePuzzleInit(reader);
					break;
				case 13:
					HandlePuzzleComplete(reader);
					break;
				case 14:
					HandlePuzzleBlock(reader);
					break;
				case 15:
					HandleClownHonk(reader);
					break;
				case 16:
					HandleVentSoundPacket(reader);
					break;
				case 17:
					HandleInteractionLockPacket(peerId, reader);
					break;
				case 18:
					HandleExitDoorProgressPacket(reader);
					break;
				case 19:
					HandleCrankSyncPacket(reader);
					break;
				case 20:
					HandleDeathGhostPacket(peerId, reader);
					break;
				case 21:
					HandleVersionCheck(peerId, reader);
					break;
				case 22:
					HandlePing(peerId, reader);
					break;
				case 23:
					HandlePong(peerId, reader);
					break;
				case 24:
					HandleHostMigration(peerId, reader);
					break;
				case 25:
					HandleClownState(reader);
					break;
				case 26:
					HandleClownAttack(reader);
					break;
				case 27:
					HandleSmileTrigger(reader);
					break;
				case 28:
					HandleVentDoor(reader);
					break;
				case 29:
					HandlePaintingDeath();
					break;
				case 40:
					HandleEndProgress(reader);
					break;
				case 41:
					HandleEarCovering(reader);
					break;
				case 42:
					HandleTargetedKill(reader);
					break;
				case 200:
					MPManager.Instance?.VoiceChat?.OnVoiceDataReceived(peerId, reader);
					break;
				case 30:
				case 31:
				case 32:
					MPManager.Instance?.Spectate?.OnPacketReceived(@byte, reader);
					break;
				default:
					Plugin.Log.LogWarning((object)$"Unknown packet type: {@byte}");
					break;
				}
			}
		}

		private void HandlePositionPacket(int peerId, PacketReader reader)
		{
			//IL_011a: 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_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			if (_remotePlayers.TryGetValue(peerId, out var value))
			{
				bool @bool = reader.GetBool();
				Vector3 bodyPos = default(Vector3);
				((Vector3)(ref bodyPos))..ctor(reader.GetFloat(), reader.GetFloat(), reader.GetFloat());
				Quaternion bodyRot = default(Quaternion);
				((Quaternion)(ref bodyRot))..ctor(reader.GetFloat(), reader.GetFloat(), reader.GetFloat(), reader.GetFloat());
				Vector3 headPos = default(Vector3);
				((Vector3)(ref headPos))..ctor(reader.GetFloat(), reader.GetFloat(), reader.GetFloat());
				Quaternion headRot = default(Quaternion);
				((Quaternion)(ref headRot))..ctor(reader.GetFloat(), reader.GetFloat(), reader.GetFloat(), reader.GetFloat());
				Vector3 leftHandPos = default(Vector3);
				((Vector3)(ref leftHandPos))..ctor(reader.GetFloat(), reader.GetFloat(), reader.GetFloat());
				Quaternion leftHandRot = default(Quaternion);
				((Quaternion)(ref leftHandRot))..ctor(reader.GetFloat(), reader.GetFloat(), reader.GetFloat(), reader.GetFloat());
				Vector3 rightHandPos = default(Vector3);
				((Vector3)(ref rightHandPos))..ctor(reader.GetFloat(), reader.GetFloat(), reader.GetFloat());
				Quaternion rightHandRot = default(Quaternion);
				((Quaternion)(ref rightHandRot))..ctor(reader.GetFloat(), reader.GetFloat(), reader.GetFloat(), reader.GetFloat());
				float @float = reader.GetFloat();
				float float2 = reader.GetFloat();
				float float3 = reader.GetFloat();
				float float4 = reader.GetFloat();
				value.SetTargets(@bool, bodyPos, bodyRot, headPos, headRot, leftHandPos, leftHandRot, rightHandPos, rightHandRot, @float, float2, float3, float4);
			}
		}

		private void HandleFlashlightPacket(int peerId, PacketReader reader)
		{
			bool @bool = reader.GetBool();
			if (_remotePlayers.TryGetValue(peerId, out var value))
			{
				value.SetFlashlightState(@bool);
			}
		}

		private void HandleSceneChangePacket(PacketReader reader)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			string @string = reader.GetString();
			int @int = reader.GetInt();
			Plugin.Log.LogInfo((object)$"Received scene change: {@string}, night={@int}");
			Scene activeScene = SceneManager.GetActiveScene();
			string name = ((Scene)(ref activeScene)).name;
			if (@string.Equals("Home", StringComparison.OrdinalIgnoreCase) && name.Contains("Night"))
			{
				sceneLeave val = Object.FindObjectOfType<sceneLeave>();
				if ((Object)(object)val != (Object)null)
				{
					val.loadSelectedNight();
					Plugin.Log.LogInfo((object)"[Sync] Saved night completion via loadSelectedNight()");
				}
			}
			calenderControl.nightSelected = @int;
			if (_steam.IsHost && _localIsGhost)
			{
				Plugin.Log.LogInfo((object)("[Ghost Host] Client triggered scene exit, loading: " + @string));
				IsLoadingFromSync = true;
				ResetGhostState();
				SceneManager.LoadScene(@string);
			}
			else if (_steam.IsHost)
			{
				Plugin.Log.LogInfo((object)("[Host] Client triggered scene exit, loading: " + @string));
				IsLoadingFromSync = true;
				TriggerClientFade();
				SceneManager.LoadScene(@string);
			}
			else
			{
				Plugin.Log.LogInfo((object)("[Client] Deferring scene load: " + @string));
				IsLoadingFromSync = true;
				_lastScene = @string;
				_pendingSceneLoad = @string;
				_sceneLoadDelayTimer = 0.1f;
				TriggerClientFade();
			}
		}

		private void HandleNightSelectedPacket(PacketReader reader)
		{
			int @int = reader.GetInt();
			Plugin.Log.LogInfo((object)$"Received night selection: {@int}");
			calenderControl.nightSelected = @int;
			calenderControl val = Object.FindObjectOfType<calenderControl>();
			if ((Object)(object)val != (Object)null)
			{
				val.setNightText();
			}
		}

		private void HandleTvSyncPacket(PacketReader reader)
		{
			long @long = reader.GetLong();
			if ((Object)(object)_tvVideoPlayer == (Object)null)
			{
				tvControl val = Object.FindObjectOfType<tvControl>();
				if ((Object)(object)val != (Object)null && (Object)(object)val.TVVP != (Object)null)
				{
					_tvVideoPlayer = val.TVVP;
				}
			}
			if ((Object)(object)_tvVideoPlayer != (Object)null && _tvVideoPlayer.isPrepared && Math.Abs(_tvVideoPlayer.frame - @long) > 30)
			{
				_tvVideoPlayer.frame = @long;
			}
		}

		private void HandlePaintingSyncPacket(PacketReader reader)
		{
			if ((Object)(object)_paintingControl == (Object)null)
			{
				_paintingControl = Object.FindObjectOfType<paintingControl>();
			}
			if (!((Object)(object)_paintingControl == (Object)null))
			{
				int @int = reader.GetInt();
				int int2 = reader.GetInt();
				int int3 = reader.GetInt();
				int int4 = reader.GetInt();
				int int5 = reader.GetInt();
				int int6 = reader.GetInt();
				_paintingControl.intpaintingTall1 = @int;
				_paintingControl.intpaintingTall2 = int2;
				_paintingControl.intpaintingTall3 = int3;
				_paintingControl.intpaintingSquare1 = int4;
				_paintingControl.intpaintingSquare2 = int5;
				_paintingControl.intpaintingSquare3 = int6;
				Type typeFromHandle = typeof(paintingControl);
				BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic;
				bool flag = (bool)typeFromHandle.GetField("boolpaintingTall1", bindingAttr).GetValue(_paintingControl);
				bool flag2 = (bool)typeFromHandle.GetField("boolpaintingTall2", bindingAttr).GetValue(_paintingControl);
				bool flag3 = (bool)typeFromHandle.GetField("boolpaintingTall3", bindingAttr).GetValue(_paintingControl);
				bool flag4 = (bool)typeFromHandle.GetField("boolpaintingSquare1", bindingAttr).GetValue(_paintingControl);
				bool flag5 = (bool)typeFromHandle.GetField("boolpaintingSquare2", bindingAttr).GetValue(_paintingControl);
				bool flag6 = (bool)typeFromHandle.GetField("boolpaintingSquare3", bindingAttr).GetValue(_paintingControl);
				_paintingControl.setPaintingMatSquare(_paintingControl.paintingTall1, @int, flag, true);
				_paintingControl.setPaintingMatSquare(_paintingControl.paintingTall2, int2, flag2, true);
				_paintingControl.setPaintingMatSquare(_paintingControl.paintingTall3, int3, flag3, true);
				_paintingControl.setPaintingMatSquare(_paintingControl.paintingSquare1, int4, flag4, false);
				_paintingControl.setPaintingMatSquare(_paintingControl.paintingSquare2, int5, flag5, false);
				_paintingControl.setPaintingMatSquare(_paintingControl.paintingSquare3, int6, flag6, false);
			}
		}

		private void HandlePaintingFlashPacket(PacketReader reader)
		{
			int @int = reader.GetInt();
			_isReceivingPaintingFlash = true;
			paintingControl paintingControl = _paintingControl;
			if (paintingControl != null)
			{
				paintingControl.onPaintingFlash(@int);
			}
			_isReceivingPaintingFlash = false;
		}

		private void HandleMonsterSyncPacket(PacketReader reader)
		{
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: 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_0223: 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_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: 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_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: 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)
			if (_steam.IsHost || _hostDiedInLevel)
			{
				return;
			}
			FindMonsters();
			if (reader.GetBool())
			{
				int @int = reader.GetInt();
				if ((Object)(object)_sparky != (Object)null)
				{
					FieldInfo field = typeof(sparkyBrain).GetField("currentState", BindingFlags.Instance | BindingFlags.NonPublic);
					int num = ((!(field != null)) ? 1 : ((int)field.GetValue(_sparky)));
					if (@int == 2 && num == 1)
					{
						field?.SetValue(_sparky, @int);
					}
				}
			}
			if (reader.GetBool())
			{
				reader.GetBool();
				int int2 = reader.GetInt();
				reader.GetInt();
				if ((Object)(object)_jeff != (Object)null)
				{
					FieldInfo field2 = typeof(jeffBrain).GetField("currentState", BindingFlags.Instance | BindingFlags.NonPublic);
					int num2 = ((!(field2 != null)) ? 1 : ((int)field2.GetValue(_jeff)));
					if (int2 == 2 && num2 == 1)
					{
						field2?.SetValue(_jeff, 2);
					}
				}
			}
			if (reader.GetBool())
			{
				reader.GetBool();
				reader.GetInt();
			}
			if (reader.GetBool())
			{
				Vector3 position = ReadVector3(reader);
				Quaternion rotation = ReadQuaternion(reader);
				bool @bool = reader.GetBool();
				bool bool2 = reader.GetBool();
				if ((Object)(object)_henry != (Object)null)
				{
					if ((Object)(object)_henry.agent != (Object)null && ((Behaviour)_henry.agent).enabled)
					{
						((Behaviour)_henry.agent).enabled = false;
					}
					((Component)_henry).transform.position = position;
					((Component)_henry).transform.rotation = rotation;
					typeof(henryBrain).GetField("resetSwitch", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(_henry, @bool);
					typeof(henryBrain).GetField("chaseSwitch", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(_henry, bool2);
				}
			}
			if (reader.GetBool())
			{
				Vector3 position2 = ReadVector3(reader);
				Quaternion rotation2 = ReadQuaternion(reader);
				if ((Object)(object)_harold != (Object)null)
				{
					if ((Object)(object)_harold.agent != (Object)null && ((Behaviour)_harold.agent).enabled)
					{
						((Behaviour)_harold.agent).enabled = false;
					}
					((Component)_harold).transform.position = position2;
					((Component)_harold).transform.rotation = rotation2;
				}
			}
			if (!reader.GetBool())
			{
				return;
			}
			int int3 = reader.GetInt();
			if ((Object)(object)_clown != (Object)null)
			{
				if ((Object)(object)_clown.clown1 != (Object)null)
				{
					_clown.clown1.SetActive(int3 == 0);
				}
				if ((Object)(object)_clown.clown2 != (Object)null)
				{
					_clown.clown2.SetActive(int3 == 1);
				}
				if ((Object)(object)_clown.clown3 != (Object)null)
				{
					_clown.clown3.SetActive(int3 == 2);
				}
				if ((Object)(object)_clown.clown4 != (Object)null)
				{
					_clown.clown4.SetActive(int3 == 3);
				}
				if ((Object)(object)_clown.clown5 != (Object)null)
				{
					_clown.clown5.SetActive(int3 == 4);
				}
				if ((Object)(object)_clown.clown6 != (Object)null)
				{
					_clown.clown6.SetActive(int3 == 5);
				}
				if ((Object)(object)_clown.clown7 != (Object)null)
				{
					_clown.clown7.SetActive(int3 == 6);
				}
			}
		}

		private void HandleJeffFlashPacket()
		{
			_isReceivingJeffFlash = true;
			jeffBrain jeff = _jeff;
			if (jeff != null)
			{
				jeff.onFlash();
			}
			_isReceivingJeffFlash = false;
		}

		private void HandleVentSoundPacket(PacketReader reader)
		{
			HandleVentSound(reader);
		}

		private void HandleInteractionLockPacket(int peerId, PacketReader reader)
		{
			string @string = reader.GetString();
			if (reader.GetBool())
			{
				_interactionLocks[@string] = peerId;
				_lockTimestamps[@string] = Time.time;
			}
			else
			{
				_interactionLocks.Remove(@string);
				_lockTimestamps.Remove(@string);
			}
		}

		private void HandleExitDoorProgressPacket(PacketReader reader)
		{
			int @int = reader.GetInt();
			int int2 = reader.GetInt();
			if (BackpackControl.batteryLocationID == 100 && BackpackControl.batteryCharge >= 0.1f)
			{
				return;
			}
			if ((Object)(object)_leaveDoor == (Object)null)
			{
				_leaveDoor = Object.FindObjectOfType<LeaveDoorControl>();
			}
			if (!((Object)(object)_leaveDoor != (Object)null))
			{
				return;
			}
			typeof(LeaveDoorControl).GetField("doorLeaveTimer", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(_leaveDoor, @int);
			typeof(LeaveDoorControl).GetField("loadingBarLock", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(_leaveDoor, @int > 0);
			if ((Object)(object)_leaveDoor.fillImg != (Object)null && int2 > 0)
			{
				_leaveDoor.fillImg.fillAmount = (float)@int / (float)int2;
			}
			if ((Object)(object)_leaveDoor.fillIcon != (Object)null)
			{
				_leaveDoor.fillIcon.SetActive(@int > 0);
			}
			FieldInfo field = typeof(LeaveDoorControl).GetField("puzzleCount", BindingFlags.Instance | BindingFlags.Public);
			if (field != null && @int > 0 && int2 > 0)
			{
				object value = field.GetValue(_leaveDoor);
				if (value != null)
				{
					PropertyInfo property = value.GetType().GetProperty("text");
					if (property != null)
					{
						int num = (int)Math.Round((float)@int / (float)int2 * 100f);
						if (@int >= int2)
						{
							property.SetValue(value, "100%");
							if ((Object)(object)_leaveDoor.doorLeaveHitbox != (Object)null)
							{
								_leaveDoor.doorLeaveHitbox.SetActive(true);
							}
							_exitDoorFullyCharged = true;
						}
						else
						{
							property.SetValue(value, num + "%");
						}
					}
				}
			}
			if (@int > 0)
			{
				if ((Object)(object)_leaveDoor.greenIcon != (Object)null)
				{
					_leaveDoor.greenIcon.SetActive(false);
				}
				if ((Object)(object)_leaveDoor.redIcon != (Object)null)
				{
					_leaveDoor.redIcon.SetActive(false);
				}
			}
		}

		private void HandleCrankSyncPacket(PacketReader reader)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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)
			bool @bool = reader.GetBool();
			float @float = reader.GetFloat();
			Quaternion remoteCrankRotTarget = ReadQuaternion(reader);
			_remoteCrankHasBattery = @bool;
			_remoteCrankChargeTarget = @float;
			_remoteCrankRotTarget = remoteCrankRotTarget;
			if (@bool && _remoteCrankChargeDisplay < 0.01f)
			{
				_remoteCrankChargeDisplay = @float;
			}
			if (!@bool)
			{
				_remoteCrankChargeTarget = 0f;
				_remoteCrankChargeDisplay = 0f;
			}
		}

		private void HandleDeathGhostPacket(int peerId, PacketReader reader)
		{
			//IL_0274: 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_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			bool @bool = reader.GetBool();
			int @int = reader.GetInt();
			Plugin.Log.LogInfo((object)$"[Death] Received death packet from peer {peerId}: isGhost={@bool}, deathType={@int}");
			if (_remotePlayers.TryGetValue(peerId, out var value))
			{
				value.SetGhostState(@bool);
				Plugin.Log.LogInfo((object)$"[Death] Set peer {peerId} ghost state to {@bool}");
			}
			if (@bool && _remoteBatteryStates.ContainsKey(peerId))
			{
				_remoteBatteryStates[peerId].LocationID = 0;
				_remoteBatteryStates[peerId].Charge = 0f;
				_remoteBatteryStates[peerId].LeftHolding = false;
				_remoteBatteryStates[peerId].RightHolding = false;
				_remoteBatteryStates[peerId].InBackpack = false;
				Plugin.LogDebug($"[Death] Cleared battery state for dead peer {peerId}");
			}
			if (@bool)
			{
				List<string> list = new List<string>();
				foreach (KeyValuePair<string, int> interactionLock in _interactionLocks)
				{
					if (interactionLock.Value == peerId)
					{
						list.Add(interactionLock.Key);
					}
				}
				foreach (string item in list)
				{
					_interactionLocks.Remove(item);
					_lockTimestamps.Remove(item);
				}
				if (list.Count > 0)
				{
					Plugin.LogDebug($"[Death] Cleared {list.Count} interaction locks from dead peer {peerId}");
				}
			}
			_remoteCrankHasBattery = false;
			Scene activeScene;
			if (_localIsGhost && @bool)
			{
				bool flag = false;
				foreach (KeyValuePair<int, RemotePlayer> remotePlayer in _remotePlayers)
				{
					if (!remotePlayer.Value.IsGhost)
					{
						flag = true;
						break;
					}
				}
				if (!flag)
				{
					activeScene = SceneManager.GetActiveScene();
					if (((Scene)(ref activeScene)).name.Contains("Night"))
					{
						Plugin.Log.LogInfo((object)"[Ghost] All players dead - scheduling Home load");
						_pendingHomeLoad = true;
						_pendingHomeLoadTimer = 3f;
						return;
					}
				}
			}
			Plugin.LogDebug($"[Death] Partner death handled - LocalGhost={_localIsGhost}, RemoteGhost={@bool}");
			activeScene = SceneManager.GetActiveScene();
			string name = ((Scene)(ref activeScene)).name;
			if (!@bool || _localIsGhost || !name.Contains("Night"))
			{
				return;
			}
			MPManager.Instance?.Spectate?.StartSending();
			if (_steam.IsHost)
			{
				return;
			}
			_hostDiedInLevel = true;
			Plugin.Log.LogInfo((object)"[Client] Host died - taking over monster control!");
			FindMonsters();
			if ((Object)(object)_sparky != (Object)null)
			{
				NavMeshAgent component = ((Component)_sparky).GetComponent<NavMeshAgent>();
				if ((Object)(object)component != (Object)null)
				{
					((Behaviour)component).enabled = true;
				}
			}
			if ((Object)(object)_jeff != (Object)null)
			{
				NavMeshAgent component2 = ((Component)_jeff).GetComponent<NavMeshAgent>();
				if ((Object)(object)component2 != (Object)null)
				{
					((Behaviour)component2).enabled = true;
				}
			}
			if ((Object)(object)_smile != (Object)null)
			{
				NavMeshAgent component3 = ((Component)_smile).GetComponent<NavMeshAgent>();
				if ((Object)(object)component3 != (Object)null)
				{
					((Behaviour)component3).enabled = true;
				}
			}
			if ((Object)(object)_henry != (Object)null)
			{
				NavMeshAgent component4 = ((Component)_henry).GetComponent<NavMeshAgent>();
				if ((Object)(object)component4 != (Object)null)
				{
					((Behaviour)component4).enabled = true;
				}
			}
			if ((Object)(object)_harold != (Object)null)
			{
				NavMeshAgent component5 = ((Component)_harold).GetComponent<NavMeshAgent>();
				if ((Object)(object)component5 != (Object)null)
				{
					((Behaviour)component5).enabled = true;
				}
			}
		}

		private void SendToAllPeers(bool reliable = true)
		{
			if (_steam != null && _steam.IsRunning)
			{
				byte[] bytes = _writer.GetBytes();
				_steam.SendToAll(bytes, reliable);
			}
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			Plugin.Log.LogInfo((object)$"OnSceneLoaded: {((Scene)(ref scene)).name}, IsGhost={_localIsGhost}");
			MinimapFriendPatch.Cleanup();
			ClearAllLocks();
			_spawnPointCaptured = false;
			_hostDiedInLevel = false;
			if (_localIsGhost && _pendingGhostTeleport && ((Scene)(ref scene)).name.Contains("Night"))
			{
				Plugin.Log.LogInfo((object)"[Ghost] Scene loaded as ghost, preparing teleport");
				HandleGhostSceneLoaded();
			}
			if (((Scene)(ref scene)).name.Equals("Home", StringComparison.OrdinalIgnoreCase))
			{
				if (_localIsGhost)
				{
					Plugin.Log.LogInfo((object)"[Ghost] Entered Home, resetting ghost state");
					ResetGhostState();
				}
				_pendingPuzzleInit = null;
			}
			if (((Scene)(ref scene)).name.Equals("Home", StringComparison.OrdinalIgnoreCase) || !((Scene)(ref scene)).name.Contains("Night"))
			{
				MPManager.Instance?.Spectate?.StopSending();
				MPManager.Instance?.Spectate?.StopReceiving();
			}
			if (((Scene)(ref scene)).name == _lastScene && !IsLoadingFromSync)
			{
				if (_steam == null || !_steam.IsRunning || _connectedPeerIds.Count <= 0)
				{
					return;
				}
				foreach (RemotePlayer value in _remotePlayers.Values)
				{
					value.Destroy();
				}
				_remotePlayers.Clear();
				_recreateRemotePlayersNextFrame = true;
				return;
			}
			Plugin.Log.LogInfo((object)("Scene loaded: " + ((Scene)(ref scene)).name));
			IsLoadingFromSync = false;
			_lastScene = ((Scene)(ref scene)).name;
			foreach (RemotePlayer value2 in _remotePlayers.Values)
			{
				value2.Destroy();
			}
			_remotePlayers.Clear();
			_remoteBatteryStates.Clear();
			_puzzleMaster = null;
			_puzzleInitSent = false;
			_puzzleInitStartWaited = false;
			_puzzleInitApplied = false;
			_puzzleInitReapplyTimer = 0f;
			_puzzleInitCompletedStates = null;
			_puzzleInitActiveStates = null;
			_completedPuzzleIDs.Clear();
			ClearAllLocks();
			if (_steam != null && _steam != null && _steam.IsRunning)
			{
				_recreateRemotePlayersNextFrame = true;
			}
		}

		public void Cleanup()
		{
			SceneManager.sceneLoaded -= OnSceneLoaded;
			ClearRemotePlayers();
			ClearAllLocks();
			ResetGhostState();
			_connectedPeerIds.Clear();
			_remoteBatteryStates.Clear();
			_pendingPuzzleInit = null;
			Plugin.Log.LogInfo((object)"PlayerSync cleaned up");
		}

		public void Update()
		{
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: 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)
			_updateCount++;
			if (_steam == null)
			{
				return;
			}
			UpdateCrankInterpolation();
			IsDyingThisFrame = false;
			if (_steam.IsRunning && _steam.IsConnected && Time.realtimeSinceStartup - _lastPingTime > 2f)
			{
				_lastPingTime = Time.realtimeSinceStartup;
				SendPingToAll();
			}
			if (_pendingHomeLoad)
			{
				_pendingHomeLoadTimer -= Time.deltaTime;
				if (_pendingHomeLoadTimer <= 0f)
				{
					_pendingHomeLoad = false;
					bool flag = true;
					foreach (KeyValuePair<int, RemotePlayer> remotePlayer in _remotePlayers)
					{
						if (!remotePlayer.Value.IsGhost)
						{
							flag = false;
							break;
						}
					}
					if (flag && _localIsGhost)
					{
						Scene activeScene = SceneManager.GetActiveScene();
						if (((Scene)(ref activeScene)).name.Contains("Night"))
						{
							Plugin.Log.LogInfo((object)"[Ghost] EXECUTING DEFERRED HOME LOAD - all players dead");
							ResetGhostState();
							IsLoadingFromSync = true;
							SceneManager.LoadScene("Home");
							return;
						}
					}
				}
			}
			if (_pendingSceneLoad != null)
			{
				if (_sceneLoadDelayTimer > 0f)
				{
					_sceneLoadDelayTimer -= Time.deltaTime;
					return;
				}
				string pendingSceneLoad = _pendingSceneLoad;
				_pendingSceneLoad = null;
				_sceneLoadDelayTimer = 0f;
				Plugin.Log.LogInfo((object)("[Client] EXECUTING DEFERRED SCENE LOAD: " + pendingSceneLoad));
				try
				{
					TriggerClientFade();
					SceneManager.LoadScene(pendingSceneLoad);
				}
				catch (Exception arg)
				{
					Plugin.Log.LogError((object)$"[Client] SceneManager.LoadScene FAILED: {arg}");
				}
			}
			if (_recreateRemotePlayersNextFrame)
			{
				_recreateRemotePlayersNextFrame = false;
				RecreateRemotePlayers();
			}
			UpdateGhostTeleport();
			if (_localIsGhost && _spawnPointCaptured && _ghostTeleportDelay <= 0f)
			{
				Camera val = _mainCamera ?? Camera.main;
				if ((Object)(object)val != (Object)null && ((Component)val).transform.position.y < -5f)
				{
					Plugin.Log.LogInfo((object)$"[Ghost] Fell through map (Y={((Component)_mainCamera).transform.position.y:F1}), re-teleporting to spawn");
					TeleportLocalPlayer(_levelSpawnPoint);
				}
			}
			if (_pendingGhostPuzzleRestore)
			{
				_ghostPuzzleRestoreFrames--;
				if (_ghostPuzzleRestoreFrames <= 0)
				{
					_pendingGhostPuzzleRestore = false;
					RestoreGhostPuzzleState();
				}
			}
			foreach (RemotePlayer value in _remotePlayers.Values)
			{
				value.UpdateInterpolation();
			}
			if (!_steam.IsRunning || (!_steam.IsHost && !_steam.IsConnected && !_steam.IsInLobby))
			{
				return;
			}
			if (!_spawnPointCaptured && _updateCount > 10)
			{
				CaptureSpawnPoint();
			}
			if (_updateCount % 300 == 0)
			{
				Plugin.LogDebug($"PlayerSync.Update: remotePlayers={_remotePlayers.Count}, ping={AveragePing:F0}ms");
			}
			if ((Object)(object)_gorillaPlayer == (Object)null && (Object)(object)_handControl == (Object)null && (Object)(object)_mainCamera == (Object)null && (Object)(object)_ovrHead == (Object)null)
			{
				_gorillaPlayer = Player.Instance;
				_handControl = Object.FindObjectOfType<HandControl>();
				_moveController = Object.FindObjectOfType<MoveTypeController>();
				_mainCamera = Camera.main;
				MonoBehaviour[] array = Object.FindObjectsOfType<MonoBehaviour>();
				foreach (MonoBehaviour val2 in array)
				{
					Type type = ((object)val2).GetType();
					if (type.Name == "OVRCameraRig")
					{
						object? obj = type.GetProperty("centerEyeAnchor")?.GetValue(val2);
						Transform val3 = (Transform)((obj is Transform) ? obj : null);
						object? obj2 = type.GetProperty("leftHandAnchor")?.GetValue(val2);
						Transform val4 = (Transform)((obj2 is Transform) ? obj2 : null);
						object? obj3 = type.GetProperty("rightHandAnchor")?.GetValue(val2);
						Transform val5 = (Transform)((obj3 is Transform) ? obj3 : null);
						if ((Object)(object)val3 != (Object)null && (Object)(object)val4 != (Object)null && (Object)(object)val5 != (Object)null)
						{
							_ovrHead = val3;
							_ovrLeftHand = val4;
							_ovrRightHand = val5;
						}
						break;
					}
				}
				if ((Object)(object)_ovrLeftHand == (Object)null || (Object)(object)_ovrRightHand == (Object)null)
				{
					BackpackControl val6 = Object.FindObjectOfType<BackpackControl>();
					if ((Object)(object)val6 != (Object)null)
					{
						if ((Object)(object)val6.leftHand != (Object)null)
						{
							_ovrLeftHand = val6.leftHand.transform;
						}
						if ((Object)(object)val6.rightHand != (Object)null)
						{
							_ovrRightHand = val6.rightHand.transform;
						}
						if ((Object)(object)val6.cam != (Object)null && (Object)(object)_ovrHead == (Object)null)
						{
							_ovrHead = val6.cam.transform;
						}
					}
				}
				if ((Object)(object)_ovrLeftHand == (Object)null || (Object)(object)_ovrRightHand == (Object)null)
				{
					ActionBasedController[] array2 = Object.FindObjectsOfType<ActionBasedController>();
					foreach (ActionBasedController val7 in array2)
					{
						string text = ((Object)((Component)val7).gameObject).name.ToLower();
						if (text.Contains("left") && (Object)(object)_ovrLeftHand == (Object)null)
						{
							_ovrLeftHand = ((Component)val7).transform;
						}
						else if (text.Contains("right") && (Object)(object)_ovrRightHand == (Object)null)
						{
							_ovrRightHand = ((Component)val7).transform;
						}
					}
				}
				if ((Object)(object)_ovrLeftHand == (Object)null || (Object)(object)_ovrRightHand == (Object)null)
				{
					crankControl val8 = Object.FindObjectOfType<crankControl>();
					if ((Object)(object)val8 != (Object)null)
					{
						if ((Object)(object)val8.handLeft != (Object)null && (Object)(object)_ovrLeftHand == (Object)null)
						{
							_ovrLeftHand = val8.handLeft.transform;
						}
						if ((Object)(object)val8.handRight != (Object)null && (Object)(object)_ovrRightHand == (Object)null)
						{
							_ovrRightHand = val8.handRight.transform;
						}
					}
				}
				Plugin.Log.LogInfo((object)("[Tracking] Head=" + (((Object)(object)_ovrHead != (Object)null) ? ((Object)_ovrHead).name : "NONE") + ", LHand=" + (((Object)(object)_ovrLeftHand != (Object)null) ? ((Object)_ovrLeftHand).name : "NONE") + ", RHand=" + (((Object)(object)_ovrRightHand != (Object)null) ? ((Object)_ovrRightHand).name : "NONE")));
				if ((Object)(object)_gorillaPlayer != (Object)null)
				{
					_playerTransform = ((Component)_gorillaPlayer).transform;
				}
			}
			if (!((Object)(object)_gorillaPlayer == (Object)null) || !((Object)(object)_handControl == (Object)null) || !((Object)(object)_mainCamera == (Object)null))
			{
				if (Time.time - _lastSyncTime >= _syncInterval)
				{
					SendPositionUpdate();
					_lastSyncTime = Time.time;
				}
				CheckFlashlightState();
				CheckSceneChange();
				CheckCalendarChange();
				CheckTvSync();
				CheckPaintingSync();
				CheckMonsterSync();
				CheckBatterySync();
				CheckCrankSync();
				CheckPuzzleInitSync();
				if (_pendingPuzzleInit != null && !_steam.IsHost)
				{
					TryApplyPuzzleInit();
				}
				ReapplyPuzzleIndicators();
				CheckExitDoorSync();
				CheckEndSceneSync();
				CheckEarCoveringSync();
				CleanupExpiredLocks();
			}
		}

		private void CheckCalendarChange()
		{
			if (_steam.IsHost)
			{
				int nightSelected = calenderControl.nightSelected;
				if (nightSelected != _lastNightSelected)
				{
					_lastNightSelected = nightSelected;
					SendNightSelected(nightSelected);
				}
			}
		}

		private void CheckTvSync()
		{
			if (!_steam.IsHost || _localIsGhost || Time.time - _lastTvSyncTime < _tvSyncInterval)
			{
				return;
			}
			_lastTvSyncTime = Time.time;
			if ((Object)(object)_tvVideoPlayer == (Object)null)
			{
				tvControl val = Object.FindObjectOfType<tvControl>();
				if ((Object)(object)val != (Object)null && (Object)(object)val.TVVP != (Object)null)
				{
					_tvVideoPlayer = val.TVVP;
				}
				else
				{
					MoviePlayerSample val2 = Object.FindObjectOfType<MoviePlayerSample>();
					if ((Object)(object)val2 != (Object)null)
					{
						_tvVideoPlayer = ((Component)val2).GetComponent<VideoPlayer>();
						if ((Object)(object)_tvVideoPlayer != (Object)null)
						{
							Plugin.LogDebug("Found TV VideoPlayer");
						}
					}
				}
			}
			if ((Object)(object)_tvVideoPlayer != (Object)null && _tvVideoPlayer.isPlaying)
			{
				SendTvSync(_tvVideoPlayer.frame);
			}
		}

		private void SendTvSync(long frame)
		{
			_writer.Reset();
			_writer.Put((byte)5);
			_writer.Put(frame);
			SendToAllPeers();
		}

		private void CheckPaintingSync()
		{
			if (_steam.IsHost && !_localIsGhost && !(Time.time - _lastPaintingSyncTime < _paintingSyncInterval))
			{
				_lastPaintingSyncTime = Time.time;
				if ((Object)(object)_paintingControl == (Object)null)
				{
					_paintingControl = Object.FindObjectOfType<paintingControl>();
				}
				if ((Object)(object)_paintingControl != (Object)null)
				{
					SendPaintingSync();
				}
			}
		}

		private void SendPaintingSync()
		{
			_writer.Reset();
			_writer.Put((byte)6);
			_writer.Put(_paintingControl.intpaintingTall1);
			_writer.Put(_paintingControl.intpaintingTall2);
			_writer.Put(_paintingControl.intpaintingTall3);
			_writer.Put(_paintingControl.intpaintingSquare1);
			_writer.Put(_paintingControl.intpaintingSquare2);
			_writer.Put(_paintingControl.intpaintingSquare3);
			SendToAllPeers();
		}

		private void SendNightSelected(int night)
		{
			_writer.Reset();
			_writer.Put((byte)4);
			_writer.Put(night);
			SendToAllPeers();
			Plugin.Log.LogInfo((object)$"[Host] Sent night selection: {night}");
		}

		private void CheckSceneChange()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			string name = ((Scene)(ref activeScene)).name;
			if (!(name != _lastScene))
			{
				return;
			}
			Plugin.Log.LogInfo((object)("Scene changed: " + _lastScene + " -> " + name));
			_ = _lastScene;
			_lastScene = name;
			if (_steam.IsHost && !IsLoadingFromSync)
			{
				SendSceneChange(name);
			}
			_gorillaPlayer = null;
			_handControl = null;
			_mainCamera = null;
			_moveController = null;
			_ovrHead = null;
			_ovrLeftHand = null;
			_ovrRightHand = null;
			_localFlashlight = null;
			_localFlashlightControl = null;
			_tvVideoPlayer = null;
			_paintingControl = null;
			_sparky = null;
			_jeff = null;
			_smile = null;
			_henry = null;
			_harold = null;
			_clown = null;
			_puzzleMaster = null;
			_puzzleInitSent = false;
			_puzzleInitStartWaited = false;
			_puzzleInitApplied = false;
			_puzzleInitReapplyTimer = 0f;
			_puzzleInitCompletedStates = null;
			_puzzleInitActiveStates = null;
			_completedPuzzleIDs.Clear();
			_leaveDoor = null;
			_lastDoorLeaveTimer = 0;
			_exitDoorFullyCharged = false;
			_crankControl = null;
			_lastCrankCharge = -1f;
			_lastCrankHasBattery = false;
			if (_steam == null || !_steam.IsRunning || _connectedPeerIds.Count <= 0)
			{
				return;
			}
			foreach (RemotePlayer value in _remotePlayers.Values)
			{
				value.Destroy();
			}
			_remotePlayers.Clear();
			_remoteBatteryStates.Clear();
			ClearAllLocks();
			_recreateRemotePlayersNextFrame = true;
		}

		private bool AnyRemotePlayerValid()
		{
			foreach (RemotePlayer value in _remotePlayers.Values)
			{
				if ((Object)(object)value.Head != (Object)null)
				{
					return true;
				}
			}
			return false;
		}

		private void ClearRemotePlayers()
		{
			foreach (RemotePlayer value in _remotePlayers.Values)
			{
				value.Destroy();
			}
			_remotePlayers.Clear();
		}

		private void RecreateRemotePlayers()
		{
			if (_steam == null || _steam == null)
			{
				return;
			}
			foreach (int connectedPeerId in _connectedPeerIds)
			{
				if (!_remotePlayers.ContainsKey(connectedPeerId))
				{
					RemotePlayer value = new RemotePlayer(connectedPeerId);
					_remotePlayers[connectedPeerId] = value;
				}
				else
				{
					_remotePlayers[connectedPeerId].TryUpgradeVisuals();
				}
			}
			Plugin.Log.LogInfo((object)$"Remote players recreated: {_remotePlayers.Count}");
		}

		public void SendSceneChange(string sceneName)
		{
			_writer.Reset();
			_writer.Put((byte)3);
			_writer.Put(sceneName);
			_writer.Put(calenderControl.nightSelected);
			SendToAllPeers();
			Plugin.Log.LogInfo((object)$"Sent scene change: {sceneName}, night={calenderControl.nightSelected}");
		}

		private void CheckFlashlightState()
		{
			bool flag = false;
			bool flag2 = false;
			if ((Object)(object)_localFlashlightControl == (Object)null)
			{
				_localFlashlightControl = Object.FindObjectOfType<FlashlightControl>();
			}
			if ((Object)(object)_localFlashlightControl != (Object)null && (Object)(object)_localFlashlightControl.flashlight != (Object)null)
			{
				flag = _localFlashlightControl.flashlight.activeSelf;
				flag2 = true;
			}
			if (!flag2)
			{
				if ((Object)(object)_localFlashlight == (Object)null)
				{
					_localFlashlight = Object.FindObjectOfType<Flashlight>();
				}
				if ((Object)(object)_localFlashlight != (Object)null && (Object)(object)_localFlashlight.spotlight != (Object)null)
				{
					flag = ((Behaviour)_localFlashlight.spotlight).enabled;
					flag2 = true;
				}
			}
			if (flag2 && flag != _lastFlashlightState)
			{
				_lastFlashlightState = flag;
				SendFlashlightState(flag);
			}
		}

		private void SendFlashlightState(bool isOn)
		{
			_writer.Reset();
			_writer.Put((byte)2);
			_writer.Put(isOn);
			SendToAllPeers();
		}

		private void CaptureHandPoses(ref float leftGrip, ref float leftTrigger, ref float rightGrip, ref float rightTrigger)
		{
			//IL_0027: 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_0041: 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_006e: 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_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)
			BackpackControl val = Object.FindObjectOfType<BackpackControl>();
			if (!((Object)(object)val != (Object)null))
			{
				return;
			}
			InputActionProperty val2;
			if ((Object)(object)val.controllerLeft != (Object)null)
			{
				try
				{
					val2 = val.controllerLeft.selectActionValue;
					leftGrip = ((InputActionProperty)(ref val2)).action.ReadValue<float>();
					val2 = val.controllerLeft.uiPressActionValue;
					leftTrigger = ((InputActionProperty)(ref val2)).action.ReadValue<float>();
				}
				catch (Exception)
				{
				}
			}
			if ((Object)(object)val.controllerRight != (Object)null)
			{
				try
				{
					val2 = val.controllerRight.selectActionValue;
					rightGrip = ((InputActionProperty)(ref val2)).action.ReadValue<float>();
					val2 = val.controllerRight.uiPressActionValue;
					rightTrigger = ((InputActionProperty)(ref val2)).action.ReadValue<float>();
				}
				catch (Exception)
				{
				}
			}
		}

		private void SendPositionUpdate()
		{
			//IL_0081: 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_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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: 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_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: 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_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: 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_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: 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_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: 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_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			_writer.Reset();
			_writer.Put((byte)1);
			bool value = (Object)(object)_moveController != (Object)null && _moveController.debugSwitch;
			_sendCount++;
			string text = "none";
			Vector3 position;
			Quaternion rotation;
			Vector3 v;
			Quaternion q;
			Vector3 v2;
			Quaternion q2;
			if ((Object)(object)_ovrHead != (Object)null && (Object)(object)_ovrLeftHand != (Object)null && (Object)(object)_ovrRightHand != (Object)null)
			{
				text = "OVR/BackpackControl";
				position = _ovrHead.position;
				rotation = _ovrHead.rotation;
				v = _ovrLeftHand.position;
				q = _ovrLeftHand.rotation;
				v2 = _ovrRightHand.position;
				q2 = _ovrRightHand.rotation;
			}
			else if ((Object)(object)_gorillaPlayer != (Object)null && (Object)(object)_gorillaPlayer.leftHandTransform != (Object)null && (Object)(object)_gorillaPlayer.rightHandTransform != (Object)null)
			{
				text = "GorillaPlayer";
				position = ((Component)_gorillaPlayer.headCollider).transform.position;
				rotation = ((Component)_gorillaPlayer.headCollider).transform.rotation;
				v = _gorillaPlayer.leftHandTransform.position;
				q = _gorillaPlayer.leftHandTransform.rotation;
				v2 = _gorillaPlayer.rightHandTransform.position;
				q2 = _gorillaPlayer.rightHandTransform.rotation;
			}
			else if ((Object)(object)_handControl != (Object)null && (Object)(object)_handControl.LTarget != (Object)null && (Object)(object)_handControl.RTarget != (Object)null)
			{
				text = "HandControl";
				position = _handControl.Head.transform.position;
				rotation = _handControl.Head.transform.rotation;
				v = _handControl.LTarget.transform.position;
				q = _handControl.LTarget.transform.rotation;
				v2 = _handControl.RTarget.transform.position;
				q2 = _handControl.RTarget.transform.rotation;
			}
			else
			{
				if (!((Object)(object)_mainCamera != (Object)null))
				{
					return;
				}
				text = "MainCamera-NoHands";
				position = ((Component)_mainCamera).transform.position;
				rotation = ((Component)_mainCamera).transform.rotation;
				v = position + ((Component)_mainCamera).transform.right * -0.3f + ((Component)_mainCamera).transform.forward * 0.2f;
				q = rotation;
				v2 = position + ((Component)_mainCamera).transform.right * 0.3f + ((Component)_mainCamera).transform.forward * 0.2f;
				q2 = rotation;
			}
			Vector3 v3 = position - Vector3.up * 0.5f;
			Quaternion q3 = Quaternion.Euler(0f, ((Quaternion)(ref rotation)).eulerAngles.y, 0f);
			float leftGrip = 0f;
			float leftTrigger = 0f;
			float rightGrip = 0f;
			float rightTrigger = 0f;
			CaptureHandPoses(ref leftGrip, ref leftTrigger, ref rightGrip, ref rightTrigger);
			_writer.Put(value);
			WriteVector3(_writer, v3);
			WriteQuaternion(_writer, q3);
			WriteVector3(_writer, position);
			WriteQuaternion(_writer, rotation);
			WriteVector3(_writer, v);
			WriteQuaternion(_writer, q);
			WriteVector3(_writer, v2);
			WriteQuaternion(_writer, q2);
			_writer.Put(leftGrip);
			_writer.Put(leftTrigger);
			_writer.Put(rightGrip);
			_writer.Put(rightTrigger);
			if (_sendCount % 100 == 1)
			{
				Plugin.LogDebug("[Send] src=" + text);
			}
			SendToAllPeers(reliable: false);
		}

		private void WriteVector3(PacketWriter writer, Vector3 v)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			writer.Put(v.x);
			writer.Put(v.y);
			writer.Put(v.z);
		}

		private void WriteQuaternion(PacketWriter writer, Quaternion q)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			writer.Put(q.x);
			writer.Put(q.y);
			writer.Put(q.z);
			writer.Put(q.w);
		}

		private Vector3 ReadVector3(PacketReader reader)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(reader.GetFloat(), reader.GetFloat(), reader.GetFloat());
		}

		private Quaternion ReadQuaternion(PacketReader reader)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			return new Quaternion(reader.GetFloat(), reader.GetFloat(), reader.GetFloat(), reader.GetFloat());
		}

		private void SendInteractionLock(string interactionId, bool locked)
		{
			if (_steam != null && _steam.IsRunning)
			{
				_writer.Reset();
				_writer.Put((byte)17);
				_writer.Put(interactionId);
				_writer.Put(locked);
				SendToAllPeers();
			}
		}

		private void TriggerClientFade()
		{
			try
			{
				Type type = Type.GetType("fadeControl, Assembly-CSharp");
				if (type == null)
				{
					Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
					for (int i = 0; i < assemblies.Length; i++)
					{
						type = assemblies[i].GetType("fadeControl");
						if (type != null)
						{
							break;
						}
					}
				}
				if (!(type != null))
				{
					return;
				}
				Object val = Object.FindObjectOfType(type);
				if (val != (Object)null)
				{
					MethodInfo method = type.GetMethod("fadeOut", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (method != null)
					{
						method.Invoke(val, null);
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("[Client] Could not trigger fade: " + ex.Message));
			}
		}

		private void HandleTvSync(PacketReader reader)
		{
			long @long = reader.GetLong();
			if (_steam.IsHost)
			{
				return;
			}
			if ((Object)(object)_tvVideoPlayer == (Object)null)
			{
				tvControl val = Object.FindObjectOfType<tvControl>();
				if ((Object)(object)val != (Object)null && (Object)(object)val.TVVP != (Object)null)
				{
					_tvVideoPlayer = val.TVVP;
				}
				else
				{
					MoviePlayerSample val2 = Object.FindObjectOfType<MoviePlayerSample>();
					if ((Object)(object)val2 != (Object)null)
					{
						_tvVideoPlayer = ((Component)val2).GetComponent<VideoPlayer>();
					}
				}
			}
			if ((Object)(object)_tvVideoPlayer != (Object)null && Math.Abs(_tvVideoPlayer.frame - @long) > 30)
			{
				_tvVideoPlayer.frame = @long;
			}
		}

		private void HandlePaintingSync(PacketReader reader)
		{
			if (_steam.IsHost)
			{
				return;
			}
			int @int = reader.GetInt();
			int int2 = reader.GetInt();
			int int3 = reader.GetInt();
			int int4 = reader.GetInt();
			int int5 = reader.GetInt();
			int int6 = reader.GetInt();
			if ((Object)(object)_paintingControl == (Object)null)
			{
				_paintingControl = Object.FindObjectOfType<paintingControl>();
			}
			if ((Object)(object)_paintingControl != (Object)null)
			{
				bool flag = false;
				if (_paintingControl.intpaintingTall1 != @int)
				{
					_paintingControl.intpaintingTall1 = @int;
					_paintingControl.setPaintingMatSquare(_paintingControl.paintingTall1, @int, false, true);
					flag = true;
				}
				if (_paintingControl.intpaintingTall2 != int2)
				{
					_paintingControl.intpaintingTall2 = int2;
					_paintingControl.setPaintingMatSquare(_paintingControl.paintingTall2, int2, false, true);
					flag = true;
				}
				if (_paintingControl.intpaintingTall3 != int3)
				{
					_paintingControl.intpaintingTall3 = int3;
					_paintingControl.setPaintingMatSquare(_paintingControl.paintingTall3, int3, false, true);
					flag = true;
				}
				if (_paintingControl.intpaintingSquare1 != int4)
				{
					_paintingControl.intpaintingSquare1 = int4;
					_paintingControl.setPaintingMatSquare(_paintingControl.paintingSquare1, int4, false, false);
					flag = true;
				}
				if (_paintingControl.intpaintingSquare2 != int5)
				{
					_paintingControl.intpaintingSquare2 = int5;
					_paintingControl.setPaintingMatSquare(_paintingControl.paintingSquare2, int5, false, false);
					flag = true;
				}
				if (_paintingControl.intpaintingSquare3 != int6)
				{
					_paintingControl.intpaintingSquare3 = int6;
					_paintingControl.setPaintingMatSquare(_paintingControl.paintingSquare3, int6, false, false);
					flag = true;
				}
				if (flag)
				{
					Plugin.LogDebug("[Client] Paintings synced from host");
				}
			}
		}

		public void SendPaintingFlash(int paintingId)
		{
			if (_steam != null && _steam.IsRunning)
			{
				_writer.Reset();
				_writer.Put((byte)7);
				_writer.Put(paintingId);
				SendToAllPeers();
			}
		}

		public void SendPaintingEntityState(paintingControl pc)
		{
			if (_steam != null && _steam.IsRunning && ShouldControlMonsters)
			{
				Type typeFromHandle = typeof(paintingControl);
				bool value = (bool)typeFromHandle.GetField("boolpaintingTall1", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(pc);
				bool value2 = (bool)typeFromHandle.GetField("boolpaintingTall2", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(pc);
				bool value3 = (bool)typeFromHandle.GetField("boolpaintingTall3", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(pc);
				bool value4 = (bool)typeFromHandle.GetField("boolpaintingSquare1", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(pc);
				bool value5 = (bool)typeFromHandle.GetField("boolpaintingSquare2", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(pc);
				bool value6 = (bool)typeFromHandle.GetField("boolpaintingSquare3", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(pc);
				_writer.Reset();
				_writer.Put((byte)11);
				_writer.Put(value);
				_writer.Put(value2);
				_writer.Put(value3);
				_writer.Put(value4);
				_writer.Put(value5);
				_writer.Put(value6);
				_writer.Put(pc.intpaintingTall1);
				_writer.Put(pc.intpaintingTall2);
				_writer.Put(pc.intpaintingTall3);
				_writer.Put(pc.intpaintingSquare1);
				_writer.Put(pc.intpaintingSquare2);
				_writer.Put(pc.intpaintingSquare3);
				SendToAllPeers();
			}
		}

		private void HandlePaintingEntity(PacketReader reader)
		{
			bool @bool = reader.GetBool();
			bool bool2 = reader.GetBool();
			bool bool3 = reader.GetBool();
			bool bool4 = reader.GetBool();
			bool bool5 = reader.GetBool();
			bool bool6 = reader.GetBool();
			int @int = reader.GetInt();
			int int2 = reader.GetInt();
			int int3 = reader.GetInt();
			int int4 = reader.GetInt();
			int int5 = reader.GetInt();
			int int6 = reader.GetInt();
			if ((Object)(object)_paintingControl == (Object)null)
			{
				_paintingControl = Object.FindObjectOfType<paintingControl>();
			}
			if ((Object)(object)_paintingControl != (Object)null)
			{
				Type typeFromHandle = typeof(paintingControl);
				typeFromHandle.GetField("boolpaintingTall1", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(_paintingControl, @bool);
				typeFromHandle.GetField("boolpaintingTall2", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(_paintingControl, bool2);
				typeFromHandle.GetField("boolpaintingTall3", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(_paintingControl, bool3);
				typeFromHandle.GetField("boolpaintingSquare1", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(_paintingControl, bool4);
				typeFromHandle.GetField("boolpaintingSquare2", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(_paintingControl, bool5);
				typeFromHandle.GetField("boolpaintingSquare3", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(_paintingControl, bool6);
				_paintingControl.setPaintingMatSquare(_paintingControl.paintingTall1, @int, @bool, true);
				_paintingControl.setPaintingMatSquare(_paintingControl.paintingTall2, int2, bool2, true);
				_paintingControl.setPaintingMatSquare(_paintingControl.paintingTall3, int3, bool3, true);
				_paintingControl.setPaintingMatSquare(_paintingControl.paintingSquare1, int4, bool4, false);
				_paintingControl.setPaintingMatSquare(_paintingControl.paintingSquare2, int5, bool5, false);
				_paintingControl.setPaintingMatSquare(_paintingControl.paintingSquare3, int6, bool6, false);
			}
		}

		public List<Vector3> GetRemotePlayerPositions()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list = new List<Vector3>();
			foreach (RemotePlayer value in _remotePlayers.Values)
			{
				if ((Object)(object)value.Head != (Object)null)
				{
					list.Add(value.Head.transform.position);
				}
			}
			return list;
		}

		public Vector3? GetRemotePlayerPosition(int peerId)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (_remotePlayers.TryGetValue(peerId, out var value) && (Object)(object)value.Head != (Object)null)
			{
				return value.Head.transform.position;
			}
			return null;
		}

		public List<Vector3> GetRemotePlayerPositionsNonGhost()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list = new List<Vector3>();
			foreach (RemotePlayer value in _remotePlayers.Values)
			{
				if ((Object)(object)value.Head != (Object)null && !value.IsGhost)
				{
					list.Add(value.Head.transform.position);
				}
			}
			return list;
		}

		private void CheckMonsterSync()
		{
			if (ShouldControlMonsters && !_localIsGhost && !(Time.time - _lastMonsterSyncTime < _monsterSyncInterval))
			{
				_lastMonsterSyncTime = Time.time;
				FindMonsters();
				CheckSyncedMonsterKills();
				SendMonsterSync();
			}
		}

		private void FindMonsters()
		{
			if ((Object)(object)_sparky == (Object)null)
			{
				_sparky = Object.FindObjectOfType<sparkyBrain>();
			}
			if ((Object)(object)_jeff == (Object)null)
			{
				_jeff = Object.FindObjectOfType<jeffBrain>();
			}
			if ((Object)(object)_smile == (Object)null)
			{
				_smile = Object.FindObjectOfType<SmileBrain>();
			}
			if ((Object)(object)_henry == (Object)null)
			{
				_henry = Object.FindObjectOfType<henryBrain>();
			}
			if ((Object)(object)_harold == (Object)null)
			{
				_harold = Object.FindObjectOfType<mapEnBrain>();
			}
			if ((Object)(object)_clown == (Object)null)
			{
				_clown = Object.FindObjectOfType<clownRandom>();
			}
		}

		private void SendMonsterSync()
		{
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: 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)
			_writer.Reset();
			_writer.Put((byte)8);
			bool flag = (Object)(object)_sparky != (Object)null;
			_writer.Put(flag);
			if (flag)
			{
				FieldInfo field = typeof(sparkyBrain).GetField("currentState", BindingFlags.Instance | BindingFlags.NonPublic);
				int value = ((!(field != null)) ? 1 : ((int)field.GetValue(_sparky)));
				_writer.Put(value);
			}
			bool flag2 = (Object)(object)_jeff != (Object)null;
			_writer.Put(flag2);
			if (flag2)
			{
				_writer.Put((Object)(object)_jeff.jeffBody != (Object)null && _jeff.jeffBody.activeSelf);
				FieldInfo field2 = typeof(jeffBrain).GetField("currentState", BindingFlags.Instance | BindingFlags.NonPublic);
				int value2 = ((!(field2 != null)) ? 1 : ((int)field2.GetValue(_jeff)));
				_writer.Put(value2);
				FieldInfo field3 = typeof(jeffBrain).GetField("totalFlashes", BindingFlags.Instance | BindingFlags.NonPublic);
				int value3 = ((field3 != null) ? ((int)field3.GetValue(_jeff)) : 0);
				_writer.Put(value3);
			}
			_writer.Put(value: false);
			bool flag3 = (Object)(object)_henry != (Object)null;
			_writer.Put(flag3);
			if (flag3)
			{
				WriteVector3(_writer, ((Component)_henry).transform.position);
				WriteQuaternion(_writer, ((Component)_henry).transform.rotation);
				FieldInfo field4 = typeof(henryBrain).GetField("resetSwitch", BindingFlags.Instance | BindingFlags.NonPublic);
				bool value4 = field4 != null && (bool)field4.GetValue(_henry);
				_writer.Put(value4);
				FieldInfo field5 = typeof(henryBrain).GetField("chaseSwitch", BindingFlags.Instance | BindingFlags.NonPublic);
				bool value5 = field5 != null && (bool)field5.GetValue(_henry);
				_writer.Put(value5);
			}
			bool flag4 = (Object)(object)_harold != (Object)null;
			_writer.Put(flag4);
			if (flag4)
			{
				WriteVector3(_writer, ((Component)_harold).transform.position);
				WriteQuaternion(_writer, ((Component)_harold).transform.rotation);
			}
			bool flag5 = (Object)(object)_clown != (Object)null;
			_writer.Put(flag5);
			if (flag5)
			{
				int value6 = -1;
				if ((Object)(object)_clown.clown1 != (Object)null && _clown.clown1.activeSelf)
				{
					value6 = 0;
				}
				else if ((Object)(object)_clown.clown2 != (Object)null && _clown.clown2.activeSelf)
				{
					value6 = 1;
				}
				else if ((Object)(object)_clown.clown3 != (Object)null && _clown.clown3.activeSelf)
				{
					value6 = 2;
				}
				else if ((Object)(object)_clown.clown4 != (Object)null && _clown.clown4.activeSelf)
				{
					value6 = 3;
				}
				else if ((Object)(object)_clown.clown5 != (Object)null && _clown.clown5.activeSelf)
				{
					value6 = 4;
				}
				else if ((Object)(object)_clown.clown6 != (Object)null && _clown.clown6.activeSelf)
				{
					value6 = 5;
				}
				else if ((Object)(object)_clown.clown7 != (Object)null && _clown.clown7.activeSelf)
				{
					value6 = 6;
				}
				_writer.Put(value6);
			}
			SendToAllPeers(reliable: false);
		}

		private void CheckSyncedMonsterKills()
		{
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			if (Time.time - _lastTargetedKillTime < 1f || _remotePlayers.Count == 0)
			{
				return;
			}
			if ((Object)(object)_henry != (Object)null)
			{
				FieldInfo field = typeof(henryBrain).GetField("resetSwitch", BindingFlags.Instance | BindingFlags.NonPublic);
				if (!(field != null) || !(bool)field.GetValue(_henry))
				{
					foreach (KeyValuePair<int, RemotePlayer> remotePlayer in _remotePlayers)
					{
						if (!remotePlayer.Value.IsGhost && !((Object)(object)remotePlayer.Value.Head == (Object)null))
						{
							float num = Vector3.Distance(remotePlayer.Value.Head.transform.position, ((Component)_henry).transform.position);
							if (num < 0.6f)
							{
								Plugin.Log.LogInfo((object)$"[Host] Henry near peer {remotePlayer.Key} (dist={num:F2}) - sending targeted kill");
								SendTargetedKillTo(remotePlayer.Key, 4);
								_lastTargetedKillTime = Time.time;
								return;
							}
						}
					}
				}
			}
			if (!((Object)(object)_harold != (Object)null))
			{
				return;
			}
			foreach (KeyValuePair<int, RemotePlayer> remotePlayer2 in _remotePlayers)
			{
				if (!remotePlayer2.Value.IsGhost && !((Object)(object)remotePlayer2.Value.Head == (Object)null))
				{
					float num2 = Vector3.Distance(remotePlayer2.Value.Head.transform.position, ((Component)_harold).transform.position);
					if (num2 < 0.6f)
					{
						Plugin.Log.LogInfo((object)$"[Host] Harold near peer {remotePlayer2.Key} (dist={num2:F2}) - sending targeted kill");
						SendTargetedKillTo(remotePlayer2.Key, 2);
						_lastTargetedKillTime = Time.time;
						break;
					}
				}
			}
		}

		private void SendTargetedKillTo(int peerId, int deathType)
		{
			if (_steam != null && _steam.IsRunning)
			{
				_writer.Reset();
				_writer.Put((byte)42);
				_writer.Put(deathType);
				byte[] bytes = _writer.GetBytes();
				_steam.SendTo(peerId, bytes);
			}
		}

		private void HandleTargetedKill(PacketReader reader)
		{
			int @int = reader.GetInt();
			if (_localIsGhost)
			{
				return;
			}
			Plugin.Log.LogInfo((object)$"[Client] Received targeted kill from host: deathType={@int}");
			jumpscareController val = Object.FindObjectOfType<jumpscareController>();
			if (!((Object)(object)val == (Object)null))
			{
				switch (@int)
				{
				case 2:
					val.onDeathHarold();
					break;
				case 4:
					val.onDeathHenry();
					break;
				}
			}
		}

		public void SendJeffFlash()
		{
			if (_steam != null && _steam.IsRunning)
			{
				_writer.Reset();
				_writer.Put((byte)9);
				SendToAllPeers();
			}
		}

		private void CheckBatterySync()
		{
			if (Time.time - _lastBatterySyncTime < _batterySyncInterval)
			{
				return;
			}
			_lastBatterySyncTime = Time.time;
			if (_localIsGhost)
			{
				return;
			}
			BackpackControl val = Object.FindObjectOfType<BackpackControl>();
			bool flag = false;
			bool flag2 = false;
			if ((Object)(object)val != (Object)null)
			{
				FieldInfo field = typeof(BackpackControl).GetField("leftHoldingBattery", BindingFlags.Instance | BindingFlags.NonPublic);
				FieldInfo field2 = typeof(BackpackControl).GetField("rightHoldingBattery", BindingFlags.Instance | BindingFlags.NonPublic);
				if (field != null)
				{
					flag = (bool)field.GetValue(val);
				}
				if (field2 != null)
				{
					flag2 = (bool)field2.GetValue(val);
				}
			}
			bool num = BackpackControl.batteryLocationID != _lastBatteryLocationID;
			bool flag3 = BackpackControl.batteryIsInBackpack != _lastBatteryInBackpack;
			bool flag4 = Mathf.Abs(BackpackControl.batteryCharge - _lastBatteryCharge) > 2f;
			bool flag5 = flag != _lastLeftHolding || flag2 != _lastRightHolding;
			if (num || flag3 || flag4 || flag5)
			{
				_lastBatteryLocationID = BackpackControl.batteryLocationID;
				_lastBatteryInBackpack = BackpackControl.batteryIsInBackpack;
				_lastBatteryCharge = BackpackControl.batteryCharge;
				_lastLeftHolding = flag;
				_lastRightHolding = flag2;
				SendBatterySync();
			}
		}

		private void SendBatterySync()
		{
			_writer.Reset();
			_writer.Put((byte)10);
			_writer.Put(BackpackControl.batteryCharge);
			_writer.Put(BackpackControl.batteryLocationID);
			_writer.Put(BackpackControl.batteryIsInBackpack);
			BackpackControl val = Object.FindObjectOfType<BackpackControl>();
			bool value = false;
			bool value2 = false;
			if ((Object)(object)val != (Object)null)
			{
				FieldInfo field = typeof(BackpackControl).GetField("leftHoldingBattery", BindingFlags.Instance | BindingFlags.NonPublic);
				FieldInfo field2 = typeof(BackpackControl).GetField("rightHoldingBattery", BindingFlags.Instance | BindingFlags.NonPublic);
				if (field != null)
				{
					value = (bool)field.GetValue(val);
				}
				if (field2 != null)
				{
				

BepInEx/plugins/Crawlspace2MP/Facepunch.Steamworks.Win64.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Steamworks.Data;
using Steamworks.Ugc;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("Garry Newman")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Facepunch.Steamworks.Win64")]
[assembly: AssemblyTitle("Facepunch.Steamworks.Win64")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
}
namespace Steamworks
{
	internal struct CallResult<T> : INotifyCompletion where T : struct, ICallbackData
	{
		private SteamAPICall_t call;

		private ISteamUtils utils;

		private bool server;

		public bool IsCompleted
		{
			get
			{
				bool pbFailed = false;
				if (utils.IsAPICallCompleted(call, ref pbFailed) || pbFailed)
				{
					return true;
				}
				return false;
			}
		}

		public CallResult(SteamAPICall_t call, bool server)
		{
			this.call = call;
			this.server = server;
			utils = (server ? SteamSharedClass<SteamUtils>.InterfaceServer : SteamSharedClass<SteamUtils>.InterfaceClient) as ISteamUtils;
			if (utils == null)
			{
				utils = SteamSharedClass<SteamUtils>.Interface as ISteamUtils;
			}
		}

		public void OnCompleted(Action continuation)
		{
			Dispatch.OnCallComplete<T>(call, continuation, server);
		}

		public T? GetResult()
		{
			bool pbFailed = false;
			if (!utils.IsAPICallCompleted(call, ref pbFailed) || pbFailed)
			{
				return null;
			}
			T val = default(T);
			int dataSize = val.DataSize;
			IntPtr intPtr = Marshal.AllocHGlobal(dataSize);
			try
			{
				if (!utils.GetAPICallResult(call, intPtr, dataSize, (int)val.CallbackType, ref pbFailed) || pbFailed)
				{
					Dispatch.OnDebugCallback?.Invoke(val.CallbackType, "!GetAPICallResult or failed", server);
					return null;
				}
				Dispatch.OnDebugCallback?.Invoke(val.CallbackType, Dispatch.CallbackToString(val.CallbackType, intPtr, dataSize), server);
				return (T)Marshal.PtrToStructure(intPtr, typeof(T));
			}
			finally
			{
				Marshal.FreeHGlobal(intPtr);
			}
		}

		internal CallResult<T> GetAwaiter()
		{
			return this;
		}
	}
	internal interface ICallbackData
	{
		CallbackType CallbackType { get; }

		int DataSize { get; }
	}
	public class AuthTicket : IDisposable
	{
		public byte[] Data;

		public uint Handle;

		public void Cancel()
		{
			if (Handle != 0)
			{
				SteamUser.Internal.CancelAuthTicket(Handle);
			}
			Handle = 0u;
			Data = null;
		}

		public void Dispose()
		{
			Cancel();
		}
	}
	public static class Dispatch
	{
		[StructLayout(LayoutKind.Sequential, Pack = 8)]
		internal struct CallbackMsg_t
		{
			public HSteamUser m_hSteamUser;

			public CallbackType Type;

			public IntPtr Data;

			public int DataSize;
		}

		private struct ResultCallback
		{
			public Action continuation;

			public bool server;
		}

		private struct Callback
		{
			public Action<IntPtr> action;

			public bool server;
		}

		public static Action<CallbackType, string, bool> OnDebugCallback;

		public static Action<Exception> OnException;

		private static bool runningFrame = false;

		private static List<Action<IntPtr>> actionsToCall = new List<Action<IntPtr>>();

		private static Dictionary<ulong, ResultCallback> ResultCallbacks = new Dictionary<ulong, ResultCallback>();

		private static Dictionary<CallbackType, List<Callback>> Callbacks = new Dictionary<CallbackType, List<Callback>>();

		internal static HSteamPipe ClientPipe { get; set; }

		internal static HSteamPipe ServerPipe { get; set; }

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void SteamAPI_ManualDispatch_Init();

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void SteamAPI_ManualDispatch_RunFrame(HSteamPipe pipe);

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.I1)]
		internal static extern bool SteamAPI_ManualDispatch_GetNextCallback(HSteamPipe pipe, [In][Out] ref CallbackMsg_t msg);

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.I1)]
		internal static extern bool SteamAPI_ManualDispatch_FreeLastCallback(HSteamPipe pipe);

		internal static void Init()
		{
			SteamAPI_ManualDispatch_Init();
		}

		internal static void Frame(HSteamPipe pipe)
		{
			if (runningFrame)
			{
				return;
			}
			try
			{
				runningFrame = true;
				SteamAPI_ManualDispatch_RunFrame(pipe);
				SteamNetworkingUtils.OutputDebugMessages();
				CallbackMsg_t msg = default(CallbackMsg_t);
				while (SteamAPI_ManualDispatch_GetNextCallback(pipe, ref msg))
				{
					try
					{
						ProcessCallback(msg, pipe == ServerPipe);
					}
					finally
					{
						SteamAPI_ManualDispatch_FreeLastCallback(pipe);
					}
				}
			}
			catch (Exception obj)
			{
				OnException?.Invoke(obj);
			}
			finally
			{
				runningFrame = false;
			}
		}

		private static void ProcessCallback(CallbackMsg_t msg, bool isServer)
		{
			OnDebugCallback?.Invoke(msg.Type, CallbackToString(msg.Type, msg.Data, msg.DataSize), isServer);
			if (msg.Type == CallbackType.SteamAPICallCompleted)
			{
				ProcessResult(msg);
			}
			else
			{
				if (!Callbacks.TryGetValue(msg.Type, out var value))
				{
					return;
				}
				actionsToCall.Clear();
				foreach (Callback item in value)
				{
					if (item.server == isServer)
					{
						actionsToCall.Add(item.action);
					}
				}
				foreach (Action<IntPtr> item2 in actionsToCall)
				{
					item2(msg.Data);
				}
				actionsToCall.Clear();
			}
		}

		internal static string CallbackToString(CallbackType type, IntPtr data, int expectedsize)
		{
			if (!CallbackTypeFactory.All.TryGetValue(type, out var value))
			{
				return $"[{type} not in sdk]";
			}
			object obj = data.ToType(value);
			if (obj == null)
			{
				return "[null]";
			}
			string text = "";
			FieldInfo[] fields = value.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (fields.Length == 0)
			{
				return "[no fields]";
			}
			int num = fields.Max((FieldInfo x) => x.Name.Length) + 1;
			if (num < 10)
			{
				num = 10;
			}
			FieldInfo[] array = fields;
			foreach (FieldInfo fieldInfo in array)
			{
				int num2 = num - fieldInfo.Name.Length;
				if (num2 < 0)
				{
					num2 = 0;
				}
				text += $"{new string(' ', num2)}{fieldInfo.Name}: {fieldInfo.GetValue(obj)}\n";
			}
			return text.Trim(new char[1] { '\n' });
		}

		private static void ProcessResult(CallbackMsg_t msg)
		{
			SteamAPICallCompleted_t steamAPICallCompleted_t = msg.Data.ToType<SteamAPICallCompleted_t>();
			if (!ResultCallbacks.TryGetValue(steamAPICallCompleted_t.AsyncCall, out var value))
			{
				OnDebugCallback?.Invoke((CallbackType)steamAPICallCompleted_t.Callback, "[no callback waiting/required]", arg3: false);
				return;
			}
			ResultCallbacks.Remove(steamAPICallCompleted_t.AsyncCall);
			value.continuation();
		}

		internal static async void LoopClientAsync()
		{
			while (ClientPipe != 0)
			{
				Frame(ClientPipe);
				await Task.Delay(16);
			}
		}

		internal static async void LoopServerAsync()
		{
			while (ServerPipe != 0)
			{
				Frame(ServerPipe);
				await Task.Delay(32);
			}
		}

		internal static void OnCallComplete<T>(SteamAPICall_t call, Action continuation, bool server) where T : struct, ICallbackData
		{
			ResultCallbacks[call.Value] = new ResultCallback
			{
				continuation = continuation,
				server = server
			};
		}

		internal static void Install<T>(Action<T> p, bool server = false) where T : ICallbackData
		{
			CallbackType callbackType = default(T).CallbackType;
			if (!Callbacks.TryGetValue(callbackType, out var value))
			{
				value = new List<Callback>();
				Callbacks[callbackType] = value;
			}
			value.Add(new Callback
			{
				action = delegate(IntPtr x)
				{
					p(x.ToType<T>());
				},
				server = server
			});
		}

		internal static void ShutdownServer()
		{
			ServerPipe = 0;
			foreach (KeyValuePair<CallbackType, List<Callback>> callback in Callbacks)
			{
				Callbacks[callback.Key].RemoveAll((Callback x) => x.server);
			}
			ResultCallbacks = ResultCallbacks.Where((KeyValuePair<ulong, ResultCallback> x) => !x.Value.server).ToDictionary((KeyValuePair<ulong, ResultCallback> x) => x.Key, (KeyValuePair<ulong, ResultCallback> x) => x.Value);
		}

		internal static void ShutdownClient()
		{
			ClientPipe = 0;
			foreach (KeyValuePair<CallbackType, List<Callback>> callback in Callbacks)
			{
				Callbacks[callback.Key].RemoveAll((Callback x) => !x.server);
			}
			ResultCallbacks = ResultCallbacks.Where((KeyValuePair<ulong, ResultCallback> x) => x.Value.server).ToDictionary((KeyValuePair<ulong, ResultCallback> x) => x.Key, (KeyValuePair<ulong, ResultCallback> x) => x.Value);
		}
	}
	internal static class SteamAPI
	{
		internal static class Native
		{
			[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl)]
			[return: MarshalAs(UnmanagedType.I1)]
			public static extern bool SteamAPI_Init();

			[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl)]
			public static extern void SteamAPI_Shutdown();

			[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl)]
			public static extern HSteamPipe SteamAPI_GetHSteamPipe();

			[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl)]
			[return: MarshalAs(UnmanagedType.I1)]
			public static extern bool SteamAPI_RestartAppIfNecessary(uint unOwnAppID);
		}

		internal static bool Init()
		{
			return Native.SteamAPI_Init();
		}

		internal static void Shutdown()
		{
			Native.SteamAPI_Shutdown();
		}

		internal static HSteamPipe GetHSteamPipe()
		{
			return Native.SteamAPI_GetHSteamPipe();
		}

		internal static bool RestartAppIfNecessary(uint unOwnAppID)
		{
			return Native.SteamAPI_RestartAppIfNecessary(unOwnAppID);
		}
	}
	internal static class SteamGameServer
	{
		internal static class Native
		{
			[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl)]
			public static extern void SteamGameServer_RunCallbacks();

			[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl)]
			public static extern void SteamGameServer_Shutdown();

			[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl)]
			public static extern HSteamPipe SteamGameServer_GetHSteamPipe();
		}

		internal static void RunCallbacks()
		{
			Native.SteamGameServer_RunCallbacks();
		}

		internal static void Shutdown()
		{
			Native.SteamGameServer_Shutdown();
		}

		internal static HSteamPipe GetHSteamPipe()
		{
			return Native.SteamGameServer_GetHSteamPipe();
		}
	}
	internal static class SteamInternal
	{
		internal static class Native
		{
			[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl)]
			[return: MarshalAs(UnmanagedType.I1)]
			public static extern bool SteamInternal_GameServer_Init(uint unIP, ushort usPort, ushort usGamePort, ushort usQueryPort, int eServerMode, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersionString);
		}

		internal static bool GameServer_Init(uint unIP, ushort usPort, ushort usGamePort, ushort usQueryPort, int eServerMode, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersionString)
		{
			return Native.SteamInternal_GameServer_Init(unIP, usPort, usGamePort, usQueryPort, eServerMode, pchVersionString);
		}
	}
	public enum CallbackType
	{
		SteamServersConnected = 101,
		SteamServerConnectFailure = 102,
		SteamServersDisconnected = 103,
		ClientGameServerDeny = 113,
		GSPolicyResponse = 115,
		IPCFailure = 117,
		LicensesUpdated = 125,
		ValidateAuthTicketResponse = 143,
		MicroTxnAuthorizationResponse = 152,
		EncryptedAppTicketResponse = 154,
		GetAuthSessionTicketResponse = 163,
		GameWebCallback = 164,
		StoreAuthURLResponse = 165,
		MarketEligibilityResponse = 166,
		DurationControl = 167,
		GSClientApprove = 201,
		GSClientDeny = 202,
		GSClientKick = 203,
		GSClientAchievementStatus = 206,
		GSGameplayStats = 207,
		GSClientGroupStatus = 208,
		GSReputation = 209,
		AssociateWithClanResult = 210,
		ComputeNewPlayerCompatibilityResult = 211,
		PersonaStateChange = 304,
		GameOverlayActivated = 331,
		GameServerChangeRequested = 332,
		GameLobbyJoinRequested = 333,
		AvatarImageLoaded = 334,
		ClanOfficerListResponse = 335,
		FriendRichPresenceUpdate = 336,
		GameRichPresenceJoinRequested = 337,
		GameConnectedClanChatMsg = 338,
		GameConnectedChatJoin = 339,
		GameConnectedChatLeave = 340,
		DownloadClanActivityCountsResult = 341,
		JoinClanChatRoomCompletionResult = 342,
		GameConnectedFriendChatMsg = 343,
		FriendsGetFollowerCount = 344,
		FriendsIsFollowing = 345,
		FriendsEnumerateFollowingList = 346,
		SetPersonaNameResponse = 347,
		UnreadChatMessagesChanged = 348,
		FavoritesListChanged = 502,
		LobbyInvite = 503,
		LobbyEnter = 504,
		LobbyDataUpdate = 505,
		LobbyChatUpdate = 506,
		LobbyChatMsg = 507,
		LobbyGameCreated = 509,
		LobbyMatchList = 510,
		LobbyKicked = 512,
		LobbyCreated = 513,
		PSNGameBootInviteResult = 515,
		FavoritesListAccountsUpdated = 516,
		IPCountry = 701,
		LowBatteryPower = 702,
		SteamAPICallCompleted = 703,
		SteamShutdown = 704,
		CheckFileSignature = 705,
		GamepadTextInputDismissed = 714,
		DlcInstalled = 1005,
		RegisterActivationCodeResponse = 1008,
		NewUrlLaunchParameters = 1014,
		AppProofOfPurchaseKeyResponse = 1021,
		FileDetailsResult = 1023,
		UserStatsReceived = 1101,
		UserStatsStored = 1102,
		UserAchievementStored = 1103,
		LeaderboardFindResult = 1104,
		LeaderboardScoresDownloaded = 1105,
		LeaderboardScoreUploaded = 1106,
		NumberOfCurrentPlayers = 1107,
		UserStatsUnloaded = 1108,
		GSStatsUnloaded = 1108,
		UserAchievementIconFetched = 1109,
		GlobalAchievementPercentagesReady = 1110,
		LeaderboardUGCSet = 1111,
		GlobalStatsReceived = 1112,
		P2PSessionRequest = 1202,
		P2PSessionConnectFail = 1203,
		SteamNetConnectionStatusChangedCallback = 1221,
		SteamNetAuthenticationStatus = 1222,
		SteamRelayNetworkStatus = 1281,
		RemoteStorageAppSyncedClient = 1301,
		RemoteStorageAppSyncedServer = 1302,
		RemoteStorageAppSyncProgress = 1303,
		RemoteStorageAppSyncStatusCheck = 1305,
		RemoteStorageFileShareResult = 1307,
		RemoteStoragePublishFileResult = 1309,
		RemoteStorageDeletePublishedFileResult = 1311,
		RemoteStorageEnumerateUserPublishedFilesResult = 1312,
		RemoteStorageSubscribePublishedFileResult = 1313,
		RemoteStorageEnumerateUserSubscribedFilesResult = 1314,
		RemoteStorageUnsubscribePublishedFileResult = 1315,
		RemoteStorageUpdatePublishedFileResult = 1316,
		RemoteStorageDownloadUGCResult = 1317,
		RemoteStorageGetPublishedFileDetailsResult = 1318,
		RemoteStorageEnumerateWorkshopFilesResult = 1319,
		RemoteStorageGetPublishedItemVoteDetailsResult = 1320,
		RemoteStoragePublishedFileSubscribed = 1321,
		RemoteStoragePublishedFileUnsubscribed = 1322,
		RemoteStoragePublishedFileDeleted = 1323,
		RemoteStorageUpdateUserPublishedItemVoteResult = 1324,
		RemoteStorageUserVoteDetails = 1325,
		RemoteStorageEnumerateUserSharedWorkshopFilesResult = 1326,
		RemoteStorageSetUserPublishedFileActionResult = 1327,
		RemoteStorageEnumeratePublishedFilesByUserActionResult = 1328,
		RemoteStoragePublishFileProgress = 1329,
		RemoteStoragePublishedFileUpdated = 1330,
		RemoteStorageFileWriteAsyncComplete = 1331,
		RemoteStorageFileReadAsyncComplete = 1332,
		GSStatsReceived = 1800,
		GSStatsStored = 1801,
		HTTPRequestCompleted = 2101,
		HTTPRequestHeadersReceived = 2102,
		HTTPRequestDataReceived = 2103,
		ScreenshotReady = 2301,
		ScreenshotRequested = 2302,
		SteamUGCQueryCompleted = 3401,
		SteamUGCRequestUGCDetailsResult = 3402,
		CreateItemResult = 3403,
		SubmitItemUpdateResult = 3404,
		ItemInstalled = 3405,
		DownloadItemResult = 3406,
		UserFavoriteItemsListChanged = 3407,
		SetUserItemVoteResult = 3408,
		GetUserItemVoteResult = 3409,
		StartPlaytimeTrackingResult = 3410,
		StopPlaytimeTrackingResult = 3411,
		AddUGCDependencyResult = 3412,
		RemoveUGCDependencyResult = 3413,
		AddAppDependencyResult = 3414,
		RemoveAppDependencyResult = 3415,
		GetAppDependenciesResult = 3416,
		DeleteItemResult = 3417,
		SteamAppInstalled = 3901,
		SteamAppUninstalled = 3902,
		PlaybackStatusHasChanged = 4001,
		VolumeHasChanged = 4002,
		MusicPlayerWantsVolume = 4011,
		MusicPlayerSelectsQueueEntry = 4012,
		MusicPlayerSelectsPlaylistEntry = 4013,
		MusicPlayerRemoteWillActivate = 4101,
		MusicPlayerRemoteWillDeactivate = 4102,
		MusicPlayerRemoteToFront = 4103,
		MusicPlayerWillQuit = 4104,
		MusicPlayerWantsPlay = 4105,
		MusicPlayerWantsPause = 4106,
		MusicPlayerWantsPlayPrevious = 4107,
		MusicPlayerWantsPlayNext = 4108,
		MusicPlayerWantsShuffled = 4109,
		MusicPlayerWantsLooped = 4110,
		MusicPlayerWantsPlayingRepeatStatus = 4114,
		HTML_BrowserReady = 4501,
		HTML_NeedsPaint = 4502,
		HTML_StartRequest = 4503,
		HTML_CloseBrowser = 4504,
		HTML_URLChanged = 4505,
		HTML_FinishedRequest = 4506,
		HTML_OpenLinkInNewTab = 4507,
		HTML_ChangedTitle = 4508,
		HTML_SearchResults = 4509,
		HTML_CanGoBackAndForward = 4510,
		HTML_HorizontalScroll = 4511,
		HTML_VerticalScroll = 4512,
		HTML_LinkAtPosition = 4513,
		HTML_JSAlert = 4514,
		HTML_JSConfirm = 4515,
		HTML_FileOpenDialog = 4516,
		HTML_NewWindow = 4521,
		HTML_SetCursor = 4522,
		HTML_StatusText = 4523,
		HTML_ShowToolTip = 4524,
		HTML_UpdateToolTip = 4525,
		HTML_HideToolTip = 4526,
		HTML_BrowserRestarted = 4527,
		BroadcastUploadStart = 4604,
		BroadcastUploadStop = 4605,
		GetVideoURLResult = 4611,
		GetOPFSettingsResult = 4624,
		SteamInventoryResultReady = 4700,
		SteamInventoryFullUpdate = 4701,
		SteamInventoryDefinitionUpdate = 4702,
		SteamInventoryEligiblePromoItemDefIDs = 4703,
		SteamInventoryStartPurchaseResult = 4704,
		SteamInventoryRequestPricesResult = 4705,
		SteamParentalSettingsChanged = 5001,
		SearchForGameProgressCallback = 5201,
		SearchForGameResultCallback = 5202,
		RequestPlayersForGameProgressCallback = 5211,
		RequestPlayersForGameResultCallback = 5212,
		RequestPlayersForGameFinalResultCallback = 5213,
		SubmitPlayerResultResultCallback = 5214,
		EndGameResultCallback = 5215,
		JoinPartyCallback = 5301,
		CreateBeaconCallback = 5302,
		ReservationNotificationCallback = 5303,
		ChangeNumOpenSlotsCallback = 5304,
		AvailableBeaconLocationsUpdated = 5305,
		ActiveBeaconsUpdated = 5306,
		SteamRemotePlaySessionConnected = 5701,
		SteamRemotePlaySessionDisconnected = 5702
	}
	internal static class CallbackTypeFactory
	{
		internal static Dictionary<CallbackType, Type> All = new Dictionary<CallbackType, Type>
		{
			{
				CallbackType.SteamServersConnected,
				typeof(SteamServersConnected_t)
			},
			{
				CallbackType.SteamServerConnectFailure,
				typeof(SteamServerConnectFailure_t)
			},
			{
				CallbackType.SteamServersDisconnected,
				typeof(SteamServersDisconnected_t)
			},
			{
				CallbackType.ClientGameServerDeny,
				typeof(ClientGameServerDeny_t)
			},
			{
				CallbackType.GSPolicyResponse,
				typeof(GSPolicyResponse_t)
			},
			{
				CallbackType.IPCFailure,
				typeof(IPCFailure_t)
			},
			{
				CallbackType.LicensesUpdated,
				typeof(LicensesUpdated_t)
			},
			{
				CallbackType.ValidateAuthTicketResponse,
				typeof(ValidateAuthTicketResponse_t)
			},
			{
				CallbackType.MicroTxnAuthorizationResponse,
				typeof(MicroTxnAuthorizationResponse_t)
			},
			{
				CallbackType.EncryptedAppTicketResponse,
				typeof(EncryptedAppTicketResponse_t)
			},
			{
				CallbackType.GetAuthSessionTicketResponse,
				typeof(GetAuthSessionTicketResponse_t)
			},
			{
				CallbackType.GameWebCallback,
				typeof(GameWebCallback_t)
			},
			{
				CallbackType.StoreAuthURLResponse,
				typeof(StoreAuthURLResponse_t)
			},
			{
				CallbackType.MarketEligibilityResponse,
				typeof(MarketEligibilityResponse_t)
			},
			{
				CallbackType.DurationControl,
				typeof(DurationControl_t)
			},
			{
				CallbackType.GSClientApprove,
				typeof(GSClientApprove_t)
			},
			{
				CallbackType.GSClientDeny,
				typeof(GSClientDeny_t)
			},
			{
				CallbackType.GSClientKick,
				typeof(GSClientKick_t)
			},
			{
				CallbackType.GSClientAchievementStatus,
				typeof(GSClientAchievementStatus_t)
			},
			{
				CallbackType.GSGameplayStats,
				typeof(GSGameplayStats_t)
			},
			{
				CallbackType.GSClientGroupStatus,
				typeof(GSClientGroupStatus_t)
			},
			{
				CallbackType.GSReputation,
				typeof(GSReputation_t)
			},
			{
				CallbackType.AssociateWithClanResult,
				typeof(AssociateWithClanResult_t)
			},
			{
				CallbackType.ComputeNewPlayerCompatibilityResult,
				typeof(ComputeNewPlayerCompatibilityResult_t)
			},
			{
				CallbackType.PersonaStateChange,
				typeof(PersonaStateChange_t)
			},
			{
				CallbackType.GameOverlayActivated,
				typeof(GameOverlayActivated_t)
			},
			{
				CallbackType.GameServerChangeRequested,
				typeof(GameServerChangeRequested_t)
			},
			{
				CallbackType.GameLobbyJoinRequested,
				typeof(GameLobbyJoinRequested_t)
			},
			{
				CallbackType.AvatarImageLoaded,
				typeof(AvatarImageLoaded_t)
			},
			{
				CallbackType.ClanOfficerListResponse,
				typeof(ClanOfficerListResponse_t)
			},
			{
				CallbackType.FriendRichPresenceUpdate,
				typeof(FriendRichPresenceUpdate_t)
			},
			{
				CallbackType.GameRichPresenceJoinRequested,
				typeof(GameRichPresenceJoinRequested_t)
			},
			{
				CallbackType.GameConnectedClanChatMsg,
				typeof(GameConnectedClanChatMsg_t)
			},
			{
				CallbackType.GameConnectedChatJoin,
				typeof(GameConnectedChatJoin_t)
			},
			{
				CallbackType.GameConnectedChatLeave,
				typeof(GameConnectedChatLeave_t)
			},
			{
				CallbackType.DownloadClanActivityCountsResult,
				typeof(DownloadClanActivityCountsResult_t)
			},
			{
				CallbackType.JoinClanChatRoomCompletionResult,
				typeof(JoinClanChatRoomCompletionResult_t)
			},
			{
				CallbackType.GameConnectedFriendChatMsg,
				typeof(GameConnectedFriendChatMsg_t)
			},
			{
				CallbackType.FriendsGetFollowerCount,
				typeof(FriendsGetFollowerCount_t)
			},
			{
				CallbackType.FriendsIsFollowing,
				typeof(FriendsIsFollowing_t)
			},
			{
				CallbackType.FriendsEnumerateFollowingList,
				typeof(FriendsEnumerateFollowingList_t)
			},
			{
				CallbackType.SetPersonaNameResponse,
				typeof(SetPersonaNameResponse_t)
			},
			{
				CallbackType.UnreadChatMessagesChanged,
				typeof(UnreadChatMessagesChanged_t)
			},
			{
				CallbackType.FavoritesListChanged,
				typeof(FavoritesListChanged_t)
			},
			{
				CallbackType.LobbyInvite,
				typeof(LobbyInvite_t)
			},
			{
				CallbackType.LobbyEnter,
				typeof(LobbyEnter_t)
			},
			{
				CallbackType.LobbyDataUpdate,
				typeof(LobbyDataUpdate_t)
			},
			{
				CallbackType.LobbyChatUpdate,
				typeof(LobbyChatUpdate_t)
			},
			{
				CallbackType.LobbyChatMsg,
				typeof(LobbyChatMsg_t)
			},
			{
				CallbackType.LobbyGameCreated,
				typeof(LobbyGameCreated_t)
			},
			{
				CallbackType.LobbyMatchList,
				typeof(LobbyMatchList_t)
			},
			{
				CallbackType.LobbyKicked,
				typeof(LobbyKicked_t)
			},
			{
				CallbackType.LobbyCreated,
				typeof(LobbyCreated_t)
			},
			{
				CallbackType.PSNGameBootInviteResult,
				typeof(PSNGameBootInviteResult_t)
			},
			{
				CallbackType.FavoritesListAccountsUpdated,
				typeof(FavoritesListAccountsUpdated_t)
			},
			{
				CallbackType.IPCountry,
				typeof(IPCountry_t)
			},
			{
				CallbackType.LowBatteryPower,
				typeof(LowBatteryPower_t)
			},
			{
				CallbackType.SteamAPICallCompleted,
				typeof(SteamAPICallCompleted_t)
			},
			{
				CallbackType.SteamShutdown,
				typeof(SteamShutdown_t)
			},
			{
				CallbackType.CheckFileSignature,
				typeof(CheckFileSignature_t)
			},
			{
				CallbackType.GamepadTextInputDismissed,
				typeof(GamepadTextInputDismissed_t)
			},
			{
				CallbackType.DlcInstalled,
				typeof(DlcInstalled_t)
			},
			{
				CallbackType.RegisterActivationCodeResponse,
				typeof(RegisterActivationCodeResponse_t)
			},
			{
				CallbackType.NewUrlLaunchParameters,
				typeof(NewUrlLaunchParameters_t)
			},
			{
				CallbackType.AppProofOfPurchaseKeyResponse,
				typeof(AppProofOfPurchaseKeyResponse_t)
			},
			{
				CallbackType.FileDetailsResult,
				typeof(FileDetailsResult_t)
			},
			{
				CallbackType.UserStatsReceived,
				typeof(UserStatsReceived_t)
			},
			{
				CallbackType.UserStatsStored,
				typeof(UserStatsStored_t)
			},
			{
				CallbackType.UserAchievementStored,
				typeof(UserAchievementStored_t)
			},
			{
				CallbackType.LeaderboardFindResult,
				typeof(LeaderboardFindResult_t)
			},
			{
				CallbackType.LeaderboardScoresDownloaded,
				typeof(LeaderboardScoresDownloaded_t)
			},
			{
				CallbackType.LeaderboardScoreUploaded,
				typeof(LeaderboardScoreUploaded_t)
			},
			{
				CallbackType.NumberOfCurrentPlayers,
				typeof(NumberOfCurrentPlayers_t)
			},
			{
				CallbackType.UserStatsUnloaded,
				typeof(UserStatsUnloaded_t)
			},
			{
				CallbackType.UserAchievementIconFetched,
				typeof(UserAchievementIconFetched_t)
			},
			{
				CallbackType.GlobalAchievementPercentagesReady,
				typeof(GlobalAchievementPercentagesReady_t)
			},
			{
				CallbackType.LeaderboardUGCSet,
				typeof(LeaderboardUGCSet_t)
			},
			{
				CallbackType.GlobalStatsReceived,
				typeof(GlobalStatsReceived_t)
			},
			{
				CallbackType.P2PSessionRequest,
				typeof(P2PSessionRequest_t)
			},
			{
				CallbackType.P2PSessionConnectFail,
				typeof(P2PSessionConnectFail_t)
			},
			{
				CallbackType.SteamNetConnectionStatusChangedCallback,
				typeof(SteamNetConnectionStatusChangedCallback_t)
			},
			{
				CallbackType.SteamNetAuthenticationStatus,
				typeof(SteamNetAuthenticationStatus_t)
			},
			{
				CallbackType.SteamRelayNetworkStatus,
				typeof(SteamRelayNetworkStatus_t)
			},
			{
				CallbackType.RemoteStorageAppSyncedClient,
				typeof(RemoteStorageAppSyncedClient_t)
			},
			{
				CallbackType.RemoteStorageAppSyncedServer,
				typeof(RemoteStorageAppSyncedServer_t)
			},
			{
				CallbackType.RemoteStorageAppSyncProgress,
				typeof(RemoteStorageAppSyncProgress_t)
			},
			{
				CallbackType.RemoteStorageAppSyncStatusCheck,
				typeof(RemoteStorageAppSyncStatusCheck_t)
			},
			{
				CallbackType.RemoteStorageFileShareResult,
				typeof(RemoteStorageFileShareResult_t)
			},
			{
				CallbackType.RemoteStoragePublishFileResult,
				typeof(RemoteStoragePublishFileResult_t)
			},
			{
				CallbackType.RemoteStorageDeletePublishedFileResult,
				typeof(RemoteStorageDeletePublishedFileResult_t)
			},
			{
				CallbackType.RemoteStorageEnumerateUserPublishedFilesResult,
				typeof(RemoteStorageEnumerateUserPublishedFilesResult_t)
			},
			{
				CallbackType.RemoteStorageSubscribePublishedFileResult,
				typeof(RemoteStorageSubscribePublishedFileResult_t)
			},
			{
				CallbackType.RemoteStorageEnumerateUserSubscribedFilesResult,
				typeof(RemoteStorageEnumerateUserSubscribedFilesResult_t)
			},
			{
				CallbackType.RemoteStorageUnsubscribePublishedFileResult,
				typeof(RemoteStorageUnsubscribePublishedFileResult_t)
			},
			{
				CallbackType.RemoteStorageUpdatePublishedFileResult,
				typeof(RemoteStorageUpdatePublishedFileResult_t)
			},
			{
				CallbackType.RemoteStorageDownloadUGCResult,
				typeof(RemoteStorageDownloadUGCResult_t)
			},
			{
				CallbackType.RemoteStorageGetPublishedFileDetailsResult,
				typeof(RemoteStorageGetPublishedFileDetailsResult_t)
			},
			{
				CallbackType.RemoteStorageEnumerateWorkshopFilesResult,
				typeof(RemoteStorageEnumerateWorkshopFilesResult_t)
			},
			{
				CallbackType.RemoteStorageGetPublishedItemVoteDetailsResult,
				typeof(RemoteStorageGetPublishedItemVoteDetailsResult_t)
			},
			{
				CallbackType.RemoteStoragePublishedFileSubscribed,
				typeof(RemoteStoragePublishedFileSubscribed_t)
			},
			{
				CallbackType.RemoteStoragePublishedFileUnsubscribed,
				typeof(RemoteStoragePublishedFileUnsubscribed_t)
			},
			{
				CallbackType.RemoteStoragePublishedFileDeleted,
				typeof(RemoteStoragePublishedFileDeleted_t)
			},
			{
				CallbackType.RemoteStorageUpdateUserPublishedItemVoteResult,
				typeof(RemoteStorageUpdateUserPublishedItemVoteResult_t)
			},
			{
				CallbackType.RemoteStorageUserVoteDetails,
				typeof(RemoteStorageUserVoteDetails_t)
			},
			{
				CallbackType.RemoteStorageEnumerateUserSharedWorkshopFilesResult,
				typeof(RemoteStorageEnumerateUserSharedWorkshopFilesResult_t)
			},
			{
				CallbackType.RemoteStorageSetUserPublishedFileActionResult,
				typeof(RemoteStorageSetUserPublishedFileActionResult_t)
			},
			{
				CallbackType.RemoteStorageEnumeratePublishedFilesByUserActionResult,
				typeof(RemoteStorageEnumeratePublishedFilesByUserActionResult_t)
			},
			{
				CallbackType.RemoteStoragePublishFileProgress,
				typeof(RemoteStoragePublishFileProgress_t)
			},
			{
				CallbackType.RemoteStoragePublishedFileUpdated,
				typeof(RemoteStoragePublishedFileUpdated_t)
			},
			{
				CallbackType.RemoteStorageFileWriteAsyncComplete,
				typeof(RemoteStorageFileWriteAsyncComplete_t)
			},
			{
				CallbackType.RemoteStorageFileReadAsyncComplete,
				typeof(RemoteStorageFileReadAsyncComplete_t)
			},
			{
				CallbackType.GSStatsReceived,
				typeof(GSStatsReceived_t)
			},
			{
				CallbackType.GSStatsStored,
				typeof(GSStatsStored_t)
			},
			{
				CallbackType.HTTPRequestCompleted,
				typeof(HTTPRequestCompleted_t)
			},
			{
				CallbackType.HTTPRequestHeadersReceived,
				typeof(HTTPRequestHeadersReceived_t)
			},
			{
				CallbackType.HTTPRequestDataReceived,
				typeof(HTTPRequestDataReceived_t)
			},
			{
				CallbackType.ScreenshotReady,
				typeof(ScreenshotReady_t)
			},
			{
				CallbackType.ScreenshotRequested,
				typeof(ScreenshotRequested_t)
			},
			{
				CallbackType.SteamUGCQueryCompleted,
				typeof(SteamUGCQueryCompleted_t)
			},
			{
				CallbackType.SteamUGCRequestUGCDetailsResult,
				typeof(SteamUGCRequestUGCDetailsResult_t)
			},
			{
				CallbackType.CreateItemResult,
				typeof(CreateItemResult_t)
			},
			{
				CallbackType.SubmitItemUpdateResult,
				typeof(SubmitItemUpdateResult_t)
			},
			{
				CallbackType.ItemInstalled,
				typeof(ItemInstalled_t)
			},
			{
				CallbackType.DownloadItemResult,
				typeof(DownloadItemResult_t)
			},
			{
				CallbackType.UserFavoriteItemsListChanged,
				typeof(UserFavoriteItemsListChanged_t)
			},
			{
				CallbackType.SetUserItemVoteResult,
				typeof(SetUserItemVoteResult_t)
			},
			{
				CallbackType.GetUserItemVoteResult,
				typeof(GetUserItemVoteResult_t)
			},
			{
				CallbackType.StartPlaytimeTrackingResult,
				typeof(StartPlaytimeTrackingResult_t)
			},
			{
				CallbackType.StopPlaytimeTrackingResult,
				typeof(StopPlaytimeTrackingResult_t)
			},
			{
				CallbackType.AddUGCDependencyResult,
				typeof(AddUGCDependencyResult_t)
			},
			{
				CallbackType.RemoveUGCDependencyResult,
				typeof(RemoveUGCDependencyResult_t)
			},
			{
				CallbackType.AddAppDependencyResult,
				typeof(AddAppDependencyResult_t)
			},
			{
				CallbackType.RemoveAppDependencyResult,
				typeof(RemoveAppDependencyResult_t)
			},
			{
				CallbackType.GetAppDependenciesResult,
				typeof(GetAppDependenciesResult_t)
			},
			{
				CallbackType.DeleteItemResult,
				typeof(DeleteItemResult_t)
			},
			{
				CallbackType.SteamAppInstalled,
				typeof(SteamAppInstalled_t)
			},
			{
				CallbackType.SteamAppUninstalled,
				typeof(SteamAppUninstalled_t)
			},
			{
				CallbackType.PlaybackStatusHasChanged,
				typeof(PlaybackStatusHasChanged_t)
			},
			{
				CallbackType.VolumeHasChanged,
				typeof(VolumeHasChanged_t)
			},
			{
				CallbackType.MusicPlayerWantsVolume,
				typeof(MusicPlayerWantsVolume_t)
			},
			{
				CallbackType.MusicPlayerSelectsQueueEntry,
				typeof(MusicPlayerSelectsQueueEntry_t)
			},
			{
				CallbackType.MusicPlayerSelectsPlaylistEntry,
				typeof(MusicPlayerSelectsPlaylistEntry_t)
			},
			{
				CallbackType.MusicPlayerRemoteWillActivate,
				typeof(MusicPlayerRemoteWillActivate_t)
			},
			{
				CallbackType.MusicPlayerRemoteWillDeactivate,
				typeof(MusicPlayerRemoteWillDeactivate_t)
			},
			{
				CallbackType.MusicPlayerRemoteToFront,
				typeof(MusicPlayerRemoteToFront_t)
			},
			{
				CallbackType.MusicPlayerWillQuit,
				typeof(MusicPlayerWillQuit_t)
			},
			{
				CallbackType.MusicPlayerWantsPlay,
				typeof(MusicPlayerWantsPlay_t)
			},
			{
				CallbackType.MusicPlayerWantsPause,
				typeof(MusicPlayerWantsPause_t)
			},
			{
				CallbackType.MusicPlayerWantsPlayPrevious,
				typeof(MusicPlayerWantsPlayPrevious_t)
			},
			{
				CallbackType.MusicPlayerWantsPlayNext,
				typeof(MusicPlayerWantsPlayNext_t)
			},
			{
				CallbackType.MusicPlayerWantsShuffled,
				typeof(MusicPlayerWantsShuffled_t)
			},
			{
				CallbackType.MusicPlayerWantsLooped,
				typeof(MusicPlayerWantsLooped_t)
			},
			{
				CallbackType.MusicPlayerWantsPlayingRepeatStatus,
				typeof(MusicPlayerWantsPlayingRepeatStatus_t)
			},
			{
				CallbackType.HTML_BrowserReady,
				typeof(HTML_BrowserReady_t)
			},
			{
				CallbackType.HTML_NeedsPaint,
				typeof(HTML_NeedsPaint_t)
			},
			{
				CallbackType.HTML_StartRequest,
				typeof(HTML_StartRequest_t)
			},
			{
				CallbackType.HTML_CloseBrowser,
				typeof(HTML_CloseBrowser_t)
			},
			{
				CallbackType.HTML_URLChanged,
				typeof(HTML_URLChanged_t)
			},
			{
				CallbackType.HTML_FinishedRequest,
				typeof(HTML_FinishedRequest_t)
			},
			{
				CallbackType.HTML_OpenLinkInNewTab,
				typeof(HTML_OpenLinkInNewTab_t)
			},
			{
				CallbackType.HTML_ChangedTitle,
				typeof(HTML_ChangedTitle_t)
			},
			{
				CallbackType.HTML_SearchResults,
				typeof(HTML_SearchResults_t)
			},
			{
				CallbackType.HTML_CanGoBackAndForward,
				typeof(HTML_CanGoBackAndForward_t)
			},
			{
				CallbackType.HTML_HorizontalScroll,
				typeof(HTML_HorizontalScroll_t)
			},
			{
				CallbackType.HTML_VerticalScroll,
				typeof(HTML_VerticalScroll_t)
			},
			{
				CallbackType.HTML_LinkAtPosition,
				typeof(HTML_LinkAtPosition_t)
			},
			{
				CallbackType.HTML_JSAlert,
				typeof(HTML_JSAlert_t)
			},
			{
				CallbackType.HTML_JSConfirm,
				typeof(HTML_JSConfirm_t)
			},
			{
				CallbackType.HTML_FileOpenDialog,
				typeof(HTML_FileOpenDialog_t)
			},
			{
				CallbackType.HTML_NewWindow,
				typeof(HTML_NewWindow_t)
			},
			{
				CallbackType.HTML_SetCursor,
				typeof(HTML_SetCursor_t)
			},
			{
				CallbackType.HTML_StatusText,
				typeof(HTML_StatusText_t)
			},
			{
				CallbackType.HTML_ShowToolTip,
				typeof(HTML_ShowToolTip_t)
			},
			{
				CallbackType.HTML_UpdateToolTip,
				typeof(HTML_UpdateToolTip_t)
			},
			{
				CallbackType.HTML_HideToolTip,
				typeof(HTML_HideToolTip_t)
			},
			{
				CallbackType.HTML_BrowserRestarted,
				typeof(HTML_BrowserRestarted_t)
			},
			{
				CallbackType.BroadcastUploadStart,
				typeof(BroadcastUploadStart_t)
			},
			{
				CallbackType.BroadcastUploadStop,
				typeof(BroadcastUploadStop_t)
			},
			{
				CallbackType.GetVideoURLResult,
				typeof(GetVideoURLResult_t)
			},
			{
				CallbackType.GetOPFSettingsResult,
				typeof(GetOPFSettingsResult_t)
			},
			{
				CallbackType.SteamInventoryResultReady,
				typeof(SteamInventoryResultReady_t)
			},
			{
				CallbackType.SteamInventoryFullUpdate,
				typeof(SteamInventoryFullUpdate_t)
			},
			{
				CallbackType.SteamInventoryDefinitionUpdate,
				typeof(SteamInventoryDefinitionUpdate_t)
			},
			{
				CallbackType.SteamInventoryEligiblePromoItemDefIDs,
				typeof(SteamInventoryEligiblePromoItemDefIDs_t)
			},
			{
				CallbackType.SteamInventoryStartPurchaseResult,
				typeof(SteamInventoryStartPurchaseResult_t)
			},
			{
				CallbackType.SteamInventoryRequestPricesResult,
				typeof(SteamInventoryRequestPricesResult_t)
			},
			{
				CallbackType.SteamParentalSettingsChanged,
				typeof(SteamParentalSettingsChanged_t)
			},
			{
				CallbackType.SearchForGameProgressCallback,
				typeof(SearchForGameProgressCallback_t)
			},
			{
				CallbackType.SearchForGameResultCallback,
				typeof(SearchForGameResultCallback_t)
			},
			{
				CallbackType.RequestPlayersForGameProgressCallback,
				typeof(RequestPlayersForGameProgressCallback_t)
			},
			{
				CallbackType.RequestPlayersForGameResultCallback,
				typeof(RequestPlayersForGameResultCallback_t)
			},
			{
				CallbackType.RequestPlayersForGameFinalResultCallback,
				typeof(RequestPlayersForGameFinalResultCallback_t)
			},
			{
				CallbackType.SubmitPlayerResultResultCallback,
				typeof(SubmitPlayerResultResultCallback_t)
			},
			{
				CallbackType.EndGameResultCallback,
				typeof(EndGameResultCallback_t)
			},
			{
				CallbackType.JoinPartyCallback,
				typeof(JoinPartyCallback_t)
			},
			{
				CallbackType.CreateBeaconCallback,
				typeof(CreateBeaconCallback_t)
			},
			{
				CallbackType.ReservationNotificationCallback,
				typeof(ReservationNotificationCallback_t)
			},
			{
				CallbackType.ChangeNumOpenSlotsCallback,
				typeof(ChangeNumOpenSlotsCallback_t)
			},
			{
				CallbackType.AvailableBeaconLocationsUpdated,
				typeof(AvailableBeaconLocationsUpdated_t)
			},
			{
				CallbackType.ActiveBeaconsUpdated,
				typeof(ActiveBeaconsUpdated_t)
			},
			{
				CallbackType.SteamRemotePlaySessionConnected,
				typeof(SteamRemotePlaySessionConnected_t)
			},
			{
				CallbackType.SteamRemotePlaySessionDisconnected,
				typeof(SteamRemotePlaySessionDisconnected_t)
			}
		};
	}
	internal class ISteamAppList : SteamInterface
	{
		internal ISteamAppList(bool IsGameServer)
		{
			SetupInterface(IsGameServer);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr SteamAPI_SteamAppList_v001();

		public override IntPtr GetUserInterfacePointer()
		{
			return SteamAPI_SteamAppList_v001();
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamAppList_GetNumInstalledApps")]
		private static extern uint _GetNumInstalledApps(IntPtr self);

		internal uint GetNumInstalledApps()
		{
			return _GetNumInstalledApps(Self);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamAppList_GetInstalledApps")]
		private static extern uint _GetInstalledApps(IntPtr self, [In][Out] AppId[] pvecAppID, uint unMaxAppIDs);

		internal uint GetInstalledApps([In][Out] AppId[] pvecAppID, uint unMaxAppIDs)
		{
			return _GetInstalledApps(Self, pvecAppID, unMaxAppIDs);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamAppList_GetAppName")]
		private static extern int _GetAppName(IntPtr self, AppId nAppID, IntPtr pchName, int cchNameMax);

		internal int GetAppName(AppId nAppID, out string pchName)
		{
			IntPtr intPtr = Helpers.TakeMemory();
			int result = _GetAppName(Self, nAppID, intPtr, 32768);
			pchName = Helpers.MemoryToString(intPtr);
			return result;
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamAppList_GetAppInstallDir")]
		private static extern int _GetAppInstallDir(IntPtr self, AppId nAppID, IntPtr pchDirectory, int cchNameMax);

		internal int GetAppInstallDir(AppId nAppID, out string pchDirectory)
		{
			IntPtr intPtr = Helpers.TakeMemory();
			int result = _GetAppInstallDir(Self, nAppID, intPtr, 32768);
			pchDirectory = Helpers.MemoryToString(intPtr);
			return result;
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamAppList_GetAppBuildId")]
		private static extern int _GetAppBuildId(IntPtr self, AppId nAppID);

		internal int GetAppBuildId(AppId nAppID)
		{
			return _GetAppBuildId(Self, nAppID);
		}
	}
	internal class ISteamApps : SteamInterface
	{
		internal ISteamApps(bool IsGameServer)
		{
			SetupInterface(IsGameServer);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr SteamAPI_SteamApps_v008();

		public override IntPtr GetUserInterfacePointer()
		{
			return SteamAPI_SteamApps_v008();
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr SteamAPI_SteamGameServerApps_v008();

		public override IntPtr GetServerInterfacePointer()
		{
			return SteamAPI_SteamGameServerApps_v008();
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_BIsSubscribed")]
		[return: MarshalAs(UnmanagedType.I1)]
		private static extern bool _BIsSubscribed(IntPtr self);

		internal bool BIsSubscribed()
		{
			return _BIsSubscribed(Self);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_BIsLowViolence")]
		[return: MarshalAs(UnmanagedType.I1)]
		private static extern bool _BIsLowViolence(IntPtr self);

		internal bool BIsLowViolence()
		{
			return _BIsLowViolence(Self);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_BIsCybercafe")]
		[return: MarshalAs(UnmanagedType.I1)]
		private static extern bool _BIsCybercafe(IntPtr self);

		internal bool BIsCybercafe()
		{
			return _BIsCybercafe(Self);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_BIsVACBanned")]
		[return: MarshalAs(UnmanagedType.I1)]
		private static extern bool _BIsVACBanned(IntPtr self);

		internal bool BIsVACBanned()
		{
			return _BIsVACBanned(Self);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_GetCurrentGameLanguage")]
		private static extern Utf8StringPointer _GetCurrentGameLanguage(IntPtr self);

		internal string GetCurrentGameLanguage()
		{
			Utf8StringPointer utf8StringPointer = _GetCurrentGameLanguage(Self);
			return utf8StringPointer;
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_GetAvailableGameLanguages")]
		private static extern Utf8StringPointer _GetAvailableGameLanguages(IntPtr self);

		internal string GetAvailableGameLanguages()
		{
			Utf8StringPointer utf8StringPointer = _GetAvailableGameLanguages(Self);
			return utf8StringPointer;
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_BIsSubscribedApp")]
		[return: MarshalAs(UnmanagedType.I1)]
		private static extern bool _BIsSubscribedApp(IntPtr self, AppId appID);

		internal bool BIsSubscribedApp(AppId appID)
		{
			return _BIsSubscribedApp(Self, appID);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_BIsDlcInstalled")]
		[return: MarshalAs(UnmanagedType.I1)]
		private static extern bool _BIsDlcInstalled(IntPtr self, AppId appID);

		internal bool BIsDlcInstalled(AppId appID)
		{
			return _BIsDlcInstalled(Self, appID);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_GetEarliestPurchaseUnixTime")]
		private static extern uint _GetEarliestPurchaseUnixTime(IntPtr self, AppId nAppID);

		internal uint GetEarliestPurchaseUnixTime(AppId nAppID)
		{
			return _GetEarliestPurchaseUnixTime(Self, nAppID);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_BIsSubscribedFromFreeWeekend")]
		[return: MarshalAs(UnmanagedType.I1)]
		private static extern bool _BIsSubscribedFromFreeWeekend(IntPtr self);

		internal bool BIsSubscribedFromFreeWeekend()
		{
			return _BIsSubscribedFromFreeWeekend(Self);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_GetDLCCount")]
		private static extern int _GetDLCCount(IntPtr self);

		internal int GetDLCCount()
		{
			return _GetDLCCount(Self);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_BGetDLCDataByIndex")]
		[return: MarshalAs(UnmanagedType.I1)]
		private static extern bool _BGetDLCDataByIndex(IntPtr self, int iDLC, ref AppId pAppID, [MarshalAs(UnmanagedType.U1)] ref bool pbAvailable, IntPtr pchName, int cchNameBufferSize);

		internal bool BGetDLCDataByIndex(int iDLC, ref AppId pAppID, [MarshalAs(UnmanagedType.U1)] ref bool pbAvailable, out string pchName)
		{
			IntPtr intPtr = Helpers.TakeMemory();
			bool result = _BGetDLCDataByIndex(Self, iDLC, ref pAppID, ref pbAvailable, intPtr, 32768);
			pchName = Helpers.MemoryToString(intPtr);
			return result;
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_InstallDLC")]
		private static extern void _InstallDLC(IntPtr self, AppId nAppID);

		internal void InstallDLC(AppId nAppID)
		{
			_InstallDLC(Self, nAppID);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_UninstallDLC")]
		private static extern void _UninstallDLC(IntPtr self, AppId nAppID);

		internal void UninstallDLC(AppId nAppID)
		{
			_UninstallDLC(Self, nAppID);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_RequestAppProofOfPurchaseKey")]
		private static extern void _RequestAppProofOfPurchaseKey(IntPtr self, AppId nAppID);

		internal void RequestAppProofOfPurchaseKey(AppId nAppID)
		{
			_RequestAppProofOfPurchaseKey(Self, nAppID);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_GetCurrentBetaName")]
		[return: MarshalAs(UnmanagedType.I1)]
		private static extern bool _GetCurrentBetaName(IntPtr self, IntPtr pchName, int cchNameBufferSize);

		internal bool GetCurrentBetaName(out string pchName)
		{
			IntPtr intPtr = Helpers.TakeMemory();
			bool result = _GetCurrentBetaName(Self, intPtr, 32768);
			pchName = Helpers.MemoryToString(intPtr);
			return result;
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_MarkContentCorrupt")]
		[return: MarshalAs(UnmanagedType.I1)]
		private static extern bool _MarkContentCorrupt(IntPtr self, [MarshalAs(UnmanagedType.U1)] bool bMissingFilesOnly);

		internal bool MarkContentCorrupt([MarshalAs(UnmanagedType.U1)] bool bMissingFilesOnly)
		{
			return _MarkContentCorrupt(Self, bMissingFilesOnly);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_GetInstalledDepots")]
		private static extern uint _GetInstalledDepots(IntPtr self, AppId appID, [In][Out] DepotId_t[] pvecDepots, uint cMaxDepots);

		internal uint GetInstalledDepots(AppId appID, [In][Out] DepotId_t[] pvecDepots, uint cMaxDepots)
		{
			return _GetInstalledDepots(Self, appID, pvecDepots, cMaxDepots);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_GetAppInstallDir")]
		private static extern uint _GetAppInstallDir(IntPtr self, AppId appID, IntPtr pchFolder, uint cchFolderBufferSize);

		internal uint GetAppInstallDir(AppId appID, out string pchFolder)
		{
			IntPtr intPtr = Helpers.TakeMemory();
			uint result = _GetAppInstallDir(Self, appID, intPtr, 32768u);
			pchFolder = Helpers.MemoryToString(intPtr);
			return result;
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_BIsAppInstalled")]
		[return: MarshalAs(UnmanagedType.I1)]
		private static extern bool _BIsAppInstalled(IntPtr self, AppId appID);

		internal bool BIsAppInstalled(AppId appID)
		{
			return _BIsAppInstalled(Self, appID);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_GetAppOwner")]
		private static extern SteamId _GetAppOwner(IntPtr self);

		internal SteamId GetAppOwner()
		{
			return _GetAppOwner(Self);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_GetLaunchQueryParam")]
		private static extern Utf8StringPointer _GetLaunchQueryParam(IntPtr self, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchKey);

		internal string GetLaunchQueryParam([MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchKey)
		{
			Utf8StringPointer utf8StringPointer = _GetLaunchQueryParam(Self, pchKey);
			return utf8StringPointer;
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_GetDlcDownloadProgress")]
		[return: MarshalAs(UnmanagedType.I1)]
		private static extern bool _GetDlcDownloadProgress(IntPtr self, AppId nAppID, ref ulong punBytesDownloaded, ref ulong punBytesTotal);

		internal bool GetDlcDownloadProgress(AppId nAppID, ref ulong punBytesDownloaded, ref ulong punBytesTotal)
		{
			return _GetDlcDownloadProgress(Self, nAppID, ref punBytesDownloaded, ref punBytesTotal);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_GetAppBuildId")]
		private static extern int _GetAppBuildId(IntPtr self);

		internal int GetAppBuildId()
		{
			return _GetAppBuildId(Self);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_RequestAllProofOfPurchaseKeys")]
		private static extern void _RequestAllProofOfPurchaseKeys(IntPtr self);

		internal void RequestAllProofOfPurchaseKeys()
		{
			_RequestAllProofOfPurchaseKeys(Self);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_GetFileDetails")]
		private static extern SteamAPICall_t _GetFileDetails(IntPtr self, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pszFileName);

		internal CallResult<FileDetailsResult_t> GetFileDetails([MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pszFileName)
		{
			SteamAPICall_t call = _GetFileDetails(Self, pszFileName);
			return new CallResult<FileDetailsResult_t>(call, base.IsServer);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_GetLaunchCommandLine")]
		private static extern int _GetLaunchCommandLine(IntPtr self, IntPtr pszCommandLine, int cubCommandLine);

		internal int GetLaunchCommandLine(out string pszCommandLine)
		{
			IntPtr intPtr = Helpers.TakeMemory();
			int result = _GetLaunchCommandLine(Self, intPtr, 32768);
			pszCommandLine = Helpers.MemoryToString(intPtr);
			return result;
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamApps_BIsSubscribedFromFamilySharing")]
		[return: MarshalAs(UnmanagedType.I1)]
		private static extern bool _BIsSubscribedFromFamilySharing(IntPtr self);

		internal bool BIsSubscribedFromFamilySharing()
		{
			return _BIsSubscribedFromFamilySharing(Self);
		}
	}
	internal class ISteamClient : SteamInterface
	{
		internal ISteamClient(bool IsGameServer)
		{
			SetupInterface(IsGameServer);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_CreateSteamPipe")]
		private static extern HSteamPipe _CreateSteamPipe(IntPtr self);

		internal HSteamPipe CreateSteamPipe()
		{
			return _CreateSteamPipe(Self);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_BReleaseSteamPipe")]
		[return: MarshalAs(UnmanagedType.I1)]
		private static extern bool _BReleaseSteamPipe(IntPtr self, HSteamPipe hSteamPipe);

		internal bool BReleaseSteamPipe(HSteamPipe hSteamPipe)
		{
			return _BReleaseSteamPipe(Self, hSteamPipe);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_ConnectToGlobalUser")]
		private static extern HSteamUser _ConnectToGlobalUser(IntPtr self, HSteamPipe hSteamPipe);

		internal HSteamUser ConnectToGlobalUser(HSteamPipe hSteamPipe)
		{
			return _ConnectToGlobalUser(Self, hSteamPipe);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_CreateLocalUser")]
		private static extern HSteamUser _CreateLocalUser(IntPtr self, ref HSteamPipe phSteamPipe, AccountType eAccountType);

		internal HSteamUser CreateLocalUser(ref HSteamPipe phSteamPipe, AccountType eAccountType)
		{
			return _CreateLocalUser(Self, ref phSteamPipe, eAccountType);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_ReleaseUser")]
		private static extern void _ReleaseUser(IntPtr self, HSteamPipe hSteamPipe, HSteamUser hUser);

		internal void ReleaseUser(HSteamPipe hSteamPipe, HSteamUser hUser)
		{
			_ReleaseUser(Self, hSteamPipe, hUser);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamUser")]
		private static extern IntPtr _GetISteamUser(IntPtr self, HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamUser(HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamUser(Self, hSteamUser, hSteamPipe, pchVersion);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamGameServer")]
		private static extern IntPtr _GetISteamGameServer(IntPtr self, HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamGameServer(HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamGameServer(Self, hSteamUser, hSteamPipe, pchVersion);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_SetLocalIPBinding")]
		private static extern void _SetLocalIPBinding(IntPtr self, ref SteamIPAddress unIP, ushort usPort);

		internal void SetLocalIPBinding(ref SteamIPAddress unIP, ushort usPort)
		{
			_SetLocalIPBinding(Self, ref unIP, usPort);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamFriends")]
		private static extern IntPtr _GetISteamFriends(IntPtr self, HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamFriends(HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamFriends(Self, hSteamUser, hSteamPipe, pchVersion);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamUtils")]
		private static extern IntPtr _GetISteamUtils(IntPtr self, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamUtils(HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamUtils(Self, hSteamPipe, pchVersion);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamMatchmaking")]
		private static extern IntPtr _GetISteamMatchmaking(IntPtr self, HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamMatchmaking(HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamMatchmaking(Self, hSteamUser, hSteamPipe, pchVersion);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamMatchmakingServers")]
		private static extern IntPtr _GetISteamMatchmakingServers(IntPtr self, HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamMatchmakingServers(HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamMatchmakingServers(Self, hSteamUser, hSteamPipe, pchVersion);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamGenericInterface")]
		private static extern IntPtr _GetISteamGenericInterface(IntPtr self, HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamGenericInterface(HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamGenericInterface(Self, hSteamUser, hSteamPipe, pchVersion);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamUserStats")]
		private static extern IntPtr _GetISteamUserStats(IntPtr self, HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamUserStats(HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamUserStats(Self, hSteamUser, hSteamPipe, pchVersion);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamGameServerStats")]
		private static extern IntPtr _GetISteamGameServerStats(IntPtr self, HSteamUser hSteamuser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamGameServerStats(HSteamUser hSteamuser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamGameServerStats(Self, hSteamuser, hSteamPipe, pchVersion);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamApps")]
		private static extern IntPtr _GetISteamApps(IntPtr self, HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamApps(HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamApps(Self, hSteamUser, hSteamPipe, pchVersion);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamNetworking")]
		private static extern IntPtr _GetISteamNetworking(IntPtr self, HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamNetworking(HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamNetworking(Self, hSteamUser, hSteamPipe, pchVersion);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamRemoteStorage")]
		private static extern IntPtr _GetISteamRemoteStorage(IntPtr self, HSteamUser hSteamuser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamRemoteStorage(HSteamUser hSteamuser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamRemoteStorage(Self, hSteamuser, hSteamPipe, pchVersion);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamScreenshots")]
		private static extern IntPtr _GetISteamScreenshots(IntPtr self, HSteamUser hSteamuser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamScreenshots(HSteamUser hSteamuser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamScreenshots(Self, hSteamuser, hSteamPipe, pchVersion);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamGameSearch")]
		private static extern IntPtr _GetISteamGameSearch(IntPtr self, HSteamUser hSteamuser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamGameSearch(HSteamUser hSteamuser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamGameSearch(Self, hSteamuser, hSteamPipe, pchVersion);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetIPCCallCount")]
		private static extern uint _GetIPCCallCount(IntPtr self);

		internal uint GetIPCCallCount()
		{
			return _GetIPCCallCount(Self);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_SetWarningMessageHook")]
		private static extern void _SetWarningMessageHook(IntPtr self, IntPtr pFunction);

		internal void SetWarningMessageHook(IntPtr pFunction)
		{
			_SetWarningMessageHook(Self, pFunction);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_BShutdownIfAllPipesClosed")]
		[return: MarshalAs(UnmanagedType.I1)]
		private static extern bool _BShutdownIfAllPipesClosed(IntPtr self);

		internal bool BShutdownIfAllPipesClosed()
		{
			return _BShutdownIfAllPipesClosed(Self);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamHTTP")]
		private static extern IntPtr _GetISteamHTTP(IntPtr self, HSteamUser hSteamuser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamHTTP(HSteamUser hSteamuser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamHTTP(Self, hSteamuser, hSteamPipe, pchVersion);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamController")]
		private static extern IntPtr _GetISteamController(IntPtr self, HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamController(HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamController(Self, hSteamUser, hSteamPipe, pchVersion);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamUGC")]
		private static extern IntPtr _GetISteamUGC(IntPtr self, HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamUGC(HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamUGC(Self, hSteamUser, hSteamPipe, pchVersion);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamAppList")]
		private static extern IntPtr _GetISteamAppList(IntPtr self, HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamAppList(HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamAppList(Self, hSteamUser, hSteamPipe, pchVersion);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamMusic")]
		private static extern IntPtr _GetISteamMusic(IntPtr self, HSteamUser hSteamuser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamMusic(HSteamUser hSteamuser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamMusic(Self, hSteamuser, hSteamPipe, pchVersion);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamMusicRemote")]
		private static extern IntPtr _GetISteamMusicRemote(IntPtr self, HSteamUser hSteamuser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamMusicRemote(HSteamUser hSteamuser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamMusicRemote(Self, hSteamuser, hSteamPipe, pchVersion);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamHTMLSurface")]
		private static extern IntPtr _GetISteamHTMLSurface(IntPtr self, HSteamUser hSteamuser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamHTMLSurface(HSteamUser hSteamuser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamHTMLSurface(Self, hSteamuser, hSteamPipe, pchVersion);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamInventory")]
		private static extern IntPtr _GetISteamInventory(IntPtr self, HSteamUser hSteamuser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamInventory(HSteamUser hSteamuser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamInventory(Self, hSteamuser, hSteamPipe, pchVersion);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamVideo")]
		private static extern IntPtr _GetISteamVideo(IntPtr self, HSteamUser hSteamuser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamVideo(HSteamUser hSteamuser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamVideo(Self, hSteamuser, hSteamPipe, pchVersion);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamParentalSettings")]
		private static extern IntPtr _GetISteamParentalSettings(IntPtr self, HSteamUser hSteamuser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamParentalSettings(HSteamUser hSteamuser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamParentalSettings(Self, hSteamuser, hSteamPipe, pchVersion);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamInput")]
		private static extern IntPtr _GetISteamInput(IntPtr self, HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamInput(HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamInput(Self, hSteamUser, hSteamPipe, pchVersion);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamParties")]
		private static extern IntPtr _GetISteamParties(IntPtr self, HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamParties(HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamParties(Self, hSteamUser, hSteamPipe, pchVersion);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamClient_GetISteamRemotePlay")]
		private static extern IntPtr _GetISteamRemotePlay(IntPtr self, HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion);

		internal IntPtr GetISteamRemotePlay(HSteamUser hSteamUser, HSteamPipe hSteamPipe, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchVersion)
		{
			return _GetISteamRemotePlay(Self, hSteamUser, hSteamPipe, pchVersion);
		}
	}
	internal class ISteamController : SteamInterface
	{
		internal ISteamController(bool IsGameServer)
		{
			SetupInterface(IsGameServer);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr SteamAPI_SteamController_v007();

		public override IntPtr GetUserInterfacePointer()
		{
			return SteamAPI_SteamController_v007();
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_Init")]
		[return: MarshalAs(UnmanagedType.I1)]
		private static extern bool _Init(IntPtr self);

		internal bool Init()
		{
			return _Init(Self);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_Shutdown")]
		[return: MarshalAs(UnmanagedType.I1)]
		private static extern bool _Shutdown(IntPtr self);

		internal bool Shutdown()
		{
			return _Shutdown(Self);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_RunFrame")]
		private static extern void _RunFrame(IntPtr self);

		internal void RunFrame()
		{
			_RunFrame(Self);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_GetConnectedControllers")]
		private static extern int _GetConnectedControllers(IntPtr self, [In][Out] ControllerHandle_t[] handlesOut);

		internal int GetConnectedControllers([In][Out] ControllerHandle_t[] handlesOut)
		{
			return _GetConnectedControllers(Self, handlesOut);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_GetActionSetHandle")]
		private static extern ControllerActionSetHandle_t _GetActionSetHandle(IntPtr self, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pszActionSetName);

		internal ControllerActionSetHandle_t GetActionSetHandle([MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pszActionSetName)
		{
			return _GetActionSetHandle(Self, pszActionSetName);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_ActivateActionSet")]
		private static extern void _ActivateActionSet(IntPtr self, ControllerHandle_t controllerHandle, ControllerActionSetHandle_t actionSetHandle);

		internal void ActivateActionSet(ControllerHandle_t controllerHandle, ControllerActionSetHandle_t actionSetHandle)
		{
			_ActivateActionSet(Self, controllerHandle, actionSetHandle);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_GetCurrentActionSet")]
		private static extern ControllerActionSetHandle_t _GetCurrentActionSet(IntPtr self, ControllerHandle_t controllerHandle);

		internal ControllerActionSetHandle_t GetCurrentActionSet(ControllerHandle_t controllerHandle)
		{
			return _GetCurrentActionSet(Self, controllerHandle);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_ActivateActionSetLayer")]
		private static extern void _ActivateActionSetLayer(IntPtr self, ControllerHandle_t controllerHandle, ControllerActionSetHandle_t actionSetLayerHandle);

		internal void ActivateActionSetLayer(ControllerHandle_t controllerHandle, ControllerActionSetHandle_t actionSetLayerHandle)
		{
			_ActivateActionSetLayer(Self, controllerHandle, actionSetLayerHandle);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_DeactivateActionSetLayer")]
		private static extern void _DeactivateActionSetLayer(IntPtr self, ControllerHandle_t controllerHandle, ControllerActionSetHandle_t actionSetLayerHandle);

		internal void DeactivateActionSetLayer(ControllerHandle_t controllerHandle, ControllerActionSetHandle_t actionSetLayerHandle)
		{
			_DeactivateActionSetLayer(Self, controllerHandle, actionSetLayerHandle);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_DeactivateAllActionSetLayers")]
		private static extern void _DeactivateAllActionSetLayers(IntPtr self, ControllerHandle_t controllerHandle);

		internal void DeactivateAllActionSetLayers(ControllerHandle_t controllerHandle)
		{
			_DeactivateAllActionSetLayers(Self, controllerHandle);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_GetActiveActionSetLayers")]
		private static extern int _GetActiveActionSetLayers(IntPtr self, ControllerHandle_t controllerHandle, [In][Out] ControllerActionSetHandle_t[] handlesOut);

		internal int GetActiveActionSetLayers(ControllerHandle_t controllerHandle, [In][Out] ControllerActionSetHandle_t[] handlesOut)
		{
			return _GetActiveActionSetLayers(Self, controllerHandle, handlesOut);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_GetDigitalActionHandle")]
		private static extern ControllerDigitalActionHandle_t _GetDigitalActionHandle(IntPtr self, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pszActionName);

		internal ControllerDigitalActionHandle_t GetDigitalActionHandle([MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pszActionName)
		{
			return _GetDigitalActionHandle(Self, pszActionName);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_GetDigitalActionData")]
		private static extern DigitalState _GetDigitalActionData(IntPtr self, ControllerHandle_t controllerHandle, ControllerDigitalActionHandle_t digitalActionHandle);

		internal DigitalState GetDigitalActionData(ControllerHandle_t controllerHandle, ControllerDigitalActionHandle_t digitalActionHandle)
		{
			return _GetDigitalActionData(Self, controllerHandle, digitalActionHandle);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_GetDigitalActionOrigins")]
		private static extern int _GetDigitalActionOrigins(IntPtr self, ControllerHandle_t controllerHandle, ControllerActionSetHandle_t actionSetHandle, ControllerDigitalActionHandle_t digitalActionHandle, ref ControllerActionOrigin originsOut);

		internal int GetDigitalActionOrigins(ControllerHandle_t controllerHandle, ControllerActionSetHandle_t actionSetHandle, ControllerDigitalActionHandle_t digitalActionHandle, ref ControllerActionOrigin originsOut)
		{
			return _GetDigitalActionOrigins(Self, controllerHandle, actionSetHandle, digitalActionHandle, ref originsOut);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_GetAnalogActionHandle")]
		private static extern ControllerAnalogActionHandle_t _GetAnalogActionHandle(IntPtr self, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pszActionName);

		internal ControllerAnalogActionHandle_t GetAnalogActionHandle([MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pszActionName)
		{
			return _GetAnalogActionHandle(Self, pszActionName);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_GetAnalogActionData")]
		private static extern AnalogState _GetAnalogActionData(IntPtr self, ControllerHandle_t controllerHandle, ControllerAnalogActionHandle_t analogActionHandle);

		internal AnalogState GetAnalogActionData(ControllerHandle_t controllerHandle, ControllerAnalogActionHandle_t analogActionHandle)
		{
			return _GetAnalogActionData(Self, controllerHandle, analogActionHandle);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_GetAnalogActionOrigins")]
		private static extern int _GetAnalogActionOrigins(IntPtr self, ControllerHandle_t controllerHandle, ControllerActionSetHandle_t actionSetHandle, ControllerAnalogActionHandle_t analogActionHandle, ref ControllerActionOrigin originsOut);

		internal int GetAnalogActionOrigins(ControllerHandle_t controllerHandle, ControllerActionSetHandle_t actionSetHandle, ControllerAnalogActionHandle_t analogActionHandle, ref ControllerActionOrigin originsOut)
		{
			return _GetAnalogActionOrigins(Self, controllerHandle, actionSetHandle, analogActionHandle, ref originsOut);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_GetGlyphForActionOrigin")]
		private static extern Utf8StringPointer _GetGlyphForActionOrigin(IntPtr self, ControllerActionOrigin eOrigin);

		internal string GetGlyphForActionOrigin(ControllerActionOrigin eOrigin)
		{
			Utf8StringPointer utf8StringPointer = _GetGlyphForActionOrigin(Self, eOrigin);
			return utf8StringPointer;
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_GetStringForActionOrigin")]
		private static extern Utf8StringPointer _GetStringForActionOrigin(IntPtr self, ControllerActionOrigin eOrigin);

		internal string GetStringForActionOrigin(ControllerActionOrigin eOrigin)
		{
			Utf8StringPointer utf8StringPointer = _GetStringForActionOrigin(Self, eOrigin);
			return utf8StringPointer;
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_StopAnalogActionMomentum")]
		private static extern void _StopAnalogActionMomentum(IntPtr self, ControllerHandle_t controllerHandle, ControllerAnalogActionHandle_t eAction);

		internal void StopAnalogActionMomentum(ControllerHandle_t controllerHandle, ControllerAnalogActionHandle_t eAction)
		{
			_StopAnalogActionMomentum(Self, controllerHandle, eAction);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_GetMotionData")]
		private static extern MotionState _GetMotionData(IntPtr self, ControllerHandle_t controllerHandle);

		internal MotionState GetMotionData(ControllerHandle_t controllerHandle)
		{
			return _GetMotionData(Self, controllerHandle);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_TriggerHapticPulse")]
		private static extern void _TriggerHapticPulse(IntPtr self, ControllerHandle_t controllerHandle, SteamControllerPad eTargetPad, ushort usDurationMicroSec);

		internal void TriggerHapticPulse(ControllerHandle_t controllerHandle, SteamControllerPad eTargetPad, ushort usDurationMicroSec)
		{
			_TriggerHapticPulse(Self, controllerHandle, eTargetPad, usDurationMicroSec);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_TriggerRepeatedHapticPulse")]
		private static extern void _TriggerRepeatedHapticPulse(IntPtr self, ControllerHandle_t controllerHandle, SteamControllerPad eTargetPad, ushort usDurationMicroSec, ushort usOffMicroSec, ushort unRepeat, uint nFlags);

		internal void TriggerRepeatedHapticPulse(ControllerHandle_t controllerHandle, SteamControllerPad eTargetPad, ushort usDurationMicroSec, ushort usOffMicroSec, ushort unRepeat, uint nFlags)
		{
			_TriggerRepeatedHapticPulse(Self, controllerHandle, eTargetPad, usDurationMicroSec, usOffMicroSec, unRepeat, nFlags);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_TriggerVibration")]
		private static extern void _TriggerVibration(IntPtr self, ControllerHandle_t controllerHandle, ushort usLeftSpeed, ushort usRightSpeed);

		internal void TriggerVibration(ControllerHandle_t controllerHandle, ushort usLeftSpeed, ushort usRightSpeed)
		{
			_TriggerVibration(Self, controllerHandle, usLeftSpeed, usRightSpeed);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_SetLEDColor")]
		private static extern void _SetLEDColor(IntPtr self, ControllerHandle_t controllerHandle, byte nColorR, byte nColorG, byte nColorB, uint nFlags);

		internal void SetLEDColor(ControllerHandle_t controllerHandle, byte nColorR, byte nColorG, byte nColorB, uint nFlags)
		{
			_SetLEDColor(Self, controllerHandle, nColorR, nColorG, nColorB, nFlags);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_ShowBindingPanel")]
		[return: MarshalAs(UnmanagedType.I1)]
		private static extern bool _ShowBindingPanel(IntPtr self, ControllerHandle_t controllerHandle);

		internal bool ShowBindingPanel(ControllerHandle_t controllerHandle)
		{
			return _ShowBindingPanel(Self, controllerHandle);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_GetInputTypeForHandle")]
		private static extern InputType _GetInputTypeForHandle(IntPtr self, ControllerHandle_t controllerHandle);

		internal InputType GetInputTypeForHandle(ControllerHandle_t controllerHandle)
		{
			return _GetInputTypeForHandle(Self, controllerHandle);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_GetControllerForGamepadIndex")]
		private static extern ControllerHandle_t _GetControllerForGamepadIndex(IntPtr self, int nIndex);

		internal ControllerHandle_t GetControllerForGamepadIndex(int nIndex)
		{
			return _GetControllerForGamepadIndex(Self, nIndex);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_GetGamepadIndexForController")]
		private static extern int _GetGamepadIndexForController(IntPtr self, ControllerHandle_t ulControllerHandle);

		internal int GetGamepadIndexForController(ControllerHandle_t ulControllerHandle)
		{
			return _GetGamepadIndexForController(Self, ulControllerHandle);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_GetStringForXboxOrigin")]
		private static extern Utf8StringPointer _GetStringForXboxOrigin(IntPtr self, XboxOrigin eOrigin);

		internal string GetStringForXboxOrigin(XboxOrigin eOrigin)
		{
			Utf8StringPointer utf8StringPointer = _GetStringForXboxOrigin(Self, eOrigin);
			return utf8StringPointer;
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_GetGlyphForXboxOrigin")]
		private static extern Utf8StringPointer _GetGlyphForXboxOrigin(IntPtr self, XboxOrigin eOrigin);

		internal string GetGlyphForXboxOrigin(XboxOrigin eOrigin)
		{
			Utf8StringPointer utf8StringPointer = _GetGlyphForXboxOrigin(Self, eOrigin);
			return utf8StringPointer;
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_GetActionOriginFromXboxOrigin")]
		private static extern ControllerActionOrigin _GetActionOriginFromXboxOrigin(IntPtr self, ControllerHandle_t controllerHandle, XboxOrigin eOrigin);

		internal ControllerActionOrigin GetActionOriginFromXboxOrigin(ControllerHandle_t controllerHandle, XboxOrigin eOrigin)
		{
			return _GetActionOriginFromXboxOrigin(Self, controllerHandle, eOrigin);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_TranslateActionOrigin")]
		private static extern ControllerActionOrigin _TranslateActionOrigin(IntPtr self, InputType eDestinationInputType, ControllerActionOrigin eSourceOrigin);

		internal ControllerActionOrigin TranslateActionOrigin(InputType eDestinationInputType, ControllerActionOrigin eSourceOrigin)
		{
			return _TranslateActionOrigin(Self, eDestinationInputType, eSourceOrigin);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamController_GetControllerBindingRevision")]
		[return: MarshalAs(UnmanagedType.I1)]
		private static extern bool _GetControllerBindingRevision(IntPtr self, ControllerHandle_t controllerHandle, ref int pMajor, ref int pMinor);

		internal bool GetControllerBindingRevision(ControllerHandle_t controllerHandle, ref int pMajor, ref int pMinor)
		{
			return _GetControllerBindingRevision(Self, controllerHandle, ref pMajor, ref pMinor);
		}
	}
	internal class ISteamFriends : SteamInterface
	{
		internal ISteamFriends(bool IsGameServer)
		{
			SetupInterface(IsGameServer);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr SteamAPI_SteamFriends_v017();

		public override IntPtr GetUserInterfacePointer()
		{
			return SteamAPI_SteamFriends_v017();
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_GetPersonaName")]
		private static extern Utf8StringPointer _GetPersonaName(IntPtr self);

		internal string GetPersonaName()
		{
			Utf8StringPointer utf8StringPointer = _GetPersonaName(Self);
			return utf8StringPointer;
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_SetPersonaName")]
		private static extern SteamAPICall_t _SetPersonaName(IntPtr self, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchPersonaName);

		internal CallResult<SetPersonaNameResponse_t> SetPersonaName([MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchPersonaName)
		{
			SteamAPICall_t call = _SetPersonaName(Self, pchPersonaName);
			return new CallResult<SetPersonaNameResponse_t>(call, base.IsServer);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_GetPersonaState")]
		private static extern FriendState _GetPersonaState(IntPtr self);

		internal FriendState GetPersonaState()
		{
			return _GetPersonaState(Self);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_GetFriendCount")]
		private static extern int _GetFriendCount(IntPtr self, int iFriendFlags);

		internal int GetFriendCount(int iFriendFlags)
		{
			return _GetFriendCount(Self, iFriendFlags);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_GetFriendByIndex")]
		private static extern SteamId _GetFriendByIndex(IntPtr self, int iFriend, int iFriendFlags);

		internal SteamId GetFriendByIndex(int iFriend, int iFriendFlags)
		{
			return _GetFriendByIndex(Self, iFriend, iFriendFlags);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_GetFriendRelationship")]
		private static extern Relationship _GetFriendRelationship(IntPtr self, SteamId steamIDFriend);

		internal Relationship GetFriendRelationship(SteamId steamIDFriend)
		{
			return _GetFriendRelationship(Self, steamIDFriend);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_GetFriendPersonaState")]
		private static extern FriendState _GetFriendPersonaState(IntPtr self, SteamId steamIDFriend);

		internal FriendState GetFriendPersonaState(SteamId steamIDFriend)
		{
			return _GetFriendPersonaState(Self, steamIDFriend);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_GetFriendPersonaName")]
		private static extern Utf8StringPointer _GetFriendPersonaName(IntPtr self, SteamId steamIDFriend);

		internal string GetFriendPersonaName(SteamId steamIDFriend)
		{
			Utf8StringPointer utf8StringPointer = _GetFriendPersonaName(Self, steamIDFriend);
			return utf8StringPointer;
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_GetFriendGamePlayed")]
		[return: MarshalAs(UnmanagedType.I1)]
		private static extern bool _GetFriendGamePlayed(IntPtr self, SteamId steamIDFriend, ref FriendGameInfo_t pFriendGameInfo);

		internal bool GetFriendGamePlayed(SteamId steamIDFriend, ref FriendGameInfo_t pFriendGameInfo)
		{
			return _GetFriendGamePlayed(Self, steamIDFriend, ref pFriendGameInfo);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_GetFriendPersonaNameHistory")]
		private static extern Utf8StringPointer _GetFriendPersonaNameHistory(IntPtr self, SteamId steamIDFriend, int iPersonaName);

		internal string GetFriendPersonaNameHistory(SteamId steamIDFriend, int iPersonaName)
		{
			Utf8StringPointer utf8StringPointer = _GetFriendPersonaNameHistory(Self, steamIDFriend, iPersonaName);
			return utf8StringPointer;
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_GetFriendSteamLevel")]
		private static extern int _GetFriendSteamLevel(IntPtr self, SteamId steamIDFriend);

		internal int GetFriendSteamLevel(SteamId steamIDFriend)
		{
			return _GetFriendSteamLevel(Self, steamIDFriend);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_GetPlayerNickname")]
		private static extern Utf8StringPointer _GetPlayerNickname(IntPtr self, SteamId steamIDPlayer);

		internal string GetPlayerNickname(SteamId steamIDPlayer)
		{
			Utf8StringPointer utf8StringPointer = _GetPlayerNickname(Self, steamIDPlayer);
			return utf8StringPointer;
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_GetFriendsGroupCount")]
		private static extern int _GetFriendsGroupCount(IntPtr self);

		internal int GetFriendsGroupCount()
		{
			return _GetFriendsGroupCount(Self);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_GetFriendsGroupIDByIndex")]
		private static extern FriendsGroupID_t _GetFriendsGroupIDByIndex(IntPtr self, int iFG);

		internal FriendsGroupID_t GetFriendsGroupIDByIndex(int iFG)
		{
			return _GetFriendsGroupIDByIndex(Self, iFG);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_GetFriendsGroupName")]
		private static extern Utf8StringPointer _GetFriendsGroupName(IntPtr self, FriendsGroupID_t friendsGroupID);

		internal string GetFriendsGroupName(FriendsGroupID_t friendsGroupID)
		{
			Utf8StringPointer utf8StringPointer = _GetFriendsGroupName(Self, friendsGroupID);
			return utf8StringPointer;
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_GetFriendsGroupMembersCount")]
		private static extern int _GetFriendsGroupMembersCount(IntPtr self, FriendsGroupID_t friendsGroupID);

		internal int GetFriendsGroupMembersCount(FriendsGroupID_t friendsGroupID)
		{
			return _GetFriendsGroupMembersCount(Self, friendsGroupID);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_GetFriendsGroupMembersList")]
		private static extern void _GetFriendsGroupMembersList(IntPtr self, FriendsGroupID_t friendsGroupID, [In][Out] SteamId[] pOutSteamIDMembers, int nMembersCount);

		internal void GetFriendsGroupMembersList(FriendsGroupID_t friendsGroupID, [In][Out] SteamId[] pOutSteamIDMembers, int nMembersCount)
		{
			_GetFriendsGroupMembersList(Self, friendsGroupID, pOutSteamIDMembers, nMembersCount);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_HasFriend")]
		[return: MarshalAs(UnmanagedType.I1)]
		private static extern bool _HasFriend(IntPtr self, SteamId steamIDFriend, int iFriendFlags);

		internal bool HasFriend(SteamId steamIDFriend, int iFriendFlags)
		{
			return _HasFriend(Self, steamIDFriend, iFriendFlags);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_GetClanCount")]
		private static extern int _GetClanCount(IntPtr self);

		internal int GetClanCount()
		{
			return _GetClanCount(Self);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_GetClanByIndex")]
		private static extern SteamId _GetClanByIndex(IntPtr self, int iClan);

		internal SteamId GetClanByIndex(int iClan)
		{
			return _GetClanByIndex(Self, iClan);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_GetClanName")]
		private static extern Utf8StringPointer _GetClanName(IntPtr self, SteamId steamIDClan);

		internal string GetClanName(SteamId steamIDClan)
		{
			Utf8StringPointer utf8StringPointer = _GetClanName(Self, steamIDClan);
			return utf8StringPointer;
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_GetClanTag")]
		private static extern Utf8StringPointer _GetClanTag(IntPtr self, SteamId steamIDClan);

		internal string GetClanTag(SteamId steamIDClan)
		{
			Utf8StringPointer utf8StringPointer = _GetClanTag(Self, steamIDClan);
			return utf8StringPointer;
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_GetClanActivityCounts")]
		[return: MarshalAs(UnmanagedType.I1)]
		private static extern bool _GetClanActivityCounts(IntPtr self, SteamId steamIDClan, ref int pnOnline, ref int pnInGame, ref int pnChatting);

		internal bool GetClanActivityCounts(SteamId steamIDClan, ref int pnOnline, ref int pnInGame, ref int pnChatting)
		{
			return _GetClanActivityCounts(Self, steamIDClan, ref pnOnline, ref pnInGame, ref pnChatting);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_DownloadClanActivityCounts")]
		private static extern SteamAPICall_t _DownloadClanActivityCounts(IntPtr self, [In][Out] SteamId[] psteamIDClans, int cClansToRequest);

		internal CallResult<DownloadClanActivityCountsResult_t> DownloadClanActivityCounts([In][Out] SteamId[] psteamIDClans, int cClansToRequest)
		{
			SteamAPICall_t call = _DownloadClanActivityCounts(Self, psteamIDClans, cClansToRequest);
			return new CallResult<DownloadClanActivityCountsResult_t>(call, base.IsServer);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_GetFriendCountFromSource")]
		private static extern int _GetFriendCountFromSource(IntPtr self, SteamId steamIDSource);

		internal int GetFriendCountFromSource(SteamId steamIDSource)
		{
			return _GetFriendCountFromSource(Self, steamIDSource);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_GetFriendFromSourceByIndex")]
		private static extern SteamId _GetFriendFromSourceByIndex(IntPtr self, SteamId steamIDSource, int iFriend);

		internal SteamId GetFriendFromSourceByIndex(SteamId steamIDSource, int iFriend)
		{
			return _GetFriendFromSourceByIndex(Self, steamIDSource, iFriend);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_IsUserInSource")]
		[return: MarshalAs(UnmanagedType.I1)]
		private static extern bool _IsUserInSource(IntPtr self, SteamId steamIDUser, SteamId steamIDSource);

		internal bool IsUserInSource(SteamId steamIDUser, SteamId steamIDSource)
		{
			return _IsUserInSource(Self, steamIDUser, steamIDSource);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_SetInGameVoiceSpeaking")]
		private static extern void _SetInGameVoiceSpeaking(IntPtr self, SteamId steamIDUser, [MarshalAs(UnmanagedType.U1)] bool bSpeaking);

		internal void SetInGameVoiceSpeaking(SteamId steamIDUser, [MarshalAs(UnmanagedType.U1)] bool bSpeaking)
		{
			_SetInGameVoiceSpeaking(Self, steamIDUser, bSpeaking);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_ActivateGameOverlay")]
		private static extern void _ActivateGameOverlay(IntPtr self, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchDialog);

		internal void ActivateGameOverlay([MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchDialog)
		{
			_ActivateGameOverlay(Self, pchDialog);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_ActivateGameOverlayToUser")]
		private static extern void _ActivateGameOverlayToUser(IntPtr self, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchDialog, SteamId steamID);

		internal void ActivateGameOverlayToUser([MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchDialog, SteamId steamID)
		{
			_ActivateGameOverlayToUser(Self, pchDialog, steamID);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_ActivateGameOverlayToWebPage")]
		private static extern void _ActivateGameOverlayToWebPage(IntPtr self, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchURL, ActivateGameOverlayToWebPageMode eMode);

		internal void ActivateGameOverlayToWebPage([MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Steamworks.Utf8StringToNative")] string pchURL, ActivateGameOverlayToWebPageMode eMode)
		{
			_ActivateGameOverlayToWebPage(Self, pchURL, eMode);
		}

		[DllImport("steam_api64", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SteamAPI_ISteamFriends_ActivateGameOverlayToStore")]
		private static extern void _ActivateGameOverlayToStore(IntPtr self, AppId nAppID, OverlayToStoreFlag eFlag);

		inte