Elin Modding Docs Doc
Loading...
Searching...
No Matches
BaseTaskHarvest.cs
1using System;
2using UnityEngine;
3
4// Token: 0x02000255 RID: 597
6{
7 // Token: 0x17000468 RID: 1128
8 // (get) Token: 0x0600109B RID: 4251 RVA: 0x0007387C File Offset: 0x00071A7C
9 public bool IsTooHard
10 {
11 get
12 {
13 return this.isToolRequired && this.reqLv > this.toolLv;
14 }
15 }
16
17 // Token: 0x17000469 RID: 1129
18 // (get) Token: 0x0600109C RID: 4252 RVA: 0x00073896 File Offset: 0x00071A96
19 public bool IsHarvest
20 {
21 get
22 {
23 return this.pos.cell.CanHarvest();
24 }
25 }
26
27 // Token: 0x1700046A RID: 1130
28 // (get) Token: 0x0600109D RID: 4253 RVA: 0x000738A8 File Offset: 0x00071AA8
29 public virtual bool CanReapSeed
30 {
31 get
32 {
33 return this.pos.cell.CanReapSeed();
34 }
35 }
36
37 // Token: 0x1700046B RID: 1131
38 // (get) Token: 0x0600109E RID: 4254 RVA: 0x000738BA File Offset: 0x00071ABA
39 public virtual BaseTaskHarvest.HarvestType harvestType
40 {
41 get
42 {
43 return BaseTaskHarvest.HarvestType.Block;
44 }
45 }
46
47 // Token: 0x1700046C RID: 1132
48 // (get) Token: 0x0600109F RID: 4255 RVA: 0x000738BD File Offset: 0x00071ABD
49 public virtual bool IsGrowth
50 {
51 get
52 {
53 return false;
54 }
55 }
56
57 // Token: 0x1700046D RID: 1133
58 // (get) Token: 0x060010A0 RID: 4256 RVA: 0x000738C0 File Offset: 0x00071AC0
59 public override bool CanPressRepeat
60 {
61 get
62 {
63 return true;
64 }
65 }
66
67 // Token: 0x1700046E RID: 1134
68 // (get) Token: 0x060010A1 RID: 4257 RVA: 0x000738C3 File Offset: 0x00071AC3
69 public override int LeftHand
70 {
71 get
72 {
73 return -1;
74 }
75 }
76
77 // Token: 0x1700046F RID: 1135
78 // (get) Token: 0x060010A2 RID: 4258 RVA: 0x000738C6 File Offset: 0x00071AC6
79 public override CursorInfo CursorIcon
80 {
81 get
82 {
83 return CursorSystem.Cut;
84 }
85 }
86
87 // Token: 0x060010A3 RID: 4259 RVA: 0x000738CD File Offset: 0x00071ACD
88 public virtual string GetBaseText(string str)
89 {
90 return base.GetText(str);
91 }
92
93 // Token: 0x060010A4 RID: 4260 RVA: 0x000738D6 File Offset: 0x00071AD6
94 public override string GetTextSmall(Card c)
95 {
96 return this.pos.cell.GetObjName();
97 }
98
99 // Token: 0x060010A5 RID: 4261 RVA: 0x000738E8 File Offset: 0x00071AE8
100 public override string GetText(string str = "")
101 {
102 if (this.owner == null)
103 {
104 this.owner = EClass.pc;
105 }
106 this.SetTarget(EClass.pc, null);
107 string text = "tHarvest".lang(this.GetBaseText(str), (EClass.pc.Tool == null) ? "hand".lang() : this.owner.Tool.NameSimple, this.toolLv.ToString() ?? "", null, null);
108 text = text + " (" + this.GetTextDifficulty() + ")";
109 if (this.IsTooHard)
110 {
111 text = text.TagColor(Color.gray);
112 }
113 return text;
114 }
115
116 // Token: 0x060010A6 RID: 4262 RVA: 0x00073990 File Offset: 0x00071B90
117 public static Thing GetBestTool(Chara c, Point p)
118 {
120 {
121 pos = p
122 };
123 task.SetOwner(c);
124 Thing tool = null;
125 int best = 0;
126 c.things.Foreach(delegate(Thing t)
127 {
128 if (!(t.trait is TraitTool))
129 {
130 return;
131 }
132 task.SetTarget(c, t);
133 if (task.efficiency > best)
134 {
135 best = task.efficiency;
136 tool = t;
137 }
138 }, true);
139 return tool;
140 }
141
142 // Token: 0x060010A7 RID: 4263 RVA: 0x00073A00 File Offset: 0x00071C00
143 public void SetTarget(Chara c, Thing tool = null)
144 {
145 if (c == null)
146 {
147 c = EClass.pc;
148 }
149 if (tool == null)
150 {
151 tool = c.Tool;
152 }
153 string[] array = null;
154 SourceMaterial.Row row = null;
155 switch (this.harvestType)
156 {
157 case BaseTaskHarvest.HarvestType.Floor:
158 if (this.pos.cell.HasBridge)
159 {
160 array = this.pos.sourceBridge.reqHarvest;
161 row = this.pos.matBridge;
162 }
163 else
164 {
165 array = this.pos.sourceFloor.reqHarvest;
166 row = this.pos.matFloor;
167 }
168 break;
169 case BaseTaskHarvest.HarvestType.Block:
170 if (this.pos.HasBlock)
171 {
172 array = this.pos.sourceBlock.reqHarvest;
173 row = this.pos.matBlock;
174 }
175 else
176 {
177 array = new string[this.pos.sourceFloor.reqHarvest.Length];
178 Array.Copy(this.pos.sourceFloor.reqHarvest, array, this.pos.sourceFloor.reqHarvest.Length);
179 array[0] = "mining";
180 row = this.pos.matFloor;
181 }
182 break;
183 case BaseTaskHarvest.HarvestType.Obj:
184 array = this.pos.sourceObj.reqHarvest;
185 row = this.pos.cell.matObj;
186 break;
187 case BaseTaskHarvest.HarvestType.Thing:
188 array = this.target.trait.ReqHarvest.Split(',', StringSplitOptions.None);
189 row = this.target.material;
190 break;
191 case BaseTaskHarvest.HarvestType.Disassemble:
192 if (this.target == null)
193 {
194 return;
195 }
196 array = new string[]
197 {
198 "handicraft",
199 "1"
200 };
201 row = this.target.material;
202 break;
203 }
204 this.matHardness = row.hardness;
205 if (this.harvestType == BaseTaskHarvest.HarvestType.Obj)
206 {
207 this.matHardness = this.matHardness * ((this.pos.growth != null) ? this.pos.growth.GetHp() : this.pos.sourceObj.hp) / 100;
208 }
209 if (row.tag.Contains("hard"))
210 {
211 this.matHardness *= 3;
212 }
213 BaseTaskHarvest.HarvestType harvestType = this.harvestType;
214 if (harvestType <= BaseTaskHarvest.HarvestType.Block && row.id == 0)
215 {
216 this.matHardness *= 100;
217 }
218 this.idEle = (this.IsHarvest ? 250 : EClass.sources.elements.alias[array[0]].id);
219 this.reqElement = Element.Create(this.idEle, 0);
220 int num = array[1].ToInt();
221 this.reqLv = this.matHardness + num;
222 this.isToolRequired = (!this.IsHarvest && this.idEle != 250);
223 this.toolLv = 0;
224 if (tool != null)
225 {
226 int num2 = (this.idEle == 220 || this.idEle == 225) ? this.GetToolEfficiency(tool, row) : 100;
227 this.toolLv += tool.material.hardness * num2 / 100;
228 this.toolLv = (int)(this.toolLv + (tool.encLV + tool.blessedState));
229 }
230 this.toolLv += c.Evalue(this.idEle) * 3 / 2;
231 if (this.toolLv < 0)
232 {
233 this.toolLv = 1;
234 }
235 this.efficiency = (this.toolLv + 5) * 100 / ((this.reqLv + 5) * 140 / 100);
236 if (this.efficiency < 50)
237 {
238 this.efficiency = 50;
239 }
240 if (this.IsTooHard)
241 {
242 this.difficulty = 3;
243 }
244 else if (this.efficiency > 150)
245 {
246 this.difficulty = 0;
247 }
248 else if (this.efficiency > 100)
249 {
250 this.difficulty = 1;
251 }
252 else
253 {
254 this.difficulty = 2;
255 }
256 PlantData plantData = EClass._map.TryGetPlant(this.pos.cell);
257 if (this.harvestType == BaseTaskHarvest.HarvestType.Obj && this.IsHarvest && plantData != null && plantData.size > 0)
258 {
259 this.maxProgress = (int)Mathf.Clamp(Rand.Range(8f, 10f) * (float)(100 + plantData.size * 100 + plantData.size * plantData.size * 30) / (float)this.efficiency, 2f, 1000f);
260 return;
261 }
262 this.maxProgress = (int)Mathf.Clamp(Rand.Range(8f, 16f) * 100f / (float)this.efficiency, 2f, 30f);
263 }
264
265 // Token: 0x060010A8 RID: 4264 RVA: 0x00073E78 File Offset: 0x00072078
266 public static int GetReqEle(string _raw)
267 {
268 string[] array = _raw.Split(',', StringSplitOptions.None);
269 return EClass.sources.elements.alias[array[0]].id;
270 }
271
272 // Token: 0x060010A9 RID: 4265 RVA: 0x00073EAC File Offset: 0x000720AC
273 public int GetToolEfficiency(Thing t, SourceMaterial.Row mat)
274 {
275 int[] toolEfficiency = this.GetToolEfficiency(mat);
276 new int[2];
277 if (!t.HasElement(220, 1))
278 {
279 toolEfficiency[0] = 0;
280 }
281 if (!t.HasElement(225, 1))
282 {
283 toolEfficiency[1] = 0;
284 }
285 if (t.trait is TraitToolHammer)
286 {
287 toolEfficiency[0] = 50 + this.owner.Evalue(261);
288 }
289 int num = 20;
290 foreach (int num2 in toolEfficiency)
291 {
292 if (num2 > num)
293 {
294 num = num2;
295 }
296 }
297 return num;
298 }
299
300 // Token: 0x060010AA RID: 4266 RVA: 0x00073F30 File Offset: 0x00072130
301 public int[] GetToolEfficiency(SourceMaterial.Row mat)
302 {
303 string category = mat.category;
304 uint num = <PrivateImplementationDetails>.ComputeStringHash(category);
305 if (num <= 1237752336U)
306 {
307 if (num <= 862676408U)
308 {
309 if (num != 174734082U)
310 {
311 if (num != 270655681U)
312 {
313 if (num != 862676408U)
314 {
315 goto IL_1EB;
316 }
317 if (!(category == "skin"))
318 {
319 goto IL_1EB;
320 }
321 goto IL_1B8;
322 }
323 else
324 {
325 if (!(category == "fiber"))
326 {
327 goto IL_1EB;
328 }
329 goto IL_1C9;
330 }
331 }
332 else if (!(category == "soil"))
333 {
334 goto IL_1EB;
335 }
336 }
337 else if (num != 974867124U)
338 {
339 if (num != 1167392201U)
340 {
341 if (num != 1237752336U)
342 {
343 goto IL_1EB;
344 }
345 if (!(category == "water"))
346 {
347 goto IL_1EB;
348 }
349 }
350 else
351 {
352 if (!(category == "crystal"))
353 {
354 goto IL_1EB;
355 }
356 goto IL_1A7;
357 }
358 }
359 else
360 {
361 if (!(category == "rock"))
362 {
363 goto IL_1EB;
364 }
365 goto IL_1A7;
366 }
367 return new int[]
368 {
369 100,
370 100
371 };
372 }
373 if (num <= 2585652531U)
374 {
375 if (num != 1527558748U)
376 {
377 if (num != 2226448744U)
378 {
379 if (num != 2585652531U)
380 {
381 goto IL_1EB;
382 }
383 if (!(category == "ore"))
384 {
385 goto IL_1EB;
386 }
387 }
388 else
389 {
390 if (!(category == "wood"))
391 {
392 goto IL_1EB;
393 }
394 goto IL_1C9;
395 }
396 }
397 else if (!(category == "gem"))
398 {
399 goto IL_1EB;
400 }
401 }
402 else if (num != 2993663101U)
403 {
404 if (num != 3683705231U)
405 {
406 if (num != 3693684870U)
407 {
408 goto IL_1EB;
409 }
410 if (!(category == "organic"))
411 {
412 goto IL_1EB;
413 }
414 goto IL_1B8;
415 }
416 else
417 {
418 if (!(category == "bone"))
419 {
420 goto IL_1EB;
421 }
422 return new int[]
423 {
424 100,
425 50
426 };
427 }
428 }
429 else
430 {
431 if (!(category == "grass"))
432 {
433 goto IL_1EB;
434 }
435 goto IL_1C9;
436 }
437 IL_1A7:
438 return new int[]
439 {
440 100,
441 25
442 };
443 IL_1B8:
444 return new int[]
445 {
446 50,
447 100
448 };
449 IL_1C9:
450 return new int[]
451 {
452 25,
453 100
454 };
455 IL_1EB:
456 return new int[]
457 {
458 100,
459 100
460 };
461 }
462
463 // Token: 0x060010AB RID: 4267 RVA: 0x00074138 File Offset: 0x00072338
464 public string GetTextDifficulty()
465 {
466 return Lang.GetList("skillDiff")[this.difficulty];
467 }
468
469 // Token: 0x04000DBD RID: 3517
470 public Thing target;
471
472 // Token: 0x04000DBE RID: 3518
473 public Element reqElement;
474
475 // Token: 0x04000DBF RID: 3519
476 public int matHardness;
477
478 // Token: 0x04000DC0 RID: 3520
479 public int idEle;
480
481 // Token: 0x04000DC1 RID: 3521
482 public int reqLv;
483
484 // Token: 0x04000DC2 RID: 3522
485 public int toolLv;
486
487 // Token: 0x04000DC3 RID: 3523
488 public int maxProgress;
489
490 // Token: 0x04000DC4 RID: 3524
491 public int efficiency;
492
493 // Token: 0x04000DC5 RID: 3525
494 public int difficulty;
495
496 // Token: 0x04000DC6 RID: 3526
497 public int effectFrame = 1;
498
499 // Token: 0x04000DC7 RID: 3527
500 public bool isToolRequired;
501
502 // Token: 0x0200092D RID: 2349
503 public enum HarvestType
504 {
505 // Token: 0x040026CB RID: 9931
506 Floor,
507 // Token: 0x040026CC RID: 9932
508 Block,
509 // Token: 0x040026CD RID: 9933
510 Obj,
511 // Token: 0x040026CE RID: 9934
512 Thing,
513 // Token: 0x040026CF RID: 9935
514 Disassemble
515 }
516}
Definition Card.cs:13
Definition Chara.cs:12
Definition Point.cs:11
Definition Thing.cs:10