Decompiled source of Millenium Winterland v1.0.5

CommonAPI.dll

Decompiled 2 years 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 System.Threading;
using BepInEx;
using BepInEx.Logging;
using DG.Tweening;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Reptile;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("CommonAPI")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("General Purpose API for BRC modding.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+490a06741082075b8042a77bfe96ef00881e4aa5")]
[assembly: AssemblyProduct("CommonAPI")]
[assembly: AssemblyTitle("CommonAPI")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CommonAPI
{
	public static class AssetAPI
	{
		public enum ShaderNames
		{
			AmbientCharacter,
			AmbientEnvironment,
			AmbientEnvironmentCutout,
			AmbientEnvironmentTransparent
		}

		public enum MaterialNames
		{
			ToonWaterPyramid,
			OasisWater
		}

		private static readonly Dictionary<ShaderNames, Shader> CachedShaders = new Dictionary<ShaderNames, Shader>();

		private static readonly Dictionary<MaterialNames, Material> CachedMaterials = new Dictionary<MaterialNames, Material>();

		public static GraffitiArtInfo GetGraffitiArtInfo()
		{
			return Core.Instance.Assets.LoadAssetFromBundle<GraffitiArtInfo>("graffiti", "GraffitiArtInfo");
		}

		public static Material GetMaterial(MaterialNames materialName)
		{
			if (CachedMaterials.TryGetValue(materialName, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			Assets assets = Core.Instance.Assets;
			switch (materialName)
			{
			case MaterialNames.ToonWaterPyramid:
			{
				Material val2 = assets.LoadAssetFromBundle<Material>("common_assets", "ToonWater_Pyramid");
				CacheMaterial(materialName, val2);
				return val2;
			}
			case MaterialNames.OasisWater:
			{
				Material val = assets.LoadAssetFromBundle<Material>("common_assets", "OasisWater");
				CacheMaterial(materialName, val);
				return val;
			}
			default:
				throw new ArgumentOutOfRangeException("materialName", "Material name is out of range!");
			}
		}

		public static Shader GetShader(ShaderNames shaderName)
		{
			if (CachedShaders.TryGetValue(shaderName, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			Assets assets = Core.Instance.Assets;
			switch (shaderName)
			{
			case ShaderNames.AmbientCharacter:
			{
				Shader shader4 = assets.LoadAssetFromBundle<Material>("common_assets", "shell").shader;
				CacheShader(shaderName, shader4);
				return shader4;
			}
			case ShaderNames.AmbientEnvironment:
			{
				Shader shader3 = assets.LoadAssetFromBundle<Material>("common_assets", "SkateboardScrewPoleMat").shader;
				CacheShader(shaderName, shader3);
				return shader3;
			}
			case ShaderNames.AmbientEnvironmentCutout:
			{
				Shader shader2 = assets.LoadAssetFromBundle<Material>("common_assets", "Prelude_PropsAtlasMat").shader;
				CacheShader(shaderName, shader2);
				return shader2;
			}
			case ShaderNames.AmbientEnvironmentTransparent:
			{
				Shader shader = assets.LoadAssetFromBundle<Material>("common_assets", "MusicCollectableMiniDiscTransperantMat").shader;
				CacheShader(shaderName, shader);
				return shader;
			}
			default:
				throw new ArgumentOutOfRangeException("shaderName", "Shader name is out of range!");
			}
		}

		private static void CacheShader(ShaderNames shaderName, Shader shader)
		{
			CachedShaders[shaderName] = shader;
		}

		private static void CacheMaterial(MaterialNames materialName, Material material)
		{
			CachedMaterials[materialName] = material;
		}
	}
	[BepInPlugin("CommonAPI", "CommonAPI", "1.0.0")]
	internal class CommonAPIPlugin : BaseUnityPlugin
	{
		public static CommonAPIPlugin Instance;

		public static ManualLogSource Log => ((BaseUnityPlugin)Instance).Logger;

		private void Awake()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			try
			{
				SaveAPI.Initialize();
				CustomSequenceHandler.Initialize();
				new CustomStorage();
				new Harmony("CommonAPI").PatchAll();
				((BaseUnityPlugin)this).Logger.LogInfo((object)"CommonAPI 1.0.0 loaded!");
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)string.Format("Problem loading {0} {1}!{2}{3}", "CommonAPI", "1.0.0", Environment.NewLine, ex));
			}
		}

		private void OnApplicationQuit()
		{
			CustomStorage.Instance.HandleQuit();
		}
	}
	internal class CommonAPISettings
	{
		public static bool Debug;
	}
	public class CustomDialogue
	{
		public string CharacterName = "";

		public string Dialogue = "";

		public Action OnDialogueBegin;

		public Action OnDialogueEnd;

		public bool EndSequenceOnFinish;

		public CustomDialogue NextDialogue;

		public ShowBarsType ShowBars = (ShowBarsType)1;

		public bool AnsweredYes;

		public CustomDialogue(string characterName, string dialogue, CustomDialogue nextDialogue = null)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			CharacterName = characterName;
			Dialogue = dialogue;
			NextDialogue = nextDialogue;
		}
	}
	public class CustomInteractable : MonoBehaviour
	{
		public bool PlacePlayerAtSnapPosition = true;

		public bool LookAt = true;

		public bool ShowRep;

		public InteractableIcon Icon;

		public Sprite CustomIcon;

		internal void OnSequenceBegin(CustomSequence sequence)
		{
			//IL_0030: 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)
			if (!PlacePlayerAtSnapPosition)
			{
				return;
			}
			Transform val = ((Component)this).transform.Find("PlayerSnapPosition");
			if (!((Object)(object)val == (Object)null))
			{
				WorldHandler.instance.PlacePlayerAt(sequence.player, val.position, val.rotation, true);
				PlayerSpawner component = ((Component)val).GetComponent<PlayerSpawner>();
				if ((Object)(object)component != (Object)null)
				{
					component.SetReached();
				}
			}
		}

		public void StartEnteringSequence(CustomSequence sequence, bool setHidePlayer = false, bool setInterruptPlayer = true, bool instantly = false, bool setPausePlayer = true, bool setAllowPhoneOnAfterSequence = true, bool skippable = true, bool lowerVolumeDuringSequence = true, bool disabledExitOnInput = false)
		{
			CustomSequenceHandler.instance.StartEnteringSequence(sequence, this, setHidePlayer, setInterruptPlayer, instantly, setPausePlayer, setAllowPhoneOnAfterSequence, skippable, lowerVolumeDuringSequence, disabledExitOnInput);
		}

		private void OnTriggerStay(Collider other)
		{
			Player val = ((Component)other).GetComponentInChildren<Player>();
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = ((Component)other).GetComponentInParent<Player>();
			}
			if (Object.op_Implicit((Object)(object)val))
			{
				CheckForInteraction(val);
			}
		}

		public bool CheckForInteraction(Player player)
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			if (player.isAI)
			{
				return false;
			}
			if (player.IsDead())
			{
				return false;
			}
			if (!Player.NoMenuOpen())
			{
				return false;
			}
			if (!player.IsNotInCutsceneOrGettingCalled())
			{
				return false;
			}
			if (player.breakChainContextAvailable > 0)
			{
				return false;
			}
			if (player.graffitiContextAvailable > 0)
			{
				return false;
			}
			if (player.talkContextAvailable > 0)
			{
				return false;
			}
			CustomPlayerComponent customPlayerComponent = CustomPlayerComponent.Get(player);
			if (!Object.op_Implicit((Object)(object)customPlayerComponent))
			{
				return false;
			}
			if (!Test(player))
			{
				return false;
			}
			customPlayerComponent.CurrentCustomInteractable = this;
			customPlayerComponent.CustomInteractableContextAvailable = 10;
			if (ShowRep)
			{
				player.showRepLingerTimer = 2f;
			}
			if (LookAt)
			{
				player.characterVisual.LookAtSubject(((Component)this).gameObject, GetLookAtPos());
			}
			if (player.sprayButtonNew)
			{
				Interact(player);
				return true;
			}
			return false;
		}

		public virtual Vector3 GetLookAtPos()
		{
			//IL_0026: 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)
			Transform val = ((Component)this).transform.Find("LookTarget");
			if (Object.op_Implicit((Object)(object)val))
			{
				return val.position;
			}
			return ((Component)this).transform.position;
		}

		public virtual bool Test(Player player)
		{
			return true;
		}

		public virtual void Interact(Player player)
		{
		}
	}
	internal class CustomPlayerComponent : MonoBehaviour
	{
		public Image CustomContextIcon;

		public CustomInteractable CurrentCustomInteractable;

		public int CustomInteractableContextAvailable;

		private Player _player;

		public static CustomPlayerComponent Get(Player player)
		{
			return ((Component)player).GetComponent<CustomPlayerComponent>();
		}

		public static CustomPlayerComponent Attach(Player player)
		{
			CustomPlayerComponent customPlayerComponent = ((Component)player).gameObject.AddComponent<CustomPlayerComponent>();
			customPlayerComponent._player = player;
			customPlayerComponent.Init();
			return customPlayerComponent;
		}

		private void Init()
		{
			if (!((Object)(object)_player.ui == (Object)null))
			{
				CustomContextIcon = Object.Instantiate<Image>(_player.ui.contextTalkIcon, ((Component)_player.ui.contextTalkIcon).gameObject.transform.parent);
			}
		}
	}
	public abstract class CustomSaveData
	{
		public string Filename;

		public bool AutoSave = true;

		internal bool QueuedSave;

		public CustomSaveData(string pluginName, string filename)
		{
			Filename = Path.Combine(Paths.ConfigPath, pluginName, "saves", filename);
			SaveAPI.RegisterCustomSaveData(this);
		}

		public virtual void Initialize()
		{
		}

		public virtual void Read(BinaryReader reader)
		{
		}

		public virtual void Write(BinaryWriter writer)
		{
		}

		public void Save()
		{
			QueuedSave = true;
		}

		internal string GetFilenameForFileID(int fileID)
		{
			return string.Format(Filename, fileID);
		}
	}
	internal class CustomSaveTransaction : CustomTransaction
	{
		private string _path;

		private byte[] _data;

		public CustomSaveTransaction(byte[] data, string filepath)
		{
			_data = data;
			_path = filepath;
		}

		public override void Process()
		{
			Directory.CreateDirectory(Path.GetDirectoryName(_path));
			File.WriteAllBytes(_path, _data);
		}
	}
	public class CustomSequence
	{
		public GameObject CurrentCamera;

		public Player player;

		public DialogueUI dialogueUI;

		public EffectsUI effectsUI;

		public double time;

		public void Init()
		{
			dialogueUI = Core.Instance.UIManager.dialogueUI;
			player = WorldHandler.instance.GetCurrentPlayer();
			effectsUI = Core.instance.UIManager.effects;
		}

		public virtual void Play()
		{
			effectsUI.ShowBars(0.25f, 150f, (UpdateType)3);
		}

		public virtual void Stop()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (dialogueUI.isYesNoPromptEnabled)
			{
				dialogueUI.DisableYesNoPrompt();
			}
			effectsUI.HideBars(0.25f, (UpdateType)3);
			player.sequenceState = (SequenceState)4;
			if ((Object)(object)CurrentCamera != (Object)null)
			{
				CurrentCamera.SetActive(false);
			}
		}

		public void StartDialogue(CustomDialogue dialogue, float delay = 0.9f)
		{
			CustomSequenceHandler.instance.StartDialogueDelayed(dialogue, delay);
		}

		public void ExitSequence(float delay = 0.9f)
		{
			CustomSequenceHandler.instance.ExitCurrentSequenceDelayed(delay);
		}

		public void SetCamera(GameObject camera)
		{
			if ((Object)(object)CurrentCamera != (Object)null)
			{
				CurrentCamera.SetActive(false);
			}
			CurrentCamera = camera;
			if ((Object)(object)CurrentCamera != (Object)null)
			{
				CurrentCamera.SetActive(true);
			}
		}

		public void RequestYesNoPrompt()
		{
			dialogueUI.RequestYesNoPrompt((DialogueType)1);
		}
	}
	public class CustomSequenceHandler : AMenuController
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static OnStageInitializedDelegate <0>__StageManager_OnStagePostInitialization;
		}

		public const float DefaultExitDelay = 0.9f;

		public const float DefaultDialogueDelay = 0.9f;

		public static CustomSequenceHandler instance;

		public CustomSequence sequence;

		public CustomInteractable interactable;

		public bool disabledExit;

		private GameInput gameInput;

		private BaseModule baseModule;

		private Player player;

		private bool sequenceOverwritten;

		private float skipTimer;

		public SkipState skipTextActiveState = (SkipState)1;

		private float skipTextTimer;

		public bool isBusy;

		private bool hidePlayer;

		private bool pausePlayer;

		private bool interruptPlayer;

		private bool lowerVolume;

		private readonly float fadeDuration = 0.4f;

		internal float shutDuration = 0.2f;

		private readonly float skipFadeDuration = 0.3f;

		private float skipStartTimer;

		private readonly float skipThreshold = 0.4f;

		private readonly List<Coroutine> queuedSequenceActions = new List<Coroutine>();

		internal bool allowPhoneOnAfterSequence;

		internal CustomDialogue CurrentDialogue;

		public static void Initialize()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__StageManager_OnStagePostInitialization;
			if (obj == null)
			{
				OnStageInitializedDelegate val = StageManager_OnStagePostInitialization;
				<>O.<0>__StageManager_OnStagePostInitialization = val;
				obj = (object)val;
			}
			StageManager.OnStagePostInitialization += (OnStageInitializedDelegate)obj;
		}

		private IEnumerator StartDialogueCoroutine(CustomDialogue dialogue, float delay = 0.9f)
		{
			yield return (object)new WaitForSeconds(0.9f);
			StartDialogue(dialogue);
		}

		public void StartDialogueDelayed(CustomDialogue dialogue, float delay = 0.9f)
		{
			queuedSequenceActions.Add(((MonoBehaviour)this).StartCoroutine(StartDialogueCoroutine(dialogue, delay)));
		}

		public void StartDialogue(CustomDialogue dialogue)
		{
			instance.CurrentDialogue = dialogue;
			DialogueUI dialogueUI = Core.Instance.UIManager.dialogueUI;
			dialogueUI.effectsUI.ShowBars(0.25f, 150f, (UpdateType)3);
			dialogueUI.CanBeSkipped = true;
			dialogueUI.ToggleDialogueUI(true);
			dialogueUI.SetLine(dialogue.Dialogue);
			((Behaviour)dialogueUI.characterNameText).enabled = true;
			dialogue.OnDialogueBegin?.Invoke();
		}

		private static void StageManager_OnStagePostInitialization()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new GameObject("Custom Sequence Handler").AddComponent<CustomSequenceHandler>().Init();
		}

		public void Init()
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			instance = this;
			base.allowMouseInput = false;
			gameInput = Core.Instance.GameInput;
			base.uIManager = Core.Instance.UIManager;
			base.audioManager = Core.Instance.AudioManager;
			baseModule = Core.Instance.BaseModule;
			player = WorldHandler.instance.GetCurrentPlayer();
			Core.OnUpdate += new OnUpdateHandler(UpdateSequenceHandler);
			Core.OnCoreUpdatePaused += new OnCoreUpdateHandler(OnCoreUpdatePaused);
			Core.OnCoreUpdateUnPaused += new OnCoreUpdateUnpausedHandler(OnCoreUpdateUnPaused);
		}

		public void ExitCurrentSequenceDelayed(float delay = 0.9f)
		{
			queuedSequenceActions.Add(((MonoBehaviour)this).StartCoroutine(ExitCurrentSequenceDelayedCoroutine(delay)));
		}

		private IEnumerator ExitCurrentSequenceDelayedCoroutine(float delay = 0.9f)
		{
			yield return (object)new WaitForSeconds(delay);
			yield return ExitSequenceRoutine();
		}

		public void ExitCurrentSequence()
		{
			((MonoBehaviour)this).StartCoroutine(ExitSequenceRoutine());
		}

		public override void OnDestroy()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			((AMenuController)this).OnDestroy();
			if ((Object)(object)Core.Instance != (Object)null && (Object)(object)base.uIManager != (Object)null)
			{
				base.uIManager.AbsolutePopIfPresent((IUIMenuController)(object)this);
			}
			base.audioManager = null;
			base.uIManager = null;
			gameInput = null;
			player = null;
			instance = null;
			Core.OnUpdate -= new OnUpdateHandler(UpdateSequenceHandler);
			Core.OnCoreUpdatePaused -= new OnCoreUpdateHandler(OnCoreUpdatePaused);
			Core.OnCoreUpdateUnPaused -= new OnCoreUpdateUnpausedHandler(OnCoreUpdateUnPaused);
		}

		public void UpdateSequenceHandler()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Invalid comparison between Unknown and I4
			//IL_0094: 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: Invalid comparison between Unknown and I4
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Invalid comparison between Unknown and I4
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Expected O, but got Unknown
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Expected O, but got Unknown
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Expected O, but got Unknown
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Expected O, but got Unknown
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			if (!isBusy || (int)player.sequenceState != 1)
			{
				return;
			}
			DialogueUI dialogueUI = base.uIManager.dialogueUI;
			bool flag = ((AMenuController)this).IsEnabled && !disabledExit && gameInput.GetButtonNew(2, 0);
			if (flag && dialogueUI.CanBeSkipped && !dialogueUI.isYesNoPromptEnabled)
			{
				if (dialogueUI.ReadyToResume)
				{
					if (dialogueUI.IsShowingDialogue())
					{
						Core.Instance.AudioManager.PlaySfxUI((SfxCollectionID)23, (AudioClipID)922, 0f);
					}
					dialogueUI.EndDialogue();
				}
				else
				{
					FastForwardTypewriter();
				}
			}
			if ((int)skipTextActiveState != 0 && !dialogueUI.isYesNoPromptEnabled)
			{
				EffectsUI effects = base.uIManager.effects;
				float dt = Core.dt;
				bool num = ((AMenuController)this).IsEnabled && gameInput.GetButtonHeld(64, 0);
				if (skipStartTimer >= 0.5f)
				{
					if ((int)skipTextActiveState == 3)
					{
						skipTextTimer += dt;
						if (skipTextTimer > 1.5f && skipTimer == 0f)
						{
							Tween obj = effects.FadeSkipOut(skipFadeDuration, (UpdateType)3);
							obj.onComplete = (TweenCallback)Delegate.Combine((Delegate?)(object)obj.onComplete, (Delegate?)(TweenCallback)delegate
							{
								//IL_0002: Unknown result type (might be due to invalid IL or missing references)
								skipTextActiveState = (SkipState)1;
							});
							skipTextActiveState = (SkipState)2;
							skipTextTimer = 0f;
						}
					}
					else if ((int)skipTextActiveState == 1 && !flag && (gameInput.GetButtonHeld(64, 0) || gameInput.GetButtonHeld(4, 0)))
					{
						Tween obj2 = effects.FadeSkipIn(skipFadeDuration, (UpdateType)3);
						obj2.onComplete = (TweenCallback)Delegate.Combine((Delegate?)(object)obj2.onComplete, (Delegate?)(TweenCallback)delegate
						{
							//IL_0002: Unknown result type (might be due to invalid IL or missing references)
							skipTextActiveState = (SkipState)3;
						});
						skipTextActiveState = (SkipState)2;
					}
				}
				skipStartTimer += dt;
				if (num && skipStartTimer >= 0.5f)
				{
					skipTimer += dt;
					skipTextTimer = 0f;
				}
				else
				{
					skipTimer = 0f;
				}
			}
			if (!disabledExit && skipTimer >= skipThreshold)
			{
				((MonoBehaviour)this).StartCoroutine(ExitSequenceRoutine());
			}
		}

		private IEnumerator ExitSequenceRoutine()
		{
			if ((int)player.sequenceState != 2)
			{
				player.sequenceState = (SequenceState)2;
				Core coreInstance = Core.Instance;
				EffectsUI effectsUI = base.uIManager.effects;
				skipTextActiveState = (SkipState)4;
				effectsUI.FadeSkipOut(skipFadeDuration, (UpdateType)3);
				_ = Time.deltaTime;
				_ = fadeDuration;
				Tween val = effectsUI.FadeToBlack(fadeDuration);
				yield return TweenExtensions.WaitForCompletion(val);
				yield return (object)new WaitForSeconds(shutDuration);
				SetExitSequence();
				yield return (object)new WaitForSeconds(shutDuration);
				yield return (object)new WaitWhile((Func<bool>)(() => coreInstance.IsCorePaused));
				if (!IsInSequence())
				{
					effectsUI.FadeOpen(fadeDuration);
					isBusy = false;
					effectsUI.HideVerticalBars();
				}
			}
		}

		public override void Activate()
		{
		}

		public override void Deactivate()
		{
		}

		private void StopAllSequenceActions()
		{
			foreach (Coroutine queuedSequenceAction in queuedSequenceActions)
			{
				if (queuedSequenceAction != null)
				{
					((MonoBehaviour)this).StopCoroutine(queuedSequenceAction);
				}
			}
			queuedSequenceActions.Clear();
		}

		private void SetExitSequence()
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			StopAllSequenceActions();
			if (hidePlayer)
			{
				player.HideForSequence(false);
			}
			if (pausePlayer)
			{
				player.PauseForSequence(false);
			}
			if (lowerVolume || (base.audioManager.IsVolumeLowered && !IsInSequence()))
			{
				lowerVolume = false;
				base.audioManager.StopTemporarilyLowerVolume((MonoBehaviour)(object)this);
			}
			player.sequenceState = (SequenceState)4;
			player.RecheckLoopingSounds();
			sequence.time = 0.0;
			sequence.Stop();
			WorldHandler val = WorldHandler.instance;
			if (Object.op_Implicit((Object)(object)val))
			{
				Player currentPlayer = val.GetCurrentPlayer();
				if ((Object)(object)currentPlayer != (Object)null)
				{
					GameplayCamera cam = currentPlayer.cam;
					if ((Object)(object)cam != (Object)null && (Object)(object)val.CurrentCamera != (Object)(object)cam.cam)
					{
						((Behaviour)val.CurrentCamera).enabled = false;
					}
				}
			}
			base.uIManager.AbsolutePopIfPresent((IUIMenuController)(object)this);
			if (base.uIManager.dialogueUI.IsShowingDialogue())
			{
				base.uIManager.dialogueUI.AbortDialogue();
			}
			LetPlayerExitSequence();
		}

		public void LetPlayerExitSequence()
		{
			player.userInputEnabled = true;
			((Component)player.ui).gameObject.SetActive(true);
			player.phone.SetAllCamerasForSequenceExit();
			player.phone.AllowPhone(true, false, allowPhoneOnAfterSequence);
			player.EnablePlayer(false);
			if (!base.uIManager.IsShowingAnyMenu && baseModule.IsPlayingInStage)
			{
				baseModule.StageManager.RestoreCurrentPlayerInput();
			}
		}

		private void FastForwardTypewriter()
		{
			base.uIManager.dialogueUI.FastForwardTypewriter();
		}

		public void StartEnteringSequence(CustomSequence setSequence, CustomInteractable interactable = null, bool setHidePlayer = true, bool setInterruptPlayer = true, bool instantly = false, bool setPausePlayer = false, bool setAllowPhoneOnAfterSequence = true, bool skippable = true, bool lowerVolumeDuringSequence = false, bool disabledExitOnInput = false)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			this.interactable = interactable;
			sequenceOverwritten = false;
			if (IsInSequence() && (int)player.sequenceState != 3)
			{
				sequenceOverwritten = true;
			}
			if (player.ability == player.characterSelectAbility)
			{
				instantly = false;
			}
			sequence = setSequence;
			skipTimer = 0f;
			skipTextActiveState = (SkipState)(skippable ? 1 : 0);
			skipTextTimer = 0f;
			isBusy = true;
			hidePlayer = setHidePlayer;
			allowPhoneOnAfterSequence = setAllowPhoneOnAfterSequence;
			interruptPlayer = setInterruptPlayer;
			pausePlayer = setPausePlayer;
			lowerVolume = lowerVolume != lowerVolumeDuringSequence && lowerVolumeDuringSequence;
			disabledExit = disabledExitOnInput;
			base.audioManager.PauseAllGameplayLoopingSfx();
			base.audioManager.ClearAllGameplayLoopingSfx();
			if (base.uIManager.IsShowingAnyMenu)
			{
				base.uIManager.PopAllMenusInstant();
			}
			if (instantly)
			{
				SetInSequenceImmediate();
			}
			else
			{
				((MonoBehaviour)this).StartCoroutine(EnterSequenceRoutine());
			}
		}

		private IEnumerator EnterSequenceRoutine()
		{
			player.sequenceState = (SequenceState)0;
			if (player.inGraffitiGame)
			{
				yield return (object)new WaitUntil((Func<bool>)(() => !player.inGraffitiGame));
			}
			if (player.ability == player.characterSelectAbility)
			{
				yield return (object)new WaitUntil((Func<bool>)(() => player.ability != player.characterSelectAbility));
			}
			else if (player.ability == player.danceAbility)
			{
				player.StopCurrentAbility();
			}
			player.userInputEnabled = false;
			player.phone.AllowPhone(false, false, false);
			SetPartiallyInSequence();
			yield return TweenExtensions.WaitForCompletion(base.uIManager.effects.FadeToBlack(fadeDuration));
			SetFullyInSequence();
			yield return (object)new WaitForSeconds(shutDuration);
			base.uIManager.effects.FadeOpen(fadeDuration);
			base.uIManager.effects.ShowVerticalBars();
		}

		private void SetPartiallyInSequence()
		{
			player.FlushInput();
			if (interruptPlayer)
			{
				player.CompletelyStop();
			}
			if (pausePlayer)
			{
				player.PauseForSequence(true);
			}
			player.StopHoldProps();
			player.DestroyPickupVisuals();
			player.phone.AllowPhone(false, false, false);
			if (!sequenceOverwritten)
			{
				player.DisablePlayer();
			}
			if (lowerVolume)
			{
				base.audioManager.StartTemporarilyLowerVolume((MonoBehaviour)(object)this);
			}
		}

		private void SetFullyInSequence()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			player.sequenceState = (SequenceState)1;
			if (hidePlayer)
			{
				player.HideForSequence(true);
			}
			gameInput.DisableAllControllerMaps(0);
			gameInput.EnableControllerMap(1, 0);
			if (!((AMenuController)this).IsEnabled)
			{
				base.uIManager.PushNewMenuInstant((IUIMenuController)(object)this);
			}
			((Component)player.ui).gameObject.SetActive(false);
			sequence.Init();
			if ((Object)(object)interactable != (Object)null)
			{
				interactable.OnSequenceBegin(sequence);
			}
			sequence.Play();
			skipStartTimer = 0f;
		}

		private void SetInSequenceImmediate()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			EffectsUI effects = base.uIManager.effects;
			if (!effects.IsFadedToColor(EffectsUI.niceClear))
			{
				effects.FadeOpen(0f);
				effects.ShowVerticalBars();
			}
			SetPartiallyInSequence();
			SetFullyInSequence();
		}

		public bool IsInSequence()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Invalid comparison between Unknown and I4
			return (int)player.sequenceState != 4;
		}

		public void SetPreEnteringSequence()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			player.sequenceState = (SequenceState)3;
		}

		private void OnCoreUpdatePaused()
		{
			if (sequence != null && !base.uIManager.dialogueUI.isYesNoPromptEnabled)
			{
				_ = disabledExit;
			}
		}

		private void OnCoreUpdateUnPaused()
		{
			if (sequence != null && !base.uIManager.dialogueUI.isYesNoPromptEnabled)
			{
				_ = disabledExit;
			}
		}
	}
	public class CustomStorage
	{
		public static CustomStorage Instance;

		private Thread _storageThread;

		private bool _running = true;

		private Queue<CustomTransaction> _transactionQueue = new Queue<CustomTransaction>();

		internal CustomStorage()
		{
			Instance = this;
			_storageThread = new Thread(StorageLoop);
			_storageThread.IsBackground = true;
			_storageThread.Name = "CustomStorageThread";
			_storageThread.Start();
		}

		private void StorageLoop()
		{
			while (_running)
			{
				if (_transactionQueue.Count > 0)
				{
					_transactionQueue.Peek().Process();
					_transactionQueue.Dequeue();
				}
				else
				{
					Thread.Sleep(100);
				}
			}
		}

		internal void HandleQuit()
		{
			CommonAPIPlugin.Log.LogInfo((object)"Flushing custom save files...");
			DateTime dateTime = DateTime.Now + TimeSpan.FromSeconds(15.0);
			while (_transactionQueue.Count > 0)
			{
				if (DateTime.Now > dateTime)
				{
					throw new Exception("Could not finish saving to save files, the thread was aborted prematurely!");
				}
			}
			_running = false;
		}

		public void WriteFile(byte[] data, string path)
		{
			CustomSaveTransaction item = new CustomSaveTransaction(data, path);
			_transactionQueue.Enqueue(item);
		}
	}
	internal abstract class CustomTransaction
	{
		public abstract void Process();
	}
	public class EventDrivenInteractable : CustomInteractable
	{
		public Func<Player, bool> OnTest;

		public Func<Vector3> OnGetLookAtPos;

		public Action<Player> OnInteract;

		public override Vector3 GetLookAtPos()
		{
			//IL_0015: 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)
			if (OnGetLookAtPos == null)
			{
				return base.GetLookAtPos();
			}
			return OnGetLookAtPos();
		}

		public override void Interact(Player player)
		{
			if (OnInteract == null)
			{
				base.Interact(player);
			}
			else
			{
				OnInteract(player);
			}
		}

		public override bool Test(Player player)
		{
			if (OnTest == null)
			{
				return base.Test(player);
			}
			return OnTest(player);
		}
	}
	public enum InteractableIcon
	{
		Talk,
		Graffiti,
		Custom
	}
	public static class SaveAPI
	{
		public delegate void SaveGameDelegate(int saveSlot, string saveSlotFilename, int fileId);

		[CompilerGenerated]
		private static class <>O
		{
			public static OnStageInitializedDelegate <0>__StageManager_OnStageInitialized;

			public static OnStageInitializedDelegate <1>__StageManager_OnStagePostInitialization;
		}

		public static SaveGameDelegate OnNewGame;

		public static SaveGameDelegate OnSaveGame;

		public static SaveGameDelegate OnDeleteGame;

		public static SaveGameDelegate OnLoadStageInitialized;

		public static SaveGameDelegate OnLoadStagePostInitialization;

		internal static bool AlreadyRanOnLoadStageInitialized = false;

		internal static bool AlreadyRanOnLoadStagePostInitialization = false;

		private static List<CustomSaveData> _customSaveDatas = new List<CustomSaveData>();

		public static void RegisterCustomSaveData(CustomSaveData customSaveData)
		{
			if (!customSaveData.Filename.Contains("{0}"))
			{
				throw new Exception("Can't register save data for " + customSaveData.GetType()?.ToString() + ", Filename is missing a \"{0}\" token to differentiate save slots. Filename is: " + customSaveData.Filename);
			}
			CommonAPIPlugin.Log.LogInfo((object)$"Registering custom save data {customSaveData.GetType()}");
			_customSaveDatas.Add(customSaveData);
		}

		internal static void Initialize()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: 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
			object obj = <>O.<0>__StageManager_OnStageInitialized;
			if (obj == null)
			{
				OnStageInitializedDelegate val = StageManager_OnStageInitialized;
				<>O.<0>__StageManager_OnStageInitialized = val;
				obj = (object)val;
			}
			StageManager.OnStageInitialized += (OnStageInitializedDelegate)obj;
			object obj2 = <>O.<1>__StageManager_OnStagePostInitialization;
			if (obj2 == null)
			{
				OnStageInitializedDelegate val2 = StageManager_OnStagePostInitialization;
				<>O.<1>__StageManager_OnStagePostInitialization = val2;
				obj2 = (object)val2;
			}
			StageManager.OnStagePostInitialization += (OnStageInitializedDelegate)obj2;
		}

		private static void StageManager_OnStageInitialized()
		{
			if (!AlreadyRanOnLoadStageInitialized)
			{
				int saveSlotId = Core.Instance.SaveManager.CurrentSaveSlot.saveSlotId;
				string saveSlotFileName = Core.Instance.SaveManager.saveSlotHandler.GetSaveSlotFileName(saveSlotId);
				if (CommonAPISettings.Debug)
				{
					CommonAPIPlugin.Log.LogInfo((object)$"Loading into save slot {saveSlotId}, filename: {saveSlotFileName} (Initialized)");
				}
				int filenameID = GetFilenameID(saveSlotFileName);
				LoadAllCustomData(filenameID);
				OnLoadStageInitialized?.Invoke(saveSlotId, saveSlotFileName, filenameID);
				AlreadyRanOnLoadStageInitialized = true;
			}
		}

		private static void StageManager_OnStagePostInitialization()
		{
			if (!AlreadyRanOnLoadStagePostInitialization)
			{
				int saveSlotId = Core.Instance.SaveManager.CurrentSaveSlot.saveSlotId;
				string saveSlotFileName = Core.Instance.SaveManager.saveSlotHandler.GetSaveSlotFileName(saveSlotId);
				if (CommonAPISettings.Debug)
				{
					CommonAPIPlugin.Log.LogInfo((object)$"Loading into save slot {saveSlotId}, filename: {saveSlotFileName} (PostInitialiation)");
				}
				OnLoadStagePostInitialization?.Invoke(saveSlotId, saveSlotFileName, GetFilenameID(saveSlotFileName));
				AlreadyRanOnLoadStagePostInitialization = true;
			}
		}

		internal static void DeleteAllCustomData(int fileID)
		{
			foreach (CustomSaveData customSaveData in _customSaveDatas)
			{
				string filenameForFileID = customSaveData.GetFilenameForFileID(fileID);
				if (File.Exists(filenameForFileID))
				{
					if (CommonAPISettings.Debug)
					{
						CommonAPIPlugin.Log.LogInfo((object)$"Deleting custom data for {customSaveData.GetType()}, file: {filenameForFileID}");
					}
					File.Delete(filenameForFileID);
				}
			}
		}

		internal static void SaveAllCustomData(int fileID)
		{
			foreach (CustomSaveData customSaveData in _customSaveDatas)
			{
				if (customSaveData.AutoSave || customSaveData.QueuedSave)
				{
					customSaveData.QueuedSave = false;
					string filenameForFileID = customSaveData.GetFilenameForFileID(fileID);
					if (CommonAPISettings.Debug)
					{
						CommonAPIPlugin.Log.LogInfo((object)$"Writing custom data for {customSaveData.GetType()}, file: {filenameForFileID}");
					}
					MemoryStream memoryStream = new MemoryStream();
					BinaryWriter binaryWriter = new BinaryWriter(memoryStream);
					customSaveData.Write(binaryWriter);
					binaryWriter.Flush();
					byte[] data = memoryStream.ToArray();
					CustomStorage.Instance.WriteFile(data, filenameForFileID);
					binaryWriter.Dispose();
					memoryStream.Dispose();
				}
			}
		}

		internal static void LoadAllCustomData(int fileID)
		{
			foreach (CustomSaveData customSaveData in _customSaveDatas)
			{
				customSaveData.QueuedSave = false;
				string filenameForFileID = customSaveData.GetFilenameForFileID(fileID);
				if (File.Exists(filenameForFileID))
				{
					if (CommonAPISettings.Debug)
					{
						CommonAPIPlugin.Log.LogInfo((object)$"Loading custom data for {customSaveData.GetType()}, file: {filenameForFileID}");
					}
					FileStream fileStream = new FileStream(filenameForFileID, FileMode.Open);
					BinaryReader binaryReader = new BinaryReader(fileStream);
					customSaveData.Read(binaryReader);
					binaryReader.Dispose();
					fileStream.Dispose();
				}
				else
				{
					if (CommonAPISettings.Debug)
					{
						CommonAPIPlugin.Log.LogInfo((object)$"Making new custom data for {customSaveData.GetType()}, file: {filenameForFileID}");
					}
					customSaveData.Initialize();
				}
			}
		}

		internal static void MakeNewForAllCustomData(int fileID)
		{
			foreach (CustomSaveData customSaveData in _customSaveDatas)
			{
				customSaveData.QueuedSave = false;
				string filenameForFileID = customSaveData.GetFilenameForFileID(fileID);
				if (CommonAPISettings.Debug)
				{
					CommonAPIPlugin.Log.LogInfo((object)$"Making new custom data for {customSaveData.GetType()}, file: {filenameForFileID}");
				}
				customSaveData.Initialize();
			}
		}

		internal static int GetFilenameID(string filename)
		{
			string text = "";
			for (int i = 0; i < filename.Length; i++)
			{
				if (char.IsDigit(filename[i]))
				{
					text += filename[i];
				}
			}
			if (int.TryParse(text, out var result))
			{
				return result;
			}
			return -1;
		}
	}
	public static class StageAPI
	{
		public delegate void StageInitializationDelegate(Stage newStage, Stage previousStage);

		public static StageInitializationDelegate OnStagePreInitialization;
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "CommonAPI";

		public const string PLUGIN_NAME = "CommonAPI";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace CommonAPI.Patches
{
	[HarmonyPatch(typeof(DialogueUI))]
	internal static class DialogueUIPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("EndDialogue")]
		private static void EndDialogue_Prefix(DialogueUI __instance)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Invalid comparison between Unknown and I4
			if (!((Object)(object)CustomSequenceHandler.instance == (Object)null))
			{
				CustomSequenceHandler instance = CustomSequenceHandler.instance;
				if (instance.CurrentDialogue != null && (int)instance.CurrentDialogue.ShowBars == 1 && (Object)(object)__instance.effectsUI != (Object)null)
				{
					__instance.effectsUI.HideBars(0.25f, (UpdateType)3);
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("OnButtonPressed")]
		private static bool OnButtonPressed_Prefix(DialogueUI __instance, bool yesClicked)
		{
			if ((Object)(object)CustomSequenceHandler.instance == (Object)null)
			{
				return true;
			}
			CustomSequenceHandler instance = CustomSequenceHandler.instance;
			if (instance.CurrentDialogue == null)
			{
				return true;
			}
			instance.CurrentDialogue.AnsweredYes = yesClicked;
			if (__instance.IsShowingDialogue())
			{
				__instance.EndDialogue();
			}
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("AbortDialogue")]
		private static void AbortDialogue_Prefix()
		{
			if (!((Object)(object)CustomSequenceHandler.instance == (Object)null))
			{
				CustomSequenceHandler instance = CustomSequenceHandler.instance;
				if (instance.CurrentDialogue != null)
				{
					instance.CurrentDialogue.NextDialogue = null;
					instance.CurrentDialogue.EndSequenceOnFinish = false;
					instance.CurrentDialogue.OnDialogueEnd = null;
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("EndDialogue")]
		private static void EndDialogue_Postfix(DialogueUI __instance)
		{
			if ((Object)(object)CustomSequenceHandler.instance == (Object)null)
			{
				return;
			}
			CustomSequenceHandler instance = CustomSequenceHandler.instance;
			CustomDialogue currentDialogue = instance.CurrentDialogue;
			if (currentDialogue == null)
			{
				return;
			}
			if (currentDialogue.NextDialogue != null)
			{
				instance.StartDialogue(currentDialogue.NextDialogue);
			}
			else
			{
				if (currentDialogue.EndSequenceOnFinish)
				{
					instance.ExitCurrentSequenceDelayed();
				}
				instance.CurrentDialogue = null;
			}
			if (currentDialogue.OnDialogueEnd != null)
			{
				currentDialogue.OnDialogueEnd();
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("IsShowingDialogue")]
		private static bool IsShowingDialogue_Prefix(ref bool __result)
		{
			if ((Object)(object)CustomSequenceHandler.instance == (Object)null)
			{
				return true;
			}
			if (CustomSequenceHandler.instance.CurrentDialogue != null)
			{
				__result = true;
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("UpdateTextLabel")]
		private static bool UpdateTextLabel_Prefix(DialogueUI __instance, string line)
		{
			if ((Object)(object)CustomSequenceHandler.instance == (Object)null)
			{
				return true;
			}
			if (CustomSequenceHandler.instance.CurrentDialogue == null)
			{
				return true;
			}
			CustomDialogue currentDialogue = CustomSequenceHandler.instance.CurrentDialogue;
			if (!string.IsNullOrEmpty(currentDialogue.CharacterName))
			{
				((TMP_Text)__instance.characterNameText).text = $"{currentDialogue.CharacterName}:";
				__instance.characterNameTextContainer.SetActive(true);
			}
			else
			{
				((TMP_Text)__instance.characterNameText).text = string.Empty;
				__instance.characterNameTextContainer.SetActive(false);
			}
			((TMP_Text)__instance.textLabel).text = line;
			__instance.uiManager.SetLocalizationValueOnDialogueText(__instance.textLabel, __instance.gameTextLocalizer, Array.Empty<string>());
			return false;
		}
	}
	[HarmonyPatch(typeof(Player))]
	internal static class PlayerPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Init")]
		private static void Init_Postfix(Player __instance)
		{
			CustomPlayerComponent.Attach(__instance);
		}

		[HarmonyPrefix]
		[HarmonyPatch("UpdateSprayCanShake")]
		private static void UpdateSprayCanShake_Prefix(Player __instance)
		{
			CustomPlayerComponent customPlayerComponent = CustomPlayerComponent.Get(__instance);
			if (Object.op_Implicit((Object)(object)customPlayerComponent))
			{
				__instance.talkContextAvailable += customPlayerComponent.CustomInteractableContextAvailable;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("UpdateSprayCanShake")]
		private static void UpdateSprayCanShake_Postfix(Player __instance)
		{
			CustomPlayerComponent customPlayerComponent = CustomPlayerComponent.Get(__instance);
			if (Object.op_Implicit((Object)(object)customPlayerComponent))
			{
				__instance.talkContextAvailable -= customPlayerComponent.CustomInteractableContextAvailable;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("ContextIconsUpdate")]
		private static void ContextIconsUpdate_Postfix(Player __instance)
		{
			if (__instance.graffitiContextAvailable > 0 || __instance.talkContextAvailable > 0 || __instance.breakChainContextAvailable > 0)
			{
				return;
			}
			CustomPlayerComponent customPlayerComponent = CustomPlayerComponent.Get(__instance);
			if (!Object.op_Implicit((Object)(object)customPlayerComponent))
			{
				return;
			}
			customPlayerComponent.CustomInteractableContextAvailable = Mathf.Max(customPlayerComponent.CustomInteractableContextAvailable - 1, 0);
			bool flag = customPlayerComponent.CustomInteractableContextAvailable > 0;
			CustomInteractable currentCustomInteractable = customPlayerComponent.CurrentCustomInteractable;
			if (flag && Object.op_Implicit((Object)(object)currentCustomInteractable))
			{
				((Component)__instance.ui.breakChainsContextIcon).gameObject.SetActive(false);
				((Component)__instance.ui.contextGraffitiIcon).gameObject.SetActive(false);
				((Component)__instance.ui.contextTalkIcon).gameObject.SetActive(false);
				((Component)customPlayerComponent.CustomContextIcon).gameObject.SetActive(false);
				__instance.ui.contextLabelUiButtonGlyphComponent.SetButtonTextGlyph(10);
				__instance.ui.ShowContextLabelUI();
				switch (currentCustomInteractable.Icon)
				{
				default:
					((Component)__instance.ui.contextTalkIcon).gameObject.SetActive(true);
					break;
				case InteractableIcon.Graffiti:
					((Component)__instance.ui.contextGraffitiIcon).gameObject.SetActive(true);
					break;
				case InteractableIcon.Custom:
					((Component)customPlayerComponent.CustomContextIcon).gameObject.SetActive(true);
					customPlayerComponent.CustomContextIcon.sprite = currentCustomInteractable.CustomIcon;
					break;
				}
			}
		}
	}
	[HarmonyPatch(typeof(SaveManager))]
	internal static class SaveManagerPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("SetCurrentSaveSlot")]
		private static void SetCurrentSaveSlot_Prefix(int newCurrentSaveSlotId)
		{
			SaveAPI.AlreadyRanOnLoadStageInitialized = false;
			SaveAPI.AlreadyRanOnLoadStagePostInitialization = false;
		}
	}
	[HarmonyPatch(typeof(SaveSlotHandler))]
	internal static class SaveSlotHandlerPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("SaveSaveSlot")]
		private static void SaveSaveSlot_Prefix(SaveSlotHandler __instance, int saveSlotId)
		{
			if (saveSlotId <= -1)
			{
				return;
			}
			string saveSlotFileName = __instance.GetSaveSlotFileName(saveSlotId);
			if (!string.IsNullOrEmpty(saveSlotFileName))
			{
				int filenameID = SaveAPI.GetFilenameID(saveSlotFileName);
				SaveAPI.SaveAllCustomData(filenameID);
				if (CommonAPISettings.Debug)
				{
					CommonAPIPlugin.Log.LogInfo((object)$"Saving {saveSlotFileName} in slot {saveSlotId}");
				}
				SaveAPI.OnSaveGame?.Invoke(saveSlotId, saveSlotFileName, filenameID);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("DeleteSaveSlotData")]
		private static void DeleteSaveSlotData_Prefix(SaveSlotHandler __instance, int slotId)
		{
			if (slotId <= -1)
			{
				return;
			}
			string saveSlotFileName = __instance.GetSaveSlotFileName(slotId);
			if (!string.IsNullOrEmpty(saveSlotFileName))
			{
				int filenameID = SaveAPI.GetFilenameID(saveSlotFileName);
				SaveAPI.DeleteAllCustomData(filenameID);
				if (CommonAPISettings.Debug)
				{
					CommonAPIPlugin.Log.LogInfo((object)$"Deleting save {saveSlotFileName} in slot {slotId}");
				}
				SaveAPI.OnDeleteGame?.Invoke(slotId, saveSlotFileName, filenameID);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("AddNewSaveSlot")]
		private static void AddNewSaveSlot_Prefix(SaveSlotHandler __instance, int saveSlotId)
		{
			string text = __instance.GenerateNewSaveSlotFileName(saveSlotId);
			int filenameID = SaveAPI.GetFilenameID(text);
			SaveAPI.MakeNewForAllCustomData(filenameID);
			if (CommonAPISettings.Debug)
			{
				CommonAPIPlugin.Log.LogInfo((object)$"Creating save {text} in slot {saveSlotId}");
			}
			SaveAPI.OnNewGame?.Invoke(saveSlotId, text, filenameID);
		}
	}
	[HarmonyPatch(typeof(SequenceHandler))]
	internal class SequenceHandlerPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("UpdateSequenceHandler")]
		private static bool UpdateSequenceHandler_Prefix()
		{
			if ((Object)(object)CustomSequenceHandler.instance == (Object)null)
			{
				return true;
			}
			if (CustomSequenceHandler.instance.isBusy)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(StageManager))]
	internal static class StageManagerPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("SetupWorldHandler")]
		private static void SetupWorldHandler_Prefix(Stage newStage, Stage prevStage)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			StageAPI.OnStagePreInitialization?.Invoke(newStage, prevStage);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}

CrewBoomAPI.dll

Decompiled 2 years ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("CrewBoomAPI")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("API to interact with Crew Boom.")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+1069d195e0cb08bb95407551b4c19397823315f8")]
[assembly: AssemblyProduct("CrewBoomAPI")]
[assembly: AssemblyTitle("CrewBoomAPI")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CrewBoomAPI
{
	public class CharacterInfo
	{
		public readonly string Name;

		public readonly string GraffitiName;

		public CharacterInfo(string name, string graffitiName)
		{
			Name = name;
			GraffitiName = graffitiName;
		}
	}
	public static class CrewBoomAPIDatabase
	{
		private static Dictionary<int, Guid> _userCharacters;

		public static bool IsInitialized { get; private set; }

		public static CharacterInfo PlayerCharacterInfo { get; private set; }

		public static event Action OnInitialized;

		public static event Action<Guid> OnOverride;

		public static event Action<CharacterInfo> OnPlayerCharacterInfoChanged;

		public static void Initialize(Dictionary<int, Guid> userCharacters)
		{
			_userCharacters = userCharacters;
			CrewBoomAPIDatabase.OnInitialized?.Invoke();
			IsInitialized = true;
		}

		public static void UpdatePlayerCharacter(CharacterInfo characterInfo)
		{
			PlayerCharacterInfo = characterInfo;
			CrewBoomAPIDatabase.OnPlayerCharacterInfoChanged?.Invoke(characterInfo);
		}

		public static bool GetUserGuidForCharacter(int character, out Guid guid)
		{
			guid = Guid.Empty;
			if (_userCharacters.TryGetValue(character, out guid))
			{
				return true;
			}
			return false;
		}

		public static void OverrideNextCharacterLoadedWithGuid(Guid guid)
		{
			CrewBoomAPIDatabase.OnOverride?.Invoke(guid);
		}
	}
}

SlopCrew.API.dll

Decompiled 2 years ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("SlopCrew.API")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+3fa4f9a5baab184c4664e5d8d813add8410e890c")]
[assembly: AssemblyProduct("SlopCrew")]
[assembly: AssemblyTitle("SlopCrew.API")]
[assembly: AssemblyVersion("1.1.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SlopCrew.API
{
	public class APIManager
	{
		public static ISlopCrewAPI? API;

		public static event Action<ISlopCrewAPI>? OnAPIRegistered;

		public static void RegisterAPI(ISlopCrewAPI api)
		{
			API = api;
			APIManager.OnAPIRegistered?.Invoke(api);
		}
	}
	public interface ISlopCrewAPI
	{
		string ServerAddress { get; }

		int PlayerCount { get; }

		bool Connected { get; }

		int? StageOverride { get; set; }

		event Action<int> OnPlayerCountChanged;

		event Action OnConnected;

		event Action OnDisconnected;

		event Action<uint, string, byte[]> OnCustomPacketReceived;

		void SendCustomPacket(string id, byte[] data);
	}
}

SlopCrew.Server.XmasEvent.Common.dll

Decompiled 2 years ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("SlopCrew.Server.XmasEvent.Common")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+3fa4f9a5baab184c4664e5d8d813add8410e890c")]
[assembly: AssemblyProduct("SlopCrew.Server.XmasEvent.Common")]
[assembly: AssemblyTitle("SlopCrew.Server.XmasEvent.Common")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SlopCrew.Server.XmasEvent
{
	[Serializable]
	public class XmasClientCollectGiftPacket : XmasPacket
	{
		public const string PacketId = "Xmas-Client-CollectGift";

		public bool IgnoreCooldown = false;

		protected override uint LatestVersion => 1u;

		public override string GetPacketId()
		{
			return "Xmas-Client-CollectGift";
		}

		protected override void Read(BinaryReader reader)
		{
			IgnoreCooldown = reader.ReadBoolean();
		}

		protected override void Write(BinaryWriter writer)
		{
			writer.Write(IgnoreCooldown);
		}

		public override string Describe()
		{
			return base.Describe() + $" IgnoreCooldown={IgnoreCooldown}";
		}
	}
	[Serializable]
	public class XmasClientModifyEventStatePacket : XmasPacket
	{
		public const string PacketId = "Xmas-Client-ModifyEventState";

		public List<XmasPhaseModifications> PhaseModifications = new List<XmasPhaseModifications>();

		protected override uint LatestVersion => 1u;

		public override string GetPacketId()
		{
			return "Xmas-Client-ModifyEventState";
		}

		protected override void Write(BinaryWriter writer)
		{
			writer.Write((ushort)PhaseModifications.Count);
			foreach (XmasPhaseModifications phaseModification in PhaseModifications)
			{
				phaseModification.Write(writer);
			}
		}

		protected override void Read(BinaryReader reader)
		{
			uint version = Version;
			uint num = version;
			if (num == 1)
			{
				PhaseModifications = new List<XmasPhaseModifications>();
				ushort num2 = reader.ReadUInt16();
				for (int i = 0; i < num2; i++)
				{
					XmasPhaseModifications item = new XmasPhaseModifications();
					item.Read(reader);
					PhaseModifications.Add(item);
				}
			}
			else
			{
				UnexpectedVersion();
			}
		}

		public override string Describe()
		{
			string text = base.Describe() + "\n";
			for (int i = 0; i < PhaseModifications.Count; i++)
			{
				XmasPhaseModifications xmasPhaseModifications = PhaseModifications[i];
				text += $"Phase {i}: ";
				if (xmasPhaseModifications.ModifyActive)
				{
					text += string.Format("{0}={1} ", "Active", xmasPhaseModifications.Phase.Active);
				}
				if (xmasPhaseModifications.ModifyGiftsCollected)
				{
					text += string.Format("{0}={1} ", "GiftsCollected", xmasPhaseModifications.Phase.GiftsCollected);
				}
				if (xmasPhaseModifications.ModifyGiftsGoal)
				{
					text += string.Format("{0}={1} ", "GiftsGoal", xmasPhaseModifications.Phase.GiftsGoal);
				}
				if (xmasPhaseModifications.ModifyActivatePhaseAutomatically)
				{
					text += string.Format("{0}Active={1} ", "ActivateNextPhaseAutomatically", xmasPhaseModifications.Phase.ActivateNextPhaseAutomatically);
				}
				text += "\n";
			}
			return text;
		}
	}
	[Serializable]
	public struct XmasPhaseModifications
	{
		public bool ModifyActive;

		public bool ModifyGiftsCollected;

		public bool ModifyGiftsGoal;

		public bool ModifyActivatePhaseAutomatically;

		public XmasPhase Phase;

		public XmasPhaseModifications()
		{
			ModifyActive = false;
			ModifyGiftsCollected = false;
			ModifyGiftsGoal = false;
			ModifyActivatePhaseAutomatically = false;
			Phase = new XmasPhase();
		}

		public void Write(BinaryWriter writer)
		{
			writer.Write(ModifyActive);
			writer.Write(ModifyGiftsCollected);
			writer.Write(ModifyGiftsGoal);
			writer.Write(ModifyActivatePhaseAutomatically);
			Phase.Write(writer);
		}

		public void Read(BinaryReader reader)
		{
			ModifyActive = reader.ReadBoolean();
			ModifyGiftsCollected = reader.ReadBoolean();
			ModifyGiftsGoal = reader.ReadBoolean();
			ModifyActivatePhaseAutomatically = reader.ReadBoolean();
			Phase.Read(reader);
		}
	}
	[Serializable]
	public class XmasServerAcceptGiftPacket : XmasPacket
	{
		public const string PacketId = "Xmas-Server-AcceptGift";

		protected override uint LatestVersion => 1u;

		public override string GetPacketId()
		{
			return "Xmas-Server-AcceptGift";
		}

		protected override void Read(BinaryReader reader)
		{
		}

		protected override void Write(BinaryWriter writer)
		{
		}
	}
	[Serializable]
	public class XmasServerEventStatePacket : XmasPacket
	{
		public const string PacketId = "Xmas-Server-EventState";

		public List<XmasPhase> Phases = new List<XmasPhase>();

		protected override uint LatestVersion => 1u;

		public override string GetPacketId()
		{
			return "Xmas-Server-EventState";
		}

		protected override void Write(BinaryWriter writer)
		{
			writer.Write((ushort)Phases.Count);
			foreach (XmasPhase phase in Phases)
			{
				phase.Write(writer);
			}
		}

		protected override void Read(BinaryReader reader)
		{
			uint version = Version;
			uint num = version;
			if (num == 1)
			{
				Phases = new List<XmasPhase>();
				ushort num2 = reader.ReadUInt16();
				for (int i = 0; i < num2; i++)
				{
					XmasPhase xmasPhase = new XmasPhase();
					xmasPhase.Read(reader);
					Phases.Add(xmasPhase);
				}
			}
			else
			{
				UnexpectedVersion();
			}
		}

		public XmasServerEventStatePacket Clone()
		{
			XmasServerEventStatePacket xmasServerEventStatePacket = new XmasServerEventStatePacket();
			xmasServerEventStatePacket.PlayerID = PlayerID;
			xmasServerEventStatePacket.Version = Version;
			xmasServerEventStatePacket.Phases = new List<XmasPhase>();
			foreach (XmasPhase phase in Phases)
			{
				xmasServerEventStatePacket.Phases.Add(phase.Clone());
			}
			return xmasServerEventStatePacket;
		}

		public override string Describe()
		{
			return base.Describe() + "\n" + DescribeWithoutPacketInfo();
		}

		public string DescribeWithoutPacketInfo()
		{
			string text = "";
			for (int i = 0; i < Phases.Count; i++)
			{
				XmasPhase xmasPhase = Phases[i];
				text += $"Phase#{i}: ";
				text += $"{xmasPhase.GiftsCollected}/{xmasPhase.GiftsGoal} gifts ";
				if (xmasPhase.Active)
				{
					text += "Active ";
				}
				if (xmasPhase.ActivateNextPhaseAutomatically)
				{
					text += "ActivateNextPhaseAutomatically ";
				}
				text += "\n";
			}
			return text;
		}
	}
	[Serializable]
	public class XmasPhase
	{
		public bool Active = false;

		public uint GiftsCollected = 0u;

		public uint GiftsGoal = 1u;

		public bool ActivateNextPhaseAutomatically = false;

		public void Write(BinaryWriter writer)
		{
			writer.Write(Active);
			writer.Write((ushort)GiftsCollected);
			writer.Write((ushort)GiftsGoal);
			writer.Write(ActivateNextPhaseAutomatically);
		}

		public void Read(BinaryReader reader)
		{
			Active = reader.ReadBoolean();
			GiftsCollected = reader.ReadUInt16();
			GiftsGoal = reader.ReadUInt16();
			ActivateNextPhaseAutomatically = reader.ReadBoolean();
		}

		public XmasPhase Clone()
		{
			XmasPhase xmasPhase = new XmasPhase();
			xmasPhase.Active = Active;
			xmasPhase.GiftsCollected = GiftsCollected;
			xmasPhase.GiftsGoal = GiftsGoal;
			xmasPhase.ActivateNextPhaseAutomatically = ActivateNextPhaseAutomatically;
			return xmasPhase;
		}
	}
	[Serializable]
	public class XmasServerRejectGiftPacket : XmasPacket
	{
		public const string PacketId = "Xmas-Server-RejectGift";

		protected override uint LatestVersion => 1u;

		public override string GetPacketId()
		{
			return "Xmas-Server-RejectGift";
		}

		protected override void Read(BinaryReader reader)
		{
		}

		protected override void Write(BinaryWriter writer)
		{
		}
	}
	public abstract class XmasPacket
	{
		public uint? PlayerID;

		public uint Version;

		protected abstract uint LatestVersion { get; }

		public abstract string GetPacketId();

		public XmasPacket()
		{
			Version = LatestVersion;
		}

		public byte[] Serialize()
		{
			MemoryStream memoryStream = new MemoryStream();
			using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream, Encoding.UTF8, leaveOpen: false))
			{
				binaryWriter.Write((ushort)Version);
				Write(binaryWriter);
			}
			return memoryStream.ToArray();
		}

		protected virtual void Write(BinaryWriter writer)
		{
			throw new NotImplementedException();
		}

		public void Deserialize(byte[] data)
		{
			MemoryStream input = new MemoryStream(data, writable: false);
			using BinaryReader binaryReader = new BinaryReader(input, Encoding.UTF8);
			Version = binaryReader.ReadUInt16();
			Read(binaryReader);
		}

		protected virtual void Read(BinaryReader reader)
		{
			throw new NotImplementedException();
		}

		protected void UnexpectedVersion()
		{
			throw new XmasPacketParseException($"Got packet with unexpected version: {GetType().Name} {Version}");
		}

		public virtual string Describe()
		{
			string name = GetType().Name;
			return name + $" Version={Version} PlayerID={PlayerID}";
		}
	}
	public class XmasPacketParseException : Exception
	{
		public XmasPacketParseException(string message)
			: base(message)
		{
		}
	}
	public static class XmasPacketFactory
	{
		public static XmasPacket? ParsePacket(uint playerID, string id, byte[] data)
		{
			XmasPacket xmasPacket = CreatePacketFromID(id);
			if (xmasPacket != null)
			{
				xmasPacket.PlayerID = playerID;
				xmasPacket.Deserialize(data);
			}
			return xmasPacket;
		}

		public static XmasPacket? CreatePacketFromID(string id)
		{
			return id switch
			{
				"Xmas-Client-CollectGift" => new XmasClientCollectGiftPacket(), 
				"Xmas-Server-AcceptGift" => new XmasServerAcceptGiftPacket(), 
				"Xmas-Server-RejectGift" => new XmasServerRejectGiftPacket(), 
				"Xmas-Server-EventState" => new XmasServerEventStatePacket(), 
				"Xmas-Client-ModifyEventState" => new XmasClientModifyEventStatePacket(), 
				_ => null, 
			};
		}
	}
}

Winterland.Common.dll

Decompiled 2 years ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CommonAPI;
using CrewBoomAPI;
using DG.Tweening;
using Microsoft.CodeAnalysis;
using Reptile;
using SlopCrew.API;
using SlopCrew.Server.XmasEvent;
using TMPro;
using UnityEngine;
using UnityEngine.Playables;
using Winterland.Common;
using Winterland.Common.Challenge;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
internal class EffectSpawner : MonoBehaviour
{
	public GameObject prefab;

	public string prefabAssetBundle;

	public string prefabAssetPath;

	public float playbackSpeed = 1f;

	public bool spawnParentedToMe = true;

	private bool spawnNextFrame;

	private void Awake()
	{
		if ((Object)(object)prefab == (Object)null)
		{
			prefab = Core.Instance.Assets.LoadAssetFromBundle<GameObject>(prefabAssetBundle, prefabAssetPath);
		}
	}

	private void OnEnable()
	{
		TreeController componentInParent = ((Component)this).GetComponentInParent<TreeController>();
		if ((Object)(object)componentInParent == (Object)null || !componentInParent.IsFastForwarding)
		{
			spawnNextFrame = true;
		}
	}

	private void OnDisable()
	{
		spawnNextFrame = false;
	}

	private void FixedUpdate()
	{
		if (spawnNextFrame)
		{
			spawnNextFrame = false;
			SpawnEffect();
		}
	}

	private void SpawnEffect()
	{
		//IL_0034: 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_0060: Unknown result type (might be due to invalid IL or missing references)
		GameObject val;
		if (spawnParentedToMe)
		{
			val = Object.Instantiate<GameObject>(prefab, ((Component)this).transform);
		}
		else
		{
			val = Object.Instantiate<GameObject>(prefab);
			val.transform.position = ((Component)this).transform.position;
			val.transform.rotation = ((Component)this).transform.rotation;
			val.transform.localScale = ((Component)this).transform.localScale;
		}
		Animation anim = val.GetComponent<OneOffVisualEffect>().anim;
		anim[((Object)anim.clip).name].speed = playbackSpeed;
	}
}
internal class SetAnimatorParameters : MonoBehaviour
{
	[SerializeField]
	private Animator animator;

	[SerializeField]
	private List<string> boolsToSet = new List<string>();

	private void OnValidate()
	{
		if ((Object)(object)animator == (Object)null)
		{
			animator = ((Component)this).GetComponent<Animator>();
		}
	}

	private void Awake()
	{
		setParams();
	}

	private void OnEnable()
	{
		setParams();
	}

	private void setParams()
	{
		foreach (string item in boolsToSet)
		{
			animator.SetBoolString(item, true);
		}
	}
}
internal class GiftConveyorBelt : MonoBehaviour
{
	public GameObject GiftLogicPrefab;

	public float spawnMinInterval = 0.5f;

	public float spawnMaxInterval = 0.75f;

	public float spawnMinYRot = -45f;

	public float spawnMaxYRot = 45f;

	public float spawnMinScale = 0.7f;

	public float spawnMaxScale = 1.3f;

	private Coroutine animCoro;

	public Transform waypointParent;

	public Transform[] waypoints;

	public float movementSpeed;

	public Transform giftVisualsPrefabParent;

	public Transform[] giftVisualsPrefabs;

	private float[] timeBetweenWaypoints;

	public float[] TimeBetweenWaypoints => timeBetweenWaypoints;

	private void OnValidate()
	{
		waypoints = TransformExtentions.GetAllChildren(waypointParent);
		giftVisualsPrefabs = TransformExtentions.GetAllChildren(giftVisualsPrefabParent);
	}

	private void Awake()
	{
		//IL_0028: 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)
		timeBetweenWaypoints = new float[waypoints.Length - 1];
		for (int i = 0; i < waypoints.Length - 1; i++)
		{
			timeBetweenWaypoints[i] = Vector3.Distance(waypoints[i].position, waypoints[i + 1].position) / movementSpeed;
		}
		Transform[] array = waypoints;
		for (int j = 0; j < array.Length; j++)
		{
			Object.Destroy((Object)(object)array[j].GetChild(0));
		}
		GiftLogicPrefab.SetActive(false);
		((Component)waypointParent).gameObject.SetActive(false);
		((Component)giftVisualsPrefabParent).gameObject.SetActive(false);
	}

	private void OnEnable()
	{
		animCoro = ((MonoBehaviour)this).StartCoroutine(Animation());
	}

	private void OnDisable()
	{
		if (animCoro != null)
		{
			((MonoBehaviour)this).StopCoroutine(animCoro);
			animCoro = null;
		}
	}

	private IEnumerator Animation()
	{
		while (true)
		{
			yield return (object)new WaitForSeconds(Random.Range(spawnMinInterval, spawnMaxInterval));
			GameObject obj = Object.Instantiate<GameObject>(GiftLogicPrefab);
			GiftConveyorBeltGift component = obj.GetComponent<GiftConveyorBeltGift>();
			obj.SetActive(true);
			component.Init(this, ((Component)giftVisualsPrefabs[Random.Range(0, giftVisualsPrefabs.Length)]).gameObject, Random.Range(spawnMinYRot, spawnMaxYRot), new Vector3(Random.Range(spawnMinScale, spawnMaxScale), Random.Range(spawnMinScale, spawnMaxScale), Random.Range(spawnMinScale, spawnMaxScale)));
		}
	}
}
internal class GiftConveyorBeltGift : MonoBehaviour
{
	public Transform GiftParent;

	public float simulatePhysicsXSecondsAfterLastWaypoint;

	private GiftConveyorBelt belt;

	private uint lastWaypointIndex;

	private float timeSinceLastWaypoint;

	private bool finishedWaypoints;

	public void Init(GiftConveyorBelt belt, GameObject giftPrefab, float yRot, Vector3 scale)
	{
		//IL_0024: 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_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		this.belt = belt;
		Object.Instantiate<GameObject>(giftPrefab, GiftParent).SetActive(true);
		Vector3 localEulerAngles = ((Component)GiftParent).transform.localEulerAngles;
		localEulerAngles.y = yRot;
		((Component)GiftParent).transform.localEulerAngles = localEulerAngles;
		((Component)GiftParent).transform.localScale = scale;
	}

	private void Update()
	{
		if (!finishedWaypoints)
		{
			moveAlongWaypoints();
		}
	}

	private void moveAlongWaypoints()
	{
		//IL_00ad: 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_00cc: 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_0107: 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)
		timeSinceLastWaypoint += Time.deltaTime;
		while (timeSinceLastWaypoint > belt.TimeBetweenWaypoints[lastWaypointIndex])
		{
			timeSinceLastWaypoint -= belt.TimeBetweenWaypoints[lastWaypointIndex];
			lastWaypointIndex++;
			if (lastWaypointIndex >= belt.waypoints.Length - 1)
			{
				finishWaypoints();
				return;
			}
		}
		float num = timeSinceLastWaypoint / belt.TimeBetweenWaypoints[lastWaypointIndex];
		((Component)this).transform.position = Vector3.Lerp(belt.waypoints[lastWaypointIndex].position, belt.waypoints[lastWaypointIndex + 1].position, num);
		((Component)this).transform.rotation = Quaternion.Lerp(belt.waypoints[lastWaypointIndex].rotation, belt.waypoints[lastWaypointIndex + 1].rotation, num);
	}

	private void finishWaypoints()
	{
		//IL_0048: 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_0072: 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_0085: Unknown result type (might be due to invalid IL or missing references)
		finishedWaypoints = true;
		if (simulatePhysicsXSecondsAfterLastWaypoint == 0f)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
			return;
		}
		Rigidbody component = ((Component)this).GetComponent<Rigidbody>();
		component.isKinematic = false;
		Vector3 val = belt.waypoints[belt.waypoints.Length - 1].position - belt.waypoints[belt.waypoints.Length - 2].position;
		component.velocity = ((Vector3)(ref val)).normalized * belt.movementSpeed;
		((MonoBehaviour)this).StartCoroutine(DestroySelfAfterDelay(simulatePhysicsXSecondsAfterLastWaypoint));
	}

	private IEnumerator DestroySelfAfterDelay(float delay)
	{
		yield return (object)new WaitForSeconds(delay);
		Object.Destroy((Object)(object)((Component)this).gameObject);
	}
}
internal class TimelineScrubber
{
	private PlayableDirector director;

	private bool started;

	private float percent;

	public TimelineScrubber(PlayableDirector director)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Invalid comparison between Unknown and I4
		this.director = director;
		if ((int)director.timeUpdateMode != 3)
		{
			Debug.LogError((object)("TimelineScrubber instantiated for a PlayableDirector that's not in manual mode: " + ((Object)((Component)director).gameObject).name));
		}
	}

	public void ResetTimeline()
	{
		director.Stop();
		director.time = 0.0;
		started = false;
	}

	public void SetPercentComplete(float newPercent)
	{
		if (!started || newPercent < percent)
		{
			started = true;
			initializeTimelineToPosition(getTimeForPercent(newPercent));
		}
		else
		{
			advanceTimelineToPosition(getTimeForPercent(newPercent));
		}
		percent = newPercent;
	}

	private void initializeTimelineToPosition(float position)
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: 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_0034: Unknown result type (might be due to invalid IL or missing references)
		director.Stop();
		director.Play();
		PlayableGraph playableGraph = director.playableGraph;
		((PlayableGraph)(ref playableGraph)).Evaluate();
		playableGraph = director.playableGraph;
		((PlayableGraph)(ref playableGraph)).Evaluate(position);
	}

	private void advanceTimelineToPosition(float position)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Invalid comparison between Unknown and I4
		//IL_002c: 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)
		float num = position - (float)director.time;
		if (!(num <= 0f) && (int)director.state == 1)
		{
			PlayableGraph playableGraph = director.playableGraph;
			((PlayableGraph)(ref playableGraph)).Evaluate(num);
		}
	}

	private float getTimeForPercent(float percent)
	{
		return (float)director.duration * percent;
	}
}
namespace Winterland.Common
{
	[ExecuteAlways]
	public class AmbientOverride : MonoBehaviour
	{
		public static AmbientOverride Instance;

		[Header("Skybox texture. Leave this set to nothing to keep the original stage skybox.")]
		public Texture Skybox;

		public Color LightColor = Color.white;

		public Color ShadowColor = Color.black;

		[HideInInspector]
		public Color CurrentLightColor = Color.white;

		[HideInInspector]
		public Color CurrentShadowColor = Color.black;

		[HideInInspector]
		public AmbientOverrideTrigger CurrentAmbientTrigger;

		private Color oldLightColor = Color.white;

		private Color oldShadowColor = Color.black;

		private float currentTimer;

		private float currentTransitionDuration = 1f;

		private void Update()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (Application.isEditor)
			{
				Shader.SetGlobalColor("LightColor", LightColor);
				Shader.SetGlobalColor("ShadowColor", ShadowColor);
			}
			else
			{
				ReptileUpdate();
			}
			void ReptileUpdate()
			{
				//IL_006c: 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_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bc: 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_00cd: 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_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_00de: Unknown result type (might be due to invalid IL or missing references)
				//IL_008d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0092: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_009e: Unknown result type (might be due to invalid IL or missing references)
				currentTimer += Core.dt;
				if (currentTimer > currentTransitionDuration)
				{
					currentTimer = currentTransitionDuration;
				}
				float num = 1f;
				if (currentTransitionDuration > 0f)
				{
					num = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f).Evaluate(currentTimer / currentTransitionDuration);
				}
				Color lightColor = LightColor;
				Color shadowColor = ShadowColor;
				if ((Object)(object)CurrentAmbientTrigger != (Object)null)
				{
					lightColor = CurrentAmbientTrigger.LightColor;
					shadowColor = CurrentAmbientTrigger.ShadowColor;
				}
				CurrentLightColor = Color.op_Implicit(Vector4.Lerp(Color.op_Implicit(oldLightColor), Color.op_Implicit(lightColor), num));
				CurrentShadowColor = Color.op_Implicit(Vector4.Lerp(Color.op_Implicit(oldShadowColor), Color.op_Implicit(shadowColor), num));
			}
		}

		public void TransitionAmbient(AmbientOverrideTrigger trigger)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)CurrentAmbientTrigger != (Object)(object)trigger)
			{
				CurrentAmbientTrigger = trigger;
				currentTimer = 0f;
				currentTransitionDuration = trigger.TransitionDuration;
				oldLightColor = CurrentLightColor;
				oldShadowColor = CurrentShadowColor;
			}
		}

		public void StopAmbient(AmbientOverrideTrigger trigger)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)trigger == (Object)(object)CurrentAmbientTrigger)
			{
				CurrentAmbientTrigger = null;
				currentTimer = 0f;
				currentTransitionDuration = trigger.TransitionDuration;
				oldLightColor = CurrentLightColor;
				oldShadowColor = CurrentShadowColor;
			}
		}

		private void Awake()
		{
			Instance = this;
			if (!Application.isEditor)
			{
				ReptileAwake();
			}
			void ReptileAwake()
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				oldLightColor = LightColor;
				oldShadowColor = ShadowColor;
				if ((Object)(object)Skybox != (Object)null)
				{
					RenderSettings.skybox.mainTexture = Skybox;
				}
				AmbientManager val = Object.FindObjectOfType<AmbientManager>();
				if ((Object)(object)val != (Object)null)
				{
					((Component)val).transform.rotation = ((Component)this).transform.rotation;
				}
				Light component = ((Component)this).GetComponent<Light>();
				if ((Object)(object)component != (Object)null)
				{
					Object.Destroy((Object)(object)component);
				}
			}
		}

		private void OnDestroy()
		{
			Instance = null;
		}
	}
	public class AmbientOverrideTrigger : MonoBehaviour
	{
		public Color LightColor = Color.white;

		public Color ShadowColor = Color.black;

		public float TransitionDuration = 2f;

		private void OnTriggerEnter(Collider other)
		{
			Player val = ((Component)other).GetComponent<Player>();
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)other).GetComponentInParent<Player>();
			}
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)other).GetComponentInChildren<Player>();
			}
			if (!((Object)(object)val == (Object)null) && !val.isAI)
			{
				AmbientOverride.Instance.TransitionAmbient(this);
			}
		}

		private void OnTriggerExit(Collider other)
		{
			Player val = ((Component)other).GetComponent<Player>();
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)other).GetComponentInParent<Player>();
			}
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)other).GetComponentInChildren<Player>();
			}
			if (!((Object)(object)val == (Object)null) && !val.isAI)
			{
				AmbientOverride.Instance.StopAmbient(this);
			}
		}
	}
	public class Arcade : MonoBehaviour
	{
		private void Awake()
		{
			ArcadeManager.Instance.RegisterArcade(this);
		}

		private void Start()
		{
			UpdateAvailability();
		}

		public void UpdateAvailability()
		{
			((Component)this).gameObject.SetActive(WinterProgress.Instance.LocalProgress.ArcadeUnlocked);
		}
	}
	public class ArcadeManager : MonoBehaviour
	{
		public List<Arcade> Arcades = new List<Arcade>();

		public static ArcadeManager Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
		}

		public void RegisterArcade(Arcade arcade)
		{
			Arcades.Add(arcade);
		}

		public void UpdateArcades()
		{
			foreach (Arcade arcade in Arcades)
			{
				arcade.UpdateAvailability();
			}
		}
	}
	public class BindGameObjectActive : MonoBehaviour
	{
		[Header("When the GameObject referenced here is disabled, I will get disabled as well, and viceversa.")]
		public GameObject BoundGameObject;

		private void Awake()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			Core.OnAlwaysUpdate += new OnUpdateHandler(CoreUpdate);
		}

		private void CoreUpdate()
		{
			if (BoundGameObject.activeInHierarchy && !((Component)this).gameObject.activeSelf)
			{
				((Component)this).gameObject.SetActive(true);
			}
			else if (!BoundGameObject.activeInHierarchy && ((Component)this).gameObject.activeSelf)
			{
				((Component)this).gameObject.SetActive(false);
			}
		}

		private void OnDestroy()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			Core.OnAlwaysUpdate -= new OnUpdateHandler(CoreUpdate);
		}
	}
	public enum BrcCharacter
	{
		None = -1,
		Vinyl,
		Frank,
		Coil,
		Red,
		Tryce,
		Bel,
		Rave,
		DotExeMember,
		Solace,
		DjCyber,
		EclipseMember,
		DevilTheoryMember,
		FauxWithBoostPack,
		FleshPrince,
		Irene,
		Felix,
		OldHeadMember,
		Base,
		Jet,
		Mesh,
		FuturismMember,
		Rise,
		Shine,
		FauxWithoutBoostPack,
		DotExeBoss,
		FelixWithCyberHead
	}
	public class BuiltToy : MonoBehaviour
	{
		public Toys Toy;

		private Material material;

		private static int GraffitiTextureProperty = Shader.PropertyToID("_Graffiti");

		private void Awake()
		{
			Renderer componentInChildren = ((Component)this).GetComponentInChildren<Renderer>();
			material = componentInChildren.sharedMaterial;
		}

		public void SetGraffiti(GraffitiArt graffiti)
		{
			material.SetTexture(GraffitiTextureProperty, graffiti.graffitiMaterial.mainTexture);
		}
	}
	public class CameraSequenceAction : SequenceAction
	{
		[Header("Leave this on None to keep the current camera.")]
		public CameraRegisterer Camera;

		public override void Run(bool immediate)
		{
			base.Run(immediate);
			if (!immediate && (Object)(object)Camera != (Object)null)
			{
				((CustomSequence)Sequence).SetCamera(((Component)Camera).gameObject);
			}
		}
	}
	public class CameraZoomZone : MonoBehaviour
	{
		public bool ChangeCameraPosition;

		public float CameraDragDistanceDefault = 1f;

		public float CameraDragDistanceMax = 1f;

		public float CameraHeight = 2f;

		public bool ChangeCameraFOV;

		public float CameraFOV = 40f;

		private void OnTriggerEnter(Collider other)
		{
			Player val = ((Component)other).GetComponent<Player>();
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)other).GetComponentInParent<Player>();
			}
			if (!((Object)(object)val == (Object)null) && !val.isAI)
			{
				WinterPlayer winterPlayer = WinterPlayer.Get(val);
				if (!((Object)(object)winterPlayer == (Object)null))
				{
					winterPlayer.CurrentCameraZoomZone = this;
				}
			}
		}

		private void OnTriggerExit(Collider other)
		{
			Player val = ((Component)other).GetComponent<Player>();
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)other).GetComponentInParent<Player>();
			}
			if (!((Object)(object)val == (Object)null) && !val.isAI)
			{
				WinterPlayer winterPlayer = WinterPlayer.Get(val);
				if (!((Object)(object)winterPlayer == (Object)null) && (Object)(object)winterPlayer.CurrentCameraZoomZone == (Object)(object)this)
				{
					winterPlayer.CurrentCameraZoomZone = null;
				}
			}
		}
	}
	public enum Condition
	{
		None,
		HasWantedLevel,
		CollectedAllToyLines,
		CollectedSomeToyLines,
		ArcadeBestTimeSet
	}
	public class CustomCharacterSelectSpot : MonoBehaviour
	{
		public string GUID;

		private static GameObject Source;

		private void Reset()
		{
			GUID = Guid.NewGuid().ToString();
		}

		private void Awake()
		{
			//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)
			if ((Object)(object)Source == (Object)null)
			{
				Source = ((Component)Object.FindObjectOfType<CharacterSelectSpot>()).gameObject;
			}
			GameObject obj = Object.Instantiate<GameObject>(Source, ((Component)this).transform);
			obj.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity);
			((AProgressable)obj.GetComponent<CharacterSelectSpot>()).uid = GUID;
			((Component)obj.transform.Find("mesh")).gameObject.SetActive(false);
		}
	}
	[ExecuteAlways]
	public class CustomNPC : MonoBehaviour
	{
		[Header("General")]
		[SerializeField]
		private string guid = "";

		public ChallengeLevel Challenge;

		public string Name = "";

		public bool PlacePlayerAtSnapPosition = true;

		public bool LookAt = true;

		public bool FixStupidFBXLookAtRotation;

		public bool ShowRep;

		public int MaxDialogueLevel = 1;

		[HideInInspector]
		public int CurrentDialogueLevel;

		private EventDrivenInteractable interactable;

		private DialogueBranch[] dialogueBranches;

		private Transform head;

		private const float MaxHeadYaw = 75f;

		private const float MaxHeadPitch = 60f;

		private const float LookAtDuration = 2f;

		private const float LookAtSpeed = 4f;

		private float currentLookAtAmount;

		private float lookAtTimer;

		private Player lookAtTarget;

		private bool isLookingAt;

		public Guid GUID
		{
			get
			{
				return Guid.Parse(guid);
			}
			set
			{
				guid = value.ToString();
			}
		}

		private void Reset()
		{
			if (Application.isEditor)
			{
				((Component)this).gameObject.layer = 19;
				GUID = Guid.NewGuid();
			}
		}

		private void Awake()
		{
			if (!Application.isEditor)
			{
				ReptileAwake();
			}
			void ReptileAwake()
			{
				//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Expected O, but got Unknown
				//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c3: Expected O, but got Unknown
				CurrentDialogueLevel = 0;
				dialogueBranches = OrderedComponent.GetComponentsOrdered<DialogueBranch>(((Component)this).gameObject);
				interactable = ((Component)this).gameObject.AddComponent<EventDrivenInteractable>();
				interactable.OnInteract = Interact;
				interactable.OnGetLookAtPos = GetLookAtPos;
				((CustomInteractable)interactable).PlacePlayerAtSnapPosition = PlacePlayerAtSnapPosition;
				((CustomInteractable)interactable).ShowRep = ShowRep;
				((CustomInteractable)interactable).LookAt = LookAt;
				head = TransformExtentions.FindRecursive(((Component)this).transform, "head");
				Core.OnUpdate += new OnUpdateHandler(OnUpdate);
				Core.OnLateUpdate += new OnLateUpdateHandler(OnLateUpdate);
				DeserializeNPC();
			}
		}

		private void OnUpdate()
		{
			if (isLookingAt)
			{
				currentLookAtAmount += 4f * Core.dt;
				lookAtTimer -= Core.dt;
				if (lookAtTimer <= 0f)
				{
					lookAtTimer = 0f;
					isLookingAt = false;
				}
			}
			else
			{
				currentLookAtAmount -= 4f * Core.dt;
			}
			currentLookAtAmount = Mathf.Clamp(currentLookAtAmount, 0f, 1f);
		}

		private void OnLateUpdate()
		{
			UpdateHeadTransform();
		}

		private void OnTriggerStay(Collider other)
		{
			Player val = ((Component)other).GetComponentInChildren<Player>();
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)other).GetComponentInParent<Player>();
			}
			if (!((Object)(object)val == (Object)null) && !val.isAI)
			{
				StartLookAt(val);
			}
		}

		private void UpdateHeadTransform()
		{
			//IL_0073: 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)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)lookAtTarget == (Object)null || (Object)(object)head == (Object)null)
			{
				return;
			}
			CharacterVisual characterVisual = lookAtTarget.characterVisual;
			if ((Object)(object)characterVisual == (Object)null)
			{
				return;
			}
			Transform transform = characterVisual.head;
			if (!((Object)(object)head == (Object)null))
			{
				if (characterVisual.VFX.phone.activeSelf)
				{
					transform = characterVisual.VFX.phone.transform;
				}
				Vector3 val = head.position - transform.position;
				Quaternion val2 = Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up);
				Vector3 eulerAngles = ((Quaternion)(ref val2)).eulerAngles;
				val2 = Quaternion.LookRotation(-((Component)this).transform.forward, Vector3.up);
				Vector3 eulerAngles2 = ((Quaternion)(ref val2)).eulerAngles;
				float num = Mathf.DeltaAngle(eulerAngles.y, eulerAngles2.y);
				float num2 = Mathf.DeltaAngle(eulerAngles.x, eulerAngles2.x);
				eulerAngles.y = eulerAngles2.y - Mathf.Clamp(num, -75f, 75f);
				eulerAngles.x = eulerAngles2.x - Mathf.Clamp(num2, -60f, 60f);
				if (FixStupidFBXLookAtRotation)
				{
					eulerAngles.z -= 90f;
				}
				((Component)head).transform.rotation = Quaternion.Lerp(((Component)head).transform.rotation, Quaternion.Euler(eulerAngles), currentLookAtAmount);
			}
		}

		private void StartLookAt(Player player)
		{
			if (!((Object)(object)player.characterVisual == (Object)null))
			{
				lookAtTarget = player;
				lookAtTimer = 2f;
				isLookingAt = true;
			}
		}

		private void DeserializeNPC()
		{
			SerializedNPC nPCProgress = WinterProgress.Instance.LocalProgress.GetNPCProgress(this);
			if (nPCProgress != null)
			{
				CurrentDialogueLevel = nPCProgress.DialogueLevel;
			}
		}

		private void OnDestroy()
		{
			if (!Application.isEditor)
			{
				ReptileDestroy();
				return;
			}
			DialogueBranch[] components = ((Component)this).GetComponents<DialogueBranch>();
			for (int i = 0; i < components.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)components[i]);
			}
			void ReptileDestroy()
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Expected O, but got Unknown
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Expected O, but got Unknown
				Core.OnUpdate -= new OnUpdateHandler(OnUpdate);
				Core.OnLateUpdate -= new OnLateUpdateHandler(OnLateUpdate);
			}
		}

		public void AddDialogueLevel(int dialogueLevelToAdd)
		{
			CurrentDialogueLevel += dialogueLevelToAdd;
			CurrentDialogueLevel = Mathf.Clamp(CurrentDialogueLevel, 0, MaxDialogueLevel);
		}

		public Vector3 GetLookAtPos()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)head))
			{
				return head.position;
			}
			return ((Component)this).transform.position;
		}

		public void Interact(Player player)
		{
			Sequence sequence = null;
			DialogueBranch[] array = dialogueBranches;
			foreach (DialogueBranch dialogueBranch in array)
			{
				if (dialogueBranch.Test(this))
				{
					sequence = dialogueBranch.Sequence;
					break;
				}
			}
			if (!((Object)(object)sequence == (Object)null))
			{
				StartSequence(sequence);
			}
		}

		public void StartSequence(Sequence sequence)
		{
			SequenceWrapper customSequence = sequence.GetCustomSequence(this);
			if (customSequence != null)
			{
				((CustomInteractable)interactable).StartEnteringSequence((CustomSequence)(object)customSequence, sequence.HidePlayer, true, false, true, true, sequence.Skippable, true, false);
			}
		}
	}
	public class CustomToilet : MonoBehaviour
	{
		private static GameObject Source;

		private void Awake()
		{
			//IL_0031: 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)
			if ((Object)(object)Source == (Object)null)
			{
				Source = ((Component)Object.FindObjectOfType<PublicToilet>()).gameObject;
			}
			Object.Instantiate<GameObject>(Source, ((Component)this).transform).transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity);
		}
	}
	public class DebugUI : MonoBehaviour
	{
		private class DebugMenu
		{
			public string Name;

			public Action OnGUI;
		}

		private const int Width = 400;

		private const int Height = 1200;

		private List<DebugMenu> debugMenus = new List<DebugMenu>();

		private bool show = true;

		private DebugMenu currentDebugMenu;

		public static DebugUI Instance { get; private set; }

		public static void Create(bool enabled)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			if (!((Object)(object)Instance != (Object)null))
			{
				GameObject val = new GameObject("Winterland Debug UI");
				val.SetActive(enabled);
				Instance = val.AddComponent<DebugUI>();
				Object.DontDestroyOnLoad((Object)val);
			}
		}

		public void RegisterMenu(string name, Action onDebugUI)
		{
			DebugMenu item = new DebugMenu
			{
				Name = name,
				OnGUI = onDebugUI
			};
			debugMenus.Add(item);
		}

		private void OnGUI()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			Cursor.visible = true;
			Cursor.lockState = (CursorLockMode)0;
			GUILayout.BeginArea(new Rect(0f, 0f, 400f, 1200f));
			GUILayout.BeginVertical(GUI.skin.box, Array.Empty<GUILayoutOption>());
			GUILayout.BeginVertical(GUI.skin.box, Array.Empty<GUILayoutOption>());
			GUILayout.BeginVertical("Debug UI", GUI.skin.box, Array.Empty<GUILayoutOption>());
			GUILayout.Space(20f);
			try
			{
				if (GUILayout.Button("Show/Hide", Array.Empty<GUILayoutOption>()))
				{
					show = !show;
				}
				if (!show)
				{
					return;
				}
				if (currentDebugMenu != null)
				{
					if (GUILayout.Button("Back", Array.Empty<GUILayoutOption>()))
					{
						currentDebugMenu = null;
					}
					else
					{
						currentDebugMenu.OnGUI();
					}
					return;
				}
				foreach (DebugMenu debugMenu in debugMenus)
				{
					if (GUILayout.Button(debugMenu.Name, Array.Empty<GUILayoutOption>()))
					{
						currentDebugMenu = debugMenu;
					}
				}
			}
			finally
			{
				GUILayout.EndVertical();
				GUILayout.EndVertical();
				GUILayout.EndVertical();
				GUILayout.EndArea();
			}
		}
	}
	[ExecuteAlways]
	public class DialogBlock : OrderedComponent
	{
		public enum SpeakerMode
		{
			None,
			NPC,
			Text
		}

		[HideInInspector]
		public DialogSequenceAction Owner;

		public SpeakerMode Speaker = SpeakerMode.NPC;

		[HideInInspector]
		public string SpeakerName = "???";

		public string Text = "...";

		[Header("Random clips to play when the character says this line.")]
		public AudioClip[] AudioClips;

		protected override void OnValidate()
		{
			base.OnValidate();
			if (Application.isEditor)
			{
				((Object)this).hideFlags = (HideFlags)2;
			}
		}

		private void Awake()
		{
			if (Application.isEditor && (Object)(object)((Component)this).GetComponent<DialogSequenceAction>() == (Object)null)
			{
				Object.DestroyImmediate((Object)(object)this);
			}
		}

		public override bool IsPeer(Component other)
		{
			DialogBlock dialogBlock = other as DialogBlock;
			if ((Object)(object)dialogBlock == (Object)null)
			{
				return false;
			}
			if ((Object)(object)dialogBlock.Owner == (Object)(object)Owner)
			{
				return true;
			}
			return false;
		}

		private void Start()
		{
			if (Application.isEditor && (Object)(object)Owner == (Object)null)
			{
				Object.DestroyImmediate((Object)(object)this);
			}
		}
	}
	public class DialogSequenceAction : CameraSequenceAction
	{
		public enum DialogType
		{
			Normal,
			YesNah
		}

		[Header("Type of dialog. Can make a branching question.")]
		public DialogType Type;

		[HideInInspector]
		public string YesTarget = "";

		[HideInInspector]
		public string NahTarget = "";

		[Header("Random clips to play when the character starts talking.")]
		public AudioClip[] AudioClips;

		public override void Run(bool immediate)
		{
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Expected O, but got Unknown
			base.Run(immediate);
			if (immediate)
			{
				return;
			}
			if (AudioClips != null && AudioClips.Length != 0)
			{
				AudioManager audioManager = Core.Instance.AudioManager;
				AudioClip val = AudioClips[Random.Range(0, AudioClips.Length)];
				audioManager.PlayNonloopingSfx(audioManager.audioSources[5], val, audioManager.mixerGroups[5], 0f);
			}
			DialogBlock[] array = (from block in OrderedComponent.GetComponentsOrdered<DialogBlock>(((Component)this).gameObject)
				where (Object)(object)block.Owner == (Object)(object)this
				select block).ToArray();
			List<CustomDialogue> list = new List<CustomDialogue>();
			for (int i = 0; i < array.Length; i++)
			{
				DialogBlock dialog = array[i];
				string text = dialog.Text;
				text = text.Replace("$TOYS_LEFT", (ToyLineManager.Instance.ToyLines.Count - WinterProgress.Instance.LocalProgress.ToyLinesCollected).ToString());
				if ((Object)(object)NPC != (Object)null && (Object)(object)NPC.Challenge != (Object)null)
				{
					string newValue = ChallengeUI.SecondsToMMSS(NPC.Challenge.Timer);
					string newValue2 = ChallengeUI.SecondsToMMSS(NPC.Challenge.BestTime);
					if (NPC.Challenge.BestTime == 0f)
					{
						newValue2 = "Not set";
					}
					text = text.Replace("$ARCADE_LASTTIME", newValue);
					text = text.Replace("$ARCADE_BESTTIME", newValue2);
				}
				CustomDialogue customDialog = new CustomDialogue(dialog.SpeakerName, text, (CustomDialogue)null);
				list.Add(customDialog);
				if (dialog.Speaker == DialogBlock.SpeakerMode.None)
				{
					customDialog.CharacterName = "";
				}
				if (dialog.Speaker == DialogBlock.SpeakerMode.NPC)
				{
					customDialog.CharacterName = NPC.Name;
				}
				if (i > 0)
				{
					CustomDialogue val2 = list[i - 1];
					if (val2 != null)
					{
						val2.NextDialogue = customDialog;
					}
				}
				CustomDialogue obj = customDialog;
				obj.OnDialogueBegin = (Action)Delegate.Combine(obj.OnDialogueBegin, (Action)delegate
				{
					if (dialog.AudioClips != null && dialog.AudioClips.Length != 0)
					{
						AudioManager audioManager2 = Core.Instance.AudioManager;
						AudioClip val3 = dialog.AudioClips[Random.Range(0, dialog.AudioClips.Length)];
						audioManager2.PlayNonloopingSfx(audioManager2.audioSources[5], val3, audioManager2.mixerGroups[5], 0f);
					}
				});
				if (i < array.Length - 1)
				{
					continue;
				}
				CustomDialogue obj2 = customDialog;
				obj2.OnDialogueBegin = (Action)Delegate.Combine(obj2.OnDialogueBegin, (Action)delegate
				{
					if (Type == DialogType.YesNah)
					{
						((CustomSequence)Sequence).RequestYesNoPrompt();
					}
				});
				CustomDialogue obj3 = customDialog;
				obj3.OnDialogueEnd = (Action)Delegate.Combine(obj3.OnDialogueEnd, (Action)delegate
				{
					if (Type == DialogType.YesNah)
					{
						SequenceAction actionByName = Sequence.Sequence.GetActionByName(YesTarget);
						SequenceAction actionByName2 = Sequence.Sequence.GetActionByName(NahTarget);
						if (customDialog.AnsweredYes)
						{
							if ((Object)(object)actionByName == (Object)null)
							{
								Finish(immediate);
							}
							else
							{
								actionByName.Run(immediate);
							}
						}
						else if ((Object)(object)actionByName2 == (Object)null)
						{
							Finish(immediate);
						}
						else
						{
							actionByName2.Run(immediate);
						}
					}
					else
					{
						Finish(immediate);
					}
				});
			}
			if (list.Count > 0)
			{
				((CustomSequence)Sequence).StartDialogue(list[0], 0.9f);
			}
		}
	}
	[ExecuteAlways]
	public class DialogueBranch : OrderedComponent
	{
		public Sequence Sequence;

		public WinterObjective RequiredObjective;

		public Condition Condition;

		public int MinimumDialogueLevel;

		protected override void OnValidate()
		{
			base.OnValidate();
			if (Application.isEditor)
			{
				((Object)this).hideFlags = (HideFlags)2;
			}
		}

		public override bool IsPeer(Component other)
		{
			return other is DialogueBranch;
		}

		public bool Test(CustomNPC npc)
		{
			if (npc.CurrentDialogueLevel < MinimumDialogueLevel)
			{
				return false;
			}
			switch (Condition)
			{
			case Condition.HasWantedLevel:
				if (!WantedManager.instance.Wanted)
				{
					return false;
				}
				break;
			case Condition.CollectedAllToyLines:
				if (!ToyLineManager.Instance.GetCollectedAllToyLines())
				{
					return false;
				}
				break;
			case Condition.CollectedSomeToyLines:
				if (ToyLineManager.Instance.GetCollectedAllToyLines() || WinterProgress.Instance.LocalProgress.ToyLinesCollected == 0)
				{
					return false;
				}
				break;
			case Condition.ArcadeBestTimeSet:
				if ((Object)(object)npc.Challenge == (Object)null)
				{
					return false;
				}
				if (npc.Challenge.BestTime == 0f)
				{
					return false;
				}
				break;
			}
			if ((Object)(object)RequiredObjective != (Object)null && ((Object)WinterProgress.Instance.LocalProgress.Objective).name != ((Object)RequiredObjective).name)
			{
				return false;
			}
			return true;
		}
	}
	public class EndSequenceAction : SequenceAction
	{
		public override void Run(bool immediate)
		{
			base.Run(immediate);
			if (!immediate)
			{
				((CustomSequence)Sequence).ExitSequence(0.9f);
			}
		}
	}
	public class FallenSnowController : MonoBehaviour
	{
		public float MinimumSpeedForSnowParticles = 5f;

		public GameObject SnowFootstepParticlesPrefab;

		public Action OnUpdate;

		public Action OnUpdateOneShot;

		private const string CameraPositionProp = "CameraPosition";

		private const string DepthHalfRadiusProp = "DepthHalfRadius";

		private const string DepthTextureProp = "DepthTexture";

		[SerializeField]
		private float clearRate = 0.033f;

		[SerializeField]
		private float clearStrength = 0.1f;

		[SerializeField]
		private float updateRate = 0.016f;

		[SerializeField]
		private float depthRadiusHalf = 100f;

		[SerializeField]
		private RenderTexture depthRenderTexture;

		[SerializeField]
		private Texture2D holeTexture;

		[SerializeField]
		private float gridSize = 10f;

		private RenderTexture backBufferRenderTexture;

		private Texture2D clearTexture;

		private Vector2 cameraPosition = Vector2.zero;

		private float currentUpdateTime;

		private float currentClearTime;

		public static FallenSnowController Instance { get; private set; }

		private void ProcessRenderTextureDraws()
		{
			RenderTexture.active = depthRenderTexture;
			GL.PushMatrix();
			GL.LoadPixelMatrix(0f, depthRadiusHalf * 2f, depthRadiusHalf * 2f, 0f);
			OnUpdateOneShot?.Invoke();
			OnUpdate?.Invoke();
			GL.PopMatrix();
			RenderTexture.active = null;
			OnUpdateOneShot = null;
		}

		public void DrawHole(Vector2 worldPosition, float size, float strength)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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_0023: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			Vector2 depthPositionAt = GetDepthPositionAt(worldPosition);
			depthPositionAt.y = 0f - depthPositionAt.y + depthRadiusHalf * 2f;
			depthPositionAt -= new Vector2(size * 0.5f, size * 0.5f);
			Graphics.DrawTexture(new Rect(depthPositionAt.x, depthPositionAt.y, size, size), (Texture)(object)holeTexture, new Rect(0f, 0f, 1f, 1f), 0, 0, 0, 0, new Color(1f, 1f, 1f, strength), (Material)null, -1);
		}

		private Vector2 GetDepthPositionAt(Vector2 position)
		{
			//IL_0001: 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_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_001d: 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_001f: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = cameraPosition - new Vector2(depthRadiusHalf, depthRadiusHalf);
			return position - val;
		}

		private void Awake()
		{
			//IL_000d: 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_003b: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			RenderTexture.active = depthRenderTexture;
			GL.Clear(true, true, Color.black);
			RenderTexture.active = null;
			backBufferRenderTexture = Object.Instantiate<RenderTexture>(depthRenderTexture);
			clearTexture = new Texture2D(1, 1);
			clearTexture.SetPixel(0, 0, Color.black);
			clearTexture.Apply();
			Instance = this;
			Shader.SetGlobalFloat("DepthHalfRadius", depthRadiusHalf);
			Shader.SetGlobalTexture("DepthTexture", (Texture)(object)depthRenderTexture);
		}

		private void TransformTexture(Vector2 previousCameraPosition, Vector2 currentCameraPosition)
		{
			//IL_0011: 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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
			Graphics.Blit((Texture)(object)depthRenderTexture, backBufferRenderTexture);
			Vector2 val = (currentCameraPosition - previousCameraPosition) / (depthRadiusHalf * 2f) * new Vector2((float)((Texture)depthRenderTexture).width, (float)((Texture)depthRenderTexture).height);
			val.x = 0f - val.x;
			RenderTexture.active = depthRenderTexture;
			GL.PushMatrix();
			GL.LoadPixelMatrix(0f, (float)((Texture)depthRenderTexture).width, (float)((Texture)depthRenderTexture).height, 0f);
			GL.Clear(true, true, Color.black);
			Graphics.DrawTexture(new Rect(val.x, val.y, (float)((Texture)depthRenderTexture).width, (float)((Texture)depthRenderTexture).height), (Texture)(object)backBufferRenderTexture);
			GL.PopMatrix();
			RenderTexture.active = null;
		}

		private void Update()
		{
			//IL_0008: 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_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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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_0053: 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_016c: 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_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: 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_017c: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(((Component)this).transform.position.x, ((Component)this).transform.position.z);
			Camera currentCamera = WorldHandler.instance.CurrentCamera;
			if ((Object)(object)currentCamera != (Object)null)
			{
				((Vector2)(ref val))..ctor(((Component)currentCamera).transform.position.x, ((Component)currentCamera).transform.position.z);
			}
			Vector2 val2 = cameraPosition;
			val.x = Mathf.Floor(val.x / gridSize) * gridSize;
			val.y = Mathf.Floor(val.y / gridSize) * gridSize;
			currentUpdateTime += Core.dt;
			currentClearTime += Core.dt;
			float num = Mathf.Floor(currentClearTime / clearRate);
			for (int i = 0; (float)i < num; i++)
			{
				OnUpdateOneShot = (Action)Delegate.Combine(OnUpdateOneShot, (Action)delegate
				{
					//IL_0022: 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_005f: Unknown result type (might be due to invalid IL or missing references)
					Graphics.DrawTexture(new Rect(0f, 0f, depthRadiusHalf * 2f, depthRadiusHalf * 2f), (Texture)(object)clearTexture, new Rect(0f, 0f, 1f, 1f), 0, 0, 0, 0, new Color(1f, 1f, 1f, clearStrength), (Material)null, -1);
				});
			}
			float num2 = Mathf.Floor(currentUpdateTime / updateRate);
			for (int j = 0; (float)j < num2; j++)
			{
				ProcessRenderTextureDraws();
			}
			currentUpdateTime -= num2 * updateRate;
			currentClearTime -= num * clearRate;
			cameraPosition = val;
			if (val != val2)
			{
				TransformTexture(val2, val);
			}
			Shader.SetGlobalVector("CameraPosition", Vector4.op_Implicit(cameraPosition));
		}

		private void OnDestroy()
		{
			Object.Destroy((Object)(object)clearTexture);
			Object.Destroy((Object)(object)backBufferRenderTexture);
		}
	}
	public class FallingSnowBlocker : MonoBehaviour
	{
		private void Awake()
		{
			Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren<Collider>();
			FallingSnowController[] array = Object.FindObjectsOfType<FallingSnowController>(true);
			foreach (FallingSnowController fallingSnowController in array)
			{
				Collider[] array2 = componentsInChildren;
				foreach (Collider trigger in array2)
				{
					fallingSnowController.AddKillTrigger(trigger);
				}
			}
		}
	}
	public class FallingSnowController : MonoBehaviour
	{
		[Tooltip("How much to move the particles upwards when you look up. To make it look like the particles are coming from higher up.")]
		[SerializeField]
		private float heightOffsetWhenLookingUp = 10f;

		[Tooltip("Size of the snow chunk grid. Make this match the size of the emitter.")]
		[SerializeField]
		private float gridSize = 50f;

		[SerializeField]
		private GameObject snowEmitter;

		[Tooltip("Amount of adjacent snow chunks to create around the camera. Probably best left at 1 as it increases the number of chunks exponentially.")]
		[SerializeField]
		private int amountAroundCamera = 1;

		private Dictionary<Vector2, GameObject> particles;

		private Stack<GameObject> particlePool;

		private List<GameObject> allParticles;

		private void Awake()
		{
			particles = new Dictionary<Vector2, GameObject>();
			particlePool = new Stack<GameObject>();
			allParticles = new List<GameObject>();
			int num = 1 + amountAroundCamera * 2;
			int num2 = num * num;
			AddToPool(snowEmitter);
			allParticles.Add(snowEmitter);
			for (int i = 1; i < num2; i++)
			{
				GameObject val = Object.Instantiate<GameObject>(snowEmitter);
				AddToPool(val);
				allParticles.Add(val);
			}
		}

		public void AddKillTrigger(Collider trigger)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			foreach (GameObject allParticle in allParticles)
			{
				ParticleSystem[] componentsInChildren = allParticle.GetComponentsInChildren<ParticleSystem>(true);
				if (componentsInChildren != null)
				{
					ParticleSystem[] array = componentsInChildren;
					for (int i = 0; i < array.Length; i++)
					{
						TriggerModule trigger2 = array[i].trigger;
						((TriggerModule)(ref trigger2)).AddCollider((Component)(object)trigger);
					}
				}
			}
		}

		private void AddToPool(GameObject instance)
		{
			instance.transform.parent = ((Component)this).transform;
			particlePool.Push(instance);
		}

		private GameObject GetFromPool()
		{
			return particlePool.Pop();
		}

		private Vector2 GridSnapPosition(Vector3 position)
		{
			//IL_0000: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Floor(position.x / gridSize) * gridSize;
			float num2 = Mathf.Floor(position.z / gridSize) * gridSize;
			return new Vector2(num, num2);
		}

		private bool InRange(Vector2 position, Vector2 position2)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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)
			float num = Mathf.Abs(position.x - position2.x);
			float num2 = Mathf.Abs(position.y - position2.y);
			if (num > (float)amountAroundCamera * gridSize || num2 > (float)amountAroundCamera * gridSize)
			{
				return false;
			}
			return true;
		}

		private void Update()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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_0103: 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_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			Camera currentCamera = WorldHandler.instance.CurrentCamera;
			if ((Object)(object)currentCamera == (Object)null)
			{
				return;
			}
			Vector3 val = ((Component)currentCamera).transform.forward - Vector3.Project(((Component)currentCamera).transform.forward, Vector3.up);
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			Vector3 position = ((Component)currentCamera).transform.position + normalized * gridSize;
			Vector2 val2 = GridSnapPosition(position);
			float y = ((Component)currentCamera).transform.position.y;
			float num = Mathf.Max(0f, Vector3.Dot(((Component)currentCamera).transform.forward, Vector3.up));
			y += heightOffsetWhenLookingUp * num;
			Dictionary<Vector2, GameObject> dictionary = new Dictionary<Vector2, GameObject>();
			foreach (KeyValuePair<Vector2, GameObject> particle in particles)
			{
				if (!InRange(particle.Key, val2))
				{
					AddToPool(particle.Value);
					continue;
				}
				particle.Value.transform.position = new Vector3(particle.Value.transform.position.x, y, particle.Value.transform.position.z);
				dictionary[particle.Key] = particle.Value;
			}
			particles = dictionary;
			Vector2 val3 = default(Vector2);
			for (int i = -amountAroundCamera; i <= amountAroundCamera; i++)
			{
				for (int j = -amountAroundCamera; j <= amountAroundCamera; j++)
				{
					((Vector2)(ref val3))..ctor(val2.x + (float)i * gridSize, val2.y + (float)j * gridSize);
					if (!particles.ContainsKey(val3))
					{
						GameObject fromPool = GetFromPool();
						fromPool.transform.position = new Vector3(val3.x + gridSize * 0.5f, y, val3.y + gridSize * 0.5f);
						particles[val3] = fromPool;
					}
				}
			}
		}
	}
	public class FauxHead : MonoBehaviour
	{
		[SerializeField]
		private float timeIdleToConsiderGrounded = 0.2f;

		[SerializeField]
		private float maximumDistanceTravelledToConsiderGrounded = 0.05f;

		private float lastMovedHeight;

		private float currentTimeIdle;

		[SerializeField]
		private LayerMask groundMask;

		[SerializeField]
		private float groundRayLength = 0.5f;

		[SerializeField]
		private float kickCooldownInSeconds = 0.5f;

		private float currentKickCooldown;

		private int currentJuggles;

		private Rigidbody body;

		private bool onGround;

		private void Awake()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			body = ((Component)this).GetComponent<Rigidbody>();
			lastMovedHeight = ((Component)this).transform.position.y;
		}

		private void OnTriggerStay(Collider other)
		{
			if (((Component)other).gameObject.layer != 18 || currentKickCooldown > 0f)
			{
				return;
			}
			Player val = ((Component)other).GetComponentInParent<Player>();
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)other).GetComponentInChildren<Player>();
			}
			if ((Object)(object)val == (Object)null || val.isAI)
			{
				return;
			}
			FauxJuggleUI fauxJuggleUI = WinterUI.Instance?.FauxJuggleUI;
			if (!((Object)(object)fauxJuggleUI == (Object)null))
			{
				currentKickCooldown = kickCooldownInSeconds;
				currentJuggles++;
				currentTimeIdle = 0f;
				if (currentJuggles >= 2)
				{
					fauxJuggleUI.UpdateCounter(currentJuggles);
				}
			}
		}

		private void FixedUpdate()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			currentKickCooldown -= Core.dt;
			if (currentKickCooldown < 0f)
			{
				currentKickCooldown = 0f;
			}
			if (currentKickCooldown <= 0f)
			{
				RaycastHit val = default(RaycastHit);
				if (Physics.Raycast(new Ray(((Component)this).transform.position, Vector3.down), ref val, groundRayLength, LayerMask.op_Implicit(groundMask), (QueryTriggerInteraction)1))
				{
					onGround = true;
					if (Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponent<Player>()))
					{
						onGround = false;
					}
				}
				else
				{
					onGround = false;
				}
			}
			else
			{
				onGround = false;
			}
			if (onGround)
			{
				currentTimeIdle = 0f;
			}
			if (Mathf.Abs(((Component)this).transform.position.y - lastMovedHeight) > maximumDistanceTravelledToConsiderGrounded)
			{
				currentTimeIdle = 0f;
				lastMovedHeight = ((Component)this).transform.position.y;
			}
			else
			{
				currentTimeIdle += Core.dt;
				if (currentTimeIdle > timeIdleToConsiderGrounded)
				{
					onGround = true;
				}
			}
			if (onGround)
			{
				currentJuggles = 0;
				FauxJuggleUI fauxJuggleUI = WinterUI.Instance?.FauxJuggleUI;
				if ((Object)(object)fauxJuggleUI != (Object)null && onGround && fauxJuggleUI.CurrentJuggleAmount > 0)
				{
					fauxJuggleUI.EndJuggle();
				}
			}
		}
	}
	public class FauxJuggleUI : MonoBehaviour
	{
		[HideInInspector]
		public int CurrentJuggleAmount;

		[SerializeField]
		private TextMeshProUGUI counterLabel;

		[SerializeField]
		private TextMeshProUGUI highScoreLabel;

		[SerializeField]
		private float highScoreLabelGrowSize = 5f;

		[SerializeField]
		private float highScoreLabelAnimationDuration = 0.5f;

		[SerializeField]
		private float highScoreLabelDisplayDuration = 2f;

		private float highScoreLabelDefaultSize;

		private float counterLabelDefaultSize;

		public bool Visible
		{
			get
			{
				return ((Component)this).gameObject.activeSelf;
			}
			set
			{
				if (value && !((Component)this).gameObject.activeSelf)
				{
					((Component)this).gameObject.SetActive(true);
				}
				else if (!value && ((Component)this).gameObject.activeSelf)
				{
					((Component)this).gameObject.SetActive(false);
				}
			}
		}

		private void Awake()
		{
			Visible = false;
			highScoreLabelDefaultSize = ((TMP_Text)highScoreLabel).fontSize;
			counterLabelDefaultSize = ((TMP_Text)counterLabel).fontSize;
		}

		public void EndJuggle()
		{
			((MonoBehaviour)this).StopAllCoroutines();
			ILocalProgress localProgress = WinterProgress.Instance.LocalProgress;
			if (CurrentJuggleAmount > localProgress.FauxJuggleHighScore)
			{
				localProgress.FauxJuggleHighScore = CurrentJuggleAmount;
				localProgress.Save();
				UpdateHighScoreLabelNew();
				((MonoBehaviour)this).StartCoroutine(PlayHighScoreAnimation());
			}
			((MonoBehaviour)this).StartCoroutine(PlayCounterAnimation());
			((MonoBehaviour)this).StartCoroutine(PlayDisableUIAnimation());
			CurrentJuggleAmount = 0;
		}

		private void UpdateHighScoreLabel()
		{
			ILocalProgress localProgress = WinterProgress.Instance.LocalProgress;
			((TMP_Text)highScoreLabel).text = $"High score: {localProgress.FauxJuggleHighScore}";
		}

		private void UpdateHighScoreLabelNew()
		{
			ILocalProgress localProgress = WinterProgress.Instance.LocalProgress;
			((TMP_Text)highScoreLabel).text = $"High score: {localProgress.FauxJuggleHighScore}(NEW!)";
		}

		public void UpdateCounter(int number)
		{
			((MonoBehaviour)this).StopAllCoroutines();
			Visible = true;
			UpdateHighScoreLabel();
			((TMP_Text)highScoreLabel).fontSize = highScoreLabelDefaultSize;
			CurrentJuggleAmount = number;
			((TMP_Text)counterLabel).text = CurrentJuggleAmount.ToString();
		}

		private IEnumerator PlayDisableUIAnimation()
		{
			yield return (object)new WaitForSeconds(highScoreLabelDisplayDuration);
			Visible = false;
		}

		private IEnumerator PlayHighScoreAnimation()
		{
			float animationTimer = 0f;
			AnimationCurve animationCurve = AnimationCurve.EaseInOut(0f, 1f, 1f, 0f);
			while (animationTimer < highScoreLabelDisplayDuration)
			{
				animationTimer += Core.dt;
				float num = animationCurve.Evaluate(Mathf.Min(1f, animationTimer / highScoreLabelAnimationDuration));
				((TMP_Text)highScoreLabel).fontSize = highScoreLabelDefaultSize + highScoreLabelGrowSize * num;
				yield return null;
			}
		}

		private IEnumerator PlayCounterAnimation()
		{
			float animationTimer = 0f;
			AnimationCurve animationCurve = AnimationCurve.EaseInOut(0f, 1f, 1f, 0f);
			while (animationTimer < highScoreLabelDisplayDuration)
			{
				animationTimer += Core.dt;
				float num = animationCurve.Evaluate(Mathf.Min(1f, animationTimer / highScoreLabelAnimationDuration));
				((TMP_Text)counterLabel).fontSize = counterLabelDefaultSize + highScoreLabelGrowSize * num;
				yield return null;
			}
		}
	}
	public class GiftPile : MonoBehaviour
	{
		public int MinimumGiftAmount = 1;

		private void Awake()
		{
			GiftPileManager.Instance.RegisterPile(this);
		}

		private void Start()
		{
			UpdateAvailability();
		}

		public void UpdateAvailability()
		{
			((Component)this).gameObject.SetActive(WinterProgress.Instance.LocalProgress.Gifts >= MinimumGiftAmount);
		}
	}
	public class GiftPileManager : MonoBehaviour
	{
		public List<GiftPile> GiftPiles = new List<GiftPile>();

		public static GiftPileManager Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
		}

		public void RegisterPile(GiftPile giftPile)
		{
			GiftPiles.Add(giftPile);
		}

		public void UpdatePiles()
		{
			foreach (GiftPile giftPile in GiftPiles)
			{
				giftPile.UpdateAvailability();
			}
		}
	}
	public static class GUILayoutUtility
	{
		private class HorizontalDisposable : IDisposable
		{
			public void Dispose()
			{
				GUILayout.EndHorizontal();
			}
		}

		private class VerticalDisposable : IDisposable
		{
			public void Dispose()
			{
				GUILayout.EndVertical();
			}
		}

		public static IDisposable Horizontal(params GUILayoutOption[] options)
		{
			GUILayout.BeginHorizontal(options);
			return new HorizontalDisposable();
		}

		public static IDisposable Vertical(params GUILayoutOption[] options)
		{
			GUILayout.BeginVertical(options);
			return new VerticalDisposable();
		}

		public static IDisposable Horizontal()
		{
			throw new NotImplementedException();
		}
	}
	public interface IGlobalProgress
	{
		public delegate void OnGlobalStageChangedHandler();

		XmasServerEventStatePacket State { get; }

		event OnGlobalStageChangedHandler OnGlobalStateChanged;
	}
	public class WritableGlobalProgress : IGlobalProgress
	{
		public XmasServerEventStatePacket State { get; private set; }

		public event IGlobalProgress.OnGlobalStageChangedHandler OnGlobalStateChanged;

		public void SetState(XmasServerEventStatePacket state)
		{
			State = state;
			this.OnGlobalStateChanged?.Invoke();
		}
	}
	public interface ILocalProgress
	{
		WinterObjective Objective { get; set; }

		int Gifts { get; set; }

		int FauxJuggleHighScore { get; set; }

		int ToyLinesCollected { get; }

		bool ArcadeUnlocked { get; set; }

		void InitializeNew();

		void Save();

		void Load();

		void SetNPCDirty(CustomNPC npc);

		SerializedNPC GetNPCProgress(CustomNPC npc);

		void SetToyLineCollected(Guid guid, bool collected);

		bool IsToyLineCollected(Guid guid);

		void SetChallengeBestTime(ChallengeLevel challenge, float bestTime);

		float GetChallengeBestTime(ChallengeLevel challenge);
	}
	public class JumpSequenceAction : SequenceAction
	{
		[Header("Target action to jump to.")]
		public string Target = "";

		public override void Run(bool immediate)
		{
			base.Run(immediate);
			SequenceAction actionByName = Sequence.Sequence.GetActionByName(Target);
			if ((Object)(object)actionByName != (Object)null)
			{
				actionByName.Run(immediate);
			}
			else
			{
				Finish(immediate);
			}
		}
	}
	public class LocalProgress : ILocalProgress
	{
		private const byte Version = 4;

		private string savePath;

		private Dictionary<Guid, SerializedNPC> npcs;

		private HashSet<Guid> collectedToyLines;

		private Dictionary<string, float> challengeBestTimes;

		public WinterObjective Objective { get; set; }

		public int Gifts { get; set; }

		public int FauxJuggleHighScore { get; set; }

		public int ToyLinesCollected => collectedToyLines.Count;

		public bool ArcadeUnlocked { get; set; }

		public LocalProgress()
		{
			InitializeNew();
		}

		public void InitializeNew()
		{
			npcs = new Dictionary<Guid, SerializedNPC>();
			collectedToyLines = new HashSet<Guid>();
			challengeBestTimes = new Dictionary<string, float>();
			Gifts = 0;
			FauxJuggleHighScore = 0;
			ArcadeUnlocked = false;
			Objective = ObjectiveDatabase.StartingObjective;
			savePath = Path.Combine(Paths.ConfigPath, "MilleniumWinterland/localprogress.mwp");
		}

		public void Save()
		{
			using MemoryStream memoryStream = new MemoryStream();
			using (BinaryWriter writer = new BinaryWriter(memoryStream))
			{
				Write(writer);
			}
			CustomStorage.Instance.WriteFile(memoryStream.ToArray(), savePath);
		}

		public void SetNPCDirty(CustomNPC npc)
		{
			npcs[npc.GUID] = new SerializedNPC(npc);
		}

		public void SetToyLineCollected(Guid guid, bool collected)
		{
			if (collected)
			{
				collectedToyLines.Add(guid);
			}
			else
			{
				collectedToyLines.Remove(guid);
			}
		}

		public bool IsToyLineCollected(Guid guid)
		{
			return collectedToyLines.Contains(guid);
		}

		public SerializedNPC GetNPCProgress(CustomNPC npc)
		{
			if (!npcs.TryGetValue(npc.GUID, out var value))
			{
				return null;
			}
			return value;
		}

		public void Load()
		{
			if (!File.Exists(savePath))
			{
				Debug.Log((object)"No Winterland save to load, starting a new game.");
				return;
			}
			using FileStream input = File.Open(savePath, FileMode.Open);
			using BinaryReader reader = new BinaryReader(input);
			try
			{
				Read(reader);
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"Failed to load Winterland save!{Environment.NewLine}{arg}");
			}
		}

		private void Write(BinaryWriter writer)
		{
			writer.Write((byte)4);
			writer.Write(((Object)Objective).name);
			writer.Write(npcs.Count);
			foreach (SerializedNPC value in npcs.Values)
			{
				value.Write(writer);
			}
			writer.Write(Gifts);
			writer.Write(collectedToyLines.Count);
			foreach (Guid collectedToyLine in collectedToyLines)
			{
				writer.Write(collectedToyLine.ToString());
			}
			writer.Write(FauxJuggleHighScore);
			writer.Write(ArcadeUnlocked);
			writer.Write(challengeBestTimes.Count);
			foreach (KeyValuePair<string, float> challengeBestTime in challengeBestTimes)
			{
				writer.Write(challengeBestTime.Key);
				writer.Write(challengeBestTime.Value);
			}
		}

		private void Read(BinaryReader reader)
		{
			npcs.Clear();
			byte b = reader.ReadByte();
			if (b > 4)
			{
				Debug.LogError((object)$"Attemped to read a Winterland save that's too new (version {b}), current version is {(byte)4}.");
				return;
			}
			WinterObjective objective = ObjectiveDatabase.GetObjective(reader.ReadString());
			if ((Object)(object)objective != (Object)null)
			{
				Objective = objective;
			}
			else
			{
				Objective = ObjectiveDatabase.StartingObjective;
			}
			if (b > 0)
			{
				int num = reader.ReadInt32();
				for (int i = 0; i < num; i++)
				{
					SerializedNPC serializedNPC = new SerializedNPC(reader);
					if (serializedNPC.GUID != Guid.Empty)
					{
						npcs[serializedNPC.GUID] = serializedNPC;
					}
				}
			}
			if (b > 1)
			{
				Gifts = reader.ReadInt32();
				int num2 = reader.ReadInt32();
				for (int j = 0; j < num2; j++)
				{
					Guid guid = Guid.Parse(reader.ReadString());
					SetToyLineCollected(guid, collected: true);
				}
			}
			if (b > 2)
			{
				FauxJuggleHighScore = reader.ReadInt32();
			}
			if (b > 3)
			{
				ArcadeUnlocked = reader.ReadBoolean();
				int num3 = reader.ReadInt32();
				for (int k = 0; k < num3; k++)
				{
					string key = reader.ReadString();
					challengeBestTimes[key] = reader.ReadSingle();
				}
			}
		}

		public void SetChallengeBestTime(ChallengeLevel challenge, float bestTime)
		{
			challengeBestTimes[challenge.GUID] = bestTime;
		}

		public float GetChallengeBestTime(ChallengeLevel challenge)
		{
			if (challengeBestTimes.TryGetValue(challenge.GUID, out var value))
			{
				return value;
			}
			return 0f;
		}
	}
	public class LocalProgressDebugUI : MonoBehaviour
	{
		public static LocalProgressDebugUI Instance { get; private set; }

		public static void Create()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			if (!((Object)(object)Instance != (Object)null))
			{
				GameObject val = new GameObject("Winterland LocalProgressDebugUI");
				Instance = val.AddComponent<LocalProgressDebugUI>();
				Object.DontDestroyOnLoad((Object)val);
			}
		}

		private void Awake()
		{
			DebugUI.Instance.RegisterMenu("Local Progress", OnDebugUI);
		}

		private void OnDebugUI()
		{
			ILocalProgress localProgress = WinterProgress.Instance.LocalProgress;
			ToyLineManager instance = ToyLineManager.Instance;
			if (localProgress != null)
			{
				GUILayout.Label("Local Progress", Array.Empty<GUILayoutOption>());
				GUILayout.Label("Using " + localProgress.GetType().Name, Array.Empty<GUILayoutOption>());
				GUILayout.Label($"[ILocalProgress] Gifts wrapped: {localProgress.Gifts}", Array.Empty<GUILayoutOption>());
				GUILayout.Label($"[ILocalProgress] Faux head juggle high score: {localProgress.FauxJuggleHighScore}", Array.Empty<GUILayoutOption>());
				GUILayout.Label("[ILocalProgress] Current objective: " + ((Object)localProgress.Objective).name, Array.Empty<GUILayoutOption>());
				if (GUILayout.Button("Reset Progress", Array.Empty<GUILayoutOption>()))
				{
					localProgress.InitializeNew();
					localProgress.Save();
				}
			}
			if (!((Object)(object)instance != (Object)null))
			{
				return;
			}
			GUILayout.Label("Toy Line Manager", Array.Empty<GUILayoutOption>());
			GUILayout.Label($"[ToyLineManager] Collected all Toy Lines: {instance.GetCollectedAllToyLines()}", Array.Empty<GUILayoutOption>());
			GUILayout.Label($"[ToyLineManager] Toy Lines in this stage: {instance.ToyLines.Count}", Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Respawn Toy Lines", Array.Empty<GUILayoutOption>()))
			{
				instance.RespawnAllToyLines();
			}
			if (!GUILayout.Button("Collect all Toy Lines", Array.Empty<GUILayoutOption>()))
			{
				return;
			}
			foreach (ToyLine toyLine in instance.ToyLines)
			{
				toyLine.Collect();
			}
		}
	}
	public class MaterialReplacer : MonoBehaviour
	{
		public string NameOfMaterialToReplace;

		public Material ReplacementMaterial;

		public bool UseBRCShader;

		public ShaderNames BRCShaderName = (ShaderNames)1;

		private void Start()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (UseBRCShader)
			{
				ReplacementMaterial.shader = AssetAPI.GetShader(BRCShaderName);
			}
			Renderer[] array = Object.FindObjectsOfType<Renderer>();
			foreach (Renderer val in array)
			{
				if (!val.sharedMaterials.Any((Material x) => (Object)(object)x != (Object)null && ((Object)x).name == NameOfMaterialToReplace))
				{
					continue;
				}
				Material[] array2 = (Material[])(object)new Material[val.sharedMaterials.Length];
				for (int j = 0; j < val.sharedMaterials.Length; j++)
				{
					Material val2 = val.sharedMaterials[j];
					if ((Object)(object)val2 != (Object)null && ((Object)val2).name == NameOfMaterialToReplace)
					{
						array2[j] = ReplacementMaterial;
					}
					else
					{
						array2[j] = val2;
					}
				}
				val.sharedMaterials = array2;
			}
		}
	}
	public class MockGlobalProgress : WritableGlobalProgress
	{
		public MockGlobalProgress()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			SetState(new XmasServerEventStatePacket());
		}
	}
	public class NetworkedGlobalProgress : WritableGlobalProgress, IDisposable
	{
		public NetworkedGlobalProgress()
		{
			NetManager instance = NetManager.Instance;
			instance.OnPacket = (NetManager.OnPacketHandler)Delegate.Combine(instance.OnPacket, new NetManager.OnPacketHandler(OnPacket));
		}

		public void Dispose()
		{
			NetManager instance = NetManager.Instance;
			instance.OnPacket = (NetManager.OnPacketHandler)Delegate.Remove(instance.OnPacket, new NetManager.OnPacketHandler(OnPacket));
		}

		public void OnPacket(XmasPacket packet)
		{
			XmasServerEventStatePacket val = (XmasServerEventStatePacket)(object)((packet is XmasServerEventStatePacket) ? packet : null);
			if (val != null)
			{
				SetState(val);
			}
		}
	}
	public class NetManager : MonoBehaviour
	{
		public delegate void OnPacketHandler(XmasPacket packet);

		private ManualLogSource PacketLogger;

		private ISlopCrewAPI slopCrewApi;

		public OnPacketHandler OnPacket;

		public static NetManager Instance { get; private set; }

		public static NetManager Create()
		{
			//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_0010: Expected O, but got Unknown
			GameObject val = new GameObject("Winter NetManager");
			Object.DontDestroyOnLoad((Object)val);
			return val.AddComponent<NetManager>();
		}

		private void Awake()
		{
			Instance = this;
			bool enabled = false;
			PacketLogger = WinterLogging.CreateLogger("NetManager", enabled, onlyForDebugBuild: true);
			APIManager.OnAPIRegistered += OnSlopCrewAPIRegistered;
			ISlopCrewAPI aPI = APIManager.API;
			if (aPI != null)
			{
				OnSlopCrewAPIRegistered(aPI);
			}
		}

		private void OnDestroy()
		{
			APIManager.OnAPIRegistered -= OnSlopCrewAPIRegistered;
			if (slopCrewApi != null)
			{
				slopCrewApi.OnCustomPacketReceived -= onSlopCrewPacketReceived;
			}
		}

		private void OnSlopCrewAPIRegistered(ISlopCrewAPI slopCrewApi)
		{
			if (this.slopCrewApi == null)
			{
				this.slopCrewApi = slopCrewApi;
				slopCrewApi.OnCustomPacketReceived += onSlopCrewPacketReceived;
			}
		}

		public void onSlopCrewPacketReceived(uint player, string id, byte[] data)
		{
			//IL_0036: Expected O, but got Unknown
			PacketLogger.LogInfo((object)$"Received packet id {id} from player {player}. Data length is {data.Length}");
			XmasPacket val = null;
			try
			{
				val = XmasPacketFactory.ParsePacket(player, id, data);
			}
			catch (XmasPacketParseException val2)
			{
				Debug.Log((object)((Exception)val2).Message);
			}
			if (val != null)
			{
				DispatchReceivedPacket(val);
			}
		}

		public void DispatchReceivedPacket(XmasPacket packet)
		{
			PacketLogger.LogInfo((object)$"Winterland packet received: {packet} {packet.Describe()}");
			OnPacket?.Invoke(packet);
		}

		public void SendPacket(XmasPacket packet)
		{
			PacketLogger.LogInfo((object)$"Sending Winterland packet: {packet} {packet.Describe()}");
			slopCrewApi.SendCustomPacket(packet.GetPacketId(), packet.Serialize());
		}
	}
	public class NetManagerDebugUI : MonoBehaviour
	{
		private uint modifyPhaseIndex;

		private XmasPhaseModifications modifications = new XmasPhaseModifications();

		private bool ignoreCooldown;

		public static NetManagerDebugUI Instance { get; private set; }

		public static void Create()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			if (!((Object)(object)Instance != (Object)null))
			{
				GameObject val = new GameObject("Winterland NetManagerDebugUI");
				Instance = val.AddComponent<NetManagerDebugUI>();
				Object.DontDestroyOnLoad((Object)val);
			}
		}

		private void Awake()
		{
			DebugUI.Instance.RegisterMenu("Net Manager", OnDebugUI);
		}

		private void OnDebugUI()
		{
			//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_0099: Expected O, but got Unknown
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			_ = NetManager.Instance;
			GUILayout.Label("Using " + WinterProgress.Instance.GlobalProgress.GetType().Name, Array.Empty<GUILayoutOption>());
			XmasServerEventStatePacket state = WinterProgress.Instance.GlobalProgress.State;
			if (state != null)
			{
				GUILayout.TextArea(state.DescribeWithoutPacketInfo(), Array.Empty<GUILayoutOption>());
			}
			ignoreCooldown = GUILayout.Toggle(ignoreCooldown, "Ignore cooldown", Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Send XmasClientCollectGiftPacket", Array.Empty<GUILayoutOption>()))
			{
				NetManager.Instance.SendPacket((XmasPacket)new XmasClientCollectGiftPacket
				{
					IgnoreCooldown = ignoreCooldown
				});
			}
			GUILayout.Label("Choose phase to modify, check fields to modify, set values, and send", Array.Empty<GUILayoutOption>());
			GUILayout.Label("Only fields w/Write selected will be modified", Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			uintField(ref modifyPhaseIndex, "Phase #");
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			modToggle(ref modifications.ModifyActive);
			boolField(ref modifications.Phase.Active, "Active");
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			modToggle(ref modifications.ModifyGiftsCollected);
			uintField(ref modifications.Phase.GiftsCollected, "GiftsCollected");
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			modToggle(ref modifications.ModifyGiftsGoal);
			uintField(ref modifications.Phase.GiftsGoal, "GiftsGoal");
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			modToggle(ref modifications.ModifyActivatePhaseAutomatically);
			boolField(ref modifications.Phase.ActivateNextPhaseAutomatically, "ActivateNextPhaseAutomatically");
			GUILayout.EndHorizontal();
			if (GUILayout.Button("Write", Array.Empty<GUILayoutOption>()))
			{
				sendModificationPacket(modifyPhaseIndex, modifications);
			}
			static void boolField(ref bool value, string name)
			{
				value = GUILayout.Toggle(value, name, Array.Empty<GUILayoutOption>());
			}
			static void modToggle(ref bool modify)
			{
				modify = GUILayout.Toggle(modify, "Write", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
			}
			static void uintField(ref uint value, string name)
			{
				GUILayout.Label(name, Array.Empty<GUILayoutOption>());
				uint.TryParse(GUILayout.TextField(value.ToString(), Array.Empty<GUILayoutOption>()), out value);
			}
		}

		private void sendModificationPacket(uint phase, XmasPhaseModifications modifications)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0010: 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)
			XmasClientModifyEventStatePacket val = new XmasClientModifyEventStatePacket();
			for (int i = 0; i < phase; i++)
			{
				val.PhaseModifications.Add(new XmasPhaseModifications());
			}
			val.PhaseModifications.Add(modifications);
			NetManager.Instance.SendPacket((XmasPacket)(object)val);
		}
	}
	public class NotificationSequenceAction : SequenceAction
	{
		[Header("Text to show in this UI Notification.")]
		public string NotificationText = "";

		public override void Run(bool immediate)
		{
			base.Run(immediate);
			Core.Instance.UIManager.ShowNotification(NotificationText, Array.Empty<string>());
			Finish(immediate);
		}
	}
	public static class ObjectiveDatabase
	{
		public static WinterObjective StartingObjective;

		private static Dictionary<string, WinterObjective> ObjectiveByName;

		public static void Initialize(AssetBundle bundle)
		{
			ObjectiveByName = new Dictionary<string, WinterObjective>();
			WinterObjective[] array = bundle.LoadAllAssets<WinterObjective>();
			foreach (WinterObjective winterObjective in array)
			{
				ObjectiveByName[((Object)winterObjective).name] = winterObjective;
				if (winterObjective.StartingObjective)
				{
					StartingObjective = winterObjective;
				}
			}
		}

		public static WinterObjective GetObjective(string objectiveName)
		{
			if (ObjectiveByName.TryGetValue(objectiveName, out var value))
			{
				return value;
			}
			return null;
		}
	}
	public abstract class OrderedComponent : MonoBehaviour
	{
		[HideInInspector]
		public int Order = -1;

		public virtual bool IsPeer(Component other)
		{
			if (((object)other).GetType() == ((object)this).GetType())
			{
				return true;
			}
			return false;
		}

		protected virtual void OnValidate()
		{
			if (Order < 0 || GetOrderCollision(Order))
			{
				Order = GetHighestOrder() + 1;
			}
		}

		public void SetHighestOrder()
		{
			Order = GetHighestOrder() + 1;
		}

		public OrderedComponent MoveUp()
		{
			OrderedComponent firstComponentAbove = GetFirstComponentAbove(Order);
			if ((Object)(object)firstComponentAbove != (Object)null)
			{
				int order = Order;
				Order = firstComponentAbove.Order;
				firstComponentAbove.Order = order;
			}
			return firstComponentAbove;
		}

		public OrderedComponent MoveDown()
		{
			OrderedComponent firstComponentBelow = GetFirstComponentBelow(Order);
			if ((Object)(object)firstComponentBelow != (Object)null)
			{
				int order = Order;
				Order = firstComponentBelow.Order;
				firstComponentBelow.Order = order;
			}
			return firstComponentBelow;
		}

		private OrderedComponent GetFirstComponentAbove(int order)
		{
			OrderedComponent[] componentsAbove = GetComponentsAbove(order);
			OrderedComponent orderedComponent = null;
			OrderedComponent[] array = componentsAbove;
			foreach (OrderedComponent orderedComponent2 in array)
			{
				if ((Object)(object)orderedComponent == (Object)null)
				{
					orderedComponent = orderedComponent2;
				}
				else if (orderedComponent2.Order > orderedComponent.Order)
				{
					orderedComponent = orderedComponent2;
				}
			}
			return orderedComponent;
		}

		private OrderedComponent GetFirstComponentBelow(int order)
		{
			OrderedComponent[] componentsBelow = GetComponentsBelow(order);
			OrderedComponent orderedComponent = null;
			OrderedComponent[] array = componentsBelow;
			foreach (OrderedComponent orderedComponent2 in array)
			{
				if ((Object)(object)orderedComponent == (Object)null)
				{
					orderedComponent = orderedComponent2;
				}
				else if (orderedComponent2.Order < orderedComponent.Order)
				{
					orderedComponent = orderedComponent2;
				}
			}
			return orderedComponent;
		}

		private OrderedComponent[] GetComponentsAbove(int order)
		{
			return (from x in ((Component)this).gameObject.GetComponents<OrderedComponent>()
				where x.Order < order && IsPeer((Component)(object)x)
				select x).ToArray();
		}

		private OrderedComponent[] GetComponentsBelow(int order)
		{
			return (from x in ((Component)this).gameObject.GetComponents<OrderedComponent>()
				where x.Order > order && IsPeer((Component)(object)x)
				select x).ToArray();
		}

		private int GetHighestOrder()
		{
			IEnumerable<OrderedComponent> enumerable = from x in ((Component)this).gameObject.GetComponents<OrderedComponent>()
				where IsPeer((Component)(object)x)
				select x;
			int num = -1;
			foreach (OrderedComponent item in enumerable)
			{
				if (item.Order > num)
				{
					num = item.Order;
				}
			}
			return num;
		}

		private bool GetOrderCollision(int order)
		{
			return ((Component)this).gameObject.GetComponents<OrderedComponent>().Any((OrderedComponent x) => x.Order == order && IsPeer((Component)(object)x) && (Object)(object)x != (Object)(object)this);
		}

		public static T[] GetComponentsOrdered<T>(GameObject gameObject, Func<T, bool> predicate = null) where T : OrderedComponent
		{
			T[] source = gameObject.GetComponents<T>();
			if (predicate != null)
			{
				source = source.Where(predicate).ToArray();
			}
			List<T> list = source.ToList();
			list.Sort((T x, T y) => x.Order - y.Order);
			return list.ToArray();
		}
	}
	[RequireComponent(typeof(SnowSinker))]
	[RequireComponent(typeof(Rigidbody))]
	public class PhysicsSnowSinker : MonoBehaviour
	{
		public LayerMask Mask;

		public float RayDistance = 1f;

		private SnowSinker snowSinker;

		private Rigidbody body;

		private void Awake()
		{
			snowSinker = ((Component)this).GetComponent<SnowSinker>();
			body = ((Component)this).GetComponent<Rigidbody>();
		}

		private void FixedUpdate()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit val = default(RaycastHit);
			if (body.isKinematic)
			{
				snowSinker.Enabled = false;
			}
			else if (Physics.Raycast(new Ray(((Component)this).transform.position, Vector3.down), ref val, RayDistance, LayerMask.op_Implicit(Mask), (QueryTriggerInteraction)1))
			{
				bool flag = true;
				if ((Object)(object)((Component)((RaycastHit)(ref val)).collider).gameObject.GetComponent<Rigidbody>() != (Object)null)
				{
					flag = false;
				}
				if (flag)
				{
					snowSinker.Enabled = true;
				}
				else
				{
					snowSinker.Enabled = false;
				}
			}
			else
			{
				snowSinker.Enabled = false;
			}
		}
	}
	public class PickupRotation : MonoBehaviour
	{
		[SerializeField]
		private Vector3 rotationSpeed;

		private void Update()
		{
			//IL_0007: 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)
			((Component)this).transform.Rotate(rotationSpeed * Time.deltaTime, (Space)0);
		}
	}
	public class PlayerCollisionUtility
	{
		public static Player GetPlayer(Collider other, bool includeAI = false)
		{
			Player val = ((Component)other).GetComponent<Player>();
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)other).GetComponentInParent<Player>();
			}
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)other).GetComponentInChildren<Player>();
			}
			if (!includeAI && val.isAI)
			{
				return null;
			}
			return val;
		}
	}
	public class QuitChallengeSequenceAction : SequenceAction
	{
		public override void Run(bool immediate)
		{
			base.Run(immediate);
			ChallengeLevel currentChallengeLevel = ChallengeLevel.CurrentChallengeLevel;
			if ((Object)(object)currentChallengeLevel == (Object)null)
			{
				Finish(immediate);
				return;
			}
			currentChallengeLevel.QuitChallenge();
			Finish(immediate);
		}
	}
	[RequireComponent(typeof(GraffitiSpot))]
	public class REPLessGraffiti : MonoBehaviour
	{
		public static bool IsREPLess(GraffitiSpot graffSpot)
		{
			if ((Object)(object)((Component)graffSpot).GetComponent<REPLessGraffiti>() != (Object)null)
			{
				return true;
			}
			return false;
		}
	}
	public class RespawnToyLinesSequenceAction : SequenceAction
	{
		[Header("Name of action to jump to if the gift collection is successful.")]
		public string SuccessTarget = "";

		[Header("Name of action to jump to if SlopCrew rejects collection.")]
		public string RejectedTarget = "";

		[Header("Name of action to jump to if can't reach SlopCrew")]
		public string NoConnectionTarget = "";

		private bool immediate;

		private const float TimeOutSeconds = 5f;

		public override void Run(bool immediate)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			base.Run(immediate);
			this.immediate = immediate;
			CustomSequenceHandler instance = CustomSequenceHandler.instance;
			ISlopCrewAPI aPI = APIManager.API;
			if (aPI != null && aPI.Connected)
			{
				instance.skipTextActiveState = (SkipState)0;
				XmasClientCollectGiftPacket packet = new XmasClientCollectGiftPacket();
				NetManager.Instance.SendPacket((XmasPacket)(object)packet);
				NetManager instance2 = NetManager.Instance;
				instance2.OnPacket = (NetManager.OnPacketHandler)Delegate.Combine(instance2.OnPacket, new NetManager.OnPacketHandler(ListenForPacket));
				((MonoBehaviour)this).StartCoroutine(RunTimeout());
			}
			else
			{
				RunNoConnection(immediate);
			}
		}

		private IEnumerator RunTimeout()
		{
			yield return (object)new WaitForSeconds(5f);
			if ((Object)(object)Sequence.CurrentAction == (Object)(object)this)
			{
				RunNoConnection(immediate);
			}
		}

		private void ListenForPacket(XmasPacket packet)
		{
			if (packet.PlayerID == (uint?)uint.MaxValue)
			{
				if (packet is XmasServerAcceptGiftPacket)
				{
					RunSuccess(immediate);
				}
				else if (packet is XmasServerRejectGiftPacket)
				{
					RunFailure(immediate);
				}
			}
		}

		private void RunSuccess(bool immediate)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			NetManager instance = NetManager.Instance;
			instance.OnPacket = (NetManager.OnPacketHandler)Delegate.Remove(instance.OnPacket, new NetManager.OnPacketHandler(ListenForPacket));
			((MonoBehaviour)this).StopAllCoroutines();
			if (Sequence.Sequence.Skippable)
			{
				CustomSequenceHandler.instance.skipTextActiveState = (SkipState)1;
			}
			ILocalProgress localProgress = WinterProgress.Instance.LocalProgress;
			ToyLineManager.Instance.RespawnAllToyLines();
			localProgress.Gifts++;
			localProgress.Save();
			GiftPileManager.Instance.UpdatePiles();
			SequenceAction actionByName = Sequence.Sequence.GetActionByName(SuccessTarget);
			if ((Object)(object)actionByName != (Object)null)
			{
				actionByName.Run(immediate);
			}
			else
			{
				Finish(immediate);
			}
		}

		private void RunFailure(bool immediate)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			NetManager instance = NetManager.Instance;
			instance.OnPacket = (NetManager.OnPacketHandler)Delegate.Remove(instance.OnPacket, new NetManager.OnPacketHandler(ListenForPacket));
			((MonoBehaviour)this).StopAllCoroutines();
			if (Sequence.Sequence.Skippable)
			{
				CustomSequenceHandler.instance.skipTextActiveState = (SkipState)1;
			}
			SequenceAction actionByName = Sequence.Sequence.GetActionByName(RejectedTarget);
			if ((Object)(object)actionByName != (Object)null)
			{
				actionByName.Run(immediate);
			}
			else
			{
				Finish(immediate);
			}
		}

		private void RunNoConnection(bool immediate)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			NetManager instance = NetManager.Instance;
			instance.OnPacket = (NetManager.OnPacketHandler)Delegate.Remove(instance.OnPacket, new NetManager.OnPacketHandler(ListenForPacket));
			((MonoBehaviour)this).StopAllCoroutines();
			if (Sequence.Sequence.Skippable)
			{
				CustomSequenceHandler.instance.skipTextActiveState = (SkipState)1;
			}
			SequenceAction actionByName = Sequence.Sequence.GetActionByName(NoConnectionTarget);
			if ((Object)(object)actionByName != (Object)null)
			{
				actionByName.Run(immediate);
			}
			else
			{
				Finish(immediate);
			}
		}
	}
	public class Sequence : MonoBehaviour
	{
		[Header("General")]
		public bool HidePlayer;

		public bool Skippable = true;

		public bool StandDownEnemies = true;

		public int DialogueLevelToAdd;

		[Header("Events")]
		public WinterObjective SetObjectiveOnEnd;

		public string RunActionOnEnd;

		private SequenceWrapper actualSequence;

		private bool initialized;

		private SequenceAction[] actions;

		private void Initialize(CustomNPC npc)
		{
			if (initialized)
			{
				return;
			}
			initialized = true;
			actualSequence = new SequenceWrapper(this);
			actualSequence.NPC = npc;
			actions = OrderedComponent.GetComponentsOrdered<SequenceAction>(((Component)this).gameObject);
			for (int i = 0; i < actions.Length; i++)
			{
				SequenceAction sequenceAction = actions[i];
				sequenceAction.NPC = npc;
				sequenceAction.Sequence = actualSequence;
				if (i < actions.Length - 1)
				{
					sequenceAction.NextAction = actions[i + 1];
				}
			}
		}

		public SequenceWrapper GetCustomSequence(CustomNPC npc)
		{
			Initialize(npc);
			return actualSequence;
		}

		public SequenceAction[] GetActions()
		{
			if (Application.isEditor)
			{
				actions = ((Component)this).gameObject.GetComponents<SequenceAction>();
			}
			return actions;
		}

		public SequenceAction GetActionByName(string name)
		{
			if (Application.isEditor)
			{
				actions = ((Component)this).gameObject.GetComponents<SequenceAction>();
			}
			if (string.IsNullOrEmpty(name))
			{
				return null;
			}
			SequenceAction[] array = actions;
			foreach (SequenceAction sequenceAction in array)
			{
				if (sequenceAction.Name == name)
				{
					return sequenceAction;
				}
			}
			return null;
		}
	}
	[ExecuteAlways]
	public abstract class SequenceAction : OrderedComponent
	{
		[Header("Name used to point to this action when branching. Used in Yes/Nah prompts.")]
		public string Name = "";

		[HideInInspector]
		public CustomNPC NPC;

		[HideInInspector]
		public SequenceWrapper Sequence;

		[HideInInspector]
		public SequenceAction NextAction;

		protected override void OnValidate()
		{
			base.OnValidate();
			if (Application.isEditor)
			{
				((Object)this).hideFlags = (HideFlags)2;
				if ((Object)(object)((Component)this).gameObject.GetComponent<Sequence>() == (Object)null)
				{
					

Winterland.MapStation.Common.dll

Decompiled 2 years ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using Microsoft.CodeAnalysis;
using Reptile;
using UnityEngine;
using UnityEngine.Audio;
using Winterland.MapStation.Common.Serialization;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Winterland.MapStation.Common
{
	public class DebugShapeUtility
	{
		public static IEnumerable<Renderer> FindDebugShapes(GameObject root)
		{
			return root.GetComponentsInChildren<Renderer>(true).Where(delegate(Renderer r)
			{
				Material sharedMaterial = r.sharedMaterial;
				return ((sharedMaterial != null) ? ((Object)sharedMaterial).name : null) == "Debug";
			});
		}

		public static void SetDebugShapesVisibility(GameObject root, bool visible)
		{
			foreach (Renderer item in FindDebugShapes(root))
			{
				item.enabled = visible;
			}
		}
	}
	public static class Doctor
	{
		private static readonly string[] VendingMachineAnimations = new string[5] { "none", "shake", "emptyShake", "close", "drop" };

		public static List<string> Analyze(GameObject root)
		{
			List<string> list = new List<string>();
			GraffitiSpot[] componentsInChildren = root.GetComponentsInChildren<GraffitiSpot>();
			foreach (GraffitiSpot val in componentsInChildren)
			{
				if ((Object)(object)val.dynamicRepPickup == (Object)null)
				{
					list.Add("Found GraffitiSpot.dynamicRepPickup == null. This will soft-lock when tagged.");
				}
				if (!Regex.Match(((AProgressable)val).uid, "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$", RegexOptions.None).Success)
				{
					list.Add($"Found GraffitiSpot.uid which is not in expected UID format (all lowercase, numbers and letters a-f, correct length, correct hyphens) UID={((AProgressable)val).uid}");
				}
				if (((Component)val).tag != "GraffitiSpot")
				{
					list.Add("Found GraffitiSpot not tagged as 'GraffitiSpot'");
				}
				if (((Component)val).gameObject.layer != 19)
				{
					list.Add("Found GraffitiSpot not on the 'TriggerDetectPlayer' layer.");
				}
			}
			VendingMachine[] componentsInChildren2 = root.GetComponentsInChildren<VendingMachine>();
			foreach (VendingMachine obj in componentsInChildren2)
			{
				if (((Component)obj).gameObject.layer != 17)
				{
					list.Add("Found VendingMachine that is not on the Enemies layer, this means it cannot be kicked.");
				}
				Animation component = ((Component)obj).GetComponent<Animation>();
				if ((Object)(object)component == (Object)null)
				{
					list.Add("Found VendingMachine without an Animation component.");
				}
				string[] vendingMachineAnimations = VendingMachineAnimations;
				foreach (string text in vendingMachineAnimations)
				{
					if ((TrackedReference)(object)component.GetState(text) == (TrackedReference)null)
					{
						list.Add("Found VendingMachine with Animation component missing animation: " + text + ". This will fail with errors when kicked.");
					}
				}
			}
			Teleport[] componentsInChildren3 = root.GetComponentsInChildren<Teleport>();
			foreach (Teleport obj2 in componentsInChildren3)
			{
				if ((Object)(object)obj2.teleportTo == (Object)null)
				{
					list.Add("Found Teleport missing a `teleportTo` destination.");
				}
				BoxCollider componentInChildren = ((Component)obj2).GetComponentInChildren<BoxCollider>();
				if ((Object)(object)componentInChildren == (Object)null)
				{
					list.Add("Found Teleport without a Box Collider on a child GameObject.");
				}
				if (((Component)componentInChildren).tag != "Teleport")
				{
					list.Add("Found Teleporter's child collider not tagged as 'Teleport'");
				}
				if (((Component)componentInChildren).gameObject.layer != 19)
				{
					list.Add("Found Teleport's child collider not on the 'TriggerDetectPlayer' layer.");
				}
			}
			return list;
		}

		public static void AnalyzeAndLog(GameObject root)
		{
			List<string> list = Analyze(root);
			Debug.Log((object)$"MapStation: Analysis of {((Object)root).name} found {list.Count} problems.");
			foreach (string item in list)
			{
				Debug.Log((object)item);
			}
		}
	}
	public class NoOpDynamicPickup : MonoBehaviour
	{
		private void Awake()
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
	public class SerializationTest : MonoBehaviour
	{
		[Serializable]
		public struct SerializedStruct
		{
			public string Foo;

			public string Bar;
		}

		public SerializedStruct data;

		private void Awake()
		{
			Debug.Log((object)$"Serialized data: foo={data.Foo}, bar={data.Bar}");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "Winterland.MapStation.Common";

		public const string PLUGIN_NAME = "Winterland.MapStation.Common";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace Winterland.MapStation.Common.Serialization
{
	internal class SerializationExample : MonoBehaviour
	{
		[Serializable]
		private class Conversation
		{
			public string showIfUnlockableIsUnlocked;
		}

		[Serializable]
		private class Dialog
		{
			public string say;

			public string animation;

			public bool askYesNo;
		}

		private class SList_NpcDialog : SList<Dialog>
		{
		}

		[SerializeReference]
		private Conversation conversation = new Conversation();

		[SerializeReference]
		private SList_NpcDialog npcDialog_ = new SList_NpcDialog();

		private List<Dialog> npcDialogs => npcDialog_.items;

		private void Awake()
		{
			string text = "";
			text += string.Format("{0} serialized data:\n", "SerializationExample");
			text += string.Format("{0}.{1}={2}\n", "Conversation", "showIfUnlockableIsUnlocked", conversation.showIfUnlockableIsUnlocked);
			text += string.Format("{0}.Count={1}\n", "npcDialogs", npcDialogs.Count);
			for (int i = 0; i < npcDialogs.Count; i++)
			{
				text += string.Format("{0}[{1}].{2}={3}\n", "npcDialogs", i, "say", npcDialogs[i].say);
				text += string.Format("{0}[{1}].{2}={3}\n", "npcDialogs", i, "animation", npcDialogs[i].animation);
				text += string.Format("{0}[{1}].{2}={3}\n", "npcDialogs", i, "askYesNo", npcDialogs[i].askYesNo);
			}
			Debug.Log((object)text);
		}
	}
	public class SList
	{
	}
	[Serializable]
	public class SList<T> : SList, ISerializationCallbackReceiver where T : new()
	{
		[HideInInspector]
		[SerializeReference]
		private Node linkedList;

		[SerializeReference]
		public List<T> items;

		public void copyToLinkedList()
		{
			if (items == null || items.Count == 0)
			{
				linkedList = null;
				return;
			}
			if (linkedList == null)
			{
				linkedList = new Node();
			}
			Node next = linkedList;
			int i = 0;
			for (int count = items.Count; i < count; i++)
			{
				next.value = items[i];
				if (i < count - 1)
				{
					Node node = next;
					if (node.next == null)
					{
						node.next = new Node();
					}
					next = next.next;
				}
				else
				{
					next.next = null;
				}
			}
		}

		public void copyToList()
		{
			if (items == null)
			{
				items = new List<T>();
			}
			else
			{
				items.Clear();
			}
			for (Node next = linkedList; next != null; next = next.next)
			{
				items.Add((T)next.value);
			}
		}

		private void instantiateNullList()
		{
			if (items == null)
			{
				items = new List<T>();
			}
		}

		private void instantiateNullItemsInList()
		{
			int i = 0;
			for (int count = items.Count; i < count; i++)
			{
				if (items[i] == null)
				{
					items[i] = new T();
				}
			}
		}

		public void OnBeforeSerialize()
		{
			instantiateNullList();
			instantiateNullItemsInList();
			copyToLinkedList();
		}

		public void OnAfterDeserialize()
		{
			if (!Application.isEditor)
			{
				copyToList();
			}
		}
	}
	[Serializable]
	public class Node
	{
		[SerializeReference]
		public object value;

		[SerializeReference]
		public Node next;
	}
}
namespace Winterland.MapStation.Common.VanillaAssets
{
	public class DeleteVanillaGameObjectsV1 : MonoBehaviour
	{
		public class SList_Deletion : SList<Deletion>
		{
		}

		[Serializable]
		public class Deletion
		{
			public string Path;
		}

		private HashSet<GameObject> disabledGameObjects = new HashSet<GameObject>();

		[SerializeReference]
		private SList_Deletion deletions = new SList_Deletion();

		public static DeleteVanillaGameObjectsV1 Instance { get; private set; }

		private List<Deletion> Deletions => deletions.items;

		private void Awake()
		{
			if (!Application.isEditor)
			{
				Instance = this;
				DeleteGameObjects();
			}
		}

		public void DeleteGameObjects()
		{
			foreach (Deletion deletion in Deletions)
			{
				GameObject val = GameObject.Find(deletion.Path);
				if ((Object)(object)val == (Object)null)
				{
					Debug.Log((object)("DeleteVanillaGameObjectsV1 could not find GameObject to delete at path: " + deletion.Path));
				}
				else
				{
					HandleDeleteGameObject(val);
				}
			}
		}

		private void HandleDeleteGameObject(GameObject gameObject)
		{
			if ((Object)(object)gameObject.GetComponent<StreetLifeCluster>() != (Object)null)
			{
				DisableGameObject(gameObject);
			}
			else
			{
				Object.Destroy((Object)(object)gameObject);
			}
		}

		private void DisableGameObject(GameObject gameObject)
		{
			gameObject.SetActive(false);
			disabledGameObjects.Add(gameObject);
		}

		public bool IsDisabled(GameObject gameObject)
		{
			if (disabledGameObjects.Contains(gameObject))
			{
				return true;
			}
			return false;
		}
	}
	public class MoveVanillaGameObjectV1 : MonoBehaviour
	{
		public string moveThis;

		public Transform targetLocation;

		private void Awake()
		{
			if (!Application.isEditor)
			{
				MoveGameObject();
			}
		}

		public void MoveGameObject()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.Find(moveThis);
			obj.transform.position = targetLocation.position;
			obj.transform.rotation = targetLocation.rotation;
		}
	}
	public class VanillaAssetReference : MonoBehaviour
	{
		public Component component;

		[TextArea(3, 10)]
		public List<string> fields = new List<string>();

		public const BindingFlags UseTheseBindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy;

		private void Awake()
		{
			AssignReferences();
		}

		public void AssignReferences()
		{
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			foreach (string field in fields)
			{
				int num = field.IndexOf("=");
				int num2 = field.IndexOf(":");
				string text = field.Substring(0, num);
				int num3 = -1;
				int num4 = text.IndexOf("[");
				if (num4 >= 0)
				{
					num3 = int.Parse(text.Substring(num4 + 1, -1));
					((Object)this).name = text.Substring(0, num4);
				}
				else
				{
					((Object)this).name = text;
				}
				string text2 = field.Substring(num + 1, num2 - num - 1);
				string text3 = field.Substring(num2 + 1);
				Object val = Core.Instance.Assets.LoadAssetFromBundle<Object>(text2, text3);
				if (val == (Object)null)
				{
					Debug.Log((object)string.Format("{0}: Restoring reference to vanilla asset failed, asset not found: {1}.{2} = LoadAssetFromBundle(\"{3}\", \"{4}\")", "VanillaAssetReference", ((object)component).GetType().Name, ((Object)this).name, text2, text3));
					continue;
				}
				Type type = ((object)component).GetType();
				MemberInfo memberInfo = type.GetMember(((Object)this).name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy)[0];
				string text4 = string.Format("VanillaAssetReference: Assigning {0}.{1} = asset {2}:{3} (asset found={4}, field found={5}, asset type={6})", type.Name, text, text2, text3, val != (Object)null, memberInfo != null, (val != (Object)null) ? ((object)val).GetType().Name : "<not found>");
				try
				{
					if (num3 >= 0)
					{
						object obj = ((memberInfo is PropertyInfo propertyInfo) ? propertyInfo.GetValue(component) : ((FieldInfo)memberInfo).GetValue(component));
						obj.GetType().GetProperty("Item").SetValue(obj, val, new object[1] { num3 });
					}
					else if (memberInfo is PropertyInfo propertyInfo2)
					{
						propertyInfo2.SetValue(component, val);
					}
					else
					{
						((FieldInfo)memberInfo).SetValue(component, val);
					}
				}
				catch (Exception ex)
				{
					Debug.Log((object)(text4 + "\nFailed with error:\n" + ex.Message + "\n" + ex.StackTrace));
				}
			}
		}
	}
	public class VanillaAssetReferenceV2 : MonoBehaviour
	{
		public class SList_Components : SList<ComponentEntry>
		{
		}

		[SerializeReference]
		private SList_Components components = new SList_Components();

		public const BindingFlags UseTheseBindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy;

		private List<ComponentEntry> Components => components.items;

		private void Awake()
		{
			AssignReferences();
		}

		public void AssignReferences()
		{
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			foreach (ComponentEntry component2 in Components)
			{
				Component component = component2.Component;
				foreach (FieldEntry field in component2.Fields)
				{
					Object val = null;
					Object[] array = null;
					if (field.SubAssetType == SubAssetType.FbxChild)
					{
						array = Core.Instance.Assets.availableBundles[field.BundleName].AssetBundle.LoadAssetWithSubAssets(field.Path);
					}
					else
					{
						val = Core.Instance.Assets.LoadAssetFromBundle<Object>(field.BundleName, field.Path);
					}
					if (val == (Object)null && array == null)
					{
						Debug.Log((object)string.Format("{0}: Restoring reference to vanilla asset failed, asset not found: {1}.{2} = LoadAssetFromBundle(\"{3}\", \"{4}\")", "VanillaAssetReferenceV2", ((object)component).GetType().Name, field.Name, field.BundleName, field.Path));
						continue;
					}
					switch (field.SubAssetType)
					{
					case SubAssetType.FbxChild:
					{
						Object[] array2 = array;
						foreach (Object val2 in array2)
						{
							if (val2.name == field.SubPath)
							{
								val = val2;
								break;
							}
						}
						break;
					}
					case SubAssetType.MixerGroup:
						val = (Object)(object)((AudioMixer)val).FindMatchingGroups(field.SubPath)[0];
						break;
					}
					if (val == (Object)null)
					{
						Debug.Log((object)string.Format("{0}: Restoring reference to vanilla asset failed, sub-asset not found: {1}.{2} = LoadAssetFromBundle(\"{3}\", \"{4}\"); SubAssetType={5}; SubPath={6}", "VanillaAssetReferenceV2", ((object)component).GetType().Name, field.Name, field.BundleName, field.Path, field.SubAssetType.ToString(), field.SubPath));
						continue;
					}
					string message = "";
					try
					{
						if (component is Animation && field.Name == "AddClip")
						{
							AddAnimationClip(val, component, field, out message);
						}
						else
						{
							AssignMember(val, component, field, out message);
						}
					}
					catch (Exception ex)
					{
						Debug.Log((object)(message + "\nFailed with error:\n" + ex.Message + "\n" + ex.StackTrace));
					}
				}
			}
		}

		public static void AssignMember(Object asset, Component component, FieldEntry f, out string message)
		{
			Type type = ((object)component).GetType();
			MemberInfo memberInfo = type.GetMember(f.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy)[0];
			message = string.Format("{0}: Assigning {1}.{2} = asset {3}:{4} (asset found={5}, field found={6}, asset type={7})", "VanillaAssetReferenceV2", type.Name, f.PropertyPath, f.BundleName, f.Path, asset != (Object)null, memberInfo != null, (asset != (Object)null) ? ((object)asset).GetType().Name : "<not found>");
			if (f.Index >= 0)
			{
				object obj = ((memberInfo is PropertyInfo propertyInfo) ? propertyInfo.GetValue(component) : ((FieldInfo)memberInfo).GetValue(component));
				obj.GetType().GetProperty("Item").SetValue(obj, asset, new object[1] { f.Index });
			}
			else if (memberInfo is PropertyInfo propertyInfo2)
			{
				propertyInfo2.SetValue(component, asset);
			}
			else
			{
				((FieldInfo)memberInfo).SetValue(component, asset);
			}
		}

		public static void AddAnimationClip(Object asset, Component component, FieldEntry f, out string message)
		{
			message = "VanillaAssetReferenceV2: Animation.AddClip(asset, " + asset.name + ") where asset is " + f.BundleName + ":" + f.Path + ((f.SubPath != null) ? (":" + f.SubPath) : "") + " (asset type=" + ((asset != (Object)null) ? ((object)asset).GetType().Name : "<not found>") + ")";
			((Animation)((component is Animation) ? component : null)).AddClip((AnimationClip)(object)((asset is AnimationClip) ? asset : null), asset.name);
		}
	}
	[Serializable]
	public class ComponentEntry
	{
		private class SList_FieldEntry : SList<FieldEntry>
		{
		}

		[SerializeField]
		public Component Component;

		[SerializeReference]
		private SList_FieldEntry fields = new SList_FieldEntry();

		public List<FieldEntry> Fields => fields.items;
	}
	[Serializable]
	public class FieldEntry
	{
		[HideInInspector]
		[SerializeField]
		public bool Enabled = true;

		[HideInInspector]
		[SerializeField]
		public bool AutoSync = true;

		[SerializeField]
		public string Name;

		[HideInInspector]
		[SerializeField]
		public int Index = -1;

		[SerializeField]
		public string BundleName;

		[SerializeField]
		public string Path;

		[SerializeField]
		public SubAssetType SubAssetType;

		[SerializeField]
		public string SubPath = "";

		public string PropertyPath
		{
			get
			{
				if (Index < 0)
				{
					return Name;
				}
				return $"{Name}[{Index}]";
			}
		}
	}
	public enum SubAssetType
	{
		None,
		MixerGroup,
		FbxChild
	}
}
namespace Winterland.MapStation.Common.Dependencies
{
	public class AssemblyDependencies
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}

Winterland.MapStation.Plugin.dll

Decompiled 2 years ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Microsoft.CodeAnalysis;
using Reptile;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("Winterland.MapStation.Plugin")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e86c4645c87181b62d12a363fffb9927d2c72a1c")]
[assembly: AssemblyProduct("Winterland.MapStation.Plugin")]
[assembly: AssemblyTitle("Winterland.MapStation.Plugin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: TypeForwardedTo(typeof(GraffitiSpot))]
[assembly: TypeForwardedTo(typeof(GrindLine))]
[assembly: TypeForwardedTo(typeof(GrindNode))]
[assembly: TypeForwardedTo(typeof(GrindPath))]
[assembly: TypeForwardedTo(typeof(VertShape))]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Winterland.MapStation.Components
{
	public class Grind : MonoBehaviour
	{
	}
}
namespace Winterland.MapStation.Plugin
{
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "Winterland.MapStation.Plugin";

		public const string PLUGIN_NAME = "Winterland.MapStation.Plugin";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace Winterland.MapStation.Plugin.Dependencies
{
	public class AssemblyDependencies
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}

Winterland.MustLoadInEditor.dll

Decompiled 2 years ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Winterland.MustLoadInEditor")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Small inspectable classes which absolutely must load in Unity Editor without errors.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e86c4645c87181b62d12a363fffb9927d2c72a1c")]
[assembly: AssemblyProduct("Winterland.MustLoadInEditor")]
[assembly: AssemblyTitle("Winterland.MustLoadInEditor")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Winterland.MustLoadInEditor
{
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "Winterland.MustLoadInEditor";

		public const string PLUGIN_NAME = "Winterland.MustLoadInEditor";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}

Winterland.Plugin.dll

Decompiled 2 years ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using CommonAPI;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Reptile;
using Rewired;
using TMPro;
using UnityEngine;
using Winterland.Common;
using Winterland.MapStation.Common;
using Winterland.MapStation.Common.Dependencies;
using Winterland.MapStation.Common.VanillaAssets;
using Winterland.MapStation.Plugin.Dependencies;
using Winterland.Plugin;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("Winterland.Plugin")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("BepInEx Plugin Assembly for Millenium Winterland.")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+e86c4645c87181b62d12a363fffb9927d2c72a1c")]
[assembly: AssemblyProduct("Winterland.Plugin")]
[assembly: AssemblyTitle("Winterland.Plugin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Winterland.Plugin
{
	internal class KBMInputDisabler
	{
		public static void Disable()
		{
			Player rewiredPlayer = Core.Instance.GameInput.rewiredMappingHandler.GetRewiredPlayer(0);
			((Controller)rewiredPlayer.controllers.Mouse).enabled = false;
			((Controller)rewiredPlayer.controllers.Keyboard).enabled = false;
		}
	}
	[BepInPlugin("Winterland.Plugin", "Winterland.Plugin", "1.0.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public delegate void UpdateDelegate();

		public static Plugin Instance;

		public static ManualLogSource Log = null;

		internal static bool DynamicCameraInstalled = false;

		private static Type ForceLoadMapStationCommonAssembly = typeof(AssemblyDependencies);

		private static Type ForceLoadMapStationPluginAssembly = typeof(AssemblyDependencies);

		public static UpdateDelegate UpdateEvent;

		private void Awake()
		{
			Instance = this;
			try
			{
				Initialize();
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Winterland.Plugin 1.0.2 is loaded!");
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)string.Format("Plugin {0} {1} failed to load!{2}{3}", "Winterland.Plugin", "1.0.2", Environment.NewLine, ex));
			}
		}

		private void Initialize()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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_0084: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "AssetBundles");
			string text2 = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			if (Directory.Exists(text))
			{
				text2 = text;
			}
			WinterAssets val = new WinterAssets(text2);
			new WinterConfig(((BaseUnityPlugin)this).Config);
			WinterCharacters.Initialize();
			ObjectiveDatabase.Initialize(val.WinterBundle);
			NetManager.Create();
			new WinterProgress();
			Log = ((BaseUnityPlugin)this).Logger;
			StageAPI.OnStagePreInitialization = (StageInitializationDelegate)Delegate.Combine((Delegate?)(object)StageAPI.OnStagePreInitialization, (Delegate?)new StageInitializationDelegate(StageAPI_OnStagePreInitialization));
			new Harmony("Winterland.Plugin").PatchAll();
			DynamicCameraInstalled = Chainloader.PluginInfos.Keys.Contains("DynamicCamera") || Chainloader.PluginInfos.Keys.Contains("com.Dragsun.Savestate") || Chainloader.PluginInfos.Keys.Contains("Savestate");
		}

		private void StageAPI_OnStagePreInitialization(Stage newStage, Stage previousStage)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			WinterManager.Create().SetupStage(newStage);
		}

		private void Update()
		{
			UpdateEvent?.Invoke();
		}
	}
	public class WinterManager : MonoBehaviour
	{
		public GameObject stageAdditions;

		public static WinterManager Instance { get; private set; }

		public static WinterManager Create()
		{
			//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)
			GameObject val = new GameObject("Winter Manager");
			WinterManager result = val.AddComponent<WinterManager>();
			val.AddComponent<ToyLineManager>();
			val.AddComponent<ArcadeManager>();
			val.AddComponent<GiftPileManager>();
			return result;
		}

		public void SetupStage(Stage stage)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			GameObject prefabForStage = WinterAssets.Instance.GetPrefabForStage(stage);
			if (!((Object)(object)prefabForStage == (Object)null))
			{
				stageAdditions = Object.Instantiate<GameObject>(prefabForStage);
				StageObject[] componentsInChildren = stageAdditions.GetComponentsInChildren<StageObject>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].PutInChunk();
				}
				DebugShapeUtility.SetDebugShapesVisibility(stageAdditions, false);
				Doctor.AnalyzeAndLog(stageAdditions);
			}
		}

		private void SetupUI()
		{
			AssetBundle winterBundle = WinterAssets.Instance.WinterBundle;
			if (!((Object)(object)winterBundle == (Object)null))
			{
				GameObject val = winterBundle.LoadAsset<GameObject>("WinterUI");
				if (!((Object)(object)val == (Object)null))
				{
					GameObject obj = Object.Instantiate<GameObject>(val);
					Transform val2 = ((Component)Core.Instance.UIManager).transform.Find("GamePlayUI(Clone)").Find("GameplayUI").Find("gameplayUIScreen");
					obj.transform.SetParent(val2, false);
				}
			}
		}

		private void Awake()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			Instance = this;
			LightmapSettings.lightmaps = (LightmapData[])(object)new LightmapData[0];
			QualitySettings.shadowDistance = 150f;
			StageManager.OnStagePostInitialization += new OnStageInitializedDelegate(StageManager_OnStagePostInitialization);
		}

		private void OnDestroy()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			Instance = null;
			StageManager.OnStagePostInitialization -= new OnStageInitializedDelegate(StageManager_OnStagePostInitialization);
		}

		private void StageManager_OnStagePostInitialization()
		{
			SetupUI();
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "Winterland.Plugin";

		public const string PLUGIN_NAME = "Winterland.Plugin";

		public const string PLUGIN_VERSION = "1.0.2";
	}
}
namespace Winterland.Plugin.Patches
{
	[HarmonyPatch(typeof(AmbientManager))]
	internal class AmbientManagerPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Update")]
		private static bool Update_Prefix(AmbientManager __instance)
		{
			//IL_0015: 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)
			if ((Object)(object)AmbientOverride.Instance == (Object)null)
			{
				return true;
			}
			__instance.ApplyAmbientChange(AmbientOverride.Instance.CurrentLightColor, AmbientOverride.Instance.CurrentShadowColor);
			return false;
		}
	}
	[HarmonyPatch(typeof(CharacterSelect))]
	internal class CharacterSelectPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("PopulateListOfSelectableCharacters")]
		private static void PopulateListOfSelectableCharacters_Postfix(CharacterSelect __instance, Player player)
		{
			//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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_0025: Invalid comparison between Unknown and I4
			//IL_0031: 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)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Invalid comparison between Unknown and I4
			//IL_0028: 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_004b: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			List<Characters> list = new List<Characters>();
			foreach (Characters selectableCharacter in __instance.selectableCharacters)
			{
				Characters baseCharacter = WinterCharacters.GetBaseCharacter(selectableCharacter);
				if ((int)baseCharacter == -1)
				{
					list.Add(selectableCharacter);
					continue;
				}
				Characters val = WinterCharacters.GetBaseCharacter(player.character);
				if ((int)val == -1)
				{
					val = player.character;
				}
				if (baseCharacter == val)
				{
					list.Add(selectableCharacter);
				}
				else if (__instance.IsCharacterUnlocked(baseCharacter))
				{
					list.Add(selectableCharacter);
				}
			}
			__instance.selectableCharacters = list;
		}
	}
	[HarmonyPatch(typeof(ComboMascot))]
	internal class ComboMascotPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("OnTriggerEnter")]
		private static bool OnTriggerEnter_Prefix(Collider other)
		{
			WinterPlayer componentInParent = ((Component)other).GetComponentInParent<WinterPlayer>();
			if ((Object)(object)componentInParent == (Object)null)
			{
				return true;
			}
			if ((Object)(object)componentInParent.CurrentToyLine != (Object)null)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(GameplayCamera))]
	internal class GameplayCameraPatch
	{
		private static float OriginalDragDistanceDefault;

		private static float OriginalDragDistanceMax;

		private static float OriginalCameraHeight;

		private static float OriginalCameraFOV;

		private const float CameraTransitionSpeed = 5f;

		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		private static void Awake_Postfix(GameplayCamera __instance)
		{
			OriginalDragDistanceDefault = __instance.dragDistanceDefault;
			OriginalDragDistanceMax = __instance.dragDistanceMax;
			OriginalCameraHeight = __instance.defaultCamHeight;
			OriginalCameraFOV = __instance.cam.fieldOfView;
		}

		[HarmonyPostfix]
		[HarmonyPatch("UpdateCamera")]
		private static void UpdateCamera_Postfix(GameplayCamera __instance)
		{
		}
	}
	[HarmonyPatch(typeof(GraffitiGame))]
	internal class GraffitiGamePatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Init")]
		private static void Init_Postfix(GraffitiSpot g, GraffitiGame __instance)
		{
			ToyGraffitiSpot val = ToyGraffitiSpot.Get(g);
			if (!((Object)(object)val == (Object)null))
			{
				__instance.distanceToGrafSpot = 1.75f;
				AmbientOverrideTrigger interiorLighting = val.ToyMachine.InteriorLighting;
				AmbientOverride instance = AmbientOverride.Instance;
				if ((Object)(object)interiorLighting != (Object)null && (Object)(object)instance != (Object)null)
				{
					instance.TransitionAmbient(interiorLighting);
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("SetState")]
		private static void SetState_Postfix(GraffitiGameState setState, GraffitiGame __instance)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Invalid comparison between Unknown and I4
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			ToyGraffitiSpot val = ToyGraffitiSpot.Get(__instance.gSpot);
			if (!((Object)(object)val == (Object)null) && (int)setState == 2)
			{
				__instance.showPieceCamSpeed = 5f;
				WinterPlayer local = WinterPlayer.GetLocal();
				if ((Object)(object)local.CurrentToyLine != (Object)null)
				{
					val.ToyMachine.ShowBuiltToy(local.CurrentToyLine.Toy, __instance.grafArt);
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("End")]
		private static void End_Postfix(GraffitiGame __instance)
		{
			ToyGraffitiSpot val = ToyGraffitiSpot.Get(__instance.gSpot);
			if (!((Object)(object)val == (Object)null))
			{
				val.ToyMachine.HideBuiltToy();
				AmbientOverrideTrigger interiorLighting = val.ToyMachine.InteriorLighting;
				AmbientOverride instance = AmbientOverride.Instance;
				if ((Object)(object)interiorLighting != (Object)null && (Object)(object)instance != (Object)null)
				{
					instance.StopAmbient(interiorLighting);
				}
			}
		}
	}
	[HarmonyPatch(typeof(GraffitiSpot))]
	internal class GraffitiSpotPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("GiveRep")]
		private static bool GiveRep_Prefix(GraffitiSpot __instance)
		{
			if (REPLessGraffiti.IsREPLess(__instance))
			{
				return false;
			}
			if ((Object)(object)ToyGraffitiSpot.Get(__instance) != (Object)null)
			{
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("CanDoGraffiti")]
		private static bool CanDoGraffiti_Prefix(ref bool __result, Player byPlayer, GraffitiSpot __instance)
		{
			if ((Object)(object)ToyGraffitiSpot.Get(__instance) != (Object)null && !(byPlayer.ability is ToyMachineAbility))
			{
				__result = false;
				return false;
			}
			if (byPlayer.ability is ToyMachineAbility)
			{
				WinterPlayer val = WinterPlayer.Get(byPlayer);
				if ((Object)(object)val != (Object)null)
				{
					if ((Object)(object)val.CurrentToyLine == (Object)null)
					{
						__result = false;
						return false;
					}
					if (val.CollectedToyParts != val.CurrentToyLine.ToyParts.Length)
					{
						__result = false;
						return false;
					}
				}
				Ability ability = byPlayer.ability;
				if (!((ToyMachineAbility)((ability is ToyMachineAbility) ? ability : null)).CanTag)
				{
					__result = false;
					return false;
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(GrindAbility))]
	internal class GrindAbilityPatch
	{
		private static bool Fixed = false;

		private static Vector3 DeltaPosition = Vector3.zero;

		private static Quaternion PreviousRotation = Quaternion.identity;

		[HarmonyPrefix]
		[HarmonyPatch("FixedUpdateAbility")]
		private static void FixedUpdateAbility_Prefix(GrindAbility __instance)
		{
			//IL_0011: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			float num = float.Epsilon;
			Vector3 position = ((Ability)__instance).p.tf.position;
			Vector3 forward = ((Ability)__instance).p.tf.forward;
			Vector3 val = __instance.grindLine.GetNextNode(forward) - position;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			if (((Vector3)(ref normalized)).sqrMagnitude <= num)
			{
				Fixed = true;
				DeltaPosition = 1f * (PreviousRotation * Vector3.forward);
				((Ability)__instance).p.SetRotHard(PreviousRotation);
				Transform tf = ((Ability)__instance).p.tf;
				tf.position += DeltaPosition;
			}
			PreviousRotation = ((Ability)__instance).p.tf.rotation;
		}

		[HarmonyPostfix]
		[HarmonyPatch("FixedUpdateAbility")]
		private static void FixedUpdateAbility_Postfix(GrindAbility __instance)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (Fixed)
			{
				Transform tf = ((Ability)__instance).p.tf;
				tf.position -= DeltaPosition;
			}
			Fixed = false;
		}
	}
	[HarmonyPatch(typeof(PauseMenu))]
	internal class PauseMenuPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("RefreshLabels")]
		private static void RefreshLabels_Postfix(PauseMenu __instance)
		{
			WinterProgress instance = WinterProgress.Instance;
			object obj;
			if (instance == null)
			{
				obj = null;
			}
			else
			{
				ILocalProgress localProgress = instance.LocalProgress;
				obj = ((localProgress != null) ? localProgress.Objective : null);
			}
			WinterObjective val = (WinterObjective)obj;
			if (!((Object)(object)val == (Object)null) && val.Test() && !string.IsNullOrEmpty(val.Description))
			{
				((TMP_Text)__instance.currentObjectiveText).text = val.Description;
			}
		}
	}
	[HarmonyPatch(typeof(Player))]
	internal static class PlayerPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Init")]
		private static void Init_Postfix(Player __instance)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			WinterPlayer val = ((Component)__instance).gameObject.AddComponent<WinterPlayer>();
			val.player = __instance;
			if (!__instance.isAI)
			{
				val.ToyMachineAbility = new ToyMachineAbility(__instance);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("EndGraffitiMode")]
		private static void EndGraffitiMode_Postfix(Player __instance, GraffitiSpot graffitiSpot)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			if ((int)graffitiSpot.state == 2 && !__instance.isAI && graffitiSpot.ClaimedByPlayableCrew())
			{
				ToyGraffitiSpot val = ToyGraffitiSpot.Get(graffitiSpot);
				if (!((Object)(object)val == (Object)null))
				{
					val.ToyMachine.FinishToyLine();
					val.ToyMachine.TeleportPlayerToExit(true);
					graffitiSpot.allowRedo = true;
				}
			}
		}
	}
	[HarmonyPatch(typeof(SceneObjectsRegister))]
	internal class SceneObjectsRegisterPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("GetTotalGraffitiREP")]
		private static bool GetTotalGraffitiREP_Prefix(ref int __result, SceneObjectsRegister __instance)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			for (int i = 0; i < __instance.grafSpots.Count; i++)
			{
				if (!(__instance.grafSpots[i] is GraffitiSpotFinisher) && !((Object)(object)ToyGraffitiSpot.Get(__instance.grafSpots[i]) != (Object)null) && !REPLessGraffiti.IsREPLess(__instance.grafSpots[i]))
				{
					num += GraffitiSpot.GetREP(__instance.grafSpots[i].size);
				}
			}
			__result = num;
			return false;
		}
	}
	[HarmonyPatch(typeof(StreetLifeCluster))]
	internal class StreetLifeClusterPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("UpdateStreetLifeCluster")]
		private static bool UpdateStreetLifeCluster_Prefix(StreetLifeCluster __instance)
		{
			DeleteVanillaGameObjectsV1 instance = DeleteVanillaGameObjectsV1.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				return true;
			}
			if (instance.IsDisabled(((Component)__instance).gameObject))
			{
				__instance.SetClusterActive(false);
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(WorldHandler))]
	internal class WorldHandlerPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("SetNPCAvailabilityBasedOnPlayer")]
		private static bool SetNPCAvailabilityBasedOnPlayer_Prefix(WorldHandler __instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//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)
			Characters baseCharacter = WinterCharacters.GetBaseCharacter(__instance.currentPlayer.character);
			if ((int)baseCharacter == -1)
			{
				return true;
			}
			foreach (NPC nPC in __instance.sceneObjectsRegister.NPCs)
			{
				((GameplayEvent)nPC).SetAvailable(nPC.character != baseCharacter);
			}
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("CharacterIsAlreadyNPCInScene")]
		private static bool CharacterIsAlreadyNPCInScene_Prefix(ref Characters c, WorldHandler __instance, ref bool __result)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_000a: Invalid comparison between Unknown and I4
			//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_001f: 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_0022: Invalid comparison between Unknown and I4
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected I4, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Invalid comparison between Unknown and I4
			//IL_002a: 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)
			Characters baseCharacter = WinterCharacters.GetBaseCharacter(c);
			if ((int)baseCharacter != -1)
			{
				c = (Characters)(int)baseCharacter;
			}
			Characters val = WinterCharacters.GetBaseCharacter(__instance.currentPlayer.character);
			if ((int)val == -1)
			{
				val = __instance.currentPlayer.character;
			}
			if ((int)val == (int)c)
			{
				__result = true;
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("SetNPCAvailabilityBasedOnCharacter")]
		private static void SetNPCAvailabilityBasedOnCharacter_Prefix(ref Characters oldChar, ref Characters newChar)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_000a: Invalid comparison between Unknown and I4
			//IL_0011: 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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Invalid comparison between Unknown and I4
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected I4, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected I4, but got Unknown
			Characters baseCharacter = WinterCharacters.GetBaseCharacter(oldChar);
			if ((int)baseCharacter != -1)
			{
				oldChar = (Characters)(int)baseCharacter;
			}
			Characters baseCharacter2 = WinterCharacters.GetBaseCharacter(newChar);
			if ((int)baseCharacter2 != -1)
			{
				newChar = (Characters)(int)baseCharacter2;
			}
		}
	}
}
namespace Winterland.Common
{
	public class DebugShapeDebugUI : MonoBehaviour
	{
		private bool visible;

		public static DebugShapeDebugUI Instance { get; private set; }

		public static void Create()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			if (!((Object)(object)Instance != (Object)null))
			{
				GameObject val = new GameObject("Winterland DebugShapeDebugUI");
				Instance = val.AddComponent<DebugShapeDebugUI>();
				Object.DontDestroyOnLoad((Object)val);
			}
		}

		private void Awake()
		{
			DebugUI.Instance.RegisterMenu("Debug Shapes", (Action)OnDebugUI);
		}

		private void OnDebugUI()
		{
			GUILayout.Label("Red Debug Shapes", Array.Empty<GUILayoutOption>());
			if ((Object)(object)WinterManager.Instance != (Object)null && (Object)(object)WinterManager.Instance.stageAdditions != (Object)null && GUILayout.Button((visible ? "Hide" : "Show") + " Red Debug Shapes", Array.Empty<GUILayoutOption>()))
			{
				visible = !visible;
				DebugShapeUtility.SetDebugShapesVisibility(WinterManager.Instance.stageAdditions, visible);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}