Decompiled source of Vanaheim v1.5.2

Vanaheim.dll

Decompiled 4 days ago
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Vanaheim")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HP")]
[assembly: AssemblyProduct("Vanaheim")]
[assembly: AssemblyCopyright("Copyright © HP 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("75197ad0-6f9f-4b64-9c56-795ccdd26874")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Vanaheim;

public class Class1
{
}
internal class Class2
{
}
[BepInPlugin("vanaheim.havstormr", "Vanaheim - Havstormr", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class VanaheimPlugin : BaseUnityPlugin
{
	public class MoldrikrController : MonoBehaviour
	{
		private const string BlackTickPrefabName = "Vanaheim_BlackBrood";

		private const string ChannelEffectPrefab = "fx_leviathanLava_leave";

		private const string SlamImpactEffectPrefab = "fx_seekerbrute_death";

		private const string PoisonCloudPrefab = "vfx_blob_attack";

		private const float FirstBreakHp = 0.9f;

		private const float SecondBreakHp = 0.45f;

		private const float VulnerableDuration = 20f;

		private const float FinalPulseInterval = 7f;

		private const float FinalPulseRange = 25f;

		private const float FinalPoisonDamage = 180f;

		private const int FirstBreakTickCount = 3;

		private const int SecondBreakTickCount = 4;

		private const float PhaseOneSpeedMultiplier = 0.85f;

		private const float PhaseOneDamageMultiplier = 1f;

		private const float PhaseTwoSpeedMultiplier = 1.25f;

		private const float PhaseTwoDamageMultiplier = 1.5f;

		private const float PhaseThreeSpeedMultiplier = 1.45f;

		private const float PhaseThreeDamageMultiplier = 2f;

		private Character _character;

		private MonsterAI _ai;

		private ZNetView _zNetView;

		private Rigidbody _body;

		private Animator _animator;

		private bool _firstBreakTriggered;

		private bool _secondBreakTriggered;

		private bool _isChanneling;

		private float _channelEndTime;

		private float _nextTickSummonTime;

		private float _nextFinalPoisonPulseTime;

		private bool _groundSlamEffectQueued;

		private float _groundSlamEffectTime;

		private bool _groundSlamEffectFired;

		private bool _finalPhaseStarted;

		private bool _deathAnnouncementSent;

		private float _baseSpeed;

		private float _baseRunSpeed;

		private readonly List<Attack> _attacks = new List<Attack>();

		private readonly Dictionary<Attack, float> _baseAttackMultipliers = new Dictionary<Attack, float>();

		private void Awake()
		{
			_character = ((Component)this).GetComponent<Character>();
			_ai = ((Component)this).GetComponent<MonsterAI>();
			_zNetView = ((Component)this).GetComponent<ZNetView>();
			_body = ((Component)this).GetComponent<Rigidbody>();
			_animator = ((Component)this).GetComponentInChildren<Animator>();
		}

		private void Start()
		{
			if ((Object)(object)_character != (Object)null)
			{
				_baseSpeed = _character.m_speed;
				_baseRunSpeed = _character.m_runSpeed;
			}
			_attacks.Clear();
			_baseAttackMultipliers.Clear();
			Attack[] componentsInChildren = ((Component)this).GetComponentsInChildren<Attack>(true);
			foreach (Attack val in componentsInChildren)
			{
				if (val != null)
				{
					_attacks.Add(val);
					_baseAttackMultipliers[val] = val.m_damageMultiplier;
				}
			}
			_nextFinalPoisonPulseTime = Time.time + 10f;
			ApplyPhaseBuffs(0.85f, 1f);
			ApplyVeryResistantPhase();
			Announce("The earth trembles as Moldrikr, the Black Carapace, emerges!");
		}

		private void Update()
		{
			if ((Object)(object)_character == (Object)null || (Object)(object)_zNetView == (Object)null || !_zNetView.IsValid() || !_zNetView.IsOwner())
			{
				return;
			}
			if (_character.IsDead())
			{
				if (!_deathAnnouncementSent)
				{
					_deathAnnouncementSent = true;
					Announce("Moldrikr's shell shatters, and the brood scatters into the darkness.");
				}
				return;
			}
			float healthPercentage = _character.GetHealthPercentage();
			if (!_firstBreakTriggered && healthPercentage <= 0.9f)
			{
				_firstBreakTriggered = true;
				StartChannel(1);
			}
			else if (!_secondBreakTriggered && healthPercentage <= 0.45f)
			{
				_secondBreakTriggered = true;
				StartChannel(2);
			}
			else if (_isChanneling)
			{
				UpdateChannel();
			}
			else
			{
				UpdateGroundSlamDetection();
				UpdateFinalPoisonPulse();
			}
		}

		private void ApplyPhaseBuffs(float speedMultiplier, float damageMultiplier)
		{
			if ((Object)(object)_character != (Object)null)
			{
				_character.m_speed = _baseSpeed * speedMultiplier;
				_character.m_runSpeed = _baseRunSpeed * speedMultiplier;
			}
			foreach (Attack attack in _attacks)
			{
				if (attack != null && _baseAttackMultipliers.TryGetValue(attack, out var value))
				{
					attack.m_damageMultiplier = value * damageMultiplier;
				}
			}
		}

		private void StartChannel(int breakNumber)
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			if (breakNumber == 1)
			{
				Announce("The Black Carapace cracks open, spilling forth its brood! He is exposed!");
			}
			else
			{
				Announce("Moldrikr can no longer contain the corruption within!");
			}
			_isChanneling = true;
			_channelEndTime = Time.time + 20f;
			_nextTickSummonTime = Time.time + 2f;
			if ((Object)(object)_ai != (Object)null)
			{
				((Behaviour)_ai).enabled = false;
			}
			if ((Object)(object)_body != (Object)null)
			{
				_body.velocity = Vector3.zero;
			}
			ApplyWeakPhase();
			if ((Object)(object)_character != (Object)null)
			{
				_character.Stagger(Vector3.zero);
			}
			if ((Object)(object)_body != (Object)null)
			{
				_body.velocity = Vector3.zero;
				_body.angularVelocity = Vector3.zero;
			}
			SpawnEffect("fx_leviathanLava_leave", ((Component)this).transform.position, Quaternion.identity, 2.5f);
			SpawnEffect("fx_leviathanLava_leave", ((Component)this).transform.position, Quaternion.Euler(0f, 90f, 0f), 2.2f);
		}

		private void UpdateChannel()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_body != (Object)null)
			{
				_body.velocity = Vector3.zero;
				_body.angularVelocity = Vector3.zero;
			}
			if (Time.time >= _nextTickSummonTime)
			{
				_nextTickSummonTime = Time.time + 4f;
				if (_secondBreakTriggered)
				{
					SummonTicks(4);
				}
				else
				{
					SummonTicks(3);
				}
			}
			if (Time.time >= _channelEndTime)
			{
				EndChannel();
			}
		}

		private void EndChannel()
		{
			_isChanneling = false;
			if ((Object)(object)_ai != (Object)null)
			{
				((Behaviour)_ai).enabled = true;
			}
			float healthPercentage = _character.GetHealthPercentage();
			if (healthPercentage > 0.45f)
			{
				Announce("Moldrikr's cracked shell hardens once more!");
				ApplyPhaseBuffs(1.25f, 1.5f);
				ApplyResistantPhase();
			}
			else
			{
				Announce("Moldrikr's shell is shattered! Toxic Fumes emanate from his broken carapace!");
				_finalPhaseStarted = true;
				_nextFinalPoisonPulseTime = Time.time + 3f;
				ApplyPhaseBuffs(1.45f, 2f);
				ApplyNormalPhase();
			}
		}

		private void SummonTicks(int count)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			GameObject prefab = ZNetScene.instance.GetPrefab("Vanaheim_BlackBrood");
			if ((Object)(object)prefab == (Object)null)
			{
				Debug.LogWarning((object)"[Moldrikr] Black tick prefab not found.");
				return;
			}
			for (int i = 0; i < count; i++)
			{
				Vector2 insideUnitCircle = Random.insideUnitCircle;
				Vector2 val = ((Vector2)(ref insideUnitCircle)).normalized * Random.Range(5f, 12f);
				Vector3 val2 = ((Component)this).transform.position + new Vector3(val.x, 1f, val.y);
				Object.Instantiate<GameObject>(prefab, val2, Quaternion.identity);
			}
		}

		private void UpdateGroundSlamDetection()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_animator == (Object)null))
			{
				AnimatorStateInfo currentAnimatorStateInfo = _animator.GetCurrentAnimatorStateInfo(0);
				bool flag = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("SeekerBrute_groundslam") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("Base Layer.SeekerBrute_groundslam") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).shortNameHash == Animator.StringToHash("SeekerBrute_groundslam");
				if (flag && !_groundSlamEffectQueued && !_groundSlamEffectFired)
				{
					_groundSlamEffectQueued = true;
					_groundSlamEffectTime = Time.time + 0.9f;
				}
				if (_groundSlamEffectQueued && !_groundSlamEffectFired && Time.time >= _groundSlamEffectTime)
				{
					_groundSlamEffectQueued = false;
					_groundSlamEffectFired = true;
					DoPoisonSlamEffect();
				}
				if (!flag)
				{
					_groundSlamEffectQueued = false;
					_groundSlamEffectFired = false;
				}
			}
		}

		private void UpdateFinalPoisonPulse()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Expected O, but got Unknown
			if (!_finalPhaseStarted || Time.time < _nextFinalPoisonPulseTime)
			{
				return;
			}
			_nextFinalPoisonPulseTime = Time.time + 7f;
			SpawnEffect("vfx_blob_attack", ((Component)this).transform.position, Quaternion.identity, 3f);
			foreach (Player allPlayer in Player.GetAllPlayers())
			{
				if (!((Object)(object)allPlayer == (Object)null))
				{
					float num = Vector3.Distance(((Component)this).transform.position, ((Component)allPlayer).transform.position);
					if (!(num > 25f))
					{
						HitData val = new HitData
						{
							m_point = ((Component)allPlayer).transform.position
						};
						Vector3 val2 = ((Component)allPlayer).transform.position - ((Component)this).transform.position;
						val.m_dir = ((Vector3)(ref val2)).normalized;
						val.m_pushForce = 0f;
						HitData val3 = val;
						val3.m_damage.m_poison = 180f;
						((Character)allPlayer).Damage(val3);
					}
				}
			}
		}

		private void DoPoisonSlamEffect()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			SpawnEffect("fx_seekerbrute_death", ((Component)this).transform.position, Quaternion.identity, 2f);
		}

		private void Announce(string message)
		{
			if ((Object)(object)MessageHud.instance != (Object)null)
			{
				MessageHud.instance.ShowMessage((MessageType)2, message, 0, (Sprite)null, false);
			}
		}

		private void TintEffectGreen(GameObject effect)
		{
			//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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)effect == (Object)null)
			{
				return;
			}
			Color val = default(Color);
			((Color)(ref val))..ctor(0.02f, 0.55f, 0.08f, 1f);
			ParticleSystem[] componentsInChildren = effect.GetComponentsInChildren<ParticleSystem>(true);
			foreach (ParticleSystem val2 in componentsInChildren)
			{
				MainModule main = val2.main;
				((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(val);
				ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime;
				if (((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled)
				{
					((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val);
				}
			}
			Renderer[] componentsInChildren2 = effect.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val3 in componentsInChildren2)
			{
				Material[] materials = val3.materials;
				foreach (Material val4 in materials)
				{
					if (!((Object)(object)val4 == (Object)null))
					{
						if (val4.HasProperty("_Color"))
						{
							val4.color = val;
						}
						if (val4.HasProperty("_EmissionColor"))
						{
							val4.SetColor("_EmissionColor", val);
						}
					}
				}
			}
		}

		private void SpawnEffect(string prefabName, Vector3 position, Quaternion rotation, float scale)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ZNetScene.instance == (Object)null)
			{
				return;
			}
			GameObject prefab = ZNetScene.instance.GetPrefab(prefabName);
			if ((Object)(object)prefab == (Object)null)
			{
				Debug.LogWarning((object)("[Moldrikr] Effect prefab not found: " + prefabName));
				return;
			}
			GameObject val = Object.Instantiate<GameObject>(prefab, position, rotation);
			val.transform.localScale = Vector3.one * scale;
			if (prefabName == "fx_leviathanLava_leave")
			{
				TintEffectGreen(val);
			}
		}

		private void ApplyVeryResistantPhase()
		{
			SetAllDamageModifiers(_character, (DamageModifier)5);
		}

		private void ApplyResistantPhase()
		{
			SetAllDamageModifiers(_character, (DamageModifier)1);
		}

		private void ApplyWeakPhase()
		{
			SetAllDamageModifiers(_character, (DamageModifier)2);
		}

		private void ApplyNormalPhase()
		{
			SetAllDamageModifiers(_character, (DamageModifier)0);
		}
	}

	public class TimedSummon : MonoBehaviour
	{
		private const float LifeTime = 60f;

		private const int MaxActiveSummons = 3;

		private static readonly List<TimedSummon> ActiveSummons = new List<TimedSummon>();

		private ZNetView _zNetView;

		private float _despawnTime;

		private void Awake()
		{
			_zNetView = ((Component)this).GetComponent<ZNetView>();
			_despawnTime = Time.time + 60f;
			ActiveSummons.RemoveAll((TimedSummon s) => (Object)(object)s == (Object)null);
			ActiveSummons.Add(this);
			while (ActiveSummons.Count > 3)
			{
				TimedSummon timedSummon = ActiveSummons[0];
				ActiveSummons.RemoveAt(0);
				if ((Object)(object)timedSummon != (Object)null)
				{
					timedSummon.ExpireSummon();
				}
			}
		}

		private void Update()
		{
			if (!((Object)(object)_zNetView == (Object)null) && _zNetView.IsValid() && _zNetView.IsOwner() && Time.time >= _despawnTime)
			{
				ExpireSummon();
			}
		}

		private void OnDestroy()
		{
			ActiveSummons.Remove(this);
		}

		private void ExpireSummon()
		{
			Character component = ((Component)this).GetComponent<Character>();
			if ((Object)(object)component != (Object)null && !component.IsDead())
			{
				component.SetHealth(0f);
			}
		}
	}

	public class HavstormrController : MonoBehaviour
	{
		public string StormEnvironment = "ThunderStorm";

		public string DrakeAddPrefab = "Havstormr_Drake";

		public string SerpentAddPrefab = "Havstormr_Serpent";

		private Character character;

		private float drakeTimer = 50f;

		private float serpentTimer = 115f;

		private bool deathHandled = false;

		private bool stormStarted = false;

		private void Awake()
		{
			character = ((Component)this).GetComponent<Character>();
		}

		private void Start()
		{
			ForceStorm();
			stormStarted = true;
			if ((Object)(object)MessageHud.instance != (Object)null)
			{
				MessageHud.instance.ShowMessage((MessageType)2, "The sea blackens beneath Havstormr's wings...", 0, (Sprite)null, false);
			}
		}

		private void Update()
		{
			if ((Object)(object)character == (Object)null)
			{
				return;
			}
			if (character.IsDead())
			{
				if (!deathHandled)
				{
					deathHandled = true;
					ResetStorm();
					if ((Object)(object)MessageHud.instance != (Object)null)
					{
						MessageHud.instance.ShowMessage((MessageType)2, "Havstormr falls. The eternal storm begins to break.", 0, (Sprite)null, false);
					}
				}
				return;
			}
			ForceStorm();
			if (IsServer())
			{
				drakeTimer -= Time.deltaTime;
				serpentTimer -= Time.deltaTime;
				if (drakeTimer <= 0f)
				{
					SpawnDrakes();
					drakeTimer = Random.Range(45f, 60f);
				}
				if (serpentTimer <= 0f)
				{
					SpawnSerpent();
					serpentTimer = Random.Range(100f, 130f);
				}
			}
		}

		private void OnDestroy()
		{
			if (stormStarted && !deathHandled)
			{
				ResetStorm();
			}
		}

		private bool IsServer()
		{
			return (Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer();
		}

		private void ForceStorm()
		{
			if ((Object)(object)EnvMan.instance != (Object)null)
			{
				EnvMan.instance.m_debugEnv = StormEnvironment;
			}
		}

		private void ResetStorm()
		{
			if ((Object)(object)EnvMan.instance != (Object)null)
			{
				EnvMan.instance.m_debugEnv = "";
			}
		}

		private void SpawnDrakes()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			int num = Random.Range(1, 3);
			for (int i = 0; i < num; i++)
			{
				Vector3 val = Random.insideUnitSphere * 14f;
				val.y = Random.Range(4f, 8f);
				SpawnPrefab(DrakeAddPrefab, ((Component)this).transform.position + val, Quaternion.identity);
			}
			if ((Object)(object)MessageHud.instance != (Object)null)
			{
				MessageHud.instance.ShowMessage((MessageType)1, "Storm drakes descend from the clouds.", 0, (Sprite)null, false);
			}
		}

		private void SpawnSerpent()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Random.insideUnitSphere * 22f;
			val.y = 0f;
			SpawnPrefab(SerpentAddPrefab, ((Component)this).transform.position + val, Quaternion.identity);
			if ((Object)(object)MessageHud.instance != (Object)null)
			{
				MessageHud.instance.ShowMessage((MessageType)1, "Something coils beneath the waves...", 0, (Sprite)null, false);
			}
		}

		private void SpawnPrefab(string prefabName, Vector3 position, Quaternion rotation)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)ZNetScene.instance == (Object)null))
			{
				GameObject prefab = ZNetScene.instance.GetPrefab(prefabName);
				if ((Object)(object)prefab == (Object)null)
				{
					Debug.LogError((object)("Could not find prefab: " + prefabName));
				}
				else
				{
					Object.Instantiate<GameObject>(prefab, position, rotation);
				}
			}
		}
	}

	public class HavstormrLightningImpactAoE : MonoBehaviour
	{
		public float Radius = 4f;

		public float LightningDamage = 12f;

		public float BluntDamage = 4f;

		public float PushForce = 12f;

		public GameObject ImpactFx;

		private bool hasTriggered = false;

		private void OnDestroy()
		{
			TriggerImpact();
		}

		private void TriggerImpact()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			if (!hasTriggered)
			{
				hasTriggered = true;
				if ((Object)(object)ImpactFx != (Object)null)
				{
					Object.Instantiate<GameObject>(ImpactFx, ((Component)this).transform.position, Quaternion.identity);
				}
				ApplyAoE();
			}
		}

		private void ApplyAoE()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Invalid comparison between Unknown and I4
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_0099: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, Radius);
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				Character componentInParent = ((Component)val).GetComponentInParent<Character>();
				if (!((Object)(object)componentInParent == (Object)null) && !componentInParent.IsDead() && (int)componentInParent.GetFaction() != 8)
				{
					HitData val2 = new HitData();
					val2.m_damage.m_lightning = LightningDamage;
					val2.m_damage.m_blunt = BluntDamage;
					val2.m_point = ((Component)componentInParent).transform.position;
					Vector3 val3 = ((Component)componentInParent).transform.position - ((Component)this).transform.position;
					val2.m_dir = ((Vector3)(ref val3)).normalized;
					val2.m_pushForce = PushForce;
					val2.m_backstabBonus = 1f;
					componentInParent.Damage(val2);
				}
			}
		}
	}

	public class ErikSpawnerController : MonoBehaviour
	{
		public string ErikPrefabName = "ErikTheRed";

		public float SpawnRadius = 5f;

		public float TriggerDistance = 60f;

		public float CheckInterval = 500f;

		public int MaxAlive = 1;

		private float timer;

		private readonly List<Character> spawned = new List<Character>();

		private void Start()
		{
			timer = 2f;
		}

		private void Update()
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			timer -= Time.deltaTime;
			if (timer > 0f)
			{
				return;
			}
			timer = CheckInterval;
			if ((Object)(object)ZNet.instance != (Object)null && !ZNet.instance.IsServer())
			{
				return;
			}
			CleanupDead();
			if (spawned.Count < MaxAlive)
			{
				Player closestPlayer = Player.GetClosestPlayer(((Component)this).transform.position, TriggerDistance);
				if (!((Object)(object)closestPlayer == (Object)null))
				{
					SpawnErik();
				}
			}
		}

		private void CleanupDead()
		{
			for (int num = spawned.Count - 1; num >= 0; num--)
			{
				if ((Object)(object)spawned[num] == (Object)null || spawned[num].IsDead())
				{
					spawned.RemoveAt(num);
				}
			}
		}

		private void SpawnErik()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ZNetScene.instance == (Object)null)
			{
				return;
			}
			GameObject prefab = ZNetScene.instance.GetPrefab(ErikPrefabName);
			if ((Object)(object)prefab == (Object)null)
			{
				Debug.LogWarning((object)("[Vanaheim] ErikSpawner could not find prefab: " + ErikPrefabName));
				return;
			}
			Vector2 val = Random.insideUnitCircle * SpawnRadius;
			Vector3 val2 = ((Component)this).transform.position + new Vector3(val.x, 0f, val.y);
			val2.y = ((Component)this).transform.position.y;
			GameObject val3 = Object.Instantiate<GameObject>(prefab, val2, Quaternion.identity);
			Character component = val3.GetComponent<Character>();
			if ((Object)(object)component != (Object)null)
			{
				spawned.Add(component);
			}
		}
	}

	private const string PluginGuid = "vanaheim.havstormr";

	private const string PluginName = "Vanaheim - Havstormr";

	private const string PluginVersion = "1.0.0";

	private const string MoldrikrBossPrefabName = "Vanaheim_Moldrikr";

	private const string BlackTickPrefabName = "Vanaheim_BlackBrood";

	private const string BaseMoldrikrBossPrefabName = "SeekerBrute";

	private const string BaseTickPrefabName = "Tick";

	private const string MoldrikrBundleName = "moldrikrvisual";

	private const string MoldrikrStaffPrefabName = "Vanaheim_StaffMoldrikr";

	private const string BaseMoldrikrStaffPrefabName = "StaffGreenRoots";

	private const string BlackBroodSpawnPrefabName = "staff_blackbrood_spawn";

	private const string BlackBroodProjectilePrefabName = "staff_blackbrood_projectile";

	private const string BaseGreenRootsSpawnPrefabName = "staff_greenroots_spawn";

	private const string BaseGreenRootsProjectilePrefabName = "staff_greenroots_projectile";

	private const float MoldrikrHealth = 18000f;

	private const float MoldrikrBaseAttackDamageMultiplier = 2.25f;

	private const float BlackTickHealth = 180f;

	private const float BlackTickDamageMultiplier = 1.5f;

	private const string MoldrikrSeekerSummonPrefabName = "Vanaheim_MoldrikrSeeker";

	private const string BaseSeekerPrefabName = "Seeker";

	private AssetBundle moldrikrVisualBundle;

	private GameObject moldrikrVisualPrefab;

	private void Awake()
	{
		PrefabManager.OnVanillaPrefabsAvailable += CreatePrefabs;
		ItemManager.OnItemsRegistered += FixJournalIcon;
	}

	private void CreatePrefabs()
	{
		LoadMoldrikrVisualBundle();
		CreateHavstormrTrophy();
		CreateStormpiercerBow();
		CreateErikJournal();
		CreateEnchantedBlackmetal();
		CreateHavstormrChains();
		CreateHavstormr();
		CreateStormDrake();
		CreateStormSerpent();
		CreateErikTheRed();
		CreateErikSpawner();
		CreatePortalStone();
		CreateBlackTick();
		CreateMoldrikr();
		CreateMoldrikrSeekerSummon();
		CreateBlackBroodSpawn();
		CreateBlackBroodProjectile();
		CreateMoldrikrStaff();
		LoadDeadSerpentRock();
		PrefabManager.OnVanillaPrefabsAvailable -= CreatePrefabs;
	}

	private void LoadDeadSerpentRock()
	{
		string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
		string text = Path.Combine(directoryName, "Bundles", "deadserpentbundle");
		if (!File.Exists(text))
		{
			text = Path.Combine(directoryName, "deadserpentbundle");
		}
		AssetBundle val = AssetBundle.LoadFromFile(text);
		if ((Object)(object)val == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load deadserpentbundle at: " + text));
			return;
		}
		RegisterBundlePrefab(val, "DeadSerpent_Rock");
		RegisterBundlePrefab(val, "DeadSerpent_Rock2");
	}

	private void RegisterBundlePrefab(AssetBundle bundle, string prefabName)
	{
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Expected O, but got Unknown
		GameObject val = bundle.LoadAsset<GameObject>(prefabName);
		if ((Object)(object)val == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load prefab named " + prefabName + " from deadserpentbundle."));
			return;
		}
		((Object)val).name = prefabName;
		StripMineRockComponents(val);
		CustomPrefab val2 = new CustomPrefab(val, true);
		PrefabManager.Instance.AddPrefab(val2);
	}

	private GameObject GetItemPrefabSafe(string prefabName)
	{
		GameObject val = null;
		if ((Object)(object)ObjectDB.instance != (Object)null)
		{
			val = ObjectDB.instance.GetItemPrefab(prefabName);
		}
		if ((Object)(object)val == (Object)null)
		{
			val = PrefabManager.Instance.GetPrefab(prefabName);
		}
		if ((Object)(object)val == (Object)null && (Object)(object)ZNetScene.instance != (Object)null)
		{
			val = ZNetScene.instance.GetPrefab(prefabName);
		}
		if ((Object)(object)val == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not find item prefab: " + prefabName));
		}
		return val;
	}

	private Transform FindDeepChild(Transform parent, string name)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		foreach (Transform item in parent)
		{
			Transform val = item;
			if (((Object)val).name == name)
			{
				return val;
			}
			Transform val2 = FindDeepChild(val, name);
			if ((Object)(object)val2 != (Object)null)
			{
				return val2;
			}
		}
		return null;
	}

	private void StripMineRockComponents(GameObject prefab)
	{
		MineRock5[] componentsInChildren = prefab.GetComponentsInChildren<MineRock5>(true);
		foreach (MineRock5 val in componentsInChildren)
		{
			Object.DestroyImmediate((Object)(object)val);
		}
		MineRock[] componentsInChildren2 = prefab.GetComponentsInChildren<MineRock>(true);
		foreach (MineRock val2 in componentsInChildren2)
		{
			Object.DestroyImmediate((Object)(object)val2);
		}
		Destructible[] componentsInChildren3 = prefab.GetComponentsInChildren<Destructible>(true);
		foreach (Destructible val3 in componentsInChildren3)
		{
			Object.DestroyImmediate((Object)(object)val3);
		}
		WearNTear[] componentsInChildren4 = prefab.GetComponentsInChildren<WearNTear>(true);
		foreach (WearNTear val4 in componentsInChildren4)
		{
			Object.DestroyImmediate((Object)(object)val4);
		}
	}

	private void CreateErikTheRed()
	{
		//IL_001c: 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_0164: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = PrefabManager.Instance.CreateClonedPrefab("ErikTheRed", "Skeleton");
		val.transform.localScale = Vector3.one * 1.5f;
		Character component = val.GetComponent<Character>();
		if ((Object)(object)component != (Object)null)
		{
			component.m_name = "Erik the Red";
			component.m_health = 500f;
		}
		Humanoid component2 = val.GetComponent<Humanoid>();
		if ((Object)(object)component2 != (Object)null)
		{
			GameObject itemPrefabSafe = GetItemPrefabSafe("ArmorCaptainHelmetDO");
			if ((Object)(object)itemPrefabSafe != (Object)null)
			{
				AdjustErikHelmetPrefab(itemPrefabSafe);
			}
			GameObject itemPrefabSafe2 = GetItemPrefabSafe("skeleton_sword_hildir");
			if ((Object)(object)itemPrefabSafe2 != (Object)null)
			{
				TintErikSword(itemPrefabSafe2);
			}
			GameObject itemPrefabSafe3 = GetItemPrefabSafe("ArmorIronChest");
			List<GameObject> list = new List<GameObject>();
			if ((Object)(object)itemPrefabSafe2 != (Object)null)
			{
				list.Add(itemPrefabSafe2);
			}
			if ((Object)(object)itemPrefabSafe3 != (Object)null)
			{
				list.Add(itemPrefabSafe3);
			}
			component2.m_defaultItems = list.ToArray();
			component2.m_randomWeapon = (GameObject[])(object)new GameObject[0];
			component2.m_randomArmor = (GameObject[])(object)new GameObject[0];
			component2.m_randomShield = (GameObject[])(object)new GameObject[0];
		}
		else
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"ErikTheRed clone has no Humanoid component.");
		}
		TintObject(val, new Color(0.55f, 0.48f, 0.42f, 1f));
		AddErikHat(val);
		ConfigureErikDrops(val);
		PrefabManager.Instance.AddPrefab(val);
	}

	private void CreateHavstormr()
	{
		//IL_001c: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = PrefabManager.Instance.CreateClonedPrefab("Havstormr", "Dragon");
		val.transform.localScale = Vector3.one * 1.5f;
		Character component = val.GetComponent<Character>();
		if ((Object)(object)component != (Object)null)
		{
			component.m_name = "Havstormr, the Abyssal Tyrant";
			component.m_health = 10000f;
			component.m_defeatSetGlobalKey = null;
			component.m_bossEvent = "";
			ConfigureResistances(component);
		}
		ConfigureHavstormrAI(val);
		ConfigureHavstormrBreathDamage(val);
		ConfigureHavstormrLightningVisuals(val);
		TintObject(val, new Color(0.05f, 0.12f, 0.35f, 1f));
		ConfigureHavstormrDrops(val);
		HavstormrController havstormrController = val.AddComponent<HavstormrController>();
		havstormrController.StormEnvironment = "ThunderStorm";
		havstormrController.DrakeAddPrefab = "Havstormr_Drake";
		havstormrController.SerpentAddPrefab = "Havstormr_Serpent";
		PrefabManager.Instance.AddPrefab(val);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Created Havstormr prefab.");
	}

	private void ConfigureHavstormrLightningVisuals(GameObject boss)
	{
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		Humanoid component = boss.GetComponent<Humanoid>();
		if ((Object)(object)component == (Object)null)
		{
			return;
		}
		GameObject prefab = PrefabManager.Instance.GetPrefab("fx_eikthyr_forwardshockwave");
		if ((Object)(object)prefab == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not find lightning FX prefab.");
			return;
		}
		GameObject[] defaultItems = component.m_defaultItems;
		foreach (GameObject val in defaultItems)
		{
			if ((Object)(object)val == (Object)null)
			{
				continue;
			}
			string text = ((Object)val).name.ToLower();
			if (!text.Contains("spit") && !text.Contains("cold") && !text.Contains("breath"))
			{
				continue;
			}
			ItemDrop component2 = val.GetComponent<ItemDrop>();
			if ((Object)(object)component2 == (Object)null)
			{
				continue;
			}
			SharedData shared = component2.m_itemData.m_shared;
			if (shared.m_attack != null && !((Object)(object)shared.m_attack.m_attackProjectile == (Object)null))
			{
				GameObject attackProjectile = shared.m_attack.m_attackProjectile;
				Projectile component3 = attackProjectile.GetComponent<Projectile>();
				TintObject(attackProjectile, new Color(0.15f, 0.55f, 1f, 1f));
				Light[] componentsInChildren = attackProjectile.GetComponentsInChildren<Light>(true);
				Light[] array = componentsInChildren;
				foreach (Light val2 in array)
				{
					val2.color = new Color(0.25f, 0.65f, 1f, 1f);
					val2.intensity = 3f;
				}
				ParticleSystem[] componentsInChildren2 = attackProjectile.GetComponentsInChildren<ParticleSystem>(true);
				ParticleSystem[] array2 = componentsInChildren2;
				foreach (ParticleSystem val3 in array2)
				{
					MainModule main = val3.main;
					((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.25f, 0.75f, 1f, 1f));
				}
				if (!((Object)(object)component3 == (Object)null))
				{
					component3.m_spawnOnHit = prefab;
				}
			}
		}
	}

	private void FixJournalIcon()
	{
		GameObject val = PrefabManager.Instance.GetPrefab("MWL_SkillBook_Run_bookTier1") ?? PrefabManager.Instance.GetPrefab("MWL_skillBook_Run_bookTier1");
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		ItemDrop component = val.GetComponent<ItemDrop>();
		object obj;
		if (component == null)
		{
			obj = null;
		}
		else
		{
			ItemData itemData = component.m_itemData;
			if (itemData == null)
			{
				obj = null;
			}
			else
			{
				SharedData shared = itemData.m_shared;
				if (shared == null)
				{
					obj = null;
				}
				else
				{
					Sprite[] icons = shared.m_icons;
					obj = ((icons != null) ? icons[0] : null);
				}
			}
		}
		Sprite val2 = (Sprite)obj;
		GameObject prefab = PrefabManager.Instance.GetPrefab("Journal_ErikTheRed");
		if ((Object)(object)prefab == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"Journal_ErikTheRed prefab missing during icon patch.");
			return;
		}
		ItemDrop component2 = prefab.GetComponent<ItemDrop>();
		if ((Object)(object)component2 != (Object)null && (Object)(object)val2 != (Object)null)
		{
			component2.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { val2 };
		}
	}

	private void ConfigureHavstormrAI(GameObject boss)
	{
		MonsterAI component = boss.GetComponent<MonsterAI>();
		if ((Object)(object)component == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"Havstormr has no MonsterAI component.");
			return;
		}
		((BaseAI)component).m_deathMessage = "Havstormr falls. The storm begins to break.";
		((BaseAI)component).m_randomFly = true;
		((BaseAI)component).m_chanceToLand = 0f;
		((BaseAI)component).m_groundDuration = 0f;
		((BaseAI)component).m_airDuration = 9999f;
		((BaseAI)component).m_flyAltitudeMin = 10f;
		((BaseAI)component).m_flyAltitudeMax = 25f;
		((BaseAI)component).m_flyAbsMinAltitude = 10f;
		((BaseAI)component).m_maxLandAltitude = -1000f;
		((BaseAI)component).m_takeoffTime = 1f;
		((BaseAI)component).m_viewRange = 90f;
		((BaseAI)component).m_viewAngle = 160f;
		((BaseAI)component).m_hearRange = 9999f;
		component.m_maxChaseDistance = 120f;
		component.m_attackPlayerObjects = true;
		((BaseAI)component).m_randomMoveRange = 32f;
		component.m_circleTargetDistance = 25f;
		component.m_circleTargetInterval = 2f;
		Character component2 = boss.GetComponent<Character>();
		if ((Object)(object)component2 != (Object)null)
		{
			component2.m_flySlowSpeed = 8f;
			component2.m_flyFastSpeed = 18f;
			component2.m_flyTurnSpeed = 130f;
			component2.m_acceleration = 0.8f;
		}
	}

	private void ConfigureHavstormrBreathDamage(GameObject boss)
	{
		Humanoid component = boss.GetComponent<Humanoid>();
		if ((Object)(object)component == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"Havstormr has no Humanoid component.");
			return;
		}
		GameObject[] defaultItems = component.m_defaultItems;
		foreach (GameObject val in defaultItems)
		{
			if ((Object)(object)val == (Object)null)
			{
				continue;
			}
			string text = ((Object)val).name.ToLower();
			if (!text.Contains("spit") && !text.Contains("cold") && !text.Contains("breath"))
			{
				continue;
			}
			ItemDrop component2 = val.GetComponent<ItemDrop>();
			if ((Object)(object)component2 == (Object)null)
			{
				continue;
			}
			SharedData shared = component2.m_itemData.m_shared;
			if (shared.m_attack == null || (Object)(object)shared.m_attack.m_attackProjectile == (Object)null)
			{
				continue;
			}
			shared.m_attack.m_projectiles = 4;
			shared.m_attack.m_projectileBursts = 1;
			GameObject attackProjectile = shared.m_attack.m_attackProjectile;
			Projectile component3 = attackProjectile.GetComponent<Projectile>();
			if ((Object)(object)component3 == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("Breath projectile has no Projectile component: " + ((Object)attackProjectile).name));
				continue;
			}
			HavstormrLightningImpactAoE havstormrLightningImpactAoE = attackProjectile.GetComponent<HavstormrLightningImpactAoE>();
			if ((Object)(object)havstormrLightningImpactAoE == (Object)null)
			{
				havstormrLightningImpactAoE = attackProjectile.AddComponent<HavstormrLightningImpactAoE>();
			}
			GameObject prefab = PrefabManager.Instance.GetPrefab("fx_eikthyr_forwardshockwave");
			havstormrLightningImpactAoE.ImpactFx = prefab;
			havstormrLightningImpactAoE.Radius = 4f;
			havstormrLightningImpactAoE.LightningDamage = 8f;
			havstormrLightningImpactAoE.BluntDamage = 4f;
			havstormrLightningImpactAoE.PushForce = 12f;
			component3.m_damage.m_lightning = 65f;
			component3.m_damage.m_frost = 0f;
		}
	}

	private void CreateStormDrake()
	{
		//IL_001c: 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_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = PrefabManager.Instance.CreateClonedPrefab("Havstormr_Drake", "Hatchling");
		val.transform.localScale = Vector3.one * 1.1f;
		Character component = val.GetComponent<Character>();
		if ((Object)(object)component != (Object)null)
		{
			component.m_name = "Storm Drake";
			component.m_health = 325f;
			component.m_faction = (Faction)8;
		}
		TintObject(val, new Color(0.1f, 0.25f, 0.65f, 1f));
		PrefabManager.Instance.AddPrefab(val);
	}

	private void CreateStormSerpent()
	{
		//IL_001c: 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_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = PrefabManager.Instance.CreateClonedPrefab("Havstormr_Serpent", "Serpent");
		val.transform.localScale = Vector3.one * 0.8f;
		Character component = val.GetComponent<Character>();
		if ((Object)(object)component != (Object)null)
		{
			component.m_name = "Abyssal Serpent";
			component.m_health = 650f;
			component.m_faction = (Faction)8;
		}
		TintObject(val, new Color(0.02f, 0.08f, 0.22f, 1f));
		PrefabManager.Instance.AddPrefab(val);
	}

	private void CreatePortalStone()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Expected O, but got Unknown
		ItemConfig val = new ItemConfig
		{
			Name = "Portal Stone",
			Description = "A charged stone humming with portal magic."
		};
		CustomItem val2 = new CustomItem("PortalStone", "Thunderstone", val);
		ItemManager.Instance.AddItem(val2);
	}

	private void CreateEnchantedBlackmetal()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Expected O, but got Unknown
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		ItemConfig val = new ItemConfig
		{
			Name = "Enchanted Blackmetal",
			Description = "A dark alloy humming with stormbound power."
		};
		CustomItem val2 = new CustomItem("EnchantedBlackmetal", "BlackMetalScrap", val);
		TintObject(val2.ItemPrefab, new Color(0.3f, 0.3f, 0.6f, 1f));
		ItemManager.Instance.AddItem(val2);
	}

	private void CreateHavstormrChains()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Expected O, but got Unknown
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Expected O, but got Unknown
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Expected O, but got Unknown
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Expected O, but got Unknown
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Expected O, but got Unknown
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Expected O, but got Unknown
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Expected O, but got Unknown
		ItemConfig val = new ItemConfig
		{
			Name = "Havstormr's Chains",
			Description = "Forged to bind the storm itself. The metal hums with restrained lightning, as if something within struggles to break free."
		};
		CustomItem val2 = new CustomItem("HavstormrChains", "Chain", val);
		ItemManager.Instance.AddItem(val2);
		RecipeConfig val3 = new RecipeConfig();
		val3.Name = "Recipe_HavstormrChains";
		val3.Item = "HavstormrChains";
		val3.Amount = 1;
		val3.CraftingStation = "forge";
		val3.MinStationLevel = 1;
		val3.Requirements = (RequirementConfig[])(object)new RequirementConfig[4]
		{
			new RequirementConfig("EnchantedBlackmetal", 1, 0, true),
			new RequirementConfig("Chain", 3, 0, true),
			new RequirementConfig("Iron", 25, 0, true),
			new RequirementConfig("Silver", 25, 0, true)
		};
		RecipeConfig val4 = val3;
		CustomRecipe val5 = new CustomRecipe(val4);
		ItemManager.Instance.AddRecipe(val5);
	}

	private void CreateErikJournal()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Expected O, but got Unknown
		ItemConfig val = new ItemConfig
		{
			Name = "Journal of Erik the Red",
			Description = "You see numerous references to a great storm and beast. Erik was obsessed with taking its power and treasure for himself. You see a map with a set of coordinates."
		};
		CustomItem val2 = new CustomItem("Journal_ErikTheRed", "TrophyNeck", val);
		GameObject val3 = GetItemPrefabSafe("MWL_SkillBook_Run_bookTier1") ?? GetItemPrefabSafe("MWL_skillBook_Run_bookTier1");
		if ((Object)(object)val3 != (Object)null)
		{
			ItemDrop component = val3.GetComponent<ItemDrop>();
			ItemDrop component2 = val2.ItemPrefab.GetComponent<ItemDrop>();
			if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null)
			{
				component2.m_itemData.m_shared.m_icons = component.m_itemData.m_shared.m_icons;
			}
		}
		ItemManager.Instance.AddItem(val2);
	}

	private void CreateHavstormrTrophy()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Expected O, but got Unknown
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		ItemConfig val = new ItemConfig
		{
			Name = "Havstormr Trophy",
			Description = "A storm-darkened trophy torn from Havstormr, the Abyssal Tyrant."
		};
		CustomItem val2 = new CustomItem("Havstormr_Trophy", "TrophyDragonQueen", val);
		TintObject(val2.ItemPrefab, new Color(0.05f, 0.12f, 0.35f, 1f));
		ItemManager.Instance.AddItem(val2);
	}

	private void CreateStormpiercerBow()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Expected O, but got Unknown
		ItemConfig val = new ItemConfig
		{
			Name = "Stormpiercer",
			Description = "A bow carved from stormbone and abyssal scale. Its arrows crackle with thunder and freezing sea-wind."
		};
		CustomItem val2 = new CustomItem("Havstormr_Bow", "BowDraugrFang", val);
		ItemDrop component = val2.ItemPrefab.GetComponent<ItemDrop>();
		if ((Object)(object)component != (Object)null)
		{
			component.m_itemData.m_shared.m_name = "Stormpiercer";
			component.m_itemData.m_shared.m_description = "A bow carved from stormbone and abyssal scale. Its arrows crackle with thunder and freezing sea-wind.";
			component.m_itemData.m_shared.m_damages.m_pierce = 85f;
			component.m_itemData.m_shared.m_damages.m_frost = 12f;
			component.m_itemData.m_shared.m_damages.m_lightning = 18f;
			component.m_itemData.m_shared.m_damages.m_poison = 0f;
			component.m_itemData.m_shared.m_damages.m_spirit = 0f;
			component.m_itemData.m_shared.m_attackForce = 25f;
			component.m_itemData.m_shared.m_maxDurability = 250f;
			component.m_itemData.m_shared.m_useDurabilityDrain = 1f;
			component.m_itemData.m_shared.m_movementModifier = -0.05f;
		}
		TintStormpiercer(val2.ItemPrefab);
		ItemManager.Instance.AddItem(val2);
	}

	private void ConfigureResistances(Character character)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		DamageModifiers damageModifiers = character.m_damageModifiers;
		damageModifiers.m_frost = (DamageModifier)3;
		damageModifiers.m_lightning = (DamageModifier)3;
		damageModifiers.m_pierce = (DamageModifier)2;
		character.m_damageModifiers = damageModifiers;
	}

	private void ConfigureErikDrops(GameObject erik)
	{
		CharacterDrop val = erik.GetComponent<CharacterDrop>();
		if ((Object)(object)val == (Object)null)
		{
			val = erik.AddComponent<CharacterDrop>();
		}
		val.m_drops.Clear();
		AddDrop(val, "Journal_ErikTheRed", 1, 1, 1f);
	}

	private void ConfigureHavstormrDrops(GameObject boss)
	{
		CharacterDrop val = boss.GetComponent<CharacterDrop>();
		if ((Object)(object)val == (Object)null)
		{
			val = boss.AddComponent<CharacterDrop>();
		}
		val.m_drops.Clear();
		AddDrop(val, "Havstormr_Trophy", 1, 1, 1f);
		AddDrop(val, "SerpentScale", 8, 16, 1f);
		AddDrop(val, "Coins", 100, 250, 1f);
	}

	private void AddDrop(CharacterDrop drops, string prefabName, int min, int max, float chance)
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: 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_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Expected O, but got Unknown
		GameObject prefab = PrefabManager.Instance.GetPrefab(prefabName);
		if ((Object)(object)prefab == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("Drop prefab not found: " + prefabName));
			return;
		}
		drops.m_drops.Add(new Drop
		{
			m_prefab = prefab,
			m_amountMin = min,
			m_amountMax = max,
			m_chance = chance,
			m_levelMultiplier = false,
			m_onePerPlayer = false
		});
	}

	private void CreateErikSpawner()
	{
		GameObject val = PrefabManager.Instance.CreateClonedPrefab("Spawner_ErikTheRed", "Spawner_Ghost");
		SpawnArea[] componentsInChildren = val.GetComponentsInChildren<SpawnArea>(true);
		foreach (SpawnArea val2 in componentsInChildren)
		{
			Object.DestroyImmediate((Object)(object)val2);
		}
		CreatureSpawner[] componentsInChildren2 = val.GetComponentsInChildren<CreatureSpawner>(true);
		foreach (CreatureSpawner val3 in componentsInChildren2)
		{
			Object.DestroyImmediate((Object)(object)val3);
		}
		ErikSpawnerController erikSpawnerController = val.GetComponent<ErikSpawnerController>();
		if ((Object)(object)erikSpawnerController == (Object)null)
		{
			erikSpawnerController = val.AddComponent<ErikSpawnerController>();
		}
		erikSpawnerController.ErikPrefabName = "ErikTheRed";
		erikSpawnerController.SpawnRadius = 5f;
		erikSpawnerController.TriggerDistance = 60f;
		erikSpawnerController.CheckInterval = 500f;
		erikSpawnerController.MaxAlive = 1;
		PrefabManager.Instance.AddPrefab(val);
	}

	private void AddErikHat(GameObject erik)
	{
		//IL_0175: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		GameObject itemPrefabSafe = GetItemPrefabSafe("ArmorCaptainHelmetDO");
		if ((Object)(object)itemPrefabSafe == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"ArmorCaptainHelmetDO not found for Erik visual hat.");
			return;
		}
		Transform val = FindDeepChild(erik.transform, "Head");
		if ((Object)(object)val == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"Erik head bone not found for visual hat.");
			return;
		}
		GameObject val2 = Object.Instantiate<GameObject>(itemPrefabSafe, val, false);
		((Object)val2).name = "ErikTheRed_VisualHat";
		Collider[] componentsInChildren = val2.GetComponentsInChildren<Collider>(true);
		foreach (Collider val3 in componentsInChildren)
		{
			Object.DestroyImmediate((Object)(object)val3);
		}
		Rigidbody[] componentsInChildren2 = val2.GetComponentsInChildren<Rigidbody>(true);
		foreach (Rigidbody val4 in componentsInChildren2)
		{
			Object.DestroyImmediate((Object)(object)val4);
		}
		ZSyncTransform[] componentsInChildren3 = val2.GetComponentsInChildren<ZSyncTransform>(true);
		foreach (ZSyncTransform val5 in componentsInChildren3)
		{
			Object.DestroyImmediate((Object)(object)val5);
		}
		ZNetView[] componentsInChildren4 = val2.GetComponentsInChildren<ZNetView>(true);
		foreach (ZNetView val6 in componentsInChildren4)
		{
			Object.DestroyImmediate((Object)(object)val6);
		}
		ItemDrop[] componentsInChildren5 = val2.GetComponentsInChildren<ItemDrop>(true);
		foreach (ItemDrop val7 in componentsInChildren5)
		{
			Object.DestroyImmediate((Object)(object)val7);
		}
		val2.transform.localPosition = new Vector3(0.001f, 0.0021f, -0.0004f);
		val2.transform.localRotation = Quaternion.Euler(350f, 295.3f, 345f);
		val2.transform.localScale = Vector3.one * 0.013f;
	}

	private void TintErikSword(GameObject sword)
	{
		//IL_026e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0273: Unknown result type (might be due to invalid IL or missing references)
		//IL_028b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0290: Unknown result type (might be due to invalid IL or missing references)
		//IL_029d: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b4: Expected O, but got Unknown
		//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dc: 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)
		//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0301: Unknown result type (might be due to invalid IL or missing references)
		//IL_0317: Unknown result type (might be due to invalid IL or missing references)
		//IL_0321: Unknown result type (might be due to invalid IL or missing references)
		//IL_0326: Unknown result type (might be due to invalid IL or missing references)
		//IL_033d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0342: Unknown result type (might be due to invalid IL or missing references)
		//IL_0353: Unknown result type (might be due to invalid IL or missing references)
		//IL_0358: Unknown result type (might be due to invalid IL or missing references)
		//IL_0369: Unknown result type (might be due to invalid IL or missing references)
		//IL_036e: Unknown result type (might be due to invalid IL or missing references)
		//IL_037d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0413: Unknown result type (might be due to invalid IL or missing references)
		//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c3: Expected O, but got Unknown
		//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0501: Unknown result type (might be due to invalid IL or missing references)
		//IL_050b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0510: Unknown result type (might be due to invalid IL or missing references)
		//IL_0526: Unknown result type (might be due to invalid IL or missing references)
		//IL_0530: Unknown result type (might be due to invalid IL or missing references)
		//IL_0535: Unknown result type (might be due to invalid IL or missing references)
		//IL_054c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0551: Unknown result type (might be due to invalid IL or missing references)
		//IL_0562: Unknown result type (might be due to invalid IL or missing references)
		//IL_0567: Unknown result type (might be due to invalid IL or missing references)
		//IL_0578: Unknown result type (might be due to invalid IL or missing references)
		//IL_057d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_044d: Unknown result type (might be due to invalid IL or missing references)
		//IL_021f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_0482: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d5: Unknown result type (might be due to invalid IL or missing references)
		Renderer[] componentsInChildren = sword.GetComponentsInChildren<Renderer>(true);
		Renderer[] array = componentsInChildren;
		foreach (Renderer val in array)
		{
			string text = ((Object)((Component)val).gameObject).name.ToLower();
			bool flag = text.Contains("fx") || text.Contains("vfx") || text.Contains("eff") || text.Contains("particle") || text.Contains("trail") || text.Contains("flame") || text.Contains("fire") || text.Contains("glow");
			Material[] materials = val.materials;
			foreach (Material val2 in materials)
			{
				if (!flag)
				{
					if (val2.HasProperty("_EmissionColor"))
					{
						val2.DisableKeyword("_EMISSION");
						val2.SetColor("_EmissionColor", Color.black);
					}
					if (val2.HasProperty("_Color"))
					{
						val2.color = new Color(0.72f, 0.74f, 0.76f, 1f);
					}
					if (val2.HasProperty("_TintColor"))
					{
						val2.SetColor("_TintColor", new Color(0.72f, 0.74f, 0.76f, 1f));
					}
				}
				else
				{
					if (val2.HasProperty("_EmissionColor"))
					{
						val2.EnableKeyword("_EMISSION");
						val2.SetColor("_EmissionColor", new Color(0.1f, 0.65f, 2f, 1f));
					}
					if (val2.HasProperty("_TintColor"))
					{
						val2.SetColor("_TintColor", new Color(0.15f, 0.65f, 1.6f, 1f));
					}
					if (val2.HasProperty("_Color"))
					{
						val2.color = new Color(0.2f, 0.7f, 1.4f, 1f);
					}
				}
			}
		}
		ParticleSystem[] componentsInChildren2 = sword.GetComponentsInChildren<ParticleSystem>(true);
		ParticleSystem[] array2 = componentsInChildren2;
		foreach (ParticleSystem val3 in array2)
		{
			MainModule main = val3.main;
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.25f, 0.75f, 1.8f, 1f));
			ColorOverLifetimeModule colorOverLifetime = val3.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			Gradient val4 = new Gradient();
			val4.SetKeys((GradientColorKey[])(object)new GradientColorKey[3]
			{
				new GradientColorKey(new Color(0.15f, 0.55f, 2f), 0f),
				new GradientColorKey(new Color(0.55f, 0.9f, 2.2f), 0.45f),
				new GradientColorKey(new Color(0.05f, 0.25f, 1.2f), 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
			{
				new GradientAlphaKey(1f, 0f),
				new GradientAlphaKey(0.85f, 0.45f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val4);
		}
		ParticleSystemRenderer[] componentsInChildren3 = sword.GetComponentsInChildren<ParticleSystemRenderer>(true);
		ParticleSystemRenderer[] array3 = componentsInChildren3;
		foreach (ParticleSystemRenderer val5 in array3)
		{
			if (!((Object)(object)((Renderer)val5).material == (Object)null))
			{
				Material material = ((Renderer)val5).material;
				if (material.HasProperty("_EmissionColor"))
				{
					material.EnableKeyword("_EMISSION");
					material.SetColor("_EmissionColor", new Color(0.1f, 0.65f, 2f, 1f));
				}
				if (material.HasProperty("_TintColor"))
				{
					material.SetColor("_TintColor", new Color(0.15f, 0.65f, 1.6f, 1f));
				}
				if (material.HasProperty("_Color"))
				{
					material.color = new Color(0.2f, 0.7f, 1.4f, 1f);
				}
			}
		}
		TrailRenderer[] componentsInChildren4 = sword.GetComponentsInChildren<TrailRenderer>(true);
		TrailRenderer[] array4 = componentsInChildren4;
		foreach (TrailRenderer val6 in array4)
		{
			Gradient val7 = new Gradient();
			val7.SetKeys((GradientColorKey[])(object)new GradientColorKey[3]
			{
				new GradientColorKey(new Color(0.15f, 0.55f, 2f), 0f),
				new GradientColorKey(new Color(0.6f, 0.9f, 2.2f), 0.5f),
				new GradientColorKey(new Color(0.05f, 0.25f, 1.2f), 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
			{
				new GradientAlphaKey(1f, 0f),
				new GradientAlphaKey(0.8f, 0.5f),
				new GradientAlphaKey(0f, 1f)
			});
			val6.colorGradient = val7;
		}
		Light[] componentsInChildren5 = sword.GetComponentsInChildren<Light>(true);
		Light[] array5 = componentsInChildren5;
		foreach (Light val8 in array5)
		{
			val8.color = new Color(0.25f, 0.65f, 1f, 1f);
			val8.intensity = 3f;
			val8.range = Mathf.Max(val8.range, 4f);
		}
	}

	private void AdjustErikHelmetPrefab(GameObject helmet)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		helmet.transform.localPosition = new Vector3(0f, 0.45f, 0.02f);
		helmet.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
		helmet.transform.localScale = Vector3.one * 1.05f;
	}

	private void TintObject(GameObject obj, Color tint)
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		Renderer[] componentsInChildren = obj.GetComponentsInChildren<Renderer>(true);
		Renderer[] array = componentsInChildren;
		foreach (Renderer val in array)
		{
			Material[] materials = val.materials;
			foreach (Material val2 in materials)
			{
				val2.color = tint;
			}
		}
	}

	private void TintStormpiercer(GameObject bow)
	{
		//IL_0168: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c2: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
		Renderer[] componentsInChildren = bow.GetComponentsInChildren<Renderer>(true);
		Renderer[] array = componentsInChildren;
		foreach (Renderer val in array)
		{
			Material[] materials = val.materials;
			foreach (Material val2 in materials)
			{
				if (val2.HasProperty("_Color"))
				{
					val2.color = new Color(0.08f, 0.12f, 0.2f, 1f);
				}
				if (val2.HasProperty("_EmissionColor"))
				{
					val2.EnableKeyword("_EMISSION");
					val2.SetColor("_EmissionColor", new Color(0.01f, 0.04f, 0.1f, 1f));
				}
				if (val2.HasProperty("_TintColor"))
				{
					val2.SetColor("_TintColor", new Color(0.08f, 0.18f, 0.3f, 1f));
				}
			}
		}
		Light[] componentsInChildren2 = bow.GetComponentsInChildren<Light>(true);
		Light[] array2 = componentsInChildren2;
		foreach (Light val3 in array2)
		{
			val3.intensity *= 0.25f;
			val3.range *= 0.5f;
			val3.color = new Color(0.25f, 0.45f, 0.65f, 1f);
		}
		ParticleSystem[] componentsInChildren3 = bow.GetComponentsInChildren<ParticleSystem>(true);
		ParticleSystem[] array3 = componentsInChildren3;
		foreach (ParticleSystem val4 in array3)
		{
			MainModule main = val4.main;
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.15f, 0.35f, 0.65f, 0.45f));
			((MainModule)(ref main)).startSizeMultiplier = ((MainModule)(ref main)).startSizeMultiplier * 0.65f;
			((MainModule)(ref main)).startLifetimeMultiplier = ((MainModule)(ref main)).startLifetimeMultiplier * 0.75f;
			EmissionModule emission = val4.emission;
			((EmissionModule)(ref emission)).rateOverTimeMultiplier = ((EmissionModule)(ref emission)).rateOverTimeMultiplier * 0.35f;
		}
		TrailRenderer[] componentsInChildren4 = bow.GetComponentsInChildren<TrailRenderer>(true);
		TrailRenderer[] array4 = componentsInChildren4;
		foreach (TrailRenderer val5 in array4)
		{
			val5.time *= 0.5f;
			val5.widthMultiplier *= 0.5f;
		}
	}

	private void LoadMoldrikrVisualBundle()
	{
		string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
		string text = Path.Combine(directoryName, "Bundles", "moldrikrvisual");
		if (!File.Exists(text))
		{
			text = Path.Combine(directoryName, "moldrikrvisual");
		}
		moldrikrVisualBundle = AssetBundle.LoadFromFile(text);
		if ((Object)(object)moldrikrVisualBundle == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load Moldrikr visual bundle at: " + text));
			return;
		}
		string[] allAssetNames = moldrikrVisualBundle.GetAllAssetNames();
		foreach (string text2 in allAssetNames)
		{
			string text3 = text2.ToLower();
			if (text3.Contains("moldrikrvisual") && text3.EndsWith(".prefab"))
			{
				moldrikrVisualPrefab = moldrikrVisualBundle.LoadAsset<GameObject>(text2);
			}
		}
		if ((Object)(object)moldrikrVisualPrefab == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Could not find moldrikrvisual prefab in bundle.");
		}
	}

	private void CreateMoldrikr()
	{
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: Expected O, but got Unknown
		//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b2: Expected O, but got Unknown
		GameObject val = PrefabManager.Instance.CreateClonedPrefab("Vanaheim_Moldrikr", "SeekerBrute");
		if ((Object)(object)val == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Failed to clone prefab: SeekerBrute");
			return;
		}
		val.transform.localScale = Vector3.one * 2.3f;
		ApplyCustomTextureToVanillaVisual(val);
		Character component = val.GetComponent<Character>();
		if ((Object)(object)component != (Object)null)
		{
			component.m_name = "$enemy_moldrikr";
			component.m_boss = true;
			component.m_health = 18000f;
			component.m_faction = (Faction)8;
			SetAllDamageModifiers(component, (DamageModifier)5);
		}
		Humanoid component2 = val.GetComponent<Humanoid>();
		if ((Object)(object)component2 != (Object)null)
		{
			((Character)component2).m_name = "$enemy_moldrikr";
		}
		MonsterAI component3 = val.GetComponent<MonsterAI>();
		if ((Object)(object)component3 != (Object)null)
		{
			((BaseAI)component3).m_viewRange = 60f;
			component3.m_attackPlayerObjects = true;
			component3.m_circulateWhileCharging = true;
		}
		Attack[] componentsInChildren = val.GetComponentsInChildren<Attack>(true);
		foreach (Attack val2 in componentsInChildren)
		{
			val2.m_damageMultiplier *= 2.25f;
		}
		CharacterDrop component4 = val.GetComponent<CharacterDrop>();
		if ((Object)(object)component4 != (Object)null)
		{
			component4.m_drops.Clear();
			AddDrop(component4, "Carapace", 8, 14, 1f);
			AddDrop(component4, "Mandible", 2, 4, 1f);
		}
		val.AddComponent<MoldrikrController>();
		CreatureConfig val3 = new CreatureConfig
		{
			Name = "$enemy_moldrikr",
			Faction = (Faction)8
		};
		CreatureManager.Instance.AddCreature(new CustomCreature(val, false, val3));
		CustomLocalization localization = LocalizationManager.Instance.GetLocalization();
		string text = "English";
		localization.AddTranslation(ref text, new Dictionary<string, string> { { "enemy_moldrikr", "Moldrikr, The Black Carapace" } });
	}

	private void CreateBlackTick()
	{
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: 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_0150: Expected O, but got Unknown
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Expected O, but got Unknown
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = PrefabManager.Instance.CreateClonedPrefab("Vanaheim_BlackBrood", "Tick");
		if ((Object)(object)val == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Failed to clone prefab: Tick");
			return;
		}
		Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(true);
		foreach (Renderer val2 in componentsInChildren)
		{
			Material[] materials = val2.materials;
			foreach (Material val3 in materials)
			{
				if (!((Object)(object)val3 == (Object)null) && val3.HasProperty("_Color"))
				{
					val3.color = new Color(0.05f, 0.05f, 0.05f, 1f);
				}
			}
		}
		Character component = val.GetComponent<Character>();
		if ((Object)(object)component != (Object)null)
		{
			component.m_name = "$enemy_blackbrood";
			component.m_health = 180f;
		}
		Attack[] componentsInChildren2 = val.GetComponentsInChildren<Attack>(true);
		foreach (Attack val4 in componentsInChildren2)
		{
			val4.m_damageMultiplier *= 1.5f;
		}
		CreatureConfig val5 = new CreatureConfig
		{
			Name = "$enemy_blackbrood",
			Faction = (Faction)8
		};
		CreatureManager.Instance.AddCreature(new CustomCreature(val, false, val5));
		CustomLocalization localization = LocalizationManager.Instance.GetLocalization();
		string text = "English";
		localization.AddTranslation(ref text, new Dictionary<string, string> { { "enemy_blackbrood", "Black Brood" } });
	}

	private void CreateMoldrikrSeekerSummon()
	{
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Expected O, but got Unknown
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Expected O, but got Unknown
		GameObject val = PrefabManager.Instance.CreateClonedPrefab("Vanaheim_MoldrikrSeeker", "Seeker");
		if ((Object)(object)val == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Failed to clone prefab: Seeker");
			return;
		}
		val.transform.localScale = Vector3.one * 0.85f;
		val.AddComponent<TimedSummon>();
		ApplyCustomTextureToVanillaVisual(val);
		Character component = val.GetComponent<Character>();
		if ((Object)(object)component != (Object)null)
		{
			component.m_name = "$enemy_moldrikr_seeker";
			component.m_faction = (Faction)0;
		}
		CharacterDrop component2 = val.GetComponent<CharacterDrop>();
		if ((Object)(object)component2 != (Object)null)
		{
			component2.m_drops.Clear();
		}
		Humanoid component3 = val.GetComponent<Humanoid>();
		if ((Object)(object)component3 != (Object)null)
		{
			((Character)component3).m_name = "$enemy_moldrikr_seeker";
		}
		MonsterAI component4 = val.GetComponent<MonsterAI>();
		if ((Object)(object)component4 != (Object)null)
		{
			component4.m_attackPlayerObjects = false;
		}
		CreatureConfig val2 = new CreatureConfig
		{
			Name = "$enemy_moldrikr_seeker",
			Faction = (Faction)0
		};
		CreatureManager.Instance.AddCreature(new CustomCreature(val, false, val2));
		CustomLocalization localization = LocalizationManager.Instance.GetLocalization();
		string text = "English";
		localization.AddTranslation(ref text, new Dictionary<string, string> { { "enemy_moldrikr_seeker", "Black Brood Seeker" } });
	}

	private void CreateBlackBroodSpawn()
	{
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Expected O, but got Unknown
		GameObject val = PrefabManager.Instance.CreateClonedPrefab("staff_blackbrood_spawn", "staff_greenroots_spawn");
		if ((Object)(object)val == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Failed to clone prefab: staff_greenroots_spawn");
			return;
		}
		GameObject prefab = PrefabManager.Instance.GetPrefab("Vanaheim_MoldrikrSeeker");
		if ((Object)(object)prefab == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Could not find seeker summon prefab: Vanaheim_MoldrikrSeeker");
			return;
		}
		SpawnAbility component = val.GetComponent<SpawnAbility>();
		if ((Object)(object)component == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Black Brood spawn is missing SpawnAbility.");
			return;
		}
		component.m_spawnPrefab = (GameObject[])(object)new GameObject[1] { prefab };
		PrefabManager.Instance.AddPrefab(new CustomPrefab(val, false));
	}

	private void CreateBlackBroodProjectile()
	{
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Expected O, but got Unknown
		GameObject val = PrefabManager.Instance.CreateClonedPrefab("staff_blackbrood_projectile", "staff_greenroots_projectile");
		if ((Object)(object)val == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Failed to clone prefab: staff_greenroots_projectile");
			return;
		}
		GameObject prefab = PrefabManager.Instance.GetPrefab("staff_blackbrood_spawn");
		if ((Object)(object)prefab == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Could not find Black Brood spawn prefab: staff_blackbrood_spawn");
			return;
		}
		Projectile component = val.GetComponent<Projectile>();
		if ((Object)(object)component == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Black Brood projectile is missing Projectile component.");
			return;
		}
		component.m_spawnOnHit = prefab;
		PrefabManager.Instance.AddPrefab(new CustomPrefab(val, false));
	}

	private void CreateMoldrikrStaff()
	{
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Expected O, but got Unknown
		GameObject val = PrefabManager.Instance.CreateClonedPrefab("Vanaheim_StaffMoldrikr", "StaffGreenRoots");
		if ((Object)(object)val == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Failed to clone prefab: StaffGreenRoots");
			return;
		}
		ItemDrop component = val.GetComponent<ItemDrop>();
		if ((Object)(object)component != (Object)null)
		{
			component.m_itemData.m_shared.m_name = "$item_staff_moldrikr";
			component.m_itemData.m_shared.m_description = "A blackened staff pulsing with corrupted brood magic.";
		}
		GameObject prefab = PrefabManager.Instance.GetPrefab("staff_blackbrood_projectile");
		if ((Object)(object)prefab == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Could not find Black Brood projectile prefab: staff_blackbrood_projectile");
		}
		else if ((Object)(object)component != (Object)null)
		{
			component.m_itemData.m_shared.m_attack.m_attackProjectile = prefab;
		}
		RethemeStaffVFX(val);
		ItemManager.Instance.AddItem(new CustomItem(val, false));
		CustomLocalization localization = LocalizationManager.Instance.GetLocalization();
		string text = "English";
		localization.AddTranslation(ref text, new Dictionary<string, string> { { "item_staff_moldrikr", "Staff of the Black Brood" } });
	}

	private void RethemeStaffVFX(GameObject staff)
	{
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: 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_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_0225: Unknown result type (might be due to invalid IL or missing references)
		//IL_0245: Unknown result type (might be due to invalid IL or missing references)
		Color val = default(Color);
		((Color)(ref val))..ctor(0.04f, 0.35f, 0.07f, 0.65f);
		Color color = default(Color);
		((Color)(ref color))..ctor(0.005f, 0.04f, 0.015f, 0.55f);
		Color color2 = default(Color);
		((Color)(ref color2))..ctor(0.12f, 0.65f, 0.1f, 0.45f);
		ParticleSystem[] componentsInChildren = staff.GetComponentsInChildren<ParticleSystem>(true);
		foreach (ParticleSystem val2 in componentsInChildren)
		{
			string text = GetTransformPath(((Component)val2).transform).ToLower();
			if (text.Contains("spores"))
			{
				((Component)val2).gameObject.SetActive(false);
				continue;
			}
			MainModule main = val2.main;
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(val);
			((MainModule)(ref main)).startSizeMultiplier = ((MainModule)(ref main)).startSizeMultiplier * 0.75f;
			EmissionModule emission = val2.emission;
			((EmissionModule)(ref emission)).rateOverTimeMultiplier = ((EmissionModule)(ref emission)).rateOverTimeMultiplier * 0.35f;
			ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime;
			if (((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled)
			{
				((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val);
			}
		}
		Light[] componentsInChildren2 = staff.GetComponentsInChildren<Light>(true);
		foreach (Light val3 in componentsInChildren2)
		{
			val3.color = color2;
			val3.intensity *= 0.25f;
			val3.range *= 0.75f;
		}
		Renderer[] componentsInChildren3 = staff.GetComponentsInChildren<Renderer>(true);
		foreach (Renderer val4 in componentsInChildren3)
		{
			string text2 = GetTransformPath(((Component)val4).transform).ToLower();
			if (!text2.Contains("glow") && !text2.Contains("flare") && !text2.Contains("flames") && !text2.Contains("embers"))
			{
				continue;
			}
			Material[] materials = val4.materials;
			foreach (Material val5 in materials)
			{
				if (!((Object)(object)val5 == (Object)null))
				{
					if (val5.HasProperty("_Color"))
					{
						val5.color = color;
					}
					if (val5.HasProperty("_EmissionColor"))
					{
						val5.SetColor("_EmissionColor", val);
					}
				}
			}
		}
	}

	private string GetTransformPath(Transform transform)
	{
		if ((Object)(object)transform == (Object)null)
		{
			return "";
		}
		string text = ((Object)transform).name;
		while ((Object)(object)transform.parent != (Object)null)
		{
			transform = transform.parent;
			text = ((Object)transform).name + "/" + text;
		}
		return text;
	}

	private void ApplyCustomTextureToVanillaVisual(GameObject boss)
	{
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Expected O, but got Unknown
		if ((Object)(object)moldrikrVisualPrefab == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"No custom visual prefab loaded. Keeping vanilla material.");
			return;
		}
		Renderer componentInChildren = moldrikrVisualPrefab.GetComponentInChildren<Renderer>(true);
		if ((Object)(object)componentInChildren == (Object)null || (Object)(object)componentInChildren.sharedMaterial == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not find material on custom visual prefab.");
			return;
		}
		Material sharedMaterial = componentInChildren.sharedMaterial;
		Texture val = null;
		if (sharedMaterial.HasProperty("_MainTex"))
		{
			val = sharedMaterial.GetTexture("_MainTex");
		}
		if ((Object)(object)val == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not find Moldrikr albedo texture on source material.");
			return;
		}
		Transform val2 = boss.transform.Find("Visual");
		if ((Object)(object)val2 == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not find boss Visual child.");
			return;
		}
		Renderer[] componentsInChildren = ((Component)val2).GetComponentsInChildren<Renderer>(true);
		foreach (Renderer val3 in componentsInChildren)
		{
			Material val4 = new Material(val3.sharedMaterial);
			if (val4.HasProperty("_MainTex"))
			{
				val4.SetTexture("_MainTex", val);
			}
			val3.material = val4;
		}
	}

	public static void SetAllDamageModifiers(Character character, DamageModifier modifier)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: 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_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		character.m_damageModifiers.m_blunt = modifier;
		character.m_damageModifiers.m_slash = modifier;
		character.m_damageModifiers.m_pierce = modifier;
		character.m_damageModifiers.m_chop = modifier;
		character.m_damageModifiers.m_pickaxe = modifier;
		character.m_damageModifiers.m_fire = modifier;
		character.m_damageModifiers.m_frost = modifier;
		character.m_damageModifiers.m_lightning = modifier;
		character.m_damageModifiers.m_poison = modifier;
		character.m_damageModifiers.m_spirit = modifier;
	}
}