Files
BepInEx/Projects/BanquetForFools/Source/Assembly-CSharp/InventoryContainer.cs
2025-05-21 20:40:04 +02:00

1417 lines
40 KiB
C#

using System;
using System.Collections.Generic;
using DarkTonic.MasterAudio;
using PixelCrushers.DialogueSystem;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
// Token: 0x020000B4 RID: 180
public class InventoryContainer : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerDownHandler, IPointerUpHandler
{
// Token: 0x0600111A RID: 4378 RVA: 0x0014E91D File Offset: 0x0014CB1D
private void Awake()
{
this.tr = base.transform;
this.Close();
}
// Token: 0x0600111B RID: 4379 RVA: 0x0014E931 File Offset: 0x0014CB31
private void Start()
{
if (this.inv == null)
{
this.inv = Links.x.inventory;
}
}
// Token: 0x0600111C RID: 4380 RVA: 0x0014E954 File Offset: 0x0014CB54
public void Open()
{
this.active = true;
if (this.img)
{
this.img.enabled = true;
}
if (this.weightTextGo)
{
this.weightTextGo.SetActive(true);
}
foreach (GameObject gameObject in this.slots)
{
if (!Links.x.characterSheet.merchant)
{
gameObject.SetActive(true);
}
else
{
gameObject.SetActive(false);
}
}
int num = 0;
foreach (Image image in this.imgs)
{
image.enabled = true;
this.btns[num].enabled = true;
num++;
}
if (this.bag)
{
foreach (global::Item item in this.bagItems)
{
if (item)
{
if (!Links.x.characterSheet.merchant || (Links.x.characterSheet.merchant && !item.isEquipped))
{
item.img.enabled = true;
item.stackText.enabled = true;
item.ToggleSocket(false);
item.bag = this;
}
else
{
item.img.enabled = false;
item.stackText.enabled = false;
item.ToggleSocket(false);
}
item.SetDurabilityVisual();
}
}
}
}
// Token: 0x0600111D RID: 4381 RVA: 0x0014EB2C File Offset: 0x0014CD2C
public void Close()
{
this.active = false;
if (this.img && !this.ground && !this.equip)
{
this.img.enabled = false;
}
if (this.weightTextGo)
{
this.weightTextGo.SetActive(false);
}
int num = 0;
foreach (Image image in this.imgs)
{
image.enabled = false;
this.btns[num].enabled = false;
num++;
}
foreach (GameObject gameObject in this.slots)
{
gameObject.SetActive(false);
}
foreach (global::Item item in this.bagItems)
{
if (item && item.img)
{
item.img.enabled = true;
}
}
if (this.bag)
{
foreach (global::Item item2 in this.bagItems)
{
if (item2)
{
item2.img.enabled = false;
item2.stackText.enabled = false;
item2.ToggleSocket(false);
}
}
}
}
// Token: 0x0600111E RID: 4382 RVA: 0x0014ECF0 File Offset: 0x0014CEF0
public void PickUpItemFromInventory(UITriggerButton btn, global::Item item)
{
if (this.btns.IndexOf(btn) > -1)
{
if (Links.x.inventory.dragging)
{
Links.x.inventory.releaseItem = true;
return;
}
this.draggingButton = btn.GetButton();
this.OnPointerDown(null);
Links.x.inventory.hitItem = item;
Links.x.inventory.PrepareDrag();
}
}
// Token: 0x0600111F RID: 4383 RVA: 0x0014ED60 File Offset: 0x0014CF60
public global::Item GetItem(Button btn)
{
Vector3 position = btn.transform.position;
float num = float.PositiveInfinity;
int num2 = -1;
int count = this.bagItems.Count;
for (int i = 0; i < count; i++)
{
if (this.bagItems[i])
{
float sqrMagnitude = (this.bagItems[i].tr.position - position).sqrMagnitude;
if (sqrMagnitude < num)
{
num = sqrMagnitude;
num2 = i;
}
}
}
if (num2 > -1)
{
return this.bagItems[num2];
}
return null;
}
// Token: 0x06001120 RID: 4384 RVA: 0x0014EDFC File Offset: 0x0014CFFC
public void UpdateItemInteractableState(bool state)
{
Color color = new Color(0.5f, 0.5f, 0.5f, 1f);
Color color2 = new Color(1f, 1f, 1f, 1f);
Color color3 = new Color(0.5f, 0.5f, 0.5f, 0.4f);
Color color4 = new Color(1f, 1f, 1f, 0.4f);
if (Links.x.mk)
{
for (int i = 0; i < this.btns.Count; i++)
{
this.btns[i].GetButton().enabled = false;
this.imgs[i].raycastTarget = state;
if (Links.x.inventory.dragging)
{
this.imgs[i].color = color;
}
else
{
this.imgs[i].color = color;
}
}
}
else if (this.ground)
{
for (int j = 0; j < this.btns.Count; j++)
{
this.imgs[j].color = color2;
this.imgs[j].raycastTarget = state;
if (!state)
{
this.btns[j].GetButton().enabled = state;
this.btns[j].GetButton().interactable = state;
if (Links.x.inventory.dragging)
{
this.imgs[j].color = color3;
}
else
{
this.imgs[j].color = color3;
}
}
else
{
this.btns[j].GetButton().enabled = state;
this.btns[j].GetButton().interactable = state;
if (Links.x.inventory.dragging)
{
this.imgs[j].color = color4;
}
else
{
this.imgs[j].color = color4;
}
}
}
}
else
{
for (int k = 0; k < this.btns.Count; k++)
{
this.btns[k].GetButton().enabled = false;
this.btns[k].GetButton().interactable = false;
if (Links.x.inventory.dragging)
{
this.imgs[k].color = color3;
}
}
}
this.lastInteractableState = state;
}
// Token: 0x06001121 RID: 4385 RVA: 0x0014F0A8 File Offset: 0x0014D2A8
public void AddImage(Image img, global::Item x)
{
int num = this.imgs.IndexOf(img);
if (num == -1)
{
this.imgs.Add(img);
UITriggerButton component = img.gameObject.GetComponent<UITriggerButton>();
component.SetBag(this);
component.SetItem(x);
this.btns.Add(component);
if (x)
{
x.bag = this;
}
}
else
{
this.btns[num].SetBag(this);
this.btns[num].SetItem(x);
if (x)
{
x.bag = this;
}
}
Links.x.inventory.SetBackImageSize(img, x);
}
// Token: 0x06001122 RID: 4386 RVA: 0x0014F150 File Offset: 0x0014D350
public void SetInteractable(Image img)
{
int num = this.imgs.IndexOf(img);
if (num > -1)
{
this.btns[num].GetButton().interactable = true;
}
}
// Token: 0x06001123 RID: 4387 RVA: 0x0014F188 File Offset: 0x0014D388
public void RemoveImage(Image img)
{
int num = this.imgs.IndexOf(img);
if (num > -1)
{
this.imgs.RemoveAt(num);
this.btns.RemoveAt(num);
}
}
// Token: 0x06001124 RID: 4388 RVA: 0x0014F1C0 File Offset: 0x0014D3C0
public void EmptyItems()
{
foreach (global::Item item in this.bagItems)
{
if (item)
{
item.DestroyItem(false, false);
}
}
this.bagItems.Clear();
this.bagID.Clear();
this.bagAmount.Clear();
this.socketA.Clear();
this.socketB.Clear();
this.bagPos.Clear();
this.durability.Clear();
}
// Token: 0x06001125 RID: 4389 RVA: 0x0014F26C File Offset: 0x0014D46C
public void SetDurability(Vector4 dur, int index)
{
this.durability[index] = dur;
global::Item item = this.bagItems[index];
if (item && item.invRow._Tag.Contains("Armor"))
{
item.CheckIfPatchBreaks();
}
}
// Token: 0x06001126 RID: 4390 RVA: 0x0014F2B8 File Offset: 0x0014D4B8
public void SetSocketA(Vector3 sock, int index)
{
this.socketA[index] = sock;
global::Item item = this.bagItems[index];
if (item)
{
item.socketA = sock;
}
}
// Token: 0x06001127 RID: 4391 RVA: 0x0014F2F0 File Offset: 0x0014D4F0
public void SetListItems(int invIndex, global::Item i, int newID, int amt, Vector3 sockA, Vector3 sockB, int pos, Vector4 time)
{
this.bagItems[invIndex] = i;
this.bagID[invIndex] = newID;
this.bagAmount[invIndex] = amt;
this.bagPos[invIndex] = pos;
this.socketA[invIndex] = sockA;
this.socketB[invIndex] = sockB;
this.durability[invIndex] = time;
}
// Token: 0x06001128 RID: 4392 RVA: 0x0014F360 File Offset: 0x0014D560
public void CreateFist(int equipIndex, Transform par, bool updateCharacter)
{
global::Item item = Links.x.inventory.SpawnItem(null, false, 1, 0, new Vector3(-1f, -1f, -1f), new Vector3(-1f, -1f, -1f), new Vector4(0f, 0f, 0f, 0f), Vector3.zero, par);
if (item)
{
Image component = item.gameObject.GetComponent<Image>();
if (component != null)
{
component.sprite = Links.x.inventory.emptySprite;
}
if (this.bagID[equipIndex + 1] > 0)
{
this.bagID[equipIndex + 1] = 0;
this.bagAmount[equipIndex + 1] = 1;
this.socketA[equipIndex + 1] = Vector3.zero;
this.socketB[equipIndex + 1] = Vector3.zero;
}
this.bagID[equipIndex] = 1;
this.bagAmount[equipIndex] = 1;
this.socketA[equipIndex] = Vector3.zero;
this.socketB[equipIndex] = Vector3.zero;
if (item != null)
{
this.bagItems[equipIndex] = item;
}
this.character.UpdateListsFromInv(true);
if (equipIndex == 0 && updateCharacter)
{
this.character.CreateEquippedItems(1, 0, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), 0, false);
}
}
}
// Token: 0x06001129 RID: 4393 RVA: 0x0014F4F0 File Offset: 0x0014D6F0
public void NewHour()
{
int count = this.durability.Count;
for (int i = 0; i < count; i++)
{
if ((int)this.durability[i].x != 0 && (i > 18 || i == 7 || i == 13 || i == 14 || i == 8))
{
int num = (int)this.durability[i].x - (int)Mathf.Floor((float)Links.x.gameplay.GetCurrentGameTimeHours());
if (num > 0)
{
if (num <= 24 && this.bagItems[i])
{
this.bagItems[i].SetDurabilityVisual();
}
}
else
{
Library.Inventory inventory;
if (this.bagItems[i])
{
inventory = this.bagItems[i].invRow;
}
else
{
inventory = Links.x.library.GetInvRowByIndex(this.bagID[i]);
}
if (inventory._Life > 0)
{
bool flag = true;
if (!inventory._Effect.Contains("Cure"))
{
if (inventory._SetQuest != "")
{
if (inventory._SetQuest == "C6_Dan")
{
Links.x.gameFeed.AddFeed("<color=#FFFFFF>The dryad flower has withered</color>");
flag = false;
int id = Links.x.library.GetInvRowFromName("DryadFlowerDead")._ID;
int bagGridID = this.bagItems[i].bagGridID;
List<int> list = new List<int>();
foreach (int num2 in this.bagItems[i].gridImg)
{
list.Add(num2);
}
Vector3 position = this.bagItems[i].transform.position;
this.character.UpdateInvLists("BagRemove", i, 0, 0, Vector4.zero, Vector3.zero, Vector3.zero, this.bagItems[i]);
global::Item item;
ItemEquipped itemEquipped;
Links.x.inventory.AddFromGround(null, null, 0, false, 0f, id, 1, Vector3.zero, Vector3.zero, Vector4.zero, this.character, false, false, out item, out itemEquipped);
global::Item item2 = this.CheckListForItem(id);
if (item2)
{
item2.bagGridID = bagGridID;
item2.gridImg.Clear();
foreach (int num3 in list)
{
item2.gridImg.Add(num3);
}
item2.transform.position = position;
}
QuestLog.SetQuestState("C6_Willowmaid", QuestState.ReturnToNPC);
}
else
{
Links.x.gameFeed.AddFeed("<color=#FFFFFF>" + inventory._DisplayName + " has crumbled from age</color>");
}
}
else
{
Links.x.gameFeed.AddFeed("<color=#FFFFFF>" + inventory._DisplayName + " has crumbled from age</color>");
}
}
if (flag)
{
this.character.UpdateInvLists("BagRemove", i, 0, 0, Vector4.zero, Vector3.zero, Vector3.zero, this.bagItems[i]);
}
}
}
}
}
}
// Token: 0x0600112A RID: 4394 RVA: 0x0014F868 File Offset: 0x0014DA68
public global::Item CheckListForItem(int num)
{
for (int i = 0; i < this.bagItems.Count; i++)
{
if (this.bagItems[i] && this.bagItems[i].ID == num)
{
return this.bagItems[i];
}
}
return null;
}
// Token: 0x0600112B RID: 4395 RVA: 0x0014F8C0 File Offset: 0x0014DAC0
public void RemoveBagItem(int index)
{
this.bagItems[index] = null;
this.bagID[index] = 0;
this.bagAmount[index] = 0;
this.bagPos[index] = -1;
this.socketA[index] = Vector3.zero;
this.socketB[index] = Vector3.zero;
this.durability[index] = Vector4.zero;
this.UpdateWeight();
}
// Token: 0x0600112C RID: 4396 RVA: 0x0014F93C File Offset: 0x0014DB3C
public void LookForTorch()
{
int count = this.bagID.Count;
for (int i = 0; i < count; i++)
{
if ((i == 7 || i == 13 || i == 14) && (this.bagID[i] == Links.x.library.torchID || this.bagID[i] == Links.x.library.incenseTorchID))
{
float z = this.durability[i].z;
float seconds = Links.x.gameplay.seconds;
if (this.durability[i].x - (seconds - z) <= 0f)
{
if (this.bagID[i] == Links.x.library.torchID)
{
Links.x.gameFeed.AddFeed(this.character.stats.GetName() + "'s torch is depleted");
}
else
{
Links.x.gameFeed.AddFeed(this.character.stats.GetName() + "'s incense is depleted");
}
this.character.UpdateInvLists("BagRemove", i, 0, 0, Vector4.zero, Vector3.zero, Vector3.zero, null);
}
}
if (i == 8 && this.bagID[i] > 1)
{
Library.Inventory invRowByIndex = Links.x.library.GetInvRowByIndex(this.bagID[i]);
if (invRowByIndex._Effect.Contains("Cure"))
{
float x = this.durability[i].x;
float seconds2 = Links.x.gameplay.seconds;
if (x - seconds2 <= 0f)
{
string text = "Cure";
string text2 = "";
int num = invRowByIndex._Effect.IndexOf(text);
if (num != -1)
{
text2 = invRowByIndex._Effect.Substring(num + text.Length);
}
if (this.character.stats.HasEffectAndCure(text2))
{
Links.x.gameFeed.AddFeed(invRowByIndex._DisplayName + " has cured " + this.character.stats.GetName());
MasterAudio.PlaySoundAndForget("Feedback", 0.2f, new float?(1f), 0f, "Word of Power", null);
}
else
{
Links.x.gameFeed.AddFeed(this.character.stats.GetName() + "'s " + invRowByIndex._DisplayName + " has crumbled");
string text3 = "Crumbled ";
Character character = this.character;
Debug.Log(text3 + ((character != null) ? character.ToString() : null));
}
this.character.UpdateInvLists("BagRemove", i, 0, 0, Vector4.zero, Vector3.zero, Vector3.zero, this.bagItems[i]);
}
}
}
if (i > 17 && this.bagID[i] == Links.x.library.bombID && Links.x.gameplay.seconds > this.bagItems[i].durability.x + 126f)
{
Links.x.gameFeed.AddFeed(this.character.stats.GetName() + "'s " + this.bagItems[i].invRow._DisplayName + " exploded");
this.bagItems[i].BombBomb(this.character.currentPosition);
this.character.UpdateInvLists("BagRemove", i, 0, 0, Vector4.zero, Vector3.zero, Vector3.zero, this.bagItems[i]);
}
}
}
// Token: 0x0600112D RID: 4397 RVA: 0x0014FD20 File Offset: 0x0014DF20
public void SwapBagItem(int index1, int index2, Character party, bool updatedBodyEquipped)
{
this.durability = this.durability;
this.bagItems = this.bagItems;
this.bagID = this.bagID;
this.bagAmount = this.bagAmount;
this.socketA = this.socketA;
this.socketB = this.socketB;
this.bagPos = this.bagPos;
global::Item item = this.bagItems[index1];
int num = this.bagID[index1];
int num2 = this.bagAmount[index1];
int num3 = this.bagPos[index1];
Vector3 vector = this.socketA[index1];
Vector3 vector2 = this.socketB[index1];
Vector4 vector3 = this.durability[index1];
global::Item item2 = this.bagItems[index2];
int num4 = this.bagID[index2];
int num5 = this.bagAmount[index2];
int num6 = this.bagPos[index2];
Vector3 vector4 = this.socketA[index2];
Vector3 vector5 = this.socketB[index2];
Vector4 vector6 = this.durability[index2];
this.bagItems[index1] = item2;
this.bagID[index1] = num4;
this.bagAmount[index1] = num5;
this.bagPos[index1] = num6;
this.socketA[index1] = vector4;
this.socketB[index1] = vector5;
this.durability[index1] = vector6;
this.bagItems[index2] = item;
this.bagID[index2] = num;
this.bagAmount[index2] = num2;
this.bagPos[index2] = num3;
this.socketA[index2] = vector;
this.socketB[index2] = vector2;
this.durability[index2] = vector3;
if (index1 < 19 && updatedBodyEquipped)
{
party.CreateEquippedItems(this.bagID[index1], this.bagAmount[index1], this.socketA[index1], this.socketB[index1], index1 * 2, true);
}
if (index1 < 19 && updatedBodyEquipped)
{
party.CreateEquippedItems(this.bagID[index2], this.bagAmount[index2], this.socketA[index2], this.socketB[index2], index2 * 2, true);
}
if (index1 >= 19 && index2 <= 19)
{
this.bagItems[index2].DestroyItem(false, false);
this.bagItems[index2] = null;
}
if (index2 >= 19 && index1 <= 19)
{
this.bagItems[index1].DestroyItem(false, false);
this.bagItems[index1] = null;
}
party.UpdateListsFromInv(updatedBodyEquipped);
if (party.portrait && updatedBodyEquipped)
{
party.portrait.skillBag.UpdateWindowStates();
}
}
// Token: 0x0600112E RID: 4398 RVA: 0x0015000C File Offset: 0x0014E20C
public void UpdateBagItem(int index, int id, int stack, Vector4 dur, Vector3 sA, Vector3 sB, Character c)
{
this.bagItems[index] = null;
this.bagID[index] = id;
this.bagAmount[index] = stack;
this.bagPos[index] = 0;
this.socketA[index] = sA;
this.socketB[index] = sB;
this.durability[index] = dur;
}
// Token: 0x0600112F RID: 4399 RVA: 0x00150078 File Offset: 0x0014E278
public void UpdateBagItem(global::Item item, int index)
{
this.bagItems[index] = item;
this.bagID[index] = item.ID;
this.bagAmount[index] = item.stackSize;
this.bagPos[index] = item.bagGridID;
this.socketA[index] = item.socketA;
this.socketB[index] = item.socketB;
this.durability[index] = item.durability;
}
// Token: 0x06001130 RID: 4400 RVA: 0x001500FE File Offset: 0x0014E2FE
public int ItemIndex(global::Item item)
{
return this.bagItems.IndexOf(item);
}
// Token: 0x06001131 RID: 4401 RVA: 0x0015010C File Offset: 0x0014E30C
public global::Item GetBagItem(int i)
{
return this.bagItems[i];
}
// Token: 0x06001132 RID: 4402 RVA: 0x0015011C File Offset: 0x0014E31C
public void SetBagAmt(int index, int num)
{
if (index <= 18)
{
if (Links.x.characterSheet.open)
{
ItemEquipped itemEquipped = Links.x.characterSheet.body.GetItemEquipped(index);
if (itemEquipped)
{
itemEquipped.stackSize = num;
}
else
{
Debug.Log("missing current equipped " + index.ToString());
}
}
this.bagAmount[index] = num;
return;
}
if (index > -1 && index < this.bagAmount.Count)
{
this.bagAmount[index] = num;
this.character.UpdateListsFromInv(true);
}
}
// Token: 0x06001133 RID: 4403 RVA: 0x001501B8 File Offset: 0x0014E3B8
public void SetBagAmt(global::Item item, int num)
{
int num2 = this.bagItems.IndexOf(item);
if (num2 > -1 && num2 < this.bagAmount.Count)
{
this.bagAmount[num2] = num;
this.character.UpdateListsFromInv(true);
}
}
// Token: 0x06001134 RID: 4404 RVA: 0x00150200 File Offset: 0x0014E400
public void RemoveStack(global::Item item, int amt)
{
int num = this.bagItems.IndexOf(item);
if (num <= -1)
{
if (item)
{
item.DestroyItem(true, false);
}
return;
}
item.stackSize = this.bagAmount[num] - amt;
if (item.stackSize <= 0)
{
item.DestroyItem(true, false);
this.UpdateWeight();
return;
}
this.bagAmount[num] = item.stackSize;
this.bagItems[num].CheckStackSize();
this.SetBagAmt(item, item.stackSize);
this.character.UpdateListsFromInv(true);
}
// Token: 0x06001135 RID: 4405 RVA: 0x00150298 File Offset: 0x0014E498
public void UpdateWeight()
{
this.weight = 0f;
for (int i = 0; i < this.bagItems.Count; i++)
{
if (this.bagItems[i])
{
this.bagPos[i] = this.bagItems[i].bagGridID;
int num = this.bagAmount[i];
if (num < 1 || !this.bagItems[i].invRow._Stackable)
{
num = 1;
}
this.weight += this.bagItems[i].invRow._Weight * (float)num;
this.bagItems[i].durability = this.durability[i];
}
else if (i < 19 && this.bagID[i] > 1)
{
Library.Inventory invRowByIndex = Links.x.library.GetInvRowByIndex(this.bagID[i]);
int num2 = this.bagAmount[i];
if (num2 < 1 || !invRowByIndex._Stackable)
{
num2 = 1;
}
this.weight += invRowByIndex._Weight * (float)num2;
}
}
this.weight = Mathf.Round(this.weight);
if (Links.x.inventory.open)
{
this.weightText.text = "Bag Weight: " + this.weight.ToString() + "/" + this.character.stats.CarryingWeight().ToString();
Links.x.inventory.bagWeightFill.fillAmount = this.weight / (float)this.character.stats.CarryingWeight();
Links.x.inventory.bagWeightFill.color = Color.Lerp(Links.x.inventory.bagFillLowColor, Links.x.inventory.bagFillHighColor, Links.x.inventory.bagWeightFill.fillAmount);
if (this.weight > (float)this.character.stats.CarryingWeight() && Links.x.gaia.sceneLoaded)
{
this.weightText.color = Links.x.inventory.weightTextColor;
if (Links.x.inventory.open && this.character == Links.x.inventory.selectedPlayer && !Links.x.characterSheet.merchant && !Links.x.characterSheet.pagan && !Links.x.characterSheet.blacksmith && !Links.x.characterSheet.minstrel)
{
Links.x.characterSheet.StartQuip("I'm overburdened", FaceAnimations.AnimationNames.Frown);
Links.x.inventory.TooMuchWeight(this.character);
return;
}
}
}
else
{
this.weightText.color = Links.x.inventory.weightTextHeavyColor;
}
}
// Token: 0x06001136 RID: 4406 RVA: 0x001505B4 File Offset: 0x0014E7B4
public void UseItem(global::Item item, ItemEquipped equippedItem, int hitEquippedIndex)
{
Library.Inventory inventory;
if (item)
{
inventory = item.invRow;
}
else
{
inventory = equippedItem.invRow;
}
if (inventory._RightClickAction != "")
{
if (inventory._RightClickAction == "Consume" && (!Records.x.InCombat(false) || (Records.x.pocketPause && !Links.x.inventory.open)))
{
this.str.Clear();
this.str.Append(Links.x.gameFeed.GetPartyColorText(this.character));
this.str.Append(this.character.stats.GetName());
this.str.Append("</color>");
this.str.Append(" consumed ");
this.str.Append(inventory._DisplayName);
Links.x.gameFeed.AddFeed(this.str.ToString());
if (!Records.x.inMenus)
{
MasterAudio.PlaySoundAndForget("Amphora", 1f, new float?(1f), 0f, "", null);
}
else if (inventory._RightClickAction == "Consume")
{
if (inventory._Stackable)
{
if (!inventory._Effect.Contains("Berry"))
{
MasterAudio.PlaySoundAndForget("Inventory", 1f, new float?(1f), 0f, "Amphora", null);
}
else
{
MasterAudio.PlaySoundAndForget("Inventory", 1f, new float?(1f), 0f, "Pot", null);
}
}
else
{
MasterAudio.PlaySoundAndForget("Inventory", 1f, new float?(1f), 0f, "Pot", null);
}
}
if (equippedItem)
{
this.AddEffect(item, inventory, hitEquippedIndex);
}
else
{
int num = this.bagItems.IndexOf(item);
this.AddEffect(item, inventory, num);
}
if (equippedItem)
{
Links.x.inventory.AddCombatTime(this.character, "Short");
}
else
{
Links.x.inventory.AddCombatTime(this.character, "Medium");
}
this.character.portrait.skillBag.SetTrinketGrid(false);
return;
}
if (inventory._RightClickAction == "Spellbook")
{
Links.x.characterSheet.booksMenu.clickedOpen = Links.x.gameplay.currentEventObject;
Links.x.characterSheet.booksMenu.OpenSpells();
return;
}
if (inventory._RightClickAction == "Songbook")
{
Links.x.characterSheet.booksMenu.clickedOpen = Links.x.gameplay.currentEventObject;
Links.x.characterSheet.booksMenu.OpenSongs();
return;
}
if (inventory._Name.Contains("SpellScroll") || inventory._Name.Contains("PaganScroll"))
{
Links.x.characterSheet.StartQuip("I need to equip this to use it", FaceAnimations.AnimationNames.Frown);
return;
}
if (inventory._Tag == "Revive")
{
Links.x.characterSheet.StartQuip("I need to equip this to use it", FaceAnimations.AnimationNames.Frown);
}
}
}
// Token: 0x06001137 RID: 4407 RVA: 0x0015093C File Offset: 0x0014EB3C
public void UseBeltItem(int beltIndex)
{
if (Records.x.removeControls)
{
return;
}
if (!Links.x.gaia.sceneLoaded)
{
return;
}
if (!this.character.IsSentient())
{
return;
}
int invNum = this.character.GetInvNum(beltIndex * 2);
Library.Inventory invRowByIndex = Links.x.library.GetInvRowByIndex(invNum);
if (invRowByIndex != null)
{
if (invRowByIndex._Name.Contains("SpellScroll") || invRowByIndex._Name.Contains("PaganScroll"))
{
if (Records.x.pocketPause || (!Records.x.pocketPause && this.character.attackTime >= 1f && !this.character.inAction && !this.character.inRecovery && !this.character.inQueuedAbility))
{
Library.Abilities abilityRow = Links.x.library.GetAbilityRow(invRowByIndex._Effect);
Library.Pagan paganRow = Links.x.library.GetPaganRow(invRowByIndex._Effect);
this.character.portrait.skillBag.RemoveSelectedButton();
if (Links.x.gameplay.spellTargetingGround || Links.x.gameplay.charming)
{
Links.x.gameplay.RemoveAbilityInfo();
}
if (!this.character.actions)
{
Links.x.combat.GivePartyActions(this.character, false);
Links.x.gameplay.combatStartedWithSkill = true;
}
Links.x.gameplay.actionCharacter = this.character;
Links.x.gameplay.currentAbility = abilityRow._Name;
this.character.actions.spellIndex = (int)invRowByIndex._Level;
this.character.actions.paganRow = paganRow;
this.character.portrait.skillBag.selectedSkillButton = null;
Links.x.gameplay.spellcasting = true;
Links.x.gameplay.spellPaganRow = paganRow;
if (abilityRow._RadiusCenter == "Mouse")
{
Links.x.gameplay.RemoveSpellTargets();
Links.x.gameplay.spellTargetingGround = true;
int num = 1;
Vector4 spellScrollData = Records.x.GetSpellScrollData((int)invRowByIndex._Level);
if (paganRow._Slider1 == "Radius")
{
num = (int)spellScrollData.x;
}
else if (paganRow._Slider2 == "Radius")
{
num = (int)spellScrollData.y;
}
else if (paganRow._Slider3 == "Radius")
{
num = (int)spellScrollData.z;
}
Links.x.gameplay.tileEffectRadius = num;
if (Links.x.joy)
{
Links.x.gameplay.StartControllerTargeting();
}
Links.x.gameplay.SetPartyColliders(false);
}
else if (abilityRow._RadiusCenter.Contains("TargetParty"))
{
Links.x.gameplay.RemoveSpellTargets();
if (Links.x.joy)
{
Links.x.gameplay.EndControllerTargeting();
}
Links.x.gameplay.spellTargetingParty = true;
Shader.SetGlobalFloat("_TargetingParty", 1f);
Links.x.gameplay.SetPartyColliders(true);
}
else if (abilityRow._RadiusCenter.Contains("TargetEnemy"))
{
Links.x.gameplay.RemoveSpellTargets();
if (Links.x.joy)
{
Links.x.gameplay.EndControllerTargeting();
}
Links.x.gameplay.spellTargetingEnemy = true;
Links.x.gameplay.SetPartyColliders(false);
}
else
{
Links.x.gameplay.spellTargetingGround = false;
if (Links.x.joy)
{
Links.x.gameplay.EndControllerTargeting();
}
}
if (invRowByIndex._Name.Contains("SpellScroll") || invRowByIndex._Name.Contains("PaganScroll"))
{
this.character.actions.spellScroll = invRowByIndex;
this.character.actions.spellScrollID = beltIndex;
}
if (!Records.x.pocketPause)
{
Links.x.gameplay.PocketPause(true);
}
this.character.actions.Ability(invRowByIndex._Effect, invRowByIndex._Effect, false, false);
Links.x.combat.RemoveFromNeedsTurn(this.character);
Links.x.gameplay.SetDomeSize();
return;
}
Links.x.gameFeed.ShowNotice("Not ready");
return;
}
else if (invRowByIndex._Tag == "Revive")
{
if (Records.x.pocketPause || (!Records.x.pocketPause && this.character.attackTime >= 1f && !this.character.inAction && !this.character.inRecovery && !this.character.inQueuedAbility))
{
Library.Abilities abilityRow2 = Links.x.library.GetAbilityRow("Revive");
Library.Pagan paganRow2 = Links.x.library.GetPaganRow("Revive");
this.character.portrait.skillBag.RemoveSelectedButton();
if (Links.x.gameplay.spellTargetingGround || Links.x.gameplay.charming)
{
Links.x.gameplay.RemoveAbilityInfo();
}
if (!this.character.actions)
{
Links.x.combat.GivePartyActions(this.character, false);
Links.x.gameplay.combatStartedWithSkill = true;
}
Links.x.gameplay.actionCharacter = this.character;
Links.x.gameplay.currentAbility = abilityRow2._Name;
this.character.actions.spellIndex = (int)invRowByIndex._Level;
this.character.actions.paganRow = paganRow2;
this.character.portrait.skillBag.selectedSkillButton = null;
Links.x.gameplay.spellcasting = true;
Links.x.gameplay.RemoveSpellTargets();
if (Links.x.joy)
{
Links.x.gameplay.EndControllerTargeting();
}
Links.x.gameplay.spellPaganRow = paganRow2;
Links.x.gameplay.spellTargetingParty = true;
Shader.SetGlobalFloat("_TargetingParty", 1f);
Links.x.gameplay.SetPartyColliders(true);
this.character.actions.spellScroll = invRowByIndex;
this.character.actions.spellScrollID = beltIndex;
if (!Records.x.pocketPause)
{
Links.x.gameplay.PocketPause(true);
}
this.character.actions.Ability(invRowByIndex._Effect, invRowByIndex._Effect, false, false);
Links.x.combat.RemoveFromNeedsTurn(this.character);
Links.x.gameplay.SetDomeSize();
return;
}
Links.x.gameFeed.ShowNotice("Cannot use right now");
return;
}
else if (!Records.x.InCombat(false) || (Records.x.InCombat(false) && !Links.x.inventory.open))
{
bool flag = false;
if (this.character.hasActions)
{
flag = this.character.actions.cannotInterrupt;
}
this.str.Clear();
this.str.Append(Links.x.gameFeed.GetPartyColorText(this.character));
this.str.Append(this.character.stats.GetName());
this.str.Append("</color>");
this.str.Append(" consumed ");
this.str.Append(invRowByIndex._DisplayName);
Links.x.gameFeed.AddFeed(this.str.ToString());
if (!Records.x.inMenus)
{
MasterAudio.PlaySoundAndForget("Amphora", 1f, new float?(1f), 0f, "", null);
}
else if (invRowByIndex._RightClickAction == "Consume" || invRowByIndex._RightClickAction == "Revive")
{
if (invRowByIndex._Stackable)
{
MasterAudio.PlaySoundAndForget("Inventory", 1f, new float?(1f), 0f, "Amphora", null);
}
else
{
MasterAudio.PlaySoundAndForget("Inventory", 1f, new float?(1f), 0f, "Pot", null);
}
}
if (invRowByIndex._Effect != "")
{
this.AddEffect(null, invRowByIndex, beltIndex);
}
else
{
this.RemoveBeltItem(beltIndex);
}
if (Links.x.inventory.open)
{
Links.x.inventory.AddCombatTime(this.character, "Short");
}
if (!this.character.hasActions || flag)
{
this.character.portrait.QueueIcon(false);
}
}
}
}
// Token: 0x06001138 RID: 4408 RVA: 0x001512B4 File Offset: 0x0014F4B4
public void RemoveBeltItem(int beltIndex)
{
if (this.bagAmount[beltIndex] > 1)
{
int num = this.bagAmount[beltIndex];
this.bagAmount[beltIndex] = num - 1;
this.character.UpdateListsFromInv(true);
if (Links.x.inventory.open)
{
Links.x.inventory.SetupEquippedItems(Links.x.characterSheet.body, false, beltIndex, false);
}
if (beltIndex < 18)
{
ItemEquipped itemEquippedFromIndex = Links.x.inventory.GetItemEquippedFromIndex(beltIndex);
if (itemEquippedFromIndex)
{
itemEquippedFromIndex.stackSize = num - 1;
itemEquippedFromIndex.UpdateStackSize();
}
}
}
else
{
this.bagItems[beltIndex] = null;
this.bagID[beltIndex] = 0;
this.bagAmount[beltIndex] = 0;
this.socketA[beltIndex] = Vector3.zero;
this.socketB[beltIndex] = Vector3.zero;
this.bagPos[beltIndex] = -1;
this.durability[beltIndex] = new Vector4(0f, 0f, 0f, 0f);
this.character.UpdateListsFromInv(true);
if (Links.x.inventory.open)
{
Links.x.inventory.SetupEquippedItems(Links.x.characterSheet.body, false, beltIndex, false);
}
this.character.CreateEquippedItems(this.bagID[beltIndex], this.bagAmount[beltIndex], this.socketA[beltIndex], this.socketB[beltIndex], beltIndex * 2, true);
}
if (this.character.portrait)
{
this.character.portrait.skillBag.UpdateWindowStates();
}
}
// Token: 0x06001139 RID: 4409 RVA: 0x00151484 File Offset: 0x0014F684
public void AddEffect(global::Item item, Library.Inventory equippedItemRow, int equipIndex)
{
Library.Inventory inventory = null;
if (item)
{
inventory = item.invRow;
}
else if (equippedItemRow != null)
{
inventory = equippedItemRow;
}
if (inventory._Effect != "")
{
this.AddEffect(inventory._Effect, (float)((int)inventory._Level));
}
if (item)
{
int num = this.bagAmount[equipIndex];
if (num > 1)
{
this.bagAmount[equipIndex] = num - 1;
item.stackSize = num - 1;
this.bagItems[equipIndex].CheckStackSize();
}
else
{
Links.x.inventory.DestroyedItem(item, this.character);
}
this.character.UpdateListsFromInv(true);
}
else
{
int num2 = this.bagAmount[equipIndex];
if (num2 > 1)
{
this.bagAmount[equipIndex] = num2 - 1;
ItemEquipped itemEquippedFromIndex = Links.x.inventory.GetItemEquippedFromIndex(equipIndex);
if (itemEquippedFromIndex)
{
itemEquippedFromIndex.stackSize = num2 - 1;
itemEquippedFromIndex.UpdateStackSize();
}
this.character.UpdateListsFromInv(true);
}
else
{
this.bagItems[equipIndex] = null;
this.bagID[equipIndex] = 0;
this.bagAmount[equipIndex] = 0;
this.socketA[equipIndex] = Vector3.zero;
this.socketB[equipIndex] = Vector3.zero;
this.bagPos[equipIndex] = -1;
this.durability[equipIndex] = new Vector4(0f, 0f, 0f, 0f);
this.character.UpdateListsFromInv(true);
if (Links.x.inventory.open)
{
Links.x.inventory.SetupEquippedItems(this.character.body, false, equipIndex, false);
}
this.character.CreateEquippedItems(this.bagID[equipIndex], this.bagAmount[equipIndex], this.socketA[equipIndex], this.socketB[equipIndex], equipIndex * 2, true);
if (Links.x.joy)
{
EventSystem.current.SetSelectedGameObject(Links.x.characterSheet.attackSpeedText.gameObject.transform.parent.gameObject);
}
}
}
this.character.portrait.skillBag.UpdateWindowStates();
if (Links.x.inventory.open)
{
Links.x.characterSheet.GetStats();
}
this.character.PlayAnimation("Use", 0f);
}
// Token: 0x0600113A RID: 4410 RVA: 0x0015170C File Offset: 0x0014F90C
public void AddEffect(string abilityName, float lvl)
{
Effects effects = this.character.gameObject.AddComponent<Effects>();
Links.x.cellar.AddEffects(effects);
effects.gameObject.SetActive(true);
effects.source = null;
effects.target = this.character;
effects.fromLoad = false;
effects.effectName = abilityName;
effects.removeAtSceneSwitch = false;
effects.tileEffect = null;
effects.sourceLevel = lvl;
effects.Inflicted(false);
}
// Token: 0x0600113B RID: 4411 RVA: 0x00151784 File Offset: 0x0014F984
public void OnPointerEnter(PointerEventData eventData)
{
this.inv = Links.x.inventory;
if (this.ground)
{
if (this.inv.hitGroundItem != null)
{
return;
}
if (Links.x.joy)
{
if (this.inv.dragging)
{
Links.x.inventory.SetDragMessageText("GroundDragging", null);
}
else
{
Links.x.inventory.SetDragMessageText("", null);
}
}
}
if (this.equip && !Links.x.characterSheet.pagan && !Links.x.characterSheet.minstrel)
{
if (!this.inv.dragging)
{
if (Links.x.joy)
{
Links.x.inventory.SetDragMessageText("Equip", null);
}
}
else if (Links.x.joy)
{
Links.x.inventory.SetDragMessageText("EquipDragging", null);
}
}
if (this.inv && Links.x.mk && (!this.equip || (this.equip && !Links.x.characterSheet.pagan && !Links.x.characterSheet.minstrel && !Links.x.characterSheet.merchant)))
{
this.inv.dropObject = base.gameObject;
this.inv.dropPosition = eventData.position;
this.inv.dropScript = this;
}
}
// Token: 0x0600113C RID: 4412 RVA: 0x00151910 File Offset: 0x0014FB10
public void OnPointerExit(PointerEventData eventData)
{
this.inv = Links.x.inventory;
if (this.equip && !Links.x.characterSheet.pagan && !Links.x.characterSheet.minstrel && Links.x.joy)
{
if (this.inv.dragging)
{
Links.x.inventory.SetDragMessageText("Dragging", null);
}
else
{
Links.x.inventory.SetDragMessageText("", null);
}
}
if (this.ground && Links.x.joy)
{
if (this.inv.dragging)
{
Links.x.inventory.SetDragMessageText("Dragging", null);
}
else
{
Links.x.inventory.SetDragMessageText("", null);
}
}
if (this.inv && Links.x.mk)
{
this.inv.dropObject = null;
this.inv.dropScript = null;
}
}
// Token: 0x0600113D RID: 4413 RVA: 0x00151A1C File Offset: 0x0014FC1C
public void OnPointerDown(PointerEventData eventData)
{
this.inv = Links.x.inventory;
if (!Links.x.inventory.dragging && (!this.equip || (this.equip && !Links.x.characterSheet.pagan && !Links.x.characterSheet.minstrel && !Links.x.characterSheet.merchant)))
{
if (Links.x.mk)
{
this.inv.prevPosition = eventData.position;
}
else if (this.draggingButton)
{
this.inv.prevPosition = this.draggingButton.transform.position;
}
this.inv.startDragObject = base.gameObject;
this.inv.startDragObjectScript = this;
}
if (this.equip && !Links.x.inventory.hitEquipped)
{
Links.x.inventory.spinning = true;
Links.x.inventory.mouseStart = Input.mousePosition;
}
}
// Token: 0x0600113E RID: 4414 RVA: 0x00151B41 File Offset: 0x0014FD41
public void OnPointerUp(PointerEventData eventData)
{
this.inv = Links.x.inventory;
if (this.equip)
{
Links.x.inventory.spinning = false;
}
}
// Token: 0x04001C76 RID: 7286
private Inventory inv;
// Token: 0x04001C77 RID: 7287
public Character character;
// Token: 0x04001C78 RID: 7288
public bool bag;
// Token: 0x04001C79 RID: 7289
public bool merchantTake;
// Token: 0x04001C7A RID: 7290
public bool merchantGive;
// Token: 0x04001C7B RID: 7291
public bool ground;
// Token: 0x04001C7C RID: 7292
public bool portrait;
// Token: 0x04001C7D RID: 7293
public bool equip;
// Token: 0x04001C7E RID: 7294
public InventoryContainer linkedBag;
// Token: 0x04001C7F RID: 7295
public bool active;
// Token: 0x04001C80 RID: 7296
public int bagNum;
// Token: 0x04001C81 RID: 7297
private Transform tr;
// Token: 0x04001C82 RID: 7298
public float weight;
// Token: 0x04001C83 RID: 7299
public GameObject weightTextGo;
// Token: 0x04001C84 RID: 7300
public TextMeshProUGUI weightText;
// Token: 0x04001C85 RID: 7301
public Image img;
// Token: 0x04001C86 RID: 7302
public Button btn;
// Token: 0x04001C87 RID: 7303
public GameObject label;
// Token: 0x04001C88 RID: 7304
public GameObject ammo1;
// Token: 0x04001C89 RID: 7305
public GameObject ammo2;
// Token: 0x04001C8A RID: 7306
public GameObject ammo3;
// Token: 0x04001C8B RID: 7307
public GameObject hand2;
// Token: 0x04001C8C RID: 7308
public GameObject hand3;
// Token: 0x04001C8D RID: 7309
public GameObject hand4;
// Token: 0x04001C8E RID: 7310
public List<GameObject> slots = new List<GameObject>();
// Token: 0x04001C8F RID: 7311
public List<Image> imgs = new List<Image>();
// Token: 0x04001C90 RID: 7312
public List<UITriggerButton> btns = new List<UITriggerButton>();
// Token: 0x04001C91 RID: 7313
public Button draggingButton;
// Token: 0x04001C92 RID: 7314
public List<global::Item> bagItems = new List<global::Item>();
// Token: 0x04001C93 RID: 7315
public List<int> bagID = new List<int>();
// Token: 0x04001C94 RID: 7316
public List<int> bagAmount = new List<int>();
// Token: 0x04001C95 RID: 7317
public List<Vector3> socketA = new List<Vector3>();
// Token: 0x04001C96 RID: 7318
public List<Vector3> socketB = new List<Vector3>();
// Token: 0x04001C97 RID: 7319
public List<int> bagPos = new List<int>();
// Token: 0x04001C98 RID: 7320
public List<Vector4> durability = new List<Vector4>();
// Token: 0x04001C99 RID: 7321
public bool lastInteractableState;
// Token: 0x04001C9A RID: 7322
private StringFast str = new StringFast(64);
}