Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
LayerInteraction.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4
5public class LayerInteraction : ELayer
6{
7 public enum Mode
8 {
9 Map,
11 EloMap,
12 Area,
13 Custom
14 }
15
16 public class Page
17 {
19
20 public Area area;
21
22 public List<Item> items = new List<Item>();
23
24 public Item Add(object target, string text, string idSprite, Action action, int priority = 0, bool auto = false)
25 {
26 Item item = new Item
27 {
28 target = target,
29 text = text,
30 idSprite = idSprite,
31 action = action,
32 priority = priority,
33 auto = auto
34 };
35 items.Add(item);
36 return item;
37 }
38
39 public Item Add(object target, string text, Func<bool> valueFunc, Action<bool> action)
40 {
41 Action action2 = delegate
42 {
43 SE.Click();
44 action(!valueFunc());
45 };
46 Item item = new Item
47 {
48 target = target,
49 textFunc = () => text.lang() + " (" + (valueFunc() ? "on" : "off") + ")",
50 action = action2,
51 reload = true
52 };
53 items.Add(item);
54 return item;
55 }
56 }
57
58 public class Item
59 {
60 public object target;
61
62 public string text;
63
64 public string idSprite;
65
66 public Action action;
67
68 public int priority;
69
70 public bool auto;
71
72 public bool reload;
73
74 public Func<string> textFunc;
75
76 public bool IsArea => target is Area;
77 }
78
80
81 public static IInspect Target;
82
83 public Mode mode;
84
85 public Point point;
86
87 public List<Page> pages = new List<Page>();
88
89 private bool first = true;
90
92
94
95 public override void OnInit()
96 {
97 Instance = this;
98 first = true;
99 }
100
101 public override void OnKill()
102 {
103 Target = null;
104 }
105
106 private void Update()
107 {
108 if (mode == Mode.Map)
109 {
111 MeshPass obj = ((point.HasBlock || point.cell.liquidLv > 0) ? ELayer.screen.guide.passGuideBlock : ELayer.screen.guide.passGuideFloor);
112 int num = 0;
113 Vector3 vector = point.Position();
114 obj.Add(vector.x, vector.y, vector.z, num, 0.3f);
115 }
116 }
117
118 public override void OnUpdateInput()
119 {
120 }
121
122 public static void Show(IInspect newTarget)
123 {
124 if (Target != newTarget)
125 {
126 Target = newTarget;
127 Page page = GetPage(Target);
128 ((Instance != null) ? Instance : ELayer.ui.AddLayer<LayerInteraction>()).ShowPage(page);
129 }
130 }
131
132 public static bool TryShow(bool quick)
133 {
135 {
136 return false;
137 }
139 return true;
140 }
141
142 public static Page GetPage(IInspect o)
143 {
144 Page page = new Page();
145 _ = page.items;
146 if (o is Area)
147 {
148 Area area = o as Area;
149 page.area = area;
150 }
151 else if (o is Chara)
152 {
153 Chara t2 = o as Chara;
154 string text = "charaInfo".lang();
155 if (!t2.IsHomeMember())
156 {
157 text = text + "(" + "unidentified".lang() + ")";
158 }
159 if (t2.IsHomeMember())
160 {
161 page.Add(t2, "tTalk".lang(), "", delegate
162 {
163 t2.ShowDialog();
164 });
165 }
166 else
167 {
168 page.Add(t2, text, "", delegate
169 {
170 if (!t2.IsHomeMember())
171 {
172 SE.Beep();
173 }
174 });
175 }
176 }
177 else if (o is Thing)
178 {
179 Thing t = o as Thing;
180 page.Add(t, "objInfo", "", delegate
181 {
182 ELayer.ui.AddLayer<LayerInfo>().Set(t);
183 });
184 if (t.trait is TraitQuestBoard)
185 {
186 page.Add(t, "quest", "", delegate
187 {
188 ELayer.ui.AddLayer<LayerQuestBoard>();
189 }, 20, auto: true);
190 page.Add(t, "hire", "", delegate
191 {
192 ELayer.ui.AddLayer<LayerHire>();
193 }, 20, auto: true);
194 }
195 if (t.trait is TraitGacha)
196 {
197 page.Add(t, "gacha", "", delegate
198 {
199 ELayer.ui.AddLayer<LayerGacha>();
200 }, 10, auto: true);
201 }
202 if (t.trait.IsFactory)
203 {
204 page.Add(t, "craft", "icon_Inspect", delegate
205 {
206 ELayer.ui.AddLayer<LayerCraft>().SetFactory(t);
207 }, 100, auto: true);
208 }
209 if (t.IsInstalled)
210 {
211 page.Add(t, "move", "", delegate
212 {
214 });
215 }
216 }
217 return page;
218 }
219
220 public void Show(List<Page> _pages, Mode _mode)
221 {
222 pages = _pages;
223 mode = _mode;
224 switch (mode)
225 {
226 case Mode.Map:
228 break;
229 case Mode.EloMap:
230 {
231 Page page = new Page();
232 pages = new List<Page>();
233 pages.Add(page);
234 page.Add(null, "test1", "", delegate
235 {
236 });
237 page.Add(null, "test2", "", delegate
238 {
239 });
240 break;
241 }
242 }
243 foreach (Page page2 in pages)
244 {
245 ButtonGrid buttonGrid = (ButtonGrid)(page2.button = menu.Add() as ButtonGrid);
246 buttonGrid.SetObject(page2.items[0].target);
247 Page _page = page2;
248 buttonGrid.onClick.AddListener(delegate
249 {
250 ShowPage(_page);
251 SE.Click();
252 });
253 buttonGrid.RebuildLayout(recursive: true);
254 }
255 menu.Show();
256 ShowPage(0);
257 }
258
259 public void ShowPage(int index)
260 {
261 ShowPage(pages[index]);
262 }
263
264 public void ShowPage(Page page)
265 {
266 menu.Clear();
267 foreach (Item item in page.items)
268 {
269 UIButton uIButton = menu.Add();
270 uIButton.icon.sprite = SpriteSheet.Get(item.idSprite.IsEmpty("icon_" + item.text)) ?? uIButton.icon.sprite;
271 uIButton.mainText.SetText((item.textFunc != null) ? item.textFunc() : item.text.lang());
272 uIButton.onClick.AddListener(delegate
273 {
274 item.action();
275 if (item.reload)
276 {
277 Reload();
278 ShowPage(page);
279 }
280 });
281 uIButton.RebuildLayout(recursive: true);
282 }
283 Chara chara = Target as Chara;
284 bool flag = chara?.IsHomeMember() ?? false;
285 windowChara.SetActive(flag);
286 if (flag)
287 {
288 windowChara.SetChara(chara);
289 }
290 menu.Show();
291 }
292
293 public void Reload()
294 {
295 }
296}
void Activate(Thing t)
static AM_Inspect Inspect
Definition: ActionMode.cs:23
Definition: Area.cs:4
ScreenGuide guide
BaseTileSelector tileSelector
void SetObject(object o)
Definition: ButtonGrid.cs:405
Trait trait
Definition: Card.cs:49
bool IsInstalled
Definition: Card.cs:2241
Definition: Chara.cs:10
void ShowDialog()
Definition: Chara.cs:6368
bool IsHomeMember()
Definition: Chara.cs:5942
Definition: ELayer.cs:4
static Scene scene
Definition: ELayer.cs:27
static UI ui
Definition: ELayer.cs:21
static BaseGameScreen screen
Definition: ELayer.cs:29
Func< string > textFunc
Item Add(object target, string text, Func< bool > valueFunc, Action< bool > action)
Item Add(object target, string text, string idSprite, Action action, int priority=0, bool auto=false)
override void OnInit()
static LayerInteraction Instance
static void Show(IInspect newTarget)
static bool TryShow(bool quick)
void ShowPage(int index)
static Page GetPage(IInspect o)
InteractionMenu menu
WindowChara windowChara
List< Page > pages
void Show(List< Page > _pages, Mode _mode)
override void OnUpdateInput()
static IInspect Target
override void OnKill()
void ShowPage(Page page)
void Add(Point point, float tile=0f, float color=0f)
Definition: MeshPass.cs:122
Definition: Point.cs:9
ref Vector3 Position(int height)
Definition: Point.cs:524
Point Set(int _x, int _z)
Definition: Point.cs:479
List< IInspect > ListInspectorTargets()
Definition: Point.cs:1316
bool IsValid
Definition: Point.cs:88
Definition: Scene.cs:8
static Point HitPoint
Definition: Scene.cs:21
PointTarget mouseTarget
Definition: Scene.cs:129
MeshPass passGuideBlock
Definition: ScreenGuide.cs:5
MeshPass passGuideFloor
Definition: ScreenGuide.cs:7
static Sprite Get(string id)
Definition: SpriteSheet.cs:28
Definition: Thing.cs:8
virtual bool IsFactory
Definition: Trait.cs:135
Image icon
Definition: UIButton.cs:110
UIText mainText
Definition: UIButton.cs:102
void SetText(string s)
Definition: UIText.cs:159
void SetChara(Chara c)
Definition: WindowChara.cs:163