Elin Modding Docs Doc
All Classes Namespaces
GrowSystem.cs
1using System;
2using UnityEngine;
3
4// Token: 0x02000674 RID: 1652
5public class GrowSystem : EClass
6{
7 // Token: 0x06002E4A RID: 11850 RVA: 0x001054D7 File Offset: 0x001036D7
8 public bool IsLastStage()
9 {
10 return this.stage.idx == this.StageLength - 1;
11 }
12
13 // Token: 0x17000D1C RID: 3356
14 // (get) Token: 0x06002E4B RID: 11851 RVA: 0x001054EE File Offset: 0x001036EE
15 public virtual RenderData RenderHarvest
16 {
17 get
18 {
19 return this.source.renderData;
20 }
21 }
22
23 // Token: 0x17000D1D RID: 3357
24 // (get) Token: 0x06002E4C RID: 11852 RVA: 0x001054FB File Offset: 0x001036FB
25 public virtual int Step
26 {
27 get
28 {
29 return 5;
30 }
31 }
32
33 // Token: 0x17000D1E RID: 3358
34 // (get) Token: 0x06002E4D RID: 11853 RVA: 0x001054FE File Offset: 0x001036FE
35 public virtual int StageLength
36 {
37 get
38 {
39 return 5;
40 }
41 }
42
43 // Token: 0x17000D1F RID: 3359
44 // (get) Token: 0x06002E4E RID: 11854 RVA: 0x00105501 File Offset: 0x00103701
45 public virtual int DefaultStage
46 {
47 get
48 {
49 return Mathf.Clamp(this.StageLength - 2, 0, this.StageLength - 1);
50 }
51 }
52
53 // Token: 0x17000D20 RID: 3360
54 // (get) Token: 0x06002E4F RID: 11855 RVA: 0x00105519 File Offset: 0x00103719
55 public virtual int HarvestStage
56 {
57 get
58 {
59 return -1;
60 }
61 }
62
63 // Token: 0x17000D21 RID: 3361
64 // (get) Token: 0x06002E50 RID: 11856 RVA: 0x0010551C File Offset: 0x0010371C
65 public virtual int AutoMineStage
66 {
67 get
68 {
69 return this.HarvestStage;
70 }
71 }
72
73 // Token: 0x17000D22 RID: 3362
74 // (get) Token: 0x06002E51 RID: 11857 RVA: 0x00105524 File Offset: 0x00103724
75 protected virtual int HaltStage
76 {
77 get
78 {
79 return this.HarvestStage;
80 }
81 }
82
83 // Token: 0x06002E52 RID: 11858 RVA: 0x0010552C File Offset: 0x0010372C
84 protected virtual bool IsHarvestStage(int idx)
85 {
86 return idx == this.HarvestStage;
87 }
88
89 // Token: 0x17000D23 RID: 3363
90 // (get) Token: 0x06002E53 RID: 11859 RVA: 0x00105537 File Offset: 0x00103737
91 protected virtual bool DrawHarvestOnTop
92 {
93 get
94 {
95 return false;
96 }
97 }
98
99 // Token: 0x17000D24 RID: 3364
100 // (get) Token: 0x06002E54 RID: 11860 RVA: 0x0010553A File Offset: 0x0010373A
101 protected virtual bool UseGenericFirstStageTile
102 {
103 get
104 {
105 return true;
106 }
107 }
108
109 // Token: 0x17000D25 RID: 3365
110 // (get) Token: 0x06002E55 RID: 11861 RVA: 0x0010553D File Offset: 0x0010373D
111 protected virtual bool WitherOnLastStage
112 {
113 get
114 {
115 return true;
116 }
117 }
118
119 // Token: 0x17000D26 RID: 3366
120 // (get) Token: 0x06002E56 RID: 11862 RVA: 0x00105540 File Offset: 0x00103740
121 protected virtual bool CanRegrow
122 {
123 get
124 {
125 return true;
126 }
127 }
128
129 // Token: 0x17000D27 RID: 3367
130 // (get) Token: 0x06002E57 RID: 11863 RVA: 0x00105543 File Offset: 0x00103743
131 public virtual int ShadowStage
132 {
133 get
134 {
135 return 1;
136 }
137 }
138
139 // Token: 0x17000D28 RID: 3368
140 // (get) Token: 0x06002E58 RID: 11864 RVA: 0x00105546 File Offset: 0x00103746
141 public virtual bool IsTree
142 {
143 get
144 {
145 return false;
146 }
147 }
148
149 // Token: 0x17000D29 RID: 3369
150 // (get) Token: 0x06002E59 RID: 11865 RVA: 0x00105549 File Offset: 0x00103749
151 public virtual bool IsCrimeToHarvest
152 {
153 get
154 {
155 return false;
156 }
157 }
158
159 // Token: 0x17000D2A RID: 3370
160 // (get) Token: 0x06002E5A RID: 11866 RVA: 0x0010554C File Offset: 0x0010374C
161 public virtual float MtpProgress
162 {
163 get
164 {
165 return 1f;
166 }
167 }
168
169 // Token: 0x17000D2B RID: 3371
170 // (get) Token: 0x06002E5B RID: 11867 RVA: 0x00105553 File Offset: 0x00103753
171 public virtual bool NeedSunlight
172 {
173 get
174 {
175 return true;
176 }
177 }
178
179 // Token: 0x06002E5C RID: 11868 RVA: 0x00105556 File Offset: 0x00103756
180 public virtual bool BlockSight(Cell cell)
181 {
182 return false;
183 }
184
185 // Token: 0x06002E5D RID: 11869 RVA: 0x00105559 File Offset: 0x00103759
186 public virtual bool BlockPass(Cell cell)
187 {
188 return false;
189 }
190
191 // Token: 0x06002E5E RID: 11870 RVA: 0x0010555C File Offset: 0x0010375C
192 public virtual string GetSoundProgress()
193 {
194 return "Material/grass";
195 }
196
197 // Token: 0x17000D2C RID: 3372
198 // (get) Token: 0x06002E5F RID: 11871 RVA: 0x00105563 File Offset: 0x00103763
199 public virtual AnimeID AnimeProgress
200 {
201 get
202 {
203 return AnimeID.HitObj;
204 }
205 }
206
207 // Token: 0x17000D2D RID: 3373
208 // (get) Token: 0x06002E60 RID: 11872 RVA: 0x00105566 File Offset: 0x00103766
209 public GrowSystem.Stage stage
210 {
211 get
212 {
213 return this.stages[(int)(GrowSystem.cell.objVal / 30)];
214 }
215 }
216
217 // Token: 0x06002E61 RID: 11873 RVA: 0x0010557C File Offset: 0x0010377C
218 public virtual GrowSystem.Stage CreateStage()
219 {
220 return new GrowSystem.Stage();
221 }
222
223 // Token: 0x06002E62 RID: 11874 RVA: 0x00105584 File Offset: 0x00103784
224 public void Init(SourceObj.Row _row)
225 {
226 this.source = _row;
227 this.stages = new GrowSystem.Stage[this.StageLength];
228 string[] growth = _row._growth;
229 string[] array = growth[1].Split('/', StringSplitOptions.None);
230 this.baseTiles = new int[array.Length];
231 for (int i = 0; i < array.Length; i++)
232 {
233 this.baseTiles[i] = array[i].ToInt();
234 }
235 if (growth.Length > 2)
236 {
237 this.harvestTile = this.RenderHarvest.ConvertTile(growth[2].ToInt());
238 this.idHarvestThing = growth[3];
239 }
240 for (int j = 0; j < this.StageLength; j++)
241 {
242 GrowSystem.Stage stage = this.CreateStage();
243 this.stages[j] = stage;
244 stage.idx = j;
245 if (j == 0 && this.UseGenericFirstStageTile)
246 {
247 this.SetGenericFirstStageTile(stage);
248 }
249 else
250 {
251 this.SetStageTile(stage);
252 }
253 if (this.harvestTile != 0 && this.IsHarvestStage(j))
254 {
255 stage.harvest = true;
256 }
257 }
258 }
259
260 // Token: 0x06002E63 RID: 11875 RVA: 0x00105671 File Offset: 0x00103871
261 public virtual void SetGenericFirstStageTile(GrowSystem.Stage s)
262 {
263 s.renderData = EClass.core.refs.renderers.objS_flat;
264 s.SetTile(0, new int[]
265 {
266 100,
267 101,
268 102
269 });
270 }
271
272 // Token: 0x06002E64 RID: 11876 RVA: 0x001056A5 File Offset: 0x001038A5
273 public virtual void SetStageTile(GrowSystem.Stage s)
274 {
275 s.renderData = this.source.renderData;
276 s.SetTile(s.idx + (this.UseGenericFirstStageTile ? -1 : 0), this.baseTiles);
277 }
278
279 // Token: 0x06002E65 RID: 11877 RVA: 0x001056D7 File Offset: 0x001038D7
280 public virtual int GetStageTile()
281 {
282 return GrowSystem.currentStage.tiles[GrowSystem.cell.objDir % GrowSystem.currentStage.tiles.Length];
283 }
284
285 // Token: 0x06002E66 RID: 11878 RVA: 0x001056FB File Offset: 0x001038FB
286 public virtual int GetShadow(int index)
287 {
288 return -1;
289 }
290
291 // Token: 0x06002E67 RID: 11879 RVA: 0x00105700 File Offset: 0x00103900
292 public virtual void OnRenderTileMap(RenderParam p)
293 {
294 int num = (int)(GrowSystem.cell.objVal / 30);
295 GrowSystem.currentStage = this.stages[num];
296 SourceObj.Row row = this.source;
297 float y = p.y;
298 float z = p.z;
299 if (num != 0 || !this.UseGenericFirstStageTile)
300 {
301 p.y += row.pref.y;
302 p.z += row.pref.z;
303 }
304 if (GrowSystem.currentStage.harvest)
305 {
306 if (GrowSystem.cell.isHarvested || this.harvestTile == 0)
307 {
308 p.tile = (float)((this.afterHarvestTile != 0) ? this.afterHarvestTile : this.GetStageTile());
309 GrowSystem.currentStage.renderData.Draw(p);
310 }
311 else
312 {
313 if (this.DrawHarvestOnTop)
314 {
315 p.tile = (float)this.GetStageTile();
316 GrowSystem.currentStage.renderData.Draw(p);
317 p.liquidLv = 0;
318 }
319 p.tile = (float)this.harvestTile;
320 this.RenderHarvest.Draw(p);
321 }
322 }
323 else
324 {
325 p.tile = (float)this.GetStageTile();
326 GrowSystem.currentStage.renderData.Draw(p);
327 }
328 p.y = y;
329 p.z = z;
330 if (num < this.ShadowStage)
331 {
332 return;
333 }
334 int shadow = this.GetShadow(num);
335 if (shadow == -1)
336 {
337 shadow = row.pref.shadow;
338 }
339 if (shadow > 1 && !GrowSystem.cell.ignoreObjShadow)
340 {
341 EClass.screen.tileMap.passShadow.AddShadow(p.x + row.renderData.offsetShadow.x, p.y + row.renderData.offsetShadow.y, p.z + row.renderData.offsetShadow.z, ShadowData.Instance.items[shadow], row.pref, 0, p.snow);
342 }
343 }
344
345 // Token: 0x06002E68 RID: 11880 RVA: 0x001058EC File Offset: 0x00103AEC
346 public void SetRandomStage()
347 {
348 int num = Rand.rnd(this.stages.Length);
349 if (num == 0 && EClass.rnd(5) != 0 && this.stages.Length >= 2)
350 {
351 num++;
352 }
353 else if (num == this.stages.Length - 1 && EClass.rnd(5) != 0 && this.stages.Length >= 2)
354 {
355 num--;
356 }
357 GrowSystem.cell.objVal = (byte)(num * 30);
358 }
359
360 // Token: 0x06002E69 RID: 11881 RVA: 0x00105956 File Offset: 0x00103B56
361 public void SetDefaultStage()
362 {
363 GrowSystem.cell.objVal = (byte)(this.DefaultStage * 30);
364 }
365
366 // Token: 0x06002E6A RID: 11882 RVA: 0x0010596C File Offset: 0x00103B6C
367 public bool CanGrow(VirtualDate date)
368 {
369 if (this.source.id == 0)
370 {
371 return false;
372 }
373 if (GrowSystem.cell.HasBlock)
374 {
375 return false;
376 }
377 if (this.NeedSunlight)
378 {
379 if (date.sunMap == null)
380 {
381 date.BuildSunMap();
382 }
383 if ((GrowSystem.cell.HasRoof || date.IsWinter) && !date.sunMap.Contains(GrowSystem.cell.index))
384 {
385 return false;
386 }
387 }
388 return true;
389 }
390
391 // Token: 0x06002E6B RID: 11883 RVA: 0x001059DA File Offset: 0x00103BDA
392 public void TryGrow(VirtualDate date)
393 {
394 if (!this.CanGrow(date))
395 {
396 return;
397 }
398 this.Grow(1);
399 }
400
401 // Token: 0x06002E6C RID: 11884 RVA: 0x001059F0 File Offset: 0x00103BF0
402 public void EqualizePlants(Point pos)
403 {
404 PlantData p1 = EClass._map.TryGetPlant(pos);
405 if (p1 == null || p1.seed == null)
406 {
407 return;
408 }
409 pos.ForeachNeighbor(delegate(Point pos2)
410 {
411 PlantData plantData = EClass._map.TryGetPlant(pos2);
412 Thing thing = (plantData != null) ? plantData.seed : null;
413 if (thing == null)
414 {
415 Thing installed = pos2.Installed;
416 if (installed != null && installed.id == p1.seed.id)
417 {
418 thing = installed;
419 }
420 }
421 if (thing == null)
422 {
423 return;
424 }
425 if (p1.seed.refVal != thing.refVal)
426 {
427 return;
428 }
429 if (thing.encLV >= p1.seed.encLV)
430 {
431 p1.seed = thing;
432 }
433 }, false);
434 }
435
436 // Token: 0x06002E6D RID: 11885 RVA: 0x00105A40 File Offset: 0x00103C40
437 public void Grow(int mtp = 1)
438 {
439 bool flag = GrowSystem.cell.isWatered || (GrowSystem.cell.IsTopWater && this.source.tag.Contains("flood"));
440 PlantData plantData = EClass._map.TryGetPlant(GrowSystem.cell);
441 if (plantData != null && flag)
442 {
443 plantData.water++;
444 }
445 int num = this.Step * mtp * (flag ? 2 : 1);
446 int num2 = (int)(GrowSystem.cell.objVal / 30);
447 int num3 = ((int)GrowSystem.cell.objVal + num) / 30;
448 if (num2 != num3)
449 {
450 if (EClass.player.isAutoFarming && num2 == this.HarvestStage && this.CanHarvest())
451 {
452 this.PopHarvest(null, null, -1);
453 }
454 if (EClass.player.isAutoFarming && num2 >= this.AutoMineStage)
455 {
456 Point point = GrowSystem.cell.GetPoint();
457 this.EqualizePlants(point);
458 Thing thing = this.TryPopSeed(null);
459 this.PopMineObj(null);
460 if (thing != null)
461 {
462 point.SetObj(0, 1, 0);
463 EClass._zone.AddCard(thing, point).Install();
464 }
465 }
466 else if (num2 == this.StageLength - 1)
467 {
468 if (EClass.player.isAutoFarming)
469 {
470 Point point2 = GrowSystem.cell.GetPoint();
471 this.EqualizePlants(point2);
472 Thing thing2 = this.TryPopSeed(null);
473 if (thing2 != null)
474 {
475 point2.SetObj(0, 1, 0);
476 EClass._zone.AddCard(thing2, point2).Install();
477 }
478 }
479 else
480 {
481 this.OnExceedLastStage();
482 }
483 }
484 else
485 {
486 this.OnReachNextStage();
487 }
488 }
489 else
490 {
491 Cell cell = GrowSystem.cell;
492 cell.objVal += (byte)num;
493 }
494 GrowSystem.cell.Refresh();
495 EClass._map.RefreshFOV((int)GrowSystem.cell.x, (int)GrowSystem.cell.z, 6, false);
496 }
497
498 // Token: 0x06002E6E RID: 11886 RVA: 0x00105C0B File Offset: 0x00103E0B
499 public virtual void OnReachNextStage()
500 {
501 this.SetStage((int)(GrowSystem.cell.objVal / 30 + 1), false);
502 }
503
504 // Token: 0x06002E6F RID: 11887 RVA: 0x00105C24 File Offset: 0x00103E24
505 public virtual void OnExceedLastStage()
506 {
507 GrowSystem.cell.objVal = (byte)(this.stages.Length * 30 - 1);
508 if (!this.CanRegrow)
509 {
510 return;
511 }
512 if (Rand.rnd(2) == 0)
513 {
514 Point point = GrowSystem.cell.GetPoint();
515 if (point.IsFarmField)
516 {
517 return;
518 }
519 if (Rand.rnd(2) == 0)
520 {
521 Point randomNeighbor = point.GetRandomNeighbor();
522 if (randomNeighbor.cell.CanGrowWeed)
523 {
524 randomNeighbor.SetObj((int)GrowSystem.cell.obj, 1, 0);
525 point.SetObj(0, 1, 0);
526 return;
527 }
528 }
529 GrowSystem.cell.objVal = 0;
530 GrowSystem.cell.isHarvested = false;
531 GrowSystem.cell.isWatered = GrowSystem.cell.HasLiquid;
532 }
533 }
534
535 // Token: 0x06002E70 RID: 11888 RVA: 0x00105CD0 File Offset: 0x00103ED0
536 public void SetStage(int idx, bool renewHarvest = false)
537 {
538 GrowSystem.cell.objVal = (byte)(idx * 30);
539 GrowSystem.cell.gatherCount = 0;
540 if (GrowSystem.cell.HasLiquid)
541 {
542 GrowSystem.cell.isWatered = true;
543 }
544 if (renewHarvest)
545 {
546 GrowSystem.cell.isHarvested = true;
547 }
548 }
549
550 // Token: 0x06002E71 RID: 11889 RVA: 0x00105D1C File Offset: 0x00103F1C
551 public bool HaltGrowth()
552 {
553 return this.stage.idx == this.HarvestStage;
554 }
555
556 // Token: 0x17000D2E RID: 3374
557 // (get) Token: 0x06002E72 RID: 11890 RVA: 0x00105D31 File Offset: 0x00103F31
558 public virtual bool IsMature
559 {
560 get
561 {
562 return false;
563 }
564 }
565
566 // Token: 0x06002E73 RID: 11891 RVA: 0x00105D34 File Offset: 0x00103F34
567 public void Perish()
568 {
569 if (EClass.player.isAutoFarming)
570 {
571 if (this.CanHarvest())
572 {
573 this.PopHarvest(null, null, -1);
574 }
575 Thing thing = this.TryPopSeed(null);
576 if (thing != null)
577 {
578 EClass._zone.AddCard(thing, GrowSystem.cell.GetPoint()).Install();
579 }
580 EClass._map.SetObj((int)GrowSystem.cell.x, (int)GrowSystem.cell.z, 0, 1, 0);
581 return;
582 }
583 if (this.WitherOnLastStage && this.stage.idx == this.StageLength - 2)
584 {
585 this.SetStage(this.StageLength - 1, false);
586 return;
587 }
588 if (EClass.rnd(3) == 0)
589 {
590 Thing thing2 = this.TryPopSeed(null);
591 if (thing2 != null)
592 {
593 EClass._zone.AddCard(thing2, GrowSystem.cell.GetPoint()).Install();
594 }
595 }
596 EClass._map.SetObj((int)GrowSystem.cell.x, (int)GrowSystem.cell.z, 0, 1, 0);
597 }
598
599 // Token: 0x06002E74 RID: 11892 RVA: 0x00105E22 File Offset: 0x00104022
600 public bool IsWithered()
601 {
602 return this.WitherOnLastStage && this.stage.idx == this.StageLength - 1;
603 }
604
605 // Token: 0x06002E75 RID: 11893 RVA: 0x00105E44 File Offset: 0x00104044
606 public bool CanHarvest()
607 {
608 return this.stage.harvest && !GrowSystem.cell.isHarvested;
609 }
610
611 // Token: 0x06002E76 RID: 11894 RVA: 0x00105E62 File Offset: 0x00104062
612 public virtual bool CanReapSeed()
613 {
614 return this.CanHarvest();
615 }
616
617 // Token: 0x06002E77 RID: 11895 RVA: 0x00105E6A File Offset: 0x0010406A
618 public virtual void OnHit(Chara c)
619 {
620 }
621
622 // Token: 0x06002E78 RID: 11896 RVA: 0x00105E6C File Offset: 0x0010406C
623 public virtual void OnHitFail(Chara c)
624 {
625 }
626
627 // Token: 0x06002E79 RID: 11897 RVA: 0x00105E6E File Offset: 0x0010406E
628 public void OnProgressComplete(Chara c)
629 {
630 EClass._map.MineObj(GrowSystem.cell.GetPoint(), null, c);
631 }
632
633 // Token: 0x06002E7A RID: 11898 RVA: 0x00105E86 File Offset: 0x00104086
634 public void PopMineObj(Chara c = null)
635 {
636 this.OnMineObj(c);
637 this.TryPopSeed(c);
638 }
639
640 // Token: 0x06002E7B RID: 11899 RVA: 0x00105E98 File Offset: 0x00104098
641 public virtual void OnMineObj(Chara c = null)
642 {
643 if (!this.IsWithered())
644 {
645 int num = GrowSystem.cell.sourceObj.components.Length - 1;
646 Thing t = ThingGen.Create(GrowSystem.cell.sourceObj.components[num].Split('/', StringSplitOptions.None)[0], GrowSystem.cell.matObj_fixed.alias);
647 this.TryPick(GrowSystem.cell, t, c, false);
648 }
649 }
650
651 // Token: 0x06002E7C RID: 11900 RVA: 0x00105F00 File Offset: 0x00104100
652 public void TryPick(Cell cell, Thing t, Chara c, bool applySeed = false)
653 {
654 if (applySeed)
655 {
656 this.ApplySeed(t);
657 }
658 if (EClass.player.isAutoFarming)
659 {
660 if (EClass.rnd(4) == 0)
661 {
662 return;
663 }
664 if (t.Num > 1)
665 {
666 t.SetNum(t.Num / 2);
667 }
668 else if (EClass.rnd(2) == 0)
669 {
670 return;
671 }
672 if (!EClass._zone.TryAddThingInSharedContainer(t, null, true, false, null, true))
673 {
674 EClass.game.cards.container_shipping.AddCard(t);
675 return;
676 }
677 }
678 else
679 {
680 EClass._map.TrySmoothPick(cell, t, c);
681 }
682 }
683
684 // Token: 0x06002E7D RID: 11901 RVA: 0x00105F86 File Offset: 0x00104186
685 public void TryPick(Cell cell, string idThing, int idMat = -1, int num = 1, bool applySeed = false)
686 {
687 if (num <= 0)
688 {
689 return;
690 }
691 this.TryPick(cell, ThingGen.Create(idThing, idMat, -1).SetNum(num), EClass.pc, applySeed);
692 }
693
694 // Token: 0x06002E7E RID: 11902 RVA: 0x00105FAC File Offset: 0x001041AC
695 public Thing TryPopSeed(Chara c)
696 {
697 if (this.source.HasTag(CTAG.seed))
698 {
699 int num = GrowSystem.cell.IsFarmField ? 400 : 1000;
700 if (EClass._zone.IsPCFaction)
701 {
702 int soilCost = EClass._zone.GetSoilCost();
703 int maxSoil = EClass.Branch.MaxSoil;
704 if (soilCost > maxSoil)
705 {
706 num += (soilCost - maxSoil) * 10;
707 }
708 }
709 if (this.IsWithered())
710 {
711 num /= 5;
712 }
713 if (EClass.player.isAutoFarming || EClass.rnd(num) < EClass.rnd(this.source.chance))
714 {
715 Thing thing = TraitSeed.MakeSeed(this.source, EClass._map.TryGetPlant(GrowSystem.cell));
716 if (EClass.player.isAutoFarming)
717 {
718 return thing;
719 }
720 this.TryPick(GrowSystem.cell, thing, c, false);
721 return thing;
722 }
723 }
724 return null;
725 }
726
727 // Token: 0x06002E7F RID: 11903 RVA: 0x0010607D File Offset: 0x0010427D
728 public void Harvest(Chara c)
729 {
730 GrowSystem.cell.isHarvested = true;
731 GrowSystem.cell.gatherCount = 0;
732 this.PopHarvest(c, null, -1);
733 }
734
735 // Token: 0x06002E80 RID: 11904 RVA: 0x0010609E File Offset: 0x0010429E
736 public void PopHarvest(Chara c, string idThing, int num = -1)
737 {
738 this.PopHarvest(c, ThingGen.Create(idThing, -1, -1), num);
739 }
740
741 // Token: 0x06002E81 RID: 11905 RVA: 0x001060B0 File Offset: 0x001042B0
742 public void PopHarvest(Chara c, Thing t = null, int num = -1)
743 {
744 if (t == null)
745 {
746 if (this.idHarvestThing.StartsWith('#'))
747 {
748 t = ThingGen.CreateFromCategory(this.idHarvestThing.Replace("#", ""), -1);
749 }
750 else
751 {
752 t = ThingGen.Create(this.idHarvestThing.IsEmpty("apple"), -1, -1);
753 }
754 }
755 this.ApplySeed(t);
756 PlantData plantData = EClass._map.TryGetPlant(GrowSystem.cell);
757 if (plantData != null && plantData.size > 0)
758 {
759 t.c_weight = t.SelfWeight * (80 + plantData.size * plantData.size * 100) / 100;
760 t.SetBool(115, true);
761 t.isWeightChanged = true;
762 }
763 t.SetBlessedState(BlessedState.Normal);
764 if (this.source._growth.Length > 4)
765 {
766 int num2 = EClass.rnd(this.source._growth[4].ToInt()) + 1;
767 if (EClass._zone.IsPCFaction)
768 {
769 int soilCost = EClass._zone.GetSoilCost();
770 int maxSoil = EClass.Branch.MaxSoil;
771 if (soilCost > maxSoil && EClass.player.stats.days >= 5)
772 {
773 num2 -= EClass.rnd(2 + (soilCost - maxSoil) / 20);
774 }
775 }
776 if (num2 <= 0)
777 {
778 if (!EClass.player.isAutoFarming)
779 {
780 c.Say("cropSpoiled", c, GrowSystem.cell.GetObjName(), null);
781 }
782 return;
783 }
784 t.SetNum(num2);
785 }
786 else
787 {
788 Debug.Log("harvest count not set:" + this.source.id.ToString() + "/" + this.source.alias);
789 }
790 if (num != -1)
791 {
792 t.SetNum(num);
793 }
794 if (c == null || EClass.player.isAutoFarming)
795 {
796 this.TryPick(GrowSystem.cell, t, c, false);
797 return;
798 }
799 c.Pick(t, true, true);
800 }
801
802 // Token: 0x06002E82 RID: 11906 RVA: 0x00106270 File Offset: 0x00104470
803 public void ApplySeed(Thing t)
804 {
805 PlantData plantData = EClass._map.TryGetPlant(GrowSystem.cell);
806 Thing thing = (plantData != null) ? plantData.seed : null;
807 if (EClass._zone.IsUserZone)
808 {
809 thing = null;
810 }
811 if (thing != null)
812 {
813 int encLv = thing.encLV / 10 + ((thing.encLV > 0) ? 1 : 0);
814 foreach (Element element in thing.elements.dict.Values)
815 {
816 if ((!element.IsFoodTrait || t.IsFood) && (element.IsFoodTrait || element.id == 2))
817 {
818 t.elements.ModBase(element.id, element.Value / 10 * 10);
819 }
820 }
821 t.SetEncLv(encLv);
822 t.c_refText = thing.c_refText;
823 t.isCrafted = true;
824 }
825 }
826
827 // Token: 0x06002E83 RID: 11907 RVA: 0x00106368 File Offset: 0x00104568
828 public virtual int GetHp()
829 {
830 return this.source.hp;
831 }
832
833 // Token: 0x04001A4D RID: 6733
834 public static SourceObj.Row[] sourceSnowTree = new SourceObj.Row[]
835 {
836 EClass.sources.objs.map[54],
837 EClass.sources.objs.map[55]
838 };
839
840 // Token: 0x04001A4E RID: 6734
841 public const int DivStage = 30;
842
843 // Token: 0x04001A4F RID: 6735
844 public static Cell cell;
845
846 // Token: 0x04001A50 RID: 6736
847 public static GrowSystem.Stage currentStage;
848
849 // Token: 0x04001A51 RID: 6737
850 public SourceObj.Row source;
851
852 // Token: 0x04001A52 RID: 6738
853 public GrowSystem.Stage[] stages;
854
855 // Token: 0x04001A53 RID: 6739
856 public int[] baseTiles;
857
858 // Token: 0x04001A54 RID: 6740
859 public int harvestTile;
860
861 // Token: 0x04001A55 RID: 6741
862 public int afterHarvestTile;
863
864 // Token: 0x04001A56 RID: 6742
865 public string idHarvestThing;
866
867 // Token: 0x02000BE3 RID: 3043
868 public class Stage
869 {
870 // Token: 0x060045CA RID: 17866 RVA: 0x0015FA93 File Offset: 0x0015DC93
871 public void SetTile(int _tile)
872 {
873 this.tiles = new int[this.Convert(_tile)];
874 }
875
876 // Token: 0x060045CB RID: 17867 RVA: 0x0015FAA8 File Offset: 0x0015DCA8
877 public void SetTile(int tileIdx, params int[] _tiles)
878 {
879 this.tiles = new int[_tiles.Length];
880 for (int i = 0; i < this.tiles.Length; i++)
881 {
882 this.tiles[i] = this.Convert(_tiles[i] + tileIdx);
883 }
884 }
885
886 // Token: 0x060045CC RID: 17868 RVA: 0x0015FAE9 File Offset: 0x0015DCE9
887 public int Convert(int tile)
888 {
889 return this.renderData.ConvertTile(tile);
890 }
891
892 // Token: 0x04002F7A RID: 12154
893 public int[] tiles;
894
895 // Token: 0x04002F7B RID: 12155
896 public int idx;
897
898 // Token: 0x04002F7C RID: 12156
899 public int tileEx;
900
901 // Token: 0x04002F7D RID: 12157
902 public RenderData renderData;
903
904 // Token: 0x04002F7E RID: 12158
905 public bool harvest;
906 }
907}
Definition Cell.cs:10
Definition Chara.cs:12
Definition Point.cs:11
Definition Thing.cs:10