Decompiled source of Project GNC Gungeon n Celeste v1.1.0

plugins/ProjectGNCC.dll

Decompiled a year ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Alexandria.ItemAPI;
using BepInEx;
using DungeonAPI;
using Dungeonator;
using Gungeon;
using ItemAPI;
using MiscAPI;
using MonoMod.RuntimeDetour;
using ProjectGNCC;
using ProjectGNCC.BadelinesItems;
using TrailAPI;
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: AssemblyVersion("1.0.0.0")]
namespace TrailAPI
{
	public class AfterImageTrailControllerMKII : BraveBehaviour
	{
		private class Shadow
		{
			public float timer;

			public tk2dSprite sprite;
		}

		public bool spawnShadows = true;

		public float shadowTimeDelay = 0.1f;

		public float shadowLifetime = 0.6f;

		public float minTranslation = 0.2f;

		public float maxEmission = 800f;

		public float minEmission = 100f;

		public float targetHeight = -2f;

		public Color dashColor = new Color(1f, 0f, 1f, 1f);

		public Shader OptionalImageShader;

		public bool UseTargetLayer;

		public string TargetLayer;

		public float OpacityOffset;

		[NonSerialized]
		private Shader OverrideImageShader;

		private readonly LinkedList<Shadow> m_activeShadows = new LinkedList<Shadow>();

		private readonly LinkedList<Shadow> m_inactiveShadows = new LinkedList<Shadow>();

		private float m_spawnTimer;

		private Vector2 m_lastSpawnPosition;

		public void Start()
		{
			if ((Object)(object)((BraveBehaviour)this).transform.parent != (Object)null && (Object)(object)((Component)((BraveBehaviour)this).transform.parent).GetComponent<Projectile>() != (Object)null)
			{
				((Component)((BraveBehaviour)this).transform.parent).GetComponent<Projectile>().OnDestruction += projectile_OnDestruction;
			}
			NewStart();
		}

		public void NewStart()
		{
			//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)
			if ((Object)(object)OptionalImageShader != (Object)null)
			{
				OverrideImageShader = OptionalImageShader;
			}
			m_lastSpawnPosition = Vector2.zero;
			m_spawnTimer = 0f;
		}

		private void projectile_OnDestruction(Projectile source)
		{
			if (m_activeShadows.Count > 0)
			{
				((MonoBehaviour)GameManager.Instance).StartCoroutine(HandleDeathShadowCleanup());
			}
		}

		public void LateUpdate()
		{
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			LinkedListNode<Shadow> linkedListNode = m_activeShadows.First;
			while (linkedListNode != null)
			{
				LinkedListNode<Shadow> next = linkedListNode.Next;
				linkedListNode.Value.timer -= BraveTime.DeltaTime;
				if ((double)linkedListNode.Value.timer <= 0.0)
				{
					m_activeShadows.Remove(linkedListNode);
					m_inactiveShadows.AddLast(linkedListNode);
					if (Object.op_Implicit((Object)(object)linkedListNode.Value.sprite))
					{
						((BraveBehaviour)linkedListNode.Value.sprite).renderer.enabled = false;
					}
				}
				else if (Object.op_Implicit((Object)(object)linkedListNode.Value.sprite))
				{
					float num = linkedListNode.Value.timer / shadowLifetime - OpacityOffset;
					if (num < 0f)
					{
						num = 0f;
					}
					Material val = ((BraveBehaviour)linkedListNode.Value.sprite).renderer.sharedMaterial;
					if ((Object)(object)val == (Object)null)
					{
						val = ((BraveBehaviour)linkedListNode.Value.sprite).renderer.material;
					}
					if ((Object)(object)val == (Object)null)
					{
						BadelineItemsModule.Log("SharedMaterial Backup failed in LateUpdate! Expect errors!");
					}
					val.SetFloat("_EmissivePower", Mathf.Lerp(maxEmission, minEmission, num));
					val.SetFloat("_Opacity", num);
				}
				linkedListNode = next;
			}
			if (spawnShadows)
			{
				if ((double)m_spawnTimer > 0.0)
				{
					m_spawnTimer -= BraveTime.DeltaTime;
				}
				if (!((double)m_spawnTimer > 0.0) && !((double)Vector2.Distance(m_lastSpawnPosition, Vector2.op_Implicit(((BraveBehaviour)this).transform.position)) <= (double)minTranslation))
				{
					SpawnNewShadow();
					m_spawnTimer += shadowTimeDelay;
					m_lastSpawnPosition = Vector2.op_Implicit(((BraveBehaviour)this).transform.position);
				}
			}
		}

		public IEnumerator HandleDeathShadowCleanup()
		{
			while (m_activeShadows.Count > 0)
			{
				LinkedListNode<Shadow> node = m_activeShadows.First;
				while (node != null)
				{
					LinkedListNode<Shadow> next = node.Next;
					node.Value.timer -= BraveTime.DeltaTime;
					if ((double)node.Value.timer <= 0.0)
					{
						m_activeShadows.Remove(node);
						m_inactiveShadows.AddLast(node);
						if (Object.op_Implicit((Object)(object)node.Value.sprite))
						{
							((BraveBehaviour)node.Value.sprite).renderer.enabled = false;
						}
					}
					else if (Object.op_Implicit((Object)(object)node.Value.sprite))
					{
						float t = node.Value.timer / shadowLifetime - OpacityOffset;
						if (t < 0f)
						{
							t = 0f;
						}
						Material sharedMaterial = ((BraveBehaviour)node.Value.sprite).renderer.sharedMaterial;
						if ((Object)(object)sharedMaterial == (Object)null)
						{
							sharedMaterial = ((BraveBehaviour)node.Value.sprite).renderer.material;
						}
						if ((Object)(object)sharedMaterial == (Object)null)
						{
							BadelineItemsModule.Log("SharedMaterial Backup failed in LateUpdate! Expect errors!");
						}
						sharedMaterial.SetFloat("_EmissivePower", Mathf.Lerp(maxEmission, minEmission, t));
						sharedMaterial.SetFloat("_Opacity", t);
					}
					node = next;
				}
				yield return null;
			}
		}

		protected override void OnDestroy()
		{
			((MonoBehaviour)GameManager.Instance).StartCoroutine(HandleDeathShadowCleanup());
			((BraveBehaviour)this).OnDestroy();
		}

		private void SpawnNewShadow()
		{
			//IL_009f: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			if (m_inactiveShadows.Count == 0)
			{
				CreateInactiveShadow();
			}
			LinkedListNode<Shadow> first = m_inactiveShadows.First;
			tk2dSprite sprite = first.Value.sprite;
			m_inactiveShadows.RemoveFirst();
			if (!Object.op_Implicit((Object)(object)sprite) || !Object.op_Implicit((Object)(object)((BraveBehaviour)sprite).renderer))
			{
				return;
			}
			first.Value.timer = shadowLifetime;
			((tk2dBaseSprite)sprite).SetSprite(((BraveBehaviour)this).sprite.Collection, ((BraveBehaviour)this).sprite.spriteId);
			((BraveBehaviour)sprite).transform.position = ((BraveBehaviour)((BraveBehaviour)this).sprite).transform.position;
			((BraveBehaviour)sprite).transform.rotation = ((BraveBehaviour)((BraveBehaviour)this).sprite).transform.rotation;
			((tk2dBaseSprite)sprite).scale = ((BraveBehaviour)this).sprite.scale;
			((tk2dBaseSprite)sprite).usesOverrideMaterial = true;
			((tk2dBaseSprite)sprite).IsPerpendicular = true;
			if (Object.op_Implicit((Object)(object)((BraveBehaviour)sprite).renderer))
			{
				((BraveBehaviour)sprite).renderer.enabled = true;
				if ((Object)(object)OverrideImageShader != (Object)null)
				{
					((BraveBehaviour)sprite).renderer.material.shader = OverrideImageShader;
				}
				((BraveBehaviour)sprite).renderer.sharedMaterial.SetFloat("_EmissivePower", minEmission);
				((BraveBehaviour)sprite).renderer.sharedMaterial.SetFloat("_Opacity", 1f - OpacityOffset);
				((BraveBehaviour)sprite).renderer.sharedMaterial.SetColor("_DashColor", dashColor);
			}
			((tk2dBaseSprite)sprite).HeightOffGround = targetHeight;
			((tk2dBaseSprite)sprite).UpdateZDepth();
			m_activeShadows.AddLast(first);
		}

		private void CreateInactiveShadow()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			GameObject val = new GameObject("after image");
			if (UseTargetLayer)
			{
				val.layer = LayerMask.NameToLayer(TargetLayer);
			}
			tk2dSprite sprite = val.AddComponent<tk2dSprite>();
			val.transform.parent = SpawnManager.Instance.VFX;
			m_inactiveShadows.AddLast(new Shadow
			{
				timer = shadowLifetime,
				sprite = sprite
			});
		}
	}
	public class DashTrail
	{
		public AfterImageTrailControllerMKII trail;

		private bool needReset;

		public DashTrail(GameObject addto, Color color, float opacityOffset = 0f, float TimeDelay = 0.125f, float Lifetime = 1.2f, float minDistance = 0f, string DashText = "Brave/Internal/HighPriestAfterImage", string FXText = "Brave/Internal/DownwellAfterImage")
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			needReset = false;
			trail = addto.AddComponent<AfterImageTrailControllerMKII>();
			setUpDashPart(trail, color, DashText, opacityOffset, TimeDelay, Lifetime, minDistance);
		}

		private void setUpDashPart(AfterImageTrailControllerMKII setup, Color color, string location, float opacityOffset, float STimeDelay, float SLifetime, float minDistance)
		{
			//IL_0029: 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)
			setup.spawnShadows = true;
			setup.shadowTimeDelay = STimeDelay;
			setup.shadowLifetime = SLifetime;
			setup.minTranslation = minDistance;
			setup.OpacityOffset = opacityOffset;
			setup.dashColor = color;
			setup.OptionalImageShader = ShaderCache.Acquire(location);
			((Behaviour)setup).enabled = false;
		}

		public void activateTrail()
		{
			((Behaviour)trail).enabled = true;
			trail.NewStart();
			needReset = true;
		}

		public void resetTrail()
		{
			((Behaviour)trail).enabled = false;
			if (needReset)
			{
				needReset = false;
				((MonoBehaviour)GameManager.Instance).StartCoroutine(trail.HandleDeathShadowCleanup());
			}
		}

		public void hardresetTrail()
		{
			((Behaviour)trail).enabled = false;
			Object.Destroy((Object)(object)trail);
		}
	}
	public class ShadowHandler : MonoBehaviour
	{
		public Vector3 Offset;

		public GameObject shadowObject;

		public ShadowHandler()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			shadowObject = (GameObject)Object.Instantiate(ResourceCache.Acquire("DefaultShadowSprite"));
			Offset = Vector2.op_Implicit(new Vector2(0f, 0f));
		}

		public void Start()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			GameObject val = Object.Instantiate<GameObject>(shadowObject);
			val.transform.parent = ((Component)this).gameObject.transform;
			tk2dSprite component = val.GetComponent<tk2dSprite>();
			((BraveBehaviour)component).renderer.enabled = true;
			((tk2dBaseSprite)component).HeightOffGround = ((tk2dBaseSprite)((Component)this).gameObject.GetComponent<tk2dSprite>()).HeightOffGround - 0.1f;
			Vector3Extensions.WithZ(val.transform.position, ((Component)this).gameObject.transform.position.z + 99999f);
			val.transform.position = ((Component)this).gameObject.transform.position + Offset;
			DepthLookupManager.ProcessRenderer(val.GetComponent<Renderer>(), (GungeonSortingLayer)0);
			((tk2dBaseSprite)component).usesOverrideMaterial = true;
			((BraveBehaviour)component).renderer.material.shader = Shader.Find("Brave/Internal/SimpleAlphaFadeUnlit");
			((BraveBehaviour)component).renderer.material.SetFloat("_Fade", 0.66f);
		}
	}
}
namespace MiscAPI
{
	public class DialogueInterface
	{
		public static void BeginStaticDialogueFromActiveItem(string Person, string Emotion, int duration, PlayerItem source, PlayerController user)
		{
			((MonoBehaviour)source).StartCoroutine(InternalDialogueSystem(Person, Emotion, duration, user));
		}

		public static void BeginStaticDialogueFromPassiveItem(string Person, string Emotion, int duration, PassiveItem source, PlayerController user)
		{
			((MonoBehaviour)source).StartCoroutine(InternalDialogueSystem(Person, Emotion, duration, user));
		}

		public static void BeginStaticDialogueFromGunBehavior(string Person, string Emotion, int duration, GunBehaviour source, PlayerController user)
		{
			((MonoBehaviour)source).StartCoroutine(InternalDialogueSystem(Person, Emotion, duration, user));
		}

		private static IEnumerator InternalDialogueSystem(string Person, string Emotion, int duration, PlayerController user)
		{
			AkSoundEngine.PostEvent("Play_" + Person + "_" + Emotion + "_Dialogue", ((Component)user).gameObject);
			int timer = duration;
			while (timer > 0)
			{
				timer--;
				yield return null;
			}
			BreakDialogue(Person, Emotion, user);
		}

		public static void BreakDialogue(string Person, string Emotion, PlayerController user)
		{
			AkSoundEngine.PostEvent("Break_" + Person + "_" + Emotion + "_Dialogue", ((Component)user).gameObject);
		}
	}
	public class SharedHooks
	{
		public static Hook RandomFlowHook;

		public static bool Spawnroom;

		public static void Init()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			RandomFlowHook = new Hook((MethodBase)typeof(SemioticDungeonGenSettings).GetMethod("GetRandomFlow", BindingFlags.Instance | BindingFlags.Public), typeof(SharedHooks).GetMethod("GetRandomHook", BindingFlags.Instance | BindingFlags.Public), (object)typeof(SemioticDungeonGenSettings));
			Spawnroom = false;
			Debug.Log((object)"Strawberry Room Modifier: Additional secret room set to NOT spawn.");
		}

		public DungeonFlow GetRandomHook(Func<SemioticDungeonGenSettings, DungeonFlow> orig, SemioticDungeonGenSettings self)
		{
			//IL_0011: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Invalid comparison between Unknown and I4
			Debug.Log((object)"Strawberry Room Modifier Online");
			GameMode currentGameMode = GameManager.Instance.CurrentGameMode;
			if (!((object)(GameMode)(ref currentGameMode)).ToString().ToLower().StartsWith("boss") && ((int)GameManager.Instance.CurrentLevelOverrideState == 1 || ((Object)GameManager.Instance.CurrentlyGeneratingDungeonPrefab).name.StartsWith("Base_Castle") || ((Object)GameManager.Instance.CurrentlyGeneratingDungeonPrefab).name.StartsWith("Base_Sewer") || ((Object)GameManager.Instance.CurrentlyGeneratingDungeonPrefab).name.StartsWith("Base_Gungeon") || ((Object)GameManager.Instance.CurrentlyGeneratingDungeonPrefab).name.StartsWith("Base_Cathedral") || ((Object)GameManager.Instance.CurrentlyGeneratingDungeonPrefab).name.StartsWith("Base_Mines") || ((Object)GameManager.Instance.CurrentlyGeneratingDungeonPrefab).name.StartsWith("Base_Catacombs")))
			{
				Debug.Log((object)"Strawberry Room Modifier: Attempting manual override");
				return GetRandomHookCont();
			}
			try
			{
				Debug.Log((object)"Strawberry Room Modifier: Attempting normal generation");
				return orig(self);
			}
			catch (Exception)
			{
				Debug.Log((object)"Strawberry Room Modifier: Errored at normal generation: trying manual override");
				return GetRandomHookCont();
			}
		}

		public DungeonFlow GetRandomHookCont()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			Debug.Log((object)"Strawberry Room Modifier: Beginning override!");
			if ((int)GameManager.Instance.CurrentLevelOverrideState == 1)
			{
				Debug.Log((object)"Strawberry Room Modifier: Loading Breach code:");
				Spawnroom = false;
				Debug.Log((object)"Strawberry Room Modifier: Additional secret room set to NOT spawn.");
				return FlowModifier.foyer;
			}
			Dungeon val = GameManager.Instance.Dungeon;
			if ((Object)(object)val == (Object)null)
			{
				Debug.Log((object)"Strawberry Room Modifier: Dungeon object found to be null. This is fine, so long as an alternate is found. Looking for alternate:");
				val = GameManager.Instance.CurrentlyGeneratingDungeonPrefab;
			}
			if ((Object)(object)val == (Object)null)
			{
				Debug.Log((object)"Strawberry Room Modifier: No Alternate found! Dungeon is still null! Defaulting to F1 to wrongwarp (yes those exist) instead of crashing");
				val = FlowModifier.ModifiedFloors[0];
			}
			else
			{
				Debug.Log((object)("Strawberry Room Modifier: Alternate floor found: " + ((Object)val).name));
			}
			List<DungeonFlow> list = new List<DungeonFlow>();
			switch (((Object)val).name)
			{
			case "Base_Gungeon":
				foreach (DungeonFlow flow2 in FlowModifier.FlowList)
				{
					if (!string.IsNullOrEmpty((flow2 != null) ? ((Object)flow2).name : null) && ((Object)flow2).name.ToLower().StartsWith("f2_gungeon_flow"))
					{
						list.Add(flow2);
					}
				}
				break;
			case "Base_Castle":
				foreach (DungeonFlow flow3 in FlowModifier.FlowList)
				{
					if (!string.IsNullOrEmpty((flow3 != null) ? ((Object)flow3).name : null) && ((Object)flow3).name.ToLower().StartsWith("f1_castle_flow"))
					{
						list.Add(flow3);
					}
				}
				break;
			case "Base_Sewer":
				foreach (DungeonFlow flow4 in FlowModifier.FlowList)
				{
					if (!string.IsNullOrEmpty((flow4 != null) ? ((Object)flow4).name : null) && ((Object)flow4).name.ToLower().StartsWith("f1a_sewers_flow"))
					{
						list.Add(flow4);
					}
				}
				break;
			case "Base_Cathedral":
				foreach (DungeonFlow flow5 in FlowModifier.FlowList)
				{
					if (!string.IsNullOrEmpty((flow5 != null) ? ((Object)flow5).name : null) && ((Object)flow5).name.ToLower().StartsWith("f2a_cathedral_flow"))
					{
						list.Add(flow5);
					}
				}
				break;
			case "Base_Mines":
				foreach (DungeonFlow flow6 in FlowModifier.FlowList)
				{
					if (!string.IsNullOrEmpty((flow6 != null) ? ((Object)flow6).name : null) && ((Object)flow6).name.ToLower().StartsWith("f3_mines_flow"))
					{
						list.Add(flow6);
					}
				}
				break;
			case "Base_Catacombs":
				foreach (DungeonFlow flow7 in FlowModifier.FlowList)
				{
					if (!string.IsNullOrEmpty((flow7 != null) ? ((Object)flow7).name : null) && ((Object)flow7).name.ToLower().StartsWith("f4_catacomb_flow"))
					{
						list.Add(flow7);
					}
				}
				break;
			case "Base_Forge":
				foreach (DungeonFlow flow8 in FlowModifier.FlowList)
				{
					if (!string.IsNullOrEmpty((flow8 != null) ? ((Object)flow8).name : null) && ((Object)flow8).name.ToLower().StartsWith("f5_forge_flow"))
					{
						list.Add(flow8);
					}
				}
				break;
			case "Base_BulletHell":
				foreach (DungeonFlow flow9 in FlowModifier.FlowList)
				{
					if (!string.IsNullOrEmpty((flow9 != null) ? ((Object)flow9).name : null) && ((Object)flow9).name.ToLower().StartsWith("f6_bullethell_flow"))
					{
						list.Add(flow9);
					}
				}
				break;
			case "Base_Nakatomi":
				foreach (DungeonFlow flow10 in FlowModifier.FlowList)
				{
					if (!string.IsNullOrEmpty((flow10 != null) ? ((Object)flow10).name : null) && ((Object)flow10).name.ToLower().StartsWith("fs4_nakatomi_flow"))
					{
						list.Add(flow10);
					}
				}
				break;
			case "Base_ResourcefulRat":
				foreach (DungeonFlow flow11 in FlowModifier.FlowList)
				{
					if (!string.IsNullOrEmpty((flow11 != null) ? ((Object)flow11).name : null) && ((Object)flow11).name.ToLower().StartsWith("resourcefulratlair_flow"))
					{
						list.Add(flow11);
					}
				}
				break;
			}
			if (list.Count > 0)
			{
				foreach (DungeonFlow item in list)
				{
					Debug.Log((object)("Strawberry Room Modifier: Flows found! Possible load includes: " + ((Object)item).name));
				}
				if (list.Count == 1)
				{
					return FlowDuplicator.DuplicateFlow(list[0], val);
				}
				DungeonFlow flow = list[BraveRandom.GenerationRandomRange(0, list.Count)];
				return FlowDuplicator.DuplicateFlow(flow, val);
			}
			Debug.Log((object)"Strawberry Room Modifier: Error! All code ran and no proper flow identified!");
			return null;
		}
	}
}
namespace ItemAPI
{
	public class AdvancedTransformGunSynergyProcessor : MonoBehaviour
	{
		public string SynergyToCheck;

		public int NonSynergyGunId;

		public int SynergyGunId;

		private Gun m_gun;

		private bool m_transformed;

		public bool ShouldResetAmmoAfterTransformation;

		public int ResetAmmoCount;

		public AdvancedTransformGunSynergyProcessor()
		{
			NonSynergyGunId = -1;
			SynergyGunId = -1;
		}

		private void Awake()
		{
			m_gun = ((Component)this).GetComponent<Gun>();
		}

		private void Update()
		{
			if (Dungeon.IsGenerating || Dungeon.ShouldAttemptToLoadFromMidgameSave)
			{
				return;
			}
			if (Object.op_Implicit((Object)(object)m_gun) && m_gun.CurrentOwner is PlayerController)
			{
				GameActor currentOwner = m_gun.CurrentOwner;
				PlayerController val = (PlayerController)(object)((currentOwner is PlayerController) ? currentOwner : null);
				if (!((Behaviour)m_gun).enabled)
				{
					return;
				}
				if (CustomSynergies.PlayerHasActiveSynergy(val, SynergyToCheck) && !m_transformed)
				{
					m_transformed = true;
					? val2 = m_gun;
					PickupObject byId = PickupObjectDatabase.GetById(SynergyGunId);
					((Gun)val2).TransformToTargetGun((Gun)(object)((byId is Gun) ? byId : null));
					if (ShouldResetAmmoAfterTransformation)
					{
						m_gun.ammo = ResetAmmoCount;
					}
				}
				else if (!CustomSynergies.PlayerHasActiveSynergy(val, SynergyToCheck) && m_transformed)
				{
					m_transformed = false;
					? val3 = m_gun;
					PickupObject byId2 = PickupObjectDatabase.GetById(NonSynergyGunId);
					((Gun)val3).TransformToTargetGun((Gun)(object)((byId2 is Gun) ? byId2 : null));
					if (ShouldResetAmmoAfterTransformation)
					{
						m_gun.ammo = ResetAmmoCount;
					}
				}
			}
			else if (Object.op_Implicit((Object)(object)m_gun) && !Object.op_Implicit((Object)(object)m_gun.CurrentOwner) && m_transformed)
			{
				m_transformed = false;
				? val4 = m_gun;
				PickupObject byId3 = PickupObjectDatabase.GetById(NonSynergyGunId);
				((Gun)val4).TransformToTargetGun((Gun)(object)((byId3 is Gun) ? byId3 : null));
				if (ShouldResetAmmoAfterTransformation)
				{
					m_gun.ammo = ResetAmmoCount;
				}
			}
			ShouldResetAmmoAfterTransformation = false;
		}
	}
	public static class BreakableAPIToolbox
	{
		public enum BreakDirection
		{
			NORTH,
			SOUTH,
			EAST,
			WEST
		}

		public static Shader worldShader = ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTiltedCutoutFastPixelShadow");

		public static KickableObject GenerateKickableObject(string name, string[] idleSpritePaths, string[] rollNorthPaths, string[] rollSouthPaths, string[] rollEastPaths, string[] rollWestPaths, string[] impactNorthPaths, string[] impactSouthPaths, string[] impactEastPaths, string[] impactWestPaths, string[] impactNotRollingPaths, string[] RolledIntoBreakPaths, int idleAnimFPS = 4, int rollAnimFPS = 5, int breakAnimFPS = 4, int breakNotRollingFPS = 4, int breakRolledIntoFPS = 4, bool UsesCustomColliderValues = false, int ColliderSizeX = 16, int ColliderSizeY = 8, int ColliderOffsetX = 0, int ColliderOffsetY = 8, bool HasAdditionalCollisions = true, bool AdditionalCollisionsUseColliderSizes = true, int AdiitionalColliderSizeX = 8, int AdiitionalColliderSizeY = 8, int AdiitionalColliderOffsetX = 0, int AdiitionalColliderOffsetY = 0, string breakAudioEvent = "Play_OBJ_barrel_break_01", float rollingSpeed = 3f, List<CollisionLayer> collisionLayerList = null, bool usesWorldShader = true)
		{
			//IL_0080: 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_00a0: 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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: 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_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Expected O, but got Unknown
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Expected O, but got Unknown
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Expected O, but got Unknown
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Expected O, but got Unknown
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			Texture2D textureFromResource = ResourceExtractor.GetTextureFromResource(idleSpritePaths[0], (Assembly)null);
			GameObject val = SpriteBuilder.SpriteFromResource(idleSpritePaths[0], (GameObject)null, (Assembly)null);
			FakePrefab.MarkAsFakePrefab(val);
			((Object)val).name = name;
			KickableObject val2 = val.AddComponent<KickableObject>();
			MinorBreakable val3 = val.AddComponent<MinorBreakable>();
			tk2dSpriteCollectionData val4 = SpriteBuilder.ConstructCollection(val, name + "_Collection", false);
			int num = SpriteBuilder.AddSpriteToCollection(idleSpritePaths[0], val4, (Assembly)null);
			tk2dSprite orAddComponent = GameObjectExtensions.GetOrAddComponent<tk2dSprite>(val);
			((tk2dBaseSprite)orAddComponent).SetSprite(val4, num);
			IntVector2 val5 = default(IntVector2);
			((IntVector2)(ref val5))..ctor(ColliderSizeX, ColliderSizeY);
			IntVector2 val6 = default(IntVector2);
			((IntVector2)(ref val6))..ctor(ColliderOffsetX, ColliderOffsetY);
			IntVector2 val7 = default(IntVector2);
			((IntVector2)(ref val7))..ctor(val5.x, val5.y);
			IntVector2 val8 = default(IntVector2);
			((IntVector2)(ref val8))..ctor(AdiitionalColliderSizeX, AdiitionalColliderSizeY);
			IntVector2 val9 = default(IntVector2);
			((IntVector2)(ref val9))..ctor(val8.x, val8.y);
			IntVector2 val10 = default(IntVector2);
			((IntVector2)(ref val10))..ctor(AdiitionalColliderOffsetX, AdiitionalColliderOffsetY);
			if (!UsesCustomColliderValues)
			{
				IntVector2 val11 = default(IntVector2);
				((IntVector2)(ref val11))..ctor(((Texture)textureFromResource).width, ((Texture)textureFromResource).height);
				((IntVector2)(ref val7))..ctor(val11.x, val11.y);
			}
			if (AdditionalCollisionsUseColliderSizes)
			{
				val9 = val7;
				val10 = val6;
			}
			SpeculativeRigidbody val12 = orAddComponent.SetUpEmptySpeculativeRigidbody(val6, val7);
			if (collisionLayerList == null)
			{
				val12.PixelColliders.Add(new PixelCollider
				{
					ColliderGenerationMode = (PixelColliderGeneration)0,
					CollisionLayer = (CollisionLayer)6,
					IsTrigger = false,
					BagleUseFirstFrameOnly = false,
					SpecifyBagelFrame = string.Empty,
					BagelColliderNumber = 0,
					ManualOffsetX = val6.x,
					ManualOffsetY = val6.y,
					ManualWidth = val7.x,
					ManualHeight = val7.y,
					ManualDiameter = 0,
					ManualLeftX = 0,
					ManualLeftY = 0,
					ManualRightX = 0,
					ManualRightY = 0
				});
			}
			else
			{
				foreach (CollisionLayer collisionLayer in collisionLayerList)
				{
					val12.PixelColliders.Add(new PixelCollider
					{
						ColliderGenerationMode = (PixelColliderGeneration)0,
						CollisionLayer = collisionLayer,
						IsTrigger = false,
						BagleUseFirstFrameOnly = false,
						SpecifyBagelFrame = string.Empty,
						BagelColliderNumber = 0,
						ManualOffsetX = val6.x,
						ManualOffsetY = val6.y,
						ManualWidth = val7.x,
						ManualHeight = val7.y,
						ManualDiameter = 0,
						ManualLeftX = 0,
						ManualLeftY = 0,
						ManualRightX = 0,
						ManualRightY = 0
					});
				}
			}
			tk2dSpriteAnimator orAddComponent2 = GameObjectExtensions.GetOrAddComponent<tk2dSpriteAnimator>(val);
			tk2dSpriteAnimation val13 = val.AddComponent<tk2dSpriteAnimation>();
			val13.clips = (tk2dSpriteAnimationClip[])(object)new tk2dSpriteAnimationClip[0];
			orAddComponent2.Library = val13;
			List<tk2dSpriteAnimationClip> list = new List<tk2dSpriteAnimationClip>();
			if (idleSpritePaths.Length >= 1)
			{
				tk2dSpriteAnimationClip val14 = new tk2dSpriteAnimationClip();
				val14.name = "idle";
				val14.frames = (tk2dSpriteAnimationFrame[])(object)new tk2dSpriteAnimationFrame[0];
				val14.fps = idleAnimFPS;
				tk2dSpriteAnimationClip val15 = val14;
				List<tk2dSpriteAnimationFrame> list2 = new List<tk2dSpriteAnimationFrame>();
				for (int i = 0; i < idleSpritePaths.Length; i++)
				{
					tk2dSpriteCollectionData val16 = val4;
					int num2 = SpriteBuilder.AddSpriteToCollection(idleSpritePaths[i], val16, (Assembly)null);
					GunTools.ConstructOffsetsFromAnchor(val16.spriteDefinitions[num2], (Anchor)0, (Vector2?)null, false, true);
					list2.Add(new tk2dSpriteAnimationFrame
					{
						spriteId = num2,
						spriteCollection = val16
					});
				}
				val15.frames = list2.ToArray();
				val15.wrapMode = (WrapMode)0;
				list.Add(val15);
			}
			tk2dSpriteAnimationClip item = AddAnimation(orAddComponent2, val4, rollNorthPaths, name + "_roll_north", rollAnimFPS, (WrapMode)0);
			tk2dSpriteAnimationClip item2 = AddAnimation(orAddComponent2, val4, rollSouthPaths, name + "_roll_south", rollAnimFPS, (WrapMode)0);
			tk2dSpriteAnimationClip item3 = AddAnimation(orAddComponent2, val4, rollEastPaths, name + "_roll_east", rollAnimFPS, (WrapMode)0);
			tk2dSpriteAnimationClip item4 = AddAnimation(orAddComponent2, val4, rollWestPaths, name + "_roll_west", rollAnimFPS, (WrapMode)0);
			val2.rollAnimations = new string[4]
			{
				name + "_roll_north",
				name + "_roll_west",
				name + "_roll_south",
				name + "_roll_east"
			};
			list.AddRange(new List<tk2dSpriteAnimationClip> { item, item2, item3, item4 });
			tk2dSpriteAnimationClip item5 = AddAnimation(orAddComponent2, val4, impactNorthPaths, name + "_impact_north", breakAnimFPS, (WrapMode)2);
			tk2dSpriteAnimationClip item6 = AddAnimation(orAddComponent2, val4, impactSouthPaths, name + "_impact_south", breakAnimFPS, (WrapMode)2);
			tk2dSpriteAnimationClip item7 = AddAnimation(orAddComponent2, val4, impactEastPaths, name + "_impact_east", breakAnimFPS, (WrapMode)2);
			tk2dSpriteAnimationClip item8 = AddAnimation(orAddComponent2, val4, impactWestPaths, name + "_impact_west", breakAnimFPS, (WrapMode)2);
			val2.impactAnimations = new string[4]
			{
				name + "_impact_north",
				name + "_impact_west",
				name + "_impact_south",
				name + "_impact_east"
			};
			list.AddRange(new List<tk2dSpriteAnimationClip> { item5, item6, item7, item8 });
			tk2dSpriteAnimationClip item9 = AddAnimation(orAddComponent2, val4, impactNotRollingPaths, name + "_impact_nonroll", breakNotRollingFPS, (WrapMode)2);
			list.Add(item9);
			tk2dSpriteAnimationClip item10 = AddAnimation(orAddComponent2, val4, RolledIntoBreakPaths, name + "_rolled_into", breakRolledIntoFPS, (WrapMode)2);
			list.Add(item10);
			val2.RollingBreakAnim = name + "_rolled_into";
			val3.breakAnimName = name + "_impact_nonroll";
			tk2dSpriteAnimationClip[] clips = list.ToArray();
			orAddComponent2.Library.clips = clips;
			orAddComponent2.playAutomatically = true;
			orAddComponent2.DefaultClipId = orAddComponent2.GetClipIdByName("idle");
			val3.breakAudioEventName = breakAudioEvent;
			((BraveBehaviour)val2).sprite = (tk2dBaseSprite)(object)orAddComponent;
			((BraveBehaviour)val2).spriteAnimator = orAddComponent2;
			val2.AllowTopWallTraversal = true;
			val2.rollSpeed = rollingSpeed;
			if (usesWorldShader)
			{
				((BraveBehaviour)((BraveBehaviour)val2).sprite).renderer.material.shader = worldShader;
				((BraveBehaviour)((BraveBehaviour)val2).sprite).renderer.material.EnableKeyword("BRIGHTNESS_CLAMP_ON");
			}
			return val2;
		}

		public static tk2dSpriteAnimationClip AddAnimation(tk2dSpriteAnimator animator, tk2dSpriteCollectionData Tablecollection, string[] spritePaths, string clipName, int FPS, WrapMode wrapMode)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			tk2dSpriteAnimation val = ((Component)animator).gameObject.AddComponent<tk2dSpriteAnimation>();
			val.clips = (tk2dSpriteAnimationClip[])(object)new tk2dSpriteAnimationClip[0];
			animator.Library = val;
			tk2dSpriteAnimationClip val2 = new tk2dSpriteAnimationClip();
			val2.name = clipName;
			val2.frames = (tk2dSpriteAnimationFrame[])(object)new tk2dSpriteAnimationFrame[0];
			val2.fps = FPS;
			tk2dSpriteAnimationClip val3 = val2;
			List<tk2dSpriteAnimationFrame> list = new List<tk2dSpriteAnimationFrame>();
			for (int i = 0; i < spritePaths.Length; i++)
			{
				int num = SpriteBuilder.AddSpriteToCollection(spritePaths[i], Tablecollection, (Assembly)null);
				tk2dSpriteDefinition val4 = Tablecollection.spriteDefinitions[num];
				list.Add(new tk2dSpriteAnimationFrame
				{
					spriteId = num,
					spriteCollection = Tablecollection
				});
			}
			val3.frames = list.ToArray();
			val3.wrapMode = wrapMode;
			return val3;
		}

		public static FlippableCover GenerateTable(string name, string[] idleSpritePaths, string[] outlinePaths, string[] northFlipPaths, string[] southFlipPaths, string[] eastFlipPaths, string[] westFlipPaths, string[] northBreakPaths, string[] southBreakPaths, string[] eastBreakPaths, string[] westBreakPaths, string[] unflippedBreakPaths, int IdleFPS = 4, int FlipFPS = 6, int BreakFPS = 7, int UnflippedBreakFPS = 5, bool UsesCustomColliderValues = false, int ColliderSizeX = 16, int ColliderSizeY = 8, int ColliderOffsetX = 0, int ColliderOffsetY = 8, int FlippedColliderSizeX_Horizontal = 20, int FlippedColliderSizeY_Horizontal = 2, int FlippedColliderSizeX_Vertical = 4, int FlippedColliderSizeY_Vertical = 8, FlipStyle flipStyle = 0, float TableHP = 90f, string ShadowSpritePath = null, Dictionary<float, string> breakAnimPercentages_AND_SpritePathsandBreakDirectionsNorth = null, Dictionary<float, string> breakAnimPercentages_AND_SpritePathsandBreakDirectionsSouth = null, Dictionary<float, string> breakAnimPercentages_AND_SpritePathsandBreakDirectionsEast = null, Dictionary<float, string> breakAnimPercentages_AND_SpritePathsandBreakDirectionsWest = null, Dictionary<float, string> unflippedBreakAnimPercentagesAndSpritePaths = null, bool IsSlideable = true, bool hasDecorations = true, float chanceToDecorateTable = 1f)
		{
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: 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_0237: 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_0143: Expected O, but got Unknown
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Invalid comparison between Unknown and I4
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Invalid comparison between Unknown and I4
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Invalid comparison between Unknown and I4
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Invalid comparison between Unknown and I4
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: 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_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_0421: Unknown result type (might be due to invalid IL or missing references)
			//IL_0429: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Unknown result type (might be due to invalid IL or missing references)
			//IL_043e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: 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_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Expected O, but got Unknown
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_065e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0660: Unknown result type (might be due to invalid IL or missing references)
			//IL_0670: Unknown result type (might be due to invalid IL or missing references)
			//IL_0675: Unknown result type (might be due to invalid IL or missing references)
			//IL_0677: Unknown result type (might be due to invalid IL or missing references)
			//IL_067c: Unknown result type (might be due to invalid IL or missing references)
			//IL_067e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0683: Unknown result type (might be due to invalid IL or missing references)
			//IL_068a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0691: Unknown result type (might be due to invalid IL or missing references)
			//IL_0698: Unknown result type (might be due to invalid IL or missing references)
			//IL_0699: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06be: Expected O, but got Unknown
			//IL_06c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0708: Unknown result type (might be due to invalid IL or missing references)
			//IL_0714: Expected O, but got Unknown
			//IL_073d: Unknown result type (might be due to invalid IL or missing references)
			//IL_049d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04da: Unknown result type (might be due to invalid IL or missing references)
			//IL_04df: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_050e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0516: Unknown result type (might be due to invalid IL or missing references)
			//IL_051e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0523: Unknown result type (might be due to invalid IL or missing references)
			//IL_052b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0533: Unknown result type (might be due to invalid IL or missing references)
			//IL_0552: Unknown result type (might be due to invalid IL or missing references)
			//IL_055a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0562: Unknown result type (might be due to invalid IL or missing references)
			//IL_0567: Unknown result type (might be due to invalid IL or missing references)
			//IL_056f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0577: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ae6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b23: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0883: Unknown result type (might be due to invalid IL or missing references)
			//IL_0832: Unknown result type (might be due to invalid IL or missing references)
			//IL_0950: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a10: Unknown result type (might be due to invalid IL or missing references)
			//IL_09bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a7f: Unknown result type (might be due to invalid IL or missing references)
			Texture2D textureFromResource = ResourceExtractor.GetTextureFromResource(idleSpritePaths[0], (Assembly)null);
			GameObject val = SpriteBuilder.SpriteFromResource(idleSpritePaths[0], (GameObject)null, (Assembly)null);
			FakePrefab.MarkAsFakePrefab(val);
			((Object)val).name = name + "_Table";
			FlippableCover val2 = val.AddComponent<FlippableCover>();
			MajorBreakable val3 = val.AddComponent<MajorBreakable>();
			tk2dSpriteCollectionData val4 = SpriteBuilder.ConstructCollection(val, name + "_Collection", false);
			int num = SpriteBuilder.AddSpriteToCollection(idleSpritePaths[0], val4, (Assembly)null);
			tk2dSprite orAddComponent = GameObjectExtensions.GetOrAddComponent<tk2dSprite>(val);
			tk2dBaseSprite orAddComponent2 = GameObjectExtensions.GetOrAddComponent<tk2dBaseSprite>(val);
			orAddComponent2.SetSprite(val4, num);
			((tk2dBaseSprite)orAddComponent).SetSprite(val4, num);
			orAddComponent2.HeightOffGround = 0f;
			((tk2dBaseSprite)orAddComponent).HeightOffGround = 0f;
			val.layer = 0;
			IntVector2 val5 = default(IntVector2);
			((IntVector2)(ref val5))..ctor(ColliderOffsetX, ColliderOffsetY);
			IntVector2 val6 = default(IntVector2);
			((IntVector2)(ref val6))..ctor(ColliderSizeX, ColliderSizeY);
			if (!UsesCustomColliderValues)
			{
				IntVector2 val7 = default(IntVector2);
				((IntVector2)(ref val7))..ctor(((Texture)textureFromResource).width, ((Texture)textureFromResource).height);
				((IntVector2)(ref val6))..ctor(val7.x, val7.y);
			}
			val3.HitPoints = TableHP;
			tk2dSpriteAnimator orAddComponent3 = GameObjectExtensions.GetOrAddComponent<tk2dSpriteAnimator>(val);
			tk2dSpriteAnimation val8 = val.AddComponent<tk2dSpriteAnimation>();
			val8.clips = (tk2dSpriteAnimationClip[])(object)new tk2dSpriteAnimationClip[0];
			orAddComponent3.Library = val8;
			List<tk2dSpriteAnimationClip> list = new List<tk2dSpriteAnimationClip>();
			if (idleSpritePaths.Length >= 1)
			{
				tk2dSpriteAnimationClip val9 = new tk2dSpriteAnimationClip();
				val9.name = "idle";
				val9.frames = (tk2dSpriteAnimationFrame[])(object)new tk2dSpriteAnimationFrame[0];
				val9.fps = IdleFPS;
				tk2dSpriteAnimationClip val10 = val9;
				List<tk2dSpriteAnimationFrame> list2 = new List<tk2dSpriteAnimationFrame>();
				for (int i = 0; i < idleSpritePaths.Length; i++)
				{
					tk2dSpriteCollectionData val11 = val4;
					int num2 = SpriteBuilder.AddSpriteToCollection(idleSpritePaths[i], val11, (Assembly)null);
					tk2dSpriteDefinition val12 = val11.spriteDefinitions[num2];
					GunTools.ConstructOffsetsFromAnchor(val12, (Anchor)0, (Vector2?)null, false, true);
					GenerateColliderForSpriteDefinition(val12, new Vector3((float)val6.x, (float)val6.y), new Vector3((float)val5.x, (float)val5.y));
					list2.Add(new tk2dSpriteAnimationFrame
					{
						spriteId = num2,
						spriteCollection = val11
					});
				}
				val10.frames = list2.ToArray();
				val10.wrapMode = (WrapMode)0;
				list.Add(val10);
			}
			val2.flipStyle = flipStyle;
			val2.outlineNorth = GenerateTableOutlineObject("North_" + name, outlinePaths[0], ((Component)val2).gameObject, val4);
			val2.outlineEast = GenerateTableOutlineObject("East_" + name, outlinePaths[1], ((Component)val2).gameObject, val4);
			val2.outlineWest = GenerateTableOutlineObject("West_" + name, outlinePaths[2], ((Component)val2).gameObject, val4);
			val2.outlineSouth = GenerateTableOutlineObject("South_" + name, outlinePaths[3], ((Component)val2).gameObject, val4);
			if (ShadowSpritePath != null)
			{
				GameObject val13 = SpriteBuilder.SpriteFromResource(ShadowSpritePath, (GameObject)null, (Assembly)null);
				FakePrefab.MarkAsFakePrefab(val13);
				int num3 = SpriteBuilder.AddSpriteToCollection(ShadowSpritePath, val4, (Assembly)null);
				tk2dSprite component = val13.GetComponent<tk2dSprite>();
				((tk2dBaseSprite)component).SetSprite(val4, num3);
				val2.shadowSprite = component;
				val13.transform.parent = val.transform;
			}
			bool flag = (int)flipStyle == 1 || (int)flipStyle == 3;
			if (!((int)flipStyle == 2 || (int)flipStyle == 3))
			{
				tk2dSpriteAnimationClip item = AddTableAnimation(orAddComponent3, val4, northFlipPaths, name + "_flip_north", FlipFPS, new Vector3((float)FlippedColliderSizeX_Horizontal, (float)(FlippedColliderSizeY_Horizontal + val6.y)), new Vector3((float)val5.x, (float)(ColliderOffsetY + val6.y - FlippedColliderSizeY_Horizontal)));
				tk2dSpriteAnimationClip item2 = AddTableAnimation(orAddComponent3, val4, southFlipPaths, name + "_flip_south", FlipFPS, new Vector3((float)FlippedColliderSizeX_Horizontal, (float)FlippedColliderSizeY_Horizontal), new Vector3((float)val5.x, (float)val5.y));
				tk2dSpriteAnimationClip item3 = AddTableAnimation(orAddComponent3, val4, northBreakPaths, name + "_break_north", BreakFPS, new Vector3((float)val6.x, (float)val6.y), new Vector3((float)val5.x, (float)val5.y));
				tk2dSpriteAnimationClip item4 = AddTableAnimation(orAddComponent3, val4, southBreakPaths, name + "_break_south", BreakFPS, new Vector3((float)val6.x, (float)val6.y), new Vector3((float)val5.x, (float)val5.y));
				list.Add(item);
				list.Add(item2);
				list.Add(item3);
				list.Add(item4);
			}
			if (!flag)
			{
				tk2dSpriteAnimationClip item5 = AddTableAnimation(orAddComponent3, val4, westFlipPaths, name + "_flip_east", FlipFPS, new Vector3((float)(FlippedColliderSizeX_Vertical * 2), (float)FlippedColliderSizeY_Vertical), new Vector3((float)(ColliderOffsetX + val6.x), (float)val5.y));
				tk2dSpriteAnimationClip item6 = AddTableAnimation(orAddComponent3, val4, eastFlipPaths, name + "_flip_west", FlipFPS, new Vector3((float)FlippedColliderSizeX_Vertical, (float)FlippedColliderSizeY_Vertical), new Vector3((float)val5.x, (float)val5.y));
				tk2dSpriteAnimationClip item7 = AddTableAnimation(orAddComponent3, val4, westBreakPaths, name + "_break_east", BreakFPS, new Vector3((float)val6.x, (float)val6.y), new Vector3((float)val5.x, (float)val5.y));
				tk2dSpriteAnimationClip item8 = AddTableAnimation(orAddComponent3, val4, eastBreakPaths, name + "_break_west", BreakFPS, new Vector3((float)val6.x, (float)val6.y), new Vector3((float)val5.x, (float)val5.y));
				list.Add(item5);
				list.Add(item6);
				list.Add(item7);
				list.Add(item8);
			}
			tk2dSpriteAnimationClip item9 = AddTableAnimation(orAddComponent3, val4, unflippedBreakPaths, name + "_break_unflipped", UnflippedBreakFPS, new Vector3((float)val6.x, (float)val6.y), new Vector3((float)val5.x, (float)val5.y));
			list.Add(item9);
			val2.flipAnimation = name + "_flip_{0}";
			val2.breakAnimation = name + "_break_{0}";
			val2.unflippedBreakAnimation = name + "_break_unflipped";
			orAddComponent3.Library.clips = list.ToArray();
			orAddComponent3.playAutomatically = true;
			orAddComponent3.DefaultClipId = orAddComponent3.GetClipIdByName("idle");
			SpeculativeRigidbody val14 = orAddComponent.SetUpEmptySpeculativeRigidbody(val5, val6);
			val14.PixelColliders.Add(new PixelCollider
			{
				ColliderGenerationMode = (PixelColliderGeneration)1,
				CollisionLayer = (CollisionLayer)5,
				IsTrigger = false,
				Enabled = true,
				BagleUseFirstFrameOnly = true,
				ManualOffsetX = val5.x,
				ManualOffsetY = val5.y,
				ManualDiameter = 0
			});
			val14.PixelColliders.Add(new PixelCollider
			{
				ColliderGenerationMode = (PixelColliderGeneration)1,
				CollisionLayer = (CollisionLayer)8,
				IsTrigger = false,
				Enabled = false,
				BagleUseFirstFrameOnly = true,
				ManualOffsetX = val5.x,
				ManualOffsetY = val5.y,
				ManualDiameter = 0
			});
			((BraveBehaviour)val2).sprite = (tk2dBaseSprite)(object)orAddComponent;
			((BraveBehaviour)val2).spriteAnimator = orAddComponent3;
			((BraveBehaviour)val2).specRigidbody = val14;
			((BraveBehaviour)orAddComponent3).transform.position = ((BraveBehaviour)val2).transform.position;
			((BraveBehaviour)orAddComponent3).transform.parent = ((BraveBehaviour)val2).transform;
			((BraveBehaviour)val2).majorBreakable.destroyedOnBreak = false;
			if (breakAnimPercentages_AND_SpritePathsandBreakDirectionsNorth != null || breakAnimPercentages_AND_SpritePathsandBreakDirectionsSouth != null || breakAnimPercentages_AND_SpritePathsandBreakDirectionsEast != null || breakAnimPercentages_AND_SpritePathsandBreakDirectionsWest != null)
			{
				List<BreakFrame> list3 = new List<BreakFrame>();
				if (breakAnimPercentages_AND_SpritePathsandBreakDirectionsNorth != null)
				{
					foreach (KeyValuePair<float, string> item15 in breakAnimPercentages_AND_SpritePathsandBreakDirectionsNorth)
					{
						BreakFrame item10 = default(BreakFrame);
						item10.healthPercentage = item15.Key;
						int num4 = SpriteBuilder.AddSpriteToCollection(item15.Value, val4, (Assembly)null);
						string text = val4.spriteDefinitions[num4].name;
						ETGModConsole.Log((object)val4.spriteDefinitions[num4].name, false);
						if (text.ToLower().Contains("north"))
						{
							text = ReturnString(text, "north");
						}
						item10.sprite = text;
						list3.Add(item10);
					}
				}
				if (breakAnimPercentages_AND_SpritePathsandBreakDirectionsSouth != null)
				{
					foreach (KeyValuePair<float, string> item16 in breakAnimPercentages_AND_SpritePathsandBreakDirectionsSouth)
					{
						BreakFrame item11 = default(BreakFrame);
						item11.healthPercentage = item16.Key;
						int num5 = SpriteBuilder.AddSpriteToCollection(item16.Value, val4, (Assembly)null);
						string text2 = val4.spriteDefinitions[num5].name;
						ETGModConsole.Log((object)val4.spriteDefinitions[num5].name, false);
						if (text2.ToLower().Contains("south"))
						{
							text2 = ReturnString(text2, "south");
						}
						item11.sprite = text2;
						list3.Add(item11);
					}
				}
				if (breakAnimPercentages_AND_SpritePathsandBreakDirectionsEast != null)
				{
					foreach (KeyValuePair<float, string> item17 in breakAnimPercentages_AND_SpritePathsandBreakDirectionsEast)
					{
						BreakFrame item12 = default(BreakFrame);
						item12.healthPercentage = item17.Key;
						int num6 = SpriteBuilder.AddSpriteToCollection(item17.Value, val4, (Assembly)null);
						string text3 = val4.spriteDefinitions[num6].name;
						if (text3.ToLower().Contains("east"))
						{
							text3 = ReturnString(text3, "east");
						}
						ETGModConsole.Log((object)text3, false);
						item12.sprite = text3;
						list3.Add(item12);
					}
				}
				if (breakAnimPercentages_AND_SpritePathsandBreakDirectionsWest != null)
				{
					foreach (KeyValuePair<float, string> item18 in breakAnimPercentages_AND_SpritePathsandBreakDirectionsWest)
					{
						BreakFrame item13 = default(BreakFrame);
						item13.healthPercentage = item18.Key;
						int num7 = SpriteBuilder.AddSpriteToCollection(item18.Value, val4, (Assembly)null);
						string text4 = val4.spriteDefinitions[num7].name;
						if (text4.ToLower().Contains("west"))
						{
							text4 = ReturnString(text4, "west");
						}
						ETGModConsole.Log((object)text4, false);
						item13.sprite = text4;
						list3.Add(item13);
					}
				}
				BreakFrame[] prebreakFrames = list3.ToArray();
				val2.prebreakFrames = prebreakFrames;
			}
			if (unflippedBreakAnimPercentagesAndSpritePaths != null)
			{
				List<BreakFrame> list4 = new List<BreakFrame>();
				foreach (KeyValuePair<float, string> unflippedBreakAnimPercentagesAndSpritePath in unflippedBreakAnimPercentagesAndSpritePaths)
				{
					BreakFrame item14 = default(BreakFrame);
					item14.healthPercentage = unflippedBreakAnimPercentagesAndSpritePath.Key;
					int num8 = SpriteBuilder.AddSpriteToCollection(unflippedBreakAnimPercentagesAndSpritePath.Value, val4, (Assembly)null);
					item14.sprite = val4.spriteDefinitions[num8].name;
					list4.Add(item14);
				}
				BreakFrame[] prebreakFramesUnflipped = list4.ToArray();
				val2.prebreakFramesUnflipped = prebreakFramesUnflipped;
			}
			if (IsSlideable)
			{
				GameObjectExtensions.GetOrAddComponent<SlideSurface>(((Component)val2).gameObject);
			}
			if (hasDecorations)
			{
				SurfaceDecorator orAddComponent4 = GameObjectExtensions.GetOrAddComponent<SurfaceDecorator>(((Component)val2).gameObject);
				orAddComponent4.chanceToDecorate = chanceToDecorateTable;
				orAddComponent4.parentSprite = ((Component)val2).GetComponent<tk2dSprite>();
			}
			return val2;
		}

		private static string ReturnString(string str, string oldChar)
		{
			return str.Replace(oldChar, "{0}");
		}

		private static GameObject GenerateTableOutlineObject(string name, string outlinePath, GameObject parent, tk2dSpriteCollectionData collection)
		{
			GameObject val = SpriteBuilder.SpriteFromResource(outlinePath, (GameObject)null, (Assembly)null);
			FakePrefab.MarkAsFakePrefab(val);
			((Object)val).name = name + "_Outline";
			val.layer = 0;
			((tk2dBaseSprite)val.GetComponent<tk2dSprite>()).HeightOffGround = 0.1f;
			SpriteBuilder.AddSpriteToCollection(outlinePath, collection, (Assembly)null);
			val.transform.parent = parent.transform;
			return val;
		}

		public static SpeculativeRigidbody SetUpEmptySpeculativeRigidbody(this tk2dSprite sprite, IntVector2 offset, IntVector2 dimensions)
		{
			SpeculativeRigidbody orAddComponent = GameObjectExtensions.GetOrAddComponent<SpeculativeRigidbody>(((Component)sprite).gameObject);
			orAddComponent.PixelColliders = new List<PixelCollider>();
			return orAddComponent;
		}

		public static tk2dSpriteAnimationClip AddTableAnimation(tk2dSpriteAnimator animator, tk2dSpriteCollectionData Tablecollection, string[] spritePaths, string clipName, int FPS, Vector3 colliderSize, Vector3 colliderOffset)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			tk2dSpriteAnimation val = ((Component)animator).gameObject.AddComponent<tk2dSpriteAnimation>();
			val.clips = (tk2dSpriteAnimationClip[])(object)new tk2dSpriteAnimationClip[0];
			animator.Library = val;
			tk2dSpriteAnimationClip val2 = new tk2dSpriteAnimationClip();
			val2.name = clipName;
			val2.frames = (tk2dSpriteAnimationFrame[])(object)new tk2dSpriteAnimationFrame[0];
			val2.fps = FPS;
			tk2dSpriteAnimationClip val3 = val2;
			List<tk2dSpriteAnimationFrame> list = new List<tk2dSpriteAnimationFrame>();
			for (int i = 0; i < spritePaths.Length; i++)
			{
				int num = SpriteBuilder.AddSpriteToCollection(spritePaths[i], Tablecollection, (Assembly)null);
				tk2dSpriteDefinition val4 = Tablecollection.spriteDefinitions[num];
				GunTools.ConstructOffsetsFromAnchor(val4, (Anchor)0, (Vector2?)null, false, true);
				tk2dSpriteDefinition val5 = ((!clipName.Contains("break")) ? GenerateColliderForSpriteDefinition(val4, colliderSize, colliderOffset) : GenerateNoColliderForSpriteDefinition(val4));
				list.Add(new tk2dSpriteAnimationFrame
				{
					spriteId = num,
					spriteCollection = Tablecollection
				});
			}
			val3.frames = list.ToArray();
			val3.wrapMode = (WrapMode)2;
			return val3;
		}

		private static tk2dSpriteDefinition GenerateColliderForSpriteDefinition(tk2dSpriteDefinition frameDef, Vector3 colliderSize, Vector3 colliderOffset)
		{
			//IL_000a: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			frameDef.colliderVertices = (Vector3[])(object)new Vector3[2]
			{
				new Vector3(colliderSize.x / 32f, colliderSize.y / 32f),
				new Vector3(colliderSize.x / 32f, colliderSize.y / 32f)
			};
			frameDef.collisionLayer = (CollisionLayer)6;
			frameDef.colliderConvex = false;
			frameDef.colliderType = (ColliderType)2;
			frameDef.colliderSmoothSphereCollisions = false;
			frameDef.complexGeometry = false;
			frameDef.flipped = (FlipMode)1;
			frameDef.AddOffset(new Vector2(colliderOffset.x / 32f, colliderOffset.y / 32f));
			return frameDef;
		}

		private static tk2dSpriteDefinition GenerateNoColliderForSpriteDefinition(tk2dSpriteDefinition frameDef)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			frameDef.colliderVertices = (Vector3[])(object)new Vector3[1]
			{
				new Vector3(0f, 0f)
			};
			frameDef.collisionLayer = (CollisionLayer)6;
			frameDef.colliderConvex = false;
			frameDef.colliderType = (ColliderType)1;
			frameDef.colliderSmoothSphereCollisions = false;
			frameDef.complexGeometry = false;
			frameDef.flipped = (FlipMode)1;
			return frameDef;
		}

		private static void AddOffset(this tk2dSpriteDefinition def, Vector2 offset)
		{
			//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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			float x = offset.x;
			float y = offset.y;
			if (def.colliderVertices != null && def.colliderVertices.Length != 0)
			{
				ref Vector3 reference = ref def.colliderVertices[0];
				reference += new Vector3(x, y, 0f);
			}
		}

		public static NoteDoer GenerateNoteDoer(MajorBreakable majorBreakable, Transform textboxSpawnPoint, string stringKey, bool DestroyedAfterRead = false, NoteBackgroundType noteBackgroundType = 3)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			NoteDoer val = ((Component)majorBreakable).gameObject.AddComponent<NoteDoer>();
			val.textboxSpawnPoint = textboxSpawnPoint;
			val.DestroyedOnFinish = DestroyedAfterRead;
			val.stringKey = stringKey;
			val.noteBackgroundType = noteBackgroundType;
			return val;
		}

		public static GameObject GenerateTransformObject(GameObject attacher, Vector2 attachpoint, string name = "shootPoint")
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			GameObject val = new GameObject(name);
			val.transform.parent = attacher.transform;
			val.transform.position = Vector2.op_Implicit(attachpoint);
			GameObject val2 = val;
			return ((Component)attacher.transform.Find(name)).gameObject;
		}

		public static MajorBreakable GenerateMajorBreakable(string name, string[] idleSpritePaths, int idleAnimFPS = 2, string[] breakSpritePaths = null, int breakAnimFPS = 5, float HP = 100f, string ShadowSpritePath = null, float ShadowOffsetX = 0f, float ShadowOffsetY = 0f, bool UsesCustomColliderValues = false, int ColliderSizeX = 16, int ColliderSizeY = 8, int ColliderOffsetX = 0, int ColliderOffsetY = 8, bool DistribleShards = true, VFXPool breakVFX = null, VFXPool damagedVFX = null, bool BlocksPaths = false, List<CollisionLayer> collisionLayerList = null, Dictionary<float, string> preBreakframesAndHPPercentages = null, bool usesWorldShader = true)
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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_00aa: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: 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_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Expected O, but got Unknown
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: 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_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: 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_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Expected O, but got Unknown
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Expected O, but got Unknown
			//IL_0220: 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_022e: 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_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: 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_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Expected O, but got Unknown
			//IL_0557: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0446: Expected O, but got Unknown
			//IL_05f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Expected O, but got Unknown
			//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_04af: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c4: Expected O, but got Unknown
			//IL_04ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0655: Unknown result type (might be due to invalid IL or missing references)
			//IL_0690: Unknown result type (might be due to invalid IL or missing references)
			Texture2D textureFromResource = ResourceExtractor.GetTextureFromResource(idleSpritePaths[0], (Assembly)null);
			GameObject val = SpriteBuilder.SpriteFromResource(idleSpritePaths[0], (GameObject)null, (Assembly)null);
			FakePrefab.MarkAsFakePrefab(val);
			((Object)val).name = name;
			MajorBreakable val2 = val.AddComponent<MajorBreakable>();
			tk2dSpriteCollectionData val3 = SpriteBuilder.ConstructCollection(val, name + "_Collection", false);
			int num = SpriteBuilder.AddSpriteToCollection(idleSpritePaths[0], val3, (Assembly)null);
			tk2dSprite orAddComponent = GameObjectExtensions.GetOrAddComponent<tk2dSprite>(val);
			((tk2dBaseSprite)orAddComponent).SetSprite(val3, num);
			IntVector2 val4 = default(IntVector2);
			((IntVector2)(ref val4))..ctor(ColliderSizeX, ColliderSizeY);
			IntVector2 val5 = default(IntVector2);
			((IntVector2)(ref val5))..ctor(ColliderOffsetX, ColliderOffsetY);
			IntVector2 val6 = default(IntVector2);
			((IntVector2)(ref val6))..ctor(val4.x, val4.y);
			if (!UsesCustomColliderValues)
			{
				IntVector2 val7 = default(IntVector2);
				((IntVector2)(ref val7))..ctor(((Texture)textureFromResource).width, ((Texture)textureFromResource).height);
				((IntVector2)(ref val6))..ctor(val7.x, val7.y);
			}
			SpeculativeRigidbody val8 = orAddComponent.SetUpEmptySpeculativeRigidbody(val5, val6);
			if (collisionLayerList == null)
			{
				val8.PixelColliders.Add(new PixelCollider
				{
					ColliderGenerationMode = (PixelColliderGeneration)0,
					CollisionLayer = (CollisionLayer)6,
					IsTrigger = false,
					BagleUseFirstFrameOnly = false,
					SpecifyBagelFrame = string.Empty,
					BagelColliderNumber = 0,
					ManualOffsetX = val5.x,
					ManualOffsetY = val5.y,
					ManualWidth = val6.x,
					ManualHeight = val6.y,
					ManualDiameter = 0,
					ManualLeftX = 0,
					ManualLeftY = 0,
					ManualRightX = 0,
					ManualRightY = 0
				});
				val8.PixelColliders.Add(new PixelCollider
				{
					ColliderGenerationMode = (PixelColliderGeneration)0,
					CollisionLayer = (CollisionLayer)8,
					IsTrigger = false,
					BagleUseFirstFrameOnly = false,
					SpecifyBagelFrame = string.Empty,
					BagelColliderNumber = 0,
					ManualOffsetX = val5.x,
					ManualOffsetY = val5.y,
					ManualWidth = val6.x,
					ManualHeight = val6.y,
					ManualDiameter = 0,
					ManualLeftX = 0,
					ManualLeftY = 0,
					ManualRightX = 0,
					ManualRightY = 0
				});
			}
			else
			{
				foreach (CollisionLayer collisionLayer in collisionLayerList)
				{
					val8.PixelColliders.Add(new PixelCollider
					{
						ColliderGenerationMode = (PixelColliderGeneration)0,
						CollisionLayer = collisionLayer,
						IsTrigger = false,
						BagleUseFirstFrameOnly = false,
						SpecifyBagelFrame = string.Empty,
						BagelColliderNumber = 0,
						ManualOffsetX = val5.x,
						ManualOffsetY = val5.y,
						ManualWidth = val6.x,
						ManualHeight = val6.y,
						ManualDiameter = 0,
						ManualLeftX = 0,
						ManualLeftY = 0,
						ManualRightX = 0,
						ManualRightY = 0
					});
				}
			}
			tk2dSpriteAnimator orAddComponent2 = GameObjectExtensions.GetOrAddComponent<tk2dSpriteAnimator>(val);
			tk2dSpriteAnimation val9 = val.AddComponent<tk2dSpriteAnimation>();
			val9.clips = (tk2dSpriteAnimationClip[])(object)new tk2dSpriteAnimationClip[0];
			orAddComponent2.Library = val9;
			List<tk2dSpriteAnimationClip> list = new List<tk2dSpriteAnimationClip>();
			if (idleSpritePaths.Length >= 1)
			{
				tk2dSpriteAnimationClip val10 = new tk2dSpriteAnimationClip();
				val10.name = "idle";
				val10.frames = (tk2dSpriteAnimationFrame[])(object)new tk2dSpriteAnimationFrame[0];
				val10.fps = idleAnimFPS;
				tk2dSpriteAnimationClip val11 = val10;
				List<tk2dSpriteAnimationFrame> list2 = new List<tk2dSpriteAnimationFrame>();
				for (int i = 0; i < idleSpritePaths.Length; i++)
				{
					tk2dSpriteCollectionData val12 = val3;
					int num2 = SpriteBuilder.AddSpriteToCollection(idleSpritePaths[i], val12, (Assembly)null);
					tk2dSpriteDefinition val13 = val12.spriteDefinitions[num2];
					list2.Add(new tk2dSpriteAnimationFrame
					{
						spriteId = num2,
						spriteCollection = val12
					});
					GunTools.ConstructOffsetsFromAnchor(val13, (Anchor)0, (Vector2?)null, false, true);
				}
				val11.frames = list2.ToArray();
				val11.wrapMode = (WrapMode)0;
				orAddComponent2.Library.clips = val9.clips.Concat((IEnumerable<tk2dSpriteAnimationClip>)(object)new tk2dSpriteAnimationClip[1] { val11 }).ToArray();
				orAddComponent2.playAutomatically = true;
				orAddComponent2.DefaultClipId = orAddComponent2.GetClipIdByName("idle");
				list.Add(val11);
			}
			if (breakSpritePaths != null)
			{
				val.AddComponent<tk2dSpriteAnimation>().clips = (tk2dSpriteAnimationClip[])(object)new tk2dSpriteAnimationClip[0];
				tk2dSpriteAnimationClip val10 = new tk2dSpriteAnimationClip();
				val10.name = "break";
				val10.frames = (tk2dSpriteAnimationFrame[])(object)new tk2dSpriteAnimationFrame[0];
				val10.fps = breakAnimFPS;
				tk2dSpriteAnimationClip val14 = val10;
				List<tk2dSpriteAnimationFrame> list3 = new List<tk2dSpriteAnimationFrame>();
				for (int j = 0; j < breakSpritePaths.Length; j++)
				{
					tk2dSpriteCollectionData val15 = val3;
					int num3 = SpriteBuilder.AddSpriteToCollection(breakSpritePaths[j], val15, (Assembly)null);
					GunTools.ConstructOffsetsFromAnchor(val15.spriteDefinitions[num3], (Anchor)0, (Vector2?)null, false, true);
					list3.Add(new tk2dSpriteAnimationFrame
					{
						spriteId = num3,
						spriteCollection = val15
					});
				}
				val14.frames = list3.ToArray();
				val14.wrapMode = (WrapMode)2;
				list.Add(val14);
				tk2dSpriteAnimationClip[] clips = list.ToArray();
				orAddComponent2.Library.clips = clips;
				orAddComponent2.playAutomatically = true;
				orAddComponent2.DefaultClipId = orAddComponent2.GetClipIdByName("idle");
				val2.breakAnimation = "break";
			}
			((BraveBehaviour)val2).sprite = (tk2dBaseSprite)(object)orAddComponent;
			((BraveBehaviour)((BraveBehaviour)val2).sprite).transform.position = ((BraveBehaviour)((BraveBehaviour)val2).sprite).transform.position;
			((BraveBehaviour)val2).specRigidbody = val8;
			((BraveBehaviour)val2).spriteAnimator = orAddComponent2;
			val2.HitPoints = HP;
			val2.HandlePathBlocking = BlocksPaths;
			if (ShadowSpritePath != null)
			{
				GameObject val16 = SpriteBuilder.SpriteFromResource(ShadowSpritePath, (GameObject)null, (Assembly)null);
				((Object)val16).name = "Shadow_" + name;
				int num4 = SpriteBuilder.AddSpriteToCollection(ShadowSpritePath, val3, (Assembly)null);
				tk2dSprite orAddComponent3 = GameObjectExtensions.GetOrAddComponent<tk2dSprite>(val16);
				((tk2dBaseSprite)orAddComponent3).SetSprite(val3, num4);
				FakePrefab.MarkAsFakePrefab(val16);
				ShadowHandler orAddComponent4 = GameObjectExtensions.GetOrAddComponent<ShadowHandler>(((Component)val2).gameObject);
				orAddComponent4.shadowObject = ((Component)orAddComponent3).gameObject;
				orAddComponent4.Offset = new Vector3(ShadowOffsetX, ShadowOffsetY);
			}
			if (breakVFX != null)
			{
				val2.breakVfx = breakVFX;
			}
			if (damagedVFX != null)
			{
				val2.damageVfx = damagedVFX;
			}
			if (preBreakframesAndHPPercentages != null)
			{
				List<BreakFrame> list4 = new List<BreakFrame>();
				foreach (KeyValuePair<float, string> preBreakframesAndHPPercentage in preBreakframesAndHPPercentages)
				{
					BreakFrame item = default(BreakFrame);
					item.healthPercentage = preBreakframesAndHPPercentage.Key;
					int num5 = SpriteBuilder.AddSpriteToCollection(preBreakframesAndHPPercentage.Value, val3, (Assembly)null);
					item.sprite = val3.spriteDefinitions[num5].name;
					list4.Add(item);
				}
				BreakFrame[] prebreakFrames = list4.ToArray();
				val2.prebreakFrames = prebreakFrames;
			}
			val2.distributeShards = DistribleShards;
			if (usesWorldShader)
			{
				((BraveBehaviour)((BraveBehaviour)val2).sprite).renderer.material.shader = worldShader;
				((BraveBehaviour)((BraveBehaviour)val2).sprite).renderer.material.EnableKeyword("BRIGHTNESS_CLAMP_ON");
			}
			return val2;
		}

		public static MinorBreakable GenerateMinorBreakable(string name, string[] idleSpritePaths, int idleAnimFPS = 1, string[] breakSpritePaths = null, int breakAnimFPS = 5, string breakAudioEvent = "Play_OBJ_pot_shatter_01", string ShadowSpritePath = null, float ShadowOffsetX = 0f, float ShadowOffsetY = -1f, bool UsesCustomColliderValues = false, int ColliderSizeX = 16, int ColliderSizeY = 8, int ColliderOffsetX = 0, int ColliderOffsetY = 8, GameObject DestroyVFX = null, List<CollisionLayer> collisionLayerList = null, bool usesWorldShader = true)
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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_00aa: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: 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_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Expected O, but got Unknown
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Expected O, but got Unknown
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: 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_019c: 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_01a3: 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_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: 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_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: 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_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Expected O, but got Unknown
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Expected O, but got Unknown
			//IL_0532: Unknown result type (might be due to invalid IL or missing references)
			//IL_0537: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Expected O, but got Unknown
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0429: Expected O, but got Unknown
			//IL_044f: Unknown result type (might be due to invalid IL or missing references)
			Texture2D textureFromResource = ResourceExtractor.GetTextureFromResource(idleSpritePaths[0], (Assembly)null);
			GameObject val = SpriteBuilder.SpriteFromResource(idleSpritePaths[0], (GameObject)null, (Assembly)null);
			FakePrefab.MarkAsFakePrefab(val);
			((Object)val).name = name;
			MinorBreakable val2 = val.AddComponent<MinorBreakable>();
			tk2dSpriteCollectionData val3 = SpriteBuilder.ConstructCollection(val, name + "_Collection", false);
			int num = SpriteBuilder.AddSpriteToCollection(idleSpritePaths[0], val3, (Assembly)null);
			tk2dSprite orAddComponent = GameObjectExtensions.GetOrAddComponent<tk2dSprite>(val);
			((tk2dBaseSprite)orAddComponent).SetSprite(val3, num);
			IntVector2 val4 = default(IntVector2);
			((IntVector2)(ref val4))..ctor(ColliderSizeX, ColliderSizeY);
			IntVector2 val5 = default(IntVector2);
			((IntVector2)(ref val5))..ctor(ColliderOffsetX, ColliderOffsetY);
			IntVector2 val6 = default(IntVector2);
			((IntVector2)(ref val6))..ctor(val4.x, val4.y);
			if (!UsesCustomColliderValues)
			{
				IntVector2 val7 = default(IntVector2);
				((IntVector2)(ref val7))..ctor(((Texture)textureFromResource).width, ((Texture)textureFromResource).height);
				((IntVector2)(ref val6))..ctor(val7.x, val7.y);
			}
			SpeculativeRigidbody val8 = orAddComponent.SetUpEmptySpeculativeRigidbody(val5, val6);
			if (collisionLayerList == null)
			{
				val8.PixelColliders.Add(new PixelCollider
				{
					ColliderGenerationMode = (PixelColliderGeneration)0,
					CollisionLayer = (CollisionLayer)6,
					IsTrigger = false,
					BagleUseFirstFrameOnly = false,
					SpecifyBagelFrame = string.Empty,
					BagelColliderNumber = 0,
					ManualOffsetX = val5.x,
					ManualOffsetY = val5.y,
					ManualWidth = val6.x,
					ManualHeight = val6.y,
					ManualDiameter = 0,
					ManualLeftX = 0,
					ManualLeftY = 0,
					ManualRightX = 0,
					ManualRightY = 0
				});
			}
			else
			{
				foreach (CollisionLayer collisionLayer in collisionLayerList)
				{
					val8.PixelColliders.Add(new PixelCollider
					{
						ColliderGenerationMode = (PixelColliderGeneration)0,
						CollisionLayer = collisionLayer,
						IsTrigger = false,
						BagleUseFirstFrameOnly = false,
						SpecifyBagelFrame = string.Empty,
						BagelColliderNumber = 0,
						ManualOffsetX = val5.x,
						ManualOffsetY = val5.y,
						ManualWidth = val6.x,
						ManualHeight = val6.y,
						ManualDiameter = 0,
						ManualLeftX = 0,
						ManualLeftY = 0,
						ManualRightX = 0,
						ManualRightY = 0
					});
				}
			}
			tk2dSpriteAnimator orAddComponent2 = GameObjectExtensions.GetOrAddComponent<tk2dSpriteAnimator>(val);
			tk2dSpriteAnimation val9 = val.AddComponent<tk2dSpriteAnimation>();
			val9.clips = (tk2dSpriteAnimationClip[])(object)new tk2dSpriteAnimationClip[0];
			orAddComponent2.Library = val9;
			List<tk2dSpriteAnimationClip> list = new List<tk2dSpriteAnimationClip>();
			if (idleSpritePaths.Length >= 1)
			{
				tk2dSpriteAnimationClip val10 = new tk2dSpriteAnimationClip();
				val10.name = "idle";
				val10.frames = (tk2dSpriteAnimationFrame[])(object)new tk2dSpriteAnimationFrame[0];
				val10.fps = idleAnimFPS;
				tk2dSpriteAnimationClip val11 = val10;
				List<tk2dSpriteAnimationFrame> list2 = new List<tk2dSpriteAnimationFrame>();
				for (int i = 0; i < idleSpritePaths.Length; i++)
				{
					tk2dSpriteCollectionData val12 = val3;
					int num2 = SpriteBuilder.AddSpriteToCollection(idleSpritePaths[i], val12, (Assembly)null);
					GunTools.ConstructOffsetsFromAnchor(val12.spriteDefinitions[num2], (Anchor)0, (Vector2?)null, false, true);
					list2.Add(new tk2dSpriteAnimationFrame
					{
						spriteId = num2,
						spriteCollection = val12
					});
				}
				val11.frames = list2.ToArray();
				val11.wrapMode = (WrapMode)0;
				orAddComponent2.Library.clips = val9.clips.Concat((IEnumerable<tk2dSpriteAnimationClip>)(object)new tk2dSpriteAnimationClip[1] { val11 }).ToArray();
				orAddComponent2.playAutomatically = true;
				orAddComponent2.DefaultClipId = orAddComponent2.GetClipIdByName("idle");
				list.Add(val11);
			}
			if (breakSpritePaths != null)
			{
				val.AddComponent<tk2dSpriteAnimation>().clips = (tk2dSpriteAnimationClip[])(object)new tk2dSpriteAnimationClip[0];
				tk2dSpriteAnimationClip val10 = new tk2dSpriteAnimationClip();
				val10.name = "break";
				val10.frames = (tk2dSpriteAnimationFrame[])(object)new tk2dSpriteAnimationFrame[0];
				val10.fps = breakAnimFPS;
				tk2dSpriteAnimationClip val13 = val10;
				List<tk2dSpriteAnimationFrame> list3 = new List<tk2dSpriteAnimationFrame>();
				for (int j = 0; j < breakSpritePaths.Length; j++)
				{
					tk2dSpriteCollectionData val14 = val3;
					int num3 = SpriteBuilder.AddSpriteToCollection(breakSpritePaths[j], val14, (Assembly)null);
					GunTools.ConstructOffsetsFromAnchor(val14.spriteDefinitions[num3], (Anchor)0, (Vector2?)null, false, true);
					list3.Add(new tk2dSpriteAnimationFrame
					{
						spriteId = num3,
						spriteCollection = val14
					});
				}
				val13.frames = list3.ToArray();
				val13.wrapMode = (WrapMode)2;
				list.Add(val13);
				tk2dSpriteAnimationClip[] clips = list.ToArray();
				orAddComponent2.Library.clips = clips;
				orAddComponent2.playAutomatically = true;
				orAddComponent2.DefaultClipId = orAddComponent2.GetClipIdByName("idle");
				val2.breakAnimName = "break";
			}
			((BraveBehaviour)val2).sprite = (tk2dBaseSprite)(object)orAddComponent;
			((BraveBehaviour)val2).specRigidbody = val8;
			((BraveBehaviour)val2).spriteAnimator = orAddComponent2;
			val2.breakAudioEventName = breakAudioEvent;
			if (ShadowSpritePath != null)
			{
				GameObject val15 = SpriteBuilder.SpriteFromResource(ShadowSpritePath, (GameObject)null, (Assembly)null);
				FakePrefab.MarkAsFakePrefab(val15);
				((Object)val15).name = "Shadow_" + name;
				int num4 = SpriteBuilder.AddSpriteToCollection(ShadowSpritePath, val3, (Assembly)null);
				tk2dSprite orAddComponent3 = GameObjectExtensions.GetOrAddComponent<tk2dSprite>(val15);
				((tk2dBaseSprite)orAddComponent3).SetSprite(val3, num4);
				ShadowHandler orAddComponent4 = GameObjectExtensions.GetOrAddComponent<ShadowHandler>(((Component)val2).gameObject);
				orAddComponent4.shadowObject = ((Component)orAddComponent3).gameObject;
				orAddComponent4.Offset = new Vector3(ShadowOffsetX, ShadowOffsetY);
			}
			if (usesWorldShader)
			{
				((BraveBehaviour)((BraveBehaviour)val2).sprite).renderer.material.shader = worldShader;
				((BraveBehaviour)((BraveBehaviour)val2).sprite).renderer.material.EnableKeyword("BRIGHTNESS_CLAMP_ON");
			}
			if ((Object)(object)DestroyVFX != (Object)null)
			{
				val2.AdditionalVFXObject = DestroyVFX;
			}
			return val2;
		}

		public static WaftingDebrisObject GenerateWaftingDebrisObject(string shardSpritePath, Vector2 waftDuration, Vector2 waftDistance, Vector2 initialBurstDuration, bool debrisObjectsCanRotate = true, float LifeSpanMin = 0.33f, float LifeSpanMax = 2f, float AngularVelocity = 540f, float AngularVelocityVariance = 180f, tk2dSprite shadowSprite = null, float Mass = 1f, string AudioEventName = null, GameObject BounceVFX = null, int DebrisBounceCount = 0, bool DoesGoopOnRest = false, GoopDefinition GoopType = null, float GoopRadius = 1f, bool usesWorldShader = true)
		{
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: 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_00f3: 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)
			GameObject val = SpriteBuilder.SpriteFromResource(shardSpritePath, (GameObject)null, (Assembly)null);
			FakePrefab.MarkAsFakePrefab(val);
			tk2dSprite component = val.GetComponent<tk2dSprite>();
			WaftingDebrisObject val2 = val.AddComponent<WaftingDebrisObject>();
			((DebrisObject)val2).canRotate = debrisObjectsCanRotate;
			((DebrisObject)val2).lifespanMin = LifeSpanMin;
			((DebrisObject)val2).lifespanMax = LifeSpanMax;
			((DebrisObject)val2).bounceCount = DebrisBounceCount;
			((DebrisObject)val2).angularVelocity = AngularVe