Decompiled source of GJStore v0.0.3

BepInEx/plugins/GJStore/GJStore.dll

Decompiled 4 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GJCompanyShowroom;
using GJNoisyDog;
using GJStoreCage;
using GJStoreCageAudio059;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("GJStore")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyProduct("GJStore")]
[assembly: AssemblyTitle("GJStore")]
[assembly: AssemblyInformationalVersion("1.0.24")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.24.0")]
[assembly: AssemblyVersion("1.0.24.0")]
[module: <908a15ee-58fd-4f8b-a1fb-ea82063beae0>RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<21219435-5d5a-4e34-a715-f28568d854d4>Embedded]
	internal sealed class <21219435-5d5a-4e34-a715-f28568d854d4>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	[<21219435-5d5a-4e34-a715-f28568d854d4>Embedded]
	internal sealed class <908a15ee-58fd-4f8b-a1fb-ea82063beae0>RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public <908a15ee-58fd-4f8b-a1fb-ea82063beae0>RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace GJCompanyShowroom
{
	internal static class Cloak20Merchant
	{
		private sealed class Part
		{
			internal string Name;

			internal string MaterialName;

			internal string Texture;

			internal Color32 Color;

			internal bool DoubleSided;

			internal Vector3[] Base;

			internal Vector2[] Uv;

			internal Vector3[][] Morph;

			internal Vector3[] Flap;

			internal int[] Triangles;
		}

		private sealed class Source
		{
			internal float IdleDuration;

			internal float ReachDuration;

			internal float[] Idle;

			internal float[] Reach;

			internal List<Part> Parts = new List<Part>();
		}

		internal const float ModelHeight = 2.033f;

		private static Source _source;

		private static string _folder;

		private static readonly Dictionary<string, Texture2D> Textures = new Dictionary<string, Texture2D>();

		private static readonly Dictionary<string, Material> Materials = new Dictionary<string, Material>();

		private static string ReadString(BinaryReader br)
		{
			int num = br.ReadInt32();
			if (num < 0 || num > 1024)
			{
				throw new InvalidDataException("CLOAK20 invalid string length");
			}
			return Encoding.UTF8.GetString(br.ReadBytes(num));
		}

		private static Vector3 ReadVector3(BinaryReader br)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
		}

		internal static void Validate(string assets)
		{
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: 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_02a0: Unknown result type (might be due to invalid IL or missing references)
			if (_source != null)
			{
				return;
			}
			_folder = assets;
			Source source = new Source();
			using (FileStream fileStream = File.OpenRead(Path.Combine(assets, "Cloak20Merchant.gjc2")))
			{
				using BinaryReader binaryReader = new BinaryReader(fileStream);
				if (Encoding.ASCII.GetString(binaryReader.ReadBytes(4)) != "GJC2")
				{
					throw new InvalidDataException("Not a CLOAK_20 GJC2 asset");
				}
				int num = binaryReader.ReadInt32();
				source.IdleDuration = binaryReader.ReadSingle();
				int num2 = binaryReader.ReadInt32();
				source.ReachDuration = binaryReader.ReadSingle();
				if (num < 2 || num > 300 || num2 < 2 || num2 > 300)
				{
					throw new InvalidDataException("CLOAK_20 clip frame count invalid");
				}
				source.Idle = new float[num * 4];
				source.Reach = new float[num2 * 4];
				for (int i = 0; i < source.Idle.Length; i++)
				{
					source.Idle[i] = binaryReader.ReadSingle();
				}
				for (int j = 0; j < source.Reach.Length; j++)
				{
					source.Reach[j] = binaryReader.ReadSingle();
				}
				int num3 = binaryReader.ReadInt32();
				if (num3 < 1 || num3 > 40)
				{
					throw new InvalidDataException("CLOAK_20 part count invalid");
				}
				for (int k = 0; k < num3; k++)
				{
					Part part = new Part();
					part.Name = ReadString(binaryReader);
					part.MaterialName = ReadString(binaryReader);
					part.Texture = ReadString(binaryReader);
					part.Color = new Color32(binaryReader.ReadByte(), binaryReader.ReadByte(), binaryReader.ReadByte(), binaryReader.ReadByte());
					part.DoubleSided = binaryReader.ReadByte() != 0;
					int num4 = binaryReader.ReadInt32();
					int num5 = binaryReader.ReadInt32();
					if (num4 < 1 || num4 > 300000 || num5 < 3 || num5 > 1000000 || num5 % 3 != 0)
					{
						throw new InvalidDataException("CLOAK_20 bad mesh size: " + part.Name);
					}
					part.Base = (Vector3[])(object)new Vector3[num4];
					part.Uv = (Vector2[])(object)new Vector2[num4];
					part.Morph = new Vector3[4][];
					for (int l = 0; l < 4; l++)
					{
						part.Morph[l] = (Vector3[])(object)new Vector3[num4];
					}
					part.Flap = (Vector3[])(object)new Vector3[num4];
					for (int m = 0; m < num4; m++)
					{
						part.Base[m] = ReadVector3(binaryReader);
						part.Uv[m] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle());
						for (int n = 0; n < 4; n++)
						{
							part.Morph[n][m] = ReadVector3(binaryReader);
						}
						part.Flap[m] = ReadVector3(binaryReader);
					}
					part.Triangles = new int[num5];
					for (int num6 = 0; num6 < num5; num6++)
					{
						int num7 = binaryReader.ReadInt32();
						if (num7 < 0 || num7 >= num4)
						{
							throw new InvalidDataException("CLOAK_20 invalid triangle");
						}
						part.Triangles[num6] = num7;
					}
					if (!string.IsNullOrEmpty(part.Texture) && !File.Exists(Path.Combine(assets, part.Texture)))
					{
						throw new FileNotFoundException("CLOAK_20 missing texture", part.Texture);
					}
					source.Parts.Add(part);
				}
				if (fileStream.Position != fileStream.Length)
				{
					throw new InvalidDataException("CLOAK_20 unexpected trailing bytes");
				}
			}
			_source = source;
		}

		internal static GameObject Create(Transform parent, Vector3 localPosition, Quaternion localRotation, float scale, string assets, float nearHz, float farHz, float farDistance, float pauseDistance, bool castShadows)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Expected O, but got Unknown
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Expected O, but got Unknown
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			Validate(assets);
			GameObject val = new GameObject("GJ_CLOAK_20_Rigged_Merchant");
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPosition;
			val.transform.localRotation = localRotation;
			val.transform.localScale = Vector3.one * scale;
			Cloak20PosePlayer cloak20PosePlayer = val.AddComponent<Cloak20PosePlayer>();
			cloak20PosePlayer.Initialize(_source.Idle, _source.IdleDuration, _source.Reach, _source.ReachDuration);
			cloak20PosePlayer.ConfigurePerformance(nearHz, farHz, farDistance, pauseDistance);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(0f, 1.57f, 0f);
			GameObject val3 = new GameObject("GJ_CLOAK20_HeadPivot");
			val3.transform.SetParent(val.transform, false);
			val3.transform.localPosition = val2;
			val3.transform.localRotation = Quaternion.identity;
			List<Renderer> list = new List<Renderer>();
			foreach (Part part in _source.Parts)
			{
				if (!part.Name.StartsWith("PHOTO_PROJECTED_FRONT", StringComparison.Ordinal))
				{
					GameObject val4 = new GameObject("CLOAK20_" + part.Name);
					bool flag = part.Name == "HOOD_fitted_heavy_fabric" || part.Name == "HOOD_black_interior";
					val4.transform.SetParent(flag ? val3.transform : val.transform, false);
					if (flag)
					{
						val4.transform.localPosition = -val2;
					}
					Mesh val5 = new Mesh
					{
						name = "CLOAK20_" + part.Name
					};
					if (part.Base.Length > 65535)
					{
						val5.indexFormat = (IndexFormat)1;
					}
					val5.MarkDynamic();
					val5.vertices = part.Base;
					val5.uv = part.Uv;
					val5.triangles = part.Triangles;
					val5.RecalculateNormals();
					val5.RecalculateBounds();
					Bounds bounds = val5.bounds;
					((Bounds)(ref bounds)).Expand(0.25f);
					val5.bounds = bounds;
					val4.AddComponent<MeshFilter>().sharedMesh = val5;
					MeshRenderer val6 = val4.AddComponent<MeshRenderer>();
					((Renderer)val6).sharedMaterial = GetMaterial(part);
					((Renderer)val6).shadowCastingMode = (ShadowCastingMode)(castShadows ? 1 : 0);
					((Renderer)val6).receiveShadows = true;
					list.Add((Renderer)(object)val6);
					bool containsOriginalFace = part.Name == "SCAVENGER_Original_Lethal_Company_LOD1";
					cloak20PosePlayer.Add(val5, part.Base, part.Morph, part.Flap, containsOriginalFace);
				}
			}
			cloak20PosePlayer.SetRenderers(list.ToArray());
			return val;
		}

		private static Material GetMaterial(Part p)
		{
			//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_00f7: Expected O, but got Unknown
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: 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_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			string key = p.MaterialName + "/" + p.Texture + "/" + p.Color.r + "/" + p.Color.g + "/" + p.Color.b + "/" + p.DoubleSided;
			if (Materials.TryGetValue(key, out var value))
			{
				return value;
			}
			Shader obj = Shader.Find("HDRP/Lit") ?? Shader.Find("HDRP/Unlit") ?? Shader.Find("Standard");
			if ((Object)(object)obj == (Object)null)
			{
				throw new InvalidOperationException("No compatible CLOAK20 shader");
			}
			Material val = new Material(obj)
			{
				name = "GJ_CLOAK20_" + p.MaterialName
			};
			Color val2 = Color32.op_Implicit(p.Color);
			if (p.MaterialName.IndexOf("Fabric", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				((Color)(ref val2))..ctor(val2.r * 0.72f, val2.g * 0.72f, val2.b * 0.72f, 1f);
			}
			val2.a = 1f;
			if (val.HasProperty("_BaseColor"))
			{
				val.SetColor("_BaseColor", val2);
			}
			if (val.HasProperty("_Color"))
			{
				val.SetColor("_Color", val2);
			}
			if (!string.IsNullOrEmpty(p.Texture))
			{
				Texture2D texture = GetTexture(p.Texture);
				if (val.HasProperty("_BaseColorMap"))
				{
					val.SetTexture("_BaseColorMap", (Texture)(object)texture);
				}
				if (val.HasProperty("_MainTex"))
				{
					val.SetTexture("_MainTex", (Texture)(object)texture);
				}
			}
			if (val.HasProperty("_Metallic"))
			{
				val.SetFloat("_Metallic", 0f);
			}
			if (val.HasProperty("_Smoothness"))
			{
				val.SetFloat("_Smoothness", 0.07f);
			}
			if (val.HasProperty("_SurfaceType"))
			{
				val.SetFloat("_SurfaceType", 0f);
			}
			if (val.HasProperty("_BlendMode"))
			{
				val.SetFloat("_BlendMode", 0f);
			}
			if (val.HasProperty("_AlphaCutoffEnable"))
			{
				val.SetFloat("_AlphaCutoffEnable", 0f);
			}
			if (val.HasProperty("_SrcBlend"))
			{
				val.SetFloat("_SrcBlend", 1f);
			}
			if (val.HasProperty("_DstBlend"))
			{
				val.SetFloat("_DstBlend", 0f);
			}
			if (val.HasProperty("_ZWrite"))
			{
				val.SetFloat("_ZWrite", 1f);
			}
			if (p.DoubleSided)
			{
				if (val.HasProperty("_DoubleSidedEnable"))
				{
					val.SetFloat("_DoubleSidedEnable", 1f);
				}
				if (val.HasProperty("_CullMode"))
				{
					val.SetFloat("_CullMode", 0f);
				}
				if (val.HasProperty("_CullModeForward"))
				{
					val.SetFloat("_CullModeForward", 0f);
				}
				val.EnableKeyword("_DOUBLESIDED_ON");
			}
			val.DisableKeyword("_SURFACE_TYPE_TRANSPARENT");
			val.DisableKeyword("_ALPHATEST_ON");
			val.SetOverrideTag("RenderType", "Opaque");
			val.renderQueue = 2000;
			Materials.Add(key, val);
			return val;
		}

		private static Texture2D GetTexture(string name)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			if (Textures.TryGetValue(name, out var value))
			{
				return value;
			}
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false)
			{
				name = "GJ_CLOAK20_" + name
			};
			if (!ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(_folder, name)), false))
			{
				throw new InvalidDataException("CLOAK20 texture decode failed: " + name);
			}
			Color32[] pixels = val.GetPixels32();
			for (int i = 0; i < pixels.Length; i++)
			{
				pixels[i].a = byte.MaxValue;
			}
			val.SetPixels32(pixels);
			val.Apply(false, false);
			((Texture)val).wrapMode = (TextureWrapMode)0;
			((Texture)val).filterMode = (FilterMode)1;
			Textures.Add(name, val);
			return val;
		}
	}
	internal sealed class Cloak20PosePlayer : MonoBehaviour
	{
		private sealed class AnimatedPart
		{
			internal Mesh Mesh;

			internal Vector3[] Base;

			internal Vector3[][] Morph;

			internal Vector3[] Flap;

			internal Vector3[] Work;
		}

		private readonly List<AnimatedPart> _parts = new List<AnimatedPart>();

		private AnimatedPart _facePart;

		private Vector3[] _faceTurned;

		private float _headYaw;

		private float _appliedHeadYaw = float.NaN;

		private bool _faceBaseDirty;

		private static readonly Vector3 NeckPivot = new Vector3(0f, 1.57f, 0f);

		private const float NeckBlendBottom = 1.44f;

		private const float NeckBlendTop = 1.65f;

		private float[] _idle;

		private float[] _reach;

		private float _idleLength;

		private float _reachLength;

		private float _clock;

		private float _nextUpdate;

		private bool _reaching;

		private readonly float[] _weight = new float[4];

		private Renderer[] _renderers;

		private float _nearHz = 8f;

		private float _farHz = 2f;

		private float _farDistanceSq = 100f;

		private float _pauseDistanceSq = 576f;

		private bool _forceRefresh = true;

		internal void ConfigurePerformance(float nearHz, float farHz, float farDistance, float pauseDistance)
		{
			_nearHz = Mathf.Clamp(nearHz, 2f, 20f);
			_farHz = Mathf.Clamp(farHz, 0.5f, 10f);
			farDistance = Mathf.Clamp(farDistance, 5f, 25f);
			pauseDistance = Mathf.Max(farDistance + 1f, Mathf.Clamp(pauseDistance, 10f, 80f));
			_farDistanceSq = farDistance * farDistance;
			_pauseDistanceSq = pauseDistance * pauseDistance;
		}

		internal void SetRenderers(Renderer[] renderers)
		{
			_renderers = renderers;
		}

		private bool AnyRendererVisible()
		{
			if (_renderers == null || _renderers.Length == 0)
			{
				return true;
			}
			Renderer[] renderers = _renderers;
			foreach (Renderer val in renderers)
			{
				if ((Object)(object)val != (Object)null && val.enabled && val.isVisible)
				{
					return true;
				}
			}
			return false;
		}

		internal void Initialize(float[] idle, float idleLength, float[] reach, float reachLength)
		{
			_idle = idle;
			_idleLength = idleLength;
			_reach = reach;
			_reachLength = reachLength;
		}

		internal void Add(Mesh mesh, Vector3[] baseVertices, Vector3[][] morphs, Vector3[] flap, bool containsOriginalFace)
		{
			AnimatedPart animatedPart = new AnimatedPart
			{
				Mesh = mesh,
				Base = baseVertices,
				Morph = morphs,
				Flap = flap,
				Work = (Vector3[])(object)new Vector3[baseVertices.Length]
			};
			_parts.Add(animatedPart);
			if (containsOriginalFace)
			{
				_facePart = animatedPart;
				_faceTurned = (Vector3[])(object)new Vector3[baseVertices.Length];
				_faceBaseDirty = true;
			}
		}

		internal void SetHeadYaw(float yawDegrees)
		{
			_headYaw = Mathf.Clamp(yawDegrees, -35f, 35f);
		}

		internal void PlayReach()
		{
			_clock = 0f;
			_reaching = true;
			_forceRefresh = true;
			_nextUpdate = 0f;
		}

		private void Update()
		{
			//IL_009a: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			if (_idle == null || _reach == null)
			{
				return;
			}
			_clock += Time.deltaTime;
			if (_reaching && _clock >= _reachLength)
			{
				_reaching = false;
				_clock = 0f;
				_forceRefresh = true;
			}
			float unscaledTime = Time.unscaledTime;
			if (!_forceRefresh && unscaledTime < _nextUpdate)
			{
				return;
			}
			float num = 0f;
			bool flag = false;
			GameNetworkManager instance = GameNetworkManager.Instance;
			if ((Object)(object)instance != (Object)null && (Object)(object)instance.localPlayerController != (Object)null)
			{
				Vector3 val = ((Component)instance.localPlayerController).transform.position - ((Component)this).transform.position;
				num = ((Vector3)(ref val)).sqrMagnitude;
				flag = true;
			}
			if (!_reaching && !_forceRefresh && flag && num > _pauseDistanceSq)
			{
				_nextUpdate = unscaledTime + 0.65f;
				return;
			}
			if (!_reaching && !_forceRefresh && flag && num > 16f && !AnyRendererVisible())
			{
				_nextUpdate = unscaledTime + 0.45f;
				return;
			}
			float num2 = ((flag && num > _farDistanceSq) ? _farHz : _nearHz);
			if (_reaching)
			{
				num2 = Mathf.Max(num2, 10f);
			}
			_nextUpdate = unscaledTime + 1f / num2;
			_forceRefresh = false;
			float[] array = (_reaching ? _reach : _idle);
			float num3 = (_reaching ? _reachLength : _idleLength);
			int num4 = array.Length / 4;
			float num5 = Mathf.Repeat(_clock, num3) / num3 * (float)(num4 - 1);
			int num6 = Mathf.Clamp(Mathf.FloorToInt(num5), 0, num4 - 2);
			float num7 = num5 - (float)num6;
			for (int i = 0; i < 4; i++)
			{
				_weight[i] = Mathf.Lerp(array[num6 * 4 + i], array[(num6 + 1) * 4 + i], num7);
			}
			float num8 = _weight[0];
			float num9 = _weight[1];
			float num10 = _weight[2];
			float num11 = _weight[3];
			float num12 = (_reaching ? Mathf.Clamp01(num10 + num11 * 0.2f) : 0f);
			foreach (AnimatedPart part in _parts)
			{
				Vector3[] array2 = part.Morph[0];
				Vector3[] array3 = part.Morph[1];
				Vector3[] array4 = part.Morph[2];
				Vector3[] array5 = part.Morph[3];
				if (_reaching)
				{
					for (int j = 0; j < part.Work.Length; j++)
					{
						part.Work[j] = part.Base[j] + array4[j] * num10 + array5[j] * num11 + part.Flap[j] * num12;
					}
				}
				else
				{
					for (int k = 0; k < part.Work.Length; k++)
					{
						part.Work[k] = part.Base[k] + array2[k] * num8 + array3[k] * num9;
					}
				}
				part.Mesh.vertices = part.Work;
				if (part == _facePart)
				{
					_faceBaseDirty = true;
				}
			}
		}

		private void LateUpdate()
		{
			//IL_0047: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			if (_facePart == null || _faceTurned == null || (!_faceBaseDirty && Mathf.Abs(Mathf.DeltaAngle(_appliedHeadYaw, _headYaw)) < 0.1f))
			{
				return;
			}
			Quaternion val = Quaternion.Euler(0f, _headYaw, 0f);
			Vector3[] work = _facePart.Work;
			Vector3[] array = _facePart.Base;
			for (int i = 0; i < work.Length; i++)
			{
				float num = Mathf.InverseLerp(1.44f, 1.65f, array[i].y);
				float num2 = num * num * (3f - 2f * num);
				if (num2 <= 0f)
				{
					_faceTurned[i] = work[i];
					continue;
				}
				Vector3 val2 = work[i];
				Vector3 val3 = NeckPivot + val * (val2 - NeckPivot);
				_faceTurned[i] = ((num2 >= 1f) ? val3 : Vector3.Lerp(val2, val3, num2));
			}
			_facePart.Mesh.vertices = _faceTurned;
			_appliedHeadYaw = _headYaw;
			_faceBaseDirty = false;
		}

		private void OnDestroy()
		{
			foreach (AnimatedPart part in _parts)
			{
				if ((Object)(object)part.Mesh != (Object)null)
				{
					Object.Destroy((Object)(object)part.Mesh);
				}
			}
			_parts.Clear();
		}
	}
	internal static class CloakedMerchant
	{
		private sealed class ModelPart
		{
			internal string Name;

			internal string MaterialName;

			internal string TextureFile;

			internal Color32 Color;

			internal bool DoubleSided;

			internal Vector3[] Base;

			internal Vector2[] UV;

			internal Vector3[] Inhale;

			internal Vector3[] Follow;

			internal int[] Triangles;
		}

		private sealed class ModelData
		{
			internal float Duration;

			internal float[] InhaleWeights;

			internal float[] FollowWeights;

			internal List<ModelPart> Parts = new List<ModelPart>();
		}

		private static ModelData _model;

		internal const float ModelHeight = 2.033f;

		private static readonly Dictionary<string, Material> Materials = new Dictionary<string, Material>();

		private static readonly Dictionary<string, Texture2D> Textures = new Dictionary<string, Texture2D>();

		private static string _directory;

		internal static void Validate(string directory)
		{
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: 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_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			_directory = directory;
			if (_model != null)
			{
				return;
			}
			ModelData modelData = new ModelData();
			using (FileStream fileStream = File.OpenRead(Path.Combine(directory, "CloakedMerchant.gjc")))
			{
				using BinaryReader binaryReader = new BinaryReader(fileStream);
				if (Encoding.ASCII.GetString(binaryReader.ReadBytes(4)) != "GJC1")
				{
					throw new InvalidDataException("CloakedMerchant.gjc is not GJC1");
				}
				int num = binaryReader.ReadInt32();
				modelData.Duration = binaryReader.ReadSingle();
				if (num < 2 || num > 1000 || modelData.Duration < 0.1f)
				{
					throw new InvalidDataException("Invalid cloak animation header");
				}
				modelData.InhaleWeights = new float[num];
				modelData.FollowWeights = new float[num];
				for (int i = 0; i < num; i++)
				{
					modelData.InhaleWeights[i] = binaryReader.ReadSingle();
					modelData.FollowWeights[i] = binaryReader.ReadSingle();
				}
				int num2 = binaryReader.ReadInt32();
				if (num2 < 1 || num2 > 64)
				{
					throw new InvalidDataException("Invalid cloak mesh part count");
				}
				for (int j = 0; j < num2; j++)
				{
					ModelPart modelPart = new ModelPart();
					modelPart.Name = ReadString(binaryReader);
					modelPart.MaterialName = ReadString(binaryReader);
					modelPart.TextureFile = ReadString(binaryReader);
					modelPart.Color = new Color32(binaryReader.ReadByte(), binaryReader.ReadByte(), binaryReader.ReadByte(), binaryReader.ReadByte());
					modelPart.DoubleSided = binaryReader.ReadByte() != 0;
					int num3 = binaryReader.ReadInt32();
					int num4 = binaryReader.ReadInt32();
					if (num3 < 1 || num3 > 500000 || num4 < 3 || num4 > 3000000 || num4 % 3 != 0)
					{
						throw new InvalidDataException("Invalid cloak mesh dimensions: " + modelPart.Name);
					}
					modelPart.Base = (Vector3[])(object)new Vector3[num3];
					modelPart.UV = (Vector2[])(object)new Vector2[num3];
					modelPart.Inhale = (Vector3[])(object)new Vector3[num3];
					modelPart.Follow = (Vector3[])(object)new Vector3[num3];
					for (int k = 0; k < num3; k++)
					{
						modelPart.Base[k] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
						modelPart.UV[k] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle());
						modelPart.Inhale[k] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
						modelPart.Follow[k] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
					}
					modelPart.Triangles = new int[num4];
					for (int l = 0; l < num4; l++)
					{
						int num5 = binaryReader.ReadInt32();
						if (num5 < 0 || num5 >= num3)
						{
							throw new InvalidDataException("Out-of-range triangle in " + modelPart.Name);
						}
						modelPart.Triangles[l] = num5;
					}
					if (!string.IsNullOrEmpty(modelPart.TextureFile) && !File.Exists(Path.Combine(directory, modelPart.TextureFile)))
					{
						throw new FileNotFoundException("Missing CLOAK_08 texture", modelPart.TextureFile);
					}
					modelData.Parts.Add(modelPart);
				}
				if (fileStream.Position != fileStream.Length)
				{
					throw new InvalidDataException("CloakedMerchant.gjc unexpected trailing bytes");
				}
			}
			_model = modelData;
		}

		private static string ReadString(BinaryReader br)
		{
			int num = br.ReadInt32();
			if (num < 0 || num > 1024)
			{
				throw new InvalidDataException("Invalid CLOAK string length");
			}
			return Encoding.UTF8.GetString(br.ReadBytes(num));
		}

		internal static GameObject Create(Transform parent, Vector3 localPosition, Quaternion localRotation, float localScale, string directory)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Expected O, but got Unknown
			//IL_0144: 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_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			Validate(directory);
			GameObject val = new GameObject("GJ_CLOAK_08_Cloaked_Merchant_Breathing");
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPosition;
			val.transform.localRotation = localRotation;
			val.transform.localScale = Vector3.one * localScale;
			CloakedMerchantBreathing cloakedMerchantBreathing = val.AddComponent<CloakedMerchantBreathing>();
			cloakedMerchantBreathing.Initialize(_model.Duration, _model.InhaleWeights, _model.FollowWeights);
			foreach (ModelPart part in _model.Parts)
			{
				if (!part.Name.StartsWith("PHOTO_PROJECTED_FRONT", StringComparison.Ordinal))
				{
					GameObject val2 = new GameObject("CLOAK_08_" + part.Name);
					val2.transform.SetParent(val.transform, false);
					Mesh val3 = new Mesh
					{
						name = part.Name + "_BreathRuntime"
					};
					if (part.Base.Length > 65535)
					{
						val3.indexFormat = (IndexFormat)1;
					}
					val3.MarkDynamic();
					val3.vertices = part.Base;
					val3.uv = part.UV;
					val3.triangles = part.Triangles;
					val3.RecalculateNormals();
					val3.RecalculateBounds();
					Bounds bounds = val3.bounds;
					((Bounds)(ref bounds)).Expand(0.08f);
					val3.bounds = bounds;
					val2.AddComponent<MeshFilter>().sharedMesh = val3;
					MeshRenderer obj = val2.AddComponent<MeshRenderer>();
					((Renderer)obj).sharedMaterial = MaterialFor(part);
					((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1;
					((Renderer)obj).receiveShadows = true;
					cloakedMerchantBreathing.Add(val3, part.Base, part.Inhale, part.Follow);
				}
			}
			return val;
		}

		private static Material MaterialFor(ModelPart part)
		{
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			string key = part.MaterialName + "|" + part.TextureFile + "|" + part.Color.r + "," + part.Color.g + "," + part.Color.b + "|" + part.DoubleSided;
			if (Materials.TryGetValue(key, out var value))
			{
				return value;
			}
			Shader obj = Shader.Find("HDRP/Lit") ?? Shader.Find("HDRP/Unlit") ?? Shader.Find("Standard") ?? Shader.Find("Unlit/Texture");
			if ((Object)(object)obj == (Object)null)
			{
				throw new InvalidOperationException("No compatible shader for CLOAK_08");
			}
			value = new Material(obj)
			{
				name = "CLOAK_08_" + part.MaterialName
			};
			Color val = Color32.op_Implicit(part.Color);
			if (part.Name.IndexOf("PHOTO_PROJECTED_FRONT", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				((Color)(ref val))..ctor(0.05f, 0.05f, 0.05f, 1f);
			}
			else if (part.MaterialName.IndexOf("Fabric", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				val *= 0.5f;
			}
			val.a = 1f;
			if (value.HasProperty("_BaseColor"))
			{
				value.SetColor("_BaseColor", val);
			}
			if (value.HasProperty("_SurfaceType"))
			{
				value.SetFloat("_SurfaceType", 0f);
			}
			if (value.HasProperty("_Surface"))
			{
				value.SetFloat("_Surface", 0f);
			}
			if (value.HasProperty("_BlendMode"))
			{
				value.SetFloat("_BlendMode", 0f);
			}
			if (value.HasProperty("_AlphaCutoffEnable"))
			{
				value.SetFloat("_AlphaCutoffEnable", 0f);
			}
			if (value.HasProperty("_AlphaClip"))
			{
				value.SetFloat("_AlphaClip", 0f);
			}
			if (value.HasProperty("_SrcBlend"))
			{
				value.SetFloat("_SrcBlend", 1f);
			}
			if (value.HasProperty("_DstBlend"))
			{
				value.SetFloat("_DstBlend", 0f);
			}
			if (value.HasProperty("_ZWrite"))
			{
				value.SetFloat("_ZWrite", 1f);
			}
			value.SetOverrideTag("RenderType", "Opaque");
			value.DisableKeyword("_SURFACE_TYPE_TRANSPARENT");
			value.DisableKeyword("_ALPHATEST_ON");
			value.renderQueue = 2000;
			if (value.HasProperty("_Color"))
			{
				value.SetColor("_Color", val);
			}
			if (value.HasProperty("_Metallic"))
			{
				value.SetFloat("_Metallic", 0f);
			}
			if (value.HasProperty("_Smoothness"))
			{
				value.SetFloat("_Smoothness", 0.03f);
			}
			if (part.DoubleSided)
			{
				if (value.HasProperty("_DoubleSidedEnable"))
				{
					value.SetFloat("_DoubleSidedEnable", 1f);
				}
				if (value.HasProperty("_CullMode"))
				{
					value.SetFloat("_CullMode", 0f);
				}
				if (value.HasProperty("_CullModeForward"))
				{
					value.SetFloat("_CullModeForward", 0f);
				}
				value.EnableKeyword("_DOUBLESIDED_ON");
			}
			if (!string.IsNullOrEmpty(part.TextureFile))
			{
				Texture2D val2 = TextureFor(part.TextureFile);
				if (value.HasProperty("_BaseColorMap"))
				{
					value.SetTexture("_BaseColorMap", (Texture)(object)val2);
				}
				if (value.HasProperty("_UnlitColorMap"))
				{
					value.SetTexture("_UnlitColorMap", (Texture)(object)val2);
				}
				if (value.HasProperty("_MainTex"))
				{
					value.SetTexture("_MainTex", (Texture)(object)val2);
				}
			}
			Materials.Add(key, value);
			return value;
		}

		private static Texture2D TextureFor(string name)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			if (Textures.TryGetValue(name, out var value))
			{
				return value;
			}
			value = new Texture2D(2, 2, (TextureFormat)4, false)
			{
				name = "CLOAK_08_" + name
			};
			if (!ImageConversion.LoadImage(value, File.ReadAllBytes(Path.Combine(_directory, name)), false))
			{
				throw new InvalidDataException("Cannot read CLOAK_08 texture: " + name);
			}
			Color32[] pixels = value.GetPixels32();
			for (int i = 0; i < pixels.Length; i++)
			{
				pixels[i].a = byte.MaxValue;
			}
			value.SetPixels32(pixels);
			value.Apply(false, false);
			((Texture)value).wrapMode = (TextureWrapMode)0;
			((Texture)value).filterMode = (FilterMode)1;
			Textures.Add(name, value);
			return value;
		}
	}
	internal sealed class CloakedMerchantBreathing : MonoBehaviour
	{
		private sealed class Part
		{
			internal Mesh Mesh;

			internal Vector3[] Base;

			internal Vector3[] Inhale;

			internal Vector3[] Follow;

			internal Vector3[] Working;
		}

		private readonly List<Part> _parts = new List<Part>();

		private float[] _inhaleWeights;

		private float[] _followWeights;

		private float _duration;

		private float _elapsed;

		private float _nextUpdate;

		internal void Initialize(float duration, float[] inhale, float[] follow)
		{
			_duration = duration;
			_inhaleWeights = inhale;
			_followWeights = follow;
		}

		internal void Add(Mesh mesh, Vector3[] baseVertices, Vector3[] inhale, Vector3[] follow)
		{
			_parts.Add(new Part
			{
				Mesh = mesh,
				Base = baseVertices,
				Inhale = inhale,
				Follow = follow,
				Working = (Vector3[])(object)new Vector3[baseVertices.Length]
			});
		}

		private void Update()
		{
			//IL_00ea: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: 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_0121: Unknown result type (might be due to invalid IL or missing references)
			if (_inhaleWeights == null || _duration <= 0f)
			{
				return;
			}
			_elapsed += Time.deltaTime;
			if (Time.unscaledTime < _nextUpdate)
			{
				return;
			}
			_nextUpdate = Time.unscaledTime + 0.1f;
			float num = Mathf.Repeat(_elapsed, _duration) / _duration * (float)(_inhaleWeights.Length - 1);
			int num2 = Mathf.Clamp(Mathf.FloorToInt(num), 0, _inhaleWeights.Length - 2);
			float num3 = num - (float)num2;
			float num4 = Mathf.Lerp(_inhaleWeights[num2], _inhaleWeights[num2 + 1], num3);
			float num5 = Mathf.Lerp(_followWeights[num2], _followWeights[num2 + 1], num3);
			foreach (Part part in _parts)
			{
				for (int i = 0; i < part.Working.Length; i++)
				{
					part.Working[i] = part.Base[i] + part.Inhale[i] * num4 + part.Follow[i] * num5;
				}
				part.Mesh.vertices = part.Working;
			}
		}

		private void OnDestroy()
		{
			foreach (Part part in _parts)
			{
				if ((Object)(object)part.Mesh != (Object)null)
				{
					Object.Destroy((Object)(object)part.Mesh);
				}
			}
			_parts.Clear();
		}
	}
	[DefaultExecutionOrder(31000)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("gj.noisydog", "GJ Store", "1.0.24")]
	public sealed class CompanyShowroomPlugin : GJDogDollPlugin
	{
		[Serializable]
		private sealed class EditorLayout
		{
			public string format = "GJ_STORE_EDITOR_1";

			public bool hasAnchor;

			public Vector3 center;

			public Vector3 door;

			public float yaw;

			public float width;

			public float depth;

			public float height;

			public float doorWidth;

			public float doorHeight;

			public float doorCenterY;

			public float doorOffsetX;

			public float floorRise;

			public bool frontLining;

			public float counterX;

			public float counterZ;

			public float rackX;

			public float rackZ;

			public float merchantX;

			public float merchantZ;

			public float merchantHeight;

			public int pointLights;
		}

		private const string CompanyScene = "CompanyBuilding";

		private const string MessageName = "GJ.CompanyShowroom.v2";

		private const byte OpcodeRequestLayout = 1;

		private const byte OpcodeLayout = 2;

		private const byte OpcodeTake = 3;

		private const byte OpcodeClaimed = 4;

		private const byte OpcodeTint = 5;

		private const byte OpcodeLayoutState = 6;

		private const byte OpcodeDoorToggleRequest = 7;

		private const byte OpcodeDoorState = 8;

		private const byte OpcodeCloakReachRequest = 9;

		private const byte OpcodeCloakReach = 10;

		private static readonly string[] ColorNames = new string[16]
		{
			"빨강", "주황", "노랑", "초록", "파랑", "남색", "흰색", "검정", "연두", "하늘색",
			"갈색", "파스텔 분홍", "살색", "선명한 보라", "무지개", "찐한 분홍"
		};

		internal static readonly string[] ColorIds = new string[16]
		{
			"Red", "Orange", "Yellow", "Green", "Blue", "Purple", "White", "Black", "Lime", "SkyBlue",
			"Beige", "HotPink", "LightPink", "DeepSkyBlue", "Rainbow", "VividPink"
		};

		private static readonly Color[] Colors = (Color[])(object)new Color[16]
		{
			Hex("B5213A"),
			Hex("D36013"),
			Hex("E2B831"),
			Hex("469E6C"),
			Hex("2453B5"),
			Hex("232D70"),
			Hex("DDE6E8"),
			Hex("050505"),
			Hex("68A620"),
			Hex("4998CD"),
			Hex("764B29"),
			Hex("F2AACB"),
			Hex("D5967D"),
			Hex("923BEE"),
			Color.white,
			Hex("DA2280")
		};

		private ConfigEntry<bool> _autoPlace;

		private ConfigEntry<bool> _autoFirstPlace;

		private ConfigEntry<bool> _preferNearHost;

		private ConfigEntry<bool> _statusOverlay;

		private ConfigEntry<bool> _showCloakedMerchant;

		private ConfigEntry<float> _merchantFrontX;

		private ConfigEntry<float> _merchantFrontZ;

		private ConfigEntry<float> _merchantHeightMeters;

		private ConfigEntry<bool> _useCloak20;

		private ConfigEntry<float> _cloakNearHz;

		private ConfigEntry<float> _cloakFarHz;

		private ConfigEntry<float> _cloakFarDistance;

		private ConfigEntry<float> _cloakPauseDistance;

		private ConfigEntry<bool> _cloakCastShadows;

		private ConfigEntry<int> _interiorLightCount;

		private ConfigEntry<bool> _entranceMat10;

		private ConfigEntry<bool> _lowerWallWood12;

		private ConfigEntry<bool> _alchemyInterior18;

		private ConfigEntry<bool> _alchemyLighting18;

		private ConfigEntry<float> _deskAdvance15;

		private ConfigEntry<float> _deskDoorClearZ15;

		private ConfigEntry<float> _merchantCounterGap15;

		private ConfigEntry<bool> _standaloneMerchantHouse;

		private ConfigEntry<bool> _showContainerAnnex;

		private ConfigEntry<float> _containerLocalX;

		private ConfigEntry<float> _containerLocalZ;

		private GJContainerDoorRuntime _doorRuntime;

		private Cloak20PosePlayer _cloak20Pose;

		private bool _doorOpen;

		private bool _nativeBound;

		private VanillaCompanyContainer.Anchor _nativeAnchor;

		private ConfigEntry<bool> _nativeManualBound;

		private ConfigEntry<bool> _nativeCalibration041;

		private ConfigEntry<bool> _nativeCalibration042;

		private bool _previewActive;

		private VanillaCompanyContainer.Anchor _previewAnchor;

		private GameObject _previewVisual;

		private ConfigEntry<float> _nativeCenterX;

		private ConfigEntry<float> _nativeCenterY;

		private ConfigEntry<float> _nativeCenterZ;

		private ConfigEntry<float> _nativeDoorX;

		private ConfigEntry<float> _nativeDoorY;

		private ConfigEntry<float> _nativeDoorZ;

		private ConfigEntry<float> _nativeYaw;

		private ConfigEntry<float> _nativeWidth;

		private ConfigEntry<float> _nativeDepth;

		private ConfigEntry<float> _nativeHeight;

		private string _nativeFindStatus = "Searching for original vanilla blue container near DepositItemsDesk";

		private float _nextNativeErrorLog;

		private ConfigEntry<float> _savedX;

		private ConfigEntry<float> _savedY;

		private ConfigEntry<float> _savedZ;

		private ConfigEntry<float> _savedYaw;

		private ConfigEntry<int> _limit;

		private ConfigEntry<bool> _unlimitedDebug;

		private GameObject _showroom;

		private GameObject[] _display = (GameObject[])(object)new GameObject[16];

		private bool[] _claimed = new bool[16];

		private readonly Dictionary<ulong, int> _spawnedTint = new Dictionary<ulong, int>();

		private readonly Dictionary<ulong, int> _tintAttempts = new Dictionary<ulong, int>();

		private static Texture2D _rainbowTexture;

		private Vector3 _shopPosition;

		private float _shopYaw;

		private bool _placed;

		private bool _inCompany;

		private bool _messagingReady;

		private NetworkManager _registeredNetwork;

		private float _nextTick;

		private float _nextLayoutRequest;

		private float _nextAutoPlaceTry;

		private bool _overlayHiddenByUser;

		private static GUIStyle _statusStyle;

		private Item _vanillaShovel;

		private static CompanyShowroomPlugin _instance;

		private ConfigFile StoreConfig;

		private bool _gjItemsFirstUpdateLogged;

		private bool _gjItemsFirstLateUpdateLogged;

		private int _gjItemsUpdateFrame = -1;

		private int _gjItemsLateUpdateFrame = -1;

		private float _gjItemsNextErrorLog;

		private const byte OpcodeDeskSlotRequest23 = 12;

		private const byte OpcodeDeskSlotState23 = 13;

		private const float DeskSlotReach23 = 3.25f;

		private const float DeskSlotHoldGrace23 = 2.5f;

		private const float DeskSlotReleaseCooldown23 = 0.35f;

		private Transform _shovelPlacementDesk;

		private BoxCollider _shovelPlacementSurface;

		private Transform _shovelSlotMarker23;

		private ulong _deskSlotItemId23;

		private float _deskSlotGraceUntil23;

		private float _deskSlotLastAction23;

		private float _deskSlotAwaitSince23;

		private ulong _deskSlotSnappedObjectId25;

		private float _deskSlotMeshLift25;

		private ConfigEntry<float> _editDoorWidth;

		private ConfigEntry<float> _editDoorHeight;

		private ConfigEntry<float> _editDoorCenterY;

		private ConfigEntry<float> _editDoorOffsetX;

		private ConfigEntry<float> _editFloorRise;

		private ConfigEntry<float> _editCounterX;

		private ConfigEntry<float> _editCounterZ;

		private ConfigEntry<float> _editRackX;

		private ConfigEntry<float> _editRackZ;

		private ConfigEntry<float> _editMerchantZ;

		private ConfigEntry<bool> _editFrontLining;

		private ConfigEntry<bool> _enableNativeShell049;

		private bool _editorOpen;

		private int _editorTab;

		private Vector2 _editorScroll;

		private Rect _editorWindow = new Rect(24f, 75f, 525f, 615f);

		private string _editorNotice = "F10: 편집기 열기 | 노란 선은 설계 미리보기이며 원본 벽은 절단하지 않습니다.";

		private readonly Dictionary<string, string> _editorInputs = new Dictionary<string, string>();

		private readonly Stack<EditorLayout> _editorUndo = new Stack<EditorLayout>();

		private readonly List<InputAction> _editorPausedGameActions = new List<InputAction>();

		private InputActionAsset _editorGameActions;

		private float _editorNextInputLookup;

		private bool _editorInputWarningShown;

		private Harmony _editorViewHarmony;

		private bool _editorViewCaptured;

		private PlayerControllerB _editorFrozenPlayer;

		private Camera _editorFrozenCamera;

		private Quaternion _editorFrozenBodyRotation;

		private Quaternion _editorFrozenWorldCameraRotation;

		private CursorLockMode _editorPreviousCursorLock;

		private bool _editorPreviousCursorVisible;

		private static readonly CultureInfo Invariant = CultureInfo.InvariantCulture;

		private const byte OpcodeFurnitureB = 11;

		private const int FurnitureCount = 6;

		private const int ShelfFirst = 4;

		private const int ShelfLast = 5;

		private const float ShelfSmall = 0.8f;

		private const float ShelfLarge = 1f;

		private static readonly string[] BNames = new string[17]
		{
			"상인", "책상", "삽 진열대", "입구 카펫", "서재 선반 왼쪽", "서재 선반 오른쪽", "감옥 1", "감옥 2", "감옥 3", "감옥 4",
			"감옥 5", "감옥 6", "감옥 7", "감옥 8", "GJ 간판", "감옥 문", "천장 전등"
		};

		private static readonly string[] BKeys = new string[17]
		{
			"Merchant", "Counter", "Rack", "Mat", "AlchemyShelfLeft", "AlchemyShelfRight", "PrisonStack1", "PrisonStack2", "PrisonStack3", "PrisonStack4",
			"PrisonStack5", "PrisonStack6", "PrisonStack7", "PrisonStack8", "StoreSign", "PrisonGate", "CeilingLight"
		};

		private readonly Transform[] _bFurniture = (Transform[])(object)new Transform[17];

		private readonly ConfigEntry<bool>[] _bSaved = new ConfigEntry<bool>[17];

		private readonly ConfigEntry<float>[] _bX = new ConfigEntry<float>[17];

		private readonly ConfigEntry<float>[] _bZ = new ConfigEntry<float>[17];

		private readonly ConfigEntry<float>[] _bYaw = new ConfigEntry<float>[17];

		private readonly ConfigEntry<float>[] _bSize = new ConfigEntry<float>[17];

		private readonly Vector3[] _bBeforePos = (Vector3[])(object)new Vector3[17];

		private readonly Quaternion[] _bBeforeRot = (Quaternion[])(object)new Quaternion[17];

		private readonly Vector3[] _bBeforeSize = (Vector3[])(object)new Vector3[17];

		private readonly Vector3[] _bRemotePos = (Vector3[])(object)new Vector3[17];

		private readonly float[] _bRemoteYaw = new float[17];

		private readonly float[] _bRemoteSize = new float[17];

		private bool _bHasRemoteLayout;

		private bool _bRemoteHasShelves;

		private bool _bOpen;

		private bool _bDragging;

		private int _bSelected;

		private Rect _bWindow = new Rect(30f, 65f, 510f, 700f);

		private string _bNotice = "마우스로 표시점을 끌어 이동하세요.";

		private ManualLogSource Log => ((BaseUnityPlugin)this).Logger;

		private string EditorFilePath => Path.Combine(Paths.ConfigPath, "GJ_Store_Editor_Layout.json");

		private static Color Hex(string hex)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			Color result = default(Color);
			ColorUtility.TryParseHtmlString("#" + hex, ref result);
			return result;
		}

		private void Awake()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_074d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0758: Unknown result type (might be due to invalid IL or missing references)
			//IL_0763: Unknown result type (might be due to invalid IL or missing references)
			InitializeGJItems();
			StoreConfig = new ConfigFile(Path.Combine(Paths.ConfigPath, "GJ.CompanyShowroom.cfg"), true);
			_instance = this;
			GJStoreItemsDriver.Install(this, ((BaseUnityPlugin)this).Logger);
			_autoPlace = StoreConfig.Bind<bool>("Placement", "AutomaticallyUseSavedPosition", true, "Use the saved host placement automatically when returning to Company.");
			_autoFirstPlace = StoreConfig.Bind<bool>("Placement", "AutoPlaceOnFirstCompanyVisit", true, "Automatically place the GJ shop on the first visit; host-near placement takes priority.");
			_preferNearHost = StoreConfig.Bind<bool>("Placement", "PreferNearHostAfterShipExit", true, "Wait until the host leaves the ship, then find visible open ground nearby. Disable to use the old selling-desk placement.");
			_statusOverlay = StoreConfig.Bind<bool>("Debug", "ShowShopStatusOverlay", true, "Show shop state, distance and controls in a small company-only overlay; F9 toggles visibility.");
			_showCloakedMerchant = StoreConfig.Bind<bool>("CloakedMerchant", "ShowCloakedMerchant", true, "Place CLOAK_08 at the front of the GJ Store counter with 4.8s idle breathing.");
			_merchantFrontX = StoreConfig.Bind<float>("CloakedMerchant", "FrontX", 0f, "Character horizontal offset from the center of the counter, in metres.");
			_merchantFrontZ = StoreConfig.Bind<float>("CloakedMerchant", "FrontZ", 2.2f, "Character stands ahead of the counter (local +Z), in metres. Default avoids the desk collider.");
			_merchantHeightMeters = StoreConfig.Bind<float>("CloakedMerchant", "TargetHeightMeters", 2.5f, "Exact intended visual height (metres); 2.50 by default. Old Scale config is ignored.");
			_useCloak20 = StoreConfig.Bind<bool>("CloakedMerchant", "UseCLOAK20Rigged", true, "Use original CLOAK_20 13-mesh model with idle, reach and cape flap instead of the older CLOAK_08 model.");
			_cloakNearHz = StoreConfig.Bind<float>("Performance", "CloakNearAnimationHz", 8f, "CLOAK_20 mesh updates per second while nearby (2-20). E-reach still uses >=10 Hz.");
			_cloakFarHz = StoreConfig.Bind<float>("Performance", "CloakFarAnimationHz", 2f, "CLOAK_20 mesh updates per second at medium range (0.5-10).");
			_cloakFarDistance = StoreConfig.Bind<float>("Performance", "CloakFarDistanceMeters", 10f, "Use lower animation rate when more than this many meters away.");
			_cloakPauseDistance = StoreConfig.Bind<float>("Performance", "CloakPauseDistanceMeters", 24f, "Pause animation mesh uploads when farther than this many meters; playback clock still advances.");
			_cloakCastShadows = StoreConfig.Bind<bool>("Performance", "CloakCastShadows", false, "Enable high-cost real-time shadows for the detailed double-sided CLOAK_20 model (off improves GPU FPS).");
			_interiorLightCount = StoreConfig.Bind<int>("Performance", "InteriorPointLights", 1, "Number of interior point lights (0-2). Default 1 reduces render cost; these lights never cast shadows.");
			_entranceMat10 = StoreConfig.Bind<bool>("Interior", "GJStoreEntranceMat10", true, "Place ONLY the GJ STORE welcome mat inside the real entrance. No extra lamps, props, signage, colliders or lighting edits.");
			_lowerWallWood12 = StoreConfig.Bind<bool>("Interior", "GJStoreLowerWoodWall12", true, "Wooden lower 1.2m wall panels on all 4 shop walls, entrance cut out. Cosmetic; no collision, shader effects, new lighting, or merchant shifts.");
			_alchemyInterior18 = StoreConfig.Bind<bool>("Interior", "GJStoreAlchemyLibrary18", true, "3D alchemy library: two antique bookcases, books, colored potions, brass armillary, skull, crystal dome, lanterns and shop sign. No vanilla save changes.");
			_alchemyLighting18 = StoreConfig.Bind<bool>("Interior", "GJStoreAlchemyWarmLights18", true, "Warm lantern glow for the new 3D library; turn off to keep only original lights.");
			_deskAdvance15 = StoreConfig.Bind<float>("Interior", "DeskForward15Meters", 1.1f, "Move merchant counter toward customer aisle from v14 (0-1.8 metres).");
			_deskDoorClearZ15 = StoreConfig.Bind<float>("Interior", "DeskAwayFromDoor15Meters", 1.1f, "Slide counter and seller deeper into shop away from doorway clearance (0-2m).");
			_merchantCounterGap15 = StoreConfig.Bind<float>("Interior", "MerchantBehindDeskGap15Meters", 0.3f, "Clear space between merchant collider and counter back (0.2-0.8m).");
			_standaloneMerchantHouse = StoreConfig.Bind<bool>("GJStore", "AutomaticMerchantHouse054", true, "Automatically replace ONLY the exactly verified blue Company ShippingContainer with GJ's full shop shell and furnishings. Original meshes/colliders are restored on scene exit. Does not touch Company terrain/CozyRoom.");
			_showContainerAnnex = StoreConfig.Bind<bool>("ContainerDoor", "ShowRightHandAnnex", false, "DEPRECATED: ignored since v0.1.33. We never spawn a second container. Door goes in the existing CompanyBuilding blue container.");
			_containerLocalX = StoreConfig.Bind<float>("ContainerDoor", "LocalX", 6.7f, "Right-hand container local position X relative to the GJ store showroom root.");
			_containerLocalZ = StoreConfig.Bind<float>("ContainerDoor", "LocalZ", 1.65f, "Right-hand container local position Z relative to the GJ store showroom root.");
			_nativeManualBound = StoreConfig.Bind<bool>("VanillaContainerDoor", "ManualTargetSaved", false, "Aimed at the ORIGINAL blue shipping-container front wall with Ctrl+F11. Overrides ambiguous auto detection.");
			_nativeCalibration041 = StoreConfig.Bind<bool>("VanillaContainerDoor", "ConfirmedBlueWallV041", false, "Safety gate for v0.1.33. True only after host aimed at the real blue wall and pressed Ctrl+F11. Old saved coordinates are ignored until then.");
			_nativeCalibration042 = StoreConfig.Bind<bool>("VanillaContainerDoor", "ConfirmedVisualPreviewV042", false, "Host visually confirmed the door/room preview in v0.1.33. Old collider-derived anchors are ignored.");
			_nativeCenterX = StoreConfig.Bind<float>("VanillaContainerDoor", "RoomX", 0f, "Native room center X");
			_nativeCenterY = StoreConfig.Bind<float>("VanillaContainerDoor", "RoomY", 0f, "Native room floor Y");
			_nativeCenterZ = StoreConfig.Bind<float>("VanillaContainerDoor", "RoomZ", 0f, "Native room center Z");
			_nativeDoorX = StoreConfig.Bind<float>("VanillaContainerDoor", "DoorX", 0f, "Native wall doorway center X");
			_nativeDoorY = StoreConfig.Bind<float>("VanillaContainerDoor", "DoorY", 0f, "Native wall doorway center Y");
			_nativeDoorZ = StoreConfig.Bind<float>("VanillaContainerDoor", "DoorZ", 0f, "Native wall doorway center Z");
			_nativeYaw = StoreConfig.Bind<float>("VanillaContainerDoor", "InwardYaw", 0f, "Inside-facing angle");
			_nativeWidth = StoreConfig.Bind<float>("VanillaContainerDoor", "Width", 8.2f, "Native blue container width");
			_nativeDepth = StoreConfig.Bind<float>("VanillaContainerDoor", "Depth", 4.5f, "Native blue container depth");
			_nativeHeight = StoreConfig.Bind<float>("VanillaContainerDoor", "Height", 3.3f, "Native blue container height");
			_savedX = StoreConfig.Bind<float>("Placement", "X", 0f, "Saved position X; set by Ctrl+F10.");
			_savedY = StoreConfig.Bind<float>("Placement", "Y", 0f, "Saved floor position Y; set by Ctrl+F10.");
			_savedZ = StoreConfig.Bind<float>("Placement", "Z", 0f, "Saved position Z; set by Ctrl+F10.");
			_savedYaw = StoreConfig.Bind<float>("Placement", "Yaw", 0f, "Saved yaw degrees; set by Ctrl+F10.");
			_limit = StoreConfig.Bind<int>("Stock", "MaxPickupsPerCompanyVisit", 16, "Deprecated in v0.1.15: global pickup limit is ignored. All 16 colors are available once per Company visit.");
			_unlimitedDebug = StoreConfig.Bind<bool>("Stock", "UnlimitedForTesting", false, "Deprecated: all 16 colors are always available once per Company visit.");
			InitializeEditor();
			InitializeFurnitureB();
			InstallEditorViewPatch();
			RuntimeMeshes.DirectoryPath = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Assets");
			try
			{
				RuntimeMeshes.Validate();
				Log.LogInfo((object)"Loaded original clean desk, wall rack, and 16 approved color GLB-derived meshes.");
			}
			catch (Exception ex)
			{
				Log.LogError((object)("3D asset loading failed: " + ex));
				((Behaviour)this).enabled = false;
				return;
			}
			if (_showCloakedMerchant.Value)
			{
				try
				{
					if (_useCloak20.Value)
					{
						Cloak20Merchant.Validate(RuntimeMeshes.DirectoryPath);
						Log.LogInfo((object)"CLOAK_20 source animations READY: 13 original meshes, 97-frame idle, 99-frame reach and weighted cape flap.");
					}
					else
					{
						CloakedMerchant.Validate(RuntimeMeshes.DirectoryPath);
					}
				}
				catch (Exception ex2)
				{
					Log.LogError((object)("CLOAK merchant preload failed; store still available: " + ex2));
				}
			}
			try
			{
				RuntimeMeshes.GetLocalBounds("MerchantDoorLeaf");
				RuntimeMeshes.GetLocalBounds("MerchantDoorFrame");
				RuntimeMeshes.GetLocalBounds("MerchantInterior");
				Log.LogInfo((object)"NATIVE BLUE CONTAINER DOOR ASSETS READY: frame, door, furnished interior; NO duplicate container.");
			}
			catch (Exception ex3)
			{
				Log.LogError((object)("Original container door asset preload failed (store safe): " + ex3));
			}
			SceneManager.sceneUnloaded += OnSceneUnloaded;
			Log.LogInfo((object)"GJ Store v1.0.24: v25 normal vanilla drop + visible anchored shovel above counter; E pickup, B edited desk, 16 colors and save rules preserved.");
		}

		private void OnApplicationQuit()
		{
			GJStoreItemsDriver.ShutdownForQuit(this);
		}

		private void OnDestroy()
		{
			GJStoreItemsDriver.OnOwnerDestroyed(this);
			CloseFurnitureB(commit: false);
			CloseEditor();
			UninstallEditorViewPatch();
			ClearPreview();
			VanillaCompanyContainer.Restore();
			SceneManager.sceneUnloaded -= OnSceneUnloaded;
			if ((Object)(object)_registeredNetwork != (Object)null)
			{
				_registeredNetwork.OnClientConnectedCallback -= OnClientConnected;
			}
		}

		private bool IsCompany()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			Scene sceneByName = SceneManager.GetSceneByName("CompanyBuilding");
			if (!((Scene)(ref sceneByName)).IsValid() || !((Scene)(ref sceneByName)).isLoaded)
			{
				return false;
			}
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)instance.currentLevel == (Object)null)
			{
				return false;
			}
			if (!(instance.currentLevel.sceneName == "CompanyBuilding") && instance.currentLevel.levelID != 3)
			{
				if (!string.IsNullOrEmpty(instance.currentLevel.PlanetName))
				{
					return instance.currentLevel.PlanetName.IndexOf("Gordion", StringComparison.OrdinalIgnoreCase) >= 0;
				}
				return false;
			}
			return true;
		}

		internal void TickFromStartOfRound()
		{
			Update();
			LateUpdate();
		}

		internal void TickDetachedItems()
		{
			int frameCount = Time.frameCount;
			if (_gjItemsUpdateFrame != frameCount)
			{
				_gjItemsUpdateFrame = frameCount;
				if (!_gjItemsFirstUpdateLogged)
				{
					_gjItemsFirstUpdateLogged = true;
					Log.LogWarning((object)"[GJ ITEMS CORE v31] Detached owner: item Update is running without merchant/editor logic.");
				}
				try
				{
					UpdateItems();
				}
				catch (Exception ex)
				{
					if (Time.unscaledTime >= _gjItemsNextErrorLog)
					{
						_gjItemsNextErrorLog = Time.unscaledTime + 5f;
						Log.LogError((object)("[GJ ITEMS CORE v31] Detached UpdateItems failed: " + ex));
					}
				}
			}
			if (_gjItemsLateUpdateFrame == frameCount)
			{
				return;
			}
			_gjItemsLateUpdateFrame = frameCount;
			if (!_gjItemsFirstLateUpdateLogged)
			{
				_gjItemsFirstLateUpdateLogged = true;
				Log.LogWarning((object)"[GJ ITEMS CORE v31] Detached owner: item LateUpdate is running.");
			}
			try
			{
				LateUpdateItems();
			}
			catch (Exception ex2)
			{
				if (Time.unscaledTime >= _gjItemsNextErrorLog)
				{
					_gjItemsNextErrorLog = Time.unscaledTime + 5f;
					Log.LogError((object)("[GJ ITEMS CORE v31] Detached LateUpdateItems failed: " + ex2));
				}
			}
		}

		private void Update()
		{
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Expected O, but got Unknown
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_058a: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_040b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_042f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_0447: Unknown result type (might be due to invalid IL or missing references)
			//IL_044c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0481: Unknown result type (might be due to invalid IL or missing references)
			//IL_048d: 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_02df: 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_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: 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_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_062e: Unknown result type (might be due to invalid IL or missing references)
			//IL_063a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0794: Unknown result type (might be due to invalid IL or missing references)
			//IL_0799: Unknown result type (might be due to invalid IL or missing references)
			//IL_0810: Unknown result type (might be due to invalid IL or missing references)
			if (_gjItemsUpdateFrame == Time.frameCount)
			{
				return;
			}
			_gjItemsUpdateFrame = Time.frameCount;
			if (!_gjItemsFirstUpdateLogged)
			{
				_gjItemsFirstUpdateLogged = true;
				_ = Log;
			}
			try
			{
				UpdateItems();
			}
			catch (Exception ex)
			{
				if (Time.unscaledTime >= _gjItemsNextErrorLog)
				{
					_gjItemsNextErrorLog = Time.unscaledTime + 5f;
					Log.LogError((object)("[GJ ITEMS CORE v29] UpdateItems failed: " + ex));
				}
			}
			NetworkManager singleton = NetworkManager.Singleton;
			if ((Object)(object)singleton != (Object)(object)_registeredNetwork)
			{
				if ((Object)(object)_registeredNetwork != (Object)null)
				{
					_registeredNetwork.OnClientConnectedCallback -= OnClientConnected;
				}
				_registeredNetwork = singleton;
				_messagingReady = false;
			}
			if ((Object)(object)singleton != (Object)null && !singleton.IsListening && _messagingReady)
			{
				singleton.OnClientConnectedCallback -= OnClientConnected;
				_messagingReady = false;
			}
			if ((Object)(object)singleton != (Object)null && singleton.IsListening && !_messagingReady)
			{
				singleton.CustomMessagingManager.RegisterNamedMessageHandler("GJ.CompanyShowroom.v2", new HandleNamedMessageDelegate(OnMessage));
				singleton.OnClientConnectedCallback += OnClientConnected;
				_messagingReady = true;
			}
			bool flag = IsCompany();
			if (flag && !_inCompany)
			{
				_inCompany = true;
				_placed = false;
				_claimed = new bool[16];
				_doorOpen = false;
				_bHasRemoteLayout = false;
				_nativeBound = false;
				CloseFurnitureB(commit: false);
				CloseEditor();
				ClearPreview();
				_nextAutoPlaceTry = 0f;
				_nextLayoutRequest = 0f;
				_overlayHiddenByUser = false;
				_ = Log;
			}
			else if (!flag && _inCompany)
			{
				_inCompany = false;
				_placed = false;
				CloseFurnitureB(commit: false);
				CloseEditor();
				ClearPreview();
				DestroyShowroom();
			}
			if (!flag)
			{
				return;
			}
			UpdateFurnitureB();
			HandleEditorKeyboard();
			if ((Object)(object)singleton != (Object)null && singleton.IsListening && singleton.IsServer && !_placed && Time.unscaledTime >= _nextAutoPlaceTry)
			{
				_nextAutoPlaceTry = Time.unscaledTime + 3f;
				VanillaCompanyContainer.Anchor anchor = default(VanillaCompanyContainer.Anchor);
				string reason = "";
				if (_standaloneMerchantHouse.Value)
				{
					if (GJNativeShellReplacement.TryFindStandaloneHouseAnchor(new Vector3(_nativeDoorX.Value, _nativeDoorY.Value, _nativeDoorZ.Value), _editDoorWidth.Value, _editDoorHeight.Value, out anchor, out reason))
					{
						if (_standaloneMerchantHouse.Value)
						{
							Vector3 val = anchor.Rotation * Vector3.right;
							float num = Vector3.Dot(anchor.Door - anchor.Center, val);
							float num2 = anchor.Width * 0.5f - _editDoorWidth.Value * 0.5f - 0.32f;
							float num3 = Mathf.Clamp(num - 0.52f, 0f - num2, num2);
							ref Vector3 door = ref anchor.Door;
							door += val * (num3 - num);
							_ = Log;
							_ = "GJ 058 verified entrance shift away from desk: localX=" + num3.ToString("F2") + ", width=" + _editDoorWidth.Value.ToString("F2") + "m";
						}
						_nativeBound = true;
						_nativeAnchor = anchor;
						_nativeWidth.Value = anchor.Width;
						_nativeDepth.Value = anchor.Depth;
						_nativeHeight.Value = anchor.Height;
						_editDoorCenterY.Value = anchor.Door.y - anchor.Center.y;
						_editDoorOffsetX.Value = Vector3.Dot(anchor.Door - anchor.Center, anchor.Rotation * Vector3.right);
						_nativeFindStatus = "AUTO CUSTOM HOUSE: " + reason;
						_ = Log;
						_ = _nativeFindStatus;
						PlaceHost(anchor.Center, ((Quaternion)(ref anchor.Rotation)).eulerAngles.y, fromSaved: true);
					}
					else
					{
						_nativeFindStatus = "CUSTOM HOUSE NOT BUILT: " + reason;
						if (Time.unscaledTime > _nextNativeErrorLog)
						{
							_nextNativeErrorLog = Time.unscaledTime + 12f;
							Log.LogWarning((object)_nativeFindStatus);
						}
					}
				}
				else if (!_nativeManualBound.Value || !_nativeCalibration042.Value)
				{
					anchor = default(VanillaCompanyContainer.Anchor);
					reason = (_nativeFindStatus = "UNBOUND: host must preview blue wall with Ctrl+F11 and confirm with Ctrl+F11");
					if (Time.unscaledTime > _nextNativeErrorLog && !_previewActive)
					{
						_nextNativeErrorLog = Time.unscaledTime + 12f;
						Log.LogWarning((object)("GJ Store position protection: " + reason + "; old saved coordinates are deliberately ignored."));
					}
				}
				else
				{
					anchor = VanillaCompanyContainer.FromSynced(new Vector3(_nativeCenterX.Value, _nativeCenterY.Value, _nativeCenterZ.Value), new Vector3(_nativeDoorX.Value, _nativeDoorY.Value, _nativeDoorZ.Value), _nativeYaw.Value, _nativeWidth.Value, _nativeDepth.Value, _nativeHeight.Value);
					reason = "v0.1.33 host-confirmed original blue container doorway";
				}
				if (!_standaloneMerchantHouse.Value && anchor.Width > 0.1f)
				{
					_nativeBound = true;
					_nativeAnchor = anchor;
					_nativeFindStatus = "Found: " + reason;
					PlaceHost(anchor.Center, ((Quaternion)(ref anchor.Rotation)).eulerAngles.y, fromSaved: true);
				}
			}
			Keyboard current = Keyboard.current;
			if (!_editorOpen && !_bOpen && (Object)(object)singleton != (Object)null && singleton.IsListening && current != null && ((ButtonControl)current.eKey).wasPressedThisFrame && !TryPlaceHeldShovelOnDesk() && !TryDoorInteraction() && !TryMerchantReach())
			{
				TryAimedDisplayPickup();
			}
			if (current != null && false)
			{
				_overlayHiddenByUser = !_overlayHiddenByUser;
			}
			if ((Object)(object)singleton != (Object)null && singleton.IsServer && current != null && (((ButtonControl)current.leftCtrlKey).isPressed || ((ButtonControl)current.rightCtrlKey).isPressed))
			{
				if (false && _standaloneMerchantHouse.Value)
				{
					_ = Log;
				}
				else if (false)
				{
					CalibrateNativeDoorway();
				}
				else if (false)
				{
					ClearPreview();
					_nativeFindStatus = "Preview cancelled; Ctrl+F11 to preview again";
					_ = Log;
				}
				else if (_previewActive && (((ButtonControl)current.leftArrowKey).wasPressedThisFrame || ((ButtonControl)current.rightArrowKey).wasPressedThisFrame || ((ButtonControl)current.upArrowKey).wasPressedThisFrame || ((ButtonControl)current.downArrowKey).wasPressedThisFrame))
				{
					Vector3 zero = Vector3.zero;
					if (((ButtonControl)current.leftArrowKey).wasPressedThisFrame)
					{
						zero.x -= 0.25f;
					}
					if (((ButtonControl)current.rightArrowKey).wasPressedThisFrame)
					{
						zero.x += 0.25f;
					}
					if (((ButtonControl)current.upArrowKey).wasPressedThisFrame)
					{
						zero.z += 0.25f;
					}
					if (((ButtonControl)current.downArrowKey).wasPressedThisFrame)
					{
						zero.z -= 0.25f;
					}
					ShiftPreview(zero);
				}
				else if (false)
				{
					_ = Log;
				}
			}
			if (Time.unscaledTime < _nextTick)
			{
				return;
			}
			_nextTick = Time.unscaledTime + 0.75f;
			if ((Object)(object)singleton != (Object)null && singleton.IsClient && !singleton.IsServer && !_placed && Time.unscaledTime >= _nextLayoutRequest)
			{
				_nextLayoutRequest = Time.unscaledTime + 3f;
				SendRequestLayout();
			}
			if (!((Object)(object)singleton != (Object)null) || singleton.SpawnManager == null)
			{
				return;
			}
			foreach (KeyValuePair<ulong, int> item in _spawnedTint)
			{
				if (singleton.SpawnManager.SpawnedObjects.TryGetValue(item.Key, out var value) && (Object)(object)value != (Object)null)
				{
					_tintAttempts.TryGetValue(item.Key, out var value2);
					if (value2 < 3)
					{
						ApplyVanillaShovelTint(value, item.Value);
						_tintAttempts[item.Key] = value2 + 1;
					}
				}
			}
		}

		private void OnGUI()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Invalid comparison between Unknown and I4
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Invalid comparison between Unknown and I4
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Expected O, but got Unknown
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: Unknown result type (might be due to invalid IL or missing references)
			DrawEditorGUI();
			DrawFurnitureBGUI();
			if (!_inCompany || ((int)Event.current.type != 7 && (int)Event.current.type != 8))
			{
				return;
			}
			NetworkManager singleton = NetworkManager.Singleton;
			bool flag = (Object)(object)singleton != (Object)null && singleton.IsServer;
			PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null);
			if (_statusStyle == null)
			{
				_statusStyle = new GUIStyle(GUI.skin.label);
				_statusStyle.fontSize = 13;
				_statusStyle.fontStyle = (FontStyle)1;
				_statusStyle.normal.textColor = new Color(1f, 0.92f, 0.52f, 1f);
				_statusStyle.alignment = (TextAnchor)0;
			}
			string text = ShovelDeskSlotPrompt23() ?? (IsDoorAimed() ? "[E] 컨테이너 문 열기 / 닫기" : (IsMerchantAimed() ? "[E] 상인과 거래하기" : null));
			if (text == null && CageAudioPlugin.CageTimeline.GJGateAim)
			{
				text = (CageAudioPlugin.CageTimeline.GJGateOpen ? "[E] 감옥 문 닫기" : "[E] 감옥 문 열기");
			}
			if (text == null)
			{
				int num = FindAimedDisplay();
				if (num >= 0)
				{
					text = "[E] " + ColorNames[num] + " 삽 꺼내기";
				}
			}
			if (text != null)
			{
				GUI.Label(new Rect(Mathf.Max(8f, (float)Screen.width * 0.5f - 170f), Mathf.Max(8f, (float)Screen.height * 0.5f + 34f), 340f, 28f), text, _statusStyle);
			}
		}

		private void CalibrateNativeDoorway()
		{
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: 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_02bf: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null);
			VanillaCompanyContainer.Anchor anchor;
			string explanation;
			if ((Object)(object)val == (Object)null || !val.isPlayerControlled || val.isPlayerDead || val.isInHangarShipRoom)
			{
				Log.LogWarning((object)"GJ preview refused: leave the ship and use an active host player.");
			}
			else if (_previewActive)
			{
				float num = Vector3.Distance(((Component)val).transform.position, _previewAnchor.Door);
				if (num > 7f)
				{
					string reason = "Not an opted-in F10 original-container application";
					if (!_editorOpen || !_enableNativeShell049.Value || !GJNativeShellReplacement.CanApplyExactContainerFromEditor(_previewAnchor, ((Component)val).transform.position, out reason))
					{
						_nativeFindStatus = "PREVIEW CONFIRM FAILED: door " + num.ToString("F2") + "m from host. " + reason;
						Log.LogWarning((object)("GJ preview confirmation refused: " + _nativeFindStatus));
						if (!_editorOpen)
						{
							ClearPreview();
						}
						return;
					}
					_ = Log;
					_ = "GJ 051 verified F10 edit despite door distance=" + num.ToString("F2") + "m: " + reason;
				}
				EditorUpdateAnchorForDimensions(newPreview: false);
				VanillaCompanyContainer.Anchor previewAnchor = _previewAnchor;
				ClearPreview();
				_nativeManualBound.Value = true;
				_nativeCalibration042.Value = true;
				_nativeCenterX.Value = previewAnchor.Center.x;
				_nativeCenterY.Value = previewAnchor.Center.y;
				_nativeCenterZ.Value = previewAnchor.Center.z;
				_nativeDoorX.Value = previewAnchor.Door.x;
				_nativeDoorY.Value = previewAnchor.Door.y;
				_nativeDoorZ.Value = previewAnchor.Door.z;
				_nativeYaw.Value = ((Quaternion)(ref previewAnchor.Rotation)).eulerAngles.y;
				_nativeWidth.Value = previewAnchor.Width;
				_nativeDepth.Value = previewAnchor.Depth;
				_nativeHeight.Value = previewAnchor.Height;
				_nativeAnchor = previewAnchor;
				_nativeBound = true;
				_nativeFindStatus = "HOST CONFIRMED visible preview " + ((Vector3)(ref previewAnchor.Door)).ToString("F2");
				Log.LogMessage((object)("GJ Store visual preview CONFIRMED: door=" + ((Vector3)(ref previewAnchor.Door)).ToString("F2") + " room=" + ((Vector3)(ref previewAnchor.Center)).ToString("F2") + "; vanilla Company meshes/colliders untouched."));
				PlaceHost(previewAnchor.Center, ((Quaternion)(ref previewAnchor.Rotation)).eulerAngles.y, fromSaved: true);
			}
			else if (!VanillaCompanyContainer.TryFindViewAlignedPreview(LocalCamera(), ((Component)val).transform.position, out anchor, out explanation))
			{
				_nativeFindStatus = explanation;
				Log.LogWarning((object)("GJ Ctrl+F11 preview refused: " + explanation));
			}
			else
			{
				_previewAnchor = anchor;
				_previewActive = true;
				EditorUpdateAnchorForDimensions(newPreview: true);
				ShowPreview();
				_nativeFindStatus = "PREVIEW: " + explanation;
				Log.LogMessage((object)("GJ DOOR PREVIEW READY: " + explanation + ". Yellow outline shows door/room. Ctrl+arrows move 0.25m; Ctrl+F11 CONFIRM; Ctrl+F12 CANCEL."));
			}
		}

		private void ShiftPreview(Vector3 localShift)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if (_previewActive)
			{
				Vector3 val = _previewAnchor.Rotation * localShift;
				ref Vector3 door = ref _previewAnchor.Door;
				door += val;
				ref Vector3 center = ref _previewAnchor.Center;
				center += val;
				ShowPreview();
				_ = Log;
				_ = "GJ preview moved: door=" + ((Vector3)(ref _previewAnchor.Door)).ToString("F2") + ", room=" + ((Vector3)(ref _previewAnchor.Center)).ToString("F2");
			}
		}

		private void ClearPreview()
		{
			if ((Object)(object)_previewVisual != (Object)null)
			{
				Object.Destroy((Object)(object)_previewVisual);
			}
			_previewVisual = null;
			_previewActive = false;
		}

		private void ShowPreview()
		{
			if ((Object)(object)_previewVisual != (Object)null)
			{
				Object.Destroy((Object)(object)_previewVisual);
			}
			_previewVisual = GJDoorPreview.Create(_previewAnchor, _editDoorWidth.Value, _editDoorHeight.Value, _editDoorOffsetX.Value);
		}

		private bool SavedPoseExists()
		{
			if (Mathf.Approximately(_savedX.Value, 0f) && Mathf.Approximately(_savedY.Value, 0f))
			{
				return !Mathf.Approximately(_savedZ.Value, 0f);
			}
			return true;
		}

		private bool TryFindNearHostPlacement(out Vector3 result, out float yaw)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: 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_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: 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_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: 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_0153: 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_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: 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_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: 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_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: 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_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: 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_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: 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_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			result = Vector3.zero;
			yaw = 0f;
			PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null);
			if ((Object)(object)val == (Object)null || !val.isPlayerControlled || val.isPlayerDead || val.isInHangarShipRoom)
			{
				return false;
			}
			Vector3 position = ((Component)val).transform.position;
			Vector3 forward = ((Component)val).transform.forward;
			forward.y = 0f;
			if (((Vector3)(ref forward)).sqrMagnitude < 0.01f)
			{
				forward = Vector3.forward;
			}
			((Vector3)(ref forward)).Normalize();
			Vector3 val2 = Vector3.Cross(Vector3.up, forward);
			Vector3[] array = new Vector3[9];
			Vector3 val3 = val2 * 0.92f + forward * 0.39f;
			array[0] = ((Vector3)(ref val3)).normalized;
			val3 = -val2 * 0.92f + forward * 0.39f;
			array[1] = ((Vector3)(ref val3)).normalized;
			val3 = val2 * 0.72f - forward * 0.69f;
			array[2] = ((Vector3)(ref val3)).normalized;
			val3 = -val2 * 0.72f - forward * 0.69f;
			array[3] = ((Vector3)(ref val3)).normalized;
			val3 = forward * 0.98f + val2 * 0.2f;
			array[4] = ((Vector3)(ref val3)).normalized;
			val3 = forward * 0.98f - val2 * 0.2f;
			array[5] = ((Vector3)(ref val3)).normalized;
			array[6] = val2;
			array[7] = -val2;
			array[8] = -forward;
			Vector3[] array2 = (Vector3[])(object)array;
			RaycastHit val5 = default(RaycastHit);
			RaycastHit val10 = default(RaycastHit);
			for (int i = 0; i < 2; i++)
			{
				float num = ((i == 0) ? 5.3f : 7f);
				for (int j = 0; j < array2.Length; j++)
				{
					Vector3 val4 = position + array2[j] * num;
					if (!Physics.Raycast(val4 + Vector3.up * 3.5f, Vector3.down, ref val5, 8f, -1, (QueryTriggerInteraction)1) || ((RaycastHit)(ref val5)).normal.y < 0.8f || Mathf.Abs(((RaycastHit)(ref val5)).point.y - position.y) > 1.8f)
					{
						continue;
					}
					val4.y = ((RaycastHit)(ref val5)).point.y;
					Vector3 val6 = position - val4;
					val6.y = 0f;
					if (((Vector3)(ref val6)).sqrMagnitude < 0.01f)
					{
						continue;
					}
					Quaternion val7 = Quaternion.LookRotation(((Vector3)(ref val6)).normalized, Vector3.up);
					float y = ((Quaternion)(ref val7)).eulerAngles.y;
					if (IsBoothSpaceOpen(val4, y))
					{
						Vector3 val8 = position + Vector3.up * 1.5f;
						Vector3 val9 = val4 + Vector3.up * 1.03f;
						if (!Physics.Linecast(val8, val9, ref val10, -1, (QueryTriggerInteraction)1) || !(Vector3.Distance(((RaycastHit)(ref val10)).point, val9) > 1.3f))
						{
							result = val4;
							yaw = y;
							_ = Log;
							_ = "Found near-host showroom floor: host=" + ((Vector3)(ref position)).ToString("F2") + " target=" + ((Vector3)(ref result)).ToString("F2") + " radius=" + num.ToString("F1");
							return true;
						}
					}
				}
			}
			return false;
		}

		private bool TryFindAutomaticPlacement(out Vector3 result, out float yaw)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: 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_0158: 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_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: 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_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be d