Elin Modding Docs Doc
All Classes Namespaces
LayerCollectible.cs
1using System;
2using UnityEngine;
3using UnityEngine.UI;
4
5// Token: 0x02000526 RID: 1318
6public class LayerCollectible : ELayer
7{
8 // Token: 0x17000B16 RID: 2838
9 // (get) Token: 0x0600235A RID: 9050 RVA: 0x000C6E6F File Offset: 0x000C506F
10 public Hoard hoard
11 {
12 get
13 {
14 return ELayer.player.hoard;
15 }
16 }
17
18 // Token: 0x0600235B RID: 9051 RVA: 0x000C6E7B File Offset: 0x000C507B
19 public override void OnAfterInit()
20 {
21 if (this.hoard.items.Count == 0)
22 {
23 this.hoard.Add("gold", 1, false);
24 }
25 this.Refresh();
26 }
27
28 // Token: 0x0600235C RID: 9052 RVA: 0x000C6EA8 File Offset: 0x000C50A8
29 public void Refresh()
30 {
31 ELayer.ui.GetLayer<LayerHoard>(false);
32 this.list.callbacks = new UIList.Callback<Hoard.Item, UIButton>
33 {
34 onClick = delegate(Hoard.Item a, UIButton b)
35 {
36 this.selected = b;
37 if (this.onClick != null)
38 {
39 if (this.onClick(a))
40 {
41 this.Close();
42 }
43 return;
44 }
45 UIContextMenu uicontextMenu = ELayer.ui.contextMenu.Create("ContextHoard", true);
46 int max = a.num;
47 if (max > 1 && a.IsUnique)
48 {
49 max = 1;
50 }
51 uicontextMenu.AddSlider("display", (float n) => n.ToString() + " / " + max.ToString(), (float)a.show, delegate(float v)
52 {
53 a.show = (int)v;
54 this.SetButton(a, b);
55 this.RefreshInfo(b, true);
56 }, 0f, (float)max, true, false, false);
57 uicontextMenu.AddToggle("displayRandom", a.random, delegate(bool on)
58 {
59 a.random = on;
60 });
61 uicontextMenu.Show(EInput.uiMousePosition + this.contextFix);
62 },
63 onInstantiate = delegate(Hoard.Item a, UIButton b)
64 {
65 this.SetButton(a, b);
66 }
67 };
68 foreach (SourceCollectible.Row row in ELayer.sources.collectibles.rows)
69 {
70 if (this.hoard.items.ContainsKey(row.id))
71 {
72 this.list.Add(this.hoard.items[row.id]);
73 }
74 }
75 this.list.Refresh(false);
76 this.selected = (this.list.buttons[0].component as UIButton);
77 this.RefreshInfo(this.selected, false);
78 }
79
80 // Token: 0x0600235D RID: 9053 RVA: 0x000C6FB0 File Offset: 0x000C51B0
81 private void Update()
82 {
83 UIButton componentOf = InputModuleEX.GetComponentOf<UIButton>();
84 if (componentOf && componentOf.refObj is Hoard.Item)
85 {
86 this.RefreshInfo(componentOf, false);
87 return;
88 }
89 this.RefreshInfo(this.selected, false);
90 }
91
92 // Token: 0x0600235E RID: 9054 RVA: 0x000C6FF0 File Offset: 0x000C51F0
93 public void SetButton(Hoard.Item a, UIButton b)
94 {
95 string text = a.num.ToString() ?? "";
96 if (a.num != a.show)
97 {
98 text = text + " (" + a.show.ToString() + ")";
99 }
100 b.mainText.text = text;
101 b.icon.sprite = this.hoard.GetSprite(a.id);
102 b.icon.SetNativeSize();
103 b.refObj = a;
104 }
105
106 // Token: 0x0600235F RID: 9055 RVA: 0x000C707C File Offset: 0x000C527C
107 public void RefreshInfo(UIButton button, bool force = false)
108 {
109 if (!force && (this.lastShown == button || !button))
110 {
111 return;
112 }
113 Hoard.Item item = button.refObj as Hoard.Item;
114 string text = "collectibleTitle".lang(item.Source.GetName(), item.num.ToString() ?? "", item.show.ToString() ?? "", null, null);
115 if (item.IsUnique)
116 {
117 text += " UNIQUE";
118 }
119 this.textName.text = text;
120 this.textDetail.text = item.Source.GetText("detail", true).IsEmpty("none".lang());
121 this.imageItem.sprite = this.hoard.GetSprite(item.id);
122 this.imageItem.SetNativeSize();
123 this.lastShown = button;
124 }
125
126 // Token: 0x040012CC RID: 4812
127 public UIList list;
128
129 // Token: 0x040012CD RID: 4813
130 public UIText textName;
131
132 // Token: 0x040012CE RID: 4814
133 public UIText textDetail;
134
135 // Token: 0x040012CF RID: 4815
136 public UIButton selected;
137
138 // Token: 0x040012D0 RID: 4816
139 public UIButton lastShown;
140
141 // Token: 0x040012D1 RID: 4817
142 public Image imageItem;
143
144 // Token: 0x040012D2 RID: 4818
145 public Vector3 contextFix;
146
147 // Token: 0x040012D3 RID: 4819
148 public Func<Hoard.Item, bool> onClick;
149}
Definition Hoard.cs:10