Elin Modding Docs Doc
Loading...
Searching...
No Matches
ButtonAbility.cs
1using System;
2using UnityEngine;
3using UnityEngine.EventSystems;
4using UnityEngine.UI;
5
6// Token: 0x02000520 RID: 1312
7public class ButtonAbility : UIButton, IMouseHint
8{
9 // Token: 0x06002326 RID: 8998 RVA: 0x000C5EDC File Offset: 0x000C40DC
10 public void SetAct(Chara _chara, Element e)
11 {
12 this.source = e.source;
13 this.chara = _chara;
14 this.act = ACT.Create(this.source);
15 if (this.act == null)
16 {
17 Debug.Log(this.source.alias);
18 }
19 Sprite iconType = this.act.TargetType.IconType;
20 this.imageType.SetActive(iconType);
21 this.imageType.sprite = iconType;
22 this.act.SetImage(this.icon);
23 if (EClass.game.altAbility)
24 {
25 this.textStock.SetActive(e is Spell);
26 this.textStock.text = (e.vPotential.ToString() ?? "");
27 this.onRightClick = delegate()
28 {
29 if (EClass.ui.IsActive)
30 {
31 SE.BeepSmall();
32 return;
33 }
34 this.Use();
35 };
36 }
37 else
38 {
39 this.mainText.SetText(e.Name);
40 }
41 base.SetTooltip("note", delegate(UITooltip t)
42 {
43 e.WriteNote(t.note, this.chara.elements, delegate(UINote n)
44 {
45 e._WriteNote(t.note, this.chara, this.act);
46 });
47 }, true);
48 this.RefreshFavIcon();
49 }
50
51 // Token: 0x06002327 RID: 8999 RVA: 0x000C6010 File Offset: 0x000C4210
52 public void OnDrag(PointerEventData data)
53 {
54 if (this.dragParent == null)
55 {
56 return;
57 }
58 if (data.button != PointerEventData.InputButton.Left)
59 {
60 return;
61 }
62 if (!this.dragged)
63 {
64 this.dragged = true;
65 this.dragParent.OnStartDrag(this);
66 base.OnPointerUpOnDrag(data);
67 return;
68 }
69 this.dragParent.OnDrag(this);
70 }
71
72 // Token: 0x06002328 RID: 9000 RVA: 0x000C605E File Offset: 0x000C425E
73 public override void OnPointerUp(PointerEventData eventData)
74 {
75 if (this.dragged)
76 {
77 this.dragged = false;
78 this.dragParent.OnEndDrag(this, false);
79 return;
80 }
81 base.OnPointerUp(eventData);
82 }
83
84 // Token: 0x06002329 RID: 9001 RVA: 0x000C6084 File Offset: 0x000C4284
85 public void Use()
86 {
87 if (!EClass.pc.HasNoGoal)
88 {
89 SE.BeepSmall();
90 return;
91 }
92 if (this.CanAutoUse(this.act))
93 {
94 if (ButtonAbility.TryUse(this.act, null, null, null, true, true) && EClass.pc.ai.IsNoGoal)
95 {
96 EClass.player.EndTurn(true);
97 return;
98 }
99 }
100 else
101 {
102 this.HoldAbility();
103 }
104 }
105
106 // Token: 0x0600232A RID: 9002 RVA: 0x000C60E8 File Offset: 0x000C42E8
107 public static bool TryUse(Act act, Card tg = null, Point pos = null, Card catalyst = null, bool first = true, bool mouse = true)
108 {
109 bool flag = false;
110 if (tg == null)
111 {
112 tg = EClass.pc;
113 }
114 if (pos == null)
115 {
116 pos = EClass.pc.pos.Copy();
117 }
118 if (first && EInput.GetHotkey() != -1)
119 {
120 mouse = false;
121 ButtonAbility.hotkeyTimer = 0f;
122 Debug.Log(EInput.GetHotkey());
123 }
124 if (act.HaveLongPressAction)
125 {
126 if ((mouse && EInput.rightMouse.pressedLong) || (!mouse && ButtonAbility.hotkeyTimer >= 0.45f))
127 {
128 EInput.rightMouse.Consume();
129 flag = true;
130 ButtonAbility.hotkeyTimer = 1f;
131 }
132 if ((mouse && EInput.rightMouse.pressing) || (!mouse && EInput.GetHotkey() != -1 && ButtonAbility.hotkeyTimer < 1f))
133 {
134 ButtonAbility.hotkeyTimer += Core.delta;
135 EClass.core.actionsNextFrame.Add(delegate
136 {
137 ButtonAbility.TryUse(act, tg, pos, catalyst, false, mouse);
138 });
139 if (first)
140 {
141 EClass.core.actionsNextFrame.Add(delegate
142 {
143 EInput.rightMouse.down = false;
144 EInput.rightMouse.consumed = false;
145 EInput.rightMouse.pressing = true;
146 EInput.rightMouse.usedMouse = true;
147 });
148 }
149 return false;
150 }
151 }
152 if (flag && ButtonAbility.SpecialHoldAction(act))
153 {
154 EClass.player.EndTurn(true);
155 }
156 else if (EClass.pc.UseAbility(act.source.alias, tg, pos, flag))
157 {
158 EClass.player.EndTurn(true);
159 }
160 if (catalyst != null)
161 {
162 LayerInventory.SetDirty(catalyst.Thing);
163 }
164 return false;
165 }
166
167 // Token: 0x0600232B RID: 9003 RVA: 0x000C62C4 File Offset: 0x000C44C4
168 public static bool SpecialHoldAction(Act act)
169 {
170 Act e = EClass.pc.elements.GetElement(act.id) as Act;
171 if (e == null)
172 {
173 return false;
174 }
175 int id = e.id;
176 if (id == 8230 || id == 8232)
177 {
178 bool stop = false;
179 bool first = true;
180 int count = 0;
181 EClass.pc.things.Foreach(delegate(Thing t)
182 {
183 if (t.IsIdentified)
184 {
185 return;
186 }
187 if (EClass.pc.mana.value < e.GetCost(EClass.pc).cost && !first)
188 {
189 stop = true;
190 }
191 if (e.vPotential <= 0)
192 {
193 stop = true;
194 }
195 if (stop)
196 {
197 return;
198 }
199 if (t.rarity >= Rarity.Mythical && e.id == 8230)
200 {
201 return;
202 }
203 EClass.pc.UseAbility(act.source.alias, t, EClass.pc.pos, false);
204 Debug.Log(t.IsIdentified.ToString() + "/" + ((t != null) ? t.ToString() : null));
205 int count = count;
206 count++;
207 first = false;
208 }, true);
209 if (count == 0)
210 {
211 Msg.Say("identify_nothing");
212 }
213 return true;
214 }
215 return false;
216 }
217
218 // Token: 0x0600232C RID: 9004 RVA: 0x000C6370 File Offset: 0x000C4570
219 public void HoldAbility()
220 {
221 EClass.player.SetCurrentHotItem(new HotItemAct(this.source));
222 SE.SelectHotitem();
223 }
224
225 // Token: 0x0600232D RID: 9005 RVA: 0x000C638C File Offset: 0x000C458C
226 public bool CanAutoUse(Act _act)
227 {
228 return _act.TargetType.CanSelectSelf && (!EClass._zone.IsRegion || !_act.LocalAct);
229 }
230
231 // Token: 0x0600232E RID: 9006 RVA: 0x000C63B4 File Offset: 0x000C45B4
232 public bool ShowMouseHintLeft()
233 {
234 return false;
235 }
236
237 // Token: 0x0600232F RID: 9007 RVA: 0x000C63B7 File Offset: 0x000C45B7
238 public string GetTextMouseHintLeft()
239 {
240 return "";
241 }
242
243 // Token: 0x06002330 RID: 9008 RVA: 0x000C63BE File Offset: 0x000C45BE
244 public bool ShowMouseHintRight()
245 {
246 return this.CanAutoUse(ACT.Create(this.source));
247 }
248
249 // Token: 0x06002331 RID: 9009 RVA: 0x000C63D1 File Offset: 0x000C45D1
250 public string GetTextMouseHintRight()
251 {
252 return "actUse".lang();
253 }
254
255 // Token: 0x06002332 RID: 9010 RVA: 0x000C63DD File Offset: 0x000C45DD
256 public override bool CanMiddleClick()
257 {
258 return EClass.ui.AllowInventoryInteractions;
259 }
260
261 // Token: 0x06002333 RID: 9011 RVA: 0x000C63E9 File Offset: 0x000C45E9
262 public override void OnMiddleClick()
263 {
264 if (EInput.middleMouse.clicked)
265 {
266 this.ToggleFav();
267 }
268 EInput.middleMouse.pressedLongAction = delegate()
269 {
270 if (EClass.ui.AllowInventoryInteractions)
271 {
272 this.HoldAbility();
273 EInput.Consume(false, 1);
274 }
275 };
276 }
277
278 // Token: 0x06002334 RID: 9012 RVA: 0x000C6414 File Offset: 0x000C4614
279 public void ToggleFav()
280 {
281 if (EClass.player.favAbility.Contains(this.source.id))
282 {
283 EClass.player.favAbility.Remove(this.source.id);
284 SE.Tab();
285 }
286 else
287 {
288 EClass.player.favAbility.Add(this.source.id);
289 SE.Tab();
290 }
291 this.RefreshFavIcon();
292 LayerAbility.Instance.list.Redraw();
293 }
294
295 // Token: 0x06002335 RID: 9013 RVA: 0x000C6494 File Offset: 0x000C4694
296 public void RefreshFavIcon()
297 {
298 bool enable = EClass.player.favAbility.Contains(this.source.id);
299 this.imageFav.SetActive(enable);
300 }
301
302 // Token: 0x040012B2 RID: 4786
303 public SourceElement.Row source;
304
305 // Token: 0x040012B3 RID: 4787
306 public IDragParent dragParent;
307
308 // Token: 0x040012B4 RID: 4788
309 public UIText textStock;
310
311 // Token: 0x040012B5 RID: 4789
312 public Image imageType;
313
314 // Token: 0x040012B6 RID: 4790
315 public Image imageFav;
316
317 // Token: 0x040012B7 RID: 4791
318 public Transform attach;
319
320 // Token: 0x040012B8 RID: 4792
321 public Transform transFav;
322
323 // Token: 0x040012B9 RID: 4793
324 public Chara chara;
325
326 // Token: 0x040012BA RID: 4794
327 public Act act;
328
329 // Token: 0x040012BB RID: 4795
330 [NonSerialized]
331 public bool dragged;
332
333 // Token: 0x040012BC RID: 4796
334 public static float hotkeyTimer;
335}
Definition ACT.cs:6
Definition Act.2.cs:7
Definition Card.cs:13
Definition Chara.cs:12
Definition Msg.cs:7
Definition Point.cs:11
Definition Thing.cs:10