Decompiled source of Digivolution v1.0.1

Digivolve.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[BepInPlugin("Omniscye.Digivolve", "Empress Digivolve", "1.0.0")]
public class DigivolvePlugin : BaseUnityPlugin
{
	private sealed class DigivolveRuntimeHost : MonoBehaviour
	{
		private void Update()
		{
			RuntimeUpdate();
		}
	}

	[HarmonyPatch(typeof(Enemy), "Awake")]
	private static class EnemyAwakePatch
	{
		private static void Postfix(Enemy __instance)
		{
			if (!((Object)(object)__instance == (Object)null) && !((Object)(object)((Component)__instance).GetComponent<DigivolveEnemyController>() != (Object)null))
			{
				((Component)__instance).gameObject.AddComponent<DigivolveEnemyController>().Initialize(__instance);
			}
		}
	}

	[HarmonyPatch(typeof(EnemyHealth), "OnSpawn")]
	private static class EnemyHealthOnSpawnPatch
	{
		private static void Postfix(EnemyHealth __instance)
		{
			DigivolveEnemyController component = ((Component)__instance).GetComponent<DigivolveEnemyController>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.ResetForSpawn();
			}
		}
	}

	[HarmonyPatch(typeof(EnemyHealth), "Hurt")]
	private static class EnemyHealthHurtPatch
	{
		private static bool Prefix(EnemyHealth __instance, int _damage, Vector3 _hurtDirection)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			DigivolveEnemyController component = ((Component)__instance).GetComponent<DigivolveEnemyController>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return true;
			}
			if (component.IsTransformProtected)
			{
				return false;
			}
			if (!TryTriggerDigivolve(component, _damage, _hurtDirection))
			{
				return true;
			}
			return false;
		}
	}

	[HarmonyPatch(typeof(EnemyHealth), "Death")]
	private static class EnemyHealthDeathPatch
	{
		private static bool Prefix(EnemyHealth __instance)
		{
			DigivolveEnemyController component = ((Component)__instance).GetComponent<DigivolveEnemyController>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return true;
			}
			return !component.IsTransformProtected;
		}
	}

	[HarmonyPatch(typeof(EnemyHealth), "DeathRPC")]
	private static class EnemyHealthDeathRpcPatch
	{
		private static bool Prefix(EnemyHealth __instance)
		{
			DigivolveEnemyController component = ((Component)__instance).GetComponent<DigivolveEnemyController>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return true;
			}
			return !component.IsTransformProtected;
		}
	}

	[HarmonyPatch(typeof(EnemyHealth), "DeathImpulseRPC")]
	private static class EnemyHealthDeathImpulsePatch
	{
		private static bool Prefix(EnemyHealth __instance)
		{
			DigivolveEnemyController component = ((Component)__instance).GetComponent<DigivolveEnemyController>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return true;
			}
			return !component.IsTransformProtected;
		}
	}

	[HarmonyPatch(typeof(PlayerHealth), "Hurt")]
	private static class PlayerHealthHurtPatch
	{
		private static bool Prefix(int enemyIndex)
		{
			return !ShouldSuppressEvolvedEnemyDamage(enemyIndex);
		}
	}

	public static DigivolvePlugin Instance;

	internal const int CustomDigivolveAttackEnemyIndex = -777;

	private static Harmony harmony;

	private static readonly HashSet<DigivolveEnemyController> controllers = new HashSet<DigivolveEnemyController>();

	private static ConfigEntry<float> chancePercentConfig;

	private static ConfigEntry<float> lowHealthPercentConfig;

	private static ConfigEntry<float> durationSecondsConfig;

	private static ConfigEntry<float> healthMultiplierConfig;

	private static ConfigEntry<float> evolvedScaleConfig;

	private static ConfigEntry<float> musicVolumeConfig;

	private static GameObject runtimeRoot;

	private static DigivolveRuntimeHost runtimeHost;

	private static AudioSource musicSource;

	private static AudioClip digivolutionClip;

	private static Material fxMaterial;

	private static Material shellBodyMaterial;

	private static Material shellAccentMaterial;

	private static int gameplaySceneHandle = int.MinValue;

	private static string musicFilePath = string.Empty;

	private static bool clipLoadRequested;

	private static double pendingMusicStartTime = double.NaN;

	private static ManualLogSource log;

	public static float ChancePercent => Mathf.Clamp((chancePercentConfig != null) ? chancePercentConfig.Value : 10f, 0f, 100f);

	public static float LowHealthPercent => Mathf.Clamp((lowHealthPercentConfig != null) ? lowHealthPercentConfig.Value : 20f, 1f, 95f);

	public static float DurationSeconds => Mathf.Clamp((durationSecondsConfig != null) ? durationSecondsConfig.Value : 10f, 2f, 20f);

	public static float HealthMultiplier => Mathf.Max(1.1f, (healthMultiplierConfig != null) ? healthMultiplierConfig.Value : 2f);

	public static float EvolvedScale => Mathf.Clamp((evolvedScaleConfig != null) ? evolvedScaleConfig.Value : 2f, 1f, 2f);

	public static float MusicVolume => Mathf.Clamp01((musicVolumeConfig != null) ? musicVolumeConfig.Value : 0.9f);

	public static Material SharedFxMaterial
	{
		get
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)fxMaterial))
			{
				Shader val = Shader.Find("Sprites/Default");
				if (!Object.op_Implicit((Object)(object)val))
				{
					val = Shader.Find("Legacy Shaders/Particles/Alpha Blended");
				}
				fxMaterial = new Material(val);
				fxMaterial.color = new Color(0.1f, 0.95f, 1f, 0.75f);
			}
			return fxMaterial;
		}
	}

	public static Material SharedShellBodyMaterial
	{
		get
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)shellBodyMaterial))
			{
				Shader val = Shader.Find("Standard");
				if (!Object.op_Implicit((Object)(object)val))
				{
					val = Shader.Find("Legacy Shaders/Diffuse");
				}
				if (!Object.op_Implicit((Object)(object)val))
				{
					val = Shader.Find("Sprites/Default");
				}
				shellBodyMaterial = new Material(val);
				shellBodyMaterial.color = new Color(0.04f, 0.02f, 0.02f, 1f);
				if (shellBodyMaterial.HasProperty("_Glossiness"))
				{
					shellBodyMaterial.SetFloat("_Glossiness", 0.08f);
				}
				if (shellBodyMaterial.HasProperty("_Metallic"))
				{
					shellBodyMaterial.SetFloat("_Metallic", 0.15f);
				}
			}
			return shellBodyMaterial;
		}
	}

	public static Material SharedShellAccentMaterial
	{
		get
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)shellAccentMaterial))
			{
				Shader val = Shader.Find("Sprites/Default");
				if (!Object.op_Implicit((Object)(object)val))
				{
					val = Shader.Find("Legacy Shaders/Diffuse");
				}
				shellAccentMaterial = new Material(val);
				shellAccentMaterial.color = new Color(1f, 0.08f, 0.08f, 1f);
			}
			return shellAccentMaterial;
		}
	}

	private void Awake()
	{
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Expected O, but got Unknown
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: Expected O, but got Unknown
		Instance = this;
		log = ((BaseUnityPlugin)this).Logger;
		if (chancePercentConfig == null)
		{
			chancePercentConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Digivolve", "ChancePercent", 10f, new ConfigDescription("Chance for a low-health enemy to Digivolve.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
		}
		if (lowHealthPercentConfig == null)
		{
			lowHealthPercentConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Digivolve", "LowHealthPercent", 20f, "Health percent that can trigger Digivolve.");
		}
		if (durationSecondsConfig == null)
		{
			durationSecondsConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Digivolve", "TransformationSeconds", 10f, "How long the Digivolve sequence lasts.");
		}
		if (healthMultiplierConfig == null)
		{
			healthMultiplierConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Digivolve", "HealthMultiplier", 2f, "Health multiplier applied after Digivolve finishes.");
		}
		if (evolvedScaleConfig == null)
		{
			evolvedScaleConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Digivolve", "EvolvedScale", 2f, "Visual size multiplier after Digivolve.");
		}
		if (musicVolumeConfig == null)
		{
			musicVolumeConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Audio", "DigivolutionMusicVolume", 0.9f, "Music volume for the Digivolve theme.");
		}
		if (Mathf.Abs(evolvedScaleConfig.Value - 1.16f) < 0.001f)
		{
			evolvedScaleConfig.Value = 2f;
		}
		EnsureRuntimeRoot();
		musicFilePath = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? string.Empty, "Digivolution.mp3");
		RequestDigivolutionClipLoad();
		if (harmony == null)
		{
			harmony = new Harmony("Omniscye.Digivolve");
			harmony.PatchAll(typeof(DigivolvePlugin).Assembly);
		}
		log.LogInfo((object)"Empress Digivolve loaded. Low-health enemies now have a chance to ascend.");
	}

	private void OnDestroy()
	{
		if ((Object)(object)Instance == (Object)(object)this)
		{
			Instance = null;
		}
	}

	private static void RuntimeUpdate()
	{
		//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)
		EnsureMusicRouting();
		if (IsDigivolveGameplayReady())
		{
			Scene activeScene = SceneManager.GetActiveScene();
			int handle = ((Scene)(ref activeScene)).handle;
			if (handle != gameplaySceneHandle)
			{
				gameplaySceneHandle = handle;
				ResetLevelDigivolveState();
			}
		}
	}

	private static void EnsureRuntimeRoot()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		if (!Object.op_Implicit((Object)(object)runtimeRoot))
		{
			runtimeRoot = new GameObject("EmpressDigivolveRuntime");
			Object.DontDestroyOnLoad((Object)(object)runtimeRoot);
		}
		if (!Object.op_Implicit((Object)(object)runtimeHost))
		{
			runtimeHost = runtimeRoot.GetComponent<DigivolveRuntimeHost>();
			if (!Object.op_Implicit((Object)(object)runtimeHost))
			{
				runtimeHost = runtimeRoot.AddComponent<DigivolveRuntimeHost>();
			}
		}
		if (!Object.op_Implicit((Object)(object)musicSource))
		{
			musicSource = runtimeRoot.GetComponent<AudioSource>();
			if (!Object.op_Implicit((Object)(object)musicSource))
			{
				musicSource = runtimeRoot.AddComponent<AudioSource>();
			}
			musicSource.playOnAwake = false;
			musicSource.loop = false;
			musicSource.spatialBlend = 0f;
			musicSource.priority = 72;
			musicSource.volume = MusicVolume;
		}
		EnsureMusicRouting();
	}

	private static void EnsureMusicRouting()
	{
		if (Object.op_Implicit((Object)(object)musicSource) && (Object)(object)AudioManager.instance != (Object)null && (Object)(object)AudioManager.instance.SoundMasterGroup != (Object)null)
		{
			musicSource.outputAudioMixerGroup = AudioManager.instance.SoundMasterGroup;
		}
	}

	private static void RequestDigivolutionClipLoad()
	{
		EnsureRuntimeRoot();
		if (!clipLoadRequested && !Object.op_Implicit((Object)(object)digivolutionClip) && Object.op_Implicit((Object)(object)runtimeHost) && !string.IsNullOrEmpty(musicFilePath))
		{
			clipLoadRequested = true;
			((MonoBehaviour)runtimeHost).StartCoroutine(LoadDigivolutionClip());
		}
	}

	private static IEnumerator LoadDigivolutionClip()
	{
		if (!File.Exists(musicFilePath))
		{
			clipLoadRequested = false;
			ManualLogSource obj = log;
			if (obj != null)
			{
				obj.LogWarning((object)"Digivolution.mp3 not found beside the plugin DLL.");
			}
			yield break;
		}
		string text = "file:///" + musicFilePath.Replace("\\", "/");
		UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(text, (AudioType)13);
		try
		{
			yield return request.SendWebRequest();
			if ((int)request.result != 1)
			{
				clipLoadRequested = false;
				ManualLogSource obj2 = log;
				if (obj2 != null)
				{
					obj2.LogWarning((object)("Failed to load Digivolution.mp3: " + request.error));
				}
				yield break;
			}
			digivolutionClip = DownloadHandlerAudioClip.GetContent(request);
			clipLoadRequested = false;
			if (Object.op_Implicit((Object)(object)digivolutionClip))
			{
				((Object)digivolutionClip).name = "Digivolution";
				ManualLogSource obj3 = log;
				if (obj3 != null)
				{
					obj3.LogInfo((object)"Digivolution.mp3 loaded.");
				}
				if (!double.IsNaN(pendingMusicStartTime))
				{
					double startTime = pendingMusicStartTime;
					pendingMusicStartTime = double.NaN;
					PlayDigivolutionMusic(startTime);
				}
			}
		}
		finally
		{
			((IDisposable)request)?.Dispose();
		}
	}

	private static void ResetLevelDigivolveState()
	{
		foreach (DigivolveEnemyController controller in controllers)
		{
			if (Object.op_Implicit((Object)(object)controller))
			{
				controller.ResetForLevelStart();
			}
		}
	}

	public static void RegisterController(DigivolveEnemyController controller)
	{
		if (Object.op_Implicit((Object)(object)controller))
		{
			controllers.Add(controller);
		}
	}

	public static void UnregisterController(DigivolveEnemyController controller)
	{
		if (Object.op_Implicit((Object)(object)controller))
		{
			controllers.Remove(controller);
		}
	}

	public static bool IsDigivolveGameplayReady()
	{
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Invalid comparison between Unknown and I4
		if ((Object)(object)RunManager.instance == (Object)null || (Object)(object)GameManager.instance == (Object)null || (Object)(object)GameDirector.instance == (Object)null || (Object)(object)LevelGenerator.Instance == (Object)null)
		{
			return false;
		}
		if (!SemiFunc.RunIsLevel() || SemiFunc.MenuLevel() || SemiFunc.IsMainMenu() || SemiFunc.RunIsLobby() || SemiFunc.RunIsLobbyMenu() || SemiFunc.RunIsShop() || SemiFunc.RunIsTutorial())
		{
			return false;
		}
		if (!LevelGenerator.Instance.Generated)
		{
			return false;
		}
		return (int)GameDirector.instance.currentState == 2;
	}

	public static bool CanAttemptDigivolve(DigivolveEnemyController controller)
	{
		if (!Object.op_Implicit((Object)(object)controller) || !IsDigivolveGameplayReady())
		{
			return false;
		}
		if (!SemiFunc.IsMasterClientOrSingleplayer())
		{
			return false;
		}
		if (!controller.HasDigivolved)
		{
			return !controller.IsTransforming;
		}
		return false;
	}

	public static bool TryTriggerDigivolve(DigivolveEnemyController controller, int damage, Vector3 hurtDirection)
	{
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		if (!CanAttemptDigivolve(controller))
		{
			return false;
		}
		if (!controller.CanAttemptDigivolve(damage, LowHealthPercent * 0.01f))
		{
			return false;
		}
		if (!controller.ResolveDigivolveRoll(ChancePercent * 0.01f))
		{
			return false;
		}
		controller.BeginDigivolveAuthoritative(damage, hurtDirection, DurationSeconds, HealthMultiplier, EvolvedScale);
		return true;
	}

	public static void PlayDigivolutionMusic(double startTime)
	{
		EnsureRuntimeRoot();
		if (!Object.op_Implicit((Object)(object)digivolutionClip))
		{
			pendingMusicStartTime = startTime;
			RequestDigivolutionClipLoad();
		}
		else if (Object.op_Implicit((Object)(object)musicSource))
		{
			pendingMusicStartTime = double.NaN;
			EnsureMusicRouting();
			musicSource.Stop();
			musicSource.clip = digivolutionClip;
			musicSource.volume = MusicVolume;
			double num = startTime;
			num = ((!GameManager.Multiplayer()) ? Time.unscaledTimeAsDouble : PhotonNetwork.Time);
			float time = Mathf.Clamp((float)(num - startTime), 0f, Mathf.Max(0f, digivolutionClip.length - 0.05f));
			musicSource.time = time;
			musicSource.Play();
		}
	}

	public static bool ShouldSuppressEvolvedEnemyDamage(int enemyIndex)
	{
		if (enemyIndex < 0)
		{
			return false;
		}
		Enemy val = SemiFunc.EnemyGetFromIndex(enemyIndex);
		if (!Object.op_Implicit((Object)(object)val))
		{
			return false;
		}
		DigivolveEnemyController component = ((Component)val).GetComponent<DigivolveEnemyController>();
		if (Object.op_Implicit((Object)(object)component))
		{
			return component.UsesCustomCombat;
		}
		return false;
	}
}
public enum DigivolveAspect
{
	Burst,
	Fortress,
	Phantom,
	Speed,
	Mimic
}
public class DigivolveEnemyController : MonoBehaviourPun
{
	private Enemy enemy;

	private EnemyHealth health;

	private Transform visualRoot;

	private Vector3 baseVisualScale = Vector3.one;

	private int baseHealth = 100;

	private bool rollResolved;

	private bool rollWon;

	private bool hasDigivolved;

	private bool transforming;

	private double transformStartTime;

	private float transformDuration;

	private int transformedHealthMax;

	private float evolvedScaleMultiplier = 1f;

	private int lockedHealthCurrent;

	private DigivolveAspect currentAspect;

	private float aspectActionTimer;

	private float finishPulseTimer;

	private float aspectPulseTimer;

	private float aspectPulseStrength;

	private float customAttackCooldown;

	private float shellAttackAnimTimer;

	private float shellAttackAnimDuration;

	private float shellAttackImpactTimer;

	private int pendingAttackDamage;

	private float pendingAttackRange;

	private int pendingAttackTargetViewId = -1;

	private DigivolveAspect pendingAttackAspect;

	private bool vanillaBehavioursSuppressed;

	private readonly List<Behaviour> suppressedVanillaBehaviours = new List<Behaviour>();

	private readonly List<AudioSource> suppressedAudioSources = new List<AudioSource>();

	private readonly List<bool> suppressedAudioMuteStates = new List<bool>();

	private readonly List<Collider> suppressedVanillaColliders = new List<Collider>();

	private GameObject evolvedShellRoot;

	private Rigidbody evolvedShellRigidbody;

	private float shellGroundOffset;

	private bool shellTransformOverrideActive;

	private Vector3 shellTransformOverridePosition;

	private Quaternion shellTransformOverrideRotation = Quaternion.identity;

	private float shellTransformOverrideTimer;

	private int phantomDropTargetViewId = -1;

	private float phantomDropTimer;

	private Transform shellBody;

	private Transform shellHead;

	private Transform shellCore;

	private readonly List<Transform> shellLimbs = new List<Transform>();

	private readonly List<Transform> shellAccents = new List<Transform>();

	private readonly List<Renderer> originalVisualRenderers = new List<Renderer>();

	private readonly List<Material[]> originalRendererMaterials = new List<Material[]>();

	private readonly List<Material[]> digitalRendererMaterials = new List<Material[]>();

	private readonly List<Vector3> shellLimbBaseLocalPositions = new List<Vector3>();

	private readonly List<Quaternion> shellLimbBaseLocalRotations = new List<Quaternion>();

	private readonly List<Vector3> shellAccentBaseLocalScales = new List<Vector3>();

	private Vector3 shellBodyBaseLocalPosition;

	private Quaternion shellBodyBaseLocalRotation = Quaternion.identity;

	private Quaternion shellHeadBaseLocalRotation = Quaternion.identity;

	private Vector3 shellCoreBaseLocalScale = Vector3.one;

	private GameObject effectRoot;

	private readonly List<Transform> ringRoots = new List<Transform>();

	private readonly List<Transform> dataShards = new List<Transform>();

	private readonly List<Transform> dataColumns = new List<Transform>();

	private readonly List<float> shardAngleSeeds = new List<float>();

	private readonly List<float> shardHeightSeeds = new List<float>();

	private readonly List<float> shardScaleSeeds = new List<float>();

	private readonly List<float> columnAngleSeeds = new List<float>();

	private readonly List<float> columnPhaseSeeds = new List<float>();

	private ParticleSystem burstParticles;

	private Transform corePulse;

	private Renderer corePulseRenderer;

	private Material corePulseMaterial;

	private readonly List<TextMesh> binaryGlyphs = new List<TextMesh>();

	private readonly List<float> binaryAngleSeeds = new List<float>();

	private readonly List<float> binaryHeightSeeds = new List<float>();

	private readonly List<float> binaryPhaseSeeds = new List<float>();

	private float binaryShuffleTimer;

	private Texture2D digitalPatternTexture;

	private GameObject mimicVisualRoot;

	private Animator mimicAnimator;

	private readonly List<Renderer> mimicRenderers = new List<Renderer>();

	private float mimicFloorOffset;

	private Vector3 mimicLastPosition;

	private float mimicAttackVisualCooldown;

	private int mimicSourcePlayerViewId = -1;

	private float mimicTumbleVisualTimer;

	public bool IsTransforming => transforming;

	public bool IsTransformProtected => transforming;

	public bool HasDigivolved => hasDigivolved;

	public bool UsesCustomCombat => transforming;

	public void Initialize(Enemy targetEnemy)
	{
		//IL_0063: 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)
		enemy = targetEnemy;
		health = (((Object)(object)targetEnemy != (Object)null) ? ((Component)targetEnemy).GetComponent<EnemyHealth>() : null);
		visualRoot = ResolveVisualRoot();
		if (Object.op_Implicit((Object)(object)health))
		{
			baseHealth = Mathf.Max(1, health.health);
		}
		if (Object.op_Implicit((Object)(object)visualRoot))
		{
			baseVisualScale = visualRoot.localScale;
		}
		CacheOriginalVisualRenderers();
		DigivolvePlugin.RegisterController(this);
	}

	private void Awake()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)enemy))
		{
			enemy = ((Component)this).GetComponent<Enemy>();
		}
		if (!Object.op_Implicit((Object)(object)health))
		{
			health = ((Component)this).GetComponent<EnemyHealth>();
		}
		if (!Object.op_Implicit((Object)(object)visualRoot))
		{
			visualRoot = ResolveVisualRoot();
		}
		if (Object.op_Implicit((Object)(object)visualRoot))
		{
			baseVisualScale = visualRoot.localScale;
		}
		if (Object.op_Implicit((Object)(object)health))
		{
			baseHealth = Mathf.Max(1, health.health);
		}
		CacheOriginalVisualRenderers();
		DigivolvePlugin.RegisterController(this);
	}

	private void OnDestroy()
	{
		DigivolvePlugin.UnregisterController(this);
		RestoreVanillaBehaviours();
		RestoreVanillaAudio();
		RestoreVanillaColliders();
		DestroyEffects();
		DestroyMimicVisual();
	}

	private void OnDisable()
	{
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		bool num = Object.op_Implicit((Object)(object)health) && (health.dead || health.deadImpulse);
		if (Object.op_Implicit((Object)(object)visualRoot))
		{
			visualRoot.localScale = baseVisualScale;
		}
		if (!num)
		{
			RestoreVanillaBehaviours();
			RestoreVanillaAudio();
			RestoreVanillaColliders();
			SetOriginalVisualsVisible(visible: true);
		}
		RestoreOriginalRendererMaterials();
		DestroyMimicVisual();
		DestroyShell();
		ClearMaterialPulse();
		DestroyEffects();
	}

	private void Update()
	{
		if (!Object.op_Implicit((Object)(object)enemy) || !Object.op_Implicit((Object)(object)health))
		{
			return;
		}
		if (shellTransformOverrideTimer > 0f)
		{
			shellTransformOverrideTimer -= Time.deltaTime;
			if (shellTransformOverrideTimer <= 0f)
			{
				shellTransformOverrideActive = false;
			}
		}
		if (shellAttackImpactTimer > 0f)
		{
			shellAttackImpactTimer -= Time.deltaTime;
			if (shellAttackImpactTimer <= 0f)
			{
				ResolvePendingAttackImpact();
			}
		}
		if (shellAttackAnimTimer > 0f)
		{
			shellAttackAnimTimer -= Time.deltaTime;
		}
		if (transforming)
		{
			SetOriginalVisualsVisible(visible: false);
			float num = Mathf.Max(0f, GetElapsedSeconds());
			float normalized = Mathf.Clamp01(num / Mathf.Max(0.01f, transformDuration));
			UpdateTransformationLock();
			UpdateTransformationVisuals(num, normalized);
			if (SemiFunc.IsMasterClientOrSingleplayer() && num >= transformDuration)
			{
				CompleteDigivolveAuthoritative();
			}
		}
		else if (hasDigivolved)
		{
			SetOriginalVisualsVisible(visible: true);
			if (finishPulseTimer > 0f)
			{
				finishPulseTimer -= Time.deltaTime;
			}
			if (aspectPulseTimer > 0f)
			{
				aspectPulseTimer -= Time.deltaTime;
			}
			UpdateEvolvedBuffs();
			UpdateEvolvedVisuals();
		}
	}

	public void ResetForSpawn()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: 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)
		if (!Object.op_Implicit((Object)(object)health))
		{
			health = ((Component)this).GetComponent<EnemyHealth>();
		}
		if (!Object.op_Implicit((Object)(object)enemy))
		{
			enemy = ((Component)this).GetComponent<Enemy>();
		}
		if (!Object.op_Implicit((Object)(object)visualRoot))
		{
			visualRoot = ResolveVisualRoot();
		}
		if (Object.op_Implicit((Object)(object)visualRoot))
		{
			baseVisualScale = visualRoot.localScale;
			visualRoot.localScale = baseVisualScale;
		}
		if (Object.op_Implicit((Object)(object)health))
		{
			health.health = baseHealth;
			health.healthCurrent = Mathf.Min(health.healthCurrent, health.health);
			health.dead = false;
			health.deadImpulse = false;
		}
		transforming = false;
		hasDigivolved = false;
		rollResolved = false;
		rollWon = false;
		transformStartTime = 0.0;
		transformedHealthMax = 0;
		lockedHealthCurrent = 0;
		currentAspect = DigivolveAspect.Burst;
		aspectActionTimer = 0f;
		finishPulseTimer = 0f;
		aspectPulseTimer = 0f;
		aspectPulseStrength = 0f;
		customAttackCooldown = 0f;
		shellAttackAnimTimer = 0f;
		shellAttackAnimDuration = 0f;
		shellAttackImpactTimer = 0f;
		pendingAttackDamage = 0;
		pendingAttackRange = 0f;
		pendingAttackTargetViewId = -1;
		pendingAttackAspect = DigivolveAspect.Burst;
		phantomDropTargetViewId = -1;
		phantomDropTimer = 0f;
		mimicSourcePlayerViewId = -1;
		mimicAttackVisualCooldown = 0f;
		mimicTumbleVisualTimer = 0f;
		shellTransformOverrideActive = false;
		shellTransformOverrideTimer = 0f;
		RestoreVanillaBehaviours();
		RestoreVanillaAudio();
		RestoreVanillaColliders();
		SetOriginalVisualsVisible(visible: true);
		RestoreOriginalRendererMaterials();
		DestroyMimicVisual();
		DestroyShell();
		ClearMaterialPulse();
		DestroyEffects();
	}

	public void ResetForLevelStart()
	{
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		transforming = false;
		hasDigivolved = false;
		rollResolved = false;
		rollWon = false;
		currentAspect = DigivolveAspect.Burst;
		aspectActionTimer = 0f;
		finishPulseTimer = 0f;
		aspectPulseTimer = 0f;
		aspectPulseStrength = 0f;
		customAttackCooldown = 0f;
		shellAttackAnimTimer = 0f;
		shellAttackAnimDuration = 0f;
		shellAttackImpactTimer = 0f;
		pendingAttackDamage = 0;
		pendingAttackRange = 0f;
		pendingAttackTargetViewId = -1;
		pendingAttackAspect = DigivolveAspect.Burst;
		phantomDropTargetViewId = -1;
		phantomDropTimer = 0f;
		mimicSourcePlayerViewId = -1;
		mimicAttackVisualCooldown = 0f;
		mimicTumbleVisualTimer = 0f;
		shellTransformOverrideActive = false;
		shellTransformOverrideTimer = 0f;
		RestoreVanillaBehaviours();
		RestoreVanillaAudio();
		RestoreVanillaColliders();
		if (Object.op_Implicit((Object)(object)visualRoot))
		{
			visualRoot.localScale = baseVisualScale;
		}
		SetOriginalVisualsVisible(visible: true);
		RestoreOriginalRendererMaterials();
		DestroyMimicVisual();
		DestroyShell();
		ClearMaterialPulse();
		DestroyEffects();
	}

	public bool CanAttemptDigivolve(int damage, float thresholdRatio)
	{
		if (!Object.op_Implicit((Object)(object)health) || !Object.op_Implicit((Object)(object)enemy))
		{
			return false;
		}
		if (health.dead || health.deadImpulse)
		{
			return false;
		}
		int num = Mathf.Max(1, Mathf.CeilToInt((float)baseHealth * Mathf.Clamp01(thresholdRatio)));
		int num2 = PredictHealthAfterDamage(damage);
		if (health.healthCurrent <= num)
		{
			return false;
		}
		return num2 <= num;
	}

	public bool ResolveDigivolveRoll(float chance)
	{
		if (rollResolved)
		{
			return rollWon;
		}
		rollResolved = true;
		rollWon = Random.value <= Mathf.Clamp01(chance);
		return rollWon;
	}

	public void BeginDigivolveAuthoritative(int damage, Vector3 hurtDirection, float duration, float healthMultiplier, float scaleMultiplier)
	{
		//IL_013c: 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)
		if (Object.op_Implicit((Object)(object)health) && Object.op_Implicit((Object)(object)enemy))
		{
			DigivolveAspect digivolveAspect = ChooseAspect();
			int num = ((digivolveAspect == DigivolveAspect.Mimic) ? ResolveMimicSourcePlayerViewId() : (-1));
			int num2 = Mathf.Max(1, PredictHealthAfterDamage(damage));
			health.healthCurrent = num2;
			health.dead = false;
			health.deadImpulse = false;
			double num3 = (GameManager.Multiplayer() ? PhotonNetwork.Time : Time.unscaledTimeAsDouble);
			float num4 = Mathf.Max(2f, duration);
			int num5 = Mathf.Max(baseHealth + 1, Mathf.RoundToInt((float)baseHealth * Mathf.Max(1.1f, healthMultiplier) * GetAspectHealthBonus(digivolveAspect)));
			float num6 = Mathf.Max(1f, scaleMultiplier * GetAspectScaleBonus(digivolveAspect));
			if (GameManager.Multiplayer())
			{
				((MonoBehaviourPun)this).photonView.RPC("BeginDigivolveRpc", (RpcTarget)0, new object[8]
				{
					num3,
					num4,
					num5,
					num6,
					num2,
					hurtDirection,
					(int)digivolveAspect,
					num
				});
			}
			else
			{
				BeginDigivolveRpc(num3, num4, num5, num6, num2, hurtDirection, (int)digivolveAspect, num);
			}
		}
	}

	private int PredictHealthAfterDamage(int damage)
	{
		if (!Object.op_Implicit((Object)(object)health))
		{
			return 0;
		}
		float num = 1f - Mathf.Min(health.damageResistance, 1f);
		int num2 = Mathf.Max(0, Mathf.RoundToInt((float)damage * num));
		return health.healthCurrent - num2;
	}

	[PunRPC]
	public void BeginDigivolveRpc(double startTime, float duration, int newHealthMax, float scaleMultiplier, int startHealth, Vector3 hurtDirection, int aspectId, int mimicViewId)
	{
		//IL_0173: Unknown result type (might be due to invalid IL or missing references)
		//IL_0175: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)health) && Object.op_Implicit((Object)(object)enemy))
		{
			transforming = true;
			hasDigivolved = false;
			transformStartTime = startTime;
			transformDuration = Mathf.Max(0.1f, duration);
			transformedHealthMax = newHealthMax;
			evolvedScaleMultiplier = Mathf.Max(1f, scaleMultiplier);
			lockedHealthCurrent = Mathf.Max(1, startHealth);
			currentAspect = (DigivolveAspect)Mathf.Clamp(aspectId, 0, 4);
			mimicSourcePlayerViewId = mimicViewId;
			aspectActionTimer = GetAspectBaseCooldown(currentAspect);
			finishPulseTimer = 0f;
			aspectPulseTimer = 0f;
			aspectPulseStrength = 0f;
			customAttackCooldown = 0f;
			shellAttackAnimTimer = 0f;
			shellAttackAnimDuration = 0f;
			shellAttackImpactTimer = 0f;
			pendingAttackDamage = 0;
			pendingAttackRange = 0f;
			pendingAttackTargetViewId = -1;
			pendingAttackAspect = currentAspect;
			phantomDropTargetViewId = -1;
			phantomDropTimer = 0f;
			mimicAttackVisualCooldown = 0f;
			shellTransformOverrideActive = false;
			shellTransformOverrideTimer = 0f;
			SuppressVanillaBehaviours();
			SuppressVanillaAudio();
			SuppressVanillaColliders();
			health.healthCurrent = lockedHealthCurrent;
			health.dead = false;
			health.deadImpulse = false;
			health.hurtDirection = hurtDirection;
			health.MaterialColorFlash(GetAspectPrimaryColor(currentAspect));
			SetOriginalVisualsVisible(visible: true);
			BuildEffects();
			DigivolvePlugin.PlayDigivolutionMusic(startTime);
		}
	}

	private void CompleteDigivolveAuthoritative()
	{
		if (Object.op_Implicit((Object)(object)health) && Object.op_Implicit((Object)(object)enemy) && transforming)
		{
			health.health = transformedHealthMax;
			health.healthCurrent = transformedHealthMax;
			health.dead = false;
			health.deadImpulse = false;
			if (GameManager.Multiplayer())
			{
				((MonoBehaviourPun)this).photonView.RPC("FinishDigivolveRpc", (RpcTarget)0, new object[2] { transformedHealthMax, evolvedScaleMultiplier });
			}
			else
			{
				FinishDigivolveRpc(transformedHealthMax, evolvedScaleMultiplier);
			}
		}
	}

	[PunRPC]
	public void FinishDigivolveRpc(int newHealthMax, float scaleMultiplier)
	{
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)health))
		{
			health.health = Mathf.Max(baseHealth, newHealthMax);
			health.healthCurrent = health.health;
			health.dead = false;
			health.deadImpulse = false;
			health.HealRPC();
		}
		transforming = false;
		hasDigivolved = true;
		evolvedScaleMultiplier = Mathf.Max(1f, scaleMultiplier);
		finishPulseTimer = 1.25f;
		aspectPulseTimer = 1f;
		aspectPulseStrength = 1f;
		aspectActionTimer = GetAspectBaseCooldown(currentAspect);
		customAttackCooldown = 0.45f;
		shellAttackAnimTimer = 0f;
		shellAttackAnimDuration = 0f;
		shellAttackImpactTimer = 0f;
		pendingAttackDamage = 0;
		pendingAttackRange = 0f;
		pendingAttackTargetViewId = -1;
		pendingAttackAspect = currentAspect;
		phantomDropTargetViewId = -1;
		phantomDropTimer = 0f;
		shellTransformOverrideActive = false;
		shellTransformOverrideTimer = 0f;
		if (Object.op_Implicit((Object)(object)visualRoot))
		{
			visualRoot.localScale = baseVisualScale * evolvedScaleMultiplier;
		}
		RestoreVanillaBehaviours();
		RestoreVanillaAudio();
		RestoreVanillaColliders();
		DestroyShell();
		SetOriginalVisualsVisible(visible: true);
		DestroyMimicVisual();
		if (currentAspect == DigivolveAspect.Mimic)
		{
			if (!BuildMimicVisual())
			{
				ApplyDigitalRendererMaterials();
			}
		}
		else
		{
			ApplyDigitalRendererMaterials();
		}
		if (Object.op_Implicit((Object)(object)health))
		{
			health.MaterialColorFlash(GetAspectSecondaryColor(currentAspect));
		}
		TriggerAspectPulseRpc(1f);
	}

	private float GetElapsedSeconds()
	{
		return (float)((GameManager.Multiplayer() ? PhotonNetwork.Time : Time.unscaledTimeAsDouble) - transformStartTime);
	}

	private void UpdateTransformationLock()
	{
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)health) || !Object.op_Implicit((Object)(object)enemy))
		{
			return;
		}
		health.healthCurrent = Mathf.Max(1, lockedHealthCurrent);
		health.dead = false;
		health.deadImpulse = false;
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			enemy.FreezeTimer = Mathf.Max(enemy.FreezeTimer, 0.25f);
			enemy.DisableChase(0.3f);
			enemy.ChaseTimer = 0f;
			enemy.TargetPlayerAvatar = null;
			enemy.TargetPlayerViewID = -1;
			if (enemy.HasStateChaseBegin && (Object)(object)enemy.StateChaseBegin != (Object)null)
			{
				enemy.StateChaseBegin.TargetPlayer = null;
			}
			if (enemy.HasNavMeshAgent && (Object)(object)enemy.NavMeshAgent != (Object)null)
			{
				enemy.NavMeshAgent.Stop(0.3f);
			}
			if (enemy.HasRigidbody && (Object)(object)enemy.Rigidbody != (Object)null)
			{
				enemy.Rigidbody.rb.velocity = Vector3.zero;
				enemy.Rigidbody.rb.angularVelocity = Vector3.zero;
			}
		}
	}

	private void UpdateTransformationVisuals(float elapsed, float normalized)
	{
		//IL_0036: 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_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: 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_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)visualRoot))
		{
			float num = 1f + normalized * 0.18f + Mathf.Sin(elapsed * 18f) * 0.06f;
			visualRoot.localScale = baseVisualScale * num;
			Color val = Color.HSVToRGB(Mathf.Repeat(elapsed * 0.32f, 1f), 0.82f, 1f);
			val = Color.Lerp(val, GetAspectSecondaryColor(currentAspect), 0.25f + Mathf.PingPong(elapsed * 1.7f, 0.25f));
			float amount = Mathf.Lerp(0.22f, 1f, Mathf.PingPong(elapsed * 4.8f, 1f));
			ApplyMaterialPulse(val, amount);
			UpdateEffects(elapsed, normalized, val, evolvedMode: false);
		}
	}

	private void UpdateEvolvedVisuals()
	{
		//IL_0063: 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_0081: 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_00a7: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)visualRoot) || !Object.op_Implicit((Object)(object)health))
		{
			return;
		}
		float num = 1f + Mathf.Sin(Time.time * (3f + (float)currentAspect)) * 0.015f;
		if (finishPulseTimer > 0f)
		{
			num += finishPulseTimer * 0.12f;
		}
		visualRoot.localScale = baseVisualScale * (evolvedScaleMultiplier * num);
		Color color = Color.Lerp(GetAspectPrimaryColor(currentAspect), GetAspectSecondaryColor(currentAspect), Mathf.PingPong(Time.time * 0.45f, 1f));
		float amount = 0.14f + Mathf.Sin(Time.time * 4f) * 0.05f + Mathf.Max(0f, aspectPulseTimer) * 0.18f;
		ApplyMaterialPulse(color, amount);
		if (currentAspect == DigivolveAspect.Mimic)
		{
			RestoreOriginalRendererMaterials();
			if (UpdateMimicVisual(color))
			{
				SetOriginalVisualsVisible(visible: false);
			}
			else
			{
				SetOriginalVisualsVisible(visible: true);
				ApplyDigitalRendererMaterials();
			}
		}
		else
		{
			DestroyMimicVisual();
			SetOriginalVisualsVisible(visible: true);
			UpdateDigitalizedMaterials(color);
		}
		if (Object.op_Implicit((Object)(object)effectRoot) && finishPulseTimer > 0f)
		{
			float normalized = 0.22f + Mathf.PingPong(Time.time * 0.25f, 0.06f) + Mathf.Max(0f, aspectPulseTimer) * 0.24f + finishPulseTimer * 0.2f;
			UpdateEffects(Time.time * 0.85f, normalized, color, evolvedMode: true);
		}
		else if (Object.op_Implicit((Object)(object)effectRoot) && finishPulseTimer <= 0f)
		{
			DestroyEffects();
		}
	}

	private void UpdateEvolvedBuffs()
	{
		if (!Object.op_Implicit((Object)(object)enemy) || !Object.op_Implicit((Object)(object)health))
		{
			return;
		}
		switch (currentAspect)
		{
		case DigivolveAspect.Burst:
			health.OverrideDamageResistance(0.18f, 0.25f);
			if (enemy.HasNavMeshAgent && (Object)(object)enemy.NavMeshAgent != (Object)null)
			{
				enemy.NavMeshAgent.OverrideAgent(enemy.NavMeshAgent.DefaultSpeed * 1.5f, enemy.NavMeshAgent.DefaultAcceleration * 1.7f, 0.2f);
			}
			if (enemy.HasRigidbody && (Object)(object)enemy.Rigidbody != (Object)null)
			{
				enemy.Rigidbody.OverrideFollowPosition(0.2f, enemy.Rigidbody.positionSpeedChase * 1.3f, enemy.Rigidbody.positionSpeedLerpChase * 1.25f);
				enemy.Rigidbody.OverrideFollowRotation(0.2f, enemy.Rigidbody.rotationSpeedChase * 1.35f);
			}
			break;
		case DigivolveAspect.Fortress:
			health.OverrideDamageResistance(0.42f, 0.25f);
			enemy.OverrideType((EnemyType)4, 0.25f);
			if (enemy.HasNavMeshAgent && (Object)(object)enemy.NavMeshAgent != (Object)null)
			{
				enemy.NavMeshAgent.OverrideAgent(enemy.NavMeshAgent.DefaultSpeed * 1.18f, enemy.NavMeshAgent.DefaultAcceleration * 1.4f, 0.2f);
			}
			if (enemy.HasRigidbody && (Object)(object)enemy.Rigidbody != (Object)null)
			{
				enemy.Rigidbody.OverrideFollowPosition(0.2f, enemy.Rigidbody.positionSpeedChase * 1.12f, enemy.Rigidbody.positionSpeedLerpChase * 1.1f);
				enemy.Rigidbody.OverrideFollowRotation(0.2f, enemy.Rigidbody.rotationSpeedChase * 1.08f);
			}
			break;
		case DigivolveAspect.Phantom:
			health.OverrideDamageResistance(0.24f, 0.25f);
			if (enemy.HasNavMeshAgent && (Object)(object)enemy.NavMeshAgent != (Object)null)
			{
				enemy.NavMeshAgent.OverrideAgent(enemy.NavMeshAgent.DefaultSpeed * 1.36f, enemy.NavMeshAgent.DefaultAcceleration * 1.55f, 0.2f);
			}
			if (enemy.HasRigidbody && (Object)(object)enemy.Rigidbody != (Object)null)
			{
				enemy.Rigidbody.OverrideFollowPosition(0.2f, enemy.Rigidbody.positionSpeedChase * 1.22f, enemy.Rigidbody.positionSpeedLerpChase * 1.18f);
				enemy.Rigidbody.OverrideFollowRotation(0.2f, enemy.Rigidbody.rotationSpeedChase * 1.5f);
			}
			break;
		case DigivolveAspect.Speed:
			health.OverrideDamageResistance(0.12f, 0.25f);
			if (enemy.HasNavMeshAgent && (Object)(object)enemy.NavMeshAgent != (Object)null)
			{
				enemy.NavMeshAgent.OverrideAgent(enemy.NavMeshAgent.DefaultSpeed * 1.95f, enemy.NavMeshAgent.DefaultAcceleration * 2.2f, 0.2f);
			}
			if (enemy.HasRigidbody && (Object)(object)enemy.Rigidbody != (Object)null)
			{
				enemy.Rigidbody.OverrideFollowPosition(0.2f, enemy.Rigidbody.positionSpeedChase * 1.55f, enemy.Rigidbody.positionSpeedLerpChase * 1.45f);
				enemy.Rigidbody.OverrideFollowRotation(0.2f, enemy.Rigidbody.rotationSpeedChase * 1.8f);
			}
			break;
		case DigivolveAspect.Mimic:
			health.OverrideDamageResistance(0.2f, 0.25f);
			if (enemy.HasNavMeshAgent && (Object)(object)enemy.NavMeshAgent != (Object)null)
			{
				enemy.NavMeshAgent.OverrideAgent(enemy.NavMeshAgent.DefaultSpeed * 1.35f, enemy.NavMeshAgent.DefaultAcceleration * 1.5f, 0.2f);
			}
			if (enemy.HasRigidbody && (Object)(object)enemy.Rigidbody != (Object)null)
			{
				enemy.Rigidbody.OverrideFollowPosition(0.2f, enemy.Rigidbody.positionSpeedChase * 1.2f, enemy.Rigidbody.positionSpeedLerpChase * 1.15f);
				enemy.Rigidbody.OverrideFollowRotation(0.2f, enemy.Rigidbody.rotationSpeedChase * 1.45f);
			}
			break;
		}
	}

	private bool UpdateSpecialAbilityState(float deltaTime)
	{
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		if (phantomDropTimer <= 0f)
		{
			return false;
		}
		phantomDropTimer -= deltaTime;
		PlayerAvatar target = ResolvePlayerByViewId(phantomDropTargetViewId);
		if (Object.op_Implicit((Object)(object)enemy))
		{
			enemy.CurrentState = (EnemyState)2;
			enemy.DisableChase(0.35f);
			enemy.ChaseTimer = 0f;
			if (enemy.HasNavMeshAgent && (Object)(object)enemy.NavMeshAgent != (Object)null)
			{
				enemy.NavMeshAgent.Stop(0.2f);
			}
		}
		if (phantomDropTimer <= 0f)
		{
			FinishPhantomStalkAuthoritative(target);
		}
		return true;
	}

	private Transform ResolveVisualRoot()
	{
		if (Object.op_Implicit((Object)(object)health) && Object.op_Implicit((Object)(object)health.meshParent))
		{
			return health.meshParent;
		}
		if (Object.op_Implicit((Object)(object)enemy) && Object.op_Implicit((Object)(object)enemy.CenterTransform))
		{
			return enemy.CenterTransform;
		}
		return ((Component)this).transform;
	}

	private void CacheOriginalVisualRenderers()
	{
		originalVisualRenderers.Clear();
		originalRendererMaterials.Clear();
		digitalRendererMaterials.Clear();
		Renderer[] componentsInChildren = ((Component)(Object.op_Implicit((Object)(object)visualRoot) ? visualRoot : ((Component)this).transform)).GetComponentsInChildren<Renderer>(true);
		foreach (Renderer val in componentsInChildren)
		{
			if (Object.op_Implicit((Object)(object)val) && !IsFxChild(((Component)val).transform) && !IsShellChild(((Component)val).transform))
			{
				originalVisualRenderers.Add(val);
				originalRendererMaterials.Add(val.sharedMaterials);
				digitalRendererMaterials.Add(null);
			}
		}
	}

	private void SetOriginalVisualsVisible(bool visible)
	{
		for (int i = 0; i < originalVisualRenderers.Count; i++)
		{
			Renderer val = originalVisualRenderers[i];
			if (Object.op_Implicit((Object)(object)val))
			{
				val.enabled = visible;
			}
		}
	}

	private void ApplyDigitalRendererMaterials()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: 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)
		//IL_006e: 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)
		Texture2D val = EnsureDigitalPatternTexture();
		if (!Object.op_Implicit((Object)(object)val))
		{
			return;
		}
		Color aspectPrimaryColor = GetAspectPrimaryColor(currentAspect);
		Color aspectSecondaryColor = GetAspectSecondaryColor(currentAspect);
		for (int i = 0; i < originalVisualRenderers.Count; i++)
		{
			Renderer val2 = originalVisualRenderers[i];
			if (Object.op_Implicit((Object)(object)val2))
			{
				Material[] array = digitalRendererMaterials[i];
				if (array == null || array.Length != val2.sharedMaterials.Length)
				{
					array = BuildDigitalMaterialSet(val2.sharedMaterials, aspectPrimaryColor, aspectSecondaryColor, val);
					digitalRendererMaterials[i] = array;
				}
				val2.sharedMaterials = array;
			}
		}
	}

	private void RestoreOriginalRendererMaterials()
	{
		for (int i = 0; i < originalVisualRenderers.Count && i < originalRendererMaterials.Count; i++)
		{
			Renderer val = originalVisualRenderers[i];
			if (Object.op_Implicit((Object)(object)val) && originalRendererMaterials[i] != null)
			{
				val.sharedMaterials = originalRendererMaterials[i];
			}
		}
		for (int j = 0; j < digitalRendererMaterials.Count; j++)
		{
			Material[] array = digitalRendererMaterials[j];
			if (array == null)
			{
				continue;
			}
			for (int k = 0; k < array.Length; k++)
			{
				if (Object.op_Implicit((Object)(object)array[k]))
				{
					Object.Destroy((Object)(object)array[k]);
				}
			}
			digitalRendererMaterials[j] = null;
		}
		if (Object.op_Implicit((Object)(object)digitalPatternTexture))
		{
			Object.Destroy((Object)(object)digitalPatternTexture);
		}
		digitalPatternTexture = null;
	}

	private Material[] BuildDigitalMaterialSet(Material[] sourceMaterials, Color primaryColor, Color secondaryColor, Texture2D texture)
	{
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Expected O, but got Unknown
		//IL_005a: 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_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		int num = Mathf.Max(1, (sourceMaterials != null) ? sourceMaterials.Length : 0);
		Material[] array = (Material[])(object)new Material[num];
		for (int i = 0; i < num; i++)
		{
			Material val = ((sourceMaterials != null && i < sourceMaterials.Length) ? sourceMaterials[i] : null);
			Shader val2 = Shader.Find("Sprites/Default");
			if (!Object.op_Implicit((Object)(object)val2) && (Object)(object)val != (Object)null)
			{
				val2 = val.shader;
			}
			Material val3 = new Material(val2);
			Color color = Color.Lerp(primaryColor, secondaryColor, (i % 2 == 0) ? 0.2f : 0.75f);
			SetDigitalTexture(val3, texture);
			SetDigitalColor(val3, color);
			array[i] = val3;
		}
		return array;
	}

	private void SetDigitalTexture(Material material, Texture2D texture)
	{
		if (material.HasProperty("_MainTex"))
		{
			material.SetTexture("_MainTex", (Texture)(object)texture);
		}
		if (material.HasProperty("_BaseMap"))
		{
			material.SetTexture("_BaseMap", (Texture)(object)texture);
		}
		if (material.HasProperty("_EmissionMap"))
		{
			material.SetTexture("_EmissionMap", (Texture)(object)texture);
			material.EnableKeyword("_EMISSION");
		}
		if (material.HasProperty("_Glossiness"))
		{
			material.SetFloat("_Glossiness", 0.03f);
		}
		if (material.HasProperty("_Smoothness"))
		{
			material.SetFloat("_Smoothness", 0.03f);
		}
		if (material.HasProperty("_Metallic"))
		{
			material.SetFloat("_Metallic", 0.08f);
		}
	}

	private void SetDigitalColor(Material material, Color color)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: 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_0024: 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_0056: 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)
		Color val = Color.Lerp(Color.black, color, 0.82f);
		if (material.HasProperty("_Color"))
		{
			material.SetColor("_Color", val);
		}
		if (material.HasProperty("_BaseColor"))
		{
			material.SetColor("_BaseColor", val);
		}
		if (material.HasProperty("_EmissionColor"))
		{
			material.SetColor("_EmissionColor", color * 2.1f);
			material.EnableKeyword("_EMISSION");
		}
	}

	private void UpdateDigitalizedMaterials(Color color)
	{
		//IL_0013: 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_00a3: 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_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_015c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		float num = Time.time * 0.42f;
		Color aspectSecondaryColor = GetAspectSecondaryColor(currentAspect);
		Vector2 val2 = default(Vector2);
		for (int i = 0; i < digitalRendererMaterials.Count; i++)
		{
			Material[] array = digitalRendererMaterials[i];
			if (array == null)
			{
				continue;
			}
			for (int j = 0; j < array.Length; j++)
			{
				Material val = array[j];
				if (Object.op_Implicit((Object)(object)val))
				{
					((Vector2)(ref val2))..ctor(num * (0.14f + (float)j * 0.03f), Mathf.Sin(Time.time * (1.8f + (float)i * 0.17f + (float)j * 0.08f)) * 0.08f);
					if (val.HasProperty("_MainTex"))
					{
						val.SetTextureOffset("_MainTex", val2);
						val.SetTextureScale("_MainTex", new Vector2(3.6f + (float)j * 0.45f, 3.2f + (float)i * 0.18f));
					}
					if (val.HasProperty("_BaseMap"))
					{
						val.SetTextureOffset("_BaseMap", val2);
						val.SetTextureScale("_BaseMap", new Vector2(3.6f + (float)j * 0.45f, 3.2f + (float)i * 0.18f));
					}
					Color color2 = Color.Lerp(color, aspectSecondaryColor, 0.2f + Mathf.PingPong(Time.time * 0.9f + (float)i * 0.17f + (float)j * 0.13f, 0.35f));
					SetDigitalColor(val, color2);
				}
			}
		}
	}

	private void BuildEvolvedShell()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: 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_0042: 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_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Expected O, but got Unknown
		//IL_00d6: 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_0100: Unknown result type (might be due to invalid IL or missing references)
		DestroyShell();
		Bounds val = CalculateVisualBounds();
		float width = Mathf.Max(0.55f, ((Bounds)(ref val)).size.x);
		float depth = Mathf.Max(0.55f, ((Bounds)(ref val)).size.z);
		float height = Mathf.Max(0.9f, ((Bounds)(ref val)).size.y);
		Vector3 position = ((Component)this).transform.position;
		shellGroundOffset = ((Bounds)(ref val)).min.y - position.y + 0.02f;
		evolvedShellRoot = new GameObject("EmpressEvolvedShell");
		evolvedShellRoot.layer = LayerMask.NameToLayer("Enemy");
		evolvedShellRoot.transform.SetParent(((Component)this).transform, false);
		evolvedShellRoot.transform.localPosition = new Vector3(0f, shellGroundOffset, 0f);
		evolvedShellRoot.transform.localRotation = Quaternion.identity;
		evolvedShellRoot.transform.localScale = Vector3.one;
		evolvedShellRigidbody = evolvedShellRoot.AddComponent<Rigidbody>();
		evolvedShellRigidbody.isKinematic = true;
		evolvedShellRigidbody.useGravity = false;
		evolvedShellRigidbody.detectCollisions = true;
		evolvedShellRigidbody.interpolation = (RigidbodyInterpolation)1;
		shellBody = null;
		shellHead = null;
		shellCore = null;
		shellLimbs.Clear();
		shellAccents.Clear();
		shellLimbBaseLocalPositions.Clear();
		shellLimbBaseLocalRotations.Clear();
		shellAccentBaseLocalScales.Clear();
		switch (currentAspect)
		{
		case DigivolveAspect.Burst:
			BuildBurstShell(width, depth, height);
			break;
		case DigivolveAspect.Fortress:
			BuildFortressShell(width, depth, height);
			break;
		case DigivolveAspect.Phantom:
			BuildPhantomShell(width, depth, height);
			break;
		}
		BuildShellHitCollider(width, depth, height);
		CaptureShellBasePose();
	}

	private Vector3 ResolveCombatAnchorPosition()
	{
		//IL_0016: 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_0070: 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)
		if (transforming || hasDigivolved)
		{
			return ((Component)this).transform.position;
		}
		if (Object.op_Implicit((Object)(object)enemy) && enemy.HasRigidbody && (Object)(object)enemy.Rigidbody != (Object)null)
		{
			if (Object.op_Implicit((Object)(object)enemy.Rigidbody.physGrabObject))
			{
				return enemy.Rigidbody.physGrabObject.centerPoint;
			}
			if (Object.op_Implicit((Object)(object)enemy.Rigidbody.rb))
			{
				return enemy.Rigidbody.rb.position;
			}
		}
		return ((Component)this).transform.position;
	}

	private Vector3 ResolveCombatForward()
	{
		//IL_0016: 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_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0175: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0197: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: 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_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		if (transforming || hasDigivolved)
		{
			Vector3 forward = ((Component)this).transform.forward;
			forward.y = 0f;
			if (((Vector3)(ref forward)).sqrMagnitude > 0.001f)
			{
				return ((Vector3)(ref forward)).normalized;
			}
		}
		if (Object.op_Implicit((Object)(object)enemy) && enemy.HasRigidbody && (Object)(object)enemy.Rigidbody != (Object)null)
		{
			if (Object.op_Implicit((Object)(object)enemy.Rigidbody.followTarget))
			{
				Vector3 forward2 = enemy.Rigidbody.followTarget.forward;
				forward2.y = 0f;
				if (((Vector3)(ref forward2)).sqrMagnitude > 0.001f)
				{
					return ((Vector3)(ref forward2)).normalized;
				}
			}
			if (Object.op_Implicit((Object)(object)enemy.Rigidbody.rb))
			{
				Vector3 val = enemy.Rigidbody.rb.rotation * Vector3.forward;
				val.y = 0f;
				if (((Vector3)(ref val)).sqrMagnitude > 0.001f)
				{
					return ((Vector3)(ref val)).normalized;
				}
			}
		}
		if (Object.op_Implicit((Object)(object)enemy) && ((Vector3)(ref enemy.moveDirection)).sqrMagnitude > 0.001f)
		{
			Vector3 moveDirection = enemy.moveDirection;
			moveDirection.y = 0f;
			if (((Vector3)(ref moveDirection)).sqrMagnitude > 0.001f)
			{
				return ((Vector3)(ref moveDirection)).normalized;
			}
		}
		Vector3 forward3 = ((Component)this).transform.forward;
		forward3.y = 0f;
		if (((Vector3)(ref forward3)).sqrMagnitude > 0.001f)
		{
			return ((Vector3)(ref forward3)).normalized;
		}
		return Vector3.forward;
	}

	private Quaternion ResolveShellRotation(Vector3 anchorPosition)
	{
		//IL_0056: 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_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: 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_006f: 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_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: 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_004f: Unknown result type (might be due to invalid IL or missing references)
		PlayerAvatar val = ResolvePriorityTarget();
		if (Object.op_Implicit((Object)(object)val) && !val.isDisabled)
		{
			Vector3 val2 = ((Component)val).transform.position - anchorPosition;
			val2.y = 0f;
			if (((Vector3)(ref val2)).sqrMagnitude > 0.001f)
			{
				return Quaternion.LookRotation(((Vector3)(ref val2)).normalized, Vector3.up);
			}
		}
		Vector3 val3 = ResolveCombatForward();
		if (((Vector3)(ref val3)).sqrMagnitude < 0.001f)
		{
			val3 = Vector3.forward;
		}
		return Quaternion.LookRotation(((Vector3)(ref val3)).normalized, Vector3.up);
	}

	private void SyncEvolvedShellTransform()
	{
		//IL_005e: 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_0022: 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)
		if (Object.op_Implicit((Object)(object)evolvedShellRoot))
		{
			if (shellTransformOverrideActive)
			{
				evolvedShellRoot.transform.position = shellTransformOverridePosition;
				evolvedShellRoot.transform.rotation = shellTransformOverrideRotation;
			}
			else
			{
				evolvedShellRoot.transform.localPosition = new Vector3(0f, shellGroundOffset, 0f);
				evolvedShellRoot.transform.localRotation = Quaternion.identity;
			}
		}
	}

	private void BuildBurstShell(float width, float depth, float height)
	{
		//IL_0025: 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_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: 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_00d7: 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_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f1: 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_0225: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Unknown result type (might be due to invalid IL or missing references)
		//IL_026d: Unknown result type (might be due to invalid IL or missing references)
		//IL_028d: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0330: Unknown result type (might be due to invalid IL or missing references)
		//IL_0344: Unknown result type (might be due to invalid IL or missing references)
		//IL_0364: Unknown result type (might be due to invalid IL or missing references)
		//IL_039b: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0401: Unknown result type (might be due to invalid IL or missing references)
		float num = evolvedScaleMultiplier;
		shellBody = CreateShellPart("BurstBody", (PrimitiveType)3, DigivolvePlugin.SharedShellBodyMaterial, new Vector3(0f, height * 0.56f, 0f), Vector3.zero, new Vector3(width * 0.8f * num, height * 0.52f * num, depth * 0.52f * num));
		shellHead = CreateShellPart("BurstHead", (PrimitiveType)0, DigivolvePlugin.SharedShellBodyMaterial, new Vector3(0f, height * 0.95f, depth * 0.04f), Vector3.zero, new Vector3(width * 0.44f * num, height * 0.26f * num, depth * 0.44f * num));
		shellCore = CreateShellPart("BurstCore", (PrimitiveType)0, DigivolvePlugin.SharedShellAccentMaterial, new Vector3(0f, height * 0.62f, depth * 0.24f), Vector3.zero, Vector3.one * (Mathf.Max(width, depth) * 0.2f * num));
		shellLimbs.Add(CreateShellPart("BurstArmL", (PrimitiveType)1, DigivolvePlugin.SharedShellBodyMaterial, new Vector3((0f - width) * 0.46f, height * 0.62f, 0f), new Vector3(0f, 0f, -34f), new Vector3(width * 0.16f * num, height * 0.42f * num, width * 0.16f * num)));
		shellLimbs.Add(CreateShellPart("BurstArmR", (PrimitiveType)1, DigivolvePlugin.SharedShellBodyMaterial, new Vector3(width * 0.46f, height * 0.62f, 0f), new Vector3(0f, 0f, 34f), new Vector3(width * 0.16f * num, height * 0.42f * num, width * 0.16f * num)));
		shellLimbs.Add(CreateShellPart("BurstLegL", (PrimitiveType)1, DigivolvePlugin.SharedShellBodyMaterial, new Vector3((0f - width) * 0.21f, height * 0.22f, 0f), new Vector3(0f, 0f, 5f), new Vector3(width * 0.18f * num, height * 0.48f * num, width * 0.18f * num)));
		shellLimbs.Add(CreateShellPart("BurstLegR", (PrimitiveType)1, DigivolvePlugin.SharedShellBodyMaterial, new Vector3(width * 0.21f, height * 0.22f, 0f), new Vector3(0f, 0f, -5f), new Vector3(width * 0.18f * num, height * 0.48f * num, width * 0.18f * num)));
		shellAccents.Add(CreateShellPart("BurstHornL", (PrimitiveType)3, DigivolvePlugin.SharedShellAccentMaterial, new Vector3((0f - width) * 0.16f, height * 1.12f, (0f - depth) * 0.04f), new Vector3(18f, 0f, -24f), new Vector3(width * 0.12f * num, height * 0.15f * num, width * 0.12f * num)));
		shellAccents.Add(CreateShellPart("BurstHornR", (PrimitiveType)3, DigivolvePlugin.SharedShellAccentMaterial, new Vector3(width * 0.16f, height * 1.12f, (0f - depth) * 0.04f), new Vector3(18f, 0f, 24f), new Vector3(width * 0.12f * num, height * 0.15f * num, width * 0.12f * num)));
		shellAccents.Add(CreateShellPart("BurstEyeL", (PrimitiveType)0, DigivolvePlugin.SharedShellAccentMaterial, new Vector3((0f - width) * 0.1f, height * 0.98f, depth * 0.2f), Vector3.zero, Vector3.one * (width * 0.08f * num)));
		shellAccents.Add(CreateShellPart("BurstEyeR", (PrimitiveType)0, DigivolvePlugin.SharedShellAccentMaterial, new Vector3(width * 0.1f, height * 0.98f, depth * 0.2f), Vector3.zero, Vector3.one * (width * 0.08f * num)));
	}

	private void BuildFortressShell(float width, float depth, float height)
	{
		//IL_0025: 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_004a: 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_008d: 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_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_00ff: 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_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: 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_0213: 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_024f: Unknown result type (might be due to invalid IL or missing references)
		//IL_026f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_030a: Unknown result type (might be due to invalid IL or missing references)
		//IL_031e: Unknown result type (might be due to invalid IL or missing references)
		//IL_033e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0372: Unknown result type (might be due to invalid IL or missing references)
		//IL_0386: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_042b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0430: Unknown result type (might be due to invalid IL or missing references)
		//IL_0435: Unknown result type (might be due to invalid IL or missing references)
		//IL_0443: Unknown result type (might be due to invalid IL or missing references)
		float num = evolvedScaleMultiplier;
		shellBody = CreateShellPart("FortressBody", (PrimitiveType)3, DigivolvePlugin.SharedShellBodyMaterial, new Vector3(0f, height * 0.48f, 0f), Vector3.zero, new Vector3(width * 1.08f * num, height * 0.4f * num, depth * 0.92f * num));
		shellHead = CreateShellPart("FortressHead", (PrimitiveType)3, DigivolvePlugin.SharedShellBodyMaterial, new Vector3(0f, height * 0.56f, depth * 0.5f), new Vector3(0f, 0f, 0f), new Vector3(width * 0.38f * num, height * 0.22f * num, depth * 0.34f * num));
		shellCore = CreateShellPart("FortressCore", (PrimitiveType)3, DigivolvePlugin.SharedShellAccentMaterial, new Vector3(0f, height * 0.62f, 0f), Vector3.zero, new Vector3(width * 0.22f * num, height * 0.12f * num, depth * 0.22f * num));
		shellLimbs.Add(CreateShellPart("FortressLegFL", (PrimitiveType)3, DigivolvePlugin.SharedShellBodyMaterial, new Vector3((0f - width) * 0.38f, height * 0.19f, depth * 0.3f), Vector3.zero, new Vector3(width * 0.16f * num, height * 0.38f * num, width * 0.16f * num)));
		shellLimbs.Add(CreateShellPart("FortressLegFR", (PrimitiveType)3, DigivolvePlugin.SharedShellBodyMaterial, new Vector3(width * 0.38f, height * 0.19f, depth * 0.3f), Vector3.zero, new Vector3(width * 0.16f * num, height * 0.38f * num, width * 0.16f * num)));
		shellLimbs.Add(CreateShellPart("FortressLegBL", (PrimitiveType)3, DigivolvePlugin.SharedShellBodyMaterial, new Vector3((0f - width) * 0.38f, height * 0.19f, (0f - depth) * 0.3f), Vector3.zero, new Vector3(width * 0.16f * num, height * 0.38f * num, width * 0.16f * num)));
		shellLimbs.Add(CreateShellPart("FortressLegBR", (PrimitiveType)3, DigivolvePlugin.SharedShellBodyMaterial, new Vector3(width * 0.38f, height * 0.19f, (0f - depth) * 0.3f), Vector3.zero, new Vector3(width * 0.16f * num, height * 0.38f * num, width * 0.16f * num)));
		shellAccents.Add(CreateShellPart("FortressSpineA", (PrimitiveType)3, DigivolvePlugin.SharedShellAccentMaterial, new Vector3(0f, height * 0.78f, (0f - depth) * 0.24f), new Vector3(22f, 0f, 0f), new Vector3(width * 0.14f * num, height * 0.24f * num, width * 0.12f * num)));
		shellAccents.Add(CreateShellPart("FortressSpineB", (PrimitiveType)3, DigivolvePlugin.SharedShellAccentMaterial, new Vector3(0f, height * 0.82f, 0f), new Vector3(22f, 0f, 0f), new Vector3(width * 0.16f * num, height * 0.28f * num, width * 0.14f * num)));
		shellAccents.Add(CreateShellPart("FortressSpineC", (PrimitiveType)3, DigivolvePlugin.SharedShellAccentMaterial, new Vector3(0f, height * 0.78f, depth * 0.24f), new Vector3(22f, 0f, 0f), new Vector3(width * 0.14f * num, height * 0.24f * num, width * 0.12f * num)));
		shellAccents.Add(CreateShellPart("FortressEyeL", (PrimitiveType)0, DigivolvePlugin.SharedShellAccentMaterial, new Vector3((0f - width) * 0.08f, height * 0.57f, depth * 0.7f), Vector3.zero, Vector3.one * (width * 0.07f * num)));
		shellAccents.Add(CreateShellPart("FortressEyeR", (PrimitiveType)0, DigivolvePlugin.SharedShellAccentMaterial, new Vector3(width * 0.08f, height * 0.57f, depth * 0.7f), Vector3.zero, Vector3.one * (width * 0.07f * num)));
	}

	private void BuildPhantomShell(float width, float depth, float height)
	{
		//IL_0025: 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_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: 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_025f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0264: Unknown result type (might be due to invalid IL or missing references)
		//IL_0269: Unknown result type (might be due to invalid IL or missing references)
		//IL_0277: 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_02b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c5: 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_0310: Unknown result type (might be due to invalid IL or missing references)
		//IL_0330: Unknown result type (might be due to invalid IL or missing references)
		//IL_0366: Unknown result type (might be due to invalid IL or missing references)
		//IL_037a: Unknown result type (might be due to invalid IL or missing references)
		//IL_039a: Unknown result type (might be due to invalid IL or missing references)
		float num = evolvedScaleMultiplier;
		shellBody = CreateShellPart("PhantomThorax", (PrimitiveType)0, DigivolvePlugin.SharedShellBodyMaterial, new Vector3(0f, height * 0.52f, 0f), Vector3.zero, new Vector3(width * 0.54f * num, height * 0.28f * num, depth * 0.54f * num));
		shellHead = CreateShellPart("PhantomHead", (PrimitiveType)0, DigivolvePlugin.SharedShellBodyMaterial, new Vector3(0f, height * 0.54f, depth * 0.34f), Vector3.zero, new Vector3(width * 0.34f * num, height * 0.2f * num, depth * 0.34f * num));
		shellCore = CreateShellPart("PhantomAbdomen", (PrimitiveType)0, DigivolvePlugin.SharedShellBodyMaterial, new Vector3(0f, height * 0.48f, (0f - depth) * 0.42f), Vector3.zero, new Vector3(width * 0.68f * num, height * 0.34f * num, depth * 0.74f * num));
		for (int i = 0; i < 4; i++)
		{
			float num2 = Mathf.Lerp((0f - depth) * 0.32f, depth * 0.28f, (float)i / 3f);
			shellLimbs.Add(CreateShellPart("PhantomLegL_" + i, (PrimitiveType)3, DigivolvePlugin.SharedShellBodyMaterial, new Vector3((0f - width) * 0.48f, height * (0.44f - (float)i * 0.02f), num2), new Vector3(0f, 0f, 42f + (float)i * 6f), new Vector3(width * 0.54f * num, height * 0.05f * num, width * 0.06f * num)));
			shellLimbs.Add(CreateShellPart("PhantomLegR_" + i, (PrimitiveType)3, DigivolvePlugin.SharedShellBodyMaterial, new Vector3(width * 0.48f, height * (0.44f - (float)i * 0.02f), num2), new Vector3(0f, 0f, 0f - (42f + (float)i * 6f)), new Vector3(width * 0.54f * num, height * 0.05f * num, width * 0.06f * num)));
		}
		shellAccents.Add(CreateShellPart("PhantomEyeA", (PrimitiveType)0, DigivolvePlugin.SharedShellAccentMaterial, new Vector3((0f - width) * 0.1f, height * 0.58f, depth * 0.5f), Vector3.zero, Vector3.one * (width * 0.07f * num)));
		shellAccents.Add(CreateShellPart("PhantomEyeB", (PrimitiveType)0, DigivolvePlugin.SharedShellAccentMaterial, new Vector3(width * 0.1f, height * 0.58f, depth * 0.5f), Vector3.zero, Vector3.one * (width * 0.07f * num)));
		shellAccents.Add(CreateShellPart("PhantomFangL", (PrimitiveType)3, DigivolvePlugin.SharedShellAccentMaterial, new Vector3((0f - width) * 0.07f, height * 0.45f, depth * 0.58f), new Vector3(18f, 0f, 0f), new Vector3(width * 0.05f * num, height * 0.16f * num, width * 0.05f * num)));
		shellAccents.Add(CreateShellPart("PhantomFangR", (PrimitiveType)3, DigivolvePlugin.SharedShellAccentMaterial, new Vector3(width * 0.07f, height * 0.45f, depth * 0.58f), new Vector3(18f, 0f, 0f), new Vector3(width * 0.05f * num, height * 0.16f * num, width * 0.05f * num)));
	}

	private Transform CreateShellPart(string name, PrimitiveType primitiveType, Material material, Vector3 localPosition, Vector3 localEuler, Vector3 localScale)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: 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)
		GameObject obj = GameObject.CreatePrimitive(primitiveType);
		((Object)obj).name = name;
		obj.layer = LayerMask.NameToLayer("Enemy");
		obj.transform.SetParent(evolvedShellRoot.transform, false);
		obj.transform.localPosition = localPosition;
		obj.transform.localRotation = Quaternion.Euler(localEuler);
		obj.transform.localScale = localScale;
		Collider component = obj.GetComponent<Collider>();
		if (Object.op_Implicit((Object)(object)component))
		{
			Object.Destroy((Object)(object)component);
		}
		Renderer component2 = obj.GetComponent<Renderer>();
		if (Object.op_Implicit((Object)(object)component2))
		{
			component2.sharedMaterial = material;
			component2.shadowCastingMode = (ShadowCastingMode)0;
			component2.receiveShadows = false;
		}
		return obj.transform;
	}

	private void BuildShellHitCollider(float width, float depth, float height)
	{
		//IL_0046: 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_00cb: 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)
		if (Object.op_Implicit((Object)(object)evolvedShellRoot))
		{
			switch (currentAspect)
			{
			case DigivolveAspect.Burst:
			{
				CapsuleCollider val = evolvedShellRoot.AddComponent<CapsuleCollider>();
				val.center = new Vector3(0f, height * 0.58f, 0f);
				val.radius = Mathf.Max(width, depth) * 0.28f;
				val.height = Mathf.Max(height * 1.16f, val.radius * 2f + 0.1f);
				val.direction = 1;
				break;
			}
			case DigivolveAspect.Fortress:
			{
				BoxCollider obj2 = evolvedShellRoot.AddComponent<BoxCollider>();
				obj2.center = new Vector3(0f, height * 0.42f, 0f);
				obj2.size = new Vector3(width * 1.08f, height * 0.78f, depth * 1.02f);
				break;
			}
			case DigivolveAspect.Phantom:
			{
				SphereCollider obj = evolvedShellRoot.AddComponent<SphereCollider>();
				obj.center = new Vector3(0f, height * 0.48f, 0f);
				obj.radius = Mathf.Max(width, depth) * 0.42f;
				break;
			}
			}
		}
	}

	private void CaptureShellBasePose()
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0064: 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_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: 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_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		shellLimbBaseLocalPositions.Clear();
		shellLimbBaseLocalRotations.Clear();
		shellAccentBaseLocalScales.Clear();
		if (Object.op_Implicit((Object)(object)shellBody))
		{
			shellBodyBaseLocalPosition = shellBody.localPosition;
			shellBodyBaseLocalRotation = shellBody.localRotation;
		}
		if (Object.op_Implicit((Object)(object)shellHead))
		{
			shellHeadBaseLocalRotation = shellHead.localRotation;
		}
		if (Object.op_Implicit((Object)(object)shellCore))
		{
			shellCoreBaseLocalScale = shellCore.localScale;
		}
		for (int i = 0; i < shellLimbs.Count; i++)
		{
			Transform val = shellLimbs[i];
			shellLimbBaseLocalPositions.Add(Object.op_Implicit((Object)(object)val) ? val.localPosition : Vector3.zero);
			shellLimbBaseLocalRotations.Add(Object.op_Implicit((Object)(object)val) ? val.localRotation : Quaternion.identity);
		}
		for (int j = 0; j < shellAccents.Count; j++)
		{
			Transform val2 = shellAccents[j];
			shellAccentBaseLocalScales.Add(Object.op_Implicit((Object)(object)val2) ? val2.localScale : Vector3.one);
		}
	}

	private void UpdateShellPose()
	{
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: 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_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0288: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02df: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_041f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0424: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: 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_0442: Unknown result type (might be due to invalid IL or missing references)
		//IL_0478: Unknown result type (might be due to invalid IL or missing references)
		//IL_047d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0585: Unknown result type (might be due to invalid IL or missing references)
		//IL_058b: Unknown result type (might be due to invalid IL or missing references)
		//IL_032e: Unknown result type (might be due to invalid IL or missing references)
		//IL_035e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0363: Unknown result type (might be due to invalid IL or missing references)
		//IL_0377: Unknown result type (might be due to invalid IL or missing references)
		//IL_038d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0392: 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_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_024d: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0512: Unknown result type (might be due to invalid IL or missing references)
		//IL_0517: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)evolvedShellRoot))
		{
			return;
		}
		float time = Time.time;
		float num = 0f;
		if (shellAttackAnimTimer > 0f && shellAttackAnimDuration > 0f)
		{
			num = Mathf.Sin((1f - Mathf.Clamp01(shellAttackAnimTimer / shellAttackAnimDuration)) * MathF.PI);
		}
		if (Object.op_Implicit((Object)(object)shellCore))
		{
			float num2 = 1f + Mathf.Sin(time * 8f) * 0.08f + Mathf.Max(0f, aspectPulseTimer) * 0.2f + num * 0.12f;
			shellCore.localScale = shellCoreBaseLocalScale * num2;
		}
		switch (currentAspect)
		{
		case DigivolveAspect.Burst:
		{
			if (Object.op_Implicit((Object)(object)shellBody))
			{
				shellBody.localPosition = shellBodyBaseLocalPosition + new Vector3(0f, 0f, num * 0.26f);
				shellBody.localRotation = shellBodyBaseLocalRotation * Quaternion.Euler(Mathf.Sin(time * 6f) * 5f - num * 18f, Mathf.Sin(time * 2.2f) * 12f, 0f);
			}
			if (Object.op_Implicit((Object)(object)shellHead))
			{
				shellHead.localRotation = shellHeadBaseLocalRotation * Quaternion.Euler(Mathf.Sin(time * 5f) * 8f - num * 22f, Mathf.Sin(time * 3f) * 18f, 0f);
			}
			for (int j = 0; j < shellLimbs.Count; j++)
			{
				Transform val2 = shellLimbs[j];
				if (Object.op_Implicit((Object)(object)val2))
				{
					float num4 = ((j % 2 == 0) ? 1f : (-1f));
					val2.localPosition = shellLimbBaseLocalPositions[j];
					val2.localRotation = shellLimbBaseLocalRotations[j] * Quaternion.Euler(Mathf.Sin(time * 7f + (float)j) * 10f - num * 28f, 0f, Mathf.Sin(time * 7f + (float)j) * 6f * num4);
				}
			}
			break;
		}
		case DigivolveAspect.Fortress:
		{
			if (Object.op_Implicit((Object)(object)shellBody))
			{
				shellBody.localPosition = shellBodyBaseLocalPosition + new Vector3(0f, Mathf.Sin(time * 2.5f) * 0.01f - num * 0.08f, num * 0.12f);
				shellBody.localRotation = shellBodyBaseLocalRotation * Quaternion.Euler(num * 14f, 0f, 0f);
			}
			for (int k = 0; k < shellLimbs.Count; k++)
			{
				Transform val3 = shellLimbs[k];
				if (Object.op_Implicit((Object)(object)val3))
				{
					float num5 = ((k < 2) ? 1f : (-1f));
					val3.localPosition = shellLimbBaseLocalPositions[k] + new Vector3(0f, Mathf.Sin(time * 3f + (float)k) * 0.01f * num5 - num * 0.02f, 0f);
					val3.localRotation = shellLimbBaseLocalRotations[k] * Quaternion.Euler(num * 10f, 0f, 0f);
				}
			}
			break;
		}
		case DigivolveAspect.Phantom:
		{
			if (Object.op_Implicit((Object)(object)shellBody))
			{
				shellBody.localPosition = shellBodyBaseLocalPosition + new Vector3(0f, num * 0.04f, num * 0.2f);
				shellBody.localRotation = shellBodyBaseLocalRotation * Quaternion.Euler((0f - num) * 10f, Mathf.Sin(time * 2.8f) * 18f, 0f);
			}
			if (Object.op_Implicit((Object)(object)shellHead))
			{
				shellHead.localRotation = shellHeadBaseLocalRotation * Quaternion.Euler(Mathf.Sin(time * 5f) * 10f - num * 18f, Mathf.Sin(time * 4f) * 14f, 0f);
			}
			for (int i = 0; i < shellLimbs.Count; i++)
			{
				Transform val = shellLimbs[i];
				if (Object.op_Implicit((Object)(object)val))
				{
					float num3 = ((i % 2 == 0) ? 1f : (-1f));
					val.localPosition = shellLimbBaseLocalPositions[i];
					val.localRotation = shellLimbBaseLocalRotations[i] * Quaternion.Euler(0f, 0f, Mathf.Sin(time * 8f + (float)i * 0.35f) * 8f * num3 + num * 18f * num3);
				}
			}
			break;
		}
		}
		float num6 = 1f + Mathf.Max(0f, aspectPulseTimer) * 0.18f + num * 0.08f;
		for (int l = 0; l < shellAccents.Count; l++)
		{
			Transform val4 = shellAccents[l];
			if (Object.op_Implicit((Object)(object)val4))
			{
				val4.localScale = shellAccentBaseLocalScales[l] * num6;
			}
		}
	}

	private void DestroyShell()
	{
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: 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_0095: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)evolvedShellRoot))
		{
			Object.Destroy((Object)(object)evolvedShellRoot);
		}
		evolvedShellRoot = null;
		evolvedShellRigidbody = null;
		shellBody = null;
		shellHead = null;
		shellCore = null;
		shellLimbs.Clear();
		shellAccents.Clear();
		shellLimbBaseLocalPositions.Clear();
		shellLimbBaseLocalRotations.Clear();
		shellAccentBaseLocalScales.Clear();
		shellGroundOffset = 0f;
		shellTransformOverrideActive = false;
		shellTransformOverridePosition = Vector3.zero;
		shellTransformOverrideRotation = Quaternion.identity;
		shellTransformOverrideTimer = 0f;
	}

	private void UpdateAspectBehavior(float deltaTime)
	{
		if (Object.op_Implicit((Object)(object)enemy) && Object.op_Implicit((Object)(object)health))
		{
			aspectActionTimer -= deltaTime;
			PlayerAvatar target = ResolvePriorityTarget();
			switch (currentAspect)
			{
			case DigivolveAspect.Burst:
				UpdateBurstAspect(target);
				break;
			case DigivolveAspect.Fortress:
				UpdateFortressAspect(target);
				break;
			case DigivolveAspect.Phantom:
				UpdatePhantomAspect(target);
				break;
			}
		}
	}

	private void UpdateBurstAspect(PlayerAvatar target)
	{
		health.OverrideDamageResistance(0.18f, 0.2f);
		MaintainCustomCombatLocomotion(target, 1.45f, 1.45f, 1.45f, 1.3f);
		if (aspectActionTimer > 0f || (Object)(object)target == (Object)null)
		{
			TryCustomAttack(target, 1.65f, 24, 1.05f, 0.65f);
			return;
		}
		aspectActionTimer = GetAspectBaseCooldown(currentAspect);
		TriggerAspectPulseAuthoritative(0.8f);
		TryBurstDash(target);
		if (enemy.HasNavMeshAgent && (Object)(object)enemy.NavMeshAgent != (Object)null)
		{
			enemy.NavMeshAgent.OverrideAgent(enemy.NavMeshAgent.DefaultSpeed * 2.35f, enemy.NavMeshAgent.DefaultAcceleration * 2.15f, 1.15f);
		}
		if (enemy.HasRigidbody && (Object)(object)enemy.Rigidbody != (Object)null)
		{
			enemy.Rigidbody.OverrideFollowPosition(0.8f, enemy.Rigidbody.positionSpeedChase * 1.95f, enemy.Rigidbody.positionSpeedLerpChase * 1.4f);
			enemy.Rigidbody.OverrideFollowRotation(0.8f, enemy.Rigidbody.rotationSpeedChase * 1.7f);
		}
		TryCustomAttack(target, 1.8f, 30, 0.8f, 0.9f);
	}

	private void UpdateFortressAspect(PlayerAvatar target)
	{
		health.OverrideDamageResistance(0.38f, 0.2f);
		enemy.OverrideType((EnemyType)4, 0.25f);
		MaintainCustomCombatLocomotion(target, 0.95f, 1.1f, 1.08f, 1.05f);
		if (aspectActionTimer > 0f)
		{
			TryCustomAttack(target, 1.95f, 36, 1.55f, 0.82f);
			return;
		}
		aspectActionTimer = GetAspectBaseCooldown(currentAspect);
		health.OverrideDamageResistance(0.88f, 1.8f);
		enemy.Freeze(0.15f);
		TriggerAspectPulseAuthoritative(1f);
		DoFortressShockwave(2.05f, 18);
		TryCustomAttack(target, 2.05f, 42, 1.25f, 1f);
	}

	private void UpdatePhantomAspect(PlayerAvatar target)
	{
		health.OverrideDamageResistance(0.22f, 0.2f);
		MaintainCustomCombatLocomotion(target, 1.22f, 1.32f, 1.28f, 1.2f);
		if (aspectActionTimer > 0f || (Object)(object)target == (Object)null)
		{
			TryCustomAttack(target, 1.55f, 28, 0.95f, 0.75f);
			return;
		}
		if (!TryStartPhantomStalk(target))
		{
			aspectActionTimer = 1.2f;
			return;
		}
		aspectActionTimer = GetAspectBaseCooldown(currentAspect);
		health.OverrideDamageResistance(0.65f, 0.75f);
		TriggerAspectPulseAuthoritative(0.95f);
	}

	private void MaintainCustomCombatLocomotion(PlayerAvatar target, float navSpeedMultiplier, float navAccelerationMultiplier, float followSpeedMultiplier, float followRotationMultiplier)
	{
		//IL_0015: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: 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_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_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: 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_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)enemy))
		{
			return;
		}
		enemy.CurrentState = (EnemyState)2;
		enemy.DisableChase(0.35f);
		enemy.ChaseTimer = 0f;
		enemy.TargetPlayerAvatar = null;
		enemy.TargetPlayerViewID = -1;
		if (enemy.HasStateChaseBegin && (Object)(object)enemy.StateChaseBegin != (Object)null)
		{
			enemy.StateChaseBegin.TargetPlayer = null;
		}
		if (!((Object)(object)target == (Object)null) && !target.isDisabled)
		{
			float num = Mathf.Max(1.75f, 2.8f * navSpeedMultiplier);
			float floorLift = Mathf.Max(0.65f, 1.18f + followSpeedMultiplier * 0.3f);
			Vector3 position = ((Component)this).transform.position;
			Vector3 val = ((Component)target).transform.position - position;
			val.y = 0f;
			Quaternion worldRotation = ((Component)this).transform.rotation;
			if (((Vector3)(ref val)).sqrMagnitude > 0.001f)
			{
				worldRotation = Quaternion.Slerp(((Component)this).transform.rotation, Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up), Time.deltaTime * (7f * followRotationMultiplier));
			}
			Vector3 worldPosition = position;
			float num2 = Mathf.Max(1.1f, 1.4f + pendingAttackRange * 0.1f);
			if (((Vector3)(ref val)).sqrMagnitude > num2 * num2)
			{
				Vector3 desiredPosition = position + ((Vector3)(ref val)).normalized * (num * Time.deltaTime);
				worldPosition = ResolveGroundPosition(desiredPosition, position, floorLift);
			}
			ApplyCustomBodyTransform(worldPosition, worldRotation);
		}
	}

	private Vector3 ResolveGroundPosition(Vector3 desiredPosition, Vector3 fallbackPosition, float floorLift)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: 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_006b: 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)
		int mask = LayerMask.GetMask(new string[3] { "Default", "NavmeshOnly", "PlayerOnlyColli