Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
TraitFertilizer.cs
Go to the documentation of this file.
1public class TraitFertilizer : Trait
2{
3 public override bool CanExtendBuild => true;
4
5 public bool Defertilize => this is TraitDefertilizer;
6
7 public override void OnSimulateHour(VirtualDate date)
8 {
10 {
11 return;
12 }
14 bool flag = false;
15 if (Defertilize)
16 {
17 if (plantData == null)
18 {
19 plantData = EClass._map.AddPlant(owner.pos, null);
20 }
21 plantData.fert = -1;
22 }
23 else
24 {
25 foreach (Card item in owner.pos.ListCards())
26 {
27 if (item.trait is TraitSeed && !item.isSale)
28 {
29 flag = true;
30 (item.trait as TraitSeed).TrySprout(force: true, sucker: true);
31 break;
32 }
33 }
34 if (!owner.pos.HasObj)
35 {
36 if (flag)
37 {
38 return;
39 }
41 }
42 else if (plantData == null)
43 {
44 if (owner.pos.growth == null)
45 {
46 return;
47 }
48 owner.pos.growth.TryGrow(date);
49 }
50 else if (plantData.fert == 0 && owner.pos.growth != null)
51 {
52 owner.pos.growth.TryGrow(date);
53 }
54 plantData = EClass._map.TryGetPlant(owner.Cell);
55 if (plantData != null)
56 {
57 plantData.fert++;
58 }
59 }
60 if (date.IsRealTime)
61 {
62 owner.PlaySound("mutation");
63 owner.PlayEffect("mutation");
64 }
65 owner.Destroy();
66 }
67}
Definition: Card.cs:11
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:5404
Point pos
Definition: Card.cs:55
Effect PlayEffect(string id, bool useRenderPos=true, float range=0f, Vector3 fix=default(Vector3))
Definition: Card.cs:5438
void Destroy()
Definition: Card.cs:4538
bool IsInstalled
Definition: Card.cs:2241
Cell Cell
Definition: Card.cs:1931
Definition: EClass.cs:5
static Map _map
Definition: EClass.cs:18
void TryGrow(VirtualDate date)
Definition: GrowSystem.cs:288
PlantData TryGetPlant(Point p)
Definition: Map.cs:1920
PlantData AddPlant(Point pos, Thing seed)
Definition: Map.cs:1930
void SetObj(int x, int z, int id=0, int value=1, int dir=0)
Definition: Map.cs:1522
int fert
Definition: PlantData.cs:12
List< Card > ListCards(bool includeMasked=false)
Definition: Point.cs:1015
int x
Definition: Point.cs:36
int z
Definition: Point.cs:39
bool HasObj
Definition: Point.cs:137
GrowSystem growth
Definition: Point.cs:77
override bool CanExtendBuild
override void OnSimulateHour(VirtualDate date)
Definition: Trait.cs:7
Card owner
Definition: Trait.cs:26
bool IsRealTime
Definition: VirtualDate.cs:7