Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
RecipeCard.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using Newtonsoft.Json;
3using UnityEngine;
4
5public class RecipeCard : Recipe
6{
8
9 [JsonProperty]
10 public bool freePos;
11
12 [JsonProperty]
13 public float fx;
14
15 [JsonProperty]
16 public float fy;
17
18 public Card _mold;
19
20 public CardRow sourceCard => _sourceCard ?? (_sourceCard = EClass.sources.cards.map.TryGetValue(base.source.row.idString));
21
22 public override RenderRow renderRow => sourceCard;
23
24 public override TileType tileType => Mold.trait.tileType;
25
26 public string idCard => sourceCard.id;
27
28 public override bool CanRotate => tileType.CanRotate(buildMode: true);
29
30 public override bool IsThing => true;
31
32 public override Card Mold => _mold ?? (_mold = CreateMold());
33
34 public bool isDish => sourceCard._origin == "dish";
35
36 public override IRenderer GetRenderer()
37 {
38 return Mold.renderer;
39 }
40
41 public override string GetDetail()
42 {
43 return sourceCard.GetDetail();
44 }
45
46 public override string GetIdThing()
47 {
48 return id;
49 }
50
51 public override void OnRenderMarker(Point point, bool active, HitResult result, bool main, int dir, int bridgeHeight)
52 {
53 Mold.ignoreStackHeight = Input.GetKey(KeyCode.LeftControl);
54 Mold.SetFreePos(point);
56 fx = Mold.fx;
57 fy = Mold.fy;
58 Mold.RenderMarker(point, active, result, main, dir);
59 if (!point.cell.skipRender)
60 {
61 Mold.trait.OnRenderTile(point, result, dir);
62 }
63 }
64
65 public override void BuildIngredientList()
66 {
67 if (ingredients.Count != 0)
68 {
69 return;
70 }
71 base.BuildIngredientList();
73 {
74 return;
75 }
76 bool flag = ingredients.Count < 3;
77 foreach (Ingredient ingredient in ingredients)
78 {
79 if (ingredient.id == "seasoning")
80 {
81 flag = false;
82 }
83 }
84 if (flag)
85 {
87 {
88 id = "seasoning",
89 useCat = true,
90 optional = true,
91 req = 1
92 });
93 }
94 }
95
96 public override void OnChangeIngredient()
97 {
98 if (!UseStock)
99 {
101 if (base.source.colorIng != 0)
102 {
104 }
105 }
106 }
107
108 public override void OnSelected()
109 {
110 CreateMold();
111 }
112
114 {
115 if (_mold != null)
116 {
117 _mold.Destroy();
118 }
119 if (UseStock)
120 {
121 ingredients[0].RefreshThing();
122 }
123 if (UseStock && ingredients[0].thing != null)
124 {
125 _mold = ingredients[0].thing.Duplicate(1);
126 }
127 else
128 {
130 {
132 }
133 else
134 {
136 }
138 }
139 _mold.dir = _dir;
140 _mold.altitude = ActionMode.Build.altitude;
141 _mold.idSkin = idSkin;
142 return _mold;
143 }
144
145 public override Thing Craft(BlessedState blessed, bool sound = false, List<Thing> ings = null, TraitCrafter crafter = null, bool model = false)
146 {
147 string key = idCard;
148 int num = GetMainMaterial().id;
149 Element reqSkill = base.source.GetReqSkill();
150 int num2 = reqSkill.Value - EClass.pc.Evalue(reqSkill.id);
151 int num3 = GetQualityBonus();
152 int num4 = renderRow.LV + num3;
153 bool flag = num3 < 0;
154 CardRow cardRow = EClass.sources.cards.map.TryGetValue(key);
155 bool flag2 = false;
156 if (ings != null)
157 {
158 foreach (Thing ing in ings)
159 {
160 if (ing != null && ing.IsDecayed)
161 {
162 flag2 = true;
163 }
164 }
165 }
166 if (EClass.debug.godCraft || model)
167 {
168 flag = false;
169 }
170 else if (cardRow != null && cardRow.tag.Contains("no_fail"))
171 {
172 flag = false;
173 }
175 {
176 if (num2 > 0 && EClass.rnd(num2 * 10) > EClass.rnd(100))
177 {
178 key = GetIdFailDish();
179 flag = true;
180 }
181 else
182 {
183 flag = false;
184 }
185 }
186 if (!model)
187 {
188 switch (id)
189 {
190 case "weapon_stone":
191 case "weapon_wood":
192 Rand.SetSeed();
193 key = new string[6] { "dagger", "sword", "axe_hand", "blunt_club", "spear", "staff_long" }.RandomItem();
194 break;
195 case "weapon_anvil":
196 Rand.SetSeed();
197 key = new string[6] { "dagger", "sword", "axe_hand", "blunt_club", "spear", "staff_long" }.RandomItem();
198 num = ings[1].material.id;
199 break;
200 }
201 }
202 bool flag3 = EClass.sources.cards.map[key].tag.Contains("static_craft");
203 if (!isDish && num4 < 1)
204 {
205 num4 = 1;
206 }
207 if (EClass.sources.cards.map[key].tag.Contains("noQuality"))
208 {
209 num4 = -1;
210 }
211 if (EClass.sources.cards.map[key].tag.Contains("noMaterialChange"))
212 {
213 num = -1;
214 }
215 if (flag3)
216 {
217 num3 = 0;
218 flag = false;
219 }
221 {
222 qualityBonus = num3,
223 rarity = (flag ? Rarity.Crude : Rarity.Normal)
224 });
225 Thing thing = (flag3 ? ThingGen.Create(key) : ThingGen.Create(key, num, num4));
226 if (thing.trait.CraftNum > 1)
227 {
228 thing.SetNum(thing.trait.CraftNum);
229 }
230 thing.idSkin = idSkin;
231 if (thing.IsEquipment && ings != null)
232 {
233 foreach (Thing ing2 in ings)
234 {
235 if (ing2.trait is TraitRune)
236 {
237 thing.AddRune(ing2);
238 if (!thing.HasElement(484))
239 {
240 thing.elements.SetBase(484, 1);
241 }
242 }
243 }
244 }
245 thing.Identify(show: false);
246 thing.isCrafted = true;
247 if (!flag3)
248 {
249 if (base.source.colorIng != 0)
250 {
251 thing.Dye(GetColorMaterial());
252 }
253 if (thing.IsContainer)
254 {
255 thing.RemoveThings();
256 thing.c_lockLv = 0;
257 }
258 }
259 thing.SetBlessedState(blessed);
260 if (!flag3)
261 {
262 if (isDish)
263 {
264 if (flag)
265 {
266 thing.ChangeMaterial("meat");
267 }
268 else
269 {
270 MakeDish(thing);
271 }
272 }
273 else
274 {
275 MixIngredients(thing);
276 }
277 if (isDish && flag2)
278 {
279 thing.decay = thing.MaxDecay + 1;
280 }
281 }
282 thing.trait.OnCrafted(this);
283 if (thing.IsAmmo && num2 < 0)
284 {
285 thing.SetEncLv(-num2 / 10);
286 }
287 if (model)
288 {
289 thing.SetNum(1);
290 return thing;
291 }
292 if (EClass.pc.held == null || !thing.TryStackTo(EClass.pc.held.Thing))
293 {
294 EClass.pc.HoldCard(thing);
295 }
296 if (sound)
297 {
298 thing.PlaySoundDrop(spatial: false);
299 }
300 Msg.Say("crafted", thing);
301 if (thing.Num > EClass.rnd(1000) || EClass.debug.enable)
302 {
304 }
305 if (isDish)
306 {
308 {
310 EClass.player.flags.canComupWithFoodRecipe = false;
311 }
312 if (flag && crafter != null && crafter.CanTriggerFire && EClass.rnd(4) == 0)
313 {
314 Point point = (crafter.ExistsOnMap ? crafter.owner.pos : EClass.pc.pos);
315 if (!point.cell.HasFire)
316 {
317 EClass._map.ModFire(point.x, point.z, 10);
318 }
319 }
320 }
321 return thing;
322 }
323
324 public void MakeDish(Thing t)
325 {
327 List<Thing> list = new List<Thing>();
328 foreach (Ingredient ingredient in ingredients)
329 {
330 list.Add(ingredient.thing);
331 }
333 Rand.SetSeed();
334 if (EClass.pc.HasElement(1658))
335 {
336 t.elements.SetBase(757, 1);
337 t.c_dateCooked = EClass.world.date.GetRaw() + (EClass.pc.Evalue(1658) - 1) * 48 * 60;
338 }
339 }
340
341 public void MixIngredients(Thing t)
342 {
344 List<Thing> list = new List<Thing>();
345 foreach (Ingredient ingredient in ingredients)
346 {
347 list.Add(ingredient.thing);
348 }
350 Rand.SetSeed();
351 }
352
353 public string GetIdFailDish()
354 {
355 return sourceCard.category switch
356 {
357 "meal_meat" => "fail_meat",
358 "meal_fish" => "fail_fish",
359 "meal_vegi" => "fail_vegi",
360 "meal_fruit" => "fail_fruit",
361 "meal_cake" => "fail_dough_cake",
362 "meal_bread" => "fail_dough_bread",
363 "meal_noodle" => "fail_noodle",
364 "meal_egg" => "fail_egg",
365 "meal_rice" => "fail_rice",
366 "meal_soup" => "fail_drink",
367 _ => "fail_dish",
368 };
369 }
370
371 public override void Build(TaskBuild task)
372 {
373 Card card = null;
374 if (task.target != null)
375 {
376 card = task.target;
377 }
378 else if (IngAsProduct)
379 {
380 if (task.resources.Count == 0)
381 {
382 Thing thing = ingredients[0].RefreshThing();
383 if (thing == null)
384 {
385 SE.Beep();
386 return;
387 }
388 Thing item = thing.Split(1);
389 task.resources.Add(item);
390 if (ingredients[0].thing.isDestroyed || ingredients[0].thing.ExistsOnMap)
391 {
392 ingredients[0].thing = null;
393 }
394 }
395 card = task.resources[0];
396 }
397 else if (sourceCard.isChara)
398 {
400 }
401 else
402 {
404 if (!card.IsUnique)
405 {
406 card.ChangeMaterial(GetMainMaterial());
407 }
408 if (base.source.colorIng != 0)
409 {
410 card.Dye(GetColorMaterial());
411 }
412 if (card.IsContainer)
413 {
414 card.RemoveThings();
415 }
416 foreach (Ingredient ingredient in ingredients)
417 {
418 if (ingredient.thing != null && ingredient.thing.HasElement(759))
419 {
420 card.elements.SetBase(759, ingredient.thing.Evalue(759));
421 }
422 }
423 }
424 Build(task.owner, card, task.pos, ingredients[0].mat, task.dir, task.altitude, task.bridgeHeight);
425 card.renderer.PlayAnime(AnimeID.Place);
426 }
427
428 public override void Build(Chara chara, Card t, Point pos, int mat, int dir, int altitude, int bridgeHeight)
429 {
430 if (mat == -1)
431 {
432 mat = 2;
433 }
434 EClass.pc.PlaySound(EClass.sources.materials.rows[mat].GetSoundImpact());
435 t.SetDir(dir);
436 t.idSkin = idSkin;
437 EClass._zone.AddCard(t, pos);
438 if (t.trait is TraitHouseBoard && ActionMode.Build.houseBoard != null)
439 {
440 (t.trait as TraitHouseBoard).data = IO.DeepCopy(ActionMode.Build.houseBoard.data);
441 }
442 t.SetPlaceState(PlaceState.installed, byPlayer: true);
443 t.altitude = altitude;
444 t.isPlayerCreation = true;
445 if (EClass._zone.idCurrentSubset != null)
446 {
447 t.isSubsetCard = true;
448 }
449 t.ignoreStackHeight = Input.GetKey(KeyCode.LeftControl);
450 if (ActionMode.Build.IsActive && t.trait.MaskOnBuild && EClass.debug.enable)
451 {
452 t.isMasked = true;
453 }
455 {
456 t.isRoofItem = true;
457 t.SetPlaceState(PlaceState.roaming);
458 }
459 t.ForeachPoint(delegate(Point p, bool main)
460 {
461 CheckBlock(p);
462 });
463 t.freePos = freePos;
464 if (freePos)
465 {
466 t.fx = fx;
467 t.fy = fy;
468 }
470 void CheckBlock(Point _pos)
471 {
472 if (_pos.cell.IsBlocked && _pos.HasChara)
473 {
474 foreach (Chara item in _pos.ListCharas().Copy())
475 {
476 chara.Kick(item, ignoreSelf: false, karmaLoss: false);
477 }
478 }
479 }
480 }
481
482 public override void OnChangeAltitude(int a)
483 {
484 Mold.altitude = a;
485 }
486
487 public override void Rotate()
488 {
489 Mold.Rotate();
490 _dir = Mold.dir;
491 if ((bool)BuildMenu.Instance)
492 {
494 }
495 }
496
497 public override void SetDir(int d)
498 {
499 Mold.dir = d;
500 base.SetDir(d);
501 }
502
503 public override void WriteNote(UINote n)
504 {
505 n.Clear();
506 if (!Mold.isChara)
507 {
509 }
510 n.Build();
511 }
512
513 public override Recipe Duplicate()
514 {
515 RecipeCard recipeCard = IO.DeepCopy(this);
516 recipeCard._mold = _mold;
517 return recipeCard;
518 }
519}
AnimeID
Definition: AnimeID.cs:2
BlessedState
Definition: BlessedState.cs:2
HitResult
Definition: HitResult.cs:2
PlaceState
Definition: PlaceState.cs:2
Rarity
Definition: Rarity.cs:2
new Chara owner
Definition: AIAct.cs:14
int altitude
Definition: AM_Build.cs:8
TraitHouseBoard houseBoard
Definition: AM_Build.cs:16
void Add(Act a, string s="")
Definition: ActPlan.cs:11
virtual bool IsRoofEditMode(Card c=null)
Definition: ActionMode.cs:311
static AM_Build Build
Definition: ActionMode.cs:49
virtual bool IsBuildMode
Definition: ActionMode.cs:181
static BuildMenu Instance
Definition: BuildMenu.cs:77
UIRecipeInfo info1
Definition: BuildMenu.cs:27
static void Set(CardBlueprint _bp)
void RefreshSprite()
bool isChara
Definition: CardRow.cs:55
string id
Definition: CardRow.cs:7
Definition: Card.cs:11
bool isDestroyed
Definition: Card.cs:71
bool IsDecayed
Definition: Card.cs:2147
virtual bool isThing
Definition: Card.cs:1957
bool IsAmmo
Definition: Card.cs:2107
SocketData AddRune(Card rune)
Definition: Card.cs:3345
Thing Split(int a)
Definition: Card.cs:3231
void SetPlaceState(PlaceState newState, bool byPlayer=false)
Definition: Card.cs:3454
ElementContainerCard elements
Definition: Card.cs:37
bool HasElement(int ele, int req=1)
Definition: Card.cs:5214
float fy
Definition: Card.cs:250
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:5404
Card ChangeMaterial(int idNew, bool ignoreFixedMaterial=false)
Definition: Card.cs:2838
virtual void SetDir(int d)
Definition: Card.cs:5460
float fx
Definition: Card.cs:238
Thing SetNum(int a)
Definition: Card.cs:3242
void ForeachPoint(Action< Point, bool > action)
Definition: Card.cs:6942
virtual void SetBlessedState(BlessedState s)
Definition: Card.cs:3572
Point pos
Definition: Card.cs:55
void RenderMarker(Point point, bool active, HitResult result, bool main, int dir, bool useCurrentPosition=false)
Definition: Card.cs:5552
void Dye(string idMat)
Definition: Card.cs:5267
Trait trait
Definition: Card.cs:49
bool IsEquipment
Definition: Card.cs:2049
void SetEncLv(int a)
Definition: Card.cs:3567
void Destroy()
Definition: Card.cs:4538
virtual void Rotate(bool reverse=false)
Definition: Card.cs:5479
void SetFreePos(Point point)
Definition: Card.cs:5528
virtual bool isChara
Definition: Card.cs:1959
virtual Thing Thing
Definition: Card.cs:1934
int turn
Definition: Card.cs:61
int Evalue(int ele)
Definition: Card.cs:2431
void PlaySoundDrop(bool spatial=true)
Definition: Card.cs:5389
int dir
Definition: Card.cs:142
bool TryStackTo(Thing to)
Definition: Card.cs:3144
int Num
Definition: Card.cs:154
SourceCategory.Row category
Definition: Card.cs:1925
bool IsContainer
Definition: Card.cs:1965
bool freePos
Definition: Card.cs:490
CardRenderer renderer
Definition: Card.cs:57
int LV
Definition: Card.cs:370
void RemoveThings()
Definition: Card.cs:3056
bool IsBlocked
Definition: Cell.cs:895
bool skipRender
Definition: Cell.cs:270
bool HasFire
Definition: Cell.cs:676
static Chara Create(string id, int lv=-1)
Definition: CharaGen.cs:17
Definition: Chara.cs:10
Card held
Definition: Chara.cs:67
void HoldCard(Card t, int num=-1)
Definition: Chara.cs:4084
void Kick(Point p, bool ignoreSelf=false)
Definition: Chara.cs:5174
bool godCraft
Definition: CoreDebug.cs:180
bool enable
Definition: CoreDebug.cs:285
Game game
Definition: Core.cs:72
bool IsGameStarted
Definition: Core.cs:84
static void MakeDish(Thing food, int lv, Chara crafter=null)
Definition: CraftUtil.cs:54
static Thing MixIngredients(string idProduct, List< Thing > ings, MixType type, int idMat=0, Chara crafter=null)
Definition: CraftUtil.cs:132
int GetRaw(int offsetHours=0)
Definition: Date.cs:322
Definition: EClass.cs:5
static Scene scene
Definition: EClass.cs:30
static int rnd(int a)
Definition: EClass.cs:50
static Core core
Definition: EClass.cs:6
static Zone _zone
Definition: EClass.cs:20
static World world
Definition: EClass.cs:40
static Map _map
Definition: EClass.cs:18
static SourceManager sources
Definition: EClass.cs:42
static Player player
Definition: EClass.cs:12
static Chara pc
Definition: EClass.cs:14
static CoreDebug debug
Definition: EClass.cs:48
void AddNote(UINote n, Func< Element, bool > isValid=null, Action onAdd=null, NoteMode mode=NoteMode.Default, bool addRaceFeat=false, Func< Element, string, string > funcText=null, Action< UINote, Element > onAddNote=null)
Element SetBase(string alias, int v, int potential=0)
int id
Definition: ELEMENT.cs:240
SourceElement.Row source
Definition: ELEMENT.cs:263
bool isLoading
Definition: Game.cs:235
void ModFire(int x, int z, int amount)
Definition: Map.cs:1166
Definition: Msg.cs:5
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
bool canComupWithFoodRecipe
Definition: Player.cs:294
Flags flags
Definition: Player.cs:895
RecipeManager recipes
Definition: Player.cs:898
Definition: Point.cs:9
int x
Definition: Point.cs:36
int z
Definition: Point.cs:39
List< Chara > ListCharas()
Definition: Point.cs:1135
Cell cell
Definition: Point.cs:51
bool HasChara
Definition: Point.cs:226
Definition: Rand.cs:4
static void SetSeed(int a=-1)
Definition: Rand.cs:37
float fy
Definition: RecipeCard.cs:16
override void WriteNote(UINote n)
Definition: RecipeCard.cs:503
void MixIngredients(Thing t)
Definition: RecipeCard.cs:341
override Card Mold
Definition: RecipeCard.cs:32
bool isDish
Definition: RecipeCard.cs:34
override void BuildIngredientList()
Definition: RecipeCard.cs:65
CardRow _sourceCard
Definition: RecipeCard.cs:7
override TileType tileType
Definition: RecipeCard.cs:24
override bool IsThing
Definition: RecipeCard.cs:30
override void OnChangeAltitude(int a)
Definition: RecipeCard.cs:482
string GetIdFailDish()
Definition: RecipeCard.cs:353
float fx
Definition: RecipeCard.cs:13
override void Build(TaskBuild task)
Definition: RecipeCard.cs:371
override void OnRenderMarker(Point point, bool active, HitResult result, bool main, int dir, int bridgeHeight)
Definition: RecipeCard.cs:51
override void Build(Chara chara, Card t, Point pos, int mat, int dir, int altitude, int bridgeHeight)
Definition: RecipeCard.cs:428
Card _mold
Definition: RecipeCard.cs:18
override string GetIdThing()
Definition: RecipeCard.cs:46
CardRow sourceCard
Definition: RecipeCard.cs:20
override Thing Craft(BlessedState blessed, bool sound=false, List< Thing > ings=null, TraitCrafter crafter=null, bool model=false)
Definition: RecipeCard.cs:145
override Recipe Duplicate()
Definition: RecipeCard.cs:513
override string GetDetail()
Definition: RecipeCard.cs:41
override RenderRow renderRow
Definition: RecipeCard.cs:22
override void Rotate()
Definition: RecipeCard.cs:487
Card CreateMold()
Definition: RecipeCard.cs:113
override void OnSelected()
Definition: RecipeCard.cs:108
override bool CanRotate
Definition: RecipeCard.cs:28
string idCard
Definition: RecipeCard.cs:26
override void OnChangeIngredient()
Definition: RecipeCard.cs:96
bool freePos
Definition: RecipeCard.cs:10
void MakeDish(Thing t)
Definition: RecipeCard.cs:324
override void SetDir(int d)
Definition: RecipeCard.cs:497
override IRenderer GetRenderer()
Definition: RecipeCard.cs:36
void ComeUpWithRandomRecipe(string idCat=null, int lvBonus=0)
Definition: Recipe.cs:7
string id
Definition: Recipe.cs:161
List< Ingredient > ingredients
Definition: Recipe.cs:164
virtual SourceMaterial.Row GetMainMaterial()
Definition: Recipe.cs:467
int GetQualityBonus()
Definition: Recipe.cs:380
bool UseStock
Definition: Recipe.cs:167
int _dir
Definition: Recipe.cs:175
int idSkin
Definition: Recipe.cs:181
virtual SourceMaterial.Row GetColorMaterial()
Definition: Recipe.cs:481
bool IngAsProduct
Definition: Recipe.cs:170
string[] tag
Definition: RenderRow.cs:58
ActionMode actionMode
Definition: Scene.cs:77
Dictionary< string, CardRow > map
Definition: SourceCard.cs:8
string GetDetail()
Definition: SourceData.cs:543
SourceMaterial materials
SourceCard cards
string idCurrentSubset
Definition: Spatial.cs:28
int altitude
Definition: TaskBuild.cs:17
Card target
Definition: TaskBuild.cs:35
int bridgeHeight
Definition: TaskBuild.cs:14
int dir
Definition: TaskBuild.cs:11
List< Thing > resources
Definition: TaskBuild.cs:20
Point pos
Definition: TaskPoint.cs:11
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: Thing.cs:8
Thing Identify(bool show=true, IDTSource idtSource=IDTSource.Identify)
Definition: Thing.cs:1959
virtual bool CanRotate(bool buildMode)
Definition: TileType.cs:282
virtual int CraftNum
Definition: Trait.cs:127
virtual void OnCrafted(Recipe recipe)
Definition: Trait.cs:614
virtual void OnRenderTile(Point point, HitResult result, int dir)
Definition: Trait.cs:655
virtual TileType tileType
Definition: Trait.cs:48
virtual bool MaskOnBuild
Definition: Trait.cs:169
Definition: UINote.cs:6
void Clear()
Definition: UINote.cs:35
void Build()
Definition: UINote.cs:49
void OnRotate()
GameDate date
Definition: World.cs:6
override int DangerLv
Definition: Zone.cs:107
Card AddCard(Card t, Point point)
Definition: Zone.cs:1893