using System;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

// Token: 0x02000027 RID: 39
public class DockFriend : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerDownHandler, IPointerUpHandler, IPointerExitHandler
{
	// Token: 0x0600066C RID: 1644 RVA: 0x000862C8 File Offset: 0x000844C8
	public void Setup(Character c, Character boundToCharacter)
	{
		this.character = c;
		this.boundCharacterName = boundToCharacter.stats.GetName();
		Links.x.renderPortraits.AddCharacter(null, this.character.stats.xmlName, null, false, null, this.raw, null, null);
		this.UpdateHealth();
		this.dock = boundToCharacter.portrait.skillBag;
		base.transform.SetParent(boundToCharacter.portrait.skillBag.weaponTransform);
		this.dock.AddButton(this.btn);
		base.gameObject.transform.localPosition = new Vector3(0f, 0f, 0f);
		base.gameObject.SetActive(true);
	}

	// Token: 0x0600066D RID: 1645 RVA: 0x0008638B File Offset: 0x0008458B
	public void UpdateHealth()
	{
		this.healthBar.fillAmount = 1f - (float)this.character.stats.HealthCurrent() / (float)this.character.stats.HealthMax();
	}

	// Token: 0x0600066E RID: 1646 RVA: 0x000863C1 File Offset: 0x000845C1
	public void RemovePortrait()
	{
		Links.x.renderPortraits.RemoveCharacter(null, this.character.stats.xmlName, this.raw.texture);
	}

	// Token: 0x0600066F RID: 1647 RVA: 0x000863F0 File Offset: 0x000845F0
	public void AddPortrait()
	{
		Links.x.renderPortraits.AddCharacter(null, this.character.stats.xmlName, null, false, null, this.raw, null, null);
	}

	// Token: 0x06000670 RID: 1648 RVA: 0x00086428 File Offset: 0x00084628
	public void Remove()
	{
		Links.x.renderPortraits.RemoveCharacter(null, this.character.stats.xmlName, this.raw.texture);
		base.transform.SetParent(Links.x.hudControl.miscFolderQuipsTransform);
		if (this.dock)
		{
			this.dock.RemoveButton(this.btn);
		}
		Links.x.cellar.ReturnPooledGameObject(121, base.gameObject);
	}

	// Token: 0x06000671 RID: 1649 RVA: 0x000864B0 File Offset: 0x000846B0
	public void OnPointerEnter(PointerEventData eventData)
	{
		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.dock.TooltipOn(null, base.gameObject, this.str.ToString(), true);
	}

	// Token: 0x06000672 RID: 1650 RVA: 0x0008655D File Offset: 0x0008475D
	public void OnPointerExit(PointerEventData eventData)
	{
		this.dock.TooltipOff();
	}

	// Token: 0x06000673 RID: 1651 RVA: 0x0008656A File Offset: 0x0008476A
	public void OnPointerDown(PointerEventData eventData)
	{
	}

	// Token: 0x06000674 RID: 1652 RVA: 0x0008656C File Offset: 0x0008476C
	public void OnPointerUp(PointerEventData eventData)
	{
	}

	// Token: 0x04000927 RID: 2343
	public Character character;

	// Token: 0x04000928 RID: 2344
	public string boundCharacterName;

	// Token: 0x04000929 RID: 2345
	public RawImage raw;

	// Token: 0x0400092A RID: 2346
	public Image healthBar;

	// Token: 0x0400092B RID: 2347
	private SkillBag dock;

	// Token: 0x0400092C RID: 2348
	public Button btn;

	// Token: 0x0400092D RID: 2349
	private StringFast str = new StringFast(32);
}
