Decompiled source of PEAKChallenges v1.0.0

plugins/PEAKChallenges.dll

Decompiled 5 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
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 UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
[assembly: AssemblyCompany("PEAKChallenges")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PEAKChallenges")]
[assembly: AssemblyTitle("PEAKChallenges")]
[assembly: SecurityPermission(8, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace PEAKChallenges;

[Flags]
public enum ChallengeModifierFlags
{
	None = 0,
	FogEnabled = 1,
	LavaSpeedMultiplied = 2,
	HungerRateMultiplied = 4,
	FallDamageMultiplied = 8,
	CampfireFoodReduced = 0x10,
	RescueGrappleLimited = 0x20,
	ColdEffectIntensityMultiplied = 0x40,
	HeatEffectIntensityMultiplied = 0x80,
	EffectDurationMultiplied = 0x100,
	EffectClearTimeMultiplied = 0x200,
	DayHeatEnabled = 0x400,
	WeatherDurationMultiplied = 0x800,
	FoodSpawnRateMultiplied = 0x1000,
	CoolantSpawnRateMultiplied = 0x2000,
	WarmItemSpawnRateMultiplied = 0x4000,
	StaminaCursePercent = 0x8000,
	StaminaConsumptionMultiplied = 0x10000,
	MysticalStatuesCount = 0x20000,
	MysticalChestSpawnMultiplied = 0x40000,
	AutoStaminaRegen = 0x80000,
	MysticalStatuesDisabled = 0x100000,
	MysticalChestsDisabled = 0x200000,
	StatueOfRevivalInCommonChests = 0x400000,
	HandHoldingDisabled = 0x800000
}
public class ModifierEntry
{
	[field: CompilerGenerated]
	public ChallengeModifierFlags Type
	{
		[CompilerGenerated]
		get;
		[CompilerGenerated]
		set;
	}

	[field: CompilerGenerated]
	public float Multiplier
	{
		[CompilerGenerated]
		get;
		[CompilerGenerated]
		set;
	}

	[field: CompilerGenerated]
	public int IntValue
	{
		[CompilerGenerated]
		get;
		[CompilerGenerated]
		set;
	}

	[field: CompilerGenerated]
	public string Description
	{
		[CompilerGenerated]
		get;
		[CompilerGenerated]
		set;
	}

	[field: CompilerGenerated]
	public bool IsNegative
	{
		[CompilerGenerated]
		get;
		[CompilerGenerated]
		set;
	}

	[field: CompilerGenerated]
	public bool IsPositive
	{
		[CompilerGenerated]
		get;
		[CompilerGenerated]
		set;
	}

	public ModifierEntry(ChallengeModifierFlags type, float multiplier = 1f, int intValue = 0, string description = "", bool isNegative = false, bool isPositive = false)
	{
		Type = type;
		Multiplier = multiplier;
		IntValue = intValue;
		Description = description;
		IsNegative = isNegative;
		IsPositive = isPositive;
	}
}
public class ChallengeDefinition
{
	[field: CompilerGenerated]
	public int Id
	{
		[CompilerGenerated]
		get;
	}

	[field: CompilerGenerated]
	public string Name
	{
		[CompilerGenerated]
		get;
	}

	[field: CompilerGenerated]
	public string ShortDescription
	{
		[CompilerGenerated]
		get;
	}

	[field: CompilerGenerated]
	public string FullDescription
	{
		[CompilerGenerated]
		get;
	}

	[field: CompilerGenerated]
	public string DifficultyColor
	{
		[CompilerGenerated]
		get;
	}

	[field: CompilerGenerated]
	public List<ModifierEntry> Modifiers
	{
		[CompilerGenerated]
		get;
	}

	[field: CompilerGenerated]
	public bool IsFinalChallenge
	{
		[CompilerGenerated]
		get;
	}

	public ChallengeDefinition(int id, string name, string shortDesc, string fullDesc, string difficultyColor, List<ModifierEntry> modifiers, bool isFinal = false)
	{
		Id = id;
		Name = name;
		ShortDescription = shortDesc;
		FullDescription = fullDesc;
		DifficultyColor = difficultyColor;
		Modifiers = modifiers;
		IsFinalChallenge = isFinal;
	}
}
public static class ChallengeConfig
{
	public static Dictionary<ChallengeModifierFlags, ModifierEntry> ActiveModifiers = new Dictionary<ChallengeModifierFlags, ModifierEntry>();

	private static List<ChallengeDefinition> _challenges = null;

	private static ConfigEntry<bool> _enabledConfig = null;

	internal static ManualLogSource Log => Plugin.Log;

	[field: CompilerGenerated]
	public static int ActiveChallengeId
	{
		[CompilerGenerated]
		get;
		[CompilerGenerated]
		private set;
	} = 0;


	public static bool IsActive => ActiveChallengeId > 0;

	public static global::System.Collections.Generic.IReadOnlyList<ChallengeDefinition> Challenges => (global::System.Collections.Generic.IReadOnlyList<ChallengeDefinition>)_challenges;

	public static bool IsModEnabled => _enabledConfig?.Value ?? true;

	public static void Initialize(Plugin plugin)
	{
		List<ChallengeDefinition> obj = new List<ChallengeDefinition>();
		obj.Add(CreateChallenge1());
		obj.Add(CreateChallenge2());
		obj.Add(CreateChallenge3());
		obj.Add(CreateChallenge4());
		obj.Add(CreateChallenge5());
		obj.Add(CreateChallenge6());
		obj.Add(CreateChallenge7());
		_challenges = obj;
		RegisterConfigEntries(plugin);
		Log.LogInfo($"[ChallengeConfig] Инициализировано {_challenges.Count} челленджей");
	}

	private static void RegisterConfigEntries(Plugin plugin)
	{
		string text = "Челленджи";
		_enabledConfig = ((BaseUnityPlugin)plugin).Config.Bind<bool>(text, "Включены", true, "Главный вкл/выкл челленджей");
		for (int i = 0; i < _challenges.Count; i++)
		{
			((BaseUnityPlugin)plugin).Config.Bind<bool>(text, $"Челлендж{i + 1}_Включён", true, "Вкл/выкл " + _challenges[i].Name);
		}
	}

	public static ChallengeDefinition? GetChallenge(int id)
	{
		if (id < 1 || id > _challenges.Count)
		{
			return null;
		}
		return _challenges[id - 1];
	}

	public static void ActivateChallenge(int challengeId)
	{
		//IL_0257: Unknown result type (might be due to invalid IL or missing references)
		//IL_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: Unknown result type (might be due to invalid IL or missing references)
		//IL_0267: Unknown result type (might be due to invalid IL or missing references)
		ActiveChallengeId = challengeId;
		ActiveModifiers.Clear();
		Log.LogInfo($"[ChallengeConfig] Активация челленджа #{challengeId}");
		for (int i = 1; i <= challengeId; i++)
		{
			ChallengeDefinition challenge = GetChallenge(i);
			if (challenge == null)
			{
				continue;
			}
			Log.LogInfo($"[ChallengeConfig]  → Применяются модификаторы Челленджа {i}: {challenge.Name}");
			Enumerator<ModifierEntry> enumerator = challenge.Modifiers.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					ModifierEntry current = enumerator.Current;
					if (challenge.IsFinalChallenge && (current.Type == ChallengeModifierFlags.MysticalStatuesDisabled || current.Type == ChallengeModifierFlags.MysticalChestsDisabled || current.Type == ChallengeModifierFlags.MysticalStatuesCount || current.Type == ChallengeModifierFlags.MysticalChestSpawnMultiplied))
					{
						ActiveModifiers[current.Type] = current;
					}
					else if (i == 6 && current.Type == ChallengeModifierFlags.MysticalStatuesCount)
					{
						ActiveModifiers[current.Type] = current;
					}
					else if (i == 5 && (current.Type == ChallengeModifierFlags.FoodSpawnRateMultiplied || current.Type == ChallengeModifierFlags.CoolantSpawnRateMultiplied || current.Type == ChallengeModifierFlags.WarmItemSpawnRateMultiplied))
					{
						ActiveModifiers[current.Type] = current;
					}
					else if (ActiveModifiers.ContainsKey(current.Type))
					{
						ActiveModifiers[current.Type].Multiplier *= current.Multiplier;
					}
					else
					{
						ActiveModifiers[current.Type] = new ModifierEntry(current.Type, current.Multiplier, current.IntValue, current.Description, current.IsNegative, current.IsPositive);
					}
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator).Dispose();
			}
		}
		Log.LogInfo($"[ChallengeConfig] Активных модификаторов: {ActiveModifiers.Count}");
		Enumerator<ChallengeModifierFlags, ModifierEntry> enumerator2 = ActiveModifiers.GetEnumerator();
		try
		{
			while (enumerator2.MoveNext())
			{
				KeyValuePair<ChallengeModifierFlags, ModifierEntry> current2 = enumerator2.Current;
				Log.LogInfo($"[ChallengeConfig]  → {current2.Key}: множитель={current2.Value.Multiplier}, значение={current2.Value.IntValue}");
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator2).Dispose();
		}
	}

	public static ModifierEntry? GetModifier(ChallengeModifierFlags type)
	{
		ModifierEntry result = default(ModifierEntry);
		if (!ActiveModifiers.TryGetValue(type, ref result))
		{
			return null;
		}
		return result;
	}

	public static float GetMultiplier(ChallengeModifierFlags type)
	{
		return GetModifier(type)?.Multiplier ?? 1f;
	}

	public static void DeactivateChallenge()
	{
		Log.LogInfo($"[ChallengeConfig] Деактивация челленджа #{ActiveChallengeId}");
		ActiveChallengeId = 0;
		ActiveModifiers.Clear();
	}

	private static ChallengeDefinition CreateChallenge1()
	{
		List<ModifierEntry> obj = new List<ModifierEntry>();
		obj.Add(new ModifierEntry(ChallengeModifierFlags.FogEnabled, 1f, 0, "☁\ufe0f Виден туман — видимость ограничена", isNegative: true));
		obj.Add(new ModifierEntry(ChallengeModifierFlags.LavaSpeedMultiplied, 2f, 0, "\ud83c\udf0b Лава в вулкане поднимается в 2 раза быстрее", isNegative: true));
		obj.Add(new ModifierEntry(ChallengeModifierFlags.HungerRateMultiplied, 3f, 0, "\ud83c\udf57 Голод тратится в 3 раза быстрее восхождений", isNegative: true));
		return new ChallengeDefinition(1, "Путь сквозь огонь", "Туман, быстрая лава, сильный голод", "Густой туман окутывает путь. Лава в вулкане двигается в 2 раза быстрее, а голод тратится стремительно.", "#ff6b6b", obj);
	}

	private static ChallengeDefinition CreateChallenge2()
	{
		List<ModifierEntry> obj = new List<ModifierEntry>();
		obj.Add(new ModifierEntry(ChallengeModifierFlags.FallDamageMultiplied, 4f, 0, "\ud83d\udc80 Урон от падения увеличен в 4 раза", isNegative: true));
		obj.Add(new ModifierEntry(ChallengeModifierFlags.CampfireFoodReduced, 1f, 1, "\ud83c\udfd5\ufe0f На костре 1 зефирка (минус 1 на игрока, минимум 1)", isNegative: true));
		return new ChallengeDefinition(2, "Хрупкие кости", "Падения убивают, меньше зефирок", "Здоровье от падения тратится в 4 раза сильнее. На костре (вершина горы) только 1 зефирка/хот-дог. При 3 игроках — 2 зефирки, при 4 — 3.", "#ff9f43", obj);
	}

	private static ChallengeDefinition CreateChallenge3()
	{
		List<ModifierEntry> obj = new List<ModifierEntry>();
		obj.Add(new ModifierEntry(ChallengeModifierFlags.FoodSpawnRateMultiplied, 0.3f, 0, "\ud83d\udce6 Предметы в багажах появляются в ~3 раза реже", isNegative: true));
		obj.Add(new ModifierEntry(ChallengeModifierFlags.RescueGrappleLimited, 1f, 1, "\ud83e\ude9d Спасательный захват можно использовать только 1 раз", isNegative: true));
		return new ChallengeDefinition(3, "Без припасов", "Редкие предметы, спасательный захват — один раз", "Предметы в багажах (рюкзак) появляются намного реже. Спасательный захват действует лишь 1 РАЗ за восхождение.", "#feca57", obj);
	}

	private static ChallengeDefinition CreateChallenge4()
	{
		List<ModifierEntry> obj = new List<ModifierEntry>();
		obj.Add(new ModifierEntry(ChallengeModifierFlags.ColdEffectIntensityMultiplied, 2f, 0, "\ud83e\udd76 Эффект холода в 2 раза сильнее", isNegative: true));
		obj.Add(new ModifierEntry(ChallengeModifierFlags.HeatEffectIntensityMultiplied, 2f, 0, "\ud83d\udd25 Эффект жары в 2 раза сильнее", isNegative: true));
		obj.Add(new ModifierEntry(ChallengeModifierFlags.EffectDurationMultiplied, 2f, 0, "\ud83d\udc8a Временные эффекты наносятся в 2 раза сильнее", isNegative: true));
		obj.Add(new ModifierEntry(ChallengeModifierFlags.EffectClearTimeMultiplied, 2f, 0, "⏳ Эффекты уходят в 2 раза дольше", isNegative: true));
		return new ChallengeDefinition(4, "Стихия против тебя", "Эффекты в 2 раза сильнее и уходят в 2 раза дольше", "Холод, жара и другие временные эффекты наносятся в 2 раза сильнее и уходят в 2 раза дольше.", "#ee5a24", obj);
	}

	private static ChallengeDefinition CreateChallenge5()
	{
		List<ModifierEntry> obj = new List<ModifierEntry>();
		obj.Add(new ModifierEntry(ChallengeModifierFlags.DayHeatEnabled, 1f, 0, "☀\ufe0f Днём лёгкий эффект жары (не критично)", isNegative: true));
		obj.Add(new ModifierEntry(ChallengeModifierFlags.WeatherDurationMultiplied, 2f, 0, "\ud83c\udf27\ufe0f Погодные явления длятся в 2 раза дольше", isNegative: true));
		obj.Add(new ModifierEntry(ChallengeModifierFlags.RescueGrappleLimited, 1f, 1, "\ud83e\ude9d Спасательный захват — только 1 раз", isNegative: true));
		obj.Add(new ModifierEntry(ChallengeModifierFlags.FoodSpawnRateMultiplied, 2f, 0, "\ud83c\udf4e Еда появляется в 2 раза чаще", isNegative: false, isPositive: true));
		obj.Add(new ModifierEntry(ChallengeModifierFlags.CoolantSpawnRateMultiplied, 2f, 0, "❄\ufe0f Охлаждающие предметы (меса/холодный биом) чаще", isNegative: false, isPositive: true));
		obj.Add(new ModifierEntry(ChallengeModifierFlags.WarmItemSpawnRateMultiplied, 2f, 0, "\ud83e\udde3 Согревающие предметы чаще", isNegative: false, isPositive: true));
		return new ChallengeDefinition(5, "Жаркий полдень", "Днём жара, долгая погода, но больше еды и ресурсов", "Днём появляется лёгкий эффект жары. Погодные явления (ливень, тундра и т.д.) длятся в 2 раза дольше. НО: еда появляется в 2 раза чаще, охлаждающие и согревающие предметы тоже чаще!", "#ff6348", obj);
	}

	private static ChallengeDefinition CreateChallenge6()
	{
		List<ModifierEntry> obj = new List<ModifierEntry>();
		obj.Add(new ModifierEntry(ChallengeModifierFlags.StaminaCursePercent, 1f, 5, "⚡ Проклятие стамины: отнято 5% навсегда", isNegative: true));
		obj.Add(new ModifierEntry(ChallengeModifierFlags.StaminaConsumptionMultiplied, 2f, 0, "\ud83c\udfc3 Стамина при лазании тратится в 2 раза больше", isNegative: true));
		obj.Add(new ModifierEntry(ChallengeModifierFlags.MysticalStatuesCount, 1f, 2, "\ud83d\uddff Статуя возрождения выдаёт сразу 2 мистических предмета", isNegative: false, isPositive: true));
		obj.Add(new ModifierEntry(ChallengeModifierFlags.MysticalChestSpawnMultiplied, 2f, 0, "\ud83d\udce6 Мистические сундуки появляются чаще", isNegative: false, isPositive: true));
		obj.Add(new ModifierEntry(ChallengeModifierFlags.AutoStaminaRegen, 1f, 5, "\ud83d\udc9a +5% доп. стамины каждые 2 минуты автоматически", isNegative: false, isPositive: true));
		return new ChallengeDefinition(6, "Проклятая вершина", "Меньше стамины, но больше мистических ресурсов", "Стамина проклята: отнято 5% и тратится в 2 раза больше при лазании. НО: статуя возрождения выдаёт 2 мистических предмета, мистические сундуки чаще, и каждые 2 минуты даётся 5% доп. стамины!", "#a55eea", obj);
	}

	private static ChallengeDefinition CreateChallenge7()
	{
		List<ModifierEntry> obj = new List<ModifierEntry>();
		obj.Add(new ModifierEntry(ChallengeModifierFlags.MysticalStatuesDisabled, 1f, 0, "\ud83d\udeab Мистические статуи НЕ РАБОТАЮТ", isNegative: true));
		obj.Add(new ModifierEntry(ChallengeModifierFlags.MysticalChestsDisabled, 1f, 0, "\ud83d\udeab Мистические сундуки НЕ СПАВНЯТСЯ", isNegative: true));
		obj.Add(new ModifierEntry(ChallengeModifierFlags.StaminaCursePercent, 1f, 10, "⚡ Проклятие стамины: отнято 10% навсегда", isNegative: true));
		obj.Add(new ModifierEntry(ChallengeModifierFlags.FallDamageMultiplied, 4f, 0, "\ud83d\udc80 Урон от падения в 4 раза больше", isNegative: true));
		obj.Add(new ModifierEntry(ChallengeModifierFlags.HungerRateMultiplied, 4f, 0, "\ud83c\udf57 Голод тратится в 4 раза быстрее", isNegative: true));
		obj.Add(new ModifierEntry(ChallengeModifierFlags.ColdEffectIntensityMultiplied, 4f, 0, "\ud83e\udd76 Временные эффекты в 4 раза сильнее", isNegative: true));
		obj.Add(new ModifierEntry(ChallengeModifierFlags.HeatEffectIntensityMultiplied, 4f, 0, "\ud83d\udd25 Временные эффекты в 4 раза сильнее", isNegative: true));
		obj.Add(new ModifierEntry(ChallengeModifierFlags.EffectDurationMultiplied, 4f, 0, "\ud83d\udc8a Временные эффекты в 4 раза сильнее", isNegative: true));
		obj.Add(new ModifierEntry(ChallengeModifierFlags.EffectClearTimeMultiplied, 4f, 0, "⏳ Временные эффекты остаются в 4 раза дольше", isNegative: true));
		obj.Add(new ModifierEntry(ChallengeModifierFlags.StatueOfRevivalInCommonChests, 1f, 0, "\ud83d\uddff Статуя возрождения спавнится в обычных сундуках", isNegative: false, isPositive: true));
		obj.Add(new ModifierEntry(ChallengeModifierFlags.HandHoldingDisabled, 1f, 0, "\ud83e\udd1a Нельзя давать руку друг другу!", isNegative: true));
		return new ChallengeDefinition(7, "АПОКАЛИПСИС", "ФИНАЛ: Всё запрещено, всё усилено!", "Мистические статуи НЕ РАБОТАЮТ. Мистические сундуки НЕ СПАВНЯТСЯ. -10% стамины. Урон от падения в 4 раза. Голод в 4 раза. Эффекты в 4 раза сильнее и в 4 раза дольше. НО: Статуя возрождения появляется в обычных сундуках. Руку друг другу давать НЕЛЬЗЯ.", "#ff0000", obj, isFinal: true);
	}
}
public static class ChallengeSystem
{
	private static float _autoStaminaTimer;

	private static bool _staminaCursed;

	private static float _lastDayHeatCheck;

	private static bool _dayHeatApplied;

	[field: CompilerGenerated]
	public static int RescueGrappleUsed
	{
		[CompilerGenerated]
		get;
		[CompilerGenerated]
		private set;
	}

	public static void Initialize()
	{
		Plugin.Log.LogInfo("[ChallengeSystem] Инициализирована");
	}

	public static void OnRunStart()
	{
		int activeChallengeId = ChallengeConfig.ActiveChallengeId;
		if (activeChallengeId != 0)
		{
			RescueGrappleUsed = 0;
			_autoStaminaTimer = 0f;
			_staminaCursed = false;
			ChallengeDefinition challenge = ChallengeConfig.GetChallenge(activeChallengeId);
			Plugin.Log.LogInfo($"[ChallengeSystem] Начат забег: Челлендж #{activeChallengeId} — {challenge?.Name}");
			Plugin.Log.LogInfo($"[ChallengeSystem] Активных модификаторов: {ChallengeConfig.ActiveModifiers.Count}");
			ApplyStaminaCurse();
		}
	}

	public static void ApplyStaminaCurse()
	{
		if (_staminaCursed)
		{
			return;
		}
		int staminaCursePercent = GetStaminaCursePercent();
		if (staminaCursePercent <= 0)
		{
			return;
		}
		Character localCharacter = Character.localCharacter;
		if (localCharacter == null)
		{
			return;
		}
		CharacterData data = localCharacter.data;
		if (data == null)
		{
			return;
		}
		FieldInfo field = typeof(CharacterData).GetField("_maxStamina", (BindingFlags)52);
		if (field != (FieldInfo)null)
		{
			float num = (float)field.GetValue((object)data);
			float num2 = num * ((float)staminaCursePercent / 100f);
			float num3 = num - num2;
			field.SetValue((object)data, (object)num3);
			FieldInfo field2 = typeof(CharacterData).GetField("_stam", (BindingFlags)52);
			if (field2 != (FieldInfo)null)
			{
				float num4 = (float)field2.GetValue((object)data);
				float num5 = num4 * ((float)staminaCursePercent / 100f);
				field2.SetValue((object)data, (object)(num4 - num5));
			}
			Plugin.Log.LogInfo($"[ChallengeSystem] Проклятие стамины: -{staminaCursePercent}%, max: {num} → {num3}");
			_staminaCursed = true;
		}
	}

	public static void Update()
	{
		if (!ChallengeConfig.IsActive)
		{
			return;
		}
		ModifierEntry modifier = ChallengeConfig.GetModifier(ChallengeModifierFlags.AutoStaminaRegen);
		if (modifier != null)
		{
			_autoStaminaTimer += Time.deltaTime;
			if (_autoStaminaTimer >= 120f)
			{
				_autoStaminaTimer -= 120f;
				Character localCharacter = Character.localCharacter;
				if (localCharacter?.data != null)
				{
					FieldInfo field = typeof(CharacterData).GetField("_maxStamina", (BindingFlags)52);
					if (field != (FieldInfo)null)
					{
						float num = (float)field.GetValue((object)localCharacter.data);
						float num2 = num * ((float)modifier.IntValue / 100f);
						FieldInfo field2 = typeof(CharacterData).GetField("_stam", (BindingFlags)52);
						if (field2 != (FieldInfo)null)
						{
							float num3 = (float)field2.GetValue((object)localCharacter.data);
							field2.SetValue((object)localCharacter.data, (object)Mathf.Min(num3 + num2, num));
							Plugin.Log.LogDebug($"[ChallengeSystem] Авто-реген: +{num2:F1} стамины");
						}
					}
				}
			}
		}
		if (IsDayHeatEnabled())
		{
			ApplyDayHeat();
		}
	}

	private static void ApplyDayHeat()
	{
		Character localCharacter = Character.localCharacter;
		if (localCharacter == null)
		{
			return;
		}
		CharacterAfflictions afflictions = localCharacter.afflictions;
		if (afflictions == null || Time.time - _lastDayHeatCheck < 5f)
		{
			return;
		}
		_lastDayHeatCheck = Time.time;
		if (_dayHeatApplied)
		{
			return;
		}
		MethodInfo method = typeof(CharacterAfflictions).GetMethod("SetStatus", (BindingFlags)52);
		if (method != (MethodInfo)null)
		{
			object obj = global::System.Enum.Parse(typeof(STATUSTYPE), "Heat", true);
			if (obj != null)
			{
				((MethodBase)method).Invoke((object)afflictions, new object[2] { obj, 0.1f });
				_dayHeatApplied = true;
				Plugin.Log.LogDebug("[ChallengeSystem] Применён лёгкий эффект дневной жары");
			}
		}
	}

	public static bool CanUseRescueGrapple()
	{
		ModifierEntry modifier = ChallengeConfig.GetModifier(ChallengeModifierFlags.RescueGrappleLimited);
		if (modifier == null)
		{
			return true;
		}
		if (RescueGrappleUsed >= modifier.IntValue)
		{
			Plugin.Log.LogInfo("[ChallengeSystem] Спасательный захват: лимит исчерпан!");
			return false;
		}
		return true;
	}

	public static void RegisterGrappleUse()
	{
		RescueGrappleUsed++;
		Plugin.Log.LogInfo($"[ChallengeSystem] Спасательный захват использован ({RescueGrappleUsed} раз)");
	}

	public static float GetLavaSpeedMultiplier()
	{
		return ChallengeConfig.GetMultiplier(ChallengeModifierFlags.LavaSpeedMultiplied);
	}

	public static float GetHungerRateMultiplier()
	{
		return ChallengeConfig.GetMultiplier(ChallengeModifierFlags.HungerRateMultiplied);
	}

	public static float GetFallDamageMultiplier()
	{
		return ChallengeConfig.GetMultiplier(ChallengeModifierFlags.FallDamageMultiplied);
	}

	public static float GetColdEffectMultiplier()
	{
		return ChallengeConfig.GetMultiplier(ChallengeModifierFlags.ColdEffectIntensityMultiplied);
	}

	public static float GetHeatEffectMultiplier()
	{
		return ChallengeConfig.GetMultiplier(ChallengeModifierFlags.HeatEffectIntensityMultiplied);
	}

	public static float GetEffectDurationMultiplier()
	{
		return ChallengeConfig.GetMultiplier(ChallengeModifierFlags.EffectDurationMultiplied);
	}

	public static float GetEffectClearTimeMultiplier()
	{
		return ChallengeConfig.GetMultiplier(ChallengeModifierFlags.EffectClearTimeMultiplied);
	}

	public static float GetWeatherDurationMultiplier()
	{
		return ChallengeConfig.GetMultiplier(ChallengeModifierFlags.WeatherDurationMultiplied);
	}

	public static float GetMysticalChestSpawnMultiplier()
	{
		return ChallengeConfig.GetMultiplier(ChallengeModifierFlags.MysticalChestSpawnMultiplied);
	}

	public static float GetStaminaConsumptionMultiplier()
	{
		return ChallengeConfig.GetMultiplier(ChallengeModifierFlags.StaminaConsumptionMultiplied);
	}

	public static bool IsFogEnabled()
	{
		return ChallengeConfig.ActiveModifiers.ContainsKey(ChallengeModifierFlags.FogEnabled);
	}

	public static bool IsDayHeatEnabled()
	{
		return ChallengeConfig.ActiveModifiers.ContainsKey(ChallengeModifierFlags.DayHeatEnabled);
	}

	public static bool AreMysticalStatuesDisabled()
	{
		return ChallengeConfig.ActiveModifiers.ContainsKey(ChallengeModifierFlags.MysticalStatuesDisabled);
	}

	public static bool AreMysticalChestsDisabled()
	{
		return ChallengeConfig.ActiveModifiers.ContainsKey(ChallengeModifierFlags.MysticalChestsDisabled);
	}

	public static bool IsHandHoldingDisabled()
	{
		return ChallengeConfig.ActiveModifiers.ContainsKey(ChallengeModifierFlags.HandHoldingDisabled);
	}

	public static bool IsStatueOfRevivalInCommonChests()
	{
		return ChallengeConfig.ActiveModifiers.ContainsKey(ChallengeModifierFlags.StatueOfRevivalInCommonChests);
	}

	public static int GetMysticalStatuesItemCount()
	{
		return ChallengeConfig.GetModifier(ChallengeModifierFlags.MysticalStatuesCount)?.IntValue ?? 1;
	}

	public static int GetStaminaCursePercent()
	{
		return ChallengeConfig.GetModifier(ChallengeModifierFlags.StaminaCursePercent)?.IntValue ?? 0;
	}
}
public class ChallengeTabUI : MonoBehaviour
{
	private bool _showUI;

	private int _selectedChallenge;

	private Rect _windowRect;

	private Vector2 _scrollPosition;

	private bool _showModifiers;

	private const float WINDOW_WIDTH = 550f;

	private const float WINDOW_HEIGHT = 520f;

	private static readonly Dictionary<int, string> ChallengeColors;

	private static readonly Dictionary<int, string> ChallengeEmojis;

	public void Awake()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		_windowRect = new Rect((float)Screen.width / 2f - 275f, (float)Screen.height / 2f - 260f, 550f, 520f);
		Plugin.Log.LogInfo("[ChallengeTabUI] Инициализирован. F9 — показать/скрыть, F10 — сброс челленджа");
	}

	public void Update()
	{
		ChallengeSystem.Update();
		if (Input.GetKeyDown((KeyCode)41))
		{
			_showUI = !_showUI;
			Plugin.Log.LogInfo("[ChallengeTabUI] UI " + (_showUI ? "показан" : "спрятан"));
		}
		if (Input.GetKeyDown((KeyCode)42) && ChallengeConfig.IsActive)
		{
			ChallengeConfig.DeactivateChallenge();
			_selectedChallenge = 0;
			_showModifiers = false;
			Plugin.Log.LogInfo("[ChallengeTabUI] Челлендж сброшен");
		}
		if (Input.GetKeyDown((KeyCode)27) && _showUI)
		{
			_showUI = false;
		}
	}

	public void OnGUI()
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Expected O, but got Unknown
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		if (_showUI)
		{
			_windowRect = GUILayout.Window(1337, _windowRect, new WindowFunc(DrawChallengesWindow), "⛰\ufe0f Челленджи PEAK v1.0.0");
		}
	}

	private void DrawChallengesWindow(int windowID)
	{
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Expected O, but got Unknown
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Expected O, but got Unknown
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04db: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ea: Expected O, but got Unknown
		//IL_026e: 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: Expected O, but got Unknown
		//IL_070b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0710: Unknown result type (might be due to invalid IL or missing references)
		//IL_0718: Unknown result type (might be due to invalid IL or missing references)
		//IL_071e: Unknown result type (might be due to invalid IL or missing references)
		//IL_072d: Expected O, but got Unknown
		//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d4: Expected O, but got Unknown
		//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_077c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0781: Unknown result type (might be due to invalid IL or missing references)
		//IL_0789: Unknown result type (might be due to invalid IL or missing references)
		//IL_078f: Unknown result type (might be due to invalid IL or missing references)
		//IL_079e: Expected O, but got Unknown
		//IL_07b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0523: Unknown result type (might be due to invalid IL or missing references)
		//IL_0528: Unknown result type (might be due to invalid IL or missing references)
		//IL_052f: Unknown result type (might be due to invalid IL or missing references)
		//IL_053c: Expected O, but got Unknown
		//IL_0544: Unknown result type (might be due to invalid IL or missing references)
		//IL_0549: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0319: Unknown result type (might be due to invalid IL or missing references)
		//IL_0552: Unknown result type (might be due to invalid IL or missing references)
		//IL_0557: Unknown result type (might be due to invalid IL or missing references)
		//IL_043f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0444: Unknown result type (might be due to invalid IL or missing references)
		//IL_0482: Unknown result type (might be due to invalid IL or missing references)
		//IL_0487: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b8: Expected O, but got Unknown
		//IL_031e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0312: Unknown result type (might be due to invalid IL or missing references)
		//IL_030b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0582: Unknown result type (might be due to invalid IL or missing references)
		//IL_0587: Unknown result type (might be due to invalid IL or missing references)
		//IL_057b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0574: Unknown result type (might be due to invalid IL or missing references)
		//IL_06cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_06dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e8: Expected O, but got Unknown
		//IL_066a: Unknown result type (might be due to invalid IL or missing references)
		//IL_066f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0677: Unknown result type (might be due to invalid IL or missing references)
		//IL_067e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0684: Unknown result type (might be due to invalid IL or missing references)
		//IL_0693: Expected O, but got Unknown
		//IL_0368: Unknown result type (might be due to invalid IL or missing references)
		//IL_036d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0375: Unknown result type (might be due to invalid IL or missing references)
		//IL_0381: Expected O, but got Unknown
		//IL_0381: Unknown result type (might be due to invalid IL or missing references)
		//IL_0386: Unknown result type (might be due to invalid IL or missing references)
		//IL_0612: Unknown result type (might be due to invalid IL or missing references)
		//IL_0617: Unknown result type (might be due to invalid IL or missing references)
		//IL_061f: Unknown result type (might be due to invalid IL or missing references)
		//IL_062b: Expected O, but got Unknown
		//IL_062b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0630: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.Space(6f);
		if (ChallengeConfig.IsActive)
		{
			ChallengeDefinition challenge = ChallengeConfig.GetChallenge(ChallengeConfig.ActiveChallengeId);
			if (challenge != null)
			{
				GUILayout.BeginHorizontal();
				GUILayout.FlexibleSpace();
				string obj = $"\ud83d\udd25 АКТИВЕН: Челлендж #{ChallengeConfig.ActiveChallengeId} — {challenge.Name}";
				GUIStyle val = new GUIStyle(GUI.skin.label)
				{
					fontSize = 14,
					fontStyle = (FontStyle)1
				};
				val.normal.textColor = HexToColor(challenge.DifficultyColor);
				GUILayout.Label(obj, val);
				GUILayout.FlexibleSpace();
				GUILayout.EndHorizontal();
				GUILayout.Space(4f);
			}
		}
		GUILayout.BeginHorizontal();
		GUILayout.Label("Выберите челлендж для восхождения:", GUI.skin.label);
		GUILayout.FlexibleSpace();
		if (GUILayout.Button("✖", (GUILayoutOption[])(object)new GUILayoutOption[2]
		{
			GUILayout.Width(35f),
			GUILayout.Height(22f)
		}))
		{
			_showUI = false;
		}
		GUILayout.EndHorizontal();
		GUILayout.Space(4f);
		GUIStyle val2 = new GUIStyle(GUI.skin.label);
		val2.normal.textColor = new Color(0.4f, 0.4f, 0.4f, 1f);
		val2.fontSize = 10;
		GUILayout.Label("══════════════════════════════════════════", val2);
		_scrollPosition = GUILayout.BeginScrollView(_scrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(330f) });
		GUILayout.BeginHorizontal();
		GUI.color = (Color)((_selectedChallenge == 0) ? Color.gray : new Color(0.25f, 0.25f, 0.25f, 1f));
		if (GUILayout.Button("\ud83c\udfd4\ufe0f  Стандартное восхождение (без челленджей)", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) }))
		{
			_selectedChallenge = 0;
			ChallengeConfig.DeactivateChallenge();
		}
		GUI.color = Color.white;
		GUILayout.EndHorizontal();
		GUILayout.Space(4f);
		for (int i = 1; i <= 7; i++)
		{
			DrawChallengeButton(i);
			GUILayout.Space(2f);
		}
		GUILayout.EndScrollView();
		GUILayout.Space(6f);
		if (_selectedChallenge > 0)
		{
			ChallengeDefinition challenge2 = ChallengeConfig.GetChallenge(_selectedChallenge);
			if (challenge2 != null)
			{
				_showModifiers = GUILayout.Toggle(_showModifiers, "\ud83d\udccb Показать модификаторы (" + challenge2.Name + ")", new GUIStyle(GUI.skin.toggle)
				{
					fontSize = 12
				});
				if (_showModifiers)
				{
					GUILayout.BeginVertical("box");
					GUILayout.Label("\ud83d\udcdd " + challenge2.FullDescription, new GUIStyle(GUI.skin.label)
					{
						wordWrap = true,
						fontSize = 11,
						fontStyle = (FontStyle)2
					});
					GUILayout.Space(4f);
					Enumerator<ModifierEntry> enumerator = challenge2.Modifiers.GetEnumerator();
					try
					{
						while (enumerator.MoveNext())
						{
							ModifierEntry current = enumerator.Current;
							GUI.color = (current.IsNegative ? Color.red : (current.IsPositive ? Color.green : Color.white));
							GUILayout.Label("  " + (current.IsNegative ? "✗" : (current.IsPositive ? "✓" : "•")) + " " + current.Description, new GUIStyle(GUI.skin.label)
							{
								fontSize = 10,
								wordWrap = true
							});
							GUI.color = Color.white;
						}
					}
					finally
					{
						((global::System.IDisposable)enumerator).Dispose();
					}
					GUILayout.EndVertical();
				}
				GUILayout.Space(6f);
				bool isFinalChallenge = challenge2.IsFinalChallenge;
				string text = (isFinalChallenge ? ("☠\ufe0f НАЧАТЬ " + challenge2.Name) : ("\ud83e\uddd7 Начать восхождение: " + challenge2.Name));
				GUI.color = (isFinalChallenge ? Color.red : Color.green);
				GUI.skin.button.fontSize = 14;
				GUI.skin.button.fontStyle = (FontStyle)1;
				if (GUILayout.Button(text, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(42f) }))
				{
					StartChallenge(_selectedChallenge);
				}
				GUI.color = Color.white;
				GUI.skin.button.fontSize = 0;
				GUI.skin.button.fontStyle = (FontStyle)0;
				GUILayout.Space(6f);
				GUIStyle val3 = new GUIStyle(GUI.skin.label);
				val3.normal.textColor = new Color(0.4f, 0.4f, 0.4f, 1f);
				val3.fontSize = 10;
				GUILayout.Label("══════════════════════════════════════════", val3);
			}
		}
		else
		{
			GUIStyle val4 = new GUIStyle(GUI.skin.label)
			{
				fontStyle = (FontStyle)2
			};
			val4.normal.textColor = Color.gray;
			GUILayout.Label("← Выберите челлендж для просмотра описания", val4);
		}
		if (ChallengeConfig.IsActive && _showModifiers && ChallengeConfig.ActiveChallengeId > 0)
		{
			GUILayout.BeginVertical("box");
			GUILayout.Label("⚡ Текущие активные модификаторы забега:", new GUIStyle(GUI.skin.label)
			{
				fontStyle = (FontStyle)1,
				fontSize = 11
			});
			int num = 0;
			Enumerator<ChallengeModifierFlags, ModifierEntry> enumerator2 = ChallengeConfig.ActiveModifiers.GetEnumerator();
			try
			{
				while (enumerator2.MoveNext())
				{
					ModifierEntry value = enumerator2.Current.Value;
					GUI.color = (value.IsNegative ? Color.red : (value.IsPositive ? Color.green : Color.white));
					GUILayout.Label($"  {(value.IsNegative ? "" : "")} {value.Description} (x{value.Multiplier:F2})", new GUIStyle(GUI.skin.label)
					{
						fontSize = 9,
						wordWrap = true
					});
					GUI.color = Color.white;
					num++;
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator2).Dispose();
			}
			if (num == 0)
			{
				GUIStyle val5 = new GUIStyle(GUI.skin.label)
				{
					fontSize = 9,
					fontStyle = (FontStyle)2
				};
				val5.normal.textColor = Color.gray;
				GUILayout.Label("  Нет активных модификаторов", val5);
			}
			GUILayout.Label($"  Итого: {num} модификаторов", new GUIStyle(GUI.skin.label)
			{
				fontSize = 10,
				fontStyle = (FontStyle)1
			});
			GUILayout.EndVertical();
		}
		GUILayout.Space(4f);
		GUILayout.BeginHorizontal();
		GUIStyle val6 = new GUIStyle(GUI.skin.label)
		{
			fontSize = 9
		};
		val6.normal.textColor = Color.gray;
		GUILayout.Label("[F9] Показать/скрыть  |  [F10] Сбросить челлендж  |  [Esc] Закрыть", val6);
		GUILayout.FlexibleSpace();
		string text2 = "Челлендж: " + (ChallengeConfig.IsActive ? $"#{ChallengeConfig.ActiveChallengeId}" : "нет");
		GUIStyle val7 = new GUIStyle(GUI.skin.label)
		{
			fontSize = 9
		};
		val7.normal.textColor = Color.gray;
		GUILayout.Label(text2, val7);
		GUILayout.EndHorizontal();
		GUI.DragWindow(new Rect(0f, 0f, 550f, 30f));
	}

	private void DrawChallengeButton(int challengeId)
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Expected O, but got Unknown
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: 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_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a0: 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_01b5: Expected O, but got Unknown
		ChallengeDefinition challenge = ChallengeConfig.GetChallenge(challengeId);
		if (challenge != null)
		{
			bool flag = _selectedChallenge == challengeId;
			bool flag2 = ChallengeConfig.ActiveChallengeId == challengeId;
			string valueOrDefault = CollectionExtensions.GetValueOrDefault<int, string>((IReadOnlyDictionary<int, string>)(object)ChallengeColors, challengeId, "#ffffff");
			Color val = HexToColor(valueOrDefault);
			string valueOrDefault2 = CollectionExtensions.GetValueOrDefault<int, string>((IReadOnlyDictionary<int, string>)(object)ChallengeEmojis, challengeId, "❓");
			GUILayout.BeginHorizontal();
			GUILayout.BeginVertical();
			GUI.color = (Color)(flag2 ? Color.green : (flag ? val : new Color(0.2f, 0.2f, 0.2f, 1f)));
			GUIStyle val2 = new GUIStyle(GUI.skin.button);
			val2.fontStyle = (FontStyle)(flag2 ? 1 : 0);
			val2.alignment = (TextAnchor)4;
			val2.padding.left = 10;
			string text = $"{valueOrDefault2} Челлендж {challengeId}: {challenge.Name}";
			if (challenge.IsFinalChallenge)
			{
				text += " ☠\ufe0f";
			}
			if (flag2)
			{
				text = "✅ " + text;
			}
			if (GUILayout.Button(text, val2, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) }))
			{
				_selectedChallenge = challengeId;
				_showModifiers = true;
			}
			GUILayout.EndVertical();
			GUI.color = Color.white;
			if (flag || flag2)
			{
				GUILayout.BeginVertical("box");
				string text2 = "  " + challenge.ShortDescription;
				GUIStyle val3 = new GUIStyle(GUI.skin.label)
				{
					fontSize = 10,
					fontStyle = (FontStyle)2
				};
				val3.normal.textColor = Color.white;
				GUILayout.Label(text2, val3);
				GUILayout.EndVertical();
			}
			GUILayout.EndHorizontal();
		}
	}

	private void StartChallenge(int challengeId)
	{
		ChallengeDefinition challenge = ChallengeConfig.GetChallenge(challengeId);
		if (challenge != null)
		{
			Plugin.Log.LogInfo("[ChallengeTabUI] ═══════════════════════════════");
			Plugin.Log.LogInfo("[ChallengeTabUI] \ud83d\udd25 НАЧАТО ВОСХОЖДЕНИЕ: " + challenge.Name);
			Plugin.Log.LogInfo("[ChallengeTabUI] ═══════════════════════════════");
			Plugin.Log.LogInfo("[ChallengeTabUI] " + challenge.FullDescription);
			ChallengeConfig.ActivateChallenge(challengeId);
			ChallengeSystem.OnRunStart();
			_selectedChallenge = challengeId;
			_showModifiers = true;
			Plugin.Log.LogInfo($"[ChallengeTabUI] Модификаторы применены. Всего: {ChallengeConfig.ActiveModifiers.Count}");
			_showUI = false;
		}
	}

	private Color HexToColor(string hex)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		if (string.IsNullOrEmpty(hex))
		{
			return Color.white;
		}
		if (hex.StartsWith("#"))
		{
			hex = hex.Substring(1);
		}
		if (hex.Length >= 6)
		{
			byte num = byte.Parse(hex.Substring(0, 2), (NumberStyles)515);
			byte b = byte.Parse(hex.Substring(2, 2), (NumberStyles)515);
			byte b2 = byte.Parse(hex.Substring(4, 2), (NumberStyles)515);
			byte b3 = (byte)((hex.Length >= 8) ? byte.Parse(hex.Substring(6, 2), (NumberStyles)515) : 255);
			return Color32.op_Implicit(new Color32(num, b, b2, b3));
		}
		return Color.white;
	}

	static ChallengeTabUI()
	{
		Dictionary<int, string> obj = new Dictionary<int, string>();
		obj.Add(1, "#ff6b6b");
		obj.Add(2, "#ff9f43");
		obj.Add(3, "#feca57");
		obj.Add(4, "#ee5a24");
		obj.Add(5, "#ff6348");
		obj.Add(6, "#a55eea");
		obj.Add(7, "#ff0000");
		ChallengeColors = obj;
		Dictionary<int, string> obj2 = new Dictionary<int, string>();
		obj2.Add(1, "\ud83c\udf0b");
		obj2.Add(2, "\ud83d\udc80");
		obj2.Add(3, "\ud83d\udce6");
		obj2.Add(4, "\ud83c\udf00");
		obj2.Add(5, "☀\ufe0f");
		obj2.Add(6, "⚡");
		obj2.Add(7, "\ud83d\udc80\ud83d\udd25");
		ChallengeEmojis = obj2;
	}
}
public static class Patching
{
	[HarmonyPatch(typeof(CharacterMovement), "Update")]
	public static class FallTimePatch
	{
		private static void Prefix(CharacterMovement __instance)
		{
			if (!ChallengeConfig.IsActive)
			{
				return;
			}
			float fallDamageMultiplier = ChallengeSystem.GetFallDamageMultiplier();
			if (fallDamageMultiplier != 1f)
			{
				FieldInfo fallDamageTimeField = ConstantFields.GetFallDamageTimeField();
				if (fallDamageTimeField != (FieldInfo)null)
				{
					float num = 0.5f / fallDamageMultiplier;
					fallDamageTimeField.SetValue((object)__instance, (object)num);
				}
			}
		}
	}

	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	public static class InfiniteStaminaBypass
	{
		private static void Postfix(Character __instance, ref bool __result)
		{
			if (ChallengeConfig.IsActive && __result && ChallengeSystem.GetStaminaCursePercent() > 0)
			{
				Plugin.Log.LogDebug("[InfiniteStaminaBypass] infiniteStam активен, но проклятие стамины применяется отдельно");
			}
		}
	}

	[HarmonyPatch(typeof(CharacterClimbing), "Start")]
	public static class ClimbSpeedPatch
	{
		private static void Postfix(CharacterClimbing __instance)
		{
			if (!ChallengeConfig.IsActive)
			{
				return;
			}
			float staminaConsumptionMultiplier = ChallengeSystem.GetStaminaConsumptionMultiplier();
			if (staminaConsumptionMultiplier != 1f)
			{
				FieldInfo climbSpeedModField = ConstantFields.GetClimbSpeedModField();
				if (climbSpeedModField != (FieldInfo)null)
				{
					float num = (float)climbSpeedModField.GetValue((object)__instance);
					float num2 = num / staminaConsumptionMultiplier;
					climbSpeedModField.SetValue((object)__instance, (object)num2);
					Plugin.Log.LogDebug($"[ClimbSpeedPatch] climbSpeedMod: {num} → {num2}");
				}
			}
		}
	}

	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	public static class StaminaCurseGetter
	{
		private static void Postfix(CharacterData __instance, ref float __result)
		{
			if (ChallengeConfig.IsActive)
			{
				int staminaCursePercent = ChallengeSystem.GetStaminaCursePercent();
				if (staminaCursePercent > 0)
				{
					float num = __result * ((float)staminaCursePercent / 100f);
					__result -= num;
				}
			}
		}
	}

	[HarmonyPatch(typeof(CharacterAfflictions), "SetStatus")]
	public static class SetStatusIntensityPatch
	{
		private static void Prefix(CharacterAfflictions __instance, STATUSTYPE type, ref float amount)
		{
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			if (!ChallengeConfig.IsActive)
			{
				return;
			}
			string text = ((object)(STATUSTYPE)(ref type)).ToString().ToLowerInvariant();
			float num = 1f;
			if (text.Contains("hung") || text.Contains("starv"))
			{
				float hungerRateMultiplier = ChallengeSystem.GetHungerRateMultiplier();
				if (hungerRateMultiplier != 1f)
				{
					num *= hungerRateMultiplier;
				}
			}
			if (text.Contains("cold") || text.Contains("freez") || text.Contains("frost"))
			{
				num *= ChallengeSystem.GetColdEffectMultiplier();
			}
			if (text.Contains("heat") || text.Contains("hot") || text.Contains("burn"))
			{
				num *= ChallengeSystem.GetHeatEffectMultiplier();
			}
			float num2 = Math.Max(ChallengeSystem.GetEffectDurationMultiplier(), ChallengeSystem.GetEffectClearTimeMultiplier());
			if (num2 > 1f)
			{
				num *= num2;
			}
			if (num != 1f)
			{
				amount *= num;
				Plugin.Log.LogDebug($"[SetStatusPatch] {type}: amount *= {num:F2}");
			}
		}
	}

	[HarmonyPatch(typeof(CharacterAfflictions), "UpdateWeight")]
	public static class WeightBypassPatch
	{
		private static void Postfix(CharacterAfflictions __instance)
		{
			_ = ChallengeConfig.IsActive;
		}
	}

	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	public static class FogDensityPatch
	{
		private static void Postfix(ref float __result)
		{
			if (ChallengeConfig.IsActive && ChallengeSystem.IsFogEnabled())
			{
				__result *= 3f;
			}
		}
	}

	[HarmonyPatch(typeof(PointPinger), "ReceivePoint_Rpc")]
	public static class PointPingLogPatch
	{
		private static void Postfix(Vector3 point, Vector3 hitNormal, PointPinger __instance)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (ChallengeConfig.IsActive)
			{
				Plugin.Log.LogDebug($"[PointPingPatch] Пинг в точке: {point}");
			}
		}
	}

	[HarmonyPatch(typeof(Character), "Update")]
	public static class CharacterUpdatePatch
	{
		private static void Postfix(Character __instance)
		{
			if (__instance.IsLocal && ChallengeConfig.IsActive && ChallengeConfig.ActiveChallengeId != 0)
			{
				ChallengeSystem.ApplyStaminaCurse();
			}
		}
	}

	public static void ApplyPatches(Harmony harmony)
	{
		harmony.PatchAll(Assembly.GetExecutingAssembly());
		Plugin.Log.LogInfo("[Patching] Все Harmony-патчи применены");
	}
}
[BepInPlugin("com.steelrework.PEAKChallenges", "PEAK Challenges", "1.0.0")]
[BepInAutoPlugin]
public class Plugin : BaseUnityPlugin
{
	private Harmony _harmony;

	[field: CompilerGenerated]
	internal static ManualLogSource Log
	{
		[CompilerGenerated]
		get;
		[CompilerGenerated]
		private set;
	}

	[field: CompilerGenerated]
	internal static Plugin Instance
	{
		[CompilerGenerated]
		get;
		[CompilerGenerated]
		private set;
	}

	private void Awake()
	{
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		Instance = this;
		Log.LogInfo("[PEAKChallenges] PEAK Challenges v1.0.0 загружается...");
		ChallengeConfig.Initialize(this);
		_harmony = new Harmony("com.steelrework.PEAKChallenges");
		Patching.ApplyPatches(_harmony);
		ChallengeSystem.Initialize();
		Log.LogInfo("[PEAKChallenges] Плагин " + ((BaseUnityPlugin)this).Name + " успешно загружен!");
	}

	private void OnDestroy()
	{
		Harmony harmony = _harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
		Log.LogInfo("[PEAKChallenges] Плагин выгружен.");
	}
}
public static class PluginInfo
{
	public const string PLUGIN_GUID = "com.steelrework.PEAKChallenges";

	public const string PLUGIN_NAME = "PEAK Challenges";

	public const string PLUGIN_VERSION = "1.0.0";
}