Decompiled source of ShelterFromThe27thOfMarch v1.0.0

plugins/ShelterFromThe27thOfMarch.dll

Decompiled 3 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ShelterFromThe27thOfMarch")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+db9d62552b7cd7b9eef5bf5645b319c4a13d0425")]
[assembly: AssemblyProduct("ShelterFromThe27thOfMarch")]
[assembly: AssemblyTitle("ShelterFromThe27thOfMarch")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ShelterFromThe27thOfMarch
{
	internal static class Assets
	{
		private const int SoundRate = 24000;

		private static readonly Dictionary<string, Mesh> meshes = new Dictionary<string, Mesh>();

		private static readonly Dictionary<string, AudioClip> sounds = new Dictionary<string, AudioClip>();

		private static readonly int[] AdpcmSteps = new int[89]
		{
			7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
			19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
			50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
			130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
			337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
			876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
			2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
			5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
			15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
		};

		private static readonly int[] AdpcmIndex = new int[8] { -1, -1, -1, -1, 2, 4, 6, 8 };

		private static AudioMixerGroup mixer;

		private static AudioMixerGroup Mixer
		{
			get
			{
				if (Object.op_Implicit((Object)(object)mixer) || !Object.op_Implicit((Object)(object)AudioManager.instance) || !Object.op_Implicit((Object)(object)AudioManager.instance.SoundMasterGroup))
				{
					return mixer;
				}
				AudioMixerGroup[] array = AudioManager.instance.SoundMasterGroup.audioMixer.FindMatchingGroups("Sound Effects");
				mixer = ((array.Length != 0) ? array[0] : AudioManager.instance.SoundMasterGroup);
				return mixer;
			}
		}

		internal static byte[] Bytes(string name)
		{
			using Stream stream = typeof(Assets).Assembly.GetManifestResourceStream("ShelterFromThe27thOfMarch." + name);
			if (stream == null)
			{
				throw new FileNotFoundException("Embedded asset missing: " + name);
			}
			byte[] array = new byte[stream.Length];
			for (int i = 0; i < array.Length; i += stream.Read(array, i, array.Length - i))
			{
			}
			return array;
		}

		internal static Mesh LoadMesh(string name)
		{
			//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_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_00fa: 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_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Expected O, but got Unknown
			if (meshes.TryGetValue(name, out var value) && Object.op_Implicit((Object)(object)value))
			{
				return value;
			}
			byte[] array = Bytes(name + ".mesh");
			int num = BitConverter.ToInt32(array, 0);
			int num2 = BitConverter.ToInt32(array, 4);
			int num3 = 8;
			Vector3[] array2 = (Vector3[])(object)new Vector3[num];
			Vector3[] array3 = (Vector3[])(object)new Vector3[num];
			Vector2[] array4 = (Vector2[])(object)new Vector2[num];
			int[] array5 = new int[num2];
			int num4 = 0;
			while (num4 < num)
			{
				array2[num4] = new Vector3(F(array, num3), F(array, num3 + 4), F(array, num3 + 8));
				num4++;
				num3 += 12;
			}
			int num5 = 0;
			while (num5 < num)
			{
				array3[num5] = new Vector3(F(array, num3), F(array, num3 + 4), F(array, num3 + 8));
				num5++;
				num3 += 12;
			}
			int num6 = 0;
			while (num6 < num)
			{
				array4[num6] = new Vector2(F(array, num3), F(array, num3 + 4));
				num6++;
				num3 += 8;
			}
			int num7 = 0;
			while (num7 < num2)
			{
				array5[num7] = BitConverter.ToInt32(array, num3);
				num7++;
				num3 += 4;
			}
			Mesh val = new Mesh
			{
				name = name
			};
			if (num > 65535)
			{
				val.indexFormat = (IndexFormat)1;
			}
			val.vertices = array2;
			val.normals = array3;
			val.uv = array4;
			val.triangles = array5;
			val.RecalculateBounds();
			return meshes[name] = val;
		}

		private static float F(byte[] b, int o)
		{
			return BitConverter.ToSingle(b, o);
		}

		internal static Texture2D LoadTexture(string name)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_002f: Expected O, but got Unknown
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true)
			{
				name = name,
				wrapMode = (TextureWrapMode)1
			};
			ImageConversion.LoadImage(val, Bytes(name + ".png"));
			return val;
		}

		internal static Texture2D LoadCompressed(string name, bool linear = false)
		{
			//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)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0036: 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_0046: Expected O, but got Unknown
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, linear)
			{
				name = name,
				wrapMode = (TextureWrapMode)1,
				anisoLevel = 4
			};
			ImageConversion.LoadImage(val, Bytes(name + ".png"));
			val.Compress(true);
			val.Apply(false, true);
			return val;
		}

		internal static Material Metal(Material mat, Texture2D normal, float metallic, float smoothness)
		{
			string[] array = new string[2] { "_NormalTexture", "_BumpMap" };
			foreach (string text in array)
			{
				if (mat.HasProperty(text))
				{
					mat.SetTexture(text, (Texture)(object)normal);
				}
			}
			array = new string[2] { "_NormalStrength", "_BumpScale" };
			foreach (string text2 in array)
			{
				if (mat.HasProperty(text2))
				{
					mat.SetFloat(text2, 1f);
				}
			}
			mat.EnableKeyword("_NORMALMAP");
			if (mat.HasProperty("_Metallic"))
			{
				mat.SetFloat("_Metallic", metallic);
			}
			array = new string[2] { "_Smoothness", "_Glossiness" };
			foreach (string text3 in array)
			{
				if (mat.HasProperty(text3))
				{
					mat.SetFloat(text3, smoothness);
				}
			}
			return mat;
		}

		internal static Texture2D LoadPalette(string name)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0036: Expected O, but got Unknown
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false)
			{
				name = name,
				wrapMode = (TextureWrapMode)1,
				filterMode = (FilterMode)0
			};
			ImageConversion.LoadImage(val, Bytes(name + ".png"));
			return val;
		}

		internal static AudioClip LoadSound(string name)
		{
			if (sounds.TryGetValue(name, out var value) && Object.op_Implicit((Object)(object)value))
			{
				return value;
			}
			float[] array;
			if (Has(name + ".adpcm"))
			{
				array = Adpcm(Bytes(name + ".adpcm"));
			}
			else
			{
				byte[] array2 = Bytes(name + ".pcm");
				array = new float[array2.Length / 2];
				for (int i = 0; i < array.Length; i++)
				{
					array[i] = (float)BitConverter.ToInt16(array2, i * 2) / 32768f;
				}
			}
			value = AudioClip.Create(name, array.Length, 1, 24000, false);
			value.SetData(array, 0);
			return sounds[name] = value;
		}

		private static bool Has(string name)
		{
			return typeof(Assets).Assembly.GetManifestResourceInfo("ShelterFromThe27thOfMarch." + name) != null;
		}

		private static float[] Adpcm(byte[] b)
		{
			int num = BitConverter.ToInt32(b, 0);
			float[] array = new float[num];
			int num2 = 0;
			int num3 = 0;
			for (int i = 0; i < num; i++)
			{
				int num4 = (b[4 + (i >> 1)] >> (i & 1) * 4) & 0xF;
				int num5 = AdpcmSteps[num3];
				int num6 = num5 >> 3;
				if ((num4 & 4) != 0)
				{
					num6 += num5;
				}
				if ((num4 & 2) != 0)
				{
					num6 += num5 >> 1;
				}
				if ((num4 & 1) != 0)
				{
					num6 += num5 >> 2;
				}
				num2 = Mathf.Clamp(((num4 & 8) != 0) ? (num2 - num6) : (num2 + num6), -32768, 32767);
				num3 = Mathf.Clamp(num3 + AdpcmIndex[num4 & 7], 0, 88);
				array[i] = (float)num2 / 32768f;
			}
			return array;
		}

		private static AudioSource Source(string label, AudioClip clip, Transform parent, float volume, float maxDistance)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Shelter " + label + " " + (Object.op_Implicit((Object)(object)clip) ? ((Object)clip).name : "?"));
			val.transform.SetParent(parent, false);
			AudioSource obj = val.AddComponent<AudioSource>();
			obj.clip = clip;
			obj.volume = volume;
			obj.spatialBlend = 1f;
			obj.rolloffMode = (AudioRolloffMode)1;
			obj.minDistance = 1.5f;
			obj.maxDistance = maxDistance;
			obj.dopplerLevel = 0f;
			obj.outputAudioMixerGroup = Mixer;
			return obj;
		}

		internal static void Play(AudioClip clip, Transform follow, float volume = 1f, float maxDistance = 15f)
		{
			if (Object.op_Implicit((Object)(object)clip))
			{
				AudioSource obj = Source("Sound", clip, follow, volume, maxDistance);
				obj.Play();
				Object.Destroy((Object)(object)((Component)obj).gameObject, clip.length + 0.2f);
			}
		}

		internal static AudioSource Loop(AudioClip clip, Transform follow, float volume = 1f, float maxDistance = 15f)
		{
			AudioSource val = Source("Loop", clip, follow, volume, maxDistance);
			val.loop = true;
			if (Object.op_Implicit((Object)(object)clip))
			{
				val.time = Random.Range(0f, clip.length);
				val.Play();
			}
			return val;
		}

		internal static Material MakeMaterial(Material baseMat, string name, Texture2D albedo, float smoothness = 0.15f)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_00e3: 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)
			Material val = (Object.op_Implicit((Object)(object)baseMat) ? new Material(baseMat) : new Material(Shader.Find("Standard")));
			((Object)val).name = name;
			string[] array = new string[4] { "_BaseTexture", "_MainTex", "_BaseMap", "_AlbedoTexture" };
			foreach (string text in array)
			{
				if (val.HasProperty(text))
				{
					val.SetTexture(text, (Texture)(object)albedo);
				}
			}
			array = new string[2] { "_NormalTexture", "_BumpMap" };
			foreach (string text2 in array)
			{
				if (val.HasProperty(text2))
				{
					val.SetTexture(text2, (Texture)null);
				}
			}
			array = new string[3] { "_BaseColor", "_Color", "_AlbedoColor" };
			foreach (string text3 in array)
			{
				if (val.HasProperty(text3))
				{
					val.SetColor(text3, Color.white);
				}
			}
			array = new string[4] { "_MetallicTexture", "_SmoothnessTexture", "_MetallicGlossMap", "_SpecGlossMap" };
			foreach (string text4 in array)
			{
				if (val.HasProperty(text4))
				{
					val.SetTexture(text4, (Texture)null);
				}
			}
			val.DisableKeyword("_METALLICGLOSSMAP");
			val.DisableKeyword("_SPECGLOSSMAP");
			val.DisableKeyword("_NORMALMAP");
			if (val.HasProperty("_SmoothnessTextureChannel"))
			{
				val.SetFloat("_SmoothnessTextureChannel", 0f);
			}
			if (val.HasProperty("_GlossMapScale"))
			{
				val.SetFloat("_GlossMapScale", 1f);
			}
			if (val.HasProperty("_Metallic"))
			{
				val.SetFloat("_Metallic", 0f);
			}
			array = new string[2] { "_Smoothness", "_Glossiness" };
			foreach (string text5 in array)
			{
				if (val.HasProperty(text5))
				{
					val.SetFloat(text5, smoothness);
				}
			}
			if (val.HasProperty("_EmissionColor"))
			{
				val.SetColor("_EmissionColor", Color.black);
			}
			if (val.HasProperty("_EmissionTexture"))
			{
				val.SetTexture("_EmissionTexture", (Texture)null);
			}
			if (val.HasProperty("_TilingX"))
			{
				val.SetFloat("_TilingX", 1f);
				val.SetFloat("_TilingY", 1f);
			}
			if (val.HasProperty("_OffsetX"))
			{
				val.SetFloat("_OffsetX", 0f);
				val.SetFloat("_OffsetY", 0f);
			}
			return val;
		}
	}
	internal static class Loot
	{
		internal static readonly string[] Small = new string[2] { "Valuables/02 Small/Valuable Wizard Love Potion", "Valuables/02 Small/Valuable Museum Car" };

		internal static readonly string[] Big = new string[2] { "Valuables/04 Big/Valuable Manor Television", "Valuables/04 Big/Valuable Museum Boombox" };

		private static readonly HashSet<string> Keep = new HashSet<string>
		{
			"PhotonView", "PhotonTransformView", "PhotonRigidbodyView", "ValuableObject", "PhysGrabObject", "PhysGrabObjectImpactDetector", "RoomVolumeCheck", "PhysGrabObjectBoxCollider", "PhysGrabObjectCollider", "PhysGrabObjectMeshCollider",
			"NotValuableObject"
		};

		internal const string SolidSmall = "Valuables/02 Small/Valuable Museum Car";

		private static Dictionary<string, Object> presets;

		internal static void FrameIcon(GameObject root, Bounds local, float pitch = 0f, float margin = 1.15f)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_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_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: 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_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: 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_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: 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_015b: 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_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			Transform val = root.transform.Find("SemiIcon Maker");
			if (Object.op_Implicit((Object)(object)val))
			{
				SemiIconMaker component = ((Component)val).GetComponent<SemiIconMaker>();
				Camera val2 = ((Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.iconCamera)) ? component.iconCamera : ((Component)val).GetComponentInChildren<Camera>(true));
				Transform val3 = (Object.op_Implicit((Object)(object)val2) ? ((Component)val2).transform : val);
				if (pitch != 0f)
				{
					val.rotation = Quaternion.AngleAxis(pitch, val3.right) * val.rotation;
				}
				float num = Mathf.Tan((Object.op_Implicit((Object)(object)val2) ? val2.fieldOfView : 30f) * 0.5f * (MathF.PI / 180f));
				float num2 = ((Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.renderTexture)) ? ((float)((Texture)component.renderTexture).width / (float)((Texture)component.renderTexture).height) : 1f);
				float num3 = num * num2;
				Transform transform = root.transform;
				Vector3 val4 = transform.InverseTransformDirection(val3.forward);
				Vector3 val5 = transform.InverseTransformDirection(val3.right);
				Vector3 val6 = transform.InverseTransformDirection(val3.up);
				float num4 = 0f;
				float num5 = 0f;
				for (int i = 0; i < 8; i++)
				{
					Vector3 val7 = Vector3.Scale(((Bounds)(ref local)).extents, new Vector3((float)(((i & 1) != 0) ? 1 : (-1)), (float)(((i & 2) != 0) ? 1 : (-1)), (float)(((i & 4) != 0) ? 1 : (-1))));
					float num6 = Vector3.Dot(val7, val5);
					float num7 = Vector3.Dot(val7, val6);
					float num8 = Vector3.Dot(val7, val4);
					num4 = Mathf.Max(new float[3]
					{
						num4,
						margin * Mathf.Abs(num6) / num3 - num8,
						margin * Mathf.Abs(num7) / num - num8
					});
					num5 = Mathf.Max(num5, 0f - num8);
				}
				if (Object.op_Implicit((Object)(object)val2))
				{
					num4 = Mathf.Max(num4, num5 + val2.nearClipPlane + 0.02f);
				}
				Vector3 val8 = transform.TransformPoint(((Bounds)(ref local)).center - val4 * num4);
				val.position += val8 - val3.position;
			}
		}

		internal static GameObject Holder(string name)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0026: Expected O, but got Unknown
			GameObject val = new GameObject("Shelter Prefabs " + name);
			val.SetActive(false);
			((Object)val).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)val);
			return val;
		}

		internal static GameObject CloneValuable(string[] bases, string name, out Material baseMat, out BoxCollider box)
		{
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = null;
			for (int i = 0; i < bases.Length; i++)
			{
				val = Resources.Load<GameObject>(bases[i]);
				if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.GetComponent<ValuableObject>()) && Object.op_Implicit((Object)(object)val.GetComponentInChildren<BoxCollider>(true)))
				{
					break;
				}
				val = null;
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				throw new Exception("No vanilla valuable to build on (looked for " + string.Join(", ", bases) + ").");
			}
			GameObject val2 = Object.Instantiate<GameObject>(val, Holder(name).transform);
			((Object)val2).name = name;
			MonoBehaviour[] componentsInChildren = val2.GetComponentsInChildren<MonoBehaviour>(true);
			foreach (MonoBehaviour val3 in componentsInChildren)
			{
				if (Object.op_Implicit((Object)(object)val3) && !Keep.Contains(((object)val3).GetType().Name))
				{
					Object.DestroyImmediate((Object)(object)val3);
				}
			}
			AudioSource[] componentsInChildren2 = val2.GetComponentsInChildren<AudioSource>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren2[i]);
			}
			baseMat = null;
			Renderer[] componentsInChildren3 = val2.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val4 in componentsInChildren3)
			{
				if (!Object.op_Implicit((Object)(object)baseMat) && val4 is MeshRenderer)
				{
					baseMat = val4.sharedMaterial;
				}
				val4.enabled = false;
			}
			Light[] componentsInChildren4 = val2.GetComponentsInChildren<Light>(true);
			for (int i = 0; i < componentsInChildren4.Length; i++)
			{
				((Behaviour)componentsInChildren4[i]).enabled = false;
			}
			box = null;
			Collider[] componentsInChildren5 = val2.GetComponentsInChildren<Collider>(true);
			foreach (Collider val5 in componentsInChildren5)
			{
				if (!Object.op_Implicit((Object)(object)box))
				{
					BoxCollider val6 = (BoxCollider)(object)((val5 is BoxCollider) ? val5 : null);
					if (val6 != null)
					{
						box = val6;
						continue;
					}
				}
				val5.enabled = false;
			}
			if (!Object.op_Implicit((Object)(object)box))
			{
				throw new Exception("\"" + ((Object)val).name + "\" has no box collider to reuse.");
			}
			if ((Object)(object)((Component)box).gameObject == (Object)(object)val2)
			{
				GameObject val7 = new GameObject("Valuable Box Collider")
				{
					layer = val2.layer,
					tag = val2.tag
				};
				val7.transform.SetParent(val2.transform, false);
				BoxCollider val8 = val7.AddComponent<BoxCollider>();
				((Collider)val8).sharedMaterial = ((Collider)box).sharedMaterial;
				((Collider)box).enabled = false;
				box = val8;
			}
			else
			{
				((Component)box).transform.SetParent(val2.transform, false);
			}
			return val2;
		}

		internal static void LookLike(GameObject go, string path, ref Material baseMat)
		{
			GameObject val = Resources.Load<GameObject>(path);
			if (!Object.op_Implicit((Object)(object)val))
			{
				Plugin.Log.LogWarning((object)(((Object)go).name + ": no \"" + path + "\" to borrow a look from."));
				return;
			}
			MeshRenderer[] componentsInChildren = val.GetComponentsInChildren<MeshRenderer>(true);
			foreach (MeshRenderer val2 in componentsInChildren)
			{
				if (Object.op_Implicit((Object)(object)((Renderer)val2).sharedMaterial) && ((Renderer)val2).sharedMaterial.renderQueue < 2500)
				{
					baseMat = ((Renderer)val2).sharedMaterial;
					break;
				}
			}
			ValuableObject component = val.GetComponent<ValuableObject>();
			ValuableObject component2 = go.GetComponent<ValuableObject>();
			if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component2) && Object.op_Implicit((Object)(object)component.audioPreset))
			{
				component2.audioPreset = component.audioPreset;
			}
		}

		internal static void FitBox(BoxCollider box, Bounds b)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)box).transform;
			transform.localPosition = Vector3.zero;
			transform.localRotation = Quaternion.identity;
			transform.localScale = Vector3.one;
			box.center = ((Bounds)(ref b)).center;
			box.size = ((Bounds)(ref b)).size;
		}

		internal static BoxCollider AddBox(BoxCollider like, Bounds b)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = Object.Instantiate<GameObject>(((Component)like).gameObject, ((Component)like).transform.parent, false);
			((Object)obj).name = ((Object)((Component)like).gameObject).name + " (extra)";
			BoxCollider component = obj.GetComponent<BoxCollider>();
			FitBox(component, b);
			return component;
		}

		internal static void SetValue(GameObject go, Type volume, int min, int max, string label)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			ValuableObject component = go.GetComponent<ValuableObject>();
			component.volumeType = volume;
			Value val = ScriptableObject.CreateInstance<Value>();
			((Object)val).name = "Value - " + label;
			val.valueMin = min;
			val.valueMax = Mathf.Max(min, max);
			Object.DontDestroyOnLoad((Object)(object)val);
			component.valuePreset = val;
		}

		internal static void Feel(GameObject go, string mass, string durability, string sound)
		{
			ValuableObject component = go.GetComponent<ValuableObject>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			if (presets == null)
			{
				presets = new Dictionary<string, Object>();
				Resources.LoadAll<GameObject>("Valuables");
				PhysAttribute[] array = Resources.FindObjectsOfTypeAll<PhysAttribute>();
				foreach (PhysAttribute val in array)
				{
					presets["PhysAttribute " + ((Object)val).name.Replace("PhysAttribute ", "")] = (Object)(object)val;
				}
				Durability[] array2 = Resources.FindObjectsOfTypeAll<Durability>();
				foreach (Durability val2 in array2)
				{
					presets["Durability " + ((Object)val2).name.Replace("Durability ", "").Trim()] = (Object)(object)val2;
				}
				PhysAudio[] array3 = Resources.FindObjectsOfTypeAll<PhysAudio>();
				foreach (PhysAudio val3 in array3)
				{
					presets["PhysAudio " + ((Object)val3).name.Replace("PhysAudio - ", "")] = (Object)(object)val3;
				}
			}
			if (mass != null)
			{
				PhysAttribute val4 = Find<PhysAttribute>("PhysAttribute " + mass);
				if (Object.op_Implicit((Object)(object)val4))
				{
					component.physAttributePreset = val4;
				}
			}
			if (durability != null)
			{
				Durability val5 = Find<Durability>("Durability " + durability);
				if (Object.op_Implicit((Object)(object)val5))
				{
					component.durabilityPreset = val5;
				}
			}
			if (sound != null)
			{
				PhysAudio val6 = Find<PhysAudio>("PhysAudio " + sound);
				if (Object.op_Implicit((Object)(object)val6))
				{
					component.audioPreset = val6;
				}
			}
			T Find<T>(string key) where T : Object
			{
				if (presets.TryGetValue(key, out var value))
				{
					T val7 = (T)(object)((value is T) ? value : null);
					if (val7 != null)
					{
						return val7;
					}
				}
				Plugin.Log.LogWarning((object)(((Object)go).name + ": no vanilla preset \"" + key + "\" (kept the base valuable's)."));
				return default(T);
			}
		}

		internal static PrefabRef Register(GameObject loot, bool inLevels)
		{
			PrefabRef result = (inLevels ? Valuables.RegisterValuable(loot) : NetworkPrefabs.RegisterNetworkPrefab("Valuables/" + ((Object)loot).name, loot)) ?? throw new Exception("REPOLib refused to register " + ((Object)loot).name + ".");
			Plugin.Log.LogInfo((object)("Registered " + ((Object)loot).name + (inLevels ? " (level loot)." : " (spawned only).")));
			return result;
		}

		internal static void HoldUpright(PhysGrabObject pgo, float torque = 6f, float massWhileHeld = -1f)
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)pgo) || !pgo.grabbed)
			{
				return;
			}
			bool flag = false;
			foreach (PhysGrabber item in pgo.playerGrabbing)
			{
				if (!Object.op_Implicit((Object)(object)item) || !Object.op_Implicit((Object)(object)item.playerAvatar) || !Object.op_Implicit((Object)(object)item.playerAvatar.localCamera))
				{
					continue;
				}
				if (item.isRotating)
				{
					flag = true;
					continue;
				}
				Transform overrideTransform = item.playerAvatar.localCamera.GetOverrideTransform();
				if (Object.op_Implicit((Object)(object)overrideTransform))
				{
					Vector3 val = overrideTransform.forward;
					val.y = 0f;
					if (((Vector3)(ref val)).sqrMagnitude < 0.001f)
					{
						val = overrideTransform.up;
					}
					val.y = 0f;
					val = -((Vector3)(ref val)).normalized;
					Quaternion val2 = Quaternion.Inverse(item.physRotation);
					item.cameraRelativeGrabbedForward = val2 * overrideTransform.InverseTransformDirection(val);
					item.cameraRelativeGrabbedUp = val2 * overrideTransform.InverseTransformDirection(Vector3.up);
				}
			}
			pgo.OverrideTorqueStrength(flag ? 2f : torque, 0.1f);
			pgo.OverrideAngularDrag(20f, 0.1f);
			if (massWhileHeld > 0f)
			{
				pgo.OverrideMass(massWhileHeld, 0.1f);
			}
		}
	}
	[HarmonyPatch]
	internal static class Patches
	{
		[HarmonyPatch(typeof(ItemInfoUI), "ItemInfoText")]
		[HarmonyPrefix]
		private static bool HoldToldText(string message)
		{
			string showingNow = Tell.ShowingNow;
			if (showingNow != null)
			{
				return message == showingNow;
			}
			return true;
		}

		[HarmonyPatch(typeof(LevelGenerator), "GenerateDoneApply")]
		[HarmonyPostfix]
		private static void LevelReady()
		{
			try
			{
				Shelter.LevelReady();
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Shelter: " + ex));
			}
		}

		[HarmonyPatch(typeof(PlayerHealth), "Hurt")]
		[HarmonyPrefix]
		private static bool ShelteredHurt(PlayerHealth __instance)
		{
			if (Shelter.LocalInside)
			{
				return !((Object)(object)__instance.playerAvatar == (Object)(object)PlayerAvatar.instance);
			}
			return true;
		}

		[HarmonyPatch(typeof(PlayerAvatar), "PlayerDeath")]
		[HarmonyPrefix]
		private static bool ShelteredDeath(PlayerAvatar __instance)
		{
			if (Shelter.LocalInside)
			{
				return !((Object)(object)__instance == (Object)(object)PlayerAvatar.instance);
			}
			return true;
		}

		[HarmonyPatch(typeof(SemiFunc), "LevelPointsGetPlayerDistance")]
		[HarmonyPrefix]
		private static bool ShelteredDistance(float _minDistance, float _maxDistance, bool _startRoomOnly, ref List<LevelPoint> __result)
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			if (!Shelter.AnyoneInside || !Object.op_Implicit((Object)(object)LevelGenerator.Instance) || !Object.op_Implicit((Object)(object)GameDirector.instance))
			{
				return true;
			}
			List<LevelPoint> list = new List<LevelPoint>();
			foreach (LevelPoint levelPathPoint in LevelGenerator.Instance.LevelPathPoints)
			{
				if (!Object.op_Implicit((Object)(object)levelPathPoint) || (_startRoomOnly && !levelPathPoint.inStartRoom) || (Object.op_Implicit((Object)(object)levelPathPoint.Room) && levelPathPoint.Room.Truck))
				{
					continue;
				}
				float num = 999f;
				bool flag = false;
				Vector3 position = ((Component)levelPathPoint).transform.position;
				foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
				{
					if (Object.op_Implicit((Object)(object)player) && !player.isDisabled)
					{
						float num2 = Vector3.Distance(position, Shelter.Where(player));
						if (num2 < num)
						{
							num = num2;
						}
						if (num2 < _maxDistance)
						{
							flag = true;
						}
					}
				}
				if (num > _minDistance && flag)
				{
					list.Add(levelPathPoint);
				}
			}
			__result = list;
			return false;
		}
	}
	internal static class Tell
	{
		private static string showing;

		private static float until;

		internal static string ShowingNow
		{
			get
			{
				if (showing == null || !(Time.time < until))
				{
					return null;
				}
				return showing;
			}
		}

		internal static void Local(string text, float seconds = 3f)
		{
			if (Object.op_Implicit((Object)(object)ItemInfoUI.instance))
			{
				showing = text;
				until = Time.time + seconds;
				ItemInfoUI.instance.ItemInfoText((ItemAttributes)null, text, false);
			}
		}

		internal static void Tick()
		{
			string showingNow = ShowingNow;
			if (showingNow != null && Object.op_Implicit((Object)(object)ItemInfoUI.instance))
			{
				ItemInfoUI.instance.ItemInfoText((ItemAttributes)null, showingNow, false);
			}
		}
	}
	[BepInPlugin("bigbootyteam.shelterfromthe27thofmarch", "ShelterFromThe27thOfMarch", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "bigbootyteam.shelterfromthe27thofmarch";

		public const string Name = "ShelterFromThe27thOfMarch";

		public const string Version = "1.0.0";

		internal static ManualLogSource Log;

		internal static ConfigEntry<float> ShelterChance;

		internal static ConfigEntry<float> ShelterSafeSeconds;

		internal static ConfigEntry<float> ShelterHealPerSecond;

		internal static ConfigEntry<int> ShelterMaxMonsters;

		internal static ConfigEntry<int> ShelterPerBreach;

		private void Awake()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			ShelterChance = ((BaseUnityPlugin)this).Config.Bind<float>("Shelter", "ChancePerLevel", 0.3f, new ConfigDescription("Chance its door turns up in a level, set into a bare wall.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			ShelterSafeSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Shelter", "SafeSeconds", 30f, "How long anyone can stay inside before the dangerous monsters break out (and again every this many seconds while anyone stays).");
			ShelterMaxMonsters = ((BaseUnityPlugin)this).Config.Bind<int>("Shelter", "MaxMonsters", 20, "Most monsters it can let loose in one level, in all. Many more and the game may struggle.");
			ShelterPerBreach = ((BaseUnityPlugin)this).Config.Bind<int>("Shelter", "MonstersPerBreach", 6, "How many it lets loose each breach: different tier 2 and tier 3 monsters, one of each, picked at random.");
			ShelterHealPerSecond = ((BaseUnityPlugin)this).Config.Bind<float>("Shelter", "HealPerSecond", 1f, "Health that slowly comes back each second inside.");
			new Harmony("bigbootyteam.shelterfromthe27thofmarch").PatchAll(typeof(Patches));
			try
			{
				Shelter.BuildAndRegister();
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Could not add the shelter: " + ex));
			}
		}
	}
	internal class Shelter : MonoBehaviour
	{
		internal static class Room
		{
			private static GameObject room;

			private static Texture2D cookie;

			internal static void Make()
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Expected O, but got Unknown
				//IL_0026: 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_003b: Expected O, but got Unknown
				//IL_012f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0157: Unknown result type (might be due to invalid IL or missing references)
				//IL_0190: Unknown result type (might be due to invalid IL or missing references)
				//IL_0195: Unknown result type (might be due to invalid IL or missing references)
				//IL_019a: Unknown result type (might be due to invalid IL or missing references)
				//IL_019f: Unknown result type (might be due to invalid IL or missing references)
				//IL_01df: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_0204: Unknown result type (might be due to invalid IL or missing references)
				//IL_0218: Unknown result type (might be due to invalid IL or missing references)
				//IL_026c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0271: 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_02af: Unknown result type (might be due to invalid IL or missing references)
				byte[] b;
				int i;
				if (!Object.op_Implicit((Object)(object)room))
				{
					room = new GameObject("Shelter from the 27th of March (inside)");
					room.transform.position = Origin;
					GameObject val = new GameObject("Room");
					val.transform.SetParent(room.transform, false);
					val.AddComponent<MeshFilter>().sharedMesh = Assets.LoadMesh("shelter_room");
					((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = roomMat;
					Concrete(val.transform, "shelter_floor", "shelter_floor", 3f);
					Concrete(val.transform, "shelter_ceiling", "shelter_ceiling", 3f);
					Concrete(val.transform, "shelter_walls", "shelter_wall", 2.4f);
					Concrete(val.transform, "shelter_pillars", "shelter_pillar", 1.75f, pillars: true);
					b = Assets.Bytes("shelter_room.cols");
					int num = BitConverter.ToInt32(b, 0);
					for (i = 0; i < num; i++)
					{
						BoxCollider obj = val.AddComponent<BoxCollider>();
						obj.center = new Vector3(F(0), F(1), F(2));
						obj.size = new Vector3(F(3), F(4), F(5));
					}
					if (SemiFunc.IsMasterClientOrSingleplayer() && exitPrefab != null)
					{
						NetworkPrefabs.SpawnNetworkPrefab(exitPrefab, Origin + ExitDoorAt, Quaternion.identity, (byte)0, (object[])null);
					}
					float[] array = new float[2] { -2.5f, 2.5f };
					foreach (float num2 in array)
					{
						Window(new Vector3(num2, 2.3f, -4.975f), new Vector2(1.5f, 2.4f));
						Light obj2 = Lamp(new Vector3(num2, 2.5f, -4.8f), new Color(0.82f, 0.88f, 1f), 3.2f, 16f);
						obj2.type = (LightType)0;
						obj2.spotAngle = 50f;
						obj2.innerSpotAngle = 20f;
						obj2.cookie = (Texture)(object)PaneCookie();
						((Component)obj2).transform.localRotation = Quaternion.LookRotation(new Vector3((0f - num2) * 0.06f, -0.12f, 1f));
					}
					Lamp(new Vector3(0f, 2f, -2.5f), new Color(0.7f, 0.75f, 0.85f), 0.25f, 9f).shadows = (LightShadows)0;
					Blood(room.transform);
					Props.Furnish(room.transform);
					Assets.Loop(Assets.LoadSound("shelter_hum"), room.transform, 0.35f, 30f);
				}
				float F(int k)
				{
					return BitConverter.ToSingle(b, 4 + (i * 6 + k) * 4);
				}
			}

			private static void Window(Vector3 at, Vector2 size)
			{
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: 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_0074: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_008d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Expected O, but got Unknown
				//IL_00a9: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
				GameObject obj = GameObject.CreatePrimitive((PrimitiveType)5);
				Object.Destroy((Object)(object)obj.GetComponent<Collider>());
				((Object)obj).name = "Window";
				obj.transform.SetParent(room.transform, false);
				obj.transform.localPosition = at;
				obj.transform.localScale = new Vector3(size.x, size.y, 1f);
				obj.transform.localRotation = Quaternion.Euler(0f, 180f, 0f);
				Material val = new Material(Shader.Find("Standard"))
				{
					name = "Shelter Window"
				};
				val.color = new Color(0.85f, 0.9f, 0.95f);
				val.EnableKeyword("_EMISSION");
				val.SetColor("_EmissionColor", new Color(0.85f, 0.9f, 1f) * 1.6f);
				val.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)0;
				obj.GetComponent<Renderer>().sharedMaterial = val;
				obj.GetComponent<Renderer>().shadowCastingMode = (ShadowCastingMode)0;
			}

			private static void Concrete(Transform parent, string mesh, string tex, float tile, bool pillars = false)
			{
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01de: Unknown result type (might be due to invalid IL or missing references)
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_0134: Unknown result type (might be due to invalid IL or missing references)
				//IL_0140: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f7: 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_0175: 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_0184: Unknown result type (might be due to invalid IL or missing references)
				//IL_018a: Unknown result type (might be due to invalid IL or missing references)
				//IL_018f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0151: 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_0160: 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_016b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0114: Unknown result type (might be due to invalid IL or missing references)
				//IL_011b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0122: Unknown result type (might be due to invalid IL or missing references)
				//IL_0128: 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_008d: 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_009c: 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_00c4: 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)
				Mesh val = Object.Instantiate<Mesh>(Assets.LoadMesh(mesh));
				((Object)val).name = mesh + " (mapped)";
				Vector3[] vertices = val.vertices;
				Vector3[] normals = val.normals;
				Vector2[] array = (Vector2[])(object)new Vector2[vertices.Length];
				Vector3 val4 = default(Vector3);
				for (int i = 0; i < vertices.Length; i++)
				{
					Vector3 val2 = vertices[i];
					Vector3 val3 = ((normals.Length > i) ? normals[i] : Vector3.up);
					if (pillars)
					{
						((Vector3)(ref val4))..ctor((val2.x < 0f) ? (-1.6f) : 1.6f, 0f, 0.8f);
						float num = Mathf.Atan2(val2.x - val4.x, 0f - (val2.z - val4.z));
						array[i] = new Vector2(num / (MathF.PI * 2f) + 0.5f, (0f - val2.y) / tile);
					}
					else if (Mathf.Abs(val3.y) >= Mathf.Abs(val3.x) && Mathf.Abs(val3.y) >= Mathf.Abs(val3.z))
					{
						array[i] = new Vector2(val2.x, val2.z) / tile;
					}
					else if (Mathf.Abs(val3.x) >= Mathf.Abs(val3.z))
					{
						array[i] = new Vector2(val2.z, 0f - val2.y) / tile;
					}
					else
					{
						array[i] = new Vector2(val2.x, 0f - val2.y) / tile;
					}
				}
				val.uv = array;
				Texture2D val5 = Assets.LoadTexture(tex);
				((Texture)val5).wrapMode = (TextureWrapMode)0;
				((Texture)val5).filterMode = (FilterMode)2;
				((Texture)val5).anisoLevel = 8;
				GameObject val6 = new GameObject(mesh);
				val6.transform.SetParent(parent, false);
				val6.AddComponent<MeshFilter>().sharedMesh = val;
				Material val7 = Assets.MakeMaterial(concreteBase, "Shelter from the 27th of March " + tex, val5, 0f);
				if (val7.HasProperty("_FresnelAmount"))
				{
					val7.SetFloat("_FresnelAmount", 0f);
				}
				((Renderer)val6.AddComponent<MeshRenderer>()).sharedMaterial = val7;
			}

			private static Texture2D PaneCookie()
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Expected O, but got Unknown
				//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
				if (Object.op_Implicit((Object)(object)cookie))
				{
					return cookie;
				}
				cookie = new Texture2D(128, 128, (TextureFormat)4, false)
				{
					wrapMode = (TextureWrapMode)1,
					name = "Shelter Window Light"
				};
				Color32[] array = (Color32[])(object)new Color32[16384];
				for (int i = 0; i < 128; i++)
				{
					for (int j = 0; j < 128; j++)
					{
						float num = (float)j / 127f;
						float num2 = (float)i / 127f;
						bool num3 = num < 0.2f || num > 0.8f || num2 < 0.12f || num2 > 0.88f;
						bool flag = Mathf.Abs(num - 0.5f) < 0.022f || Mathf.Abs(num2 - 0.5f) < 0.022f;
						byte b = (byte)((!(num3 || flag)) ? 255u : 0u);
						array[i * 128 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, b);
					}
				}
				cookie.SetPixels32(array);
				cookie.Apply();
				return cookie;
			}

			private static void Blood(Transform room)
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: 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_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_0094: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00db: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0100: Unknown result type (might be due to invalid IL or missing references)
				//IL_011b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0120: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_015b: 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_017b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0180: Unknown result type (might be due to invalid IL or missing references)
				//IL_018e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0193: Unknown result type (might be due to invalid IL or missing references)
				//IL_019b: 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_01bd: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
				//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_0237: 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_0265: Unknown result type (might be due to invalid IL or missing references)
				//IL_026a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0293: Unknown result type (might be due to invalid IL or missing references)
				//IL_0298: 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_02c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_0388: Unknown result type (might be due to invalid IL or missing references)
				//IL_038d: Unknown result type (might be due to invalid IL or missing references)
				//IL_057b: Unknown result type (might be due to invalid IL or missing references)
				//IL_05ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_05e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_05ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_0608: Unknown result type (might be due to invalid IL or missing references)
				//IL_060d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0628: Unknown result type (might be due to invalid IL or missing references)
				//IL_062d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0648: Unknown result type (might be due to invalid IL or missing references)
				//IL_064d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0668: Unknown result type (might be due to invalid IL or missing references)
				//IL_066d: Unknown result type (might be due to invalid IL or missing references)
				//IL_067b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0680: Unknown result type (might be due to invalid IL or missing references)
				//IL_0688: Unknown result type (might be due to invalid IL or missing references)
				//IL_069e: Unknown result type (might be due to invalid IL or missing references)
				//IL_06a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_06b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_06bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_06c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_06c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0462: Unknown result type (might be due to invalid IL or missing references)
				//IL_0467: Unknown result type (might be due to invalid IL or missing references)
				//IL_0495: Unknown result type (might be due to invalid IL or missing references)
				//IL_049a: Unknown result type (might be due to invalid IL or missing references)
				//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_07a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_07d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_080a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0535: Unknown result type (might be due to invalid IL or missing references)
				//IL_053a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0734: Unknown result type (might be due to invalid IL or missing references)
				Vector3[] array = (Vector3[])(object)new Vector3[5]
				{
					new Vector3(0.4f, 0.38f, 3.694f),
					new Vector3(0.4f, 1.18f, 3.694f),
					new Vector3(-1.05f, 0.38f, 3.694f),
					new Vector3(2.05f, 0.38f, 3.694f),
					new Vector3(-3f, 0.38f, 1.994f)
				};
				foreach (Vector3 at in array)
				{
					Decal.Flat(room, "shelter_logo", at, Vector3.back, 0.23f, 0f);
				}
				Vector4[] array2 = (Vector4[])(object)new Vector4[6]
				{
					new Vector4(0.4f, 2f, 1.3f, 0f),
					new Vector4(-0.8f, 3.1f, 0.8f, 1f),
					new Vector4(1.6f, -0.5f, 0.7f, 2f),
					new Vector4(-2f, -2.2f, 0.6f, 3f),
					new Vector4(0.9f, 3.6f, 1f, 4f),
					new Vector4(-0.3f, -1.4f, 0.5f, 2f)
				};
				foreach (Vector4 val in array2)
				{
					Decal.Flat(room, "shelter_pool" + (int)val.w, new Vector3(val.x, 0.004f, val.y), Vector3.up, val.z, Random.Range(0f, 360f));
				}
				Decal.Flat(room, "shelter_blood0", new Vector3(-3.996f, 1.4f, -1.6f), Vector3.right, 0.9f, 10f);
				Decal.Flat(room, "shelter_blood2", new Vector3(-3f, 1f, 4.996f), Vector3.back, 0.7f, -20f);
				Decal.Flat(room, "shelter_blood4", new Vector3(1.4f, 1.2f, -4.996f), Vector3.forward, 0.6f, 5f);
				Decal.Flat(room, "shelter_blood1", new Vector3(3.996f, 0.6f, 0.4f), Vector3.left, 0.8f, 0f);
				Decal.Flat(room, "shelter_blood3", new Vector3(0.15f, 1.15f, 3.696f), Vector3.back, 0.45f, 30f);
				Random rnd = new Random(2703);
				for (int j = 0; j < 30; j++)
				{
					float size = ((j < 9) ? R(0.15f, 0.35f) : ((j < 22) ? R(0.4f, 0.9f) : R(1f, 1.8f)));
					Decal.Flat(room, "shelter_pool" + rnd.Next(5), new Vector3(R(-3.6f, 3.6f), 0.0042f + (float)j * 0.0003f, R(-4.2f, 4.4f)), Vector3.up, size, R(0f, 360f));
				}
				for (int k = 0; k < 18; k++)
				{
					float size2 = ((k < 5) ? R(0.15f, 0.3f) : R(0.35f, 1.1f));
					float num = R(0.3f, 2.6f);
					float num2 = R(-3.4f, 3.4f);
					string tex = "shelter_blood" + rnd.Next(5);
					switch (rnd.Next(4))
					{
					case 0:
						Decal.Flat(room, tex, new Vector3(-3.995f, num, num2), Vector3.right, size2, R(0f, 360f));
						break;
					case 1:
						Decal.Flat(room, tex, new Vector3(3.995f, num, num2), Vector3.left, size2, R(0f, 360f));
						break;
					case 2:
						Decal.Flat(room, tex, new Vector3(num2, num, 4.995f), Vector3.back, size2, R(0f, 360f));
						break;
					default:
					{
						float num3 = ((Mathf.Abs(num2) < 1.1f) ? (Mathf.Sign(num2 + 0.01f) * R(1.1f, 1.6f)) : num2);
						Decal.Flat(room, tex, new Vector3(num3, Mathf.Min(num, 1f), -4.995f), Vector3.forward, size2, R(0f, 360f));
						break;
					}
					}
				}
				Decal.OnPillar(room, "shelter_blood2", new Vector3(-1.6f, 0f, 0.8f), 0.55f, 120f, 0.9f, 0.3f);
				Decal.OnPillar(room, "shelter_blood4", new Vector3(1.6f, 0f, 0.8f), 0.55f, -40f, 1.5f, 0.25f);
				array2 = (Vector4[])(object)new Vector4[5]
				{
					new Vector4(0.25f, 0.55f, 0.75f, 2f),
					new Vector4(0.6f, 1.25f, 0.6f, 0f),
					new Vector4(-1.2f, 0.45f, 0.5f, 4f),
					new Vector4(2.2f, 0.5f, 0.55f, 1f),
					new Vector4(-0.85f, 0.25f, 0.35f, 3f)
				};
				foreach (Vector4 val2 in array2)
				{
					Decal.Flat(room, "shelter_blood" + (int)val2.w, new Vector3(val2.x, val2.y, 3.6965f + val2.w * 0.0002f), Vector3.back, val2.z, R(0f, 360f));
				}
				for (int l = 0; l < 12; l++)
				{
					Decal.OnPillar(room, "shelter_blood" + rnd.Next(5), new Vector3((l % 2 == 0) ? 1.6f : (-1.6f), 0f, 0.8f), 0.555f + (float)l * 0.0015f, R(-180f, 180f), R(0.4f, 2.8f), R(0.4f, 1.1f));
				}
				Decal.OnPillar(room, "shelter_blood0", new Vector3(-1.6f, 0f, 0.8f), 0.55f, -150f, 1.7f, 0.55f);
				Decal.OnPillar(room, "shelter_blood3", new Vector3(1.6f, 0f, 0.8f), 0.55f, 160f, 2.4f, 0.7f);
				Decal.OnPillar(room, "shelter_blood1", new Vector3(1.6f, 0f, 0.8f), 0.55f, -120f, 0.45f, 0.5f);
				float R(float a, float b)
				{
					return a + (float)rnd.NextDouble() * (b - a);
				}
			}

			private static Light Lamp(Vector3 at, Color c, float intensity, float range)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				Light obj = new GameObject("Light").AddComponent<Light>();
				((Component)obj).transform.SetParent(room.transform, false);
				((Component)obj).transform.localPosition = at;
				obj.type = (LightType)2;
				obj.color = c;
				obj.intensity = intensity;
				obj.range = range;
				obj.shadows = (LightShadows)2;
				return obj;
			}

			internal static void Arrive()
			{
			}

			internal static void Put(Vector3 at, Quaternion rot)
			{
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: 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_0073: Unknown result type (might be due to invalid IL or missing references)
				PlayerController instance = PlayerController.instance;
				if (Object.op_Implicit((Object)(object)instance))
				{
					((Component)instance).transform.SetPositionAndRotation(at, rot);
					if (Object.op_Implicit((Object)(object)instance.rb))
					{
						instance.rb.position = at;
						instance.rb.linearVelocity = Vector3.zero;
					}
					PlayerAvatar playerAvatarScript = instance.playerAvatarScript;
					if (Object.op_Implicit((Object)(object)playerAvatarScript) && Object.op_Implicit((Object)(object)playerAvatarScript.rb))
					{
						playerAvatarScript.rb.position = at;
						((Component)playerAvatarScript).transform.position = at;
					}
				}
			}
		}

		internal const string PrefabName = "Valuable Shelter";

		internal const string DisplayName = "Shelter from the 27th of March";

		private const string DoorMesh = "shelter_door";

		private const string RoomMesh = "shelter_room";

		private const string RoomCols = "shelter_room.cols";

		private const string Open = "shelter_open";

		private const string Close = "shelter_close";

		private const string Alarm = "shelter_alarm";

		private const string Hum = "shelter_hum";

		private const float DoorW = 1.5f;

		private const float DoorH = 2.45f;

		private const float DoorD = 0.2f;

		private static readonly Vector3 Origin = new Vector3(0f, 1100f, 0f);

		private const float PillarX = 1.6f;

		private static readonly Vector3 ExitDoorAt = new Vector3(0f, 0f, -5f);

		private static PrefabRef prefab;

		private static PrefabRef exitPrefab;

		private static Material doorMat;

		private static Material roomMat;

		private static Material concreteBase;

		private const string Mark = "shelter_logo";

		internal static Shelter current;

		private PhysGrabObject grab;

		private PhotonView view;

		private Vector3 anchor;

		private Quaternion anchorRot;

		private readonly HashSet<int> inside = new HashSet<int>();

		private float lastAsk;

		private static bool darkened;

		private static Color ambientWas;

		private static float ambientIntensityWas;

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

		private float nextBreach = -1f;

		private int let_out;

		private int dragging = -1;

		private float dragDist;

		private float sentAngle;

		private float sentAt;

		private float enteredAt;

		private float healOwed;

		private static Vector3 Arrival => Origin + new Vector3(0f, 0.1f, -3.6f);

		internal static bool LocalInside
		{
			get
			{
				if (Object.op_Implicit((Object)(object)current) && Object.op_Implicit((Object)(object)PlayerAvatar.instance) && Object.op_Implicit((Object)(object)PlayerAvatar.instance.photonView))
				{
					return current.inside.Contains(PlayerAvatar.instance.photonView.ViewID);
				}
				return false;
			}
		}

		internal static bool AnyoneInside
		{
			get
			{
				if (Object.op_Implicit((Object)(object)current))
				{
					return current.inside.Count > 0;
				}
				return false;
			}
		}

		private Vector3 OutsideSpot => anchor + anchorRot * new Vector3(0f, 0.1f, 1f);

		private static Transform CameraT
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)CameraUtils.Instance) || !Object.op_Implicit((Object)(object)CameraUtils.Instance.MainCamera))
				{
					if (!Object.op_Implicit((Object)(object)Camera.main))
					{
						return null;
					}
					return ((Component)Camera.main).transform;
				}
				return ((Component)CameraUtils.Instance.MainCamera).transform;
			}
		}

		internal static void BuildAndRegister()
		{
			Material baseMat;
			GameObject obj = DoorObject("Valuable Shelter", out baseMat);
			roomMat = Assets.MakeMaterial(baseMat, "Shelter from the 27th of March Room", Assets.LoadPalette("shelter_room_albedo"), 0f);
			if (roomMat.HasProperty("_FresnelAmount"))
			{
				roomMat.SetFloat("_FresnelAmount", 0f);
			}
			concreteBase = baseMat;
			obj.AddComponent<Shelter>();
			prefab = Loot.Register(obj, inLevels: false);
			Material baseMat2;
			GameObject obj2 = DoorObject("Valuable Shelter Exit", out baseMat2);
			obj2.AddComponent<ExitDoor>();
			exitPrefab = Loot.Register(obj2, inLevels: false);
		}

		private static GameObject DoorObject(string name, out Material baseMat)
		{
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			BoxCollider box;
			GameObject val = Loot.CloneValuable(Loot.Big, name, out baseMat, out box);
			Loot.Feel(val, "Very Heavy", "Strong+", null);
			ValuableObject component = val.GetComponent<ValuableObject>();
			NotValuableObject val2 = val.AddComponent<NotValuableObject>();
			if (Object.op_Implicit((Object)(object)component))
			{
				val2.physAttributePreset = component.physAttributePreset;
				val2.audioPreset = component.audioPreset;
				val2.durabilityPreset = component.durabilityPreset;
				Object.DestroyImmediate((Object)(object)component);
			}
			val2.hasHealth = false;
			if (!Object.op_Implicit((Object)(object)doorMat))
			{
				doorMat = Assets.Metal(Assets.MakeMaterial(baseMat, "Shelter from the 27th of March Door", Assets.LoadCompressed("shelter_door_albedo")), Assets.LoadCompressed("shelter_door_normal", linear: true), 0.45f, 0.3f);
			}
			GameObject val3 = new GameObject("Shelter Model")
			{
				layer = val.layer
			};
			val3.transform.SetParent(val.transform, false);
			val3.AddComponent<MeshFilter>().sharedMesh = Assets.LoadMesh("shelter_door");
			((Renderer)val3.AddComponent<MeshRenderer>()).sharedMaterial = doorMat;
			Logo(val3.transform);
			Loot.FitBox(box, new Bounds(new Vector3(0f, 1.225f, 0.1f), new Vector3(1.5f, 2.45f, 0.2f)));
			return val;
		}

		private static void Logo(Transform door)
		{
			//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_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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: 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)
			Decal.Flat(door, "shelter_logo", new Vector3(0f, 1.53f, 0.1215f), Vector3.forward, 0.27f, 0f);
			Decal.Flat(door, "shelter_blood2", new Vector3(0.28f, 0.92f, 0.1125f), Vector3.forward, 0.45f, 20f);
			Decal.Flat(door, "shelter_blood0", new Vector3(-0.24f, 0.58f, 0.1127f), Vector3.forward, 0.34f, -60f);
			Decal.Flat(door, "shelter_blood4", new Vector3(0.22f, 0.2f, 0.1129f), Vector3.forward, 0.3f, 160f);
			Decal.Flat(door, "shelter_blood3", new Vector3(0.64f, 1.32f, 0.1425f), Vector3.forward, 0.2f, 80f);
		}

		internal static void LevelReady()
		{
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: 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_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			if (prefab == null || !SemiFunc.IsMasterClientOrSingleplayer() || !SemiFunc.RunIsLevel())
			{
				return;
			}
			float value = Random.value;
			if (value >= Plugin.ShelterChance.Value)
			{
				Plugin.Log.LogInfo((object)$"Shelter from the 27th of March isn't in this level (rolled {value:0.00}, needs under {Plugin.ShelterChance.Value:0.00}).");
				return;
			}
			Physics.SyncTransforms();
			List<LevelPoint> list = (Object.op_Implicit((Object)(object)LevelGenerator.Instance) ? LevelGenerator.Instance.LevelPathPoints : null);
			if (list == null || list.Count == 0)
			{
				return;
			}
			List<Vector3> list2 = new List<Vector3>();
			foreach (LevelPoint item in list)
			{
				if (Object.op_Implicit((Object)(object)item) && AtTruck(item))
				{
					list2.Add(((Component)item).transform.position);
				}
			}
			for (int i = 0; i < 120; i++)
			{
				LevelPoint val2 = list[Random.Range(0, list.Count)];
				if (!Object.op_Implicit((Object)(object)val2) || AtTruck(val2))
				{
					continue;
				}
				bool flag = false;
				foreach (Vector3 item2 in list2)
				{
					Vector3 val3 = item2 - ((Component)val2).transform.position;
					if (((Vector3)(ref val3)).sqrMagnitude < 144f)
					{
						flag = true;
						break;
					}
				}
				if (flag)
				{
					continue;
				}
				for (int j = 0; j < 6; j++)
				{
					float num = Random.Range(0f, 360f);
					if (WallSpot(((Component)val2).transform.position, Quaternion.Euler(0f, num, 0f) * Vector3.forward, out var at, out var facing))
					{
						NetworkPrefabs.SpawnNetworkPrefab(prefab, at, facing, (byte)0, (object[])null);
						Plugin.Log.LogInfo((object)"Shelter from the 27th of March turned up.");
						return;
					}
				}
			}
			Plugin.Log.LogInfo((object)"Shelter from the 27th of March: no bare wall found this level.");
		}

		internal static string SpawnForTest()
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: 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_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: 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_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: 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)
			//IL_0200: 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_0211: 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)
			if (prefab == null)
			{
				return "the Shelter door isn't registered";
			}
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return "Only the host can place the Shelter door";
			}
			PlayerAvatar me = PlayerAvatar.instance;
			if (!Object.op_Implicit((Object)(object)me))
			{
				return "Join a level first";
			}
			Physics.SyncTransforms();
			Vector3 forward = (Object.op_Implicit((Object)(object)Camera.main) ? ((Component)Camera.main).transform : ((Component)me).transform).forward;
			forward.y = 0f;
			if (((Vector3)(ref forward)).sqrMagnitude < 0.0001f)
			{
				forward = ((Component)me).transform.forward;
			}
			((Vector3)(ref forward)).Normalize();
			List<Vector3> list = new List<Vector3> { ((Component)me).transform.position };
			List<LevelPoint> list2 = (Object.op_Implicit((Object)(object)LevelGenerator.Instance) ? LevelGenerator.Instance.LevelPathPoints : null);
			if (list2 != null)
			{
				List<LevelPoint> list3 = new List<LevelPoint>();
				foreach (LevelPoint item in list2)
				{
					if (Object.op_Implicit((Object)(object)item))
					{
						Vector3 val2 = ((Component)item).transform.position - ((Component)me).transform.position;
						if (((Vector3)(ref val2)).sqrMagnitude < 225f)
						{
							list3.Add(item);
						}
					}
				}
				list3.Sort(delegate(LevelPoint a, LevelPoint b)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_0016: Unknown result type (might be due to invalid IL or missing references)
					//IL_001b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0020: Unknown result type (might be due to invalid IL or missing references)
					//IL_0031: 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_004b: Unknown result type (might be due to invalid IL or missing references)
					Vector3 val5 = ((Component)a).transform.position - ((Component)me).transform.position;
					float sqrMagnitude = ((Vector3)(ref val5)).sqrMagnitude;
					val5 = ((Component)b).transform.position - ((Component)me).transform.position;
					return sqrMagnitude.CompareTo(((Vector3)(ref val5)).sqrMagnitude);
				});
				foreach (LevelPoint item2 in list3)
				{
					list.Add(((Component)item2).transform.position);
				}
			}
			foreach (Vector3 item3 in list)
			{
				for (int num = 0; num < 16; num++)
				{
					float num2 = (float)(((num % 2 == 0) ? 1 : (-1)) * ((num + 1) / 2)) * 22.5f;
					if (WallSpot(item3, Quaternion.Euler(0f, num2, 0f) * forward, out var at, out var facing))
					{
						NetworkPrefabs.SpawnNetworkPrefab(prefab, at, facing, (byte)0, (object[])null);
						return $"Placed the Shelter door {Vector3.Distance(at, ((Component)me).transform.position):0} m away";
					}
				}
			}
			return "No bare wall near you for the Shelter door";
		}

		private static bool AtTruck(LevelPoint p)
		{
			if (!p.inStartRoom && !p.Truck)
			{
				if (Object.op_Implicit((Object)(object)p.Room))
				{
					return p.Room.Truck;
				}
				return false;
			}
			return true;
		}

		private static bool Solid(Collider c)
		{
			if (Object.op_Implicit((Object)(object)c) && !c.isTrigger && !Object.op_Implicit((Object)(object)((Component)c).GetComponentInParent<PhysGrabObject>()) && !Object.op_Implicit((Object)(object)((Component)c).GetComponentInParent<PlayerAvatar>()))
			{
				return !Object.op_Implicit((Object)(object)((Component)c).GetComponentInParent<EnemyParent>());
			}
			return false;
		}

		private static bool WallSpot(Vector3 from, Vector3 dir, out Vector3 at, out Quaternion facing)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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_00ee: 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_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: 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_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: 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)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			at = default(Vector3);
			facing = default(Quaternion);
			RaycastHit val = default(RaycastHit);
			if (!Physics.Raycast(from + Vector3.up * 1.2f, dir, ref val, 4f, -1, (QueryTriggerInteraction)1) || !Solid(((RaycastHit)(ref val)).collider))
			{
				return false;
			}
			Vector3 normal = ((RaycastHit)(ref val)).normal;
			if (Mathf.Abs(normal.y) > 0.08f)
			{
				return false;
			}
			normal.y = 0f;
			((Vector3)(ref normal)).Normalize();
			RaycastHit val2 = default(RaycastHit);
			if (!Physics.Raycast(((RaycastHit)(ref val)).point + normal * 0.5f, Vector3.down, ref val2, 2.5f, -1, (QueryTriggerInteraction)1) || !Solid(((RaycastHit)(ref val2)).collider))
			{
				return false;
			}
			if (((RaycastHit)(ref val2)).normal.y < 0.9f)
			{
				return false;
			}
			RaycastHit val3 = default(RaycastHit);
			float num = (Physics.Raycast(from + Vector3.up * 0.5f, Vector3.down, ref val3, 3f, -1, (QueryTriggerInteraction)1) ? ((RaycastHit)(ref val3)).point.y : from.y);
			if (Mathf.Abs(((RaycastHit)(ref val2)).point.y - num) > 0.2f)
			{
				return false;
			}
			Vector3 val4 = default(Vector3);
			((Vector3)(ref val4))..ctor(((RaycastHit)(ref val)).point.x, ((RaycastHit)(ref val2)).point.y, ((RaycastHit)(ref val)).point.z);
			Vector3 val5 = Vector3.Cross(Vector3.up, normal);
			RaycastHit val6 = default(RaycastHit);
			for (int i = -2; i <= 2; i++)
			{
				for (int j = 0; j < 5; j++)
				{
					if (!Physics.Raycast(val4 + val5 * ((float)i * 0.55f) + Vector3.up * (0.15f + (float)j * 0.65f) + normal * 0.5f, -normal, ref val6, 0.7f, -1, (QueryTriggerInteraction)1) || !Solid(((RaycastHit)(ref val6)).collider))
					{
						return false;
					}
					if (Mathf.Abs(((RaycastHit)(ref val6)).distance - 0.5f) > 0.05f || Vector3.Dot(((RaycastHit)(ref val6)).normal, normal) < 0.97f)
					{
						return false;
					}
				}
			}
			Collider[] array = Physics.OverlapBox(val4 + normal * 0.8f + Vector3.up * 1.2f, new Vector3(0.8f, 1.12f, 0.75f), Quaternion.LookRotation(normal), -1, (QueryTriggerInteraction)1);
			for (int k = 0; k < array.Length; k++)
			{
				if (Object.op_Implicit((Object)(object)array[k]))
				{
					return false;
				}
			}
			at = val4 + normal * 0.005f;
			facing = Quaternion.LookRotation(normal);
			return true;
		}

		internal static Vector3 Where(PlayerAvatar p)
		{
			//IL_003b: 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)
			if (!Object.op_Implicit((Object)(object)current) || !Object.op_Implicit((Object)(object)p.photonView) || !current.inside.Contains(p.photonView.ViewID))
			{
				return ((Component)p).transform.position;
			}
			return current.OutsideSpot;
		}

		private void Start()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			current = this;
			grab = ((Component)this).GetComponent<PhysGrabObject>();
			view = ((Component)this).GetComponent<PhotonView>();
			anchor = ((Component)this).transform.position;
			anchorRot = ((Component)this).transform.rotation;
			((MonoBehaviour)this).StartCoroutine(Props.Find());
		}

		private void LateUpdate()
		{
			//IL_003a: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			bool localInside = LocalInside;
			if (localInside && !darkened)
			{
				darkened = true;
				ambientWas = RenderSettings.ambientLight;
				ambientIntensityWas = RenderSettings.ambientIntensity;
			}
			if (localInside)
			{
				RenderSettings.ambientLight = new Color(0.03f, 0.035f, 0.045f);
				RenderSettings.ambientIntensity = 0.3f;
			}
			else if (darkened)
			{
				darkened = false;
				RenderSettings.ambientLight = ambientWas;
				RenderSettings.ambientIntensity = ambientIntensityWas;
			}
		}

		internal static string Prompt(string verb)
		{
			return verb + " <color=#FFFFFF>[" + SemiFunc.InputDisplayReplaceTags("[interact]", "<u><b>", "</b></u>") + "]</color>";
		}

		private void Update()
		{
			//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_00b4: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			Tell.Tick();
			if (SemiFunc.IsMasterClientOrSingleplayer() && Object.op_Implicit((Object)(object)grab))
			{
				grab.OverrideKinematic(0.2f);
				grab.OverrideIndestructible(0.2f);
				if (Object.op_Implicit((Object)(object)grab.rb) && !grab.rb.isKinematic)
				{
					grab.rb.linearVelocity = Vector3.zero;
					grab.rb.angularVelocity = Vector3.zero;
					grab.rb.isKinematic = true;
				}
				Vector3 val = ((Component)this).transform.position - anchor;
				if (((Vector3)(ref val)).sqrMagnitude > 0.0001f || Quaternion.Angle(((Component)this).transform.rotation, anchorRot) > 0.1f)
				{
					((Component)this).transform.SetPositionAndRotation(anchor, anchorRot);
				}
			}
			PlayerAvatar instance = PlayerAvatar.instance;
			bool flag = Object.op_Implicit((Object)(object)instance) && !instance.isDisabled && !instance.deadSet;
			int num = ((Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.photonView)) ? instance.photonView.ViewID : (-1));
			if (Object.op_Implicit((Object)(object)grab) && grab.grabbedLocal && Object.op_Implicit((Object)(object)ItemInfoUI.instance) && Tell.ShowingNow == null)
			{
				ItemInfoUI.instance.ItemInfoText((ItemAttributes)null, Prompt("Enter"), false);
			}
			if (flag && Object.op_Implicit((Object)(object)grab) && grab.grabbedLocal && SemiFunc.InputDown((InputKey)2) && Time.time - lastAsk > 1f && !inside.Contains(num))
			{
				lastAsk = Time.time;
				Ask("EnterRPC", num);
			}
			if (LocalInside)
			{
				InsideLocal(instance, flag);
			}
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				HostTick();
			}
		}

		internal void AskExit(int id)
		{
			if (!(Time.time - lastAsk < 1f) && inside.Contains(id))
			{
				lastAsk = Time.time;
				Ask("ExitRPC", id);
			}
		}

		private void Ask(string rpc, int id)
		{
			if (SemiFunc.IsMultiplayer() && Object.op_Implicit((Object)(object)view))
			{
				view.RPC(rpc, (RpcTarget)2, new object[1] { id });
			}
			else if (rpc == "EnterRPC")
			{
				EnterRPC(id);
			}
			else
			{
				ExitRPC(id);
			}
		}

		private void Say(string rpc, int id, bool on)
		{
			if (SemiFunc.IsMultiplayer() && Object.op_Implicit((Object)(object)view))
			{
				view.RPC(rpc, (RpcTarget)0, new object[2] { id, on });
			}
			else
			{
				InsideRPC(id, on);
			}
		}

		[PunRPC]
		public void EnterRPC(int id)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMasterClientOrSingleplayer() && !inside.Contains(id))
			{
				PlayerAvatar val = SemiFunc.PlayerAvatarGetFromPhotonID(id);
				if (Object.op_Implicit((Object)(object)val) && !val.isDisabled && !val.deadSet)
				{
					since[id] = Time.time;
					Say("InsideRPC", id, on: true);
					Forget(val);
					val.Spawn(Arrival + new Vector3(Random.Range(-0.8f, 0.8f), 0f, 0f), Quaternion.identity, false);
				}
			}
		}

		[PunRPC]
		public void ExitRPC(int id)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMasterClientOrSingleplayer() && inside.Contains(id))
			{
				since.Remove(id);
				Say("InsideRPC", id, on: false);
				PlayerAvatar val = SemiFunc.PlayerAvatarGetFromPhotonID(id);
				if (Object.op_Implicit((Object)(object)val) && !val.isDisabled)
				{
					val.Spawn(OutsideSpot, anchorRot, false);
				}
			}
		}

		private void HostTick()
		{
			List<int> list = null;
			foreach (int key in since.Keys)
			{
				if (!Object.op_Implicit((Object)(object)SemiFunc.PlayerAvatarGetFromPhotonID(key)))
				{
					(list ?? (list = new List<int>())).Add(key);
				}
			}
			if (list != null)
			{
				foreach (int item in list)
				{
					since.Remove(item);
					Say("InsideRPC", item, on: false);
				}
			}
			float num3 = 0f;
			foreach (float value in since.Values)
			{
				num3 = Mathf.Max(num3, Time.time - value);
			}
			if (since.Count == 0)
			{
				nextBreach = -1f;
			}
			else if (!(num3 < Plugin.ShelterSafeSeconds.Value) && (nextBreach < 0f || Time.time >= nextBreach))
			{
				nextBreach = Time.time + Plugin.ShelterSafeSeconds.Value;
				Breach();
			}
		}

		private void Breach()
		{
			if (let_out >= Plugin.ShelterMaxMonsters.Value || !Object.op_Implicit((Object)(object)EnemyDirector.instance))
			{
				return;
			}
			List<EnemySetup> list = new List<EnemySetup>();
			HashSet<string> hashSet = new HashSet<string>();
			List<EnemySetup>[] array = new List<EnemySetup>[2]
			{
				EnemyDirector.instance.enemiesDifficulty2,
				EnemyDirector.instance.enemiesDifficulty3
			};
			foreach (List<EnemySetup> list2 in array)
			{
				if (list2 == null)
				{
					continue;
				}
				foreach (EnemySetup item in list2)
				{
					if (Object.op_Implicit((Object)(object)item) && item.spawnObjects != null && item.spawnObjects.Count == 1 && item.spawnObjects[0] != null && hashSet.Add(((PrefabRef<GameObject>)(object)item.spawnObjects[0]).PrefabName ?? ((Object)item).name))
					{
						list.Add(item);
					}
				}
			}
			for (int num = list.Count - 1; num > 0; num--)
			{
				int num2 = Random.Range(0, num + 1);
				List<EnemySetup> list3 = list;
				int i = num;
				int index = num2;
				EnemySetup value = list[num2];
				EnemySetup value2 = list[num];
				list3[i] = value;
				list[index] = value2;
			}
			int num3 = Mathf.Min(Plugin.ShelterPerBreach.Value, Plugin.ShelterMaxMonsters.Value - let_out);
			if (list.Count > num3)
			{
				list.RemoveRange(num3, list.Count - num3);
			}
			((MonoBehaviour)this).StartCoroutine(LetOut(list));
			if (SemiFunc.IsMultiplayer() && Object.op_Implicit((Object)(object)view))
			{
				view.RPC("BreachRPC", (RpcTarget)0, Array.Empty<object>());
			}
			else
			{
				BreachRPC();
			}
		}

		private IEnumerator LetOut(List<EnemySetup> kinds)
		{
			List<LevelPoint> points = (Object.op_Implicit((Object)(object)LevelGenerator.Instance) ? LevelGenerator.Instance.LevelPathPoints : null);
			if (points == null || points.Count == 0)
			{
				yield break;
			}
			int before = let_out;
			foreach (EnemySetup kind in kinds)
			{
				if (let_out >= Plugin.ShelterMaxMonsters.Value)
				{
					break;
				}
				List<Vector3> list = new List<Vector3>();
				foreach (PlayerAvatar item in SemiFunc.PlayerGetList())
				{
					if (Object.op_Implicit((Object)(object)item) && !item.isDisabled && Object.op_Implicit((Object)(object)item.photonView) && !inside.Contains(item.photonView.ViewID))
					{
						list.Add(((Component)item).transform.position);
					}
				}
				Vector3 val3 = default(Vector3);
				bool flag = false;
				for (int i = 0; i < 20; i++)
				{
					if (flag)
					{
						break;
					}
					LevelPoint val4 = points[Random.Range(0, points.Count)];
					if (!Object.op_Implicit((Object)(object)val4))
					{
						continue;
					}
					val3 = ((Component)val4).transform.position;
					flag = true;
					foreach (Vector3 item2 in list)
					{
						if (Vector3.Distance(item2, val3) < 15f)
						{
							flag = false;
							break;
						}
					}
				}
				if (!flag)
				{
					LevelPoint val5 = points[Random.Range(0, points.Count)];
					if (!Object.op_Implicit((Object)(object)val5))
					{
						continue;
					}
					val3 = ((Component)val5).transform.position;
				}
				try
				{
					List<EnemyParent> list2 = Enemies.SpawnEnemy(kind, val3, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f), false);
					let_out += ((list2 == null || list2.Count <= 0) ? 1 : list2.Count);
					if (list2 != null && list2.Count > 1)
					{
						Plugin.Log.LogInfo((object)$"Shelter: {((Object)kind).name} came out as {list2.Count}.");
					}
				}
				catch (Exception ex)
				{
					Plugin.Log.LogWarning((object)("Shelter: " + ((Object)kind).name + " would not come out: " + ex.Message));
					let_out++;
				}
				yield return (object)new WaitForSeconds(0.4f);
			}
			Plugin.Log.LogInfo((object)$"Shelter from the 27th of March: the dangerous ones break out ({let_out - before} monsters, {let_out} in all).");
		}

		private static void Forget(PlayerAvatar p)
		{
			EnemyDirector instance = EnemyDirector.instance;
			if (!Object.op_Implicit((Object)(object)instance) || instance.enemiesSpawned == null || !Object.op_Implicit((Object)(object)p.photonView))
			{
				return;
			}
			int viewID = p.photonView.ViewID;
			foreach (EnemyParent item in instance.enemiesSpawned)
			{
				Enemy val2 = (Object.op_Implicit((Object)(object)item) ? item.Enemy : null);
				if (Object.op_Implicit((Object)(object)val2))
				{
					if (val2.HasVision && Object.op_Implicit((Object)(object)val2.Vision) && val2.Vision.VisionTriggered != null && val2.Vision.VisionTriggered.ContainsKey(viewID))
					{
						val2.Vision.VisionTriggered[viewID] = false;
					}
					if ((Object)(object)val2.TargetPlayerAvatar == (Object)(object)p)
					{
						val2.DisableChase(1f);
					}
				}
			}
		}

		[PunRPC]
		public void InsideRPC(int id, bool on)
		{
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			PlayerAvatar instance = PlayerAvatar.instance;
			bool flag = Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.photonView) && instance.photonView.ViewID == id;
			if (on)
			{
				inside.Add(id);
				Room.Make();
				if (flag)
				{
					enteredAt = Time.time;
					Assets.Play(Assets.LoadSound("shelter_open"), ((Component)this).transform);
					Room.Arrive();
					((MonoBehaviour)this).StartCoroutine(Face(Quaternion.identity, intoRoom: true));
					Tell.Local("The safest place on Earth.", 4f);
				}
				else
				{
					Assets.Play(Assets.LoadSound("shelter_open"), ((Component)this).transform, 0.8f);
				}
			}
			else
			{
				inside.Remove(id);
				if (flag)
				{
					((MonoBehaviour)this).StartCoroutine(Face(anchorRot, intoRoom: false));
					((MonoBehaviour)this).StartCoroutine(OutForSure());
				}
				Assets.Play(Assets.LoadSound("shelter_close"), ((Component)this).transform, flag ? 1f : 0.8f);
			}
		}

		private IEnumerator OutForSure()
		{
			for (int i = 0; i < 4; i++)
			{
				yield return (object)new WaitForSeconds(0.4f);
				PlayerAvatar instance = PlayerAvatar.instance;
				if (!Object.op_Implicit((Object)(object)instance) || instance.isDisabled || ((Component)instance).transform.position.y < Origin.y - 20f)
				{
					break;
				}
				Plugin.Log.LogInfo((object)"Shelter: the move out didn't take; putting you at the door.");
				Room.Put(OutsideSpot, anchorRot);
			}
		}

		private IEnumerator Face(Quaternion facing, bool intoRoom)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			Quaternion flat = Quaternion.Euler(0f, ((Quaternion)(ref facing)).eulerAngles.y, 0f);
			float until = Time.time + 3f;
			while (Time.time < until)
			{
				PlayerAvatar instance = PlayerAvatar.instance;
				if (!Object.op_Implicit((Object)(object)instance) || instance.isDisabled)
				{
					yield break;
				}
				if (((Component)instance).transform.position.y >= Origin.y - 20f == intoRoom)
				{
					break;
				}
				yield return null;
			}
			for (int i = 0; i < 6; i++)
			{
				if (Object.op_Implicit((Object)(object)CameraAim.Instance))
				{
					CameraAim.Instance.SetPlayerAim(flat, true);
				}
				yield return null;
			}
		}

		[PunRPC]
		public void LockerRPC(int which, float angle)
		{
			if (which >= 0 && which < Swing.All.Count && Object.op_Implicit((Object)(object)Swing.All[which]))
			{
				Swing.All[which].Set(angle, now_: false);
			}
		}

		[PunRPC]
		public void BreachRPC()
		{
			Transform cameraT = CameraT;
			if (Object.op_Implicit((Object)(object)cameraT))
			{
				Assets.Play(Assets.LoadSound("shelter_alarm"), cameraT, LocalInside ? 0.35f : 0.9f, 10f);
			}
			if (!LocalInside)
			{
				Tell.Local("Everything has broken out.", 4f);
				if (Object.op_Implicit((Object)(object)CameraGlitch.Instance))
				{
					CameraGlitch.Instance.PlayLong();
				}
			}
		}

		private void InsideLocal(PlayerAvatar me, bool alive)
		{
			//IL_00b3: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (migh