Elin Modding Docs Doc
Loading...
Searching...
No Matches
WidgetSearch.cs
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4
5// Token: 0x02000634 RID: 1588
7{
8 // Token: 0x17000CAA RID: 3242
9 // (get) Token: 0x06002C8E RID: 11406 RVA: 0x000F9C79 File Offset: 0x000F7E79
10 public override WidgetCodex.SearchType type
11 {
12 get
13 {
14 return WidgetCodex.SearchType.Search;
15 }
16 }
17
18 // Token: 0x06002C8F RID: 11407 RVA: 0x000F9C7C File Offset: 0x000F7E7C
19 public override void OnActivate()
20 {
21 base.OnActivate();
22 WidgetSearch.Instance = this;
23 WidgetSearch.selected = null;
24 this.RefreshList();
25 }
26
27 // Token: 0x06002C90 RID: 11408 RVA: 0x000F9C96 File Offset: 0x000F7E96
28 public override bool CheckClose()
29 {
30 return Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.F);
31 }
32
33 // Token: 0x06002C91 RID: 11409 RVA: 0x000F9CB0 File Offset: 0x000F7EB0
34 public override void Search(string s)
35 {
36 s = s.ToLower();
37 this.buttonClear.SetActive(this.field.text != "");
38 if (s == this.lastSearch)
39 {
40 return;
41 }
42 HashSet<Card> newCards = new HashSet<Card>();
43 if (!s.IsEmpty())
44 {
45 if (EMono._zone.IsTown || EMono._zone.IsPCFaction)
46 {
47 foreach (Chara chara in EMono._map.charas)
48 {
49 if (chara.IsNeutralOrAbove() && (chara.Name.Contains(s) || chara.sourceCard.GetSearchName(false).Contains(s)))
50 {
51 newCards.Add(chara);
52 }
53 }
54 }
55 if (EMono._zone.IsPCFaction)
56 {
57 foreach (Thing thing in EMono._map.things)
58 {
59 if (thing.Name.Contains(s) || thing.sourceCard.GetSearchName(false).Contains(s))
60 {
61 newCards.Add(thing);
62 }
63 }
64 foreach (Card card in EMono._map.props.stocked.all.Values)
65 {
66 if (card.parent is Thing && (card.parent as Thing).c_lockLv <= 0 && (card.Name.Contains(s) || card.sourceCard.GetSearchName(false).Contains(s)))
67 {
68 newCards.Add(card);
69 }
70 }
71 }
72 Action<Thing> <>9__0;
73 for (int i = 0; i < 2; i++)
74 {
75 foreach (Chara chara2 in EMono._map.charas)
76 {
77 if ((i != 0 || chara2 != EMono.pc) && (i != 1 || chara2 == EMono.pc) && chara2.IsPCFactionOrMinion)
78 {
79 ThingContainer things = chara2.things;
80 Action<Thing> action;
81 if ((action = <>9__0) == null)
82 {
83 action = (<>9__0 = delegate(Thing t)
84 {
85 Card card2 = t.parent as Card;
86 if (((card2 != null) ? card2.trait : null) is TraitChestMerchant)
87 {
88 return;
89 }
90 if (t.Name.Contains(s) || t.source.GetSearchName(false).Contains(s))
91 {
92 newCards.Add(t);
93 }
94 });
95 }
96 things.Foreach(action, true);
97 }
98 }
99 }
100 }
101 if (!newCards.SetEquals(this.cards))
102 {
103 this.cards = newCards;
104 this.RefreshList();
105 }
106 this.cgResult.alpha = ((this.list.ItemCount > 0) ? 1f : 0f);
107 this.lastSearch = s;
108 }
109
110 // Token: 0x06002C92 RID: 11410 RVA: 0x000FA000 File Offset: 0x000F8200
111 public override void RefreshList()
112 {
113 LayerInventory.SetDirtyAll(false);
114 WidgetSearch.selected = null;
115 BaseList list = this.list;
116 UIList.Callback<Card, ButtonGrid> callback = new UIList.Callback<Card, ButtonGrid>();
117 callback.onClick = delegate(Card a, ButtonGrid b)
118 {
119 Card rootCard = a.GetRootCard();
120 if (rootCard == EMono.pc)
121 {
122 LayerInventory.SetDirtyAll(false);
123 WidgetSearch.selected = a;
124 SE.Click();
125 return;
126 }
127 if (!EMono.pc.ai.IsNoGoal)
128 {
129 SE.Beep();
130 return;
131 }
132 if (a.isDestroyed || !rootCard.pos.IsValid)
133 {
134 SE.Beep();
135 this.Search(this.field.text);
136 return;
137 }
138 SE.Click();
139 WidgetSearch.selected = null;
140 EMono.pc.SetAIImmediate(new AI_Goto(rootCard.pos.Copy(), 0, false, false));
141 ActionMode.Adv.SetTurbo(3);
142 base.Close();
143 };
144 callback.onRedraw = delegate(Card a, ButtonGrid b, int i)
145 {
146 b.SetCard(a, ButtonGrid.Mode.Search, null);
147 };
148 callback.onList = delegate(UIList.SortMode m)
149 {
150 foreach (Card o in this.cards)
151 {
152 this.list.Add(o);
153 }
154 };
155 list.callbacks = callback;
156 this.list.List();
157 this.list.dsv.OnResize();
158 }
159
160 // Token: 0x06002C93 RID: 11411 RVA: 0x000FA08D File Offset: 0x000F828D
161 public override void OnDeactivate()
162 {
163 base.OnDeactivate();
164 LayerInventory.SetDirtyAll(false);
165 }
166
167 // Token: 0x040018FB RID: 6395
168 public static WidgetSearch Instance;
169
170 // Token: 0x040018FC RID: 6396
171 public HashSet<Card> cards = new HashSet<Card>();
172
173 // Token: 0x040018FD RID: 6397
174 public static Card selected;
175
176 // Token: 0x040018FE RID: 6398
177 public CanvasGroup cgResult;
178}
Definition Card.cs:13
Definition Chara.cs:12
Definition EMono.cs:6
Definition Thing.cs:10