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