using System;
using System.Collections.Generic;
using DarkTonic.MasterAudio;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

// Token: 0x020000CE RID: 206
public class Portrait : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerDownHandler, IPointerUpHandler
{
	// Token: 0x060012EE RID: 4846 RVA: 0x0016FFA0 File Offset: 0x0016E1A0
	private void Awake()
	{
		if (!this.character)
		{
			this.button = base.gameObject.GetComponent<Button>();
			if (!this.inCharacterSheet)
			{
				this.portrait.enabled = false;
			}
			else
			{
				this.button.interactable = false;
			}
			if (Links.x)
			{
				this.portrait.texture = Links.x.emptyTexture;
				if (this.shadowPortrait)
				{
					this.shadowPortrait.texture = Links.x.emptyTexture;
				}
			}
			this.portrait.raycastTarget = false;
			if (this.pedestal)
			{
				this.pedestal.color = this.none;
			}
			if (this.border)
			{
				this.border.enabled = false;
			}
		}
		if (this.btn && !this.inCharacterSheet)
		{
			this.btn.interactable = false;
		}
		this.clickedTime = -1f;
		if (this.animator)
		{
			this.animator.enabled = false;
		}
		if (this.synergy1meter)
		{
			this.SetSynergy(0f, 0f);
		}
		if (this.healthText)
		{
			this.healthText.enabled = false;
		}
		if (this.actionBar)
		{
			this.actionBarAnimator = this.actionBar.gameObject.GetComponent<HannahAnimatorSimple>();
		}
	}

	// Token: 0x060012EF RID: 4847 RVA: 0x00170114 File Offset: 0x0016E314
	public void Start()
	{
		if (this.inCharacterSheet)
		{
			this.button = base.gameObject.GetComponent<Button>();
		}
		if (!this.character && Links.x)
		{
			this.portrait.texture = Links.x.emptyTexture;
			if (this.shadowPortrait)
			{
				this.shadowPortrait.texture = Links.x.emptyTexture;
			}
		}
		if (this.time)
		{
			this.time.SetActive(false);
		}
	}

	// Token: 0x060012F0 RID: 4848 RVA: 0x001701A3 File Offset: 0x0016E3A3
	public void SetSelection()
	{
		if (this.inCharacterSheet)
		{
			if (!this.character)
			{
				return;
			}
		}
		else if (!this.character)
		{
			return;
		}
		this.SetPortraitColor();
	}

	// Token: 0x060012F1 RID: 4849 RVA: 0x001701CF File Offset: 0x0016E3CF
	public void HoverFromCharacter(bool state)
	{
		if (this.character)
		{
			this.hovering = state;
		}
		this.SetPortraitColor();
	}

	// Token: 0x060012F2 RID: 4850 RVA: 0x001701EC File Offset: 0x0016E3EC
	public void OnPointerDown(PointerEventData eventData)
	{
		this.clickedTime = Time.realtimeSinceStartup;
		int partyID = Links.x.GetPartyID(this.character);
		if (partyID > -1)
		{
			if (partyID == 0)
			{
				MasterAudio.PlaySoundAndForget("Clicks Stone A", Random.Range(0.4f, 0.6f) * 0.5f, new float?(0.95f), 0f, "", null);
			}
			if (partyID == 1)
			{
				MasterAudio.PlaySoundAndForget("Clicks Stone A", Random.Range(0.4f, 0.6f) * 0.5f, new float?(0.97f), 0f, "", null);
			}
			if (partyID == 2)
			{
				MasterAudio.PlaySoundAndForget("Clicks Stone A", Random.Range(0.4f, 0.6f) * 0.5f, new float?(1f), 0f, "", null);
			}
			if (partyID == 3)
			{
				MasterAudio.PlaySoundAndForget("Clicks Stone A", Random.Range(0.4f, 0.6f) * 0.5f, new float?(0.92f), 0f, "", null);
			}
			if (partyID == 4)
			{
				MasterAudio.PlaySoundAndForget("Clicks Stone A", Random.Range(0.4f, 0.6f) * 0.5f, new float?(0.93f), 0f, "", null);
			}
		}
	}

	// Token: 0x060012F3 RID: 4851 RVA: 0x00170360 File Offset: 0x0016E560
	public void SetPortraitColor()
	{
		if (this.character)
		{
			if (this.inCharacterSheet)
			{
				Color white = Color.white;
				if (Links.x.characterSheet.character == this.character)
				{
					white = this.selected;
				}
				else if (this.hovering)
				{
					white = this.hoverNormal;
				}
				else
				{
					white = this.none;
				}
				ColorBlock colors = this.csBtn.colors;
				colors.normalColor = white;
				colors.highlightedColor = this.hoverNormal;
				this.csBtn.colors = colors;
				return;
			}
			if (this.character.mainSelected && !this.hovering)
			{
				this.portrait.material = this.normalPortraitMaterial;
				this.selectedArt.SetActive(true);
				this.SetHealthColor();
				return;
			}
			if (this.hovering)
			{
				this.portrait.material = this.normalPortraitMaterial;
				this.selectedArt.SetActive(true);
				this.SetHealthColor();
				return;
			}
			this.portrait.material = this.normalPortraitMaterial;
			this.selectedArt.SetActive(false);
			this.SetHealthColor();
		}
	}

	// Token: 0x060012F4 RID: 4852 RVA: 0x0017047E File Offset: 0x0016E67E
	public void UpdatePortraitVisual()
	{
		if (!this.inCharacterSheet && this.character)
		{
			this.character.characterSheetPortrait.texturesIdle = this.texturesIdle;
		}
	}

	// Token: 0x060012F5 RID: 4853 RVA: 0x001704AC File Offset: 0x0016E6AC
	public void OnPointerUp(PointerEventData eventData)
	{
		if (Records.x.removeControls)
		{
			return;
		}
		this.clickedTime = -1f;
		if (this.dragging)
		{
			if (Links.x.hudControl.portraitDragSelected)
			{
				int siblingIndex = Links.x.hudControl.portraitDragSelected.gameObject.transform.GetSiblingIndex();
				base.gameObject.transform.SetSiblingIndex(siblingIndex);
				Transform portraitParent = Links.x.characterSheet.portraitParent;
			}
			Links.x.ChangePartyPosition(base.gameObject.transform.parent);
			Records.x.portraitDragging = false;
			this.dragging = false;
		}
	}

	// Token: 0x060012F6 RID: 4854 RVA: 0x00170560 File Offset: 0x0016E760
	public void FlipIcons()
	{
		if (Time.realtimeSinceStartup > this.flipStatusTime + 2f)
		{
			for (int i = 0; i < this.effectIconImages.Count; i++)
			{
				if (i < this.effectIcons.Count && this.effectIcons[i])
				{
					this.iconNames = this.effectIcons[i].iconNames;
					string name = this.effectIconImages[i].gameObject.name;
					if (this.iconNames.Count > 0)
					{
						int num = -1;
						for (int j = 0; j < this.iconNames.Count; j++)
						{
							if (name == this.iconNames[j])
							{
								num = j;
							}
						}
						if (num > -1)
						{
							num++;
							if (num >= this.iconNames.Count)
							{
								num = 0;
							}
							if (this.inCharacterSheet)
							{
								this.effectIconImages[i].sprite = Links.x.archives.GetEffectImage(this.iconNames[num]);
							}
							else
							{
								this.effectIconImages[i].sprite = Links.x.archives.GetEffectImage(this.iconNames[num]);
							}
							this.effectIconImages[i].gameObject.name = this.iconNames[num];
						}
					}
				}
			}
			this.flipStatusTime = Time.realtimeSinceStartup;
		}
	}

	// Token: 0x060012F7 RID: 4855 RVA: 0x001706E0 File Offset: 0x0016E8E0
	public void StartPulse(bool first)
	{
		if (!first)
		{
			this.startPulseDither = 1f;
			this.endPulseDither = 0f;
		}
		else
		{
			this.startPulseDither = 0f;
			this.endPulseDither = 1f;
		}
		if (this.pulsing)
		{
			this.pulse = this.startPulseDither;
		}
		this.pulseAmount = 0f;
		this.pulsing = true;
	}

	// Token: 0x060012F8 RID: 4856 RVA: 0x00170744 File Offset: 0x0016E944
	private void Update()
	{
		if (!this.dragging && Records.x.portraitDragging)
		{
			this.SetPortraitColor();
		}
		if (this.character)
		{
			if (this.pulsing)
			{
				this.pulse = Mathf.Lerp(this.startPulseDither, this.endPulseDither, this.pulseAmount);
				if (this.character.mainSelected)
				{
					Links.x.hudControl.stamina.color = Color.Lerp(Links.x.hudControl.startStaminaColor, Links.x.hudControl.startStaminaColor * 2f, this.pulse);
				}
				if ((this.endPulseDither == 1f && this.pulse >= 1f) || (this.endPulseDither == 0f && this.pulse <= 0.01f))
				{
					if (this.endPulseDither == 1f)
					{
						this.StartPulse(false);
					}
					else
					{
						this.pulsing = false;
						if (this.character.mainSelected)
						{
							Links.x.hudControl.stamina.color = Links.x.hudControl.startStaminaColor;
						}
					}
				}
				else
				{
					float num = 4f;
					if (this.endPulseDither == 1f)
					{
						num = 15f;
					}
					this.pulseAmount += Time.deltaTime * num;
				}
			}
			if (Links.x.gaia.sceneLoaded && !Records.x.removeControls)
			{
				this.FlipIcons();
			}
			if (!this.inCharacterSheet && Links.x.joy && Links.x.gameplay.cancelStart && !Links.x.hudControl.descriptionWindowOpen && Links.x.gameplay.inPartyDock)
			{
				this.skillBag.TooltipOff();
				EventSystem.current.SetSelectedGameObject(null);
				Links.x.gameplay.inPartyDock = false;
			}
			if (Time.realtimeSinceStartup > this.updateTime + 0.15f)
			{
				this.updateTime = Time.realtimeSinceStartup;
				this.currIndex++;
				if (this.hovering && !this.inCharacterSheet)
				{
					bool uiHover = Links.x.gameplay.uiHover;
				}
				if (!this.inCharacterSheet)
				{
					this.texturesIdle = this.character.characterSheetPortrait.texturesIdle;
				}
				if (this.texturesIdle != null)
				{
					this.currIndex = 0;
					this.portrait.texture = this.texturesIdle;
					if (this.shadowPortrait)
					{
						this.shadowPortrait.texture = this.portrait.texture;
					}
				}
				if (!this.inCharacterSheet)
				{
					if (this.character.stats.Silent() > 0 && this.silent == 0)
					{
						this.silent = 1;
						Color color = this.portrait.color;
						color.a = 0.4f;
						this.portrait.color = color;
						return;
					}
					if (this.silent > 0 && this.character.stats.Silent() == 0)
					{
						Color color2 = this.portrait.color;
						color2.a = 1f;
						this.portrait.color = color2;
						this.silent = 0;
					}
				}
			}
		}
	}

	// Token: 0x060012F9 RID: 4857 RVA: 0x00170A85 File Offset: 0x0016EC85
	public RenderTexture GetTextureIdle(int i)
	{
		return this.texturesIdle;
	}

	// Token: 0x060012FA RID: 4858 RVA: 0x00170A90 File Offset: 0x0016EC90
	public void OnPointerEnter(PointerEventData eventData)
	{
		if (Input.GetMouseButton(0) && !Records.x.portraitDragging && !Links.x.inventory.dragging)
		{
			return;
		}
		if (Records.x.portraitDragging)
		{
			Links.x.hudControl.portraitDragSelected = this;
		}
		if (!this.character)
		{
			return;
		}
		if (this.dragging)
		{
			return;
		}
		if (this.inCharacterSheet)
		{
			Links.x.inventory.doLookAt = true;
			Links.x.gameplay.uiCanClick = true;
			this.hovering = true;
			if (this.healthText)
			{
				this.healthText.enabled = true;
			}
			this.SetPortraitColor();
		}
	}

	// Token: 0x060012FB RID: 4859 RVA: 0x00170B44 File Offset: 0x0016ED44
	public void PortraitHover(bool state)
	{
		if (state)
		{
			this.hovering = true;
			if (this.healthText)
			{
				this.healthText.enabled = true;
			}
			this.portrait.material.SetFloat("_Hover", 1f);
			this.SetPortraitColor();
			return;
		}
		this.portrait.material.SetFloat("_Hover", 0f);
		this.hovering = false;
		this.SetPortraitColor();
		if (this.healthText)
		{
			this.healthText.enabled = false;
		}
	}

	// Token: 0x060012FC RID: 4860 RVA: 0x00170BD8 File Offset: 0x0016EDD8
	public void HeadHover(bool state)
	{
		if (state)
		{
			Links.x.tooltip.AddHoverText("Shout\n\nsomething", this.pedestal.gameObject, "Up");
			this.portrait.material.SetFloat("_Hover", 0f);
			this.portrait.material.SetFloat("_HoverHead", 1f);
			return;
		}
		Links.x.tooltip.EndHoverText(this.pedestal.gameObject, false);
		this.portrait.material.SetFloat("_HoverHead", 0f);
	}

	// Token: 0x060012FD RID: 4861 RVA: 0x00170C78 File Offset: 0x0016EE78
	public void ReceivedItem()
	{
		Links.x.itemPickupFX.gameObject.SetActive(true);
		Links.x.itemPickupFX.gameObject.GetComponent<HannahAnimator>().Play("Idle");
		Links.x.itemPickupFX.position = base.gameObject.transform.position;
	}

	// Token: 0x060012FE RID: 4862 RVA: 0x00170CD8 File Offset: 0x0016EED8
	public void FullBag()
	{
		Links.x.removeFX.gameObject.SetActive(true);
		Links.x.removeFX.gameObject.GetComponent<HannahAnimator>().Play("Idle");
		Links.x.removeFX.position = base.gameObject.transform.position;
	}

	// Token: 0x060012FF RID: 4863 RVA: 0x00170D38 File Offset: 0x0016EF38
	public void TooFar()
	{
		Links.x.removeFX.gameObject.SetActive(true);
		Links.x.removeFX.gameObject.GetComponent<HannahAnimator>().Play("Idle");
		Links.x.removeFX.position = base.gameObject.transform.position;
	}

	// Token: 0x06001300 RID: 4864 RVA: 0x00170D98 File Offset: 0x0016EF98
	public void OnPointerExit(PointerEventData eventData)
	{
		if (!this.character || (Records.x.removeControls && !this.hovering))
		{
			return;
		}
		if (this.inCharacterSheet)
		{
			Links.x.inventory.doLookAt = false;
			Links.x.characterTooltip.EndHoverText(base.gameObject, false);
			Links.x.gameplay.uiCanClick = false;
			this.hovering = false;
			if (this.healthText)
			{
				this.healthText.enabled = false;
			}
			this.SetPortraitColor();
		}
	}

	// Token: 0x06001301 RID: 4865 RVA: 0x00170E2B File Offset: 0x0016F02B
	public void AnimationDone()
	{
		this.animator.enabled = false;
	}

	// Token: 0x06001302 RID: 4866 RVA: 0x00170E39 File Offset: 0x0016F039
	public void AnimatorShake()
	{
		this.animator.enabled = true;
		this.animator.Play("PortraitShake");
	}

	// Token: 0x06001303 RID: 4867 RVA: 0x00170E57 File Offset: 0x0016F057
	public void AnimatorSynergy()
	{
		this.animator.enabled = true;
		this.animator.Play("PortraitSynergy");
	}

	// Token: 0x06001304 RID: 4868 RVA: 0x00170E75 File Offset: 0x0016F075
	public void AnimatorSynergyDone()
	{
		this.animator.enabled = false;
		this.synergyFX.enabled = false;
	}

	// Token: 0x06001305 RID: 4869 RVA: 0x00170E90 File Offset: 0x0016F090
	public void SetActionBar(float x)
	{
		if (this.actionBar)
		{
			if (!Records.x.InCombat(false) && !Records.x.pocketPause)
			{
				x = 0f;
			}
			this.actionBar.fillAmount = x;
			if (!Records.x.InCombat(false) && !Records.x.pocketPause)
			{
				Color color = this.nameText.color;
				color.a = 0.5f;
				this.nameText.color = color;
			}
			else
			{
				Color color2 = this.nameText.color;
				color2.a = 1f;
				this.nameText.color = color2;
			}
			if (x < 0.05f)
			{
				this.actionBarAnimator.enabled = false;
				return;
			}
			this.actionBarAnimator.enabled = true;
		}
	}

	// Token: 0x06001306 RID: 4870 RVA: 0x00170F60 File Offset: 0x0016F160
	public void SetHealthColor()
	{
		if (!this.healthBar)
		{
			return;
		}
		this.healthBar.enabled = true;
		this.healthCap.enabled = true;
		float num = 1f;
		if (this.character)
		{
			num = (float)this.character.stats.HealthCurrent() / (float)this.character.stats.HealthMax();
		}
		this.healthBar.fillAmount = 1f - num;
		float num2 = 119f;
		if (this.inCharacterSheet)
		{
			num2 = 525.078f;
		}
		float num3 = num2 * (1f - num) - 1.75f;
		this.healthCapRT.anchoredPosition3D = new Vector3(this.healthCapRT.anchoredPosition3D.x, num3, 0f);
		if (num > 0.95f)
		{
			this.healthCap.enabled = false;
		}
		else
		{
			this.healthCap.enabled = true;
		}
		if (!this.inCharacterSheet && this.character && this.character.characterSheetPortrait)
		{
			this.character.characterSheetPortrait.SetHealthColor();
		}
		if (this.healthText && this.character)
		{
			this.str.Clear();
			this.str.Append(this.character.stats.HealthCurrent());
			this.str.Append("<line-height=4>\n<size=1em><cspace=-5>______</cspace></size></line-height>\n");
			this.str.Append(this.character.stats.HealthMax());
			this.healthText.text = this.str.ToString();
		}
		if (this.alive)
		{
			if (num <= 0f)
			{
				this.healthBar.material = this.knockedOut;
				this.healthCap.material = this.knockedOut;
			}
			else
			{
				this.healthBar.material = this.alive;
				this.healthCap.material = this.alive;
			}
		}
		if (this.skillBag)
		{
			this.skillBag.SetAliveState();
		}
	}

	// Token: 0x06001307 RID: 4871 RVA: 0x00171178 File Offset: 0x0016F378
	public void SetStaminaBuff()
	{
		if (this.character.stats.staminaRegenMod > 0f)
		{
			if (this.character.mainSelected && !Links.x.hudControl.staminaBuff.activeSelf)
			{
				Links.x.hudControl.staminaBuff.SetActive(true);
				return;
			}
		}
		else if (this.character.mainSelected && Links.x.hudControl.staminaBuff.activeSelf)
		{
			Links.x.hudControl.staminaBuff.SetActive(false);
		}
	}

	// Token: 0x06001308 RID: 4872 RVA: 0x00171210 File Offset: 0x0016F410
	public void SetFatigue()
	{
		if (!this.character)
		{
			return;
		}
		if (this.staminaBar && this.character.mainSelected)
		{
			float fillAmount = Links.x.hudControl.stamina.fillAmount;
			float num = this.character.stats.stamina / this.character.stats.maxStamina;
			Links.x.hudControl.stamina.fillAmount = num;
			if (num >= 1f && fillAmount < 1f)
			{
				this.StartPulse(true);
			}
			this.SetStaminaBuff();
		}
	}

	// Token: 0x06001309 RID: 4873 RVA: 0x001712B0 File Offset: 0x0016F4B0
	public void SetStaminaColor()
	{
	}

	// Token: 0x0600130A RID: 4874 RVA: 0x001712B4 File Offset: 0x0016F4B4
	public void SetMagicColor()
	{
		if (!this.spiritBar1)
		{
			return;
		}
		if (this.character.stats.HasSpellbook())
		{
			if (!this.spiritBar1.gameObject.transform.parent.gameObject.activeSelf)
			{
				this.spiritBar1.gameObject.transform.parent.gameObject.SetActive(true);
			}
			float num = (float)this.character.stats.SpiritCurrent();
			this.character.stats.SpiritMax();
			float num2 = (float)Records.x.spiritFragment;
			int num3 = this.character.stats.SpiritCurrent();
			if (num3 >= 90)
			{
				this.spiritFill1.enabled = false;
				this.spiritFill2.enabled = false;
				this.spiritFill3.enabled = false;
				this.spiritBar1.enabled = true;
				this.spiritBar2.enabled = true;
				this.spiritBar3.enabled = true;
				this.spiritBar1anim.enabled = true;
				this.spiritBar2anim.enabled = true;
				this.spiritBar3anim.enabled = true;
				this.spiritFill1anim.enabled = false;
				this.spiritFill2anim.enabled = false;
				this.spiritFill3anim.enabled = false;
			}
			if (num3 < 90 && num3 >= 60)
			{
				this.spiritFill1.enabled = false;
				this.spiritFill2.enabled = false;
				this.spiritFill3.enabled = true;
				this.spiritBar1.enabled = true;
				this.spiritBar2.enabled = true;
				this.spiritBar3.enabled = false;
				this.spiritFill3.fillAmount = (num - num2 * 2f) / num2;
				this.spiritBar1anim.enabled = true;
				this.spiritBar2anim.enabled = true;
				this.spiritBar3anim.enabled = false;
				this.spiritFill1anim.enabled = false;
				this.spiritFill2anim.enabled = false;
				this.spiritFill3anim.enabled = true;
			}
			if (num3 < 60 && num3 >= Records.x.spiritFragment)
			{
				this.spiritFill1.enabled = false;
				this.spiritFill2.enabled = true;
				this.spiritFill3.enabled = false;
				this.spiritBar1.enabled = true;
				this.spiritBar2.enabled = false;
				this.spiritBar3.enabled = false;
				this.spiritFill2.fillAmount = (num - num2) / num2;
				this.spiritBar1anim.enabled = true;
				this.spiritBar2anim.enabled = false;
				this.spiritBar3anim.enabled = false;
				this.spiritFill1anim.enabled = false;
				this.spiritFill2anim.enabled = true;
				this.spiritFill3anim.enabled = false;
			}
			if (num3 < Records.x.spiritFragment)
			{
				this.spiritFill1.enabled = true;
				this.spiritFill2.enabled = false;
				this.spiritFill3.enabled = false;
				this.spiritBar1.enabled = false;
				this.spiritBar2.enabled = false;
				this.spiritBar3.enabled = false;
				this.spiritFill1.fillAmount = num / num2;
				this.spiritBar1anim.enabled = false;
				this.spiritBar2anim.enabled = false;
				this.spiritBar3anim.enabled = false;
				this.spiritFill1anim.enabled = true;
				this.spiritFill2anim.enabled = false;
				this.spiritFill3anim.enabled = false;
			}
			if (!Records.x.removeControls)
			{
				if (this.currentSpirit < (float)Records.x.spiritFragment && num3 >= Records.x.spiritFragment)
				{
					if (Links.x.gaia.sceneLoaded && !Records.x.inMenus)
					{
						MasterAudio.PlaySoundAndForget("Feedback", Random.Range(0.2f, 0.3f), new float?(1f), 0f, "SpiritFill1", null);
					}
					Links.x.itemPickupFX.gameObject.SetActive(true);
					Links.x.itemPickupFX.gameObject.GetComponent<HannahAnimator>().Play("Idle");
					Vector3 position = this.spiritFill1.gameObject.transform.position;
					Links.x.itemPickupFX.position = position;
				}
				else if (this.currentSpirit < (float)Records.x.spiritFragment * 2f && this.currentSpirit >= (float)Records.x.spiritFragment && num3 >= Records.x.spiritFragment * 2)
				{
					if (Links.x.gaia.sceneLoaded && !Records.x.inMenus)
					{
						MasterAudio.PlaySoundAndForget("Feedback", Random.Range(0.2f, 0.3f), new float?(1f), 0f, "SpiritFill2", null);
					}
					Links.x.itemPickupFX.gameObject.SetActive(true);
					Links.x.itemPickupFX.gameObject.GetComponent<HannahAnimator>().Play("Idle");
					Vector3 position2 = this.spiritFill2.gameObject.transform.position;
					Links.x.itemPickupFX.position = position2;
				}
				else if (this.currentSpirit < (float)Records.x.spiritFragment * 3f && num3 >= Records.x.spiritFragment * 3)
				{
					if (Links.x.gaia.sceneLoaded && !Records.x.inMenus)
					{
						MasterAudio.PlaySoundAndForget("Feedback", Random.Range(0.2f, 0.3f), new float?(1f), 0f, "SpiritFill3", null);
					}
					Links.x.itemPickupFX.gameObject.SetActive(true);
					Links.x.itemPickupFX.gameObject.GetComponent<HannahAnimator>().Play("Idle");
					Vector3 position3 = this.spiritFill3.gameObject.transform.position;
					Links.x.itemPickupFX.position = position3;
				}
			}
			this.currentSpirit = num;
			return;
		}
		if (this.spiritBar1.gameObject.transform.parent.gameObject.activeSelf)
		{
			this.spiritBar1.gameObject.transform.parent.gameObject.SetActive(false);
		}
	}

	// Token: 0x0600130B RID: 4875 RVA: 0x00171924 File Offset: 0x0016FB24
	public void SetSynergy(float amt1, float amt2)
	{
		if (amt1 > 0f)
		{
			this.synergy1meter.fillAmount = amt1;
		}
		else
		{
			this.synergy1meter.fillAmount = 0f;
		}
		if (amt2 > 0f)
		{
			this.synergy2meter.fillAmount = amt2;
			return;
		}
		this.synergy2meter.fillAmount = 0f;
	}

	// Token: 0x0600130C RID: 4876 RVA: 0x0017197C File Offset: 0x0016FB7C
	public void SetWpnDurabilityColor()
	{
		this.character;
	}

	// Token: 0x0600130D RID: 4877 RVA: 0x0017198C File Offset: 0x0016FB8C
	public void SetCharacter(Character newCharacter)
	{
		this.currIndex = 0;
		this.character = newCharacter;
		this.portrait.enabled = true;
		if (this.inCharacterSheet)
		{
			if (this.button)
			{
				this.button.interactable = true;
			}
			this.portrait.raycastTarget = true;
			Links.x.fellowship.AddPortraitChange(this.character);
		}
		this.SetHealthColor();
		this.SetStaminaColor();
		this.SetMagicColor();
		this.SetFatigue();
		this.SetWpnDurabilityColor();
		if (this.bag)
		{
			this.bag.character = this.character;
		}
		if (this.btn && !this.inCharacterSheet)
		{
			this.btn.interactable = true;
		}
		if (this.border)
		{
			this.border.enabled = true;
		}
		this.updateTime = Time.realtimeSinceStartup + Random.Range(0f, 0.1f);
		if (this.skillBag)
		{
			this.skillBag.character = this.character;
			this.skillBag.portrait = this;
			this.skillBag.selectedAmmoIndex = this.character.selectedAmmoIndex;
			this.skillBag.trinketWindow.gameObject.SetActive(true);
			this.skillBag.SetSkills();
		}
		if (!this.inCharacterSheet)
		{
			Links.x.hudControl.GetWindowInfo(this.character, this.skillBag.trinketWindow);
		}
		this.UpdateName();
		this.UpdateBar();
		this.UpdateKey(Links.x.joy);
		if (this.staminaBuff)
		{
			this.SetStaminaBuff();
		}
	}

	// Token: 0x0600130E RID: 4878 RVA: 0x00171B40 File Offset: 0x0016FD40
	public void UpdateKey(bool joystick)
	{
		if (!this.hotkey)
		{
			return;
		}
		if (joystick)
		{
			this.hotkey.text = "";
			return;
		}
		string text = "Party 1";
		if (this.character == Links.x.GetHotKeyCharacter(1) || (Records.x.banquetIsle && this.character.stats.GetName() == "Viorica"))
		{
			text = "Party 2";
		}
		if (this.character == Links.x.GetHotKeyCharacter(2) || (Records.x.banquetIsle && this.character.stats.GetName() == "Emil"))
		{
			text = "Party 3";
		}
		if (this.character == Links.x.GetHotKeyCharacter(3))
		{
			text = "Party 4";
		}
		this.hotkey.text = "<sprite=" + Links.x.keyControl.GetKeyIconIndex(Links.x.keyControl.GetHotkeyString(text)).ToString() + ">";
	}

	// Token: 0x0600130F RID: 4879 RVA: 0x00171C60 File Offset: 0x0016FE60
	public void UpdateName()
	{
		if (this.nameText)
		{
			this.nameText.text = this.character.stats.GetName();
		}
	}

	// Token: 0x06001310 RID: 4880 RVA: 0x00171C8A File Offset: 0x0016FE8A
	public void UpdateBar()
	{
	}

	// Token: 0x06001311 RID: 4881 RVA: 0x00171C8C File Offset: 0x0016FE8C
	public void SetRace()
	{
	}

	// Token: 0x06001312 RID: 4882 RVA: 0x00171C90 File Offset: 0x0016FE90
	public void SetCharacterHoverText()
	{
		this.str.Clear();
		this.str.Append(this.character.stats.GetName());
		this.str.Append(" ");
		this.str.Append(this.character.stats.HealthCurrent());
		this.str.Append("/");
		this.str.Append(this.character.stats.HealthMax());
		this.str.Append("\n\n<color=#605E5A>");
		Links.x.tooltip.AddHoverText(this.str.ToString(), this.pedestal.gameObject, "Up");
	}

	// Token: 0x06001313 RID: 4883 RVA: 0x00171D5A File Offset: 0x0016FF5A
	public void UpdatePortrait()
	{
		this.SetHealthColor();
		this.SetStaminaColor();
		this.SetMagicColor();
		this.SetFatigue();
	}

	// Token: 0x06001314 RID: 4884 RVA: 0x00171D74 File Offset: 0x0016FF74
	public void UpdateMP()
	{
		this.SetMagicColor();
	}

	// Token: 0x06001315 RID: 4885 RVA: 0x00171D7C File Offset: 0x0016FF7C
	public void DoSpell(int num)
	{
	}

	// Token: 0x06001316 RID: 4886 RVA: 0x00171D7E File Offset: 0x0016FF7E
	public void Spells()
	{
	}

	// Token: 0x06001317 RID: 4887 RVA: 0x00171D80 File Offset: 0x0016FF80
	public void Remove()
	{
		for (int i = 0; i < this.effectIcons.Count; i++)
		{
			if (!this.inCharacterSheet)
			{
				this.character.characterSheetPortrait.RemoveEffect(this.effectIcons[i]);
			}
			this.effectIconObjects.Add(this.effectIconImages[i].gameObject);
			if (this.effectIconImages[i])
			{
				this.effectIconImages[i].gameObject.SetActive(false);
			}
		}
		this.effectIcons.Clear();
		this.effectIconImages.Clear();
		this.character = null;
		this.portrait.enabled = false;
		if (this.healthBar)
		{
			this.healthBar.enabled = true;
			this.healthCap.enabled = true;
		}
		if (this.border)
		{
			this.border.color = this.none;
		}
		this.portrait.enabled = true;
		this.portrait.texture = Links.x.emptyTexture;
		if (this.shadowPortrait)
		{
			this.shadowPortrait.texture = this.portrait.texture;
		}
		this.SetHealthColor();
		if (this.border)
		{
			this.border.enabled = false;
		}
		if (this.skillBag)
		{
			this.skillBag.Remove();
		}
		if (this.textParser && this.textParser.open)
		{
			this.textParser.EndMenu();
		}
		if (!this.inCharacterSheet)
		{
			base.gameObject.SetActive(false);
			return;
		}
		if (this.button)
		{
			this.button.interactable = false;
		}
	}

	// Token: 0x06001318 RID: 4888 RVA: 0x00171F47 File Offset: 0x00170147
	public void QueueIcon(bool state)
	{
	}

	// Token: 0x06001319 RID: 4889 RVA: 0x00171F4C File Offset: 0x0017014C
	public void SelectCharacter()
	{
		if (Records.x.removeControls)
		{
			return;
		}
		if (this.inCharacterSheet)
		{
			if (!Links.x.inventory.dragging && Links.x.characterSheet.character != this.character)
			{
				Links.x.characterSheet.SwitchCharacter(this.character, false, false);
			}
			if (Links.x.mk)
			{
				EventSystem.current.SetSelectedGameObject(null);
				return;
			}
		}
		else
		{
			this.clickCount++;
			bool flag = false;
			if (Links.x.main && Links.x.main.timelineIcon && Links.x.main.timelineIcon.overridePause)
			{
				flag = true;
			}
			if (!flag && !Links.x.combat.pickingRally)
			{
				this.Select();
			}
			this.clickCount = 0;
		}
	}

	// Token: 0x0600131A RID: 4890 RVA: 0x0017203C File Offset: 0x0017023C
	private void Select()
	{
		if (Links.x.cameraEffects.transitioning)
		{
			return;
		}
		if (this.character.dead)
		{
			return;
		}
		Links.x.fellowship.SingleSelected(this.character);
		this.character.AddToSelected(false, true);
		this.character.SetAsLeader();
		this.SetSelection();
		if (Links.x.mk)
		{
			EventSystem.current.SetSelectedGameObject(null);
		}
		Links.x.rtsCamera.Follow(this.character.tr, this.character, false);
	}

	// Token: 0x0600131B RID: 4891 RVA: 0x001720D4 File Offset: 0x001702D4
	public void UpdateController()
	{
	}

	// Token: 0x0600131C RID: 4892 RVA: 0x001720D8 File Offset: 0x001702D8
	public void AddEffect(string substat, Effects effect)
	{
		Sprite effectImage = Links.x.archives.GetEffectImage(substat);
		if (effectImage)
		{
			GameObject gameObject;
			Image image;
			if (this.effectIconObjects.Count > 0)
			{
				gameObject = this.effectIconObjects[0];
				this.effectIconObjects.RemoveAt(0);
				image = gameObject.GetComponent<Image>();
				image.raycastTarget = this.inCharacterSheet;
				gameObject.SetActive(true);
			}
			else
			{
				gameObject = new GameObject("Effect icon");
				gameObject.transform.parent = this.effectsGrid;
				image = gameObject.AddComponent<Image>();
				gameObject.transform.localScale = new Vector3(1f, 1f, 1f);
				gameObject.transform.localPosition = Vector3.zero;
			}
			image.sprite = effectImage;
			image.raycastTarget = this.inCharacterSheet;
			gameObject.name = substat;
			int num = this.effectIcons.IndexOf(effect);
			if (num == -1)
			{
				this.effectIconImages.Add(image);
				this.effectIcons.Add(effect);
				image.gameObject.SetActive(true);
			}
			else
			{
				this.effectIconImages.Insert(num, image);
				this.effectIcons.Insert(num, effect);
				image.gameObject.SetActive(false);
			}
			if (!this.inCharacterSheet)
			{
				this.character.characterSheetPortrait.AddEffect(substat, effect);
			}
			this.effectIconImagesPortrait = this.character.characterSheetPortrait.effectIconImages;
			this.effectIconsPortrait = this.character.characterSheetPortrait.effectIconsPortrait;
		}
	}

	// Token: 0x0600131D RID: 4893 RVA: 0x00172258 File Offset: 0x00170458
	public Effects GetEffectAtIndex(int index)
	{
		if (this.effectIconsPortrait == null)
		{
			this.effectIconImagesPortrait = this.character.characterSheetPortrait.effectIconImages;
			this.effectIconsPortrait = this.character.characterSheetPortrait.effectIconsPortrait;
		}
		if (index < this.effectIcons.Count)
		{
			return this.effectIcons[index];
		}
		return null;
	}

	// Token: 0x0600131E RID: 4894 RVA: 0x001722B8 File Offset: 0x001704B8
	public int GetEffectIndex(Image img)
	{
		if (this.effectIconsPortrait == null)
		{
			this.effectIconImagesPortrait = this.character.characterSheetPortrait.effectIconImages;
			this.effectIconsPortrait = this.character.characterSheetPortrait.effectIconsPortrait;
		}
		return this.effectIconImagesPortrait.IndexOf(img);
	}

	// Token: 0x0600131F RID: 4895 RVA: 0x00172305 File Offset: 0x00170505
	public string GetEffectName(Image img)
	{
		return "";
	}

	// Token: 0x06001320 RID: 4896 RVA: 0x0017230C File Offset: 0x0017050C
	public void RemoveEffect(Effects effect)
	{
		if (effect == null)
		{
			return;
		}
		bool flag = false;
		for (int i = 0; i < this.effectIcons.Count; i++)
		{
			if (this.effectIcons[i] == effect && !flag)
			{
				flag = true;
				this.effectIcons[i] = null;
				this.effectIconObjects.Add(this.effectIconImages[i].gameObject);
				this.effectIconImages[i].gameObject.SetActive(false);
				this.effectIconImages[i] = null;
			}
		}
		for (int j = 0; j < this.effectIconImages.Count; j++)
		{
			if (j >= this.effectIcons.Count)
			{
				flag = true;
				this.effectIconObjects.Add(this.effectIconImages[j].gameObject);
				this.effectIconImages[j].gameObject.SetActive(false);
				this.effectIconImages[j] = null;
			}
			else if (this.effectIcons[j] == null && this.effectIconImages[j] != null)
			{
				flag = true;
				this.effectIcons[j] = null;
				this.effectIconObjects.Add(this.effectIconImages[j].gameObject);
				this.effectIconImages[j].gameObject.SetActive(false);
				this.effectIconImages[j] = null;
			}
		}
		if (flag)
		{
			this.effectIcons.RemoveAll((Effects item) => item == null);
			this.effectIconImages.RemoveAll((Image item) => item == null);
		}
		if (!this.inCharacterSheet)
		{
			this.character.characterSheetPortrait.RemoveEffect(effect);
		}
	}

	// Token: 0x04001FC0 RID: 8128
	[Header("INFO")]
	public int index;

	// Token: 0x04001FC1 RID: 8129
	public Character character;

	// Token: 0x04001FC2 RID: 8130
	public bool inCharacterSheet;

	// Token: 0x04001FC3 RID: 8131
	[Header("LINKS")]
	public RawImage portrait;

	// Token: 0x04001FC4 RID: 8132
	public RawImage shadowPortrait;

	// Token: 0x04001FC5 RID: 8133
	public Image border;

	// Token: 0x04001FC6 RID: 8134
	public Image pedestal;

	// Token: 0x04001FC7 RID: 8135
	public InventoryContainer bag;

	// Token: 0x04001FC8 RID: 8136
	public SkillBag skillBag;

	// Token: 0x04001FC9 RID: 8137
	public RectTransform effectParent;

	// Token: 0x04001FCA RID: 8138
	public RectTransform queuedRT;

	// Token: 0x04001FCB RID: 8139
	public Image queuedIcon;

	// Token: 0x04001FCC RID: 8140
	public Image queuedIconBorder;

	// Token: 0x04001FCD RID: 8141
	public Image selectionToggleImage;

	// Token: 0x04001FCE RID: 8142
	public Animator animator;

	// Token: 0x04001FCF RID: 8143
	public Button button;

	// Token: 0x04001FD0 RID: 8144
	public Vine vine;

	// Token: 0x04001FD1 RID: 8145
	public RectTransform portraitRT;

	// Token: 0x04001FD2 RID: 8146
	public RectTransform barsRT;

	// Token: 0x04001FD3 RID: 8147
	public TextParser textParser;

	// Token: 0x04001FD4 RID: 8148
	public TextMeshProUGUI nameText;

	// Token: 0x04001FD5 RID: 8149
	public TextMeshProUGUI healthText;

	// Token: 0x04001FD6 RID: 8150
	public Button btn;

	// Token: 0x04001FD7 RID: 8151
	public Button csBtn;

	// Token: 0x04001FD8 RID: 8152
	public Image bar;

	// Token: 0x04001FD9 RID: 8153
	public GameObject time;

	// Token: 0x04001FDA RID: 8154
	public TextMeshProUGUI timeText;

	// Token: 0x04001FDB RID: 8155
	public TextMeshProUGUI hotkey;

	// Token: 0x04001FDC RID: 8156
	public GameObject staminaBuff;

	// Token: 0x04001FDD RID: 8157
	public Image staminaBuffImage;

	// Token: 0x04001FDE RID: 8158
	public Color stmBuff;

	// Token: 0x04001FDF RID: 8159
	public Color stmDebuff;

	// Token: 0x04001FE0 RID: 8160
	[Header("GRAPHICS")]
	public Color hoverNormal;

	// Token: 0x04001FE1 RID: 8161
	public Color selected;

	// Token: 0x04001FE2 RID: 8162
	public Color none;

	// Token: 0x04001FE3 RID: 8163
	public Material normalMaterial;

	// Token: 0x04001FE4 RID: 8164
	public Material selectedMaterial;

	// Token: 0x04001FE5 RID: 8165
	public Material hoverMaterial;

	// Token: 0x04001FE6 RID: 8166
	public Material normalPortraitMaterial;

	// Token: 0x04001FE7 RID: 8167
	public Material selectedPortraitMaterial;

	// Token: 0x04001FE8 RID: 8168
	public Material hoverPortraitMaterial;

	// Token: 0x04001FE9 RID: 8169
	public Material alive;

	// Token: 0x04001FEA RID: 8170
	public Material knockedOut;

	// Token: 0x04001FEB RID: 8171
	public RenderTexture texturesIdle;

	// Token: 0x04001FEC RID: 8172
	public Sprite selectionOn;

	// Token: 0x04001FED RID: 8173
	public Sprite selectionOff;

	// Token: 0x04001FEE RID: 8174
	public Sprite selectedImage;

	// Token: 0x04001FEF RID: 8175
	public Sprite unselectedImage;

	// Token: 0x04001FF0 RID: 8176
	public Color weaponBg;

	// Token: 0x04001FF1 RID: 8177
	public Color beltItemBg;

	// Token: 0x04001FF2 RID: 8178
	public Color spellBg;

	// Token: 0x04001FF3 RID: 8179
	public Color songBg;

	// Token: 0x04001FF4 RID: 8180
	public Sprite itemSprite;

	// Token: 0x04001FF5 RID: 8181
	public Sprite spellBgSprite;

	// Token: 0x04001FF6 RID: 8182
	public Sprite songBgSprite;

	// Token: 0x04001FF7 RID: 8183
	public Sprite wordBgSprite;

	// Token: 0x04001FF8 RID: 8184
	public Sprite emptySprite;

	// Token: 0x04001FF9 RID: 8185
	public float scaleCharacter;

	// Token: 0x04001FFA RID: 8186
	public float scaleCharacterYeti;

	// Token: 0x04001FFB RID: 8187
	public float scaleCharacterVaruchov;

	// Token: 0x04001FFC RID: 8188
	public float characterPlacementYetiOffset;

	// Token: 0x04001FFD RID: 8189
	public Vector2 offsetCharacter;

	// Token: 0x04001FFE RID: 8190
	public Vector2 offsetYeti;

	// Token: 0x04001FFF RID: 8191
	public Vector2 offsetVaruchov;

	// Token: 0x04002000 RID: 8192
	public float zoomCharacter;

	// Token: 0x04002001 RID: 8193
	public float zoomYeti;

	// Token: 0x04002002 RID: 8194
	public float zoomVaruchov;

	// Token: 0x04002003 RID: 8195
	private float characterPlacement;

	// Token: 0x04002004 RID: 8196
	private float characterPlacementYeti;

	// Token: 0x04002005 RID: 8197
	private float characterPlacementVaruchov;

	// Token: 0x04002006 RID: 8198
	public float headPlacement;

	// Token: 0x04002007 RID: 8199
	public float headPlacementYeti;

	// Token: 0x04002008 RID: 8200
	public float effectsPlacement;

	// Token: 0x04002009 RID: 8201
	public float effectsPlacementYeti;

	// Token: 0x0400200A RID: 8202
	public GameObject selectedArt;

	// Token: 0x0400200B RID: 8203
	public Image healthBar;

	// Token: 0x0400200C RID: 8204
	public Image staminaBar;

	// Token: 0x0400200D RID: 8205
	public Image spiritBar1;

	// Token: 0x0400200E RID: 8206
	public Image spiritBar2;

	// Token: 0x0400200F RID: 8207
	public Image spiritBar3;

	// Token: 0x04002010 RID: 8208
	public Image spiritFill1;

	// Token: 0x04002011 RID: 8209
	public Image spiritFill2;

	// Token: 0x04002012 RID: 8210
	public Image spiritFill3;

	// Token: 0x04002013 RID: 8211
	public Image healthCap;

	// Token: 0x04002014 RID: 8212
	public Image synergyFX;

	// Token: 0x04002015 RID: 8213
	public Image actionBar;

	// Token: 0x04002016 RID: 8214
	public HannahAnimatorSimple spiritBar1anim;

	// Token: 0x04002017 RID: 8215
	public HannahAnimatorSimple spiritBar2anim;

	// Token: 0x04002018 RID: 8216
	public HannahAnimatorSimple spiritBar3anim;

	// Token: 0x04002019 RID: 8217
	public HannahAnimatorSimple spiritFill1anim;

	// Token: 0x0400201A RID: 8218
	public HannahAnimatorSimple spiritFill2anim;

	// Token: 0x0400201B RID: 8219
	public HannahAnimatorSimple spiritFill3anim;

	// Token: 0x0400201C RID: 8220
	private Color barColor;

	// Token: 0x0400201D RID: 8221
	private Color barHoverColor;

	// Token: 0x0400201E RID: 8222
	private Color barUnselectedColor;

	// Token: 0x0400201F RID: 8223
	public RectTransform healthCapRT;

	// Token: 0x04002020 RID: 8224
	public RectTransform staminaCapRT;

	// Token: 0x04002021 RID: 8225
	public Image synergy1meter;

	// Token: 0x04002022 RID: 8226
	public Image synergy2meter;

	// Token: 0x04002023 RID: 8227
	private HannahAnimatorSimple actionBarAnimator;

	// Token: 0x04002024 RID: 8228
	[Header("FUNCTIONALITY")]
	private int clickCount;

	// Token: 0x04002025 RID: 8229
	public bool hovering;

	// Token: 0x04002026 RID: 8230
	private float clickedTime;

	// Token: 0x04002027 RID: 8231
	private bool dragging;

	// Token: 0x04002028 RID: 8232
	private float updateTime;

	// Token: 0x04002029 RID: 8233
	public int currIndex;

	// Token: 0x0400202A RID: 8234
	private int silent;

	// Token: 0x0400202B RID: 8235
	private float currentSpirit;

	// Token: 0x0400202C RID: 8236
	private float startPulseDither;

	// Token: 0x0400202D RID: 8237
	private float endPulseDither;

	// Token: 0x0400202E RID: 8238
	private float pulseAmount;

	// Token: 0x0400202F RID: 8239
	private float pulse;

	// Token: 0x04002030 RID: 8240
	private bool pulsing;

	// Token: 0x04002031 RID: 8241
	[Header("Effects")]
	public List<Image> effectIconImages = new List<Image>();

	// Token: 0x04002032 RID: 8242
	public List<Effects> effectIcons = new List<Effects>();

	// Token: 0x04002033 RID: 8243
	private List<Image> effectIconImagesPortrait;

	// Token: 0x04002034 RID: 8244
	private List<Effects> effectIconsPortrait;

	// Token: 0x04002035 RID: 8245
	public List<GameObject> effectIconObjects = new List<GameObject>();

	// Token: 0x04002036 RID: 8246
	public Transform effectsGrid;

	// Token: 0x04002037 RID: 8247
	private StringFast str = new StringFast(64);

	// Token: 0x04002038 RID: 8248
	private float flipStatusTime;

	// Token: 0x04002039 RID: 8249
	private List<string> iconNames;
}
