Decompiled source of GtaLaunchOracle v1.1.9

GtaLaunchOracle/GtaLaunchOracle.dll

Decompiled 4 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Networking;

[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("GtaLaunchOracle")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.9.0")]
[assembly: AssemblyInformationalVersion("1.1.9")]
[assembly: AssemblyProduct("GtaLaunchOracle")]
[assembly: AssemblyTitle("GtaLaunchOracle")]
[assembly: AssemblyVersion("1.1.9.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 GtaLaunchOracle
{
	[BepInPlugin("novamods.valheim.gtalaunchoracle", "GTA Launch Oracle", "1.1.9")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class GtaLaunchOraclePlugin : BaseUnityPlugin
	{
		public const string ModGuid = "novamods.valheim.gtalaunchoracle";

		public const string ModName = "GTA Launch Oracle";

		public const string ModVersion = "1.1.9";

		public const string PieceName = "piece_nova_gta_oracle";

		private const string DefaultLaunchDate = "2026-11-19";

		private ConfigEntry<string> _launchDateLocal;

		private ConfigEntry<float> _soundVolume;

		private ConfigEntry<bool> _flipLogo;

		private ConfigEntry<float> _glassOpacity;

		private Texture2D _icon;

		private Texture2D _background;

		private Texture2D _logo;

		private Texture2D _logoShadow;

		private Texture2D _smoke;

		private AudioClip _useSoundClip;

		private AudioSource _audioSource;

		private float _messageEndsAt;

		private GUIStyle _titleStyle;

		private GUIStyle _countdownStyle;

		internal static GtaLaunchOraclePlugin Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
			_launchDateLocal = ((BaseUnityPlugin)this).Config.Bind<string>("Countdown", "LaunchDateLocal", "2026-11-19", "Date in YYYY-MM-DD. The timer ends at midnight on this date in the player's desktop local time zone.");
			_soundVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Audio", "UseSoundVolume", 1f, "Volume for the 10-second GTA audio clip, from 0 to 1.");
			_flipLogo = ((BaseUnityPlugin)this).Config.Bind<bool>("Visual", "FlipLogoHorizontally", true, "Flip the GTA VI wordmark's UVs. If the lettering appears mirrored, change this value and restart Valheim.");
			_glassOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "GlassOpacity", 0.04f, "Opacity of the glass shell, 0 to 0.2 recommended. The interior art is rendered after the shell for visibility.");
			_icon = LoadPng("GtaLaunchOracle.Assets.gta_icon.png");
			_background = LoadPng("GtaLaunchOracle.Assets.gta_background_disc.png");
			_logo = LoadPng("GtaLaunchOracle.Assets.gta_logo_float.png");
			_logoShadow = LoadPng("GtaLaunchOracle.Assets.gta_logo_shadow.png");
			_smoke = LoadPng("GtaLaunchOracle.Assets.smoke_soft.png");
			if ((Object)(object)_icon == (Object)null || (Object)(object)_background == (Object)null || (Object)(object)_logo == (Object)null || (Object)(object)_logoShadow == (Object)null || (Object)(object)_smoke == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"GTA Launch Oracle: an embedded artwork texture is missing. Registration aborted.");
				return;
			}
			_audioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
			_audioSource.playOnAwake = false;
			_audioSource.loop = false;
			_audioSource.spatialBlend = 0f;
			((MonoBehaviour)this).StartCoroutine(LoadUseSound());
			PrefabManager.OnVanillaPrefabsAvailable += RegisterPiece;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"GTA Launch Oracle 1.1.9 ready to register.");
		}

		private IEnumerator LoadUseSound()
		{
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "", "gta-san-andreas-abertura-oficial.mp3");
			if (!File.Exists(text))
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("GTA Oracle audio missing: " + text));
				yield break;
			}
			UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(new Uri(text).AbsoluteUri, (AudioType)13);
			try
			{
				yield return request.SendWebRequest();
				if (request.isNetworkError || request.isHttpError)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)("GTA Oracle audio load failed: " + request.error));
					yield break;
				}
				_useSoundClip = DownloadHandlerAudioClip.GetContent(request);
				if ((Object)(object)_useSoundClip != (Object)null)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)"GTA Oracle 10-second audio loaded.");
				}
			}
			finally
			{
				((IDisposable)request)?.Dispose();
			}
		}

		private void RegisterPiece()
		{
			//IL_0039: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			//IL_0139: 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_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Invalid comparison between Unknown and I4
			PrefabManager.OnVanillaPrefabsAvailable -= RegisterPiece;
			try
			{
				Sprite icon = Sprite.Create(_icon, new Rect(0f, 0f, (float)((Texture)_icon).width, (float)((Texture)_icon).height), new Vector2(0.5f, 0.5f), 100f);
				PieceConfig val = new PieceConfig();
				val.Name = "GTA Launch Oracle";
				val.Description = "A magical orb with GTA art floating inside. Press E for the release countdown.";
				val.PieceTable = "Hammer";
				val.Category = "Furniture";
				val.Usage = new string[2]
				{
					PieceUsages.Decor,
					PieceUsages.Furniture
				};
				val.Icon = icon;
				val.AllowedInDungeons = true;
				PieceConfig val2 = val;
				val2.AddRequirement("Wood", 1, true);
				CustomPiece val3 = new CustomPiece("piece_nova_gta_oracle", true, val2);
				GameObject piecePrefab = val3.PiecePrefab;
				if ((Object)(object)piecePrefab == (Object)null)
				{
					throw new InvalidOperationException("Jotunn did not make an oracle prefab.");
				}
				MeshRenderer component = piecePrefab.GetComponent<MeshRenderer>();
				if ((Object)(object)component != (Object)null)
				{
					((Renderer)component).enabled = false;
				}
				BoxCollider val4 = piecePrefab.GetComponent<BoxCollider>();
				if ((Object)(object)val4 == (Object)null)
				{
					val4 = piecePrefab.AddComponent<BoxCollider>();
				}
				val4.center = new Vector3(0f, 0.5f, 0f);
				val4.size = new Vector3(1.02f, 1.02f, 1.02f);
				((Collider)val4).isTrigger = false;
				if ((int)SystemInfo.graphicsDeviceType != 4)
				{
					BuildCrystalBall(piecePrefab);
				}
				piecePrefab.AddComponent<CrystalBallInteraction>();
				if (!PieceManager.Instance.AddPiece(val3))
				{
					((BaseUnityPlugin)this).Logger.LogError((object)"Jotunn rejected GTA Launch Oracle 1.1.9.");
				}
				else
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)"Registered GTA Launch Oracle 1.1.9: 1.0m crystal with cleaner floating logo and fixed countdown text.");
				}
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("GTA Oracle prefab registration failed: " + ex));
			}
		}

		private static Shader AvailableShader(params string[] names)
		{
			string[] array = names;
			for (int i = 0; i < array.Length; i++)
			{
				Shader val = Shader.Find(array[i]);
				if ((Object)(object)val != (Object)null && val.isSupported)
				{
					return val;
				}
			}
			Material[] array2 = Resources.FindObjectsOfTypeAll<Material>();
			foreach (Material val2 in array2)
			{
				if ((Object)(object)val2 == (Object)null || (Object)(object)val2.shader == (Object)null || !val2.shader.isSupported)
				{
					continue;
				}
				array = names;
				foreach (string text in array)
				{
					if (((Object)val2.shader).name == text)
					{
						return val2.shader;
					}
				}
			}
			return null;
		}

		private static Material AlphaMaterial(string name, Shader shader, Texture texture, Color tint, int queue)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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)
			Material val = new Material(shader)
			{
				name = name
			};
			if (val.HasProperty("_MainTex"))
			{
				val.SetTexture("_MainTex", texture);
			}
			if (val.HasProperty("_BaseMap"))
			{
				val.SetTexture("_BaseMap", texture);
			}
			if (val.HasProperty("_Color"))
			{
				val.SetColor("_Color", tint);
			}
			if (val.HasProperty("_BaseColor"))
			{
				val.SetColor("_BaseColor", tint);
			}
			if (val.HasProperty("_Mode"))
			{
				val.SetFloat("_Mode", 3f);
			}
			if (val.HasProperty("_SrcBlend"))
			{
				val.SetInt("_SrcBlend", 5);
			}
			if (val.HasProperty("_DstBlend"))
			{
				val.SetInt("_DstBlend", 10);
			}
			if (val.HasProperty("_ZWrite"))
			{
				val.SetInt("_ZWrite", 0);
			}
			if (val.HasProperty("_Cull"))
			{
				val.SetInt("_Cull", 2);
			}
			if (val.HasProperty("_Metallic"))
			{
				val.SetFloat("_Metallic", 0f);
			}
			if (val.HasProperty("_Glossiness"))
			{
				val.SetFloat("_Glossiness", 0.9f);
			}
			val.DisableKeyword("_ALPHATEST_ON");
			val.EnableKeyword("_ALPHABLEND_ON");
			val.DisableKeyword("_ALPHAPREMULTIPLY_ON");
			val.DisableKeyword("_EMISSION");
			if (val.HasProperty("_EmissionColor"))
			{
				val.SetColor("_EmissionColor", Color.black);
			}
			val.SetOverrideTag("RenderType", "Transparent");
			val.renderQueue = queue;
			return val;
		}

		private static Material OpaqueColour(string name, Shader shader, Color color)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_0021: 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)
			Material val = new Material(shader)
			{
				name = name
			};
			if (val.HasProperty("_Color"))
			{
				val.SetColor("_Color", color);
			}
			if (val.HasProperty("_BaseColor"))
			{
				val.SetColor("_BaseColor", color);
			}
			if (val.HasProperty("_MainTex"))
			{
				val.SetTexture("_MainTex", (Texture)(object)Texture2D.whiteTexture);
			}
			if (val.HasProperty("_BaseMap"))
			{
				val.SetTexture("_BaseMap", (Texture)(object)Texture2D.whiteTexture);
			}
			if (val.HasProperty("_Glossiness"))
			{
				val.SetFloat("_Glossiness", 0.65f);
			}
			if (val.HasProperty("_Metallic"))
			{
				val.SetFloat("_Metallic", 0f);
			}
			if (val.HasProperty("_Mode"))
			{
				val.SetFloat("_Mode", 0f);
			}
			if (val.HasProperty("_ZWrite"))
			{
				val.SetInt("_ZWrite", 1);
			}
			val.DisableKeyword("_ALPHABLEND_ON");
			val.DisableKeyword("_ALPHATEST_ON");
			val.renderQueue = 2500;
			return val;
		}

		private void BuildCrystalBall(GameObject root)
		{
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Expected O, but got Unknown
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Expected O, but got Unknown
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: 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_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			Shader val = AvailableShader("Standard");
			Shader val2 = AvailableShader("Standard", "Unlit/Transparent", "Legacy Shaders/Transparent/Diffuse");
			Shader val3 = AvailableShader("Particles/Standard Unlit", "Legacy Shaders/Particles/Alpha Blended", "Particles/Alpha Blended", "Sprites/Default");
			if ((Object)(object)val2 == (Object)null)
			{
				throw new InvalidOperationException("No supported transparent material shader is available. Refusing pink/opaque fallback.");
			}
			if ((Object)(object)val == (Object)null)
			{
				val = val2;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Oracle shaders: glass=" + ((Object)val2).name + ", art=" + ((Object)val2).name + ", smoke=" + (((Object)(object)val3 == (Object)null) ? "unavailable" : ((Object)val3).name)));
			GameObject val4 = new GameObject("Oracle 1.0m crystal origin");
			val4.layer = root.layer;
			val4.transform.SetParent(root.transform, false);
			val4.transform.localPosition = new Vector3(0f, 0.5f, 0f);
			float num = Mathf.Clamp(_glassOpacity.Value, 0f, 0.2f);
			if (num > 0.001f)
			{
				Material sharedMaterial = AlphaMaterial("Very faint cyan crystal glass", val2, (Texture)(object)Texture2D.whiteTexture, new Color(0.66f, 0.88f, 1f, num), 2910);
				GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0);
				((Object)obj).name = "Single transparent crystal surface";
				obj.layer = root.layer;
				obj.transform.SetParent(val4.transform, false);
				obj.transform.localScale = Vector3.one * 1f;
				Collider component = obj.GetComponent<Collider>();
				if ((Object)(object)component != (Object)null)
				{
					component.enabled = false;
				}
				((Renderer)obj.GetComponent<MeshRenderer>()).sharedMaterial = sharedMaterial;
			}
			GameObject val5 = new GameObject("GTA interior parallax scene");
			val5.layer = root.layer;
			val5.transform.SetParent(val4.transform, false);
			Material material = AlphaMaterial("Interior GTA scenery", val2, (Texture)(object)_background, new Color(0.9f, 0.95f, 1f, 1f), 3020);
			Material material2 = AlphaMaterial("Floating logo depth", val2, (Texture)(object)_logoShadow, Color.white, 3050);
			Material material3 = AlphaMaterial("Full resolution floating GTA VI logo", val2, (Texture)(object)_logo, Color.white, 3070);
			GameObject val6 = MeshObject(val5.transform, "Concave scenic circular back wall", BuildCircularDisk(0.39f, 96, 0.03f), material, new Vector3(0f, 0f, -0.11f));
			GameObject val7 = MeshObject(val5.transform, "Extruded wordmark shadow layer", BuildLogoMesh(_logoShadow, 0.31f, 0.238f, 140, 110, _flipLogo.Value), material2, new Vector3(-0.01f, -0.008f, 0.065f));
			GameObject val8 = MeshObject(val5.transform, "Separate floating GTA VI wordmark", BuildLogoMesh(_logo, 0.305f, 0.232f, 140, 110, _flipLogo.Value), material3, new Vector3(0f, 0f, 0.105f));
			CrystalInteriorFacing crystalInteriorFacing = val8.AddComponent<CrystalInteriorFacing>();
			crystalInteriorFacing.Pivot = val5.transform;
			crystalInteriorFacing.Scenery = val6.transform;
			crystalInteriorFacing.Logo = val8.transform;
			crystalInteriorFacing.LogoShadow = val7.transform;
			Material mat = OpaqueColour("Prismatic crystal rim", val, new Color(0.33f, 0.79f, 0.99f));
			Material mat2 = OpaqueColour("Pale blue rim glint", val, new Color(0.68f, 0.91f, 1f));
			CreateArc(val5.transform, "Glass crystal edge", 0.498f, 0.01f, mat, 0f, 360f, 0.01f);
			CreateArc(val5.transform, "Glass edge upper glint", 0.502f, 0.016f, mat2, 40f, 139f, 0.018f);
			CreateArc(val5.transform, "Glass edge lower glint", 0.498f, 0.007f, mat2, 215f, 274f, 0.014f);
			AddBlueLight(val4.transform);
			AddSmoke(root.transform, val3, 0.5f);
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Oracle geometry: 1.0m orb, interior disc r=.39 z=-.11; logo at z=.105; outer radius .50; logo flip=" + _flipLogo.Value));
		}

		private static GameObject MeshObject(Transform parent, string name, Mesh mesh, Material material, Vector3 localPosition)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_002a: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			GameObject val = new GameObject(name)
			{
				layer = ((Component)parent).gameObject.layer
			};
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPosition;
			val.AddComponent<MeshFilter>().sharedMesh = mesh;
			((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = material;
			return val;
		}

		private static Mesh BuildCircularDisk(float radius, int segments, float curvature)
		{
			//IL_001d: 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_0033: 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_0072: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Expected O, but got Unknown
			Vector3[] array = (Vector3[])(object)new Vector3[segments + 2];
			Vector2[] array2 = (Vector2[])(object)new Vector2[array.Length];
			int[] array3 = new int[segments * 3];
			array[0] = Vector3.zero;
			array2[0] = new Vector2(0.5f, 0.5f);
			for (int i = 0; i <= segments; i++)
			{
				float num = (float)i * MathF.PI * 2f / (float)segments;
				float num2 = Mathf.Cos(num) * radius;
				float num3 = Mathf.Sin(num) * radius;
				array[i + 1] = new Vector3(num2, num3, 0f - curvature);
				array2[i + 1] = new Vector2(0.5f + num2 / (radius * 2f), 0.5f + num3 / (radius * 2f));
				if (i < segments)
				{
					int num4 = 3 * i;
					array3[num4] = 0;
					array3[num4 + 1] = i + 1;
					array3[num4 + 2] = i + 2;
				}
			}
			Mesh val = new Mesh
			{
				name = "Interior GTA background disc",
				vertices = array,
				uv = array2,
				triangles = array3
			};
			val.RecalculateNormals();
			val.RecalculateBounds();
			return val;
		}

		private static Mesh BuildLogoMesh(Texture2D image, float halfWidth, float halfHeight, int columns, int rows, bool flipUV)
		{
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: 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_01b8: 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_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] array = (Vector3[])(object)new Vector3[(columns + 1) * (rows + 1)];
			Vector2[] array2 = (Vector2[])(object)new Vector2[array.Length];
			List<int> list = new List<int>(columns * rows * 4);
			for (int i = 0; i <= rows; i++)
			{
				for (int j = 0; j <= columns; j++)
				{
					float num = (float)j / (float)columns;
					float num2 = (float)i / (float)rows;
					int num3 = i * (columns + 1) + j;
					float num4 = (2f * num - 1f) * halfWidth;
					float num5 = (2f * num2 - 1f) * halfHeight;
					float num6 = 0.017f * (1f - num4 / halfWidth * (num4 / halfWidth));
					array[num3] = new Vector3(num4, num5, num6);
					array2[num3] = new Vector2(flipUV ? (1f - num) : num, num2);
				}
			}
			for (int k = 0; k < rows; k++)
			{
				for (int l = 0; l < columns; l++)
				{
					int num7 = k * (columns + 1) + l;
					int item = num7 + 1;
					int num8 = num7 + columns + 1;
					int item2 = num8 + 1;
					float num9 = (flipUV ? (1f - ((float)l + 0.5f) / (float)columns) : (((float)l + 0.5f) / (float)columns));
					float num10 = ((float)k + 0.5f) / (float)rows;
					if (!(image.GetPixelBilinear(num9, num10).a < 0.11f))
					{
						list.Add(num7);
						list.Add(item);
						list.Add(num8);
						list.Add(item);
						list.Add(item2);
						list.Add(num8);
					}
				}
			}
			Mesh val = new Mesh
			{
				name = "GTA logo alpha-trimmed floating 3D surface",
				vertices = array,
				uv = array2,
				triangles = list.ToArray()
			};
			val.RecalculateNormals();
			val.RecalculateBounds();
			return val;
		}

		private static void CreateArc(Transform parent, string name, float radius, float tube, Material mat, float startDegrees, float endDegrees, float depth)
		{
			//IL_00aa: 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_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_016a: 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_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Expected O, but got Unknown
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			float num = endDegrees - startDegrees;
			int num2 = Mathf.Max(8, Mathf.CeilToInt(128f * num / 360f));
			int num3 = 9;
			Vector3[] array = (Vector3[])(object)new Vector3[(num2 + 1) * num3];
			Vector2[] array2 = (Vector2[])(object)new Vector2[array.Length];
			int[] array3 = new int[num2 * 8 * 6];
			for (int i = 0; i <= num2; i++)
			{
				float num4 = (startDegrees + num * (float)i / (float)num2) * (MathF.PI / 180f);
				for (int j = 0; j <= 8; j++)
				{
					float num5 = MathF.PI * 2f * (float)j / 8f;
					float num6 = radius + tube * Mathf.Cos(num5);
					int num7 = i * num3 + j;
					array[num7] = new Vector3(num6 * Mathf.Cos(num4), num6 * Mathf.Sin(num4), tube * Mathf.Sin(num5));
					array2[num7] = new Vector2((float)i / (float)num2, (float)j / 8f);
				}
			}
			int num8 = 0;
			for (int k = 0; k < num2; k++)
			{
				for (int l = 0; l < 8; l++)
				{
					int num9 = k * num3 + l;
					array3[num8++] = num9;
					array3[num8++] = num9 + num3;
					array3[num8++] = num9 + 1;
					array3[num8++] = num9 + 1;
					array3[num8++] = num9 + num3;
					array3[num8++] = num9 + num3 + 1;
				}
			}
			Mesh val = new Mesh
			{
				name = name,
				vertices = array,
				uv = array2,
				triangles = array3
			};
			val.RecalculateNormals();
			val.RecalculateBounds();
			MeshObject(parent, name, val, mat, new Vector3(0f, 0f, depth));
		}

		private static void AddBlueLight(Transform parent)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Subtle blue crystal light")
			{
				layer = ((Component)parent).gameObject.layer
			};
			val.transform.SetParent(parent, false);
			Light obj = val.AddComponent<Light>();
			obj.type = (LightType)2;
			obj.color = new Color(0.38f, 0.73f, 1f);
			obj.intensity = 0.1f;
			obj.range = 1.1f;
			obj.shadows = (LightShadows)0;
		}

		private void AddSmoke(Transform parent, Shader shader, float centerY)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_004b: 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_006d: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: 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_00f0: 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_0103: 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_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: 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_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Expected O, but got Unknown
			//IL_01a7: 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_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: 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_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)shader == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"Oracle blue mist disabled: no supported particle shader.");
				return;
			}
			GameObject val = new GameObject("Feathered exterior blue mist");
			val.layer = ((Component)parent).gameObject.layer;
			val.transform.SetParent(parent, false);
			ParticleSystem val2 = val.AddComponent<ParticleSystem>();
			MainModule main = val2.main;
			((MainModule)(ref main)).loop = true;
			((MainModule)(ref main)).playOnAwake = true;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(1.5f, 2.8f);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.03f, 0.1f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(0.17f, 0.28f);
			((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(0.52f, 0.8f, 1f, 0.22f));
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)0;
			((MainModule)(ref main)).maxParticles = 90;
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0f);
			EmissionModule emission = val2.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(15f);
			ShapeModule shape = val2.shape;
			((ShapeModule)(ref shape)).enabled = true;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
			((ShapeModule)(ref shape)).radius = 0.52f;
			((ShapeModule)(ref shape)).radiusThickness = 0.11f;
			((ShapeModule)(ref shape)).position = new Vector3(0f, centerY, 0f);
			VelocityOverLifetimeModule velocityOverLifetime = val2.velocityOverLifetime;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)0;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = new MinMaxCurve(0.08f, 0.16f);
			ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			Gradient val3 = new Gradient();
			val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
			{
				new GradientColorKey(new Color(0.55f, 0.81f, 1f), 0f),
				new GradientColorKey(new Color(0.55f, 0.81f, 1f), 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[4]
			{
				new GradientAlphaKey(0f, 0f),
				new GradientAlphaKey(0.34f, 0.25f),
				new GradientAlphaKey(0.12f, 0.7f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val3);
			ParticleSystemRenderer component = ((Component)val2).GetComponent<ParticleSystemRenderer>();
			component.renderMode = (ParticleSystemRenderMode)0;
			component.maxParticleSize = 0.07f;
			Material sharedMaterial = AlphaMaterial("Soft edge blue smoke particle", shader, (Texture)(object)_smoke, Color.white, 3150);
			((Renderer)component).sharedMaterial = sharedMaterial;
			val.AddComponent<OracleSmokeStarter>();
		}

		private Texture2D LoadPng(string resource)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			try
			{
				using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource);
				if (stream == null)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)("Embedded oracle resource missing: " + resource));
					return null;
				}
				using MemoryStream memoryStream = new MemoryStream();
				stream.CopyTo(memoryStream);
				Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
				if (!ImageConversion.LoadImage(val, memoryStream.ToArray(), false))
				{
					return null;
				}
				((Object)val).name = resource;
				((Texture)val).wrapMode = (TextureWrapMode)1;
				((Texture)val).filterMode = (FilterMode)1;
				return val;
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Could not load embedded oracle artwork: " + ex));
				return null;
			}
		}

		internal void Announce()
		{
			_messageEndsAt = Time.unscaledTime + 10f;
			if (!((Object)(object)_audioSource == (Object)null) && !((Object)(object)_useSoundClip == (Object)null))
			{
				_audioSource.Stop();
				_audioSource.PlayOneShot(_useSoundClip, Mathf.Clamp01(_soundVolume.Value));
			}
		}

		private DateTime GetLocalLaunchDate()
		{
			if (!DateTime.TryParseExact(_launchDateLocal.Value, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var result))
			{
				result = DateTime.ParseExact("2026-11-19", "yyyy-MM-dd", CultureInfo.InvariantCulture);
			}
			return DateTime.SpecifyKind(result.Date, DateTimeKind.Unspecified);
		}

		private static TimeSpan Remaining(DateTime localDate)
		{
			try
			{
				return TimeZoneInfo.ConvertTimeToUtc(localDate, TimeZoneInfo.Local) - DateTime.UtcNow;
			}
			catch (ArgumentException)
			{
				return localDate - DateTime.Now;
			}
		}

		private void OnGUI()
		{
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			if (!(Time.unscaledTime >= _messageEndsAt))
			{
				if (_titleStyle == null)
				{
					InitStyles();
				}
				TimeSpan timeSpan = Remaining(GetLocalLaunchDate());
				string value;
				if (timeSpan.TotalSeconds > 0.0)
				{
					long num = (long)Math.Ceiling(timeSpan.TotalSeconds);
					long num2 = num / 86400;
					long num3 = num % 86400 / 3600;
					long num4 = num % 3600 / 60;
					long num5 = num % 60;
					value = string.Format(CultureInfo.InvariantCulture, "{0} DAYS  {1:00} HOURS  {2:00} MINUTES  {3:00} SECONDS", num2, num3, num4, num5);
				}
				else
				{
					value = "0 DAYS  00 HOURS  00 MINUTES  00 SECONDS";
				}
				float opacity = Mathf.Clamp01((_messageEndsAt - Time.unscaledTime) / 10f);
				Outlined(new Rect(0f, (float)Screen.height * 0.32f, (float)Screen.width, 88f), "GTA VI RELEASE", _titleStyle, opacity);
				Outlined(new Rect(0f, (float)Screen.height * 0.42f, (float)Screen.width, 62f), value, _countdownStyle, opacity);
			}
		}

		private void InitStyles()
		{
			//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_003e: 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_004c: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			float num = Mathf.Clamp((float)Screen.height / 1080f, 0.8f, 1.5f);
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				fontSize = Mathf.RoundToInt(52f * num),
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)4,
				clipping = (TextClipping)0
			};
			val.normal.textColor = new Color(1f, 0.69f, 0.13f, 1f);
			_titleStyle = val;
			GUIStyle val2 = new GUIStyle(_titleStyle)
			{
				fontSize = Mathf.RoundToInt(32f * num)
			};
			val2.normal.textColor = Color.white;
			_countdownStyle = val2;
		}

		private static void Outlined(Rect rect, string value, GUIStyle style, float opacity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_00a4: 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_00b9: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			Color color = GUI.color;
			GUI.color = new Color(0f, 0f, 0f, opacity * 0.96f);
			for (int i = -1; i <= 1; i++)
			{
				for (int j = -1; j <= 1; j++)
				{
					if (i != 0 || j != 0)
					{
						GUI.Label(new Rect(((Rect)(ref rect)).x + (float)i * 3f, ((Rect)(ref rect)).y + (float)j * 3f, ((Rect)(ref rect)).width, ((Rect)(ref rect)).height), value, style);
					}
				}
			}
			GUI.color = new Color(style.normal.textColor.r, style.normal.textColor.g, style.normal.textColor.b, opacity);
			GUI.Label(rect, value, style);
			GUI.color = color;
		}

		private void OnDestroy()
		{
			PrefabManager.OnVanillaPrefabsAvailable -= RegisterPiece;
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
		}
	}
	public sealed class CrystalInteriorFacing : MonoBehaviour
	{
		public Transform Pivot;

		public Transform Scenery;

		public Transform Logo;

		public Transform LogoShadow;

		private Camera _camera;

		private Vector3 _initialRight;

		private bool _hasOrientation;

		private void LateUpdate()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Invalid comparison between Unknown and I4
			if ((Object)(object)_camera == (Object)null || !((Behaviour)_camera).isActiveAndEnabled || (int)_camera.cameraType != 1)
			{
				_camera = FindCamera();
			}
			if ((Object)(object)_camera != (Object)null)
			{
				Face(_camera);
			}
		}

		private void OnWillRenderObject()
		{
			//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)Camera.current != (Object)null && (int)Camera.current.cameraType == 1)
			{
				Face(Camera.current);
			}
		}

		private static Camera FindCamera()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Invalid comparison between Unknown and I4
			if ((Object)(object)Camera.main != (Object)null && ((Behaviour)Camera.main).isActiveAndEnabled && (int)Camera.main.cameraType == 1)
			{
				return Camera.main;
			}
			Camera[] allCameras = Camera.allCameras;
			foreach (Camera val in allCameras)
			{
				if ((Object)(object)val != (Object)null && ((Behaviour)val).isActiveAndEnabled && (int)val.cameraType == 1)
				{
					return val;
				}
			}
			return null;
		}

		private void Face(Camera camera)
		{
			//IL_003f: 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_004f: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: 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_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Pivot == (Object)null || (Object)(object)Scenery == (Object)null || (Object)(object)Logo == (Object)null || (Object)(object)LogoShadow == (Object)null)
			{
				return;
			}
			Vector3 val = ((Component)camera).transform.position - Pivot.position;
			if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f))
			{
				if (!_hasOrientation)
				{
					_initialRight = (((Object)(object)Pivot.parent != (Object)null) ? Pivot.parent.right : Vector3.right);
					_hasOrientation = true;
				}
				Vector3 val2 = default(Vector3);
				((Vector3)(ref val2))..ctor(val.x, 0f, val.z);
				float num = ((((Vector3)(ref val2)).sqrMagnitude > 0.0001f) ? Mathf.Clamp(Vector3.Dot(((Vector3)(ref val2)).normalized, _initialRight), -1f, 1f) : 0f);
				Pivot.rotation = Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up);
				Scenery.localPosition = new Vector3(-0.016f * num, 0f, -0.11f);
				LogoShadow.localPosition = new Vector3(-0.01f + 0.018f * num, -0.008f, 0.065f);
				Logo.localPosition = new Vector3(0.028f * num, 0f, 0.105f);
			}
		}
	}
	public sealed class OracleSmokeStarter : MonoBehaviour
	{
		private void Start()
		{
			ParticleSystem component = ((Component)this).GetComponent<ParticleSystem>();
			if ((Object)(object)component != (Object)null && !component.isPlaying)
			{
				component.Play();
			}
		}
	}
	public sealed class CrystalBallInteraction : MonoBehaviour, Hoverable, Interactable
	{
		public string GetHoverName()
		{
			return "GTA Launch Oracle";
		}

		public float GetHoverOffset()
		{
			return 0f;
		}

		public string GetHoverText()
		{
			return "<color=orange>GTA Launch Oracle</color>\n[<color=yellow><b>E</b></color>] Press E to use";
		}

		public bool Interact(Humanoid user, bool hold, bool alt)
		{
			if (hold || !(user is Player) || (Object)(object)user != (Object)(object)Player.m_localPlayer)
			{
				return false;
			}
			if ((Object)(object)GtaLaunchOraclePlugin.Instance == (Object)null)
			{
				return false;
			}
			GtaLaunchOraclePlugin.Instance.Announce();
			return true;
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			return false;
		}
	}
}