Decompiled source of Zelda Lottery Shop v1.3.0

EmpressCustomShop1.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Empress_ShopLoaderAPI;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Omniscye")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+7caf00520587bc4705fdf22c05a4ce546279ff19")]
[assembly: AssemblyProduct("EmpressCustomShop1")]
[assembly: AssemblyTitle("EmpressCustomShop1")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 CustomShopMod
{
	[BepInPlugin("com.Omniscye.ZeldaLotteryShop", "Zelda Lottery Shop", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class MyShopPlugin : BaseUnityPlugin
	{
		private void Awake()
		{
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "shop"));
			if ((Object)(object)val != (Object)null)
			{
				GameObject val2 = val.LoadAsset<GameObject>("Module - Shop - N - Omni");
				if ((Object)(object)val2 != (Object)null)
				{
					ShopAPI.RegisterShop(val2, "Omniscye/ZeldaLotteryShop");
					((BaseUnityPlugin)this).Logger.LogInfo((object)"Zelda Lottery Shop registered successfully via Empress ShopAPI.");
				}
				else
				{
					((BaseUnityPlugin)this).Logger.LogError((object)"Zelda Lottery Shop: Prefab 'Module - Shop - N - Omni' not found in bundle!");
				}
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Zelda Lottery Shop: Failed to load AssetBundle 'shop'!");
			}
		}
	}
	public class GerudoTalker : MonoBehaviour
	{
		public float interactionDistance = 3f;

		public float rotationSpeed = 5f;

		public float textTypeSpeed = 0.05f;

		public AudioClip soundOpenDialog;

		public AudioClip soundCloseDialog;

		private AudioSource _a;

		private bool _b;

		private GameObject _p;

		private Text _t;

		private string _c = "";

		private Quaternion _o;

		private Coroutine _r;

		private List<string> _l = new List<string> { "The Taxman... such strength. He reminds me of the desert kings of old.", "I traveled far to find a mate worthy of a Gerudo. This 'Taxman' takes everything he wants. I like that.", "These 'Gremloblins' are pathetic. A single strike from a scimitar would end them.", "I brought my treasures here, but this 'Company' only wants scrap metal. Insulting.", "Is the Taxman single? I must know his status immediately.", "Why do you run from the monsters? A warrior stands their ground! Fight!", "This facility is cold. It lacks the warmth of the desert sands.", "I heard the Taxman demands a quota. A demanding leader ensures the strength of the tribe.", "Do you have any gemstones? This rusty metal you collect is beneath me.", "One day I will present the Taxman with a Golden Trophy. Then he will notice me." };

		private void Start()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			_o = ((Component)this).transform.rotation;
			_a = ((Component)this).gameObject.AddComponent<AudioSource>();
			_a.spatialBlend = 1f;
			_a.minDistance = 1f;
			_a.maxDistance = 10f;
			U();
		}

		private void Update()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			if (!_b)
			{
				((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, _o, Time.deltaTime * rotationSpeed);
			}
			if (!Object.op_Implicit((Object)(object)PlayerAvatar.instance))
			{
				return;
			}
			float num = Vector3.Distance(((Component)this).transform.position, ((Component)PlayerAvatar.instance).transform.position);
			if (num <= interactionDistance)
			{
				if (InputManager.instance.KeyDown((InputKey)2))
				{
					if (!_b)
					{
						S();
					}
					else
					{
						E();
					}
				}
				else if (_b && (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271)))
				{
					E();
				}
			}
			else if (_b && num > interactionDistance)
			{
				E();
			}
			if (_b)
			{
				H();
			}
		}

		private void H()
		{
			//IL_0025: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)PlayerController.instance))
			{
				PlayerController.instance.InputDisable(0.1f);
				PlayerController.instance.rb.velocity = Vector3.zero;
			}
			if (Object.op_Implicit((Object)(object)PlayerAvatar.instance))
			{
				Vector3 position = ((Component)PlayerAvatar.instance).transform.position;
				position.y = ((Component)this).transform.position.y;
				if (position - ((Component)this).transform.position != Vector3.zero)
				{
					((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, Quaternion.LookRotation(position - ((Component)this).transform.position), Time.deltaTime * rotationSpeed);
				}
			}
		}

		private void S()
		{
			_b = true;
			_c = _l[Random.Range(0, _l.Count)];
			if (Object.op_Implicit((Object)(object)_p))
			{
				_p.SetActive(true);
			}
			if (Object.op_Implicit((Object)(object)soundOpenDialog))
			{
				_a.PlayOneShot(soundOpenDialog);
			}
			if (_r != null)
			{
				((MonoBehaviour)this).StopCoroutine(_r);
			}
			_r = ((MonoBehaviour)this).StartCoroutine(T(_c));
		}

		private void E()
		{
			_b = false;
			if (Object.op_Implicit((Object)(object)_p))
			{
				_p.SetActive(false);
			}
			if (Object.op_Implicit((Object)(object)soundCloseDialog))
			{
				_a.PlayOneShot(soundCloseDialog);
			}
			if (_r != null)
			{
				((MonoBehaviour)this).StopCoroutine(_r);
			}
			if (Object.op_Implicit((Object)(object)_t))
			{
				_t.text = "";
			}
		}

		private IEnumerator T(string l)
		{
			_t.text = "";
			foreach (char c in l)
			{
				Text t = _t;
				t.text += c;
				yield return (object)new WaitForSeconds(textTypeSpeed);
			}
		}

		private void U()
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_0098: 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_00cd: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Expected O, but got Unknown
			//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_0043: 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_0172: 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_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: 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)
			Transform val = (Object.op_Implicit((Object)(object)HUDCanvas.instance) ? ((Component)HUDCanvas.instance).transform : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				GameObject val2 = new GameObject("GerudoDialogCanvas");
				Canvas obj = val2.AddComponent<Canvas>();
				obj.renderMode = (RenderMode)0;
				obj.sortingOrder = 999;
				val2.AddComponent<CanvasScaler>();
				val2.AddComponent<GraphicRaycaster>();
				val = val2.transform;
			}
			_p = new GameObject("GerudoPanel");
			_p.transform.SetParent(val, false);
			((Graphic)_p.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.8f);
			RectTransform component = _p.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0.1f, 0.1f);
			component.anchorMax = new Vector2(0.9f, 0.3f);
			Vector2 offsetMin = (component.offsetMax = Vector2.zero);
			component.offsetMin = offsetMin;
			GameObject val3 = new GameObject("GerudoText");
			val3.transform.SetParent(_p.transform, false);
			_t = val3.AddComponent<Text>();
			Font font = ((IEnumerable<Font>)Resources.FindObjectsOfTypeAll<Font>()).FirstOrDefault((Func<Font, bool>)((Font x) => ((Object)x).name == "Arial")) ?? Resources.FindObjectsOfTypeAll<Font>().FirstOrDefault() ?? Font.CreateDynamicFontFromOSFont("Arial", 16);
			_t.font = font;
			((Graphic)_t).color = Color.white;
			_t.alignment = (TextAnchor)0;
			_t.resizeTextForBestFit = true;
			_t.resizeTextMinSize = 14;
			_t.resizeTextMaxSize = 35;
			_t.verticalOverflow = (VerticalWrapMode)0;
			RectTransform component2 = val3.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0.02f, 0.1f);
			component2.anchorMax = new Vector2(0.98f, 0.9f);
			offsetMin = (component2.offsetMax = Vector2.zero);
			component2.offsetMin = offsetMin;
			_p.SetActive(false);
		}

		private void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)_p))
			{
				Object.Destroy((Object)(object)_p);
			}
		}
	}
}