Elin Modding Docs Doc
All Classes Namespaces
UIRecipeInfo.cs
1using System;
2using System.Collections.Generic;
3using DG.Tweening;
4using UnityEngine;
5using UnityEngine.UI;
6
7// Token: 0x020004FC RID: 1276
8public class UIRecipeInfo : EMono
9{
10 // Token: 0x17000AF3 RID: 2803
11 // (get) Token: 0x0600220E RID: 8718 RVA: 0x000BCCA8 File Offset: 0x000BAEA8
12 public HitSummary summary
13 {
14 get
15 {
16 return EMono.screen.tileSelector.summary;
17 }
18 }
19
20 // Token: 0x0600220F RID: 8719 RVA: 0x000BCCB9 File Offset: 0x000BAEB9
21 public void Init()
22 {
23 DropdownRecipe.colorCost = this.colorCost;
24 DropdownRecipe.colorPredict = this.colorPredict;
25 this.SetRecipe(null);
26 }
27
28 // Token: 0x06002210 RID: 8720 RVA: 0x000BCCD8 File Offset: 0x000BAED8
29 public void SetArea(Area a)
30 {
31 if (a == null)
32 {
33 this.Clear();
34 return;
35 }
36 if (this.main)
37 {
38 this.goInfo.SetActive(true);
39 this.goIngredients.SetActive(false);
40 }
41 if (this.area == a)
42 {
43 return;
44 }
45 this.area = a;
46 this.recipe = null;
47 this.textName.text = a.Name;
48 this.textDetail.SetActive(true);
49 this.textDetail.SetText(a.source.GetDetail());
50 this.note.Clear();
51 this.note.Build();
52 if (!this.main)
53 {
54 this.listIngredients.SetActive(false);
55 }
56 this.RefreshList();
57 if (this.imageArea)
58 {
59 this.imageArea.SetActive(true);
60 }
61 if (this.listVariations)
62 {
63 this.listVariations.SetActive(false);
64 }
65 this.SetActive(true);
66 this.RebuildLayout(true);
67 }
68
69 // Token: 0x06002211 RID: 8721 RVA: 0x000BCDCC File Offset: 0x000BAFCC
70 public void SetRecipe(Recipe r)
71 {
72 if (this.imageArea)
73 {
74 this.imageArea.SetActive(false);
75 }
76 this.area = null;
77 if (r == null)
78 {
79 this.textDetail.SetActive(false);
80 this.Clear();
81 return;
82 }
83 if (this.main)
84 {
85 this.goInfo.SetActive(true);
86 this.goIngredients.SetActive(r.ingredients.Count > 0 && !r.UseStock);
87 }
88 if (this.recipe == r)
89 {
90 return;
91 }
92 this.recipe = r;
93 this.Refresh();
94 }
95
96 // Token: 0x06002212 RID: 8722 RVA: 0x000BCE60 File Offset: 0x000BB060
97 public void Clear()
98 {
99 this.recipe = null;
100 this.area = null;
101 if (this.main)
102 {
103 this.goIngredients.SetActive(false);
104 this.goInfo.SetActive(false);
105 if (this.listVariations)
106 {
107 this.listVariations.SetActive(false);
108 }
109 }
110 if (this.textName.text != "")
111 {
112 this.textName.text = (this.textDetail.text = "");
113 this.RefreshList();
114 this.RefreshBalance();
115 if (this.imageArea)
116 {
117 this.imageArea.SetActive(false);
118 }
119 this.note.Clear();
120 this.note.Build();
121 this.RebuildLayout(true);
122 }
123 }
124
125 // Token: 0x06002213 RID: 8723 RVA: 0x000BCF2C File Offset: 0x000BB12C
126 public void RefreshBalance()
127 {
128 if (!this.main)
129 {
130 return;
131 }
132 string text = Lang._Number(EMono.pc.GetCurrency("money"));
133 if (this.summary.money != 0)
134 {
135 text = string.Concat(new string[]
136 {
137 text,
138 "<color=",
139 this.colorCost.ToHex(),
140 "> -",
141 this.summary.money.ToString(),
142 "</color>"
143 });
144 }
145 this.textCost.SetText(text);
146 foreach (DropdownRecipe dropdownRecipe in this.dds)
147 {
148 dropdownRecipe.RefreshLabel();
149 }
150 if (this.ddList)
151 {
152 this.ddList.Redraw();
153 }
154 if (this.textCostSP)
155 {
156 int countValid = this.summary.countValid;
157 int num = (countValid == 0) ? -1 : (this.recipe.source.GetSPCost(this.summary.factory) * countValid);
158 text = ((num == -1) ? "-" : (num.ToString() ?? ""));
159 DOTweenAnimation component = this.textCostSP.GetComponent<DOTweenAnimation>();
160 Transform transform = this.textCostSP.Find("nerun");
161 bool flag = num >= EMono.pc.stamina.value;
162 if (component && !flag)
163 {
164 component.DOPause();
165 }
166 this.textCostSP.SetText(text, (num == -1) ? FontColor.Bad : ((num < EMono.pc.stamina.value) ? FontColor.Good : FontColor.Warning));
167 if (component && flag)
168 {
169 component.tween.Restart(true, -1f);
170 }
171 if (transform)
172 {
173 transform.SetActive(flag);
174 }
175 }
176 }
177
178 // Token: 0x06002214 RID: 8724 RVA: 0x000BD114 File Offset: 0x000BB314
179 public void RefreshImages()
180 {
181 Recipe recipe = this.recipe;
182 if (this.listVariations)
183 {
184 this.listVariations.Redraw();
185 }
186 if (this.imageIcon)
187 {
188 if (recipe.UseStock && !recipe.VirtualBlock)
189 {
190 recipe.ingredients[0].thing.SetImage(this.imageIcon, recipe._dir, recipe.ingredients[0].thing.idSkin);
191 return;
192 }
193 recipe.renderRow.SetImage(this.imageIcon, null, recipe.renderRow.GetColorInt(recipe.GetColorMaterial()), true, recipe._dir, recipe.idSkin);
194 }
195 }
196
197 // Token: 0x06002215 RID: 8725 RVA: 0x000BD1C8 File Offset: 0x000BB3C8
198 public void Refresh()
199 {
200 if (this.recipe == null)
201 {
202 return;
203 }
204 if (this.recipe.UseStock || this.recipe.IngAsProduct)
205 {
206 Thing thing = this.recipe.ingredients[0].thing;
207 if (thing == null || thing.isDestroyed || thing.ExistsOnMap)
208 {
209 return;
210 }
211 }
212 Recipe r = this.recipe;
213 r.OnSelected();
214 this.RefreshList();
215 this.RefreshBalance();
216 if (r.UseStock && r.ingredients[0].thing == null)
217 {
218 return;
219 }
220 this.textName.text = r.GetName();
221 string text = "";
222 int[] tiles = this.recipe.renderRow.tiles;
223 if (EMono.debug.showExtra)
224 {
225 text = string.Concat(new string[]
226 {
227 text,
228 "(",
229 this.recipe.id,
230 " ",
231 this.recipe.renderRow.idRenderData,
232 "/",
233 ((tiles.Length != 0) ? tiles[0] : -1).ToString(),
234 ")",
235 Environment.NewLine
236 });
237 }
238 this.textDetail.SetActive(true);
239 if (this.CraftMode)
240 {
241 if (this.main)
242 {
243 EMono.pc.things.GetThingStack(r.GetIdThing(), r.GetRefVal());
244 int num = EMono.player.recipes.knownRecipes.TryGetValue(r.id, 0);
245 this.textInfo.SetText("recipe_lv".lang(num.ToString() ?? "", null, null, null, null));
246 text += r.GetDetail();
247 }
248 else
249 {
250 text += r.GetDetail();
251 r.WriteNote(this.note);
252 }
253 }
254 else
255 {
256 string detail = r.GetDetail();
257 if (!detail.IsEmpty())
258 {
259 text = text + detail + "\n\n";
260 }
261 text = string.Concat(new string[]
262 {
263 text,
264 "( ",
265 r.tileType.LangPlaceType.lang(),
266 " ) ",
267 (r.tileType.LangPlaceType + "_hint").lang()
268 });
269 if (r.UseStock && r.ingredients[0].thing != null)
270 {
271 r.ingredients[0].thing.WriteNote(this.note, null, IInspect.NoteMode.Recipe, null);
272 }
273 else
274 {
275 r.WriteNote(this.note);
276 }
277 if (!r.UseStock && r.source.NeedFactory)
278 {
279 PropSet propSet = EMono._map.Installed.cardMap.TryGetValue(r.source.idFactory, null);
280 if (propSet == null || propSet.Count == 0)
281 {
282 this.note.Space(8, 1);
283 this.note.AddText("noFactory".lang(r.source.NameFactory, null, null, null, null), FontColor.Bad);
284 this.note.Build();
285 }
286 }
287 }
288 this.textDetail.SetText(text);
289 if (this.goMoney)
290 {
291 this.goMoney.transform.SetAsLastSibling();
292 }
293 if (this.main)
294 {
295 if (this.listVariations)
296 {
297 UIList uilist = this.listVariations;
298 bool flag = r.CanRotate && r.renderRow != null;
299 int[] array = flag ? r.renderRow._tiles : null;
300 if (flag && array.Length <= 1)
301 {
302 flag = false;
303 }
304 uilist.SetActive(flag);
305 if (flag)
306 {
307 uilist.Clear();
308 BaseList baseList = uilist;
309 UIList.Callback<UIRecipeInfo.RecipeVariation, ButtonGrid> callback = new UIList.Callback<UIRecipeInfo.RecipeVariation, ButtonGrid>();
310 callback.onClick = delegate(UIRecipeInfo.RecipeVariation a, ButtonGrid b)
311 {
312 r.SetDir(a.dir);
313 };
314 callback.onInstantiate = delegate(UIRecipeInfo.RecipeVariation a, ButtonGrid b)
315 {
316 b.SetRecipeVariation(a);
317 };
318 callback.onRedraw = delegate(UIRecipeInfo.RecipeVariation a, ButtonGrid b, int i)
319 {
320 b.SetRecipeVariation(a);
321 };
322 baseList.callbacks = callback;
323 for (int j = 0; j < array.Length; j++)
324 {
325 uilist.Add(new UIRecipeInfo.RecipeVariation
326 {
327 recipe = r,
328 dir = j
329 });
330 }
331 uilist.Refresh(false);
332 uilist.group.Init(r._dir, null, false);
333 }
334 }
335 if (this.goMoney)
336 {
337 this.goMoney.SetActive(!this.CraftMode);
338 }
339 }
340 else
341 {
342 this.listIngredients.SetActive(!this.recipe.UseStock || this.recipe.VirtualBlock);
343 if (this.goMoney)
344 {
345 this.goMoney.SetActive(r.CostMoney != 0);
346 }
347 }
348 this.RefreshImages();
349 this.SetActive(true);
350 this.RebuildLayout(true);
351 }
352
353 // Token: 0x06002216 RID: 8726 RVA: 0x000BD749 File Offset: 0x000BB949
354 public void OnRotate()
355 {
356 if (this.listVariations.gameObject.activeSelf)
357 {
358 this.listVariations.group.Select(this.recipe._dir);
359 }
360 this.RefreshImages();
361 }
362
363 // Token: 0x06002217 RID: 8727 RVA: 0x000BD77E File Offset: 0x000BB97E
364 public void RefreshQuality()
365 {
366 if (!this.textQuality)
367 {
368 return;
369 }
370 this.recipe.SetTextDifficulty(this.textQuality);
371 }
372
373 // Token: 0x06002218 RID: 8728 RVA: 0x000BD7A0 File Offset: 0x000BB9A0
374 public void RefreshList()
375 {
376 if (this.textReqSkill)
377 {
378 string str = "";
379 FontColor c = FontColor.Good;
380 if (this.recipe != null)
381 {
382 Element reqSkill = this.recipe.source.GetReqSkill();
383 int value = EMono.pc.elements.GetOrCreateElement(reqSkill).Value;
384 reqSkill.Name + " " + reqSkill.Value.ToString();
385 str = "reqSkill2".lang(reqSkill.Name, reqSkill.Value.ToString() ?? "", value.ToString() ?? "", null, null);
386 if (value < reqSkill.Value)
387 {
388 c = FontColor.Warning;
389 }
390 }
391 this.textReqSkill.SetText(str.IsEmpty("noReqSkill".lang()), c);
392 }
393 if (this.ddFactory)
394 {
395 List<GridItem> list = new List<GridItem>();
396 if (this.recipe.source.NeedFactory)
397 {
398 GridItemCardSource gridItemCardSource = new GridItemCardSource
399 {
400 source = EMono.sources.cards.map[this.recipe.source.idFactory]
401 };
402 if (this.factory != null && this.recipe.source.idFactory == this.factory.id)
403 {
404 gridItemCardSource.thing = this.factory;
405 }
406 list.Add(gridItemCardSource);
407 }
408 this.ddFactory.Build(list);
409 }
410 this.RefreshQuality();
411 if (this.ddList)
412 {
413 this.ddList.SetActive(this.recipe != null && !this.recipe.UseStock);
414 if (this.recipe == null || this.recipe.UseStock)
415 {
416 return;
417 }
418 this.ddList.recipeInfo = this;
419 this.ddList.lastMats = this.lastMats;
420 this.ddList.BuildIngredients(this.recipe, this.imageIcon, new Action(this.RefreshQuality), this.searchMode);
421 return;
422 }
423 else
424 {
425 Recipe r = this.recipe;
426 UIList uilist = this.listIngredients;
427 uilist.Clear();
428 this.dds.Clear();
429 if (r == null || r.UseStock)
430 {
431 return;
432 }
433 BaseList baseList = uilist;
434 UIList.Callback<Recipe.Ingredient, UIItem> callback = new UIList.Callback<Recipe.Ingredient, UIItem>();
435 callback.onClick = delegate(Recipe.Ingredient a, UIItem b)
436 {
437 };
438 callback.onInstantiate = delegate(Recipe.Ingredient ingredient, UIItem b)
439 {
440 DropdownRecipe dropdownRecipe = b.dd as DropdownRecipe;
441 dropdownRecipe.recipe = r;
442 this.dds.Add(dropdownRecipe);
443 ThingStack thingStack = EMono._map.Stocked.ListThingStack(ingredient, this.searchMode);
444 int num = thingStack.count;
445 Color color = (num >= ingredient.req) ? SkinManager.CurrentColors.textGood : SkinManager.CurrentColors.textBad;
446 List<string> list2 = new List<string>();
447 list2.Add(ingredient.id);
448 dropdownRecipe.SetList<string>(0, list2, (string n, int i) => string.Concat(new string[]
449 {
450 "<color=",
451 color.ToHex(),
452 ">",
453 ingredient.GetName(),
454 " x ",
455 ingredient.req.ToString(),
456 " (",
457 num.ToString(),
458 ")</color>"
459 }), delegate(int i, string v)
460 {
461 }, true);
462 dropdownRecipe.textLabel.text = dropdownRecipe.orgLabel.text;
463 if (this.textCost)
464 {
465 this.textCost.text = (r.CostMoney.ToString() ?? "");
466 }
467 };
468 baseList.callbacks = callback;
469 foreach (Recipe.Ingredient o in r.ingredients)
470 {
471 uilist.Add(o);
472 }
473 uilist.Refresh(false);
474 return;
475 }
476 }
477
478 // Token: 0x0400119B RID: 4507
479 public UIText textName;
480
481 // Token: 0x0400119C RID: 4508
482 public UIText textDetail;
483
484 // Token: 0x0400119D RID: 4509
485 public UIText textCost;
486
487 // Token: 0x0400119E RID: 4510
488 public UIText textInfo;
489
490 // Token: 0x0400119F RID: 4511
491 public UIText textQuality;
492
493 // Token: 0x040011A0 RID: 4512
494 public UIText textReqSkill;
495
496 // Token: 0x040011A1 RID: 4513
497 public UIText textCostSP;
498
499 // Token: 0x040011A2 RID: 4514
500 public Thing factory;
501
502 // Token: 0x040011A3 RID: 4515
503 public Recipe recipe;
504
505 // Token: 0x040011A4 RID: 4516
506 public Area area;
507
508 // Token: 0x040011A5 RID: 4517
509 public UIList listIngredients;
510
511 // Token: 0x040011A6 RID: 4518
512 public UIList listVariations;
513
514 // Token: 0x040011A7 RID: 4519
515 public Image imageArea;
516
517 // Token: 0x040011A8 RID: 4520
518 public Image imageIcon;
519
520 // Token: 0x040011A9 RID: 4521
521 public UINote note;
522
523 // Token: 0x040011AA RID: 4522
524 public Color colorCost;
525
526 // Token: 0x040011AB RID: 4523
527 public Color colorPredict;
528
529 // Token: 0x040011AC RID: 4524
530 public GameObject goMoney;
531
532 // Token: 0x040011AD RID: 4525
533 public GameObject goIngredients;
534
535 // Token: 0x040011AE RID: 4526
536 public GameObject goInfo;
537
538 // Token: 0x040011AF RID: 4527
539 public bool main;
540
541 // Token: 0x040011B0 RID: 4528
542 public bool CraftMode;
543
544 // Token: 0x040011B1 RID: 4529
545 public StockSearchMode searchMode;
546
547 // Token: 0x040011B2 RID: 4530
548 public DropdownGrid ddList;
549
550 // Token: 0x040011B3 RID: 4531
551 public DropdownGrid ddFactory;
552
553 // Token: 0x040011B4 RID: 4532
554 public ButtonGrid buttonProduct;
555
556 // Token: 0x040011B5 RID: 4533
557 [NonSerialized]
558 public Dictionary<string, int> lastMats = new Dictionary<string, int>();
559
560 // Token: 0x040011B6 RID: 4534
561 [NonSerialized]
562 public bool hideMode = true;
563
564 // Token: 0x040011B7 RID: 4535
565 [NonSerialized]
566 public List<DropdownRecipe> dds = new List<DropdownRecipe>();
567
568 // Token: 0x02000A02 RID: 2562
569 public class RecipeVariation
570 {
571 // Token: 0x04002951 RID: 10577
572 public Recipe recipe;
573
574 // Token: 0x04002952 RID: 10578
575 public int dir;
576 }
577}
Definition Area.cs:6
Definition EMono.cs:6
Definition Thing.cs:10