Decompiled source of Kapi Perks v1.1.0

MyPerkMod.dll

Decompiled 2 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MyPerkMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MyPerkMod")]
[assembly: AssemblyTitle("MyPerkMod")]
[assembly: AssemblyVersion("1.0.0.0")]
public static class Localization
{
	private static Dictionary<string, string> ruTitles;

	private static Dictionary<string, string> enTitles;

	private static Dictionary<string, string> ruDescriptions;

	private static Dictionary<string, string> enDescriptions;

	static Localization()
	{
		ruTitles = new Dictionary<string, string>();
		enTitles = new Dictionary<string, string>();
		ruDescriptions = new Dictionary<string, string>();
		enDescriptions = new Dictionary<string, string>();
		ruTitles["mymod_accumulation_perk"] = "Накопление";
		ruTitles["mymod_goldenhands_perk"] = "Золотые руки";
		ruTitles["mymod_serenity_perk"] = "Спокойствие";
		ruTitles["mymod_claws_perk"] = "Когти";
		ruTitles["mymod_dash_perk"] = "Рывок";
		ruTitles["mymod_killresist_perk"] = "Боевой азарт";
		ruTitles["mymod_vampiricgrip_perk"] = "Вампирская хватка";
		ruTitles["mymod_adrenalsponges_perk"] = "Адреналиновые губки";
		ruTitles["mymod_callousedpalms_perk"] = "Огрубевшие ладони";
		ruTitles["mymod_photosyntheticskin_perk"] = "Фотосинтетическая кожа";
		ruTitles["mymod_slipperyluck_perk"] = "Скользкая удача";
		ruTitles["mymod_chitinoushook_perk"] = "Хитиновый крюк";
		ruTitles["mymod_berserker_perk"] = "Берсерк";
		ruTitles["mymod_bloodpact_perk"] = "Кровавый договор";
		enTitles["mymod_accumulation_perk"] = "Accumulation";
		enTitles["mymod_goldenhands_perk"] = "Golden Hands";
		enTitles["mymod_serenity_perk"] = "Serenity";
		enTitles["mymod_claws_perk"] = "Claws";
		enTitles["mymod_dash_perk"] = "Dash";
		enTitles["mymod_killresist_perk"] = "Battle Frenzy";
		enTitles["mymod_vampiricgrip_perk"] = "Vampiric Grip";
		enTitles["mymod_adrenalsponges_perk"] = "Adrenal Sponges";
		enTitles["mymod_callousedpalms_perk"] = "Calloused Palms";
		enTitles["mymod_photosyntheticskin_perk"] = "Photosynthetic Skin";
		enTitles["mymod_slipperyluck_perk"] = "Slippery Luck";
		enTitles["mymod_chitinoushook_perk"] = "Chitinous Hook";
		enTitles["mymod_berserker_perk"] = "Berserker";
		enTitles["mymod_bloodpact_perk"] = "Blood Pact";
		ruDescriptions["mymod_accumulation_perk"] = "25% шанс получить вдвое больше тараканов при получении.";
		ruDescriptions["mymod_goldenhands_perk"] = "Все предметы в магазине на 20% дешевле.";
		ruDescriptions["mymod_serenity_perk"] = "При простое (не двигаясь и не лазая) здоровье и стамина восстанавливаются вдвое быстрее.";
		ruDescriptions["mymod_claws_perk"] = "Максимальный запас стамины увеличен вдвое, но прыжок ниже на 5% и скорость бега снижена на 10%.";
		ruDescriptions["mymod_dash_perk"] = "Нажатие Shift в воздухе совершает рывок в сторону взгляда, тратит 50% стамины, перезарядка 2 сек.";
		ruDescriptions["mymod_killresist_perk"] = "С каждым убийством врага сопротивление урону растёт на 15% в течение 5 секунд (до 50% максимум).";
		ruDescriptions["mymod_vampiricgrip_perk"] = "При ударе по врагу восстанавливает 3 сек. стамины, но получаемый урон увеличен на 50%.";
		ruDescriptions["mymod_adrenalsponges_perk"] = "При получении урона восстанавливает 2 сек. стамины за каждый стак (кулдаун 3 сек).";
		ruDescriptions["mymod_callousedpalms_perk"] = "Когда стамина падает ниже 30%, её расход замедляется на 25% за каждый стак.";
		ruDescriptions["mymod_photosyntheticskin_perk"] = "На свету регенерация стамины +100%. В темноте регенерация снижена на 50%.";
		ruDescriptions["mymod_slipperyluck_perk"] = "При хватании за уступ 25% шанс на идеальную хватку (5 сек бесплатной стамины и +50% прыжок) и 5% шанс на предательство (срыв и обнуление стамины).";
		ruDescriptions["mymod_chitinoushook_perk"] = "Правая рука не может сорваться при нулевой стамине, но общая стамина уменьшена на 25%.";
		ruDescriptions["mymod_berserker_perk"] = "Чем меньше здоровья, тем выше урон. При 1 HP урон увеличивается до x10.";
		ruDescriptions["mymod_bloodpact_perk"] = "+50% к регенерации стамины и +25% к прыжку. Отключает пассивную регенерацию HP и наносит 0.5 урона в минуту (останавливается на 1 HP).";
		enDescriptions["mymod_accumulation_perk"] = "25% chance to get double roaches when collecting.";
		enDescriptions["mymod_goldenhands_perk"] = "All shop items are 20% cheaper.";
		enDescriptions["mymod_serenity_perk"] = "When idle (not moving or climbing), health and stamina regenerate twice as fast.";
		enDescriptions["mymod_claws_perk"] = "Maximum stamina doubled, but jump is 5% lower and movement speed is 10% slower.";
		enDescriptions["mymod_dash_perk"] = "Pressing Shift in the air performs a dash in look direction, consumes 50% stamina, 2 sec cooldown.";
		enDescriptions["mymod_killresist_perk"] = "Each kill grants 15% damage resistance for 5 seconds (up to 50% max).";
		enDescriptions["mymod_vampiricgrip_perk"] = "Hitting an enemy restores 3 sec of stamina, but incoming damage is increased by 50%.";
		enDescriptions["mymod_adrenalsponges_perk"] = "Taking damage restores 2 sec of stamina per stack (3 sec cooldown).";
		enDescriptions["mymod_callousedpalms_perk"] = "When stamina drops below 30%, its drain is slowed by 25% per stack.";
		enDescriptions["mymod_photosyntheticskin_perk"] = "In light, stamina regen +100%. In darkness, regen is reduced by 50%.";
		enDescriptions["mymod_slipperyluck_perk"] = "When grabbing a ledge, 25% chance for Perfect Grip (5 sec free stamina, +50% jump) and 5% chance for Betrayal (drop and stamina reset).";
		enDescriptions["mymod_chitinoushook_perk"] = "Right hand cannot slip when stamina is zero, but total stamina is reduced by 25%.";
		enDescriptions["mymod_berserker_perk"] = "The less health you have, the more damage you deal. At 1 HP, damage is increased up to x10.";
		enDescriptions["mymod_bloodpact_perk"] = "+50% stamina regen and +25% jump height. Disables passive HP regen and deals 0.5 damage per minute (stops at 1 HP).";
	}

	public static string GetTitle(string perkId)
	{
		if (Plugin.GetCurrentLanguage() == "English")
		{
			if (!enTitles.TryGetValue(perkId, out var value))
			{
				return perkId;
			}
			return value;
		}
		if (!ruTitles.TryGetValue(perkId, out var value2))
		{
			return perkId;
		}
		return value2;
	}

	public static string GetDescription(string perkId)
	{
		if (Plugin.GetCurrentLanguage() == "English")
		{
			if (!enDescriptions.TryGetValue(perkId, out var value))
			{
				return perkId;
			}
			return value;
		}
		if (!ruDescriptions.TryGetValue(perkId, out var value2))
		{
			return perkId;
		}
		return value2;
	}
}
[HarmonyPatch(typeof(CL_GameManager), "AddRoaches")]
public static class Patch_AddRoaches
{
	[HarmonyPrefix]
	public static void Prefix(ref int i, bool global)
	{
		if (!global && i > 0)
		{
			ENT_Player player = ENT_Player.GetPlayer();
			if ((Object)(object)player != (Object)null && player.HasPerk("mymod_accumulation_perk") && Random.value < 0.25f)
			{
				i *= 2;
			}
		}
	}
}
[HarmonyPatch(typeof(ENT_Player), "Damage")]
public static class Patch_AdrenalSponges_Damage
{
	[HarmonyPrefix]
	public static void Prefix(ENT_Player __instance, DamageInfo info)
	{
		if ((Object)(object)__instance == (Object)null)
		{
			return;
		}
		Perk perk = __instance.GetPerk("mymod_adrenalsponges_perk");
		if ((Object)(object)perk == (Object)null)
		{
			return;
		}
		PerkModule_AdrenalSponges perkModule_AdrenalSponges = null;
		foreach (PerkModule module in perk.modules)
		{
			if (module is PerkModule_AdrenalSponges)
			{
				perkModule_AdrenalSponges = module as PerkModule_AdrenalSponges;
				break;
			}
		}
		if (perkModule_AdrenalSponges != null && perkModule_AdrenalSponges.CanTrigger())
		{
			int stacks = perkModule_AdrenalSponges.GetStacks();
			float num = 2f * (float)stacks;
			__instance.AddGripStrength(num, false, false);
			perkModule_AdrenalSponges.Trigger();
		}
	}
}
[HarmonyPatch(typeof(DEN_BasicDenizen), "Damage", new Type[] { typeof(DamageInfo) })]
public static class Patch_Berserker_Damage
{
	[HarmonyPrefix]
	public static void Prefix(DEN_BasicDenizen __instance, ref DamageInfo info)
	{
		GameEntity sourceEntity = info.sourceEntity;
		ENT_Player val = (ENT_Player)(object)((sourceEntity is ENT_Player) ? sourceEntity : null);
		if (val != null && val.HasPerk("mymod_berserker_perk"))
		{
			float num = ((GameEntity)val).health / ((GameEntity)val).maxHealth;
			float num2 = 1f + (1f - num) * 9f;
			DamageInfo obj = info;
			obj.amount *= num2;
		}
	}
}
[HarmonyPatch(typeof(ENT_Player), "HandStamina")]
public static class Patch_CallousedPalms
{
	[HarmonyPrefix]
	public static void Prefix(ENT_Player __instance, int hand, Hand curhand, bool canInteract, bool interacting, float currentInteractDistance)
	{
		if (!__instance.HasPerk("mymod_callousedpalms_perk") || !curhand.IsHanging())
		{
			return;
		}
		float currentGripStrengthTimer = __instance.GetCurrentGripStrengthTimer(hand);
		float gripStrength = curhand.gripStrength;
		float num = currentGripStrengthTimer * 0.3f;
		if (gripStrength <= num)
		{
			FieldInfo fieldInfo = AccessTools.Field(typeof(ENT_Player), "gripStrengthLossRate");
			if (fieldInfo != null)
			{
				float num2 = (float)fieldInfo.GetValue(__instance);
				fieldInfo.SetValue(__instance, num2 * 0.75f);
			}
		}
	}

	[HarmonyPostfix]
	public static void Postfix(ENT_Player __instance, int hand, Hand curhand, bool canInteract, bool interacting, float currentInteractDistance)
	{
		if (!__instance.HasPerk("mymod_callousedpalms_perk") || !curhand.IsHanging())
		{
			return;
		}
		float currentGripStrengthTimer = __instance.GetCurrentGripStrengthTimer(hand);
		float gripStrength = curhand.gripStrength;
		float num = currentGripStrengthTimer * 0.1f;
		if (gripStrength <= num)
		{
			FieldInfo fieldInfo = AccessTools.Field(typeof(ENT_Player), "gripStrengthLossRate");
			if (fieldInfo != null)
			{
				float num2 = (float)fieldInfo.GetValue(__instance);
				fieldInfo.SetValue(__instance, num2 / 0.75f);
			}
		}
	}
}
[HarmonyPatch(typeof(ENT_Player), "HandStamina")]
public static class Patch_ChitinousHook_MinStamina
{
	private static FieldInfo handsField = AccessTools.Field(typeof(ENT_Player), "hands");

	[HarmonyPostfix]
	public static void Postfix(ENT_Player __instance, int hand, Hand curhand)
	{
		if (__instance.HasPerk("mymod_chitinoushook_perk") && curhand.id == 1 && curhand.gripStrength < 0.5f)
		{
			curhand.gripStrength = 0.5f;
		}
	}
}
[HarmonyPatch(typeof(ENT_Player), "GetCurrentGripStrengthTimer")]
public static class Patch_ChitinousHook_Stamina
{
	[HarmonyPostfix]
	public static void Postfix(ENT_Player __instance, ref float __result)
	{
		if (__instance.HasPerk("mymod_chitinoushook_perk"))
		{
			__result *= 0.75f;
		}
	}
}
[HarmonyPatch(typeof(App_PerkPage), "GenerateCards")]
public static class Patch_GenerateCards
{
	private static Perk _cachedPerk;

	private static readonly FieldInfo _cardsField = AccessTools.Field(typeof(App_PerkPage), "cards");

	[HarmonyPostfix]
	public static void Postfix(App_PerkPage __instance)
	{
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)__instance == (Object)null) && _cardsField?.GetValue(__instance) is List<App_PerkPage_Card> list)
		{
			Func<Perk>[] array = new Func<Perk>[14]
			{
				CreateAccumulation, CreateGoldenHands, CreateSerenity, CreateClaws, CreateDash, CreateKillResist, CreateVampiricGrip, CreateAdrenalSponges, CreateCallousedPalms, CreatePhotosyntheticSkin,
				CreateSlipperyLuck, CreateChitinousHook, CreateBerserker, CreateBloodPact
			};
			_cachedPerk = array[Random.Range(0, array.Length)]();
			if ((Object)(object)_cachedPerk == (Object)null)
			{
				_cachedPerk = CreateAccumulation();
			}
			App_PerkPage_Card component = ((Component)Object.Instantiate<App_PerkPage_Card>(__instance.cardAsset, __instance.cardParent.position, Quaternion.identity, __instance.cardParent)).GetComponent<App_PerkPage_Card>();
			if ((Object)(object)component != (Object)null)
			{
				component.Initialize(__instance, _cachedPerk);
				list.Add(component);
			}
		}
	}

	private static Perk CreateAccumulation()
	{
		Perk obj = ScriptableObject.CreateInstance<Perk>();
		obj.id = "mymod_accumulation_perk";
		obj.title = Localization.GetTitle(obj.id);
		obj.description = Localization.GetDescription(obj.id);
		obj.cost = 20;
		obj.modules = new List<PerkModule> { (PerkModule)(object)new PerkModule_Accumulation() };
		obj.perkCard = LoadSprite("Sprites\\AccumulationCard.png");
		obj.perkFrame = LoadSprite("Sprites\\PerkCard_Frame_Advanced.png");
		return obj;
	}

	private static Perk CreateGoldenHands()
	{
		Perk obj = ScriptableObject.CreateInstance<Perk>();
		obj.id = "mymod_goldenhands_perk";
		obj.title = Localization.GetTitle(obj.id);
		obj.description = Localization.GetDescription(obj.id);
		obj.cost = 5;
		obj.modules = new List<PerkModule> { (PerkModule)(object)new PerkModule_GoldenHands() };
		obj.perkCard = LoadSprite("Sprites\\GoldenHandsCard.png");
		obj.perkFrame = LoadSprite("Sprites\\PerkCard_Frame_Advanced.png");
		return obj;
	}

	private static Perk CreateSerenity()
	{
		Perk obj = ScriptableObject.CreateInstance<Perk>();
		obj.id = "mymod_serenity_perk";
		obj.title = Localization.GetTitle(obj.id);
		obj.description = Localization.GetDescription(obj.id);
		obj.cost = 10;
		obj.modules = new List<PerkModule> { (PerkModule)(object)new PerkModule_Serenity() };
		obj.perkCard = LoadSprite("Sprites\\SerenityCard.png");
		obj.perkFrame = LoadSprite("Sprites\\PerkCard_Frame_Advanced.png");
		return obj;
	}

	private static Perk CreateClaws()
	{
		Perk obj = ScriptableObject.CreateInstance<Perk>();
		obj.id = "mymod_claws_perk";
		obj.title = Localization.GetTitle(obj.id);
		obj.description = Localization.GetDescription(obj.id);
		obj.cost = 10;
		obj.modules = new List<PerkModule> { (PerkModule)(object)new PerkModule_Claws() };
		obj.perkCard = LoadSprite("Sprites\\ClawsCard.png");
		obj.perkFrame = LoadSprite("Sprites\\PerkCard_Frame_Advanced.png");
		return obj;
	}

	private static Perk CreateDash()
	{
		Perk obj = ScriptableObject.CreateInstance<Perk>();
		obj.id = "mymod_dash_perk";
		obj.title = Localization.GetTitle(obj.id);
		obj.description = Localization.GetDescription(obj.id);
		obj.cost = 15;
		obj.modules = new List<PerkModule> { (PerkModule)(object)new PerkModule_Dash() };
		obj.perkCard = LoadSprite("Sprites\\DashCard.png");
		obj.perkFrame = LoadSprite("Sprites\\PerkCard_Frame_Advanced.png");
		return obj;
	}

	private static Perk CreateKillResist()
	{
		Perk obj = ScriptableObject.CreateInstance<Perk>();
		obj.id = "mymod_killresist_perk";
		obj.title = Localization.GetTitle(obj.id);
		obj.description = Localization.GetDescription(obj.id);
		obj.cost = 10;
		obj.modules = new List<PerkModule> { (PerkModule)(object)new PerkModule_KillResist() };
		obj.perkCard = LoadSprite("Sprites\\KillResistCard.png");
		obj.perkFrame = LoadSprite("Sprites\\PerkCard_Frame_Advanced.png");
		return obj;
	}

	private static Perk CreateVampiricGrip()
	{
		Perk obj = ScriptableObject.CreateInstance<Perk>();
		obj.id = "mymod_vampiricgrip_perk";
		obj.title = Localization.GetTitle(obj.id);
		obj.description = Localization.GetDescription(obj.id);
		obj.cost = 10;
		obj.modules = new List<PerkModule> { (PerkModule)(object)new PerkModule_VampiricGrip() };
		obj.perkCard = LoadSprite("Sprites\\VampiricGripCard.png");
		obj.perkFrame = LoadSprite("Sprites\\PerkCard_Frame_Advanced.png");
		return obj;
	}

	private static Perk CreateAdrenalSponges()
	{
		Perk obj = ScriptableObject.CreateInstance<Perk>();
		obj.id = "mymod_adrenalsponges_perk";
		obj.title = Localization.GetTitle(obj.id);
		obj.description = Localization.GetDescription(obj.id);
		obj.cost = 5;
		obj.modules = new List<PerkModule> { (PerkModule)(object)new PerkModule_AdrenalSponges() };
		obj.perkCard = LoadSprite("Sprites\\AdrenalSpongesCard.png");
		obj.perkFrame = LoadSprite("Sprites\\PerkCard_Frame_Advanced.png");
		return obj;
	}

	private static Perk CreateCallousedPalms()
	{
		Perk obj = ScriptableObject.CreateInstance<Perk>();
		obj.id = "mymod_callousedpalms_perk";
		obj.title = Localization.GetTitle(obj.id);
		obj.description = Localization.GetDescription(obj.id);
		obj.cost = 5;
		obj.modules = new List<PerkModule> { (PerkModule)(object)new PerkModule_CallousedPalms() };
		obj.perkCard = LoadSprite("Sprites\\CallousedPalmsCard.png");
		obj.perkFrame = LoadSprite("Sprites\\PerkCard_Frame_Advanced.png");
		return obj;
	}

	private static Perk CreatePhotosyntheticSkin()
	{
		Perk obj = ScriptableObject.CreateInstance<Perk>();
		obj.id = "mymod_photosyntheticskin_perk";
		obj.title = Localization.GetTitle(obj.id);
		obj.description = Localization.GetDescription(obj.id);
		obj.cost = 10;
		obj.modules = new List<PerkModule> { (PerkModule)(object)new PerkModule_PhotosyntheticSkin() };
		obj.perkCard = LoadSprite("Sprites\\PhotosyntheticSkinCard.png");
		obj.perkFrame = LoadSprite("Sprites\\PerkCard_Frame_Advanced.png");
		return obj;
	}

	private static Perk CreateSlipperyLuck()
	{
		Perk obj = ScriptableObject.CreateInstance<Perk>();
		obj.id = "mymod_slipperyluck_perk";
		obj.title = Localization.GetTitle(obj.id);
		obj.description = Localization.GetDescription(obj.id);
		obj.cost = 10;
		obj.modules = new List<PerkModule> { (PerkModule)(object)new PerkModule_SlipperyLuck() };
		obj.perkCard = LoadSprite("Sprites\\SlipperyLuckCard.png");
		obj.perkFrame = LoadSprite("Sprites\\PerkCard_Frame_Advanced.png");
		return obj;
	}

	private static Perk CreateChitinousHook()
	{
		Perk obj = ScriptableObject.CreateInstance<Perk>();
		obj.id = "mymod_chitinoushook_perk";
		obj.title = Localization.GetTitle(obj.id);
		obj.description = Localization.GetDescription(obj.id);
		obj.cost = 20;
		obj.modules = new List<PerkModule> { (PerkModule)(object)new PerkModule_ChitinousHook() };
		obj.perkCard = LoadSprite("Sprites\\ChitinousHookCard.png");
		obj.perkFrame = LoadSprite("Sprites\\PerkCard_Frame_Advanced.png");
		return obj;
	}

	private static Perk CreateBerserker()
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		Perk obj = ScriptableObject.CreateInstance<Perk>();
		obj.id = "mymod_berserker_perk";
		obj.title = Localization.GetTitle(obj.id);
		obj.description = Localization.GetDescription(obj.id);
		obj.cost = 15;
		obj.perkType = (PerkType)2;
		obj.modules = new List<PerkModule>
		{
			(PerkModule)(object)new PerkModule_Berserker(),
			(PerkModule)(object)new PerkModule_BerserkerVisual()
		};
		obj.perkCard = LoadSprite("Sprites\\BerserkerCard.png");
		obj.perkFrame = LoadSprite("Sprites\\PerkCard_Frame_Advanced.png");
		return obj;
	}

	private static Perk CreateBloodPact()
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		Perk obj = ScriptableObject.CreateInstance<Perk>();
		obj.id = "mymod_bloodpact_perk";
		obj.title = Localization.GetTitle(obj.id);
		obj.description = Localization.GetDescription(obj.id);
		obj.cost = 15;
		obj.perkType = (PerkType)6;
		obj.modules = new List<PerkModule> { (PerkModule)(object)new PerkModule_BloodPact() };
		obj.perkCard = LoadSprite("Sprites\\BloodPactCard.png");
		obj.perkFrame = LoadSprite("Sprites\\PerkCard_Frame_Advanced.png");
		return obj;
	}

	private static Sprite LoadSprite(string fileName)
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Expected O, but got Unknown
		//IL_0063: 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)
		string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), fileName);
		if (!File.Exists(text))
		{
			Debug.LogError((object)("[MyModPerks] Image file not found: " + text));
			return null;
		}
		byte[] array = File.ReadAllBytes(text);
		Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
		if (ImageConversion.LoadImage(val, array))
		{
			Sprite obj = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
			((Texture)obj.texture).filterMode = (FilterMode)0;
			return obj;
		}
		return null;
	}
}
[HarmonyPatch(typeof(ENT_Player), "Jump")]
public static class Patch_Jump
{
	[HarmonyPrefix]
	public static void Prefix(ENT_Player __instance, ref float mult)
	{
		if (__instance.HasPerk("mymod_claws_perk"))
		{
			mult *= 0.85f;
		}
	}
}
[HarmonyPatch(typeof(ENT_Player), "GetCurrentGripStrengthTimer")]
public static class Patch_MaxStamina
{
	[HarmonyPostfix]
	public static void Postfix(ENT_Player __instance, ref float __result)
	{
		if (__instance.HasPerk("mymod_claws_perk"))
		{
			__result *= 2f;
		}
	}
}
public static class OnDenizenKilledEvent
{
	public static event Action<Denizen, DamageInfo> OnDenizenKilled;

	internal static void Invoke(Denizen denizen, DamageInfo damageInfo)
	{
		OnDenizenKilledEvent.OnDenizenKilled?.Invoke(denizen, damageInfo);
	}
}
[HarmonyPatch(typeof(Denizen), "Kill")]
public static class Patch_OnDenizenKill
{
	[HarmonyPostfix]
	public static void Postfix(Denizen __instance, string type, DamageInfo info)
	{
		if (((GameEntity)__instance).health <= 0f)
		{
			OnDenizenKilledEvent.Invoke(__instance, info);
		}
	}
}
[HarmonyPatch(typeof(ENV_Barterer), "ScanForItems")]
public static class Patch_ShopDiscount
{
	private static Dictionary<Item_Object, int> originalWorth = new Dictionary<Item_Object, int>();

	private static bool isApplying = false;

	[HarmonyPrefix]
	public static void Prefix(ENV_Barterer __instance)
	{
		if (isApplying)
		{
			return;
		}
		ENT_Player player = ENT_Player.GetPlayer();
		if ((Object)(object)player == (Object)null || !player.HasPerk("mymod_goldenhands_perk"))
		{
			return;
		}
		isApplying = true;
		originalWorth.Clear();
		foreach (Item_Object item in __instance.itemsInZone)
		{
			if ((Object)(object)item != (Object)null && item.itemData != null && item.itemData.HasTag("unpurchased"))
			{
				int worth = item.itemData.worth;
				originalWorth[item] = worth;
				item.itemData.worth = Mathf.RoundToInt((float)worth * 0.8f);
			}
		}
	}

	[HarmonyPostfix]
	public static void Postfix(ENV_Barterer __instance)
	{
		if (!isApplying)
		{
			return;
		}
		isApplying = false;
		foreach (KeyValuePair<Item_Object, int> item in originalWorth)
		{
			if ((Object)(object)item.Key != (Object)null && item.Key.itemData != null)
			{
				item.Key.itemData.worth = item.Value;
			}
		}
		originalWorth.Clear();
	}
}
[HarmonyPatch(typeof(ENT_Player), "Damage")]
public static class Patch_VampiricGrip_Damage
{
	[HarmonyPrefix]
	public static void Prefix(ENT_Player __instance, ref DamageInfo info)
	{
		if (__instance.HasPerk("mymod_vampiricgrip_perk"))
		{
			DamageInfo obj = info;
			obj.amount *= 1.5f;
		}
	}
}
[HarmonyPatch(typeof(HandItem_Melee), "Hit")]
public static class Patch_VampiricGrip_MeleeHit
{
	private static FieldInfo hasHitField = AccessTools.Field(typeof(HandItem_Melee), "hasHit");

	private static FieldInfo hitField = AccessTools.Field(typeof(HandItem_Melee), "hit");

	[HarmonyPrefix]
	public static void Prefix(HandItem_Melee __instance)
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		if (!(bool)hasHitField.GetValue(__instance))
		{
			return;
		}
		ENT_Player player = ENT_Player.GetPlayer();
		if (!((Object)(object)player == (Object)null) && player.HasPerk("mymod_vampiricgrip_perk"))
		{
			RaycastHit val = (RaycastHit)hitField.GetValue(__instance);
			Collider collider = ((RaycastHit)(ref val)).collider;
			Damageable val2 = ((collider != null) ? ((Component)collider).GetComponent<Damageable>() : null);
			if (val2 != null && val2 is Denizen)
			{
				player.AddGripStrength(3f, false, false);
			}
		}
	}
}
public class PerkModule_Accumulation : PerkModule
{
}
public class PerkModule_AdrenalSponges : PerkModule
{
	private float cooldown;

	private const float CooldownDuration = 3f;

	private int stacks = 1;

	public override void AddModule(int amount = 1, bool firstTime = true)
	{
		((PerkModule)this).AddModule(amount, firstTime);
		if (firstTime)
		{
			stacks = amount;
		}
		else
		{
			stacks += amount;
		}
	}

	public override void Update()
	{
		((PerkModule)this).Update();
		if (cooldown > 0f)
		{
			cooldown -= Time.deltaTime;
		}
	}

	public bool CanTrigger()
	{
		return cooldown <= 0f;
	}

	public void Trigger()
	{
		cooldown = 3f;
	}

	public int GetStacks()
	{
		return stacks;
	}
}
public class PerkModule_Berserker : PerkModule
{
}
public class PerkModule_BerserkerVisual : PerkModule
{
	private float vignetteTimer;

	private const float CheckInterval = 0.2f;

	private bool vignetteActive;

	public override void Update()
	{
		((PerkModule)this).Update();
		ENT_Player player = ENT_Player.GetPlayer();
		if ((Object)(object)player == (Object)null || !player.HasPerk("mymod_berserker_perk"))
		{
			return;
		}
		vignetteTimer -= Time.deltaTime;
		if (!(vignetteTimer > 0f))
		{
			vignetteTimer = 0.2f;
			float num = ((GameEntity)player).health / ((GameEntity)player).maxHealth;
			float num2 = Mathf.Clamp01((1f - num) * 0.8f);
			if (num2 > 0.05f)
			{
				CL_UIManager.instance.SetVignette("bloodied", num2);
				CL_UIManager.instance.SetVignetteTarget("bloodied", num2);
				vignetteActive = true;
			}
			else if (vignetteActive)
			{
				CL_UIManager.instance.SetVignetteTarget("bloodied", 0f);
				vignetteActive = false;
			}
		}
	}

	public override void OnDestroy(Perk p)
	{
		if (vignetteActive)
		{
			CL_UIManager.instance.SetVignetteTarget("bloodied", 0f);
		}
		((PerkModule)this).OnDestroy(p);
	}
}
public class PerkModule_BloodPact : PerkModule
{
	private float damageTimer;

	private const float DamageInterval = 60f;

	private const float DamagePerTick = 0.5f;

	private static FieldInfo healTimerField;

	public override void Initialize(Perk p)
	{
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: 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_0081: 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_009c: Expected O, but got Unknown
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Expected O, but got Unknown
		//IL_00ce: Expected O, but got Unknown
		((PerkModule)this).Initialize(p);
		ENT_Player player = ENT_Player.GetPlayer();
		if (!((Object)(object)player == (Object)null))
		{
			if (healTimerField == null)
			{
				healTimerField = AccessTools.Field(typeof(ENT_Player), "healTimer");
			}
			BuffContainer val = new BuffContainer
			{
				id = "mymod_bloodpact_buff",
				desc = "Blood Pact Effects",
				loseOverTime = false,
				multiplier = 1f,
				buffs = new List<Buff>
				{
					new Buff
					{
						id = "addStaminaRegen",
						maxAmount = 0.5f,
						amount = 0f
					},
					new Buff
					{
						id = "addJump",
						maxAmount = 0.25f,
						amount = 0f
					}
				}
			};
			if (((GameEntity)player).curBuffs.GetBuffContainer(val.id) == null)
			{
				((GameEntity)player).curBuffs.AddBuff(val);
			}
		}
	}

	public override void Update()
	{
		((PerkModule)this).Update();
		ENT_Player player = ENT_Player.GetPlayer();
		if ((Object)(object)player == (Object)null || !player.HasPerk("mymod_bloodpact_perk"))
		{
			return;
		}
		if (healTimerField != null)
		{
			healTimerField.SetValue(player, float.MaxValue);
		}
		damageTimer += Time.deltaTime;
		if (damageTimer >= 60f)
		{
			damageTimer = 0f;
			if (((GameEntity)player).health > 1f)
			{
				((GameEntity)player).Damage(DamageInfo.CreateDamageInfo(0.5f, "blood_pact"));
				CL_CameraControl.Shake(0.15f);
				CL_UIManager.instance.SetVignette("bloodied", 0.6f);
				CL_UIManager.instance.SetVignetteTarget("bloodied", 0f);
				player.SplatterScreenBlood(3);
			}
		}
	}

	public override void OnDestroy(Perk p)
	{
		ENT_Player player = ENT_Player.GetPlayer();
		if ((Object)(object)player != (Object)null && ((GameEntity)player).curBuffs != null)
		{
			((GameEntity)player).curBuffs.RemoveBuffContainer("mymod_bloodpact_buff");
		}
		((PerkModule)this).OnDestroy(p);
	}
}
public class PerkModule_CallousedPalms : PerkModule
{
}
public class PerkModule_ChitinousHook : PerkModule
{
}
public class PerkModule_Claws : PerkModule
{
	private BuffContainer clawsBuff;

	public override void Initialize(Perk p)
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: 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)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: 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_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Expected O, but got Unknown
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Expected O, but got Unknown
		//IL_00c3: Expected O, but got Unknown
		((PerkModule)this).Initialize(p);
		ENT_Player player = ENT_Player.GetPlayer();
		if (!((Object)(object)player == (Object)null))
		{
			clawsBuff = new BuffContainer
			{
				id = "mymod_claws_buff",
				desc = "Claws Effect",
				loseOverTime = false,
				loseRate = 0f,
				buffTime = 1f,
				multiplier = 1f,
				buffs = new List<Buff>
				{
					new Buff
					{
						id = "addJump",
						maxAmount = -0.05f,
						amount = 0f
					},
					new Buff
					{
						id = "addSpeed",
						maxAmount = -0.1f,
						amount = 0f
					}
				}
			};
			if (((GameEntity)player).curBuffs.GetBuffContainer(clawsBuff.id) == null)
			{
				((GameEntity)player).curBuffs.AddBuff(clawsBuff);
			}
			else
			{
				((GameEntity)player).curBuffs.GetBuffContainer(clawsBuff.id).SetMultiplier(1f);
			}
		}
	}

	public override void OnDestroy(Perk p)
	{
		ENT_Player player = ENT_Player.GetPlayer();
		if ((Object)(object)player != (Object)null && ((GameEntity)player).curBuffs != null)
		{
			((GameEntity)player).curBuffs.RemoveBuffContainer(clawsBuff.id);
		}
		((PerkModule)this).OnDestroy(p);
	}
}
public class PerkModule_Dash : PerkModule
{
	private float dashCooldown;

	private const float DashPower = 10f;

	private const float DashCooldownDuration = 2f;

	private const float StaminaCost = 0.5f;

	public override void Update()
	{
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		((PerkModule)this).Update();
		ENT_Player player = ENT_Player.GetPlayer();
		if ((Object)(object)player == (Object)null || player.IsMoveLocked() || player.isFrozen())
		{
			return;
		}
		if (dashCooldown > 0f)
		{
			dashCooldown -= Time.deltaTime;
		}
		if (!player.IsGrounded(false) && InputManager.GetButton("Sprint").Down && dashCooldown <= 0f)
		{
			float currentGripStrengthTimer = player.GetCurrentGripStrengthTimer(-1);
			if (player.GetAverageGripStrength(false) >= currentGripStrengthTimer * 0.5f)
			{
				player.DamageGripStrength(currentGripStrengthTimer * 0.5f, false);
				Vector3 forward = ((Component)player.cam).transform.forward;
				((GameEntity)player).AddForce(forward * 10f, "dash");
				dashCooldown = 2f;
			}
		}
	}
}
public class PerkModule_GoldenHands : PerkModule
{
}
public class PerkModule_KillResist : PerkModule
{
	private BuffContainer resistBuff;

	private float currentResist;

	private const float MaxResist = 0.5f;

	private const float ResistPerKill = 0.15f;

	private const float BuffDuration = 5f;

	public override void Initialize(Perk p)
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: 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)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: 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_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Expected O, but got Unknown
		//IL_0097: Expected O, but got Unknown
		((PerkModule)this).Initialize(p);
		ENT_Player player = ENT_Player.GetPlayer();
		if (!((Object)(object)player == (Object)null))
		{
			resistBuff = new BuffContainer
			{
				id = "mymod_killresist_buff",
				desc = "Damage Resistance on Kill",
				loseOverTime = true,
				loseRate = 0.2f,
				buffTime = 5f,
				multiplier = 0f,
				buffs = new List<Buff>
				{
					new Buff
					{
						id = "damageResist",
						maxAmount = 1f,
						amount = 0f
					}
				}
			};
			if (((GameEntity)player).curBuffs.GetBuffContainer(resistBuff.id) == null)
			{
				((GameEntity)player).curBuffs.AddBuff(resistBuff);
			}
			OnDenizenKilledEvent.OnDenizenKilled += OnDenizenKilled;
		}
	}

	private void OnDenizenKilled(Denizen denizen, DamageInfo damageInfo)
	{
		ENT_Player player = ENT_Player.GetPlayer();
		if (!((Object)(object)player == (Object)null) && player.HasPerk("mymod_killresist_perk") && !((Object)(object)damageInfo.sourceEntity != (Object)(object)player) && !(((GameEntity)denizen).health > 0f))
		{
			BuffContainer buffContainer = ((GameEntity)player).curBuffs.GetBuffContainer(resistBuff.id);
			if (buffContainer != null)
			{
				currentResist = Mathf.Min(currentResist + 0.15f, 0.5f);
				buffContainer.SetMultiplier(currentResist);
				buffContainer.buffTime = 5f;
				buffContainer.loseOverTime = true;
			}
		}
	}

	public override void OnDestroy(Perk p)
	{
		OnDenizenKilledEvent.OnDenizenKilled -= OnDenizenKilled;
		ENT_Player player = ENT_Player.GetPlayer();
		if ((Object)(object)player != (Object)null && ((GameEntity)player).curBuffs != null)
		{
			((GameEntity)player).curBuffs.RemoveBuffContainer(resistBuff.id);
		}
		((PerkModule)this).OnDestroy(p);
	}
}
public class PerkModule_PhotosyntheticSkin : PerkModule
{
	private BuffContainer lightBuff;

	private BuffContainer darkBuff;

	private float checkTimer;

	private const float CheckInterval = 1f;

	private bool isLight;

	private float particleTimer;

	private const float ParticleInterval = 0.5f;

	private ParticleSystem particleSystem;

	private GameObject particleObject;

	public override void Initialize(Perk p)
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: 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)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: 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_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Expected O, but got Unknown
		//IL_0097: Expected O, but got Unknown
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Expected O, but got Unknown
		//IL_0117: Expected O, but got Unknown
		((PerkModule)this).Initialize(p);
		ENT_Player player = ENT_Player.GetPlayer();
		if (!((Object)(object)player == (Object)null))
		{
			lightBuff = new BuffContainer
			{
				id = "mymod_photosynthesis_light",
				desc = "Light Regen",
				loseOverTime = false,
				loseRate = 0f,
				buffTime = 1f,
				multiplier = 0f,
				buffs = new List<Buff>
				{
					new Buff
					{
						id = "addStaminaRegen",
						maxAmount = 1f,
						amount = 0f
					}
				}
			};
			darkBuff = new BuffContainer
			{
				id = "mymod_photosynthesis_dark",
				desc = "Dark Regen Penalty",
				loseOverTime = false,
				loseRate = 0f,
				buffTime = 1f,
				multiplier = 0f,
				buffs = new List<Buff>
				{
					new Buff
					{
						id = "addStaminaRegen",
						maxAmount = -0.45f,
						amount = 0f
					}
				}
			};
			if (((GameEntity)player).curBuffs.GetBuffContainer(lightBuff.id) == null)
			{
				((GameEntity)player).curBuffs.AddBuff(lightBuff);
			}
			if (((GameEntity)player).curBuffs.GetBuffContainer(darkBuff.id) == null)
			{
				((GameEntity)player).curBuffs.AddBuff(darkBuff);
			}
			SetLightState(light: false);
			CreateParticleSystem(player);
		}
	}

	private void CreateParticleSystem(ENT_Player player)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Expected O, but got Unknown
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Expected O, but got Unknown
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Expected O, but got Unknown
		//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_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_015c: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: 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_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_0208: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0217: Unknown result type (might be due to invalid IL or missing references)
		//IL_021e: Expected O, but got Unknown
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_0246: Unknown result type (might be due to invalid IL or missing references)
		//IL_025c: 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_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0282: Unknown result type (might be due to invalid IL or missing references)
		//IL_0287: Unknown result type (might be due to invalid IL or missing references)
		//IL_0298: Unknown result type (might be due to invalid IL or missing references)
		//IL_029d: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Expected O, but got Unknown
		if ((Object)(object)player == (Object)null)
		{
			return;
		}
		particleObject = new GameObject("Photosynthesis_Particles");
		particleObject.transform.SetParent(((Component)player).transform);
		particleObject.transform.localPosition = Vector3.up * 0.8f;
		particleSystem = particleObject.AddComponent<ParticleSystem>();
		ParticleSystemRenderer component = particleObject.GetComponent<ParticleSystemRenderer>();
		if ((Object)(object)player.jumpBoostEffect != (Object)null)
		{
			ParticleSystemRenderer component2 = ((Component)player.jumpBoostEffect).GetComponent<ParticleSystemRenderer>();
			if ((Object)(object)component2 != (Object)null && (Object)(object)((Renderer)component2).material != (Object)null)
			{
				((Renderer)component).material = ((Renderer)component2).material;
			}
			else
			{
				((Renderer)component).material = new Material(Shader.Find("Sprites/Default"));
			}
		}
		else if ((Object)(object)player.bloodEffect != (Object)null)
		{
			ParticleSystemRenderer component3 = ((Component)player.bloodEffect).GetComponent<ParticleSystemRenderer>();
			if ((Object)(object)component3 != (Object)null && (Object)(object)((Renderer)component3).material != (Object)null)
			{
				((Renderer)component).material = ((Renderer)component3).material;
			}
			else
			{
				((Renderer)component).material = new Material(Shader.Find("Sprites/Default"));
			}
		}
		else
		{
			((Renderer)component).material = new Material(Shader.Find("Sprites/Default"));
		}
		MainModule main = particleSystem.main;
		((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(1.5f);
		((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0.3f);
		((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.08f);
		((MainModule)(ref main)).maxParticles = 20;
		((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.4f, 1f, 0.4f, 0.8f));
		((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.1f);
		((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
		((MainModule)(ref main)).loop = false;
		((MainModule)(ref main)).playOnAwake = false;
		EmissionModule emission = particleSystem.emission;
		((EmissionModule)(ref emission)).enabled = false;
		ShapeModule shape = particleSystem.shape;
		((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
		((ShapeModule)(ref shape)).radius = 0.4f;
		ColorOverLifetimeModule colorOverLifetime = particleSystem.colorOverLifetime;
		((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
		Gradient val = new Gradient();
		val.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
		{
			new GradientColorKey(new Color(0.4f, 1f, 0.4f), 0f),
			new GradientColorKey(new Color(0.4f, 1f, 0.4f), 1f)
		}, (GradientAlphaKey[])(object)new GradientAlphaKey[2]
		{
			new GradientAlphaKey(0.8f, 0f),
			new GradientAlphaKey(0f, 1f)
		});
		((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val);
	}

	public override void Update()
	{
		((PerkModule)this).Update();
		ENT_Player player = ENT_Player.GetPlayer();
		if ((Object)(object)player == (Object)null)
		{
			return;
		}
		checkTimer -= Time.deltaTime;
		if (checkTimer <= 0f)
		{
			checkTimer = 1f;
			bool flag = IsPlayerInLight(player);
			if (flag != isLight)
			{
				isLight = flag;
				SetLightState(isLight);
			}
		}
		if (isLight && (Object)(object)particleSystem != (Object)null)
		{
			particleTimer -= Time.deltaTime;
			if (particleTimer <= 0f)
			{
				particleTimer = 0.5f;
				particleSystem.Emit(5);
			}
		}
	}

	private void SetLightState(bool light)
	{
		if (light)
		{
			lightBuff.SetMultiplier(1f);
			darkBuff.SetMultiplier(0f);
		}
		else
		{
			lightBuff.SetMultiplier(0f);
			darkBuff.SetMultiplier(1f);
		}
	}

	private bool IsPlayerInLight(ENT_Player player)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		Vector3 position = ((Component)player).transform.position;
		if (!Physics.Raycast(position + Vector3.up * 0.5f, Vector3.up, 100f, -1))
		{
			return true;
		}
		List<CL_Lamp> effectorsOfPosition = CL_Lamp.GetEffectorsOfPosition(position);
		if (effectorsOfPosition != null)
		{
			foreach (CL_Lamp item in effectorsOfPosition)
			{
				if (Vector3.Distance(position, ((Component)item).transform.position) < 10f)
				{
					return true;
				}
			}
		}
		Light[] array = Object.FindObjectsOfType<Light>();
		foreach (Light val in array)
		{
			if (((Behaviour)val).enabled && Vector3.Distance(position, ((Component)val).transform.position) < 10f && val.intensity > 0.3f)
			{
				return true;
			}
		}
		return false;
	}

	public override void OnDestroy(Perk p)
	{
		ENT_Player player = ENT_Player.GetPlayer();
		if ((Object)(object)player != (Object)null && ((GameEntity)player).curBuffs != null)
		{
			((GameEntity)player).curBuffs.RemoveBuffContainer(lightBuff.id);
			((GameEntity)player).curBuffs.RemoveBuffContainer(darkBuff.id);
		}
		if ((Object)(object)particleObject != (Object)null)
		{
			Object.Destroy((Object)(object)particleObject);
		}
		((PerkModule)this).OnDestroy(p);
	}
}
public class PerkModule_Serenity : PerkModule
{
	private BuffContainer serenityBuff;

	public override void Initialize(Perk p)
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: 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)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: 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_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Expected O, but got Unknown
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Expected O, but got Unknown
		//IL_00c3: Expected O, but got Unknown
		((PerkModule)this).Initialize(p);
		ENT_Player player = ENT_Player.GetPlayer();
		if (!((Object)(object)player == (Object)null))
		{
			serenityBuff = new BuffContainer
			{
				id = "mymod_serenity_buff",
				desc = "Serenity Regen Boost",
				loseOverTime = false,
				loseRate = 0f,
				buffTime = 1f,
				multiplier = 0f,
				buffs = new List<Buff>
				{
					new Buff
					{
						id = "addStaminaRegen",
						maxAmount = 1f,
						amount = 0f
					},
					new Buff
					{
						id = "healingRate",
						maxAmount = 0.15f,
						amount = 0f
					}
				}
			};
			if (((GameEntity)player).curBuffs.GetBuffContainer(serenityBuff.id) == null)
			{
				((GameEntity)player).curBuffs.AddBuff(serenityBuff);
			}
		}
	}

	public override void Update()
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		((PerkModule)this).Update();
		ENT_Player player = ENT_Player.GetPlayer();
		if (!((Object)(object)player == (Object)null))
		{
			int num;
			if (player.IsGrounded(false) && !player.IsHanging())
			{
				Vector3 velocity = player.cCon.velocity;
				num = ((((Vector3)(ref velocity)).magnitude < 0.1f) ? 1 : 0);
			}
			else
			{
				num = 0;
			}
			bool flag = (byte)num != 0;
			BuffContainer buffContainer = ((GameEntity)player).curBuffs.GetBuffContainer(serenityBuff.id);
			if (buffContainer != null)
			{
				buffContainer.SetMultiplier(flag ? 1f : 0f);
			}
		}
	}

	public override void OnDestroy(Perk p)
	{
		ENT_Player player = ENT_Player.GetPlayer();
		if ((Object)(object)player != (Object)null && ((GameEntity)player).curBuffs != null)
		{
			((GameEntity)player).curBuffs.RemoveBuffContainer(serenityBuff.id);
		}
		((PerkModule)this).OnDestroy(p);
	}
}
public class PerkModule_SlipperyLuck : PerkModule
{
	private BuffContainer perfectGripBuff;

	private BuffContainer perfectJumpBuff;

	private float gripTimer;

	private float jumpTimer;

	private const float Duration = 5f;

	private bool gripActive;

	private bool jumpActive;

	public override void Initialize(Perk p)
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: 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)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Expected O, but got Unknown
		//IL_0081: Expected O, but got Unknown
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Expected O, but got Unknown
		//IL_00eb: Expected O, but got Unknown
		((PerkModule)this).Initialize(p);
		ENT_Player player = ENT_Player.GetPlayer();
		if (!((Object)(object)player == (Object)null))
		{
			perfectGripBuff = new BuffContainer
			{
				id = "mymod_slipperyluck_grip",
				desc = "Perfect Grip",
				loseOverTime = false,
				multiplier = 0f,
				buffs = new List<Buff>
				{
					new Buff
					{
						id = "addGripStrength",
						maxAmount = 999f,
						amount = 0f
					}
				}
			};
			perfectJumpBuff = new BuffContainer
			{
				id = "mymod_slipperyluck_jump",
				desc = "Perfect Jump Boost",
				loseOverTime = false,
				multiplier = 0f,
				buffs = new List<Buff>
				{
					new Buff
					{
						id = "addJump",
						maxAmount = 0.5f,
						amount = 0f
					}
				}
			};
			if (((GameEntity)player).curBuffs.GetBuffContainer(perfectGripBuff.id) == null)
			{
				((GameEntity)player).curBuffs.AddBuff(perfectGripBuff);
			}
			if (((GameEntity)player).curBuffs.GetBuffContainer(perfectJumpBuff.id) == null)
			{
				((GameEntity)player).curBuffs.AddBuff(perfectJumpBuff);
			}
			ENT_Player player2 = ENT_Player.GetPlayer();
			player2._OnHandGrab = (Action<Hand>)Delegate.Combine(player2._OnHandGrab, new Action<Hand>(OnHandGrab));
		}
	}

	private void OnHandGrab(Hand hand)
	{
		ENT_Player player = ENT_Player.GetPlayer();
		if ((Object)(object)player == (Object)null || !player.HasPerk("mymod_slipperyluck_perk"))
		{
			return;
		}
		if (Random.value < 0.25f)
		{
			BuffContainer buffContainer = ((GameEntity)player).curBuffs.GetBuffContainer(perfectGripBuff.id);
			if (buffContainer != null)
			{
				buffContainer.SetMultiplier(1f);
				gripActive = true;
				gripTimer = 5f;
			}
			BuffContainer buffContainer2 = ((GameEntity)player).curBuffs.GetBuffContainer(perfectJumpBuff.id);
			if (buffContainer2 != null)
			{
				buffContainer2.SetMultiplier(1f);
				jumpActive = true;
				jumpTimer = 5f;
			}
			Debug.Log((object)"Perfect Grip!");
		}
		else if (Random.value < 0.05f)
		{
			hand.SetGripStrength(0f);
			player.StopInteraction(hand.id, "drop", true);
			Debug.Log((object)"Betrayal!");
		}
	}

	public override void Update()
	{
		((PerkModule)this).Update();
		ENT_Player player = ENT_Player.GetPlayer();
		if ((Object)(object)player == (Object)null)
		{
			return;
		}
		if (gripActive)
		{
			gripTimer -= Time.deltaTime;
			if (gripTimer <= 0f)
			{
				BuffContainer buffContainer = ((GameEntity)player).curBuffs.GetBuffContainer(perfectGripBuff.id);
				if (buffContainer != null)
				{
					buffContainer.SetMultiplier(0f);
				}
				gripActive = false;
			}
		}
		if (!jumpActive)
		{
			return;
		}
		jumpTimer -= Time.deltaTime;
		if (jumpTimer <= 0f)
		{
			BuffContainer buffContainer2 = ((GameEntity)player).curBuffs.GetBuffContainer(perfectJumpBuff.id);
			if (buffContainer2 != null)
			{
				buffContainer2.SetMultiplier(0f);
			}
			jumpActive = false;
		}
	}

	public override void OnDestroy(Perk p)
	{
		ENT_Player player = ENT_Player.GetPlayer();
		if ((Object)(object)player != (Object)null)
		{
			player._OnHandGrab = (Action<Hand>)Delegate.Remove(player._OnHandGrab, new Action<Hand>(OnHandGrab));
			if (((GameEntity)player).curBuffs != null)
			{
				((GameEntity)player).curBuffs.RemoveBuffContainer(perfectGripBuff.id);
				((GameEntity)player).curBuffs.RemoveBuffContainer(perfectJumpBuff.id);
			}
		}
		((PerkModule)this).OnDestroy(p);
	}
}
public class PerkModule_VampiricGrip : PerkModule
{
}
[BepInPlugin("com.mymod.perkmod", "MyMod Perk Mod", "1.1.0")]
public class Plugin : BaseUnityPlugin
{
	public static ConfigEntry<string> LanguageConfig;

	private void Awake()
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		LanguageConfig = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Language", "Russian", "Выберите язык описаний перков / Choose perk descriptions language: Russian / English");
		try
		{
			new Harmony("com.mymod.perkmod").PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"MyMod Perk Mod loaded successfully!");
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("PATCH FAILED: " + ex.Message));
			((BaseUnityPlugin)this).Logger.LogError((object)("STACK: " + ex.StackTrace));
			if (ex.InnerException != null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("INNER: " + ex.InnerException.Message));
			}
		}
	}

	public static string GetCurrentLanguage()
	{
		return LanguageConfig?.Value ?? "Russian";
	}
}