Decompiled source of Insanity v1.1.0

Insanity.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using FishNet.Object;
using Insanity;
using MelonLoader;
using ScheduleOne.Audio;
using ScheduleOne.Building.Doors;
using ScheduleOne.DevUtilities;
using ScheduleOne.FX;
using ScheduleOne.GameTime;
using ScheduleOne.NPCs;
using ScheduleOne.Persistence;
using ScheduleOne.PlayerScripts;
using ScheduleOne.Property;
using ScheduleOne.VoiceOver;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(global::Insanity.Insanity), "Insanity", "1.1", "XOWithSauce", null)]
[assembly: MelonColor]
[assembly: MelonOptionalDependencies(new string[] { "FishNet.Runtime" })]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("Insanity")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Insanity")]
[assembly: AssemblyTitle("Insanity")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Insanity;

public static class BuildInfo
{
	public const string Name = "Insanity";

	public const string Description = "Nothing is real";

	public const string Author = "XOWithSauce";

	public const string Company = null;

	public const string Version = "1.1";

	public const string DownloadLink = null;
}
public class Insanity : MelonMod
{
	[CompilerGenerated]
	private sealed class <EventCoro>d__13 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public NPC npc;

		public KeyValuePair<string, Vector3> kvPair;

		public Property property;

		public Insanity <>4__this;

		private int <ranEvents>5__1;

		private GameObject <knocking>5__2;

		private AudioSource <audioSource>5__3;

		private Exception <ex>5__4;

		private int <roll>5__5;

		private Vector3 <direction>5__6;

		private Exception <ex>5__7;

		private Light[] <propertyLights>5__8;

		private List<Color> <colors>5__9;

		private List<float> <intensiti>5__10;

		private Light[] <propertyLights2>5__11;

		private List<float> <intensities>5__12;

		private Vector3 <backward>5__13;

		private int <stepCount>5__14;

		private GameObject <footsteps>5__15;

		private AudioSource <audioSource>5__16;

		private float <volMax>5__17;

		private float <volMin>5__18;

		private int <>s__19;

		private Exception <ex>5__20;

		private Exception <ex>5__21;

		private Exception <ex>5__22;

		private Light[] <>s__23;

		private int <>s__24;

		private Light <l>5__25;

		private int <i>5__26;

		private Light[] <>s__27;

		private int <>s__28;

		private Light <l>5__29;

		private int <i>5__30;

		private Exception <ex>5__31;

		private int <i>5__32;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <EventCoro>d__13(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<knocking>5__2 = null;
			<audioSource>5__3 = null;
			<ex>5__4 = null;
			<ex>5__7 = null;
			<propertyLights>5__8 = null;
			<colors>5__9 = null;
			<intensiti>5__10 = null;
			<propertyLights2>5__11 = null;
			<intensities>5__12 = null;
			<footsteps>5__15 = null;
			<audioSource>5__16 = null;
			<ex>5__20 = null;
			<ex>5__21 = null;
			<ex>5__22 = null;
			<>s__23 = null;
			<l>5__25 = null;
			<>s__27 = null;
			<l>5__29 = null;
			<ex>5__31 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Expected O, but got Unknown
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Expected O, but got Unknown
			//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0915: Unknown result type (might be due to invalid IL or missing references)
			//IL_091f: Expected O, but got Unknown
			//IL_0980: Unknown result type (might be due to invalid IL or missing references)
			//IL_0986: Unknown result type (might be due to invalid IL or missing references)
			//IL_0990: Unknown result type (might be due to invalid IL or missing references)
			//IL_0995: Unknown result type (might be due to invalid IL or missing references)
			//IL_052a: Unknown result type (might be due to invalid IL or missing references)
			//IL_085c: Unknown result type (might be due to invalid IL or missing references)
			//IL_086c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0871: Unknown result type (might be due to invalid IL or missing references)
			//IL_0876: Unknown result type (might be due to invalid IL or missing references)
			//IL_088c: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Expected O, but got Unknown
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Expected O, but got Unknown
			//IL_05be: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c8: Expected O, but got Unknown
			//IL_06a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ad: Expected O, but got Unknown
			//IL_071b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0725: Expected O, but got Unknown
			//IL_075b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0765: Expected O, but got Unknown
			//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ca: Expected O, but got Unknown
			//IL_057e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0588: Expected O, but got Unknown
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a4d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a53: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a5d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a62: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a7d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a87: Expected O, but got Unknown
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			Vector3 forward;
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				if (kvPair.Key.Contains("Door"))
				{
					if (Random.Range(0, 100) > 50)
					{
						npc.CanOpenDoors = true;
					}
					<knocking>5__2 = new GameObject("knockingSound");
					<audioSource>5__3 = <knocking>5__2.AddComponent<AudioSource>();
					<audioSource>5__3.clip = <>4__this.doorKnock.clip;
					<audioSource>5__3.spatialBlend = 1f;
					<audioSource>5__3.rolloffMode = (AudioRolloffMode)1;
					try
					{
						<knocking>5__2.transform.position = ((Component)npc).transform.position;
					}
					catch (Exception ex)
					{
						<ex>5__4 = ex;
						MelonLogger.Error((object)<ex>5__4);
					}
					<audioSource>5__3.Play();
					<>2__current = (object)new WaitForSeconds(0.77f);
					<>1__state = 1;
					return true;
				}
				goto IL_022a;
			case 1:
				<>1__state = -1;
				<audioSource>5__3.pitch = Random.Range(0.7f, 1f);
				<audioSource>5__3.Play();
				<>2__current = (object)new WaitForSeconds(Random.Range(0.9f, 1.6f));
				<>1__state = 2;
				return true;
			case 2:
				<>1__state = -1;
				<audioSource>5__3.pitch = Random.Range(0.6f, 0.8f);
				<audioSource>5__3.volume = 0.8f;
				<audioSource>5__3.Play();
				Object.Destroy((Object)(object)<knocking>5__2, <audioSource>5__3.clip.length);
				<knocking>5__2 = null;
				<audioSource>5__3 = null;
				goto IL_022a;
			case 3:
				<>1__state = -1;
				if (!<>4__this.registered)
				{
					return false;
				}
				if (<ranEvents>5__1 < 2)
				{
					<ranEvents>5__1++;
					if (!(Random.Range(0f, 1f) > 0.8f))
					{
						try
						{
							if (((Component)npc).transform.position != kvPair.Value)
							{
								((Component)npc).transform.position = kvPair.Value;
							}
							<direction>5__6 = ((Component)<>4__this.playerMain).transform.position - ((Component)npc).transform.position;
							<direction>5__6.y = 0f;
							((Component)npc).transform.rotation = Quaternion.LookRotation(<direction>5__6);
						}
						catch (Exception ex)
						{
							<ex>5__7 = ex;
							MelonLogger.Error((object)<ex>5__7);
						}
						<roll>5__5 = Random.Range(0, 8);
						int num = <roll>5__5;
						<>s__19 = num;
						switch (<>s__19)
						{
						case 0:
							break;
						case 1:
							goto IL_0401;
						case 2:
							goto IL_0431;
						case 3:
							goto IL_0460;
						case 4:
							goto IL_0651;
						case 5:
							goto IL_07c8;
						case 6:
							goto IL_0840;
						case 7:
							goto IL_08d8;
						default:
							goto IL_0ad0;
						}
						try
						{
							npc.PlayVO((EVOLineType)16);
						}
						catch (Exception ex)
						{
							<ex>5__20 = ex;
							MelonLogger.Error((object)<ex>5__20);
						}
					}
					goto IL_0236;
				}
				Singleton<MusicPlayer>.Instance.SetMusicDistorted(false, 5f);
				Singleton<MusicPlayer>.Instance.SetTrackEnabled("Schizo music", false);
				Singleton<AudioManager>.Instance.SetDistorted(false, 5f);
				Singleton<PostProcessingManager>.Instance.SaturationController.RemoveOverride("Schizophrenic");
				NPCManager.NPCRegistry.Remove(npc);
				Object.Destroy((Object)(object)((Component)npc).gameObject);
				return false;
			case 4:
				<>1__state = -1;
				<colors>5__9.Add(<l>5__25.color);
				<intensiti>5__10.Add(<l>5__25.intensity);
				if (Random.Range(0f, 1f) > 0.5f)
				{
					<l>5__25.color = Color.red;
				}
				else
				{
					<l>5__25.intensity = 0.1f;
				}
				<l>5__25 = null;
				<>s__24++;
				goto IL_055e;
			case 5:
				<>1__state = -1;
				if (!<>4__this.registered)
				{
					return false;
				}
				<i>5__26 = 0;
				goto IL_0633;
			case 6:
				<>1__state = -1;
				<propertyLights>5__8[<i>5__26].color = <colors>5__9[<i>5__26];
				<propertyLights>5__8[<i>5__26].intensity = <intensiti>5__10[<i>5__26];
				<i>5__26++;
				goto IL_0633;
			case 7:
				<>1__state = -1;
				<intensities>5__12.Add(<l>5__29.intensity);
				<l>5__29.intensity = 0.1f;
				<l>5__29 = null;
				<>s__28++;
				goto IL_06fb;
			case 8:
				<>1__state = -1;
				if (!<>4__this.registered)
				{
					return false;
				}
				<i>5__30 = 0;
				goto IL_07ad;
			case 9:
				<>1__state = -1;
				<propertyLights2>5__11[<i>5__30].intensity = <intensities>5__12[<i>5__30];
				<i>5__30++;
				goto IL_07ad;
			case 10:
				{
					<>1__state = -1;
					<i>5__32++;
					goto IL_0aab;
				}
				IL_0aab:
				if (<i>5__32 < <stepCount>5__14)
				{
					if (!<>4__this.registered)
					{
						return false;
					}
					<audioSource>5__16.pitch = Random.Range(0.8f, 1f);
					<audioSource>5__16.volume = Random.Range(<volMin>5__18, <volMax>5__17);
					<volMax>5__17 -= 0.07f;
					<volMin>5__18 -= 0.07f;
					<audioSource>5__16.Play();
					Transform transform = <footsteps>5__15.transform;
					transform.position += <backward>5__13 * 2f;
					<>2__current = (object)new WaitForSeconds(Random.Range(0.7f, 0.9f));
					<>1__state = 10;
					return true;
				}
				Object.Destroy((Object)(object)<footsteps>5__15);
				goto IL_0236;
				IL_0401:
				try
				{
					npc.PlayVO((EVOLineType)15);
				}
				catch (Exception ex)
				{
					<ex>5__21 = ex;
					MelonLogger.Error((object)<ex>5__21);
				}
				goto IL_0236;
				IL_07ad:
				if (<i>5__30 < <propertyLights2>5__11.Length)
				{
					<>2__current = (object)new WaitForSeconds(0.005f);
					<>1__state = 9;
					return true;
				}
				goto IL_0236;
				IL_0236:
				<>2__current = (object)new WaitForSeconds(Random.Range(3f, 6f));
				<>1__state = 3;
				return true;
				IL_0633:
				if (<i>5__26 < <propertyLights>5__8.Length)
				{
					<>2__current = (object)new WaitForSeconds(0.005f);
					<>1__state = 6;
					return true;
				}
				goto IL_0236;
				IL_0840:
				try
				{
					((Component)npc).transform.rotation = Quaternion.LookRotation(((Component)<>4__this.playerMain).transform.position - ((Component)npc).transform.position);
					npc.Avatar.SetEmission(Color.red);
					npc.Avatar.Effects.SetEyeLightEmission(1f, Color.red, true);
				}
				catch (Exception ex)
				{
					<ex>5__31 = ex;
					MelonLogger.Error((object)<ex>5__31);
				}
				goto IL_0236;
				IL_022a:
				<ranEvents>5__1 = 0;
				goto IL_0236;
				IL_0431:
				try
				{
					npc.PlayVO((EVOLineType)12);
				}
				catch (Exception ex)
				{
					<ex>5__22 = ex;
					MelonLogger.Error((object)<ex>5__22);
				}
				goto IL_0236;
				IL_07c8:
				if (Random.Range(0, 100) <= 10 && !Singleton<MusicPlayer>.Instance.IsPlaying)
				{
					Singleton<MusicPlayer>.Instance.SetMusicDistorted(true, 5f);
					Singleton<MusicPlayer>.Instance.SetTrackEnabled("Schizo music", true);
					Singleton<AudioManager>.Instance.SetDistorted(true, 5f);
					Singleton<PostProcessingManager>.Instance.SaturationController.AddOverride(110f, 7, "Schizophrenic");
				}
				goto IL_0236;
				IL_0651:
				<propertyLights2>5__11 = ((Component)((Component)property).transform).GetComponentsInChildren<Light>(true);
				<intensities>5__12 = new List<float>();
				<>s__27 = <propertyLights2>5__11;
				<>s__28 = 0;
				goto IL_06fb;
				IL_06fb:
				if (<>s__28 < <>s__27.Length)
				{
					<l>5__29 = <>s__27[<>s__28];
					<>2__current = (object)new WaitForSeconds(0.005f);
					<>1__state = 7;
					return true;
				}
				<>s__27 = null;
				<>2__current = (object)new WaitForSeconds(3f);
				<>1__state = 8;
				return true;
				IL_0460:
				<propertyLights>5__8 = ((Component)((Component)property).transform).GetComponentsInChildren<Light>(true);
				<colors>5__9 = new List<Color>();
				<intensiti>5__10 = new List<float>();
				<>s__23 = <propertyLights>5__8;
				<>s__24 = 0;
				goto IL_055e;
				IL_055e:
				if (<>s__24 < <>s__23.Length)
				{
					<l>5__25 = <>s__23[<>s__24];
					<>2__current = (object)new WaitForSeconds(0.005f);
					<>1__state = 4;
					return true;
				}
				<>s__23 = null;
				<>2__current = (object)new WaitForSeconds(3f);
				<>1__state = 5;
				return true;
				IL_0ad0:
				<propertyLights>5__8 = null;
				<colors>5__9 = null;
				<intensiti>5__10 = null;
				<propertyLights2>5__11 = null;
				<intensities>5__12 = null;
				<footsteps>5__15 = null;
				<audioSource>5__16 = null;
				goto IL_0236;
				IL_08d8:
				forward = ((Component)<>4__this.playerMain).transform.forward;
				<backward>5__13 = -((Vector3)(ref forward)).normalized;
				<stepCount>5__14 = Random.Range(5, 9);
				<footsteps>5__15 = new GameObject("stepSounds");
				<audioSource>5__16 = <footsteps>5__15.AddComponent<AudioSource>();
				<audioSource>5__16.clip = <>4__this.footSteps;
				<audioSource>5__16.spatialBlend = 1f;
				<audioSource>5__16.rolloffMode = (AudioRolloffMode)1;
				<footsteps>5__15.transform.position = ((Component)<>4__this.playerMain).transform.position + <backward>5__13 * 2f;
				<volMax>5__17 = 0.8f;
				<volMin>5__18 = 0.7f;
				<i>5__32 = 0;
				goto IL_0aab;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <MoveAlongPath>d__14 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public NPC npc;

		public List<Vector3> path;

		public float durationPerSegment;

		public Insanity <>4__this;

		private int <i>5__1;

		private Vector3 <start>5__2;

		private Vector3 <end>5__3;

		private float <elapsed>5__4;

		private float <t>5__5;

		private Vector3 <direction>5__6;

		private Exception <ex>5__7;

		private Vector3 <direction>5__8;

		private Exception <ex>5__9;

		private Exception <ex>5__10;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <MoveAlongPath>d__14(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<ex>5__7 = null;
			<ex>5__9 = null;
			<ex>5__10 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Expected O, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: 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_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: 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_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)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: 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)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				if (path == null || path.Count < 2)
				{
					return false;
				}
				<i>5__1 = 0;
				goto IL_02b5;
			case 1:
				<>1__state = -1;
				if (!<>4__this.registered)
				{
					return false;
				}
				<elapsed>5__4 += Time.deltaTime;
				<t>5__5 = Mathf.Clamp01(<elapsed>5__4 / durationPerSegment);
				try
				{
					((Component)npc).transform.position = Vector3.Lerp(<start>5__2, <end>5__3, <t>5__5);
					<direction>5__6 = ((Component)<>4__this.playerMain).transform.position - ((Component)npc).transform.position;
					<direction>5__6.y = 0f;
					((Component)npc).transform.rotation = Quaternion.LookRotation(<direction>5__6);
				}
				catch (Exception ex)
				{
					<ex>5__7 = ex;
					MelonLogger.Error((object)<ex>5__7);
				}
				goto IL_019d;
			case 2:
				{
					<>1__state = -1;
					try
					{
						NPCManager.NPCRegistry.Remove(npc);
						Object.Destroy((Object)(object)((Component)npc).gameObject);
					}
					catch (Exception ex)
					{
						<ex>5__10 = ex;
						MelonLogger.Error((object)<ex>5__10);
					}
					<i>5__1++;
					goto IL_02b5;
				}
				IL_019d:
				if (<elapsed>5__4 < durationPerSegment)
				{
					<>2__current = (object)new WaitForSeconds(0.02f);
					<>1__state = 1;
					return true;
				}
				try
				{
					((Component)npc).transform.position = <end>5__3;
					<direction>5__8 = ((Component)<>4__this.playerMain).transform.position - ((Component)npc).transform.position;
					<direction>5__8.y = 0f;
					((Component)npc).transform.rotation = Quaternion.LookRotation(<direction>5__8);
				}
				catch (Exception ex)
				{
					<ex>5__9 = ex;
					MelonLogger.Error((object)<ex>5__9);
				}
				<>2__current = (object)new WaitForSeconds(1f);
				<>1__state = 2;
				return true;
				IL_02b5:
				if (<i>5__1 < path.Count - 1)
				{
					<start>5__2 = path[<i>5__1];
					<end>5__3 = path[<i>5__1 + 1];
					<elapsed>5__4 = 0f;
					goto IL_019d;
				}
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <RunInsanity>d__12 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Insanity <>4__this;

		private int <currTime>5__1;

		private EDay <currentDay>5__2;

		private EDay <updatedDay>5__3;

		private int <updatedTime>5__4;

		private string <characterId>5__5;

		private Dictionary<string, Vector3> <positions>5__6;

		private int <roll>5__7;

		private KeyValuePair<string, Vector3> <kvpair>5__8;

		private NPC <spawnedNpc>5__9;

		private string <characterId>5__10;

		private Dictionary<string, List<Vector3>> <positions>5__11;

		private KeyValuePair<string, List<Vector3>> <kvpair>5__12;

		private KeyValuePair<string, Vector3> <kvStart>5__13;

		private NPC <spawnedNpc>5__14;

		private Dictionary<string, Vector3> <positions>5__15;

		private int <roll>5__16;

		private KeyValuePair<string, Vector3> <kvpair>5__17;

		private NPC <spawnedNpc>5__18;

		private Property <property>5__19;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <RunInsanity>d__12(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<characterId>5__5 = null;
			<positions>5__6 = null;
			<kvpair>5__8 = default(KeyValuePair<string, Vector3>);
			<spawnedNpc>5__9 = null;
			<characterId>5__10 = null;
			<positions>5__11 = null;
			<kvpair>5__12 = default(KeyValuePair<string, List<Vector3>>);
			<kvStart>5__13 = default(KeyValuePair<string, Vector3>);
			<spawnedNpc>5__14 = null;
			<positions>5__15 = null;
			<kvpair>5__17 = default(KeyValuePair<string, Vector3>);
			<spawnedNpc>5__18 = null;
			<property>5__19 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: 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_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(10f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				goto IL_0059;
			case 2:
				<>1__state = -1;
				if (!<>4__this.registered)
				{
					return false;
				}
				<currTime>5__1 = NetworkSingleton<TimeManager>.Instance.CurrentTime;
				<currentDay>5__2 = NetworkSingleton<TimeManager>.Instance.CurrentDay;
				if (<currTime>5__1 > 2000)
				{
					goto IL_00c8;
				}
				goto IL_0059;
			case 3:
				{
					<>1__state = -1;
					if (!<>4__this.registered)
					{
						return false;
					}
					<updatedDay>5__3 = NetworkSingleton<TimeManager>.Instance.CurrentDay;
					<updatedTime>5__4 = NetworkSingleton<TimeManager>.Instance.CurrentTime;
					if (<currentDay>5__2 != <updatedDay>5__3 && <updatedTime>5__4 > 500)
					{
						goto IL_0059;
					}
					if ((Object)(object)<>4__this.playerMain.CurrentProperty != (Object)null && <>4__this.CharacterLocations.ContainsKey(<>4__this.playerMain.CurrentProperty.PropertyName))
					{
						<characterId>5__5 = <>4__this.npcIds[Random.Range(0, <>4__this.npcIds.Count)];
						<>4__this.CharacterLocations.TryGetValue(<>4__this.playerMain.CurrentProperty.PropertyName, out <positions>5__6);
						<roll>5__7 = Random.Range(0, <positions>5__6.Count);
						<kvpair>5__8 = <positions>5__6.ElementAt(<roll>5__7);
						<spawnedNpc>5__9 = <>4__this.SpawnAndInitializeNPC(<characterId>5__5, <kvpair>5__8);
						if ((Object)(object)<spawnedNpc>5__9 != (Object)null)
						{
							MelonCoroutines.Start(<>4__this.EventCoro(<spawnedNpc>5__9, <kvpair>5__8, <>4__this.playerMain.CurrentProperty));
						}
						<characterId>5__5 = null;
						<positions>5__6 = null;
						<kvpair>5__8 = default(KeyValuePair<string, Vector3>);
						<spawnedNpc>5__9 = null;
					}
					if ((Object)(object)<>4__this.playerMain.CurrentBusiness != (Object)null)
					{
						<characterId>5__10 = <>4__this.npcIds[Random.Range(0, <>4__this.npcIds.Count)];
						if (<>4__this.CharacterSpecials.ContainsKey(((Property)<>4__this.playerMain.CurrentBusiness).PropertyName) && Random.Range(0f, 1f) > 0.8f)
						{
							<>4__this.CharacterSpecials.TryGetValue(((Property)<>4__this.playerMain.CurrentBusiness).PropertyName, out <positions>5__11);
							<kvpair>5__12 = <positions>5__11.ElementAt(0);
							<kvStart>5__13 = new KeyValuePair<string, Vector3>(<kvpair>5__12.Key, <kvpair>5__12.Value[0]);
							<spawnedNpc>5__14 = <>4__this.SpawnAndInitializeNPC(<characterId>5__10, <kvStart>5__13);
							if ((Object)(object)<spawnedNpc>5__14 != (Object)null)
							{
								MelonCoroutines.Start(<>4__this.MoveAlongPath(<spawnedNpc>5__14, <kvpair>5__12.Value, 5f));
							}
							<positions>5__11 = null;
							<kvpair>5__12 = default(KeyValuePair<string, List<Vector3>>);
							<kvStart>5__13 = default(KeyValuePair<string, Vector3>);
							<spawnedNpc>5__14 = null;
						}
						else if (<>4__this.CharacterLocations.ContainsKey(((Property)<>4__this.playerMain.CurrentBusiness).PropertyName))
						{
							<>4__this.CharacterLocations.TryGetValue(((Property)<>4__this.playerMain.CurrentBusiness).PropertyName, out <positions>5__15);
							<roll>5__16 = Random.Range(0, <positions>5__15.Count);
							<kvpair>5__17 = <positions>5__15.ElementAt(<roll>5__16);
							<spawnedNpc>5__18 = <>4__this.SpawnAndInitializeNPC(<characterId>5__10, <kvpair>5__17);
							if ((Object)(object)<spawnedNpc>5__18 != (Object)null)
							{
								<property>5__19 = (Property)(object)<>4__this.playerMain.CurrentBusiness;
								MelonCoroutines.Start(<>4__this.EventCoro(<spawnedNpc>5__18, <kvpair>5__17, <property>5__19));
								<property>5__19 = null;
							}
							<positions>5__15 = null;
							<kvpair>5__17 = default(KeyValuePair<string, Vector3>);
							<spawnedNpc>5__18 = null;
						}
						<characterId>5__10 = null;
					}
					goto IL_00c8;
				}
				IL_00c8:
				<>2__current = (object)new WaitForSeconds(Random.Range(25f, 45f));
				<>1__state = 3;
				return true;
				IL_0059:
				<>2__current = (object)new WaitForSeconds(30f);
				<>1__state = 2;
				return true;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <Setup>d__10 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Insanity <>4__this;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <Setup>d__10(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(5f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<>4__this.playerMain = Object.FindObjectOfType<Player>(true);
				<>2__current = (object)new WaitForSeconds(1f);
				<>1__state = 2;
				return true;
			case 2:
				<>1__state = -1;
				<>4__this.doorKnock = Object.FindObjectOfType<DoorKnocker>(true).KnockingSound;
				<>2__current = (object)new WaitForSeconds(1f);
				<>1__state = 3;
				return true;
			case 3:
				<>1__state = -1;
				<>4__this.footSteps = Object.FindObjectOfType<FootstepSounds>(true).soundGroups[0].clips[0];
				<>2__current = (object)new WaitForSeconds(1f);
				<>1__state = 4;
				return true;
			case 4:
				<>1__state = -1;
				coros.Add(MelonCoroutines.Start(<>4__this.RunInsanity()));
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	public static List<object> coros = new List<object>();

	private bool registered = false;

	private Player playerMain;

	private AudioSource doorKnock;

	private AudioClip footSteps;

	public List<string> npcIds = new List<string> { "ming", "jessi_waters" };

	public Dictionary<string, Dictionary<string, Vector3>> CharacterLocations = new Dictionary<string, Dictionary<string, Vector3>>
	{
		{
			"Motel Room",
			new Dictionary<string, Vector3>
			{
				{
					"MotelWindow",
					new Vector3(-67.4f, 1.3f, 86f)
				},
				{
					"MotelDoor",
					new Vector3(-67.04f, 1.3f, 82.6f)
				}
			}
		},
		{
			"Sweatshop",
			new Dictionary<string, Vector3>
			{
				{
					"SweatWindowMain",
					new Vector3(-55.16f, 0.3f, 140.1f)
				},
				{
					"SweatDoor",
					new Vector3(-64.29f, -0.4f, 141.84f)
				},
				{
					"SweatStreet1",
					new Vector3(-57.23f, -3.4f, 123.22f)
				},
				{
					"SweatHighCorner",
					new Vector3(-56.18f, 0.3f, 115.25f)
				}
			}
		},
		{
			"Bungalow",
			new Dictionary<string, Vector3>
			{
				{
					"BungalowDoorMain",
					new Vector3(-169.18f, -3.7f, 113.82f)
				},
				{
					"BungalowDoorBack",
					new Vector3(-176.87f, -3.7f, 110.26f)
				},
				{
					"BungalowWindowKitchen1",
					new Vector3(-176.77f, -3.6f, 118.66f)
				}
			}
		},
		{
			"Barn",
			new Dictionary<string, Vector3>
			{
				{
					"BarnUnderStairs",
					new Vector3(200.8111f, 0.1f, -10.9124f)
				},
				{
					"BarnFloating",
					new Vector3(187.9814f, 3.8f, -13.52317f)
				},
				{
					"BarnWoods",
					new Vector3(174.0903f, -0.1f, 3.852638f)
				},
				{
					"BarnRoad",
					new Vector3(159.279f, -0.2f, -12.15506f)
				}
			}
		},
		{
			"Docks Warehouse",
			new Dictionary<string, Vector3>
			{
				{
					"DocksOutCorner",
					new Vector3(-83.82198f, -2.1f, -35.59542f)
				},
				{
					"DocksOnPillar",
					new Vector3(-88.41868f, 0.5f, -61.17904f)
				},
				{
					"DocksOnRoof",
					new Vector3(-47.33374f, 4.1f, -68.83347f)
				}
			}
		},
		{
			"Taco Ticklers",
			new Dictionary<string, Vector3>
			{
				{
					"TacoCan",
					new Vector3(-27.67904f, 0.23f, 75.21258f)
				},
				{
					"TacoBackDoor",
					new Vector3(-31.239f, 0.23f, 84.10281f)
				},
				{
					"TacoFrontWindow",
					new Vector3(-26.84878f, 0.23f, 63.86666f)
				},
				{
					"TacoRunToStaff",
					new Vector3(-34.48309f, 0.23f, 76.22535f)
				}
			}
		},
		{
			"Laundromat",
			new Dictionary<string, Vector3>
			{
				{
					"LaundromatDoor",
					new Vector3(-23.53883f, 0.3f, 24.97166f)
				},
				{
					"LaundromatCreep",
					new Vector3(-24.18913f, 0.6f, 23.33677f)
				},
				{
					"LaundromatBoxes",
					new Vector3(-10.6364f, 0.8f, 27.53411f)
				}
			}
		},
		{
			"Car Wash",
			new Dictionary<string, Vector3>
			{
				{
					"CarWashBusStop",
					new Vector3(-23.94017f, 0.2f, -24.21171f)
				},
				{
					"CarWashBackDoor",
					new Vector3(-3.334698f, 0.35f, -22.07097f)
				},
				{
					"CarWashRunToWindow",
					new Vector3(-6.237535f, 0.35f, -15.59119f)
				}
			}
		},
		{
			"Post Office",
			new Dictionary<string, Vector3>
			{
				{
					"PostOfficeWindow1",
					new Vector3(52.59536f, 0.3f, -1.74566f)
				},
				{
					"PostOfficeWindow2",
					new Vector3(42.58666f, 0.3f, -1.472795f)
				},
				{
					"PostOfficeBack",
					new Vector3(45.09676f, 0.2f, -8.674371f)
				},
				{
					"PostOfficeStreet",
					new Vector3(41.80392f, 0.2f, 8.459332f)
				}
			}
		}
	};

	public Dictionary<string, Dictionary<string, List<Vector3>>> CharacterSpecials = new Dictionary<string, Dictionary<string, List<Vector3>>>
	{
		{
			"Taco Ticklers",
			new Dictionary<string, List<Vector3>> { 
			{
				"TacoRunToStaff",
				new List<Vector3>
				{
					new Vector3(-34.48309f, 0.23f, 76.22535f),
					new Vector3(-34.48309f, 0.23f, 79.53841f)
				}
			} }
		},
		{
			"Car Wash",
			new Dictionary<string, List<Vector3>> { 
			{
				"CarWashRunToWindow",
				new List<Vector3>
				{
					new Vector3(-9.058268f, 0.35f, -10.47236f),
					new Vector3(-6.237535f, 0.35f, -15.59119f)
				}
			} }
		}
	};

	private void OnLoadCompleteCb()
	{
		if (!registered)
		{
			coros.Add(MelonCoroutines.Start(Setup()));
			registered = true;
		}
	}

	public override void OnSceneWasInitialized(int buildIndex, string sceneName)
	{
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Expected O, but got Unknown
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Expected O, but got Unknown
		if (buildIndex == 1)
		{
			if ((Object)(object)Singleton<LoadManager>.Instance != (Object)null && !registered)
			{
				Singleton<LoadManager>.Instance.onLoadComplete.AddListener(new UnityAction(OnLoadCompleteCb));
			}
			return;
		}
		if ((Object)(object)Singleton<LoadManager>.Instance != (Object)null && registered)
		{
			Singleton<LoadManager>.Instance.onLoadComplete.RemoveListener(new UnityAction(OnLoadCompleteCb));
		}
		registered = false;
		foreach (object coro in coros)
		{
			MelonCoroutines.Stop(coro);
		}
		coros.Clear();
	}

	[IteratorStateMachine(typeof(<Setup>d__10))]
	public IEnumerator Setup()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <Setup>d__10(0)
		{
			<>4__this = this
		};
	}

	private NPC SpawnAndInitializeNPC(string characterId, KeyValuePair<string, Vector3> kvp)
	{
		//IL_017f: 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_01a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		NPC nPC = NPCManager.GetNPC(characterId);
		GameObject val = Object.Instantiate<GameObject>(((Component)nPC).gameObject, NetworkSingleton<NPCManager>.Instance.NPCContainer);
		if ((Object)(object)val == (Object)null)
		{
			return null;
		}
		NPC component = val.GetComponent<NPC>();
		string iD = "test_" + characterId + "_" + Guid.NewGuid().ToString().Substring(0, 8);
		component.ID = iD;
		component.FirstName = "";
		component.LastName = "";
		NavMeshAgent component2 = ((Component)component).GetComponent<NavMeshAgent>();
		if ((Object)(object)component2 != (Object)null)
		{
			Object.Destroy((Object)(object)component2);
		}
		Rigidbody component3 = ((Component)component).GetComponent<Rigidbody>();
		if ((Object)(object)component3 != (Object)null)
		{
			Object.Destroy((Object)(object)component3);
		}
		NetworkObject component4 = ((Component)component).GetComponent<NetworkObject>();
		if ((Object)(object)component4 != (Object)null)
		{
			((Behaviour)component4).enabled = false;
		}
		((Behaviour)component.behaviour).enabled = false;
		component.CanOpenDoors = false;
		((Behaviour)component.Movement).enabled = false;
		component.PlayerConversant = ((NetworkBehaviour)playerMain).NetworkObject;
		val.SetActive(true);
		component.SetVisible(true);
		component.Avatar.Effects.SetSicklySkinColor(true);
		component.Avatar.Effects.SetZombified(true, true);
		component.Avatar.EmotionManager.AddEmotionOverride("Zombie", "deal_rejected", 30f, 0);
		NPCManager.NPCRegistry.Add(component);
		val.transform.position = kvp.Value;
		Vector3 val2 = ((Component)playerMain).transform.position - ((Component)component).transform.position;
		val2.y = 0f;
		val.transform.rotation = Quaternion.LookRotation(val2);
		return component;
	}

	[IteratorStateMachine(typeof(<RunInsanity>d__12))]
	public IEnumerator RunInsanity()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <RunInsanity>d__12(0)
		{
			<>4__this = this
		};
	}

	[IteratorStateMachine(typeof(<EventCoro>d__13))]
	private IEnumerator EventCoro(NPC npc, KeyValuePair<string, Vector3> kvPair, Property property)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <EventCoro>d__13(0)
		{
			<>4__this = this,
			npc = npc,
			kvPair = kvPair,
			property = property
		};
	}

	[IteratorStateMachine(typeof(<MoveAlongPath>d__14))]
	private IEnumerator MoveAlongPath(NPC npc, List<Vector3> path, float durationPerSegment)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <MoveAlongPath>d__14(0)
		{
			<>4__this = this,
			npc = npc,
			path = path,
			durationPerSegment = durationPerSegment
		};
	}
}