using System; using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; // Token: 0x020000B7 RID: 183 public class ItemCard : MonoBehaviour { // Token: 0x0600118E RID: 4494 RVA: 0x00158B86 File Offset: 0x00156D86 private void Awake() { } // Token: 0x0600118F RID: 4495 RVA: 0x00158B88 File Offset: 0x00156D88 private void Start() { this.ToggleState(false); } // Token: 0x06001190 RID: 4496 RVA: 0x00158B91 File Offset: 0x00156D91 private void FixedUpdate() { if (Records.x.partySailing) { this.Positions(); } } // Token: 0x06001191 RID: 4497 RVA: 0x00158BA5 File Offset: 0x00156DA5 private void LateUpdate() { if (!Records.x.partySailing) { this.Positions(); } } // Token: 0x06001192 RID: 4498 RVA: 0x00158BBC File Offset: 0x00156DBC private void Positions() { if (this.hoverItem || this.hoverDoor || this.hoverChest || this.hoverPuzzle || this.hoverBreakable || this.itemName.color.a > 0f) { bool flag = false; float num = 0f; if (!Links.x.worldCamera.orthographic) { num = -0.1f; } if (this.controlsText.text == "") { num += 0.5f; } if (Links.x.joy && Records.x.pocketPause) { num -= 1f; } Vector3 vector = this.worldPoint; vector.y -= num; if (this.hoverDoor && !Links.x.gameplay.door) { flag = true; } if (this.hoverChest && !Links.x.gameplay.chest) { flag = true; } if (this.hoverBreakable) { if (this.hoverBreakable.breakable.armor > 0) { this.str.Clear(); this.BreakableText(this.hoverBreakable); this.controlsText.text = this.str.ToString(); } if (!Links.x.gameplay.breakable) { flag = true; } } if (this.hoverPuzzle && !Links.x.gameplay.puzzle) { flag = true; } Vector3 vector2 = Links.x.worldCamera.WorldToScreenPoint(this.worldPoint + new Vector3(0f, 1f - num, 0f)); float num2 = vector2.y / (float)Screen.height; vector2.z = 0f; vector2.x = vector2.x * (1920f / (float)Screen.width) - 960f; vector2.y = vector2.y * (Links.x.canvasRT.sizeDelta.y / (float)Screen.height) - Links.x.canvasRT.sizeDelta.y / 2f; if (num2 > 0.95f && !Links.x.worldCamera.orthographic) { vector2.y -= 60f; } this.rt.localPosition = vector2; if (flag) { this.End(); } } } // Token: 0x06001193 RID: 4499 RVA: 0x00158E55 File Offset: 0x00157055 public void StartHover(Item item, ChestActions chestActions, DoorActions doorActions, BreakableActions breakableActions, PuzzleActions puzzleActions) { if (this.corout == null) { this.corout = this.WaitHover(item, chestActions, doorActions, breakableActions, puzzleActions); base.StartCoroutine(this.corout); } } // Token: 0x06001194 RID: 4500 RVA: 0x00158E7F File Offset: 0x0015707F private IEnumerator WaitHover(Item item, ChestActions chestActions, DoorActions doorActions, BreakableActions breakableActions, PuzzleActions puzzleActions) { yield return new WaitForSeconds(0.001f); if (this.corout != null) { this.groundItem = false; this.chest = false; this.door = false; this.breakable = false; this.hoverDoor = null; this.hoverBreakable = null; this.hoverChest = null; this.hoverItem = null; this.puzzle = false; this.hoverPuzzle = null; if (item) { this.groundItem = true; this.hoverItem = item; } Color color = this.background.color; this.background.color = new Color(0f, 0f, 0f, color.a); bool flag = false; Character character = null; if (chestActions) { this.chest = true; this.hoverChest = chestActions; this.savedHealth = chestActions.currentHealth; this.savedLockState = chestActions.chest.locked; if (chestActions.chest.owner) { character = chestActions.chest.owner.GetComponent().GetFirstCharacter(); if (character && !character.stunned && !character.dead) { flag = true; color.r = 0.32941177f; color.b = 0.1254902f; color.g = 0.13333334f; this.background.color = color; } } } if (puzzleActions) { this.puzzle = true; this.hoverPuzzle = puzzleActions; } if (doorActions) { this.door = true; this.hoverDoor = doorActions; this.savedHealth = doorActions.currentHealth; this.savedLockState = doorActions.door.locked; if (doorActions.door.owner) { character = doorActions.door.owner.GetComponent().GetFirstCharacter(); if (character && !character.stunned && !character.dead) { flag = true; color.r = 0.32941177f; color.b = 0.1254902f; color.g = 0.13333334f; this.background.color = color; } } } if (breakableActions) { this.breakable = true; this.hoverBreakable = breakableActions; this.savedHealth = breakableActions.currentHealth; this.savedLockState = false; } if (this.coroutine != null) { base.StopCoroutine(this.coroutine); this.coroutine = null; } if (!Records.x.mainCharacterDead && (chestActions || doorActions || item || breakableActions || puzzleActions)) { Library.Inventory inventory = null; if (item) { inventory = item.invRow; } this.ToggleState(true); bool flag2 = false; float num = 0f; if (this.groundItem) { this.portrait.enabled = true; this.portrait.sprite = Links.x.archives.GetItem(inventory._UIModelFull); this.healthBar.enabled = false; } else if (this.chest) { this.portrait.enabled = false; this.portrait.sprite = this.chestSprite; this.healthBar.enabled = true; this.healthBar.fillAmount = (float)chestActions.currentHealth / (float)chestActions.chest.health; num = (float)chestActions.currentHealth / (float)chestActions.chest.health; if (chestActions.chest.locked) { flag2 = true; } } else if (this.door) { this.portrait.enabled = false; this.portrait.sprite = this.doorSprite; this.healthBar.enabled = true; this.healthBar.fillAmount = (float)doorActions.currentHealth / (float)doorActions.door.health; num = (float)doorActions.currentHealth / (float)doorActions.door.health; if (doorActions.door.locked) { flag2 = true; } } else if (this.breakable) { this.portrait.enabled = false; this.portrait.sprite = this.doorSprite; this.healthBar.enabled = true; this.healthBar.fillAmount = (float)breakableActions.currentHealth / (float)breakableActions.breakable.health; num = (float)breakableActions.currentHealth / (float)breakableActions.breakable.health; if (breakableActions.breakable.armor > 0) { flag2 = true; } } else if (this.puzzle) { this.portrait.enabled = false; this.healthBar.enabled = false; } this.portrait.enabled = true; this.str.Clear(); this.controlsText.spriteAsset = Links.x.GetSpriteSheetAsset(Links.x.gameplay.currentSpriteSheetAsset); if (this.groundItem) { if (Links.x.mk) { this.itemName.text = "\n" + inventory._DisplayName; } else { this.itemName.text = inventory._DisplayName; this.str.Append("Pick up"); this.str.Append(" "); } } else if (this.chest) { if (flag) { if (chestActions.chest.locked) { this.itemName.text = character.stats.GetName() + "'s locked chest"; } else { this.itemName.text = character.stats.GetName() + "'s chest"; } } else if (chestActions.chest.locked) { this.itemName.text = "Locked chest"; } else { this.itemName.text = "Chest"; } bool flag3 = chestActions.HasKey(Links.x.main); if (Links.x.mk) { if (Records.x.pocketPause) { this.str.Append("Break "); this.str.Append(" "); } else { if (chestActions.chest.locked) { if (flag3) { this.str.Append("Use Key "); } else { this.str.Append("Lockpick "); } } else { this.str.Append("Open "); } this.str.Append(" "); } } else if (!Records.x.pocketPause && chestActions.chest.locked && flag3) { this.itemName.text = "Locked chest (Use Key)"; } } else if (this.breakable) { if (breakableActions.breakable.armor > 0) { this.BreakableText(breakableActions); } else { if (breakableActions.gameObject.name.Contains("Bramb")) { if (breakableActions.gameObject.name.Contains("Strong")) { this.itemName.text = "Thick Bramble"; } else { this.itemName.text = "Bramble"; } } else if (breakableActions.gameObject.name.Contains("Urn")) { this.itemName.text = "Urn"; } else if (breakableActions.gameObject.name.Contains("Grave")) { this.itemName.text = "Gravestone"; } else if (breakableActions.gameObject.name.Contains("Spore")) { this.itemName.text = "Spore"; } else if (breakableActions.gameObject.name.Contains("Vine")) { this.itemName.text = "Vine"; } else { this.itemName.text = "Barrel"; } if (Links.x.mk) { this.str.Append("Kick "); this.str.Append(" "); } else if (!Records.x.pocketPause) { this.AddChangeTarget(); } } } else if (this.door) { bool flag4 = false; if (doorActions.door.lockable) { flag4 = doorActions.HasKey(Links.x.main); } if (flag) { this.itemName.text = character.stats.GetName() + "'s lock"; } else if (doorActions.door.locked) { this.itemName.text = "Bolted lock"; } else { this.itemName.text = "Lock"; } if (Links.x.mk) { if (Records.x.pocketPause) { this.str.Append("Break "); this.str.Append(" "); } else { if (doorActions.door.locked) { if (flag4) { this.str.Append("Unlock with key "); } else { this.str.Append("Unlock "); } } else if (flag4) { this.str.Append("Lock with key "); } else { this.str.Append("Lock "); } this.str.Append(" "); } } else if (!Records.x.pocketPause && doorActions.door.locked && flag4) { this.itemName.text = "Bolted Lock (Use Key)"; } } else if (this.puzzle) { this.itemName.text = puzzleActions.puzzle.displayNameIfHoverable; if (puzzleActions.id == "Revive") { if ((puzzleActions.gameObject.transform.position - Links.x.main.tr.position).sqrMagnitude < Links.x.main.InteractionDistanceCheck("Puzzle") || Links.x.joy) { this.str.Append("Hold to Revive "); if (Links.x.mk) { this.str.Append(" "); } else { this.str.Append(" "); } } else { this.str.Append("\nToo far to revive"); } } else if (Links.x.mk) { if (puzzleActions.id == "Birch") { this.str.Append("Visit "); } else if (puzzleActions.id.Contains("SemizenStatue")) { this.str.Append("Visit "); } else { this.str.Append("Interact "); } this.str.Append(" "); } else { bool pocketPause = Records.x.pocketPause; } } if (flag2) { string text = "Undamaged"; if (num >= 0.667f && num < 1f) { text = "Scratched"; } if (num < 0.67f && num > 0.4f) { text = "Dented"; } if (num <= 0.4f && num > 0.14f) { text = "Splintering"; } if (num <= 0.14f) { text = "Nearly Broken"; } if (num < 1f) { TextMeshProUGUI textMeshProUGUI = this.itemName; textMeshProUGUI.text += "\n("; TextMeshProUGUI textMeshProUGUI2 = this.itemName; textMeshProUGUI2.text += text; TextMeshProUGUI textMeshProUGUI3 = this.itemName; textMeshProUGUI3.text += "}"; } } this.controlsText.text = this.str.ToString(); this.vignetteRT.sizeDelta = new Vector2(this.itemName.preferredWidth + 20f, this.vignetteRT.sizeDelta.y); if (this.hoverItem || this.hoverDoor || this.hoverChest || this.hoverPuzzle || this.hoverBreakable) { if (this.animator.enabled) { float normalizedTime = this.animator.GetCurrentAnimatorStateInfo(0).normalizedTime; if (!this.animator.GetCurrentAnimatorStateInfo(0).IsName("GameCardOff")) { this.animator.Play("GameCardIdle"); } else { this.animator.Play("GameCardOn"); } } else { this.animator.enabled = true; this.animator.Play("GameCardOn"); } this.animator.SetBool("On", true); } if (!item) { this.portrait.enabled = false; this.portraitBG.enabled = false; } } this.worldPoint = Vector3.zero; GameObject gameObject = null; if (this.hoverItem) { gameObject = this.hoverItem.bracket; if (!gameObject) { this.worldPoint = this.hoverItem.tr.position + new Vector3(0f, 1f, 0f); } } if (this.hoverDoor) { gameObject = this.hoverDoor.bracket; if (!gameObject) { this.worldPoint = this.hoverDoor.lockColliderPosition + new Vector3(0f, 1f, 0f); } } if (this.hoverChest) { gameObject = this.hoverChest.bracket; if (!gameObject) { this.worldPoint = this.hoverChest.tr.position + new Vector3(0f, 1f, 0f); } } if (this.hoverBreakable) { gameObject = this.hoverBreakable.bracket; if (!gameObject) { this.worldPoint = this.hoverBreakable.transform.position + new Vector3(0f, 1f, 0f); } if (this.hoverBreakable.breakable.armor > 0) { this.str.Clear(); this.BreakableText(this.hoverBreakable); this.controlsText.text = this.str.ToString(); } } if (this.hoverPuzzle) { gameObject = this.hoverPuzzle.bracket; if (!gameObject) { this.worldPoint = this.hoverPuzzle.gameObject.transform.position + new Vector3(0f, 1f + this.hoverPuzzle.interactionPointY, 0f); } } if (gameObject) { this.worldPoint = Vector3.Lerp(gameObject.transform.GetChild(0).transform.position, gameObject.transform.GetChild(1).transform.position, 0.5f); } } this.corout = null; yield break; } // Token: 0x06001195 RID: 4501 RVA: 0x00158EB4 File Offset: 0x001570B4 private void BreakableText(BreakableActions breakableActions) { if (breakableActions.gameObject.name.Contains("Vine")) { this.itemName.text = "Vines"; } else if (breakableActions.gameObject.name.Contains("Shroom")) { this.itemName.text = "Growth"; } else if (breakableActions.gameObject.name.Contains("Bramb")) { this.itemName.text = "Bramble"; } else { this.itemName.text = "Breakable Object"; } float sqrMagnitude = (breakableActions.gameObject.transform.position - new Vector3(Links.x.gameplay.attackingCharacter.tr.position.x, breakableActions.gameObject.transform.position.y, Links.x.gameplay.attackingCharacter.tr.position.z)).sqrMagnitude; float num = Links.x.gameplay.attackingCharacter.AttackRange(); if (sqrMagnitude < num * num || Links.x.combat.BreakableIsNear(breakableActions, Links.x.gameplay.attackingCharacter)) { if (Links.x.gameplay.attackingCharacter.CanAttack() && Links.x.combat.BreakableIsNear(breakableActions, Links.x.gameplay.attackingCharacter)) { if (Links.x.mk) { this.str.Append("Attack "); this.str.Append(" "); return; } this.str.Append("Attack "); this.str.Append(" "); this.AddChangeTarget(); return; } else if (!Links.x.gameplay.attackingCharacter.CanAttack()) { this.itemName.text = ""; return; } } else { this.str.Append("\nToo far away to attack"); } } // Token: 0x06001196 RID: 4502 RVA: 0x00159170 File Offset: 0x00157370 private void AddChangeTarget() { if (Records.x.pocketPause && Links.x.combat.ItemCardCount() > 1) { this.str.Append("Change Target "); this.str.Append(" "); } if (!Records.x.pocketPause && Links.x.hudControl.ItemCardCount() > 1) { this.str.Append("Change Target "); this.str.Append(" "); } } // Token: 0x06001197 RID: 4503 RVA: 0x00159284 File Offset: 0x00157484 public void EndHover(Item item, ChestActions chestAction, DoorActions doorAction, BreakableActions breakableAction, PuzzleActions puzzleAction, bool wait) { if (((this.hoverItem == item && this.groundItem) || (this.hoverChest == chestAction && this.chest) || (this.hoverDoor == doorAction && this.door) || (this.hoverBreakable == breakableAction && this.breakable) || (this.hoverPuzzle == puzzleAction && this.puzzle)) && wait) { this.hoverItem = null; this.hoverChest = null; this.hoverDoor = null; this.hoverBreakable = null; this.hoverPuzzle = null; this.coroutine = this.StartEnd(); base.StartCoroutine(this.coroutine); if (this.corout != null) { base.StopCoroutine(this.corout); this.corout = null; } } else { this.EndHoverContinued(); } this.hoverItem = null; } // Token: 0x06001198 RID: 4504 RVA: 0x00159370 File Offset: 0x00157570 public void EndHoverContinued() { float num = this.animator.GetCurrentAnimatorStateInfo(0).normalizedTime; if (!this.animator.GetCurrentAnimatorStateInfo(0).IsName("GameCardOn")) { num = 1f; } if (this.animator.GetCurrentAnimatorStateInfo(0).IsName("GameCardOn") || this.animator.GetCurrentAnimatorStateInfo(0).IsName("GameCardIdle")) { this.animator.Play("GameCardOff", 0, 1f - num); } this.animator.SetBool("On", false); } // Token: 0x06001199 RID: 4505 RVA: 0x00159414 File Offset: 0x00157614 public void End() { if (this.corout != null) { base.StopCoroutine(this.corout); this.corout = null; } this.hoverItem = null; this.hoverChest = null; this.hoverDoor = null; this.hoverBreakable = null; this.hoverPuzzle = null; float num = this.animator.GetCurrentAnimatorStateInfo(0).normalizedTime; if (!this.animator.GetCurrentAnimatorStateInfo(0).IsName("GameCardOn")) { num = 1f; } if (this.animator.GetCurrentAnimatorStateInfo(0).IsName("GameCardOn") || this.animator.GetCurrentAnimatorStateInfo(0).IsName("GameCardIdle")) { this.animator.Play("GameCardOff", 0, 1f - num); } this.animator.SetBool("On", false); } // Token: 0x0600119A RID: 4506 RVA: 0x001594F4 File Offset: 0x001576F4 private IEnumerator StartEnd() { yield return new WaitForSeconds(0.06f); if (!this.hoverItem && !this.hoverChest && !this.hoverDoor && !this.hoverBreakable && !this.hoverPuzzle) { this.EndHoverContinued(); } yield break; } // Token: 0x0600119B RID: 4507 RVA: 0x00159503 File Offset: 0x00157703 public void AnimationDone() { this.ToggleState(false); this.animator.enabled = false; } // Token: 0x0600119C RID: 4508 RVA: 0x00159518 File Offset: 0x00157718 public void ToggleState(bool state) { for (int i = 0; i < this.images.Count; i++) { this.images[i].enabled = state; } for (int j = 0; j < this.texts.Count; j++) { this.texts[j].enabled = state; } this.portrait.enabled = state; } // Token: 0x04001CFC RID: 7420 public Animator animator; // Token: 0x04001CFD RID: 7421 public List images = new List(); // Token: 0x04001CFE RID: 7422 public List texts = new List(); // Token: 0x04001CFF RID: 7423 public Image portrait; // Token: 0x04001D00 RID: 7424 public Image portraitBG; // Token: 0x04001D01 RID: 7425 public RectTransform vignetteRT; // Token: 0x04001D02 RID: 7426 public TextMeshProUGUI itemName; // Token: 0x04001D03 RID: 7427 public TextMeshProUGUI controlsText; // Token: 0x04001D04 RID: 7428 public Item hoverItem; // Token: 0x04001D05 RID: 7429 public DoorActions hoverDoor; // Token: 0x04001D06 RID: 7430 public ChestActions hoverChest; // Token: 0x04001D07 RID: 7431 public BreakableActions hoverBreakable; // Token: 0x04001D08 RID: 7432 public PuzzleActions hoverPuzzle; // Token: 0x04001D09 RID: 7433 private IEnumerator coroutine; // Token: 0x04001D0A RID: 7434 private float closeTime; // Token: 0x04001D0B RID: 7435 private StringFast str = new StringFast(64); // Token: 0x04001D0C RID: 7436 public Sprite chestSprite; // Token: 0x04001D0D RID: 7437 public Sprite doorSprite; // Token: 0x04001D0E RID: 7438 public bool chest; // Token: 0x04001D0F RID: 7439 public bool door; // Token: 0x04001D10 RID: 7440 public bool groundItem; // Token: 0x04001D11 RID: 7441 public bool breakable; // Token: 0x04001D12 RID: 7442 public bool puzzle; // Token: 0x04001D13 RID: 7443 public Image healthBar; // Token: 0x04001D14 RID: 7444 public int savedHealth; // Token: 0x04001D15 RID: 7445 public bool savedLockState; // Token: 0x04001D16 RID: 7446 public Image background; // Token: 0x04001D17 RID: 7447 public GameCard gameCard; // Token: 0x04001D18 RID: 7448 public RectTransform rt; // Token: 0x04001D19 RID: 7449 private IEnumerator corout; // Token: 0x04001D1A RID: 7450 private Vector3 worldPoint; }