Decompiled source of ChatterReborn v0.4.1

BepInEx/plugins/ChatterReborn.dll

Decompiled a week 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.Text;
using AIGraph;
using Agents;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using CellMenu;
using ChainedPuzzles;
using ChatterReborn.Attributes;
using ChatterReborn.ChatterEvent;
using ChatterReborn.Components;
using ChatterReborn.Components.PlayerBotActionsMonitor;
using ChatterReborn.Data;
using ChatterReborn.Extra;
using ChatterReborn.Machines.Drama;
using ChatterReborn.Machines.PlayerResponse;
using ChatterReborn.Machines.WieldingItem;
using ChatterReborn.Managers;
using ChatterReborn.Utils;
using ChatterReborn.Utils.Callback;
using ChatterReborn.Utils.Extensions;
using ChatterReborn.Utils.Machine;
using ChatterReborn.Utils.Patcher;
using Enemies;
using GameData;
using Gear;
using Globals;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Attributes;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Reflection;
using LevelGeneration;
using Localization;
using Player;
using SNetwork;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ChatterReborn")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("easternunit100")]
[assembly: AssemblyProduct("ChatterReborn")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("easternunit100")]
[assembly: ComVisible(false)]
[assembly: Guid("00cf6f7d-abd0-4cb1-b4cb-9d7195503d2b")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ChatterReborn
{
	[BepInPlugin("CHTR", "chatter-reborn", "0.4.1")]
	public class ChatterRebornEntry : BasePlugin
	{
		public static ChatterRebornEntry Instance;

		private static bool m_started;

		private ChatterPatcher<ChatterRebornEntry> m_init_patcher;

		public override void Load()
		{
			Instance = this;
			AssemblyUtils.CurrentAssemblies.AddRange(Assembly.GetExecutingAssembly().GetTypes());
			AssemblyUtils.LoadDevComponents();
			MethodTokenUtils.GenerateMethodTokenIDsFile();
			Il2cppPackager.RegisterIl2cppTypes();
			InitiateEntryPatches();
		}

		private void InitiateEntryPatches()
		{
			m_init_patcher = new ChatterPatcher<ChatterRebornEntry>("ChatterEntry");
			m_init_patcher.Patch<StartMainGame>(new MethodToken("Start", 5508391u), (HarmonyPatchType)2, BindingFlags.Instance | BindingFlags.Public);
		}

		[MethodDecoderToken]
		private static void StartMainGame__Start__Postfix()
		{
			if (!m_started)
			{
				m_started = true;
				GlobalPatcher.InitiatePatches();
				Il2cppPackager.AddComponentsUponStartUp();
				ManagerInit.SetupAllMangers();
				ChatterDebug.LogMessage("CHATTER INITIATED!");
			}
		}
	}
	public class ManagerInit
	{
		private static bool _Setup;

		public static ManagerHandler ManagerHandler { get; private set; }

		public static void SetupAllMangers()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (_Setup)
			{
				return;
			}
			_Setup = true;
			ManagerHandler = new GameObject().AddComponent<ManagerHandler>();
			Object.DontDestroyOnLoad((Object)(object)ManagerHandler);
			Type[] array = Assembly.GetExecutingAssembly().GetTypes().Where(IsTypeChatterManager)
				.ToArray();
			bool flag = true;
			while (true)
			{
				Type[] array2 = array;
				foreach (Type type in array2)
				{
					if (!(type.BaseType != null))
					{
						continue;
					}
					PropertyInfo property = type.BaseType.GetProperty("Current", BindingFlags.Static | BindingFlags.Public);
					if (property != null)
					{
						if (property.GetValue(null) is ChatterManagerBase chatterManagerBase)
						{
							chatterManagerBase.Initialize(flag);
						}
						else
						{
							ChatterDebug.LogError(type?.ToString() + " is not a manager!");
						}
					}
				}
				if (flag)
				{
					flag = false;
					continue;
				}
				break;
			}
		}

		private static bool IsTypeChatterManager(Type type)
		{
			if (type.BaseType?.BaseType == null)
			{
				return false;
			}
			if (type.BaseType.BaseType != typeof(ChatterManagerBase))
			{
				return false;
			}
			if (!type.BaseType.IsGenericType)
			{
				return false;
			}
			if (type.BaseType.GenericTypeArguments.Length == 0)
			{
				return false;
			}
			if (type.BaseType.GenericTypeArguments.ElementAtOrDefault(0) != type)
			{
				return false;
			}
			return true;
		}
	}
}
namespace ChatterReborn.Patches
{
	internal class Patch_WardenObjectiveManager
	{
	}
	[HarmonyPatch(typeof(EnemyScanner))]
	internal class Patch_EnemyScanner
	{
	}
}
namespace ChatterReborn.Utils
{
	public static class AssemblyUtils
	{
		public static List<Type> CurrentAssemblies { get; set; } = new List<Type>();


		public static bool LoadAssembly(string assemblyName, out Assembly assemblyLoaded)
		{
			assemblyLoaded = null;
			try
			{
				assemblyLoaded = Assembly.Load(assemblyName);
				if (assemblyLoaded != null)
				{
					ChatterDebug.LogMessage("ChatterReborn loaded another ASM : " + assemblyName);
					return true;
				}
			}
			catch (Exception ex)
			{
				ChatterDebug.LogError("Could not load " + assemblyName + ": it does not exist! \nERROR : " + ex.Message);
			}
			return false;
		}

		public static bool DoesAssemblyExist(string stringLookUp)
		{
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			for (int i = 0; i < assemblies.Length; i++)
			{
				if (assemblies[i].FullName.Contains(stringLookUp))
				{
					return true;
				}
			}
			return false;
		}

		public static void LogAllAssemblies()
		{
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				ChatterDebug.LogMessage("Assembly : " + assembly.FullName);
			}
		}

		public static void LoadDevComponents()
		{
		}
	}
	public class DebugLoggerObject
	{
		private string _preffix;

		public DebugLoggerObject(string id)
		{
			_preffix = id;
		}

		public void DebugPrint(object o, eLogType eLogType = eLogType.Debug)
		{
			switch (eLogType)
			{
			case eLogType.Debug:
				ChatterDebug.LogDebug(_preffix + " - " + o);
				break;
			case eLogType.Message:
				ChatterDebug.LogMessage(_preffix + " - " + o);
				break;
			case eLogType.Warning:
				ChatterDebug.LogWarning(_preffix + " - " + o);
				break;
			case eLogType.Error:
				ChatterDebug.LogError(_preffix + " - " + o);
				break;
			case eLogType.None:
				break;
			}
		}
	}
	public struct DelayValue
	{
		public float totalTimer;

		public static implicit operator DelayValue(MinMaxTimer val)
		{
			return new DelayValue(val);
		}

		public static implicit operator DelayValue(float val)
		{
			return new DelayValue(val);
		}

		public static implicit operator float(DelayValue val)
		{
			return val.totalTimer;
		}

		public DelayValue(float timer)
		{
			totalTimer = timer;
		}

		public DelayValue(MinMaxTimer minMaxTimer)
		{
			totalTimer = Random.Range(minMaxTimer.min, minMaxTimer.max);
		}
	}
	public class GlobalPatcher
	{
		private static bool m_inited;

		private static ChatterPatcher<GlobalPatcher> m_patcher;

		public static void InitiatePatches()
		{
			if (!m_inited)
			{
				m_inited = true;
				m_patcher = new ChatterPatcher<GlobalPatcher>("ChatterGlobal");
				m_patcher.Patch<ElevatorRide>("StartElevatorRide", (HarmonyPatchType)2, BindingFlags.Static | BindingFlags.Public);
				m_patcher.Patch<ElevatorRide>("OnGSWantToStartExpedition", (HarmonyPatchType)2, BindingFlags.Static | BindingFlags.Public);
				m_patcher.Patch<ElevatorRide>("DropinElevatorExit", (HarmonyPatchType)2, BindingFlags.Static | BindingFlags.Public);
				m_patcher.Patch<Global>("OnLevelCleanup", (HarmonyPatchType)2, BindingFlags.Static | BindingFlags.Public);
				m_patcher.Patch<Global>("OnResetSession", (HarmonyPatchType)2, BindingFlags.Static | BindingFlags.Public);
				m_patcher.Patch<PlayerAgent>("Setup", (HarmonyPatchType)2, BindingFlags.Instance | BindingFlags.Public);
				m_patcher.Patch<PlayerAgent>("OnDespawn", (HarmonyPatchType)2, BindingFlags.Instance | BindingFlags.Public);
			}
		}

		[MethodDecoderToken]
		private static void PlayerAgent__Setup__Postfix(PlayerAgent __instance, int characterID)
		{
			if (((Agent)__instance).IsLocallyOwned)
			{
				ManagerInit.ManagerHandler.OnRegisterLocalPlayerAgent(((Il2CppObjectBase)__instance).TryCast<LocalPlayerAgent>());
			}
			else
			{
				ManagerInit.ManagerHandler.OnRegisterPlayerAgent(__instance);
			}
		}

		[MethodDecoderToken]
		private static void PlayerAgent__OnDespawn__Postfix(PlayerAgent __instance)
		{
			if (((Agent)__instance).IsLocallyOwned)
			{
				ManagerInit.ManagerHandler.DeRegisterLocalPlayerAgent(((Il2CppObjectBase)__instance).TryCast<LocalPlayerAgent>());
			}
			else
			{
				ManagerInit.ManagerHandler.DeRegisterPlayerAgent(__instance);
			}
		}

		[MethodDecoderToken]
		private static void ElevatorRide__StartElevatorRide__Postfix()
		{
			ManagerInit.ManagerHandler.OnStartElevatorRide();
		}

		[MethodDecoderToken]
		private static void ElevatorRide__OnGSWantToStartExpedition__Postfix()
		{
			ManagerInit.ManagerHandler.OnStartExpedition();
		}

		[MethodDecoderToken]
		private static void ElevatorRide__DropinElevatorExit__Postfix()
		{
			ManagerInit.ManagerHandler.OnDropInElevatorExit();
		}

		[MethodDecoderToken]
		private static void Global__OnLevelCleanup__Postfix()
		{
			ManagerInit.ManagerHandler.OnLevelCleanup();
		}

		[MethodDecoderToken]
		private static void Global__OnResetSession__Postfix()
		{
			ManagerInit.ManagerHandler.OnResetSession();
		}
	}
	public static class ExtendedStringUtils
	{
		public static void EliminateInvalidCharacters(ref string word)
		{
			char[] invalidFileNameChars = Path.GetInvalidFileNameChars();
			foreach (char oldChar in invalidFileNameChars)
			{
				word = word.Replace(oldChar, '_');
			}
			invalidFileNameChars = Path.GetInvalidPathChars();
			foreach (char oldChar2 in invalidFileNameChars)
			{
				word = word.Replace(oldChar2, '_');
			}
			word = word.Replace('-', '_');
			word = word.Replace(' ', '_');
		}
	}
	public static class Il2cppPackager
	{
		private static List<ComponentPackage> m_packagesOnLoaded = new List<ComponentPackage>();

		private static List<Type> AssemblyTypes => AssemblyUtils.CurrentAssemblies;

		public static void RegisterIl2cppTypes()
		{
			foreach (Type assemblyType in AssemblyTypes)
			{
				IL2CPPTypeAttribute customAttribute = assemblyType.GetCustomAttribute<IL2CPPTypeAttribute>();
				if (customAttribute != null && !ClassInjector.IsTypeRegisteredInIl2Cpp(assemblyType))
				{
					ClassInjector.RegisterTypeInIl2Cpp(assemblyType);
					ChatterDebug.LogMessage("Registering il2cpp monobehavior : " + assemblyType.Name);
					if (customAttribute.AddComponentOnStart)
					{
						m_packagesOnLoaded.Add(new ComponentPackage
						{
							Type = assemblyType,
							DontDestroyOnLoad = customAttribute.DontDestroyOnLoad
						});
					}
				}
			}
		}

		public static void AddComponentsUponStartUp()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			if (m_packagesOnLoaded.Count == 0)
			{
				return;
			}
			foreach (ComponentPackage item in m_packagesOnLoaded)
			{
				Type il2CPPType = item.Il2CPPType;
				if (il2CPPType != (Type)null)
				{
					Component val = new GameObject().AddComponent(il2CPPType);
					ChatterDebug.LogDebug("Adding GameObject with il2cpp monobehavior : " + item.Type.Name);
					if (item.DontDestroyOnLoad)
					{
						Object.DontDestroyOnLoad((Object)(object)val);
					}
				}
				else
				{
					ChatterDebug.LogError("ERROR : failed getting Il2cpp Type from type " + item.Type.Name);
				}
			}
		}
	}
	public struct MethodToken
	{
		public string m_name;

		public uint m_tokenID;

		public bool HasToken => m_tokenID != 0;

		public static implicit operator string(MethodToken token)
		{
			return token.m_name;
		}

		public static implicit operator uint(MethodToken token)
		{
			return token.m_tokenID;
		}

		public static implicit operator MethodToken(string name)
		{
			return new MethodToken(name);
		}

		public static implicit operator MethodToken(uint tokenID)
		{
			return new MethodToken(tokenID);
		}

		public MethodToken(uint tokenID)
		{
			this = default(MethodToken);
			m_tokenID = tokenID;
		}

		public MethodToken(string name)
		{
			this = default(MethodToken);
			m_name = name;
		}

		public MethodToken(string name, uint tokenID)
		{
			m_tokenID = tokenID;
			m_name = name;
		}
	}
	internal static class MethodTokenUtils
	{
		private static Random m_rnd = new Random(1342134234);

		private static List<uint> m_codes = new List<uint>();

		internal static Dictionary<uint, MethodInfo> s_methodInfoBytokenID = new Dictionary<uint, MethodInfo>();

		internal static Dictionary<MethodInfo, uint> s_tokenIDByMethodInfo = new Dictionary<MethodInfo, uint>();

		internal static List<string> s_missingPatches = new List<string>();

		private static void GenerateRandomTokenIDs()
		{
			for (uint num = 100000u; num < 9000000; num++)
			{
				m_codes.Add(num);
			}
		}

		private static uint GetRandomTokenID()
		{
			uint num = m_codes[m_rnd.Next(0, m_codes.Count - 1)];
			m_codes.Remove(num);
			return num;
		}

		internal static void GenerateMethodTokenIDsFile()
		{
			GenerateRandomTokenIDs();
			foreach (Type currentAssembly in AssemblyUtils.CurrentAssemblies)
			{
				MethodInfo[] methods = currentAssembly.GetMethods(BindingFlags.Static | BindingFlags.NonPublic);
				if (methods == null)
				{
					continue;
				}
				MethodInfo[] array = methods;
				foreach (MethodInfo methodInfo in array)
				{
					if (methodInfo.GetCustomAttribute<MethodDecoderTokenAttribute>() != null)
					{
						AddTokenIDToMethodName(GetRandomTokenID(), methodInfo);
					}
				}
			}
		}

		internal static bool TryToGetMethodInfoByTokenID(uint tokenID, out MethodInfo methodInfo)
		{
			return s_methodInfoBytokenID.TryGetValue(tokenID, out methodInfo);
		}

		private static void AddTokenIDToMethodName(uint tokenID, MethodInfo methodInfo)
		{
			if (!s_methodInfoBytokenID.ContainsKey(tokenID))
			{
				ChatterDebug.LogMessage("MethodTokenUtils, Now adding a tokenID to method -> " + methodInfo.Name + " with the id -> " + tokenID);
				s_methodInfoBytokenID.Add(tokenID, methodInfo);
				s_tokenIDByMethodInfo.Add(methodInfo, tokenID);
			}
		}

		internal static void GenerateMethodTokenIDs()
		{
			ChatterDebug.LogMessage("MethodTokenUtils, now generating tokenIDs...");
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("namespace ChatterRebornTokens {");
			stringBuilder.AppendLine("\tpublic static class Tokens{");
			foreach (KeyValuePair<uint, MethodInfo> item in s_methodInfoBytokenID)
			{
				stringBuilder.AppendLine("\t\tpublic const uint " + item.Value.Name + " = " + item.Key + ";");
			}
			stringBuilder.AppendLine("\t}");
			stringBuilder.AppendLine("}");
			string text = Path.Combine(Paths.GameRootPath, "ChatterRebornMethodTokens");
			if (!Directory.Exists(text))
			{
				Directory.CreateDirectory(text);
			}
			File.WriteAllText(Path.Combine(text, "ChatterRebornTokens.cs"), stringBuilder.ToString());
		}

		internal static void AddMissingPatchName(string myMethodName)
		{
			if (!s_missingPatches.Contains(myMethodName))
			{
				s_missingPatches.Add(myMethodName);
			}
		}
	}
	public struct MinMaxTimer
	{
		public float min;

		public float max;

		public MinMaxTimer(float min, float max)
		{
			this.min = min;
			this.max = max;
		}
	}
	public struct WeightValue<V>
	{
		public V Value;

		public float Weight;

		public WeightValue(V value, float weight)
		{
			Weight = weight;
			Value = value;
		}
	}
	public class GameDataBlockUtils<T> where T : GameDataBlockBase<T>
	{
		public static void AddNewBlock(string name = "")
		{
			T val = GameDataBlockBase<T>.AddNewBlock();
			if (!string.IsNullOrWhiteSpace(name))
			{
				((GameDataBlockBase<T>)val).name = name;
			}
		}
	}
	public static class ChatterDebug
	{
		private static readonly ManualLogSource logger;

		static ChatterDebug()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			logger = new ManualLogSource("chatter-reborn");
			Logger.Sources.Add((ILogSource)(object)logger);
		}

		public static void Verbose(object msg)
		{
		}

		public static void LogDebug(object msg)
		{
		}

		public static void LogMessage(object msg)
		{
		}

		public static void LogError(object msg)
		{
		}

		public static void LogWarning(object msg)
		{
		}
	}
	public class DictionaryExtended<T1, T2> : Dictionary<T1, T2>
	{
		public void Set(T1 key, T2 value)
		{
			if (!ContainsKey(key))
			{
				Add(key, value);
			}
			else
			{
				base[key] = value;
			}
		}
	}
	public class ComponentList<T> where T : Component
	{
		private Dictionary<int, T> m_comp_list;

		public void CreateList()
		{
			m_comp_list = new Dictionary<int, T>();
		}

		public void Clear()
		{
			m_comp_list.Clear();
		}

		public void Add(T component)
		{
			int instanceID = ((Object)(object)component).GetInstanceID();
			if (!m_comp_list.ContainsKey(instanceID))
			{
				m_comp_list.Add(instanceID, component);
			}
		}

		public T GetComponent(int instanceID)
		{
			T value = default(T);
			m_comp_list.TryGetValue(instanceID, out value);
			return value;
		}

		public bool TryGetComponent(int instanceID, out T comp)
		{
			comp = GetComponent(instanceID);
			return (Object)(object)comp != (Object)null;
		}

		public void Remove(T component)
		{
			m_comp_list.Remove(((Object)(object)component).GetInstanceID());
		}
	}
	public static class GOUtils
	{
		public static void SetChildToGO(GameObject child, GameObject parent)
		{
			child.transform.parent = parent.transform;
		}

		public static T SafeAddComponent<T>(bool dontDestroyOnLoad = true) where T : MonoBehaviour
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (!ClassInjector.IsTypeRegisteredInIl2Cpp<T>())
			{
				ChatterDebug.LogError("Cannot Add Component " + typeof(T).Name + " is hasn't been registered in IL2CPP!!");
				return default(T);
			}
			T val = new GameObject().AddComponent<T>();
			if (dontDestroyOnLoad)
			{
				Object.DontDestroyOnLoad((Object)(object)val);
			}
			return val;
		}

		public static T AddAbsoluteComponent<T>(this GameObject gameobject, bool skipDuplication = false) where T : MonoBehaviour
		{
			if (!ClassInjector.IsTypeRegisteredInIl2Cpp<T>())
			{
				ChatterDebug.LogError("Cannot Add Component " + typeof(T).Name + " is hasn't been registered in IL2CPP!!");
				return default(T);
			}
			if (!skipDuplication && (Object)(object)gameobject.GetComponent<T>() != (Object)null)
			{
				return default(T);
			}
			return gameobject.AddComponent<T>();
		}

		public static T GetAbsoluteComponent<T>(this GameObject gameObject) where T : MonoBehaviour
		{
			T val = gameObject.GetComponent<T>();
			if ((Object)(object)val == (Object)null)
			{
				val = gameObject.GetComponentInParent<T>();
			}
			return val;
		}

		public static bool HasComponent<T>(this GameObject gameObject) where T : MonoBehaviour
		{
			return (Object)(object)gameObject.GetComponent<T>() != (Object)null;
		}

		public static bool HasComponentInParent<T>(this GameObject gameObject) where T : MonoBehaviour
		{
			return (Object)(object)gameObject.GetComponentInParent<T>() != (Object)null;
		}

		public static bool HasComponentInChildren<T>(this GameObject gameObject) where T : MonoBehaviour
		{
			return (Object)(object)gameObject.GetComponentInChildren<T>() != (Object)null;
		}
	}
	public static class Il2cppUtils
	{
		public static List<T> ToCppList<T>(List<T> list)
		{
			List<T> val = new List<T>();
			for (int i = 0; i < list.Count; i++)
			{
				T val2 = list[i];
				val.Add(val2);
			}
			return val;
		}

		public static List<T> ToSystemList<T>(this List<T> cpplist)
		{
			List<T> list = new List<T>();
			for (int i = 0; i < cpplist.Count; i++)
			{
				T item = cpplist[i];
				list.Add(item);
			}
			return list;
		}

		public static bool Convert<T, C>(this T from, out C isthis) where T : Il2CppObjectBase where C : Il2CppObjectBase
		{
			isthis = ((Il2CppObjectBase)from).TryCast<C>();
			return isthis != null;
		}

		public static bool IsCppType<C>(this Object from) where C : Il2CppObjectBase
		{
			return Il2CppType.Of<C>().Equals(from.GetIl2CppType());
		}

		public static Dictionary<TKey, TValue> ToSystemDictionary<TKey, TValue>(Dictionary<TKey, TValue> CppDictionary)
		{
			Dictionary<TKey, TValue> dictionary = new Dictionary<TKey, TValue>();
			Enumerator<TKey, TValue> enumerator = CppDictionary.Keys.GetEnumerator();
			TValue value = default(TValue);
			while (enumerator.MoveNext())
			{
				TKey current = enumerator.Current;
				if (CppDictionary.TryGetValue(current, ref value))
				{
					dictionary.Add(current, value);
				}
			}
			return dictionary;
		}

		public static T[] ToArray<T>(Il2CppArrayBase<T> cppArray)
		{
			T[] array = new T[cppArray.Length];
			for (int i = 0; i < cppArray.Length; i++)
			{
				array[i] = cppArray[i];
			}
			return array;
		}
	}
	public static class UnityPhysicsUtils
	{
		public static bool IsPostionVisible(Vector3 from, Vector3 to, out RaycastHit raycastHit)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			Ray val = default(Ray);
			((Ray)(ref val)).origin = from;
			Vector3 direction = to - from;
			float magnitude = ((Vector3)(ref direction)).magnitude;
			((Vector3)(ref direction)).Normalize();
			((Ray)(ref val)).direction = direction;
			return !Physics.Raycast(val, ref raycastHit, magnitude, LayerManager.MASK_WORLD);
		}

		public static bool CanSee(this Agent from, GameObject targetObject)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			_ = from.EyePosition;
			if (!IsPostionVisible(from.EyePosition, targetObject.transform.position, out var raycastHit) && !((Object)(object)((Component)((RaycastHit)(ref raycastHit)).transform).gameObject == (Object)(object)targetObject))
			{
				return ((RaycastHit)(ref raycastHit)).transform.IsChildOf(targetObject.transform);
			}
			return true;
		}
	}
	public class WeightHandler<T>
	{
		private List<WeightValue<T>> m_list;

		private static readonly bool DEBUG_ENABLED;

		public List<WeightValue<T>> List
		{
			get
			{
				return m_list;
			}
			set
			{
				m_list = value;
			}
		}

		public bool HasAny => Count > 0;

		public int Count => m_list.Count;

		public WeightValue<T> Best
		{
			get
			{
				if (m_list.Count == 0)
				{
					throw new Exception("You are trying to call the Best value for type " + typeof(T).Name + " which has no items in the array. Please insert a HasAny to prevent this error..");
				}
				float num = 0f;
				for (int i = 0; i < m_list.Count; i++)
				{
					num += m_list[i].Weight;
				}
				int num2 = m_list.Count;
				float num3 = num * Random.value;
				while (num >= num3)
				{
					num2--;
					num -= m_list[num2].Weight;
				}
				return m_list[num2];
			}
		}

		public void AddValue(T value, float weight)
		{
			m_list.Add(new WeightValue<T>
			{
				Value = value,
				Weight = weight
			});
		}

		public static WeightHandler<T> CreateWeightHandler(List<WeightValue<T>> weightValues = null)
		{
			WeightHandler<T> weightHandler = new WeightHandler<T>();
			weightHandler.m_list = new List<WeightValue<T>>();
			if (weightValues != null)
			{
				weightHandler.m_list.AddRange(weightValues);
			}
			return weightHandler;
		}

		public void Clear()
		{
			if (m_list != null)
			{
				m_list.Clear();
			}
		}

		public static void DebugLog(object o)
		{
			if (DEBUG_ENABLED)
			{
				ChatterDebug.LogWarning(o);
			}
		}

		public bool TryToGetBestValue(out WeightValue<T> val)
		{
			val = default(WeightValue<T>);
			if (!HasAny)
			{
				return false;
			}
			val = Best;
			return true;
		}
	}
}
namespace ChatterReborn.Utils.Patcher
{
	public class ChatterPatcher<T> : ChatterPatcherBase
	{
		public ChatterPatcher(string id)
			: base(id)
		{
		}

		public void Patch<S>(MethodToken methodName, HarmonyPatchType patchType)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			Patch(typeof(T), typeof(S), methodName, patchType, (MethodType)0);
		}

		public void Patch<S>(MethodToken methodName, HarmonyPatchType patchType, BindingFlags bindingFlags)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			Patch(typeof(T), typeof(S), methodName, patchType, (MethodType)0, bindingFlags);
		}

		public void Patch<S>(MethodToken methodName, HarmonyPatchType patchType, BindingFlags bindingFlags, Type[] types)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			Patch(typeof(T), typeof(S), methodName, patchType, (MethodType)0, bindingFlags, types);
		}

		public void Patch<S>(MethodToken methodName, HarmonyPatchType patchType, MethodType methodType)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			Patch(typeof(T), typeof(S), methodName, patchType, methodType);
		}

		public void Patch<S>(MethodToken methodName, HarmonyPatchType patchType, MethodType methodType, Type[] types)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			Patch(typeof(T), typeof(S), methodName, patchType, methodType, BindingFlags.Default, types);
		}

		public void Patch<S>(MethodToken methodName, HarmonyPatchType patchType, MethodType methodType, BindingFlags bindingFlags)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			Patch(typeof(T), typeof(S), methodName, patchType, methodType, bindingFlags);
		}

		public void Patch<S>(MethodToken methodName, HarmonyPatchType patchType, MethodType methodType, BindingFlags bindingFlags, Type[] types)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			Patch(typeof(T), typeof(S), methodName, patchType, methodType, bindingFlags, types);
		}
	}
	public abstract class ChatterPatcherBase
	{
		private Harmony m_harmonyInstance;

		private DebugLoggerObject m_logger;

		public ChatterPatcherBase(string id)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			m_harmonyInstance = new Harmony("Harmony_" + id);
			m_logger = new DebugLoggerObject(id);
		}

		protected void Patch(Type myclass, Type classType, MethodToken methodName, HarmonyPatchType patchType, MethodType methodType = 0, BindingFlags binding = BindingFlags.Default, Type[] types = null)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Invalid comparison between Unknown and I4
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Invalid comparison between Unknown and I4
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Invalid comparison between Unknown and I4
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Expected O, but got Unknown
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Invalid comparison between Unknown and I4
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Invalid comparison between Unknown and I4
			MethodInfo methodInfo = null;
			string text = string.Concat("[", classType?.ToString(), ".", methodName, "]");
			try
			{
				methodInfo = ((types != null) ? classType.GetMethod(methodName, binding, null, types, null) : (((int)methodType == 2) ? classType.GetProperty(methodName, binding)?.GetSetMethod() : (((int)methodType != 1) ? classType.GetMethod(methodName, binding) : classType.GetProperty(methodName, binding)?.GetGetMethod())));
			}
			catch (Exception ex)
			{
				m_logger.DebugPrint("ERROR: Fatal error has occurred when patching " + text + "\nERROR MESSAGE : " + ex.Message, eLogType.Error);
				return;
			}
			if (methodInfo == null)
			{
				m_logger.DebugPrint("FAILED: Patching " + text + " MethodInfo has returned null!", eLogType.Error);
				return;
			}
			string empty = string.Empty;
			empty = (((int)patchType != 2) ? string.Concat(classType.Name, "__", methodName, "__Prefix") : string.Concat(classType.Name, "__", methodName, "__Postfix"));
			MethodInfo methodInfo2 = myclass.GetMethod(empty, BindingFlags.Static | BindingFlags.NonPublic);
			if (methodName.HasToken)
			{
				if (MethodTokenUtils.TryToGetMethodInfoByTokenID(methodName.m_tokenID, out var methodInfo3))
				{
					m_logger.DebugPrint("myMethodName " + empty + " Has gotten overriden Token methodInfo instead with id -> " + methodName.m_tokenID, eLogType.Message);
					methodInfo2 = methodInfo3;
				}
				else
				{
					m_logger.DebugPrint("myMethodName " + empty + " has a tokenID but does not exist!??", eLogType.Error);
				}
			}
			else
			{
				m_logger.DebugPrint("MissingTokenID: myMethodName " + empty + ", consider adding a tokenID!", eLogType.Warning);
			}
			if (methodInfo2 == null)
			{
				m_logger.DebugPrint("FAILED: Patching " + text + " Could not get my method [" + empty + "]", eLogType.Error);
				return;
			}
			if (methodInfo2.GetCustomAttribute<MethodDecoderTokenAttribute>() == null)
			{
				m_logger.DebugPrint("MethodDecoderTokenAttribute missing: [" + empty + "]", eLogType.Warning);
			}
			HarmonyMethod val = new HarmonyMethod(methodInfo2);
			val.methodType = methodType;
			if ((int)patchType == 2)
			{
				try
				{
					m_harmonyInstance.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					m_logger.DebugPrint("SUCCESS : PostFix patching method -> " + empty);
					return;
				}
				catch
				{
					m_logger.DebugPrint("FAILED : PostFix patching method -> " + empty, eLogType.Error);
					return;
				}
			}
			if ((int)patchType != 1)
			{
				return;
			}
			try
			{
				m_harmonyInstance.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				m_logger.DebugPrint("SUCCESS : Prefix patching method -> " + empty);
			}
			catch
			{
				m_logger.DebugPrint("FAILED : Prefix patching method -> " + empty, eLogType.Error);
			}
		}
	}
}
namespace ChatterReborn.Utils.Machine
{
	public abstract class MachineStateBase
	{
		public byte ENUM_ID;

		public float StateChangeTime;

		public bool DEBUG_ENABLED;

		public virtual void Enter()
		{
		}

		public virtual void SyncEnter()
		{
		}

		public virtual void Exit()
		{
		}

		public virtual void SyncExit()
		{
		}

		public virtual void Update()
		{
		}

		public virtual void SyncUpdate()
		{
		}

		public virtual void OnLevelCleanUp()
		{
		}

		public virtual void OnDestroyed()
		{
		}

		public virtual void Setup()
		{
		}

		public void DebugPrint(string text)
		{
			if (DEBUG_ENABLED)
			{
				ChatterDebug.LogMessage(GetType().Name + " - " + text);
			}
		}

		public abstract void SetMachine(StateMachineBase stateMachine);
	}
	public abstract class StateMachineBase
	{
		public float m_changeStateTime;

		protected bool m_IsSetup;

		public int m_state_count;

		protected float m_localDeltaRef;

		public float m_localDelta;

		public abstract bool DEBUG_ENABLED { get; set; }

		public virtual bool IsLocallyOwned => true;

		public abstract void ChangeState(int id);

		public abstract void Reset();

		public abstract void OnCurrentState(int id);

		public abstract void OnLastState(int id);
	}
	public class StateMachineExtended<MS, E> : StateMachine<MS> where MS : MachineStateBase where E : Enum
	{
		private Type m_stateEnumType;

		private E[] m_enumStates;

		private E m_currentStateName;

		private E m_lastStateName;

		public E CurrentStateName => m_currentStateName;

		public E LastStateName => m_lastStateName;

		protected void SetupMachine()
		{
			m_stateEnumType = typeof(E);
			IList values = Enum.GetValues(m_stateEnumType);
			m_state_count = values.Count;
			m_states = new MS[m_state_count];
			m_enumStates = new E[m_state_count];
			for (int i = 0; i < values.Count; i++)
			{
				m_enumStates[i] = (E)values[i];
			}
		}

		protected MS AddState(E stateEnum, MS stateInstance)
		{
			return AddState(Convert.ToInt32(stateEnum), stateInstance);
		}

		public override void OnCurrentState(int id)
		{
			m_currentStateName = m_enumStates[id];
		}

		public override void OnLastState(int id)
		{
			m_lastStateName = m_enumStates[id];
		}

		public void ChangeState(E state)
		{
			ChangeState(Convert.ToInt32(state));
		}

		public MS GetState(E stateEnum)
		{
			return m_states[Convert.ToInt32(stateEnum)];
		}
	}
	public abstract class MachineState<SM> : MachineStateBase where SM : StateMachineBase
	{
		public SM m_machine;

		public override void SetMachine(StateMachineBase stateMachine)
		{
			m_machine = (SM)stateMachine;
		}
	}
	public abstract class StateMachine<MS> : StateMachineBase where MS : MachineStateBase
	{
		public MS[] m_states;

		public MS m_last_state;

		public MS m_current_state = Activator.CreateInstance<MS>();

		private MS m_start_state;

		private bool m_debug_enabled;

		public override bool DEBUG_ENABLED
		{
			get
			{
				return m_debug_enabled;
			}
			set
			{
				m_debug_enabled = value;
				if (m_states == null)
				{
					return;
				}
				MS[] states = m_states;
				foreach (MS val in states)
				{
					if (val != null)
					{
						val.DEBUG_ENABLED = value;
					}
				}
			}
		}

		public MS StartState
		{
			get
			{
				return m_start_state;
			}
			set
			{
				m_start_state = value;
				if (value != null)
				{
					ChangeState(value);
				}
			}
		}

		protected MS AddState(int stateID, MS instance)
		{
			instance.DEBUG_ENABLED = DEBUG_ENABLED;
			instance.SetMachine(this);
			instance.ENUM_ID = (byte)stateID;
			m_states[stateID] = instance;
			instance.Setup();
			return instance;
		}

		public override void ChangeState(int stateID)
		{
			ChangeState(m_states[stateID]);
		}

		public void ChangeState(MS state)
		{
			m_last_state = m_current_state;
			if (m_last_state != null)
			{
				OnLastState(m_last_state.ENUM_ID);
			}
			m_current_state = state;
			m_current_state.StateChangeTime = Clock.Time;
			m_changeStateTime = Clock.Time;
			OnCurrentState(m_current_state.ENUM_ID);
			if (IsLocallyOwned)
			{
				if (m_last_state != null)
				{
					m_last_state.Exit();
				}
				m_current_state.Enter();
			}
			else
			{
				if (m_last_state != null)
				{
					m_last_state.SyncExit();
				}
				m_current_state.SyncEnter();
			}
		}

		public virtual void UpdateState()
		{
			m_localDelta = Clock.Time - m_localDeltaRef;
			m_localDeltaRef = Clock.Time;
			if (IsLocallyOwned)
			{
				m_current_state.Update();
			}
			else
			{
				m_current_state.SyncUpdate();
			}
		}

		public virtual void OnLevelCleanUp()
		{
		}

		public virtual void OnDestroyed()
		{
		}

		public override void Reset()
		{
			if (m_start_state != null)
			{
				ChangeState(m_start_state);
			}
		}

		public MS GetState(int id)
		{
			return m_states[id];
		}
	}
}
namespace ChatterReborn.Utils.JSON
{
	public static class JsonUtils
	{
		public static bool JsonExist { get; set; }
	}
}
namespace ChatterReborn.Utils.Extensions
{
	public static class PlayerAgentExtensions
	{
		public static void Say(this PlayerAgent playerAgent, uint eventID)
		{
			PlayerVoiceManager.WantToSay(playerAgent.CharacterID, eventID);
		}

		public static void SayAndStartDialog(this PlayerAgent playerAgent, uint eventID, uint startDialog)
		{
			PlayerVoiceManager.WantToSayAndStartDialog(playerAgent.CharacterID, eventID, startDialog);
		}

		public static List<PlayerAgent> GetAllBotPlayerAgents()
		{
			List<PlayerAgent> list = new List<PlayerAgent>();
			List<SNet_Player> list2 = SNet.Core.GetAllBots(true).ToSystemList<SNet_Player>();
			for (int i = 0; i < list2.Count; i++)
			{
				SNet_Player obj = list2[i];
				object obj2;
				if (obj == null)
				{
					obj2 = null;
				}
				else
				{
					SNet_IPlayerAgent playerAgent = obj.PlayerAgent;
					obj2 = ((playerAgent != null) ? ((Il2CppObjectBase)playerAgent).TryCast<PlayerAgent>() : null);
				}
				PlayerAgent val = (PlayerAgent)obj2;
				if ((Object)(object)val != (Object)null)
				{
					list.Add(val);
				}
			}
			return list;
		}

		public static bool IsInfectionStable(this PlayerAgent playerAgent)
		{
			return playerAgent.Damage.Infection + ((Dam_SyncedDamageBase)playerAgent.Damage).GetHealthRel() <= 1f;
		}

		public static bool IsBotOwned(this PlayerAgent playerAgent)
		{
			if (playerAgent.Owner.IsBot)
			{
				return SNet.IsMaster;
			}
			return false;
		}

		public static void WantToStartDialog(this PlayerAgent playerAgent, uint dialogID, bool forced = false)
		{
			if (forced)
			{
				PlayerDialogManager.WantToStartDialogForced(dialogID, playerAgent);
			}
			else
			{
				PlayerDialogManager.WantToStartDialog(dialogID, playerAgent);
			}
		}

		public static void WantToSay(this PlayerAgent playerAgent, uint eventID)
		{
			PlayerVoiceManager.WantToSay(playerAgent.CharacterID, eventID);
		}
	}
}
namespace ChatterReborn.Utils.Callback
{
	public static class CallBackUtils
	{
		public class CallBack : CallBackBase<Action>
		{
			public CallBack(Action action)
				: base(action)
			{
			}

			public override void Execute()
			{
				m_action();
			}

			public void QueueCallBack(DelayValue timer)
			{
				Queue(timer);
			}
		}

		public class CallBack<T1> : CallBackBase<Action<T1>>
		{
			private T1 par1;

			public CallBack(Action<T1> action)
				: base(action)
			{
			}

			public override void Execute()
			{
				m_action(par1);
			}

			public void QueueCallBack(DelayValue timer, T1 p1)
			{
				par1 = p1;
				Queue(timer);
			}
		}

		public class CallBack<T1, T2> : CallBackBase<Action<T1, T2>>
		{
			private T1 par1;

			private T2 par2;

			public CallBack(Action<T1, T2> action)
				: base(action)
			{
			}

			public override void Execute()
			{
				m_action(par1, par2);
			}

			public void QueueCallBack(DelayValue timer, T1 p1, T2 p2)
			{
				par1 = p1;
				par2 = p2;
				Queue(timer);
			}
		}

		public class CallBack<T1, T2, T3> : CallBackBase<Action<T1, T2, T3>>
		{
			private T1 par1;

			private T2 par2;

			private T3 par3;

			public CallBack(Action<T1, T2, T3> action)
				: base(action)
			{
			}

			public override void Execute()
			{
				m_action(par1, par2, par3);
			}

			public void QueueCallBack(DelayValue timer, T1 p1, T2 p2, T3 p3)
			{
				par1 = p1;
				par2 = p2;
				par3 = p3;
				Queue(timer);
			}
		}

		public class CallBack<T1, T2, T3, T4> : CallBackBase<Action<T1, T2, T3, T4>>
		{
			private T1 par1;

			private T2 par2;

			private T3 par3;

			private T4 par4;

			public CallBack(Action<T1, T2, T3, T4> action)
				: base(action)
			{
			}

			public override void Execute()
			{
				m_action(par1, par2, par3, par4);
			}

			public void QueueCallBack(DelayValue timer, T1 p1, T2 p2, T3 p3, T4 p4)
			{
				par1 = p1;
				par2 = p2;
				par3 = p3;
				par4 = p4;
				Queue(timer);
			}
		}

		public class CallBack<T1, T2, T3, T4, T5> : CallBackBase<Action<T1, T2, T3, T4, T5>>
		{
			private T1 par1;

			private T2 par2;

			private T3 par3;

			private T4 par4;

			private T5 par5;

			public CallBack(Action<T1, T2, T3, T4, T5> action)
				: base(action)
			{
			}

			public override void Execute()
			{
				m_action(par1, par2, par3, par4, par5);
			}

			public void QueueCallBack(DelayValue timer, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5)
			{
				par1 = p1;
				par2 = p2;
				par3 = p3;
				par4 = p4;
				par5 = p5;
				Queue(timer);
			}
		}

		public class CallBack<T1, T2, T3, T4, T5, T6> : CallBackBase<Action<T1, T2, T3, T4, T5, T6>>
		{
			private T1 par1;

			private T2 par2;

			private T3 par3;

			private T4 par4;

			private T5 par5;

			private T6 par6;

			public CallBack(Action<T1, T2, T3, T4, T5, T6> action)
				: base(action)
			{
			}

			public override void Execute()
			{
				m_action(par1, par2, par3, par4, par5, par6);
			}

			public void QueueCallBack(DelayValue timer, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6)
			{
				par1 = p1;
				par2 = p2;
				par3 = p3;
				par4 = p4;
				par5 = p5;
				par6 = p6;
				Queue(timer);
			}
		}

		public abstract class CallBackBase
		{
			public float ExecuteTimer { get; set; }

			public bool Started { get; set; }

			public abstract void Execute();

			public void RemoveCallBack()
			{
				CallBackManager.CallBacks.Remove(this);
			}

			protected void Queue(DelayValue timer)
			{
				if ((float)timer <= 0f)
				{
					Execute();
					return;
				}
				ExecuteTimer = Clock.Time + (float)timer;
				Started = false;
				if (CallBackManager.CallBacks.Contains(this))
				{
					CallBackManager.CallBacks.Remove(this);
				}
				CallBackManager.CallBacks.Add(this);
			}
		}

		public abstract class CallBackBase<T> : CallBackBase
		{
			protected T m_action;

			public CallBackBase(T action)
			{
				m_action = action;
			}
		}
	}
}
namespace ChatterReborn.Managers
{
	public class AgentDamageManager : ChatterManager<AgentDamageManager>
	{
		private const bool m_allowDamageSFX = true;

		protected override void PostSetup()
		{
			Type[] types = new Type[9]
			{
				typeof(float),
				typeof(Agent),
				typeof(Vector3),
				typeof(Vector3),
				typeof(Vector3),
				typeof(bool),
				typeof(int),
				typeof(float),
				typeof(float)
			};
			Type[] types2 = new Type[11]
			{
				typeof(float),
				typeof(Agent),
				typeof(Vector3),
				typeof(Vector3),
				typeof(int),
				typeof(float),
				typeof(float),
				typeof(float),
				typeof(float),
				typeof(bool),
				typeof(DamageNoiseLevel)
			};
			m_patcher.Patch<Dam_EnemyDamageBase>("BulletDamage", (HarmonyPatchType)2, BindingFlags.Instance | BindingFlags.Public, types);
			m_patcher.Patch<Dam_EnemyDamageBase>("MeleeDamage", (HarmonyPatchType)2, BindingFlags.Instance | BindingFlags.Public, types2);
			m_patcher.Patch<Dam_SyncedDamageBase>("TentacleAttackDamage", (HarmonyPatchType)2, BindingFlags.Instance | BindingFlags.Public);
			m_patcher.Patch<Dam_SyncedDamageBase>("ShooterProjectileDamage", (HarmonyPatchType)2, BindingFlags.Instance | BindingFlags.Public);
			m_patcher.Patch<Dam_SyncedDamageBase>("MeleeDamage", (HarmonyPatchType)2, BindingFlags.Instance | BindingFlags.Public);
			m_patcher.Patch<Dam_PlayerDamageLocal>("ReceiveBulletDamage", (HarmonyPatchType)1, BindingFlags.Instance | BindingFlags.Public);
			m_patcher.Patch<PlayerVoice>("VoiceCallback", (HarmonyPatchType)1, BindingFlags.Instance | BindingFlags.Public);
		}

		[MethodDecoderToken]
		private static void Dam_EnemyDamageBase__BulletDamage__Postfix(Dam_EnemyDamageBase __instance, float dam, Agent sourceAgent)
		{
			EnemyDamageEvent chatterEvent = default(EnemyDamageEvent);
			chatterEvent.m_attacker = sourceAgent;
			chatterEvent.m_damageReceiver = __instance.Owner;
			chatterEvent.m_killed = ((Dam_SyncedDamageBase)__instance).WillDamageKill(dam);
			chatterEvent.m_damageType = DamageType.Bullet;
			ChatterEventListenerHandler<EnemyDamageEvent>.PostEvent(chatterEvent);
		}

		[MethodDecoderToken]
		private static void Dam_EnemyDamageBase__MeleeDamage__Postfix(Dam_EnemyDamageBase __instance, float dam, Agent sourceAgent)
		{
			EnemyDamageEvent chatterEvent = default(EnemyDamageEvent);
			chatterEvent.m_attacker = sourceAgent;
			chatterEvent.m_damageReceiver = __instance.Owner;
			chatterEvent.m_killed = ((Dam_SyncedDamageBase)__instance).WillDamageKill(dam);
			chatterEvent.m_damageType = DamageType.Melee;
			ChatterEventListenerHandler<EnemyDamageEvent>.PostEvent(chatterEvent);
		}

		[MethodDecoderToken]
		private static void Dam_PlayerDamageLocal__ReceiveBulletDamage__Prefix(Dam_PlayerDamageLocal __instance)
		{
			if (__instance.m_damageVoiceTimer < Time.time)
			{
				((Dam_PlayerDamageBase)__instance).Owner.WantToStartDialog(152u, forced: true);
				__instance.m_damageVoiceTimer = Time.time + 2f;
			}
		}

		[MethodDecoderToken]
		private static void PlayerVoice__VoiceCallback__Prefix(PlayerVoice __instance)
		{
			if ((Object)(object)__instance != (Object)null && (Object)(object)__instance.m_owner != (Object)null && __instance.m_dialogToStart != 0 && __instance.m_owner.IsBotOwned())
			{
				PlayerDialogManager.WantToStartDialog(__instance.m_dialogToStart, __instance.m_playerID, false, false);
			}
		}

		[MethodDecoderToken]
		private static void Dam_PlayerDamageBase__OnIncomingDamage__Postfix(Dam_PlayerDamageBase __instance, float damage)
		{
			PlayerDamageEvent chatterEvent = default(PlayerDamageEvent);
			chatterEvent.damageAmount = damage;
			chatterEvent.damageReceiver = __instance.Owner;
			ChatterEventListenerHandler<PlayerDamageEvent>.PostEvent(chatterEvent);
		}

		[MethodDecoderToken]
		private static void Dam_SyncedDamageBase__TentacleAttackDamage__Postfix(Dam_SyncedDamageBase __instance)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Invalid comparison between Unknown and I4
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Invalid comparison between Unknown and I4
			PlayerAgent val = ((Il2CppObjectBase)__instance.GetBaseAgent()).TryCast<PlayerAgent>();
			if ((Object)(object)val != (Object)null && val.IsBotOwned())
			{
				uint num = 27u;
				if (((int)val.Inventory.WieldedSlot == 1 || (int)val.Inventory.WieldedSlot == 2) && !val.Inventory.HasAmmoInEquipped())
				{
					num = 149u;
				}
				PlayerVoiceManager.WantToSayAndStartDialog(val.CharacterID, 2083248599u, num);
			}
		}

		[MethodDecoderToken]
		private static void Dam_SyncedDamageBase__ShooterProjectileDamage__Postfix(Dam_SyncedDamageBase __instance)
		{
			PlayerAgent val = ((Il2CppObjectBase)__instance.GetBaseAgent()).TryCast<PlayerAgent>();
			if ((Object)(object)val != (Object)null)
			{
				OnHitReactBot(val);
			}
		}

		[MethodDecoderToken]
		private static void Dam_SyncedDamageBase__MeleeDamage__Postfix(Dam_SyncedDamageBase __instance)
		{
			PlayerAgent val = ((Il2CppObjectBase)__instance.GetBaseAgent()).TryCast<PlayerAgent>();
			if ((Object)(object)val != (Object)null)
			{
				OnHitReactBot(val);
			}
		}

		private static void OnHitReactBot(PlayerAgent playerAgent)
		{
			if (playerAgent.IsBotOwned())
			{
				DialogBotManager.OnHitReactBot(playerAgent);
			}
		}
	}
	public abstract class ChatterManagerBase
	{
		protected void BaseSetup()
		{
			DebugPrint("New Manager Initialized", eLogType.Message);
		}

		protected virtual void Setup()
		{
		}

		public virtual void OnGUI()
		{
		}

		protected virtual void PostSetup()
		{
		}

		protected void BasePostSetup()
		{
			DebugPrint("Post Setting up");
			ManagerInit.ManagerHandler.Managers.Add(this);
		}

		public virtual void OnLevelCleanUp()
		{
		}

		public virtual void OnResetSession()
		{
		}

		public virtual void OnElevatorArrived()
		{
		}

		public virtual void OnDropElevatorExit()
		{
		}

		public virtual void OnBuildDone()
		{
		}

		public virtual void OnStartExpedition()
		{
		}

		public virtual void OnDropInElevatorExit()
		{
		}

		public virtual void Update()
		{
		}

		public virtual void FixedUpdate()
		{
		}

		public abstract void Initialize(bool firstSetup = false);

		protected virtual void DebugPrint(object message, eLogType logType = eLogType.Debug)
		{
		}

		protected void LogDebug(object message)
		{
			DebugPrint(message);
		}

		protected void LogWarning(object message)
		{
			DebugPrint(message, eLogType.Warning);
		}

		protected void LogError(object message)
		{
			DebugPrint(message, eLogType.Error);
		}

		protected void LogMessage(object message)
		{
			DebugPrint(message, eLogType.Message);
		}

		public virtual void On_Registered_PlayerAgent(PlayerAgent playerAgent)
		{
		}

		public virtual void On_DeRegistered_PlayerAgent(PlayerAgent playerAgent)
		{
		}

		public virtual void On_Registered_LocalPlayerAgent(LocalPlayerAgent localPlayerAgent)
		{
		}

		public virtual void On_DeRegistered_LocalPlayerAgent(LocalPlayerAgent localPlayerAgent)
		{
		}

		public virtual void OnStartElevatorRide()
		{
		}

		public virtual void OnDropinElevatorExit()
		{
		}
	}
	public class PlayerLobbyVideoCreatorManager : ChatterManager<PlayerLobbyVideoCreatorManager>
	{
		private const bool m_allow = false;

		public override void Update()
		{
			UpdateMasterCommands();
		}

		private static void UpdateMasterCommands()
		{
		}
	}
	public class ExtraTextDataBlockManager : ChatterManager<ExtraTextDataBlockManager>
	{
		private bool m_initialized;

		private uint m_latestID;

		private Dictionary<CustomTextDataBlock, TextDataBlock> m_customTextBlocks;

		private List<uint> m_customTextDataBlockIDs;

		protected override void Setup()
		{
			AddExtraTextBlocks();
		}

		private void AddExtraTextBlocks()
		{
			m_customTextBlocks = new Dictionary<CustomTextDataBlock, TextDataBlock>();
			m_customTextDataBlockIDs = new List<uint>();
			AddNewBlock("Extras!", CustomTextDataBlock.MoreResponses);
			AddNewBlock("Acknowledgements", CustomTextDataBlock.Acknowledgements);
			AddNewBlock("Pick a Target", CustomTextDataBlock.SneakKillTargets);
			AddNewBlock("Directions", CustomTextDataBlock.Directions);
			AddNewBlock("..Pick Target", CustomTextDataBlock.PickAttackTarget);
			AddNewBlock("Combat", CustomTextDataBlock.Combat);
			AddNewBlock("Resources", CustomTextDataBlock.Resources);
			AddNewBlock("..Ping Resources", CustomTextDataBlock.PingResources);
			AddNewBlock("..Ping Consumables", CustomTextDataBlock.PingConsumables);
			AddNewBlock("Story", CustomTextDataBlock.StoryMode);
			AddNewBlock("Rundown 5", CustomTextDataBlock.StoryMode_R5_Title);
			AddNewBlock("(R5) React To Woods Log 1", CustomTextDataBlock.StoryMode_R5_React_to_Woods_Log_1);
			AddNewBlock("(R5) React To Woods Log 2", CustomTextDataBlock.StoryMode_R5_React_to_Woods_Log_2);
			AddNewBlock("(R5) React To Dauda Log 1", CustomTextDataBlock.StoryMode_R5_React_to_Dauda_Log_1);
			AddNewBlock("(R5) React To Dauda Log 2", CustomTextDataBlock.StoryMode_R5_React_to_Dauda_Log_2);
			AddNewBlock("(R5) React To Hackett Log 1", CustomTextDataBlock.StoryMode_R5_React_to_Hackett_Log_1);
			AddNewBlock("(R5) React To Hackett Log 2", CustomTextDataBlock.StoryMode_R5_React_to_Hackett_Log_2);
			AddNewBlock("(R5) React To Bishop Log 1", CustomTextDataBlock.StoryMode_R5_React_to_Bishop_Log_1);
			AddNewBlock("(R5) React To Bishop Log 2", CustomTextDataBlock.StoryMode_R5_React_to_Bishop_Log_2);
			AddNewBlock("Rundown 6", CustomTextDataBlock.StoryMode_R6_Title);
			AddNewBlock("(R6) On picked up Matter Wave Projector", CustomTextDataBlock.StoryMode_R6_PickUpMWP);
			AddNewBlock("(R6) Teleported first time", CustomTextDataBlock.StoryMode_R6_Teleported_First_Time);
			AddNewBlock("(R6) Big Walk Comment", CustomTextDataBlock.StoryMode_R6_BigWalkComment);
			AddNewBlock("(R6) Spotted flyers first time", CustomTextDataBlock.StoryMode_R6_SpotFlyingMonstersFirstTime);
			AddNewBlock("(R6) Teleported back first time", CustomTextDataBlock.StoryMode_R6_TeleportedBackFirstTime);
			AddNewBlock("(R6) Monsters came back with us", CustomTextDataBlock.StoryMode_R6_TeleportedMonstersBack);
			AddNewBlock("Rundown 8", CustomTextDataBlock.StoryMode_R8_Title);
			AddNewBlock("Rundown 8 (ALT Group)", CustomTextDataBlock.StoryMode_R8_ALT_Title);
			AddNewBlock("Rundown 8 (OG Group 1)", CustomTextDataBlock.StoryMode_R8_OG_1_Title);
			AddNewBlock("Rundown 8 (OG Group 2)", CustomTextDataBlock.StoryMode_R8_OG_2_Title);
			AddNewBlock("Rundown 8 (OG Group 3)", CustomTextDataBlock.StoryMode_R8_OG_3_Title);
			AddNewBlock("Rundown 8 (OG Group 4)", CustomTextDataBlock.StoryMode_R8_OG_4_Title);
			AddNewBlock("Rundown 8 (Jungle)", CustomTextDataBlock.StoryMode_R8_Jungle_Title);
			AddNewBlock("(R8) Do you hear?", CustomTextDataBlock.StoryMode_R8_NT_DoYouHear);
			AddNewBlock("(R8 ALT) I guess we should help them", CustomTextDataBlock.StoryMode_R8_NT_ALT_DoorHelp);
			AddNewBlock("(R8 ALT) We have company, let's hope they can go through with it.", CustomTextDataBlock.StoryMode_R8_NT_ALT_MicroDrive);
			AddNewBlock("(R8 ALT) I guess we should help them, again", CustomTextDataBlock.StoryMode_R8_NT_ALT_PowerHelp);
			AddNewBlock("(R8 ALT) We did it! We survived! Let's find away out before mor-", CustomTextDataBlock.StoryMode_R8_NT_ALT_LastStand);
			AddNewBlock("(R8 ALT) No luck, it has been an honor fighting with you guys.", CustomTextDataBlock.StoryMode_R8_NT_ALT_LastStand_2);
			AddNewBlock("(R8 ALT) (Betrayed) They left use here to die....", CustomTextDataBlock.StoryMode_R8_NT_ALT_Betrayed);
			AddNewBlock("(R8 ALT) (Betrayed) Here they come get ready!", CustomTextDataBlock.StoryMode_R8_NT_ALT_Betrayed_2);
			AddNewBlock("(R8 ALT) Schaeffer left? I guess we have to go then..", CustomTextDataBlock.StoryMode_R8_NT_ALT_SchaefferMeetKDS);
			AddNewBlock("(R8 ALT) Just Hand the Data Cubes over..", CustomTextDataBlock.StoryMode_R8_NT_ALT_HandDatacubes);
			AddNewBlock("(R8 ALT) Where the fuck is Schaeffer?/Meltdown? We have to go!", CustomTextDataBlock.StoryMode_R8_NT_ALT_NuclearFinal);
			AddNewBlock("(R8 OG) (To other group) We need the data cubes for the security door to open.", CustomTextDataBlock.StoryMode_R8_NT_OG_AskDatacubes);
			AddNewBlock("(R8 OG) (To other group) We need you to open Zone 40", CustomTextDataBlock.StoryMode_R8_NT_OG_DoorHelp);
			AddNewBlock("(R8 OG) (To other group) We have the Project Insight Archive key..", CustomTextDataBlock.StoryMode_R8_NT_OG_MicroDrive);
			AddNewBlock("(R8 OG) This is it. Let's move! Now!", CustomTextDataBlock.StoryMode_R8_NT_OG_NuclearFinal);
			AddNewBlock("(R8 OG) We need you to reroute power to zone 41! Hurry! We're in trouble!", CustomTextDataBlock.StoryMode_R8_NT_OG_PowerHelp);
			AddNewBlock("(R8 OG) We need to tell them that we need power!", CustomTextDataBlock.StoryMode_R8_NT_OG_PowerHelpStart);
			AddNewBlock("(R8 OG) Let's hope they heard that, a lot of monsters here!", CustomTextDataBlock.StoryMode_R8_NT_OG_PowerHelpDone);
			AddNewBlock("(R8 OG) Schaeffer Dead Comment", CustomTextDataBlock.StoryMode_R8_NT_OG_SchaefferDead);
			AddNewBlock("(R8 OG) Schaeffer Drowing Comment", CustomTextDataBlock.StoryMode_R8_NT_OG_SchaefferDrown);
			AddNewBlock("(R8 OG) The other group is in trouble! Let's tell them to hand over the data cubes.", CustomTextDataBlock.StoryMode_R8_NT_OG_AskDatacubesStart);
			AddNewBlock("(R8 OG) And now we wait for them to open the door.", CustomTextDataBlock.StoryMode_R8_NT_OG_DoorHelpDone);
			AddNewBlock("(R8 OG) Let's tell the other group to open the security door", CustomTextDataBlock.StoryMode_R8_NT_OG_DoorHelpStart);
			AddNewBlock("(R8 OG) This better work!", CustomTextDataBlock.StoryMode_R8_NT_OG_GasD2End);
			AddNewBlock("(R8 OG) We need to get this done", CustomTextDataBlock.StoryMode_R8_NT_OG_GasD2Start);
			AddNewBlock("(R8 OG) Schaeffer is right, we need help from the other group.", CustomTextDataBlock.StoryMode_R8_NT_OG_SchaefferDoorTaunt);
			AddNewBlock("(R8 OG) We have to stop Schaeffer!", CustomTextDataBlock.StoryMode_R8_NT_OG_SchaefferThreatResponse);
			AddNewBlock("(R8 OG) Some one needs to talk to other group.", CustomTextDataBlock.StoryMode_R8_NT_OG_MicroDriveStart);
			AddNewBlock("(R8 OG) Hopefully the other group got the message.", CustomTextDataBlock.StoryMode_R8_NT_OG_MicroDriveDone);
			AddNewBlock("(R8 OG) (To other group) This is Schaeffer, we're going to KDS Deep.", CustomTextDataBlock.StoryMode_R8_NT_OG_AskMeetKDS);
			AddNewBlock("(R8 OG) We need the data cubes to survive. Someone convince the other group.", CustomTextDataBlock.StoryMode_R8_NT_OG_AskMeetKDSStart);
			AddNewBlock("(R8 OG) Alright let's move, we have to be at the KDS Deep first.", CustomTextDataBlock.StoryMode_R8_NT_OG_AskMeetKDSDone);
			AddNewBlock("(R8 OG) Jungle Scenario 1", CustomTextDataBlock.StoryMode_R8_JungleScenario_1);
			AddNewBlock("(R8 OG) Jungle Scenario 2", CustomTextDataBlock.StoryMode_R8_JungleScenario_2);
			AddNewBlock("(R8 OG) Jungle Scenario 3", CustomTextDataBlock.StoryMode_R8_JungleScenario_3);
			AddNewBlock("(R8 OG) Jungle Scenario 4", CustomTextDataBlock.StoryMode_R8_JungleScenario_4);
		}

		public override void Update()
		{
			UpdateInitializeTexts();
		}

		private void UpdateInitializeTexts()
		{
			if (GameDataBlockBase<TextDataBlock>.m_isSetup)
			{
				UpdateTexts();
			}
		}

		private void UpdateTexts()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			if (m_initialized)
			{
				return;
			}
			m_initialized = true;
			GameDataTextLocalizationService val = ((Il2CppObjectBase)Text.TextLocalizationService).TryCast<GameDataTextLocalizationService>();
			if (val != null)
			{
				foreach (TextDataBlock value in m_customTextBlocks.Values)
				{
					if (!val.m_texts.ContainsKey(((GameDataBlockBase<TextDataBlock>)(object)value).persistentID))
					{
						val.m_texts.Add(((GameDataBlockBase<TextDataBlock>)(object)value).persistentID, value.GetText(val.CurrentLanguage, false));
					}
				}
				Text.UpdateAllTexts();
				DebugPrint("Updating all Texts in game for Chatter Reborn!");
			}
			else
			{
				DebugPrint("Could not update all Texts in game for Chatter Reborn!", eLogType.Error);
			}
		}

		private string InspectBlockName(string originalName)
		{
			string text = originalName;
			bool flag = true;
			uint num = 0u;
			do
			{
				if (flag)
				{
					flag = false;
					continue;
				}
				num++;
				string text2 = text;
				text = originalName + "_" + num;
				DebugPrint("TextBlock " + text2 + " already exists! Let's check if this one exists -> " + text, eLogType.Warning);
			}
			while (GameDataBlockBase<TextDataBlock>.HasBlock(text));
			DebugPrint("TextBlock name is a non-duplicate -> " + text + ", we are good!", eLogType.Message);
			return text;
		}

		private void CheckLastPersistentID()
		{
			m_latestID = 0u;
			foreach (TextDataBlock allBlock in GameDataBlockBase<TextDataBlock>.GetAllBlocks())
			{
				m_latestID = Math.Max(m_latestID, ((GameDataBlockBase<TextDataBlock>)(object)allBlock).persistentID);
			}
			DebugPrint("Latest Persistent ID for TextDbs -> " + m_latestID, eLogType.Message);
		}

		private void AddNewBlock(string text, CustomTextDataBlock type)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			TextDataBlock val = new TextDataBlock();
			val.English = text;
			((GameDataBlockBase<TextDataBlock>)(object)val).name = InspectBlockName("ChatterReborn.ExtraCommunicationList." + type);
			val.SkipLocalization = true;
			((GameDataBlockBase<TextDataBlock>)(object)val).internalEnabled = true;
			((GameDataBlockBase<TextDataBlock>)(object)val).persistentID = 0u;
			DebugPrint("Now adding custom dataBlock " + ((GameDataBlockBase<TextDataBlock>)(object)val).name);
			GameDataBlockBase<TextDataBlock>.AddBlock(val, -1);
			m_customTextBlocks.Add(type, val);
			m_customTextDataBlockIDs.Add(((GameDataBlockBase<TextDataBlock>)(object)val).persistentID);
		}

		public static TextDataBlock GetCustomBlock(CustomTextDataBlock type)
		{
			return ChatterManager<ExtraTextDataBlockManager>.Current.m_customTextBlocks[type];
		}

		public static bool IsTextIDCustom(uint id)
		{
			return ChatterManager<ExtraTextDataBlockManager>.Current.m_customTextDataBlockIDs.Contains(id);
		}
	}
	public class MusicTesterManager : ChatterManager<MusicTesterManager>
	{
		private readonly bool m_testMusic;

		public override void Update()
		{
			if (m_testMusic)
			{
				UpdateTestMusic();
			}
		}

		private static void UpdateTestMusic()
		{
			//IL_00b2: 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)
			if (Input.GetKeyDown((KeyCode)258))
			{
				MusicManager.Machine.Sound.Post(1105428275u, true);
				MusicManager.Machine.Sound.Post(293821756u, true);
				MusicManager.Machine.Sound.Post(128759482u, true);
			}
			if (Input.GetKeyDown((KeyCode)259))
			{
				MusicManager.Machine.Sound.Post(1105428275u, true);
				MusicManager.Machine.Sound.Post(2505707092u, true);
				MusicManager.Machine.Sound.Post(877716454u, true);
			}
			if (Input.GetKeyDown((KeyCode)260))
			{
				CellSound.SetState(3749450245u, 854497135u);
			}
			if (Input.GetKeyDown((KeyCode)257))
			{
				CellSound.SetState(1760015742u, 2710904753u);
			}
		}
	}
	public class PlayerAgentStateManager : ChatterManager<PlayerAgentStateManager>
	{
		private readonly Dictionary<DialogCharFilter, uint> m_teammateCallOuts = new Dictionary<DialogCharFilter, uint>
		{
			{
				(DialogCharFilter)2,
				2308011443u
			},
			{
				(DialogCharFilter)4,
				774767036u
			},
			{
				(DialogCharFilter)8,
				1776648661u
			},
			{
				(DialogCharFilter)16,
				244277816u
			}
		};

		protected override void PostSetup()
		{
			m_patcher.Patch<PLOC_Downed>("SyncEnter", (HarmonyPatchType)2, BindingFlags.Instance | BindingFlags.Public);
			m_patcher.Patch<PLOC_Downed>("CommonExit", (HarmonyPatchType)2, BindingFlags.Instance | BindingFlags.Public);
			if (ConfigurationManager.CallOutTeammatesEnabled)
			{
				m_patcher.Patch<LocalPlayerAgent>("UpdateGlobalInput", (HarmonyPatchType)1, BindingFlags.Instance | BindingFlags.Public);
			}
		}

		private static void PLOC_Downed__CommonExit__Postfix(PLOC_Downed __instance)
		{
			DramaChatterManager.GetMachine(((PLOC_Base)__instance).m_owner)?.CurrentState.Revived();
		}

		private static bool LocalPlayerAgent__UpdateGlobalInput__Prefix(LocalPlayerAgent __instance)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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)
			RaycastHit val = default(RaycastHit);
			if (InputMapper.GetButtonDown.Invoke((InputAction)58, ((PlayerAgent)__instance).InputFilter) && Physics.Raycast(__instance.CamPos, ((PlayerAgent)__instance).FPSCamera.Forward, ref val, 200f, LayerManager.MASK_ENEMY_PROJECTILE_EXPLOSION_TARGETS, (QueryTriggerInteraction)1))
			{
				PlayerAgent componentInParent = ((Component)((RaycastHit)(ref val)).collider).gameObject.GetComponentInParent<PlayerAgent>();
				if ((Object)(object)componentInParent != (Object)null && Time.time >= __instance.m_pingAgainTimer && ChatterManager<PlayerAgentStateManager>.Current.m_teammateCallOuts.TryGetValue(componentInParent.PlayerCharacterFilter, out var value))
				{
					__instance.m_pingAgainTimer = Clock.Time + 1f;
					((PlayerAgent)(object)__instance).Say(value);
					return false;
				}
			}
			return true;
		}

		private static void PLOC_Downed__SyncEnter__Postfix(PLOC_Downed __instance)
		{
			if (((PLOC_Base)__instance).m_owner.IsBotOwned())
			{
				PlayerDialogManager.WantToStartDialog(150u, -1, false, false);
			}
		}
	}
	public class PlayerInteractionManager : ChatterManager<PlayerInteractionManager>
	{
		private PlayerResponseMachine m_machine;

		protected override void Setup()
		{
			SetupCustomInteractions();
		}

		public override void Update()
		{
			UpdateMachineState();
		}

		private void UpdateDebugKeys()
		{
			if (Input.GetKeyDown((KeyCode)277))
			{
				ChangeResponseState(VocalResponseType.CallOutDirection);
			}
			else if (Input.GetKeyDown((KeyCode)278))
			{
				PlayerCommunicationManager.OnReceivedCommandLocally(TextCommandID.PickUpDeployables, m_machine.m_owner);
			}
			else if (Input.GetKeyDown((KeyCode)279))
			{
				PlayerCommunicationManager.OnReceivedCommandLocally(TextCommandID.DeployMines, m_machine.m_owner);
			}
			else if (Input.GetKeyDown((KeyCode)280))
			{
				PlayerCommunicationManager.OnReceivedCommandLocally(TextCommandID.Follow, m_machine.m_owner);
			}
			else if (Input.GetKeyDown((KeyCode)127))
			{
				ChangeResponseState(VocalResponseType.None);
			}
		}

		public static void SetCommandText(PlayerAgent sourcePlayer, uint textID)
		{
			ChatterManager<PlayerInteractionManager>.Current.m_machine.SetCommandText(sourcePlayer, textID);
		}

		private void UpdateMachineState()
		{
			if (m_machine != null)
			{
				m_machine.UpdateState();
			}
		}

		public override void On_Registered_LocalPlayerAgent(LocalPlayerAgent localPlayerAgent)
		{
			m_machine.SetOwner((PlayerAgent)(object)localPlayerAgent);
		}

		public override void OnLevelCleanUp()
		{
			m_machine.ChangeState(VocalResponseType.None);
		}

		public static void ChangeResponseState(VocalResponseType response)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			if ((int)ConfigurationManager.ResponseTriggerKey != 0)
			{
				ChatterManager<PlayerInteractionManager>.Current.m_machine.ChangeState(response);
			}
		}

		private void SetupCustomInteractions()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			m_machine = new PlayerResponseMachine();
			GameObject val = new GameObject("ChatterReborn_Responder_UI")
			{
				layer = 5,
				active = false
			};
			val.transform.SetParent(((Component)GuiManager.PlayerLayer.m_playerStatus).transform);
			TextMeshPro val2 = Object.Instantiate<TextMeshPro>(GuiManager.PlayerLayer.m_subtitles.m_subtitle, val.transform, true);
			val.transform.localPosition = new Vector3(0f, 350f, 0f);
			val2.transform.localScale = new Vector3(2f, 2f, 2f);
			((TMP_Text)val2).fontSize = 20f;
			((Graphic)val2).color = Color.yellow;
			((TMP_Text)val2).text = "[Placeholder Text]";
			((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
			((TMP_Text)val2).alpha = 1f;
			m_machine.Setup(val, val2);
			Object.DontDestroyOnLoad((Object)(object)val);
			LogMessage("Settting interaction go");
		}
	}
	public class SequenceEventManager : ChatterManager<SequenceEventManager>
	{
		public class SequenceEventGroup
		{
			public List<SequenceEvent> SequenceEvents;

			private SequenceEvent m_upcomingEvent;

			public float QueueStartTime;

			private bool m_trash;

			private bool m_active;

			private float m_nextActionTime;

			public bool Trash => m_trash;

			public SequenceEventGroup()
			{
				SequenceEvents = new List<SequenceEvent>();
			}

			public void AddSequenceEvent(float time, Action action)
			{
				SequenceEvent item = new SequenceEvent
				{
					Time = time,
					Action = action,
					Group = this
				};
				SequenceEvents.Add(item);
			}

			public void OnRemoved()
			{
				m_active = false;
			}

			public void ClearSequenceEvents()
			{
				SequenceEvents.Clear();
				m_trash = true;
			}

			private void QueueNextAction()
			{
				if (SequenceEvents.Count == 0)
				{
					m_trash = true;
					return;
				}
				m_upcomingEvent = SequenceEvents[0];
				m_nextActionTime += m_upcomingEvent.Time;
				SequenceEvents.RemoveAt(0);
			}

			public void QueueSequenceEvents()
			{
				m_trash = false;
				QueueStartTime = Time.time;
				m_nextActionTime = QueueStartTime;
				QueueNextAction();
				if (!m_active)
				{
					m_active = true;
					ChatterManager<SequenceEventManager>.Current.m_sequenceEventGroups.Add(this);
				}
			}

			public void Update()
			{
				if (!m_trash && m_nextActionTime < Time.time)
				{
					SequenceEvent upcomingEvent = m_upcomingEvent;
					m_upcomingEvent = null;
					QueueNextAction();
					upcomingEvent.Action();
				}
			}
		}

		public class SequenceEvent
		{
			public float Time;

			public Action Action;

			public SequenceEventGroup Group;
		}

		private List<SequenceEventGroup> m_sequenceEventGroups;

		protected override void Setup()
		{
			m_sequenceEventGroups = new List<SequenceEventGroup>();
		}

		public override void Update()
		{
			UpdateSequenceGroups();
		}

		public override void OnLevelCleanUp()
		{
			m_sequenceEventGroups.Clear();
		}

		private void UpdateSequenceGroups()
		{
			if (m_sequenceEventGroups.Count <= 0)
			{
				return;
			}
			for (int num = m_sequenceEventGroups.Count - 1; num >= 0; num--)
			{
				SequenceEventGroup sequenceEventGroup = m_sequenceEventGroups[num];
				if (sequenceEventGroup.Trash)
				{
					sequenceEventGroup.OnRemoved();
					m_sequenceEventGroups.RemoveAt(num);
				}
				else
				{
					sequenceEventGroup.Update();
				}
			}
		}
	}
	public class TextDataBlockExtendedManager : ChatterManager<TextDataBlockExtendedManager>
	{
		private TextDataBlock m_testBlock;

		private void TestLocalization()
		{
			m_testBlock = GameDataBlockBase<TextDataBlock>.AddNewBlock();
			m_testBlock.English = "this is a test for localization";
			m_testBlock.Spanish = LanguageData.op_Implicit("esta es una prueba de localización");
		}
	}
	public class PlayerCommunicationManager : ChatterManager<PlayerCommunicationManager>, IChatterEventListener<TextCommandEvent>
	{
		protected override void PostSetup()
		{
			ChatterEventListenerHandler<TextCommandEvent>.RegisterListener(this);
		}

		private static void GetCommnunicationData(SNet_Player src, uint textId, SNet_Player dst, out bool hasDst, out bool hasSrc)
		{
			string text = "\n[PUI_CommunicationMenu.OnCommunicationReceived] Results:";
			hasDst = false;
			hasSrc = false;
			if ((Object)(object)src != (Object)null)
			{
				text = text + "\n\tSourceAgent Name : " + src.NickName;
				text = text + "\n\tSourceAgent IsLocal : " + src.IsLocal;
				hasSrc = true;
			}
			if ((Object)(object)dst != (Object)null)
			{
				text = text + "\n\tDestinationAgent Name : " + dst.NickName;
				text = text + "\n\tDestinationAgent IsLocal : " + dst.IsLocal;
				hasDst = true;
			}
			text = text + "\n\tTextId : " + textId;
			text = text + "\n\tTextName : " + GameDataBlockBase<TextDataBlock>.GetBlockName(textId);
			ChatterManager<PlayerCommunicationManager>.Current.DebugPrint(text);
		}

		private bool CheckPlacement(PlayerAgent source)
		{
			return true;
		}

		public void OnChatterEvent(TextCommandEvent chatterEvent)
		{
			GetCommnunicationData(chatterEvent.source, chatterEvent.textId, chatterEvent.destination, out var hasDst, out var hasSrc);
			if (hasDst && hasSrc && chatterEvent.destination.PlayerAgent.Convert<SNet_IPlayerAgent, PlayerAgent>(out PlayerAgent isthis) && chatterEvent.source.PlayerAgent.Convert<SNet_IPlayerAgent, PlayerAgent>(out PlayerAgent isthis2) && ((Agent)isthis).IsLocallyOwned)
			{
				OnReceivedCommandLocally((TextCommandID)chatterEvent.textId, isthis2);
			}
		}

		public static void OnReceivedCommandLocally(TextCommandID textcommandID, PlayerAgent sourceAgent)
		{
			switch (textcommandID)
			{
			case TextCommandID.Follow:
				PlayerInteractionManager.SetCommandText(sourceAgent, (uint)textcommandID);
				PlayerInteractionManager.ChangeResponseState(VocalResponseType.Follow);
				break;
			case TextCommandID.PickUpDeployables:
			case TextCommandID.Scan:
			case TextCommandID.CfoamHere:
			case TextCommandID.ThrowGlowStick:
			case TextCommandID.Carry:
			case TextCommandID.DeployMines:
			case TextCommandID.DeploySentry:
				PlayerInteractionManager.SetCommandText(sourceAgent, (uint)textcommandID);
				PlayerInteractionManager.ChangeResponseState(VocalResponseType.Confirmation);
				break;
			}
		}
	}
	public class WardenObjectiveListenerManager : ChatterManager<WardenObjectiveListenerManager>, IChatterEventListener<WardenObjectiveStatus>
	{
		protected override void PostSetup()
		{
		}

		public void OnChatterEvent(WardenObjectiveStatus objStatus)
		{
		}
	}
	public class ChainedPuzzleDialogManager : ChatterManager<ChainedPuzzleDialogManager>
	{
		public override void OnElevatorArrived()
		{
			if ((Object)(object)ChainedPuzzleManager.Current == (Object)null || ChainedPuzzleManager.Current.m_instances == null)
			{
				DebugPrint("Failed adding OnSyncStateChanges to bio scans..", eLogType.Error);
				return;
			}
			List<ChainedPuzzleInstance> list = ChainedPuzzleManager.Current.m_instances.ToSystemList<ChainedPuzzleInstance>();
			for (int i = 0; i < list.Count; i++)
			{
				ChainedPuzzleInstance val = list[i];
				if (!((Object)(object)val != (Object)null) || val.m_chainedPuzzleCores == null)
				{
					continue;
				}
				iChainedPuzzleCore[] array = Il2CppArrayBase<iChainedPuzzleCore>.op_Implicit((Il2CppArrayBase<iChainedPuzzleCore>)(object)val.m_chainedPuzzleCores);
				if (array.Length == 0)
				{
					continue;
				}
				for (int j = 0; j < array.Length; j++)
				{
					iChainedPuzzleCore val2 = array[j];
					if (val2 != null)
					{
						bool isFinal = j == array.Length - 1;
						CP_Cluster_Core isthis2;
						if (val2.Convert<iChainedPuzzleCore, CP_Bioscan_Core>(out CP_Bioscan_Core isthis))
						{
							CP_Bioscan_Core_Dialog @object = new CP_Bioscan_Core_Dialog(isthis, isFinal);
							isthis.OnPuzzleDone += Action<int>.op_Implicit((Action<int>)@object.OnScanDone);
							isthis.m_sync.OnSyncStateChange += Action<eBioscanStatus, float, List<PlayerAgent>, int, Il2CppStructArray<bool>, bool>.op_Implicit((Action<eBioscanStatus, float, List<PlayerAgent>, int, Il2CppStructArray<bool>, bool>)@object.OnStateChangeDialog);
						}
						else if (val2.Convert<iChainedPuzzleCore, CP_Cluster_Core>(out isthis2))
						{
							CP_Cluster_Core_Dialog object2 = new CP_Cluster_Core_Dialog(isthis2, isFinal);
							isthis2.OnPuzzleDone += Action<int>.op_Implicit((Action<int>)object2.OnScanDone);
							isthis2.m_sync.OnSyncStateChange += Action<eClusterStatus, float, bool>.op_Implicit((Action<eClusterStatus, float, bool>)object2.OnStateChangeDialog);
						}
					}
				}
			}
		}
	}
	public class ComputerTerminalManager : ChatterManager<ComputerTerminalManager>
	{
		public static bool AnyTerminalsPlayingAudio
		{
			get
			{
				//IL_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Invalid comparison between Unknown and I4
				if ((Object)(object)LG_ComputerTerminalManager.Current == (Object)null)
				{
					return false;
				}
				if (LG_ComputerTerminalManager.Current.m_terminals == null || LG_ComputerTerminalManager.Current.m_terminals.Count <= 0)
				{
					return false;
				}
				Enumerator<uint, LG_ComputerTerminal> enumerator = LG_ComputerTerminalManager.Current.m_terminals.GetEnumerator();
				while (enumerator.MoveNext())
				{
					KeyValuePair<uint, LG_ComputerTerminal> current = enumerator.Current;
					if (current != null && (Object)(object)current.Value != (Object)null && (int)current.Value.CurrentStateName == 9)
					{
						return true;
					}
				}
				return false;
			}
		}
	}
	public class ConfigurationManager : ChatterManager<ConfigurationManager>
	{
		public static readonly string CONFIG_PATH = Path.Combine(Paths.ConfigPath, "ChatterReborn.cfg");

		public static ConfigFile Config;

		[ConfigurationAttribute_KeyCode(/*Could not decode attribute arguments.*/)]
		public static KeyCode ResponseTriggerKey;

		[ConfigurationAttribute_Toggle("Stealth Commands Shortcut", "When close to a hibernating sleeper, a prompt will appear at the buttom to announce stealth commands to your teammates..", true)]
		public static bool StealthCommandsEnabled;

		[ConfigurationAttribute_Toggle("Expedition Failed Death Scream", "Your character will release a death scream upon the expedition failed screen..", false)]
		public static bool ExpeditionFailedDeathScreamEnabled;

		[ConfigurationAttribute_Toggle("Resource Pack Received Confirmation", "Your character will say thank you to the person giving you a resource pack..", true)]
		public static bool ResourcePackRecievedConfirmationEnabled;

		[ConfigurationAttribute_Toggle("Stealth Kill Comments", "Your character will have stealth kill voice lines upon killing sleepers during sneaking..", true)]
		public static bool SneakKillCommentsEnabled;

		[ConfigurationAttribute_Toggle("Hacking Minigame dialogues", "Your character will have dialogue upon hacking security locks.", false)]
		public static bool HackingMiniGameCommentsEnabled;

		[ConfigurationAttribute_Toggle("Random Potential comments", "Your character will make periodic comments during exploration.", false)]
		public static bool ExplorationDialogueEnabled;

		[ConfigurationAttribute_Toggle("Resource Pickup Comment", "Your character will make comments upon picking up resource packs.", false)]
		public static bool ResourcePickUpCommentsEnabled;

		[ConfigurationAttribute_Toggle("Combat End Dialogue", "Your character will comment after a hectic battle with the monsters.", true)]
		public static bool EndOfCombatDialogueEnabled;

		[ConfigurationAttribute_Toggle("Combat Enter Dialogue", "Your character will make a battle cry upon entering combat.", true)]
		public static bool StartCombatDialogueEnabled;

		[ConfigurationAttribute_Toggle("Open Doors Dialogue", "Your character will have dialogue upon opening doors.", true)]
		public static bool OpenDoorsCommentEnabled;

		[ConfigurationAttribute_Toggle("Force Player in Team Scan", "If set to true and you are pointing/aiming at a player that's not in a team scan, your character will irritably shout at them. ", false)]
		public static bool IrritatedScanningCommentEnabled;

		[ConfigurationAttribute_Toggle("Fog Turbine Carrying Comment", "Your character will warn others to stay close when carrying a Fog turbine.", false)]
		public static bool HeavyFogRepellerCommmentEnabled;

		[ConfigurationAttribute_Toggle("Give Resource Packs Comment", "Your character tell the player you are trying to give resource packs to hold still.", true)]
		public static bool InteractionGiveResourcePacksCommentEnabled;

		[ConfigurationAttribute_Toggle("Callout teammates", "You will call out to other teammates if you press the ping button when pointing directly at your teammates.", false)]
		public static bool CallOutTeammatesEnabled;

		[ConfigurationAttribute_Toggle("Intro Expedition Dialogue", "Your character will initiate a dialogue when starting an expedition.", true)]
		public static bool ExpeditionIntroDialogueEnabled;

		[ConfigurationAttribute_Toggle("BioTracker Information", "Your character will inform your teammates about the pings while using the Bio Tracker when ADS'ing.", true)]
		public static bool BioTrackerCommentsEnabled;

		[ConfigurationAttribute_Toggle("Consumable Depleted", "Your character will make a little comment when running out of consumables..", true)]
		public static bool ConsumableDepletedCommentsEnabled;

		public static bool ElevatorDropDialogueEnabled;

		[ConfigurationAttribute_Toggle("Health reminder", "Your character remind other players on your current health status.", true)]
		public static bool MedicCommentsEnabled;

		[ConfigurationAttribute_Toggle("Ammo reminder", "Your character remind other players on your current ammo status when switching weapons.", true)]
		public static bool AmmoCommentsEnabled;

		[ConfigurationAttribute_Toggle("Infection reminder", "Your character will cough and sneeze depending your infection level.", false)]
		public static bool InfectionCommentsEnabled;

		[ConfigurationAttribute_Toggle("Incoming monster group", "Your character will remind others that there are still monsters aggroed even after the combat music stops.", true)]
		public static bool HearHunterGroupDialogueEnabled;

		[ConfigurationAttribute_Toggle("Bioscan dialogues", "Your character will have dialogues regarding holo-paths, scan completions, and scanning progresses if set to true.", true)]
		public static bool ChainedPuzzleDialoguesEnabled;

		[ConfigurationAttribute_Toggle("Killed last monster", "Your character will make a quick comment after killing the last monster..", false)]
		public static bool KilledSingleMonsterCommentEnabled;

		[ConfigurationAttribute_Toggle("Let their be Light in the darkness", "Your character will make a comment when another teammate , whose close to you, turns on a long range flashlight.", true)]
		public static bool FlashLightInDarknessDialogueEnabled;

		[ConfigurationAttribute_Toggle("Key Pick Up Dialogue", "Your character will inform others on what keycard you picked up.", false)]
		public static bool KeyCardPickUpDialoguesEnabled;

		[ConfigurationAttribute_Toggle("Spitter Irritated Noises", "Your character will have a 75% chance to make irritated noises if a spitter explodes on you.", true)]
		public static bool OnExplodeSpitterCommentsEnabled;

		[ConfigurationAttribute_Toggle("Monster Light Sensitivity Warning", "Your character will warn any players flashing any monsters.", false)]
		public static bool FlashLightSensitivityDialoguesEnabled;

		[ConfigurationAttribute_Toggle("Better Voice Intensity", "Your character's voice intensity will adapt to the current heat level of the combat.", true)]
		public static bool VoiceIntensityAdapterEnabled;

		[ConfigurationAttribute_Toggle("Door Pings", "Your character will have pinging voice lines for doors. If a horde is banging on a door, ping the door and your character will warn others...", true)]
		public static bool PingDoorDialoguesEnabled;

		[ConfigurationAttribute_Toggle("Reviving Comments", "Your character thank the person reviving you.", true)]
		public static bool RevivedCommentEnabled;

		[ConfigurationAttribute_Toggle("Group Up Combat", "Your character will tell others to come group up when far away and in combat", false)]
		public static bool GroupStayCloseCombatDialoguesEnabled;

		[ConfigurationAttribute_Enum("Chatter Inclusion Type", "Configure whether players or bots will be affected by the Chatter mod (NOTE: If the choice includes bots, you must be the host, otherwise it won't work).", "Choice", typeof(ChatterInclusionType), 1)]
		public static ChatterInclusionType ModInclusion;

		[ConfigurationAttribute_Toggle("Persistent Combat Chatter", "Your character will often banter during combat when shooting sleepers in your line of sight (The more aggroed monsters in AO, the more chance your character will trigger the banter).", true)]
		public static bool PersistentCombatChatterEnabled;

		[ConfigurationAttribute_Toggle("Friendly Fire Apology", "Your character will apologize upon accidentally shooting at your teammates.", false)]
		public static bool FriendlyFireApologyEnabled;

		protected override void Setup()
		{
			ApplyConfigurations();
		}

		private static void ApplyConfigurations()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			Config = new ConfigFile(CONFIG_PATH, true);
			FieldInfo[] fields = typeof(ConfigurationManager).GetFields(BindingFlags.Static | BindingFlags.Public);
			foreach (FieldInfo fieldInfo in fields)
			{
				MethodInfo method = typeof(ConfigurationManager).GetMethod("GetConfigDefinition", BindingFlags.Static | BindingFlags.NonPublic);
				if (!(method != null))
				{
					continue;
				}
				ConfigurationAttribute_Base customAttribute = fieldInfo.GetCustomAttribute<ConfigurationAttribute_Base>();
				if (customAttribute != null && customAttribute.ConfigType != 0)
				{
					MethodInfo methodInfo = method.MakeGenericMethod(customAttribute.ValueType);
					List<object> list = new List<object> { fieldInfo, customAttribute.Title, customAttribute.Header, customAttribute.Desc };
					switch (customAttribute.ConfigType)
					{
					case ConfigurationType.Toggle:
						list.Add(((ConfigurationAttribute_Toggle)customAttribute).Default);
						break;
					case ConfigurationType.KeyBind:
						list.Add(((ConfigurationAttribute_KeyCode)customAttribute).DefaultKey);
						break;
					case ConfigurationType.MultipleChoice:
						list.Add(((ConfigurationAttribute_Enum)customAttribute).DefaultChoice);
						break;
					default:
						throw new ArgumentOutOfRangeException();
					case ConfigurationType.None:
						break;
					}
					methodInfo.Invoke(null, list.ToArray());
				}
			}
		}

		private static void GetConfigDefinition<V>(FieldInfo fieldInfo, string title, string header, string desc, V defaultValue)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			fieldInfo.SetValue(null, defaultValue);
			ConfigDefinition val = new ConfigDefinition(title, header);
			Config.Bind<V>(val, defaultValue, new ConfigDescription(desc, (AcceptableValueBase)null, (object[])null));
			ConfigEntry<V> val2 = default(ConfigEntry<V>);
			if (Config.TryGetEntry<V>(val, ref val2))
			{
				fieldInfo.SetValue(null, val2.Value);
			}
		}

		public static bool IsLocalPlayerChattering()
		{
			if (ModInclusion != ChatterInclusionType.OnlyLocalPlayer)
			{
				return ModInclusion == ChatterInclusionType.LocalPlayerAndBots;
			}
			return true;
		}

		public static bool IsBotsChattering()
		{
			if (ModInclusion != ChatterInclusionType.OnlyBots)
			{
				return ModInclusion == ChatterInclusionType.LocalPlayerAndBots;
			}
			return true;
		}
	}
	public abstract class ChatterManager<T> : ChatterManagerBase
	{
		private bool m_firstSetup;

		private bool m_postSetup;

		protected ChatterPatcher<T> m_patcher;

		private readonly DebugLoggerObject m_debugLogger = new DebugLoggerObject(typeof(T).Name);

		public static T Current { get; } = Activator.CreateInstance<T>();


		public override void Initialize(bool firstSetup = false)
		{
			if (firstSetup)
			{
				if (!m_firstSetup)
				{
					m_patcher = new ChatterPatcher<T>(typeof(T).Name);
					DebugPrint("Adding ChatterPatcher");
					BaseSetup();
					Setup();
					m_firstSetup = true;
				}
				else
				{
					DebugPrint("Has already been intialized!", eLogType.Warning);
				}
			}
			else if (!m_postSetup)
			{
				BasePostSetup();
				PostSetup();
				m_postSetup = true;
			}
			else
			{
				DebugPrint("Has already been PostSetup!", eLogType.Warning);
			}
		}

		protected override void DebugPrint(object message, eLogType logType = eLogType.Debug)
		{
			m_debugLogger.DebugPrint(message, logType);
		}
	}
	public class CoolDownManager : ChatterManager<CoolDownManager>
	{
		private DictionaryExtended<string, float> m_cooldowns;

		protected override void Setup()
		{
			m_cooldowns = new DictionaryExtended<string, float>();
			base.Setup();
		}

		private void ResetCoolDowns()
		{
			m_cooldowns.Clear();
		}

		public override void OnLevelCleanUp()
		{
			ResetCoolDowns();
		}

		public static void ApplyCooldown(string key, DelayValue timer)
		{
			float totalTimer = timer.totalTimer;
			if (!ChatterManager<CoolDownManager>.Current.m_cooldowns.ContainsKey(key))
			{
				ChatterManager<CoolDownManager>.Current.m_cooldowns.Add(key, Time.time + totalTimer);
			}
			else
			{
				ChatterManager<CoolDownManager>.Current.m_cooldowns[key] = Time.time + totalTimer;
			}
		}

		public static void ApplyCooldown(CoolDownType type, DelayValue timer)
		{
			ApplyCooldown(type.ToString(), timer);
		}

		public static bool HasCooldown(CoolDownType type)
		{
			return HasCooldown(type.ToString());
		}

		public static bool HasCooldown(string key)
		{
			if (ChatterManager<CoolDownManager>.Current.m_cooldowns.ContainsKey(key))
			{
				return ChatterManager<CoolDownManager>.Current.m_cooldowns[key] > Time.time;
			}
			return false;
		}
	}
	public class DevToolManager : ChatterManager<DevToolManager>
	{
		private bool allowLogComponents;

		protected override void Setup()
		{
			base.Setup();
		}

		public static void LogComponents(GameObject targetGameObject)
		{
			if (ChatterManager<DevToolManager>.Current.allowLogComponents)
			{
				new List<Component>();
				Il2CppArrayBase<Component> components = targetGameObject.GetComponents<Component>();
				if (components != null)
				{
					LogComponents(((Object)targetGameObject).name + " GetComponents", components);
				}
				Il2CppArrayBase<Component> componentsInChildren = targetGameObject.GetComponentsInChildren<Component>();
				if (componentsInChildren != null)
				{
					LogComponents(((Object)targetGameObject).name + " GetComponentsInChildren", componentsInChildren);
				}
				Il2CppArrayBase<Component> componentsInParent = targetGameObject.GetComponentsInParent<Component>(false);
				if (componentsInParent != null)
				{
					LogComponents(((Object)targetGameObject).name + " GetComponentsInParent", componentsInParent);
				}
				ChatterManager<DevToolManager>.Current.DebugPrint("<<<<<<<Line Break>>>>>>>>");
			}
		}

		private static void LogComponents(string componentType, Il2CppArrayBase<Component> components)
		{
			List<string> list = new List<string>();
			foreach (Component component in components)
			{
				list.Add(((MemberInfo)((Object)component).GetIl2CppType()).Name + " ,");
			}
			ChatterManager<DevToolManager>.Current.DebugPrint(string.Concat(componentType, " : ", string.Concat(list)));
		}
	}
	public class DES_Manager : ChatterManager<DES_Manager>
	{
		private WieldingItemMachine machine;

		private bool m_hasScanner;

		public override void Update()
		{
			if (m_hasScanner)
			{
				machine.Update();
			}
		}

		public override void On_Registered_LocalPlayerAgent(LocalPlayerAgent localPlayerAgent)
		{
			ChatterManager<DES_Manager>.Current.machine = new WieldingItemMachine();
			ChatterManager<DES_Manager>.Current.machine.Setup(localPlayerAgent);
			m_hasScanner = true;
		}

		public override void On_DeRegistered_LocalPlayerAgent(LocalPlayerAgent localPlayerAgent)
		{
			ChatterManager<DES_Manager>.Current.machine.ChangeState(WI_State.Deciding);
			m_hasScanner = false;
		}
	}
	public class DialogBotManager : ChatterManager<DialogBotManager>
	{
		public static List<PlayerAgent> PlayerBotAgents => PlayerAgentExtensions.GetAllBotPlayerAgents();

		public static void OnHitReactBot(PlayerAgent playerAgent)
		{
			if (DramaChatterManager.GetMachine(playerAgent).CurrentState is DRAMA_Chatter_Combat dRAMA_Chatter_Combat)
			{
				dRAMA_Chatter_Combat.OnHitReaction();
			}
		}
	}
	public class DramaChatterManager : ChatterManager<DramaChatterManager>
	{
		public Action m_updateAction;

		private bool[] _allow_participation;

		private DramaChatterMachine m_local_machine;

		private bool IsSetup;

		public static DRAMA_Chatter_Base CurrentState => ChatterManager<DramaChatterManager>.Current.m_local_machine.CurrentState;

		public DramaChatterMachine[] PlayerDramaMachines { get; private set; }

		protected override void PostSetup()
		{
			m_patcher.Patch<DramaManager>("ChangeState", (HarmonyPatchType)2, BindingFlags.Static | BindingFlags.Public);
			m_patcher.Patch<DramaManager>("CheckSyncedPlayerStates", (HarmonyPatchType)2, BindingFlags.Static | BindingFlags.Public);
			m_patcher.Patch<LockMelterFirstPerson>("Setup", (HarmonyPatchType)2, BindingFlags.Instance | BindingFlags.Public);
			m_patcher.Patch<CM_PageExpeditionFail>("OnEnable", (HarmonyPatchType)2, BindingFlags.Instance | BindingFlags.Public);
			m_patcher.Patch<InfectionSpitter>("DoExplode", (HarmonyPatchType)2, BindingFlags.Instance | BindingFlags.Public);
		}

		private static void InfectionSpitter__DoExplode__Postfix(InfectionSpitter __instance)
		{
			CurrentState.OnSpitterExplode(__instance);
		}

		private static void DramaManager__ChangeState__Postfix(DRAMA_State state, bool doSync)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			OnChangeState(state, doSync);
		}

		private static void LockMelterFirstPerson__Setup__Postfix(LockMelterFirstPerson __instance)
		{
			((Interact_Timed)__instance.m_interactApplyResource).OnInteractionTriggered += Action<PlayerAgent>.op_Implicit((Action<PlayerAgent>)OnTriggered);
			void OnTriggered(PlayerAgent playerAgent)
			{
				GetMachine(((Item)__instance).Owner)?.CurrentState?.OnThrowConsumable((ItemEquippable)(object)__instance);
			}
		}

		private static void DramaManager__CheckSyncedPlayerStates__Postfix(out bool hasCombat, out bool hasEncounter, out bool hasSneaking)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Invalid comparison between Unknown and I4
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Invalid comparison between Unknown and I4
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Invalid comparison between Unknown and I4
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Invalid comparison between Unknown and I4
			hasCombat = false;
			hasEncounter = false;
			hasSneaking = false;
			if (SNet.HasMaster)
			{
				DRAMA_State val = ((Il2CppArrayBase<DRAMA_State>)(object)DramaManager.SyncedPlayerStates)[SNet.Master.CharacterIndex];
				if ((int)val == 5)
				{
					hasEncounter = true;
				}
				if ((int)val == 6 || (int)val == 8 || (int)val == 7)
				{
					hasCombat = true;
				}
				if ((int)val == 4)
				{
					hasSneaking = true;
				}
			}
		}

		private static void CM_PageExpeditionFail__OnEnable__Postfix(CM_PageExpeditionFail __instance)
		{
			if (((CM_PageBase)__instance).m_isSetup)
			{
				if (ConfigurationManager.ExpeditionFailedDeathScreamEnabled)
				{
					PrisonerDialogManager.DelayLocalDialogForced(Random.Range(1f, 3f), 154u);
				}
				ChatterManager<DramaChatterManager>.Current.DebugPrint("<<<<<<<<<DEATH SCREAM>>>>>>>>>>", eLogType.Message);
			}
		}

		public static void OtherPlayerSyncWield(ItemEquippable item)
		{
			for (int i = 0; i < ChatterManager<DramaChatterManager>.Current.PlayerDramaMachines.Length; i++)
			{
				ChatterManager<DramaChatterManager>.Current.PlayerDramaMachines[i]?.CurrentState.OtherPlayerSyncWield(item);
			}
		}

		public static DramaChatterMachine GetMachine(PlayerAgent playerAgent)
		{
			return ChatterManager<DramaChatterManager>.Current.PlayerDramaMachines[playerAgent.CharacterID];
		}

		public override void Update()
		{
			if (IsSetup && m_updateAction != null)
			{
				m_updateAction();
			}
		}

		public static void OnChangeState(DRAMA_State state, bool doSync)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < ChatterManager<DramaChatterManager>.Current.PlayerDramaMachines.Length; i++)
			{
				DramaChatterMachine dramaChatterMachine = ChatterManager<DramaChatterManager>.Current.PlayerDramaMachines[i];
				if (dramaChatterMachine != null)
				{
					dramaChatterMachine.ChangeState(state);
					if (doSync)
					{
						dramaChatterMachine.WantToSyncDramaState(state);
					}
				}
			}
		}

		public override void OnElevatorArrived()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Invalid comparison between Unknown and I4
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Invalid comparison between Unknown and I4
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Invalid comparison between Unknown and I4
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			WardenObjectiveDataBlock val = default(WardenObjectiveDataBlock);
			if (!((Object)(object)WardenObjectiveManager.Current != (Object)null) || !WardenObjectiveManager.Current.TryGetActiveWardenObjectiveData((LG_LayerType)0, ref val) || val == null)
			{
				return;
			}
			bool flag = false;
			Enumerator<GenericEnemyWaveData> enumerator = val.WavesOnElevatorLand.GetEnumerator();
			while (enumerator.MoveNext())
			{
				if (enumerator.Current.TriggerAlarm)
				{
					flag = true;
					break;
				}
			}
			uint dialogID = 87u;
			if ((int)val.Type == 3 || (int)val.Type == 6)
			{
				dialogID = 88u;
			}
			else if ((int)val.Type == 4 && flag)
			{
				dialogID = 217u;
				List<iWardenObjectiveItem> val2 = default(List<iWardenObjectiveItem>);
				if (WardenObjectiveManager.Current.m_objectiveItemCollection.TryGetValue(LayerChainIndex.ActiveChainIndex((LG_LayerType)0), ref val2) && val2 != null && val2.Count > 0)
				{
					dialogID = 215u;
				}
			}
			if (ConfigurationManager.ExpeditionIntroDialogueEnabled)
			{
				PrisonerDialogManager.DelayLocalDialog(new MinMaxTimer(0.5f, 2f), dialogID);
			}
		}

		public override void On_Registered_PlayerAgent(PlayerAgent playerAgent)
		{
			ChatterManager<DramaChatterManager>.Current.SetupMachineForPlayer(playerAgent);
		}

		public override void On_Registered_LocalPlayerAgent(LocalPlayerAgent localPlayerAgent)
		{
			ChatterManager<DramaChatterManager>.Current.SetupMachineForPlayer((PlayerAgent)(object)localPlayerAgent);
		}

		public override void On_DeRegistered_PlayerAgent(PlayerAgent playerAgent)
		{
			ChatterManager<DramaChatterManager>.Current.UnregisterMachineForPlayer(playerAgent);
		}

		public override void On_DeRegistered_LocalPlayerAgent(LocalPlayerAgent localPlayerAgent)
		{
			ChatterManager<DramaChatterManager>.Current.UnregisterMachineForPlayer((PlayerAgent)(object)localPlayerAgent);
		}

		protected override void Setup()
		{
			PlayerDramaMachines = new DramaChatterMachine[4];
			_allow_participation = new bool[4];
			IsSetup = true;
		}

		public static void SetupMachine(PlayerAgent player)
		{
			ChatterManager<DramaChatterManager>.Current.SetupMachineForPlayer(player);
		}

		public static void EnableParticipation(int characterID, bool enabled)
		{
			ChatterManager<DramaChatterManager>.Current._allow_participation[characterID] = enabled;
		}

		public static bool IsHuskPlayerAllowedToParticipate(int characterID)
		{
			return false;
		}

		private void SetupMachineForPlayer(PlayerAgent player)
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Invalid comparison between Unknown and I4
			//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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			int characterID = player.CharacterID;
			bool isBot = player.Owner.IsBot;
			bool isLocallyOwned = ((Agent)player).IsLocallyOwned;
			if (PlayerDramaMachines[characterID] != null)
			{
				ChatterDebug.LogWarning("Already setup for characterID " + characterID);
				return;
			}
			ChatterDebug.LogWarning("Is CharacterID " + characterID + " bot : " + isBot);
			PlayerDramaMachines[characterID] = new DramaChatterMachine();
			DramaChatterMachine dramaChatterMachine = PlayerDramaMachines[characterID];
			dramaChatterMachine.Setup(player);
			if (isLocallyOwned)
			{
				m_local_machine = dramaChatterMachine;
			}
			if ((int)GameStateManager.CurrentStateName == 10 && SNet.IsMaster && isBot)
			{
				DRAMA_State currentStateEnum = DramaManager.CurrentStateEnum;
				DebugPrint("DramaMachine setup mid-game, changing the state -> " + ((object)(DRAMA_State)(ref currentStateEnum)).ToString(), eLogType.Warning);
				dramaChatterMachine.ChangeState(DramaManager.CurrentStateEnum);
				dramaChatterMachine.WantToSyncDramaState(DramaManager.CurrentStateEnum);
			}
			if (isLocallyOwned)
			{
				ChatterDebug.LogWarning("[DialogDramaStateManager.SetupMachineForPlayer] Local DramaMachine has been set up for characterID " + characterID);
			}
			else if (isBot)
			{
				ChatterDebug.LogWarning("[DialogDramaStateManager.SetupMachineForPlayer] Bot DramaMachine has been set up for characterID " + characterID);
			}
			else
			{
				ChatterDebug.LogWarning("[DialogDramaStateManager.SetupMachineForPlayer] Husk DramaMachine has been set up for characterID " + characterID);
			}
		}

		public static void UnregisterMachine(PlayerAgent player)
		{
			ChatterManager<D