using System;
using DarkTonic.MasterAudio;
using UnityEngine;
using UnityEngine.EventSystems;

// Token: 0x020000CD RID: 205
public class Pointer : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerDownHandler, IPointerUpHandler
{
	// Token: 0x060012E6 RID: 4838 RVA: 0x0016FB88 File Offset: 0x0016DD88
	private void Awake()
	{
		if (this.inWindow)
		{
			this.skillBag = base.gameObject.transform.parent.gameObject.transform.parent.gameObject.transform.parent.gameObject.GetComponent<Windows>().linkedPortrait.skillBag;
		}
	}

	// Token: 0x060012E7 RID: 4839 RVA: 0x0016FBE8 File Offset: 0x0016DDE8
	public void OnPointerEnter(PointerEventData eventData)
	{
		Links.x.gameplay.uiCanClick = true;
		if (this.inWindow)
		{
			this.skillBag.TooltipOn(null, base.gameObject, base.gameObject.name, false);
		}
		if (this.inWheel)
		{
			Links.x.pocketWheel.SetHoverText(true, base.gameObject);
			if (Links.x.joy)
			{
				Links.x.pocketWheel.ControllerSelect(base.gameObject.name, true, false);
			}
		}
	}

	// Token: 0x060012E8 RID: 4840 RVA: 0x0016FC74 File Offset: 0x0016DE74
	public void OnPointerExit(PointerEventData eventData)
	{
		Links.x.gameplay.uiCanClick = false;
		if (this.inWindow)
		{
			this.skillBag.TooltipOff();
		}
		if (this.inWheel)
		{
			Links.x.pocketWheel.SetHoverText(false, base.gameObject);
		}
	}

	// Token: 0x060012E9 RID: 4841 RVA: 0x0016FCC4 File Offset: 0x0016DEC4
	public void OnPointerDown(PointerEventData eventData)
	{
		if (this.soundName != "")
		{
			MasterAudio.PlaySoundAndForget(this.soundName, Random.Range(0.2f, 0.5f), new float?(Random.Range(0.97f, 1f)), 0f, "", null);
		}
		if (this.inWindow && (Links.x.joy || (Input.GetMouseButton(1) && Links.x.mk)))
		{
			this.PointerDownInteract();
		}
		if (this.inWheel && ((Links.x.joy && Links.x.gameplay.interactStart) || (Input.GetMouseButton(1) && Links.x.mk)))
		{
			this.PointerDownInteract();
		}
		if (this.inWheel && Input.GetMouseButton(0) && Links.x.mk)
		{
			this.PointerDownAction();
		}
		if (this.tips)
		{
			Links.x.hudControl.CloseTutorialTooltip();
		}
	}

	// Token: 0x060012EA RID: 4842 RVA: 0x0016FDCC File Offset: 0x0016DFCC
	public void PointerDownInteract()
	{
		if (this.inWheel)
		{
			if (Links.x.pocketWheel.CanOpenDescription(base.gameObject))
			{
				Links.x.pocketWheel.skillBag.OpenDescription(null, base.gameObject, "", "");
			}
			if (Links.x.mk)
			{
				EventSystem.current.SetSelectedGameObject(null);
			}
		}
		if (this.inWindow)
		{
			this.skillBag.OpenDescription(null, base.gameObject, "", "");
			if (Links.x.mk)
			{
				EventSystem.current.SetSelectedGameObject(null);
			}
		}
	}

	// Token: 0x060012EB RID: 4843 RVA: 0x0016FE70 File Offset: 0x0016E070
	public void PointerDownAction()
	{
		if (this.inWheel && Links.x.joy)
		{
			if (!base.gameObject.name.Contains("Ammo"))
			{
				Links.x.pocketWheel.ControllerSelect(base.gameObject.name, true, true);
				return;
			}
		}
		else if (this.inWheel && Links.x.mk && !Links.x.pocketWheel.StartPocket(base.gameObject.name))
		{
			Links.x.pocketWheel.Select(base.gameObject.name);
		}
	}

	// Token: 0x060012EC RID: 4844 RVA: 0x0016FF10 File Offset: 0x0016E110
	public void OnPointerUp(PointerEventData eventData)
	{
		MasterAudio.PlaySoundAndForget("Click up", Random.Range(0.3f, 0.5f), new float?(Random.Range(0.97f, 1f)), 0f, "", null);
		if (Links.x.mk && base.gameObject.name != "Shout")
		{
			EventSystem.current.SetSelectedGameObject(null);
		}
	}

	// Token: 0x04001FBB RID: 8123
	public string soundName = "Clicks Stone A";

	// Token: 0x04001FBC RID: 8124
	public bool inWindow;

	// Token: 0x04001FBD RID: 8125
	private SkillBag skillBag;

	// Token: 0x04001FBE RID: 8126
	public bool inWheel;

	// Token: 0x04001FBF RID: 8127
	public bool tips;
}
