Decompiled source of Peak Archetypes v0.5.2

plugins/ushysder.PeakArcheTypes.dll

Decompiled a year ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using PeakArchetypes.Scripts;
using PeakArchetypes.Scripts.Roles;
using PeakArchetypes.Shared;
using PeakArchetypes.UI;
using PeakArchetypes.Utils;
using Photon.Pun;
using Photon.Voice.PUN;
using Photon.Voice.Unity;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UI;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ushysder.PeakArchetypes")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+327dbadf9641dcc001ed416587b3ab60337c11a9")]
[assembly: AssemblyProduct("PeakArchetypes")]
[assembly: AssemblyTitle("ushysder.PeakArchetypes")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public static class Localization
{
	public class LocalizationCache
	{
		public Dictionary<string, Dictionary<string, string>> Data { get; set; }

		public DateTime LastUpdate { get; set; }
	}

	private static readonly string CachePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "BepInEx", "cache", "PeakArchetypes_LocalizationCache.json");

	private static readonly string RemoteUrl = "https://raw.githubusercontent.com/ushysder/PeakArchetypes/refs/heads/main/Localization/Localization.json";

	public static Dictionary<string, Dictionary<string, string>> Data { get; private set; } = new Dictionary<string, Dictionary<string, string>>();


	public static string Get(string lang, string key)
	{
		if (Data.TryGetValue(lang, out var value) && value.TryGetValue(key, out var value2))
		{
			return value2;
		}
		return key;
	}

	public static string GetSystemLang()
	{
		string text = CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
		if (!Data.ContainsKey(text))
		{
			text = "en";
		}
		return text;
	}

	public static void Init()
	{
		bool flag = true;
		if (File.Exists(CachePath))
		{
			try
			{
				LocalizationCache localizationCache = JsonConvert.DeserializeObject<LocalizationCache>(File.ReadAllText(CachePath));
				if (localizationCache != null && (DateTime.UtcNow - localizationCache.LastUpdate).TotalHours < 24.0)
				{
					Data = localizationCache.Data;
					flag = false;
				}
			}
			catch
			{
			}
		}
		if (flag && TryFetchFromGitHub(out var json))
		{
			Data = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string>>>(json) ?? new Dictionary<string, Dictionary<string, string>>();
			LocalizationCache localizationCache2 = new LocalizationCache
			{
				LastUpdate = DateTime.UtcNow,
				Data = Data
			};
			File.WriteAllText(CachePath, JsonConvert.SerializeObject((object)localizationCache2, (Formatting)1));
		}
	}

	private static bool TryFetchFromGitHub(out string json)
	{
		try
		{
			using WebClient webClient = new WebClient();
			webClient.Headers.Add("User-Agent", "PeakArchetypes");
			json = webClient.DownloadString(RemoteUrl);
			return true;
		}
		catch
		{
			json = null;
			return false;
		}
	}
}
namespace PeakArchetypes
{
	[BepInPlugin("ushysder.PeakArchetypes", "PeakArchetypes", "0.5.2")]
	public class Plugin : BaseUnityPlugin
	{
		public const string modGUID = "ushysder.PeakArchetypes";

		public const string modName = "PeakArchetypes";

		public const string modVersion = "0.5.2";

		internal static ManualLogSource mls = Logger.CreateLogSource("ushysder.PeakArchetypes");

		public static int localID;

		private Harmony _harmony;

		private void Awake()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			Localization.Init();
			PConfig.AllConfigs(((BaseUnityPlugin)this).Config);
			mls.LogInfo((object)"[PeakArchetypes] Plugin initializing...");
			_harmony = new Harmony("ushysder.PeakArchetypes");
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
			RoleManager.AppendRoles();
			mls.LogInfo((object)"[PeakArchetypes] Plugin initialized.");
		}

		private void OnDestroy()
		{
			_harmony.UnpatchSelf();
			mls.LogInfo((object)"[PeakArchetypes] Plugin unloaded.");
		}
	}
}
namespace PeakArchetypes.Utils
{
	public class PConfig
	{
		public static ConfigEntry<float> clumsy_InvertMaxTime;

		public static ConfigEntry<float> clumsy_InvertMinTime;

		public static ConfigEntry<int> clumsy_ItemDropChancePercent;

		public static ConfigEntry<float> drunk_maxFallInterval;

		public static ConfigEntry<float> drunk_minFallInterval;

		public static ConfigEntry<float> drunk_passOutDuration;

		public static ConfigEntry<float> drunk_timeToMaxDrunkness;

		public static ConfigEntry<float> drugs_timeToFullPoison;

		public static ConfigEntry<float> narco_passOutDuration;

		public static ConfigEntry<float> narco_timeToFullDrowsy;

		public static ConfigEntry<float> oneEyed_targetInjuryPercent;

		public static ConfigEntry<float> medic_HealCooldownTime;

		public static ConfigEntry<float> medic_HealRadius;

		public static ConfigEntry<float> medic_HealAmountPercent;

		public static ConfigEntry<float> medic_HoldDuration;

		public static ConfigEntry<KeyCode> medic_HealKey;

		public static void AllConfigs(ConfigFile cfg)
		{
			clumsy_InvertMinTime = cfg.Bind<float>("ClumsySettings", "InvertMinTime", 10f, $"Minimum time before inversion changes (seconds). [Min: {1f}, Max: {60f}]");
			clumsy_InvertMaxTime = cfg.Bind<float>("ClumsySettings", "InvertMaxTime", 30f, $"Maximum time before inversion changes (seconds). Must be >= InvertMinTime. [Min: InvertMinTime, Max: {120f}]");
			clumsy_ItemDropChancePercent = cfg.Bind<int>("ClumsySettings", "ItemDropChancePercent", 50, "Chance (in percent) to drop a random item when inversion changes. [0 = never, 100 = always]");
			drunk_maxFallInterval = cfg.Bind<float>("DrunkSettings", "MaxFallInterval", 45f, $"Max interval between falls (in seconds). [Min: {1f}, Max: {600f}]");
			drunk_minFallInterval = cfg.Bind<float>("DrunkSettings", "MinFallInterval", 10f, $"Min interval between falls (in seconds). [Min: {1f}, Max: MaxFallInterval]");
			drunk_passOutDuration = cfg.Bind<float>("DrunkSettings", "PassOutDuration", 5f, $"Duration the player stays passed out (in seconds). [Min: {1f}, Max: {30f}]");
			drunk_timeToMaxDrunkness = cfg.Bind<float>("DrunkSettings", "TimeToMaxDrunkness", 300f, $"Time to reach full drunkenness (in seconds). [Min: {60f}, Max: {1800f}]");
			drugs_timeToFullPoison = cfg.Bind<float>("DrugsSettings", "TimeToFullPoison", 900f, $"Seconds it takes for Poison status to reach full overdose. [Min: {600f}, Max: {2700f}]");
			narco_timeToFullDrowsy = cfg.Bind<float>("NarcolepticSettings", "TimeToFullDrowsy", 300f, $"Seconds it takes for Drowsy status to reach full and cause pass out. [Min: {30f}, Max: {600f}]");
			narco_passOutDuration = cfg.Bind<float>("NarcolepticSettings", "PassOutDuration", 5f, $"Duration the player stays passed out after max Drowsy is reached. [Min: {1f}, Max: {30f}]");
			oneEyed_targetInjuryPercent = cfg.Bind<float>("OneEyedSettings", "TargetInjuryPercent", 50f, $"Percentage of injury to maintain for one-eyed effect. [Min: {10f}, Max: {90f}]");
			medic_HealCooldownTime = cfg.Bind<float>("MedicSettings", "HealCooldownTime", 900f, $"Cooldown time between be able to heals in seconds. [Min: {0f}, Max: {3600f}]");
			medic_HealRadius = cfg.Bind<float>("MedicSettings", "HealRadius", 5f, $"Radius within which players can be healed. [Min: {0.1f}, Max: {20f}]");
			medic_HealAmountPercent = cfg.Bind<float>("MedicSettings", "HealAmountPercent", 3000f, $"Percentage of health restored per heal. Example: 30 = 30%. [Min: {100f}%, Max: {10000f}%]");
			medic_HoldDuration = cfg.Bind<float>("MedicSettings", "HoldDuration", 5f, $"Time in seconds the heal button must be held to complete healing. [Min: {0.1f}, Max: {30f}]");
			medic_HealKey = cfg.Bind<KeyCode>("MedicSettings", "HealKey", (KeyCode)104, "Key used to trigger healing skill.");
		}
	}
}
namespace PeakArchetypes.UI
{
	public class RoleSelectionUI : MonoBehaviour
	{
		private Text displayText;

		private GameObject panel;

		private int selectedIndex = -1;

		private string lang;

		private List<Role> RoleList => RoleManager.defaultTypes;

		private void Start()
		{
			lang = Localization.GetSystemLang();
			CreateUI();
		}

		private void OnDestroy()
		{
			if ((Object)(object)panel != (Object)null)
			{
				Object.Destroy((Object)(object)panel);
			}
			if ((Object)(object)((Component)this).gameObject != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		private void Update()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < RoleList.Count; i++)
			{
				KeyCode val = (KeyCode)(48 + i);
				KeyCode val2 = (KeyCode)(256 + i);
				if (Input.GetKeyDown(val) || Input.GetKeyDown(val2))
				{
					selectedIndex = i;
					UpdateDisplayText();
					Debug.Log((object)$">>> Selected index {i}: {RoleList[i].RoleName}");
					break;
				}
			}
			if (selectedIndex != -1 && (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271)))
			{
				OnConfirm();
			}
		}

		private void CreateUI()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("GAME/GUIManager/Canvas_HUD");
			if ((Object)(object)val == (Object)null)
			{
				Debug.Log((object)">>> Canvas not found in scene.");
				return;
			}
			int count = RoleList.Count;
			int num = 25;
			int num2 = 20;
			int num3 = Mathf.Max(400, count * num + num2);
			panel = new GameObject("RoleSelectionPanel");
			panel.transform.SetParent(val.transform, false);
			panel.AddComponent<CanvasRenderer>();
			Image val2 = panel.AddComponent<Image>();
			((Graphic)val2).color = new Color(0f, 0f, 0f, 0.8f);
			RectTransform component = panel.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(600f, (float)num3);
			component.anchoredPosition = new Vector2(0f, 0f);
			GameObject val3 = new GameObject("RoleText");
			val3.transform.SetParent(panel.transform, false);
			displayText = val3.AddComponent<Text>();
			displayText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			displayText.fontSize = 20;
			displayText.alignment = (TextAnchor)0;
			((Graphic)displayText).color = Color.white;
			RectTransform component2 = ((Component)displayText).GetComponent<RectTransform>();
			component2.sizeDelta = new Vector2(580f, (float)(num3 - num2));
			component2.anchoredPosition = new Vector2(0f, 0f);
			UpdateDisplayText();
		}

		private void OnConfirm()
		{
			if (selectedIndex >= 0 && selectedIndex < RoleList.Count)
			{
				Role role = RoleList[selectedIndex];
				int actorNumber = PhotonNetwork.LocalPlayer.ActorNumber;
				if (RoleManager.players.ContainsKey(actorNumber))
				{
					RoleManager.players[actorNumber] = role;
				}
				else
				{
					RoleManager.players.Add(actorNumber, role);
				}
				Debug.Log((object)(">>> Selected role: " + role.RoleName));
				Object.Destroy((Object)(object)panel);
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		private void UpdateDisplayText()
		{
			string text = Localization.Get(lang, "ChooseRole") + "\n\n";
			for (int i = 0; i < RoleList.Count; i++)
			{
				string text2 = ((i == selectedIndex) ? "➡ " : "   ");
				text += $"{text2}<b>{i}</b>. {RoleList[i].RoleName} - {RoleList[i].Desc}\n";
			}
			text = text + "\n" + Localization.Get(lang, "EnterNumber");
			displayText.text = text;
		}
	}
}
namespace PeakArchetypes.Shared
{
	internal class Const
	{
		public const float clumsy_InvertMinTime = 10f;

		public const float clumsy_InvertMinTime_Min = 1f;

		public const float clumsy_InvertMinTime_Max = 60f;

		public const float clumsy_InvertMaxTime = 30f;

		public const float clumsy_InvertMaxTime_Max = 120f;

		public const int clumsy_ItemDropChancePercent = 50;

		public const int clumsy_ItemDropChancePercent_Min = 0;

		public const int clumsy_ItemDropChancePercent_Max = 100;

		public const float drunk_minFallInterval = 10f;

		public const float drunk_minFallInterval_Min = 1f;

		public const float drunk_maxFallInterval = 45f;

		public const float drunk_maxFallInterval_Min = 1f;

		public const float drunk_maxFallInterval_Max = 600f;

		public const float drunk_passOutDuration = 5f;

		public const float drunk_passOutDuration_Min = 1f;

		public const float drunk_passOutDuration_Max = 30f;

		public const float drunk_timeToMaxDrunkness = 300f;

		public const float drunk_timeToMaxDrunkness_Min = 60f;

		public const float drunk_timeToMaxDrunkness_Max = 1800f;

		public const float drugs_timeToFullPoison = 900f;

		public const float drugs_timeToFullPoison_Min = 600f;

		public const float drugs_timeToFullPoison_Max = 2700f;

		public const float narco_passOutDuration = 5f;

		public const float narco_passOutDuration_Min = 1f;

		public const float narco_passOutDuration_Max = 30f;

		public const float narco_timeToFullDrowsy = 300f;

		public const float narco_timeToFullDrowsy_Min = 30f;

		public const float narco_timeToFullDrowsy_Max = 600f;

		public const float oneEyed_targetInjuryPercent = 50f;

		public const float oneEyed_targetInjuryPercent_Min = 10f;

		public const float oneEyed_targetInjuryPercent_Max = 90f;

		public const string medic_SkillIconBase64 = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAHjAAAB4wGoU74kAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAC6pJREFUeJztmntw3NV1xz/nt6vH2hZ+P7CllSxsR/i1EsKQENcrMAOlYZoG4k5p3TYNZIDQNARS0uYxDR2aP9I83ExCCOmAM01Np+aRdgrk5ViSlXg81Ja0tgx+yFqtZNnWWrZlIa129/e7p39I3pWsXWl39QCm/v61v3PPOb9zzt577vmde+EaruEa/j9DZuIlJVU1N8dx2s827gtnKuP1+b+HcNsoouKI6NPtTfVvTJVt7qlSlA6rVt1TEDMD+/KwdgEPZiH6mFqWJQX5CqDGIIMxUZVtwAcnAL0FkTwPFAoUZS28toz4kw8IgPT24/78jim3z5pyjR8wTPsMCLfU9nt9W/YAe9IybdvmKjsR3mAccSWJJh33Iu+G26uvPFgu7Qk21QZztW/aAwBoqLn+zvEYSo51f8kI/4SlowfcSfPU7QIRUL0Xy9x7hW4ULa/eXHbqYEMoF+NmIgCsrLqjNGr1hrsOHhxINS7oYhCc3/8wFHkSdPWtTjLNLsR+5I+Q85eSci1tWEeDYsfyFgPvzwBUV1fnhW3niNvM/inw6Hi86q9Cr1+QfvzWtYycI1Y0BkeDk7Jv2pNgaLCoAJgDsnC635VATY176ca7ZmfCmtMMKPb93i2WWKUjaaLYhYP2r48d+21fLjoB5PBJpHN4txTBVHhhzqzkePtZpPti8rmrJ6Ue70V9ASt6G7BqondmHYDl1dWzLNtqQMkbSVcgUuD6OvD0SHp47eKI91j320BjOp1iyYAquHb9ajT9lrU4n/3E0O9IDPc/7lQcZ0z1aqH9V5FWoBRn4k/WAXDHPA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2xcuZmFefmrmHBAzhqfeOaIKBtXPkOPxW8YBWLl+61LH2L9kZN4QQAT1JB1TTwECPNN6bJT89uVevr66IhcbU2JHsJWTA/2iyI6OwL6cj6AyDoAj0dngEt1QnrgXAKDzi2Be8lqA88nbhz5Rr1RsA1FcL77OQBaHmxNhz/luftzRhkCz1ctXJ6Mr6yRolizAbLoxPcMcD+bm5D8tl/vhxZxsS4m2SD9PvnPEKDJgxGzrDNYNTkbfB+p+wPlYjE8fPqTvOjaC/mVnU/2JyerMOgBW8Cy8/rskYX4R5rYNiUfpvoh18BhqhnNSdExjOSf02zYPHTlIRyQiCl8MNde/OhV6Mw6AMc4lsVy2tHa6Xa2do8Z0jTfxTW79VwPWbwNj5Ofn595FumzbfDpwUI/09QmqOzoC9d/JWdlVyDgAnS37LxTfVHOjKGUJojGPgNxPPFl/iJ38Pcvl5h9WV1Bc6OGmornkgovxOJ86/L/a0tcnin6/I1D/RE6K0iCrJdB5qPYkkGiwlfr8f5CmM40iPxhw7Me+1XpCn9tQKXk5HJq0DQzw4OGDGhqMiMB3Q831TzL61HzSmLajnDy3+yuoPh6OR/VPG9/SN8Jns5JvuNjD/Y0HTGgwoiI81d5c9wRT7DxM0S7gevpFFWu4PorFE4VSKFD/L15fTWtMzb9//mjguqbiXr6wchUeK+09K2w1fLetlec7g6BEBd3e3jQ1CS+l7ZMRnre0NC5CBY5zDts+g22fQfUMsCfYuPc/AHrPBY8vWFr+GqL+Q5d7l/5P91ldPadIvIVj22lH+i7zyJEmffP8ORHkiFrOXaGmffWTsXEizFhjc9Wqewqic/qfEZUnBKz7l63gc6XlrCj0cDY6yHOhILu6QmqGunrP6qz4U53790em264Z7ewClFT6N4nyA2ATQKHl0kGTuP/baNR6NJeLDrlixgMwDKvU5/+4UT5poSuwpEvhtdDqJa9O9tLTNVzDNVxDNvg/yFyg19sacjIAAAAASUVORK5CYII=";

		public const float medic_HealCooldownTime = 900f;

		public const float medic_HealCooldownTime_Min = 0f;

		public const float medic_HealCooldownTime_Max = 3600f;

		public const float medic_HealRadius = 5f;

		public const float medic_HealRadius_Min = 0.1f;

		public const float medic_HealRadius_Max = 20f;

		public const float medic_HealAmountPercent = 30f;

		public const float medic_HealAmount_Min = 1f;

		public const float medic_HealAmount_Max = 100f;

		public const float medic_HoldDuration = 5f;

		public const float medic_HoldDuration_Min = 0.1f;

		public const float medic_HoldDuration_Max = 30f;

		public const KeyCode medic_HealKey = 104;
	}
	public class EffectParam
	{
		public VolumeComponent effect;

		public object originalValue;

		public PropertyInfo overrideProp;

		public PropertyInfo valueProp;

		public Volume volume;

		public object volumeParam;
	}
	public static class ImageUtils
	{
		public static Sprite Base64ToSprite(string base64, float pixelsPerUnit = 100f)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			byte[] array = Convert.FromBase64String(base64);
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
			ImageConversion.LoadImage(val, array);
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), pixelsPerUnit);
		}
	}
	public class RoleRPC : MonoBehaviourPun
	{
		private GameObject currentHealingCircle;

		private void Awake()
		{
			PhotonView component = ((Component)this).GetComponent<PhotonView>();
			Debug.Log((object)$"[RoleRPC] Awake on {((Object)((Component)this).gameObject).name}, PhotonView {((component != null) ? new int?(component.ViewID) : null)}");
		}

		[PunRPC]
		private void MedicHealNearbyPlayersRPC(Vector3 healCenter, float healRadius, float healAmount)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)$"[MedicHealNearbyPlayersRPC] Heal center: {healCenter}, radius: {healRadius}");
			int num = LayerMask.NameToLayer("Character");
			Collider[] array = Physics.OverlapSphere(healCenter, healRadius);
			Debug.Log((object)$"[MedicHealNearbyPlayersRPC] Found {array.Length} colliders in radius (all layers).");
			HashSet<string> hashSet = new HashSet<string>();
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				if (((Component)val).gameObject.layer != num)
				{
					continue;
				}
				Character componentInParent = ((Component)val).GetComponentInParent<Character>();
				if (!((Object)(object)componentInParent == (Object)null) && !hashSet.Contains(((Object)componentInParent).name))
				{
					CharacterAfflictions afflictions = componentInParent.refs.afflictions;
					float currentStatus = afflictions.GetCurrentStatus((STATUSTYPE)0);
					Debug.Log((object)$"[MedicHealNearbyPlayersRPC] Found Character {((Object)componentInParent).name} with current injury {currentStatus}");
					if (currentStatus > 0f)
					{
						float num2 = Mathf.Max(currentStatus - healAmount, 0f);
						afflictions.SetStatus((STATUSTYPE)0, num2);
						Debug.Log((object)$"[MedicEffects] Healed {((Object)componentInParent).name} by {healAmount}. New injury: {num2}");
						hashSet.Add(((Object)componentInParent).name);
					}
				}
			}
		}

		public void CallHealRPC(Vector3 healCenter, float healRadius, float healAmount)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			PhotonView component = ((Component)this).GetComponent<PhotonView>();
			if ((Object)(object)component == (Object)null)
			{
				Debug.LogError((object)"[RoleRPC] PhotonView missing!");
				return;
			}
			component.RPC("MedicHealNearbyPlayersRPC", (RpcTarget)0, new object[3] { healCenter, healRadius, healAmount });
		}

		[PunRPC]
		public void ShowHealingCircleRPC(Vector3 position, float radius)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)currentHealingCircle != (Object)null)
			{
				Object.Destroy((Object)(object)currentHealingCircle);
			}
			int num = 60;
			currentHealingCircle = new GameObject("HealingCircle");
			LineRenderer val = currentHealingCircle.AddComponent<LineRenderer>();
			val.positionCount = num + 1;
			val.loop = true;
			val.widthMultiplier = 0.05f;
			((Renderer)val).material = new Material(Shader.Find("Sprites/Default"));
			val.startColor = Color.green;
			val.endColor = Color.green;
			for (int i = 0; i <= num; i++)
			{
				float num2 = MathF.PI * 2f * (float)i / (float)num;
				float num3 = Mathf.Cos(num2) * radius;
				float num4 = Mathf.Sin(num2) * radius;
				val.SetPosition(i, position + new Vector3(num3, 0f, num4));
			}
		}

		[PunRPC]
		public void HideHealingCircleRPC()
		{
			if ((Object)(object)currentHealingCircle != (Object)null)
			{
				Object.Destroy((Object)(object)currentHealingCircle);
				currentHealingCircle = null;
			}
		}

		[PunRPC]
		public void RequestGiveItemRPC(int targetPlayerViewID, string itemName)
		{
			if (!PhotonNetwork.IsMasterClient)
			{
				return;
			}
			PhotonView val = PhotonView.Find(targetPlayerViewID);
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogError((object)"RequestGiveItemRPC: target player view not found");
				return;
			}
			Character component = ((Component)val).GetComponent<Character>();
			if ((Object)(object)component == (Object)null || (Object)(object)component.player == (Object)null)
			{
				Debug.LogError((object)"RequestGiveItemRPC: target player component not found");
				return;
			}
			Item[] source = Resources.FindObjectsOfTypeAll<Item>();
			Item val2 = ((IEnumerable<Item>)source).FirstOrDefault((Func<Item, bool>)((Item i) => ((Object)i).name == itemName));
			ItemSlot val3 = default(ItemSlot);
			if ((Object)(object)val2 == (Object)null)
			{
				Debug.LogError((object)("RequestGiveItemRPC: Item '" + itemName + "' not found"));
			}
			else if (!component.player.AddItem(val2.itemID, (ItemInstanceData)null, ref val3))
			{
				Debug.LogError((object)("RequestGiveItemRPC: Failed to add " + itemName + " to " + component.characterName));
			}
			else
			{
				Debug.Log((object)("RequestGiveItemRPC: Successfully added " + itemName + " to " + component.characterName));
			}
		}
	}
}
namespace PeakArchetypes.Scripts
{
	internal static class GameHelpers
	{
		private static Character character;

		public static Character GetCharacterComponent()
		{
			if ((Object)(object)character == (Object)null || !((Behaviour)character).isActiveAndEnabled)
			{
				character = Character.localCharacter;
			}
			return character;
		}
	}
	[HarmonyPatch]
	internal class MainGame
	{
		public static bool enteredAwake;

		[HarmonyPatch(typeof(Player), "Awake")]
		[HarmonyPostfix]
		private static void Postfix(Player __instance)
		{
			Character character = __instance.character;
			if ((Object)(object)character == (Object)null)
			{
				Debug.LogWarning((object)("[Patch] Player " + ((MonoBehaviourPun)__instance).photonView.Owner.NickName + " has no Character yet."));
				return;
			}
			RoleRPC component = ((Component)character).gameObject.GetComponent<RoleRPC>();
			if ((Object)(object)component == (Object)null)
			{
				Debug.Log((object)("[Patch] Adding RoleRPC to " + ((Object)character).name + " owned by " + ((MonoBehaviourPun)__instance).photonView.Owner.NickName));
				((Component)character).gameObject.AddComponent<RoleRPC>();
			}
			else
			{
				Debug.Log((object)("[Patch] RoleRPC already present on " + ((Object)character).name));
			}
		}

		[HarmonyPatch(typeof(GUIManager), "SetHeroTitle")]
		[HarmonyPrefix]
		private static bool AnnounceRole(ref string text)
		{
			RoleManager.ApplyDebuffs();
			int actorNumber = ((Component)Character.localCharacter).gameObject.GetComponent<PhotonView>().Owner.ActorNumber;
			if (RoleManager.players.ContainsKey(actorNumber))
			{
				Role component = ((Component)Character.localCharacter).gameObject.GetComponent<Role>();
				text = component.RoleName;
			}
			return true;
		}

		[HarmonyPatch(typeof(Character), "EndGame")]
		[HarmonyPrefix]
		private static bool EndGamePatch()
		{
			ResetVars("Game has ended");
			return true;
		}

		[HarmonyPatch(typeof(Campfire), "Awake")]
		[HarmonyPostfix]
		private static void InGame()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			if (!enteredAwake)
			{
				int actorNumber = PhotonNetwork.LocalPlayer.ActorNumber;
				if (!RoleManager.players.ContainsKey(actorNumber))
				{
					GameObject val = new GameObject("RoleSelectionUI");
					val.AddComponent<RoleSelectionUI>();
					enteredAwake = true;
				}
			}
		}

		[HarmonyPatch(typeof(PassportManager), "Awake")]
		[HarmonyPrefix]
		private static bool OnPlayerLeftRoomPatch()
		{
			RoleManager.players.Clear();
			enteredAwake = false;
			return true;
		}

		[HarmonyPatch(typeof(Character), "Start")]
		[HarmonyPostfix]
		private static void HookRevive(Character __instance)
		{
			if (__instance.IsLocal)
			{
				__instance.reviveAction = (Action)Delegate.Combine(__instance.reviveAction, (Action)delegate
				{
					Debug.Log((object)">>> Local player revived, reapplying debuffs...");
					RoleManager.ApplyDebuffs();
				});
			}
		}

		[HarmonyPatch(typeof(Character), "RPCA_Die")]
		[HarmonyPostfix]
		private static void PlayerDiedPatch()
		{
			Character localCharacter = Character.localCharacter;
			if (localCharacter.data.dead)
			{
				RoleManager.RemoveDebuffs();
				Debug.Log((object)">>> You died (rip)");
			}
		}

		private static void ResetVars(string msg = "")
		{
			RoleManager.RemoveDebuffs();
			RoleManager.players.Clear();
			enteredAwake = false;
			Debug.Log((object)(">>> " + msg));
		}
	}
	public class Role : MonoBehaviour
	{
		private static readonly Dictionary<RoleManager.RoleType, Type> roleComponentMap = new Dictionary<RoleManager.RoleType, Type>
		{
			{
				RoleManager.RoleType.blind,
				typeof(Blind)
			},
			{
				RoleManager.RoleType.deaf,
				typeof(Deaf)
			},
			{
				RoleManager.RoleType.mute,
				typeof(Mute)
			},
			{
				RoleManager.RoleType.clumsy,
				typeof(Clumsy)
			},
			{
				RoleManager.RoleType.drunk,
				typeof(Drunk)
			},
			{
				RoleManager.RoleType.drugs,
				typeof(Drugs)
			},
			{
				RoleManager.RoleType.narcoleptic,
				typeof(Narcoleptic)
			},
			{
				RoleManager.RoleType.oneEyed,
				typeof(OneEyed)
			},
			{
				RoleManager.RoleType.medic,
				typeof(Medic)
			}
		};

		public string Desc { get; set; }

		public string RoleName { get; set; }

		public RoleManager.RoleType RoleType { get; set; }

		public Role(string roleName, string desc, RoleManager.RoleType roleType)
		{
			RoleName = roleName;
			Desc = desc;
			RoleType = roleType;
		}

		private void OnDestroy()
		{
			ApplyRoleEffect(add: false);
		}

		private void Start()
		{
			ApplyRoleEffect(add: true);
		}

		private void ApplyRoleEffect(bool add)
		{
			Character localCharacter = Character.localCharacter;
			if ((Object)(object)localCharacter == (Object)null)
			{
				return;
			}
			GameObject gameObject = ((Component)localCharacter).gameObject;
			if (!roleComponentMap.TryGetValue(RoleType, out var value) || value == null)
			{
				return;
			}
			Component component = gameObject.GetComponent(value);
			if (add)
			{
				if ((Object)(object)component == (Object)null)
				{
					gameObject.AddComponent(value);
				}
			}
			else if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
		}
	}
	public class RoleManager
	{
		public enum RoleType
		{
			blind,
			deaf,
			mute,
			drunk,
			drugs,
			clumsy,
			nothing,
			narcoleptic,
			oneEyed,
			medic
		}

		public static List<Role> defaultTypes = new List<Role>();

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

		public static void AppendRoles()
		{
			string lang = Localization.GetSystemLang();
			AddRole("Basic", RoleType.nothing);
			AddRole("Blind", RoleType.blind);
			AddRole("Deaf", RoleType.deaf);
			AddRole("Mute", RoleType.mute);
			AddRole("Drugs", RoleType.drugs);
			AddRole("Drunk", RoleType.drunk);
			AddRole("Clumsy", RoleType.clumsy);
			AddRole("Narcoleptic", RoleType.narcoleptic);
			AddRole("OneEyed", RoleType.oneEyed);
			AddRole("Medic", RoleType.medic);
			void AddRole(string key, RoleType type)
			{
				string roleName = Localization.Get(lang, key + "_Name");
				string desc = Localization.Get(lang, key + "_Desc");
				defaultTypes.Add(new Role(roleName, desc, type));
			}
		}

		public static void ApplyDebuffs()
		{
			int actorNumber = ((Component)Character.localCharacter).gameObject.GetComponent<PhotonView>().Owner.ActorNumber;
			if (players.ContainsKey(actorNumber))
			{
				Role role = ((Component)Character.localCharacter).gameObject.GetComponent<Role>() ?? ((Component)Character.localCharacter).gameObject.AddComponent<Role>();
				role.RoleName = players[actorNumber].RoleName;
				role.RoleType = players[actorNumber].RoleType;
				role.Desc = players[actorNumber].Desc;
			}
			Debug.Log((object)"[AssignRoles] Debuffs applied to character.");
		}

		public static void RemoveDebuffs()
		{
			Role component = ((Component)Character.localCharacter).GetComponent<Role>();
			Object.Destroy((Object)(object)component);
			Debug.Log((object)"[AssignRoles] Debuffs removed from character.");
		}
	}
}
namespace PeakArchetypes.Scripts.Roles
{
	public class Blind : MonoBehaviour
	{
		private GameObject blackScreen;

		private void OnDestroy()
		{
			if ((Object)(object)blackScreen != (Object)null)
			{
				Object.Destroy((Object)(object)blackScreen);
			}
			Debug.Log((object)"[Blind] Blind effect destroyed.");
		}

		private void Start()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("GAME/GUIManager/Canvas_HUD");
			blackScreen = new GameObject("blackScreen");
			blackScreen.transform.SetParent(val.transform, false);
			((Graphic)blackScreen.AddComponent<Image>()).color = Color.black;
			blackScreen.transform.SetAsFirstSibling();
			RectTransform component = blackScreen.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(7200f, 7200f);
			Debug.Log((object)"[Blind] Blind effect started.");
		}
	}
	internal class Clumsy : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <ClumsyRoutine>d__13 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Clumsy <>4__this;

			private float <waitTime>5__1;

			private bool <invertX>5__2;

			private bool <invertY>5__3;

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

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

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

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

			private bool MoveNext()
			{
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					<invertX>5__2 = Random.value > 0.5f;
					<invertY>5__3 = Random.value > 0.5f;
					<>4__this.ApplyInversion(<invertX>5__2, <invertY>5__3);
					if (Random.Range(0, 100) < <>4__this.validatedDropChance)
					{
						<>4__this.DropRandomItem();
					}
					break;
				}
				<waitTime>5__1 = Random.Range(<>4__this.validatedMinTime, <>4__this.validatedMaxTime);
				<>2__current = (object)new WaitForSeconds(<waitTime>5__1);
				<>1__state = 1;
				return true;
			}

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

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

		private Character character;

		private CharacterMovement characterMovement;

		private FieldInfo invertXField;

		private FieldInfo invertYField;

		private float validatedMaxTime;

		private int validatedDropChance;

		private float validatedMinTime;

		private PropertyInfo valuePropX;

		private PropertyInfo valuePropY;

		private void Initialize()
		{
			if ((Object)(object)Character.localCharacter == (Object)null)
			{
				Debug.LogWarning((object)"[Clumsy] Character.localCharacter is null — skipping initialization.");
				((Behaviour)this).enabled = false;
				return;
			}
			character = GameHelpers.GetCharacterComponent();
			characterMovement = character.refs.movement;
			if ((Object)(object)characterMovement == (Object)null || (Object)(object)character == (Object)null)
			{
				Debug.LogError((object)"[Clumsy] Missing required components.");
				((Behaviour)this).enabled = false;
				return;
			}
			Type type = ((object)characterMovement).GetType();
			invertXField = type.GetField("invertXSetting", BindingFlags.Instance | BindingFlags.NonPublic);
			invertYField = type.GetField("invertYSetting", BindingFlags.Instance | BindingFlags.NonPublic);
			if (invertXField == null || invertYField == null)
			{
				Debug.LogError((object)"[Clumsy] Invert fields not found.");
				((Behaviour)this).enabled = false;
				return;
			}
			object value = invertXField.GetValue(characterMovement);
			object value2 = invertYField.GetValue(characterMovement);
			if (value == null || value2 == null)
			{
				Debug.LogError((object)"[Clumsy] Invert field values are null.");
				((Behaviour)this).enabled = false;
				return;
			}
			valuePropX = value.GetType().GetProperty("Value", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			valuePropY = value2.GetType().GetProperty("Value", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (valuePropX == null || valuePropY == null)
			{
				Debug.LogError((object)"[Clumsy] Value properties not found.");
				((Behaviour)this).enabled = false;
				return;
			}
			validatedMinTime = ((PConfig.clumsy_InvertMinTime.Value >= 1f && PConfig.clumsy_InvertMinTime.Value <= 60f) ? PConfig.clumsy_InvertMinTime.Value : 10f);
			validatedMaxTime = ((PConfig.clumsy_InvertMaxTime.Value >= validatedMinTime && PConfig.clumsy_InvertMaxTime.Value <= 120f) ? PConfig.clumsy_InvertMaxTime.Value : Mathf.Max(validatedMinTime, 30f));
			validatedDropChance = ((PConfig.clumsy_ItemDropChancePercent.Value >= 0 && PConfig.clumsy_ItemDropChancePercent.Value <= 100) ? PConfig.clumsy_ItemDropChancePercent.Value : 50);
			Debug.Log((object)$"[Clumsy] Configured time range: {validatedMinTime} to {validatedMaxTime} seconds");
		}

		private void OnDestroy()
		{
			ApplyInversion(invertX: false, invertY: false);
			((MonoBehaviour)this).StopCoroutine(ClumsyRoutine());
			Debug.Log((object)"[Clumsy] Reset Clumsy on destroy");
		}

		private void Start()
		{
			Initialize();
			((MonoBehaviour)this).StartCoroutine(ClumsyRoutine());
			Debug.Log((object)"[Clumsy] Clumsy effect coroutine started.");
		}

		private void ApplyInversion(bool invertX, bool invertY)
		{
			if (!((Object)(object)characterMovement == (Object)null) && !(invertXField == null) && !(invertYField == null) && !(valuePropX == null) && !(valuePropY == null))
			{
				object value = invertXField.GetValue(characterMovement);
				object value2 = invertYField.GetValue(characterMovement);
				if (value != null && value2 != null)
				{
					object obj = Enum.Parse(valuePropX.PropertyType, invertX ? "ON" : "OFF");
					object obj2 = Enum.Parse(valuePropY.PropertyType, invertY ? "ON" : "OFF");
					valuePropX.SetValue(value, obj);
					valuePropY.SetValue(value2, obj2);
					Debug.Log((object)$"[Clumsy] Applied inversion - X: {obj}, Y: {obj2}");
				}
			}
		}

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

		private void DropRandomItem()
		{
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			if (!character.refs.view.IsMine)
			{
				return;
			}
			List<byte> list = new List<byte>();
			ItemSlot[] itemSlots = character.player.itemSlots;
			for (byte b = 0; b < itemSlots.Length; b++)
			{
				if (!itemSlots[b].IsEmpty())
				{
					list.Add(b);
				}
			}
			if (list.Count == 0)
			{
				return;
			}
			byte b2 = list[Random.Range(0, list.Count)];
			Transform transform = ((Component)character.refs.hip).transform;
			Vector3 val = transform.position + Vector3.up * 1.5f;
			if (character.refs.view.IsMine)
			{
				Debug.Log((object)$"[Clumsy] Attempting to drop random item at slot {b2} | CurrentSelectedSlot : {character.refs.items.currentSelectedSlot.Value}.");
				if (character.refs.items.currentSelectedSlot.IsSome && character.refs.items.currentSelectedSlot.Value == b2)
				{
					character.refs.items.EquipSlot(Optionable<byte>.None);
					Debug.Log((object)$"[Clumsy] Unselected slot {b2} before dropping item.");
				}
				character.refs.view.RPC("ClumsyDropItemRPC", (RpcTarget)0, new object[2] { b2, val });
				Debug.Log((object)$"[Clumsy] Dropped item from slot {b2} at pos {val}");
			}
		}

		[PunRPC]
		private void ClumsyDropItemRPC(byte slotID, Vector3 spawnPosition)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)$"[Clumsy] Called on client {PhotonNetwork.LocalPlayer.NickName}. IsMasterClient={PhotonNetwork.IsMasterClient}");
			ItemSlot itemSlot = character.player.GetItemSlot(slotID);
			if (!itemSlot.IsEmpty())
			{
				string text = "0_Items/" + itemSlot.GetPrefabName();
				Debug.Log((object)$"[Clumsy] Attempting to instantiate prefab '{text}' at {spawnPosition}");
				GameObject val = PhotonNetwork.Instantiate(text, spawnPosition, Quaternion.identity, (byte)0, (object[])null);
				if ((Object)(object)val == (Object)null)
				{
					Debug.LogError((object)("[Clumsy] Failed to instantiate prefab '" + text + "'"));
					return;
				}
				PhotonView component = val.GetComponent<PhotonView>();
				if ((Object)(object)component == (Object)null)
				{
					Debug.LogError((object)"[Clumsy] Instantiated object missing PhotonView component");
					return;
				}
				Debug.Log((object)("[Clumsy] Successfully instantiated '" + ((Object)((Component)component).gameObject).name + "'"));
				component.RPC("SetItemInstanceDataRPC", (RpcTarget)0, new object[1] { itemSlot.data });
				component.RPC("SetKinematicRPC", (RpcTarget)0, new object[3]
				{
					false,
					((Component)component).transform.position,
					((Component)component).transform.rotation
				});
			}
			else
			{
				Debug.LogWarning((object)$"[Clumsy] Item slot {slotID} is empty, no item to instantiate");
			}
			if (character.refs.view.IsMine)
			{
				Debug.Log((object)$"[Clumsy] Emptying slot {slotID} on client {PhotonNetwork.LocalPlayer.NickName}");
				character.player.EmptySlot(Optionable<byte>.Some(slotID));
				CharacterAfflictions afflictions = character.refs.afflictions;
				MethodInfo method = ((object)afflictions).GetType().GetMethod("UpdateWeight", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (method != null)
				{
					method.Invoke(afflictions, null);
					Debug.Log((object)"[Clumsy] Called UpdateWeight successfully");
				}
				else
				{
					Debug.LogWarning((object)"[Clumsy] Could not find UpdateWeight method");
				}
			}
		}
	}
	public class Deaf : MonoBehaviour
	{
		private void Start()
		{
			AudioListener.volume = 0f;
			Debug.Log((object)"[Deaf] Deaf effect started.");
		}

		private void OnDestroy()
		{
			AudioListener.volume = 1f;
			Debug.Log((object)"[Deaf] Deaf effect destroyed.");
		}
	}
	public class Drugs : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <DrugsRoutine>d__10 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Drugs <>4__this;

			private PhotonView <view>5__1;

			private float <currentPoison>5__2;

			private Transform <hip>5__3;

			private Vector3 <forward>5__4;

			private Vector3 <dropPos>5__5;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<view>5__1 = null;
				<hip>5__3 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_0124: Unknown result type (might be due to invalid IL or missing references)
				//IL_012a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0134: Unknown result type (might be due to invalid IL or missing references)
				//IL_0139: Unknown result type (might be due to invalid IL or missing references)
				//IL_013e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0145: Unknown result type (might be due to invalid IL or missing references)
				//IL_014a: Unknown result type (might be due to invalid IL or missing references)
				//IL_015e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0163: Unknown result type (might be due to invalid IL or missing references)
				//IL_0168: Unknown result type (might be due to invalid IL or missing references)
				//IL_0186: Unknown result type (might be due to invalid IL or missing references)
				//IL_010e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0113: Unknown result type (might be due to invalid IL or missing references)
				//IL_0118: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<view>5__1 = <>4__this.character.refs.view;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				<currentPoison>5__2 = <>4__this.afflictions.GetCurrentStatus((STATUSTYPE)3);
				if (<currentPoison>5__2 < <>4__this.maxPoison)
				{
					<>4__this.afflictions.AddStatus((STATUSTYPE)3, <>4__this.poisonIncreasePerSecond * Time.deltaTime, false);
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				if ((Object)(object)<view>5__1 != (Object)null && <view>5__1.IsMine)
				{
					<hip>5__3 = ((Component)<>4__this.character.refs.hip).transform;
					<forward>5__4 = <hip>5__3.forward;
					if (Vector3.Dot(<forward>5__4, Vector3.up) < 0f)
					{
						<forward>5__4 = -<forward>5__4;
					}
					<dropPos>5__5 = <hip>5__3.position + <forward>5__4 * 0.6f;
					<dropPos>5__5 += Vector3.up * Random.Range(0f, 0.5f);
					<view>5__1.RPC("RPCA_Die", PhotonNetwork.LocalPlayer, new object[1] { <dropPos>5__5 });
					Debug.Log((object)"[Drugs] Player overdosed and died.");
					<hip>5__3 = null;
				}
				return false;
			}

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

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

		private readonly List<EffectParam> drugsParams = new List<EffectParam>();

		private readonly float maxPoison = 1f;

		private CharacterAfflictions afflictions;

		private Character character;

		private float originalPoisonReductionCooldown;

		private float originalPoisonReductionPerSecond;

		private float poisonIncreasePerSecond;

		private void Initialize()
		{
			character = GameHelpers.GetCharacterComponent();
			if ((Object)(object)character == (Object)null)
			{
				Debug.LogError((object)"[Drugs] Character component not found — disabling.");
				((Behaviour)this).enabled = false;
				return;
			}
			afflictions = character.refs.afflictions;
			if ((Object)(object)afflictions == (Object)null)
			{
				Debug.LogError((object)"[Drugs] CharacterAfflictions not found — disabling.");
				((Behaviour)this).enabled = false;
				return;
			}
			float value = PConfig.drugs_timeToFullPoison.Value;
			value = ((value >= 600f && value <= 2700f) ? value : 900f);
			poisonIncreasePerSecond = maxPoison / value;
			Debug.Log((object)$"[Drugs] poisonIncreasePerSecond set to {poisonIncreasePerSecond} (time to full: {value}s)");
			SaveAndDisablePoisonDecay();
			Volume[] array = Object.FindObjectsByType<Volume>((FindObjectsSortMode)0);
			if (array.Length == 0)
			{
				Debug.Log((object)"[Drugs] No Volume components found in the scene.");
				return;
			}
			Volume[] array2 = array;
			foreach (Volume val in array2)
			{
				if ((Object)(object)val.profile == (Object)null)
				{
					continue;
				}
				val.isGlobal = true;
				foreach (VolumeComponent component in val.profile.components)
				{
					if ((Object)(object)component == (Object)null)
					{
						continue;
					}
					string text = ((object)component).GetType().Name.ToLower();
					if (text != "hbao")
					{
						continue;
					}
					((object)component).GetType().GetProperty("active", BindingFlags.Instance | BindingFlags.Public)?.SetValue(component, true);
					FieldInfo[] fields = ((object)component).GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					HashSet<string> hashSet = new HashSet<string> { "debugMode" };
					FieldInfo[] array3 = fields;
					foreach (FieldInfo fieldInfo in array3)
					{
						if (!typeof(VolumeParameter).IsAssignableFrom(fieldInfo.FieldType) || !hashSet.Contains(fieldInfo.Name))
						{
							continue;
						}
						object value2 = fieldInfo.GetValue(component);
						if (value2 != null)
						{
							PropertyInfo property = value2.GetType().GetProperty("value", BindingFlags.Instance | BindingFlags.Public);
							PropertyInfo property2 = value2.GetType().GetProperty("overrideState", BindingFlags.Instance | BindingFlags.Public);
							if (!(property == null) && !(property2 == null))
							{
								object value3 = property.GetValue(value2);
								Type propertyType = property.PropertyType;
								object obj = Enum.Parse(propertyType, "ViewNormals");
								property2.SetValue(value2, true);
								property.SetValue(value2, obj);
								drugsParams.Add(new EffectParam
								{
									volumeParam = value2,
									valueProp = property,
									overrideProp = property2,
									originalValue = value3,
									volume = val,
									effect = component
								});
								Debug.Log((object)$"[Drugs] Set '{fieldInfo.Name}' on '{text}' to '{obj}'.");
							}
						}
					}
				}
			}
		}

		private void OnDestroy()
		{
			foreach (EffectParam drugsParam in drugsParams)
			{
				drugsParam.overrideProp?.SetValue(drugsParam.volumeParam, false);
				if (drugsParam.originalValue != null && drugsParam.valueProp != null)
				{
					drugsParam.valueProp.SetValue(drugsParam.volumeParam, drugsParam.originalValue);
				}
				if ((Object)(object)drugsParam.volume != (Object)null)
				{
					drugsParam.volume.isGlobal = false;
				}
			}
			drugsParams.Clear();
			Debug.Log((object)"[Drugs] Reset complete on destroy.");
		}

		private void Start()
		{
			Initialize();
			((MonoBehaviour)this).StartCoroutine(DrugsRoutine());
			Debug.Log((object)"[Drugs] Drugs effects started.");
		}

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

		private void RestorePoisonDecay()
		{
			afflictions.poisonReductionPerSecond = originalPoisonReductionPerSecond;
			afflictions.poisonReductionCooldown = originalPoisonReductionCooldown;
			Debug.Log((object)"[Drugs] Poison decay restored to original values.");
		}

		private void SaveAndDisablePoisonDecay()
		{
			originalPoisonReductionPerSecond = afflictions.poisonReductionPerSecond;
			originalPoisonReductionCooldown = afflictions.poisonReductionCooldown;
			afflictions.poisonReductionPerSecond = 0f;
			afflictions.poisonReductionCooldown = 999999f;
			Debug.Log((object)"[Drugs] Poison decay disabled for overdose effect.");
		}
	}
	public class Drunk : MonoBehaviour
	{
		private struct VignetteParam
		{
			public string fieldName;

			public PropertyInfo overrideProp;

			public object param;

			public PropertyInfo valueProp;
		}

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

			private object <>2__current;

			public Drunk <>4__this;

			private PhotonView <view>5__1;

			private float <drunkProgress>5__2;

			private float <currentInterval>5__3;

			private float <elapsed>5__4;

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

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

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

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

			private bool MoveNext()
			{
				//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ab: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					Debug.Log((object)"[Drunk] Coroutine started.");
					<view>5__1 = <>4__this.character.refs.view;
					goto IL_032d;
				case 1:
					<>1__state = -1;
					goto IL_0147;
				case 2:
					{
						<>1__state = -1;
						Debug.Log((object)"[Drunk] Recovering from pass out.");
						if ((Object)(object)<view>5__1 != (Object)null && <view>5__1.IsMine)
						{
							<view>5__1.RPC("RPCA_UnPassOut", PhotonNetwork.LocalPlayer, Array.Empty<object>());
						}
						<>4__this.drunkTimer = 0f;
						<>4__this.isDrunk = true;
						<>4__this.passedOut = false;
						goto IL_032d;
					}
					IL_0147:
					if (<elapsed>5__4 < <currentInterval>5__3 && <>4__this.isDrunk && !<>4__this.passedOut)
					{
						<>4__this.drunkTimer += Time.deltaTime;
						<drunkProgress>5__2 = Mathf.Clamp01(<>4__this.drunkTimer / <>4__this.timeToMaxDrunkness);
						<>4__this.drunkennessLevel = <drunkProgress>5__2;
						<>4__this.UpdateVignette(<>4__this.drunkennessLevel);
						<elapsed>5__4 += Time.deltaTime;
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					if (!<>4__this.passedOut && (Object)(object)<>4__this.character != (Object)null && (Object)(object)<view>5__1 != (Object)null && <view>5__1.IsMine)
					{
						Debug.Log((object)$"[Drunk] Falling... drunkenness level: {<drunkProgress>5__2:F2}");
						<view>5__1.RPC("RPCA_FallWithScreenShake", PhotonNetwork.LocalPlayer, new object[2] { 0.5f, 5f });
					}
					if (!<>4__this.passedOut && <drunkProgress>5__2 >= 1f)
					{
						Debug.Log((object)"[Drunk] Max drunkness reached. Passing out...");
						<>4__this.passedOut = true;
						<>4__this.isDrunk = false;
						if ((Object)(object)<view>5__1 != (Object)null && <view>5__1.IsMine)
						{
							<view>5__1.RPC("RPCA_PassOut", PhotonNetwork.LocalPlayer, Array.Empty<object>());
						}
						<>2__current = (object)new WaitForSeconds(<>4__this.passOutDuration);
						<>1__state = 2;
						return true;
					}
					goto IL_032d;
					IL_032d:
					if (<>4__this.isDrunk)
					{
						<drunkProgress>5__2 = Mathf.Clamp01(<>4__this.drunkTimer / <>4__this.timeToMaxDrunkness);
						<currentInterval>5__3 = Mathf.Lerp(<>4__this.maxFallInterval, <>4__this.minFallInterval, <drunkProgress>5__2);
						<elapsed>5__4 = 0f;
						goto IL_0147;
					}
					Debug.Log((object)"[Drunk] Coroutine exited.");
					return false;
				}
			}

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

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

		private readonly List<VignetteParam> vignetteParams = new List<VignetteParam>();

		private Character character;

		[Range(0f, 1f)]
		private float drunkennessLevel;

		private float drunkTimer = 0f;

		private bool isDrunk = false;

		private float maxFallInterval;

		private float minFallInterval;

		private bool passedOut = false;

		private float passOutDuration;

		private float timeToMaxDrunkness;

		private VolumeComponent vignetteEffect;

		private Volume vignetteVolume;

		private void Initialize()
		{
			float value = PConfig.drunk_maxFallInterval.Value;
			float value2 = PConfig.drunk_minFallInterval.Value;
			float value3 = PConfig.drunk_passOutDuration.Value;
			float value4 = PConfig.drunk_timeToMaxDrunkness.Value;
			maxFallInterval = ((value >= 1f && value <= 600f) ? value : 45f);
			minFallInterval = ((value2 >= 1f && value2 <= maxFallInterval) ? value2 : 10f);
			passOutDuration = ((value3 >= 1f && value3 <= 30f) ? value3 : 5f);
			timeToMaxDrunkness = ((value4 >= 60f && value4 <= 1800f) ? value4 : 300f);
			Debug.Log((object)$"[Drunk] Validated config: maxFall={maxFallInterval}, minFall={minFallInterval}, passOut={passOutDuration}, timeToMax={timeToMaxDrunkness}");
			FindVignetteEffect();
			character = GameHelpers.GetCharacterComponent();
			if ((Object)(object)character == (Object)null)
			{
				Debug.LogWarning((object)"[Drunk] No Character component found.");
				((Behaviour)this).enabled = false;
			}
			else
			{
				isDrunk = true;
				Debug.Log((object)"[Drunk] Initialized and ready to go.");
			}
		}

		private void OnDestroy()
		{
			isDrunk = false;
			passedOut = false;
			drunkTimer = 0f;
			drunkennessLevel = 0f;
			((MonoBehaviour)this).StopCoroutine(DrunkRoutine());
			foreach (VignetteParam vignetteParam in vignetteParams)
			{
				if (vignetteParam.valueProp != null)
				{
					if (vignetteParam.valueProp.PropertyType == typeof(float))
					{
						vignetteParam.valueProp.SetValue(vignetteParam.param, 0f);
					}
					else if (vignetteParam.valueProp.PropertyType == typeof(bool))
					{
						vignetteParam.valueProp.SetValue(vignetteParam.param, false);
					}
				}
				vignetteParam.overrideProp?.SetValue(vignetteParam.param, false);
			}
			if ((Object)(object)vignetteVolume != (Object)null)
			{
				vignetteVolume.isGlobal = false;
			}
			Debug.Log((object)"[Drunk] Reset complete on destroy.");
		}

		private void Start()
		{
			Initialize();
			((MonoBehaviour)this).StartCoroutine(DrunkRoutine());
			Debug.Log((object)"[Drunk] Drunk Effects started.");
		}

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

		private void FindVignetteEffect()
		{
			Volume[] array = Object.FindObjectsByType<Volume>((FindObjectsSortMode)0);
			Volume[] array2 = array;
			foreach (Volume val in array2)
			{
				if ((Object)(object)val.profile == (Object)null)
				{
					continue;
				}
				foreach (VolumeComponent component in val.profile.components)
				{
					if ((Object)(object)component == (Object)null || !((object)component).GetType().Name.ToLower().Contains("vignette"))
					{
						continue;
					}
					vignetteVolume = val;
					vignetteEffect = component;
					vignetteVolume.isGlobal = true;
					FieldInfo[] fields = ((object)vignetteEffect).GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					FieldInfo[] array3 = fields;
					foreach (FieldInfo fieldInfo in array3)
					{
						if (!typeof(VolumeParameter).IsAssignableFrom(fieldInfo.FieldType))
						{
							continue;
						}
						object value = fieldInfo.GetValue(vignetteEffect);
						if (value != null)
						{
							PropertyInfo property = value.GetType().GetProperty("value", BindingFlags.Instance | BindingFlags.Public);
							PropertyInfo property2 = value.GetType().GetProperty("overrideState", BindingFlags.Instance | BindingFlags.Public);
							if (property != null && property2 != null)
							{
								vignetteParams.Add(new VignetteParam
								{
									param = value,
									valueProp = property,
									overrideProp = property2,
									fieldName = fieldInfo.Name.ToLower()
								});
							}
						}
					}
					Debug.Log((object)"[Drunk] Found and cached vignette effect.");
					return;
				}
			}
			Debug.LogWarning((object)"[Drunk] No vignette effect found.");
		}

		private void UpdateVignette(float level)
		{
			if ((Object)(object)vignetteEffect == (Object)null || vignetteParams.Count == 0)
			{
				return;
			}
			level = Mathf.Clamp01(level);
			foreach (VignetteParam vignetteParam in vignetteParams)
			{
				vignetteParam.overrideProp.SetValue(vignetteParam.param, true);
				if (vignetteParam.valueProp.PropertyType == typeof(float) && vignetteParam.fieldName.Contains("intensity"))
				{
					float num = Mathf.Lerp(0.2f, 1f, level);
					vignetteParam.valueProp.SetValue(vignetteParam.param, num);
				}
				else if (vignetteParam.valueProp.PropertyType == typeof(bool))
				{
					vignetteParam.valueProp.SetValue(vignetteParam.param, true);
				}
			}
		}
	}
	public class Medic : MonoBehaviour
	{
		private float HealCooldownTime;

		private float HealRadius;

		private float HealAmount;

		private float HoldDuration;

		private KeyCode HealKey;

		public Sprite SkillIcon;

		private CharacterAfflictions afflictions;

		private Character character;

		private float healCooldown = 0f;

		private Image iconImage;

		private Text cooldownText;

		private Text keybindText;

		private GameObject hudObject;

		private Canvas healCanvas;

		private Text chargingText;

		private Text timerText;

		private bool isHealingHold = false;

		private float holdTimer = 0f;

		private Slider progressBarSlider;

		private string lang;

		private void Initialize()
		{
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Expected O, but got I4
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186->IL0186: Incompatible stack types: O vs I4
			//IL_017c->IL0186: Incompatible stack types: I4 vs O
			//IL_017c->IL0186: Incompatible stack types: O vs I4
			lang = Localization.GetSystemLang();
			character = GameHelpers.GetCharacterComponent();
			if ((Object)(object)character == (Object)null)
			{
				Debug.LogError((object)"[Medic] Character component not found — disabling.");
				((Behaviour)this).enabled = false;
				return;
			}
			afflictions = character.refs.afflictions;
			if ((Object)(object)afflictions == (Object)null)
			{
				Debug.LogError((object)"[Medic] CharacterAfflictions not found — disabling.");
				((Behaviour)this).enabled = false;
				return;
			}
			HealCooldownTime = ((PConfig.medic_HealCooldownTime.Value >= 0f && PConfig.medic_HealCooldownTime.Value <= 3600f) ? PConfig.medic_HealCooldownTime.Value : 900f);
			HealRadius = ((PConfig.medic_HealRadius.Value >= 0.1f && PConfig.medic_HealRadius.Value <= 20f) ? PConfig.medic_HealRadius.Value : 5f);
			float num = ((PConfig.medic_HealAmountPercent.Value >= 1f && PConfig.medic_HealAmountPercent.Value <= 100f) ? PConfig.medic_HealAmountPercent.Value : 30f);
			HealAmount = num / 100f;
			HoldDuration = ((PConfig.medic_HoldDuration.Value >= 0.1f && PConfig.medic_HoldDuration.Value <= 30f) ? PConfig.medic_HoldDuration.Value : 5f);
			object obj = this;
			int num2;
			if ((int)PConfig.medic_HealKey.Value != 0)
			{
				obj = PConfig.medic_HealKey.Value;
				num2 = (int)obj;
			}
			else
			{
				num2 = 104;
				obj = num2;
				num2 = (int)obj;
			}
			((Medic)num2).HealKey = (KeyCode)obj;
			string @base = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAHjAAAB4wGoU74kAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAC6pJREFUeJztmntw3NV1xz/nt6vH2hZ+P7CllSxsR/i1EsKQENcrMAOlYZoG4k5p3TYNZIDQNARS0uYxDR2aP9I83ExCCOmAM01Np+aRdgrk5ViSlXg81Ja0tgx+yFqtZNnWWrZlIa129/e7p39I3pWsXWl39QCm/v61v3PPOb9zzt577vmde+EaruEa/j9DZuIlJVU1N8dx2s827gtnKuP1+b+HcNsoouKI6NPtTfVvTJVt7qlSlA6rVt1TEDMD+/KwdgEPZiH6mFqWJQX5CqDGIIMxUZVtwAcnAL0FkTwPFAoUZS28toz4kw8IgPT24/78jim3z5pyjR8wTPsMCLfU9nt9W/YAe9IybdvmKjsR3mAccSWJJh33Iu+G26uvPFgu7Qk21QZztW/aAwBoqLn+zvEYSo51f8kI/4SlowfcSfPU7QIRUL0Xy9x7hW4ULa/eXHbqYEMoF+NmIgCsrLqjNGr1hrsOHhxINS7oYhCc3/8wFHkSdPWtTjLNLsR+5I+Q85eSci1tWEeDYsfyFgPvzwBUV1fnhW3niNvM/inw6Hi86q9Cr1+QfvzWtYycI1Y0BkeDk7Jv2pNgaLCoAJgDs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rCj0cDY6yHOhILu6QmqGunrP6qz4U53790em264Z7ewClFT6N4nyA2ATQKHl0kGTuP/baNR6NJeLDrlixgMwDKvU5/+4UT5poSuwpEvhtdDqJa9O9tLTNVzDNVxDNvg/yFyg19sacjIAAAAASUVORK5CYII=";
			SkillIcon = ImageUtils.Base64ToSprite(@base);
			CreateHUD();
			SetupHealingProgressUI();
			GiveStartingItems();
			healCooldown = 0f;
			Debug.Log((object)"[Medic] Medic initialized with starting items.");
		}

		private void Start()
		{
			Initialize();
			Debug.Log((object)"[Medic] Medic effects started.");
		}

		private void Update()
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			if (!character.refs.view.IsMine)
			{
				return;
			}
			if (healCooldown > 0f)
			{
				healCooldown -= Time.deltaTime;
				if (healCooldown < 0f)
				{
					healCooldown = 0f;
				}
			}
			UpdateHUD();
			if (healCooldown <= 0f)
			{
				if (Input.GetKey(HealKey))
				{
					if (!isHealingHold)
					{
						isHealingHold = true;
						holdTimer = 0f;
						RoleRPC component = ((Component)character).GetComponent<RoleRPC>();
						if ((Object)(object)component != (Object)null)
						{
							Vector3 val = ((Component)character.refs.hip).transform.position + Vector3.up * 1.5f;
							((MonoBehaviourPun)component).photonView.RPC("ShowHealingCircleRPC", (RpcTarget)0, new object[2] { val, HealRadius });
						}
						ShowHealingProgressUI(show: true);
					}
					holdTimer += Time.deltaTime;
					progressBarSlider.value = HoldDuration - holdTimer;
					float num = Mathf.Max(HoldDuration - holdTimer, 0f);
					timerText.text = num.ToString("F1") + "s";
					if (holdTimer >= HoldDuration)
					{
						isHealingHold = false;
						holdTimer = 0f;
						if ((Object)(object)progressBarSlider != (Object)null)
						{
							progressBarSlider.value = HoldDuration;
						}
						RoleRPC component2 = ((Component)character).GetComponent<RoleRPC>();
						if ((Object)(object)component2 != (Object)null)
						{
							Vector3 healCenter = ((Component)character.refs.hip).transform.position + Vector3.up * 1.5f;
							component2.CallHealRPC(healCenter, HealRadius, HealAmount);
							((MonoBehaviourPun)component2).photonView.RPC("HideHealingCircleRPC", (RpcTarget)0, Array.Empty<object>());
						}
						healCooldown = HealCooldownTime;
						ShowHealingProgressUI(show: false);
					}
				}
				else if (isHealingHold)
				{
					isHealingHold = false;
					holdTimer = 0f;
					if ((Object)(object)progressBarSlider != (Object)null)
					{
						progressBarSlider.value = HoldDuration;
					}
					RoleRPC component3 = ((Component)character).GetComponent<RoleRPC>();
					if (component3 != null)
					{
						((MonoBehaviourPun)component3).photonView.RPC("HideHealingCircleRPC", (RpcTarget)0, Array.Empty<object>());
					}
					ShowHealingProgressUI(show: false);
				}
			}
			else
			{
				ShowHealingProgressUI(show: false);
			}
		}

		private void GiveStartingItems()
		{
			Debug.Log((object)"[Medic] Attempting to give starting medical items...");
			Item[] source = Resources.FindObjectsOfTypeAll<Item>();
			Item val = ((IEnumerable<Item>)source).FirstOrDefault((Func<Item, bool>)((Item item) => ((Object)item).name == "FirstAidKit"));
			if ((Object)(object)val != (Object)null)
			{
				Debug.Log((object)$"[Medic] Found FirstAidKit with ID: {val.itemID}");
			}
			else
			{
				Debug.LogError((object)"[Medic] Could not find FirstAidKit prefab!");
			}
			Item val2 = ((IEnumerable<Item>)source).FirstOrDefault((Func<Item, bool>)((Item item) => ((Object)item).name == "Cure-All"));
			if ((Object)(object)val2 != (Object)null)
			{
				Debug.Log((object)$"[Medic] Found Cure-All with ID: {val2.itemID}");
			}
			else
			{
				Debug.LogError((object)"[Medic] Could not find Cure-All prefab!");
			}
			if ((Object)(object)character.player == (Object)null)
			{
				Debug.LogError((object)("[Medic] Character " + character.characterName + " has no player component!"));
				return;
			}
			if ((Object)(object)val != (Object)null)
			{
				TryGiveItemToPlayer(val);
			}
			if ((Object)(object)val2 != (Object)null)
			{
				TryGiveItemToPlayer(val2);
			}
			CharacterAfflictions val3 = character.refs.afflictions;
			MethodInfo method = ((object)val3).GetType().GetMethod("UpdateWeight", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (method != null)
			{
				method.Invoke(val3, null);
				Debug.Log((object)"[Medic] Called UpdateWeight successfully");
			}
			else
			{
				Debug.LogWarning((object)"[Medic] Could not find UpdateWeight method");
			}
		}

		private void TryGiveItemToPlayer(Item item)
		{
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			if (character.player.HasEmptySlot(item.itemID))
			{
				ItemSlot val = default(ItemSlot);
				if (!PhotonNetwork.IsMasterClient)
				{
					RoleRPC component = ((Component)character).GetComponent<RoleRPC>();
					if (component != null)
					{
						((MonoBehaviourPun)component).photonView.RPC("RequestGiveItemRPC", (RpcTarget)2, new object[2]
						{
							character.refs.view.ViewID,
							((Object)item).name
						});
					}
				}
				else if (character.player.AddItem(item.itemID, (ItemInstanceData)null, ref val))
				{
					Debug.Log((object)$"[Medic] Successfully gave {((Object)item).name} to {character.characterName} in slot {val.itemSlotID}");
				}
				else
				{
					Debug.LogError((object)("[Medic] Failed to add " + ((Object)item).name + " to " + character.characterName));
				}
			}
			else
			{
				Debug.LogWarning((object)("[Medic] No empty slots available for " + ((Object)item).name + " — dropping on ground."));
				Vector3 val2 = ((Component)character.refs.hip).transform.position + Vector3.up * 1.5f;
				if (character.refs.view.IsMine)
				{
					character.refs.view.RPC("MedicDropItemRPC", (RpcTarget)0, new object[3]
					{
						((Object)item).name,
						item.data,
						val2
					});
				}
			}
		}

		[PunRPC]
		private void MedicDropItemRPC(string prefabName, ItemInstanceData data, Vector3 spawnPosition)
		{
			//IL_0007: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)$"[Medic] Attempting to instantiate prefab '{prefabName}' at {spawnPosition}");
			string text = "0_Items/" + prefabName;
			GameObject val = PhotonNetwork.Instantiate(text, spawnPosition, Quaternion.identity, (byte)0, (object[])null);
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogError((object)("[Medic] Failed to instantiate prefab '" + text + "'"));
				return;
			}
			PhotonView component = val.GetComponent<PhotonView>();
			if ((Object)(object)component == (Object)null)
			{
				Debug.LogError((object)"[Medic] Instantiated object missing PhotonView component");
				return;
			}
			Debug.Log((object)("[Medic] Successfully instantiated '" + ((Object)((Component)component).gameObject).name + "'"));
			component.RPC("SetItemInstanceDataRPC", (RpcTarget)0, new object[1] { data });
			component.RPC("SetKinematicRPC", (RpcTarget)0, new object[3]
			{
				false,
				((Component)component).transform.position,
				((Component)component).transform.rotation
			});
		}

		private void CreateHUD()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Expected O, but got Unknown
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Expected O, but got Unknown
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("GAME/GUIManager/Canvas_HUD");
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogError((object)"[MedicHUD] Canvas_HUD not found.");
				return;
			}
			hudObject = new GameObject("MedicSkillIcon");
			hudObject.transform.SetParent(val.transform, false);
			RectTransform val2 = hudObject.AddComponent<RectTransform>();
			val2.anchorMin = new Vector2(0.9f, 0.15f);
			val2.anchorMax = val2.anchorMin;
			val2.sizeDelta = new Vector2(64f, 64f);
			iconImage = hudObject.AddComponent<Image>();
			iconImage.sprite = SkillIcon;
			iconImage.type = (Type)3;
			iconImage.fillMethod = (FillMethod)4;
			iconImage.fillOrigin = 2;
			iconImage.fillClockwise = false;
			((Graphic)iconImage).color = Color.gray;
			iconImage.fillAmount = 1f;
			GameObject val3 = new GameObject("CooldownText");
			val3.transform.SetParent(hudObject.transform, false);
			cooldownText = val3.AddComponent<Text>();
			cooldownText.alignment = (TextAnchor)4;
			cooldownText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			cooldownText.fontSize = 20;
			((Graphic)cooldownText).color = Color.white;
			((Graphic)cooldownText).rectTransform.sizeDelta = new Vector2(64f, 64f);
			GameObject val4 = new GameObject("KeybindText");
			val4.transform.SetParent(hudObject.transform, false);
			keybindText = val4.AddComponent<Text>();
			keybindText.alignment = (TextAnchor)1;
			keybindText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			keybindText.fontSize = 14;
			((Graphic)keybindText).color = Color.yellow;
			keybindText.text = $"[{HealKey}]";
			((Graphic)keybindText).rectTransform.anchoredPosition = new Vector2(0f, -40f);
			((Component)keybindText).gameObject.SetActive(false);
		}

		private void UpdateHUD()
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			if (healCooldown > 0f)
			{
				cooldownText.text = Mathf.CeilToInt(healCooldown).ToString();
				((Component)keybindText).gameObject.SetActive(false);
				((Graphic)iconImage).color = new Color(0.5f, 0.5f, 0.5f, 1f);
			}
			else
			{
				cooldownText.text = "";
				((Component)keybindText).gameObject.SetActive(true);
				((Graphic)iconImage).color = Color.Lerp(Color.white, Color.green, Mathf.PingPong(Time.time * 2f, 1f));
			}
		}

		private void SetupHealingProgressUI()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Expected O, but got Unknown
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Expected O, but got Unknown
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Expected O, but got Unknown
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Expected O, but got Unknown
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0461: Unknown result type (might be due to invalid IL or missing references)
			//IL_0478: Unknown result type (might be due to invalid IL or missing references)
			//IL_048f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("MedicHealCanvas");
			healCanvas = val.AddComponent<Canvas>();
			healCanvas.renderMode = (RenderMode)0;
			val.AddComponent<CanvasScaler>();
			val.AddComponent<GraphicRaycaster>();
			GameObject val2 = new GameObject("ProgressBarSlider");
			val2.transform.SetParent(val.transform);
			Slider val3 = val2.AddComponent<Slider>();
			RectTransform component = val2.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(300f, 25f);
			component.anchorMin = new Vector2(0.5f, 0f);
			component.anchorMax = new Vector2(0.5f, 0f);
			component.pivot = new Vector2(0.5f, 0f);
			component.anchoredPosition = new Vector2(0f, 100f);
			val3.minValue = 0f;
			val3.maxValue = HoldDuration;
			val3.value = 0f;
			GameObject val4 = new GameObject("Background");
			val4.transform.SetParent(val2.transform);
			Image val5 = val4.AddComponent<Image>();
			((Graphic)val5).color = Color.black;
			RectTransform component2 = val4.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0f, 0f);
			component2.anchorMax = new Vector2(1f, 1f);
			component2.offsetMin = Vector2.zero;
			component2.offsetMax = Vector2.zero;
			((Selectable)val3).targetGraphic = (Graphic)(object)val5;
			GameObject val6 = new GameObject("Fill Area");
			val6.transform.SetParent(val2.transform);
			RectTransform val7 = val6.AddComponent<RectTransform>();
			val7.anchorMin = new Vector2(0f, 0f);
			val7.anchorMax = new Vector2(1f, 1f);
			val7.offsetMin = new Vector2(5f, 5f);
			val7.offsetMax = new Vector2(-5f, -5f);
			GameObject val8 = new GameObject("Fill");
			val8.transform.SetParent(val6.transform);
			Image val9 = val8.AddComponent<Image>();
			((Graphic)val9).color = Color.green;
			RectTransform component3 = val8.GetComponent<RectTransform>();
			component3.anchorMin = new Vector2(0f, 0f);
			component3.anchorMax = new Vector2(1f, 1f);
			component3.offsetMin = Vector2.zero;
			component3.offsetMax = Vector2.zero;
			val3.fillRect = component3;
			((Selectable)val3).interactable = false;
			progressBarSlider = val3;
			((Component)progressBarSlider).gameObject.SetActive(false);
			GameObject val10 = new GameObject("ChargingText");
			val10.transform.SetParent(val.transform);
			chargingText = val10.AddComponent<Text>();
			chargingText.alignment = (TextAnchor)4;
			chargingText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			chargingText.fontSize = 18;
			((Graphic)chargingText).color = Color.white;
			chargingText.text = Localization.Get(lang, "HealingText");
			RectTransform component4 = val10.GetComponent<RectTransform>();
			component4.anchorMin = new Vector2(0.5f, 0f);
			component4.anchorMax = new Vector2(0.5f, 0f);
			component4.anchoredPosition = new Vector2(0f, 140f);
			component4.sizeDelta = new Vector2(200f, 30f);
			((Component)chargingText).gameObject.SetActive(false);
			GameObject val11 = new GameObject("TimerText");
			val11.transform.SetParent(val.transform);
			timerText = val11.AddComponent<Text>();
			timerText.alignment = (TextAnchor)4;
			timerText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			timerText.fontSize = 18;
			((Graphic)timerText).color = Color.yellow;
			timerText.text = "";
			RectTransform component5 = val11.GetComponent<RectTransform>();
			component5.anchorMin = new Vector2(0.5f, 0f);
			component5.anchorMax = new Vector2(0.5f, 0f);
			component5.anchoredPosition = new Vector2(0f, 80f);
			component5.sizeDelta = new Vector2(200f, 30f);
			((Component)timerText).gameObject.SetActive(false);
		}

		private void ShowHealingProgressUI(bool show)
		{
			Canvas obj = healCanvas;
			if (obj != null)
			{
				((Component)obj).gameObject.SetActive(show);
			}
			Text obj2 = chargingText;
			if (obj2 != null)
			{
				((Component)obj2).gameObject.SetActive(show);
			}
			Text obj3 = timerText;
			if (obj3 != null)
			{
				((Component)obj3).gameObject.SetActive(show);
			}
			Slider obj4 = progressBarSlider;
			if (obj4 != null)
			{
				((Component)obj4).gameObject.SetActive(show);
			}
			if (show && (Object)(object)progressBarSlider != (Object)null)
			{
				progressBarSlider.value = HoldDuration;
			}
			if (!show && (Object)(object)timerText != (Object)null)
			{
				timerText.text = "";
			}
		}
	}
	public class Mute : MonoBehaviour
	{
		private Recorder recorder;

		private void Start()
		{
			PhotonVoiceView component = ((Component)Character.localCharacter).GetComponent<PhotonVoiceView>();
			recorder = ((component != null) ? component.RecorderInUse : null);
			if ((Object)(object)recorder != (Object)null)
			{
				recorder.TransmitEnabled = false;
			}
			Debug.Log((object)"[Mute] Mute effect started.");
		}

		private void OnDestroy()
		{
			if ((Object)(object)recorder != (Object)null)
			{
				recorder.TransmitEnabled = true;
			}
			Debug.Log((object)"[Mute] Mute effect destroyed.");
		}
	}
	public class Narcoleptic : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <NarcolepticRoutine>d__12 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Narcoleptic <>4__this;

			private float <currentDrowsy>5__1;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0168: Unknown result type (might be due to invalid IL or missing references)
				//IL_0172: Expected O, but got Unknown
				//IL_0139: Unknown result type (might be due to invalid IL or missing references)
				//IL_0143: Expected O, but got Unknown
				//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f1: Expected O, but got Unknown
				bool flag;
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					goto IL_0184;
				case 1:
					<>1__state = -1;
					goto IL_00b6;
				case 2:
					<>1__state = -1;
					if (<>4__this.CanWakeUp())
					{
						Debug.Log((object)"[Narcoleptic] Player waking up from narcolepsy.");
						<>4__this.afflictions.SetStatus((STATUSTYPE)6, 0f);
						<>2__current = (object)new WaitForSeconds(1f);
						<>1__state = 3;
						return true;
					}
					Debug.Log((object)"[Narcoleptic] Cannot wake up yet, stamina too low.");
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 4;
					return true;
				case 3:
					<>1__state = -1;
					goto IL_0184;
				case 4:
					{
						<>1__state = -1;
						goto IL_0184;
					}
					IL_00b6:
					if (!<>4__this.characterData.passedOut)
					{
						<currentDrowsy>5__1 = <>4__this.afflictions.GetCurrentStatus((STATUSTYPE)6);
						if (<currentDrowsy>5__1 < <>4__this.maxDrowsy)
						{
							<>4__this.afflictions.AddStatus((STATUSTYPE)6, <>4__this.drowsyIncreasePerSecond * Time.deltaTime, false);
						}
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					Debug.Log((object)"[Narcoleptic] Player passed out.");
					<>2__current = (object)new WaitForSeconds(<>4__this.passOutDuration);
					<>1__state = 2;
					return true;
					IL_0184:
					flag = true;
					goto IL_00b6;
				}
			}

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

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

		private readonly float maxDrowsy = 1f;

		private CharacterAfflictions afflictions;

		private Character character;

		private CharacterData characterData;

		private float drowsyIncreasePerSecond;

		private float originalDrowsyReductionCooldown;

		private float originalDrowsyReductionPerSecond;

		private float passOutDuration;

		private void Initialize()
		{
			character = GameHelpers.GetCharacterComponent();
			if ((Object)(object)character == (Object)null)
			{
				Debug.LogError((object)"[Narcoleptic] Character component not found.");
				((Behaviour)this).enabled = false;
				return;
			}
			afflictions = character.refs.afflictions;
			if ((Object)(object)afflictions == (Object)null)
			{
				Debug.LogError((object)"[Narcoleptic] CharacterAfflictions not found.");
				((Behaviour)this).enabled = false;
				return;
			}
			characterData = character.data;
			float value = PConfig.narco_passOutDuration.Value;
			float value2 = PConfig.narco_timeToFullDrowsy.Value;
			value2 = ((value2 >= 30f && value2 <= 600f) ? value2 : 300f);
			drowsyIncreasePerSecond = maxDrowsy / value2;
			Debug.Log((object)$"[Narcoleptic] drowsyIncreasePerSecond set to {drowsyIncreasePerSecond} (time to full: {value2}s)");
			passOutDuration = ((value >= 1f && value <= 30f) ? value : 5f);
			Debug.Log((object)$"[Narcoleptic] passOutDuration set to {passOutDuration}s");
			SaveAndDisableDrowsyDecay();
		}

		private void OnDestroy()
		{
			((MonoBehaviour)this).StopCoroutine(NarcolepticRoutine());
			RestoreDrowsyDecay();
			Debug.Log((object)"[Narcoleptic] Reset complete on destroy.");
		}

		private void Start()
		{
			Initialize();
			((MonoBehaviour)this).StartCoroutine(NarcolepticRoutine());
			Debug.Log((object)"[Narcoleptic] Narcoleptic Effects started.");
		}

		private bool CanWakeUp()
		{
			float statusSum = afflictions.statusSum;
			float currentStatus = afflictions.GetCurrentStatus((STATUSTYPE)6);
			float num = 1f - (statusSum - currentStatus);
			return num >= 0.1f;
		}

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

		private void RestoreDrowsyDecay()
		{
			afflictions.drowsyReductionPerSecond = originalDrowsyReductionPerSecond;
			afflictions.drowsyReductionCooldown = originalDrowsyReductionCooldown;
		}

		private void SaveAndDisableDrowsyDecay()
		{
			originalDrowsyReductionPerSecond = afflictions.drowsyReductionPerSecond;
			originalDrowsyReductionCooldown = afflictions.drowsyReductionCooldown;
			afflictions.drowsyReductionPerSecond = 0f;
			afflictions.drowsyReductionCooldown = 999999f;
		}
	}
	public class OneEyed : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <OneEyedRoutine>d__8 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public OneEyed <>4__this;

			private float <currentInjury>5__1;

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

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

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

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

			private bool MoveNext()
			{
				//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ae: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				<currentInjury>5__1 = <>4__this.afflictions.GetCurrentStatus((STATUSTYPE)0);
				if (<currentInjury>5__1 < <>4__this.targetInjury)
				{
					<>4__this.afflictions.AddStatus((STATUSTYPE)0, <>4__this.targetInjury - <currentInjury>5__1, false);
					Debug.Log((object)$"[OneEyed] Injury level restored to {<>4__this.targetInjury}");
				}
				<>2__current = (object)new WaitForSeconds(1f);
				<>1__state = 1;
				return true;
			}

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

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

		private CharacterAfflictions afflictions;

		private Character character;

		private float targetInjury;

		private GameObject blackHalfScreen;

		private void Initialize()
		{
			character = GameHelpers.GetCharacterComponent();
			if ((Object)(object)character == (Object)null)
			{
				Debug.LogError((object)"[OneEyed] Character component not found — disabling.");
				((Behaviour)this).enabled = false;
				return;
			}
			afflictions = character.refs.afflictions;
			if ((Object)(object)afflictions == (Object)null)
			{
				Debug.LogError((object)"[OneEyed] CharacterAfflictions not found — disabling.");
				((Behaviour)this).enabled = false;
				return;
			}
			float num = PConfig.oneEyed_targetInjuryPercent.Value;
			if (num < 10f || num > 90f)
			{
				Debug.LogWarning((object)$"[OneEyed] Invalid injury percentage {num} — using default 50%");
				num = 50f;
			}
			targetInjury = num / 100f;
			Debug.Log((object)$"[OneEyed] targetInjury set to {targetInjury} ({num}%)");
			CreateHalfBlackScreen();
		}

		private void OnDestroy()
		{
			((MonoBehaviour)this).StopCoroutine(OneEyedRoutine());
			if ((Object)(object)blackHalfScreen != (Object)null)
			{
				Object.Destroy((Object)(object)blackHalfScreen);
			}
			Debug.Log((object)"[OneEyed] Reset complete on destroy.");
		}

		private void Start()
		{
			Initialize();
			((MonoBehaviour)this).StartCoroutine(OneEyedRoutine());
			Debug.Log((object)"[OneEyed] OneEyed Effects started.");
		}

		private void CreateHalfBlackScreen()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("GAME/GUIManager/Canvas_HUD");
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogError((object)"[OneEyed] Canvas_HUD not found — cannot create black screen overlay.");
				return;
			}
			blackHalfScreen = new GameObject("blackHalfScreen");
			blackHalfScreen.transform.SetParent(val.transform, false);
			Image val2 = blackHalfScreen.AddComponent<Image>();
			((Graphic)val2).color = Color.black;
			RectTransform component = blackHalfScreen.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0.5f, 0f);
			component.anchorMax = new Vector2(1f, 1f);
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			blackHalfScreen.transform.SetAsFirstSibling();
			Debug.Log((object)"[OneEyed] Half-screen black overlay created.");
		}

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