8 public bool IsLastStage()
10 return this.stage.idx == this.StageLength - 1;
19 return this.source.renderData;
25 public virtual int Step
35 public virtual int StageLength
45 public virtual int DefaultStage
49 return Mathf.Clamp(this.StageLength - 2, 0, this.StageLength - 1);
55 public virtual int HarvestStage
65 public virtual int AutoMineStage
69 return this.HarvestStage;
75 protected virtual int HaltStage
79 return this.HarvestStage;
84 protected virtual bool IsHarvestStage(
int idx)
86 return idx == this.HarvestStage;
91 protected virtual bool DrawHarvestOnTop
101 protected virtual bool UseGenericFirstStageTile
111 protected virtual bool WitherOnLastStage
121 protected virtual bool CanRegrow
131 public virtual int ShadowStage
141 public virtual bool IsTree
151 public virtual bool IsCrimeToHarvest
161 public virtual float MtpProgress
171 public virtual bool NeedSunlight
180 public virtual bool BlockSight(
Cell cell)
186 public virtual bool BlockPass(
Cell cell)
192 public virtual string GetSoundProgress()
194 return "Material/grass";
199 public virtual AnimeID AnimeProgress
203 return AnimeID.HitObj;
213 return this.stages[(int)(
GrowSystem.cell.objVal / 30)];
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++)
233 this.baseTiles[i] = array[i].ToInt();
235 if (growth.Length > 2)
237 this.harvestTile = this.RenderHarvest.ConvertTile(growth[2].ToInt());
238 this.idHarvestThing = growth[3];
240 for (
int j = 0; j < this.StageLength; j++)
243 this.stages[j] = stage;
245 if (j == 0 && this.UseGenericFirstStageTile)
247 this.SetGenericFirstStageTile(stage);
251 this.SetStageTile(stage);
253 if (this.harvestTile != 0 && this.IsHarvestStage(j))
255 stage.harvest =
true;
263 s.renderData =
EClass.core.refs.renderers.objS_flat;
264 s.SetTile(0,
new int[]
275 s.renderData = this.source.renderData;
276 s.SetTile(s.idx + (
this.UseGenericFirstStageTile ? -1 : 0),
this.baseTiles);
280 public virtual int GetStageTile()
282 return GrowSystem.currentStage.tiles[GrowSystem.cell.objDir %
GrowSystem.currentStage.tiles.Length];
286 public virtual int GetShadow(
int index)
295 GrowSystem.currentStage = this.stages[num];
299 if (num != 0 || !this.UseGenericFirstStageTile)
306 if (
GrowSystem.cell.isHarvested ||
this.harvestTile == 0)
308 p.tile = (float)((this.afterHarvestTile != 0) ? this.afterHarvestTile : this.GetStageTile());
313 if (this.DrawHarvestOnTop)
315 p.tile = (float)this.GetStageTile();
319 p.tile = (float)this.harvestTile;
320 this.RenderHarvest.Draw(p);
325 p.tile = (float)this.GetStageTile();
330 if (num < this.ShadowStage)
334 int shadow = this.GetShadow(num);
337 shadow = row.pref.shadow;
339 if (shadow > 1 && !
GrowSystem.cell.ignoreObjShadow)
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);
346 public void SetRandomStage()
348 int num = Rand.rnd(this.stages.Length);
349 if (num == 0 &&
EClass.rnd(5) != 0 &&
this.stages.Length >= 2)
353 else if (num == this.stages.Length - 1 &&
EClass.rnd(5) != 0 &&
this.stages.Length >= 2)
357 GrowSystem.cell.objVal = (byte)(num * 30);
361 public void SetDefaultStage()
363 GrowSystem.cell.objVal = (byte)(this.DefaultStage * 30);
369 if (this.source.id == 0)
377 if (this.NeedSunlight)
379 if (date.sunMap ==
null)
394 if (!this.CanGrow(date))
402 public void EqualizePlants(
Point pos)
405 if (p1 ==
null || p1.seed ==
null)
409 pos.ForeachNeighbor(delegate(
Point pos2)
412 Thing thing = (plantData !=
null) ? plantData.seed :
null;
415 Thing installed = pos2.Installed;
416 if (installed !=
null && installed.id == p1.seed.id)
425 if (p1.seed.refVal != thing.refVal)
429 if (thing.encLV >= p1.seed.encLV)
437 public void Grow(
int mtp = 1)
439 bool flag = GrowSystem.cell.isWatered || (GrowSystem.cell.IsTopWater && this.source.tag.Contains(
"flood"));
441 if (plantData !=
null && flag)
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;
450 if (
EClass.player.isAutoFarming && num2 ==
this.HarvestStage &&
this.CanHarvest())
452 this.PopHarvest(
null,
null, -1);
454 if (
EClass.player.isAutoFarming && num2 >=
this.AutoMineStage)
457 this.EqualizePlants(point);
458 Thing thing = this.TryPopSeed(
null);
459 this.PopMineObj(
null);
462 point.SetObj(0, 1, 0);
463 EClass._zone.AddCard(thing, point).Install();
466 else if (num2 == this.StageLength - 1)
468 if (
EClass.player.isAutoFarming)
471 this.EqualizePlants(point2);
472 Thing thing2 = this.TryPopSeed(
null);
475 point2.SetObj(0, 1, 0);
476 EClass._zone.AddCard(thing2, point2).Install();
481 this.OnExceedLastStage();
486 this.OnReachNextStage();
492 cell.objVal += (byte)num;
499 public virtual void OnReachNextStage()
501 this.SetStage((
int)(
GrowSystem.cell.objVal / 30 + 1),
false);
505 public virtual void OnExceedLastStage()
507 GrowSystem.cell.objVal = (byte)(this.stages.Length * 30 - 1);
512 if (Rand.rnd(2) == 0)
515 if (point.IsFarmField)
519 if (Rand.rnd(2) == 0)
521 Point randomNeighbor = point.GetRandomNeighbor();
522 if (randomNeighbor.cell.CanGrowWeed)
524 randomNeighbor.SetObj((
int)
GrowSystem.cell.obj, 1, 0);
525 point.SetObj(0, 1, 0);
529 GrowSystem.cell.objVal = 0;
530 GrowSystem.cell.isHarvested =
false;
531 GrowSystem.cell.isWatered =
GrowSystem.cell.HasLiquid;
536 public void SetStage(
int idx,
bool renewHarvest =
false)
538 GrowSystem.cell.objVal = (byte)(idx * 30);
539 GrowSystem.cell.gatherCount = 0;
542 GrowSystem.cell.isWatered =
true;
546 GrowSystem.cell.isHarvested =
true;
551 public bool HaltGrowth()
553 return this.stage.idx == this.HarvestStage;
558 public virtual bool IsMature
569 if (
EClass.player.isAutoFarming)
571 if (this.CanHarvest())
573 this.PopHarvest(
null,
null, -1);
575 Thing thing = this.TryPopSeed(
null);
583 if (this.WitherOnLastStage && this.stage.idx ==
this.StageLength - 2)
585 this.SetStage(this.StageLength - 1,
false);
590 Thing thing2 = this.TryPopSeed(
null);
600 public bool IsWithered()
602 return this.WitherOnLastStage && this.stage.idx == this.StageLength - 1;
606 public bool CanHarvest()
608 return this.stage.harvest && !
GrowSystem.cell.isHarvested;
612 public virtual bool CanReapSeed()
614 return this.CanHarvest();
618 public virtual void OnHit(
Chara c)
623 public virtual void OnHitFail(
Chara c)
628 public void OnProgressComplete(
Chara c)
634 public void PopMineObj(
Chara c =
null)
641 public virtual void OnMineObj(
Chara c =
null)
643 if (!this.IsWithered())
645 int num = GrowSystem.cell.sourceObj.components.Length - 1;
652 public void TryPick(
Cell cell,
Thing t,
Chara c,
bool applySeed =
false)
658 if (
EClass.player.isAutoFarming)
668 else if (
EClass.rnd(2) == 0)
672 if (!
EClass._zone.TryAddThingInSharedContainer(t,
null,
true,
false,
null,
true))
674 EClass.game.cards.container_shipping.AddCard(t);
680 EClass._map.TrySmoothPick(cell, t, c);
685 public void TryPick(
Cell cell,
string idThing,
int idMat = -1,
int num = 1,
bool applySeed =
false)
691 this.TryPick(cell,
ThingGen.Create(idThing, idMat, -1).SetNum(num),
EClass.pc, applySeed);
697 if (this.source.HasTag(CTAG.seed))
699 int num = GrowSystem.cell.IsFarmField ? 400 : 1000;
700 if (
EClass._zone.IsPCFaction)
702 int soilCost =
EClass._zone.GetSoilCost();
703 int maxSoil =
EClass.Branch.MaxSoil;
704 if (soilCost > maxSoil)
706 num += (soilCost - maxSoil) * 10;
709 if (this.IsWithered())
716 if (
EClass.player.isAutoFarming)
720 this.TryPick(
GrowSystem.cell, thing, c,
false);
728 public void Harvest(
Chara c)
730 GrowSystem.cell.isHarvested =
true;
731 GrowSystem.cell.gatherCount = 0;
732 this.PopHarvest(c,
null, -1);
736 public void PopHarvest(
Chara c,
string idThing,
int num = -1)
738 this.PopHarvest(c,
ThingGen.Create(idThing, -1, -1), num);
742 public void PopHarvest(
Chara c,
Thing t =
null,
int num = -1)
746 if (this.idHarvestThing.StartsWith(
'#'))
748 t =
ThingGen.CreateFromCategory(this.idHarvestThing.Replace(
"#",
""), -1);
752 t =
ThingGen.Create(this.idHarvestThing.IsEmpty(
"apple"), -1, -1);
757 if (plantData !=
null && plantData.size > 0)
759 t.c_weight = t.SelfWeight * (80 + plantData.size * plantData.size * 100) / 100;
760 t.SetBool(115,
true);
761 t.isWeightChanged =
true;
763 t.SetBlessedState(BlessedState.Normal);
764 if (this.source._growth.Length > 4)
766 int num2 =
EClass.rnd(this.source._growth[4].ToInt()) + 1;
767 if (
EClass._zone.IsPCFaction)
769 int soilCost =
EClass._zone.GetSoilCost();
770 int maxSoil =
EClass.Branch.MaxSoil;
771 if (soilCost > maxSoil &&
EClass.player.stats.days >= 5)
773 num2 -=
EClass.rnd(2 + (soilCost - maxSoil) / 20);
778 if (!
EClass.player.isAutoFarming)
780 c.Say(
"cropSpoiled", c,
GrowSystem.cell.GetObjName(),
null);
788 Debug.Log(
"harvest count not set:" + this.source.id.ToString() +
"/" +
this.source.alias);
794 if (c ==
null ||
EClass.player.isAutoFarming)
799 c.Pick(t,
true,
true);
803 public void ApplySeed(
Thing t)
806 Thing thing = (plantData !=
null) ? plantData.seed :
null;
807 if (
EClass._zone.IsUserZone)
813 int encLv = thing.encLV / 10 + ((thing.encLV > 0) ? 1 : 0);
814 foreach (
Element element
in thing.elements.dict.Values)
816 if ((!element.IsFoodTrait || t.IsFood) && (element.IsFoodTrait || element.id == 2))
818 t.elements.ModBase(element.id, element.Value / 10 * 10);
822 t.c_refText = thing.c_refText;
828 public virtual int GetHp()
830 return this.source.hp;
836 EClass.sources.objs.map[54],
837 EClass.sources.objs.map[55]
841 public const int DivStage = 30;
844 public static Cell cell;
856 public int[] baseTiles;
859 public int harvestTile;
862 public int afterHarvestTile;
865 public string idHarvestThing;
871 public void SetTile(
int _tile)
873 this.tiles =
new int[this.Convert(_tile)];
877 public void SetTile(
int tileIdx, params
int[] _tiles)
879 this.tiles =
new int[_tiles.Length];
880 for (
int i = 0; i < this.tiles.Length; i++)
882 this.tiles[i] = this.Convert(_tiles[i] + tileIdx);
887 public int Convert(
int tile)
889 return this.renderData.ConvertTile(tile);