Decompiled source of FurnitureDeconstructor v1.0.1

Antro.FurnitureDeconstructor.dll

Decompiled 12 hours ago
using System;
using System.Collections;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Networking;
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(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Antro.FurnitureDeconstructor")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Antro.FurnitureDeconstructor")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.0")]
[assembly: AssemblyProduct("Antro.FurnitureDeconstructor")]
[assembly: AssemblyTitle("Antro.FurnitureDeconstructor")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 FurnitureDeconstructMod
{
	[BepInPlugin("Antro.gnome_deconstruct", "Furniture Deconstruct Mod", "1.7.0")]
	public class FurnitureDeconstructPlugin : BaseUnityPlugin
	{
		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			Harmony val = new Harmony("Antro.gnome_deconstruct");
			val.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Furniture Deconstruct Mod 1.7.0 loaded!");
		}
	}
	[HarmonyPatch(typeof(PlayerNetworking), "OnEntitySpawned")]
	public class PlayerSpawnPatch
	{
		private static void Postfix(PlayerNetworking __instance)
		{
			if (((NetworkBehaviour)__instance).IsServer && ((NetworkBehaviour)__instance).IsLocalPlayer)
			{
				((Component)__instance).gameObject.AddComponent<FurnitureDeconstructComponent>();
			}
		}
	}
	public class FurnitureDeconstructComponent : MonoBehaviour
	{
		[Header("Settings")]
		public KeyCode deconstructKey = (KeyCode)102;

		public float requiredHoldTime = 1.5f;

		public float interactionDistance = 4f;

		private float currentHoldTime = 0f;

		private Furniture targetFurniture = null;

		private bool isUiOpen = false;

		private bool isLookingAtValidFurniture = false;

		private bool uiStolen = false;

		private PlayerNetworking localPlayer;

		private CraftingRecipes allRecipes;

		private AllItems allItemsManager;

		private Sprite customPanelSprite;

		private Sprite customButtonSprite;

		private readonly List<string> blacklist = new List<string> { "stockpile", "gamebutton", "medicalterminal", "gnomehouse", "graphics" };

		private void Start()
		{
			localPlayer = ((Component)this).GetComponent<PlayerNetworking>();
		}

		private void EnsureManagersLoaded()
		{
			if ((Object)(object)allRecipes == (Object)null)
			{
				CraftingRecipes[] array = Resources.FindObjectsOfTypeAll<CraftingRecipes>();
				if (array.Length != 0)
				{
					allRecipes = array[0];
				}
			}
			if ((Object)(object)allItemsManager == (Object)null)
			{
				AllItems[] array2 = Resources.FindObjectsOfTypeAll<AllItems>();
				if (array2.Length != 0)
				{
					allItemsManager = array2[0];
				}
			}
		}

		private void TryStealUI()
		{
			if (uiStolen)
			{
				return;
			}
			Image[] array = Resources.FindObjectsOfTypeAll<Image>();
			Image[] array2 = array;
			foreach (Image val in array2)
			{
				if (!((Object)(object)val.sprite == (Object)null) && !((Object)(object)((Component)val).transform.parent == (Object)null))
				{
					if (((Object)((Component)val).gameObject).name == "Image" && ((Object)((Component)val).transform.parent).name == "Settings")
					{
						customPanelSprite = val.sprite;
					}
					if (((Object)((Component)val).gameObject).name == "Bg" && ((Object)((Component)val).transform.parent).name.Contains("SGButtonPrimaryUGUI"))
					{
						customButtonSprite = val.sprite;
					}
				}
			}
			if ((Object)(object)customPanelSprite != (Object)null || (Object)(object)customButtonSprite != (Object)null)
			{
				uiStolen = true;
			}
		}

		private void Update()
		{
			//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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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_00ba: 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_00e6: 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_018e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)localPlayer == (Object)null || !((NetworkBehaviour)localPlayer).IsServer || !((NetworkBehaviour)localPlayer).IsLocalPlayer || isUiOpen)
			{
				return;
			}
			Camera main = Camera.main;
			if ((Object)(object)main == (Object)null)
			{
				return;
			}
			EnsureManagersLoaded();
			Vector3 position = ((Component)main).transform.position;
			Vector3 forward = ((Component)main).transform.forward;
			Furniture val = null;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(position, forward, ref val2, interactionDistance, -5, (QueryTriggerInteraction)1))
			{
				val = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<Furniture>();
			}
			if ((Object)(object)val == (Object)null)
			{
				RaycastHit[] array = Physics.SphereCastAll(position, 0.2f, forward, interactionDistance, -5, (QueryTriggerInteraction)1);
				float num = float.MaxValue;
				RaycastHit[] array2 = array;
				for (int i = 0; i < array2.Length; i++)
				{
					RaycastHit val3 = array2[i];
					if (!((Object)(object)((Component)((RaycastHit)(ref val3)).collider).transform.root == (Object)(object)((Component)localPlayer).transform.root))
					{
						Furniture componentInParent = ((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent<Furniture>();
						if ((Object)(object)componentInParent != (Object)null && ((RaycastHit)(ref val3)).distance < num)
						{
							num = ((RaycastHit)(ref val3)).distance;
							val = componentInParent;
						}
					}
				}
			}
			if ((Object)(object)val != (Object)null && !IsBlacklisted(val))
			{
				isLookingAtValidFurniture = true;
				if (Input.GetKey(deconstructKey))
				{
					TryStealUI();
					currentHoldTime += Time.deltaTime;
					if (currentHoldTime >= requiredHoldTime)
					{
						targetFurniture = val;
						OpenConfirmationUI();
						currentHoldTime = 0f;
						isLookingAtValidFurniture = false;
					}
				}
				else
				{
					currentHoldTime = 0f;
				}
			}
			else
			{
				isLookingAtValidFurniture = false;
				currentHoldTime = 0f;
			}
		}

		private bool IsBlacklisted(Furniture f)
		{
			if ((Object)(object)f == (Object)null)
			{
				return true;
			}
			string text = ((Object)((Component)f).gameObject).name.ToLower();
			string text2 = (((Object)(object)f.FurnitureData != (Object)null) ? ((Object)f.FurnitureData).name.ToLower() : "");
			foreach (string item in blacklist)
			{
				if (text.Contains(item) || text2.Contains(item))
				{
					return true;
				}
			}
			return false;
		}

		private void OpenConfirmationUI()
		{
			isUiOpen = true;
			if ((Object)(object)localPlayer.Controller != (Object)null)
			{
				localPlayer.Controller.ShowCursor(true);
			}
		}

		private void CloseConfirmationUI()
		{
			isUiOpen = false;
			targetFurniture = null;
			if ((Object)(object)localPlayer.Controller != (Object)null)
			{
				localPlayer.Controller.ShowCursor(false);
			}
		}

		private void ConfirmDeconstruct()
		{
			if ((Object)(object)targetFurniture != (Object)null && NetworkManager.Singleton.IsServer)
			{
				RefundResourcesWithScanner(targetFurniture.FurnitureData);
				try
				{
					if ((Object)(object)((NetworkBehaviour)targetFurniture).NetworkObject != (Object)null)
					{
						((NetworkBehaviour)targetFurniture).NetworkObject.Despawn(true);
					}
				}
				catch (Exception ex)
				{
					Debug.LogWarning((object)("[Deconstruct Mod] Ignored Despawn Warning: " + ex.Message));
				}
			}
			CloseConfirmationUI();
		}

		private InventoryBase GetStockpileInventory()
		{
			try
			{
				GameProgressionManager instance = GameProgressionManager.Instance;
				if ((Object)(object)instance != (Object)null && (Object)(object)instance.Deposit != (Object)null && (Object)(object)instance.Deposit.ResourceInventory != (Object)null)
				{
					return instance.Deposit.ResourceInventory;
				}
			}
			catch
			{
			}
			GnomiumDeposit val = Object.FindFirstObjectByType<GnomiumDeposit>();
			if ((Object)(object)val != (Object)null)
			{
				return val.ResourceInventory;
			}
			return null;
		}

		private void RefundResourcesWithScanner(FurnitureData fData)
		{
			//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_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_01c4: 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_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)fData == (Object)null)
			{
				return;
			}
			if ((Object)(object)allRecipes == (Object)null)
			{
				Debug.LogError((object)"[Deconstruct Mod] allRecipes is missing! Cannot refund.");
				return;
			}
			InventoryBase stockpileInventory = GetStockpileInventory();
			if ((Object)(object)stockpileInventory == (Object)null)
			{
				Debug.LogWarning((object)"[Deconstruct Mod] Stockpile inventory not found! Resources might not be saved.");
			}
			bool flag = false;
			Recipe[] recipes = allRecipes.recipes;
			int num2 = default(int);
			foreach (Recipe val in recipes)
			{
				if (!((Object)(object)val.CraftResult != (Object)null) || !(((Object)val.CraftResult).name == ((Object)fData).name))
				{
					continue;
				}
				flag = true;
				Vector3 val2 = ((Component)targetFurniture).transform.position + Vector3.up * 0.5f;
				ItemCost[] cost = val.cost;
				foreach (ItemCost val3 in cost)
				{
					if ((Object)(object)val3.item == (Object)null)
					{
						continue;
					}
					int num = Mathf.Max(1, Mathf.FloorToInt((float)val3.amount * 0.7f));
					string text = ((Object)val3.item).name.ToLower();
					if (ResourceStorage.TryGetItemEntry(text, ref num2))
					{
						if ((Object)(object)stockpileInventory != (Object)null && NetworkManager.Singleton.IsServer)
						{
							stockpileInventory.TryAddItem(((Object)val3.item).name, num);
							Debug.Log((object)$"[Deconstruct Mod] Added {num}x {((Object)val3.item).name} to the Base Stockpile!");
						}
					}
					else
					{
						if (!((Object)(object)allItemsManager != (Object)null))
						{
							continue;
						}
						for (int k = 0; k < num; k++)
						{
							Vector2 val4 = Random.insideUnitCircle * 0.3f;
							Vector3 val5 = val2 + new Vector3(val4.x, 0f, val4.y);
							ItemInstance val6 = allItemsManager.SpawnItemInstance(((Object)val3.item).name, val5);
							if ((Object)(object)val6 != (Object)null)
							{
								Rigidbody component = ((Component)val6).GetComponent<Rigidbody>();
								if ((Object)(object)component != (Object)null)
								{
									component.position = val5;
									component.AddForce(Vector3.up * 1.5f, (ForceMode)1);
								}
							}
						}
						Debug.Log((object)$"[Deconstruct Mod] Dropped {num}x {((Object)val3.item).name} on the floor.");
					}
				}
				break;
			}
			if (!flag)
			{
				Debug.LogWarning((object)("[Deconstruct Mod] Could not find recipe for " + ((Object)fData).name));
			}
		}

		private void DrawSpriteRect(Rect rect, Sprite sprite)
		{
			//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_006f: 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)
			if ((Object)(object)sprite != (Object)null && (Object)(object)sprite.texture != (Object)null)
			{
				Rect textureRect = sprite.textureRect;
				Texture2D texture = sprite.texture;
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(((Rect)(ref textureRect)).x / (float)((Texture)texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)texture).height, ((Rect)(ref textureRect)).width / (float)((Texture)texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)texture).height);
				GUI.DrawTextureWithTexCoords(rect, (Texture)(object)texture, val);
			}
		}

		private void OnGUI()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_0032: Expected O, but got Unknown
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Expected O, but got Unknown
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Expected O, but got Unknown
			//IL_027a: 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_0094: 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_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Expected O, but got Unknown
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: 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_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: 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_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			GUI.depth = -100;
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				fontSize = 30,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)4
			};
			if (isUiOpen)
			{
				float num = 600f;
				float num2 = 350f;
				Rect val2 = default(Rect);
				((Rect)(ref val2))..ctor(((float)Screen.width - num) / 2f, ((float)Screen.height - num2) / 2f, num, num2);
				if ((Object)(object)customPanelSprite != (Object)null)
				{
					DrawSpriteRect(val2, customPanelSprite);
				}
				else
				{
					GUI.Box(val2, "");
				}
				Rect val3 = default(Rect);
				((Rect)(ref val3))..ctor(((Rect)(ref val2)).x + 20f, ((Rect)(ref val2)).y + 20f, num - 40f, 220f);
				GUI.Label(val3, "Are you sure you want to deconstruct?\n\n70% of resources will be\nrefunded to the Stockpile.", val);
				GUIStyle val4 = new GUIStyle(GUI.skin.label)
				{
					fontSize = 32,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)4
				};
				Rect val5 = default(Rect);
				((Rect)(ref val5))..ctor(((Rect)(ref val2)).x + 80f, ((Rect)(ref val2)).y + 230f, 180f, 90f);
				GUI.color = new Color(0.8f, 1f, 0.8f);
				if ((Object)(object)customButtonSprite != (Object)null)
				{
					DrawSpriteRect(val5, customButtonSprite);
				}
				else
				{
					GUI.Box(val5, "");
				}
				if (GUI.Button(val5, "Yes", val4))
				{
					ConfirmDeconstruct();
				}
				Rect val6 = default(Rect);
				((Rect)(ref val6))..ctor(((Rect)(ref val2)).x + 340f, ((Rect)(ref val2)).y + 230f, 180f, 90f);
				GUI.color = new Color(1f, 0.8f, 0.8f);
				if ((Object)(object)customButtonSprite != (Object)null)
				{
					DrawSpriteRect(val6, customButtonSprite);
				}
				else
				{
					GUI.Box(val6, "");
				}
				if (GUI.Button(val6, "No", val4))
				{
					CloseConfirmationUI();
				}
				GUI.color = Color.white;
			}
			else if (isLookingAtValidFurniture)
			{
				GUIStyle val7 = new GUIStyle(val)
				{
					fontSize = 38
				};
				val7.normal.textColor = Color.white;
				GUIStyle val8 = new GUIStyle(val7);
				val8.normal.textColor = Color.black;
				string text = $"Hold [{deconstructKey}] to Deconstruct";
				if (currentHoldTime > 0f)
				{
					int num3 = (int)Mathf.Clamp(currentHoldTime / requiredHoldTime * 100f, 0f, 100f);
					text = $"Deconstructing... {num3}%";
				}
				Rect val9 = default(Rect);
				((Rect)(ref val9))..ctor(0f, (float)Screen.height / 2f + 60f, (float)Screen.width, 60f);
				GUI.Label(new Rect(((Rect)(ref val9)).x + 3f, ((Rect)(ref val9)).y + 3f, ((Rect)(ref val9)).width, ((Rect)(ref val9)).height), text, val8);
				GUI.Label(val9, text, val7);
			}
		}
	}
}
namespace DiscordInviteMod
{
	[BepInPlugin("Antro.discord_invite", "Discord Invite Button", "1.0.2")]
	public class DiscordInvitePlugin : BaseUnityPlugin
	{
		private const string SharedObjectName = "SharedDiscordInviteButton_BG";

		private void Awake()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			if ((Object)(object)GameObject.Find("SharedDiscordInviteButton_BG") == (Object)null)
			{
				GameObject val = new GameObject("SharedDiscordInviteButton_BG");
				Object.DontDestroyOnLoad((Object)(object)val);
				val.AddComponent<DiscordInviteComponent>();
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Discord Invite Button initialized successfully!");
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Discord Invite Button already exists from another mod. Skipping creation.");
			}
		}
	}
	public class DiscordInviteComponent : MonoBehaviour
	{
		private readonly string discordUrl = "https://discord.gg/bPjcrJxBmP";

		private readonly string logoUrl = "https://i.imgur.com/48jKo1r_d.png?maxwidth=520&shape=thumb&fidelity=high";

		private readonly string arrowUrl = "https://i.imgur.com/TUT8ICu_d.png?maxwidth=520&shape=thumb&fidelity=high";

		private readonly float logoSize = 300f;

		private readonly float padding = 40f;

		private readonly float arrowSize = 160f;

		private readonly float baseRadius = 260f;

		private readonly float animAmplitude = 25f;

		private readonly float animSpeed = 5f;

		private Texture2D logoTexture;

		private Texture2D arrowTexture;

		private GUIStyle transparentStyle;

		private string folderPath;

		private bool hasClickedLogo = false;

		private const string PrefsKey = "Antro_DiscordInvite_HasClicked";

		private bool isBrandingVisible = false;

		private void Start()
		{
			hasClickedLogo = PlayerPrefs.GetInt("Antro_DiscordInvite_HasClicked", 0) == 1;
			folderPath = Path.Combine(Paths.PluginPath, "DiscordInviteMod");
			if (!Directory.Exists(folderPath))
			{
				Directory.CreateDirectory(folderPath);
			}
			((MonoBehaviour)this).StartCoroutine(LoadOrDownloadImage(logoUrl, "DiscordLogoCache.png", delegate(Texture2D result)
			{
				logoTexture = result;
			}));
			if (!hasClickedLogo)
			{
				((MonoBehaviour)this).StartCoroutine(LoadOrDownloadImage(arrowUrl, "DiscordArrowCache.png", delegate(Texture2D result)
				{
					arrowTexture = result;
				}));
			}
			((MonoBehaviour)this).StartCoroutine(CheckBrandingVisibility());
		}

		private IEnumerator CheckBrandingVisibility()
		{
			while (true)
			{
				GameObject branding = GameObject.Find("Branding (1)");
				isBrandingVisible = (Object)(object)branding != (Object)null && branding.activeInHierarchy;
				yield return (object)new WaitForSeconds(0.5f);
			}
		}

		private IEnumerator LoadOrDownloadImage(string url, string fileName, Action<Texture2D> onLoaded)
		{
			string localPath = Path.Combine(folderPath, fileName);
			if (File.Exists(localPath))
			{
				string fileUrl = "file://" + localPath.Replace("\\", "/");
				UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(fileUrl);
				try
				{
					yield return uwr.SendWebRequest();
					if ((int)uwr.result == 1)
					{
						onLoaded?.Invoke(DownloadHandlerTexture.GetContent(uwr));
						yield break;
					}
				}
				finally
				{
					((IDisposable)uwr)?.Dispose();
				}
			}
			UnityWebRequest uwr2 = UnityWebRequestTexture.GetTexture(url);
			try
			{
				yield return uwr2.SendWebRequest();
				if ((int)uwr2.result == 1)
				{
					Texture2D tex = DownloadHandlerTexture.GetContent(uwr2);
					onLoaded?.Invoke(tex);
					try
					{
						File.WriteAllBytes(localPath, uwr2.downloadHandler.data);
					}
					catch
					{
					}
				}
			}
			finally
			{
				((IDisposable)uwr2)?.Dispose();
			}
		}

		private void OnGUI()
		{
			//IL_0271: 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_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Expected O, but got Unknown
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Expected O, but got Unknown
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			if (!isBrandingVisible || ((Object)(object)NetworkManager.Singleton != (Object)null && (NetworkManager.Singleton.IsClient || NetworkManager.Singleton.IsServer)))
			{
				return;
			}
			GUI.depth = -1000;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor((float)Screen.width - logoSize - padding, padding, logoSize, logoSize);
			if (!hasClickedLogo && (Object)(object)logoTexture != (Object)null && (Object)(object)arrowTexture != (Object)null)
			{
				float num = ((Rect)(ref val)).x + logoSize / 2f;
				float num2 = ((Rect)(ref val)).y + logoSize / 2f;
				float[,] array = new float[3, 3]
				{
					{
						(float)Math.PI,
						90f,
						0f
					},
					{
						(float)Math.PI * 3f / 4f,
						45f,
						2f
					},
					{
						(float)Math.PI / 2f,
						0f,
						4f
					}
				};
				Rect val2 = default(Rect);
				for (int i = 0; i < 3; i++)
				{
					float num3 = array[i, 0];
					float num4 = array[i, 1];
					float num5 = array[i, 2];
					float num6 = baseRadius + Mathf.Sin(Time.realtimeSinceStartup * animSpeed + num5) * animAmplitude;
					float num7 = num + Mathf.Cos(num3) * num6;
					float num8 = num2 + Mathf.Sin(num3) * num6;
					((Rect)(ref val2))..ctor(num7 - arrowSize / 2f, num8 - arrowSize / 2f, arrowSize, arrowSize);
					Matrix4x4 matrix = GUI.matrix;
					GUIUtility.RotateAroundPivot(num4, new Vector2(num7, num8));
					GUI.DrawTexture(val2, (Texture)(object)arrowTexture, (ScaleMode)2, true);
					GUI.matrix = matrix;
				}
			}
			if ((Object)(object)logoTexture != (Object)null)
			{
				if (transparentStyle == null)
				{
					transparentStyle = new GUIStyle(GUI.skin.button);
					transparentStyle.normal.background = null;
					transparentStyle.hover.background = null;
					transparentStyle.active.background = null;
				}
				if (GUI.Button(val, (Texture)(object)logoTexture, transparentStyle))
				{
					HandleLogoClick();
				}
			}
			else
			{
				GUIStyle val3 = new GUIStyle(GUI.skin.button)
				{
					fontSize = 14,
					fontStyle = (FontStyle)1
				};
				if (GUI.Button(new Rect((float)(Screen.width - 150) - padding, padding, 150f, 50f), "Discord", val3))
				{
					HandleLogoClick();
				}
			}
		}

		private void HandleLogoClick()
		{
			if (!hasClickedLogo)
			{
				hasClickedLogo = true;
				PlayerPrefs.SetInt("Antro_DiscordInvite_HasClicked", 1);
				PlayerPrefs.Save();
				if ((Object)(object)arrowTexture != (Object)null)
				{
					Object.Destroy((Object)(object)arrowTexture);
					arrowTexture = null;
				}
			}
			Application.OpenURL(discordUrl);
		}
	}
}