Decompiled source of The mist v1.0.0

plugins/Mod.dll

Decompiled a year ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using Alexandria.ItemAPI;
using Alexandria.Misc;
using BepInEx;
using Dungeonator;
using InControl;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Mod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Mod")]
[assembly: AssemblyCopyright("Copyright ©  2020")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d6d7a494-722e-4763-959b-c2d6b6a42b01")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Mod;

internal class VFXToolbox
{
	private static GameObject VFXScapeGoat;

	private static tk2dSpriteCollectionData PrivateVFXCollection;

	public static GameObject laserSightPrefab;

	public static tk2dSpriteCollectionData VFXCollection => PrivateVFXCollection;

	public static void InitVFX()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		VFXScapeGoat = new GameObject();
		Object.DontDestroyOnLoad((Object)(object)VFXScapeGoat);
		Object obj = LoadHelper.LoadAssetFromAnywhere("assets/resourcesbundle/global vfx/vfx_lasersight.prefab");
		laserSightPrefab = (GameObject)(object)((obj is GameObject) ? obj : null);
	}

	public static GameObject RenderLaserSight(Vector2 position, float length, float width, float angle, bool alterColour = false, Color? colour = null)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: 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)
		GameObject val = SpawnManager.SpawnVFX(laserSightPrefab, Vector2.op_Implicit(position), Quaternion.Euler(0f, 0f, angle));
		tk2dTiledSprite component = val.GetComponent<tk2dTiledSprite>();
		float num = 1f;
		if (width != -1f)
		{
			num = width;
		}
		component.dimensions = new Vector2(length, num);
		if (alterColour && colour.HasValue)
		{
			((tk2dBaseSprite)component).usesOverrideMaterial = true;
			((BraveBehaviour)((BraveBehaviour)component).sprite).renderer.material.shader = ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive");
			((BraveBehaviour)((BraveBehaviour)component).sprite).renderer.material.SetColor("_OverrideColor", colour.Value);
			((BraveBehaviour)((BraveBehaviour)component).sprite).renderer.material.SetColor("_EmissiveColor", colour.Value);
			((BraveBehaviour)((BraveBehaviour)component).sprite).renderer.material.SetFloat("_EmissivePower", 100f);
			((BraveBehaviour)((BraveBehaviour)component).sprite).renderer.material.SetFloat("_EmissiveColorPower", 1.55f);
		}
		return val;
	}

	public static void GlitchScreenForSeconds(float seconds)
	{
		((MonoBehaviour)GameManager.Instance).StartCoroutine(DoScreenGlitch(seconds));
	}

	private static IEnumerator DoScreenGlitch(float seconds)
	{
		Material glitchPass = new Material(Shader.Find("Brave/Internal/GlitchUnlit"));
		Pixelator.Instance.RegisterAdditionalRenderPass(glitchPass);
		yield return (object)new WaitForSeconds(seconds);
		Pixelator.Instance.DeregisterAdditionalRenderPass(glitchPass);
	}

	public static void DoStringSquirt(string text, Vector2 point, Color colour, float heightOffGround = 3f, float opacity = 1f)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Expected O, but got Unknown
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: 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_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: 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_00b7: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: 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)
		GameObject val = (GameObject)Object.Instantiate(BraveResources.Load("DamagePopupLabel", ".prefab"), ((BraveBehaviour)GameUIRoot.Instance).transform);
		dfLabel component = val.GetComponent<dfLabel>();
		((Component)component).gameObject.SetActive(true);
		component.Text = text;
		((dfControl)component).Color = Color32.op_Implicit(colour);
		((dfControl)component).Opacity = opacity;
		component.TextAlignment = (TextAlignment)1;
		((Component)component).transform.position = Vector2.op_Implicit(point);
		Vector2 val2 = default(Vector2);
		((Vector2)(ref val2))..ctor(((Component)component).transform.position.x - (((dfControl)component).GetCenter().x - ((Component)component).transform.position.x), point.y);
		((Component)component).transform.position = dfVectorExtensions.QuantizeFloor(((Component)component).transform.position, ((dfControl)component).PixelsToUnits() / (Pixelator.Instance.ScaleTileScale / Pixelator.Instance.CurrentTileScale));
		((MonoBehaviour)component).StartCoroutine(HandleDamageNumberCR(Vector2.op_Implicit(val2), val2.y - heightOffGround, component));
	}

	private static IEnumerator HandleDamageNumberCR(Vector3 startWorldPosition, float worldFloorHeight, dfLabel damageLabel)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		float elapsed = 0f;
		float duration = 1.5f;
		float holdTime = 0f;
		Camera mainCam = GameManager.Instance.MainCameraController.Camera;
		Vector3 worldPosition = startWorldPosition;
		Vector3 lastVelocity = new Vector3(Mathf.Lerp(-8f, 8f, Random.value), Random.Range(15f, 25f), 0f);
		while (elapsed < duration)
		{
			float dt = BraveTime.DeltaTime;
			elapsed += dt;
			if (GameManager.Instance.IsPaused)
			{
				break;
			}
			if (elapsed > holdTime)
			{
				lastVelocity += new Vector3(0f, -50f, 0f) * dt;
				Vector3 vector = lastVelocity * dt + worldPosition;
				if (vector.y < worldFloorHeight)
				{
					float num = worldFloorHeight - vector.y;
					float num2 = worldFloorHeight + num;
					vector.y = num2 * 0.5f;
					lastVelocity.y *= -0.5f;
				}
				worldPosition = vector;
				((Component)damageLabel).transform.position = Vector3Extensions.WithZ(dfFollowObject.ConvertWorldSpaces(worldPosition, mainCam, GameUIRoot.Instance.Manager.RenderCamera), 0f);
			}
			float t = elapsed / duration;
			((dfControl)damageLabel).Opacity = 1f - t;
			yield return null;
		}
		((Component)damageLabel).gameObject.SetActive(false);
		Object.Destroy((Object)(object)((Component)damageLabel).gameObject, 1f);
	}

	public static GameObject CreateOverheadVFX(List<string> filepaths, string name, int fps)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Expected O, but got Unknown
		//IL_0031: 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_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Expected O, but got Unknown
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Expected O, but got Unknown
		GameObject val = SpriteBuilder.SpriteFromResource(filepaths[0], new GameObject(name), (Assembly)null);
		val.SetActive(false);
		tk2dBaseSprite component = val.GetComponent<tk2dBaseSprite>();
		GunTools.ConstructOffsetsFromAnchor(component.GetCurrentSpriteDef(), (Anchor)1, (Vector2?)Vector2.op_Implicit(component.GetCurrentSpriteDef().position3), false, true);
		FakePrefab.MarkAsFakePrefab(val);
		Object.DontDestroyOnLoad((Object)(object)val);
		tk2dSpriteAnimator val2 = val.AddComponent<tk2dSpriteAnimator>();
		val2.Library = val.AddComponent<tk2dSpriteAnimation>();
		val2.Library.clips = (tk2dSpriteAnimationClip[])(object)new tk2dSpriteAnimationClip[0];
		tk2dSpriteAnimationClip val3 = new tk2dSpriteAnimationClip();
		val3.name = "NewOverheadVFX";
		val3.fps = fps;
		val3.frames = (tk2dSpriteAnimationFrame[])(object)new tk2dSpriteAnimationFrame[0];
		tk2dSpriteAnimationClip val4 = val3;
		foreach (string filepath in filepaths)
		{
			int num = SpriteBuilder.AddSpriteToCollection(filepath, val.GetComponent<tk2dBaseSprite>().Collection, (Assembly)null);
			GunTools.ConstructOffsetsFromAnchor(val.GetComponent<tk2dBaseSprite>().Collection.spriteDefinitions[num], (Anchor)1, (Vector2?)null, false, true);
			tk2dSpriteAnimationFrame val5 = new tk2dSpriteAnimationFrame
			{
				spriteId = num,
				spriteCollection = val.GetComponent<tk2dBaseSprite>().Collection
			};
			val4.frames = val4.frames.Concat((IEnumerable<tk2dSpriteAnimationFrame>)(object)new tk2dSpriteAnimationFrame[1] { val5 }).ToArray();
		}
		val2.Library.clips = val2.Library.clips.Concat((IEnumerable<tk2dSpriteAnimationClip>)(object)new tk2dSpriteAnimationClip[1] { val4 }).ToArray();
		val2.playAutomatically = true;
		val2.DefaultClipId = val2.GetClipIdByName("NewOverheadVFX");
		return val;
	}

	public static GameObject CreateVFX(string name, List<string> spritePaths, int fps, IntVector2 Dimensions, Anchor anchor, bool usesZHeight, float zHeightOffset, float emissivePower = -1f, Color? emissiveColour = null, WrapMode wrap = 2, bool persist = false)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Expected O, but got Unknown
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: 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_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Expected O, but got Unknown
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fa: 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_02df: Unknown result type (might be due to invalid IL or missing references)
		//IL_039c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: Unknown result type (might be due to invalid IL or missing references)
		//IL_0251: Expected O, but got Unknown
		//IL_022a: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name);
		VFXObject val2 = new VFXObject();
		val.SetActive(false);
		FakePrefab.MarkAsFakePrefab(val);
		Object.DontDestroyOnLoad((Object)(object)val);
		tk2dSpriteCollectionData val3 = SpriteBuilder.ConstructCollection(val, name + "_Collection", false);
		int num = SpriteBuilder.AddSpriteToCollection(spritePaths[0], val3, (Assembly)null);
		tk2dSprite orAddComponent = GameObjectExtensions.GetOrAddComponent<tk2dSprite>(val);
		((tk2dBaseSprite)orAddComponent).SetSprite(val3, num);
		tk2dSpriteDefinition currentSpriteDef = ((tk2dBaseSprite)orAddComponent).GetCurrentSpriteDef();
		currentSpriteDef.colliderVertices = (Vector3[])(object)new Vector3[2]
		{
			new Vector3(0f, 0f, 0f),
			new Vector3((float)(Dimensions.x / 16), (float)(Dimensions.y / 16), 0f)
		};
		tk2dSpriteAnimator orAddComponent2 = GameObjectExtensions.GetOrAddComponent<tk2dSpriteAnimator>(val);
		tk2dSpriteAnimation orAddComponent3 = GameObjectExtensions.GetOrAddComponent<tk2dSpriteAnimation>(val);
		orAddComponent3.clips = (tk2dSpriteAnimationClip[])(object)new tk2dSpriteAnimationClip[0];
		orAddComponent2.Library = orAddComponent3;
		tk2dSpriteAnimationClip val4 = new tk2dSpriteAnimationClip();
		val4.name = "start";
		val4.frames = (tk2dSpriteAnimationFrame[])(object)new tk2dSpriteAnimationFrame[0];
		val4.fps = fps;
		tk2dSpriteAnimationClip val5 = val4;
		List<tk2dSpriteAnimationFrame> list = new List<tk2dSpriteAnimationFrame>();
		for (int i = 0; i < spritePaths.Count; i++)
		{
			tk2dSpriteCollectionData val6 = val3;
			int num2 = SpriteBuilder.AddSpriteToCollection(spritePaths[i], val6, (Assembly)null);
			tk2dSpriteDefinition val7 = val6.spriteDefinitions[num2];
			GunTools.ConstructOffsetsFromAnchor(val7, anchor, (Vector2?)null, false, true);
			val7.colliderVertices = currentSpriteDef.colliderVertices;
			if (emissivePower > 0f)
			{
				val7.material.shader = ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive");
			}
			if (emissivePower > 0f)
			{
				val7.material.SetFloat("_EmissiveColorPower", emissivePower);
			}
			if (emissiveColour.HasValue)
			{
				val7.material.SetColor("_EmissiveColor", emissiveColour.Value);
			}
			if (emissivePower > 0f)
			{
				val7.materialInst.shader = ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive");
			}
			if (emissivePower > 0f)
			{
				val7.materialInst.SetFloat("_EmissiveColorPower", emissivePower);
			}
			if (emissiveColour.HasValue)
			{
				val7.materialInst.SetColor("_EmissiveColor", emissiveColour.Value);
			}
			list.Add(new tk2dSpriteAnimationFrame
			{
				spriteId = num2,
				spriteCollection = val6
			});
		}
		if (emissivePower > 0f)
		{
			((BraveBehaviour)orAddComponent).renderer.material.shader = ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive");
		}
		if (emissivePower > 0f)
		{
			((BraveBehaviour)orAddComponent).renderer.material.SetFloat("_EmissiveColorPower", emissivePower);
		}
		if (emissiveColour.HasValue)
		{
			((BraveBehaviour)orAddComponent).renderer.material.SetColor("_EmissiveColor", emissiveColour.Value);
		}
		val5.frames = list.ToArray();
		val5.wrapMode = wrap;
		orAddComponent3.clips = orAddComponent3.clips.Concat((IEnumerable<tk2dSpriteAnimationClip>)(object)new tk2dSpriteAnimationClip[1] { val5 }).ToArray();
		if (!persist)
		{
			SpriteAnimatorKiller val8 = ((Component)orAddComponent2).gameObject.AddComponent<SpriteAnimatorKiller>();
			val8.fadeTime = -1f;
			val8.animator = orAddComponent2;
			val8.delayDestructionTime = -1f;
		}
		orAddComponent2.playAutomatically = true;
		orAddComponent2.DefaultClipId = orAddComponent2.GetClipIdByName("start");
		val2.attached = true;
		val2.persistsOnDeath = false;
		val2.usesZHeight = usesZHeight;
		val2.zHeight = zHeightOffset;
		val2.alignment = (VFXAlignment)1;
		val2.destructible = false;
		val2.effect = val;
		return val;
	}

	public static VFXComplex CreateVFXComplex(string name, List<string> spritePaths, int fps, IntVector2 Dimensions, Anchor anchor, bool usesZHeight, float zHeightOffset, bool persist = false, float emissivePower = -1f, Color? emissiveColour = null)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Expected O, but got Unknown
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Expected O, but got Unknown
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0314: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_0255: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: Unknown result type (might be due to invalid IL or missing references)
		//IL_026a: Expected O, but got Unknown
		//IL_0243: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name);
		VFXPool val2 = new VFXPool
		{
			type = (VFXPoolType)1
		};
		VFXComplex val3 = new VFXComplex();
		VFXObject val4 = new VFXObject();
		val.SetActive(false);
		FakePrefab.MarkAsFakePrefab(val);
		Object.DontDestroyOnLoad((Object)(object)val);
		tk2dSpriteCollectionData val5 = SpriteBuilder.ConstructCollection(val, name + "_Collection", false);
		int num = SpriteBuilder.AddSpriteToCollection(spritePaths[0], val5, (Assembly)null);
		tk2dSprite orAddComponent = GameObjectExtensions.GetOrAddComponent<tk2dSprite>(val);
		((tk2dBaseSprite)orAddComponent).SetSprite(val5, num);
		tk2dSpriteDefinition currentSpriteDef = ((tk2dBaseSprite)orAddComponent).GetCurrentSpriteDef();
		currentSpriteDef.colliderVertices = (Vector3[])(object)new Vector3[2]
		{
			new Vector3(0f, 0f, 0f),
			new Vector3((float)(Dimensions.x / 16), (float)(Dimensions.y / 16), 0f)
		};
		tk2dSpriteAnimator orAddComponent2 = GameObjectExtensions.GetOrAddComponent<tk2dSpriteAnimator>(val);
		tk2dSpriteAnimation orAddComponent3 = GameObjectExtensions.GetOrAddComponent<tk2dSpriteAnimation>(val);
		orAddComponent3.clips = (tk2dSpriteAnimationClip[])(object)new tk2dSpriteAnimationClip[0];
		orAddComponent2.Library = orAddComponent3;
		tk2dSpriteAnimationClip val6 = new tk2dSpriteAnimationClip();
		val6.name = "start";
		val6.frames = (tk2dSpriteAnimationFrame[])(object)new tk2dSpriteAnimationFrame[0];
		val6.fps = fps;
		tk2dSpriteAnimationClip val7 = val6;
		List<tk2dSpriteAnimationFrame> list = new List<tk2dSpriteAnimationFrame>();
		for (int i = 0; i < spritePaths.Count; i++)
		{
			tk2dSpriteCollectionData val8 = val5;
			int num2 = SpriteBuilder.AddSpriteToCollection(spritePaths[i], val8, (Assembly)null);
			tk2dSpriteDefinition val9 = val8.spriteDefinitions[num2];
			GunTools.ConstructOffsetsFromAnchor(val9, anchor, (Vector2?)null, false, true);
			val9.colliderVertices = currentSpriteDef.colliderVertices;
			if (emissivePower > 0f)
			{
				val9.material.shader = ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive");
			}
			if (emissivePower > 0f)
			{
				val9.material.SetFloat("_EmissiveColorPower", emissivePower);
			}
			if (emissiveColour.HasValue)
			{
				val9.material.SetColor("_EmissiveColor", emissiveColour.Value);
			}
			if (emissivePower > 0f)
			{
				val9.materialInst.shader = ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive");
			}
			if (emissivePower > 0f)
			{
				val9.materialInst.SetFloat("_EmissiveColorPower", emissivePower);
			}
			if (emissiveColour.HasValue)
			{
				val9.materialInst.SetColor("_EmissiveColor", emissiveColour.Value);
			}
			list.Add(new tk2dSpriteAnimationFrame
			{
				spriteId = num2,
				spriteCollection = val8
			});
		}
		if (emissivePower > 0f)
		{
			((BraveBehaviour)orAddComponent).renderer.material.shader = ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive");
		}
		if (emissivePower > 0f)
		{
			((BraveBehaviour)orAddComponent).renderer.material.SetFloat("_EmissiveColorPower", emissivePower);
		}
		if (emissiveColour.HasValue)
		{
			((BraveBehaviour)orAddComponent).renderer.material.SetColor("_EmissiveColor", emissiveColour.Value);
		}
		val7.frames = list.ToArray();
		val7.wrapMode = (WrapMode)2;
		orAddComponent3.clips = orAddComponent3.clips.Concat((IEnumerable<tk2dSpriteAnimationClip>)(object)new tk2dSpriteAnimationClip[1] { val7 }).ToArray();
		SpriteAnimatorKiller val10 = ((Component)orAddComponent2).gameObject.AddComponent<SpriteAnimatorKiller>();
		val10.fadeTime = -1f;
		val10.animator = orAddComponent2;
		val10.delayDestructionTime = -1f;
		orAddComponent2.playAutomatically = true;
		orAddComponent2.DefaultClipId = orAddComponent2.GetClipIdByName("start");
		val4.attached = true;
		val4.persistsOnDeath = persist;
		val4.usesZHeight = usesZHeight;
		val4.zHeight = zHeightOffset;
		val4.alignment = (VFXAlignment)1;
		val4.destructible = false;
		val4.effect = val;
		val3.effects = (VFXObject[])(object)new VFXObject[1] { val4 };
		val2.effects = (VFXComplex[])(object)new VFXComplex[1] { val3 };
		return val3;
	}

	public static VFXPool CreateVFXPool(string name, List<string> spritePaths, int fps, IntVector2 Dimensions, Anchor anchor, bool usesZHeight, float zHeightOffset, bool persist = false, VFXAlignment alignment = 1, float emissivePower = -1f, Color? emissiveColour = null)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Expected O, but got Unknown
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Expected O, but got Unknown
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0314: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_0255: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: Unknown result type (might be due to invalid IL or missing references)
		//IL_026a: Expected O, but got Unknown
		//IL_0243: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name);
		VFXPool val2 = new VFXPool
		{
			type = (VFXPoolType)1
		};
		VFXComplex val3 = new VFXComplex();
		VFXObject val4 = new VFXObject();
		val.SetActive(false);
		FakePrefab.MarkAsFakePrefab(val);
		Object.DontDestroyOnLoad((Object)(object)val);
		tk2dSpriteCollectionData val5 = SpriteBuilder.ConstructCollection(val, name + "_Collection", false);
		int num = SpriteBuilder.AddSpriteToCollection(spritePaths[0], val5, (Assembly)null);
		tk2dSprite orAddComponent = GameObjectExtensions.GetOrAddComponent<tk2dSprite>(val);
		((tk2dBaseSprite)orAddComponent).SetSprite(val5, num);
		tk2dSpriteDefinition currentSpriteDef = ((tk2dBaseSprite)orAddComponent).GetCurrentSpriteDef();
		currentSpriteDef.colliderVertices = (Vector3[])(object)new Vector3[2]
		{
			new Vector3(0f, 0f, 0f),
			new Vector3((float)(Dimensions.x / 16), (float)(Dimensions.y / 16), 0f)
		};
		tk2dSpriteAnimator orAddComponent2 = GameObjectExtensions.GetOrAddComponent<tk2dSpriteAnimator>(val);
		tk2dSpriteAnimation orAddComponent3 = GameObjectExtensions.GetOrAddComponent<tk2dSpriteAnimation>(val);
		orAddComponent3.clips = (tk2dSpriteAnimationClip[])(object)new tk2dSpriteAnimationClip[0];
		orAddComponent2.Library = orAddComponent3;
		tk2dSpriteAnimationClip val6 = new tk2dSpriteAnimationClip();
		val6.name = "start";
		val6.frames = (tk2dSpriteAnimationFrame[])(object)new tk2dSpriteAnimationFrame[0];
		val6.fps = fps;
		tk2dSpriteAnimationClip val7 = val6;
		List<tk2dSpriteAnimationFrame> list = new List<tk2dSpriteAnimationFrame>();
		for (int i = 0; i < spritePaths.Count; i++)
		{
			tk2dSpriteCollectionData val8 = val5;
			int num2 = SpriteBuilder.AddSpriteToCollection(spritePaths[i], val8, (Assembly)null);
			tk2dSpriteDefinition val9 = val8.spriteDefinitions[num2];
			GunTools.ConstructOffsetsFromAnchor(val9, anchor, (Vector2?)null, false, true);
			val9.colliderVertices = currentSpriteDef.colliderVertices;
			if (emissivePower > 0f)
			{
				val9.material.shader = ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive");
			}
			if (emissivePower > 0f)
			{
				val9.material.SetFloat("_EmissiveColorPower", emissivePower);
			}
			if (emissiveColour.HasValue)
			{
				val9.material.SetColor("_EmissiveColor", emissiveColour.Value);
			}
			if (emissivePower > 0f)
			{
				val9.materialInst.shader = ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive");
			}
			if (emissivePower > 0f)
			{
				val9.materialInst.SetFloat("_EmissiveColorPower", emissivePower);
			}
			if (emissiveColour.HasValue)
			{
				val9.materialInst.SetColor("_EmissiveColor", emissiveColour.Value);
			}
			list.Add(new tk2dSpriteAnimationFrame
			{
				spriteId = num2,
				spriteCollection = val8
			});
		}
		if (emissivePower > 0f)
		{
			((BraveBehaviour)orAddComponent).renderer.material.shader = ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive");
		}
		if (emissivePower > 0f)
		{
			((BraveBehaviour)orAddComponent).renderer.material.SetFloat("_EmissiveColorPower", emissivePower);
		}
		if (emissiveColour.HasValue)
		{
			((BraveBehaviour)orAddComponent).renderer.material.SetColor("_EmissiveColor", emissiveColour.Value);
		}
		val7.frames = list.ToArray();
		val7.wrapMode = (WrapMode)2;
		orAddComponent3.clips = orAddComponent3.clips.Concat((IEnumerable<tk2dSpriteAnimationClip>)(object)new tk2dSpriteAnimationClip[1] { val7 }).ToArray();
		if (!persist)
		{
			SpriteAnimatorKiller val10 = ((Component)orAddComponent2).gameObject.AddComponent<SpriteAnimatorKiller>();
			val10.fadeTime = -1f;
			val10.animator = orAddComponent2;
			val10.delayDestructionTime = -1f;
		}
		orAddComponent2.playAutomatically = true;
		orAddComponent2.DefaultClipId = orAddComponent2.GetClipIdByName("start");
		val4.attached = true;
		val4.persistsOnDeath = persist;
		val4.usesZHeight = usesZHeight;
		val4.zHeight = zHeightOffset;
		val4.alignment = alignment;
		val4.destructible = false;
		val4.effect = val;
		val3.effects = (VFXObject[])(object)new VFXObject[1] { val4 };
		val2.effects = (VFXComplex[])(object)new VFXComplex[1] { val3 };
		return val2;
	}

	public static VFXPool CreateMuzzleflash(string name, List<string> spriteNames, int fps, List<IntVector2> spriteSizes, List<Anchor> anchors, List<Vector2> manualOffsets, bool orphaned, bool attached, bool persistsOnDeath, bool usesZHeight, float zHeight, VFXAlignment alignment, bool destructible, List<float> emissivePowers, List<Color> emissiveColors)
	{
		//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_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Expected O, but got Unknown
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Expected O, but got Unknown
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Expected O, but got Unknown
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Expected O, but got Unknown
		//IL_007e: 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_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: 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_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Expected O, but got Unknown
		//IL_00d3: 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_00eb: 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_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: 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)
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		//IL_0235: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
		VFXPool val = new VFXPool
		{
			type = (VFXPoolType)1
		};
		VFXComplex val2 = new VFXComplex();
		VFXObject val3 = new VFXObject();
		GameObject val4 = new GameObject(name);
		val4.SetActive(false);
		FakePrefab.MarkAsFakePrefab(val4);
		Object.DontDestroyOnLoad((Object)(object)val4);
		tk2dSprite val5 = val4.AddComponent<tk2dSprite>();
		tk2dSpriteAnimator val6 = val4.AddComponent<tk2dSpriteAnimator>();
		tk2dSpriteAnimationClip val7 = new tk2dSpriteAnimationClip();
		val7.fps = fps;
		val7.frames = (tk2dSpriteAnimationFrame[])(object)new tk2dSpriteAnimationFrame[0];
		tk2dSpriteAnimationClip val8 = val7;
		for (int i = 0; i < spriteNames.Count; i++)
		{
			string text = spriteNames[i];
			IntVector2 val9 = spriteSizes[i];
			Anchor val10 = anchors[i];
			Vector2 val11 = manualOffsets[i];
			float num = emissivePowers[i];
			Color val12 = emissiveColors[i];
			tk2dSpriteAnimationFrame val13 = new tk2dSpriteAnimationFrame
			{
				spriteId = VFXCollection.GetSpriteIdByName(text)
			};
			tk2dSpriteDefinition val14 = SetupDefinitionForShellSprite(text, val13.spriteId, val9.x, val9.y);
			GunTools.ConstructOffsetsFromAnchor(val14, val10, (Vector2?)Vector2.op_Implicit(val14.position3), false, true);
			GunTools.MakeOffset(val14, val11, false);
			val14.material.shader = ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive");
			val14.material.SetFloat("_EmissiveColorPower", num);
			val14.material.SetColor("_EmissiveColor", val12);
			val14.materialInst.shader = ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive");
			val14.materialInst.SetFloat("_EmissiveColorPower", num);
			val14.materialInst.SetColor("_EmissiveColor", val12);
			val13.spriteCollection = VFXCollection;
			val8.frames = val8.frames.Concat((IEnumerable<tk2dSpriteAnimationFrame>)(object)new tk2dSpriteAnimationFrame[1] { val13 }).ToArray();
		}
		((BraveBehaviour)val5).renderer.material.shader = ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive");
		((BraveBehaviour)val5).renderer.material.SetFloat("_EmissiveColorPower", emissivePowers[0]);
		((BraveBehaviour)val5).renderer.material.SetColor("_EmissiveColor", emissiveColors[0]);
		val8.wrapMode = (WrapMode)2;
		val8.name = "start";
		((BraveBehaviour)val6).spriteAnimator.Library = ((Component)val6).gameObject.AddComponent<tk2dSpriteAnimation>();
		((BraveBehaviour)val6).spriteAnimator.Library.clips = (tk2dSpriteAnimationClip[])(object)new tk2dSpriteAnimationClip[1] { val8 };
		((Behaviour)((BraveBehaviour)val6).spriteAnimator.Library).enabled = true;
		SpriteAnimatorKiller val15 = ((Component)val6).gameObject.AddComponent<SpriteAnimatorKiller>();
		val15.fadeTime = -1f;
		val15.animator = val6;
		val15.delayDestructionTime = -1f;
		val3.orphaned = orphaned;
		val3.attached = attached;
		val3.persistsOnDeath = persistsOnDeath;
		val3.usesZHeight = usesZHeight;
		val3.zHeight = zHeight;
		val3.alignment = alignment;
		val3.destructible = destructible;
		val3.effect = val4;
		val2.effects = (VFXObject[])(object)new VFXObject[1] { val3 };
		val.effects = (VFXComplex[])(object)new VFXComplex[1] { val2 };
		val6.playAutomatically = true;
		val6.DefaultClipId = val6.GetClipIdByName("start");
		return val;
	}

	public static GameObject CreateCustomClip(string spriteName, int pixelWidth, int pixelHeight)
	{
		PickupObject byId = PickupObjectDatabase.GetById(95);
		GameObject val = Object.Instantiate<GameObject>(((Gun)((byId is Gun) ? byId : null)).clipObject);
		val.gameObject.SetActive(false);
		FakePrefab.MarkAsFakePrefab(val.gameObject);
		Object.DontDestroyOnLoad((Object)(object)val);
		val.GetComponent<tk2dBaseSprite>().spriteId = VFXCollection.inst.GetSpriteIdByName(spriteName);
		SetupDefinitionForClipSprite(spriteName, val.GetComponent<tk2dBaseSprite>().spriteId, pixelWidth, pixelHeight);
		return val;
	}

	public static void SetupDefinitionForClipSprite(string name, int id, int pixelWidth, int pixelHeight)
	{
		//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_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: 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_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_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_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		float num = 14f;
		float num2 = (float)pixelWidth / num;
		float num3 = (float)pixelHeight / num;
		tk2dSpriteDefinition[] spriteDefinitions = VFXCollection.inst.spriteDefinitions;
		PickupObject byId = PickupObjectDatabase.GetById(47);
		tk2dSpriteDefinition val = GunTools.CopyDefinitionFrom(spriteDefinitions[((Gun)((byId is Gun) ? byId : null)).clipObject.GetComponent<tk2dBaseSprite>().spriteId]);
		val.boundsDataCenter = new Vector3(num2 / 2f, num3 / 2f, 0f);
		val.boundsDataExtents = new Vector3(num2, num3, 0f);
		val.untrimmedBoundsDataCenter = new Vector3(num2 / 2f, num3 / 2f, 0f);
		val.untrimmedBoundsDataExtents = new Vector3(num2, num3, 0f);
		val.position0 = new Vector3(0f, 0f, 0f);
		val.position1 = new Vector3(0f + num2, 0f, 0f);
		val.position2 = new Vector3(0f, 0f + num3, 0f);
		val.position3 = new Vector3(0f + num2, 0f + num3, 0f);
		val.colliderVertices[1].x = num2;
		val.colliderVertices[1].y = num3;
		val.name = name;
		VFXCollection.spriteDefinitions[id] = val;
	}

	public static GameObject CreateCustomShellCasing(string spriteName, int pixelWidth, int pixelHeight)
	{
		PickupObject byId = PickupObjectDatabase.GetById(202);
		GameObject val = Object.Instantiate<GameObject>(((Gun)((byId is Gun) ? byId : null)).shellCasing);
		val.gameObject.SetActive(false);
		FakePrefab.MarkAsFakePrefab(val.gameObject);
		Object.DontDestroyOnLoad((Object)(object)val);
		val.GetComponent<tk2dBaseSprite>().spriteId = VFXCollection.inst.GetSpriteIdByName(spriteName);
		SetupDefinitionForShellSprite(spriteName, val.GetComponent<tk2dBaseSprite>().spriteId, pixelWidth, pixelHeight);
		return val;
	}

	public static tk2dSpriteDefinition SetupDefinitionForShellSprite(string name, int id, int pixelWidth, int pixelHeight, tk2dSpriteDefinition overrideToCopyFrom = null)
	{
		//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_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: 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_00dc: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		float num = 14f;
		float num2 = (float)pixelWidth / num;
		float num3 = (float)pixelHeight / num;
		tk2dSpriteDefinition val = overrideToCopyFrom ?? GunTools.CopyDefinitionFrom(VFXCollection.inst.spriteDefinitions[((Gun)/*isinst with value type is only supported in some contexts*/).shellCasing.GetComponent<tk2dBaseSprite>().spriteId]);
		val.boundsDataCenter = new Vector3(num2 / 2f, num3 / 2f, 0f);
		val.boundsDataExtents = new Vector3(num2, num3, 0f);
		val.untrimmedBoundsDataCenter = new Vector3(num2 / 2f, num3 / 2f, 0f);
		val.untrimmedBoundsDataExtents = new Vector3(num2, num3, 0f);
		val.position0 = new Vector3(0f, 0f, 0f);
		val.position1 = new Vector3(0f + num2, 0f, 0f);
		val.position2 = new Vector3(0f, 0f + num3, 0f);
		val.position3 = new Vector3(0f + num2, 0f + num3, 0f);
		val.name = name;
		VFXCollection.spriteDefinitions[id] = val;
		return val;
	}
}
public class StaticCoroutine : MonoBehaviour
{
	private static StaticCoroutine m_instance;

	private void OnDestroy()
	{
		((MonoBehaviour)m_instance).StopAllCoroutines();
	}

	private void OnApplicationQuit()
	{
		((MonoBehaviour)m_instance).StopAllCoroutines();
	}

	private static StaticCoroutine Build()
	{
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Expected O, but got Unknown
		if ((Object)(object)m_instance != (Object)null)
		{
			return m_instance;
		}
		m_instance = (StaticCoroutine)(object)Object.FindObjectOfType(typeof(StaticCoroutine));
		if ((Object)(object)m_instance != (Object)null)
		{
			return m_instance;
		}
		GameObject val = new GameObject("StaticCoroutine");
		val.AddComponent<StaticCoroutine>();
		m_instance = val.GetComponent<StaticCoroutine>();
		if ((Object)(object)m_instance != (Object)null)
		{
			return m_instance;
		}
		ETGModConsole.Log((object)"STATIC COROUTINE: Build did not generate a replacement instance. Method Failed!", false);
		return null;
	}

	public static void Start(string methodName)
	{
		((MonoBehaviour)Build()).StartCoroutine(methodName);
	}

	public static void Start(string methodName, object value)
	{
		((MonoBehaviour)Build()).StartCoroutine(methodName, value);
	}

	public static Coroutine Start(IEnumerator routine)
	{
		return ((MonoBehaviour)Build()).StartCoroutine(routine);
	}
}
public class TeleportPlayerToCursorPosition : MonoBehaviour
{
	private static Vector2 lockedDodgeRollDirection;

	public static BlinkPassiveItem m_BlinkPassive = ((Component)PickupObjectDatabase.GetById(436)).GetComponent<BlinkPassiveItem>();

	public GameObject BlinkpoofVfx = m_BlinkPassive.BlinkpoofVfx;

	public static void StartTeleport(PlayerController user, Vector2 newPosition)
	{
		//IL_0019: 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_0033: 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_003d: 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)
		((BraveBehaviour)user).healthHaver.TriggerInvulnerabilityPeriod(0.001f);
		user.DidUnstealthyAction();
		Vector2 targetPoint = BraveMathCollege.ClampToBounds(newPosition, GameManager.Instance.MainCameraController.MinVisiblePoint, GameManager.Instance.MainCameraController.MaxVisiblePoint);
		BlinkToPoint(user, targetPoint);
	}

	private static void BlinkToPoint(PlayerController Owner, Vector2 targetPoint)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		//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_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: 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_0041: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		Vector2 val = targetPoint - ((BraveBehaviour)Owner).specRigidbody.UnitCenter;
		lockedDodgeRollDirection = ((Vector2)(ref val)).normalized;
		Vector2 val2 = Vector2.op_Implicit(((BraveBehaviour)Owner).transform.position);
		int num = (int)targetPoint.x;
		int num2 = (int)targetPoint.y;
		int num3 = (int)val2.x;
		int num4 = (int)val2.y;
		int num5 = Math.Abs(num3 - num);
		int num6 = ((num < num3) ? 1 : (-1));
		int num7 = -Math.Abs(num4 - num2);
		int num8 = ((num2 < num4) ? 1 : (-1));
		int num9 = num5 + num7;
		int num10 = 600;
		while (num10 > 0 && (num != num3 || num2 != num4))
		{
			if (CanBlinkToPoint(new Vector2((float)num, (float)num2), Owner))
			{
				StaticCoroutine.Start(HandleBlinkTeleport(Owner, new Vector2((float)num, (float)num2), lockedDodgeRollDirection));
				break;
			}
			int num11 = 2 * num9;
			if (num11 >= num7)
			{
				num9 += num7;
				num += num6;
			}
			if (num11 <= num5)
			{
				num9 += num5;
				num2 += num8;
			}
			num10--;
		}
	}

	private static bool CanBlinkToPoint(Vector2 point, PlayerController owner)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Invalid comparison between Unknown and I4
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Invalid comparison between Unknown and I4
		RoomHandler currentRoom = owner.CurrentRoom;
		bool flag = owner.IsValidPlayerPosition(point);
		if (flag && currentRoom != null)
		{
			CellData val = GameManager.Instance.Dungeon.data[Vector2Extensions.ToIntVector2(point, (VectorConversions)0)];
			if (val == null)
			{
				return false;
			}
			RoomHandler nearestRoom = val.nearestRoom;
			if ((int)val.type != 2)
			{
				flag = false;
			}
			if (currentRoom.IsSealed && nearestRoom != currentRoom)
			{
				flag = false;
			}
			if (currentRoom.IsSealed && val.isExitCell)
			{
				flag = false;
			}
			if ((int)nearestRoom.visibility == 0 || (int)nearestRoom.visibility == 3)
			{
				flag = false;
			}
		}
		if (currentRoom == null)
		{
			flag = false;
		}
		return flag;
	}

	private static IEnumerator HandleBlinkTeleport(PlayerController Owner, Vector2 targetPoint, Vector2 targetDirection)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		((GameActor)Owner).PlayEffectOnActor(DiffusionSmoke.SmokeVFX, new Vector3(0.8125f, 0f), false, true, false);
		AkSoundEngine.PostEvent("Play_ENM_wizardred_vanish_01", ((Component)Owner).gameObject);
		List<AIActor> m_rollDamagedEnemies = ReflectionHelpers.ReflectGetField<List<AIActor>>(typeof(PlayerController), "m_rollDamagedEnemies", Owner);
		if (m_rollDamagedEnemies != null)
		{
			m_rollDamagedEnemies.Clear();
			FieldInfo m_rollDamagedEnemiesClear = typeof(PlayerController).GetField("m_rollDamagedEnemies", BindingFlags.Instance | BindingFlags.NonPublic);
			m_rollDamagedEnemiesClear.SetValue(Owner, m_rollDamagedEnemies);
		}
		if (Object.op_Implicit((Object)(object)((BraveBehaviour)Owner).knockbackDoer))
		{
			((BraveBehaviour)Owner).knockbackDoer.ClearContinuousKnockbacks();
		}
		Owner.IsEthereal = true;
		Owner.IsVisible = false;
		float RecoverySpeed = GameManager.Instance.MainCameraController.OverrideRecoverySpeed;
		bool IsLerping = GameManager.Instance.MainCameraController.IsLerping;
		DoAOEEffect(((BraveBehaviour)Owner).sprite.WorldCenter);
		yield return (object)new WaitForSeconds(0.05f);
		GameManager.Instance.MainCameraController.OverrideRecoverySpeed = 80f;
		GameManager.Instance.MainCameraController.IsLerping = true;
		if (Owner.IsPrimaryPlayer)
		{
			GameManager.Instance.MainCameraController.UseOverridePlayerOnePosition = true;
			GameManager.Instance.MainCameraController.OverridePlayerOnePosition = targetPoint;
			yield return (object)new WaitForSeconds(0.12f);
			((BraveBehaviour)Owner).specRigidbody.Velocity = Vector2.zero;
			((BraveBehaviour)Owner).specRigidbody.Position = new Position(targetPoint);
			GameManager.Instance.MainCameraController.UseOverridePlayerOnePosition = false;
		}
		else
		{
			GameManager.Instance.MainCameraController.UseOverridePlayerTwoPosition = true;
			GameManager.Instance.MainCameraController.OverridePlayerTwoPosition = targetPoint;
			yield return (object)new WaitForSeconds(0.12f);
			((BraveBehaviour)Owner).specRigidbody.Velocity = Vector2.zero;
			((BraveBehaviour)Owner).specRigidbody.Position = new Position(targetPoint);
			GameManager.Instance.MainCameraController.UseOverridePlayerTwoPosition = false;
		}
		((BraveBehaviour)Owner).healthHaver.TriggerInvulnerabilityPeriod(0.5f);
		GameManager.Instance.MainCameraController.OverrideRecoverySpeed = RecoverySpeed;
		GameManager.Instance.MainCameraController.IsLerping = IsLerping;
		Owner.IsEthereal = false;
		Owner.IsVisible = true;
		DoAOEEffect(targetPoint);
		SpawnManager.SpawnVFX(DiffusionSmoke.SmokeVFX, Vector2.op_Implicit(targetPoint + new Vector2(0.8125f, 0f)), Quaternion.identity);
		if (!(Owner.CurrentFireMeterValue <= 0f))
		{
			Owner.CurrentFireMeterValue = Mathf.Max(0f, Owner.CurrentFireMeterValue -= 0.5f);
			if (Owner.CurrentFireMeterValue == 0f)
			{
				Owner.IsOnFire = false;
			}
		}
	}

	public static void DoAOEEffect(Vector2 position)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: 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_00a5: 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_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		RoomHandler absoluteRoomFromPosition = GameManager.Instance.Dungeon.data.GetAbsoluteRoomFromPosition(Vector2Extensions.ToIntVector2(position, (VectorConversions)2));
		List<AIActor> list = new List<AIActor>();
		if (absoluteRoomFromPosition.GetActiveEnemies((ActiveEnemyType)1) != null)
		{
			foreach (AIActor activeEnemy in absoluteRoomFromPosition.GetActiveEnemies((ActiveEnemyType)1))
			{
				list.Add(activeEnemy);
			}
		}
		Exploder.DoRadialKnockback(Vector2.op_Implicit(position), 100f, 2.5f);
		if (list != null)
		{
			for (int i = 0; i < list.Count; i++)
			{
				AIActor val = list[i];
				if (Vector2.Distance(val.m_lastPosition, position) <= 1.5f)
				{
					((BraveBehaviour)val).behaviorSpeculator.Stun(4f, true);
				}
			}
		}
		ReadOnlyCollection<Projectile> allProjectiles = StaticReferenceManager.AllProjectiles;
		if (allProjectiles == null)
		{
			return;
		}
		for (int num = allProjectiles.Count - 1; num >= 0; num--)
		{
			Projectile val2 = allProjectiles[num];
			if (Vector2.Distance(((BraveBehaviour)val2).specRigidbody.UnitCenter, position) <= 2f)
			{
				val2.DieInAir(false, true, true, false);
			}
		}
	}

	public static void CorrectForWalls(PlayerController portal)
	{
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		if (!PhysicsEngine.Instance.OverlapCast(((BraveBehaviour)portal).specRigidbody, (List<CollisionData>)null, true, false, (int?)null, (int?)null, false, (Vector2?)null, (Func<SpeculativeRigidbody, bool>)null, (SpeculativeRigidbody[])(object)new SpeculativeRigidbody[0]))
		{
			return;
		}
		Vector2 val = Vector3Extensions.XY(((BraveBehaviour)portal).transform.position);
		IntVector2[] cardinalsAndOrdinals = IntVector2.CardinalsAndOrdinals;
		int num = 0;
		int num2 = 1;
		do
		{
			for (int i = 0; i < cardinalsAndOrdinals.Length; i++)
			{
				((BraveBehaviour)portal).specRigidbody.Position = new Position(val + PhysicsEngine.PixelToUnit(cardinalsAndOrdinals[i] * num2));
				((BraveBehaviour)portal).specRigidbody.Reinitialize();
				if (!PhysicsEngine.Instance.OverlapCast(((BraveBehaviour)portal).specRigidbody, (List<CollisionData>)null, true, false, (int?)null, (int?)null, false, (Vector2?)null, (Func<SpeculativeRigidbody, bool>)null, (SpeculativeRigidbody[])(object)new SpeculativeRigidbody[0]))
				{
					return;
				}
			}
			num2++;
			num++;
		}
		while (num <= 200);
		Debug.LogError((object)"FREEZE AVERTED!  TELL RUBEL!  (you're welcome) 147");
	}
}
public static class ReflectionHelpers
{
	public delegate void ActionEX<T1, T2, T3, T4>(T1 arg1, T2 arg2, T3 arg3, T4 arg4);

	public delegate void ActionEX<T1, T2, T3, T4, T5>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5);

	public delegate void ActionEX<T1, T2, T3, T4, T5, T6>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6);

	public delegate void ActionEX<T1, T2, T3, T4, T5, T6, T7>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7);

	public delegate void ActionEX<T1, T2, T3, T4, T5, T6, T7, T8>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8);

	public delegate void ActionEX<T1, T2, T3, T4, T5, T6, T7, T8, T9>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9);

	public delegate void ActionEX<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10);

	public delegate void ActionEX<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11);

	public delegate TResult FuncEX<T1, T2, T3, T4, T5, TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5);

	public delegate TResult FuncEX<T1, T2, T3, T4, T5, T6, TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6);

	public delegate TResult FuncEX<T1, T2, T3, T4, T5, T6, T7, TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7);

	public delegate TResult FuncEX<T1, T2, T3, T4, T5, T6, T7, T8, TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8);

	public static IList CreateDynamicList(Type type)
	{
		if ((object)type == null)
		{
			throw new ArgumentNullException("type", "Argument cannot be null.");
		}
		ConstructorInfo[] constructors = typeof(List<>).MakeGenericType(type).GetConstructors();
		ConstructorInfo[] array = constructors;
		foreach (ConstructorInfo constructorInfo in array)
		{
			ParameterInfo[] parameters = constructorInfo.GetParameters();
			if (parameters.Length == 0)
			{
				return (IList)constructorInfo.Invoke(null, null);
			}
		}
		throw new ApplicationException("Could not create a new list with type <" + type.ToString() + ">.");
	}

	public static IDictionary CreateDynamicDictionary(Type typeKey, Type typeValue)
	{
		if ((object)typeKey == null)
		{
			throw new ArgumentNullException("type_key", "Argument cannot be null.");
		}
		if ((object)typeValue == null)
		{
			throw new ArgumentNullException("type_value", "Argument cannot be null.");
		}
		ConstructorInfo[] constructors = typeof(Dictionary<, >).MakeGenericType(typeKey, typeValue).GetConstructors();
		ConstructorInfo[] array = constructors;
		foreach (ConstructorInfo constructorInfo in array)
		{
			ParameterInfo[] parameters = constructorInfo.GetParameters();
			if (parameters.Length == 0)
			{
				return (IDictionary)constructorInfo.Invoke(null, null);
			}
		}
		throw new ApplicationException("Could not create a new dictionary with types <" + typeKey.ToString() + "," + typeValue.ToString() + ">.");
	}

	public static T ReflectGetField<T>(Type classType, string fieldName, object o = null)
	{
		FieldInfo field = classType.GetField(fieldName, BindingFlags.Public | BindingFlags.NonPublic | ((o != null) ? BindingFlags.Instance : BindingFlags.Static));
		return (T)field.GetValue(o);
	}

	public static void ReflectSetField<T>(Type classType, string fieldName, T value, object o = null)
	{
		FieldInfo field = classType.GetField(fieldName, BindingFlags.Public | BindingFlags.NonPublic | ((o != null) ? BindingFlags.Instance : BindingFlags.Static));
		field.SetValue(o, value);
	}

	public static T ReflectGetProperty<T>(Type classType, string propName, object o = null, object[] indexes = null)
	{
		PropertyInfo property = classType.GetProperty(propName, BindingFlags.Public | BindingFlags.NonPublic | ((o != null) ? BindingFlags.Instance : BindingFlags.Static));
		return (T)property.GetValue(o, indexes);
	}

	public static void ReflectSetProperty<T>(Type classType, string propName, T value, object o = null, object[] indexes = null)
	{
		PropertyInfo property = classType.GetProperty(propName, BindingFlags.Public | BindingFlags.NonPublic | ((o != null) ? BindingFlags.Instance : BindingFlags.Static));
		property.SetValue(o, value, indexes);
	}

	public static MethodInfo ReflectGetMethod(Type classType, string methodName, Type[] methodArgumentTypes = null, Type[] genericMethodTypes = null, bool? isStatic = null)
	{
		MethodInfo[] array = ReflectTryGetMethods(classType, methodName, methodArgumentTypes, genericMethodTypes, isStatic);
		if (array.Count() == 0)
		{
			throw new MissingMethodException("Cannot reflect method, not found based on input parameters.");
		}
		if (array.Count() > 1)
		{
			throw new InvalidOperationException("Cannot reflect method, more than one method matched based on input parameters.");
		}
		return array[0];
	}

	public static MethodInfo ReflectTryGetMethod(Type classType, string methodName, Type[] methodArgumentTypes = null, Type[] genericMethodTypes = null, bool? isStatic = null)
	{
		MethodInfo[] array = ReflectTryGetMethods(classType, methodName, methodArgumentTypes, genericMethodTypes, isStatic);
		if (array.Count() == 0)
		{
			return null;
		}
		if (array.Count() > 1)
		{
			return null;
		}
		return array[0];
	}

	public static MethodInfo[] ReflectTryGetMethods(Type classType, string methodName, Type[] methodArgumentTypes = null, Type[] genericMethodTypes = null, bool? isStatic = null)
	{
		BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.NonPublic;
		if (!isStatic.HasValue || isStatic.Value)
		{
			bindingFlags |= BindingFlags.Static;
		}
		if (!isStatic.HasValue || !isStatic.Value)
		{
			bindingFlags |= BindingFlags.Instance;
		}
		MethodInfo[] methods = classType.GetMethods(bindingFlags);
		List<MethodInfo> list = new List<MethodInfo>();
		for (int i = 0; i < methods.Length; i++)
		{
			if (methods[i].Name != methodName)
			{
				continue;
			}
			if (methods[i].IsGenericMethodDefinition)
			{
				if (genericMethodTypes == null || genericMethodTypes.Length == 0)
				{
					continue;
				}
				Type[] genericArguments = methods[i].GetGenericArguments();
				if (genericArguments.Length != genericMethodTypes.Length)
				{
					continue;
				}
				methods[i] = methods[i].MakeGenericMethod(genericMethodTypes);
			}
			else if (genericMethodTypes != null && genericMethodTypes.Length != 0)
			{
				continue;
			}
			ParameterInfo[] parameters = methods[i].GetParameters();
			if (methodArgumentTypes != null)
			{
				if (parameters.Length != methodArgumentTypes.Length)
				{
					continue;
				}
				for (int num = 0; num < parameters.Length; num++)
				{
					ParameterInfo parameterInfo = parameters[num];
					if ((object)parameterInfo.ParameterType != methodArgumentTypes[num])
					{
						goto IL_0190;
					}
				}
			}
			list.Add(methods[i]);
			IL_0190:;
		}
		return list.ToArray();
	}

	public static T InvokeMethod<T>(Type type, string methodName, object typeInstance = null, object[] methodParams = null)
	{
		BindingFlags bindingAttr = BindingFlags.Public | BindingFlags.NonPublic | ((typeInstance == null) ? BindingFlags.Static : BindingFlags.Instance);
		return (T)type.GetMethod(methodName, bindingAttr).Invoke(typeInstance, methodParams);
	}

	public static void InvokeMethod(Type type, string methodName, object typeInstance = null, object[] methodParams = null)
	{
		BindingFlags bindingAttr = BindingFlags.Public | BindingFlags.NonPublic | ((typeInstance == null) ? BindingFlags.Static : BindingFlags.Instance);
		type.GetMethod(methodName, bindingAttr).Invoke(typeInstance, methodParams);
	}

	public static object InvokeRefs<T0>(MethodInfo methodInfo, object o, T0 p0)
	{
		object[] parameters = new object[1] { p0 };
		return methodInfo.Invoke(o, parameters);
	}

	public static object InvokeRefs<T0>(MethodInfo methodInfo, object o, ref T0 p0)
	{
		object[] array = new object[1] { p0 };
		object result = methodInfo.Invoke(o, array);
		p0 = (T0)array[0];
		return result;
	}

	public static object InvokeRefs<T0, T1>(MethodInfo methodInfo, object o, T0 p0, T1 p1)
	{
		object[] parameters = new object[2] { p0, p1 };
		return methodInfo.Invoke(o, parameters);
	}

	public static object InvokeRefs<T0, T1>(MethodInfo methodInfo, object o, ref T0 p0, T1 p1)
	{
		object[] array = new object[2] { p0, p1 };
		object result = methodInfo.Invoke(o, array);
		p0 = (T0)array[0];
		return result;
	}

	public static object InvokeRefs<T0, T1>(MethodInfo methodInfo, object o, T0 p0, ref T1 p1)
	{
		object[] array = new object[2] { p0, p1 };
		object result = methodInfo.Invoke(o, array);
		p1 = (T1)array[1];
		return result;
	}

	public static object InvokeRefs<T0, T1>(MethodInfo methodInfo, object o, ref T0 p0, ref T1 p1)
	{
		object[] array = new object[2] { p0, p1 };
		object result = methodInfo.Invoke(o, array);
		p0 = (T0)array[0];
		p1 = (T1)array[1];
		return result;
	}

	public static object InvokeRefs<T0, T1, T2>(MethodInfo methodInfo, object o, T0 p0, T1 p1, T2 p2)
	{
		object[] parameters = new object[3] { p0, p1, p2 };
		return methodInfo.Invoke(o, parameters);
	}

	public static object InvokeRefs<T0, T1, T2>(MethodInfo methodInfo, object o, ref T0 p0, T1 p1, T2 p2)
	{
		object[] array = new object[3] { p0, p1, p2 };
		object result = methodInfo.Invoke(o, array);
		p0 = (T0)array[0];
		return result;
	}

	public static object InvokeRefs<T0, T1, T2>(MethodInfo methodInfo, object o, T0 p0, ref T1 p1, T2 p2)
	{
		object[] array = new object[3] { p0, p1, p2 };
		object result = methodInfo.Invoke(o, array);
		p1 = (T1)array[1];
		return result;
	}

	public static object InvokeRefs<T0, T1, T2>(MethodInfo methodInfo, object o, T0 p0, T1 p1, ref T2 p2)
	{
		object[] array = new object[3] { p0, p1, p2 };
		object result = methodInfo.Invoke(o, array);
		p2 = (T2)array[2];
		return result;
	}

	public static object InvokeRefs<T0, T1, T2>(MethodInfo methodInfo, object o, ref T0 p0, ref T1 p1, T2 p2)
	{
		object[] array = new object[3] { p0, p1, p2 };
		object result = methodInfo.Invoke(o, array);
		p0 = (T0)array[0];
		p1 = (T1)array[1];
		return result;
	}

	public static object InvokeRefs<T0, T1, T2>(MethodInfo methodInfo, object o, ref T0 p0, T1 p1, ref T2 p2)
	{
		object[] array = new object[3] { p0, p1, p2 };
		object result = methodInfo.Invoke(o, array);
		p0 = (T0)array[0];
		p2 = (T2)array[2];
		return result;
	}

	public static object InvokeRefs<T0, T1, T2>(MethodInfo methodInfo, object o, T0 p0, ref T1 p1, ref T2 p2)
	{
		object[] array = new object[3] { p0, p1, p2 };
		object result = methodInfo.Invoke(o, array);
		p1 = (T1)array[1];
		p2 = (T2)array[2];
		return result;
	}

	public static object InvokeRefs<T0, T1, T2>(MethodInfo methodInfo, object o, ref T0 p0, ref T1 p1, ref T2 p2)
	{
		object[] array = new object[3] { p0, p1, p2 };
		object result = methodInfo.Invoke(o, array);
		p0 = (T0)array[0];
		p1 = (T1)array[1];
		p2 = (T2)array[2];
		return result;
	}
}
public class ExamplePassive : PassiveItem
{
	public static void Register()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Expected O, but got Unknown
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		string text = "Example Item Name";
		string text2 = "Mod/Resources/example_item_sprite";
		GameObject val = new GameObject(text);
		ExamplePassive examplePassive = val.AddComponent<ExamplePassive>();
		ItemBuilder.AddSpriteToObject(text, text2, val, (Assembly)null);
		string text3 = "Example Short Desc.";
		string text4 = "Example Long Description\n\nWow this description is really looooooooooong!";
		ItemBuilder.SetupItem((PickupObject)(object)examplePassive, text3, text4, "example");
		ItemBuilder.AddPassiveStatModifier((PickupObject)(object)examplePassive, (StatType)3, 1f, (ModifyMethod)0);
		ItemBuilder.AddPassiveStatModifier((PickupObject)(object)examplePassive, (StatType)4, 1f, (ModifyMethod)0);
		((PickupObject)examplePassive).quality = (ItemQuality)2;
	}

	public override void Pickup(PlayerController player)
	{
		((PassiveItem)this).Pickup(player);
		Module.Log("Player picked up " + ((PickupObject)this).DisplayName);
	}

	public override void DisableEffect(PlayerController player)
	{
		Module.Log("Player dropped or got rid of " + ((PickupObject)this).DisplayName);
	}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("accidia.etg.themist", "The Mist", "0.0.0")]
public class Module : BaseUnityPlugin
{
	public const string GUID = "accidia.etg.themist";

	public const string NAME = "The Mist";

	public const string VERSION = "0.0.0";

	public const string TEXT_COLOR = "#00FFFF";

	public void Start()
	{
		ETGModMainBehaviour.WaitForGameManagerStart((Action<GameManager>)GMStart);
	}

	public void GMStart(GameManager g)
	{
		DiffusionSmoke.Register();
		Log("The Mist v0.0.0 appeared into existence.", "#00FFFF");
	}

	public static void Log(string text, string color = "#FFFFFF")
	{
		ETGModConsole.Log((object)("<color=" + color + ">" + text + "</color>"), false);
	}
}
public class DiffusionSmoke : PlayerItem
{
	public static int ID;

	public static float cooldown = 6f;

	public static GameObject SmokeVFX;

	public Vector2 cursorPosition;

	public bool holding;

	private Vector2 m_cachedBlinkPosition;

	private tk2dSprite m_extantBlinkShadow;

	protected int m_overrideFlatColorID = Shader.PropertyToID("_FlatColor");

	public static void Register()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Expected O, but got Unknown
		//IL_0060: 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)
		string text = "Heart of The Mist";
		string text2 = "Mod/Resources/mist_heart_sprite";
		GameObject val = new GameObject(text);
		DiffusionSmoke diffusionSmoke = val.AddComponent<DiffusionSmoke>();
		ItemBuilder.SetCooldownType((PlayerItem)(object)diffusionSmoke, (CooldownType)0, cooldown);
		ItemBuilder.AddSpriteToObject(text, text2, val, (Assembly)null);
		string text3 = "Channeled Diffusion";
		string text4 = "Allows you to travel to different places very quickly, with a slow cooldown.\n\nVery little is actually known about the mist. What gas they are, where they come from and why they are here. Upon entering a room, they leak out gas passively, which is why they need food despite not having a stomach, and the small particles which spread out can be used as an extension of their body, allowing near instant travel to a specific area. This does however exhaust the little amount of usable gas, which means it cannot be done rapidly without risk to their health. No one knows how the hoodie comes along.";
		ItemBuilder.SetupItem((PickupObject)(object)diffusionSmoke, text3, text4, "aci");
		((PlayerItem)diffusionSmoke).consumable = false;
		((PickupObject)diffusionSmoke).CanBeDropped = false;
		((PickupObject)diffusionSmoke).quality = (ItemQuality)2;
		ID = ((PickupObject)diffusionSmoke).PickupObjectId;
		ItemBuilder.AddPassiveStatModifier((PickupObject)(object)diffusionSmoke, (StatType)8, 1f, (ModifyMethod)0);
		SmokeVFX = VFXToolbox.CreateVFX("Smoke", new List<string> { "Mod/Resources/smoke_vfx/smoke_effect_001", "Mod/Resources/smoke_vfx/smoke_effect_002", "Mod/Resources/smoke_vfx/smoke_effect_003", "Mod/Resources/smoke_vfx/smoke_effect_004", "Mod/Resources/smoke_vfx/smoke_effect_005", "Mod/Resources/smoke_vfx/smoke_effect_006", "Mod/Resources/smoke_vfx/smoke_effect_007" }, 12, new IntVector2(69, 66), (Anchor)1, usesZHeight: false, 0f, -1f, null, (WrapMode)2);
	}

	public override void DoEffect(PlayerController user)
	{
		((MonoBehaviour)GameManager.Instance).StartCoroutine(DoActiveEffect());
	}

	private IEnumerator DoActiveEffect()
	{
		BraveInput instanceForPlayer = BraveInput.GetInstanceForPlayer(base.LastOwner.PlayerIDX);
		PlayerController user = base.LastOwner;
		Vector2 previous = Vector2.zero;
		Vector2 oldPlayerpoint = ((BraveBehaviour)user).specRigidbody.UnitCenter;
		while (((OneAxisInputControl)instanceForPlayer.ActiveActions.UseItemAction).IsPressed && Time.timeScale != 0f && !((OneAxisInputControl)instanceForPlayer.ActiveActions.MapAction).IsPressed)
		{
			Vector2 position2 = ((!instanceForPlayer.IsKeyboardAndMouse(false)) ? (((GameActor)user).CenterPosition + MathsAndLogicHelper.DegreeToVector2(((GameActor)user).CurrentGun.CurrentAngle) * BraveTime.DeltaTime * 15f) : (Vector3Extensions.XY(user.unadjustedAimPoint) - (((GameActor)user).CenterPosition - ((BraveBehaviour)user).specRigidbody.UnitCenter)));
			position2 = (m_cachedBlinkPosition = BraveMathCollege.ClampToBounds(position2, GameManager.Instance.MainCameraController.MinVisiblePoint, GameManager.Instance.MainCameraController.MaxVisiblePoint));
			UpdateBlinkShadow(position2 - previous, user.CanBlinkToPoint(position2, Vector3Extensions.XY(((BraveBehaviour)user).transform.position) - ((BraveBehaviour)user).specRigidbody.UnitCenter));
			((PlayerItem)this).CurrentTimeCooldown = cooldown;
			previous = m_cachedBlinkPosition;
			oldPlayerpoint = ((BraveBehaviour)user).specRigidbody.UnitCenter;
			yield return null;
		}
		ClearBlinkShadow();
		if (user.IsDodgeRolling)
		{
			user.ForceStopDodgeRoll();
		}
		Vector2 worldCenter = Vector2.op_Implicit(user.unadjustedAimPoint);
		TeleportPlayerToCursorPosition.StartTeleport(user, worldCenter);
		if (!user.IsInCombat)
		{
			((PlayerItem)this).CurrentTimeCooldown = ((PlayerItem)this).CurrentTimeCooldown / 2f;
		}
		yield return (object)new WaitForSeconds(0.2f);
		if (((BraveBehaviour)user).specRigidbody.UnitCenter - oldPlayerpoint == Vector2.zero)
		{
			((PlayerItem)this).ClearCooldowns();
		}
	}

	public void DoAOEEffect(PlayerController user)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		RoomHandler absoluteRoom = Vector3Extensions.GetAbsoluteRoom(((BraveBehaviour)user).transform.position);
		List<AIActor> list = new List<AIActor>();
		if (absoluteRoom.GetActiveEnemies((ActiveEnemyType)1) != null)
		{
			foreach (AIActor activeEnemy in absoluteRoom.GetActiveEnemies((ActiveEnemyType)1))
			{
				list.Add(activeEnemy);
			}
		}
		if (list == null)
		{
			return;
		}
		for (int i = 0; i < list.Count; i++)
		{
			AIActor val = list[i];
			if (Vector2.Distance(((BraveBehaviour)val).specRigidbody.UnitCenter, ((BraveBehaviour)user).sprite.WorldCenter) <= 2f)
			{
				((BraveBehaviour)val).behaviorSpeculator.Stun(4f, true);
			}
		}
	}

	public void OnPreRigidBodyCollision(SpeculativeRigidbody myrigidbody, PixelCollider mypixelcollider, SpeculativeRigidbody otherrigidbody, PixelCollider otherpixelcollider)
	{
		if (Object.op_Implicit((Object)(object)((BraveBehaviour)otherrigidbody).aiActor))
		{
			GameActor gameActor = ((BraveBehaviour)otherrigidbody).gameActor;
			if (Object.op_Implicit((Object)(object)gameActor) && Object.op_Implicit((Object)(object)((BraveBehaviour)gameActor).healthHaver) && !((BraveBehaviour)gameActor).healthHaver.IsBoss)
			{
				((BraveBehaviour)gameActor).behaviorSpeculator.Stun(4f, true);
			}
		}
	}

	public void OnBlinkCloneCreated(tk2dSprite cloneSprite)
	{
		//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_0020: Unknown result type (might be due to invalid IL or missing references)
		PickupObject byId = PickupObjectDatabase.GetById(436);
		SpawnManager.SpawnVFX(((BlinkPassiveItem)((byId is BlinkPassiveItem) ? byId : null)).BlinkpoofVfx, Vector2.op_Implicit(((tk2dBaseSprite)cloneSprite).WorldCenter), Quaternion.identity);
	}

	public override void Pickup(PlayerController player)
	{
		player.OnBlinkShadowCreated = (Action<tk2dSprite>)Delegate.Combine(player.OnBlinkShadowCreated, new Action<tk2dSprite>(OnBlinkCloneCreated));
		((PlayerItem)this).Pickup(player);
	}

	public override bool CanBeUsed(PlayerController user)
	{
		return true;
	}

	public DebrisObject Drop(PlayerController player)
	{
		ClearBlinkShadow();
		return ((PlayerItem)this).Drop(player, 4f);
	}

	public override void OnDestroy()
	{
		if (Object.op_Implicit((Object)(object)base.LastOwner))
		{
			ClearBlinkShadow();
		}
		((PlayerItem)this).OnDestroy();
	}

	protected void UpdateBlinkShadow(Vector2 delta, bool canWarpDirectly)
	{
		//IL_0154: 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_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Expected O, but got Unknown
		//IL_0055: 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_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: 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_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_0233: Unknown result type (might be due to invalid IL or missing references)
		//IL_0218: Unknown result type (might be due to invalid IL or missing references)
		//IL_024a: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: 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_026a: 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_0274: Unknown result type (might be due to invalid IL or missing references)
		//IL_0279: Unknown result type (might be due to invalid IL or missing references)
		PlayerController lastOwner = base.LastOwner;
		if ((Object)(object)m_extantBlinkShadow == (Object)null)
		{
			GameObject val = new GameObject("blinkshadow");
			m_extantBlinkShadow = tk2dSprite.AddComponent(val, ((BraveBehaviour)lastOwner).sprite.Collection, ((BraveBehaviour)lastOwner).sprite.spriteId);
			((BraveBehaviour)m_extantBlinkShadow).transform.position = Vector2.op_Implicit(m_cachedBlinkPosition + (Vector3Extensions.XY(((BraveBehaviour)((BraveBehaviour)lastOwner).sprite).transform.position) - ((BraveBehaviour)lastOwner).specRigidbody.UnitCenter));
			tk2dSpriteAnimator val2 = ((Component)m_extantBlinkShadow).gameObject.AddComponent<tk2dSpriteAnimator>();
			val2.Library = ((BraveBehaviour)lastOwner).spriteAnimator.Library;
			((BraveBehaviour)m_extantBlinkShadow).renderer.material.SetColor(m_overrideFlatColorID, (!canWarpDirectly) ? new Color(0.4f, 0f, 0f, 1f) : new Color(0.25f, 0.25f, 0.25f, 1f));
			((tk2dBaseSprite)m_extantBlinkShadow).usesOverrideMaterial = true;
			((tk2dBaseSprite)m_extantBlinkShadow).FlipX = ((BraveBehaviour)lastOwner).sprite.FlipX;
			((tk2dBaseSprite)m_extantBlinkShadow).FlipY = ((BraveBehaviour)lastOwner).sprite.FlipY;
			OnBlinkCloneCreated(m_extantBlinkShadow);
		}
		else
		{
			if (delta == Vector2.zero)
			{
				((BraveBehaviour)m_extantBlinkShadow).spriteAnimator.Stop();
				((tk2dBaseSprite)m_extantBlinkShadow).SetSprite(((BraveBehaviour)lastOwner).sprite.Collection, ((BraveBehaviour)lastOwner).sprite.spriteId);
			}
			else
			{
				string baseAnimationName = lastOwner.GetBaseAnimationName(delta, lastOwner.m_currentGunAngle, false, true);
				if (!string.IsNullOrEmpty(baseAnimationName) && !((BraveBehaviour)m_extantBlinkShadow).spriteAnimator.IsPlaying(baseAnimationName))
				{
					((BraveBehaviour)m_extantBlinkShadow).spriteAnimator.Play(baseAnimationName);
				}
			}
			((BraveBehaviour)m_extantBlinkShadow).renderer.material.SetColor(m_overrideFlatColorID, (!canWarpDirectly) ? new Color(0.4f, 0f, 0f, 1f) : new Color(0.25f, 0.25f, 0.25f, 1f));
			((BraveBehaviour)m_extantBlinkShadow).transform.position = Vector2.op_Implicit(m_cachedBlinkPosition + (Vector3Extensions.XY(((BraveBehaviour)((BraveBehaviour)lastOwner).sprite).transform.position) - ((BraveBehaviour)lastOwner).specRigidbody.UnitCenter));
		}
		((tk2dBaseSprite)m_extantBlinkShadow).FlipX = ((BraveBehaviour)lastOwner).sprite.FlipX;
		((tk2dBaseSprite)m_extantBlinkShadow).FlipY = ((BraveBehaviour)lastOwner).sprite.FlipY;
	}

	protected void ClearBlinkShadow()
	{
		if (Object.op_Implicit((Object)(object)m_extantBlinkShadow))
		{
			Object.Destroy((Object)(object)((Component)m_extantBlinkShadow).gameObject);
			m_extantBlinkShadow = null;
		}
	}
}