Elin Modding Docs Doc
Loading...
Searching...
No Matches
TraitCrafter.cs
1using System;
2using System.Collections.Generic;
3using System.Runtime.CompilerServices;
4using UnityEngine;
5
6// Token: 0x020003D1 RID: 977
7public class TraitCrafter : Trait
8{
9 // Token: 0x17000894 RID: 2196
10 // (get) Token: 0x06001C7B RID: 7291 RVA: 0x000A9CB1 File Offset: 0x000A7EB1
11 public override bool ShowFuelWindow
12 {
13 get
14 {
15 return false;
16 }
17 }
18
19 // Token: 0x17000895 RID: 2197
20 // (get) Token: 0x06001C7C RID: 7292 RVA: 0x000A9CB4 File Offset: 0x000A7EB4
21 public virtual Emo Icon
22 {
23 get
24 {
25 return Emo.none;
26 }
27 }
28
29 // Token: 0x17000896 RID: 2198
30 // (get) Token: 0x06001C7D RID: 7293 RVA: 0x000A9CB7 File Offset: 0x000A7EB7
31 public virtual int numIng
32 {
33 get
34 {
35 return 1;
36 }
37 }
38
39 // Token: 0x17000897 RID: 2199
40 // (get) Token: 0x06001C7E RID: 7294 RVA: 0x000A9CBA File Offset: 0x000A7EBA
41 public virtual string IdSource
42 {
43 get
44 {
45 return "";
46 }
47 }
48
49 // Token: 0x17000898 RID: 2200
50 // (get) Token: 0x06001C7F RID: 7295 RVA: 0x000A9CC1 File Offset: 0x000A7EC1
51 public virtual TraitCrafter.AnimeType animeType
52 {
53 get
54 {
55 return TraitCrafter.AnimeType.Default;
56 }
57 }
58
59 // Token: 0x17000899 RID: 2201
60 // (get) Token: 0x06001C80 RID: 7296 RVA: 0x000A9CC4 File Offset: 0x000A7EC4
61 public virtual AnimeID IdAnimeProgress
62 {
63 get
64 {
65 return AnimeID.HitObj;
66 }
67 }
68
69 // Token: 0x1700089A RID: 2202
70 // (get) Token: 0x06001C81 RID: 7297 RVA: 0x000A9CC7 File Offset: 0x000A7EC7
71 public virtual string idSoundProgress
72 {
73 get
74 {
75 return "";
76 }
77 }
78
79 // Token: 0x1700089B RID: 2203
80 // (get) Token: 0x06001C82 RID: 7298 RVA: 0x000A9CCE File Offset: 0x000A7ECE
81 public virtual string idSoundComplete
82 {
83 get
84 {
85 return null;
86 }
87 }
88
89 // Token: 0x1700089C RID: 2204
90 // (get) Token: 0x06001C83 RID: 7299 RVA: 0x000A9CD1 File Offset: 0x000A7ED1
91 public virtual bool StopSoundProgress
92 {
93 get
94 {
95 return false;
96 }
97 }
98
99 // Token: 0x1700089D RID: 2205
100 // (get) Token: 0x06001C84 RID: 7300 RVA: 0x000A9CD4 File Offset: 0x000A7ED4
101 public override bool IsNightOnlyLight
102 {
103 get
104 {
105 return false;
106 }
107 }
108
109 // Token: 0x1700089E RID: 2206
110 // (get) Token: 0x06001C85 RID: 7301 RVA: 0x000A9CD7 File Offset: 0x000A7ED7
111 public virtual bool CanUseFromInventory
112 {
113 get
114 {
115 return false;
116 }
117 }
118
119 // Token: 0x1700089F RID: 2207
120 // (get) Token: 0x06001C86 RID: 7302 RVA: 0x000A9CDA File Offset: 0x000A7EDA
121 public virtual string idSoundBG
122 {
123 get
124 {
125 return null;
126 }
127 }
128
129 // Token: 0x170008A0 RID: 2208
130 // (get) Token: 0x06001C87 RID: 7303 RVA: 0x000A9CDD File Offset: 0x000A7EDD
131 public virtual string CrafterTitle
132 {
133 get
134 {
135 return "";
136 }
137 }
138
139 // Token: 0x170008A1 RID: 2209
140 // (get) Token: 0x06001C88 RID: 7304 RVA: 0x000A9CE4 File Offset: 0x000A7EE4
141 public virtual bool AutoTurnOff
142 {
143 get
144 {
145 return false;
146 }
147 }
148
149 // Token: 0x170008A2 RID: 2210
150 // (get) Token: 0x06001C89 RID: 7305 RVA: 0x000A9CE7 File Offset: 0x000A7EE7
151 public virtual bool IsConsumeIng
152 {
153 get
154 {
155 return true;
156 }
157 }
158
159 // Token: 0x170008A3 RID: 2211
160 // (get) Token: 0x06001C8A RID: 7306 RVA: 0x000A9CEA File Offset: 0x000A7EEA
161 public virtual bool CloseOnComplete
162 {
163 get
164 {
165 return false;
166 }
167 }
168
169 // Token: 0x170008A4 RID: 2212
170 // (get) Token: 0x06001C8B RID: 7307 RVA: 0x000A9CED File Offset: 0x000A7EED
171 public virtual int CostSP
172 {
173 get
174 {
175 return 1;
176 }
177 }
178
179 // Token: 0x06001C8C RID: 7308 RVA: 0x000A9CF0 File Offset: 0x000A7EF0
180 public virtual string IDReqEle(RecipeSource r)
181 {
182 return base.GetParam(1, null) ?? "handicraft";
183 }
184
185 // Token: 0x06001C8D RID: 7309 RVA: 0x000A9D04 File Offset: 0x000A7F04
186 public virtual bool IsCraftIngredient(Card c, int idx)
187 {
188 foreach (SourceRecipe.Row r in EClass.sources.recipes.rows)
189 {
190 if (idx == 1)
191 {
192 Card card = LayerDragGrid.Instance.buttons[0].Card;
193 if (!this.IsIngredient(0, r, card) || (card == c && card.Num < 2))
194 {
195 continue;
196 }
197 }
198 if (this.IsIngredient(idx, r, c))
199 {
200 return true;
201 }
202 }
203 return false;
204 }
205
206 // Token: 0x06001C8E RID: 7310 RVA: 0x000A9DA0 File Offset: 0x000A7FA0
207 public bool IsIngredient(int idx, SourceRecipe.Row r, Card c)
208 {
209 if (r.factory != this.IdSource || c == null)
210 {
211 return false;
212 }
213 if (c.c_isImportant && this.ShouldConsumeIng(r, idx))
214 {
215 return false;
216 }
217 string[] array = (idx == 0) ? r.ing1 : r.ing2;
218 if (r.type.ToEnum(true) == TraitCrafter.MixType.Grind && idx == 1)
219 {
220 if (r.tag.Contains("rust") && c.encLV >= 0)
221 {
222 return false;
223 }
224 if (r.tag.Contains("mod_eject"))
225 {
226 if (c.sockets == null)
227 {
228 return false;
229 }
230 bool flag = false;
231 using (List<int>.Enumerator enumerator = c.sockets.GetEnumerator())
232 {
233 while (enumerator.MoveNext())
234 {
235 if (enumerator.Current != 0)
236 {
237 flag = true;
238 }
239 }
240 }
241 if (!flag)
242 {
243 return false;
244 }
245 }
246 }
247 foreach (string text in array)
248 {
249 if (r.tag.Contains("noCarbone") && c.material.alias == "carbone")
250 {
251 return false;
252 }
253 if (text.StartsWith('#'))
254 {
255 string text2 = text.Replace("#", "");
256 if (c.category.IsChildOf(text2) && this.IsIngredient(text2, c))
257 {
258 return true;
259 }
260 }
261 else
262 {
263 string[] array3 = text.Split('@', StringSplitOptions.None);
264 if (array3.Length > 1)
265 {
266 if (c.id != array3[0] && c.sourceCard._origin != array3[0])
267 {
268 return false;
269 }
270 SourceChara.Row row = c.refCard as SourceChara.Row;
271 if (row != null && row.race_row.tag.Contains(array3[1]))
272 {
273 return true;
274 }
275 if (c.material.tag.Contains(array3[1]))
276 {
277 return true;
278 }
279 }
280 else
281 {
282 if (text == "any" && !c.IsUnique && !c.IsImportant && !c.trait.CanOnlyCarry)
283 {
284 return true;
285 }
286 if (c.id == text || c.sourceCard._origin == text)
287 {
288 return true;
289 }
290 }
291 }
292 }
293 return false;
294 }
295
296 // Token: 0x06001C8F RID: 7311 RVA: 0x000A9FDC File Offset: 0x000A81DC
297 public virtual bool IsIngredient(string cat, Card c)
298 {
299 return true;
300 }
301
302 // Token: 0x06001C90 RID: 7312 RVA: 0x000A9FE0 File Offset: 0x000A81E0
303 public int GetSortVal(SourceRecipe.Row r)
304 {
305 int num = r.id;
306 string[] ing = r.ing1;
307 for (int i = 0; i < ing.Length; i++)
308 {
309 if (ing[i].Contains('@'))
310 {
311 num -= 10000;
312 }
313 }
314 return num;
315 }
316
317 // Token: 0x06001C91 RID: 7313 RVA: 0x000AA01E File Offset: 0x000A821E
318 public virtual int GetDuration(AI_UseCrafter ai, int costSp)
319 {
320 int a = 1;
321 int num = this.GetSource(ai).time * 100;
322 int num2 = 80;
323 Card pc = EClass.pc;
324 Recipe recipe = ai.recipe;
325 return Mathf.Max(a, num / (num2 + pc.Evalue(this.IDReqEle((recipe != null) ? recipe.source : null)) * 5));
326 }
327
328 // Token: 0x06001C92 RID: 7314 RVA: 0x000AA05D File Offset: 0x000A825D
329 public virtual int GetCostSp(AI_UseCrafter ai)
330 {
331 return this.GetSource(ai).sp;
332 }
333
334 // Token: 0x06001C93 RID: 7315 RVA: 0x000AA06C File Offset: 0x000A826C
335 public SourceRecipe.Row GetSource(AI_UseCrafter ai)
336 {
337 List<SourceRecipe.Row> list = new List<SourceRecipe.Row>();
338 foreach (SourceRecipe.Row row in EClass.sources.recipes.rows)
339 {
340 if (row.factory == this.IdSource)
341 {
342 list.Add(row);
343 }
344 }
345 for (int i = 0; i < this.numIng; i++)
346 {
347 foreach (SourceRecipe.Row row2 in EClass.sources.recipes.rows)
348 {
349 if (i >= ai.ings.Count || !this.IsIngredient(i, row2, ai.ings[i]))
350 {
351 list.Remove(row2);
352 }
353 }
354 }
355 if (list.Count == 0)
356 {
357 return null;
358 }
359 list.Sort((SourceRecipe.Row a, SourceRecipe.Row b) => this.GetSortVal(a) - this.GetSortVal(b));
360 return list[0];
361 }
362
363 // Token: 0x06001C94 RID: 7316 RVA: 0x000AA188 File Offset: 0x000A8388
364 public virtual bool ShouldConsumeIng(SourceRecipe.Row item, int index)
365 {
366 if (this.IsFactory)
367 {
368 return true;
369 }
370 if (item == null)
371 {
372 return false;
373 }
374 int id = item.id;
375 return id - 47 > 1 || index == 0;
376 }
377
378 // Token: 0x06001C95 RID: 7317 RVA: 0x000AA1B8 File Offset: 0x000A83B8
379 public virtual Thing Craft(AI_UseCrafter ai)
380 {
381 Thing thing = ai.ings[0];
382 Thing thing2 = (this.numIng > 1) ? ai.ings[1] : null;
383 SourceRecipe.Row source = this.GetSource(ai);
384 if (source == null)
385 {
386 return null;
387 }
388 if (!EClass.player.knownCraft.Contains(source.id))
389 {
390 SE.Play("idea");
391 Msg.Say("newKnownCraft");
392 EClass.player.knownCraft.Add(source.id);
393 if (LayerDragGrid.Instance)
394 {
395 LayerDragGrid.Instance.info.Refresh();
396 }
397 }
398 string text = source.thing;
399 TraitCrafter.MixType mixType = source.type.ToEnum(true);
400 int num = source.num.Calc(0, 0, 0);
401 TraitCrafter.<>c__DisplayClass45_0 CS$<>8__locals1;
402 CS$<>8__locals1.t = null;
403 switch (mixType)
404 {
405 case TraitCrafter.MixType.Food:
406 CS$<>8__locals1.t = CraftUtil.MixIngredients(text, ai.ings, CraftUtil.MixType.General, 0);
407 break;
408 case TraitCrafter.MixType.Resource:
409 {
410 string[] array = text.Split('%', StringSplitOptions.None);
411 CS$<>8__locals1.t = CraftUtil.MixIngredients(ThingGen.Create(array[0], (array.Length > 1) ? EClass.sources.materials.alias[array[1]].id : thing.material.id, -1), ai.ings, CraftUtil.MixType.General, 999).Thing;
412 break;
413 }
414 case TraitCrafter.MixType.Dye:
415 CS$<>8__locals1.t = ThingGen.Create(text, thing2.material.id, -1);
416 break;
417 case TraitCrafter.MixType.Butcher:
418 text = SpawnListThing.Get("butcher", (SourceThing.Row a) => a.Category.id == "bodyparts").Select(-1, -1).id;
419 CS$<>8__locals1.t = ThingGen.Create(text, -1, -1);
420 break;
421 case TraitCrafter.MixType.Grind:
422 if (source.tag.Contains("rust"))
423 {
424 EClass.pc.Say("polish", EClass.pc, ai.ings[1], null, null);
425 ai.ings[1].ModEncLv(1);
426 ai.ings[0].ModNum(-1, true);
427 }
428 if (source.tag.Contains("mod_eject"))
429 {
430 ai.ings[1].EjectSockets();
431 ai.ings[0].ModNum(-1, true);
432 }
433 break;
434 case TraitCrafter.MixType.Sculpture:
435 {
436 CS$<>8__locals1.t = ThingGen.Create(text, -1, -1);
437 List<CardRow> list = EClass.player.codex.ListKills();
438 list.Add(EClass.sources.cards.map["putty"]);
439 list.Add(EClass.sources.cards.map["snail"]);
440 CardRow cardRow = list.RandomItemWeighted((CardRow a) => (float)Mathf.Max(50 - a.LV, 1));
441 CS$<>8__locals1.t.c_idRefCard = cardRow.id;
442 CS$<>8__locals1.t.ChangeMaterial(thing.material);
443 CS$<>8__locals1.t.SetEncLv(Mathf.Min(EClass.rnd(EClass.rnd(Mathf.Max(5 + EClass.pc.Evalue(258) - cardRow.LV, 1))), 12));
444 CS$<>8__locals1.t = CraftUtil.MixIngredients(CS$<>8__locals1.t, ai.ings, CraftUtil.MixType.General, 999).Thing;
445 break;
446 }
447 case TraitCrafter.MixType.Talisman:
448 {
449 int num2 = EClass.pc.Evalue(1418);
450 Thing thing3 = ai.ings[1];
451 SourceElement.Row source2 = (thing3.trait as TraitSpellbook).source;
452 int num3 = thing3.c_charges * source2.charge * (100 + num2 * 50) / 500 + 1;
453 int num4 = 100;
454 Thing thing4 = ThingGen.Create("talisman", -1, -1).SetNum(num3);
455 thing4.refVal = source2.id;
456 thing4.encLV = num4 * (100 + num2 * 10) / 100;
457 thing.ammoData = thing4;
458 thing.c_ammo = num3;
459 EClass.pc.Say("talisman", thing, thing4, null, null);
460 thing3.Destroy();
461 break;
462 }
463 case TraitCrafter.MixType.Scratch:
464 {
465 TraitCrafter.<>c__DisplayClass45_1 CS$<>8__locals2;
466 CS$<>8__locals2.claimed = false;
467 TraitCrafter.<Craft>g__Prize|45_2(20, "medal", "save", false, ref CS$<>8__locals1, ref CS$<>8__locals2);
468 TraitCrafter.<Craft>g__Prize|45_2(10, "plat", "save", false, ref CS$<>8__locals1, ref CS$<>8__locals2);
469 TraitCrafter.<Craft>g__Prize|45_2(10, "furniture", "nice", true, ref CS$<>8__locals1, ref CS$<>8__locals2);
470 TraitCrafter.<Craft>g__Prize|45_2(4, "plamo_box", "nice", false, ref CS$<>8__locals1, ref CS$<>8__locals2);
471 TraitCrafter.<Craft>g__Prize|45_2(4, "food", "", false, ref CS$<>8__locals1, ref CS$<>8__locals2);
472 TraitCrafter.<Craft>g__Prize|45_2(1, "casino_coin", "", false, ref CS$<>8__locals1, ref CS$<>8__locals2);
473 break;
474 }
475 case TraitCrafter.MixType.Incubator:
476 TraitFoodEggFertilized.Incubate(ai.ings[0], this.owner.pos, this.owner);
477 break;
478 default:
479 CS$<>8__locals1.t = ThingGen.Create(text, -1, -1);
480 if (text == "gene")
481 {
482 if (ai.ings[0].c_DNA != null)
483 {
484 CS$<>8__locals1.t.MakeRefFrom(ai.ings[0].c_idRefCard);
485 CS$<>8__locals1.t.c_DNA = ai.ings[0].c_DNA;
486 CS$<>8__locals1.t.c_DNA.GenerateWithGene(DNA.Type.Inferior, CS$<>8__locals1.t, null);
487 }
488 }
489 else
490 {
491 CS$<>8__locals1.t = CraftUtil.MixIngredients(CS$<>8__locals1.t, ai.ings, CraftUtil.MixType.General, 999).Thing;
492 }
493 break;
494 }
495 if (CS$<>8__locals1.t != null)
496 {
497 if (CS$<>8__locals1.t.HasElement(1229, 1))
498 {
499 num = 1;
500 }
501 if (CS$<>8__locals1.t.HasElement(704, 1))
502 {
503 num = 1;
504 }
505 if (CS$<>8__locals1.t.HasElement(703, 1))
506 {
507 num = 1;
508 }
509 CS$<>8__locals1.t.SetNum(num);
510 }
511 return CS$<>8__locals1.t;
512 }
513
514 // Token: 0x06001C96 RID: 7318 RVA: 0x000AA7BC File Offset: 0x000A89BC
515 public override void TrySetAct(ActPlan p)
516 {
517 if (this is TraitFactory)
518 {
519 return;
520 }
521 if (this is TraitIncubator && !EClass._zone.IsPCFaction)
522 {
523 return;
524 }
525 p.TrySetAct(this.CrafterTitle, delegate()
526 {
527 LayerDragGrid.CreateCraft(this);
528 return false;
529 }, this.owner, null, 1, false, true, false);
530 }
531
532 // Token: 0x06001C97 RID: 7319 RVA: 0x000AA80B File Offset: 0x000A8A0B
533 public override bool CanUse(Chara c)
534 {
535 return this.CanUseFromInventory;
536 }
537
538 // Token: 0x06001C98 RID: 7320 RVA: 0x000AA813 File Offset: 0x000A8A13
539 public override bool OnUse(Chara c)
540 {
541 LayerDragGrid.CreateCraft(this);
542 return false;
543 }
544
545 // Token: 0x06001C9B RID: 7323 RVA: 0x000AA838 File Offset: 0x000A8A38
546 [CompilerGenerated]
547 internal static void <Craft>g__Prize|45_2(int chance, string s, string col, bool cat, ref TraitCrafter.<>c__DisplayClass45_0 A_4, ref TraitCrafter.<>c__DisplayClass45_1 A_5)
548 {
549 if (A_5.claimed || EClass.rnd(chance) != 0)
550 {
551 return;
552 }
553 A_4.t = (cat ? ThingGen.CreateFromCategory(s, EClass.pc.LV) : ThingGen.Create(s, -1, EClass.pc.LV));
554 A_5.claimed = true;
555 if (col != "")
556 {
557 Msg.SetColor(col);
558 }
559 }
560
561 // Token: 0x020009AB RID: 2475
562 public enum MixType
563 {
564 // Token: 0x0400283E RID: 10302
565 None,
566 // Token: 0x0400283F RID: 10303
567 Food,
568 // Token: 0x04002840 RID: 10304
569 Resource,
570 // Token: 0x04002841 RID: 10305
571 Dye,
572 // Token: 0x04002842 RID: 10306
573 Butcher,
574 // Token: 0x04002843 RID: 10307
575 Grind,
576 // Token: 0x04002844 RID: 10308
577 Sculpture,
578 // Token: 0x04002845 RID: 10309
579 Talisman,
580 // Token: 0x04002846 RID: 10310
581 Scratch,
582 // Token: 0x04002847 RID: 10311
583 Incubator
584 }
585
586 // Token: 0x020009AC RID: 2476
587 public enum AnimeType
588 {
589 // Token: 0x04002849 RID: 10313
590 Default,
591 // Token: 0x0400284A RID: 10314
592 Microwave,
593 // Token: 0x0400284B RID: 10315
594 Pot
595 }
596}
Definition Card.cs:13
Definition Chara.cs:12
Definition DNA.cs:9
Definition Msg.cs:7
Definition Thing.cs:10
Definition Trait.cs:9