Decompiled source of Invencibility v1.0.0

plugins\Invencibility.dll

Decompiled 3 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using BoplFixedMath;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using OctoLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Invencibility")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Invencibility")]
[assembly: AssemblyTitle("Invencibility")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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;
		}
	}
}
namespace Invencibility
{
	internal static class InvUtil
	{
		public static bool IsInvencibilityObject(Object obj)
		{
			if (obj != (Object)null && obj.name != null)
			{
				return obj.name.Contains("Invencibility");
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(AbilityGrid), "Awake")]
	internal static class InvCooldownPatch
	{
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void Postfix(AbilityGrid __instance)
		{
			//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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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)
			NamedSpriteList value = Traverse.Create((object)__instance).Field("abilityIcons").GetValue<NamedSpriteList>();
			if (value?.sprites == null)
			{
				return;
			}
			foreach (NamedSprite sprite in value.sprites)
			{
				if (!(sprite.name != "Invencibility") && !((Object)(object)sprite.associatedGameObject == (Object)null))
				{
					InstantAbility component = sprite.associatedGameObject.GetComponent<InstantAbility>();
					if ((Object)(object)component != (Object)null)
					{
						component.SetCoolDown((Fix)60f);
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(Invisibility), "CastInvisibility")]
	internal static class InvCastPatch
	{
		internal static StarPower LastStar;

		internal static bool LastEndedActive;

		[HarmonyPrefix]
		private static bool Prefix(Invisibility __instance)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			if (!InvUtil.IsInvencibilityObject((Object)(object)((Component)__instance).gameObject))
			{
				return true;
			}
			InstantAbility component = ((Component)__instance).GetComponent<InstantAbility>();
			if ((Object)(object)component == (Object)null)
			{
				return false;
			}
			SlimeController slimeController = ((AbilityMonoBehaviour)component).GetSlimeController();
			if ((Object)(object)slimeController == (Object)null)
			{
				return false;
			}
			int abilityButtonUsedIndex = Traverse.Create((object)component).Field("playerInfo").GetValue<PlayerInfo>()
				.AbilityButtonUsedIndex012;
			StarPower starPower = ((Component)slimeController).GetComponent<StarPower>();
			if ((Object)(object)starPower == (Object)null)
			{
				starPower = ((Component)slimeController).gameObject.AddComponent<StarPower>();
			}
			bool active = starPower.Active;
			bool flag = starPower.HandleCast(slimeController, component, abilityButtonUsedIndex);
			if (active != flag || flag)
			{
				LastStar = starPower;
				LastEndedActive = flag;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(SlimeController), "EnterAbility")]
	internal static class InvEnterAbilityPostfix
	{
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void Postfix(SlimeController __instance, int abilityIndex)
		{
			StarPower lastStar = InvCastPatch.LastStar;
			if (!((Object)(object)lastStar == (Object)null) && !((Object)(object)lastStar != (Object)(object)((Component)__instance).GetComponent<StarPower>()))
			{
				if (InvCastPatch.LastEndedActive)
				{
					lastStar.ReassertAfterEnterAbility();
				}
				InvCastPatch.LastStar = null;
			}
		}
	}
	[HarmonyPatch(typeof(SlimeController), "AddAbility")]
	internal static class InvAddAbilityReadyPatch
	{
		[HarmonyPostfix]
		private static void Postfix(SlimeController __instance)
		{
			InvReadyHelper.EnsureSlotsReady(__instance);
		}
	}
	[HarmonyPatch(typeof(SlimeController), "AddAdditionalAbility")]
	internal static class InvAddAdditionalReadyPatch
	{
		[HarmonyPostfix]
		private static void Postfix(SlimeController __instance)
		{
			InvReadyHelper.EnsureSlotsReady(__instance);
		}
	}
	[HarmonyPatch(typeof(SlimeController), "Init")]
	internal static class InvInitReadyPatch
	{
		[HarmonyPostfix]
		private static void Postfix(SlimeController __instance)
		{
			InvReadyHelper.EnsureSlotsReady(__instance);
		}
	}
	[HarmonyPatch(typeof(SlimeController), "BeforeSpawnInit")]
	internal static class InvBeforeSpawnReadyPatch
	{
		[HarmonyPostfix]
		private static void Postfix(SlimeController __instance)
		{
			InvReadyHelper.EnsureSlotsReady(__instance);
		}
	}
	internal static class InvReadyHelper
	{
		public static void EnsureSlotsReady(SlimeController slime)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)slime == (Object)null)
			{
				return;
			}
			List<AbilityMonoBehaviour> value = Traverse.Create((object)slime).Field("abilities").GetValue<List<AbilityMonoBehaviour>>();
			Fix[] value2 = Traverse.Create((object)slime).Field("abilityCooldownTimers").GetValue<Fix[]>();
			if (value == null || value2 == null)
			{
				return;
			}
			for (int i = 0; i < value.Count && i < value2.Length; i++)
			{
				AbilityMonoBehaviour val = value[i];
				if (!((Object)(object)val == (Object)null) && !((MonoUpdatable)val).IsDestroyed && InvUtil.IsInvencibilityObject((Object)(object)((Component)val).gameObject))
				{
					value2[i] = (Fix)100000L;
					InstantAbility component = ((Component)val).GetComponent<InstantAbility>();
					if ((Object)(object)component != (Object)null)
					{
						component.SetCoolDown((Fix)60f);
					}
				}
			}
		}
	}
	[BepInPlugin("com.Jero.Invencibility", "Invencibility", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		internal static Assembly ModAssembly;

		private void Awake()
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			ModAssembly = Assembly.GetExecutingAssembly();
			Texture2D val = Textures.LoadFromAssembly("AbilityIcon", ModAssembly, true);
			if ((Object)(object)val == (Object)null)
			{
				Log.LogError((object)"Failed to load AbilityIcon.png — ability will have no icon.");
			}
			else
			{
				((Texture)val).filterMode = (FilterMode)1;
				((Texture)val).wrapMode = (TextureWrapMode)1;
				try
				{
					val.Apply(false, false);
				}
				catch
				{
				}
			}
			Abilities.NewAbilityWithBase("Invisibility", "Invencibility", val);
			Abilities.AbilitySetCooldown("Invencibility", (Fix)60f);
			Abilities.AbilitySetOffensive("Invencibility", false);
			Localization.AddTranslation("Invencibility", (Language)0, "Invincibility");
			Localization.AddTranslation("Invencibility", (Language)2, "Invencibilidad");
			new Harmony("com.Jero.Invencibility").PatchAll();
			Log.LogInfo((object)string.Format("Invencibility {0} loaded — {1}s star, {2}s cooldown.", "1.0.0", 5f, 60f));
		}
	}
	internal static class PluginInfo
	{
		public const string GUID = "com.Jero.Invencibility";

		public const string Name = "Invencibility";

		public const string Version = "1.0.0";
	}
	public class StarPower : MonoBehaviour
	{
		public const float DurationSeconds = 5f;

		public const float CooldownSeconds = 60f;

		public const uint InvulnMask = 256u;

		private const float BreathPeriodSeconds = 1.4f;

		private const float HaloSizeMul = 2.85f;

		private const float HaloSizePulse = 0.22f;

		private const float CoreSizeMul = 1.55f;

		private const float HaloAlphaMin = 0.35f;

		private const float HaloAlphaMax = 0.72f;

		private const float CoreAlphaMin = 0.28f;

		private const float CoreAlphaMax = 0.58f;

		private const float BodyGoldBlendMin = 0.28f;

		private const float BodyGoldBlendMax = 0.62f;

		private static readonly Color GoldDeep = new Color(0.78f, 0.52f, 0.1f, 1f);

		private static readonly Color GoldMid = new Color(0.98f, 0.78f, 0.28f, 1f);

		private static readonly Color GoldLight = new Color(1f, 0.94f, 0.62f, 1f);

		private static Sprite _haloSprite;

		private static Sprite _coreSprite;

		private SlimeController _slime;

		private InstantAbility _source;

		private int _abilityIndex = -1;

		private float _activeElapsed;

		private int _activateFrame = -1;

		private float _breathPhase;

		private SpriteRenderer _halo;

		private SpriteRenderer _core;

		private Material _mat;

		private Color _savedMain = Color.white;

		private Color _savedShadow = Color.white;

		private Color _savedReflection = Color.white;

		private Color _savedSpriteColor = Color.white;

		private bool _hasSavedColors;

		public bool Active { get; private set; }

		public int AbilityIndex => _abilityIndex;

		public bool HandleCast(SlimeController slime, InstantAbility source, int abilityIndex)
		{
			_slime = slime;
			_source = source;
			_abilityIndex = abilityIndex;
			if (Active)
			{
				if (Time.frameCount <= _activateFrame + 2 || _activeElapsed < 0.25f)
				{
					Plugin.Log.LogInfo((object)"Invencibility: ignored duplicate cast (grace)");
					return true;
				}
				Plugin.Log.LogInfo((object)"Invencibility: ignored cast while already active");
				return true;
			}
			Activate();
			return true;
		}

		private void Activate()
		{
			Active = true;
			_activeElapsed = 0f;
			_activateFrame = Time.frameCount;
			_breathPhase = 0f;
			SetInvulnerable(on: true);
			CacheOriginalColors();
			EnsureAura();
			SetAuraVisible(visible: true);
			ApplyVisuals(GetBreath01());
			SetCooldownState(5f, 0.01f);
			Plugin.Log.LogInfo((object)$"Invencibility ON (gold aura) — player {_slime.GetPlayerId()}");
		}

		private void Deactivate()
		{
			if (Active)
			{
				Active = false;
				SetInvulnerable(on: false);
				RestoreOriginalColors();
				SetAuraVisible(visible: false);
				SetCooldownState(60f, 0f);
				ManualLogSource log = Plugin.Log;
				object arg = 60f;
				SlimeController slime = _slime;
				log.LogInfo((object)$"Invencibility OFF — {arg:0}s cooldown — player {((slime != null) ? new int?(slime.GetPlayerId()) : ((int?)null))}");
			}
		}

		private void SetInvulnerable(bool on)
		{
			SlimeController slime = _slime;
			PlayerCollision val = ((slime != null) ? slime.GetPlayerCollision() : null);
			if (!((Object)(object)val == (Object)null))
			{
				val.SetInvulnerable(on, 256u);
			}
		}

		private void SetCooldownState(float cooldownMax, float timerProgress)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_source != (Object)null)
			{
				_source.SetCoolDown((Fix)cooldownMax);
			}
			if (!((Object)(object)_slime == (Object)null) && _abilityIndex >= 0)
			{
				Fix[] value = Traverse.Create((object)_slime).Field("abilityCooldownTimers").GetValue<Fix[]>();
				if (value != null && _abilityIndex < value.Length)
				{
					value[_abilityIndex] = (Fix)timerProgress;
				}
			}
		}

		public void ReassertAfterEnterAbility()
		{
			if (Active && !((Object)(object)_slime == (Object)null) && _abilityIndex >= 0)
			{
				SetCooldownState(5f, Mathf.Max(0.01f, _activeElapsed));
				SetInvulnerable(on: true);
			}
		}

		private void Update()
		{
			if (Active && !((Object)(object)_slime == (Object)null))
			{
				_activeElapsed += Time.deltaTime;
				_breathPhase += Time.deltaTime;
				SetCooldownState(5f, Mathf.Min(_activeElapsed, 4.95f));
				SetInvulnerable(on: true);
				if (_activeElapsed >= 5f)
				{
					Deactivate();
				}
			}
		}

		private void LateUpdate()
		{
			if (Active && !((Object)(object)_slime == (Object)null))
			{
				EnsureAura();
				ApplyVisuals(GetBreath01());
			}
		}

		private void OnDisable()
		{
			if (Active)
			{
				SetInvulnerable(on: false);
				RestoreOriginalColors();
				SetAuraVisible(visible: false);
				Active = false;
			}
		}

		private float GetBreath01()
		{
			float num = _breathPhase / 1.4f * (float)Math.PI * 2f;
			return 0.5f + 0.5f * Mathf.Sin(num);
		}

		private void CacheOriginalColors()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			_mat = null;
			EnsureMaterial();
			_hasSavedColors = false;
			SpriteRenderer val = (((Object)(object)_slime != (Object)null) ? _slime.GetPlayerSprite() : null);
			if ((Object)(object)val != (Object)null)
			{
				_savedSpriteColor = val.color;
			}
			if ((Object)(object)_mat != (Object)null)
			{
				if (_mat.HasProperty("_MainColor"))
				{
					_savedMain = _mat.GetColor("_MainColor");
				}
				if (_mat.HasProperty("_ShadowColor"))
				{
					_savedShadow = _mat.GetColor("_ShadowColor");
				}
				if (_mat.HasProperty("_ReflectionColour"))
				{
					_savedReflection = _mat.GetColor("_ReflectionColour");
				}
			}
			_hasSavedColors = true;
		}

		private void EnsureMaterial()
		{
			if (!((Object)(object)_mat != (Object)null) && !((Object)(object)_slime == (Object)null))
			{
				_mat = _slime.GetPlayerMaterial();
			}
		}

		private void EnsureAura()
		{
			EnsureSprites();
			if (!((Object)(object)_halo != (Object)null) || !((Object)(object)_core != (Object)null))
			{
				_halo = CreateAuraLayer("InvencibilityHalo", _haloSprite);
				_core = CreateAuraLayer("InvencibilityCore", _coreSprite);
				Plugin.Log.LogInfo((object)"Invencibility: gold aura layers created");
			}
		}

		private SpriteRenderer CreateAuraLayer(string name, Sprite sprite)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_002f: 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_003f: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Expected O, but got Unknown
			GameObject val = new GameObject(name)
			{
				layer = ((Component)this).gameObject.layer
			};
			val.transform.SetParent(((Component)this).transform, false);
			val.transform.localPosition = Vector3.zero;
			val.transform.localRotation = Quaternion.identity;
			val.transform.localScale = Vector3.one;
			SpriteRenderer val2 = val.AddComponent<SpriteRenderer>();
			val2.sprite = sprite;
			SpriteRenderer val3 = (((Object)(object)_slime != (Object)null) ? _slime.GetPlayerSprite() : null);
			if ((Object)(object)val3 != (Object)null && (Object)(object)((Renderer)val3).sharedMaterial != (Object)null)
			{
				((Renderer)val2).sharedMaterial = ((Renderer)val3).sharedMaterial;
			}
			else
			{
				Shader val4 = Shader.Find("Sprites/Default");
				if ((Object)(object)val4 != (Object)null)
				{
					((Renderer)val2).sharedMaterial = new Material(val4);
				}
			}
			val2.color = Color.white;
			((Renderer)val2).enabled = false;
			return val2;
		}

		private void SetAuraVisible(bool visible)
		{
			if ((Object)(object)_halo != (Object)null)
			{
				((Renderer)_halo).enabled = visible;
			}
			if ((Object)(object)_core != (Object)null)
			{
				((Renderer)_core).enabled = visible;
			}
		}

		private void ApplyVisuals(float breath01)
		{
			ApplyBodyGold(breath01);
			ApplyAura(breath01);
		}

		private void ApplyBodyGold(float breath01)
		{
			//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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_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_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: 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)
			EnsureMaterial();
			if (!_hasSavedColors)
			{
				CacheOriginalColors();
			}
			float num = Mathf.Lerp(0.28f, 0.62f, breath01);
			Color val = Color.Lerp(GoldDeep, GoldLight, breath01);
			Color val2 = Color.Lerp(GoldDeep * 0.65f, GoldMid * 0.75f, breath01);
			val2.a = 1f;
			Color val3 = Color.Lerp(GoldMid, GoldLight, breath01);
			if ((Object)(object)_mat != (Object)null)
			{
				if (_mat.HasProperty("_MainColor"))
				{
					_mat.SetColor("_MainColor", Color.Lerp(_savedMain, val, num));
				}
				if (_mat.HasProperty("_ShadowColor"))
				{
					_mat.SetColor("_ShadowColor", Color.Lerp(_savedShadow, val2, num));
				}
				if (_mat.HasProperty("_ReflectionColour"))
				{
					_mat.SetColor("_ReflectionColour", Color.Lerp(_savedReflection, val3, Mathf.Min(1f, num + 0.15f)));
				}
			}
			SpriteRenderer playerSprite = _slime.GetPlayerSprite();
			if ((Object)(object)playerSprite != (Object)null)
			{
				Color color = Color.Lerp(_savedSpriteColor, val, num * 0.85f);
				color.a = _savedSpriteColor.a;
				playerSprite.color = color;
			}
		}

		private void ApplyAura(float breath01)
		{
			//IL_0192: 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_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: 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_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_halo == (Object)null || (Object)(object)_core == (Object)null || (Object)(object)_slime == (Object)null)
			{
				return;
			}
			SpriteRenderer playerSprite = _slime.GetPlayerSprite();
			if ((Object)(object)playerSprite != (Object)null)
			{
				((Renderer)_halo).sortingLayerID = ((Renderer)playerSprite).sortingLayerID;
				((Renderer)_core).sortingLayerID = ((Renderer)playerSprite).sortingLayerID;
				((Renderer)_halo).sortingOrder = ((Renderer)playerSprite).sortingOrder - 2;
				((Renderer)_core).sortingOrder = ((Renderer)playerSprite).sortingOrder - 1;
				((Component)_halo).gameObject.layer = ((Component)playerSprite).gameObject.layer;
				((Component)_core).gameObject.layer = ((Component)playerSprite).gameObject.layer;
			}
			float num = 1f;
			if ((Object)(object)_slime.body != (Object)null && (Object)(object)_slime.body.fixtrans != (Object)null)
			{
				num = Mathf.Max(0.15f, (float)_slime.body.fixtrans.Scale);
			}
			float num2 = num * 1.1f;
			if ((Object)(object)playerSprite != (Object)null)
			{
				Bounds bounds = ((Renderer)playerSprite).bounds;
				num2 = Mathf.Max(((Bounds)(ref bounds)).size.x, ((Bounds)(ref bounds)).size.y);
				if (num2 < 0.05f)
				{
					num2 = num;
				}
			}
			float targetWorldSpan = num2 * (2.85f + 0.22f * breath01);
			float targetWorldSpan2 = num2 * (1.55f + 0.099f * breath01);
			SetSpriteWorldSize(_halo, targetWorldSpan);
			SetSpriteWorldSize(_core, targetWorldSpan2);
			Color val = Color.Lerp(GoldDeep, GoldMid, breath01);
			Color val2 = Color.Lerp(GoldMid, GoldLight, Mathf.SmoothStep(0f, 1f, breath01));
			_halo.color = new Color(val.r, val.g, val.b, Mathf.Lerp(0.35f, 0.72f, breath01));
			_core.color = new Color(val2.r, val2.g, val2.b, Mathf.Lerp(0.28f, 0.58f, breath01));
		}

		private void SetSpriteWorldSize(SpriteRenderer sr, float targetWorldSpan)
		{
			//IL_001e: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)sr == (Object)null) && !((Object)(object)sr.sprite == (Object)null))
			{
				Bounds bounds = sr.sprite.bounds;
				float x = ((Bounds)(ref bounds)).size.x;
				bounds = sr.sprite.bounds;
				float num = Mathf.Max(x, ((Bounds)(ref bounds)).size.y);
				if (num < 0.0001f)
				{
					num = 1f;
				}
				float num2 = Mathf.Max(0.0001f, ((Component)this).transform.lossyScale.x);
				float num3 = targetWorldSpan / num / num2;
				((Component)sr).transform.localPosition = Vector3.zero;
				((Component)sr).transform.localScale = new Vector3(num3, num3, 1f);
			}
		}

		private void RestoreOriginalColors()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: 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)
			if (_hasSavedColors)
			{
				EnsureMaterial();
				if ((Object)(object)_mat != (Object)null)
				{
					if (_mat.HasProperty("_MainColor"))
					{
						_mat.SetColor("_MainColor", _savedMain);
					}
					if (_mat.HasProperty("_ShadowColor"))
					{
						_mat.SetColor("_ShadowColor", _savedShadow);
					}
					if (_mat.HasProperty("_ReflectionColour"))
					{
						_mat.SetColor("_ReflectionColour", _savedReflection);
					}
				}
				SpriteRenderer val = (((Object)(object)_slime != (Object)null) ? _slime.GetPlayerSprite() : null);
				if ((Object)(object)val != (Object)null)
				{
					val.color = _savedSpriteColor;
				}
			}
			_hasSavedColors = false;
			_mat = null;
		}

		private static void EnsureSprites()
		{
			if (!((Object)(object)_haloSprite != (Object)null) || !((Object)(object)_coreSprite != (Object)null))
			{
				_haloSprite = BuildRadialGlowSprite(160, softEdge: true);
				_coreSprite = BuildRadialGlowSprite(112, softEdge: false);
			}
		}

		private static Sprite BuildRadialGlowSprite(int size, bool softEdge)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(size, size, (TextureFormat)4, false);
			((Object)val).hideFlags = (HideFlags)61;
			((Texture)val).filterMode = (FilterMode)1;
			((Texture)val).wrapMode = (TextureWrapMode)1;
			float num = (float)(size - 1) * 0.5f;
			float num2 = (float)(size - 1) * 0.5f;
			float num3 = (float)size * 0.5f;
			Color32[] array = (Color32[])(object)new Color32[size * size];
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					float num4 = ((float)j - num) / num3;
					float num5 = ((float)i - num2) / num3;
					float num6 = Mathf.Sqrt(num4 * num4 + num5 * num5);
					float num7;
					if (softEdge)
					{
						num7 = Mathf.Clamp01(1f - num6);
						num7 = num7 * num7 * (3f - 2f * num7);
						num7 = Mathf.Pow(num7, 1.15f);
					}
					else
					{
						num7 = Mathf.Clamp01(1f - num6 * 1.25f);
						num7 *= num7;
					}
					byte b = (byte)Mathf.Clamp(Mathf.RoundToInt(num7 * 255f), 0, 255);
					array[i * size + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, b);
				}
			}
			val.SetPixels32(array);
			val.Apply(false, true);
			return Sprite.Create(val, new Rect(0f, 0f, (float)size, (float)size), new Vector2(0.5f, 0.5f), 64f);
		}
	}
}