Decompiled source of Cancerous Beam v1.0.0

plugins/CancerousBeam.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.CancerBeam;
using PoyrazBoplMod.Abilities.FreezeRay;
using PoyrazBoplMod.Abilities.SelfStab;
using PoyrazBoplMod.Core;
using PoyrazBoplMod.Shared;
using UnityEngine;
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("CancerousBeam")]
[assembly: AssemblyConfiguration("CancerBeam")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("CancerousBeam")]
[assembly: AssemblyTitle("CancerousBeam")]
[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.cancerousbeam", "Cancerous Beam", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "com.poyraz.cancerousbeam";

		public const string Name = "Cancerous Beam";

		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);
			CancerBeamAbility.Register();
			PatchAll(new Harmony("com.poyraz.cancerousbeam"));
			SceneManager.sceneLoaded += OnSceneLoaded;
			AbilityRegistry.EnsureRegistered();
			Log.LogInfo((object)"Cancerous Beam 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 DuplicatorGuard
	{
		private static readonly Assembly Ours = typeof(DuplicatorGuard).Assembly;

		private static int warnings;

		internal static bool IsOurs(Transform t)
		{
			if (((Object)t).name.StartsWith("PoyrazMod_", StringComparison.Ordinal))
			{
				return true;
			}
			MonoBehaviour[] componentsInChildren = ((Component)t).GetComponentsInChildren<MonoBehaviour>(true);
			foreach (MonoBehaviour val in componentsInChildren)
			{
				if ((Object)(object)val != (Object)null && ((object)val).GetType().Assembly == Ours)
				{
					return true;
				}
			}
			return false;
		}

		internal static void Warn(string what, Exception e)
		{
			if (warnings++ < 5)
			{
				Plugin.Log.LogWarning((object)$"Klonlama korumasi ({what}): {e}");
			}
		}
	}
	[HarmonyPatch(typeof(ShootDuplicator), "DuplicateObject")]
	internal static class Patch_Duplicate_SkipModChildren
	{
		private static void Prefix(GameObject obj, out List<Transform> __state)
		{
			__state = null;
			if ((Object)(object)obj == (Object)null)
			{
				return;
			}
			Transform transform = obj.transform;
			for (int num = transform.childCount - 1; num >= 0; num--)
			{
				Transform child = transform.GetChild(num);
				if (DuplicatorGuard.IsOurs(child))
				{
					(__state ?? (__state = new List<Transform>())).Add(child);
				}
			}
			if (__state == null)
			{
				return;
			}
			foreach (Transform item in __state)
			{
				item.SetParent((Transform)null, true);
			}
		}

		private static void Postfix(GameObject obj, List<Transform> __state)
		{
			if (__state == null || (Object)(object)obj == (Object)null)
			{
				return;
			}
			for (int num = __state.Count - 1; num >= 0; num--)
			{
				if ((Object)(object)__state[num] != (Object)null)
				{
					__state[num].SetParent(obj.transform, true);
				}
			}
		}

		private static Exception Finalizer(Exception __exception, GameObject obj, List<Transform> __state)
		{
			if (__exception != null)
			{
				Postfix(obj, __state);
			}
			return __exception;
		}
	}
	[HarmonyPatch(typeof(DuplicatePlatformEffect), "ScaleEffect")]
	internal static class Patch_DuplicateEffect_ScaleGuard
	{
		private static readonly FieldRef<DuplicatePlatformEffect, SpriteRenderer> shaderRef = AccessTools.FieldRefAccess<DuplicatePlatformEffect, SpriteRenderer>("platformShaderEffect");

		private static bool Prefix(DuplicatePlatformEffect __instance)
		{
			SpriteRenderer val = shaderRef.Invoke(__instance);
			if ((Object)(object)val != (Object)null && (Object)(object)val.sprite != (Object)null)
			{
				return (Object)(object)val.sprite.texture != (Object)null;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(DuplicatePlatformEffect), "UpdateSim")]
	internal static class Patch_DuplicateEffect_Guard
	{
		private static readonly FieldRef<DuplicatePlatformEffect, StickyRoundedRectangle> srrRef = AccessTools.FieldRefAccess<DuplicatePlatformEffect, StickyRoundedRectangle>("srr");

		private static readonly FieldRef<DuplicatePlatformEffect, SpriteRenderer> shaderRef = AccessTools.FieldRefAccess<DuplicatePlatformEffect, SpriteRenderer>("platformShaderEffect");

		private static readonly FieldRef<DuplicatePlatformEffect, ParticleSystem> spawnInRef = AccessTools.FieldRefAccess<DuplicatePlatformEffect, ParticleSystem>("spawnInEffect");

		private static void Prefix(DuplicatePlatformEffect __instance, out Fix __state)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			StickyRoundedRectangle val = srrRef.Invoke(__instance);
			__state = (((Object)(object)val != (Object)null && !((MonoUpdatable)val).IsDestroyed) ? val.rr.Scale : Fix.Zero);
		}

		private static Exception Finalizer(Exception __exception, DuplicatePlatformEffect __instance, Fix __state)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			if (__exception == null || (Object)(object)__instance == (Object)null)
			{
				return __exception;
			}
			DuplicatorGuard.Warn("efekt", __exception);
			try
			{
				StickyRoundedRectangle val = srrRef.Invoke(__instance);
				if ((Object)(object)val != (Object)null && !((MonoUpdatable)val).IsDestroyed)
				{
					if (__state > Fix.Zero)
					{
						val.rr.Scale = __state;
					}
					if ((Object)(object)val.currentDuplicatePlatformEffect == (Object)(object)__instance)
					{
						val.currentDuplicatePlatformEffect = null;
					}
				}
				SpriteRenderer val2 = shaderRef.Invoke(__instance);
				if ((Object)(object)val2 != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)val2).gameObject);
				}
				ParticleSystem val3 = spawnInRef.Invoke(__instance);
				if ((Object)(object)val3 != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)val3).gameObject);
				}
				if (!((MonoUpdatable)__instance).IsDestroyed)
				{
					Updater.DestroyFix(((Component)__instance).gameObject);
				}
			}
			catch (Exception e)
			{
				DuplicatorGuard.Warn("efekt temizligi", e);
			}
			return null;
		}
	}
	[HarmonyPatch(typeof(ShootDuplicator), "Shoot")]
	internal static class Patch_ShootDuplicator_Guard
	{
		private static Exception Finalizer(Exception __exception, ShootDuplicator __instance, ref bool hasFired)
		{
			if (__exception == null)
			{
				return null;
			}
			DuplicatorGuard.Warn("atis", __exception);
			hasFired = true;
			if ((Object)(object)__instance != (Object)null && !((Component)__instance).gameObject.activeSelf)
			{
				((Component)__instance).gameObject.SetActive(true);
			}
			return null;
		}
	}
	internal static class ModAudio
	{
		public const int SampleRate = 44100;

		private static readonly FieldRef<AudioManager, float> masterRef = AccessTools.FieldRefAccess<AudioManager, float>("currentMasterVolume");

		private static readonly Random jitter = new Random();

		private static AudioSource[] pool;

		private static int next;

		public static void Play(AudioClip clip, float volume = 1f, float pitch = 1f)
		{
			if ((Object)(object)clip == (Object)null)
			{
				return;
			}
			try
			{
				if (Ready())
				{
					AudioSource obj = pool[next++ % pool.Length];
					obj.clip = clip;
					obj.pitch = pitch * (1f + ((float)jitter.NextDouble() - 0.5f) * 0.06f);
					obj.volume = Mathf.Clamp01(volume * GameVolume());
					obj.Play();
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogDebug((object)("Ses calinamadi: " + ex.Message));
			}
		}

		public static float GameVolume()
		{
			AudioManager val = AudioManager.Get();
			if ((Object)(object)val == (Object)null)
			{
				return 0.5f;
			}
			float num = 1f;
			try
			{
				num = masterRef.Invoke(val);
			}
			catch
			{
			}
			return val.sfxVolume * num;
		}

		private static bool Ready()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			if (pool != null && (Object)(object)pool[0] != (Object)null)
			{
				return true;
			}
			GameObject val = new GameObject("PoyrazMod_ModAudio");
			Object.DontDestroyOnLoad((Object)(object)val);
			pool = (AudioSource[])(object)new AudioSource[10];
			for (int i = 0; i < pool.Length; i++)
			{
				AudioSource val2 = val.AddComponent<AudioSource>();
				val2.playOnAwake = false;
				val2.spatialBlend = 0f;
				pool[i] = val2;
			}
			return true;
		}

		public static AudioClip LoadWavIfExists(string fileName)
		{
			try
			{
				if (!File.Exists(Path.Combine(Plugin.PluginDir, "sounds", fileName)))
				{
					return null;
				}
			}
			catch
			{
				return null;
			}
			return LoadWav(fileName);
		}

		public static AudioClip LoadWav(string fileName)
		{
			try
			{
				string text = Path.Combine(Plugin.PluginDir, "sounds", fileName);
				if (!File.Exists(text))
				{
					Plugin.Log.LogWarning((object)("Ses dosyasi yok (yedek ses calinacak): " + text));
					return null;
				}
				byte[] array = File.ReadAllBytes(text);
				if (array.Length < 44 || Encoding.ASCII.GetString(array, 0, 4) != "RIFF" || Encoding.ASCII.GetString(array, 8, 4) != "WAVE")
				{
					return null;
				}
				int num = 1;
				int num2 = 44100;
				int num3 = 16;
				int num4 = 12;
				while (num4 + 8 <= array.Length)
				{
					string text2 = Encoding.ASCII.GetString(array, num4, 4);
					int num5 = BitConverter.ToInt32(array, num4 + 4);
					int num6 = num4 + 8;
					if (text2 == "fmt ")
					{
						num = BitConverter.ToInt16(array, num6 + 2);
						num2 = BitConverter.ToInt32(array, num6 + 4);
						num3 = BitConverter.ToInt16(array, num6 + 14);
					}
					else if (text2 == "data")
					{
						if (num3 != 16)
						{
							return null;
						}
						int num7 = Mathf.Min(num5, array.Length - num6) / (2 * num);
						float[] array2 = new float[num7];
						for (int i = 0; i < num7; i++)
						{
							float num8 = 0f;
							for (int j = 0; j < num; j++)
							{
								num8 += (float)BitConverter.ToInt16(array, num6 + (i * num + j) * 2) / 32768f;
							}
							array2[i] = num8 / (float)num;
						}
						AudioClip obj = AudioClip.Create("Poyraz_" + fileName, num7, 1, num2, false);
						obj.SetData(array2, 0);
						((Object)obj).hideFlags = (HideFlags)32;
						return obj;
					}
					num4 = num6 + num5 + (num5 & 1);
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Ses dosyasi okunamadi: " + fileName + " (" + ex.Message + ")"));
			}
			return null;
		}

		public static AudioClip FromSamples(string name, float[] data)
		{
			float num = 0.0001f;
			foreach (float num2 in data)
			{
				num = Mathf.Max(num, Mathf.Abs(num2));
			}
			for (int j = 0; j < data.Length; j++)
			{
				data[j] = data[j] / num * 0.9f;
			}
			AudioClip obj = AudioClip.Create(name, data.Length, 1, 44100, false);
			obj.SetData(data, 0);
			((Object)obj).hideFlags = (HideFlags)32;
			return obj;
		}
	}
	internal static class PlayerKill
	{
		private static readonly FieldRef<SlimeController, List<AbilityMonoBehaviour>> abilitiesRef = AccessTools.FieldRefAccess<SlimeController, List<AbilityMonoBehaviour>>("abilities");

		private static readonly FieldRef<Player, SlimeController> setterRef = AccessTools.FieldRefAccess<Player, SlimeController>("positionSetterLastFrame");

		private static readonly FieldRef<Player, SlimeController> setterNowRef = AccessTools.FieldRefAccess<Player, SlimeController>("positionSetterThisFrame");

		public static SlimeController SlimeOf(Player player)
		{
			if (player == null)
			{
				return null;
			}
			SlimeController val = setterNowRef.Invoke(player);
			if ((Object)(object)val == (Object)null || ((MonoUpdatable)val).IsDestroyed)
			{
				val = setterRef.Invoke(player);
			}
			if ((Object)(object)val != (Object)null && !((MonoUpdatable)val).IsDestroyed)
			{
				return val;
			}
			SlimeController[] array = Object.FindObjectsOfType<SlimeController>();
			foreach (SlimeController val2 in array)
			{
				if ((Object)(object)val2 != (Object)null && !((MonoUpdatable)val2).IsDestroyed && val2.playerNumber == player.Id)
				{
					return val2;
				}
			}
			return null;
		}

		public static bool CanKillNow(SlimeController slime)
		{
			if ((Object)(object)slime == (Object)null || ((MonoUpdatable)slime).IsDestroyed)
			{
				return false;
			}
			if (((Component)slime).gameObject.activeInHierarchy)
			{
				return true;
			}
			List<AbilityMonoBehaviour> list = abilitiesRef.Invoke(slime);
			if (list == null)
			{
				return false;
			}
			foreach (AbilityMonoBehaviour item in list)
			{
				if ((Object)(object)item != (Object)null && !((MonoUpdatable)item).IsDestroyed && ((Component)item).gameObject.activeInHierarchy && ((Component)item).GetComponent<IAbilityComponent>() != null)
				{
					return true;
				}
			}
			return false;
		}

		public static void Kill(SlimeController slime, Player player, int killerId, bool spawnEffect)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)slime == (Object)null || ((MonoUpdatable)slime).IsDestroyed || player == null)
			{
				return;
			}
			int alive = player.playersAndClonesStillAlive;
			ReviveStatus extra = player.ExtraLife;
			List<AbilityMonoBehaviour> list = abilitiesRef.Invoke(slime);
			if (list != null)
			{
				foreach (AbilityMonoBehaviour item in new List<AbilityMonoBehaviour>(list))
				{
					if (Died())
					{
						return;
					}
					if (!((Object)(object)item == (Object)null) && !((MonoUpdatable)item).IsDestroyed && ((Component)item).gameObject.activeInHierarchy)
					{
						IAbilityComponent component = ((Component)item).GetComponent<IAbilityComponent>();
						if (component != null)
						{
							FixTransform component2 = ((Component)item).GetComponent<FixTransform>();
							component.ExitAbility(new AbilityExitInfo
							{
								isDead = true,
								killerId = killerId,
								position = (((Object)(object)component2 != (Object)null) ? component2.position : player.Position),
								causeOfDeath = (CauseOfDeath)0
							});
						}
					}
				}
			}
			if (!Died())
			{
				PlayerCollision activePlayerCollision = slime.GetActivePlayerCollision();
				if ((Object)(object)activePlayerCollision != (Object)null && !((MonoUpdatable)activePlayerCollision).IsDestroyed)
				{
					activePlayerCollision.killPlayer(killerId, spawnEffect, true, (CauseOfDeath)0);
				}
			}
			bool Died()
			{
				//IL_0034: 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)slime == (Object)null) && !((MonoUpdatable)slime).IsDestroyed && player.playersAndClonesStillAlive == alive)
				{
					return player.ExtraLife != extra;
				}
				return true;
			}
		}
	}
	internal static class SpaceTrash
	{
		internal enum Mode
		{
			Heating,
			Glitch,
			Meltdown,
			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 MeltdownTime = (Fix)1.4;

		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;

		internal static int DebugMeltdowns;

		public static event Action<Vec2, int> OnRadioactiveBlast;

		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 Meltdown(StickyRoundedRectangle p, int owner)
		{
			//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)
			if (Is(p))
			{
				State state = Get(p);
				if (state.Mode != Mode.Meltdown && state.Mode != Mode.Gone)
				{
					state.Mode = Mode.Meltdown;
					state.T = Fix.Zero;
					state.Owner = owner;
					DebugMeltdowns++;
					state.Look?.StartMeltdown();
				}
			}
		}

		public static void Tick(Fix dt, bool timeStopped)
		{
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: 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_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: 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_0119: 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_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: 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_02c5: 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_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			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 component3 = ((Component)state.Platform).GetComponent<ShakablePlatform>();
							if (component3 != null)
							{
								component3.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.Meltdown:
						if (!timeStopped)
						{
							state.T += dt;
							ShakablePlatform component = ((Component)state.Platform).GetComponent<ShakablePlatform>();
							if (component != null)
							{
								component.AddShake((Fix)0.1, (Fix)0.05 + state.T / MeltdownTime * (Fix)0.2, 3, (Material)null, (AnimationCurveFixed)null);
							}
							if (state.T >= MeltdownTime)
							{
								Vec2 arg = Center(state.Platform);
								int owner = state.Owner;
								Blast(state);
								SpaceTrash.OnRadioactiveBlast?.Invoke(arg, owner);
							}
						}
						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 float MeltOf(StickyRoundedRectangle p)
		{
			//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_0024: Unknown result type (might be due to invalid IL or missing references)
			State state = Find(p);
			if (state == null || state.Mode != Mode.Meltdown)
			{
				return -1f;
			}
			return Mathf.Clamp01((float)(state.T / MeltdownTime));
		}

		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 bool melting;

		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 StartMeltdown()
		{
			melting = true;
			glitching = false;
		}

		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_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f1: 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_0516: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_051b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0542: Unknown result type (might be due to invalid IL or missing references)
			//IL_0554: Unknown result type (might be due to invalid IL or missing references)
			//IL_0564: Unknown result type (might be due to invalid IL or missing references)
			//IL_0566: Unknown result type (might be due to invalid IL or missing references)
			//IL_058d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d7: 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_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_0639: Unknown result type (might be due to invalid IL or missing references)
			//IL_0677: Unknown result type (might be due to invalid IL or missing references)
			//IL_0684: Unknown result type (might be due to invalid IL or missing references)
			//IL_0698: Unknown result type (might be due to invalid IL or missing references)
			//IL_069d: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b1: 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;
			}
			if (melting)
			{
				Melt(deltaTime, 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 Melt(float dt, int fx)
		{
			//IL_0050: 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_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_0096: 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_00b7: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: 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_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: 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)
			float num = Mathf.Max(0f, SpaceTrash.MeltOf(platform));
			float num2 = 0.8f + 0.2f * Mathf.Sin(t * (30f + 40f * num));
			Color val = Color.Lerp(new Color(0.2f, 0.75f, 0.1f, 1f), new Color(0.85f, 1f, 0.6f, 1f), num);
			val.a = Mathf.Clamp01((0.45f + 0.6f * num) * num2);
			hot.color = val;
			((Component)hot).transform.localPosition = Vector3.zero;
			FitFill();
			Color color = val;
			color.a = Mathf.Clamp01((0.3f + 0.45f * num) * num2);
			fill.color = color;
			SpriteRenderer obj = cyan;
			Color color2 = (red.color = Color.clear);
			obj.color = color2;
			glow.color = new Color(0.35f, 1f, 0.15f, Mathf.Clamp01((0.5f + 0.5f * num) * num2));
			SetGlowSize(1.4f + 0.9f * num);
			smokeTimer -= dt;
			if (smokeTimer <= 0f)
			{
				smokeTimer = Mathf.Lerp(0.09f, 0.03f, num);
				Debris debris = Debris.Spawn(IceArt.Glow, RandomPointOn(), VisualRandom.Range(0.8f, 1.5f), new Color(0.3f, 0.85f, 0.15f, 0.35f), fx, 2);
				debris.Velocity = Vector2.up * VisualRandom.Range(1.5f, 3.5f) + VisualRandom.InsideUnitCircle() * 0.6f;
				debris.Growth = 1.3f;
				debris.MaxLife = VisualRandom.Range(0.8f, 1.3f);
				debris.FadeIn = 0.1f;
				debris.FadeStart = 0.3f;
				Debris debris2 = Debris.Spawn(IceArt.Glow, RandomPointOn(), VisualRandom.Range(0.15f, 0.35f), new Color(0.8f, 1f, 0.5f, 1f), fx, 22);
				debris2.Velocity = new Vector2(VisualRandom.Range(-2f, 2f), VisualRandom.Range(2f, 6f));
				debris2.Gravity = 4f;
				debris2.MaxLife = VisualRandom.Range(0.3f, 0.6f);
			}
		}

		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_0042: 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_0053: 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_0092: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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_00f2: 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_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: 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_016f: 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_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: 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_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0447: Unknown result type (might be due to invalid IL or missing references)
			//IL_044c: Unknown result type (might be due to invalid IL or missing references)
			//IL_044d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_0456: Unknown result type (might be due to invalid IL or missing references)
			//IL_0457: Unknown result type (might be due to invalid IL or missing references)
			//IL_045e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0460: Unknown result type (might be due to invalid IL or missing references)
			//IL_0461: Unknown result type (might be due to invalid IL or missing references)
			//IL_0468: Unknown result type (might be due to invalid IL or missing references)
			//IL_046a: Unknown result type (might be due to invalid IL or missing references)
			//IL_046b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: 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;
				bool num = melting;
				melting = false;
				int num2 = SortingLayer.NameToID("explosion");
				Vector3 position = ((Component)platform).transform.position;
				Vector3 right = ((Component)platform).transform.right;
				float size = Size;
				Color val = (num ? new Color(0.25f, 0.9f, 0.1f, 0.95f) : new Color(1f, 0.35f, 0.05f, 0.95f));
				Color val2 = (num ? new Color(0.85f, 1f, 0.5f, 0.95f) : new Color(1f, 0.85f, 0.3f, 0.95f));
				Debris debris = Debris.Spawn(IceArt.Glow, position, size * 1.3f, new Color(1f, 0.95f, 0.8f, 1f), num2, 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(val, val2, VisualRandom.Range(0f, 1f)), num2, 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, num2, 23);
					Vector2 val3 = VisualRandom.InsideUnitCircle();
					debris3.Velocity = ((Vector2)(ref val3)).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, num2);
				}
				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), num2, 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 val4 = (glow.color = Color.clear);
				Color val5 = (obj4.color = val4);
				Color val7 = (obj3.color = val5);
				Color color2 = (obj2.color = val7);
				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