Decompiled source of Overworked v1.0.1

Rebalance80.dll

Decompiled 10 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Rebalance80.Patches;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Rebalance80")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A mod which aims in rebalancing some features for v80, such as cheaper flash lights and extension ladders which are now required for adamance on quota 1 and disabling the new cadaver enemy which is currently unfinished.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Rebalance80")]
[assembly: AssemblyTitle("Rebalance80")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 Rebalance80
{
	[BepInPlugin("dev.timmywastor.overworked", "Overworked", "0.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		public const string modGUID = "dev.timmywastor.overworked";

		public const string modName = "Overworked";

		public const string modVersion = "0.0.1";

		private static Harmony _harmony = new Harmony("dev.timmywastor.overworked");

		public static ManualLogSource mls = Logger.CreateLogSource("dev.timmywastor.overworked");

		public static string PluginFolder;

		private void Awake()
		{
			string location = ((BaseUnityPlugin)this).Info.Location;
			PluginFolder = Path.GetDirectoryName(location);
			mls.LogInfo((object)"Initialized with success!");
			PatchAllStuff();
		}

		private void PatchAllStuff()
		{
			_harmony.PatchAll(typeof(TerminalPatch));
			_harmony.PatchAll(typeof(RoundManagerPatch));
			_harmony.PatchAll(typeof(MenuManagerPatch));
			_harmony.PatchAll(typeof(PlayerControllerBPatch));
			_harmony.PatchAll(typeof(StartOfRoundPatch));
			_harmony.PatchAll(typeof(GrabbableObjectPatch));
			_harmony.PatchAll(typeof(HUDManagerPatch));
			_harmony.PatchAll(typeof(ShotgunItemPatch));
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "Rebalance80";

		public const string PLUGIN_NAME = "Rebalance80";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace Rebalance80.Patches
{
	[HarmonyPatch(typeof(GrabbableObject))]
	internal class GrabbableObjectPatch
	{
		private static MethodInfo teleportMethod = AccessTools.Method(typeof(PlayerControllerB), "ThrowObjectServerRpc", (Type[])null, (Type[])null);

		[HarmonyPatch("DiscardItem")]
		[HarmonyPrefix]
		private static void DiscardItemPatch(GrabbableObject __instance)
		{
			if ((Object)(object)__instance.playerHeldBy != (Object)null && __instance.itemProperties.isScrap)
			{
				SetCollected(__instance, value: false);
				if (__instance.playerHeldBy.isInHangarShipRoom)
				{
					SetCollected(__instance, value: true);
				}
			}
		}

		public static void SetCollected(GrabbableObject target, bool value)
		{
			ScanNodeProperties componentInChildren = ((Component)target).GetComponentInChildren<ScanNodeProperties>();
			if (Object.op_Implicit((Object)(object)componentInChildren))
			{
				componentInChildren.headerText = componentInChildren.headerText.Replace(" <color=red>Collected</color>", "");
				if (value)
				{
					componentInChildren.headerText += " <color=red>Collected</color>";
				}
			}
		}

		public static void TeleportItemInShipRPC(Vector3 position, GrabbableObject __instance)
		{
			//IL_0022: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			NetworkObject component = ((Component)__instance).GetComponent<NetworkObject>();
			PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
			teleportMethod.Invoke(localPlayerController, new object[5]
			{
				(object)new NetworkObjectReference(component),
				true,
				true,
				position,
				0
			});
			((Component)__instance).gameObject.transform.position = position;
			__instance.targetFloorPosition = position;
		}

		public static void TeleportItemInShip(Vector3 position, GrabbableObject __instance)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			NetworkObject component = ((Component)__instance).GetComponent<NetworkObject>();
			PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
			GrabbableObject currentlyHeldObjectServer = localPlayerController.currentlyHeldObjectServer;
			bool isInElevator = localPlayerController.isInElevator;
			bool isInHangarShipRoom = localPlayerController.isInHangarShipRoom;
			localPlayerController.currentlyHeldObjectServer = __instance;
			localPlayerController.isInElevator = true;
			localPlayerController.isInHangarShipRoom = true;
			localPlayerController.DiscardHeldObject(true, (NetworkObject)null, position, false);
			localPlayerController.currentlyHeldObjectServer = currentlyHeldObjectServer;
			localPlayerController.isInElevator = isInElevator;
			localPlayerController.isInHangarShipRoom = isInHangarShipRoom;
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal class HUDManagerPatch
	{
		private static Image selfRed;

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void AwakePatch(HUDManager __instance)
		{
			//IL_004d: 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)
			((Behaviour)__instance.selfRedCanvasGroup).enabled = false;
			selfRed = GameObject.Find("Systems/UI/Canvas/IngamePlayerHUD/TopLeftCorner/SelfRed").GetComponent<Image>();
			selfRed.fillMethod = (FillMethod)1;
			selfRed.type = (Type)3;
			((Graphic)selfRed).color = Color32.op_Implicit(new Color32((byte)214, (byte)105, (byte)36, byte.MaxValue));
		}

		[HarmonyPatch("UpdateHealthUI")]
		[HarmonyPostfix]
		private static void UpdateHealthUIPatch(ref int health, ref bool hurtPlayer)
		{
			//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)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			if (health > 50)
			{
				((Graphic)selfRed).color = Color32.op_Implicit(new Color32((byte)214, (byte)105, (byte)36, byte.MaxValue));
			}
			else if (health > 30)
			{
				((Graphic)selfRed).color = Color32.op_Implicit(new Color32((byte)211, (byte)88, (byte)69, byte.MaxValue));
			}
			else
			{
				((Graphic)selfRed).color = Color32.op_Implicit(new Color32((byte)209, (byte)0, (byte)27, byte.MaxValue));
			}
			selfRed.fillAmount = (float)health / 100f;
		}
	}
	[HarmonyPatch(typeof(MenuManager))]
	internal class MenuManagerPatch
	{
		private static void UpdateLogo()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			Object.Destroy((Object)(object)GameObject.Find("Canvas/MenuContainer/MainButtons").GetComponent<Image>());
			GameObject val = GameObject.Find("Canvas/MenuContainer/MainButtons/HeaderImage");
			Image component = val.GetComponent<Image>();
			string fileName = Plugin.PluginFolder + "/Assets/Overworked.png";
			Sprite val2 = Utilities.FileToSprite(fileName);
			((Texture)val2.texture).filterMode = (FilterMode)0;
			val.transform.localScale = new Vector3(4f, 4f, 4f);
			val.transform.position = new Vector3(1092.387f, 640.6386f, -35.8852f);
			component.sprite = val2;
		}

		private static void UpdateLoadingScreen()
		{
			//IL_0069: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			Object.Destroy((Object)(object)GameObject.Find("Canvas/MenuContainer/LoadingScreen").GetComponent<Image>());
			GameObject val = GameObject.Find("Canvas/MenuContainer/LoadingScreen/Image");
			Image component = val.GetComponent<Image>();
			string fileName = Plugin.PluginFolder + "/Assets/Overworked.png";
			Sprite val2 = Utilities.FileToSprite(fileName);
			((Texture)val2.texture).filterMode = (FilterMode)0;
			component.sprite = val2;
			((Component)component).transform.localScale = new Vector3(4f, 4f, 4f);
			((Component)component).transform.position = new Vector3(1092.362f, 637f, -35.1465f);
			GameObject val3 = GameObject.Find("Canvas/MenuContainer/LoadingScreen/LoadingTextContainer");
			GameObject val4 = GameObject.Find("Canvas/MenuContainer/LoadingScreen/LoadingTextContainer/LoadingText");
			TextMeshProUGUI component2 = val4.GetComponent<TextMeshProUGUI>();
			val3.transform.position = new Vector3(1091.79f, 587.8602f, -36.6692f);
			((TMP_Text)component2).fontSize = 30f;
		}

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void AwakePatch()
		{
			UpdateLoadingScreen();
			UpdateLogo();
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePatch(PlayerControllerB __instance)
		{
			if (__instance.isInsideFactory && RoundManager.Instance.currentDungeonType == 4)
			{
				__instance.hinderedMultiplier = 0.5f;
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatch
	{
		[HarmonyPatch("LoadNewLevel")]
		[HarmonyPrefix]
		private static void LoadNewLevelPatch(ref int randomSeed, ref SelectableLevel newLevel)
		{
			string planetName = newLevel.PlanetName;
			string text = planetName;
			if (!(text == "20 Adamance"))
			{
				if (text == "68 Artifice")
				{
					newLevel.maxScrap = 31;
					newLevel.minScrap = 37;
				}
			}
			else
			{
				newLevel.maxScrap = 18;
				newLevel.minScrap = 16;
			}
			foreach (SpawnableEnemyWithRarity enemy in newLevel.Enemies)
			{
				string enemyName = enemy.enemyType.enemyName;
				string text2 = enemyName;
				if (text2 == "Cadaver Growths")
				{
					enemy.rarity = 0;
				}
			}
		}

		[HarmonyPatch("DespawnPropsAtEndOfRound")]
		[HarmonyPostfix]
		private static void DespawnPropsAtEndOfRoundPatch()
		{
			StartOfRoundPatch.TeleportAllItems(gameLoaded: true);
		}
	}
	[HarmonyPatch(typeof(ShotgunItem))]
	internal class ShotgunItemPatch
	{
		private static void UpdateShotgunShellCount(ShotgunItem __instance)
		{
			HUDManager.Instance.ChangeControlTip(1, "Fire (" + ((__instance.shellsLoaded > 0) ? __instance.shellsLoaded.ToString() : "empty") + ") : [LMB]", false);
		}

		[HarmonyPatch("ItemActivate")]
		[HarmonyPostfix]
		private static void ItemActivatePatch(ShotgunItem __instance)
		{
			UpdateShotgunShellCount(__instance);
		}

		[HarmonyPatch("SetControlTipsForItem")]
		[HarmonyPostfix]
		private static void SetControlTipsForItemPatch(ShotgunItem __instance)
		{
			UpdateShotgunShellCount(__instance);
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		private static MethodInfo teleportMethod = AccessTools.Method(typeof(StartOfRound), "TeleportPlayerInShipIfOutOfRoomBounds", (Type[])null, (Type[])null);

		private static bool wasInShip = false;

		private static Dictionary<string, Vector3> placements = new Dictionary<string, Vector3>
		{
			{
				"ScrapTwoHanded",
				new Vector3(-1.4633f, 0.2862f, -14.0595f)
			},
			{
				"ScrapOneHanded",
				new Vector3(0.1829f, 0.2862f, -14.0479f)
			},
			{
				"Pro-flashlight",
				new Vector3(7.7134f, 0.3565f, -14.1152f)
			},
			{
				"Shovel",
				new Vector3(8.9974f, 0.283f, -14.1425f)
			},
			{
				"Lockpicker",
				new Vector3(6.6094f, 0.3796f, -14.103f)
			},
			{
				"Weed killer",
				new Vector3(5.3645f, 0.7417f, -14.1853f)
			},
			{
				"Spray paint",
				new Vector3(4.6839f, 0.3617f, -13.9803f)
			},
			{
				"Walkie-talkie",
				new Vector3(4.1293f, 0.3417f, -14.1254f)
			},
			{
				"Stun grenade",
				new Vector3(3.4229f, 0.3009f, -13.9947f)
			},
			{
				"Extension ladder",
				new Vector3(7.8912f, 0.396f, -13.0898f)
			},
			{
				"Belt bag",
				new Vector3(6.547f, 0.6398f, -12.9742f)
			},
			{
				"Jetpack",
				new Vector3(5.6698f, 0.4417f, -13.0838f)
			},
			{
				"Key",
				new Vector3(4.0051f, 0.3117f, -13.084f)
			},
			{
				"Shotgun",
				new Vector3(4.7607f, 0.323f, -15.0969f)
			}
		};

		[HarmonyPatch("LateUpdate")]
		[HarmonyPrefix]
		private static bool LateUpdatePatch(StartOfRound __instance, ref float ___updatePlayerVoiceInterval)
		{
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: 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_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: 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_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null)
			{
				return false;
			}
			if (___updatePlayerVoiceInterval > 5f)
			{
				___updatePlayerVoiceInterval = 0f;
				__instance.UpdatePlayerVoiceEffects();
			}
			else
			{
				___updatePlayerVoiceInterval += Time.deltaTime;
			}
			if (!__instance.inShipPhase && __instance.shipDoorsEnabled && !__instance.suckingPlayersOutOfShip)
			{
				if (((Component)GameNetworkManager.Instance.localPlayerController).transform.position.y < -600f)
				{
					GameNetworkManager.Instance.localPlayerController.KillPlayer(Vector3.zero, false, (CauseOfDeath)2, 0, default(Vector3), false);
				}
				else if (GameNetworkManager.Instance.localPlayerController.thisController.isGrounded)
				{
					Bounds bounds = __instance.shipBounds.bounds;
					bool flag = ((Bounds)(ref bounds)).Contains(((Component)GameNetworkManager.Instance.localPlayerController).transform.position + Vector3.up * 0.25f);
					bounds = __instance.shipInnerRoomBounds.bounds;
					bool flag2 = ((Bounds)(ref bounds)).Contains(((Component)GameNetworkManager.Instance.localPlayerController).transform.position + Vector3.up * 0.25f);
					bool flag3 = flag || flag2;
					if (flag3)
					{
						GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom = true;
						GameNetworkManager.Instance.localPlayerController.SetAllItemsInElevator(true, true);
						if (!wasInShip)
						{
							GameNetworkManager.Instance.localPlayerController.isInElevator = true;
						}
					}
					else if (!flag3)
					{
						GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom = false;
						GameNetworkManager.Instance.localPlayerController.SetAllItemsInElevator(false, false);
						if (wasInShip)
						{
							GameNetworkManager.Instance.localPlayerController.isInElevator = false;
						}
					}
					wasInShip = flag3;
				}
				__instance.UpdateOcclusionCuller();
			}
			else if (!__instance.suckingPlayersOutOfShip)
			{
				teleportMethod.Invoke(__instance, null);
			}
			if (__instance.suckingPlayersOutOfShip)
			{
				__instance.starSphereObject.transform.position = ((Component)GameNetworkManager.Instance.localPlayerController).transform.position;
				__instance.currentPlanetPrefab.transform.position = ((Component)GameNetworkManager.Instance.localPlayerController).transform.position + new Vector3(-101f, -65f, 160f);
			}
			if (__instance.fearLevelIncreasing)
			{
				__instance.fearLevelIncreasing = false;
			}
			else if (GameNetworkManager.Instance.localPlayerController.isPlayerDead)
			{
				__instance.fearLevel -= Time.deltaTime * 0.5f;
			}
			else
			{
				__instance.fearLevel -= Time.deltaTime * 0.055f;
			}
			return false;
		}

		public static void TeleportAllItems(bool gameLoaded)
		{
			//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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: 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_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("Environment/HangarShip");
			GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
			GrabbableObject[] array2 = array;
			foreach (GrabbableObject val2 in array2)
			{
				val2.itemProperties.canBeGrabbedBeforeGameStart = true;
				Vector3 val3 = ((Component)val2).transform.position;
				Vector3 value3;
				if (val2.itemProperties.isScrap && !placements.ContainsKey(val2.itemProperties.itemName))
				{
					GrabbableObjectPatch.SetCollected(((Component)val2).gameObject.GetComponent<GrabbableObject>(), value: true);
					Vector3 value2;
					if (val2.itemProperties.twoHanded)
					{
						if (placements.TryGetValue("ScrapTwoHanded", out var value))
						{
							val3 = value;
						}
					}
					else if (placements.TryGetValue("ScrapOneHanded", out value2))
					{
						val3 = value2;
					}
				}
				else if (placements.TryGetValue(val2.itemProperties.itemName, out value3))
				{
					val3 = value3;
				}
				if (gameLoaded)
				{
					try
					{
						if (!val2.isHeld && val2.itemProperties.isScrap)
						{
							Vector3 position = val.transform.InverseTransformPoint(val3);
							GrabbableObjectPatch.TeleportItemInShipRPC(position, val2);
						}
					}
					catch (Exception)
					{
						Plugin.mls.LogInfo((object)"A scrap could not be teleported...");
					}
				}
				else
				{
					((Component)val2).gameObject.transform.position = val3;
					val2.targetFloorPosition = val3;
				}
			}
		}

		[HarmonyPatch("LoadShipGrabbableItems")]
		[HarmonyPostfix]
		private static void LoadShipGrabbableItemsPatch(StartOfRound __instance)
		{
			TeleportAllItems(gameLoaded: false);
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	internal class TerminalPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPrefix]
		private static void AwakePatch(ref Item[] ___buyableItemsList)
		{
			for (int i = 0; i < ___buyableItemsList.Length; i++)
			{
				Item val = ___buyableItemsList[i];
				string itemName = val.itemName;
				string text = itemName;
				if (!(text == "Pro-flashlight"))
				{
					if (text == "Extension ladder")
					{
						val.creditsWorth = 30;
					}
				}
				else
				{
					val.creditsWorth = 30;
				}
			}
		}
	}
	internal class Utilities
	{
		public static Sprite FileToSprite(string fileName)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			string text = Path.Combine(Plugin.PluginFolder, fileName);
			if (!File.Exists(text))
			{
				Debug.LogError((object)("Can't find " + text));
				return null;
			}
			byte[] array = File.ReadAllBytes(text);
			Texture2D val = new Texture2D(2, 2);
			ImageConversion.LoadImage(val, array);
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
		}
	}
}