Decompiled source of RacesOfValheim v1.1.1

RacesOfValheim.dll

Decompiled 11 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Jotunn;
using Jotunn.Entities;
using Jotunn.Managers;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RacesOfValheim")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RacesOfValheim")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace RacesOfValheim;

public static class BossProgressionManager
{
	public static int DebugState = -1;

	public const string Eikthyr = "defeated_eikthyr";

	public const string TheElder = "defeated_gdking";

	public const string Bonemass = "defeated_bonemass";

	public const string Moder = "defeated_dragon";

	public const string Yagluth = "defeated_goblinking";

	public const string TheQueen = "defeated_queen";

	public const string Fader = "defeated_fader";

	public static int GetCurrentProgressionState()
	{
		if (DebugState != -1)
		{
			return DebugState;
		}
		if ((Object)(object)ZoneSystem.instance == (Object)null)
		{
			return 1;
		}
		if (ZoneSystem.instance.GetGlobalKey("defeated_fader"))
		{
			return 8;
		}
		if (ZoneSystem.instance.GetGlobalKey("defeated_queen"))
		{
			return 7;
		}
		if (ZoneSystem.instance.GetGlobalKey("defeated_goblinking"))
		{
			return 6;
		}
		if (ZoneSystem.instance.GetGlobalKey("defeated_dragon"))
		{
			return 5;
		}
		if (ZoneSystem.instance.GetGlobalKey("defeated_bonemass"))
		{
			return 4;
		}
		if (ZoneSystem.instance.GetGlobalKey("defeated_gdking"))
		{
			return 3;
		}
		if (ZoneSystem.instance.GetGlobalKey("defeated_eikthyr"))
		{
			return 2;
		}
		return 1;
	}
}
public class FenrirFormBehavior : MonoBehaviour
{
	private Animator playerAnim;

	private Animator fenrirAnim;

	private bool isAttacking = false;

	private void Start()
	{
		playerAnim = ((Component)((Component)Player.m_localPlayer).transform.Find("Visual")).GetComponent<Animator>();
		fenrirAnim = ((Component)this).GetComponent<Animator>();
		if ((Object)(object)fenrirAnim == (Object)null)
		{
			fenrirAnim = ((Component)this).GetComponentInChildren<Animator>();
		}
	}

	private void Update()
	{
		if ((Object)(object)playerAnim == (Object)null || (Object)(object)fenrirAnim == (Object)null || isAttacking)
		{
			return;
		}
		bool flag = playerAnim.GetBool("onGround");
		fenrirAnim.SetBool("onGround", flag);
		fenrirAnim.SetBool("inWater", playerAnim.GetBool("inWater"));
		if (!flag)
		{
			fenrirAnim.SetFloat("forward_speed", 0f);
			fenrirAnim.SetFloat("sideway_speed", 0f);
		}
		else if (((Character)Player.m_localPlayer).IsCrouching())
		{
			fenrirAnim.SetFloat("forward_speed", 0f);
			fenrirAnim.SetFloat("sideway_speed", 0f);
		}
		else
		{
			fenrirAnim.SetFloat("forward_speed", playerAnim.GetFloat("forward_speed"));
			fenrirAnim.SetFloat("sideway_speed", playerAnim.GetFloat("sideway_speed"));
		}
		if (flag)
		{
			if (Input.GetKeyDown((KeyCode)111))
			{
				((MonoBehaviour)this).StartCoroutine(HowlRoutine());
			}
			else if (Input.GetMouseButtonDown(1))
			{
				((MonoBehaviour)this).StartCoroutine(ClawRoutine("attack_claw1", 110f, 1.2f, 0.5f));
			}
			else if (Input.GetMouseButtonDown(0))
			{
				((MonoBehaviour)this).StartCoroutine(ClawRoutine("attack_claw0", 60f, 1f, 0.4f));
			}
			else if (Input.GetMouseButtonDown(2))
			{
				((MonoBehaviour)this).StartCoroutine(JumpAttackRoutine());
			}
		}
	}

	private void PlaySFX(params string[] prefabNames)
	{
		//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)
		foreach (string text in prefabNames)
		{
			GameObject prefab = Cache.GetPrefab<GameObject>(text);
			if ((Object)(object)prefab != (Object)null)
			{
				Object.Instantiate<GameObject>(prefab, ((Component)Player.m_localPlayer).transform.position, Quaternion.identity);
				return;
			}
		}
		Logger.LogWarning((object)("[FenrirForm] Nessun suono trovato tra: " + string.Join(", ", prefabNames)));
	}

	private IEnumerator HowlRoutine()
	{
		isAttacking = true;
		fenrirAnim.SetFloat("forward_speed", 0f);
		fenrirAnim.SetFloat("sideway_speed", 0f);
		fenrirAnim.SetTrigger("attack_taunt");
		PlaySFX("sfx_wolf_howl", "sfx_wolf_alert", "sfx_fenring_idle");
		yield return (object)new WaitForSeconds(2f);
		isAttacking = false;
	}

	private IEnumerator ClawRoutine(string triggerName, float baseDamage, float lockDuration, float dmgDelay)
	{
		isAttacking = true;
		fenrirAnim.SetFloat("forward_speed", 0f);
		fenrirAnim.SetFloat("sideway_speed", 0f);
		fenrirAnim.SetTrigger(triggerName);
		PlaySFX("sfx_fenring_attack", "sfx_fenring_attack_claw", "sfx_wolf_attack");
		yield return (object)new WaitForSeconds(dmgDelay);
		if ((Object)(object)ZNetScene.instance != (Object)null)
		{
			GameObject attackSfx = ZNetScene.instance.GetPrefab("sfx_fenring_attack");
			if ((Object)(object)attackSfx != (Object)null)
			{
				Object.Instantiate<GameObject>(attackSfx, ((Component)Player.m_localPlayer).transform.position, Quaternion.identity);
			}
		}
		ExecuteClawDamage(baseDamage);
		float remainingTimeToIdle = lockDuration - dmgDelay;
		if (remainingTimeToIdle > 0f)
		{
			yield return (object)new WaitForSeconds(remainingTimeToIdle);
		}
		fenrirAnim.ResetTrigger(triggerName);
		isAttacking = false;
	}

	private IEnumerator JumpAttackRoutine()
	{
		isAttacking = true;
		fenrirAnim.SetFloat("forward_speed", 0f);
		fenrirAnim.SetFloat("sideway_speed", 0f);
		fenrirAnim.SetTrigger("attack_jump");
		yield return (object)new WaitForSeconds(0.75f);
		if ((Object)(object)ZNetScene.instance != (Object)null)
		{
			GameObject attackSfx = ZNetScene.instance.GetPrefab("sfx_fenring_attack");
			if ((Object)(object)attackSfx != (Object)null)
			{
				Object.Instantiate<GameObject>(attackSfx, ((Component)Player.m_localPlayer).transform.position, Quaternion.identity);
			}
		}
		float dashDuration = 0.2f;
		float elapsedDash = 0f;
		while (elapsedDash < dashDuration)
		{
			if ((Object)(object)Player.m_localPlayer != (Object)null)
			{
				Rigidbody rb = ((Component)Player.m_localPlayer).GetComponent<Rigidbody>();
				if ((Object)(object)rb != (Object)null)
				{
					Vector3 dashVelocity = ((Component)Player.m_localPlayer).transform.forward * 31.5f;
					if (elapsedDash < dashDuration / 2f)
					{
						dashVelocity += Vector3.up * 13.1f;
					}
					rb.MovePosition(rb.position + dashVelocity * Time.fixedDeltaTime);
				}
			}
			elapsedDash += Time.fixedDeltaTime;
			yield return (object)new WaitForFixedUpdate();
		}
		ExecuteClawDamage(95f);
		yield return (object)new WaitForSeconds(0.55f);
		fenrirAnim.ResetTrigger("attack_jump");
		isAttacking = false;
	}

	private void ExecuteClawDamage(float baseDamage)
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: 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)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: 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_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_020f: Unknown result type (might be due to invalid IL or missing references)
		//IL_021b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0220: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0251: Unknown result type (might be due to invalid IL or missing references)
		//IL_0253: Unknown result type (might be due to invalid IL or missing references)
		//IL_0255: Unknown result type (might be due to invalid IL or missing references)
		//IL_0296: Unknown result type (might be due to invalid IL or missing references)
		//IL_029d: Expected O, but got Unknown
		//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02da: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Player.m_localPlayer == (Object)null)
		{
			return;
		}
		Vector3 position = ((Component)Player.m_localPlayer).transform.position;
		Vector3 val = position + ((Component)Player.m_localPlayer).transform.forward * 1.5f + Vector3.up * 1f;
		float num = 2.5f;
		float skillLevel = ((Character)Player.m_localPlayer).GetSkillLevel((SkillType)11);
		float slash = baseDamage + skillLevel;
		int mask = LayerMask.GetMask(new string[12]
		{
			"Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "character", "character_net", "character_ghost", "hitbox",
			"character_noenv", "vehicle"
		});
		Collider[] array = Physics.OverlapSphere(val, num, mask);
		HashSet<GameObject> hashSet = new HashSet<GameObject>();
		Collider[] array2 = array;
		RaycastHit val7 = default(RaycastHit);
		foreach (Collider val2 in array2)
		{
			if ((Object)(object)((Component)val2).gameObject == (Object)(object)((Component)Player.m_localPlayer).gameObject || ((Object)(object)val2.attachedRigidbody != (Object)null && (Object)(object)((Component)val2.attachedRigidbody).gameObject == (Object)(object)((Component)Player.m_localPlayer).gameObject))
			{
				continue;
			}
			IDestructible componentInParent = ((Component)val2).GetComponentInParent<IDestructible>();
			if (componentInParent == null)
			{
				continue;
			}
			Character val3 = (Character)(object)((componentInParent is Character) ? componentInParent : null);
			if ((Object)(object)val3 != (Object)null && (Object)(object)val3 == (Object)(object)Player.m_localPlayer)
			{
				continue;
			}
			IDestructible obj = ((componentInParent is MonoBehaviour) ? componentInParent : null);
			GameObject val4 = ((obj != null) ? ((Component)obj).gameObject : null);
			if ((Object)(object)val4 != (Object)null)
			{
				if (hashSet.Contains(val4))
				{
					continue;
				}
				hashSet.Add(val4);
			}
			Bounds bounds = val2.bounds;
			Vector3 center = ((Bounds)(ref bounds)).center;
			Vector3 val5 = center - position;
			Vector3 normalized = ((Vector3)(ref val5)).normalized;
			float num2 = Vector3.Angle(((Component)Player.m_localPlayer).transform.forward, normalized);
			if (num2 < 70f)
			{
				Vector3 val6 = position + Vector3.up * 1.5f;
				if (!Physics.Linecast(val6, center, ref val7, LayerMask.GetMask(new string[4] { "Default", "static_solid", "terrain", "piece" })))
				{
					HitData val8 = new HitData();
					val8.m_damage.m_slash = slash;
					val8.m_pushForce = 30f;
					val8.m_point = center;
					val8.m_dir = ((Component)Player.m_localPlayer).transform.forward;
					val8.m_skill = (SkillType)11;
					val8.m_dodgeable = true;
					val8.m_blockable = true;
					val8.m_hitType = (HitType)2;
					val8.m_toolTier = 0;
					val8.SetAttacker((Character)(object)Player.m_localPlayer);
					componentInParent.Damage(val8);
				}
			}
		}
	}
}
public class CultistFormBehavior : MonoBehaviour
{
	private Animator playerAnim;

	private Animator cultistAnim;

	private bool isAttacking = false;

	private bool isShootingFire = false;

	private float fireTimer = 0f;

	private GameObject fireEffectInstance;

	private void Start()
	{
		playerAnim = ((Component)((Component)Player.m_localPlayer).transform.Find("Visual")).GetComponent<Animator>();
		cultistAnim = ((Component)this).GetComponent<Animator>();
		if ((Object)(object)cultistAnim == (Object)null)
		{
			cultistAnim = ((Component)this).GetComponentInChildren<Animator>();
		}
	}

	private void Update()
	{
		if ((Object)(object)playerAnim == (Object)null || (Object)(object)cultistAnim == (Object)null || isAttacking)
		{
			return;
		}
		bool flag = playerAnim.GetBool("onGround");
		cultistAnim.SetBool("onGround", flag);
		cultistAnim.SetBool("inWater", playerAnim.GetBool("inWater"));
		if (!flag)
		{
			cultistAnim.SetFloat("forward_speed", 0f);
			cultistAnim.SetFloat("sideway_speed", 0f);
		}
		else if (((Character)Player.m_localPlayer).IsCrouching())
		{
			cultistAnim.SetFloat("forward_speed", 0f);
			cultistAnim.SetFloat("sideway_speed", 0f);
		}
		else
		{
			cultistAnim.SetFloat("forward_speed", playerAnim.GetFloat("forward_speed"));
			cultistAnim.SetFloat("sideway_speed", playerAnim.GetFloat("sideway_speed"));
		}
		if (flag)
		{
			if (Input.GetMouseButton(1))
			{
				if (Player.m_localPlayer.GetEitr() > 0f)
				{
					if (!isShootingFire)
					{
						StartFire();
					}
					else
					{
						UpdateFire();
					}
				}
				else if (isShootingFire)
				{
					StopFire();
				}
			}
			else if (isShootingFire)
			{
				StopFire();
			}
			if (Input.GetKeyDown((KeyCode)111))
			{
				((MonoBehaviour)this).StartCoroutine(HowlRoutine());
			}
			if (Input.GetMouseButtonDown(0) && !isShootingFire)
			{
				((MonoBehaviour)this).StartCoroutine(ClawRoutine());
			}
			else if (Input.GetMouseButtonDown(2) && !isShootingFire)
			{
				((MonoBehaviour)this).StartCoroutine(DoubleClawRoutine());
			}
		}
		else if (isShootingFire)
		{
			StopFire();
		}
	}

	private void PlaySFX(params string[] prefabNames)
	{
		//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)
		foreach (string text in prefabNames)
		{
			GameObject prefab = Cache.GetPrefab<GameObject>(text);
			if ((Object)(object)prefab != (Object)null)
			{
				Object.Instantiate<GameObject>(prefab, ((Component)Player.m_localPlayer).transform.position, Quaternion.identity);
				return;
			}
		}
		Logger.LogWarning((object)("[CultistForm] Nessun suono trovato tra: " + string.Join(", ", prefabNames)));
	}

	private IEnumerator HowlRoutine()
	{
		isAttacking = true;
		cultistAnim.SetFloat("forward_speed", 0f);
		cultistAnim.SetFloat("sideway_speed", 0f);
		cultistAnim.SetTrigger("attack_taunt");
		PlaySFX("sfx_wolf_howl", "sfx_wolf_alert", "sfx_fenring_idle");
		yield return (object)new WaitForSeconds(2f);
		isAttacking = false;
	}

	private void StartFire()
	{
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: 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_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: 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_0150: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Player.m_localPlayer == (Object)null || isShootingFire)
		{
			return;
		}
		isShootingFire = true;
		cultistAnim.SetFloat("forward_speed", 0f);
		cultistAnim.SetFloat("sideway_speed", 0f);
		cultistAnim.SetBool("attack_fire", true);
		PlaySFX("sfx_cultist_attack_fire_start");
		cultistAnim.SetTrigger("attack_flames");
		if (!((Object)(object)ZNetScene.instance != (Object)null) || !((Object)(object)fireEffectInstance == (Object)null))
		{
			return;
		}
		GameObject prefab = ZNetScene.instance.GetPrefab("fx_fenring_flames");
		if ((Object)(object)prefab != (Object)null)
		{
			fireEffectInstance = Object.Instantiate<GameObject>(prefab, ((Component)Player.m_localPlayer).transform.position + Vector3.up * 1.5f + ((Component)Player.m_localPlayer).transform.forward, ((Component)Player.m_localPlayer).transform.rotation, ((Component)Player.m_localPlayer).transform);
			ParticleSystem[] componentsInChildren = fireEffectInstance.GetComponentsInChildren<ParticleSystem>();
			ParticleSystem[] array = componentsInChildren;
			foreach (ParticleSystem val in array)
			{
				MainModule main = val.main;
				((MainModule)(ref main)).startLifetimeMultiplier = ((MainModule)(ref main)).startLifetimeMultiplier * 1.2f;
			}
		}
	}

	private void UpdateFire()
	{
		((Character)Player.m_localPlayer).UseEitr(12.5f * Time.deltaTime);
		cultistAnim.SetFloat("forward_speed", 0f);
		cultistAnim.SetFloat("sideway_speed", 0f);
		fireTimer += Time.deltaTime;
		if (fireTimer >= 0.2f)
		{
			fireTimer = 0f;
			ExecuteFireDamage();
		}
	}

	private void StopFire()
	{
		isShootingFire = false;
		cultistAnim.ResetTrigger("attack_flames");
		if ((Object)(object)fireEffectInstance != (Object)null)
		{
			Object.Destroy((Object)(object)fireEffectInstance);
			fireEffectInstance = null;
		}
	}

	private void ExecuteFireDamage()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: 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)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: 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_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: 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_01fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: Unknown result type (might be due to invalid IL or missing references)
		//IL_020e: Unknown result type (might be due to invalid IL or missing references)
		//IL_020f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		//IL_0218: Unknown result type (might be due to invalid IL or missing references)
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: Unknown result type (might be due to invalid IL or missing references)
		//IL_024a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0251: Expected O, but got Unknown
		//IL_0261: Unknown result type (might be due to invalid IL or missing references)
		//IL_0263: Unknown result type (might be due to invalid IL or missing references)
		//IL_0274: Unknown result type (might be due to invalid IL or missing references)
		//IL_0279: 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_029a: 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_02eb: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Player.m_localPlayer == (Object)null)
		{
			return;
		}
		Vector3 position = ((Component)Player.m_localPlayer).transform.position;
		Vector3 val = position + ((Component)Player.m_localPlayer).transform.forward * 2.5f + Vector3.up * 1f;
		float num = 3f;
		float skillLevel = ((Character)Player.m_localPlayer).GetSkillLevel((SkillType)9);
		float num2 = 20f;
		float fire = num2 + skillLevel * 0.5f;
		int mask = LayerMask.GetMask(new string[12]
		{
			"Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "character", "character_net", "character_ghost", "hitbox",
			"character_noenv", "vehicle"
		});
		Collider[] array = Physics.OverlapSphere(val, num, mask);
		HashSet<GameObject> hashSet = new HashSet<GameObject>();
		Collider[] array2 = array;
		foreach (Collider val2 in array2)
		{
			if ((Object)(object)((Component)val2).gameObject == (Object)(object)((Component)Player.m_localPlayer).gameObject || ((Object)(object)val2.attachedRigidbody != (Object)null && (Object)(object)((Component)val2.attachedRigidbody).gameObject == (Object)(object)((Component)Player.m_localPlayer).gameObject))
			{
				continue;
			}
			IDestructible componentInParent = ((Component)val2).GetComponentInParent<IDestructible>();
			if (componentInParent == null)
			{
				continue;
			}
			Character val3 = (Character)(object)((componentInParent is Character) ? componentInParent : null);
			if ((Object)(object)val3 != (Object)null && (Object)(object)val3 == (Object)(object)Player.m_localPlayer)
			{
				continue;
			}
			IDestructible obj = ((componentInParent is MonoBehaviour) ? componentInParent : null);
			GameObject val4 = ((obj != null) ? ((Component)obj).gameObject : null);
			if ((Object)(object)val4 != (Object)null)
			{
				if (hashSet.Contains(val4))
				{
					continue;
				}
				hashSet.Add(val4);
			}
			Bounds bounds = val2.bounds;
			Vector3 center = ((Bounds)(ref bounds)).center;
			Vector3 val5 = center - position;
			Vector3 normalized = ((Vector3)(ref val5)).normalized;
			float num3 = Vector3.Angle(((Component)Player.m_localPlayer).transform.forward, normalized);
			if (!(num3 < 45f))
			{
				continue;
			}
			HitData val6 = new HitData();
			val6.m_damage.m_fire = fire;
			val6.m_point = center;
			val6.m_dir = ((Component)Player.m_localPlayer).transform.forward;
			val6.m_skill = (SkillType)9;
			val6.m_dodgeable = true;
			val6.m_blockable = true;
			val6.m_hitType = (HitType)2;
			val6.SetAttacker((Character)(object)Player.m_localPlayer);
			componentInParent.Damage(val6);
			if ((Object)(object)ZNetScene.instance != (Object)null)
			{
				GameObject prefab = ZNetScene.instance.GetPrefab("vfx_FireballHit");
				if ((Object)(object)prefab != (Object)null)
				{
					Object.Instantiate<GameObject>(prefab, center, Quaternion.identity);
				}
			}
		}
	}

	private IEnumerator ClawRoutine()
	{
		isAttacking = true;
		cultistAnim.SetFloat("forward_speed", 0f);
		cultistAnim.SetFloat("sideway_speed", 0f);
		cultistAnim.SetTrigger("attack_claw");
		yield return (object)new WaitForSeconds(0.4f);
		PlaySFX("sfx_cultist_attack", "sfx_fenring_attack", "sfx_wolf_attack");
		ExecuteClawDamage(85f);
		float remainingTimeToIdle = 0.099999994f;
		if (remainingTimeToIdle > 0f)
		{
			yield return (object)new WaitForSeconds(remainingTimeToIdle);
		}
		cultistAnim.ResetTrigger("attack_claw");
		isAttacking = false;
	}

	private IEnumerator DoubleClawRoutine()
	{
		isAttacking = true;
		cultistAnim.SetFloat("forward_speed", 0f);
		cultistAnim.SetFloat("sideway_speed", 0f);
		cultistAnim.SetTrigger("attack_claw_double");
		yield return (object)new WaitForSeconds(0.6f);
		PlaySFX("sfx_cultist_attack_double", "sfx_cultist_attack", "sfx_fenring_attack");
		ExecuteClawDamage(140f);
		yield return (object)new WaitForSeconds(1.2f);
		cultistAnim.ResetTrigger("attack_claw_double");
		isAttacking = false;
	}

	private void ExecuteClawDamage(float baseDamage)
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: 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)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: 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_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_020f: Unknown result type (might be due to invalid IL or missing references)
		//IL_021b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0220: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0251: Unknown result type (might be due to invalid IL or missing references)
		//IL_0253: Unknown result type (might be due to invalid IL or missing references)
		//IL_0255: Unknown result type (might be due to invalid IL or missing references)
		//IL_0296: Unknown result type (might be due to invalid IL or missing references)
		//IL_029d: Expected O, but got Unknown
		//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02da: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Player.m_localPlayer == (Object)null)
		{
			return;
		}
		Vector3 position = ((Component)Player.m_localPlayer).transform.position;
		Vector3 val = position + ((Component)Player.m_localPlayer).transform.forward * 1.5f + Vector3.up * 1f;
		float num = 2.5f;
		float skillLevel = ((Character)Player.m_localPlayer).GetSkillLevel((SkillType)11);
		float slash = baseDamage + skillLevel;
		int mask = LayerMask.GetMask(new string[12]
		{
			"Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "character", "character_net", "character_ghost", "hitbox",
			"character_noenv", "vehicle"
		});
		Collider[] array = Physics.OverlapSphere(val, num, mask);
		HashSet<GameObject> hashSet = new HashSet<GameObject>();
		Collider[] array2 = array;
		RaycastHit val7 = default(RaycastHit);
		foreach (Collider val2 in array2)
		{
			if ((Object)(object)((Component)val2).gameObject == (Object)(object)((Component)Player.m_localPlayer).gameObject || ((Object)(object)val2.attachedRigidbody != (Object)null && (Object)(object)((Component)val2.attachedRigidbody).gameObject == (Object)(object)((Component)Player.m_localPlayer).gameObject))
			{
				continue;
			}
			IDestructible componentInParent = ((Component)val2).GetComponentInParent<IDestructible>();
			if (componentInParent == null)
			{
				continue;
			}
			Character val3 = (Character)(object)((componentInParent is Character) ? componentInParent : null);
			if ((Object)(object)val3 != (Object)null && (Object)(object)val3 == (Object)(object)Player.m_localPlayer)
			{
				continue;
			}
			IDestructible obj = ((componentInParent is MonoBehaviour) ? componentInParent : null);
			GameObject val4 = ((obj != null) ? ((Component)obj).gameObject : null);
			if ((Object)(object)val4 != (Object)null)
			{
				if (hashSet.Contains(val4))
				{
					continue;
				}
				hashSet.Add(val4);
			}
			Bounds bounds = val2.bounds;
			Vector3 center = ((Bounds)(ref bounds)).center;
			Vector3 val5 = center - position;
			Vector3 normalized = ((Vector3)(ref val5)).normalized;
			float num2 = Vector3.Angle(((Component)Player.m_localPlayer).transform.forward, normalized);
			if (num2 < 70f)
			{
				Vector3 val6 = position + Vector3.up * 1.5f;
				if (!Physics.Linecast(val6, center, ref val7, LayerMask.GetMask(new string[4] { "Default", "static_solid", "terrain", "piece" })))
				{
					HitData val8 = new HitData();
					val8.m_damage.m_slash = slash;
					val8.m_pushForce = 30f;
					val8.m_point = center;
					val8.m_dir = ((Component)Player.m_localPlayer).transform.forward;
					val8.m_skill = (SkillType)11;
					val8.m_dodgeable = true;
					val8.m_blockable = true;
					val8.m_hitType = (HitType)2;
					val8.m_toolTier = 0;
					val8.SetAttacker((Character)(object)Player.m_localPlayer);
					componentInParent.Damage(val8);
				}
			}
		}
	}
}
public class WolfFormBehavior : MonoBehaviour
{
	private Animator playerAnim;

	private Animator wolfAnim;

	private bool isAttacking = false;

	private void Start()
	{
		playerAnim = ((Component)((Component)Player.m_localPlayer).transform.Find("Visual")).GetComponent<Animator>();
		wolfAnim = ((Component)this).GetComponent<Animator>();
		if ((Object)(object)wolfAnim == (Object)null)
		{
			wolfAnim = ((Component)this).GetComponentInChildren<Animator>();
		}
	}

	private void Update()
	{
		if ((Object)(object)playerAnim == (Object)null || (Object)(object)wolfAnim == (Object)null || isAttacking)
		{
			return;
		}
		bool flag = playerAnim.GetBool("onGround");
		try
		{
			wolfAnim.SetBool("onGround", flag);
		}
		catch
		{
		}
		try
		{
			wolfAnim.SetBool("inWater", playerAnim.GetBool("inWater"));
		}
		catch
		{
		}
		if (!flag)
		{
			try
			{
				wolfAnim.SetFloat("forward_speed", 0f);
			}
			catch
			{
			}
			try
			{
				wolfAnim.SetFloat("sideway_speed", 0f);
			}
			catch
			{
			}
		}
		else if (((Character)Player.m_localPlayer).IsCrouching())
		{
			try
			{
				wolfAnim.SetFloat("forward_speed", 0f);
			}
			catch
			{
			}
			try
			{
				wolfAnim.SetFloat("sideway_speed", 0f);
			}
			catch
			{
			}
		}
		else
		{
			try
			{
				wolfAnim.SetFloat("forward_speed", playerAnim.GetFloat("forward_speed"));
			}
			catch
			{
			}
			try
			{
				wolfAnim.SetFloat("sideway_speed", playerAnim.GetFloat("sideway_speed"));
			}
			catch
			{
			}
		}
		if (flag)
		{
			if (Input.GetMouseButtonDown(0))
			{
				((MonoBehaviour)this).StartCoroutine(WolfAttackRoutine("attack1", 40f, 0.6f, 0.2f));
			}
			else if (Input.GetMouseButtonDown(1))
			{
				((MonoBehaviour)this).StartCoroutine(WolfAttackRoutine("attack2", 60f, 0.8f, 0.3f));
			}
			else if (Input.GetMouseButtonDown(2))
			{
				((MonoBehaviour)this).StartCoroutine(WolfAttackRoutine("attack3", 80f, 1f, 0.4f));
			}
		}
	}

	private void PlaySFX(params string[] prefabNames)
	{
		//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)
		foreach (string text in prefabNames)
		{
			GameObject prefab = Cache.GetPrefab<GameObject>(text);
			if ((Object)(object)prefab != (Object)null)
			{
				Object.Instantiate<GameObject>(prefab, ((Component)Player.m_localPlayer).transform.position, Quaternion.identity);
				break;
			}
		}
	}

	private IEnumerator WolfAttackRoutine(string triggerName, float baseDamage, float lockDuration, float dmgDelay)
	{
		isAttacking = true;
		try
		{
			wolfAnim.SetFloat("forward_speed", 0f);
		}
		catch
		{
		}
		try
		{
			wolfAnim.SetFloat("sideway_speed", 0f);
		}
		catch
		{
		}
		wolfAnim.SetTrigger(triggerName);
		yield return (object)new WaitForSeconds(dmgDelay);
		if ((Object)(object)ZNetScene.instance != (Object)null)
		{
			GameObject attackSfx = ZNetScene.instance.GetPrefab("sfx_wolf_attack");
			if ((Object)(object)attackSfx != (Object)null)
			{
				Object.Instantiate<GameObject>(attackSfx, ((Component)Player.m_localPlayer).transform.position, Quaternion.identity);
			}
		}
		ExecuteBiteDamage(baseDamage);
		float remainingTimeToIdle = lockDuration - dmgDelay;
		if (remainingTimeToIdle > 0f)
		{
			yield return (object)new WaitForSeconds(remainingTimeToIdle);
		}
		wolfAnim.ResetTrigger(triggerName);
		isAttacking = false;
	}

	private void ExecuteBiteDamage(float baseDamage)
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: 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)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: 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_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_020f: Unknown result type (might be due to invalid IL or missing references)
		//IL_021b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0220: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0251: Unknown result type (might be due to invalid IL or missing references)
		//IL_0253: Unknown result type (might be due to invalid IL or missing references)
		//IL_0255: Unknown result type (might be due to invalid IL or missing references)
		//IL_0296: Unknown result type (might be due to invalid IL or missing references)
		//IL_029d: Expected O, but got Unknown
		//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02da: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Player.m_localPlayer == (Object)null)
		{
			return;
		}
		Vector3 position = ((Component)Player.m_localPlayer).transform.position;
		Vector3 val = position + ((Component)Player.m_localPlayer).transform.forward * 1.5f + Vector3.up * 0.5f;
		float num = 2f;
		float skillLevel = ((Character)Player.m_localPlayer).GetSkillLevel((SkillType)11);
		float slash = baseDamage + skillLevel;
		int mask = LayerMask.GetMask(new string[12]
		{
			"Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "character", "character_net", "character_ghost", "hitbox",
			"character_noenv", "vehicle"
		});
		Collider[] array = Physics.OverlapSphere(val, num, mask);
		HashSet<GameObject> hashSet = new HashSet<GameObject>();
		Collider[] array2 = array;
		RaycastHit val7 = default(RaycastHit);
		foreach (Collider val2 in array2)
		{
			if ((Object)(object)((Component)val2).gameObject == (Object)(object)((Component)Player.m_localPlayer).gameObject || ((Object)(object)val2.attachedRigidbody != (Object)null && (Object)(object)((Component)val2.attachedRigidbody).gameObject == (Object)(object)((Component)Player.m_localPlayer).gameObject))
			{
				continue;
			}
			IDestructible componentInParent = ((Component)val2).GetComponentInParent<IDestructible>();
			if (componentInParent == null)
			{
				continue;
			}
			Character val3 = (Character)(object)((componentInParent is Character) ? componentInParent : null);
			if ((Object)(object)val3 != (Object)null && (Object)(object)val3 == (Object)(object)Player.m_localPlayer)
			{
				continue;
			}
			IDestructible obj = ((componentInParent is MonoBehaviour) ? componentInParent : null);
			GameObject val4 = ((obj != null) ? ((Component)obj).gameObject : null);
			if ((Object)(object)val4 != (Object)null)
			{
				if (hashSet.Contains(val4))
				{
					continue;
				}
				hashSet.Add(val4);
			}
			Bounds bounds = val2.bounds;
			Vector3 center = ((Bounds)(ref bounds)).center;
			Vector3 val5 = center - position;
			Vector3 normalized = ((Vector3)(ref val5)).normalized;
			float num2 = Vector3.Angle(((Component)Player.m_localPlayer).transform.forward, normalized);
			if (num2 < 70f)
			{
				Vector3 val6 = position + Vector3.up * 1f;
				if (!Physics.Linecast(val6, center, ref val7, LayerMask.GetMask(new string[4] { "Default", "static_solid", "terrain", "piece" })))
				{
					HitData val8 = new HitData();
					val8.m_damage.m_slash = slash;
					val8.m_pushForce = 20f;
					val8.m_point = center;
					val8.m_dir = ((Component)Player.m_localPlayer).transform.forward;
					val8.m_skill = (SkillType)11;
					val8.m_dodgeable = true;
					val8.m_blockable = true;
					val8.m_hitType = (HitType)2;
					val8.m_toolTier = 0;
					val8.SetAttacker((Character)(object)Player.m_localPlayer);
					componentInParent.Damage(val8);
				}
			}
		}
	}
}
public class UlvFormBehavior : MonoBehaviour
{
	private Animator playerAnim;

	private Animator ulvAnim;

	private bool isAttacking = false;

	private void Start()
	{
		playerAnim = ((Component)((Component)Player.m_localPlayer).transform.Find("Visual")).GetComponent<Animator>();
		ulvAnim = ((Component)this).GetComponent<Animator>();
		if ((Object)(object)ulvAnim == (Object)null)
		{
			ulvAnim = ((Component)this).GetComponentInChildren<Animator>();
		}
	}

	private void Update()
	{
		if ((Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)playerAnim == (Object)null || (Object)(object)ulvAnim == (Object)null || isAttacking)
		{
			return;
		}
		bool flag = playerAnim.GetBool("onGround");
		try
		{
			ulvAnim.SetBool("onGround", flag);
		}
		catch
		{
		}
		try
		{
			ulvAnim.SetBool("inWater", playerAnim.GetBool("inWater"));
		}
		catch
		{
		}
		if (!flag)
		{
			try
			{
				ulvAnim.SetFloat("forward_speed", 0f);
			}
			catch
			{
			}
			try
			{
				ulvAnim.SetFloat("sideway_speed", 0f);
			}
			catch
			{
			}
		}
		else if (((Character)Player.m_localPlayer).IsCrouching())
		{
			try
			{
				ulvAnim.SetFloat("forward_speed", 0f);
			}
			catch
			{
			}
			try
			{
				ulvAnim.SetFloat("sideway_speed", 0f);
			}
			catch
			{
			}
		}
		else
		{
			try
			{
				ulvAnim.SetFloat("forward_speed", playerAnim.GetFloat("forward_speed"));
			}
			catch
			{
			}
			try
			{
				ulvAnim.SetFloat("sideway_speed", playerAnim.GetFloat("sideway_speed"));
			}
			catch
			{
			}
		}
		if (flag)
		{
			if (Input.GetMouseButtonDown(0))
			{
				((MonoBehaviour)this).StartCoroutine(UlvAttackRoutine("attack_bite", 40f, 0.6f, 0.2f));
			}
			else if (Input.GetMouseButtonDown(1))
			{
				((MonoBehaviour)this).StartCoroutine(UlvAttackRoutine("attack_bite", 60f, 0.8f, 0.3f));
			}
			else if (Input.GetMouseButtonDown(2))
			{
				((MonoBehaviour)this).StartCoroutine(UlvJumpAttackRoutine());
			}
		}
	}

	private void PlaySFX(params string[] prefabNames)
	{
		//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)
		foreach (string text in prefabNames)
		{
			GameObject prefab = Cache.GetPrefab<GameObject>(text);
			if ((Object)(object)prefab != (Object)null)
			{
				Object.Instantiate<GameObject>(prefab, ((Component)Player.m_localPlayer).transform.position, Quaternion.identity);
				break;
			}
		}
	}

	private IEnumerator UlvAttackRoutine(string triggerName, float baseDamage, float lockDuration, float dmgDelay)
	{
		isAttacking = true;
		try
		{
			ulvAnim.SetFloat("forward_speed", 0f);
		}
		catch
		{
		}
		try
		{
			ulvAnim.SetFloat("sideway_speed", 0f);
		}
		catch
		{
		}
		try
		{
			ulvAnim.SetTrigger(triggerName);
		}
		catch
		{
		}
		if (triggerName == "attack_bite")
		{
			PlaySFX("sfx_ulv_attack", "sfx_wolf_attack", "sfx_fenring_attack");
		}
		else
		{
			PlaySFX("sfx_ulv_attack", "sfx_wolf_attack", "sfx_fenring_attack");
		}
		yield return (object)new WaitForSeconds(dmgDelay);
		if ((Object)(object)ZNetScene.instance != (Object)null)
		{
			GameObject attackSfx = ZNetScene.instance.GetPrefab("sfx_wood_hit");
			if ((Object)(object)attackSfx != (Object)null)
			{
				Object.Instantiate<GameObject>(attackSfx, ((Component)Player.m_localPlayer).transform.position, Quaternion.identity);
			}
		}
		ExecuteBiteDamage(baseDamage);
		float remainingTimeToIdle = lockDuration - dmgDelay;
		if (remainingTimeToIdle > 0f)
		{
			yield return (object)new WaitForSeconds(remainingTimeToIdle);
		}
		try
		{
			ulvAnim.ResetTrigger(triggerName);
		}
		catch
		{
		}
		isAttacking = false;
	}

	private void ExecuteBiteDamage(float baseDamage)
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: 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)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: 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_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_020f: Unknown result type (might be due to invalid IL or missing references)
		//IL_021b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0220: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0251: Unknown result type (might be due to invalid IL or missing references)
		//IL_0253: Unknown result type (might be due to invalid IL or missing references)
		//IL_0255: Unknown result type (might be due to invalid IL or missing references)
		//IL_0296: Unknown result type (might be due to invalid IL or missing references)
		//IL_029d: Expected O, but got Unknown
		//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02da: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Player.m_localPlayer == (Object)null)
		{
			return;
		}
		Vector3 position = ((Component)Player.m_localPlayer).transform.position;
		Vector3 val = position + ((Component)Player.m_localPlayer).transform.forward * 1.5f + Vector3.up * 0.5f;
		float num = 2f;
		float skillLevel = ((Character)Player.m_localPlayer).GetSkillLevel((SkillType)11);
		float slash = baseDamage + skillLevel;
		int mask = LayerMask.GetMask(new string[12]
		{
			"Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "character", "character_net", "character_ghost", "hitbox",
			"character_noenv", "vehicle"
		});
		Collider[] array = Physics.OverlapSphere(val, num, mask);
		HashSet<GameObject> hashSet = new HashSet<GameObject>();
		Collider[] array2 = array;
		RaycastHit val7 = default(RaycastHit);
		foreach (Collider val2 in array2)
		{
			if ((Object)(object)((Component)val2).gameObject == (Object)(object)((Component)Player.m_localPlayer).gameObject || ((Object)(object)val2.attachedRigidbody != (Object)null && (Object)(object)((Component)val2.attachedRigidbody).gameObject == (Object)(object)((Component)Player.m_localPlayer).gameObject))
			{
				continue;
			}
			IDestructible componentInParent = ((Component)val2).GetComponentInParent<IDestructible>();
			if (componentInParent == null)
			{
				continue;
			}
			Character val3 = (Character)(object)((componentInParent is Character) ? componentInParent : null);
			if ((Object)(object)val3 != (Object)null && (Object)(object)val3 == (Object)(object)Player.m_localPlayer)
			{
				continue;
			}
			IDestructible obj = ((componentInParent is MonoBehaviour) ? componentInParent : null);
			GameObject val4 = ((obj != null) ? ((Component)obj).gameObject : null);
			if ((Object)(object)val4 != (Object)null)
			{
				if (hashSet.Contains(val4))
				{
					continue;
				}
				hashSet.Add(val4);
			}
			Bounds bounds = val2.bounds;
			Vector3 center = ((Bounds)(ref bounds)).center;
			Vector3 val5 = center - position;
			Vector3 normalized = ((Vector3)(ref val5)).normalized;
			float num2 = Vector3.Angle(((Component)Player.m_localPlayer).transform.forward, normalized);
			if (num2 < 70f)
			{
				Vector3 val6 = position + Vector3.up * 1f;
				if (!Physics.Linecast(val6, center, ref val7, LayerMask.GetMask(new string[4] { "Default", "static_solid", "terrain", "piece" })))
				{
					HitData val8 = new HitData();
					val8.m_damage.m_slash = slash;
					val8.m_pushForce = 25f;
					val8.m_point = center;
					val8.m_dir = ((Component)Player.m_localPlayer).transform.forward;
					val8.m_skill = (SkillType)11;
					val8.m_dodgeable = true;
					val8.m_blockable = true;
					val8.m_hitType = (HitType)2;
					val8.m_toolTier = 0;
					val8.SetAttacker((Character)(object)Player.m_localPlayer);
					componentInParent.Damage(val8);
				}
			}
		}
	}

	private IEnumerator UlvJumpAttackRoutine()
	{
		isAttacking = true;
		try
		{
			ulvAnim.SetFloat("forward_speed", 0f);
		}
		catch
		{
		}
		try
		{
			ulvAnim.SetFloat("sideway_speed", 0f);
		}
		catch
		{
		}
		try
		{
			ulvAnim.SetTrigger("attack_slash");
		}
		catch
		{
		}
		PlaySFX("sfx_ulv_attack", "sfx_wolf_attack");
		yield return (object)new WaitForSeconds(0.3f);
		float leapDuration = 0.25f;
		float leapSpeed = 18f;
		float elapsed = 0f;
		while (elapsed < leapDuration)
		{
			if ((Object)(object)Player.m_localPlayer != (Object)null)
			{
				Vector3 moveDir = ((Component)Player.m_localPlayer).transform.forward;
				Transform transform = ((Component)Player.m_localPlayer).transform;
				transform.position += moveDir * leapSpeed * Time.deltaTime;
			}
			elapsed += Time.deltaTime;
			yield return null;
		}
		if ((Object)(object)ZNetScene.instance != (Object)null)
		{
			GameObject attackSfx = ZNetScene.instance.GetPrefab("sfx_wood_hit");
			if ((Object)(object)attackSfx != (Object)null)
			{
				Object.Instantiate<GameObject>(attackSfx, ((Component)Player.m_localPlayer).transform.position, Quaternion.identity);
			}
		}
		ExecuteBiteDamage(80f);
		yield return (object)new WaitForSeconds(0.4f);
		try
		{
			ulvAnim.ResetTrigger("attack_slash");
		}
		catch
		{
		}
		isAttacking = false;
	}
}
[HarmonyPatch(typeof(Character), "StartAttack")]
public static class BlockPlayerLogicAttackPatch
{
	public static bool Prefix(Character __instance)
	{
		if ((Object)(object)__instance != (Object)null && (Object)(object)__instance == (Object)(object)Player.m_localPlayer && __instance.GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirForm")))
		{
			return false;
		}
		return true;
	}
}
[HarmonyPatch(typeof(ZSyncAnimation), "SetTrigger")]
public static class BlockPlayerAnimationsPatch
{
	public static bool Prefix(ZSyncAnimation __instance, string name)
	{
		if ((Object)(object)Player.m_localPlayer != (Object)null && (Object)(object)((Component)__instance).gameObject == (Object)(object)((Component)Player.m_localPlayer).gameObject && ((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirForm")))
		{
			string text = name.ToLower();
			if (text.Contains("attack") || text.Contains("swing") || text.Contains("punch"))
			{
				return false;
			}
		}
		return true;
	}
}
[HarmonyPatch(typeof(Skills), "LowerAllSkills")]
public static class FistsSkillDeathPatch
{
	private static float savedUnarmedSkillLevel = -1f;

	public static void Prefix(Skills __instance)
	{
		if (!((Object)(object)Player.m_localPlayer != (Object)null) || !((Object)(object)__instance == (Object)(object)((Character)Player.m_localPlayer).GetSkills()) || !((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirCurse")))
		{
			return;
		}
		object value = Traverse.Create((object)__instance).Method("GetSkill", new object[1] { (object)(SkillType)11 }).GetValue();
		if (value != null)
		{
			Skill val = (Skill)((value is Skill) ? value : null);
			if (val != null)
			{
				savedUnarmedSkillLevel = val.m_level;
			}
		}
	}

	public static void Postfix(Skills __instance)
	{
		if (!(savedUnarmedSkillLevel >= 0f))
		{
			return;
		}
		object value = Traverse.Create((object)__instance).Method("GetSkill", new object[1] { (object)(SkillType)11 }).GetValue();
		if (value != null)
		{
			Skill val = (Skill)((value is Skill) ? value : null);
			if (val != null)
			{
				val.m_level = savedUnarmedSkillLevel;
			}
		}
		savedUnarmedSkillLevel = -1f;
	}
}
[HarmonyPatch(typeof(Player), "GetTotalFoodValue")]
public static class FenrirEitrPatch
{
	public static void Postfix(Player __instance, ref float hp, ref float stamina, ref float eitr)
	{
		if ((Object)(object)__instance != (Object)null && ((Character)__instance).GetSEMan() != null && ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirCurse")))
		{
			int currentProgressionState = BossProgressionManager.GetCurrentProgressionState();
			eitr += FenrirProgression.GetEitrBonus(currentProgressionState);
		}
	}
}
[HarmonyPatch(typeof(Player), "GetBodyArmor")]
public static class FenrirArmorPatch
{
	public static void Postfix(Player __instance, ref float __result)
	{
		if ((Object)(object)__instance != (Object)null && (Object)(object)__instance == (Object)(object)Player.m_localPlayer && ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirCurse")))
		{
			int currentProgressionState = BossProgressionManager.GetCurrentProgressionState();
			__result += FenrirProgression.GetArmorBonus(currentProgressionState);
		}
	}
}
public static class FenrirProgression
{
	public enum FormType
	{
		None,
		Wolf,
		Ulv,
		Fenring,
		Cultist
	}

	public class FormRules
	{
		public FormType Form;

		public bool NeedsNight;

		public float DurationMinutes;

		public float CooldownMinutes;

		public FormRules(FormType form, bool needsNight, float duration, float cooldown)
		{
			Form = form;
			NeedsNight = needsNight;
			DurationMinutes = duration;
			CooldownMinutes = cooldown;
		}
	}

	public static float GetArmorBonus(int state)
	{
		if (state >= 8)
		{
			return 30f;
		}
		if (state >= 4)
		{
			return 20f;
		}
		if (state >= 3)
		{
			return 10f;
		}
		return 0f;
	}

	public static float GetFallDamageModifier(int state)
	{
		if (state >= 5)
		{
			return -1f;
		}
		if (state >= 3)
		{
			return -0.5f;
		}
		return 0f;
	}

	public static float GetRunStaminaModifier(int state)
	{
		if (state >= 1)
		{
			return -0.2f;
		}
		return 0f;
	}

	public static float GetStaminaRegenModifier(int state)
	{
		if (state >= 1)
		{
			return 1.2f;
		}
		return 1f;
	}

	public static float GetJumpModifier(int state)
	{
		if (state >= 3)
		{
			return 1.25f;
		}
		return 1f;
	}

	public static float GetFistsBonus(int state)
	{
		if (state >= 8)
		{
			return 60f;
		}
		if (state >= 4)
		{
			return 40f;
		}
		if (state >= 1)
		{
			return 25f;
		}
		return 0f;
	}

	public static float GetEitrBonus(int state)
	{
		if (state >= 7)
		{
			return 30f;
		}
		return 0f;
	}

	public static float GetEitrRegenModifier(int state)
	{
		if (state >= 7)
		{
			return 1.3f;
		}
		return 1f;
	}

	public static FormRules GetGKeyRules(int state)
	{
		if (state >= 6)
		{
			return new FormRules(FormType.Fenring, needsNight: false, 0f, 0f);
		}
		if (state >= 5)
		{
			return new FormRules(FormType.Fenring, needsNight: true, 2f, 5f);
		}
		if (state >= 4)
		{
			return new FormRules(FormType.Fenring, needsNight: true, 2f, 10f);
		}
		if (state >= 3)
		{
			return new FormRules(FormType.Ulv, needsNight: true, 0f, 0f);
		}
		return null;
	}

	public static FormRules GetHKeyRules(int state)
	{
		if (state >= 4)
		{
			return new FormRules(FormType.Ulv, needsNight: false, 0f, 0f);
		}
		if (state >= 3)
		{
			return new FormRules(FormType.Wolf, needsNight: false, 0f, 0f);
		}
		if (state >= 2)
		{
			return new FormRules(FormType.Wolf, needsNight: true, 0f, 0f);
		}
		return null;
	}

	public static FormRules GetJKeyRules(int state)
	{
		if (state >= 8)
		{
			return new FormRules(FormType.Cultist, needsNight: false, 0f, 0f);
		}
		if (state >= 7)
		{
			return new FormRules(FormType.Cultist, needsNight: false, 2f, 5f);
		}
		if (state >= 6)
		{
			return new FormRules(FormType.Cultist, needsNight: false, 2f, 10f);
		}
		return null;
	}
}
public class FenrirRace : MonoBehaviour
{
	public static FenrirRace Instance;

	public static SE_FenrirCurse curseSE;

	public static SE_Stats formBuffSE;

	public static SE_Stats wolfFormBuffSE;

	public static SE_Stats cultistFormBuffSE;

	public static SE_FormCooldown fenrirCdSE;

	public static SE_FormCooldown cultistCdSE;

	private GameObject currentTransformation;

	private bool isTransformed = false;

	private bool isTransformingSequence = false;

	private FenrirProgression.FormRules activeRules = null;

	private bool wasNight = false;

	private void Awake()
	{
		Instance = this;
	}

	public void CreateModAssets()
	{
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: 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_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Expected O, but got Unknown
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Expected O, but got Unknown
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Expected O, but got Unknown
		//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01de: Unknown result type (might be due to invalid IL or missing references)
		//IL_0226: Unknown result type (might be due to invalid IL or missing references)
		//IL_0230: Expected O, but got Unknown
		//IL_027d: 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_02ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d4: Expected O, but got Unknown
		//IL_0350: Unknown result type (might be due to invalid IL or missing references)
		//IL_035a: Expected O, but got Unknown
		curseSE = ScriptableObject.CreateInstance<SE_FenrirCurse>();
		((Object)curseSE).name = "SE_FenrirCurse";
		((StatusEffect)curseSE).m_name = "Fenrir's Blood";
		((StatusEffect)curseSE).m_tooltip = "You are of the Fenrir race.";
		((SE_Stats)curseSE).m_mods = new List<DamageModPair>
		{
			new DamageModPair
			{
				m_type = (DamageType)512,
				m_modifier = (DamageModifier)2
			}
		};
		ItemDrop prefab = Cache.GetPrefab<ItemDrop>("TrophyFenring");
		GameObject val = ((prefab != null) ? ((Component)prefab).gameObject : null);
		Sprite icon = null;
		if ((Object)(object)val != (Object)null)
		{
			ItemDrop component = val.GetComponent<ItemDrop>();
			if ((Object)(object)component != (Object)null && component.m_itemData.m_shared.m_icons.Length != 0)
			{
				icon = component.m_itemData.m_shared.m_icons[0];
				((StatusEffect)curseSE).m_icon = icon;
			}
		}
		ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)curseSE, false));
		fenrirCdSE = ScriptableObject.CreateInstance<SE_FormCooldown>();
		((Object)fenrirCdSE).name = "SE_FenrirCooldown";
		((StatusEffect)fenrirCdSE).m_name = "Fenrir Form Cooldown";
		((StatusEffect)fenrirCdSE).m_icon = icon;
		ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)fenrirCdSE, false));
		cultistCdSE = ScriptableObject.CreateInstance<SE_FormCooldown>();
		((Object)cultistCdSE).name = "SE_CultistCooldown";
		((StatusEffect)cultistCdSE).m_name = "Cultist Form Cooldown";
		((StatusEffect)cultistCdSE).m_icon = icon;
		ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)cultistCdSE, false));
		formBuffSE = ScriptableObject.CreateInstance<SE_Stats>();
		((Object)formBuffSE).name = "SE_FenrirForm";
		((StatusEffect)formBuffSE).m_name = "Bestial Fury";
		formBuffSE.m_speedModifier = 1f;
		formBuffSE.m_jumpModifier = new Vector3(0f, 1f, 0f);
		formBuffSE.m_fallDamageModifier = -1f;
		formBuffSE.m_staminaRegenMultiplier = 1.3f;
		formBuffSE.m_runStaminaDrainModifier = -0.2f;
		((StatusEffect)formBuffSE).m_icon = icon;
		ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)formBuffSE, false));
		cultistFormBuffSE = ScriptableObject.CreateInstance<SE_Stats>();
		((Object)cultistFormBuffSE).name = "SE_CultistForm";
		((StatusEffect)cultistFormBuffSE).m_name = "Cultist Fury";
		cultistFormBuffSE.m_speedModifier = 1f;
		cultistFormBuffSE.m_jumpModifier = new Vector3(0f, 1f, 0f);
		cultistFormBuffSE.m_fallDamageModifier = -1f;
		cultistFormBuffSE.m_staminaRegenMultiplier = 1.3f;
		cultistFormBuffSE.m_runStaminaDrainModifier = -0.2f;
		((StatusEffect)cultistFormBuffSE).m_icon = icon;
		ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)cultistFormBuffSE, false));
		wolfFormBuffSE = ScriptableObject.CreateInstance<SE_Stats>();
		((Object)wolfFormBuffSE).name = "SE_WolfForm";
		((StatusEffect)wolfFormBuffSE).m_name = "Wolf Senses";
		wolfFormBuffSE.m_speedModifier = 0.5f;
		wolfFormBuffSE.m_fallDamageModifier = -0.5f;
		wolfFormBuffSE.m_staminaRegenMultiplier = 1.3f;
		wolfFormBuffSE.m_runStaminaDrainModifier = -0.2f;
		((StatusEffect)wolfFormBuffSE).m_icon = icon;
		ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)wolfFormBuffSE, false));
	}

	private void Update()
	{
		if ((Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)EnvMan.instance == (Object)null || isTransformingSequence || !((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirCurse")))
		{
			return;
		}
		bool flag = EnvMan.IsNight();
		if (flag && !wasNight)
		{
			((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirCooldown"), false);
			((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_CultistCooldown"), false);
			StatusEffect statusEffect = ((Character)Player.m_localPlayer).GetSEMan().GetStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirForm"));
			if ((Object)(object)statusEffect != (Object)null)
			{
				statusEffect.m_ttl = 0f;
			}
			StatusEffect statusEffect2 = ((Character)Player.m_localPlayer).GetSEMan().GetStatusEffect(StringExtensionMethods.GetStableHashCode("SE_CultistForm"));
			if ((Object)(object)statusEffect2 != (Object)null)
			{
				statusEffect2.m_ttl = 0f;
			}
			StatusEffect statusEffect3 = ((Character)Player.m_localPlayer).GetSEMan().GetStatusEffect(StringExtensionMethods.GetStableHashCode("SE_WolfForm"));
			if ((Object)(object)statusEffect3 != (Object)null)
			{
				statusEffect3.m_ttl = 0f;
			}
		}
		wasNight = flag;
		if (isTransformed && !((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirForm")) && !((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_CultistForm")) && !((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_WolfForm")))
		{
			ForceRevert();
			return;
		}
		int currentProgressionState = BossProgressionManager.GetCurrentProgressionState();
		if (Input.GetKeyDown((KeyCode)103))
		{
			TryTransformWithRules(FenrirProgression.GetGKeyRules(currentProgressionState));
		}
		else if (Input.GetKeyDown((KeyCode)104))
		{
			TryTransformWithRules(FenrirProgression.GetHKeyRules(currentProgressionState));
		}
		else if (Input.GetKeyDown((KeyCode)106))
		{
			TryTransformWithRules(FenrirProgression.GetJKeyRules(currentProgressionState));
		}
	}

	private void TryTransformWithRules(FenrirProgression.FormRules rules)
	{
		if (rules == null || rules.Form == FenrirProgression.FormType.None)
		{
			return;
		}
		if (isTransformed)
		{
			((MonoBehaviour)this).StartCoroutine(RevertToHumanRoutine());
			return;
		}
		if (rules.NeedsNight && !EnvMan.IsNight())
		{
			((Character)Player.m_localPlayer).Message((MessageType)2, "The beast rests. You can only transform at night.", 0, (Sprite)null);
			return;
		}
		if (rules.CooldownMinutes > 0f)
		{
			string text = ((rules.Form == FenrirProgression.FormType.Cultist) ? "SE_CultistCooldown" : "SE_FenrirCooldown");
			StatusEffect statusEffect = ((Character)Player.m_localPlayer).GetSEMan().GetStatusEffect(StringExtensionMethods.GetStableHashCode(text));
			if ((Object)(object)statusEffect != (Object)null)
			{
				float value = Traverse.Create((object)statusEffect).Field<float>("m_time").Value;
				float num = statusEffect.m_ttl - value;
				if (num < 0f)
				{
					num = 0f;
				}
				int num2 = Mathf.FloorToInt(num / 60f);
				int num3 = Mathf.FloorToInt(num % 60f);
				string arg = ((rules.Form == FenrirProgression.FormType.Cultist) ? "Cultist" : "Fenrir");
				((Character)Player.m_localPlayer).Message((MessageType)2, $"{arg} form is on cooldown ({num2}:{num3:00}).", 0, (Sprite)null);
				return;
			}
		}
		((MonoBehaviour)this).StartCoroutine(TransformIntoWolfRoutine(rules));
	}

	public void ForceRevert()
	{
		if (isTransformed && !isTransformingSequence)
		{
			((MonoBehaviour)this).StartCoroutine(RevertToHumanRoutine());
		}
	}

	private IEnumerator TransformIntoWolfRoutine(FenrirProgression.FormRules rules)
	{
		isTransformingSequence = true;
		activeRules = rules;
		ZSyncAnimation zAnim = ((Component)Player.m_localPlayer).GetComponent<ZSyncAnimation>();
		if ((Object)(object)zAnim != (Object)null)
		{
			zAnim.SetTrigger("gpower");
		}
		yield return (object)new WaitForSeconds(1.1f);
		SpawnPoofEffect();
		if ((Object)(object)ZNetScene.instance != (Object)null)
		{
			GameObject howlPrefab = ZNetScene.instance.GetPrefab("sfx_wolf_howl") ?? ZNetScene.instance.GetPrefab("sfx_fenring_idle");
			if ((Object)(object)howlPrefab != (Object)null)
			{
				Object.Instantiate<GameObject>(howlPrefab, ((Component)Player.m_localPlayer).transform.position, Quaternion.identity);
			}
		}
		yield return (object)new WaitForSeconds(0.1f);
		ExecuteTransformation(rules);
		if ((Object)(object)currentTransformation != (Object)null && (Object)(object)currentTransformation.GetComponent<WolfFormBehavior>() == (Object)null && (Object)(object)currentTransformation.GetComponent<UlvFormBehavior>() == (Object)null)
		{
			float elapsed = 0f;
			float duration = 0.5f;
			float startMultiplier = 0.5f;
			Vector3 startScale = Vector3.one * startMultiplier;
			Vector3 endScale = Vector3.one;
			currentTransformation.transform.localScale = startScale;
			while (elapsed < duration && !((Object)(object)currentTransformation == (Object)null))
			{
				currentTransformation.transform.localScale = Vector3.Lerp(startScale, endScale, elapsed / duration);
				elapsed += Time.deltaTime;
				yield return null;
			}
			if ((Object)(object)currentTransformation != (Object)null)
			{
				currentTransformation.transform.localScale = endScale;
			}
		}
		isTransformingSequence = false;
	}

	private IEnumerator RevertToHumanRoutine()
	{
		isTransformingSequence = true;
		if ((Object)(object)currentTransformation != (Object)null)
		{
			FenrirFormBehavior fenrirBehavior = currentTransformation.GetComponent<FenrirFormBehavior>();
			if ((Object)(object)fenrirBehavior != (Object)null)
			{
				((Behaviour)fenrirBehavior).enabled = false;
			}
			CultistFormBehavior cultistBehavior = currentTransformation.GetComponent<CultistFormBehavior>();
			if ((Object)(object)cultistBehavior != (Object)null)
			{
				((Behaviour)cultistBehavior).enabled = false;
			}
			WolfFormBehavior wolfBehavior = currentTransformation.GetComponent<WolfFormBehavior>();
			if ((Object)(object)wolfBehavior != (Object)null)
			{
				((Behaviour)wolfBehavior).enabled = false;
			}
			UlvFormBehavior ulvBehavior = currentTransformation.GetComponent<UlvFormBehavior>();
			if ((Object)(object)ulvBehavior != (Object)null)
			{
				((Behaviour)ulvBehavior).enabled = false;
			}
			if ((Object)(object)wolfBehavior == (Object)null && (Object)(object)ulvBehavior == (Object)null)
			{
				float elapsed = 0f;
				float duration = 0.5f;
				Vector3 startScale = currentTransformation.transform.localScale;
				float endMultiplier = 0.5f;
				Vector3 endScale = startScale * endMultiplier;
				while (elapsed < duration && !((Object)(object)currentTransformation == (Object)null))
				{
					currentTransformation.transform.localScale = Vector3.Lerp(startScale, endScale, elapsed / duration);
					elapsed += Time.deltaTime;
					yield return null;
				}
			}
		}
		SpawnPoofEffect();
		yield return (object)new WaitForSeconds(0.1f);
		ExecuteReversion();
		isTransformingSequence = false;
	}

	private void SpawnPoofEffect()
	{
		//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_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)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: 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_006b: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)Player.m_localPlayer == (Object)null))
		{
			Vector3 val = ((Component)Player.m_localPlayer).transform.position + Vector3.up;
			GameObject prefab = Cache.GetPrefab<GameObject>("vfx_corpse_destruction");
			if ((Object)(object)prefab != (Object)null)
			{
				Object.Instantiate<GameObject>(prefab, val, Quaternion.identity);
			}
			GameObject prefab2 = Cache.GetPrefab<GameObject>("vfx_HitSparks");
			if ((Object)(object)prefab2 != (Object)null)
			{
				Object.Instantiate<GameObject>(prefab2, val, Quaternion.identity);
			}
		}
	}

	private void ExecuteTransformation(FenrirProgression.FormRules rules)
	{
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		Transform val = ((Component)Player.m_localPlayer).transform.Find("Visual");
		string text = "";
		switch (rules.Form)
		{
		case FenrirProgression.FormType.Wolf:
			text = "Wolf";
			break;
		case FenrirProgression.FormType.Ulv:
			text = "Ulv";
			break;
		case FenrirProgression.FormType.Fenring:
			text = "Fenring";
			break;
		case FenrirProgression.FormType.Cultist:
			text = "Fenring_Cultist";
			break;
		}
		GameObject prefab = Cache.GetPrefab<GameObject>(text);
		ZNetView component = ((Component)Player.m_localPlayer).GetComponent<ZNetView>();
		if ((Object)(object)component != (Object)null && component.IsValid())
		{
			component.GetZDO().Set("RacesOfValheim_FenrirForm", text);
		}
		if (!((Object)(object)prefab != (Object)null) || !((Object)(object)val != (Object)null))
		{
			return;
		}
		val.localScale = Vector3.one * 0.001f;
		Transform val2 = prefab.transform.Find("Visual");
		if (!((Object)(object)val2 != (Object)null))
		{
			return;
		}
		currentTransformation = Object.Instantiate<GameObject>(((Component)val2).gameObject, ((Component)Player.m_localPlayer).transform);
		currentTransformation.transform.localPosition = Vector3.zero;
		currentTransformation.transform.localRotation = Quaternion.identity;
		Component component2 = currentTransformation.GetComponent("AnimEvent");
		if ((Object)(object)component2 != (Object)null)
		{
			Object.Destroy((Object)(object)component2);
		}
		float ttl = ((rules.DurationMinutes > 0f) ? (rules.DurationMinutes * 60f) : 0f);
		switch (text)
		{
		case "Ulv":
		{
			currentTransformation.AddComponent<UlvFormBehavior>();
			((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("SE_WolfForm"), true, 0, 0f);
			StatusEffect statusEffect3 = ((Character)Player.m_localPlayer).GetSEMan().GetStatusEffect(StringExtensionMethods.GetStableHashCode("SE_WolfForm"));
			if ((Object)(object)statusEffect3 != (Object)null)
			{
				statusEffect3.m_ttl = ttl;
			}
			((Character)Player.m_localPlayer).Message((MessageType)2, "You are an Ulv!", 0, (Sprite)null);
			break;
		}
		case "Wolf":
		{
			currentTransformation.AddComponent<WolfFormBehavior>();
			((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("SE_WolfForm"), true, 0, 0f);
			StatusEffect statusEffect2 = ((Character)Player.m_localPlayer).GetSEMan().GetStatusEffect(StringExtensionMethods.GetStableHashCode("SE_WolfForm"));
			if ((Object)(object)statusEffect2 != (Object)null)
			{
				statusEffect2.m_ttl = ttl;
			}
			((Character)Player.m_localPlayer).Message((MessageType)2, "You are a Wolf!", 0, (Sprite)null);
			break;
		}
		case "Fenring_Cultist":
		{
			currentTransformation.AddComponent<CultistFormBehavior>();
			((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("SE_CultistForm"), true, 0, 0f);
			StatusEffect statusEffect4 = ((Character)Player.m_localPlayer).GetSEMan().GetStatusEffect(StringExtensionMethods.GetStableHashCode("SE_CultistForm"));
			if ((Object)(object)statusEffect4 != (Object)null)
			{
				statusEffect4.m_ttl = ttl;
			}
			((Character)Player.m_localPlayer).Message((MessageType)2, "You are a Cultist!", 0, (Sprite)null);
			break;
		}
		default:
		{
			currentTransformation.AddComponent<FenrirFormBehavior>();
			((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirForm"), true, 0, 0f);
			StatusEffect statusEffect = ((Character)Player.m_localPlayer).GetSEMan().GetStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirForm"));
			if ((Object)(object)statusEffect != (Object)null)
			{
				statusEffect.m_ttl = ttl;
			}
			((Character)Player.m_localPlayer).Message((MessageType)2, "You are a Fenring!", 0, (Sprite)null);
			break;
		}
		}
		isTransformed = true;
	}

	private void DestroyAllForms()
	{
		if (!((Object)(object)Player.m_localPlayer == (Object)null))
		{
			FenrirFormBehavior[] componentsInChildren = ((Component)Player.m_localPlayer).GetComponentsInChildren<FenrirFormBehavior>(true);
			FenrirFormBehavior[] array = componentsInChildren;
			foreach (FenrirFormBehavior fenrirFormBehavior in array)
			{
				Object.Destroy((Object)(object)((Component)fenrirFormBehavior).gameObject);
			}
			CultistFormBehavior[] componentsInChildren2 = ((Component)Player.m_localPlayer).GetComponentsInChildren<CultistFormBehavior>(true);
			CultistFormBehavior[] array2 = componentsInChildren2;
			foreach (CultistFormBehavior cultistFormBehavior in array2)
			{
				Object.Destroy((Object)(object)((Component)cultistFormBehavior).gameObject);
			}
			WolfFormBehavior[] componentsInChildren3 = ((Component)Player.m_localPlayer).GetComponentsInChildren<WolfFormBehavior>(true);
			WolfFormBehavior[] array3 = componentsInChildren3;
			foreach (WolfFormBehavior wolfFormBehavior in array3)
			{
				Object.Destroy((Object)(object)((Component)wolfFormBehavior).gameObject);
			}
			UlvFormBehavior[] componentsInChildren4 = ((Component)Player.m_localPlayer).GetComponentsInChildren<UlvFormBehavior>(true);
			UlvFormBehavior[] array4 = componentsInChildren4;
			foreach (UlvFormBehavior ulvFormBehavior in array4)
			{
				Object.Destroy((Object)(object)((Component)ulvFormBehavior).gameObject);
			}
		}
	}

	private void ExecuteReversion()
	{
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		Transform val = ((Component)Player.m_localPlayer).transform.Find("Visual");
		if ((Object)(object)currentTransformation != (Object)null)
		{
			Object.Destroy((Object)(object)currentTransformation);
		}
		DestroyAllForms();
		ZNetView component = ((Component)Player.m_localPlayer).GetComponent<ZNetView>();
		if ((Object)(object)component != (Object)null && component.IsValid())
		{
			component.GetZDO().Set("RacesOfValheim_FenrirForm", "");
		}
		if ((Object)(object)val != (Object)null)
		{
			val.localScale = Vector3.one;
			((Component)val).gameObject.SetActive(true);
		}
		((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirForm"), false);
		((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_CultistForm"), false);
		((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_WolfForm"), false);
		isTransformed = false;
		((Character)Player.m_localPlayer).Message((MessageType)2, "You returned to human form.", 0, (Sprite)null);
		if (activeRules != null && activeRules.CooldownMinutes > 0f)
		{
			string text = ((activeRules.Form == FenrirProgression.FormType.Cultist) ? "SE_CultistCooldown" : "SE_FenrirCooldown");
			((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode(text), true, 0, 0f);
			StatusEffect statusEffect = ((Character)Player.m_localPlayer).GetSEMan().GetStatusEffect(StringExtensionMethods.GetStableHashCode(text));
			if ((Object)(object)statusEffect != (Object)null)
			{
				statusEffect.m_ttl = activeRules.CooldownMinutes * 60f;
			}
		}
		activeRules = null;
	}
}
public class SE_FormCooldown : StatusEffect
{
	public override void Stop()
	{
		((StatusEffect)this).Stop();
		if ((Object)(object)Player.m_localPlayer != (Object)null)
		{
			((Character)Player.m_localPlayer).Message((MessageType)2, base.m_name + " is Ready!", 0, (Sprite)null);
		}
	}
}
public class SE_FenrirCurse : SE_Stats
{
	public override void Setup(Character character)
	{
		((SE_Stats)this).Setup(character);
		if ((Object)(object)character == (Object)(object)Player.m_localPlayer)
		{
			Player.m_localPlayer.m_customData["FenrirCurse_Active"] = "true";
		}
	}

	public override void UpdateStatusEffect(float dt)
	{
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: 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)
		((SE_Stats)this).UpdateStatusEffect(dt);
		int currentProgressionState = BossProgressionManager.GetCurrentProgressionState();
		base.m_runStaminaDrainModifier = FenrirProgression.GetRunStaminaModifier(currentProgressionState);
		base.m_staminaRegenMultiplier = FenrirProgression.GetStaminaRegenModifier(currentProgressionState);
		base.m_fallDamageModifier = FenrirProgression.GetFallDamageModifier(currentProgressionState);
		float jumpModifier = FenrirProgression.GetJumpModifier(currentProgressionState);
		if (jumpModifier > 1f)
		{
			base.m_jumpModifier = new Vector3(0f, jumpModifier - 1f, 0f);
		}
		else
		{
			base.m_jumpModifier = Vector3.zero;
		}
		float fistsBonus = FenrirProgression.GetFistsBonus(currentProgressionState);
		if (fistsBonus > 0f)
		{
			base.m_raiseSkill = (SkillType)11;
			base.m_raiseSkillModifier = fistsBonus;
		}
		else
		{
			base.m_raiseSkill = (SkillType)0;
			base.m_raiseSkillModifier = 0f;
		}
	}
}
[HarmonyPatch(typeof(BaseAI), "IsEnemy", new Type[]
{
	typeof(Character),
	typeof(Character)
})]
public static class RaceHostilityManager
{
	public static void Postfix(Character a, Character b, ref bool __result)
	{
		if (!__result || (Object)(object)a == (Object)null || (Object)(object)b == (Object)null)
		{
			return;
		}
		Character val = (a.IsPlayer() ? a : (b.IsPlayer() ? b : null));
		Character val2 = (a.IsPlayer() ? b : (b.IsPlayer() ? a : null));
		if (!((Object)(object)val != (Object)null) || !((Object)(object)val2 != (Object)null))
		{
			return;
		}
		Player val3 = (Player)(object)((val is Player) ? val : null);
		if ((Object)(object)val3 != (Object)null && val3.m_customData.ContainsKey("Race") && val3.m_customData["Race"] == "Fenrir")
		{
			string text = ((Object)((Component)val2).gameObject).name.ToLower();
			if (text.Contains("wolf") || text.Contains("fenring") || text.Contains("ulv") || text.Contains("cultist"))
			{
				__result = false;
			}
		}
	}
}
[BepInPlugin("com.nandor.racesofvalheim", "Races Of Valheim", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class RacesOfValheim : BaseUnityPlugin
{
	public const string PluginGUID = "com.nandor.racesofvalheim";

	public const string PluginName = "Races Of Valheim";

	public const string PluginVersion = "1.0.0";

	private readonly Harmony harmony = new Harmony("com.nandor.racesofvalheim");

	public static RacesOfValheim Instance;

	private GameObject raceSelectionMenu;

	private void Awake()
	{
		Instance = this;
		harmony.PatchAll();
		((Component)this).gameObject.AddComponent<FenrirRace>();
		((Component)this).gameObject.AddComponent<SkadiRace>();
		((Component)this).gameObject.AddComponent<SkeletonRace>();
		PrefabManager.OnVanillaPrefabsAvailable += CreateAllModAssets;
		CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new ResetRaceCommand());
		CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new CheckProgressionCommand());
		CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new IncreaseProgressionCommand());
		CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new ResetProgressionCommand());
	}

	private void CreateAllModAssets()
	{
		PrefabManager.OnVanillaPrefabsAvailable -= CreateAllModAssets;
		FenrirRace.Instance.CreateModAssets();
		SkadiRace.Instance.CreateModAssets();
		SkeletonRace.Instance.CreateModAssets();
	}

	public void ShowRaceSelectionMenu()
	{
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Expected O, but got Unknown
		//IL_0087: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Expected O, but got Unknown
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: 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_01a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b2: Expected O, but got Unknown
		//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Expected O, but got Unknown
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0202: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: Expected O, but got Unknown
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_022f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0239: Expected O, but got Unknown
		if (!((Object)(object)raceSelectionMenu != (Object)null))
		{
			if (GUIManager.Instance == null || (Object)(object)GUIManager.CustomGUIFront == (Object)null)
			{
				Logger.LogWarning((object)"GUIManager.CustomGUIFront is null, cannot show race menu.");
				return;
			}
			raceSelectionMenu = new GameObject("RaceSelectionMenu");
			raceSelectionMenu.transform.SetParent(GUIManager.CustomGUIFront.transform, false);
			RectTransform val = raceSelectionMenu.AddComponent<RectTransform>();
			val.anchorMin = new Vector2(0f, 0f);
			val.anchorMax = new Vector2(1f, 1f);
			val.offsetMin = Vector2.zero;
			val.offsetMax = Vector2.zero;
			Image val2 = raceSelectionMenu.AddComponent<Image>();
			((Graphic)val2).color = new Color(0f, 0f, 0f, 0.9f);
			GameObject val3 = new GameObject("Title");
			val3.transform.SetParent(raceSelectionMenu.transform, false);
			Text val4 = val3.AddComponent<Text>();
			val4.font = GUIManager.Instance.AveriaSerifBold;
			val4.text = "Choose your Race";
			val4.fontSize = 50;
			val4.alignment = (TextAnchor)4;
			((Graphic)val4).color = Color.white;
			RectTransform component = val3.GetComponent<RectTransform>();
			component.anchoredPosition = new Vector2(0f, 200f);
			component.sizeDelta = new Vector2(600f, 100f);
			CreateRaceButton("Human", new Vector2(-450f, 0f), GetHumanIcon(), new UnityAction(SelectHuman));
			CreateRaceButton("Fenrir", new Vector2(-150f, 0f), GetFenrirIcon(), new UnityAction(SelectFenrir));
			CreateRaceButton("Skadi", new Vector2(150f, 0f), GetSkadiIcon(), new UnityAction(SelectSkadi));
			CreateRaceButton("Skeleton", new Vector2(450f, 0f), GetSkeletonIcon(), new UnityAction(SelectSkeleton));
			GUIManager.BlockInput(true);
		}
	}

	private Sprite GetHumanIcon()
	{
		ItemDrop prefab = Cache.GetPrefab<ItemDrop>("Club");
		GameObject val = ((prefab != null) ? ((Component)prefab).gameObject : null);
		if ((Object)(object)val != (Object)null)
		{
			ItemDrop component = val.GetComponent<ItemDrop>();
			if ((Object)(object)component != (Object)null && component.m_itemData.m_shared.m_icons.Length != 0)
			{
				return component.m_itemData.m_shared.m_icons[0];
			}
		}
		return null;
	}

	private Sprite GetFenrirIcon()
	{
		ItemDrop prefab = Cache.GetPrefab<ItemDrop>("TrophyFenring");
		GameObject val = ((prefab != null) ? ((Component)prefab).gameObject : null);
		if ((Object)(object)val != (Object)null)
		{
			ItemDrop component = val.GetComponent<ItemDrop>();
			if ((Object)(object)component != (Object)null && component.m_itemData.m_shared.m_icons.Length != 0)
			{
				return component.m_itemData.m_shared.m_icons[0];
			}
		}
		return null;
	}

	private Sprite GetSkadiIcon()
	{
		ItemDrop prefab = Cache.GetPrefab<ItemDrop>("TrophyHatchling");
		GameObject val = ((prefab != null) ? ((Component)prefab).gameObject : null);
		if ((Object)(object)val != (Object)null)
		{
			ItemDrop component = val.GetComponent<ItemDrop>();
			if ((Object)(object)component != (Object)null && component.m_itemData.m_shared.m_icons.Length != 0)
			{
				return component.m_itemData.m_shared.m_icons[0];
			}
		}
		return null;
	}

	private Sprite GetSkeletonIcon()
	{
		ItemDrop prefab = Cache.GetPrefab<ItemDrop>("TrophySkeleton");
		GameObject val = ((prefab != null) ? ((Component)prefab).gameObject : null);
		if ((Object)(object)val != (Object)null)
		{
			ItemDrop component = val.GetComponent<ItemDrop>();
			if ((Object)(object)component != (Object)null && component.m_itemData.m_shared.m_icons.Length != 0)
			{
				return component.m_itemData.m_shared.m_icons[0];
			}
		}
		return null;
	}

	private void CreateRaceButton(string label, Vector2 position, Sprite iconSprite, UnityAction onClick)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Expected O, but got Unknown
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: 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)
		//IL_0149: Expected O, but got Unknown
		//IL_0184: 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_01bb: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(label + "Button");
		val.transform.SetParent(raceSelectionMenu.transform, false);
		RectTransform val2 = val.AddComponent<RectTransform>();
		val2.sizeDelta = new Vector2(250f, 80f);
		val2.anchoredPosition = position;
		Image val3 = val.AddComponent<Image>();
		((Graphic)val3).color = new Color(0.2f, 0.2f, 0.2f, 1f);
		Button val4 = val.AddComponent<Button>();
		((UnityEvent)val4.onClick).AddListener(onClick);
		GameObject val5 = new GameObject("Text");
		val5.transform.SetParent(val.transform, false);
		Text val6 = val5.AddComponent<Text>();
		val6.font = GUIManager.Instance.AveriaSerifBold;
		val6.text = label;
		val6.fontSize = 30;
		val6.alignment = (TextAnchor)4;
		((Graphic)val6).color = Color.white;
		RectTransform component = val5.GetComponent<RectTransform>();
		component.anchorMin = Vector2.zero;
		component.anchorMax = Vector2.one;
		component.offsetMin = Vector2.zero;
		component.offsetMax = Vector2.zero;
		if ((Object)(object)iconSprite != (Object)null)
		{
			GameObject val7 = new GameObject("Icon");
			val7.transform.SetParent(val.transform, false);
			Image val8 = val7.AddComponent<Image>();
			val8.sprite = iconSprite;
			RectTransform component2 = val7.GetComponent<RectTransform>();
			component2.sizeDelta = new Vector2(60f, 60f);
			component2.anchoredPosition = new Vector2(-70f, 0f);
			val6.alignment = (TextAnchor)5;
			component.offsetMax = new Vector2(-30f, 0f);
		}
	}

	private void SelectHuman()
	{
		if ((Object)(object)Player.m_localPlayer != (Object)null)
		{
			Player.m_localPlayer.m_customData["Race"] = "Human";
			ZNetView component = ((Component)Player.m_localPlayer).GetComponent<ZNetView>();
			if ((Object)(object)component != (Object)null && component.IsValid())
			{
				component.GetZDO().Set("RacesOfValheim_Race", "Human");
			}
			((Character)Player.m_localPlayer).Message((MessageType)2, "You chose to remain Human.", 0, (Sprite)null);
		}
		CloseRaceSelectionMenu();
	}

	private void SelectFenrir()
	{
		if ((Object)(object)Player.m_localPlayer != (Object)null)
		{
			Player.m_localPlayer.m_customData["Race"] = "Fenrir";
			ZNetView component = ((Component)Player.m_localPlayer).GetComponent<ZNetView>();
			if ((Object)(object)component != (Object)null && component.IsValid())
			{
				component.GetZDO().Set("RacesOfValheim_Race", "Fenrir");
			}
			Player.m_localPlayer.m_customData["FenrirCurse_Active"] = "true";
			((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirCurse"), true, 0, 0f);
			((Character)Player.m_localPlayer).Message((MessageType)2, "You chose the path of the Fenrir.", 0, (Sprite)null);
		}
		CloseRaceSelectionMenu();
	}

	private void SelectSkadi()
	{
		if ((Object)(object)Player.m_localPlayer != (Object)null)
		{
			Player.m_localPlayer.m_customData["Race"] = "Skadi";
			ZNetView component = ((Component)Player.m_localPlayer).GetComponent<ZNetView>();
			if ((Object)(object)component != (Object)null && component.IsValid())
			{
				component.GetZDO().Set("RacesOfValheim_Race", "Skadi");
			}
			((Character)Player.m_localPlayer).Message((MessageType)2, "You chose the path of Skadi.", 0, (Sprite)null);
			VisEquipment component2 = ((Component)Player.m_localPlayer).GetComponent<VisEquipment>();
			if ((Object)(object)component2 != (Object)null)
			{
				((object)component2).GetType().GetMethod("UpdateColors", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(component2, null);
			}
		}
		CloseRaceSelectionMenu();
	}

	private void SelectSkeleton()
	{
		if ((Object)(object)Player.m_localPlayer != (Object)null)
		{
			Player.m_localPlayer.m_customData["Race"] = "Skeleton";
			ZNetView component = ((Component)Player.m_localPlayer).GetComponent<ZNetView>();
			if ((Object)(object)component != (Object)null && component.IsValid())
			{
				component.GetZDO().Set("RacesOfValheim_Race", "Skeleton");
			}
			((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("SE_SkeletonStats"), true, 0, 0f);
			((Character)Player.m_localPlayer).Message((MessageType)2, "You chose the path of the Skeleton.", 0, (Sprite)null);
			CloseRaceSelectionMenu();
		}
	}

	public void CloseRaceSelectionMenu()
	{
		if ((Object)(object)raceSelectionMenu != (Object)null)
		{
			Object.Destroy((Object)(object)raceSelectionMenu);
			raceSelectionMenu = null;
		}
		GUIManager.BlockInput(false);
	}
}
[HarmonyPatch(typeof(Player), "OnSpawned")]
public static class PlayerSpawnPatch
{
	public static void Postfix(Player __instance)
	{
		if (!((Object)(object)__instance == (Object)(object)Player.m_localPlayer))
		{
			return;
		}
		if (__instance.m_customData.ContainsKey("FenrirCurse_Active") && __instance.m_customData["FenrirCurse_Active"] == "true")
		{
			((Character)__instance).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirCurse"), true, 0, 0f);
		}
		if (__instance.m_customData.ContainsKey("Race") && __instance.m_customData["Race"] == "Skadi")
		{
			VisEquipment component = ((Component)__instance).GetComponent<VisEquipment>();
			if ((Object)(object)component != (Object)null)
			{
				((object)component).GetType().GetMethod("UpdateColors", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(component, null);
			}
		}
		if (!__instance.m_customData.ContainsKey("Race") && (Object)(object)RacesOfValheim.Instance != (Object)null)
		{
			RacesOfValheim.Instance.ShowRaceSelectionMenu();
		}
	}
}
public class ResetRaceCommand : ConsoleCommand
{
	public override string Name => "resetrace";

	public override string Help => "Resets the player's race and reopens the race selection menu for debugging";

	public override void Run(string[] args)
	{
		if ((Object)(object)Player.m_localPlayer != (Object)null)
		{
			Player.m_localPlayer.m_customData.Remove("Race");
			Player.m_localPlayer.m_customData.Remove("FenrirCurse_Active");
			((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_FenrirCurse"), false);
			if ((Object)(object)RacesOfValheim.Instance != (Object)null)
			{
				if ((Object)(object)FenrirRace.Instance != (Object)null)
				{
					FenrirRace.Instance.ForceRevert();
				}
				RacesOfValheim.Instance.ShowRaceSelectionMenu();
			}
			Console.instance.Print("Race has been reset. The selection menu should now appear.");
		}
		else
		{
			Console.instance.Print("You must be in-game to reset your race.");
		}
	}
}
public class CheckProgressionCommand : ConsoleCommand
{
	public override string Name => "checkprogression";

	public override string Help => "Checks the current boss progression state (1-8)";

	public override void Run(string[] args)
	{
		int currentProgressionState = BossProgressionManager.GetCurrentProgressionState();
		Console.instance.Print($"Current World Boss Progression State: {currentProgressionState}");
		if ((Object)(object)Player.m_localPlayer != (Object)null)
		{
			((Character)Player.m_localPlayer).Message((MessageType)2, $"World Progression State: {currentProgressionState}", 0, (Sprite)null);
		}
	}
}
public class IncreaseProgressionCommand : ConsoleCommand
{
	public override string Name => "increaseprogression";

	public override string Help => "[DEBUG] Increases the current boss progression state by 1 (max 8)";

	public override void Run(string[] args)
	{
		if (BossProgressionManager.DebugState == -1)
		{
			BossProgressionManager.DebugState = BossProgressionManager.GetCurrentProgressionState();
		}
		if (BossProgressionManager.DebugState < 8)
		{
			BossProgressionManager.DebugState++;
			Console.instance.Print($"[DEBUG] Progression state increased to: {BossProgressionManager.DebugState}");
			if ((Object)(object)Player.m_localPlayer != (Object)null)
			{
				((Character)Player.m_localPlayer).Message((MessageType)2, $"Progression State: {BossProgressionManager.DebugState}", 0, (Sprite)null);
			}
		}
		else
		{
			Console.instance.Print("[DEBUG] Progression state is already at maximum (8).");
		}
	}
}
public class ResetProgressionCommand : ConsoleCommand
{
	public override string Name => "resetprogression";

	public override string Help => "[DEBUG] Resets the progression state to natural world state";

	public override void Run(string[] args)
	{
		BossProgressionManager.DebugState = -1;
		int currentProgressionState = BossProgressionManager.GetCurrentProgressionState();
		Console.instance.Print($"[DEBUG] Progression state reset to natural world state: {currentProgressionState}");
		if ((Object)(object)Player.m_localPlayer != (Object)null)
		{
			((Character)Player.m_localPlayer).Message((MessageType)2, $"Progression reset to: {currentProgressionState}", 0, (Sprite)null);
		}
	}
}
public class DrakeFormBehavior : MonoBehaviour
{
	private Animator anim;

	private bool isFlying = false;

	private bool isLanding = false;

	private float lastAttackTime = 0f;

	private SkadiProgression.FormRules formRules;

	private const float ATTACK_COST = 20f;

	private const float ATTACK_COOLDOWN = 3f;

	public void Initialize(SkadiProgression.FormRules rules)
	{
		formRules = rules;
	}

	private void Start()
	{
		anim = ((Component)this).GetComponentInChildren<Animator>();
		if ((Object)(object)Player.m_localPlayer != (Object)null)
		{
			Traverse.Create((object)Player.m_localPlayer).Field("m_debugFly").SetValue((object)false);
		}
	}

	private void Update()
	{
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Player.m_localPlayer == (Object)null || ((Character)Player.m_localPlayer).IsDead())
		{
			return;
		}
		if (Input.GetMouseButtonDown(1) && formRules != null && formRules.Form != SkadiProgression.FormType.SkeletonDragon)
		{
			if (!isFlying && !isLanding)
			{
				isFlying = true;
				Traverse.Create((object)Player.m_localPlayer).Field("m_debugFly").SetValue((object)true);
			}
			else if (isFlying && !isLanding)
			{
				isLanding = true;
				isFlying = false;
				Traverse.Create((object)Player.m_localPlayer).Field("m_debugFly").SetValue((object)false);
			}
			else if (isLanding)
			{
				isLanding = false;
				isFlying = true;
				Traverse.Create((object)Player.m_localPlayer).Field("m_debugFly").SetValue((object)true);
			}
		}
		if (isLanding)
		{
			Traverse val = Traverse.Create((object)Player.m_localPlayer).Field("m_maxAirAltitude");
			if (val.FieldExists())
			{
				val.SetValue((object)((Component)Player.m_localPlayer).transform.position.y);
			}
			if (((Character)Player.m_localPlayer).IsOnGround())
			{
				isLanding = false;
			}
		}
		if ((Object)(object)anim != (Object)null)
		{
			bool flag = !isFlying && !isLanding && ((Character)Player.m_localPlayer).IsOnGround();
			anim.Se