Elin Decompiled Documentation EA 23.219 Nightly
Loading...
Searching...
No Matches
Recipe.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using Newtonsoft.Json;
3using UnityEngine;
4using UnityEngine.UI;
5
6public class Recipe : EClass
7{
8 public enum State
9 {
10 Valid,
12 }
13
14 public enum IngType
15 {
16 Default,
18 }
19
20 public class Ingredient : EClass
21 {
22 [JsonProperty]
23 public int uid;
24
25 [JsonProperty]
26 public int req;
27
28 [JsonProperty]
29 public int mat = -1;
30
31 [JsonProperty]
32 public int refVal = -1;
33
34 [JsonProperty]
35 public string id;
36
37 [JsonProperty]
38 public string tag;
39
40 [JsonProperty]
41 public List<string> idOther = new List<string>();
42
43 [JsonProperty]
45
46 public Thing thing;
47
48 public bool optional;
49
50 public bool dye;
51
52 public bool useCat;
53
54 public bool IsThingSpecified => uid != 0;
55
56 public string IdThing
57 {
58 get
59 {
60 if (!useCat)
61 {
62 return id;
63 }
64 return EClass.sources.categories.map[id].GetIdThing();
65 }
66 }
67
69 {
70 if (thing == null)
71 {
73 if (thing == null)
74 {
76 if (thing == null)
77 {
79 if (thing == null)
80 {
82 }
83 }
84 }
85 }
86 return thing;
87 }
88
89 public bool CanSetThing(Thing t)
90 {
91 if (t.id != id || t.Num < req)
92 {
93 return false;
94 }
95 return true;
96 }
97
98 public void SetThing(Thing t = null)
99 {
100 uid = t?.uid ?? 0;
101 thing = t;
102 mat = t?.material.id ?? (-1);
103 }
104
105 public string GetName()
106 {
107 if (useCat)
108 {
109 string text = CatName(id);
110 if (idOther.Count > 0)
111 {
112 foreach (string item in idOther)
113 {
114 text = text + ", " + CatName(item);
115 }
116 }
117 return "ingCat".lang(text);
118 }
119 string text2 = EClass.sources.cards.map[id].GetName().IsEmpty(("card_" + id).lang());
120 string text3 = (tag.IsEmpty() ? "" : ("(" + ("tag_" + tag).lang() + ")"));
121 if (idOther.Count > 0)
122 {
123 foreach (string item2 in idOther)
124 {
125 text3 = text3 + ", " + EClass.sources.cards.map[item2].GetName();
126 }
127 }
128 return text2 + text3;
129 static string CatName(string id)
130 {
131 return EClass.sources.categories.map[id].GetName();
132 }
133 }
134
136 {
137 if (ingType == IngType.CreativeFood && t.HasElement(10) && !t.category.IsChildOf("seasoning") && !t.category.IsChildOf("meal") && !(t.trait is TraitFoodFishSlice))
138 {
139 return true;
140 }
141 Debug.Log(t.Name + "/" + tag + "/" + t.material.tag);
142 if (!tag.IsEmpty() && !t.material.tag.Contains(tag))
143 {
144 return false;
145 }
146 if (useCat)
147 {
148 if (t.category.IsChildOf(id))
149 {
150 return true;
151 }
152 foreach (string item in idOther)
153 {
154 if (t.category.IsChildOf(item))
155 {
156 return true;
157 }
158 }
159 return false;
160 }
161 if (t.id == id || t.source._origin == id)
162 {
163 return true;
164 }
165 foreach (string item2 in idOther)
166 {
167 if (t.id == id || t.source._origin == item2)
168 {
169 return true;
170 }
171 }
172 return false;
173 }
174 }
175
176 public static Dictionary<string, Recipe> recipeCache = new Dictionary<string, Recipe>();
177
178 [JsonProperty]
179 public string id;
180
181 [JsonProperty]
182 public List<Ingredient> ingredients = new List<Ingredient>();
183
184 [JsonProperty]
185 public bool UseStock;
186
187 [JsonProperty]
188 public bool IngAsProduct;
189
190 [JsonProperty]
191 public bool VirtualBlock;
192
193 public int _dir;
194
195 public int sync;
196
197 public int idMat = -1;
198
199 public int idSkin;
200
201 public State state;
202
204
206
208
209 public virtual TileRow tileRow => source.row as TileRow;
210
211 public virtual RenderRow renderRow => source.row;
212
213 public string Name => GetName();
214
215 public virtual TileType tileType
216 {
217 get
218 {
219 if (!(source.type == "Bridge") || source.row.tileType is TileTypeBridge)
220 {
221 return renderRow.tileType;
222 }
223 return TileType.Bridge;
224 }
225 }
226
228
229 public int MaxAltitude
230 {
231 get
232 {
234 {
235 return tileType.MaxAltitude;
236 }
237 return 0;
238 }
239 }
240
241 public int RecipeLv => EClass.player.recipes.knownRecipes.TryGetValue(id, 0);
242
243 public bool IsFloor => tileType.IsFloor;
244
245 public bool IsObj => tileRow is SourceObj.Row;
246
247 public virtual bool IsBlock => !IsFloorOrBridge;
248
250
251 public bool IsBridge => source.type == "Bridge";
252
253 public virtual bool IsThing => false;
254
255 public virtual Card Mold => null;
256
257 public virtual int W
258 {
259 get
260 {
261 if (_dir % 2 != 0)
262 {
263 return renderRow.H;
264 }
265 return renderRow.W;
266 }
267 }
268
269 public virtual int H
270 {
271 get
272 {
273 if (_dir % 2 != 0)
274 {
275 return renderRow.W;
276 }
277 return renderRow.H;
278 }
279 }
280
281 public virtual bool RequireIngredients => true;
282
283 public bool MultiSize
284 {
285 get
286 {
287 if (W == 1)
288 {
289 return H != 1;
290 }
291 return true;
292 }
293 }
294
296
297 public virtual int CostMoney => 0;
298
299 public virtual bool CanRotate
300 {
301 get
302 {
303 if (tileType.CanRotate(buildMode: true))
304 {
305 return tileRow._tiles.Length > 1;
306 }
307 return false;
308 }
309 }
310
311 public static Recipe GetOrCreate(string id)
312 {
313 Recipe recipe = recipeCache.TryGetValue(id);
314 if (recipe == null)
315 {
316 RecipeSource recipeSource = RecipeManager.dict.TryGetValue(id);
317 if (recipeSource != null)
318 {
319 recipe = Create(recipeSource);
320 recipeCache.Add(id, recipe);
321 }
322 }
323 return recipe;
324 }
325
326 public static Recipe Create(RecipeSource _source, int idMat = -1, Thing ing = null)
327 {
328 string type = _source.type;
329 Recipe recipe = (_source.isBridgePillar ? new RecipeBridgePillar() : (type.IsEmpty() ? new RecipeCard() : ((type == "Custom") ? new RecipeCustom() : new Recipe())));
330 recipe.id = _source.id;
331 recipe._source = _source;
332 recipe.idMat = idMat;
333 if (ing != null)
334 {
335 recipe.BuildIngredientList(ing);
336 if (ing.trait is TraitTile)
337 {
338 recipe.VirtualBlock = true;
339 }
340 }
341 return recipe;
342 }
343
344 public static Recipe Create(Thing t)
345 {
346 RecipeSource recipeSource = RecipeManager.dict.TryGetValue(t.id);
347 if (recipeSource == null)
348 {
349 return null;
350 }
351 RecipeCard recipeCard = new RecipeCard
352 {
353 id = recipeSource.id,
354 _source = recipeSource,
355 IngAsProduct = true,
356 idSkin = t.idSkin
357 };
358 recipeCard.BuildIngredientList(t);
359 if (t.uid == 0 || recipeCard.ingredients[0].uid == 0 || recipeCard.ingredients[0].thing == null)
360 {
361 Debug.LogError("expection: invalid ingredient " + t);
362 }
363 return recipeCard;
364 }
365
366 public static void DropIngredients(string id, string idMatMain, int num = 1)
367 {
369 Recipe orCreate = GetOrCreate(EClass.sources.cards.map[id].RecipeID);
370 orCreate.BuildIngredientList();
371 Msg.Say("dropReward");
372 foreach (Ingredient ingredient in orCreate.ingredients)
373 {
374 Thing thing = ThingGen.Create(ingredient.id).SetNum(ingredient.req);
375 if (ingredient == orCreate.ingredients[0])
376 {
377 thing.ChangeMaterial(idMatMain);
378 thing.SetNum(num);
379 }
380 EClass.player.DropReward(thing, silent: true);
381 }
382 }
383
384 public bool IsStaticLV()
385 {
386 switch (source.idFactory)
387 {
388 case "factory_floor":
389 case "factory_block":
390 case "factory_wall":
391 case "factory_platform":
392 return true;
393 default:
394 return renderRow.Category.IsChildOf("block");
395 }
396 }
397
398 public int GetQualityBonus()
399 {
400 if (IsStaticLV())
401 {
402 return 0;
403 }
404 Element reqSkill = source.GetReqSkill();
405 int num = reqSkill.Value - EClass.pc.Evalue(reqSkill.id);
406 int num2 = 0;
407 if (num > 0)
408 {
409 if (num < 5)
410 {
411 return 0;
412 }
413 return -(num - 4) * 10;
414 }
415 num2 += EClass.curve(-num, 10, 20, 80) / 10 * 10 + 10;
416 if (RecipeLv > 0)
417 {
418 num2 += (int)Mathf.Sqrt(RecipeLv - 1) * 10;
419 }
420 return num2;
421 }
422
423 public virtual int GetRefVal()
424 {
425 if (source.row is SourceBlock.Row)
426 {
427 return (source.row as SourceBlock.Row).id;
428 }
429 if (source.row is SourceFloor.Row)
430 {
431 return (source.row as SourceFloor.Row).id;
432 }
433 if (source.row is SourceObj.Row)
434 {
435 return (source.row as SourceObj.Row).id;
436 }
437 return -1;
438 }
439
440 public virtual string GetIdThing()
441 {
442 if (source.row is SourceBlock.Row)
443 {
444 return (source.row as SourceBlock.Row).idThing;
445 }
446 if (source.row is SourceFloor.Row)
447 {
448 if (!IsBridge)
449 {
450 return "floor";
451 }
452 return "platform";
453 }
454 if (source.row is SourceObj.Row)
455 {
456 return "obj";
457 }
458 return null;
459 }
460
461 public virtual bool ShouldShowHighlight(HitResult r)
462 {
463 return r != HitResult.Valid;
464 }
465
467 {
469 {
470 return BaseTileSelector.BoxType.Box;
471 }
472 return BaseTileSelector.BoxType.Fence;
473 }
474
475 public int GetDefaultColor()
476 {
477 if (UseStock)
478 {
479 Thing thing = ingredients[0].thing;
480 return renderRow.GetColorInt(thing.isDyed ? thing.DyeMat : thing.material);
481 }
483 }
484
486 {
487 int num = -1;
488 if (ingredients.Count > 0)
489 {
490 num = ((ingredients[0].thing == null) ? ingredients[0].mat : ingredients[0].thing.material.id);
491 }
492 if (num == -1)
493 {
494 num = 3;
495 }
496 return EClass.sources.materials.rows[num];
497 }
498
500 {
501 if (idMat != -1)
502 {
503 return EClass.sources.materials.rows[idMat];
504 }
505 if (UseStock)
506 {
507 ingredients[0].RefreshThing();
508 Thing thing = ingredients[0].thing;
509 if (thing != null)
510 {
511 if (!thing.isDyed)
512 {
513 return thing.material;
514 }
515 return thing.DyeMat;
516 }
517 return EClass.sources.materials.rows[3];
518 }
519 int num = ((ingredients.Count > 0) ? ingredients[source.colorIng].mat : 3);
520 if (num == -1)
521 {
522 num = 3;
523 }
524 return EClass.sources.materials.rows[num];
525 }
526
527 public virtual void BuildIngredientList()
528 {
530 {
532 }
533 }
534
536 {
537 UseStock = true;
539 {
540 id = t.id,
541 tag = null,
542 req = 1,
543 uid = t.uid,
544 thing = t,
545 mat = t.material.id
546 };
547 ingredients.Add(item);
548 }
549
550 public virtual void OnChangeIngredient()
551 {
552 }
553
554 public virtual Thing Craft(BlessedState blessed, bool sound = false, List<Thing> ings = null, TraitCrafter crafter = null, bool model = false)
555 {
556 Thing thing = null;
557 string type = source.type;
558 thing = ((type == "Block") ? ThingGen.CreateBlock(tileRow.id, GetMainMaterial().id) : ((!(type == "Obj")) ? ThingGen.CreateFloor(tileRow.id, GetMainMaterial().id, source.isBridge) : ThingGen.CreateObj(tileRow.id, GetMainMaterial().id)));
559 if (thing == null)
560 {
561 return null;
562 }
563 thing.trait.OnCrafted(this, ings);
564 thing.SetBlessedState(blessed);
565 if (model)
566 {
567 return thing;
568 }
569 Msg.Say("crafted", thing);
570 thing = EClass.pc.AddCard(thing) as Thing;
571 if (thing.GetRootCard() == EClass.pc)
572 {
573 EClass.pc.HoldCard(thing);
574 }
575 return thing;
576 }
577
578 public bool HasSameTile(Point point, int dir, int altitude, int bridgeHeight)
579 {
580 if (IsObj)
581 {
582 if (point.growth != null && point.sourceObj == tileRow && point.cell.matObj == GetColorMaterial())
583 {
584 return true;
585 }
586 if (dir == point.cell.objDir && point.cell.matObj == GetColorMaterial() && point.sourceObj == tileRow)
587 {
588 return true;
589 }
590 }
591 else if (IsBridge)
592 {
593 if (dir == point.cell.floorDir && point.matBridge == GetColorMaterial() && point.sourceBridge == tileRow && Mathf.Clamp(bridgeHeight + altitude, 0, 255) == point.cell.bridgeHeight)
594 {
595 return true;
596 }
597 }
598 else if (IsFloorOrBridge)
599 {
600 if (dir == point.cell.floorDir && point.matFloor == GetColorMaterial() && point.sourceFloor == tileRow)
601 {
602 return true;
603 }
604 }
605 else if (IsWallOrFence)
606 {
607 if (point.matBlock == GetColorMaterial() && point.sourceBlock == tileRow && dir == point.cell.blockDir)
608 {
609 return true;
610 }
611 }
612 else if (IsBlock && point.matBlock == GetColorMaterial() && (point.sourceBlock == tileRow || (tileRow != null && tileRow.tileType == point.sourceBlock.tileType && tileRow.tileType == TileType.Slope)))
613 {
614 if (point.sourceBlock.tileType.AltitudeAsDir && dir != point.cell.objDir)
615 {
616 return false;
617 }
618 return true;
619 }
620 return false;
621 }
622
623 public virtual void Build(TaskBuild task)
624 {
625 Build(task.owner, null, task.pos, (ingredients.Count > 0) ? ingredients[0].mat : task.recipe.idMat, task.dir, task.altitude, task.bridgeHeight);
626 }
627
628 public virtual void Build(Chara chara, Card t, Point pos, int mat, int dir, int altitude, int bridgeHeight)
629 {
630 if (mat == -1)
631 {
632 mat = 2;
633 }
634 EClass.pc.PlaySound(EClass.sources.materials.rows[mat].GetSoundImpact());
635 pos.cell.isModified = true;
636 switch (source.type)
637 {
638 case "Block":
639 {
640 int ramp = tileRow.id;
641 if (ramp == 3)
642 {
643 ramp = EClass.sources.materials.rows[mat].ramp;
644 }
646 {
647 EClass._map.SetRoofBlock(pos.x, pos.z, mat, ramp, dir, altitude);
648 break;
649 }
650 if (pos.HasObj && !pos.sourceObj.tileType.CanBuiltOnBlock)
651 {
653 EClass._map.SetObj(pos.x, pos.z);
654 }
655 EClass._map.SetBlock(pos.x, pos.z, mat, ramp, dir);
656 if (tileType.IsBlockPass && pos.HasChara)
657 {
658 foreach (Chara item in pos.ListCharas())
659 {
660 chara.Kick(item, ignoreSelf: false, karmaLoss: false);
661 }
662 }
664 {
665 pos.cell.objDir = dir;
666 }
667 {
668 foreach (Card item2 in pos.ListCards())
669 {
670 if (item2.isThing && item2.placeState == PlaceState.roaming)
671 {
672 item2._Move(item2.pos.GetNearestPoint());
673 }
674 }
675 break;
676 }
677 }
678 case "Floor":
679 if (pos.HasObj && pos.sourceObj.tileType.RemoveOnFloorChange && (!BuildMenu.Instance || !EClass.debug.ignoreBuildRule))
680 {
681 EClass._map.SetObj(pos.x, pos.z);
682 }
683 EClass._map.SetFloor(pos.x, pos.z, mat, tileRow.id, dir);
684 break;
685 case "Bridge":
686 if (pos.sourceObj.tileType.RemoveOnFloorChange)
687 {
688 EClass._map.SetObj(pos.x, pos.z);
689 }
690 EClass._map.SetBridge(pos.x, pos.z, Mathf.Clamp(bridgeHeight + altitude, 0, 255), mat, tileRow.id, dir);
691 break;
692 case "Obj":
693 EClass._map.SetObj(pos.x, pos.z, mat, tileRow.id, 1, dir, ignoreRandomMat: true);
695 {
696 EClass._map.SetBlockDir(pos.x, pos.z, dir);
697 }
698 if (pos.growth != null)
699 {
701 }
702 break;
703 }
704 }
705
706 public virtual void OnRenderMarker(Point point, bool active, HitResult result, bool main, int dir, int bridgeHeight)
707 {
708 if (dir != -1)
709 {
710 _dir = dir;
711 }
712 RenderParam renderParam = tileRow.GetRenderParam(DefaultMaterial, _dir, point, bridgeHeight);
713 renderParam.matColor = (active ? EClass.Colors.blockColors.Active : EClass.Colors.blockColors.Inactive);
714 point.ApplyAnime(renderParam);
715 if (tileType.IsWater)
716 {
718 {
719 EClass.screen.guide.passGuideFloor.Add(point, (float)result, 0.3f);
720 }
721 return;
722 }
724 {
725 Vector3 v = point.Position();
727 {
729 }
730 }
732 {
733 if (bridgeHeight > 0 && !point.cell.skipRender && EClass.screen.guide.isActive)
734 {
735 EClass.screen.guide.passGuideFloor.Add(point, (float)result, 0.3f);
736 }
737 if (!tileType.IsWallOrFence && (point.HasChara || (point.HasObj && point.cell.blocked)))
738 {
739 Vector3 v2 = point.Position();
741 {
743 }
744 return;
745 }
747 {
748 EClass.screen.tileMap.SetRoofHeight(renderParam, point.cell, point.x, point.z, 0, bridgeHeight, tileType.IsWallOrFence ? _dir : (-1), ignoreAltitudeY: true);
749 }
750 renderParam.y = renderParam.y - EClass.screen.tileMap.rendererBlockMarker.offset.y + renderRow.renderData.offset.y;
751 renderParam.z += EClass.setting.render.tileMarkerZ;
752 int num = ((tileType.blockRenderMode != BlockRenderMode.Pillar) ? 1 : (_dir + 1 + ((_dir >= 7) ? _dir : 0)));
753 if (num == 1)
754 {
756 }
757 else
758 {
760 }
761 }
763 {
764 if (point.HasObj)
765 {
766 _ = ref point.Position();
767 }
768 renderParam.z += ((point.cell.liquidLv > 0) ? (-0.01f) : EClass.setting.render.tileMarkerZFloor);
770 }
771 else
772 {
773 renderParam.z += EClass.setting.render.tileMarkerZ;
774 renderRow.renderData.Draw(renderParam);
775 }
776 }
777
778 public string GetName()
779 {
780 if (UseStock && ingredients[0].thing == null)
781 {
782 return "";
783 }
784 string text = (UseStock ? ingredients[0].thing.Name : source.Name);
785 if (text == "")
786 {
787 text = ("card_" + source.id).lang();
788 }
789 if (text == "*r")
790 {
791 text = source.row.GetText("aka");
792 }
793 if (text == "*r")
794 {
795 text = "(" + source.row.GetField<string>("id") + ")";
796 }
797 return text.ToTitleCase();
798 }
799
800 public virtual string GetDetail()
801 {
802 return renderRow.GetText("detail").IsEmpty(source.GetDetail());
803 }
804
805 public virtual void WriteNote(UINote n)
806 {
807 n.Clear();
808 n.Build();
809 }
810
811 public void WriteReqFactory(UINote n, bool hasFactory = true)
812 {
814 {
815 n.AddHeaderTopic("reqFactory".lang(source.NameFactory.TagColor(hasFactory ? FontColor.Default : FontColor.Bad)));
816 n.Space(8);
817 }
818 }
819
820 public void WriteReqSkill(UINote n)
821 {
822 n.AddHeaderTopic("reqSkill");
823 Element reqSkill = source.GetReqSkill();
824 int value = EClass.pc.elements.GetOrCreateElement(reqSkill).Value;
825 Color textColor = EClass.Colors.Skin.GetTextColor((value >= reqSkill.Value) ? FontColor.Good : FontColor.Warning);
826 n.AddText(null, reqSkill.Name + " " + reqSkill.Value + " (" + value + ")", textColor).text1.SetSize(-1);
827 n.Space(8);
828 }
829
830 public virtual IRenderer GetRenderer()
831 {
832 return tileRow.renderData;
833 }
834
835 public virtual void OnSelected()
836 {
837 }
838
839 public virtual void OnChangeAltitude(int a)
840 {
841 }
842
843 public virtual void Rotate()
844 {
845 if (EInput.isShiftDown || Input.GetMouseButton(1))
846 {
847 _dir--;
848 }
849 else
850 {
851 _dir++;
852 }
854 {
856 {
857 _dir = 0;
858 }
859 if (_dir < 0)
860 {
861 _dir = tileType.MaxAltitude - 1;
862 }
863 }
864 else
865 {
866 int num = tileRow._tiles.Length;
868 {
869 num = 2;
870 }
871 if (_dir < 0)
872 {
873 _dir = num - 1;
874 }
875 if (_dir >= num)
876 {
877 _dir = 0;
878 }
879 }
880 if ((bool)BuildMenu.Instance)
881 {
883 }
884 }
885
886 public virtual void SetDir(int d)
887 {
888 _dir = d;
889 if ((bool)BuildMenu.Instance)
890 {
892 }
893 }
894
895 public virtual Recipe Duplicate()
896 {
897 return IO.DeepCopy(this);
898 }
899
900 public virtual void SetImage(Image icon)
901 {
902 renderRow.SetImage(icon, null, renderRow.GetColorInt((ingredients != null && ingredients.Count > 0 && ingredients[0].thing != null) ? ingredients[0].thing.material : DefaultMaterial), setNativeSize: true, 0, idSkin);
903 }
904
905 public bool IsCraftable()
906 {
907 foreach (Ingredient ingredient in ingredients)
908 {
909 if (ingredient.optional)
910 {
911 continue;
912 }
913 ThingStack thingStack = EClass._map.Stocked.ListThingStack(ingredient, StockSearchMode.AroundPC);
914 bool flag = false;
915 foreach (Thing item in thingStack.list)
916 {
917 if (item.Num >= ingredient.req)
918 {
919 flag = true;
920 break;
921 }
922 }
923 if (!flag)
924 {
925 return false;
926 }
927 }
928 return true;
929 }
930
931 public int GetMaxCount()
932 {
933 int num = 999;
934 for (int i = 0; i < ingredients.Count; i++)
935 {
936 Ingredient ingredient = ingredients[i];
937 Thing thing = ingredient.thing;
938 int num2 = 0;
939 if (!ingredient.optional || thing != null)
940 {
941 if (thing != null && !thing.isDestroyed)
942 {
943 num2 = thing.Num / ingredient.req;
944 }
945 if (num2 < num)
946 {
947 num = num2;
948 }
949 }
950 }
951 return num;
952 }
953
954 public void SetTextDifficulty(UIText text)
955 {
956 Element reqSkill = source.GetReqSkill();
958 string text2 = reqSkill.Name + " " + reqSkill.Value;
959 text.SetText(text2);
960 }
961
962 public int GetSortVal()
963 {
964 Element reqSkill = source.GetReqSkill();
965 return reqSkill.source.id * 10000 - reqSkill.Value;
966 }
967
968 public bool HasFirstTimeBonus()
969 {
970 if (IsStaticLV())
971 {
972 return false;
973 }
974 if (EClass.player.recipes.craftedRecipes.Contains(id))
975 {
976 return false;
977 }
978 return true;
979 }
980
982 {
983 if (HasFirstTimeBonus())
984 {
986 Element reqSkill = source.GetReqSkill();
987 int num = 1 + ((!IsStaticLV()) ? (reqSkill.Value / 20) : 0);
988 Msg.Say("firstTimeCraft", Name);
989 EClass.pc.Pick(ThingGen.Create("ticket_fortune").SetNum(num));
990 }
991 }
992
994 {
995 List<int> list = new List<int>();
996 foreach (Ingredient ingredient in ingredients)
997 {
998 int item = ((ingredient.thing != null) ? ingredient.thing.uid : 0);
999 list.Add(item);
1000 }
1002 }
1003
1005 {
1006 QuestTrackCraft result = null;
1007 foreach (Quest item in EClass.game.quests.list)
1008 {
1009 if (item is QuestTrackCraft)
1010 {
1011 result = item as QuestTrackCraft;
1012 break;
1013 }
1014 }
1015 return result;
1016 }
1017
1018 public void ToggleTrack(QuestTrackCraft quest)
1019 {
1020 if (quest != null && quest.idRecipe == id)
1021 {
1022 EClass.game.quests.Remove(quest);
1023 }
1024 else
1025 {
1026 if (quest != null)
1027 {
1028 EClass.game.quests.Remove(quest);
1029 }
1030 QuestTrackCraft questTrackCraft = Quest.Create("track_craft") as QuestTrackCraft;
1031 questTrackCraft.SetRecipe(this);
1032 EClass.game.quests.Start(questTrackCraft);
1033 }
1035 {
1036 EClass.player.questTracker = true;
1037 EClass.ui.widgets.ActivateWidget("QuestTracker");
1039 }
1041 }
1042}
BlessedState
Definition: BlessedState.cs:2
BlockRenderMode
FontColor
Definition: FontColor.cs:2
HitResult
Definition: HitResult.cs:2
PlaceState
Definition: PlaceState.cs:2
StockSearchMode
new Chara owner
Definition: AIAct.cs:14
virtual bool IsRoofEditMode(Card c=null)
Definition: ActionMode.cs:311
ScreenGuide guide
BaseTileSelector tileSelector
BaseTileMap tileMap
MeshPass passFloor
Definition: BaseTileMap.cs:145
MeshPass passFloorEx
Definition: BaseTileMap.cs:163
MeshPass passFloorWater
Definition: BaseTileMap.cs:165
RenderData rendererFloorMarker
Definition: BaseTileMap.cs:201
RenderData rendererBlockMarker
Definition: BaseTileMap.cs:199
MeshPass passLiquid
Definition: BaseTileMap.cs:135
void SetRoofHeight(MeshPassParam _param, Cell _cell, int _cx, int _cz, int h=0, int altitude=0, int dirWall=-1, bool ignoreAltitudeY=false)
MeshPass passBlockEx
Definition: BaseTileMap.cs:161
MeshPass passBlock
Definition: BaseTileMap.cs:147
static BuildMenu Instance
Definition: BuildMenu.cs:77
UIRecipeInfo info1
Definition: BuildMenu.cs:27
Definition: Card.cs:11
bool isDestroyed
Definition: Card.cs:75
virtual MoveResult _Move(Point p, MoveType type=MoveType.Walk)
Definition: Card.cs:5690
virtual bool isThing
Definition: Card.cs:2069
ElementContainerCard elements
Definition: Card.cs:41
string id
Definition: Card.cs:35
bool HasElement(int ele, int req=1)
Definition: Card.cs:5787
SourceMaterial.Row DyeMat
Definition: Card.cs:1928
SourceMaterial.Row material
Definition: Card.cs:2039
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6001
Card ChangeMaterial(int idNew, bool ignoreFixedMaterial=false)
Definition: Card.cs:3022
Card AddCard(Card c)
Definition: Card.cs:3071
string Name
Definition: Card.cs:2125
Thing SetNum(int a)
Definition: Card.cs:3425
PlaceState placeState
Definition: Card.cs:83
virtual void SetBlessedState(BlessedState s)
Definition: Card.cs:3825
Point pos
Definition: Card.cs:59
int uid
Definition: Card.cs:122
Trait trait
Definition: Card.cs:53
bool isDyed
Definition: Card.cs:458
ThingContainer things
Definition: Card.cs:38
Card GetRootCard()
Definition: Card.cs:3356
int Evalue(int ele)
Definition: Card.cs:2559
int Num
Definition: Card.cs:158
SourceCategory.Row category
Definition: Card.cs:2037
SourceMaterial.Row matObj
Definition: Cell.cs:1036
bool skipRender
Definition: Cell.cs:270
int floorDir
Definition: Cell.cs:922
int objDir
Definition: Cell.cs:910
byte bridgeHeight
Definition: Cell.cs:74
int blockDir
Definition: Cell.cs:898
Definition: Chara.cs:10
void HoldCard(Card t, int num=-1)
Definition: Chara.cs:4395
void Kick(Point p, bool ignoreSelf=false, bool checkWall=true)
Definition: Chara.cs:5648
Thing Pick(Thing t, bool msg=true, bool tryStack=true)
Definition: Chara.cs:4231
BlockColors blockColors
SkinColorProfile Skin
bool ignoreBuildRule
Definition: CoreDebug.cs:185
Definition: EClass.cs:5
static Game game
Definition: EClass.cs:8
static Scene scene
Definition: EClass.cs:30
static ColorProfile Colors
Definition: EClass.cs:38
static int curve(int a, int start, int step, int rate=75)
Definition: EClass.cs:68
static Map _map
Definition: EClass.cs:18
static SourceManager sources
Definition: EClass.cs:42
static BaseGameScreen screen
Definition: EClass.cs:32
static Player player
Definition: EClass.cs:12
static Chara pc
Definition: EClass.cs:14
static CoreDebug debug
Definition: EClass.cs:48
static UI ui
Definition: EClass.cs:16
static GameSetting setting
Definition: EClass.cs:34
Definition: EInput.cs:8
static bool isShiftDown
Definition: EInput.cs:261
Element GetOrCreateElement(Element ele)
int id
Definition: ELEMENT.cs:250
int Value
Definition: ELEMENT.cs:292
virtual string Name
Definition: ELEMENT.cs:304
RenderSetting render
Definition: GameSetting.cs:301
QuestManager quests
Definition: Game.cs:179
void SetDefaultStage()
Definition: GrowSystem.cs:259
void SetBridge(int x, int z, int height=0, int idMat=0, int idBridge=0, int dir=0)
Definition: Map.cs:972
void SetBlockDir(int x, int z, int dir)
Definition: Map.cs:1165
void MineObjSound(Point point)
Definition: Map.cs:1937
void SetFloor(int x, int z, int idMat=0, int idFloor=0)
Definition: Map.cs:957
void SetBlock(int x, int z, int idMat=0, int idBlock=0)
Definition: Map.cs:996
void SetRoofBlock(int x, int z, int idMat, int idBlock, int dir, int height)
Definition: Map.cs:987
PropsStocked Stocked
Definition: Map.cs:121
void SetObj(int x, int z, int id=0, int value=1, int dir=0)
Definition: Map.cs:1535
void Add(Point point, float tile=0f, float color=0f)
Definition: MeshPass.cs:122
Definition: Msg.cs:5
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
RecipeManager recipes
Definition: Player.cs:1094
Thing DropReward(Thing t, bool silent=false)
Definition: Player.cs:2527
Definition: Point.cs:9
SourceMaterial.Row matBlock
Definition: Point.cs:55
SourceMaterial.Row matFloor
Definition: Point.cs:57
SourceBlock.Row sourceBlock
Definition: Point.cs:63
ref Vector3 Position(int height)
Definition: Point.cs:536
List< Card > ListCards(bool includeMasked=false)
Definition: Point.cs:1035
RenderParam ApplyAnime(RenderParam p)
Definition: Point.cs:1309
int x
Definition: Point.cs:36
Point GetNearestPoint(bool allowBlock=false, bool allowChara=true, bool allowInstalled=true, bool ignoreCenter=false, int minRadius=0)
Definition: Point.cs:607
int z
Definition: Point.cs:39
SourceMaterial.Row matBridge
Definition: Point.cs:59
SourceObj.Row sourceObj
Definition: Point.cs:69
List< Chara > ListCharas()
Definition: Point.cs:1155
SourceFloor.Row sourceFloor
Definition: Point.cs:65
bool HasObj
Definition: Point.cs:137
Cell cell
Definition: Point.cs:51
SourceFloor.Row sourceBridge
Definition: Point.cs:67
GrowSystem growth
Definition: Point.cs:77
bool HasChara
Definition: Point.cs:226
bool HasNonWallBlock
Definition: Point.cs:182
Thing Find(int uid)
Definition: Props.cs:389
ThingStack ListThingStack(Recipe.Ingredient ing, StockSearchMode searchMode)
Definition: Props.cs:204
List< Quest > list
Definition: QuestManager.cs:11
void Remove(Quest q)
Definition: QuestManager.cs:67
Quest Start(string id, string idGlobalChara)
Definition: QuestManager.cs:41
void SetRecipe(Recipe r)
Definition: Quest.cs:7
static Quest Create(string _id, string _idPerson=null, Chara c=null)
Definition: Quest.cs:241
override void BuildIngredientList()
Definition: RecipeCard.cs:65
Dictionary< string, List< int > > lastIngredients
static void BuildList()
HashSet< string > craftedRecipes
static RecipeSource Get(string id)
static Dictionary< string, RecipeSource > dict
Dictionary< string, int > knownRecipes
Element GetReqSkill()
RenderRow row
Definition: RecipeSource.cs:5
List< Recipe.Ingredient > GetIngredients()
string idFactory
Definition: RecipeSource.cs:85
string NameFactory
Definition: RecipeSource.cs:73
string GetDetail()
string type
Definition: RecipeSource.cs:7
bool NeedFactory
Definition: RecipeSource.cs:61
Thing RefreshThing()
Definition: Recipe.cs:68
bool IsThingSpecified
Definition: Recipe.cs:54
string GetName()
Definition: Recipe.cs:105
List< string > idOther
Definition: Recipe.cs:41
bool CanSetThing(Thing t)
Definition: Recipe.cs:89
string tag
Definition: Recipe.cs:38
void SetThing(Thing t=null)
Definition: Recipe.cs:98
IngType ingType
Definition: Recipe.cs:44
string IdThing
Definition: Recipe.cs:57
bool IsValidIngredient(Thing t)
Definition: Recipe.cs:135
Definition: Recipe.cs:7
string id
Definition: Recipe.cs:179
virtual int GetRefVal()
Definition: Recipe.cs:423
SourceMaterial.Row DefaultMaterial
Definition: Recipe.cs:207
int RecipeLv
Definition: Recipe.cs:241
State
Definition: Recipe.cs:9
void SetTextDifficulty(UIText text)
Definition: Recipe.cs:954
virtual void WriteNote(UINote n)
Definition: Recipe.cs:805
void WriteReqSkill(UINote n)
Definition: Recipe.cs:820
void WriteReqFactory(UINote n, bool hasFactory=true)
Definition: Recipe.cs:811
static Recipe Create(Thing t)
Definition: Recipe.cs:344
State state
Definition: Recipe.cs:201
virtual void OnRenderMarker(Point point, bool active, HitResult result, bool main, int dir, int bridgeHeight)
Definition: Recipe.cs:706
virtual bool RequireIngredients
Definition: Recipe.cs:281
int GetMaxCount()
Definition: Recipe.cs:931
virtual string GetIdThing()
Definition: Recipe.cs:440
bool HasSameTile(Point point, int dir, int altitude, int bridgeHeight)
Definition: Recipe.cs:578
virtual IRenderer GetRenderer()
Definition: Recipe.cs:830
virtual Card Mold
Definition: Recipe.cs:255
virtual bool CanRotate
Definition: Recipe.cs:300
virtual TileRow tileRow
Definition: Recipe.cs:209
virtual void Rotate()
Definition: Recipe.cs:843
virtual void SetDir(int d)
Definition: Recipe.cs:886
virtual TileType tileType
Definition: Recipe.cs:216
RecipeSource _source
Definition: Recipe.cs:203
static void DropIngredients(string id, string idMatMain, int num=1)
Definition: Recipe.cs:366
int sync
Definition: Recipe.cs:195
virtual void OnSelected()
Definition: Recipe.cs:835
bool IsObj
Definition: Recipe.cs:245
virtual RenderRow renderRow
Definition: Recipe.cs:211
int idMat
Definition: Recipe.cs:197
RecipeSource source
Definition: Recipe.cs:205
void SaveLastIngredients()
Definition: Recipe.cs:993
int GetSortVal()
Definition: Recipe.cs:962
List< Ingredient > ingredients
Definition: Recipe.cs:182
virtual void Build(TaskBuild task)
Definition: Recipe.cs:623
virtual bool IsFloorOrBridge
Definition: Recipe.cs:227
virtual bool IsBlock
Definition: Recipe.cs:247
bool VirtualBlock
Definition: Recipe.cs:191
bool IsCraftable()
Definition: Recipe.cs:905
void BuildIngredientList(Thing t)
Definition: Recipe.cs:535
IngType
Definition: Recipe.cs:15
QuestTrackCraft GetQuestTrack()
Definition: Recipe.cs:1004
virtual SourceMaterial.Row GetMainMaterial()
Definition: Recipe.cs:485
virtual int H
Definition: Recipe.cs:270
virtual int CostMoney
Definition: Recipe.cs:297
static Dictionary< string, Recipe > recipeCache
Definition: Recipe.cs:176
static Recipe Create(RecipeSource _source, int idMat=-1, Thing ing=null)
Definition: Recipe.cs:326
int MaxAltitude
Definition: Recipe.cs:230
virtual bool IsThing
Definition: Recipe.cs:253
bool IsFloor
Definition: Recipe.cs:243
void ToggleTrack(QuestTrackCraft quest)
Definition: Recipe.cs:1018
void TryGetFirstTimeBonus()
Definition: Recipe.cs:981
string Name
Definition: Recipe.cs:213
virtual void Build(Chara chara, Card t, Point pos, int mat, int dir, int altitude, int bridgeHeight)
Definition: Recipe.cs:628
bool IsWallOrFence
Definition: Recipe.cs:249
int GetQualityBonus()
Definition: Recipe.cs:398
bool MultiSize
Definition: Recipe.cs:284
virtual void OnChangeIngredient()
Definition: Recipe.cs:550
virtual string GetDetail()
Definition: Recipe.cs:800
virtual Thing Craft(BlessedState blessed, bool sound=false, List< Thing > ings=null, TraitCrafter crafter=null, bool model=false)
Definition: Recipe.cs:554
bool UseStock
Definition: Recipe.cs:185
bool HasFirstTimeBonus()
Definition: Recipe.cs:968
int _dir
Definition: Recipe.cs:193
int GetDefaultColor()
Definition: Recipe.cs:475
bool IsStaticLV()
Definition: Recipe.cs:384
bool IsBridge
Definition: Recipe.cs:251
static Recipe GetOrCreate(string id)
Definition: Recipe.cs:311
int idSkin
Definition: Recipe.cs:199
string GetName()
Definition: Recipe.cs:778
virtual void SetImage(Image icon)
Definition: Recipe.cs:900
virtual SourceMaterial.Row GetColorMaterial()
Definition: Recipe.cs:499
virtual void BuildIngredientList()
Definition: Recipe.cs:527
BaseTileSelector tileSelector
Definition: Recipe.cs:295
BaseTileSelector.BoxType GetBoxType()
Definition: Recipe.cs:466
virtual void OnChangeAltitude(int a)
Definition: Recipe.cs:839
virtual bool ShouldShowHighlight(HitResult r)
Definition: Recipe.cs:461
virtual int W
Definition: Recipe.cs:258
bool IngAsProduct
Definition: Recipe.cs:188
virtual Recipe Duplicate()
Definition: Recipe.cs:895
void Draw(RenderParam p, int tile)
Definition: RenderData.cs:128
void DrawRepeat(RenderParam p, int count, float size, bool skipFirst=false)
Definition: RenderData.cs:214
Vector3 offset
Definition: RenderData.cs:18
MeshPass pass
Definition: RenderData.cs:16
int GetColorInt(SourceMaterial.Row mat)
Definition: RenderRow.cs:424
RenderData renderData
Definition: RenderRow.cs:71
SourceCategory.Row Category
Definition: RenderRow.cs:119
TileType tileType
Definition: RenderRow.cs:77
int[] _tiles
Definition: RenderRow.cs:12
void SetImage(Image image, Sprite sprite=null, int matCol=0, bool setNativeSize=true, int dir=0, int idSkin=0, Card card=null)
Definition: RenderRow.cs:351
virtual RenderParam GetRenderParam(SourceMaterial.Row mat, int dir, Point point=null, int bridgeHeight=-1)
Definition: RenderRow.cs:388
SourceMaterial.Row DefaultMaterial
Definition: RenderRow.cs:86
ActionMode actionMode
Definition: Scene.cs:79
bool isActive
Definition: ScreenGuide.cs:15
MeshPass passGuideBlock
Definition: ScreenGuide.cs:5
MeshPass passGuideFloor
Definition: ScreenGuide.cs:7
Color GetTextColor(FontColor fontColor)
Dictionary< string, CardRow > map
Definition: SourceCard.cs:8
string GetText(string id="name", bool returnNull=false)
Definition: SourceData.cs:553
SourceMaterial materials
SourceCard cards
SourceCategory categories
int altitude
Definition: TaskBuild.cs:17
Recipe recipe
Definition: TaskBuild.cs:8
int bridgeHeight
Definition: TaskBuild.cs:14
int dir
Definition: TaskBuild.cs:11
Point pos
Definition: TaskPoint.cs:11
Thing Find(int uid)
static Thing CreateBlock(int id, int idMat)
Definition: ThingGen.cs:101
static Thing CreateObj(int id, int idMat)
Definition: ThingGen.cs:116
static Thing CreateFloor(int id, int idMat, bool platform=false)
Definition: ThingGen.cs:108
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: Thing.cs:8
SourceThing.Row source
Definition: Thing.cs:11
int id
Definition: TileRow.cs:8
virtual BaseTileSelector.BoxType BoxType
Definition: TileType.cs:273
static TileTypeBridge Bridge
Definition: TileType.cs:65
virtual bool IsFloor
Definition: TileType.cs:139
virtual int MaxAltitude
Definition: TileType.cs:208
virtual float RepeatSize
Definition: TileType.cs:241
static TileTypeSlope Slope
Definition: TileType.cs:25
virtual bool IsWallOrFence
Definition: TileType.cs:143
virtual bool AltitudeAsDir
Definition: TileType.cs:219
virtual bool IsFloorOrBridge
Definition: TileType.cs:135
virtual bool CanRotate(bool buildMode)
Definition: TileType.cs:294
virtual BlockRenderMode blockRenderMode
Definition: TileType.cs:277
virtual bool ChangeBlockDir
Definition: TileType.cs:127
static TileTypeDoor Door
Definition: TileType.cs:95
virtual bool IsBlockPass
Definition: TileType.cs:153
virtual bool IsWater
Definition: TileType.cs:163
virtual void OnCrafted(Recipe recipe, List< Thing > ings)
Definition: Trait.cs:659
UIText text1
Definition: UIItem.cs:6
Definition: UINote.cs:6
UIItem AddHeaderTopic(string text, Sprite sprite=null)
Definition: UINote.cs:89
void Clear()
Definition: UINote.cs:35
UIItem AddText(string text, FontColor color=FontColor.DontChange)
Definition: UINote.cs:113
void Space(int sizeY=0, int sizeX=1)
Definition: UINote.cs:62
void Build()
Definition: UINote.cs:49
void OnRotate()
Definition: UIText.cs:6
void SetText(string s)
Definition: UIText.cs:159
UIText SetSize(int a)
Definition: UIText.cs:227
static void RefreshButtons()
static WidgetQuestTracker Instance