418 lines
9.9 KiB
C#
418 lines
9.9 KiB
C#
using System;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
// Token: 0x020000B9 RID: 185
|
|
public class ItemEquipped : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerDownHandler, IPointerUpHandler
|
|
{
|
|
// Token: 0x060011AA RID: 4522 RVA: 0x00159C60 File Offset: 0x00157E60
|
|
public void SetDurabilityVisual()
|
|
{
|
|
if (this.inPortrait)
|
|
{
|
|
return;
|
|
}
|
|
if (this.itemRenderer && this.invRow != null)
|
|
{
|
|
if (this.invRow._DurabilityMax > 0)
|
|
{
|
|
if (this.durability.x <= (float)Records.x.durabilityThreshold)
|
|
{
|
|
this.itemRenderer.material.SetFloat("_Glow", 1f);
|
|
}
|
|
else
|
|
{
|
|
this.itemRenderer.material.SetFloat("_Glow", 0f);
|
|
}
|
|
}
|
|
if (this.invRow._Life > 0 && !this.invRow._Effect.Contains("Cure"))
|
|
{
|
|
if ((int)this.durability.x - (int)Mathf.Floor((float)Links.x.gameplay.GetCurrentGameTimeHours()) <= 10)
|
|
{
|
|
this.itemRenderer.material.SetFloat("_Glow", 1f);
|
|
}
|
|
else
|
|
{
|
|
this.itemRenderer.material.SetFloat("_Glow", 0f);
|
|
}
|
|
}
|
|
if (this.socketA.x > 0f && (this.invRow._Tag == "Weapon" || this.invRow._Tag == "Jewelry"))
|
|
{
|
|
this.itemRenderer.material.SetFloat("_Sparkle", 1f);
|
|
}
|
|
else
|
|
{
|
|
this.itemRenderer.material.SetFloat("_Sparkle", 0f);
|
|
}
|
|
}
|
|
if (this.img)
|
|
{
|
|
bool flag = false;
|
|
if (this.socketA.x > 0f && (this.invRow._Tag == "Weapon" || this.invRow._Tag == "Jewelry"))
|
|
{
|
|
flag = true;
|
|
}
|
|
if (this.invRow._DurabilityMax > 0)
|
|
{
|
|
if (this.durability.x <= (float)Records.x.durabilityThreshold)
|
|
{
|
|
if (this.durability.x <= 0f)
|
|
{
|
|
this.img.material = Links.x.inventory.inventoryItemBrokenMaterial;
|
|
if (flag)
|
|
{
|
|
this.img.material = Links.x.inventory.inventoryItemMagicBrokenMaterial;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.img.material = Links.x.inventory.inventoryItemLowDurabilityMaterial;
|
|
if (flag)
|
|
{
|
|
this.img.material = Links.x.inventory.inventoryItemMagicLowDurabilityMaterial;
|
|
}
|
|
}
|
|
}
|
|
else if (flag)
|
|
{
|
|
this.img.material = Links.x.inventory.inventoryItemMagic;
|
|
}
|
|
else
|
|
{
|
|
this.img.material = Links.x.inventory.inventoryItemMaterial;
|
|
}
|
|
}
|
|
else if (flag)
|
|
{
|
|
this.img.material = Links.x.inventory.inventoryItemMagic;
|
|
}
|
|
else
|
|
{
|
|
this.img.material = Links.x.inventory.inventoryItemMaterial;
|
|
}
|
|
if (this.invRow._Life > 0)
|
|
{
|
|
if ((int)this.durability.x - (int)Mathf.Floor((float)Links.x.gameplay.GetCurrentGameTimeHours()) <= 10 && !this.invRow._Effect.Contains("Cure"))
|
|
{
|
|
this.img.material = Links.x.inventory.inventoryItemLowDurabilityMaterial;
|
|
}
|
|
else
|
|
{
|
|
this.img.material = Links.x.inventory.inventoryItemMaterial;
|
|
}
|
|
}
|
|
}
|
|
if (this.thisImg)
|
|
{
|
|
bool flag2 = false;
|
|
if (this.socketA.x > 0f && (this.invRow._Tag == "Weapon" || this.invRow._Tag == "Jewelry"))
|
|
{
|
|
flag2 = true;
|
|
}
|
|
if (this.invRow._DurabilityMax > 0)
|
|
{
|
|
if (this.durability.x <= (float)Records.x.durabilityThreshold)
|
|
{
|
|
if (this.durability.x <= 0f)
|
|
{
|
|
this.thisImg.material = Links.x.inventory.inventoryItemBrokenMaterial;
|
|
if (flag2)
|
|
{
|
|
this.thisImg.material = Links.x.inventory.inventoryItemMagicBrokenMaterial;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.thisImg.material = Links.x.inventory.inventoryItemLowDurabilityMaterial;
|
|
if (flag2)
|
|
{
|
|
this.thisImg.material = Links.x.inventory.inventoryItemMagicLowDurabilityMaterial;
|
|
}
|
|
}
|
|
}
|
|
else if (flag2)
|
|
{
|
|
this.thisImg.material = Links.x.inventory.inventoryItemMagic;
|
|
}
|
|
else
|
|
{
|
|
this.thisImg.material = Links.x.inventory.inventoryItemMaterial;
|
|
}
|
|
}
|
|
else if (flag2)
|
|
{
|
|
this.thisImg.material = Links.x.inventory.inventoryItemMagic;
|
|
}
|
|
else
|
|
{
|
|
this.thisImg.material = Links.x.inventory.inventoryItemMaterial;
|
|
}
|
|
if (this.invRow._Life > 0)
|
|
{
|
|
if ((int)this.durability.x - (int)Mathf.Floor((float)Links.x.gameplay.GetCurrentGameTimeHours()) <= 10 && !this.invRow._Effect.Contains("Cure"))
|
|
{
|
|
this.thisImg.material = Links.x.inventory.inventoryItemLowDurabilityMaterial;
|
|
return;
|
|
}
|
|
this.thisImg.material = Links.x.inventory.inventoryItemMaterial;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Token: 0x060011AB RID: 4523 RVA: 0x0015A1EC File Offset: 0x001583EC
|
|
public void UpdateStackSize()
|
|
{
|
|
if (!this.thisImg && !this.buddyItemEquipped2D)
|
|
{
|
|
return;
|
|
}
|
|
if (this.inPortrait)
|
|
{
|
|
return;
|
|
}
|
|
if (this.invRow == null)
|
|
{
|
|
return;
|
|
}
|
|
if (!this.stackSizeText)
|
|
{
|
|
return;
|
|
}
|
|
if (this.thisImg && !this.thisImg.enabled && this.stackSizeText)
|
|
{
|
|
this.stackSizeText.text = "";
|
|
return;
|
|
}
|
|
if (!this.invRow._Stackable)
|
|
{
|
|
this.stackSizeText.text = "";
|
|
return;
|
|
}
|
|
if (this.buddyItemEquipped2D && this.buddyItemEquipped2D.stackSizeText)
|
|
{
|
|
this.buddyItemEquipped2D.stackSizeText.text = this.buddyItemEquipped2D.stackSize.ToString();
|
|
}
|
|
if (this.stackSizeText)
|
|
{
|
|
this.stackSizeText.text = this.stackSize.ToString();
|
|
}
|
|
}
|
|
|
|
// Token: 0x060011AC RID: 4524 RVA: 0x0015A2EC File Offset: 0x001584EC
|
|
public void ClearItem()
|
|
{
|
|
this.invRow = Links.x.library.GetInvRow(0);
|
|
this.ID = 0;
|
|
if (this.img)
|
|
{
|
|
this.img.enabled = false;
|
|
}
|
|
if (this.thisImg)
|
|
{
|
|
this.thisImg.enabled = false;
|
|
}
|
|
}
|
|
|
|
// Token: 0x060011AD RID: 4525 RVA: 0x0015A348 File Offset: 0x00158548
|
|
public void ReturnToArchives()
|
|
{
|
|
if (this.itemRenderer)
|
|
{
|
|
this.itemRenderer.material.SetFloat("_Hover", 0f);
|
|
this.itemRenderer.material.SetFloat("_Sparkle", 0f);
|
|
}
|
|
if (base.gameObject.layer != 26)
|
|
{
|
|
if (this.btn)
|
|
{
|
|
this.img.enabled = false;
|
|
this.buddyItemEquipped2D.buddyItemEquipped3D = null;
|
|
}
|
|
if (this.stackSizeText)
|
|
{
|
|
this.stackSizeText.text = "";
|
|
}
|
|
if (this.buddyItemEquipped2D && this.buddyItemEquipped2D.stackSizeText)
|
|
{
|
|
this.buddyItemEquipped2D.stackSizeText.text = "";
|
|
}
|
|
}
|
|
if (base.gameObject.layer != 26)
|
|
{
|
|
if (this.buddyItemEquipped2D)
|
|
{
|
|
this.buddyItemEquipped2D.ClearItem();
|
|
}
|
|
if (this.buddyItemEquipped3D)
|
|
{
|
|
this.buddyItemEquipped3D.ClearItem();
|
|
}
|
|
}
|
|
this.inPortrait = false;
|
|
}
|
|
|
|
// Token: 0x060011AE RID: 4526 RVA: 0x0015A464 File Offset: 0x00158664
|
|
public void Setup()
|
|
{
|
|
if (this.inPortrait)
|
|
{
|
|
return;
|
|
}
|
|
if (this.invRow._ArmorID == -1)
|
|
{
|
|
return;
|
|
}
|
|
Button button = null;
|
|
Image image = null;
|
|
Links.x.inventory.GetEquipSlotInfo(this.equipIndex, out button, out image);
|
|
this.btn = button;
|
|
this.img = image;
|
|
if (this.img)
|
|
{
|
|
this.img.sprite = Links.x.archives.GetItem(this.invRow._UIModel);
|
|
this.img.enabled = true;
|
|
this.btn.interactable = true;
|
|
this.buddyItemEquipped2D = this.btn.gameObject.GetComponent<ItemEquipped>();
|
|
this.buddyItemEquipped2D.buddyItemEquipped3D = this;
|
|
this.buddyItemEquipped2D.ID = this.ID;
|
|
this.buddyItemEquipped2D.socketA = this.socketA;
|
|
this.buddyItemEquipped2D.socketB = this.socketB;
|
|
this.buddyItemEquipped2D.stackSize = this.stackSize;
|
|
this.buddyItemEquipped2D.invRow = this.invRow;
|
|
this.buddyItemEquipped2D.durability = this.durability;
|
|
this.buddyItemEquipped2D.equipIndex = this.equipIndex;
|
|
this.buddyItemEquipped2D.thisImg = this.img;
|
|
this.buddyItemEquipped2D.SetDurabilityVisual();
|
|
this.SetDurabilityVisual();
|
|
if (this.buddyItemEquipped2D.stackSizeText)
|
|
{
|
|
if (this.invRow._Stackable)
|
|
{
|
|
this.buddyItemEquipped2D.stackSizeText.text = this.stackSize.ToString();
|
|
}
|
|
else
|
|
{
|
|
this.buddyItemEquipped2D.stackSizeText.text = "";
|
|
}
|
|
}
|
|
}
|
|
if (this.buddyItemEquipped2D)
|
|
{
|
|
this.buddyItemEquipped2D.SetDurabilityVisual();
|
|
}
|
|
}
|
|
|
|
// Token: 0x060011AF RID: 4527 RVA: 0x0015A628 File Offset: 0x00158828
|
|
public void OnPointerEnter(PointerEventData eventData)
|
|
{
|
|
if (this.inPortrait)
|
|
{
|
|
return;
|
|
}
|
|
if (Links.x.mk)
|
|
{
|
|
Links.x.inventory.dropObject = base.gameObject;
|
|
Links.x.inventory.dropPosition = eventData.position;
|
|
Links.x.inventory.dropScript = Links.x.inventory.equipBag;
|
|
}
|
|
if (this.thisImg)
|
|
{
|
|
this.thisImg.color = Color.white;
|
|
}
|
|
}
|
|
|
|
// Token: 0x060011B0 RID: 4528 RVA: 0x0015A6B4 File Offset: 0x001588B4
|
|
public void OnPointerExit(PointerEventData eventData)
|
|
{
|
|
if (this.inPortrait)
|
|
{
|
|
return;
|
|
}
|
|
if (Links.x.mk)
|
|
{
|
|
Links.x.inventory.dropObject = null;
|
|
Links.x.inventory.dropScript = null;
|
|
}
|
|
if (this.thisImg)
|
|
{
|
|
this.thisImg.color = new Color(0.9f, 0.9f, 0.9f, 1f);
|
|
}
|
|
}
|
|
|
|
// Token: 0x060011B1 RID: 4529 RVA: 0x0015A728 File Offset: 0x00158928
|
|
public void OnPointerDown(PointerEventData eventData)
|
|
{
|
|
if (this.inPortrait)
|
|
{
|
|
return;
|
|
}
|
|
if (!Links.x.inventory.dragging)
|
|
{
|
|
if (Links.x.mk)
|
|
{
|
|
Links.x.inventory.prevPosition = eventData.position;
|
|
}
|
|
Links.x.inventory.startDragObject = base.gameObject;
|
|
Links.x.inventory.startDragObjectScript = Links.x.inventory.equipBag;
|
|
}
|
|
}
|
|
|
|
// Token: 0x060011B2 RID: 4530 RVA: 0x0015A7A8 File Offset: 0x001589A8
|
|
public void OnPointerUp(PointerEventData eventData)
|
|
{
|
|
}
|
|
|
|
// Token: 0x04001D21 RID: 7457
|
|
[Header("DATA")]
|
|
public int ID;
|
|
|
|
// Token: 0x04001D22 RID: 7458
|
|
public Vector3 socketA = new Vector3(-1f, -1f, -1f);
|
|
|
|
// Token: 0x04001D23 RID: 7459
|
|
public Vector3 socketB = new Vector3(-1f, -1f, -1f);
|
|
|
|
// Token: 0x04001D24 RID: 7460
|
|
public int stackSize;
|
|
|
|
// Token: 0x04001D25 RID: 7461
|
|
public Library.Inventory invRow;
|
|
|
|
// Token: 0x04001D26 RID: 7462
|
|
public Vector4 durability;
|
|
|
|
// Token: 0x04001D27 RID: 7463
|
|
public int equipIndex;
|
|
|
|
// Token: 0x04001D28 RID: 7464
|
|
public bool inPortrait;
|
|
|
|
// Token: 0x04001D29 RID: 7465
|
|
[Header("3D VERSION")]
|
|
public Renderer itemRenderer;
|
|
|
|
// Token: 0x04001D2A RID: 7466
|
|
public Image img;
|
|
|
|
// Token: 0x04001D2B RID: 7467
|
|
public Button btn;
|
|
|
|
// Token: 0x04001D2C RID: 7468
|
|
public ItemEquipped buddyItemEquipped2D;
|
|
|
|
// Token: 0x04001D2D RID: 7469
|
|
[Header("2D VERSION")]
|
|
public bool is2D;
|
|
|
|
// Token: 0x04001D2E RID: 7470
|
|
public ItemEquipped buddyItemEquipped3D;
|
|
|
|
// Token: 0x04001D2F RID: 7471
|
|
public Image thisImg;
|
|
|
|
// Token: 0x04001D30 RID: 7472
|
|
public TextMeshProUGUI stackSizeText;
|
|
}
|