Elin Modding Docs Doc
Loading...
Searching...
No Matches
RecipeCard.cs
1using System;
2using System.Collections.Generic;
3using Newtonsoft.Json;
4using UnityEngine;
5
6// Token: 0x0200005B RID: 91
7public class RecipeCard : Recipe
8{
9 // Token: 0x1700006E RID: 110
10 // (get) Token: 0x0600023E RID: 574 RVA: 0x00011960 File Offset: 0x0000FB60
11 public CardRow sourceCard
12 {
13 get
14 {
15 CardRow result;
16 if ((result = this._sourceCard) == null)
17 {
18 result = (this._sourceCard = EClass.sources.cards.map.TryGetValue(base.source.row.idString, null));
19 }
20 return result;
21 }
22 }
23
24 // Token: 0x1700006F RID: 111
25 // (get) Token: 0x0600023F RID: 575 RVA: 0x000119A5 File Offset: 0x0000FBA5
26 public override RenderRow renderRow
27 {
28 get
29 {
30 return this.sourceCard;
31 }
32 }
33
34 // Token: 0x17000070 RID: 112
35 // (get) Token: 0x06000240 RID: 576 RVA: 0x000119AD File Offset: 0x0000FBAD
36 public override TileType tileType
37 {
38 get
39 {
40 return this.Mold.trait.tileType;
41 }
42 }
43
44 // Token: 0x06000241 RID: 577 RVA: 0x000119BF File Offset: 0x0000FBBF
45 public override IRenderer GetRenderer()
46 {
47 return this.Mold.renderer;
48 }
49
50 // Token: 0x17000071 RID: 113
51 // (get) Token: 0x06000242 RID: 578 RVA: 0x000119CC File Offset: 0x0000FBCC
52 public string idCard
53 {
54 get
55 {
56 return this.sourceCard.id;
57 }
58 }
59
60 // Token: 0x06000243 RID: 579 RVA: 0x000119D9 File Offset: 0x0000FBD9
61 public override string GetDetail()
62 {
63 return this.sourceCard.GetDetail();
64 }
65
66 // Token: 0x06000244 RID: 580 RVA: 0x000119E6 File Offset: 0x0000FBE6
67 public override string GetIdThing()
68 {
69 return this.id;
70 }
71
72 // Token: 0x17000072 RID: 114
73 // (get) Token: 0x06000245 RID: 581 RVA: 0x000119EE File Offset: 0x0000FBEE
74 public override bool CanRotate
75 {
76 get
77 {
78 return this.tileType.CanRotate(true);
79 }
80 }
81
82 // Token: 0x17000073 RID: 115
83 // (get) Token: 0x06000246 RID: 582 RVA: 0x000119FC File Offset: 0x0000FBFC
84 public override bool IsThing
85 {
86 get
87 {
88 return true;
89 }
90 }
91
92 // Token: 0x17000074 RID: 116
93 // (get) Token: 0x06000247 RID: 583 RVA: 0x00011A00 File Offset: 0x0000FC00
94 public override Card Mold
95 {
96 get
97 {
98 Card result;
99 if ((result = this._mold) == null)
100 {
101 result = (this._mold = this.CreateMold());
102 }
103 return result;
104 }
105 }
106
107 // Token: 0x17000075 RID: 117
108 // (get) Token: 0x06000248 RID: 584 RVA: 0x00011A26 File Offset: 0x0000FC26
109 public bool isDish
110 {
111 get
112 {
113 return this.sourceCard._origin == "dish";
114 }
115 }
116
117 // Token: 0x06000249 RID: 585 RVA: 0x00011A40 File Offset: 0x0000FC40
118 public override void OnRenderMarker(Point point, bool active, HitResult result, bool main, int dir, int bridgeHeight)
119 {
120 this.Mold.ignoreStackHeight = Input.GetKey(KeyCode.LeftControl);
121 this.Mold.SetFreePos(point);
122 this.freePos = this.Mold.freePos;
123 this.fx = this.Mold.fx;
124 this.fy = this.Mold.fy;
125 this.Mold.RenderMarker(point, active, result, main, dir, false);
126 if (!point.cell.skipRender)
127 {
128 this.Mold.trait.OnRenderTile(point, result, dir);
129 }
130 }
131
132 // Token: 0x0600024A RID: 586 RVA: 0x00011AD8 File Offset: 0x0000FCD8
133 public override void BuildIngredientList()
134 {
135 if (this.ingredients.Count != 0)
136 {
137 return;
138 }
139 base.BuildIngredientList();
140 if (!EClass.core.IsGameStarted || EClass.core.game.isLoading)
141 {
142 return;
143 }
144 if (this.isDish && EClass.pc.Evalue(1650) >= 2)
145 {
146 bool flag = this.ingredients.Count < 3;
147 using (List<Recipe.Ingredient>.Enumerator enumerator = this.ingredients.GetEnumerator())
148 {
149 while (enumerator.MoveNext())
150 {
151 if (enumerator.Current.id == "seasoning")
152 {
153 flag = false;
154 }
155 }
156 }
157 if (flag)
158 {
159 this.ingredients.Add(new Recipe.Ingredient
160 {
161 id = "seasoning",
162 optional = true,
163 req = 1
164 });
165 }
166 }
167 }
168
169 // Token: 0x0600024B RID: 587 RVA: 0x00011BC0 File Offset: 0x0000FDC0
170 public override void OnChangeIngredient()
171 {
172 if (this.UseStock)
173 {
174 return;
175 }
176 this.Mold.ChangeMaterial(this.GetMainMaterial());
177 if (base.source.colorIng != 0)
178 {
179 this.Mold.Dye(this.GetColorMaterial());
180 }
181 }
182
183 // Token: 0x0600024C RID: 588 RVA: 0x00011BFB File Offset: 0x0000FDFB
184 public override void OnSelected()
185 {
186 this.CreateMold();
187 }
188
189 // Token: 0x0600024D RID: 589 RVA: 0x00011C04 File Offset: 0x0000FE04
190 public Card CreateMold()
191 {
192 if (this._mold != null)
193 {
194 this._mold.Destroy();
195 }
196 if (this.UseStock)
197 {
198 this.ingredients[0].RefreshThing();
199 }
200 if (this.UseStock && this.ingredients[0].thing != null)
201 {
202 this._mold = this.ingredients[0].thing.Duplicate(1);
203 }
204 else
205 {
206 if (this.sourceCard.isChara)
207 {
208 this._mold = CharaGen.Create(this.idCard, -1);
209 }
210 else
211 {
212 this._mold = ThingGen.Create(this.idCard, -1, -1);
213 }
214 this.OnChangeIngredient();
215 }
216 this._mold.dir = this._dir;
217 this._mold.altitude = ActionMode.Build.altitude;
218 this._mold.idSkin = this.idSkin;
219 return this._mold;
220 }
221
222 // Token: 0x0600024E RID: 590 RVA: 0x00011CF0 File Offset: 0x0000FEF0
223 public override Thing Craft(BlessedState blessed, bool sound = false, List<Thing> ings = null, bool model = false)
224 {
225 string text = this.idCard;
226 int idMat = this.GetMainMaterial().id;
227 Element reqSkill = base.source.GetReqSkill();
228 int num = reqSkill.Value - EClass.pc.Evalue(reqSkill.id);
229 int qualityBonus = base.GetQualityBonus();
230 int num2 = this.renderRow.LV + qualityBonus;
231 bool flag = qualityBonus < 0;
232 CardRow cardRow = EClass.sources.cards.map.TryGetValue(text, null);
233 bool flag2 = false;
234 if (ings != null)
235 {
236 foreach (Thing thing in ings)
237 {
238 if (thing != null && thing.IsDecayed)
239 {
240 flag2 = true;
241 }
242 }
243 }
244 if (EClass.debug.godCraft || model)
245 {
246 flag = false;
247 }
248 else if (cardRow != null && cardRow.tag.Contains("no_fail"))
249 {
250 flag = false;
251 }
252 else if (this.isDish && !EClass.scene.actionMode.IsBuildMode)
253 {
254 if (num > 0 && EClass.rnd(num * 10) > EClass.rnd(100))
255 {
256 text = this.GetIdFailDish();
257 flag = true;
258 }
259 else
260 {
261 flag = false;
262 }
263 }
264 if (!model)
265 {
266 string id = this.id;
267 if (!(id == "weapon_stone") && !(id == "weapon_wood"))
268 {
269 if (id == "weapon_anvil")
270 {
271 Rand.SetSeed(-1);
272 text = new string[]
273 {
274 "dagger",
275 "sword",
276 "axe_hand",
277 "blunt_club",
278 "spear",
279 "staff_long"
280 }.RandomItem<string>();
281 idMat = ings[1].material.id;
282 }
283 }
284 else
285 {
286 Rand.SetSeed(-1);
287 text = new string[]
288 {
289 "dagger",
290 "sword",
291 "axe_hand",
292 "blunt_club",
293 "spear",
294 "staff_long"
295 }.RandomItem<string>();
296 }
297 }
298 if (!this.isDish && num2 < 1)
299 {
300 num2 = 1;
301 }
302 if (EClass.sources.cards.map[text].tag.Contains("noQuality"))
303 {
304 num2 = -1;
305 }
306 if (EClass.sources.cards.map[text].tag.Contains("noMaterialChange"))
307 {
308 idMat = -1;
309 }
311 {
312 qualityBonus = qualityBonus,
313 rarity = (flag ? Rarity.Crude : Rarity.Normal)
314 });
315 Thing thing2 = ThingGen.Create(text, idMat, num2);
316 if (thing2.trait.CraftNum > 1)
317 {
318 thing2.SetNum(thing2.trait.CraftNum);
319 }
320 thing2.idSkin = this.idSkin;
321 thing2.Identify(false, IDTSource.Identify);
322 thing2.isCrafted = true;
323 if (base.source.colorIng != 0)
324 {
325 thing2.Dye(this.GetColorMaterial());
326 }
327 if (thing2.IsContainer)
328 {
329 thing2.RemoveThings();
330 thing2.c_lockLv = 0;
331 }
332 thing2.SetBlessedState(blessed);
333 if (this.isDish)
334 {
335 if (!flag)
336 {
337 this.MakeDish(thing2);
338 }
339 }
340 else
341 {
342 this.MixIngredients(thing2);
343 }
344 if (this.isDish && flag2)
345 {
346 thing2.decay = thing2.MaxDecay + 1;
347 }
348 thing2.trait.OnCrafted(this);
349 if (model)
350 {
351 thing2.SetNum(1);
352 return thing2;
353 }
354 if (EClass.pc.held == null || !thing2.TryStackTo(EClass.pc.held.Thing))
355 {
356 EClass.pc.HoldCard(thing2, -1);
357 }
358 if (sound)
359 {
360 thing2.PlaySoundDrop(false);
361 }
362 Msg.Say("crafted", thing2, null, null, null);
363 if (thing2.Num > EClass.rnd(1000) || EClass.debug.enable)
364 {
365 EClass.player.recipes.ComeUpWithRandomRecipe(thing2.category.id, 0);
366 }
367 if (this.isDish && (EClass.debug.enable || (EClass.player.flags.canComupWithFoodRecipe && EClass.rnd(30) == 0)))
368 {
369 EClass.player.recipes.ComeUpWithRandomRecipe(thing2.category.id, 0);
370 EClass.player.flags.canComupWithFoodRecipe = false;
371 }
372 return thing2;
373 }
374
375 // Token: 0x0600024F RID: 591 RVA: 0x00012144 File Offset: 0x00010344
376 public void MakeDish(Thing t)
377 {
378 Rand.SetSeed(EClass.pc.turn);
379 List<Thing> list = new List<Thing>();
380 foreach (Recipe.Ingredient ingredient in this.ingredients)
381 {
382 list.Add(ingredient.thing);
383 }
384 CraftUtil.MakeDish(t, list, base.GetQualityBonus());
385 Rand.SetSeed(-1);
386 }
387
388 // Token: 0x06000250 RID: 592 RVA: 0x000121C4 File Offset: 0x000103C4
389 public void MixIngredients(Thing t)
390 {
391 Rand.SetSeed(EClass.pc.turn);
392 List<Thing> list = new List<Thing>();
393 foreach (Recipe.Ingredient ingredient in this.ingredients)
394 {
395 list.Add(ingredient.thing);
396 }
397 CraftUtil.MixIngredients(t, list, CraftUtil.MixType.General, base.GetQualityBonus());
398 Rand.SetSeed(-1);
399 }
400
401 // Token: 0x06000251 RID: 593 RVA: 0x00012248 File Offset: 0x00010448
402 public string GetIdFailDish()
403 {
404 string category = this.sourceCard.category;
405 uint num = <PrivateImplementationDetails>.ComputeStringHash(category);
406 if (num <= 2191978763U)
407 {
408 if (num <= 1612508523U)
409 {
410 if (num != 228605988U)
411 {
412 if (num == 1612508523U)
413 {
414 if (category == "meal_bread")
415 {
416 return "fail_dough_bread";
417 }
418 }
419 }
420 else if (category == "meal_meat")
421 {
422 return "fail_meat";
423 }
424 }
425 else if (num != 1937649754U)
426 {
427 if (num != 2035834996U)
428 {
429 if (num == 2191978763U)
430 {
431 if (category == "meal_cake")
432 {
433 return "fail_dough_cake";
434 }
435 }
436 }
437 else if (category == "meal_noodle")
438 {
439 return "fail_noodle";
440 }
441 }
442 else if (category == "meal_vegi")
443 {
444 return "fail_vegi";
445 }
446 }
447 else if (num <= 2808738325U)
448 {
449 if (num != 2235373338U)
450 {
451 if (num == 2808738325U)
452 {
453 if (category == "meal_fish")
454 {
455 return "fail_fish";
456 }
457 }
458 }
459 else if (category == "meal_rice")
460 {
461 return "fail_rice";
462 }
463 }
464 else if (num != 3150879124U)
465 {
466 if (num != 3348186596U)
467 {
468 if (num == 4237839943U)
469 {
470 if (category == "meal_fruit")
471 {
472 return "fail_fruit";
473 }
474 }
475 }
476 else if (category == "meal_egg")
477 {
478 return "fail_egg";
479 }
480 }
481 else if (category == "meal_soup")
482 {
483 return "fail_drink";
484 }
485 return "fail_dish";
486 }
487
488 // Token: 0x06000252 RID: 594 RVA: 0x000123E8 File Offset: 0x000105E8
489 public override void Build(TaskBuild task)
490 {
491 Card card;
492 if (task.target != null)
493 {
494 card = task.target;
495 }
496 else if (this.IngAsProduct)
497 {
498 if (task.resources.Count == 0)
499 {
500 Thing thing = this.ingredients[0].RefreshThing();
501 if (thing == null)
502 {
503 SE.Beep();
504 return;
505 }
506 Thing item = thing.Split(1);
507 task.resources.Add(item);
508 if (this.ingredients[0].thing.isDestroyed || this.ingredients[0].thing.ExistsOnMap)
509 {
510 this.ingredients[0].thing = null;
511 }
512 }
513 card = task.resources[0];
514 }
515 else
516 {
517 if (this.sourceCard.isChara)
518 {
519 card = CharaGen.Create(this.idCard, Mathf.Max(EClass._zone.DangerLv, EClass.pc.LV));
520 }
521 else
522 {
523 card = ThingGen.Create(this.idCard, -1, Mathf.Max(EClass._zone.DangerLv, EClass.pc.LV));
524 }
525 if (!card.isChara)
526 {
527 if (!card.IsUnique)
528 {
529 card.ChangeMaterial(this.GetMainMaterial());
530 }
531 if (base.source.colorIng != 0)
532 {
533 card.Dye(this.GetColorMaterial());
534 }
535 if (card.IsContainer)
536 {
537 card.RemoveThings();
538 }
539 }
540 }
541 this.Build(task.owner, card, task.pos, this.ingredients[0].mat, task.dir, task.altitude, task.bridgeHeight);
542 card.renderer.PlayAnime(AnimeID.Place, default(Vector3), false);
543 }
544
545 // Token: 0x06000253 RID: 595 RVA: 0x00012594 File Offset: 0x00010794
546 public override void Build(Chara chara, Card t, Point pos, int mat, int dir, int altitude, int bridgeHeight)
547 {
548 if (mat == -1)
549 {
550 mat = 2;
551 }
552 EClass.pc.PlaySound(EClass.sources.materials.rows[mat].GetSoundImpact(null), 1f, true);
553 t.SetDir(dir);
554 t.idSkin = this.idSkin;
555 EClass._zone.AddCard(t, pos);
556 if (t.trait is TraitHouseBoard && ActionMode.Build.houseBoard != null)
557 {
558 (t.trait as TraitHouseBoard).data = IO.DeepCopy<TraitHouseBoard.Data>(ActionMode.Build.houseBoard.data);
559 }
560 t.SetPlaceState(PlaceState.installed, true);
561 t.altitude = altitude;
562 t.isPlayerCreation = true;
563 if (EClass._zone.idCurrentSubset != null)
564 {
565 t.isSubsetCard = true;
566 }
567 t.ignoreStackHeight = Input.GetKey(KeyCode.LeftControl);
568 if (ActionMode.Build.IsActive && t.trait.MaskOnBuild)
569 {
570 t.isMasked = true;
571 }
572 if (EClass.scene.actionMode.IsRoofEditMode(t) && t.isThing)
573 {
574 t.isRoofItem = true;
575 t.SetPlaceState(PlaceState.roaming, false);
576 }
577 t.ForeachPoint(delegate(Point p, bool main)
578 {
579 base.<Build>g__CheckBlock|0(p);
580 });
581 t.freePos = this.freePos;
582 if (this.freePos)
583 {
584 t.fx = this.fx;
585 t.fy = this.fy;
586 }
587 t.renderer.RefreshSprite();
588 }
589
590 // Token: 0x06000254 RID: 596 RVA: 0x0001270D File Offset: 0x0001090D
591 public override void OnChangeAltitude(int a)
592 {
593 this.Mold.altitude = a;
594 }
595
596 // Token: 0x06000255 RID: 597 RVA: 0x0001271B File Offset: 0x0001091B
597 public override void Rotate()
598 {
599 this.Mold.Rotate(false);
600 this._dir = this.Mold.dir;
601 if (BuildMenu.Instance)
602 {
603 BuildMenu.Instance.info1.OnRotate();
604 }
605 }
606
607 // Token: 0x06000256 RID: 598 RVA: 0x00012755 File Offset: 0x00010955
608 public override void SetDir(int d)
609 {
610 this.Mold.dir = d;
611 base.SetDir(d);
612 }
613
614 // Token: 0x06000257 RID: 599 RVA: 0x0001276A File Offset: 0x0001096A
615 public override void WriteNote(UINote n)
616 {
617 n.Clear();
618 if (!this.Mold.isChara)
619 {
620 this.Mold.elements.AddNote(n, null, null, ElementContainer.NoteMode.Default, false, null, null);
621 }
622 n.Build();
623 }
624
625 // Token: 0x06000258 RID: 600 RVA: 0x0001279C File Offset: 0x0001099C
626 public override Recipe Duplicate()
627 {
628 RecipeCard recipeCard = IO.DeepCopy<RecipeCard>(this);
629 recipeCard._mold = this._mold;
630 return recipeCard;
631 }
632
633 // Token: 0x040004F5 RID: 1269
634 public CardRow _sourceCard;
635
636 // Token: 0x040004F6 RID: 1270
637 [JsonProperty]
638 public bool freePos;
639
640 // Token: 0x040004F7 RID: 1271
641 [JsonProperty]
642 public float fx;
643
644 // Token: 0x040004F8 RID: 1272
645 [JsonProperty]
646 public float fy;
647
648 // Token: 0x040004F9 RID: 1273
649 public Card _mold;
650}
Definition Card.cs:13
Definition Chara.cs:12
Definition Msg.cs:7
Definition Point.cs:11
Definition Thing.cs:10