Decompiled source of Seppuku v1.0.0

plugins/Seppuku.dll

Decompiled 8 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using BoplFixedMath;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PoyrazBoplMod.Abilities.FreezeRay;
using PoyrazBoplMod.Abilities.SelfStab;
using PoyrazBoplMod.Core;
using PoyrazBoplMod.Shared;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace PoyrazBoplMod
{
	[BepInPlugin("com.poyraz.seppuku", "Seppuku", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "com.poyraz.seppuku";

		public const string Name = "Seppuku";

		public const string Version = "1.0.0";

		internal static ManualLogSource Log;

		internal static string PluginDir;

		private static bool loggedSounds;

		private void Awake()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			PluginDir = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			SelfStabAbility.Register();
			PatchAll(new Harmony("com.poyraz.seppuku"));
			SceneManager.sceneLoaded += OnSceneLoaded;
			AbilityRegistry.EnsureRegistered();
			Log.LogInfo((object)"Seppuku 1.0.0 yuklendi.");
		}

		private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			AbilityRegistry.EnsureRegistered();
		}

		private static void PatchAll(Harmony harmony)
		{
			foreach (Type item in from t in typeof(Plugin).Assembly.GetTypes()
				where t.GetCustomAttributes(typeof(HarmonyPatch), inherit: false).Any()
				select t)
			{
				try
				{
					harmony.CreateClassProcessor(item).Patch();
				}
				catch (Exception arg)
				{
					Log.LogError((object)$"Patch uygulanamadi: {item.FullName}\n{arg}");
				}
			}
		}
	}
}
namespace PoyrazBoplMod.UI
{
	internal sealed class AbilityGridScroll : MonoBehaviour
	{
		public const int VisibleRows = 10;

		private const float ScrollSharpness = 14f;

		private const float CircleSharpness = 22f;

		private const float GrowSharpness = 18f;

		private const float BarWidth = 22f;

		private static readonly FieldRef<AbilityGrid, AbilityGridEntry[]> gridRef = AccessTools.FieldRefAccess<AbilityGrid, AbilityGridEntry[]>("grid");

		private static readonly FieldRef<AbilityGrid, int> rowsRef = AccessTools.FieldRefAccess<AbilityGrid, int>("rows");

		private static readonly FieldRef<AbilityGrid, float> entrySizeRef = AccessTools.FieldRefAccess<AbilityGrid, float>("entrySize");

		private static readonly FieldRef<AbilityGrid, bool> keyboardMouseRef = AccessTools.FieldRefAccess<AbilityGrid, bool>("usesKeyboardAndMouse");

		private static readonly Vector2 GridPadding = new Vector2(126f, -122f);

		private static Sprite roundSprite;

		private AbilityGrid owner;

		private AbilityGridEntry[] entries;

		private RectTransform content;

		private RectTransform track;

		private RectTransform thumb;

		private Vector2 contentBase;

		private int columns;

		private int rows;

		private int visibleRows;

		private float entrySize;

		private int firstRow;

		private float offset;

		private int lastSelected = -1;

		private Vector2 circlePos;

		private float[] grow;

		private bool snap = true;

		public int FirstRow => firstRow;

		public int MaxFirstRow => Mathf.Max(0, rows - visibleRows);

		private static bool OtherModInstalled(AbilityGrid grid)
		{
			MonoBehaviour[] components = ((Component)grid).GetComponents<MonoBehaviour>();
			foreach (MonoBehaviour val in components)
			{
				if ((Object)(object)val != (Object)null && ((object)val).GetType().Name == "AbilityGridScroll" && ((object)val).GetType() != typeof(AbilityGridScroll))
				{
					return true;
				}
			}
			return false;
		}

		public static void Install(AbilityGrid grid)
		{
			if ((Object)(object)grid == (Object)null || (Object)(object)((Component)grid).GetComponent<AbilityGridScroll>() != (Object)null || OtherModInstalled(grid))
			{
				return;
			}
			AbilityGridEntry[] array = gridRef.Invoke(grid);
			if (array == null || array.Length == 0 || (Object)(object)grid.selectionCircle == (Object)null)
			{
				return;
			}
			AbilityGridScroll abilityGridScroll = ((Component)grid).gameObject.AddComponent<AbilityGridScroll>();
			try
			{
				abilityGridScroll.Build(grid, array);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Yetenek listesi kaydirma kurulamadi: " + ex));
				Object.Destroy((Object)(object)abilityGridScroll);
			}
		}

		public void SnapToSelection()
		{
			snap = true;
			lastSelected = -1;
		}

		public void ScrollBy(int rowsDelta)
		{
			firstRow = Mathf.Clamp(firstRow + rowsDelta, 0, MaxFirstRow);
		}

		private void Build(AbilityGrid grid, AbilityGridEntry[] gridEntries)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: 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_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			owner = grid;
			entries = gridEntries;
			RectTransform val = (RectTransform)((Component)grid).transform;
			Rect rect = val.rect;
			columns = Mathf.Max(1, grid.columns);
			rows = Mathf.Max(1, rowsRef.Invoke(grid));
			visibleRows = Mathf.Min(rows, 10);
			entrySize = Mathf.Sqrt(((Rect)(ref rect)).width * ((Rect)(ref rect)).height * 0.9f / (float)(columns * visibleRows));
			entrySizeRef.Invoke(grid) = entrySize;
			RectTransform val2 = NewRect("PoyrazMod_GridViewport", val);
			((Transform)val2).SetSiblingIndex(((Transform)grid.selectionCircle).GetSiblingIndex());
			content = NewRect("PoyrazMod_GridContent", val2);
			contentBase = content.anchoredPosition;
			((Transform)grid.selectionCircle).SetParent((Transform)(object)content, false);
			grow = new float[entries.Length];
			for (int i = 0; i < entries.Length; i++)
			{
				AbilityGridEntry obj = entries[i];
				((Transform)obj.rectTrans).SetParent((Transform)(object)content, false);
				int num = i / columns;
				int num2 = i % columns;
				obj.rectTrans.anchoredPosition = GridPadding + new Vector2((float)num2 * entrySize - ((Rect)(ref rect)).width / 2f, (float)(-num) * entrySize + ((Rect)(ref rect)).height / 2f);
				grow[i] = 1f;
				ApplyScale(i);
			}
			float y = VisualCenter(entries[0]).y;
			float num3 = y - (float)(visibleRows - 1) * entrySize;
			float num4 = y + entrySize * 0.64f;
			float num5 = num3 - entrySize * 0.55f;
			RectMask2D obj2 = ((Component)val2).gameObject.AddComponent<RectMask2D>();
			obj2.padding = new Vector4(-400f, num5 - ((Rect)(ref rect)).yMin, -400f, ((Rect)(ref rect)).yMax - num4);
			obj2.softness = new Vector2Int(0, Mathf.RoundToInt(entrySize * 0.08f));
			if (rows > visibleRows)
			{
				BuildScrollbar(val, VisualCenter(entries[Mathf.Min(columns, entries.Length) - 1]).x + entrySize * 0.75f, num4, num5);
			}
		}

		private static RectTransform NewRect(string name, RectTransform parent)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			RectTransform val = (RectTransform)new GameObject(name, new Type[1] { typeof(RectTransform) }).transform;
			((Transform)val).SetParent((Transform)(object)parent, false);
			val.anchorMin = Vector2.zero;
			val.anchorMax = Vector2.one;
			val.pivot = parent.pivot;
			val.offsetMin = Vector2.zero;
			val.offsetMax = Vector2.zero;
			return val;
		}

		private Vector2 VisualCenter(AbilityGridEntry e)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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)
			RectTransform rectTrans = e.rectTrans;
			Rect rect = rectTrans.rect;
			Vector2 val = Vector2.Scale(((Rect)(ref rect)).size, Vector2.op_Implicit(((Transform)rectTrans).localScale));
			return Vector2.op_Implicit(((Transform)rectTrans).localPosition) + Vector2.Scale(new Vector2(0.5f, 0.5f) - rectTrans.pivot, val);
		}

		private void BuildScrollbar(RectTransform parent, float x, float top, float bottom)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			float num = entrySize * 0.25f;
			track = NewBar("PoyrazMod_GridScrollbar", parent, new Color(0f, 0f, 0f, 0.22f));
			RectTransform obj = track;
			RectTransform obj2 = track;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0.5f, 0.5f);
			obj2.anchorMax = val;
			obj.anchorMin = val;
			track.sizeDelta = new Vector2(22f, top - bottom - num * 2f);
			((Transform)track).localPosition = new Vector3(x, (top + bottom) / 2f, 0f);
			thumb = NewBar("Thumb", track, new Color(1f, 1f, 1f, 0.9f));
			RectTransform obj3 = thumb;
			RectTransform obj4 = thumb;
			((Vector2)(ref val))..ctor(0.5f, 1f);
			obj4.anchorMax = val;
			obj3.anchorMin = val;
			thumb.pivot = new Vector2(0.5f, 1f);
		}

		private static RectTransform NewBar(string name, RectTransform parent, Color color)
		{
			//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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			RectTransform val2 = (RectTransform)val.transform;
			((Transform)val2).SetParent((Transform)(object)parent, false);
			Image obj = val.AddComponent<Image>();
			obj.sprite = RoundSprite();
			obj.type = (Type)1;
			((Graphic)obj).color = color;
			((Graphic)obj).raycastTarget = false;
			return val2;
		}

		private static Sprite RoundSprite()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)roundSprite != (Object)null)
			{
				return roundSprite;
			}
			Texture2D val = new Texture2D(32, 32, (TextureFormat)4, false);
			Color[] array = (Color[])(object)new Color[1024];
			for (int i = 0; i < 32; i++)
			{
				for (int j = 0; j < 32; j++)
				{
					float num = (float)j + 0.5f - 16f;
					float num2 = (float)i + 0.5f - 16f;
					float num3 = Mathf.Clamp01(16f - Mathf.Sqrt(num * num + num2 * num2));
					array[i * 32 + j] = new Color(1f, 1f, 1f, num3);
				}
			}
			val.SetPixels(array);
			val.Apply();
			((Texture)val).wrapMode = (TextureWrapMode)1;
			((Object)val).hideFlags = (HideFlags)32;
			roundSprite = Sprite.Create(val, new Rect(0f, 0f, 32f, 32f), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4(15f, 15f, 15f, 15f));
			((Object)roundSprite).hideFlags = (HideFlags)32;
			return roundSprite;
		}

		private void ApplyScale(int i)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			RectTransform rectTrans = entries[i].rectTrans;
			Rect rect = rectTrans.rect;
			float num = owner.nonSelectedScale * grow[i] * entrySize;
			((Transform)rectTrans).localScale = new Vector3(num / ((Rect)(ref rect)).width, num / ((Rect)(ref rect)).height, 1f);
		}

		private static float Approach(float k, float dt)
		{
			return 1f - Mathf.Exp((0f - k) * dt);
		}

		private void LateUpdate()
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: 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_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)owner == (Object)null || (Object)(object)content == (Object)null || !((Behaviour)owner).enabled)
			{
				return;
			}
			float unscaledDeltaTime = Time.unscaledDeltaTime;
			int num = Mathf.Clamp(owner.SelectedIcon, 0, entries.Length - 1);
			if (keyboardMouseRef.Invoke(owner) && Mouse.current != null)
			{
				float y = ((InputControl<Vector2>)(object)Mouse.current.scroll).ReadValue().y;
				if (y > 0.01f)
				{
					firstRow--;
				}
				else if (y < -0.01f)
				{
					firstRow++;
				}
			}
			if (num != lastSelected)
			{
				int num2 = num / columns;
				if (num2 < firstRow)
				{
					firstRow = num2;
				}
				else if (num2 > firstRow + visibleRows - 1)
				{
					firstRow = num2 - visibleRows + 1;
				}
				lastSelected = num;
			}
			firstRow = Mathf.Clamp(firstRow, 0, MaxFirstRow);
			float num3 = (float)firstRow * entrySize;
			offset = (snap ? num3 : Mathf.Lerp(offset, num3, Approach(14f, unscaledDeltaTime)));
			if (Mathf.Abs(offset - num3) < 0.5f)
			{
				offset = num3;
			}
			content.anchoredPosition = contentBase + new Vector2(0f, offset);
			float num4 = ((owner.nonSelectedScale > 0.0001f) ? (owner.selectedScale / owner.nonSelectedScale) : 1f);
			float num5 = (snap ? 1f : Approach(18f, unscaledDeltaTime));
			for (int i = 0; i < entries.Length; i++)
			{
				if (!((Object)(object)entries[i] == (Object)null))
				{
					grow[i] = Mathf.Lerp(grow[i], (i == num) ? num4 : 1f, num5);
					ApplyScale(i);
				}
			}
			Vector2 anchoredPosition = entries[num].rectTrans.anchoredPosition;
			circlePos = (snap ? anchoredPosition : Vector2.Lerp(circlePos, anchoredPosition, Approach(22f, unscaledDeltaTime)));
			owner.selectionCircle.anchoredPosition = circlePos;
			UpdateScrollbar();
			snap = false;
		}

		private void UpdateScrollbar()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)track == (Object)null))
			{
				Rect rect = track.rect;
				float height = ((Rect)(ref rect)).height;
				float num = Mathf.Max(height * (float)visibleRows / (float)rows, 44f);
				float num2 = ((MaxFirstRow > 0) ? Mathf.Clamp01(offset / ((float)MaxFirstRow * entrySize)) : 0f);
				thumb.sizeDelta = new Vector2(22f, num);
				thumb.anchoredPosition = new Vector2(0f, (0f - (height - num)) * num2);
			}
		}
	}
	[HarmonyPatch(typeof(AbilityGrid), "Awake")]
	internal static class Patch_AbilityGrid_Awake
	{
		private static void Postfix(AbilityGrid __instance)
		{
			AbilityGridScroll.Install(__instance);
		}
	}
	[HarmonyPatch(typeof(AbilityGrid), "Init")]
	internal static class Patch_AbilityGrid_Init
	{
		private static void Postfix(AbilityGrid __instance)
		{
			AbilityGridScroll component = ((Component)__instance).GetComponent<AbilityGridScroll>();
			if ((Object)(object)component != (Object)null)
			{
				component.SnapToSelection();
			}
		}
	}
}
namespace PoyrazBoplMod.Shared
{
	internal static class SpaceTrash
	{
		internal enum Mode
		{
			Heating,
			Glitch,
			Gone
		}

		internal sealed class State
		{
			public StickyRoundedRectangle Platform;

			public GameObject Go;

			public Mode Mode;

			public Fix Heat;

			public Fix T;

			public Fix Respawn;

			public int Owner;

			public int Booms;

			public bool HitThisTick;

			public Vec2 HitPoint;

			public SpaceTrashLook Look;
		}

		public static readonly Fix HeatToExplode = (Fix)1.6;

		public static readonly Fix CoolRate = (Fix)0.6;

		public static readonly Fix GlitchBoom1 = (Fix)0.55;

		public static readonly Fix GlitchBoom2 = (Fix)1.15;

		public static readonly Fix BlastScale = (Fix)1.25;

		public static readonly Fix SmallBlastScale = (Fix)0.85;

		public static readonly Fix RespawnTime = (Fix)10L;

		public static readonly Fix RespawnRetry = (Fix)0.5;

		private static readonly List<State> states = new List<State>();

		private static int lastTick = -1;

		private static Explosion explosionPrefab;

		internal static int DebugExplosions;

		internal static int DebugBlasts;

		internal static int DebugGlitches;

		internal static int DebugRespawns;

		public static bool Is(StickyRoundedRectangle p)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Invalid comparison between Unknown and I4
			if ((Object)(object)p != (Object)null && !((MonoUpdatable)p).IsDestroyed && (int)p.platformType == 4 && (Object)(object)((Component)p).GetComponent<Boulder>() == (Object)null)
			{
				return ((Component)p).gameObject.activeInHierarchy;
			}
			return false;
		}

		internal static State Find(StickyRoundedRectangle p)
		{
			foreach (State state in states)
			{
				if ((Object)(object)state.Platform == (Object)(object)p)
				{
					return state;
				}
			}
			return null;
		}

		private static State Get(StickyRoundedRectangle p)
		{
			State state = Find(p);
			if (state != null)
			{
				return state;
			}
			state = new State
			{
				Platform = p,
				Go = ((Component)p).gameObject,
				Mode = Mode.Heating
			};
			state.Look = SpaceTrashLook.Attach(p);
			states.Add(state);
			return state;
		}

		public static void BeamHit(StickyRoundedRectangle p, int owner, Vec2 at)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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)
			if (!Is(p))
			{
				return;
			}
			State state = Get(p);
			if (state.Mode == Mode.Heating)
			{
				state.Owner = owner;
				state.HitPoint = at;
				if (!state.HitThisTick)
				{
					state.HitThisTick = true;
					state.Heat += GameTime.FixedTimeStep;
				}
			}
		}

		public static void FreezeHit(StickyRoundedRectangle p, int owner)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if (Is(p))
			{
				State state = Get(p);
				if (state.Mode == Mode.Heating)
				{
					state.Mode = Mode.Glitch;
					state.T = Fix.Zero;
					state.Booms = 0;
					state.Owner = owner;
					DebugGlitches++;
					state.Look?.StartGlitch();
				}
			}
		}

		public static void Tick(Fix dt, bool timeStopped)
		{
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: 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_01ad: 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_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: 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_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: 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_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: 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_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: 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_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: 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_0218: Unknown result type (might be due to invalid IL or missing references)
			int simulationTicks = Updater.SimulationTicks;
			if (simulationTicks == lastTick || states.Count == 0)
			{
				return;
			}
			lastTick = simulationTicks;
			for (int num = states.Count - 1; num >= 0; num--)
			{
				State state = states[num];
				if ((Object)(object)state.Go == (Object)null || (Object)(object)state.Platform == (Object)null || ((MonoUpdatable)state.Platform).IsDestroyed)
				{
					state.Look?.Remove();
					states.RemoveAt(num);
				}
				else
				{
					switch (state.Mode)
					{
					case Mode.Heating:
					{
						if (!state.HitThisTick && !timeStopped)
						{
							state.Heat -= dt * CoolRate;
						}
						state.HitThisTick = false;
						if (state.Heat <= Fix.Zero)
						{
							state.Look?.Remove();
							states.RemoveAt(num);
							break;
						}
						Fix val = state.Heat / HeatToExplode;
						if (val > (Fix)0.4)
						{
							ShakablePlatform component = ((Component)state.Platform).GetComponent<ShakablePlatform>();
							if (component != null)
							{
								component.AddShake((Fix)0.1, (val - (Fix)0.4) * (Fix)0.25, 3, (Material)null, (AnimationCurveFixed)null);
							}
						}
						if (state.Heat >= HeatToExplode)
						{
							Blast(state);
						}
						break;
					}
					case Mode.Glitch:
						if (!timeStopped)
						{
							state.T += dt;
							ShakablePlatform component2 = ((Component)state.Platform).GetComponent<ShakablePlatform>();
							if (component2 != null)
							{
								component2.AddShake((Fix)0.1, (Fix)0.12, 3, (Material)null, (AnimationCurveFixed)null);
							}
							if (state.Booms == 0 && state.T >= GlitchBoom1)
							{
								state.Booms = 1;
								Explode(Center(state.Platform), SmallBlastScale, state.Owner);
								state.Look?.SmallBoom();
							}
							if (state.T >= GlitchBoom2)
							{
								Blast(state);
							}
						}
						break;
					case Mode.Gone:
						if (!timeStopped)
						{
							state.Respawn -= dt;
						}
						if (!(state.Respawn > Fix.Zero))
						{
							if (PlayerInTheWay(state.Platform))
							{
								state.Respawn = RespawnRetry;
								break;
							}
							state.Go.SetActive(true);
							DebugRespawns++;
							state.Look?.WarpIn();
							states.RemoveAt(num);
						}
						break;
					}
				}
			}
		}

		private static void Blast(State s)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			StickyRoundedRectangle platform = s.Platform;
			Vec2 val = Center(platform);
			Vec2 val2 = default(Vec2);
			((Vec2)(ref val2))..ctor(platform.rr.rotation);
			Fix val3 = platform.rr.CalcExtents().x + platform.rr.radius;
			for (int i = -1; i <= 1; i++)
			{
				Explode(val + val2 * (val3 * (Fix)0.65 * (Fix)(long)i), BlastScale, s.Owner);
			}
			DebugBlasts++;
			s.Look?.Blast();
			s.Mode = Mode.Gone;
			s.Respawn = RespawnTime;
			s.Heat = Fix.Zero;
			((Component)platform).gameObject.SetActive(false);
		}

		private static Vec2 Center(StickyRoundedRectangle p)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return p.rr.position;
		}

		private static void Explode(Vec2 pos, Fix scale, int owner)
		{
			//IL_0011: 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)
			Explosion val = ExplosionPrefab();
			if (!((Object)(object)val == (Object)null))
			{
				Explosion obj = FixTransform.InstantiateFixed<Explosion>(val, pos);
				IPhysicsCollider component = ((Component)obj).GetComponent<IPhysicsCollider>();
				if (component != null)
				{
					component.Scale = scale;
				}
				obj.PlayerOwnerId = owner;
				DebugExplosions++;
			}
		}

		private static Explosion ExplosionPrefab()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)explosionPrefab != (Object)null)
			{
				return explosionPrefab;
			}
			NamedSpriteList val = (((Object)(object)SteamManager.instance != (Object)null) ? SteamManager.instance.abilityIcons : null);
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			foreach (NamedSprite sprite in val.sprites)
			{
				ThrowItem2 val2 = (((Object)(object)sprite.associatedGameObject != (Object)null) ? sprite.associatedGameObject.GetComponent<ThrowItem2>() : null);
				GrenadeExplode val3 = (((Object)(object)val2 != (Object)null && (Object)(object)val2.ItemPrefab != (Object)null) ? ((Component)val2.ItemPrefab).GetComponent<GrenadeExplode>() : null);
				if ((Object)(object)val3 != (Object)null && (Object)(object)val3.explosion != (Object)null)
				{
					return explosionPrefab = val3.explosion;
				}
			}
			return null;
		}

		private static bool PlayerInTheWay(StickyRoundedRectangle platform)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_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)
			Fix val = (Fix)1.2;
			foreach (Player item in PlayerHandler.Get().PlayerList())
			{
				if (item != null && item.IsAlive)
				{
					Vec2 position = item.Position;
					if (platform.ContainsPoint(position) || Vec2.Distance(platform.GetClosestPoint(position), position) < val)
					{
						return true;
					}
				}
			}
			return false;
		}

		public static void ResetAll()
		{
			states.Clear();
			lastTick = -1;
		}

		internal static float HeatOf(StickyRoundedRectangle p)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//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)
			State state = Find(p);
			if (state == null || state.Mode != Mode.Heating)
			{
				return 0f;
			}
			return Mathf.Clamp01((float)(state.Heat / HeatToExplode));
		}

		internal static bool DebugIsGone(StickyRoundedRectangle p)
		{
			State state = Find(p);
			if (state == null)
			{
				return false;
			}
			return state.Mode == Mode.Gone;
		}

		internal static void DebugSetRespawn(StickyRoundedRectangle p, Fix t)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			State state = Find(p);
			if (state != null && state.Mode == Mode.Gone)
			{
				state.Respawn = t;
			}
		}
	}
	internal sealed class SpaceTrashLook : MonoBehaviour
	{
		private StickyRoundedRectangle platform;

		private SpriteRenderer ren;

		private SpriteRenderer hot;

		private SpriteRenderer fill;

		private SpriteRenderer cyan;

		private SpriteRenderer red;

		private SpriteRenderer glow;

		private float t;

		private float smokeTimer;

		private float sparkTimer;

		private float errorTimer;

		private float warp = -1f;

		private bool glitching;

		private bool removing;

		private int errorBeeps;

		private static Sprite square;

		private static Sprite capsule;

		private static Sprite Square
		{
			get
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Expected O, but got Unknown
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)square != (Object)null)
				{
					return square;
				}
				Texture2D val = new Texture2D(4, 4, (TextureFormat)4, false);
				Color[] array = (Color[])(object)new Color[16];
				for (int i = 0; i < 16; i++)
				{
					array[i] = Color.white;
				}
				val.SetPixels(array);
				val.Apply();
				((Texture)val).filterMode = (FilterMode)0;
				square = Sprite.Create(val, new Rect(0f, 0f, 4f, 4f), new Vector2(0.5f, 0.5f), 4f);
				((Object)square).hideFlags = (HideFlags)32;
				return square;
			}
		}

		private static Sprite Capsule
		{
			get
			{
				//IL_00df: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
				//IL_010c: Unknown result type (might be due to invalid IL or missing references)
				//IL_011b: Unknown result type (might be due to invalid IL or missing references)
				//IL_012a: Expected O, but got Unknown
				//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)capsule != (Object)null)
				{
					return capsule;
				}
				Color[] array = (Color[])(object)new Color[16384];
				for (int i = 0; i < 64; i++)
				{
					for (int j = 0; j < 256; j++)
					{
						float num = Mathf.Clamp((float)j + 0.5f, 32f, 224f);
						float num2 = (float)j + 0.5f - num;
						float num3 = (float)i + 0.5f - 32f;
						float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3) / 32f;
						array[i * 256 + j] = new Color(1f, 1f, 1f, Mathf.Clamp01((1f - num4) * 6f) * Mathf.Lerp(1f, 0.75f, num4));
					}
				}
				Texture2D val = new Texture2D(256, 64, (TextureFormat)4, false);
				val.SetPixels(array);
				val.Apply();
				((Texture)val).wrapMode = (TextureWrapMode)1;
				capsule = Sprite.Create(val, new Rect(0f, 0f, 256f, 64f), new Vector2(0.5f, 0.5f), 256f);
				((Object)capsule).hideFlags = (HideFlags)32;
				return capsule;
			}
		}

		private float Size
		{
			get
			{
				//IL_001a: 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_0022: 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)
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)ren != (Object)null))
				{
					return 4f;
				}
				Bounds bounds = ((Renderer)ren).bounds;
				float x = ((Bounds)(ref bounds)).size.x;
				bounds = ((Renderer)ren).bounds;
				return Mathf.Max(x, ((Bounds)(ref bounds)).size.y);
			}
		}

		public static SpaceTrashLook Attach(StickyRoundedRectangle p)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			SpaceTrashLook componentInChildren = ((Component)p).GetComponentInChildren<SpaceTrashLook>(true);
			if ((Object)(object)componentInChildren != (Object)null)
			{
				componentInChildren.removing = false;
				return componentInChildren;
			}
			GameObject val = new GameObject("PoyrazMod_SpaceTrashLook");
			val.transform.SetParent(((Component)p).transform, false);
			SpaceTrashLook spaceTrashLook = val.AddComponent<SpaceTrashLook>();
			spaceTrashLook.platform = p;
			spaceTrashLook.Setup();
			return spaceTrashLook;
		}

		private void Setup()
		{
			//IL_0104: 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_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: 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_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: 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)
			ren = ((Component)platform).GetComponent<SpriteRenderer>();
			if (!((Object)(object)ren == (Object)null))
			{
				int sortingLayerID = ((Renderer)ren).sortingLayerID;
				int sortingOrder = ((Renderer)ren).sortingOrder;
				glow = Make("Glow", IceArt.Glow, sortingLayerID, sortingOrder - 1);
				hot = Make("Hot", ren.sprite, sortingLayerID, sortingOrder + 2);
				fill = Make("HotFill", Capsule, sortingLayerID, sortingOrder + 3);
				SpriteRenderer obj = fill;
				bool flipX = (fill.flipY = false);
				obj.flipX = flipX;
				cyan = Make("GlitchA", ren.sprite, sortingLayerID, sortingOrder + 4);
				red = Make("GlitchB", ren.sprite, sortingLayerID, sortingOrder + 4);
				SpriteRenderer obj2 = hot;
				SpriteRenderer obj3 = fill;
				SpriteRenderer obj4 = cyan;
				SpriteRenderer obj5 = red;
				Color val = (glow.color = Color.clear);
				Color val2 = (obj5.color = val);
				Color val4 = (obj4.color = val2);
				Color color = (obj3.color = val4);
				obj2.color = color;
			}
		}

		private SpriteRenderer Make(string name, Sprite sprite, int layer, int order)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(((Component)this).transform, false);
			SpriteRenderer obj = val.AddComponent<SpriteRenderer>();
			obj.sprite = sprite;
			((Renderer)obj).sharedMaterial = IceArt.DefaultSpriteMaterial;
			((Renderer)obj).sortingLayerID = layer;
			((Renderer)obj).sortingOrder = order;
			obj.flipX = (Object)(object)ren != (Object)null && ren.flipX;
			obj.flipY = (Object)(object)ren != (Object)null && ren.flipY;
			return obj;
		}

		private void FitFill()
		{
			//IL_002d: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: 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)
			if (!((Object)(object)platform == (Object)null) && !((Object)(object)platform.rr == (Object)null))
			{
				Vec2 val = platform.rr.CalcExtents();
				float num = (float)platform.rr.radius;
				float num2 = ((float)val.x + num) * 2f;
				float num3 = ((float)val.y + num) * 2f;
				Vector3 lossyScale = ((Component)this).transform.lossyScale;
				float num4 = Mathf.Max(0.001f, Mathf.Abs(lossyScale.x));
				float num5 = Mathf.Max(0.001f, Mathf.Abs(lossyScale.y));
				((Component)fill).transform.localScale = new Vector3(num2 * 0.97f / num4, num3 * 0.9f / 0.25f / num5, 1f);
				((Component)fill).transform.localPosition = ((Component)this).transform.InverseTransformPoint(Vector2.op_Implicit((Vector2)platform.rr.position)) - Vector3.zero;
			}
		}

		public void Remove()
		{
			if ((Object)(object)this != (Object)null)
			{
				removing = true;
			}
		}

		public void StartGlitch()
		{
			glitching = true;
			errorBeeps = 0;
			errorTimer = 0f;
		}

		private static void GameSound(string name, float pitchVariation = 0.1f)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			AudioManager val = AudioManager.Get();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Sound[] sounds = val.sounds;
			for (int i = 0; i < sounds.Length; i++)
			{
				if (sounds[i].name == name)
				{
					val.Play(name, 0f, pitchVariation);
					break;
				}
			}
		}

		private Vector3 RandomPointOn()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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)
			Bounds val = (Bounds)(((Object)(object)ren != (Object)null) ? ((Renderer)ren).bounds : new Bounds(((Component)this).transform.position, Vector3.one));
			Vector3 right = ((Component)platform).transform.right;
			float num = Mathf.Max(((Bounds)(ref val)).extents.x, ((Bounds)(ref val)).extents.y) * 0.85f;
			return ((Component)platform).transform.position + right * VisualRandom.Range(0f - num, num) + Vector2.op_Implicit(VisualRandom.InsideUnitCircle() * 0.4f);
		}

		private void LateUpdate()
		{
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: 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_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0505: Unknown result type (might be due to invalid IL or missing references)
			//IL_049a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_050a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0531: Unknown result type (might be due to invalid IL or missing references)
			//IL_0543: Unknown result type (might be due to invalid IL or missing references)
			//IL_0553: Unknown result type (might be due to invalid IL or missing references)
			//IL_0555: Unknown result type (might be due to invalid IL or missing references)
			//IL_057c: Unknown result type (might be due to invalid IL or missing references)
			//IL_058f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0594: Unknown result type (might be due to invalid IL or missing references)
			//IL_0595: Unknown result type (might be due to invalid IL or missing references)
			//IL_059c: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0628: Unknown result type (might be due to invalid IL or missing references)
			//IL_0666: Unknown result type (might be due to invalid IL or missing references)
			//IL_0673: Unknown result type (might be due to invalid IL or missing references)
			//IL_0687: Unknown result type (might be due to invalid IL or missing references)
			//IL_068c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0696: Unknown result type (might be due to invalid IL or missing references)
			//IL_069b: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)platform == (Object)null || ((MonoUpdatable)platform).IsDestroyed || (Object)(object)ren == (Object)null)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			float deltaTime = Time.deltaTime;
			t += deltaTime;
			int num = SortingLayer.NameToID("explosion");
			if (warp >= 0f)
			{
				warp += deltaTime;
				float num2 = 1f - Mathf.Clamp01(warp / 0.6f);
				cyan.color = new Color(0.4f, 1f, 1f, 0.8f * num2);
				((Component)cyan).transform.localPosition = Vector3.zero;
				red.color = Color.clear;
				hot.color = Color.clear;
				fill.color = Color.clear;
				glow.color = new Color(0.4f, 1f, 1f, 0.5f * num2);
				SetGlowSize(1.3f);
				if (warp >= 0.6f)
				{
					warp = -1f;
					if (removing || SpaceTrash.Find(platform) == null)
					{
						Object.Destroy((Object)(object)((Component)this).gameObject);
					}
				}
				return;
			}
			if (glitching)
			{
				bool flag = Mathf.Repeat(t * 23f, 1f) < 0.7f;
				float num3 = 0.25f;
				((Component)cyan).transform.localPosition = new Vector3(VisualRandom.Range(0f - num3, num3), VisualRandom.Range((0f - num3) * 0.5f, num3 * 0.5f), 0f);
				((Component)red).transform.localPosition = new Vector3(VisualRandom.Range(0f - num3, num3), VisualRandom.Range((0f - num3) * 0.5f, num3 * 0.5f), 0f);
				fill.color = Color.clear;
				cyan.color = new Color(0f, 1f, 1f, flag ? 0.55f : 0.1f);
				red.color = new Color(1f, 0f, 0.4f, flag ? 0.55f : 0.15f);
				hot.color = ((VisualRandom.Range(0f, 1f) < 0.15f) ? new Color(1f, 1f, 1f, 0.7f) : new Color(1f, 0.1f, 0.1f, 0.25f));
				glow.color = new Color(1f, 0.1f, 0.2f, 0.35f + 0.25f * Mathf.Sin(t * 40f));
				SetGlowSize(1.2f);
				if (VisualRandom.Range(0f, 1f) < deltaTime * 40f)
				{
					Color color = ((VisualRandom.Range(0f, 1f) < 0.5f) ? new Color(0f, 1f, 1f, 0.9f) : new Color(1f, 0f, 0.45f, 0.9f));
					Debris debris = Debris.Spawn(Square, RandomPointOn(), VisualRandom.Range(0.15f, 0.5f), color, num, 20);
					debris.GrowX = VisualRandom.Range(1f, 4f);
					debris.MaxLife = VisualRandom.Range(0.05f, 0.15f);
				}
				errorTimer -= deltaTime;
				if (errorTimer <= 0f && errorBeeps < 3)
				{
					errorTimer = 0.2f;
					errorBeeps++;
					GameSound("smallError", 0.05f);
				}
				Sparks(deltaTime * 30f, num);
				return;
			}
			float num4 = SpaceTrash.HeatOf(platform);
			if (removing && num4 <= 0f)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			float num5 = 0.85f + 0.15f * Mathf.Sin(t * 30f + Mathf.Sin(t * 7f) * 3f);
			Color val = ((num4 < 0.6f) ? Color.Lerp(new Color(0.75f, 0.05f, 0.02f, 1f), new Color(1f, 0.18f, 0.05f, 1f), num4 / 0.6f) : Color.Lerp(new Color(1f, 0.18f, 0.05f, 1f), new Color(1f, 0.75f, 0.35f, 1f), (num4 - 0.6f) / 0.4f));
			val.a = Mathf.Clamp01(Mathf.Pow(num4, 0.6f) * 1.05f * num5);
			hot.color = val;
			((Component)hot).transform.localPosition = Vector3.zero;
			FitFill();
			Color color2 = val;
			color2.a = Mathf.Clamp01(Mathf.Pow(num4, 0.9f) * 0.62f * num5);
			fill.color = color2;
			SpriteRenderer obj = cyan;
			Color color3 = (red.color = Color.clear);
			obj.color = color3;
			glow.color = new Color(1f, 0.2f, 0.05f, Mathf.Clamp01(0.9f * num4 * num5));
			SetGlowSize(1.3f + 0.5f * num4);
			smokeTimer -= deltaTime;
			if (smokeTimer <= 0f && num4 > 0.08f)
			{
				smokeTimer = Mathf.Lerp(0.25f, 0.05f, num4);
				Debris debris2 = Debris.Spawn(IceArt.Glow, RandomPointOn(), VisualRandom.Range(0.8f, 1.4f) * (0.7f + num4 * 0.6f), new Color(0.16f, 0.15f, 0.15f, 0.35f + 0.25f * num4), num, 2);
				debris2.Velocity = Vector2.up * VisualRandom.Range(1.5f, 3f) + VisualRandom.InsideUnitCircle() * 0.6f;
				debris2.Drag = 0.8f;
				debris2.Growth = 1.3f;
				debris2.MaxLife = VisualRandom.Range(0.9f, 1.5f);
				debris2.FadeIn = 0.1f;
				debris2.FadeStart = 0.3f;
			}
			Sparks(deltaTime * 25f * num4, num);
		}

		private void SetGlowSize(float k)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			float num = Size * k;
			Bounds bounds = IceArt.Glow.bounds;
			float num2 = num / Mathf.Max(0.001f, ((Bounds)(ref bounds)).size.x) / Mathf.Max(0.001f, Mathf.Abs(((Component)this).transform.lossyScale.x));
			((Component)glow).transform.localScale = new Vector3(num2, num2 * 0.6f, 1f);
		}

		private void Sparks(float chance, int layer)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			if (!(VisualRandom.Range(0f, 1f) >= chance))
			{
				Debris debris = Debris.Spawn(IceArt.Glow, RandomPointOn(), VisualRandom.Range(0.12f, 0.22f), new Color(1f, 0.8f, 0.3f, 1f), layer, 22);
				debris.Velocity = new Vector2(VisualRandom.Range(-5f, 5f), VisualRandom.Range(3f, 9f));
				debris.Gravity = 20f;
				debris.MaxLife = VisualRandom.Range(0.3f, 0.6f);
				debris.Stretch = true;
			}
		}

		public void SmallBoom()
		{
			//IL_002e: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)this == (Object)null) && !((Object)(object)platform == (Object)null))
			{
				int num = SortingLayer.NameToID("explosion");
				Vector3 position = ((Component)platform).transform.position;
				Debris debris = Debris.Spawn(IceArt.Glow, position, Size * 0.7f, new Color(1f, 0.85f, 0.6f, 0.9f), num, 25);
				debris.Growth = 2f;
				debris.MaxLife = 0.25f;
				for (int i = 0; i < 18; i++)
				{
					Sparks(1f, num);
				}
				GameSound("explosion");
				IceVisuals.ShakeCamera(0.45f);
			}
		}

		public void Blast()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: 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_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: 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_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: 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_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: 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_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0404: Unknown result type (might be due to invalid IL or missing references)
			//IL_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_040e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)this == (Object)null) && !((Object)(object)platform == (Object)null))
			{
				glitching = false;
				int num = SortingLayer.NameToID("explosion");
				Vector3 position = ((Component)platform).transform.position;
				Vector3 right = ((Component)platform).transform.right;
				float size = Size;
				Debris debris = Debris.Spawn(IceArt.Glow, position, size * 1.3f, new Color(1f, 0.95f, 0.8f, 1f), num, 26);
				debris.Growth = 2.5f;
				debris.MaxLife = 0.3f;
				for (int i = 0; i < 9; i++)
				{
					Vector3 position2 = position + right * VisualRandom.Range((0f - size) * 0.45f, size * 0.45f) + Vector2.op_Implicit(VisualRandom.InsideUnitCircle() * 0.8f);
					Debris debris2 = Debris.Spawn(IceArt.Glow, position2, VisualRandom.Range(1.5f, 3f), Color.Lerp(new Color(1f, 0.35f, 0.05f, 0.95f), new Color(1f, 0.85f, 0.3f, 0.95f), VisualRandom.Range(0f, 1f)), num, 24);
					debris2.Velocity = VisualRandom.InsideUnitCircle() * 3f + Vector2.up * 1.5f;
					debris2.Growth = 1.6f;
					debris2.MaxLife = VisualRandom.Range(0.35f, 0.6f);
					debris2.FadeStart = 0.3f;
				}
				for (int j = 0; j < 22; j++)
				{
					Vector3 position3 = position + right * VisualRandom.Range((0f - size) * 0.45f, size * 0.45f);
					Color color = Color.Lerp(new Color(0.33f, 0.38f, 0.45f, 1f), new Color(0.6f, 0.62f, 0.66f, 1f), VisualRandom.Range(0f, 1f));
					Debris debris3 = Debris.Spawn(IceArt.RandomChunk(), position3, VisualRandom.Range(0.3f, 0.75f), color, num, 23);
					Vector2 val = VisualRandom.InsideUnitCircle();
					debris3.Velocity = ((Vector2)(ref val)).normalized * VisualRandom.Range(8f, 20f) + Vector2.up * 4f;
					debris3.Gravity = 22f;
					debris3.Spin = VisualRandom.Range(-900f, 900f);
					debris3.MaxLife = VisualRandom.Range(0.8f, 1.4f);
					debris3.FadeStart = 0.7f;
				}
				for (int k = 0; k < 30; k++)
				{
					Sparks(1f, num);
				}
				for (int l = 0; l < 10; l++)
				{
					Vector3 position4 = position + right * VisualRandom.Range((0f - size) * 0.4f, size * 0.4f);
					Debris debris4 = Debris.Spawn(IceArt.Glow, position4, VisualRandom.Range(2f, 3.5f), new Color(0.15f, 0.14f, 0.14f, 0.6f), num, 21);
					debris4.Velocity = VisualRandom.InsideUnitCircle() * 2f + Vector2.up * 2f;
					debris4.Drag = 1f;
					debris4.Growth = 1.2f;
					debris4.MaxLife = VisualRandom.Range(1.2f, 1.8f);
					debris4.FadeIn = 0.15f;
					debris4.FadeStart = 0.3f;
				}
				GameSound("explosion");
				GameSound("debris");
				IceVisuals.ShakeCamera(0.9f);
				SpriteRenderer obj = hot;
				SpriteRenderer obj2 = fill;
				SpriteRenderer obj3 = cyan;
				SpriteRenderer obj4 = red;
				Color val2 = (glow.color = Color.clear);
				Color val3 = (obj4.color = val2);
				Color val5 = (obj3.color = val3);
				Color color2 = (obj2.color = val5);
				obj.color = color2;
			}
		}

		public void WarpIn()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)this == (Object)null))
			{
				warp = 0f;
				removing = true;
				for (int i = 0; i < 10; i++)
				{
					IceVisuals.Twinkle(RandomPointOn(), 1f, SortingLayer.NameToID("explosion"), 20);
				}
				GameSound("teleport2");
			}
		}
	}
}
namespace PoyrazBoplMod.Core
{
	internal class CustomAbility
	{
		public string Name;

		public string IconFile;

		public Color PlaceholderColor = Color.white;

		public Func<NamedSprite, bool> IsTemplate;

		public Action<GameObject, NamedSprite> Setup;

		public Dictionary<Language, string> Translations = new Dictionary<Language, string>();

		public GameObject Prefab;

		public Sprite Icon;

		public bool IsOffensive;

		internal string TemplateName;

		internal GameObject TemplateSource;

		internal bool BuildFailed;
	}
	internal static class AbilityRegistry
	{
		private static readonly List<CustomAbility> abilities = new List<CustomAbility>();

		private static readonly Dictionary<string, CustomAbility> byLowerName = new Dictionary<string, CustomAbility>();

		private static GameObject templateHolder;

		public static IReadOnlyList<CustomAbility> All => abilities;

		public static void Add(CustomAbility ability)
		{
			abilities.Add(ability);
			byLowerName[ability.Name.ToLowerInvariant()] = ability;
		}

		public static bool TryTranslate(string enText, Language lang, out string result)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			result = null;
			if (enText == null || !byLowerName.TryGetValue(enText.ToLowerInvariant(), out var value))
			{
				return false;
			}
			if (!value.Translations.TryGetValue(lang, out result))
			{
				result = enText;
			}
			return true;
		}

		public static void EnsureRegistered()
		{
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			NamedSpriteList[] array;
			try
			{
				array = Resources.FindObjectsOfTypeAll<NamedSpriteList>();
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Yetenek listeleri bulunamadi: " + ex));
				return;
			}
			if (array == null || array.Length == 0)
			{
				return;
			}
			foreach (CustomAbility ability in abilities)
			{
				if ((Object)(object)ability.Prefab == (Object)null && !ability.BuildFailed)
				{
					TryBuild(ability, array);
				}
			}
			NamedSpriteList[] array2 = array;
			foreach (NamedSpriteList val in array2)
			{
				if ((Object)(object)val == (Object)null || val.sprites == null || ((Object)val).name.IndexOf("demo", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					continue;
				}
				foreach (CustomAbility ability2 in abilities)
				{
					if (!((Object)(object)ability2.Prefab == (Object)null) && val.IndexOf(ability2.Name) < 0 && ContainsTemplate(val, ability2))
					{
						val.sprites.Add(new NamedSprite(ability2.Name, ability2.Icon, ability2.Prefab, ability2.IsOffensive));
						Plugin.Log.LogInfo((object)$"'{ability2.Name}' yetenegi '{((Object)val).name}' listesine eklendi (sira: {val.sprites.Count - 1}).");
					}
				}
			}
		}

		private static bool ContainsTemplate(NamedSpriteList list, CustomAbility ability)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			foreach (NamedSprite sprite in list.sprites)
			{
				if (sprite.name == ability.TemplateName)
				{
					return true;
				}
				if ((Object)(object)ability.TemplateSource != (Object)null && (Object)(object)sprite.associatedGameObject == (Object)(object)ability.TemplateSource)
				{
					return true;
				}
			}
			return false;
		}

		private static void TryBuild(CustomAbility ability, NamedSpriteList[] lists)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			foreach (NamedSpriteList val in lists)
			{
				if ((Object)(object)val == (Object)null || val.sprites == null)
				{
					continue;
				}
				foreach (NamedSprite sprite in val.sprites)
				{
					if (!((Object)(object)sprite.associatedGameObject == (Object)null) && ability.IsTemplate(sprite))
					{
						try
						{
							Build(ability, sprite);
							return;
						}
						catch (Exception arg)
						{
							ability.BuildFailed = true;
							Plugin.Log.LogError((object)$"'{ability.Name}' olusturulamadi:\n{arg}");
							return;
						}
					}
				}
			}
		}

		private static void Build(CustomAbility ability, NamedSprite source)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: 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)
			if ((Object)(object)templateHolder == (Object)null)
			{
				templateHolder = new GameObject("PoyrazBoplMod_Templates");
				templateHolder.SetActive(false);
				Object.DontDestroyOnLoad((Object)(object)templateHolder);
			}
			GameObject val = Object.Instantiate<GameObject>(source.associatedGameObject, templateHolder.transform);
			((Object)val).name = ability.Name;
			ability.Setup(val, source);
			ability.TemplateName = source.name;
			ability.TemplateSource = source.associatedGameObject;
			ability.IsOffensive = source.isOffensiveAbility;
			ability.Icon = IconLoader.LoadOrPlaceholder(ability.IconFile, ability.PlaceholderColor, source.sprite);
			ability.Prefab = val;
			Sprite sprite = source.sprite;
			ManualLogSource log = Plugin.Log;
			string[] obj = new string[6] { "'", ability.Name, "' olusturuldu ('", source.name, "' kopyalandi). Ikon boyutu: ", null };
			object obj2;
			if (!((Object)(object)sprite != (Object)null))
			{
				obj2 = "?";
			}
			else
			{
				Rect rect = sprite.rect;
				object arg = (int)((Rect)(ref rect)).width;
				rect = sprite.rect;
				obj2 = $"{arg}x{(int)((Rect)(ref rect)).height}";
			}
			obj[5] = (string)obj2;
			log.LogInfo((object)string.Concat(obj));
		}
	}
	[HarmonyPatch(typeof(SteamManager), "Awake")]
	internal static class Patch_SteamManager_Awake
	{
		private static void Postfix()
		{
			AbilityRegistry.EnsureRegistered();
		}
	}
	[HarmonyPatch(typeof(AbilityGrid), "Awake")]
	internal static class Patch_AbilityGrid_Awake
	{
		private static void Prefix()
		{
			AbilityRegistry.EnsureRegistered();
		}
	}
	[HarmonyPatch(typeof(LocalizationTable), "GetText")]
	internal static class Patch_LocalizationTable_GetText
	{
		private static bool Prefix(string enText, Language lang, ref string __result)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if (!AbilityRegistry.TryTranslate(enText, lang, out var result))
			{
				return true;
			}
			__result = result;
			return false;
		}
	}
	internal static class GameLayers
	{
		private static bool initialized;

		public static int Player;

		public static int Water;

		public static int Wall;

		public static int Projectile;

		public static int Explosion;

		public static int LethalTerrain;

		public static int Orb;

		public static int RigidBodyAffector;

		public static void Init()
		{
			if (!initialized)
			{
				Player = LayerMask.NameToLayer("Player");
				Water = LayerMask.NameToLayer("Water");
				Wall = LayerMask.NameToLayer("wall");
				Projectile = LayerMask.NameToLayer("Projectile");
				Explosion = LayerMask.NameToLayer("Explosion");
				LethalTerrain = LayerMask.NameToLayer("LethalTerrain");
				Orb = LayerMask.NameToLayer("orb");
				RigidBodyAffector = LayerMask.NameToLayer("RigidBodyAffector");
				initialized = true;
			}
		}

		public static string Name(int layer)
		{
			if (layer < 0)
			{
				return "?";
			}
			return LayerMask.LayerToName(layer);
		}
	}
	internal static class Sfx
	{
		private static HashSet<string> known;

		private static readonly FieldInfo instanceField = AccessTools.Field(typeof(AudioManager), "instance");

		public static AudioManager Audio
		{
			get
			{
				object? obj = instanceField?.GetValue(null);
				return (AudioManager)((obj is AudioManager) ? obj : null);
			}
		}

		public static void Play(params string[] candidates)
		{
			AudioManager audio = Audio;
			if ((Object)(object)audio == (Object)null || audio.sounds == null)
			{
				return;
			}
			if (known == null || known.Count == 0)
			{
				known = new HashSet<string>(from s in audio.sounds
					where s.name != null
					select s.name);
			}
			foreach (string text in candidates)
			{
				if (known.Contains(text))
				{
					audio.Play(text);
					break;
				}
			}
		}

		public static void LogAllSoundNames()
		{
			AudioManager audio = Audio;
			if (!((Object)(object)audio == (Object)null) && audio.sounds != null)
			{
				Plugin.Log.LogInfo((object)("Oyundaki sesler: " + string.Join(", ", audio.sounds.Select((Sound s) => s.name))));
			}
		}
	}
	internal static class PhysicsUtil
	{
		public delegate void BodyEditor(ref PhysicsBody body);

		public static readonly Fix PinnedInverseMass = Fix.FromRaw(65536L);

		public static readonly Fix PinnedInverseMassLimit = Fix.FromRaw(131072L);

		public static void EditBody(IPhysicsCollider col, BodyEditor edit)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected I4, but got Unknown
			if (IsAlive(col) && !col.IsComposite())
			{
				DetPhysics val = DetPhysics.Get();
				int instanceId = col.GetPhysicsParent().instanceId;
				Shape shape = col.shape;
				switch ((int)shape)
				{
				case 0:
					edit(ref val.circles.physicsBodies[val.circles.ColliderIndex(instanceId)]);
					break;
				case 1:
					edit(ref val.boxes.physicsBodies[val.boxes.ColliderIndex(instanceId)]);
					break;
				case 2:
					edit(ref val.roundedRects.physicsBodies[val.roundedRects.ColliderIndex(instanceId)]);
					break;
				}
			}
		}

		public static PhysicsBody ReadBody(IPhysicsCollider col)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (!IsAlive(col) || col.IsComposite())
			{
				return default(PhysicsBody);
			}
			return col.GetBody();
		}

		public static void Pin(IPhysicsCollider col)
		{
			EditBody(col, delegate(ref PhysicsBody body)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: 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)
				body.velocity = Vec2.zero;
				body.angularVelocity = Fix.Zero;
				body.force = Vec2.zero;
				body.gravityScale = Fix.Zero;
			});
		}

		public static Fix GetGravityScale(IPhysicsCollider col)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (!IsAlive(col) || col.IsComposite())
			{
				return Fix.One;
			}
			return col.GetBody().gravityScale;
		}

		public static void SetGravityScale(IPhysicsCollider col, Fix value)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			EditBody(col, delegate(ref PhysicsBody body)
			{
				//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)
				body.gravityScale = value;
			});
		}

		public static bool IsAlive(IPhysicsCollider col)
		{
			if (col != null && !col.IsDestroyed && (Object)(object)((col is Object) ? col : null) != (Object)null && col.initHasBeenCalled)
			{
				return IsRegistered(col);
			}
			return false;
		}

		private static bool IsRegistered(IPhysicsCollider col)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected I4, but got Unknown
			DetPhysics val = DetPhysics.Get();
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			int instanceId = col.GetPhysicsParent().instanceId;
			Shape shape = col.shape;
			return (int)shape switch
			{
				0 => val.circles.ContainsParent(instanceId), 
				1 => val.boxes.ContainsParent(instanceId), 
				2 => val.roundedRects.ContainsParent(instanceId), 
				_ => false, 
			};
		}

		public static void ClearForce(IPhysicsCollider col)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected I4, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_0085: 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)
			if (IsAlive(col) && !col.IsComposite())
			{
				DetPhysics val = DetPhysics.Get();
				int instanceId = col.GetPhysicsParent().instanceId;
				Shape shape = col.shape;
				switch ((int)shape)
				{
				case 0:
					val.circles.physicsBodies[val.circles.ColliderIndex(instanceId)].force = Vec2.zero;
					break;
				case 1:
					val.boxes.physicsBodies[val.boxes.ColliderIndex(instanceId)].force = Vec2.zero;
					break;
				case 2:
					val.roundedRects.physicsBodies[val.roundedRects.ColliderIndex(instanceId)].force = Vec2.zero;
					break;
				}
			}
		}
	}
	internal sealed class ReferenceComparer<T> : IEqualityComparer<T> where T : class
	{
		public static readonly ReferenceComparer<T> Instance = new ReferenceComparer<T>();

		public bool Equals(T x, T y)
		{
			return x == y;
		}

		public int GetHashCode(T obj)
		{
			return RuntimeHelpers.GetHashCode(obj);
		}
	}
	internal static class GamePrefabs
	{
		private static Boulder boulder;

		public static Boulder Boulder
		{
			get
			{
				Find();
				return boulder;
			}
		}

		private static void Find()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)boulder != (Object)null)
			{
				return;
			}
			NamedSpriteList val = (((Object)(object)SteamManager.instance != (Object)null) ? SteamManager.instance.abilityIcons : null);
			if ((Object)(object)val == (Object)null || val.sprites == null)
			{
				return;
			}
			foreach (NamedSprite sprite in val.sprites)
			{
				GameObject associatedGameObject = sprite.associatedGameObject;
				if (!((Object)(object)associatedGameObject == (Object)null))
				{
					ShootDuplicator component = associatedGameObject.GetComponent<ShootDuplicator>();
					if ((Object)(object)component != (Object)null && (Object)(object)component.boulderPrefab != (Object)null)
					{
						boulder = component.boulderPrefab;
					}
				}
			}
		}
	}
	internal static class IconLoader
	{
		public static Sprite LoadOrPlaceholder(string fileName, Color placeholderColor, Sprite reference)
		{
			//IL_002e: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected O, but got Unknown
			int num = 128;
			int height = 128;
			float num2 = 100f;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0.5f, 0.5f);
			if ((Object)(object)reference != (Object)null)
			{
				Rect rect = reference.rect;
				num = Mathf.Max(1, (int)((Rect)(ref rect)).width);
				rect = reference.rect;
				height = Mathf.Max(1, (int)((Rect)(ref rect)).height);
				num2 = reference.pixelsPerUnit;
				float x = reference.pivot.x;
				rect = reference.rect;
				float num3 = x / ((Rect)(ref rect)).width;
				float y = reference.pivot.y;
				rect = reference.rect;
				((Vector2)(ref val))..ctor(num3, y / ((Rect)(ref rect)).height);
			}
			Texture2D val2 = null;
			string text = (string.IsNullOrEmpty(fileName) ? null : Path.Combine(Plugin.PluginDir, "icons", fileName));
			if (text != null && File.Exists(text))
			{
				try
				{
					val2 = new Texture2D(2, 2, (TextureFormat)4, false);
					if (!ImageConversion.LoadImage(val2, File.ReadAllBytes(text)))
					{
						val2 = null;
					}
					else
					{
						num2 *= (float)((Texture)val2).width / (float)num;
					}
				}
				catch (Exception ex)
				{
					Plugin.Log.LogWarning((object)("Ikon okunamadi (" + text + "): " + ex.Message));
					val2 = null;
				}
			}
			if ((Object)(object)val2 == (Object)null)
			{
				val2 = SolidTexture(num, height, placeholderColor);
			}
			((Texture)val2).filterMode = (FilterMode)1;
			((Texture)val2).wrapMode = (TextureWrapMode)1;
			((Object)val2).hideFlags = (HideFlags)32;
			Sprite obj = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), val, num2);
			((Object)obj).name = Path.GetFileNameWithoutExtension(fileName ?? "icon");
			((Object)obj).hideFlags = (HideFlags)32;
			return obj;
		}

		private static Texture2D SolidTexture(int width, int height, Color color)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(width, height, (TextureFormat)4, false);
			Color32[] array = (Color32[])(object)new Color32[width * height];
			Color32 val2 = Color32.op_Implicit(color);
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = val2;
			}
			val.SetPixels32(array);
			val.Apply();
			return val;
		}
	}
}
namespace PoyrazBoplMod.Abilities.FreezeRay
{
	internal static class IceArt
	{
		public static readonly Color Outline = new Color(0.22f, 0.56f, 1f, 1f);

		public static readonly Color FacetLight = new Color(0.9f, 0.98f, 1f, 0.76f);

		public static readonly Color FacetDark = new Color(0.44f, 0.75f, 1f, 0.64f);

		public static readonly Color FrontTop = new Color(0.78f, 0.95f, 1f, 1f);

		public static readonly Color FrontBottom = new Color(0.56f, 0.85f, 1f, 1f);

		public static readonly Color TopFace = new Color(0.92f, 0.99f, 1f, 0.82f);

		public static readonly Color SideFace = new Color(0.48f, 0.78f, 1f, 0.7f);

		public static readonly Color FrostTint = new Color(0.62f, 0.88f, 1f, 1f);

		private static readonly Color Shine = new Color(1f, 1f, 1f, 0.95f);

		private static readonly Color FacetLine = new Color(1f, 1f, 1f, 0.42f);

		private static readonly Vector2 LightDir = new Vector2(-0.6f, 0.8f);

		public const float CubeFrontFraction = 49f / 64f;

		public const float CubeDepthFraction = 0.18367347f;

		private static Sprite smallCube;

		private static Sprite snowflake;

		private static Sprite sparkle;

		private static Sprite icicle;

		private static Sprite shard;

		private static Sprite drop;

		private static Sprite squareRing;

		private static Sprite dot;

		private static Sprite glow;

		private static Sprite pixel;

		private static Sprite darkCore;

		private static Sprite brightCore;

		private static readonly Dictionary<int, Sprite> cubes = new Dictionary<int, Sprite>();

		private static Sprite[] chunks;

		public const float IcicleSpikeAspect = 0.25f;

		private static Sprite icicleSpike;

		private static readonly Dictionary<Sprite, Sprite> icicleLike = new Dictionary<Sprite, Sprite>();

		private static Material defaultSpriteMaterial;

		public const float BeamGlowLength = 0.125f;

		private static Sprite beamGlow;

		public const float LineThickness = 0.25f;

		private static Sprite line;

		private static readonly Vector2[][] CrackLines = new Vector2[8][]
		{
			(Vector2[])(object)new Vector2[5]
			{
				new Vector2(52f, 58f),
				new Vector2(40f, 64f),
				new Vector2(34f, 78f),
				new Vector2(22f, 84f),
				new Vector2(18f, 96f)
			},
			(Vector2[])(object)new Vector2[5]
			{
				new Vector2(52f, 58f),
				new Vector2(66f, 52f),
				new Vector2(72f, 40f),
				new Vector2(86f, 34f),
				new Vector2(90f, 20f)
			},
			(Vector2[])(object)new Vector2[4]
			{
				new Vector2(52f, 58f),
				new Vector2(48f, 42f),
				new Vector2(38f, 34f),
				new Vector2(36f, 14f)
			},
			(Vector2[])(object)new Vector2[4]
			{
				new Vector2(66f, 52f),
				new Vector2(74f, 66f),
				new Vector2(88f, 72f),
				new Vector2(94f, 90f)
			},
			(Vector2[])(object)new Vector2[3]
			{
				new Vector2(40f, 64f),
				new Vector2(54f, 74f),
				new Vector2(56f, 96f)
			},
			(Vector2[])(object)new Vector2[4]
			{
				new Vector2(72f, 40f),
				new Vector2(64f, 26f),
				new Vector2(52f, 20f),
				new Vector2(50f, 8f)
			},
			(Vector2[])(object)new Vector2[3]
			{
				new Vector2(22f, 84f),
				new Vector2(12f, 74f),
				new Vector2(10f, 60f)
			},
			(Vector2[])(object)new Vector2[3]
			{
				new Vector2(88f, 72f),
				new Vector2(100f, 70f),
				new Vector2(102f, 54f)
			}
		};

		private static readonly int[] CrackLinesByStage = new int[4] { 0, 2, 4, 8 };

		private static readonly Dictionary<int, Color[]> cubeBase = new Dictionary<int, Color[]>();

		private static readonly Vector2[][] ChunkShapes = new Vector2[6][]
		{
			(Vector2[])(object)new Vector2[4]
			{
				new Vector2(3f, 16f),
				new Vector2(12f, 6f),
				new Vector2(30f, 13f),
				new Vector2(14f, 25f)
			},
			(Vector2[])(object)new Vector2[4]
			{
				new Vector2(16f, 1f),
				new Vector2(23f, 12f),
				new Vector2(17f, 31f),
				new Vector2(9f, 14f)
			},
			(Vector2[])(object)new Vector2[6]
			{
				new Vector2(4f, 6f),
				new Vector2(18f, 2f),
				new Vector2(28f, 10f),
				new Vector2(26f, 24f),
				new Vector2(12f, 29f),
				new Vector2(3f, 18f)
			},
			(Vector2[])(object)new Vector2[4]
			{
				new Vector2(6f, 3f),
				new Vector2(27f, 7f),
				new Vector2(24f, 22f),
				new Vector2(9f, 28f)
			},
			(Vector2[])(object)new Vector2[5]
			{
				new Vector2(16f, 1f),
				new Vector2(29f, 12f),
				new Vector2(22f, 30f),
				new Vector2(6f, 26f),
				new Vector2(3f, 10f)
			},
			(Vector2[])(object)new Vector2[3]
			{
				new Vector2(3f, 4f),
				new Vector2(29f, 9f),
				new Vector2(14f, 30f)
			}
		};

		private const int FrostScale = 4;

		private const int FrostSize = 256;

		private const int FrostCorner = 80;

		private const int FacetCell = 12;

		private static Texture2D frostTexture;

		private static Texture2D slabTexture;

		private static readonly Dictionary<int, Sprite> frostByRadius = new Dictionary<int, Sprite>();

		private static readonly Dictionary<int, Sprite> slabByRadius = new Dictionary<int, Sprite>();

		public static Sprite SmallCube
		{
			get
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)smallCube != (Object)null))
				{
					return smallCube = ToSprite(SmallCubeTexture(), new Vector2(0.375f, 0.0625f));
				}
				return smallCube;
			}
		}

		public static Sprite IceCube => Cube(1f, 0);

		public static Sprite Snowflake
		{
			get
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)snowflake != (Object)null))
				{
					return snowflake = ToSprite(SnowflakeTexture(), new Vector2(0.5f, 0.5f));
				}
				return snowflake;
			}
		}

		public static Sprite Sparkle
		{
			get
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)sparkle != (Object)null))
				{
					return sparkle = ToSprite(SparkleTexture(), new Vector2(0.5f, 0.5f));
				}
				return sparkle;
			}
		}

		public static Sprite Icicle
		{
			get
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)icicle != (Object)null))
				{
					return icicle = ToSprite(IcicleTexture(), new Vector2(0.5f, 1f));
				}
				return icicle;
			}
		}

		public static Sprite Shard
		{
			get
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)shard != (Object)null))
				{
					return shard = ToSprite(ShardTexture(), new Vector2(0.5f, 0f));
				}
				return shard;
			}
		}

		public static Sprite Drop
		{
			get
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)drop != (Object)null))
				{
					return drop = ToSprite(DropTexture(), new Vector2(0.5f, 0.5f));
				}
				return drop;
			}
		}

		public static Sprite Ring
		{
			get
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)squareRing != (Object)null))
				{
					return squareRing = ToSprite(SquareRingTexture(), new Vector2(0.5f, 0.5f));
				}
				return squareRing;
			}
		}

		public static Sprite Dot
		{
			get
			{
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)dot != (Object)null))
				{
					return dot = ToSprite(RadialTexture(16, 1.5f), new Vector2(0.5f, 0.5f));
				}
				return dot;
			}
		}

		public static Sprite Glow
		{
			get
			{
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)glow != (Object)null))
				{
					return glow = ToSprite(RadialTexture(32, 2.2f), new Vector2(0.5f, 0.5f));
				}
				return glow;
			}
		}

		public static Sprite IcicleSpike
		{
			get
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)icicleSpike != (Object)null))
				{
					return icicleSpike = ToSprite(IcicleSpikeTexture(96, 384, tipDown: false), new Vector2(0.5f, 0.5f));
				}
				return icicleSpike;
			}
		}

		public static Material DefaultSpriteMaterial
		{
			get
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Expected O, but got Unknown
				if ((Object)(object)defaultSpriteMaterial != (Object)null)
				{
					return defaultSpriteMaterial;
				}
				GameObject val = new GameObject("PoyrazMod_MaterialProbe");
				defaultSpriteMaterial = ((Renderer)val.AddComponent<SpriteRenderer>()).sharedMaterial;
				Object.DestroyImmediate((Object)val);
				return defaultSpriteMaterial;
			}
		}

		public static Sprite BeamGlow
		{
			get
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)beamGlow != (Object)null))
				{
					return beamGlow = ToSprite(BeamGlowTexture(), new Vector2(0.5f, 0.5f));
				}
				return beamGlow;
			}
		}

		public static Sprite Line
		{
			get
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)line != (Object)null))
				{
					return line = ToSprite(LineTexture(), new Vector2(0.5f, 0.5f));
				}
				return line;
			}
		}

		public static Sprite Pixel
		{
			get
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)pixel != (Object)null))
				{
					return pixel = ToSprite(SolidTexture(4, Color.white), new Vector2(0.5f, 0.5f), point: true);
				}
				return pixel;
			}
		}

		public static void Warmup()
		{
			Stopwatch stopwatch = Stopwatch.StartNew();
			for (int i = 0; i < 4; i++)
			{
				Cube(1f, i);
				Cube(5f, i);
			}
			_ = SmallCube;
			_ = Shard;
			_ = Icicle;
			_ = IcicleSpike;
			AllChunks();
			_ = Sparkle;
			_ = Snowflake;
			_ = Drop;
			CoreGem(bright: false);
			CoreGem(bright: true);
			_ = Ring;
			_ = Dot;
			_ = Glow;
			_ = BeamGlow;
			PlatformFrost(0.25f);
			IceSlab(0.25f);
			Plugin.Log.LogInfo((object)$"Buz cizimleri hazirlandi ({stopwatch.ElapsedMilliseconds} ms)");
		}

		public static Sprite Cube(float side, int stage)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			int num = ((side <= 3.5f) ? 256 : 512);
			int key = num * 10 + Mathf.Clamp(stage, 0, 3);
			if (cubes.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			value = ToSprite(CubeTexture(num, Mathf.Clamp(stage, 0, 3)), new Vector2(55f / 128f, 55f / 128f));
			cubes[key] = value;
			return value;
		}

		public static Sprite CoreGem(bool bright)
		{
			//IL_0055: 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)
			if (bright)
			{
				if (!((Object)(object)brightCore != (Object)null))
				{
					return brightCore = ToSprite(GemTexture(bright: true), new Vector2(0.5f, 0.5f));
				}
				return brightCore;
			}
			if (!((Object)(object)darkCore != (Object)null))
			{
				return darkCore = ToSprite(GemTexture(bright: false), new Vector2(0.5f, 0.5f));
			}
			return darkCore;
		}

		public static Sprite IcicleLike(Sprite original)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL