Elin Modding Docs Doc
Loading...
Searching...
No Matches
SourceMaterial.cs
1using System;
2using System.Collections.Generic;
3using System.Runtime.CompilerServices;
4using UnityEngine;
5
6// Token: 0x02000022 RID: 34
7public class SourceMaterial : SourceDataInt<SourceMaterial.Row>
8{
9 // Token: 0x0600012A RID: 298 RVA: 0x0000B914 File Offset: 0x00009B14
10 public override SourceMaterial.Row CreateRow()
11 {
12 return new SourceMaterial.Row
13 {
14 id = SourceData.GetInt(0),
15 alias = SourceData.GetString(1),
16 name_JP = SourceData.GetString(2),
17 name = SourceData.GetString(3),
18 category = SourceData.GetString(4),
19 tag = SourceData.GetStringArray(5),
20 thing = SourceData.GetString(6),
21 goods = SourceData.GetStringArray(7),
22 minerals = SourceData.GetStringArray(8),
23 decal = SourceData.GetInt(9),
24 decay = SourceData.GetInt(10),
25 grass = SourceData.GetInt(11),
26 defFloor = SourceData.GetInt(12),
27 defBlock = SourceData.GetInt(13),
28 edge = SourceData.GetInt(14),
29 ramp = SourceData.GetInt(15),
30 idSound = SourceData.GetString(16),
31 soundFoot = SourceData.GetString(17),
32 hardness = SourceData.GetInt(18),
33 groups = SourceData.GetStringArray(19),
34 tier = SourceData.GetInt(20),
35 chance = SourceData.GetInt(21),
36 weight = SourceData.GetInt(22),
37 value = SourceData.GetInt(23),
38 quality = SourceData.GetInt(24),
39 atk = SourceData.GetInt(25),
40 dmg = SourceData.GetInt(26),
41 dv = SourceData.GetInt(27),
42 pv = SourceData.GetInt(28),
43 dice = SourceData.GetInt(29),
44 bits = SourceData.GetStringArray(30),
45 elements = Core.ParseElements(SourceData.GetStr(31, false)),
46 altName = SourceData.GetStringArray(32),
47 altName_JP = SourceData.GetStringArray(33)
48 };
49 }
50
51 // Token: 0x0600012B RID: 299 RVA: 0x0000BADD File Offset: 0x00009CDD
52 public override void SetRow(SourceMaterial.Row r)
53 {
54 this.map[r.id] = r;
55 }
56
57 // Token: 0x0600012C RID: 300 RVA: 0x0000BAF4 File Offset: 0x00009CF4
58 public override void OnInit()
59 {
60 Cell.matList = this.rows;
61 SourceMaterial.tierMap.Clear();
62 SourceMaterial.tierMap.Add("gem", new SourceMaterial.TierList());
63 SourceMaterial.tierMap.Add("ore", new SourceMaterial.TierList());
64 foreach (SourceMaterial.Row row in this.rows)
65 {
66 row.Init();
67 row.elementMap = Element.GetElementMap(row.elements);
68 if (!row.groups.IsEmpty())
69 {
70 foreach (string key in row.groups)
71 {
72 SourceMaterial.TierList tierList = SourceMaterial.tierMap.TryGetValue(key, null);
73 if (tierList == null)
74 {
75 tierList = new SourceMaterial.TierList();
76 SourceMaterial.tierMap[key] = tierList;
77 }
78 SourceMaterial.Tier tier = tierList.tiers[row.tier];
79 tier.list.Add(row);
80 tier.sum += row.chance;
81 }
82 }
83 string category = row.category;
84 if (!(category == "gem"))
85 {
86 if (category == "ore")
87 {
88 SourceMaterial.Tier tier2 = SourceMaterial.tierMap["ore"].tiers[row.tier];
89 tier2.list.Add(row);
90 tier2.sum += row.chance;
91 }
92 }
93 else
94 {
95 SourceMaterial.Tier tier3 = SourceMaterial.tierMap["gem"].tiers[row.tier];
96 tier3.list.Add(row);
97 tier3.sum += row.chance;
98 }
99 }
100 }
101
102 // Token: 0x0600012D RID: 301 RVA: 0x0000BCBC File Offset: 0x00009EBC
103 public override void OnAfterImportData()
104 {
105 this.rows.Sort((SourceMaterial.Row a, SourceMaterial.Row b) => a.id - b.id);
106 }
107
108 // Token: 0x0600012E RID: 302 RVA: 0x0000BCE8 File Offset: 0x00009EE8
109 public void OnImportRow(SourceMaterial.Row r)
110 {
111 SourceMaterial.<>c__DisplayClass8_0 CS$<>8__locals1;
112 CS$<>8__locals1.list = new List<int>(r.elements);
113 for (int i = 0; i < r.elements.Length; i += 2)
114 {
115 SourceMaterial.<OnImportRow>g__Add|8_0(r.elements[i], r.elements[i + 1], ref CS$<>8__locals1);
116 }
117 SourceMaterial.<OnImportRow>g__Add|8_0(13, r.hardness, ref CS$<>8__locals1);
118 r.elements = CS$<>8__locals1.list.ToArray();
119 }
120
121 // Token: 0x17000036 RID: 54
122 // (get) Token: 0x0600012F RID: 303 RVA: 0x0000BD53 File Offset: 0x00009F53
123 public override string[] ImportFields
124 {
125 get
126 {
127 return new string[]
128 {
129 "altName"
130 };
131 }
132 }
133
134 // Token: 0x06000132 RID: 306 RVA: 0x0000BD77 File Offset: 0x00009F77
135 [CompilerGenerated]
136 internal static void <OnImportRow>g__Add|8_0(int ele, int a, ref SourceMaterial.<>c__DisplayClass8_0 A_2)
137 {
138 A_2.list.Add(ele);
139 A_2.list.Add(a);
140 }
141
142 // Token: 0x040000DB RID: 219
143 public static Dictionary<string, SourceMaterial.TierList> tierMap = new Dictionary<string, SourceMaterial.TierList>();
144
145 // Token: 0x020007A5 RID: 1957
146 [Serializable]
147 public class Row : SourceData.BaseRow
148 {
149 // Token: 0x170010E9 RID: 4329
150 // (get) Token: 0x06003756 RID: 14166 RVA: 0x0012AA1D File Offset: 0x00128C1D
151 public override bool UseAlias
152 {
153 get
154 {
155 return true;
156 }
157 }
158
159 // Token: 0x170010EA RID: 4330
160 // (get) Token: 0x06003757 RID: 14167 RVA: 0x0012AA20 File Offset: 0x00128C20
161 public override string GetAlias
162 {
163 get
164 {
165 return this.alias;
166 }
167 }
168
169 // Token: 0x06003758 RID: 14168 RVA: 0x0012AA28 File Offset: 0x00128C28
170 public override void OnImportData(SourceData data)
171 {
172 base.OnImportData(data);
173 this.SetTiles();
174 }
175
176 // Token: 0x06003759 RID: 14169 RVA: 0x0012AA38 File Offset: 0x00128C38
177 public void Init()
178 {
179 MatColors matColors = Core.Instance.Colors.matColors.TryGetValue(this.alias, null);
180 this.matColor = matColors.main;
181 this.altColor = matColors.alt;
182 this.SetTiles();
183 }
184
185 // Token: 0x0600375A RID: 14170 RVA: 0x0012AA7F File Offset: 0x00128C7F
186 public void SetTiles()
187 {
188 }
189
190 // Token: 0x0600375B RID: 14171 RVA: 0x0012AA84 File Offset: 0x00128C84
191 public void AddBlood(Point p, int a = 1)
192 {
193 if (this.decal == 0)
194 {
195 return;
196 }
197 if (p.cell.IsSnowTile && this != MATERIAL.sourceSnow)
198 {
199 MATERIAL.sourceSnow.AddBlood(p, a);
200 return;
201 }
202 for (int i = 0; i < a; i++)
203 {
204 EClass._map.AddDecal(p.x + ((EClass.rnd(2) == 0) ? 0 : (EClass.rnd(3) - 1)), p.z + ((EClass.rnd(2) == 0) ? 0 : (EClass.rnd(3) - 1)), this.decal, 1, true);
205 }
206 }
207
208 // Token: 0x0600375C RID: 14172 RVA: 0x0012AB0E File Offset: 0x00128D0E
209 public void PlayHitEffect(Point p)
210 {
211 Effect.Get("mine2").Play(p, 0f, null, null).SetParticleColor(this.GetColor()).Emit(2 + EClass.rnd(4));
212 }
213
214 // Token: 0x0600375D RID: 14173 RVA: 0x0012AB40 File Offset: 0x00128D40
215 public Color GetColor()
216 {
217 return Core.Instance.Colors.matColors[this.alias].main;
218 }
219
220 // Token: 0x0600375E RID: 14174 RVA: 0x0012AB64 File Offset: 0x00128D64
221 public string TryGetSound(string suffx, RenderRow c = null)
222 {
223 string soundImpact = this.GetSoundImpact(c);
224 if (EClass.Sound.Exist(soundImpact + "_" + suffx))
225 {
226 return soundImpact + "_" + suffx;
227 }
228 return soundImpact;
229 }
230
231 // Token: 0x0600375F RID: 14175 RVA: 0x0012AB9F File Offset: 0x00128D9F
232 public string GetSoundDead(RenderRow c = null)
233 {
234 return this.TryGetSound("dead", c);
235 }
236
237 // Token: 0x06003760 RID: 14176 RVA: 0x0012ABAD File Offset: 0x00128DAD
238 public string GetSoundDrop(RenderRow c = null)
239 {
240 return this.TryGetSound("drop", c);
241 }
242
243 // Token: 0x06003761 RID: 14177 RVA: 0x0012ABBB File Offset: 0x00128DBB
244 public string GetSoundCraft(RenderRow c = null)
245 {
246 if (this.category == "wood")
247 {
248 return "build_progress";
249 }
250 return this.TryGetSound("craft", c);
251 }
252
253 // Token: 0x06003762 RID: 14178 RVA: 0x0012ABE1 File Offset: 0x00128DE1
254 public string GetSoundImpact(RenderRow c = null)
255 {
256 if (c != null && !c.idSound.IsEmpty())
257 {
258 return "Material/" + c.idSound;
259 }
260 return "Material/" + this.idSound;
261 }
262
263 // Token: 0x06003763 RID: 14179 RVA: 0x0012AC14 File Offset: 0x00128E14
264 public void CreateByProduct(Thing container, int num)
265 {
266 SourceMaterial.Row.<>c__DisplayClass52_0 CS$<>8__locals1;
267 CS$<>8__locals1.<>4__this = this;
268 CS$<>8__locals1.num = num;
269 CS$<>8__locals1.container = container;
270 Thing thing = ThingGen.CreateRawMaterial(this);
271 thing.ModNum(CS$<>8__locals1.num, true);
272 CS$<>8__locals1.container.AddThing(thing, true, -1, -1);
273 this.<CreateByProduct>g__C|52_0("dye", ref CS$<>8__locals1);
274 string text = this.category;
275 uint num2 = <PrivateImplementationDetails>.ComputeStringHash(text);
276 if (num2 <= 1167392201U)
277 {
278 if (num2 <= 270655681U)
279 {
280 if (num2 != 174734082U)
281 {
282 if (num2 == 270655681U)
283 {
284 if (text == "fiber")
285 {
286 this.<CreateByProduct>g__C|52_0("thread", ref CS$<>8__locals1);
287 this.<CreateByProduct>g__C|52_0("texture", ref CS$<>8__locals1);
288 this.<CreateByProduct>g__C|52_0("string", ref CS$<>8__locals1);
289 }
290 }
291 }
292 else if (text == "soil")
293 {
294 this.<CreateByProduct>g__C|52_0("glass", ref CS$<>8__locals1);
295 this.<CreateByProduct>g__C|52_0("clay", ref CS$<>8__locals1);
296 this.<CreateByProduct>g__C|52_0("brick", ref CS$<>8__locals1);
297 }
298 }
299 else if (num2 != 862676408U)
300 {
301 if (num2 != 974867124U)
302 {
303 if (num2 == 1167392201U)
304 {
305 if (text == "crystal")
306 {
307 this.<CreateByProduct>g__C|52_0("glass", ref CS$<>8__locals1);
308 this.<CreateByProduct>g__C|52_0("gem", ref CS$<>8__locals1);
309 }
310 }
311 }
312 else if (text == "rock")
313 {
314 this.<CreateByProduct>g__C|52_0("rock", ref CS$<>8__locals1);
315 this.<CreateByProduct>g__C|52_0("pebble", ref CS$<>8__locals1);
316 this.<CreateByProduct>g__C|52_0("cutstone", ref CS$<>8__locals1);
317 }
318 }
319 else if (text == "skin")
320 {
321 this.<CreateByProduct>g__C|52_0("texture", ref CS$<>8__locals1);
322 }
323 }
324 else if (num2 <= 1527558748U)
325 {
326 if (num2 != 1237752336U)
327 {
328 if (num2 == 1527558748U)
329 {
330 if (text == "gem")
331 {
332 this.<CreateByProduct>g__C|52_0("cutstone", ref CS$<>8__locals1);
333 this.<CreateByProduct>g__C|52_0("ingot", ref CS$<>8__locals1);
334 this.<CreateByProduct>g__C|52_0("gem", ref CS$<>8__locals1);
335 }
336 }
337 }
338 else if (!(text == "water"))
339 {
340 }
341 }
342 else if (num2 != 2226448744U)
343 {
344 if (num2 != 2585652531U)
345 {
346 if (num2 == 3683705231U)
347 {
348 if (text == "bone")
349 {
350 this.<CreateByProduct>g__C|52_0("glass", ref CS$<>8__locals1);
351 this.<CreateByProduct>g__C|52_0("stick", ref CS$<>8__locals1);
352 }
353 }
354 }
355 else if (text == "ore")
356 {
357 this.<CreateByProduct>g__C|52_0("cutstone", ref CS$<>8__locals1);
358 this.<CreateByProduct>g__C|52_0("ingot", ref CS$<>8__locals1);
359 }
360 }
361 else if (text == "wood")
362 {
363 this.<CreateByProduct>g__C|52_0("plank", ref CS$<>8__locals1);
364 this.<CreateByProduct>g__C|52_0("stick", ref CS$<>8__locals1);
365 this.<CreateByProduct>g__C|52_0("bark", ref CS$<>8__locals1);
366 }
367 foreach (string text2 in this.goods)
368 {
369 this.<CreateByProduct>g__C|52_0(text2, ref CS$<>8__locals1);
370 }
371 }
372
373 // Token: 0x170010EB RID: 4331
374 // (get) Token: 0x06003764 RID: 14180 RVA: 0x0012AF42 File Offset: 0x00129142
375 public bool UsePick
376 {
377 get
378 {
379 return SourceMaterial.Row.IDPick.Contains(this.category);
380 }
381 }
382
383 // Token: 0x170010EC RID: 4332
384 // (get) Token: 0x06003765 RID: 14181 RVA: 0x0012AF54 File Offset: 0x00129154
385 public bool UseAxe
386 {
387 get
388 {
389 return SourceMaterial.Row.IDAxe.Contains(this.category);
390 }
391 }
392
393 // Token: 0x06003768 RID: 14184 RVA: 0x0012AFC4 File Offset: 0x001291C4
394 [CompilerGenerated]
395 private void <CreateByProduct>g__C|52_0(string _id, ref SourceMaterial.Row.<>c__DisplayClass52_0 A_2)
396 {
397 Thing thing = ThingGen.Create(_id, -1, -1);
398 thing.ChangeMaterial(this.id);
399 thing.ModNum(A_2.num, true);
400 A_2.container.AddThing(thing, true, -1, -1);
401 }
402
403 // Token: 0x04002036 RID: 8246
404 public int id;
405
406 // Token: 0x04002037 RID: 8247
407 public string alias;
408
409 // Token: 0x04002038 RID: 8248
410 public string name_JP;
411
412 // Token: 0x04002039 RID: 8249
413 public string name;
414
415 // Token: 0x0400203A RID: 8250
416 public string category;
417
418 // Token: 0x0400203B RID: 8251
419 public string[] tag;
420
421 // Token: 0x0400203C RID: 8252
422 public string thing;
423
424 // Token: 0x0400203D RID: 8253
425 public string[] goods;
426
427 // Token: 0x0400203E RID: 8254
428 public string[] minerals;
429
430 // Token: 0x0400203F RID: 8255
431 public int decal;
432
433 // Token: 0x04002040 RID: 8256
434 public int decay;
435
436 // Token: 0x04002041 RID: 8257
437 public int grass;
438
439 // Token: 0x04002042 RID: 8258
440 public int defFloor;
441
442 // Token: 0x04002043 RID: 8259
443 public int defBlock;
444
445 // Token: 0x04002044 RID: 8260
446 public int edge;
447
448 // Token: 0x04002045 RID: 8261
449 public int ramp;
450
451 // Token: 0x04002046 RID: 8262
452 public string idSound;
453
454 // Token: 0x04002047 RID: 8263
455 public string soundFoot;
456
457 // Token: 0x04002048 RID: 8264
458 public int hardness;
459
460 // Token: 0x04002049 RID: 8265
461 public string[] groups;
462
463 // Token: 0x0400204A RID: 8266
464 public int tier;
465
466 // Token: 0x0400204B RID: 8267
467 public int chance;
468
469 // Token: 0x0400204C RID: 8268
470 public int weight;
471
472 // Token: 0x0400204D RID: 8269
473 public int value;
474
475 // Token: 0x0400204E RID: 8270
476 public int quality;
477
478 // Token: 0x0400204F RID: 8271
479 public int atk;
480
481 // Token: 0x04002050 RID: 8272
482 public int dmg;
483
484 // Token: 0x04002051 RID: 8273
485 public int dv;
486
487 // Token: 0x04002052 RID: 8274
488 public int pv;
489
490 // Token: 0x04002053 RID: 8275
491 public int dice;
492
493 // Token: 0x04002054 RID: 8276
494 public string[] bits;
495
496 // Token: 0x04002055 RID: 8277
497 public int[] elements;
498
499 // Token: 0x04002056 RID: 8278
500 public string[] altName;
501
502 // Token: 0x04002057 RID: 8279
503 public string[] altName_JP;
504
505 // Token: 0x04002058 RID: 8280
506 [NonSerialized]
507 public Color matColor;
508
509 // Token: 0x04002059 RID: 8281
510 [NonSerialized]
511 public Color altColor;
512
513 // Token: 0x0400205A RID: 8282
514 public Dictionary<int, int> elementMap;
515
516 // Token: 0x0400205B RID: 8283
517 public static string[] IDPick = new string[]
518 {
519 "rock",
520 "ore",
521 "gem",
522 "crystal",
523 "bone"
524 };
525
526 // Token: 0x0400205C RID: 8284
527 public static string[] IDAxe = new string[]
528 {
529 "wood"
530 };
531
532 // Token: 0x0400205D RID: 8285
533 public string name_L;
534
535 // Token: 0x0400205E RID: 8286
536 public string detail_L;
537
538 // Token: 0x0400205F RID: 8287
539 public string[] altName_L;
540 }
541
542 // Token: 0x020007A6 RID: 1958
543 public class TierList
544 {
545 // Token: 0x06003769 RID: 14185 RVA: 0x0012B004 File Offset: 0x00129204
546 public TierList()
547 {
548 this.tiers = new SourceMaterial.Tier[5];
549 for (int i = 0; i < 5; i++)
550 {
551 this.tiers[i] = new SourceMaterial.Tier();
552 }
553 }
554
555 // Token: 0x04002060 RID: 8288
556 public SourceMaterial.Tier[] tiers;
557 }
558
559 // Token: 0x020007A7 RID: 1959
560 public class Tier
561 {
562 // Token: 0x0600376A RID: 14186 RVA: 0x0012B03C File Offset: 0x0012923C
563 public SourceMaterial.Row Select()
564 {
565 int num = 0;
566 int num2 = EClass.rnd(this.sum);
567 foreach (SourceMaterial.Row row in this.list)
568 {
569 num += row.chance;
570 if (num2 < num)
571 {
572 return row;
573 }
574 }
575 return this.list.RandomItem<SourceMaterial.Row>();
576 }
577
578 // Token: 0x04002061 RID: 8289
579 public int sum;
580
581 // Token: 0x04002062 RID: 8290
582 public List<SourceMaterial.Row> list = new List<SourceMaterial.Row>();
583 }
584}
Definition Point.cs:11
Definition Thing.cs:10