Decompiled source of AlternateStart v1.4.0

plugins/AlternateStart.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using AlternateStart.Characters;
using AlternateStart.StartScenarios;
using BepInEx;
using BepInEx.Bootstrap;
using CustomAttributes;
using HarmonyLib;
using NodeCanvas.DialogueTrees;
using NodeCanvas.Framework;
using NodeCanvas.Tasks.Actions;
using SideLoader;
using SideLoader.Managers;
using SideLoader.Model;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("OutwardModTemplate")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OutwardModTemplate")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c5450fe0-edcf-483f-b9ea-4b1ef9d36da7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace AlternateStart
{
	public enum ScenarioPassives
	{
		NONE = 0,
		Random = -2200,
		Vanilla = -2201,
		VanillaAlt = -2202,
		VanillaBerg = -2203,
		VanillaLevant = -2204,
		VanillaMonsoon = -2205,
		VanillaHarmattan = -2206,
		LevantSlums = -2207,
		EnmerkarHunter = -2208,
		PriestElatt = -2209,
		Claustrophobic = -2210,
		VendavelSlave = -2211,
		GiantRisen = -2212,
		ConfluxWatcher = -2213,
		Veteran = -2214,
		WolfgangMercenary = -2215,
		RobbedTrader = -2216,
		Survivor = -2217,
		CorruptedSoul = -2218,
		ChosenOne = -2219,
		TimeMage = -2220,
		Unbound = -2320,
		Cannibal = -2321,
		SandBandit = -2322,
		Nightmare = -2323
	}
	public enum ScenarioQuest
	{
		Quest_Test = -2300,
		Quest_Vanilla = -2301,
		Quest_VanillaAlt = -2302,
		Quest_VanillaBerg = -2303,
		Quest_VanillaLevant = -2304,
		Quest_VanillaMonsoon = -2305,
		Quest_VanillaHarmattan = -2306,
		Quest_LevantSlums = -2307,
		Quest_EmercarHunter = -2308,
		Quest_PriestElatt = -2309,
		Quest_Claustro = -2310,
		Quest_VendavelSlave = -2311,
		Quest_GiantRisen = -2312,
		Quest_ConfluxWatcher = -2313,
		Quest_Veteran = -2314,
		Quest_WolfgangMercenary = -2315,
		Quest_RobbedTrader = -2316,
		Quest_Survivor = -2317,
		Quest_CorruptedSoul = -2318,
		Quest_ChosenOne = -2319,
		Quest_TimeMage = -2320,
		Quest_Unbound = -23320,
		Quest_Cannibal = -23321,
		Quest_SandBandit = -23322
	}
	public enum ScenarioTheme
	{
		None,
		Magic,
		Stamina,
		Tanky,
		Freeform
	}
	public enum ScenarioType
	{
		WIPtest = 0,
		VanillaLike = -2207,
		Normal = -2208,
		Outlaw = -2209
	}
	internal static class QuestExtensions
	{
		internal static void UpdateLogEntry(this QuestProgress progress, QuestLogEntrySignature signature, bool displayTime)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			progress.UpdateLogEntry(signature.UID, displayTime, signature);
		}
	}
	public class ExtrasManager : MonoBehaviour
	{
		public static ExtrasManager Instance;

		private Vector3 spawn = new Vector3(1284.4f, -3.7f, 1622.2f);

		private Vector3 spawnRot = new Vector3(0f, 203f, 0f);

		public List<Character> allPlayers;

		internal void Awake()
		{
			Instance = this;
			allPlayers = new List<Character>();
		}
	}
	public static class GearManager
	{
		internal static void Init()
		{
		}

		public static void StartingGear()
		{
			foreach (PlayerSystem item in Global.Lobby.PlayersInLobby)
			{
				Character controlledCharacter = item.ControlledCharacter;
				CharacterSkillKnowledge skillKnowledge = controlledCharacter.Inventory.SkillKnowledge;
				foreach (Scenario value in ScenarioManager.startScenarios.Values)
				{
					if (((CharacterKnowledge)skillKnowledge).IsItemLearned((int)value.Passive))
					{
						Debug.Log((object)"adding scenario gear");
						value.Gear(controlledCharacter);
						break;
					}
				}
			}
		}

		public static void RandomPassive()
		{
		}
	}
	[BepInPlugin("com.iggy.altstart", "Alternate Start", "1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "com.iggy.altstart";

		private const string NAME = "Alternate Start";

		private const string VERSION = "1.0";

		public static Plugin Instance;

		public const string SL_PACK_NAME = "iggythemad AlternateStart";

		public const string QUEST_EVENT_FAMILY_NAME = "A_Iggy_AlternateStart";

		private const string trainersOfAuraiGUID = "com.iggy.trainersofaurai";

		public static bool trainersOfAuraiInstalled;

		internal void Awake()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			((BaseUnityPlugin)this).Logger.LogMessage((object)"Alternate Start Awake()");
			CompatibilitySetup();
			((Component)this).gameObject.AddComponent<ExtrasManager>();
			ScenarioManager.Init();
			GearManager.Init();
			SL.OnPacksLoaded += SL_OnPacksLoaded;
			new Harmony("com.iggy.altstart").PatchAll();
			setCustomAttributes();
		}

		public void CompatibilitySetup()
		{
			foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
			{
				BepInPlugin metadata = pluginInfo.Value.Metadata;
				if (!trainersOfAuraiInstalled && metadata.GUID.Equals("com.iggy.trainersofaurai"))
				{
					Debug.Log((object)"TrainersOfAurai X AltStart:  com.iggy.trainersofaurai");
					trainersOfAuraiInstalled = true;
					break;
				}
			}
		}

		internal void OnGUI()
		{
		}

		internal void setCustomAttributes()
		{
			CustomAttributeHelper.PassiveSelfCritStore(-2219, 15f);
		}

		private void SL_OnPacksLoaded()
		{
			TrainerManager.Init();
		}

		internal static void Log(object log)
		{
			((BaseUnityPlugin)Instance).Logger.LogMessage((object)(log?.ToString() ?? string.Empty));
		}

		internal static void LogWarning(object log)
		{
			((BaseUnityPlugin)Instance).Logger.LogWarning((object)(log?.ToString() ?? string.Empty));
		}

		internal static void LogError(object log)
		{
			((BaseUnityPlugin)Instance).Logger.LogError((object)(log?.ToString() ?? string.Empty));
		}
	}
	public static class ScenarioManager
	{
		[HarmonyPatch(typeof(NetworkLevelLoader), "LoadLevel", new Type[]
		{
			typeof(int),
			typeof(int),
			typeof(float),
			typeof(bool)
		})]
		public class NetworkLevelLoader_LoadLevel
		{
			internal static void Prefix(ref int _buildIndex)
			{
				try
				{
					CharacterSave chosenSave = SplitScreenManager.Instance.LocalPlayers[0].ChosenSave;
					if (!((CharacterSaveData)chosenSave.PSave).NewSave && !string.IsNullOrEmpty(chosenSave.PSave.AreaName))
					{
						return;
					}
					for (int i = 0; i < SceneManager.sceneCountInBuildSettings; i++)
					{
						string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(SceneUtility.GetScenePathByBuildIndex(i));
						if (fileNameWithoutExtension != null && fileNameWithoutExtension == "DreamWorld")
						{
							_buildIndex = i;
							break;
						}
					}
				}
				catch
				{
				}
			}
		}

		[HarmonyPatch(typeof(CharacterSkillKnowledge), "AddItem", new Type[] { typeof(Item) })]
		private static class CharacterSkillKnowledge_AddItem
		{
			internal static void Postfix(Item _item)
			{
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)((EffectSynchronizer)_item).OwnerCharacter == (Object)null) && ((EffectSynchronizer)_item).OwnerCharacter.IsLocalPlayer && !QuestEventManager.Instance.HasQuestEvent("iggythemad.altstart.destinyChosen") && _item.ItemID <= 0 && !(SceneManagerHelper.ActiveSceneName != "DreamWorld"))
				{
					((EffectSynchronizer)_item).OwnerCharacter.StatusEffectMngr.AddStatusEffect("StartTag");
					((EffectSynchronizer)_item).OwnerCharacter.AutoKnock(true, Vector3.back, ((EffectSynchronizer)_item).OwnerCharacter);
					if ((Object)(object)CharacterManager.Instance.GetWorldHostCharacter() == (Object)(object)((EffectSynchronizer)_item).OwnerCharacter)
					{
						((MonoBehaviour)Plugin.Instance).StartCoroutine(CheckStartPassives(((EffectSynchronizer)_item).OwnerCharacter, _item));
					}
				}
			}
		}

		[HarmonyPatch(typeof(InteractionTriggerBase), "TryActivateBasicAction", new Type[]
		{
			typeof(Character),
			typeof(int)
		})]
		public class InteractionTriggerBase_TryActivateBasicAction
		{
			[HarmonyPrefix]
			public static bool Prefix(InteractionTriggerBase __instance, Character _character, int _toggleState)
			{
				if (!_character.IsLocalPlayer || SceneManagerHelper.ActiveSceneName != "DreamWorld")
				{
					return true;
				}
				if (_character.StatusEffectMngr.HasStatusEffect("StartTag"))
				{
					return false;
				}
				return true;
			}
		}

		public static readonly Dictionary<ScenarioPassives, Scenario> startScenarios = new Dictionary<ScenarioPassives, Scenario>();

		internal static QuestEventSignature QE_DestinyChosen;

		private const string QE_DESTINY_CHOSEN_UID = "iggythemad.altstart.destinyChosen";

		private const string FULL_STOP_STATUS_IDENTIFIER = "fullstop";

		private const string startTag = "StartTag";

		internal static void Init()
		{
			QE_DestinyChosen = CustomQuests.CreateQuestEvent("iggythemad.altstart.destinyChosen", false, false, true, "A_Iggy_AlternateStart", "CustomEvent", "A custom event created with SideLoader");
			SL.OnGameplayResumedAfterLoading += SL_OnGameplayResumedAfterLoading;
			Type[] types = typeof(Scenario).Assembly.GetTypes();
			foreach (Type type in types)
			{
				if (type.IsSubclassOf(typeof(Scenario)))
				{
					Scenario scenario = Activator.CreateInstance(type) as Scenario;
					scenario.Init();
					startScenarios.Add(scenario.Passive, scenario);
				}
			}
		}

		private static void SL_OnGameplayResumedAfterLoading()
		{
			if (!(SceneManagerHelper.ActiveSceneName == "DreamWorld") || QuestEventManager.Instance.HasQuestEvent(QE_DestinyChosen))
			{
				return;
			}
			foreach (Item learnedItem in ((CharacterKnowledge)CharacterManager.Instance.GetWorldHostCharacter().Inventory.SkillKnowledge).m_learnedItems)
			{
				if (Enum.IsDefined(typeof(ScenarioPassives), learnedItem.ItemID))
				{
					Debug.Log((object)"HAS START SCENARIO");
					return;
				}
			}
			foreach (PlayerSystem item in Global.Lobby.PlayersInLobby)
			{
				item.ControlledCharacter.Inventory.RemoveMoney(27, true);
			}
			((MonoBehaviour)Plugin.Instance).StartCoroutine(DreamworldStopper());
		}

		private static IEnumerator DreamworldStopper()
		{
			yield return (object)new WaitForSeconds(0.2f);
			Vector3 spawn = new Vector3(-12.2f, 0.2f, -0.6f);
			Vector3 spawnRot = new Vector3(0f, 75.2f, 0f);
			while (SceneManagerHelper.ActiveSceneName == "DreamWorld")
			{
				foreach (PlayerSystem item in Global.Lobby.PlayersInLobby)
				{
					if (item.IsLocalPlayer && Vector3.Distance(((Component)item.ControlledCharacter).transform.position, spawn) > 3f)
					{
						item.ControlledCharacter.Teleport(spawn, spawnRot);
					}
				}
				yield return (object)new WaitForSeconds(0.5f);
			}
		}

		internal static void SetFullStop(bool add)
		{
			if (PhotonNetwork.isNonMasterClientInRoom)
			{
				return;
			}
			foreach (PlayerSystem item in Global.Lobby.PlayersInLobby)
			{
				if (add)
				{
					item.ControlledCharacter.StatusEffectMngr.AddStatusEffect("fullstop");
				}
				else
				{
					item.ControlledCharacter.StatusEffectMngr.RemoveStatusWithIdentifierName("fullstop");
				}
			}
		}

		private static IEnumerator CheckStartPassives(Character character, Item _item)
		{
			yield return (object)new WaitForSeconds(0.2f);
			List<Character> characterList = new List<Character>();
			while (true)
			{
				LobbySystem lobby = Global.Lobby;
				if (((lobby != null) ? lobby.PlayersInLobby : null) == null)
				{
					yield return null;
					continue;
				}
				break;
			}
			while (characterList.Count < Global.Lobby.PlayersInLobby.Count)
			{
				yield return (object)new WaitForSeconds(1f);
				foreach (PlayerSystem item in Global.Lobby.PlayersInLobby)
				{
					if (item.ControlledCharacter.StatusEffectMngr.HasStatusEffect("StartTag") && !characterList.Contains(item.ControlledCharacter))
					{
						characterList.Add(item.ControlledCharacter);
					}
				}
			}
			if (((CharacterKnowledge)character.Inventory.SkillKnowledge).IsItemLearned(-2200))
			{
				((MonoBehaviour)Plugin.Instance).StartCoroutine(PickAndStartScenario());
			}
			else if (IsAnyChosen<ScenarioPassives>(character))
			{
				ScenarioPassives itemID = (ScenarioPassives)_item.ItemID;
				((MonoBehaviour)Plugin.Instance).StartCoroutine(startScenarios[itemID].StartScenario());
			}
			foreach (PlayerSystem item2 in Global.Lobby.PlayersInLobby)
			{
				if (item2.ControlledCharacter.StatusEffectMngr.HasStatusEffect("StartTag"))
				{
					item2.ControlledCharacter.StatusEffectMngr.RemoveStatusWithIdentifierName("StartTag");
				}
			}
		}

		private static bool IsAnyChosen<T>(Character character) where T : Enum
		{
			T choice;
			return TryGetChoice<T>(character, out choice);
		}

		private static bool TryGetChoice<T>(Character character, out T choice) where T : Enum
		{
			foreach (object value in Enum.GetValues(typeof(T)))
			{
				if (((CharacterKnowledge)character.Inventory.SkillKnowledge).IsItemLearned((int)value))
				{
					choice = (T)value;
					return true;
				}
			}
			choice = default(T);
			return false;
		}

		private static IEnumerator PickAndStartScenario()
		{
			Character worldHostCharacter = CharacterManager.Instance.GetWorldHostCharacter();
			_ = worldHostCharacter.Inventory.SkillKnowledge;
			TryGetChoice<ScenarioPassives>(worldHostCharacter, out var choice);
			List<Scenario> list = new List<Scenario>();
			foreach (Scenario value in startScenarios.Values)
			{
				if (value.Difficulty != 0 && value.Difficulty != ScenarioType.Outlaw)
				{
					list.Add(value);
				}
			}
			if (!list.Any())
			{
				CharacterManager.Instance.GetWorldHostCharacter().CharacterUI.NotificationPanel.ShowNotification($"Sorry, there are no {choice} scenarios!");
				yield break;
			}
			Plugin.Log("Eligable scenarios: " + string.Join(",", list.Select((Scenario it) => it.GetType().Name)));
			Scenario scenario = list[Random.Range(0, list.Count)];
			Plugin.Log("Chosen scenario: " + scenario.GetType().Name);
			((MonoBehaviour)Plugin.Instance).StartCoroutine(scenario.StartScenario());
			foreach (PlayerSystem item in Global.Lobby.PlayersInLobby)
			{
				if (((CharacterKnowledge)item.ControlledCharacter.Inventory.SkillKnowledge).IsItemLearned(-2200))
				{
					if ((Object)(object)worldHostCharacter == (Object)(object)item.ControlledCharacter)
					{
						item.ControlledCharacter.Inventory.ReceiveSkillReward((int)scenario.Passive);
						continue;
					}
					Scenario scenario2 = list[Random.Range(0, list.Count)];
					item.ControlledCharacter.Inventory.ReceiveSkillReward((int)scenario2.Passive);
				}
			}
		}
	}
	public static class TrainerManager
	{
		internal static SL_Character bergSpellblade;

		private static SLPack pack;

		public static void Init()
		{
			pack = SL.GetSLPack("iggythemad AlternateStart");
			bergSpellblade = pack.CharacterTemplates["com.iggy.berg.spellblade.trainer"];
			bergSpellblade.OnSpawn += SpellbladeSetup;
			SL.OnGameplayResumedAfterLoading += spawnSpellblade;
		}

		private static void spawnSpellblade()
		{
			//IL_006a: 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)
			if (SceneManagerHelper.ActiveSceneName == "Berg" && CharacterManager.Instance.GetWorldHostCharacter().IsLocalPlayer && QuestEventManager.Instance.HasQuestEvent(QuestEventDictionary.GetQuestEvent("lDHL_XMS7kKEs0uOqrLQjw")))
			{
				Vector3 trainerPos = default(Vector3);
				((Vector3)(ref trainerPos))..ctor(1284.4f, -3.7f, 1622.2f);
				Vector3 trainerRot = default(Vector3);
				((Vector3)(ref trainerRot))..ctor(0f, 203f, 0f);
				SpawnCharacter("com.iggy.berg.spellblade.trainer", trainerPos, trainerRot);
			}
		}

		public static Character SpawnCharacter(string trainerID, Vector3 trainerPos, Vector3 trainerRot)
		{
			//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_0012: Unknown result type (might be due to invalid IL or missing references)
			return pack.CharacterTemplates[trainerID].Spawn(trainerPos, trainerRot, UID.op_Implicit(UID.Generate()), (string)null);
		}

		public static void SpellbladeSetup(Character trainer, string _)
		{
			GenericTrainerSetup(trainer, bergSpellblade, "com.iggy.bergspellblade", "You are alive! It's good to see a familiar face.", "What can you teach me?", "What happened to Cierzo?", "What should I do now?", "The Vendavel Scum. We were not prepared for an attack. I tried to fight back, but it was too late.", "Move on. Join a faction. Rissa is here, but you are free to do as you like.");
		}

		public static void GenericTrainerSetup(Character trainer, SL_Character currentCharacter, string treeUID, string introDialogue, string ask1, string ask2, string ask3, string reply2, string reply3)
		{
			//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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_009c: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			//IL_00b9: Expected O, but got Unknown
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Expected O, but got Unknown
			//IL_00dc: Expected O, but got Unknown
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Expected O, but got Unknown
			//IL_00ff: Expected O, but got Unknown
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Expected O, but got Unknown
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Expected O, but got Unknown
			Object.DestroyImmediate((Object)(object)((Component)trainer).GetComponent<CharacterStats>());
			Object.DestroyImmediate((Object)(object)((Component)trainer).GetComponent<StartingEquipment>());
			DialogueActor componentInChildren = ((Component)trainer).GetComponentInChildren<DialogueActor>();
			componentInChildren.SetName(currentCharacter.Name);
			Trainer componentInChildren2 = ((Component)trainer).GetComponentInChildren<Trainer>();
			componentInChildren2.m_skillTreeUID = new UID(treeUID);
			Graph graph = ((GraphOwner)((Component)trainer).GetComponentInChildren<DialogueTreeController>()).graph;
			List<ActorParameter> actorParameters = ((DialogueTree)((graph is DialogueTree) ? graph : null))._actorParameters;
			actorParameters[0].actor = (IDialogueActor)(object)componentInChildren;
			actorParameters[0].name = componentInChildren.name;
			StatementNodeExt val = graph.AddNode<StatementNodeExt>();
			val.statement = new Statement(introDialogue);
			val.SetActorName(componentInChildren.name);
			MultipleChoiceNodeExt val2 = graph.AddNode<MultipleChoiceNodeExt>();
			val2.availableChoices.Add(new Choice
			{
				statement = new Statement
				{
					text = ask1
				}
			});
			val2.availableChoices.Add(new Choice
			{
				statement = new Statement
				{
					text = ask2
				}
			});
			val2.availableChoices.Add(new Choice
			{
				statement = new Statement
				{
					text = ask3
				}
			});
			Node obj = graph.allNodes[1];
			ActionNode val3 = (ActionNode)(object)((obj is ActionNode) ? obj : null);
			ActionTask action = val3.action;
			((TrainDialogueAction)((action is TrainDialogueAction) ? action : null)).Trainer = new BBParameter<Trainer>(componentInChildren2);
			StatementNodeExt val4 = graph.AddNode<StatementNodeExt>();
			val4.statement = new Statement(reply2);
			val4.SetActorName(componentInChildren.name);
			StatementNodeExt val5 = graph.AddNode<StatementNodeExt>();
			val5.statement = new Statement(reply3);
			val5.SetActorName(componentInChildren.name);
			graph.allNodes.Clear();
			graph.allNodes.Add((Node)(object)val);
			graph.allNodes.Add((Node)(object)val2);
			graph.allNodes.Add((Node)(object)val3);
			graph.allNodes.Add((Node)(object)val4);
			graph.allNodes.Add((Node)(object)val5);
			graph.primeNode = (Node)(object)val;
			graph.ConnectNodes((Node)(object)val, (Node)(object)val2, -1, -1);
			graph.ConnectNodes((Node)(object)val2, (Node)(object)val3, 0, -1);
			graph.ConnectNodes((Node)(object)val2, (Node)(object)val4, 1, -1);
			graph.ConnectNodes((Node)(object)val4, (Node)(object)val, -1, -1);
			graph.ConnectNodes((Node)(object)val2, (Node)(object)val5, 2, -1);
			graph.ConnectNodes((Node)(object)val5, (Node)(object)val, -1, -1);
			((Component)trainer).gameObject.SetActive(true);
		}
	}
	public static class VanillaQuestsHelper
	{
		public const int lookingToTheFutureQ = 7011002;

		public const int callToAdventureQ = 7011001;

		public const int enrollmentQ = 7011400;

		public const string playerInCierzo = "sm812Cio9ki5ssbsiPr3Fw";

		public const string tutorialIntroFinished = "HteYicnCK0atCgd4j5TV1Q";

		public const string introPlayerHouse = "z23QoIdtkU6cUPoUOfDn6w";

		public const string grandmother = "YQD53MKgwke6juWiSWI7jQ";

		public const string rissaBegExtension = "nt9KhXoJtkOalZ-wtfueDA";

		public const string rissaTalk = "n_3w-BcFfEW52Ht4Q3ZCjw";

		public const string debtPAID = "8GvHUbDz90OOJWurd-RZlg";

		public const string callToAdventureENDa = "g3EX5w1mwUaYW1o0cpj0SQ";

		public const string notLighthouseOwner = "-Ku9dHjTl0KeUPxWk0ZWWQ";

		public const string lostLightHouse = "qPEx275DTUSPbnv-PnFn7w";

		public const string debtNOTpaid = "sAc2Dj-T_kysKXFV48Hp0A";

		public const string callToAdventureENDb = "8iAJYhhqj02ODuwZ9VvXMw";

		public const string bergHouse = "g403vlCU6EG0s1mI6t_rFA";

		public const string harmattanHouse = "0r087PIxTUqoj6N7z2HFNw";

		public const string levantHouse = "LpVUuoxfhkaWOgh6XLbarA";

		public const string monsoonHouse = "shhCMFa-lUqbIYS9hRcsdg";

		public const int vendavelQ = 7011004;

		public const string cierzoDestroy = "lDHL_XMS7kKEs0uOqrLQjw";

		public const string cierzoWarning = "-vFSY-MNoUuLH1XXBkcqvQ";

		public const string cierzoTimer = "bm3rB3abI0KFok2x5P0lrg";

		public const string cierzoFail = "WvGjemEntk6quLjy4rLrJQ";

		public const string factionCommit = "bjVloYMQxk6KXx0gph2A1Q";

		public const string directionRISA = "seEIFfM9SkeZxc4CpR40oQ";

		public const string directionOLIELE = "Bo4-Xvq4_kudPDnOgkI3VA";

		public const string directionYSAN = "gAJAjuzl7ESFpMooq1oOCg";

		public const string olieleMonsoon = "3_soGcNagk-KcYSeqpEgMg";

		public const string yzanLevant = "BgpOoGQF10O7IQyiB9HODw";

		public const string rissaBerg = "1a6Zs9A_gEmScBetAraQaw";

		public const string readyToChoose = "jNfNsLGBpk2iMRts9kkerw";

		public const string BCproposition = "fo2uI7yiw0WSRE7MsbYFyw";

		public const string HKproposition = "JlFMC_51RUalSa8yLkhTmg";

		public const string HMproposition = "JqL0_JD55US2gL0-GbOBow";

		public const string argensonMet = "QMe_j2TIWEKpssXkLHMMZA";

		public const string argensonStash = "h8jI-dDsfkStb3XkCjqMPw";

		public const string YzanFriendship = "nr9KDCbQzUae1Gwf-6yOIQ";

		public const string callAdventureExpired = "zoKR1_bqiUiAetJ3uxw-Ug";

		public const string callAdventureCompleted = "ZYzrMi1skUiJ4BgXXQ3sfw";

		public const string ashAllyFail = "nDy01eTHlUa_BPDlbIhZPQ";

		public const string ashCompleteFail = "f1JVZyhg2UiBA8xmC-w6Hw";

		public const string ashFight = "XqlcpbTJC0aTDZfjD4xCTg";

		public const string ashWarp = "oGkuUgWvfkej_El-rhz2gw";

		internal static void SkipHostToFactionChoice(bool keepHouse, bool complete)
		{
			Character worldHostCharacter = CharacterManager.Instance.GetWorldHostCharacter();
			worldHostCharacter.Inventory.QuestKnowledge.ReceiveQuest(7011001);
			worldHostCharacter.Inventory.QuestKnowledge.ReceiveQuest(7011002);
			((MonoBehaviour)Plugin.Instance).StartCoroutine(AddPrefactionEvents(keepHouse, complete));
		}

		internal static void DestroyCierzo(bool instant, bool receiveQ)
		{
			Character worldHostCharacter = CharacterManager.Instance.GetWorldHostCharacter();
			AddQuestEvent("-vFSY-MNoUuLH1XXBkcqvQ");
			AddQuestEvent("bm3rB3abI0KFok2x5P0lrg");
			if (receiveQ)
			{
				worldHostCharacter.Inventory.QuestKnowledge.ReceiveQuest(7011004);
			}
			if (instant)
			{
				AddQuestEvent("lDHL_XMS7kKEs0uOqrLQjw");
				AddQuestEvent("WvGjemEntk6quLjy4rLrJQ");
			}
		}

		internal static void AddQuestEvent(string questUID)
		{
			QuestEventManager.Instance.AddEvent(QuestEventDictionary.GetQuestEvent(questUID), 1);
		}

		internal static void RemoveEvent(string questUID)
		{
			QuestEventManager.Instance.RemoveEvent(questUID, true);
		}

		internal static IEnumerator AddPrefactionEvents(bool keepHouse, bool complete)
		{
			Character host = CharacterManager.Instance.GetWorldHostCharacter();
			yield return (object)new WaitForSeconds(0.1f);
			AddQuestEvent("sm812Cio9ki5ssbsiPr3Fw");
			AddQuestEvent("HteYicnCK0atCgd4j5TV1Q");
			AddQuestEvent("z23QoIdtkU6cUPoUOfDn6w");
			AddQuestEvent("nt9KhXoJtkOalZ-wtfueDA");
			AddQuestEvent("YQD53MKgwke6juWiSWI7jQ");
			AddQuestEvent("n_3w-BcFfEW52Ht4Q3ZCjw");
			if (keepHouse)
			{
				AddQuestEvent("8GvHUbDz90OOJWurd-RZlg");
				AddQuestEvent("g3EX5w1mwUaYW1o0cpj0SQ");
			}
			else
			{
				AddQuestEvent("-Ku9dHjTl0KeUPxWk0ZWWQ");
				AddQuestEvent("qPEx275DTUSPbnv-PnFn7w");
				AddQuestEvent("sAc2Dj-T_kysKXFV48Hp0A");
				AddQuestEvent("8iAJYhhqj02ODuwZ9VvXMw");
			}
			AddQuestEvent("seEIFfM9SkeZxc4CpR40oQ");
			AddQuestEvent("jNfNsLGBpk2iMRts9kkerw");
			AddQuestEvent("3_soGcNagk-KcYSeqpEgMg");
			AddQuestEvent("Bo4-Xvq4_kudPDnOgkI3VA");
			AddQuestEvent("JqL0_JD55US2gL0-GbOBow");
			AddQuestEvent("JlFMC_51RUalSa8yLkhTmg");
			AddQuestEvent("BgpOoGQF10O7IQyiB9HODw");
			AddQuestEvent("gAJAjuzl7ESFpMooq1oOCg");
			AddQuestEvent("QMe_j2TIWEKpssXkLHMMZA");
			AddQuestEvent("h8jI-dDsfkStb3XkCjqMPw");
			AddQuestEvent("nr9KDCbQzUae1Gwf-6yOIQ");
			AddQuestEvent("zoKR1_bqiUiAetJ3uxw-Ug");
			AddQuestEvent("ZYzrMi1skUiJ4BgXXQ3sfw");
			if (complete)
			{
				AddQuestEvent("fo2uI7yiw0WSRE7MsbYFyw");
				AddQuestEvent("1a6Zs9A_gEmScBetAraQaw");
				host.Inventory.QuestKnowledge.ReceiveQuest(7011400);
			}
		}

		internal static void StartHouseTimer()
		{
			CharacterManager.Instance.GetWorldHostCharacter().Inventory.QuestKnowledge.ReceiveQuest(7011001);
			((MonoBehaviour)Plugin.Instance).StartCoroutine(AddHouseTimerEvents());
		}

		private static IEnumerator AddHouseTimerEvents()
		{
			yield return (object)new WaitForSeconds(0.5f);
			AddQuestEvent("sm812Cio9ki5ssbsiPr3Fw");
			AddQuestEvent("HteYicnCK0atCgd4j5TV1Q");
			AddQuestEvent("z23QoIdtkU6cUPoUOfDn6w");
			AddQuestEvent("n_3w-BcFfEW52Ht4Q3ZCjw");
			AddQuestEvent("zoKR1_bqiUiAetJ3uxw-Ug");
		}

		public static bool hasOrHadQuest(int QuestID)
		{
			if (((CharacterKnowledge)CharacterManager.Instance.GetWorldHostCharacter().Inventory.QuestKnowledge).IsItemLearned(QuestID))
			{
				return true;
			}
			return false;
		}
	}
}
namespace AlternateStart.StartScenarios
{
	public class CannibalScenario : Scenario
	{
		public override ScenarioQuest Type => ScenarioQuest.Quest_Cannibal;

		public override ScenarioType Difficulty => ScenarioType.WIPtest;

		public override ScenarioPassives Passive => ScenarioPassives.Cannibal;

		public override AreaEnum SpawnScene => (AreaEnum)209;

		public override Vector3 SpawnPosition => new Vector3(-55.4f, -40f, -3.1f);

		public override Vector3 SpawnRotation => new Vector3(0f, 20.4f, 0f);

		public override bool HasQuest => false;

		public override string QuestName => "";

		public override Dictionary<string, string> QuestLogSignatures => new Dictionary<string, string>();

		public override void Gear(Character character)
		{
			character.Inventory.ReceiveItemReward(3000081, 1, true);
			character.Inventory.ReceiveItemReward(3000083, 1, true);
			character.Inventory.ReceiveItemReward(2020050, 1, true);
			character.Inventory.ReceiveItemReward(5100060, 1, true);
			character.Inventory.ReceiveItemReward(4100550, 3, false);
		}

		public override void OnScenarioChosen()
		{
			VanillaQuestsHelper.SkipHostToFactionChoice(keepHouse: false, complete: true);
		}

		public override void OnScenarioChosen(Character character)
		{
		}

		public override void OnStartSpawn()
		{
		}

		public override void OnStartSpawn(Character character)
		{
		}

		public override void UpdateQuestProgress(Quest quest)
		{
		}
	}
	public class ChosenOneScenario : Scenario
	{
		[HarmonyPatch(typeof(PlayerCharacterStats), "get_RemainingBreakthrough")]
		private class PlayerCharacterStats_RemainingBreakthrough
		{
			public static bool Prefix(ref int __result, PlayerCharacterStats __instance)
			{
				if (((CharacterStats)__instance).m_character.IsLocalPlayer && ((CharacterKnowledge)((CharacterStats)__instance).m_character.Inventory.SkillKnowledge).IsItemLearned(-2219))
				{
					__result = Mathf.Clamp(maxBreakthroughs - __instance.m_usedBreakthroughCount, 0, 20);
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(SkillUnlockRequirementDisplay), "RefreshDisplay", new Type[] { typeof(SkillTreeSlotDisplay) })]
		public class SkillUnlockRequirementDisplay_RefreshDisplay
		{
			[HarmonyPostfix]
			public static void Postfix(SkillUnlockRequirementDisplay __instance, SkillTreeSlotDisplay _display)
			{
				if (!((Object)(object)_display == (Object)null) && ((UIElement)_display).LocalCharacter.IsLocalPlayer && ((CharacterKnowledge)((UIElement)_display).LocalCharacter.Inventory.SkillKnowledge).IsItemLearned(-2219))
				{
					if (!StoredCosts.Keys.Contains(((Item)_display.FocusedSkillSlot.Skill).ItemID))
					{
						StoredCosts.Add(((Item)_display.FocusedSkillSlot.Skill).ItemID, _display.FocusedSkillSlot.RequiredMoney);
					}
					StoredCosts.TryGetValue(((Item)_display.FocusedSkillSlot.Skill).ItemID, out var value);
					value = (int)Math.Round((float)value * 1.25f);
					_display.FocusedSkillSlot.m_requiredMoney = value;
				}
			}
		}

		private const string LogSignature_A = "chosen.objective.a";

		private const string LogSignature_B = "chosen.objective.b";

		private const string LogSignature_C = "chosen.objective.c";

		private QuestEventSignature QE_FixedLimitlessStart;

		private static int maxBreakthroughs = 4;

		public static Dictionary<int, int> StoredCosts = new Dictionary<int, int>();

		public override ScenarioQuest Type => ScenarioQuest.Quest_ChosenOne;

		public override ScenarioType Difficulty => ScenarioType.Normal;

		public override ScenarioPassives Passive => ScenarioPassives.ChosenOne;

		public override AreaEnum SpawnScene => (AreaEnum)101;

		public override Vector3 SpawnPosition => new Vector3(865.8f, 212.7f, 880.1f);

		public override Vector3 SpawnRotation => new Vector3(0f, 225.7f, 0f);

		public override bool HasQuest => true;

		public override string QuestName => "Angelic Descend";

		public override Dictionary<string, string> QuestLogSignatures => new Dictionary<string, string>
		{
			{ "chosen.objective.a", "Visit any city. Learn about the factions and their conflicts. Save Aurai." },
			{ "chosen.objective.b", "You've learned about the factions." },
			{ "chosen.objective.c", "You are ready to join a faction." }
		};

		public override void Gear(Character character)
		{
			character.Inventory.ReceiveItemReward(4100550, 5, false);
			character.Inventory.ReceiveItemReward(3000009, 1, true);
			character.Inventory.ReceiveItemReward(3000002, 1, true);
			character.Inventory.ReceiveItemReward(2010050, 1, false);
			character.Inventory.ReceiveItemReward(5100500, 1, true);
			character.Inventory.ReceiveItemReward(5300040, 1, true);
		}

		public override void Init()
		{
			base.Init();
			QE_FixedLimitlessStart = CustomQuests.CreateQuestEvent("iggythemad.chosenone.fixedstart", false, true, true, "A_Iggy_AlternateStart", "CustomEvent", "A custom event created with SideLoader");
			SL.OnGameplayResumedAfterLoading += SL_OnGameplayResumedAfterLoading;
		}

		private void SL_OnGameplayResumedAfterLoading()
		{
			if (!PhotonNetwork.isNonMasterClientInRoom && base.IsActiveScenario)
			{
				Character worldHostCharacter = CharacterManager.Instance.GetWorldHostCharacter();
				if (((CharacterKnowledge)worldHostCharacter.Inventory.QuestKnowledge).IsItemLearned((int)Type))
				{
					Item itemFromItemID = ((CharacterKnowledge)worldHostCharacter.Inventory.QuestKnowledge).GetItemFromItemID((int)Type);
					Quest quest = (Quest)(object)((itemFromItemID is Quest) ? itemFromItemID : null);
					UpdateQuestProgress(quest);
				}
			}
		}

		public override void UpdateQuestProgress(Quest quest)
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			if (!PhotonNetwork.isNonMasterClientInRoom && base.IsActiveScenario)
			{
				CharacterManager.Instance.GetWorldHostCharacter();
				int eventCurrentStack = QuestEventManager.Instance.GetEventCurrentStack(QE_FixedLimitlessStart.EventUID);
				QuestProgress questProgress = quest.m_questProgress;
				if (eventCurrentStack < 1)
				{
					QuestEventManager.Instance.AddEvent(QE_FixedLimitlessStart, 1);
					eventCurrentStack = QuestEventManager.Instance.GetEventCurrentStack(QE_FixedLimitlessStart.EventUID);
					questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("chosen.objective.a")), displayTime: true);
					ShowUIMessage("The world needs me. I should find about the troubles of Aurai...");
				}
				else if (eventCurrentStack < 2 && AreaManager.Instance.GetIsCurrentAreaTownOrCity())
				{
					QuestEventManager.Instance.AddEvent(QE_FixedLimitlessStart, 2);
					questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("chosen.objective.b")), displayTime: true);
					questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("chosen.objective.c")), displayTime: true);
					questProgress.DisableQuest((ProgressState)3);
					VanillaQuestsHelper.SkipHostToFactionChoice(keepHouse: false, complete: true);
					ShowUIMessage("Time to learn about the people of Aurai. I will join them!");
				}
			}
		}

		public override void OnScenarioChosen()
		{
		}

		public override void OnScenarioChosen(Character character)
		{
		}

		public override void OnStartSpawn()
		{
			GetOrGiveQuestToHost();
		}

		public override void OnStartSpawn(Character character)
		{
			character.SpellCastAnim((SpellCastType)41, (SpellCastModifier)0, 0);
		}
	}
	public class ClaustroScenario : Scenario
	{
		[HarmonyPatch(typeof(CharacterInventory), "EquipItem", new Type[]
		{
			typeof(Equipment),
			typeof(bool)
		})]
		public class CharacterInventory_EquipItem
		{
			[HarmonyPrefix]
			public static void Postfix(CharacterInventory __instance, Equipment _itemToEquip, bool _playAnim, ref Character ___m_character)
			{
				Character val = ___m_character;
				if (!((Object)(object)___m_character == (Object)null) && ___m_character.IsLocalPlayer && ((CharacterKnowledge)val.Inventory.SkillKnowledge).IsItemLearned(-2210))
				{
					((MonoBehaviour)Plugin.Instance).StartCoroutine(Instance.checkHelmet(val));
				}
			}
		}

		[HarmonyPatch(typeof(CharacterInventory), "TakeItem", new Type[]
		{
			typeof(Item),
			typeof(bool)
		})]
		public class CharacterInventory_TakeItem
		{
			[HarmonyPrefix]
			public static void Prefix(CharacterInventory __instance, Item takenItem, ref bool _tryToEquip, ref Character ___m_character)
			{
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				Character val = ___m_character;
				if (!((Object)(object)val == (Object)null) && val.IsLocalPlayer)
				{
					Equipment val2 = (Equipment)(object)((!(takenItem is Equipment)) ? null : ((takenItem is Equipment) ? takenItem : null));
					if (((CharacterKnowledge)val.Inventory.SkillKnowledge).IsItemLearned(-2210) && val2 != null && (int)val2.EquipSlot == 0)
					{
						_tryToEquip = false;
					}
				}
			}
		}

		[HarmonyPatch(typeof(CharacterInventory), "UnequipItem", new Type[]
		{
			typeof(Equipment),
			typeof(bool)
		})]
		public class CharacterInventory_UnequipItem
		{
			[HarmonyPrefix]
			public static void Postfix(CharacterInventory __instance, Equipment _itemToUnequip, bool _playAnim, ref Character ___m_character)
			{
				Character val = ___m_character;
				if (!((Object)(object)___m_character == (Object)null) && ___m_character.IsLocalPlayer && ((CharacterKnowledge)val.Inventory.SkillKnowledge).IsItemLearned(-2210))
				{
					((MonoBehaviour)Plugin.Instance).StartCoroutine(Instance.checkHelmet(val));
				}
			}
		}

		[HarmonyPatch(typeof(CharacterKnowledge), "AddItem")]
		public class CharacterKnowledge_AddItem
		{
			[HarmonyPrefix]
			public static void Prefix(CharacterKnowledge __instance, Item _item, ref Character ___m_character)
			{
				Character val = ___m_character;
				if (!((Object)(object)val == (Object)null) && val.IsLocalPlayer && ((CharacterKnowledge)val.Inventory.SkillKnowledge).IsItemLearned(-2210))
				{
					((MonoBehaviour)Plugin.Instance).StartCoroutine(Instance.checkHelmet(val));
				}
			}
		}

		private const string LogSignature_A = "claustro.objective.a";

		private const string LogSignature_B = "claustro.objective.b";

		private const string LogSignature_C = "claustro.objective.c";

		private QuestEventSignature QE_FixedClaustroStart;

		private string claustroEffectID = "claustroEffect";

		public override ScenarioQuest Type => ScenarioQuest.Quest_Claustro;

		public override ScenarioType Difficulty => ScenarioType.Normal;

		public override ScenarioPassives Passive => ScenarioPassives.Claustrophobic;

		public override AreaEnum SpawnScene => (AreaEnum)550;

		public override Vector3 SpawnPosition => new Vector3(1499.7f, -8.9f, 54.7f);

		public override Vector3 SpawnRotation => new Vector3(0f, 99.8f, 0f);

		public override bool HasQuest => true;

		public override string QuestName => "Kidnap Miracle";

		public override Dictionary<string, string> QuestLogSignatures => new Dictionary<string, string>
		{
			{ "claustro.objective.a", "Escape before your kidnappers return." },
			{ "claustro.objective.b", "Reach somewhere safe. A city perhaps." },
			{ "claustro.objective.c", "You are ready to join a faction." }
		};

		internal static ClaustroScenario Instance { get; private set; }

		public override void Gear(Character character)
		{
			character.Stats.FullStamina();
			character.Inventory.ReceiveItemReward(3000081, 1, true);
			character.Inventory.ReceiveItemReward(3000083, 1, true);
			character.Inventory.ReceiveItemReward(3000086, 1, true);
		}

		public override void Init()
		{
			base.Init();
			QE_FixedClaustroStart = CustomQuests.CreateQuestEvent("iggythemad.claustro.fixedstart", false, true, true, "A_Iggy_AlternateStart", "CustomEvent", "A custom event created with SideLoader");
			SL.OnGameplayResumedAfterLoading += SL_OnGameplayResumedAfterLoading;
		}

		private void SL_OnGameplayResumedAfterLoading()
		{
			if (!PhotonNetwork.isNonMasterClientInRoom && base.IsActiveScenario)
			{
				Character worldHostCharacter = CharacterManager.Instance.GetWorldHostCharacter();
				if (((CharacterKnowledge)worldHostCharacter.Inventory.QuestKnowledge).IsItemLearned((int)Type))
				{
					Item itemFromItemID = ((CharacterKnowledge)worldHostCharacter.Inventory.QuestKnowledge).GetItemFromItemID((int)Type);
					Quest quest = (Quest)(object)((itemFromItemID is Quest) ? itemFromItemID : null);
					UpdateQuestProgress(quest);
				}
			}
		}

		public override void UpdateQuestProgress(Quest quest)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			if (PhotonNetwork.isNonMasterClientInRoom || !base.IsActiveScenario)
			{
				return;
			}
			int num = 3;
			int eventCurrentStack = QuestEventManager.Instance.GetEventCurrentStack(QE_FixedClaustroStart.EventUID);
			QuestProgress questProgress = quest.m_questProgress;
			if (eventCurrentStack >= num)
			{
				questProgress.DisableQuest((ProgressState)3);
				return;
			}
			if (eventCurrentStack < 1)
			{
				QuestEventManager.Instance.AddEvent(QE_FixedClaustroStart, 1);
				eventCurrentStack = QuestEventManager.Instance.GetEventCurrentStack(QE_FixedClaustroStart.EventUID);
				questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("claustro.objective.a")), displayTime: true);
				ShowUIMessage("Something happened... this is my chance to escape.");
			}
			else if (eventCurrentStack < 2)
			{
				QuestEventManager.Instance.AddEvent(QE_FixedClaustroStart, 1);
				questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("claustro.objective.b")), displayTime: false);
				ShowUIMessage("I should go somewhere safe...");
			}
			if (eventCurrentStack < 3 && AreaManager.Instance.GetIsCurrentAreaTownOrCity())
			{
				QuestEventManager.Instance.AddEvent(QE_FixedClaustroStart, 2);
				questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("claustro.objective.b")), displayTime: true);
				questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("claustro.objective.c")), displayTime: true);
				questProgress.DisableQuest((ProgressState)3);
				VanillaQuestsHelper.SkipHostToFactionChoice(keepHouse: false, complete: true);
				ShowUIMessage("It would be safer to join a faction...");
			}
			ReloadLogs(eventCurrentStack, questProgress);
		}

		public void ReloadLogs(int stack, QuestProgress progress)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			foreach (KeyValuePair<string, string> questLogSignature in QuestLogSignatures)
			{
				if (num < stack && questLogSignature.Key != null)
				{
					Debug.Log((object)("log: " + questLogSignature.Key));
					progress.UpdateLogEntry(progress.GetLogSignature(UID.op_Implicit(questLogSignature.Key)), displayTime: false);
					num++;
				}
			}
		}

		public override void OnScenarioChosen(Character character)
		{
		}

		public override void OnStartSpawn()
		{
			GetOrGiveQuestToHost();
		}

		public override void OnStartSpawn(Character character)
		{
		}

		public ClaustroScenario()
		{
			Instance = this;
		}

		private IEnumerator checkHelmet(Character player)
		{
			player.StatusEffectMngr.RemoveStatusWithIdentifierName(claustroEffectID);
			yield return (object)new WaitForSeconds(0.5f);
			player.StatusEffectMngr.AddStatusEffect(claustroEffectID);
		}
	}
	public class ConfluxWatcherScenario : Scenario
	{
		private const string LogSignature_A = "watcher.objective.a";

		private const string LogSignature_B = "watcher.objective.b";

		private const string LogSignature_C = "watcher.objective.c";

		private QuestEventSignature QE_FixedWatcherStart;

		public override ScenarioQuest Type => ScenarioQuest.Quest_ConfluxWatcher;

		public override ScenarioType Difficulty => ScenarioType.Normal;

		public override ScenarioPassives Passive => ScenarioPassives.ConfluxWatcher;

		public override AreaEnum SpawnScene => (AreaEnum)106;

		public override Vector3 SpawnPosition => new Vector3(-435.2f, -19.1f, -96.5f);

		public override Vector3 SpawnRotation => new Vector3(0f, 172.4f, 0f);

		public override bool HasQuest => true;

		public override string QuestName => "Thy watch has ended";

		public override Dictionary<string, string> QuestLogSignatures => new Dictionary<string, string>
		{
			{ "watcher.objective.a", "Get out into the world." },
			{ "watcher.objective.b", "Visit the nearby village of Cierzo." },
			{ "watcher.objective.c", "You are again part of the world." }
		};

		public override void Gear(Character character)
		{
			character.Inventory.ReceiveSkillReward(8200040);
			character.Inventory.ReceiveSkillReward(8100220);
			character.Inventory.ReceiveSkillReward(8100230);
			character.Stats.SetManaPoint(3);
			character.Inventory.ReceiveItemReward(3000134, 1, true);
			character.Inventory.ReceiveItemReward(3000131, 1, true);
			character.Inventory.ReceiveItemReward(3000136, 1, true);
			character.Inventory.ReceiveItemReward(5100500, 1, true);
		}

		public override void Init()
		{
			base.Init();
			QE_FixedWatcherStart = CustomQuests.CreateQuestEvent("iggythemad.watcher.fixedstart", false, true, true, "A_Iggy_AlternateStart", "CustomEvent", "A custom event created with SideLoader");
			SL.OnGameplayResumedAfterLoading += SL_OnGameplayResumedAfterLoading;
		}

		private void SL_OnGameplayResumedAfterLoading()
		{
			if (!PhotonNetwork.isNonMasterClientInRoom && base.IsActiveScenario)
			{
				Character worldHostCharacter = CharacterManager.Instance.GetWorldHostCharacter();
				if (((CharacterKnowledge)worldHostCharacter.Inventory.QuestKnowledge).IsItemLearned((int)Type))
				{
					Item itemFromItemID = ((CharacterKnowledge)worldHostCharacter.Inventory.QuestKnowledge).GetItemFromItemID((int)Type);
					Quest quest = (Quest)(object)((itemFromItemID is Quest) ? itemFromItemID : null);
					UpdateQuestProgress(quest);
				}
			}
		}

		public override void UpdateQuestProgress(Quest quest)
		{
			//IL_006e: 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_0104: 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)
			if (PhotonNetwork.isNonMasterClientInRoom || !base.IsActiveScenario)
			{
				return;
			}
			int num = 3;
			int eventCurrentStack = QuestEventManager.Instance.GetEventCurrentStack(QE_FixedWatcherStart.EventUID);
			QuestProgress questProgress = quest.m_questProgress;
			if (eventCurrentStack >= num)
			{
				questProgress.DisableQuest((ProgressState)3);
				return;
			}
			if (eventCurrentStack < 1)
			{
				QuestEventManager.Instance.AddEvent(QE_FixedWatcherStart, 1);
				eventCurrentStack = QuestEventManager.Instance.GetEventCurrentStack(QE_FixedWatcherStart.EventUID);
				questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("watcher.objective.a")), displayTime: true);
				ShowUIMessage("My watch is over. The world might need me.");
			}
			else if (eventCurrentStack < 2 && SceneManagerHelper.ActiveSceneName == "ChersoneseNewTerrain")
			{
				QuestEventManager.Instance.AddEvent(QE_FixedWatcherStart, 1);
				questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("watcher.objective.b")), displayTime: false);
				ShowUIMessage("There used to be a village nearby...Cierzo, is it?");
			}
			if (eventCurrentStack < 3 && SceneManagerHelper.ActiveSceneName == "CierzoNewTerrain")
			{
				QuestEventManager.Instance.AddEvent(QE_FixedWatcherStart, 2);
				questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("watcher.objective.b")), displayTime: true);
				questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("watcher.objective.c")), displayTime: true);
				questProgress.DisableQuest((ProgressState)3);
				VanillaQuestsHelper.SkipHostToFactionChoice(keepHouse: false, complete: false);
				ShowUIMessage("I should ask around...");
			}
			ReloadLogs(eventCurrentStack, questProgress);
		}

		public void ReloadLogs(int stack, QuestProgress progress)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			foreach (KeyValuePair<string, string> questLogSignature in QuestLogSignatures)
			{
				if (num < stack && questLogSignature.Key != null)
				{
					Debug.Log((object)("log: " + questLogSignature.Key));
					progress.UpdateLogEntry(progress.GetLogSignature(UID.op_Implicit(questLogSignature.Key)), displayTime: false);
					num++;
				}
			}
		}

		public override void OnScenarioChosen()
		{
		}

		public override void OnStartSpawn()
		{
			GetOrGiveQuestToHost();
		}

		public override void OnStartSpawn(Character character)
		{
		}

		public override void OnScenarioChosen(Character character)
		{
		}
	}
	public class CorruptedScenario : Scenario
	{
		[HarmonyPatch(typeof(PlayerCharacterStats), "AffectCorruptionLevel", new Type[]
		{
			typeof(float),
			typeof(bool)
		})]
		public class PlayerCharacterStats_AffectCorruptionLevel
		{
			[HarmonyPrefix]
			public static bool Prefix(PlayerCharacterStats __instance, float _corruptionValue, bool _affectedByResistance, ref Character ___m_character)
			{
				if ((Object)(object)__instance == (Object)null)
				{
					return true;
				}
				if (!((CharacterStats)__instance).m_character.IsLocalPlayer)
				{
					return true;
				}
				if (((CharacterKnowledge)((CharacterStats)__instance).m_character.Inventory.SkillKnowledge).IsItemLearned(-2218))
				{
					__instance.m_corruptionLevel = 900f;
					return false;
				}
				return true;
			}
		}

		private const string LogSignature_A = "corrupted.objective.a";

		private const string LogSignature_B = "corrupted.objective.b";

		private const string LogSignature_C = "corrupted.objective.c";

		private QuestEventSignature QE_FixedCorruptedStart;

		public override ScenarioQuest Type => ScenarioQuest.Quest_CorruptedSoul;

		public override ScenarioType Difficulty => ScenarioType.Normal;

		public override ScenarioPassives Passive => ScenarioPassives.CorruptedSoul;

		public override AreaEnum SpawnScene => (AreaEnum)108;

		public override Vector3 SpawnPosition => new Vector3(-37.3f, -7f, -126.4f);

		public override Vector3 SpawnRotation => new Vector3(0f, 222.9f, 0f);

		public override bool HasQuest => true;

		public override string QuestName => "Corruption Reborn";

		public override Dictionary<string, string> QuestLogSignatures => new Dictionary<string, string>
		{
			{ "corrupted.objective.a", "Whatever happend to you. Find a way out. " },
			{ "corrupted.objective.b", "Head to a nearby settlement" },
			{ "corrupted.objective.c", "You are ready to join a faction." }
		};

		internal static CorruptedScenario Instance { get; private set; }

		public override void Gear(Character character)
		{
			character.Inventory.ReceiveItemReward(3000044, 1, true);
			character.Inventory.ReceiveItemReward(3000046, 1, true);
			character.Inventory.ReceiveItemReward(2150001, 1, false);
			character.Inventory.ReceiveItemReward(5100060, 1, true);
			character.Stats.SetManaPoint(1);
			character.Inventory.ReceiveSkillReward(8200040);
			character.Inventory.ReceiveSkillReward(8201000);
		}

		public override void Init()
		{
			base.Init();
			QE_FixedCorruptedStart = CustomQuests.CreateQuestEvent("iggythemad.corrupted.fixedstart", false, true, true, "A_Iggy_AlternateStart", "CustomEvent", "A custom event created with SideLoader");
			SL.OnGameplayResumedAfterLoading += SL_OnGameplayResumedAfterLoading;
		}

		private void SL_OnGameplayResumedAfterLoading()
		{
			foreach (Character value in CharacterManager.Instance.Characters.Values)
			{
				if (value.IsLocalPlayer && ((CharacterKnowledge)value.Inventory.SkillKnowledge).IsItemLearned(-2218) && value.PlayerStats.Corruption < 900f)
				{
					value.PlayerStats.AffectCorruptionLevel(900f, false);
				}
			}
			Character worldHostCharacter = CharacterManager.Instance.GetWorldHostCharacter();
			if (((CharacterKnowledge)worldHostCharacter.Inventory.QuestKnowledge).IsItemLearned((int)Type))
			{
				Item itemFromItemID = ((CharacterKnowledge)worldHostCharacter.Inventory.QuestKnowledge).GetItemFromItemID((int)Type);
				Quest quest = (Quest)(object)((itemFromItemID is Quest) ? itemFromItemID : null);
				UpdateQuestProgress(quest);
			}
		}

		public override void UpdateQuestProgress(Quest quest)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			if (PhotonNetwork.isNonMasterClientInRoom || !base.IsActiveScenario)
			{
				return;
			}
			int num = 3;
			int eventCurrentStack = QuestEventManager.Instance.GetEventCurrentStack(QE_FixedCorruptedStart.EventUID);
			QuestProgress questProgress = quest.m_questProgress;
			if (eventCurrentStack >= num)
			{
				questProgress.DisableQuest((ProgressState)3);
				return;
			}
			if (eventCurrentStack < 1)
			{
				QuestEventManager.Instance.AddEvent(QE_FixedCorruptedStart, 1);
				eventCurrentStack = QuestEventManager.Instance.GetEventCurrentStack(QE_FixedCorruptedStart.EventUID);
				questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("corrupted.objective.a")), displayTime: true);
				ShowUIMessage("What... Where am I?");
			}
			else if (eventCurrentStack < 2)
			{
				QuestEventManager.Instance.AddEvent(QE_FixedCorruptedStart, 1);
				questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("corrupted.objective.b")), displayTime: false);
				ShowUIMessage("I should find others... Living, preferably.");
			}
			if (eventCurrentStack < 3 && AreaManager.Instance.GetIsCurrentAreaTownOrCity())
			{
				QuestEventManager.Instance.AddEvent(QE_FixedCorruptedStart, 2);
				questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("corrupted.objective.b")), displayTime: true);
				questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("corrupted.objective.c")), displayTime: true);
				questProgress.DisableQuest((ProgressState)3);
				VanillaQuestsHelper.SkipHostToFactionChoice(keepHouse: false, complete: true);
				ShowUIMessage("I'm somehow back to life. I should do something with it.");
			}
			ReloadLogs(eventCurrentStack, questProgress);
		}

		public void ReloadLogs(int stack, QuestProgress progress)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			foreach (KeyValuePair<string, string> questLogSignature in QuestLogSignatures)
			{
				if (num < stack && questLogSignature.Key != null)
				{
					Debug.Log((object)("log: " + questLogSignature.Key));
					progress.UpdateLogEntry(progress.GetLogSignature(UID.op_Implicit(questLogSignature.Key)), displayTime: false);
					num++;
				}
			}
		}

		public override void OnScenarioChosen()
		{
		}

		public override void OnStartSpawn()
		{
			GetOrGiveQuestToHost();
		}

		public override void OnScenarioChosen(Character character)
		{
		}

		public override void OnStartSpawn(Character character)
		{
		}

		public CorruptedScenario()
		{
			Instance = this;
		}
	}
	public class EnmerkarHunterScenario : Scenario
	{
		[HarmonyPatch(typeof(LocalCharacterControl), "DetectMovementInputs")]
		public class LocalCharacterControl_DetectMovementInputs
		{
			[HarmonyPostfix]
			public static void Postfix(LocalCharacterControl __instance, ref Character ___m_character)
			{
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)__instance == (Object)null) && ((CharacterControl)__instance).Character.IsLocalPlayer && ((CharacterKnowledge)((CharacterControl)__instance).Character.Inventory.SkillKnowledge).IsItemLearned(-2208) && ((CharacterControl)__instance).Character.CurrentlyChargingAttack)
				{
					((CharacterControl)__instance).m_moveInput = ((CharacterControl)__instance).m_moveInput * new Vector2(0.3f, 0.3f);
					__instance.m_modifMoveInput = Vector2.op_Implicit(Vector2.op_Implicit(__instance.m_modifMoveInput) * new Vector2(0.6f, 0.6f));
					((MonoBehaviour)Plugin.Instance).StartCoroutine(Instance.checkBowDraw(((CharacterControl)__instance).Character));
				}
			}
		}

		[HarmonyPatch(typeof(CharacterInventory), "EquipItem", new Type[]
		{
			typeof(Equipment),
			typeof(bool)
		})]
		public class CharacterInventory_EquipItem
		{
			[HarmonyPrefix]
			public static void Postfix(CharacterInventory __instance, Equipment _itemToEquip, bool _playAnim, ref Character ___m_character)
			{
				Character val = ___m_character;
				if (!((Object)(object)val == (Object)null) && val.IsLocalPlayer && ((CharacterKnowledge)val.Inventory.SkillKnowledge).IsItemLearned(-2208))
				{
					((MonoBehaviour)Plugin.Instance).StartCoroutine(Instance.checkBow(val));
				}
			}
		}

		[HarmonyPatch(typeof(CharacterInventory), "UnequipItem", new Type[]
		{
			typeof(Equipment),
			typeof(bool)
		})]
		public class CharacterInventory_UnequipItem
		{
			[HarmonyPrefix]
			public static void Postfix(CharacterInventory __instance, Equipment _itemToUnequip, bool _playAnim, ref Character ___m_character)
			{
				Character val = ___m_character;
				if (!((Object)(object)val == (Object)null) && val.IsLocalPlayer && ((CharacterKnowledge)val.Inventory.SkillKnowledge).IsItemLearned(-2208))
				{
					((MonoBehaviour)Plugin.Instance).StartCoroutine(Instance.checkBow(val));
				}
			}
		}

		[HarmonyPatch(typeof(CharacterKnowledge), "AddItem")]
		public class CharacterKnowledge_AddItem
		{
			[HarmonyPrefix]
			public static void Prefix(CharacterKnowledge __instance, Item _item, ref Character ___m_character)
			{
				Character val = ___m_character;
				if (!((Object)(object)val == (Object)null) && val.IsLocalPlayer && ((CharacterKnowledge)val.Inventory.SkillKnowledge).IsItemLearned(-2208))
				{
					((MonoBehaviour)Plugin.Instance).StartCoroutine(Instance.checkBow(val));
				}
			}
		}

		private const string LogSignature_A = "hunter.objective.a";

		private const string LogSignature_B = "hunter.objective.b";

		private const string LogSignature_C = "hunter.objective.c";

		private QuestEventSignature QE_FixedHunterStart;

		private string bowmanEffect = "bowmanEffect";

		public override ScenarioQuest Type => ScenarioQuest.Quest_EmercarHunter;

		public override ScenarioType Difficulty => ScenarioType.Normal;

		public override ScenarioPassives Passive => ScenarioPassives.EnmerkarHunter;

		public override AreaEnum SpawnScene => (AreaEnum)550;

		public override Vector3 SpawnPosition => new Vector3(600.6f, 0.8f, 8.1f);

		public override Vector3 SpawnRotation => new Vector3(0f, 29.3f, 0f);

		public override bool HasQuest => true;

		public override string QuestName => "A Good Hunt";

		public override Dictionary<string, string> QuestLogSignatures => new Dictionary<string, string>
		{
			{ "hunter.objective.a", "Leave your hut." },
			{ "hunter.objective.b", "Go to any city to sell your goods." },
			{ "hunter.objective.c", "You are ready to join a faction." }
		};

		internal static EnmerkarHunterScenario Instance { get; private set; }

		public override void Gear(Character character)
		{
			character.Inventory.ReceiveItemReward(9000010, 13, false);
			character.Inventory.ReceiveItemReward(3000020, 1, true);
			character.Inventory.ReceiveItemReward(3000022, 1, true);
			character.Inventory.ReceiveItemReward(2200000, 1, false);
			character.Inventory.ReceiveItemReward(5200001, 30, true);
			character.Inventory.ReceiveItemReward(4000060, 4, false);
		}

		public override void Init()
		{
			base.Init();
			QE_FixedHunterStart = CustomQuests.CreateQuestEvent("iggythemad.hunter.fixedstart", false, true, true, "A_Iggy_AlternateStart", "CustomEvent", "A custom event created with SideLoader");
			SL.OnGameplayResumedAfterLoading += SL_OnGameplayResumedAfterLoading;
		}

		private void SL_OnGameplayResumedAfterLoading()
		{
			if (!PhotonNetwork.isNonMasterClientInRoom && base.IsActiveScenario)
			{
				Character worldHostCharacter = CharacterManager.Instance.GetWorldHostCharacter();
				if (((CharacterKnowledge)worldHostCharacter.Inventory.QuestKnowledge).IsItemLearned((int)Type))
				{
					Item itemFromItemID = ((CharacterKnowledge)worldHostCharacter.Inventory.QuestKnowledge).GetItemFromItemID((int)Type);
					Quest quest = (Quest)(object)((itemFromItemID is Quest) ? itemFromItemID : null);
					UpdateQuestProgress(quest);
				}
			}
		}

		public override void UpdateQuestProgress(Quest quest)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			if (PhotonNetwork.isNonMasterClientInRoom || !base.IsActiveScenario)
			{
				return;
			}
			int num = 3;
			int eventCurrentStack = QuestEventManager.Instance.GetEventCurrentStack(QE_FixedHunterStart.EventUID);
			QuestProgress questProgress = quest.m_questProgress;
			if (eventCurrentStack >= num)
			{
				questProgress.DisableQuest((ProgressState)3);
				return;
			}
			if (eventCurrentStack < 1)
			{
				QuestEventManager.Instance.AddEvent(QE_FixedHunterStart, 1);
				eventCurrentStack = QuestEventManager.Instance.GetEventCurrentStack(QE_FixedHunterStart.EventUID);
				questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("hunter.objective.a")), displayTime: true);
				ShowUIMessage("Today's was a good hunt...");
			}
			else if (eventCurrentStack < 2)
			{
				QuestEventManager.Instance.AddEvent(QE_FixedHunterStart, 1);
				questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("hunter.objective.b")), displayTime: false);
				ShowUIMessage("I should sell my goods in the city...");
			}
			if (eventCurrentStack < 3 && AreaManager.Instance.GetIsCurrentAreaTownOrCity())
			{
				QuestEventManager.Instance.AddEvent(QE_FixedHunterStart, 2);
				questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("hunter.objective.b")), displayTime: true);
				questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("hunter.objective.c")), displayTime: true);
				questProgress.DisableQuest((ProgressState)3);
				VanillaQuestsHelper.SkipHostToFactionChoice(keepHouse: false, complete: true);
				ShowUIMessage("Huh... Should I join a faction?");
			}
			ReloadLogs(eventCurrentStack, questProgress);
		}

		public void ReloadLogs(int stack, QuestProgress progress)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			foreach (KeyValuePair<string, string> questLogSignature in QuestLogSignatures)
			{
				if (num < stack && questLogSignature.Key != null)
				{
					Debug.Log((object)("log: " + questLogSignature.Key));
					progress.UpdateLogEntry(progress.GetLogSignature(UID.op_Implicit(questLogSignature.Key)), displayTime: false);
					num++;
				}
			}
		}

		public override void OnScenarioChosen()
		{
		}

		public override void OnScenarioChosen(Character character)
		{
		}

		public override void OnStartSpawn()
		{
			GetOrGiveQuestToHost();
		}

		public override void OnStartSpawn(Character character)
		{
			character.Inventory.ReceiveSkillReward(8205160);
		}

		public EnmerkarHunterScenario()
		{
			Instance = this;
		}

		private IEnumerator checkBowDraw(Character player)
		{
			player.Animator.speed = 2.2f;
			while (player.CurrentlyChargingAttack)
			{
				yield return (object)new WaitForSeconds(0.1f);
			}
			player.Animator.speed = 1f;
		}

		private IEnumerator checkBow(Character player)
		{
			player.StatusEffectMngr.RemoveStatusWithIdentifierName(bowmanEffect);
			yield return (object)new WaitForSeconds(0.5f);
			if ((int)player.CurrentWeapon.Type != 200)
			{
				player.StatusEffectMngr.AddStatusEffect(bowmanEffect);
			}
		}
	}
	public class GiantRisenScenario : Scenario
	{
		[HarmonyPatch(typeof(Character), "DodgeInput", new Type[] { typeof(Vector3) })]
		public class Character_DodgeInput
		{
			[HarmonyPostfix]
			public static void Postfix(Character __instance, Vector3 _direction)
			{
				if (__instance.IsLocalPlayer && ((CharacterKnowledge)__instance.Inventory.SkillKnowledge).IsItemLearned(-2212) && !__instance.DodgeRestricted)
				{
					((MonoBehaviour)Plugin.Instance).StartCoroutine(Instance.DodgeSlower(__instance));
				}
			}
		}

		private const string LogSignature_A = "giant.objective.a";

		private const string LogSignature_B = "giant.objective.b";

		private const string LogSignature_C = "giant.objective.c";

		private QuestEventSignature QE_FixedGiantRisenStart;

		public override ScenarioQuest Type => ScenarioQuest.Quest_GiantRisen;

		public override ScenarioType Difficulty => ScenarioType.Normal;

		public override ScenarioPassives Passive => ScenarioPassives.GiantRisen;

		public override AreaEnum SpawnScene => (AreaEnum)203;

		public override Vector3 SpawnPosition => default(Vector3);

		public override bool HasQuest => true;

		public override string QuestName => "Giant Mistake";

		public override Dictionary<string, string> QuestLogSignatures => new Dictionary<string, string>
		{
			{ "giant.objective.a", "The giants have disowned you! Run for your life!" },
			{ "giant.objective.b", "Find a new home..." },
			{ "giant.objective.c", "You are ready to join a faction." }
		};

		internal static GiantRisenScenario Instance { get; private set; }

		public override void Gear(Character character)
		{
			character.Inventory.ReceiveItemReward(3000221, 1, true);
			character.Inventory.ReceiveItemReward(3000220, 1, true);
			character.Inventory.ReceiveItemReward(3000222, 1, true);
			character.Inventory.ReceiveItemReward(2110000, 1, true);
		}

		public override void Init()
		{
			base.Init();
			QE_FixedGiantRisenStart = CustomQuests.CreateQuestEvent("iggythemad.giantrisen.fixedstart", false, true, true, "A_Iggy_AlternateStart", "CustomEvent", "A custom event created with SideLoader");
			SL.OnGameplayResumedAfterLoading += SL_OnGameplayResumedAfterLoading;
		}

		public override void OnScenarioChosen()
		{
		}

		public override void OnScenarioChosen(Character character)
		{
		}

		public override void OnStartSpawn()
		{
			GetOrGiveQuestToHost();
			VanillaQuestsHelper.AddQuestEvent("XqlcpbTJC0aTDZfjD4xCTg");
		}

		public override void OnStartSpawn(Character character)
		{
		}

		private void SL_OnGameplayResumedAfterLoading()
		{
			if (!PhotonNetwork.isNonMasterClientInRoom && base.IsActiveScenario)
			{
				Character worldHostCharacter = CharacterManager.Instance.GetWorldHostCharacter();
				if (((CharacterKnowledge)worldHostCharacter.Inventory.QuestKnowledge).IsItemLearned((int)Type))
				{
					Item itemFromItemID = ((CharacterKnowledge)worldHostCharacter.Inventory.QuestKnowledge).GetItemFromItemID((int)Type);
					Quest quest = (Quest)(object)((itemFromItemID is Quest) ? itemFromItemID : null);
					UpdateQuestProgress(quest);
				}
			}
		}

		public override void UpdateQuestProgress(Quest quest)
		{
			//IL_0058: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			if (PhotonNetwork.isNonMasterClientInRoom || !base.IsActiveScenario)
			{
				return;
			}
			int num = 3;
			int eventCurrentStack = QuestEventManager.Instance.GetEventCurrentStack(QE_FixedGiantRisenStart.EventUID);
			QuestProgress questProgress = quest.m_questProgress;
			if (eventCurrentStack >= num)
			{
				questProgress.DisableQuest((ProgressState)3);
				return;
			}
			if (eventCurrentStack < 1)
			{
				QuestEventManager.Instance.AddEvent(QE_FixedGiantRisenStart, 1);
				questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("giant.objective.a")), displayTime: true);
				ShowUIMessage("I've been exiled! I should flee!");
			}
			else if (eventCurrentStack < 2)
			{
				QuestEventManager.Instance.AddEvent(QE_FixedGiantRisenStart, 1);
				questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("giant.objective.b")), displayTime: false);
				ShowUIMessage("I need to find a new home...");
			}
			else if (eventCurrentStack < 3 && AreaManager.Instance.GetIsCurrentAreaTownOrCity())
			{
				QuestEventManager.Instance.AddEvent(QE_FixedGiantRisenStart, 1);
				questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("giant.objective.b")), displayTime: true);
				questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("giant.objective.c")), displayTime: true);
				questProgress.DisableQuest((ProgressState)3);
				VanillaQuestsHelper.RemoveEvent("oGkuUgWvfkej_El-rhz2gw");
				VanillaQuestsHelper.RemoveEvent("XqlcpbTJC0aTDZfjD4xCTg");
				VanillaQuestsHelper.RemoveEvent("nDy01eTHlUa_BPDlbIhZPQ");
				VanillaQuestsHelper.RemoveEvent("f1JVZyhg2UiBA8xmC-w6Hw");
				VanillaQuestsHelper.SkipHostToFactionChoice(keepHouse: false, complete: true);
				ShowUIMessage("Maybe I should join a new faction...");
			}
			ReloadLogs(eventCurrentStack, questProgress);
		}

		public void ReloadLogs(int stack, QuestProgress progress)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			foreach (KeyValuePair<string, string> questLogSignature in QuestLogSignatures)
			{
				if (num < stack && questLogSignature.Key != null)
				{
					Debug.Log((object)("log: " + questLogSignature.Key));
					progress.UpdateLogEntry(progress.GetLogSignature(UID.op_Implicit(questLogSignature.Key)), displayTime: false);
					num++;
				}
			}
		}

		public GiantRisenScenario()
		{
			Instance = this;
		}

		public IEnumerator DodgeSlower(Character _character)
		{
			if (_character.Dodging)
			{
				_character.Animator.speed = 0.6f;
				while (_character.Dodging)
				{
					yield return (object)new WaitForSeconds(0.2f);
				}
				yield return (object)new WaitForSeconds(0.2f);
				_character.Animator.speed = 1f;
			}
		}
	}
	public class LimitlessScenario : Scenario
	{
		private const string LogSignature_A = "unbound.objective.a";

		private const string LogSignature_B = "unbound.objective.b";

		private const string LogSignature_C = "unbound.objective.c";

		private QuestEventSignature QE_FixedUnboundStart;

		public int questTrigger;

		public override ScenarioQuest Type => ScenarioQuest.Quest_Unbound;

		public override ScenarioType Difficulty => ScenarioType.WIPtest;

		public override ScenarioPassives Passive => ScenarioPassives.Unbound;

		public override AreaEnum SpawnScene => (AreaEnum)501;

		public override Vector3 SpawnPosition => new Vector3(1053.8f, -32f, 1155.6f);

		public override Vector3 SpawnRotation => new Vector3(0f, 230.2f, 0f);

		public override bool HasQuest => true;

		public override string QuestName => "Unbound. Unlimited.";

		public override Dictionary<string, string> QuestLogSignatures => new Dictionary<string, string>
		{
			{ "unbound.objective.a", "You've unlocked your true potential. You are unbound. Find any trainer to learn from." },
			{ "unbound.objective.b", "Purchase your first skill. No restrictions. Choose wisely." },
			{ "unbound.objective.c", "You are ready to face the world. You are ready to join a faction." }
		};

		public override void Gear(Character character)
		{
			character.Inventory.AddMoney(37);
			character.Inventory.ReceiveItemReward(4100550, 3, false);
			character.Inventory.ReceiveItemReward(3000091, 1, true);
			character.Inventory.ReceiveItemReward(3000282, 1, true);
			character.Inventory.ReceiveItemReward(2160020, 1, false);
			character.Inventory.ReceiveItemReward(5110030, 1, false);
		}

		public override void Init()
		{
			base.Init();
			QE_FixedUnboundStart = CustomQuests.CreateQuestEvent("iggythemad.unbound.fixedstart", false, true, true, "A_Iggy_AlternateStart", "CustomEvent", "A custom event created with SideLoader");
			SL.OnGameplayResumedAfterLoading += SL_OnGameplayResumedAfterLoading;
		}

		private void SL_OnGameplayResumedAfterLoading()
		{
			if (!PhotonNetwork.isNonMasterClientInRoom && base.IsActiveScenario)
			{
				Character worldHostCharacter = CharacterManager.Instance.GetWorldHostCharacter();
				if (((CharacterKnowledge)worldHostCharacter.Inventory.QuestKnowledge).IsItemLearned((int)Type))
				{
					Item itemFromItemID = ((CharacterKnowledge)worldHostCharacter.Inventory.QuestKnowledge).GetItemFromItemID((int)Type);
					Quest quest = (Quest)(object)((itemFromItemID is Quest) ? itemFromItemID : null);
					UpdateQuestProgress(quest);
				}
			}
		}

		public override void UpdateQuestProgress(Quest quest)
		{
			//IL_006b: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
			if (!PhotonNetwork.isNonMasterClientInRoom && base.IsActiveScenario)
			{
				CharacterManager.Instance.GetWorldHostCharacter();
				int eventCurrentStack = QuestEventManager.Instance.GetEventCurrentStack(QE_FixedUnboundStart.EventUID);
				QuestProgress questProgress = quest.m_questProgress;
				if (eventCurrentStack < 1)
				{
					QuestEventManager.Instance.AddEvent(QE_FixedUnboundStart, 1);
					eventCurrentStack = QuestEventManager.Instance.GetEventCurrentStack(QE_FixedUnboundStart.EventUID);
					questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("unbound.objective.a")), displayTime: true);
					ShowUIMessage("I feel... free. Unbound. I need power!");
				}
				else if (eventCurrentStack < 2 && AreaManager.Instance.GetIsCurrentAreaTownOrCity())
				{
					QuestEventManager.Instance.AddEvent(QE_FixedUnboundStart, 1);
					questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("unbound.objective.b")), displayTime: true);
					ShowUIMessage("So many choices... I gotta choose wisely.");
				}
				else if (eventCurrentStack < 3 && questTrigger == 1)
				{
					QuestEventManager.Instance.AddEvent(QE_FixedUnboundStart, 2);
					questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("unbound.objective.c")), displayTime: true);
					questProgress.DisableQuest((ProgressState)3);
					VanillaQuestsHelper.SkipHostToFactionChoice(keepHouse: false, complete: true);
				}
				ReloadLogs(eventCurrentStack, questProgress);
			}
		}

		public void ReloadLogs(int stack, QuestProgress progress)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			foreach (KeyValuePair<string, string> questLogSignature in QuestLogSignatures)
			{
				if (num < stack && questLogSignature.Key != null)
				{
					Debug.Log((object)("log: " + questLogSignature.Key));
					progress.UpdateLogEntry(progress.GetLogSignature(UID.op_Implicit(questLogSignature.Key)), displayTime: false);
					num++;
				}
			}
		}

		public override void OnScenarioChosen()
		{
		}

		public override void OnScenarioChosen(Character character)
		{
		}

		public override void OnStartSpawn()
		{
			GetOrGiveQuestToHost();
		}

		public override void OnStartSpawn(Character character)
		{
		}
	}
	public class NightmareScenario : Scenario
	{
		[HarmonyPatch(typeof(InteractionTriggerBase), "TryActivateBasicAction", new Type[]
		{
			typeof(Character),
			typeof(int)
		})]
		public class InteractionTriggerBase_TryActivateBasicAction
		{
			[HarmonyPrefix]
			public static bool Prefix(InteractionTriggerBase __instance, Character _character, int _toggleState)
			{
				//IL_0090: 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_0074: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
				if (!Instance.IsActiveScenario || PhotonNetwork.isNonMasterClientInRoom || !Object.op_Implicit((Object)(object)_character) || SceneManagerHelper.ActiveSceneName != "Chersonese_Dungeon3")
				{
					return true;
				}
				EventActivator currentTriggerManager = __instance.CurrentTriggerManager;
				if (Object.op_Implicit((Object)(object)((currentTriggerManager is InteractionActivator) ? currentTriggerManager : null)))
				{
					EventActivator currentTriggerManager2 = __instance.CurrentTriggerManager;
					InteractionActivator val = (InteractionActivator)(object)((currentTriggerManager2 is InteractionActivator) ? currentTriggerManager2 : null);
					if (val.BasicInteraction != null)
					{
						IInteraction basicInteraction = val.BasicInteraction;
						if (basicInteraction is InteractionOpenContainer)
						{
							return false;
						}
						if ((basicInteraction is InteractionToggleContraption && Vector3.Distance(_character.CenterPosition, Instance.SpawnPosition) < 5f) || Vector3.Distance(_character.CenterPosition, Instance.lockedLever) < 5f)
						{
							_character.CharacterUI.ShowInfoNotification("The lever is stuck...");
							return false;
						}
						if (basicInteraction is InteractionSwitchArea && (!_character.Inventory.OwnsOrHasEquipped(Instance.keyID) || Vector3.Distance(_character.CenterPosition, Instance.lockedDoor) < 8f))
						{
							_character.CharacterUI.ShowInfoNotification("It is locked...");
							return false;
						}
					}
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(DefeatScenariosManager), "StartDefeat")]
		public class DefeatScenariosManager_StartDefeat
		{
			[HarmonyPrefix]
			public static bool Prefix(DefeatScenariosManager __instance)
			{
				if (!Instance.IsActiveScenario || PhotonNetwork.isNonMasterClientInRoom)
				{
					return true;
				}
				foreach (PlayerSystem item in Global.Lobby.PlayersInLobby)
				{
					item.ControlledCharacter.Resurrect();
				}
				NetworkLevelLoader.Instance.RequestSwitchArea(AreaManager.Instance.GetArea((AreaEnum)101).SceneName, 0, 1.5f, false);
				return false;
			}
		}

		private const string LogSignature_A = "ghostquest.objective.a";

		public int keyID = -2350;

		public string ghostlyTimerID = "GhostlyTimer";

		internal static NightmareScenario Instance { get; private set; }

		public override ScenarioQuest Type => ScenarioQuest.Quest_Vanilla;

		public override ScenarioType Difficulty => ScenarioType.WIPtest;

		public override ScenarioPassives Passive => ScenarioPassives.Nightmare;

		public override AreaEnum SpawnScene => (AreaEnum)105;

		public override Vector3 SpawnPosition => new Vector3(-29.4f, 0f, -40.9f);

		public override Vector3 SpawnRotation => new Vector3(0f, 182f, 0f);

		public override bool HasQuest => true;

		public override string QuestName => "Ghost Quest";

		public override Dictionary<string, string> QuestLogSignatures => new Dictionary<string, string> { { "ghostquest.objective.a", "This is a log entry" } };

		public Vector3 KeyPosition => new Vector3(10.2f, -53f, -70.2f);

		public Vector3 lockedLever => new Vector3(6.3f, 0f, -117f);

		public Vector3 lockedDoor => new Vector3(0.4f, 0f, -142f);

		public override void Gear(Character character)
		{
			character.Inventory.ReceiveItemReward(3000130, 1, true);
			character.Inventory.ReceiveItemReward(3000136, 1, true);
		}

		public NightmareScenario()
		{
			Instance = this;
		}

		public override void OnScenarioChosen()
		{
			VanillaQuestsHelper.StartHouseTimer();
		}

		public override void OnScenarioChosen(Character character)
		{
			character.ChangeFaction((Factions)5, true);
		}

		public override void OnStartSpawn()
		{
			//IL_0016: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			((Component)ItemManager.Instance.GenerateItemNetwork(keyID)).transform.position = KeyPosition;
			((Component)ItemManager.Instance.GenerateItemNetwork(5100070)).transform.position = SpawnPosition + new Vector3(0f, 1f, 0f);
		}

		public override void OnStartSpawn(Character character)
		{
			character.StatusEffectMngr.AddStatusEffect(ghostlyTimerID);
		}

		public override void UpdateQuestProgress(Quest quest)
		{
		}
	}
	public class PriestElattScenario : Scenario
	{
		[HarmonyPatch(typeof(Character), "ReceiveHit", new Type[]
		{
			typeof(Object),
			typeof(DamageList),
			typeof(Vector3),
			typeof(Vector3),
			typeof(float),
			typeof(float),
			typeof(Character),
			typeof(float),
			typeof(bool)
		})]
		public class Character_ReceiveHit
		{
			[HarmonyPrefix]
			public static void Prefix(Character __instance, Object _damageSource, ref DamageList _damage, Vector3 _hitDir, Vector3 _hitPoint, float _angle, float _angleDir, Character _dealerChar, float _knockBack, bool _hitInventory)
			{
				//IL_0036: 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_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Expected O, but got Unknown
				if (!((Object)(object)__instance == (Object)null) && !((Object)(object)_dealerChar == (Object)null) && _dealerChar.IsLocalPlayer && ((CharacterKnowledge)_dealerChar.Inventory.SkillKnowledge).IsItemLearned(-2209))
				{
					Types val = (Types)3;
					int num = 3;
					float num2 = _damage.TotalDamage * _dealerChar.Stats.m_totalDamageAttack[num];
					num2 -= num2 * Instance.holyNerf;
					_damage.Clear();
					_damage.Add(new DamageType(val, num2));
				}
			}
		}

		private float holyNerf = 0.25f;

		public override ScenarioQuest Type => ScenarioQuest.Quest_PriestElatt;

		public override ScenarioType Difficulty => ScenarioType.Normal;

		public override ScenarioPassives Passive => ScenarioPassives.PriestElatt;

		public override AreaEnum SpawnScene => (AreaEnum)200;

		public override Vector3 SpawnPosition => new Vector3(-175.2f, -1514.6f, 751.9f);

		public override Vector3 SpawnRotation => new Vector3(0f, 359f, 0f);

		public override bool HasQuest => false;

		public override string QuestName => "";

		public override Dictionary<string, string> QuestLogSignatures => new Dictionary<string, string>();

		internal static PriestElattScenario Instance { get; private set; }

		public override void Gear(Character character)
		{
			character.Inventory.ReceiveSkillReward(8100250);
			character.Inventory.ReceiveItemReward(9000010, 32, false);
			character.Inventory.ReceiveItemReward(3000071, 1, true);
			character.Inventory.ReceiveItemReward(3000070, 1, true);
			character.Inventory.ReceiveItemReward(3000174, 1, true);
			character.Inventory.ReceiveItemReward(2020010, 1, false);
			character.Inventory.ReceiveItemReward(5110030, 1, true);
		}

		public override void OnScenarioChosen()
		{
		}

		public override void OnScenarioChosen(Character character)
		{
		}

		public override void OnStartSpawn()
		{
			VanillaQuestsHelper.SkipHostToFactionChoice(keepHouse: false, complete: true);
		}

		public override void OnStartSpawn(Character character)
		{
		}

		public override void UpdateQuestProgress(Quest quest)
		{
		}

		public PriestElattScenario()
		{
			Instance = this;
		}
	}
	public class RobbedTraderScenario : Scenario
	{
		[HarmonyPatch(typeof(DefeatScenariosManager), "StartDefeat")]
		public class DefeatScenariosManager_StartDefeat
		{
			[HarmonyPrefix]
			public static bool Prefix(DefeatScenariosManager __instance)
			{
				if (!Instance.IsActiveScenario || PhotonNetwork.isNonMasterClientInRoom)
				{
					return true;
				}
				if (QuestEventManager.Instance.HasQuestEvent(QuestEventDictionary.GetQuestEvent("jNfNsLGBpk2iMRts9kkerw")))
				{
					return true;
				}
				foreach (PlayerSystem item in Global.Lobby.PlayersInLobby)
				{
					item.ControlledCharacter.Resurrect();
				}
				NetworkLevelLoader.Instance.RequestSwitchArea(AreaManager.Instance.GetArea((AreaEnum)101).SceneName, 0, 1.5f, false);
				return false;
			}
		}

		[HarmonyPatch(typeof(InteractionTriggerBase), "TryActivateBasicAction", new Type[]
		{
			typeof(Character),
			typeof(int)
		})]
		public class InteractionTriggerBase_TryActivateBasicAction
		{
			[HarmonyPrefix]
			public static bool Prefix(InteractionTriggerBase __instance, Character _character, int _toggleState)
			{
				//IL_0179: Unknown result type (might be due to invalid IL or missing references)
				//IL_0183: Unknown result type (might be due to invalid IL or missing references)
				//IL_0094: Unknown result type (might be due to invalid IL or missing references)
				//IL_009e: Unknown result type (might be due to invalid IL or missing references)
				//IL_010f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0119: Unknown result type (might be due to invalid IL or missing references)
				if (!Instance.IsActiveScenario || PhotonNetwork.isNonMasterClientInRoom || !Object.op_Implicit((Object)(object)_character))
				{
					return true;
				}
				if (!_character.IsLocalPlayer)
				{
					return true;
				}
				if (QuestEventManager.Instance.HasQuestEvent(QuestEventDictionary.GetQuestEvent("jNfNsLGBpk2iMRts9kkerw")))
				{
					return true;
				}
				EventActivator currentTriggerManager = __instance.CurrentTriggerManager;
				if (Object.op_Implicit((Object)(object)((currentTriggerManager is InteractionActivator) ? currentTriggerManager : null)))
				{
					EventActivator currentTriggerManager2 = __instance.CurrentTriggerManager;
					InteractionActivator val = (InteractionActivator)(object)((currentTriggerManager2 is InteractionActivator) ? currentTriggerManager2 : null);
					if (val.BasicInteraction != null)
					{
						IInteraction basicInteraction = val.BasicInteraction;
						if (SceneManagerHelper.ActiveSceneName == "CierzoNewTerrain")
						{
							if (basicInteraction is InteractionMerchantDialogue && Vector3.Distance(((Component)_character).transform.position, Instance.traderPosition) < 5f)
							{
								if (_character.Inventory.OwnsOrHasEquipped(-2353))
								{
									Instance.ShowUIMessage("I need to sell the goods before leaving.", instant: true);
								}
								else
								{
									VanillaQuestsHelper.SkipHostToFactionChoice(keepHouse: false, complete: true);
									NetworkLevelLoader.Instance.RequestSwitchArea(AreaManager.Instance.GetArea((AreaEnum)400).SceneName, 0, 1.5f, false);
								}
								return false;
							}
							if (basicInteraction is InteractionMerchantDialogue && Vector3.Distance(((Component)_character).transform.position, Instance.alchemistPosition) < 5f)
							{
								return true;
							}
							if (_character.Inventory.OwnsOrHasEquipped(-2353))
							{
								Instance.ShowUIMessage("I have no time for this...", instant: true);
							}
							else
							{
								Instance.ShowUIMessage("I should go back to harmattan...", instant: true);
							}
							return false;
						}
						if (SceneManagerHelper.ActiveSceneName == "ChersoneseNewTerrain")
						{
							if (Vector3.Distance(((Component)_character).transform.position, Instance.cierzoEntrance) < 5f)
							{
								return true;
							}
							Instance.ShowUIMessage("There is no time for this.", instant: true);
							return false;
						}
					}
				}
				return true;
			}
		}

		public string enemyID = "com.iggy.banditgeneric";

		public Vector3 traderPosition = new Vector3(1408.7f, 5.9f, 1663.8f);

		public Vector3 alchemistPosition = new Vector3(1384.9f, 7.8f, 1649.1f);

		public Vector3 chersoneseFailSpawn = new Vector3(181.5f, 32.6f, 1444.4f);

		public Vector3 cierzoEntrance = new Vector3(131.9f, 34.9f, 1461.7f);

		internal static RobbedTraderScenario Instance { get; private set; }

		public override ScenarioQuest Type => ScenarioQuest.Quest_RobbedTrader;

		public override ScenarioType Difficulty => ScenarioType.Normal;

		public override ScenarioPassives Passive => ScenarioPassives.RobbedTrader;

		public override AreaEnum SpawnScene => (AreaEnum)101;

		public override Vector3 SpawnPosition => new Vector3(300.3f, 37.3f, 1423.9f);

		public override Vector3 SpawnRotation => new Vector3(0f, 285.7f, 0f);

		public override bool HasQuest => false;

		public override string QuestName => "";

		public override Dictionary<string, string> QuestLogSignatures => new Dictionary<string, string>();

		public override void Gear(Character character)
		{
			character.Inventory.ReceiveItemReward(9000010, 56, false);
			character.Inventory.ReceiveItemReward(3000190, 1, true);
			character.Inventory.ReceiveItemReward(3000004, 1, true);
			character.Inventory.ReceiveItemReward(-2353, 1, true);
		}

		public override void Init()
		{
			base.Init();
			SL.OnGameplayResumedAfterLoading += SL_OnGameplayResumedAfterLoading;
		}

		public RobbedTraderScenario()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
		}

		public override void OnScenarioChosen()
		{
		}

		public override void OnScenarioChosen(Character character)
		{
		}

		public override void OnStartSpawn()
		{
		}

		public override void OnStartSpawn(Character character)
		{
			ShowUIMessage("I can see the lighthouse! Got to sell the goods in Cierzo!");
		}

		private void SL_OnGameplayResumedAfterLoading()
		{
			if (Instance.IsActiveScenario)
			{
				_ = PhotonNetwork.isNonMasterClientInRoom;
			}
		}

		public override void UpdateQuestProgress(Quest quest)
		{
		}
	}
	public class SandBanditScenario : Scenario
	{
		[HarmonyPatch(typeof(CharacterStats), "ReceiveDamage")]
		public class Character_ReceiveDamage
		{
			[HarmonyPostfix]
			public static void Postfix(CharacterStats __instance, ref float _damage, ref Character ___m_character)
			{
				if (Instance.IsActiveScenario && ___m_character.IsAI && !(SceneManagerHelper.ActiveSceneName != "Abrassar_Dungeon6") && _damage > __instance.CurrentHealth)
				{
					((MonoBehaviour)Plugin.Instance).StartCoroutine(Instance.LeftAlive());
				}
			}
		}

		[HarmonyPatch(typeof(CharacterManager), "RequestAreaSwitch")]
		public class CharacterManager_RequestAreaSwitch
		{
			[HarmonyPrefix]
			public static bool Prefix(CharacterManager __instance, Character _character, Area _areaToSwitchTo, int _longTravelTime, int _spawnPoint, float _offset, string _overrideLocKey)
			{
				if (!Instance.IsActiveScenario)
				{
					return true;
				}
				if (PhotonNetwork.isNonMasterClientInRoom)
				{
					return true;
				}
				if (_areaToSwitchTo.SceneName == "Levant")
				{
					_character.CharacterUI.ShowInfoNotification("You are not welcome here");
					return false;
				}
				return true;
			}
		}

		private const float GRACE_PERIOD_INGAMETIME = 0.3f;

		private const string LogSignature_A = "sandbandits.objective.a";

		private const string LogSignature_B = "sandbandits.objective.b";

		private static QuestEventSignature QE_StartTimer;

		private Coroutine delayedQuestUpdate;

		internal static DialogueCharacter levantGuard;

		public override ScenarioQuest Type => ScenarioQuest.Quest_SandBandit;

		public override ScenarioType Difficulty => ScenarioType.WIPtest;

		public override ScenarioPassives Passive => ScenarioPassives.SandBandit;

		public override AreaEnum SpawnScene => (AreaEnum)307;

		public override Vector3 SpawnPosition => new Vector3(-53.3f, 0.5f, 55.1f);

		public override Vector3 SpawnRotation => new Vector3(0f, 227.3f, 0f);

		public override bool HasQuest => true;

		public override string QuestName => "Sand Corsair Exile";

		public override Dictionary<string, string> QuestLogSignatures => new Dictionary<string, string>
		{
			{ "sandbandits.objective.a", "You have been exiled from the Sand Corsairs, leave before they turn on you!" },
			{ "sandbandits.objective.b", "Your grace period is over, Old Levant is no longer your ally." }
		};

		internal static SandBanditScenario Instance { get; private set; }

		public override void Gear(Character character)
		{
			character.Inventory.ReceiveItemReward(9000010, 26, false);
			character.Inventory.ReceiveItemReward(5100010, 1, true);
			character.Inventory.ReceiveItemReward(3000087, 1, true);
			character.Inventory.ReceiveItemReward(3000201, 1, true);
			character.Inventory.ReceiveItemReward(3000205, 1, true);
			character.Inventory.ReceiveItemReward(2000110, 1, true);
		}

		public SandBanditScenario()
		{
			Instance = this;
		}

		public override void Init()
		{
			base.Init();
			QE_StartTimer = CustomQuests.CreateQuestEvent("iggythemad.sandbandits.starttimer", true, false, true, "A_Iggy_AlternateStart", "CustomEvent", "A custom event created with SideLoader");
			SL.OnGameplayResumedAfterLoading += SL_OnGameplayResumedAfterLoading;
			SetupTestCharacter();
		}

		public override void OnScenarioChosen()
		{
			VanillaQuestsHelper.SkipHostToFactionChoice(keepHouse: false, complete: true);
		}

		public override void OnScenarioChosen(Character character)
		{
		}

		public override void OnStartSpawn()
		{
			ChangeCharactersFactions((Factions)2, QuestLogSignatures["sandbandits.objective.a"]);
			QuestEventManager.Instance.AddEvent(QE_StartTimer, 1);
			GetOrGiveQuestToHost();
			StartDelayedQuestUpdate();
		}

		public override void OnStartSpawn(Character character)
		{
		}

		private void ChangeCharactersFactions(Factions faction, string notifText)
		{
			//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)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			foreach (string value in CharacterManager.Instance.PlayerCharacters.Values)
			{
				Character character = CharacterManager.Instance.GetCharacter(value);
				if (character.Faction != faction)
				{
					character.ChangeFaction(faction, true);
					if (!string.IsNullOrEmpty(notifText))
					{
						ShowUIMessage(notifText);
					}
				}
			}
		}

		private void SL_OnGameplayResumedAfterLoading()
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Invalid comparison between Unknown and I4
			if (PhotonNetwork.isNonMasterClientInRoom || !base.IsActiveScenario)
			{
				return;
			}
			Character worldHostCharacter = CharacterManager.Instance.GetWorldHostCharacter();
			if (((CharacterKnowledge)worldHostCharacter.Inventory.QuestKnowledge).IsItemLearned((int)Type))
			{
				Item itemFromItemID = ((CharacterKnowledge)worldHostCharacter.Inventory.QuestKnowledge).GetItemFromItemID((int)Type);
				Quest quest = (Quest)(object)((itemFromItemID is Quest) ? itemFromItemID : null);
				UpdateQuestProgress(quest);
			}
			if (SceneManagerHelper.ActiveSceneName == "Abrassar_Dungeon6")
			{
				Character[] array = Object.FindObjectsOfType<Character>();
				int num = 0;
				Character[] array2 = array;
				foreach (Character val in array2)
				{
					if (val.Alive && val.IsAI && (int)val.Faction == 2)
					{
						num++;
					}
				}
				Instance.ShowUIMessage(num + " former friends left alive.");
			}
			else if (SceneManagerHelper.ActiveSceneName == "Levant")
			{
				NetworkLevelLoader.Instance.RequestSwitchArea(AreaManager.Instance.GetArea((AreaEnum)301).SceneName, 0, 1.5f, false);
			}
		}

		private void StartDelayedQuestUpdate()
		{
			if (delayedQuestUpdate != null)
			{
				((MonoBehaviour)Plugin.Instance).StopCoroutine(delayedQuestUpdate);
			}
			delayedQuestUpdate = ((MonoBehaviour)Plugin.Instance).StartCoroutine(UpdateQuestAfterDelay());
		}

		private IEnumerator UpdateQuestAfterDelay()
		{
			float eventActiveTimeDelta = QuestEventManager.Instance.GetEventActiveTimeDelta(QE_StartTimer.EventUID);
			while (eventActiveTimeDelta < 0.3f)
			{
				yield return (object)new WaitForSeconds(1f);
				if (!((Object)(object)QuestEventManager.Instance == (Object)null))
				{
					CharacterManager instance = CharacterManager.Instance;
					if (!Object.op_Implicit((Object)(object)((instance != null) ? instance.GetWorldHostCharacter() : null)))
					{
						yield break;
					}
					eventActiveTimeDelta = QuestEventManager.Instance.GetEventActiveTimeDelta(QE_StartTimer.EventUID);
					continue;
				}
				yield break;
			}
			CharacterManager instance2 = CharacterManager.Instance;
			Character val = ((instance2 != null) ? instance2.GetWorldHostCharacter() : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				if (((CharacterKnowledge)val.Inventory.QuestKnowledge).IsItemLearned((int)Type))
				{
					Item itemFromItemID = ((CharacterKnowledge)val.Inventory.QuestKnowledge).GetItemFromItemID((int)Type);
					Quest quest = (Quest)(object)((itemFromItemID is Quest) ? itemFromItemID : null);
					UpdateQuestProgress(quest);
				}
				delayedQuestUpdate = null;
			}
		}

		public override void UpdateQuestProgress(Quest quest)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			if (!PhotonNetwork.isNonMasterClientInRoom && base.IsActiveScenario)
			{
				float eventActiveTimeDelta = QuestEventManager.Instance.GetEventActiveTimeDelta(QE_StartTimer.EventUID);
				QuestProgress questProgress = quest.m_questProgress;
				questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("sandbandits.objective.a")), eventActiveTimeDelta >= 0.3f);
				if (eventActiveTimeDelta >= 0.3f)
				{
					questProgress.UpdateLogEntry(questProgress.GetLogSignature(UID.op_Implicit("sandbandits.objective.b")), displayTime: true);
					ChangeCharactersFactions((Factions)1, QuestLogSignatures["sandbandits.objective.b"]);
					questProgress.DisableQuest((ProgressState)3);
				}
				else
				{
					ChangeCharactersFactions((Factions)2, string.Empty);
					StartDelayedQuestUpdate();
				}
			}
		}

		private IEnumerator LeftAlive()
		{
			yield return (object)new WaitForSeconds(0.5f);
			Character[] array = Object.FindObjectsOfType<Character>();
			int num = 0;
			Character[] array2 = array;
			foreach (Character val in array2)
			{
				if (val.Alive && val.IsAI && (int)val.Faction == 2)
				{
					num++;
				}
			}
			Instance.ShowUIMessage(num + " former friends left alive.");
			if (num > 0)
			{
				Instance.ShowUIMessage(num + " former friends left alive.");
			}
		}

		private void SetupTestCharacter()
		{
			//IL_0036: 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)
			levantGuard = new DialogueCharacter
			{
				UID = "levantguard.character",
				Name = "Levant Guard",
				SpawnSceneBuildName = "Abrassar",
				SpawnPosition = new Vector3(-159.4f, 131.8f, -532.7f),
				SpawnRotation = new Vector3(0f, 43.7f, 0f),
				HelmetID = 3000115,
				ChestID = 3000112,
				BootsID = 3000118,
				WeaponID = 2130305,
				StartingPose = (SpellCastType)42
			};
			SL_Character obj = levantGuard.CreateAndApplyTemplate();
			levantGuard.OnSetupDialogueGraph += TestCharacter_OnSetupDialogueGraph;
			obj.ShouldSpawn = () => base.IsActiveScenario;
		}

		private void TestCharacter_OnSetupDialogueGraph(DialogueTree graph, Character character)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL