Elin Modding Docs Doc
Loading...
Searching...
No Matches
ThingGen.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Runtime.CompilerServices;
5using UnityEngine;
6
7// Token: 0x020004EC RID: 1260
8public class ThingGen : CardGen
9{
10 // Token: 0x06002191 RID: 8593 RVA: 0x000B9B70 File Offset: 0x000B7D70
11 public static Thing _Create(string id, int idMat = -1, int lv = -1)
12 {
13 Thing thing = new Thing();
14 CardRow s = EClass.sources.cards.map.TryGetValue(id, null);
15 if (s == null)
16 {
17 Debug.LogError("exception: Item not found:" + id);
18 id = "869";
19 s = EClass.sources.cards.map.TryGetValue(id, null);
20 }
21 if (s.isOrigin)
22 {
23 CardRow cardRow = SpawnListThing.Get("origin_" + id, (SourceThing.Row a) => a.origin == s).Select(lv, -1);
24 id = (((cardRow != null) ? cardRow.id : null) ?? (from a in EClass.sources.cards.rows
25 where a.origin == s
26 select a).First<CardRow>().id);
27 }
28 if (lv < 1)
29 {
30 lv = 1;
31 }
32 thing.Create(id, idMat, lv);
33 if (thing.trait is TraitAmmo)
34 {
35 thing.SetNum(EClass.rnd(20) + 10);
36 }
37 return thing;
38 }
39
40 // Token: 0x06002192 RID: 8594 RVA: 0x000B9C7B File Offset: 0x000B7E7B
41 public static Thing TestCreate()
42 {
43 return ThingGen._Create(SpawnList.Get("thing", null, null).Select(-1, -1).id, -1, -1);
44 }
45
46 // Token: 0x06002193 RID: 8595 RVA: 0x000B9C9C File Offset: 0x000B7E9C
47 public static Thing CreateCurrency(int a, string id = "money")
48 {
49 return ThingGen.Create(id, -1, -1).SetNum(a);
50 }
51
52 // Token: 0x06002194 RID: 8596 RVA: 0x000B9CAC File Offset: 0x000B7EAC
53 public static Thing CreateParcel(string idLang = null, params Thing[] things)
54 {
55 Thing thing = ThingGen.Create("parcel", -1, -1);
56 foreach (Thing c in things)
57 {
58 thing.AddCard(c);
59 }
60 thing.c_idRefName = idLang.lang();
61 return thing;
62 }
63
64 // Token: 0x06002195 RID: 8597 RVA: 0x000B9CEF File Offset: 0x000B7EEF
65 public static Thing Create(string id, int idMat = -1, int lv = -1)
66 {
67 return ThingGen._Create(id, idMat, lv);
68 }
69
70 // Token: 0x06002196 RID: 8598 RVA: 0x000B9CF9 File Offset: 0x000B7EF9
71 public static Thing Create(string id, string idMat)
72 {
73 return ThingGen.Create(id, idMat.IsEmpty() ? -1 : EClass.sources.materials.alias[idMat].id, -1);
74 }
75
76 // Token: 0x06002197 RID: 8599 RVA: 0x000B9D27 File Offset: 0x000B7F27
77 public static Thing CreateFromFilter(string id, int lv = -1)
78 {
79 return ThingGen._Create(SpawnList.Get(id, null, null).Select(lv, -1).id, -1, lv);
80 }
81
82 // Token: 0x06002198 RID: 8600 RVA: 0x000B9D44 File Offset: 0x000B7F44
83 public static Thing CreateRawMaterial(SourceMaterial.Row m)
84 {
85 Thing thing = ThingGen.Create(m.thing, -1, -1);
86 thing.ChangeMaterial(m.id);
87 return thing;
88 }
89
90 // Token: 0x06002199 RID: 8601 RVA: 0x000B9D60 File Offset: 0x000B7F60
91 public static Thing CreateFromCategory(string idCat, int lv = -1)
92 {
93 return ThingGen._Create(SpawnListThing.Get("cat_" + idCat, (SourceThing.Row s) => EClass.sources.categories.map[s.category].IsChildOf(idCat)).Select(lv, -1).id, -1, lv);
94 }
95
96 // Token: 0x0600219A RID: 8602 RVA: 0x000B9DB0 File Offset: 0x000B7FB0
97 public static Thing CreateFromTag(string idTag, int lv = -1)
98 {
99 return ThingGen._Create(SpawnListThing.Get("tag_" + idTag, (SourceThing.Row s) => s.tag.Contains(idTag)).Select(lv, -1).id, -1, lv);
100 }
101
102 // Token: 0x0600219B RID: 8603 RVA: 0x000B9E00 File Offset: 0x000B8000
103 public static Thing CreateBill(int pay, bool tax)
104 {
105 Thing thing = ThingGen.Create(tax ? "bill_tax" : "bill", -1, -1);
106 thing.c_bill = pay;
107 if (tax)
108 {
109 EClass.player.stats.taxBills += thing.c_bill;
110 EClass.player.taxBills++;
111 }
112 else
113 {
114 EClass.player.unpaidBill += thing.c_bill;
115 }
116 return thing;
117 }
118
119 // Token: 0x0600219C RID: 8604 RVA: 0x000B9E76 File Offset: 0x000B8076
120 public static Thing CreateBlock(int id, int idMat)
121 {
122 Thing thing = ThingGen.Create(EClass.sources.blocks.rows[id].idThing, idMat, -1);
123 thing.refVal = id;
124 return thing;
125 }
126
127 // Token: 0x0600219D RID: 8605 RVA: 0x000B9EA0 File Offset: 0x000B80A0
128 public static Thing CreateFloor(int id, int idMat, bool platform = false)
129 {
130 SourceFloor.Row row = EClass.sources.floors.rows[id];
131 Thing thing = ThingGen.Create(platform ? "platform" : "floor", idMat, -1);
132 thing.refVal = id;
133 return thing;
134 }
135
136 // Token: 0x0600219E RID: 8606 RVA: 0x000B9ED5 File Offset: 0x000B80D5
137 public static Thing CreateObj(int id, int idMat)
138 {
139 SourceObj.Row row = EClass.sources.objs.rows[id];
140 Thing thing = ThingGen.Create("obj", idMat, -1);
141 thing.refVal = id;
142 return thing;
143 }
144
145 // Token: 0x0600219F RID: 8607 RVA: 0x000B9F00 File Offset: 0x000B8100
146 public static Thing CreateMap(string idSource = null, int lv = -1)
147 {
148 if (idSource.IsEmpty())
149 {
150 idSource = EClass.game.world.region.GetRandomSiteSource().id;
151 }
152 if (lv == -1)
153 {
154 lv = 1 + EClass.rnd(EClass.rnd(50) + 1);
155 }
156 return ThingGen.Create("map", -1, -1);
157 }
158
159 // Token: 0x060021A0 RID: 8608 RVA: 0x000B9F52 File Offset: 0x000B8152
160 public static Thing CreatePlan(int ele)
161 {
162 Thing thing = ThingGen.Create("book_plan", -1, -1);
163 thing.refVal = ele;
164 return thing;
165 }
166
167 // Token: 0x060021A1 RID: 8609 RVA: 0x000B9F67 File Offset: 0x000B8167
168 public static Thing CreateRecipe(string id)
169 {
170 Thing thing = ThingGen.Create("rp_random", -1, -1);
171 thing.SetStr(53, id);
172 return thing;
173 }
174
175 // Token: 0x060021A2 RID: 8610 RVA: 0x000B9F7E File Offset: 0x000B817E
176 public static Thing CreateSpellbook(string alias, int num = 1)
177 {
178 return ThingGen.CreateSpellbook(EClass.sources.elements.alias[alias].id, num);
179 }
180
181 // Token: 0x060021A3 RID: 8611 RVA: 0x000B9FA0 File Offset: 0x000B81A0
182 public static Thing CreateSpellbook(int ele, int num = 1)
183 {
184 Thing thing = ThingGen.Create("spellbook", -1, -1).SetNum(num);
185 thing.refVal = ele;
186 return thing;
187 }
188
189 // Token: 0x060021A4 RID: 8612 RVA: 0x000B9FBB File Offset: 0x000B81BB
190 public static Thing CreateScroll(int ele, int num = 1)
191 {
192 Thing thing = ThingGen.Create("scroll_random", -1, -1).SetNum(num);
193 thing.refVal = ele;
194 return thing;
195 }
196
197 // Token: 0x060021A5 RID: 8613 RVA: 0x000B9FD6 File Offset: 0x000B81D6
198 public static Thing CreatePotion(int ele, int num = 1)
199 {
200 Thing thing = ThingGen.Create("potion", -1, -1).SetNum(num);
201 thing.refVal = ele;
202 return thing;
203 }
204
205 // Token: 0x060021A6 RID: 8614 RVA: 0x000B9FF1 File Offset: 0x000B81F1
206 public static Thing CreatePerfume(int ele, int num = 1)
207 {
208 Thing thing = ThingGen.Create("perfume", -1, -1).SetNum(num);
209 thing.refVal = ele;
210 return thing;
211 }
212
213 // Token: 0x060021A7 RID: 8615 RVA: 0x000BA00C File Offset: 0x000B820C
214 public static Thing CreateCardboardBox(int uidZone = -1)
215 {
216 Thing thing = ThingGen.Create("cardboard_box", new string[]
217 {
218 "pine",
219 "wood_birch",
220 "wood_acacia",
221 "oak",
222 "cedar"
223 }.RandomItem<string>());
224 thing.things.DestroyAll(null);
225 Spatial spatial = (uidZone == -1) ? null : EClass.game.spatials.map.TryGetValue(uidZone, null);
226 if (spatial != null)
227 {
228 thing.c_idRefName = "sender_header".lang("sender_post".lang(spatial.Name, null, null, null, null), null, null, null, null);
229 }
230 return thing;
231 }
232
233 // Token: 0x060021A8 RID: 8616 RVA: 0x000BA0AD File Offset: 0x000B82AD
234 public static Thing CreateTreasure(string id, int lv, TreasureType type = TreasureType.Map)
235 {
236 Thing thing = ThingGen.Create(id, -1, lv);
237 ThingGen.CreateTreasureContent(thing, lv, type, true);
238 return thing;
239 }
240
241 // Token: 0x060021A9 RID: 8617 RVA: 0x000BA0C0 File Offset: 0x000B82C0
242 public static void CreateTreasureContent(Thing t, int lv, TreasureType type, bool clearContent)
243 {
244 ThingGen.<>c__DisplayClass24_0 CS$<>8__locals1;
245 CS$<>8__locals1.miracleChance = lv;
246 int num = EClass.curve(lv, 20, 15, 75);
247 bool flag = true;
248 bool flag2 = true;
249 CS$<>8__locals1.guaranteedMythical = ((type == TreasureType.BossQuest) ? 1 : 0);
250 ThingGen.<CreateTreasureContent>g__ChangeSeed|24_0();
251 t.AddEditorTag(EditorTag.PreciousContainer);
252 if (clearContent)
253 {
254 t.things.DestroyAll(null);
255 }
256 switch (type)
257 {
258 case TreasureType.BossNefia:
259 case TreasureType.BossQuest:
260 t.Add("money", EClass.rndHalf(500 + num * 50), 1);
261 t.Add("plat", EClass.rndHalf(Mathf.Min(3 + num / 10, 15)), 1);
262 t.Add("rp_random", 1, lv);
263 if (EClass.rnd(5) == 0)
264 {
265 t.Add("medal", EClass.rnd(3), 1);
266 }
267 else if (EClass.rnd(3) == 0)
268 {
269 t.Add("map_treasure", 1, EClass.rndHalf(lv + 10));
270 }
271 else
272 {
273 t.Add("book_skill", 1, lv);
274 }
275 t.c_lockLv /= 2;
276 break;
277 case TreasureType.Map:
278 CS$<>8__locals1.miracleChance += 50;
279 t.Add("money", EClass.rndHalf(1000 + num * 100), 1);
280 t.Add("money2", EClass.rndHalf(Mathf.Min(3 + num / 10, 10)), 1);
281 t.Add("medal", EClass.rnd(3), 1);
282 break;
283 case TreasureType.RandomChest:
284 flag2 = false;
285 CS$<>8__locals1.miracleChance /= 2;
286 if (CS$<>8__locals1.miracleChance > 50)
287 {
288 CS$<>8__locals1.miracleChance = 50;
289 }
290 if (EClass.rnd(2) == 0)
291 {
292 t.Add("money", EClass.rndHalf(10 + num * 25), 1);
293 }
294 else if (EClass.rnd(2) == 0)
295 {
296 t.Add("money2", 1 + EClass.rnd(Mathf.Min(2 + num / 25, 5)), 1);
297 }
298 else
299 {
300 t.Add("plat", 1 + EClass.rnd(Mathf.Min(2 + num / 25, 5)), 1);
301 }
302 if (EClass._zone is Zone_Civilized)
303 {
304 flag = false;
305 }
306 else
307 {
308 if (EClass.rnd(10) == 0)
309 {
310 t.Add("map_treasure", 1, EClass.rndHalf(lv + 10));
311 }
312 if (EClass.rnd(3) == 0)
313 {
314 t.AddCard(ThingGen.Create("rp_random", -1, lv));
315 }
316 if (t.c_lockLv > 0 && EClass.rnd(3) == 0)
317 {
318 t.Add("medal", 1, 1);
319 }
320 }
321 break;
322 }
323 if (type == TreasureType.RandomChest && EClass.rnd(2) == 0)
324 {
325 t.AddCard(ThingGen.CreateFromCategory("junk", lv));
326 }
327 else if (EClass.rnd(3) == 0)
328 {
329 t.Add("rp_random", 1, lv);
330 }
331 else if (type != TreasureType.Map && EClass.rnd(2) == 0)
332 {
333 Thing thing = ThingGen.CreateFromCategory("furniture", lv);
334 if (!thing.IsContainer)
335 {
336 t.AddCard(thing);
337 }
338 }
339 else
340 {
341 t.AddCard(ThingGen.CreateFromCategory("junk", lv));
342 }
343 if (EClass.rnd(3) == 0)
344 {
345 t.Add("book_ancient", 1, lv);
346 }
347 if (t.c_lockLv > 0)
348 {
349 CS$<>8__locals1.miracleChance += 20 + (int)Mathf.Sqrt((float)(t.c_lockLv * 5));
350 }
351 if (flag)
352 {
353 ThingGen.<CreateTreasureContent>g__SetRarity|24_1(100, ref CS$<>8__locals1);
354 t.AddCard(ThingGen.CreateFromFilter("eq", lv));
355 if (flag2)
356 {
357 ThingGen.<CreateTreasureContent>g__SetRarity|24_1(20, ref CS$<>8__locals1);
358 t.AddCard(ThingGen.CreateFromFilter("eq", lv));
359 }
360 }
361 Rand.SetSeed(-1);
362 }
363
364 // Token: 0x060021AA RID: 8618 RVA: 0x000BA430 File Offset: 0x000B8630
365 public static void TryLickChest(Thing chest)
366 {
367 foreach (Chara chara in EClass._map.charas)
368 {
369 if (chara.HasElement(1412, 1) && chara.Dist(chest) < 3)
370 {
371 chara.Say("lick", chara, chest, null, null);
372 chest.PlaySound("offering", 1f, true);
373 chest.PlayEffect("mutation", true, 0f, default(Vector3));
374 using (List<Thing>.Enumerator enumerator2 = chest.things.GetEnumerator())
375 {
376 while (enumerator2.MoveNext())
377 {
378 Thing thing = enumerator2.Current;
379 thing.TryLickEnchant(chara, false, null, null);
380 }
381 break;
382 }
383 }
384 }
385 }
386
387 // Token: 0x060021AC RID: 8620 RVA: 0x000BA528 File Offset: 0x000B8728
388 [CompilerGenerated]
389 internal static void <CreateTreasureContent>g__ChangeSeed|24_0()
390 {
391 EClass.player.seedChest++;
392 Rand.SetSeed(EClass.game.seed + EClass.player.seedChest);
393 }
394
395 // Token: 0x060021AD RID: 8621 RVA: 0x000BA558 File Offset: 0x000B8758
396 [CompilerGenerated]
397 internal static void <CreateTreasureContent>g__SetRarity|24_1(int mtp, ref ThingGen.<>c__DisplayClass24_0 A_1)
398 {
399 ThingGen.<CreateTreasureContent>g__ChangeSeed|24_0();
400 Rarity rarity = (A_1.miracleChance * mtp / 100 >= EClass.rnd(100)) ? ((EClass.rnd(20) == 0) ? Rarity.Mythical : Rarity.Legendary) : Rarity.Superior;
401 if (A_1.guaranteedMythical > 0)
402 {
403 int guaranteedMythical = A_1.guaranteedMythical;
404 A_1.guaranteedMythical = guaranteedMythical - 1;
405 rarity = Rarity.Mythical;
406 }
408 {
409 rarity = rarity
410 });
411 }
412}
Definition Chara.cs:12
Definition Thing.cs:10