Decompiled source of NPC API MelanieMelicious v1.0.0

MelanieMeliciousNPCAPI.dll

Decompiled 4 hours 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 BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using MelanieMeliciousNPCAPI.NetcodePatcher;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MelanieMeliciousNPCAPI")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("MelanieMelicious")]
[assembly: AssemblyProduct("Melanie NPC API")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MelMelNPC
{
	public class HarmonyPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		private static void PostStart()
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			Object.Instantiate<GameObject>(Plugin.bundle.LoadAsset<GameObject>("Assets/MelanieNPC/Prefab/UI/NPCChat.prefab"), HUDManager.Instance.HUDContainer.transform);
			Object.Instantiate<GameObject>(Plugin.bundle.LoadAsset<GameObject>("Assets/MelanieNPC/Prefab/UI/NPCShop.prefab"), HUDManager.Instance.HUDContainer.transform);
			if (GameNetworkManager.Instance.isHostingGame)
			{
				GameObject val = Object.Instantiate<GameObject>(Plugin.bundle.LoadAsset<GameObject>("Assets/MelanieNPC/Prefab/MMNPCSpawn.prefab"), Vector3.zero, Quaternion.identity);
				val.GetComponent<NetworkObject>().Spawn(false);
				foreach (NPCChatNode savedResponse in NPCManager.savedResponses)
				{
					savedResponse.LoadData();
				}
				{
					foreach (NPCQuestNode quest in NPCManager.quests)
					{
						quest.LoadData();
					}
					return;
				}
			}
			for (int i = 0; i < NPCManager.savedResponses.Count; i++)
			{
				NPCManager.Instance.ChatServerRpc(i);
			}
			for (int j = 0; j < NPCManager.quests.Count; j++)
			{
				NPCManager.Instance.QuestServerRpc(j);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(HUDManager), "Start")]
		private static void PostHUD(HUDManager __instance)
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			Object.Instantiate<GameObject>(Plugin.bundle.LoadAsset<GameObject>("Assets/MelanieNPC/Prefab/UI/NPCChat.prefab"), __instance.HUDContainer.transform);
			Object.Instantiate<GameObject>(Plugin.bundle.LoadAsset<GameObject>("Assets/MelanieNPC/Prefab/UI/NPCShop.prefab"), __instance.HUDContainer.transform);
			foreach (NPCQuestNode quest in NPCManager.quests)
			{
				quest.LoadData();
			}
			if (!GameNetworkManager.Instance.isHostingGame)
			{
				return;
			}
			GameObject val = Object.Instantiate<GameObject>(Plugin.bundle.LoadAsset<GameObject>("Assets/MelanieNPC/Prefab/MMNPCSpawn.prefab"), Vector3.zero, Quaternion.identity);
			val.GetComponent<NetworkObject>().Spawn(false);
			foreach (NPCChatNode savedResponse in NPCManager.savedResponses)
			{
				savedResponse.LoadData();
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(HUDManager), "CloseSpecialMenus")]
		private static void PostCloseMenu(HUDManager __instance)
		{
			((Component)NPCChat.Instance).gameObject.SetActive(false);
			((Component)NPCShop.Instance).gameObject.SetActive(false);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(GameNetworkManager), "SaveGameValues")]
		private static void SaveNPCNodes()
		{
			if (!((NetworkBehaviour)StartOfRound.Instance).IsServer)
			{
				return;
			}
			try
			{
				foreach (NPCChatNode savedResponse in NPCManager.savedResponses)
				{
					savedResponse.SaveData();
				}
				foreach (NPCQuestNode quest in NPCManager.quests)
				{
					quest.SaveData();
				}
			}
			catch
			{
				Plugin.mls.LogError((object)"Issue in NPC save patch. Aborting to prevent save break.");
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		private static void NetworkPatch(ref GameNetworkManager __instance)
		{
			((Component)__instance).GetComponent<NetworkManager>().AddNetworkPrefab(Plugin.bundle.LoadAsset<GameObject>("Assets/MelanieNPC/Prefab/MMNPCSpawn.prefab"));
		}
	}
	public class NPC : MonoBehaviour
	{
		[SerializeField]
		private string nameBox;

		[SerializeField]
		internal NPCChatNode welcome;

		[SerializeField]
		private Transform spawnScrapPos;

		public void Welcome()
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			HUDManager.Instance.CloseSpecialMenus();
			((Component)NPCChat.Instance).gameObject.SetActive(true);
			NPCChat.Instance.nameBox.text = nameBox;
			Transform parent = NPCChat.Instance.nameBox.transform.parent;
			RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null);
			val.SetSizeWithCurrentAnchors((Axis)0, (float)(nameBox.Length * 10 + 5));
			val.anchoredPosition = new Vector2((float)(nameBox.Length * 5 - 305), 120f);
			if ((Object)(object)spawnScrapPos != (Object)null)
			{
				NPCShop.Instance.spawnScrapPos = spawnScrapPos.position;
			}
			else
			{
				NPCShop.Instance.spawnScrapPos = ((Component)this).transform.position;
			}
			NPCChat.Instance.Talk(welcome);
		}
	}
	public class NPCChat : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <TalkDelay>d__10 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public NPCChat <>4__this;

			private int <length>5__1;

			private int <i>5__2;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				//IL_007e: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>4__this.messageBox.maxVisibleCharacters = 0;
					<length>5__1 = <>4__this.messageBox.text.Length;
					<i>5__2 = 0;
					break;
				case 1:
					<>1__state = -1;
					<i>5__2++;
					break;
				}
				if (<i>5__2 <= <length>5__1)
				{
					<>4__this.messageBox.maxVisibleCharacters = <i>5__2;
					<>2__current = (object)new WaitForSeconds(0.05f);
					<>1__state = 1;
					return true;
				}
				return false;
			}

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

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

		[SerializeField]
		internal TMP_Text nameBox;

		[SerializeField]
		private TMP_Text messageBox;

		public TMP_Text[] responseSelect;

		private List<NPCChatNode> responses = new List<NPCChatNode>();

		public static NPCChat Instance { get; private set; }

		public void Talk(NPCChatNode message)
		{
			if ((Object)(object)message.shop != (Object)null)
			{
				message.shop.GetItems();
				((Component)NPCShop.Instance).gameObject.SetActive(true);
				NPCShop.Instance.OpenShop(message.shop);
				((Component)this).gameObject.SetActive(false);
				return;
			}
			if (message.selectEvent != null)
			{
				message.selectEvent.Invoke();
			}
			if (message.responses.Count != 0)
			{
				responses.Clear();
				responses.AddRange(message.responses);
				if (message.quests.Count != 0)
				{
					foreach (NPCQuestNode quest in message.quests)
					{
						if (quest.IsComplete())
						{
							if (!quest.claimed)
							{
								quest.completeEvent.Invoke();
								responses.Insert(0, quest.questComplete);
							}
							continue;
						}
						responses.Insert(0, quest.questDefault);
						if (!GameNetworkManager.Instance.localPlayerController.isHoldingObject)
						{
							continue;
						}
						foreach (NPCQuestCondition condition in quest.conditions)
						{
							if ((Object)(object)condition.item != (Object)null && (Object)(object)GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer.itemProperties == (Object)(object)condition.item)
							{
								responses.Insert(0, quest.questProgress);
								break;
							}
						}
					}
				}
				messageBox.SetText(message.displayText, true);
				((MonoBehaviour)this).StartCoroutine(TalkDelay());
				for (int i = 0; i < responseSelect.Length; i++)
				{
					if (i >= responses.Count)
					{
						((Component)responseSelect[i].transform.parent).gameObject.SetActive(false);
						continue;
					}
					responseSelect[i].text = responses[i].selectText;
					((Component)responseSelect[i].transform.parent).gameObject.SetActive(true);
				}
				GameNetworkManager.Instance.localPlayerController.inSpecialMenu = true;
				Cursor.lockState = (CursorLockMode)0;
				((Behaviour)GameNetworkManager.Instance.localPlayerController.cursorIcon).enabled = false;
				((TMP_Text)GameNetworkManager.Instance.localPlayerController.cursorTip).text = "";
				if ((Object)(object)GameNetworkManager.Instance.localPlayerController.hoveringOverTrigger != (Object)null)
				{
					GameNetworkManager.Instance.localPlayerController.previousHoveringOverTrigger = GameNetworkManager.Instance.localPlayerController.hoveringOverTrigger;
				}
				GameNetworkManager.Instance.localPlayerController.hoveringOverTrigger = null;
			}
			else
			{
				((Component)this).gameObject.SetActive(false);
				if (GameNetworkManager.Instance.localPlayerController.inSpecialMenu)
				{
					GameNetworkManager.Instance.localPlayerController.SetInSpecialMenu(false, (SpecialHUDMenu)0);
				}
			}
		}

		public void Respond(int response)
		{
			TMP_Text[] array = responseSelect;
			foreach (TMP_Text val in array)
			{
				((Component)val.transform.parent).gameObject.SetActive(false);
			}
			Talk(responses[response]);
		}

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

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)Instance).gameObject);
			}
			Instance = this;
			((Component)this).gameObject.SetActive(false);
		}
	}
	[CreateAssetMenu(menuName = "ScriptableObjects/MelMelNPC/NPCChatNode")]
	public class NPCChatNode : ScriptableObject
	{
		[TextArea(2, 4)]
		public string displayText;

		public string selectText;

		public UnityEvent selectEvent;

		[HideInInspector]
		public List<NPCChatNode> responses = new List<NPCChatNode>();

		[SerializeField]
		private bool saveUnlockedDialogue;

		public List<NPCChatNode> allResponses = new List<NPCChatNode>();

		public List<int> lockedResponsesIndex = new List<int>();

		internal List<int> lockedResponses = new List<int>();

		public NPCShopNode shop;

		public List<NPCQuestNode> quests;

		private string loaded;

		public void UnlockDialogue(int index)
		{
			lockedResponses.Remove(index);
			NPCManager.Instance.ChatServerRpc(NPCManager.savedResponses.IndexOf(this), lockedResponses.ToArray());
		}

		public void LockDialogue(int index)
		{
			lockedResponses.Add(index);
			NPCManager.Instance.ChatServerRpc(NPCManager.savedResponses.IndexOf(this), lockedResponses.ToArray());
		}

		private void OnEnable()
		{
			if (!saveUnlockedDialogue)
			{
				lockedResponses.Clear();
				lockedResponses.AddRange(lockedResponsesIndex);
				responses.Clear();
				responses.AddRange(allResponses);
				{
					foreach (int lockedResponse in lockedResponses)
					{
						responses.Remove(allResponses[lockedResponse]);
					}
					return;
				}
			}
			NPCManager.savedResponses.Add(this);
			NPCManager.savedResponses.Sort();
		}

		internal void LoadData()
		{
			if (!GameNetworkManager.Instance.isHostingGame || loaded == GameNetworkManager.Instance.currentSaveFileName)
			{
				return;
			}
			try
			{
				if (ES3.KeyExists(((Object)this).name, GameNetworkManager.Instance.currentSaveFileName))
				{
					lockedResponses = ES3.Load<List<int>>(((Object)this).name, GameNetworkManager.Instance.currentSaveFileName);
					NPCManager.Instance.ChatClientRpc(NPCManager.savedResponses.IndexOf(this), lockedResponses.ToArray());
				}
				else
				{
					lockedResponses.Clear();
					lockedResponses.AddRange(lockedResponsesIndex);
					NPCManager.Instance.ChatClientRpc(NPCManager.savedResponses.IndexOf(this), lockedResponses.ToArray());
				}
			}
			catch
			{
				Plugin.mls.LogError((object)("Error while loading NPC chat node data for " + ((Object)this).name + ". Aborting to prevent save break."));
			}
			loaded = GameNetworkManager.Instance.currentSaveFileName;
		}

		internal void SaveData()
		{
			if (!GameNetworkManager.Instance.isHostingGame)
			{
				return;
			}
			try
			{
				ES3.Save<List<int>>(((Object)this).name, lockedResponses, GameNetworkManager.Instance.currentSaveFileName);
			}
			catch
			{
				Plugin.mls.LogError((object)("Error while saving NPC chat node data for " + ((Object)this).name + ". Aborting to prevent save break."));
			}
		}
	}
	public class NPCManager : NetworkBehaviour
	{
		public static List<NPCChatNode> savedResponses = new List<NPCChatNode>();

		public static List<NPCQuestNode> quests = new List<NPCQuestNode>();

		internal Terminal terminal;

		public static NPCManager Instance { get; private set; }

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			if ((Object)(object)Instance != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)Instance).gameObject);
			}
			Instance = this;
			terminal = Object.FindObjectOfType<Terminal>();
		}

		[ServerRpc(RequireOwnership = false)]
		public void CreditsServerRpc(int value, bool addQuota = false)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(718831296u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, value);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref addQuota, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 718831296u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					CreditsClientRpc(value, addQuota);
				}
			}
		}

		[ClientRpc]
		public void CreditsClientRpc(int value, bool addQuota)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4046728999u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, value);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref addQuota, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4046728999u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				Terminal obj = terminal;
				obj.groupCredits += value;
				if (addQuota)
				{
					TimeOfDay instance = TimeOfDay.Instance;
					instance.quotaFulfilled += value;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SpawnItemServerRpc(int itemList, float posX, float posY, float posZ)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2989129686u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, itemList);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref posX, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref posY, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref posZ, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2989129686u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					GameObject val3 = Object.Instantiate<GameObject>(StartOfRound.Instance.allItemsList.itemsList[itemList].spawnPrefab, new Vector3(posX, posY, posZ), Quaternion.identity, RoundManager.Instance.spawnedScrapContainer);
					val3.GetComponent<NetworkObject>().Spawn(false);
					SpawnItemClientRpc(NetworkObjectReference.op_Implicit(val3.GetComponent<NetworkObject>()), 0);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		internal void QuestServerRpc(int index0, int index1, int progress)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3039930900u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, index0);
					BytePacker.WriteValueBitPacked(val2, index1);
					BytePacker.WriteValueBitPacked(val2, progress);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3039930900u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					QuestClientRpc(index0, index1, progress);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		internal void QuestServerRpc(int index, bool claim)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3934955173u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, index);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref claim, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3934955173u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					QuestClientRpc(index, claim);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		internal void QuestServerRpc(int index)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3003663075u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, index);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3003663075u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				QuestClientRpc(index, quests[index].claimed);
				for (int i = 0; i < quests[index].conditions.Count; i++)
				{
					QuestClientRpc(index, i, quests[index].conditions[i].progress);
				}
			}
		}

		[ClientRpc]
		internal void QuestClientRpc(int index0, int index1, int progress)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2613414402u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, index0);
					BytePacker.WriteValueBitPacked(val2, index1);
					BytePacker.WriteValueBitPacked(val2, progress);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2613414402u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					quests[index0].conditions[index1].progress = (short)progress;
				}
			}
		}

		[ClientRpc]
		internal void QuestClientRpc(int index, bool claim)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4294733108u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, index);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref claim, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4294733108u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					quests[index].claimed = claim;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		internal void ChatServerRpc(int index, int[] syncLockDialogue)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3281280143u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, index);
				bool flag = syncLockDialogue != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe<int>(syncLockDialogue, default(ForPrimitives));
				}
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3281280143u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				ChatClientRpc(index, syncLockDialogue);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		internal void ChatServerRpc(int index)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2269701451u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, index);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2269701451u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					ChatClientRpc(index, savedResponses[index].lockedResponses.ToArray());
				}
			}
		}

		[ClientRpc]
		internal void ChatClientRpc(int index, int[] syncLockDialogue)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2216386288u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, index);
				bool flag = syncLockDialogue != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe<int>(syncLockDialogue, default(ForPrimitives));
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2216386288u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			base.__rpc_exec_stage = (__RpcExecStage)0;
			savedResponses[index].lockedResponses = syncLockDialogue.ToList();
			savedResponses[index].responses.Clear();
			savedResponses[index].responses.AddRange(savedResponses[index].allResponses);
			foreach (int lockedResponse in savedResponses[index].lockedResponses)
			{
				savedResponses[index].responses.Remove(savedResponses[index].allResponses[lockedResponse]);
			}
		}

		[ClientRpc]
		private void SpawnItemClientRpc(NetworkObjectReference netObjRef, int value)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(473036251u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref netObjRef, default(ForNetworkSerializable));
				BytePacker.WriteValueBitPacked(val2, value);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 473036251u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				NetworkObject val3 = default(NetworkObject);
				if (((NetworkObjectReference)(ref netObjRef)).TryGet(ref val3, (NetworkManager)null))
				{
					((Component)val3).GetComponent<GrabbableObject>().SetScrapValue(value);
				}
			}
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Expected O, but got Unknown
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Expected O, but got Unknown
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(718831296u, new RpcReceiveHandler(__rpc_handler_718831296), "CreditsServerRpc");
			((NetworkBehaviour)this).__registerRpc(4046728999u, new RpcReceiveHandler(__rpc_handler_4046728999), "CreditsClientRpc");
			((NetworkBehaviour)this).__registerRpc(2989129686u, new RpcReceiveHandler(__rpc_handler_2989129686), "SpawnItemServerRpc");
			((NetworkBehaviour)this).__registerRpc(3039930900u, new RpcReceiveHandler(__rpc_handler_3039930900), "QuestServerRpc");
			((NetworkBehaviour)this).__registerRpc(3934955173u, new RpcReceiveHandler(__rpc_handler_3934955173), "QuestServerRpc");
			((NetworkBehaviour)this).__registerRpc(3003663075u, new RpcReceiveHandler(__rpc_handler_3003663075), "QuestServerRpc");
			((NetworkBehaviour)this).__registerRpc(2613414402u, new RpcReceiveHandler(__rpc_handler_2613414402), "QuestClientRpc");
			((NetworkBehaviour)this).__registerRpc(4294733108u, new RpcReceiveHandler(__rpc_handler_4294733108), "QuestClientRpc");
			((NetworkBehaviour)this).__registerRpc(3281280143u, new RpcReceiveHandler(__rpc_handler_3281280143), "ChatServerRpc");
			((NetworkBehaviour)this).__registerRpc(2269701451u, new RpcReceiveHandler(__rpc_handler_2269701451), "ChatServerRpc");
			((NetworkBehaviour)this).__registerRpc(2216386288u, new RpcReceiveHandler(__rpc_handler_2216386288), "ChatClientRpc");
			((NetworkBehaviour)this).__registerRpc(473036251u, new RpcReceiveHandler(__rpc_handler_473036251), "SpawnItemClientRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_718831296(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int value = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref value);
				bool addQuota = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref addQuota, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NPCManager)(object)target).CreditsServerRpc(value, addQuota);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_4046728999(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int value = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref value);
				bool addQuota = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref addQuota, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NPCManager)(object)target).CreditsClientRpc(value, addQuota);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2989129686(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int itemList = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref itemList);
				float posX = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref posX, default(ForPrimitives));
				float posY = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref posY, default(ForPrimitives));
				float posZ = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref posZ, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NPCManager)(object)target).SpawnItemServerRpc(itemList, posX, posY, posZ);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3039930900(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int index = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref index);
				int index2 = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref index2);
				int progress = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref progress);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NPCManager)(object)target).QuestServerRpc(index, index2, progress);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3934955173(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int index = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref index);
				bool claim = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref claim, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NPCManager)(object)target).QuestServerRpc(index, claim);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3003663075(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int index = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref index);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NPCManager)(object)target).QuestServerRpc(index);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2613414402(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int index = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref index);
				int index2 = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref index2);
				int progress = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref progress);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NPCManager)(object)target).QuestClientRpc(index, index2, progress);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_4294733108(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int index = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref index);
				bool claim = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref claim, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NPCManager)(object)target).QuestClientRpc(index, claim);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3281280143(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int index = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref index);
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				int[] syncLockDialogue = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref syncLockDialogue, default(ForPrimitives));
				}
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NPCManager)(object)target).ChatServerRpc(index, syncLockDialogue);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2269701451(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int index = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref index);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NPCManager)(object)target).ChatServerRpc(index);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2216386288(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int index = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref index);
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				int[] syncLockDialogue = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref syncLockDialogue, default(ForPrimitives));
				}
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NPCManager)(object)target).ChatClientRpc(index, syncLockDialogue);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_473036251(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference netObjRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref netObjRef, default(ForNetworkSerializable));
				int value = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref value);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NPCManager)(object)target).SpawnItemClientRpc(netObjRef, value);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "NPCManager";
		}
	}
	[Serializable]
	public class NPCQuestCondition
	{
		public string requirement = "(Example) 'Pull lever in [example location]' or 'Give 3 Shovels'";

		public Item item;

		public string itemByName;

		public short progress = 0;

		public short progressMax = 0;
	}
	[CreateAssetMenu(menuName = "ScriptableObjects/MelMelNPC/NPCQuestNode")]
	public class NPCQuestNode : ScriptableObject
	{
		[ES3NonSerializable]
		public List<NPCQuestCondition> conditions = new List<NPCQuestCondition>();

		[ES3NonSerializable]
		public UnityEvent completeEvent;

		[ES3NonSerializable]
		public NPCChatNode questDefault;

		[ES3NonSerializable]
		public NPCChatNode questProgress;

		[ES3NonSerializable]
		public NPCChatNode questComplete;

		public bool claimed = false;

		private bool loadedItems = false;

		private string loaded;

		public void Progress(int index)
		{
			if (conditions[index].progress <= conditions[index].progressMax)
			{
				conditions[index].progress++;
				NPCManager.Instance.QuestServerRpc(NPCManager.quests.IndexOf(this), index, conditions[index].progress);
			}
		}

		public void DespawnHeld()
		{
			GameNetworkManager.Instance.localPlayerController.DespawnHeldObject();
		}

		public void ClaimQuest(bool claim)
		{
			NPCManager.Instance.QuestServerRpc(NPCManager.quests.IndexOf(this), claim);
		}

		internal bool IsComplete()
		{
			foreach (NPCQuestCondition condition in conditions)
			{
				if (condition.progress < condition.progressMax)
				{
					return false;
				}
			}
			return true;
		}

		internal void LoadData()
		{
			if (!loadedItems)
			{
				foreach (NPCQuestCondition condition in conditions)
				{
					if (condition.itemByName == null)
					{
						continue;
					}
					foreach (Item items in StartOfRound.Instance.allItemsList.itemsList)
					{
						if (items.itemName == condition.itemByName)
						{
							condition.item = items;
							break;
						}
					}
				}
				loadedItems = true;
			}
			if (!GameNetworkManager.Instance.isHostingGame || loaded == GameNetworkManager.Instance.currentSaveFileName)
			{
				return;
			}
			try
			{
				if (ES3.KeyExists(((Object)this).name, GameNetworkManager.Instance.currentSaveFileName))
				{
					claimed = ES3.Load<bool>(((Object)this).name, GameNetworkManager.Instance.currentSaveFileName);
					NPCManager.Instance.QuestClientRpc(NPCManager.quests.IndexOf(this), claimed);
					for (int i = 0; i < conditions.Count; i++)
					{
						if (ES3.KeyExists($"{((Object)this).name}.Condition{i}", GameNetworkManager.Instance.currentSaveFileName))
						{
							conditions[i].progress = ES3.Load<short>($"{((Object)this).name}.Condition{i}", GameNetworkManager.Instance.currentSaveFileName);
						}
						NPCManager.Instance.QuestClientRpc(NPCManager.quests.IndexOf(this), i, conditions[i].progress);
					}
				}
				else
				{
					claimed = false;
					for (int j = 0; j < conditions.Count; j++)
					{
						conditions[j].progress = 0;
						NPCManager.Instance.QuestClientRpc(NPCManager.quests.IndexOf(this), j, conditions[j].progress);
					}
				}
			}
			catch
			{
				Plugin.mls.LogError((object)("Error while loading NPC quest node data for " + ((Object)this).name + ". Aborting to prevent save break."));
			}
			loaded = GameNetworkManager.Instance.currentSaveFileName;
		}

		internal void SaveData()
		{
			if (!GameNetworkManager.Instance.isHostingGame)
			{
				return;
			}
			try
			{
				ES3.Save<bool>(((Object)this).name, claimed, GameNetworkManager.Instance.currentSaveFileName);
				for (int i = 0; i < conditions.Count; i++)
				{
					ES3.Save<short>($"{((Object)this).name}.Condition{i}", conditions[i].progress, GameNetworkManager.Instance.currentSaveFileName);
				}
			}
			catch
			{
				Plugin.mls.LogError((object)("Error while saving NPC quest node for " + ((Object)this).name + ". Aborting to prevent save break."));
			}
		}

		private void OnEnable()
		{
			NPCManager.quests.Add(this);
			NPCManager.quests.Sort();
		}
	}
	public class NPCShop : MonoBehaviour
	{
		public Item[] buy;

		public int[] buyCost;

		public TMP_Text[] buySelect;

		public Item[] sell;

		public TMP_Text[] sellSelect;

		private float sellMulti;

		private bool addQuota;

		[SerializeField]
		private TMP_Text addQuotaText;

		public Item[] tradeWant;

		public Item[] tradeGive;

		public TMP_Text[] tradeSelect;

		internal Vector3 spawnScrapPos;

		private AudioClip purchase;

		private const string noQuota = "Does NOT Progress Quota!";

		private const string yesQuota = "Progresses Quota!";

		public static NPCShop Instance { get; private set; }

		public void Buy(int index)
		{
			if (NPCManager.Instance.terminal.groupCredits >= buyCost[index])
			{
				NPCManager.Instance.SpawnItemServerRpc(StartOfRound.Instance.allItemsList.itemsList.IndexOf(buy[index]), spawnScrapPos.x, spawnScrapPos.y, spawnScrapPos.z);
				NPCManager.Instance.CreditsServerRpc(-buyCost[index]);
				HUDManager.Instance.UIAudio.PlayOneShot(purchase);
			}
			else
			{
				HUDManager.Instance.DisplayTip("Error:", "Not enough credits!", true, false, "LC_Tip1");
			}
		}

		public void Sell(int index)
		{
			if (GameNetworkManager.Instance.localPlayerController.isHoldingObject && (Object)(object)GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer.itemProperties == (Object)(object)sell[index])
			{
				NPCManager.Instance.CreditsServerRpc((int)((float)GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer.scrapValue * sellMulti), addQuota);
				HUDManager.Instance.UIAudio.PlayOneShot(purchase);
				GameNetworkManager.Instance.localPlayerController.DespawnHeldObject();
			}
			else
			{
				HUDManager.Instance.DisplayTip("Error:", "Not holding sell item!", true, false, "LC_Tip1");
			}
		}

		public void Trade(int index)
		{
			if (GameNetworkManager.Instance.localPlayerController.isHoldingObject && (Object)(object)GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer.itemProperties == (Object)(object)tradeWant[index])
			{
				NPCManager.Instance.SpawnItemServerRpc(StartOfRound.Instance.allItemsList.itemsList.IndexOf(tradeGive[index]), spawnScrapPos.x, spawnScrapPos.y, spawnScrapPos.z);
				HUDManager.Instance.UIAudio.PlayOneShot(purchase);
				GameNetworkManager.Instance.localPlayerController.DespawnHeldObject();
			}
			else
			{
				HUDManager.Instance.DisplayTip("Error:", "Not holding trade item!", true, false, "LC_Tip1");
			}
		}

		public void OpenShop(NPCShopNode shop)
		{
			buy = shop.buy.ToArray();
			buyCost = shop.buyCost.ToArray();
			sell = shop.sell.ToArray();
			sellMulti = shop.sellMulti;
			addQuota = shop.addQuota;
			tradeWant = shop.tradeWant.ToArray();
			tradeGive = shop.tradeGive.ToArray();
			for (int i = 0; i < buySelect.Length; i++)
			{
				if (i >= buy.Length || i >= buyCost.Length)
				{
					((Component)buySelect[i].transform.parent).gameObject.SetActive(false);
					continue;
				}
				buySelect[i].text = $"[ {buyCost[i]} Credits -> {buy[i].itemName} ]";
				((Component)buySelect[i].transform.parent).gameObject.SetActive(true);
			}
			if (addQuota)
			{
				addQuotaText.text = "Progresses Quota!";
			}
			else
			{
				addQuotaText.text = "Does NOT Progress Quota!";
			}
			for (int j = 0; j < sellSelect.Length; j++)
			{
				if (j >= sell.Length)
				{
					((Component)sellSelect[j].transform.parent).gameObject.SetActive(false);
					continue;
				}
				sellSelect[j].text = $"[ {sell[j].itemName} -> {sellMulti * 100f}% Value ]";
				((Component)sellSelect[j].transform.parent).gameObject.SetActive(true);
			}
			for (int k = 0; k < tradeSelect.Length; k++)
			{
				if (k >= tradeWant.Length || k >= tradeGive.Length)
				{
					((Component)tradeSelect[k].transform.parent).gameObject.SetActive(false);
					continue;
				}
				tradeSelect[k].text = "[ " + tradeWant[k].itemName + " -> " + tradeGive[k].itemName + " ]";
				((Component)sellSelect[k].transform.parent).gameObject.SetActive(true);
			}
		}

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)Instance).gameObject);
			}
			Instance = this;
			purchase = Plugin.bundle.LoadAsset<AudioClip>("Assets/MelanieNPC/Audio/PurchaseSFX.ogg");
			((Component)this).gameObject.SetActive(false);
		}
	}
	[CreateAssetMenu(menuName = "ScriptableObjects/MelMelNPC/NPCShopNode")]
	public class NPCShopNode : ScriptableObject
	{
		public List<Item> buy = new List<Item>();

		public List<string> buyByName = new List<string>();

		public List<int> buyCost = new List<int>();

		public List<Item> sell = new List<Item>();

		public List<string> sellByName = new List<string>();

		public short sellMulti = 1;

		public bool addQuota = false;

		public List<Item> tradeWant = new List<Item>();

		public List<string> tradeWantByName = new List<string>();

		public List<Item> tradeGive = new List<Item>();

		public List<string> tradeGiveByName = new List<string>();

		private bool foundItems = false;

		internal void GetItems()
		{
			if (foundItems)
			{
				return;
			}
			foreach (string item in buyByName)
			{
				foreach (Item items in StartOfRound.Instance.allItemsList.itemsList)
				{
					if (items.itemName == item)
					{
						buy.Add(items);
						break;
					}
				}
			}
			foreach (string item2 in sellByName)
			{
				foreach (Item items2 in StartOfRound.Instance.allItemsList.itemsList)
				{
					if (items2.itemName == item2)
					{
						sell.Add(items2);
						break;
					}
				}
			}
			foreach (string item3 in tradeWantByName)
			{
				foreach (Item items3 in StartOfRound.Instance.allItemsList.itemsList)
				{
					if (items3.itemName == item3)
					{
						tradeWant.Add(items3);
						break;
					}
				}
			}
			foreach (string item4 in tradeGiveByName)
			{
				foreach (Item items4 in StartOfRound.Instance.allItemsList.itemsList)
				{
					if (items4.itemName == item4)
					{
						tradeGive.Add(items4);
						break;
					}
				}
			}
			foundItems = true;
		}
	}
	[BepInPlugin("MelanieMelicious.NPCAPI", "MelanieMelicious - NPC API", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "MelanieMelicious.NPCAPI";

		private const string NAME = "MelanieMelicious - NPC API";

		private const string VERSION = "1.0.0";

		public const string NAMESPACE = "melanienpcapi";

		private readonly Harmony harmony = new Harmony("MelanieMelicious.NPCAPI");

		internal static ManualLogSource mls;

		public static AssetBundle bundle;

		public UnlockablesList unlockList;

		public static Plugin instance;

		private void Awake()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
			instance = this;
			mls = Logger.CreateLogSource("MelanieMelicious - NPC API");
			mls = ((BaseUnityPlugin)this).Logger;
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "melanienpcapi");
			bundle = AssetBundle.LoadFromFile(text);
			unlockList = bundle.LoadAsset<UnlockablesList>("Assets/MelanieNPC/Test/Test.asset");
			harmony.PatchAll(typeof(HarmonyPatches));
		}
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
		}
	}
}
namespace MelanieMeliciousNPCAPI.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}