Elin Modding Docs Doc
Loading...
Searching...
No Matches
TaskWater.cs
1using System;
2using System.Collections.Generic;
3
4// Token: 0x02000260 RID: 608
5public class TaskWater : Task
6{
7 // Token: 0x1700049B RID: 1179
8 // (get) Token: 0x06001120 RID: 4384 RVA: 0x000771C3 File Offset: 0x000753C3
9 public TraitToolWaterCan waterCan
10 {
11 get
12 {
13 Chara chara = this.owner ?? Act.CC;
14 object obj;
15 if (chara == null)
16 {
17 obj = null;
18 }
19 else
20 {
21 Card held = chara.held;
22 obj = ((held != null) ? held.trait : null);
23 }
24 return obj as TraitToolWaterCan;
25 }
26 }
27
28 // Token: 0x06001121 RID: 4385 RVA: 0x000771F1 File Offset: 0x000753F1
29 public override bool CanPerform()
30 {
31 return TaskWater.ShouldWater(Act.TP) && this.IsWaterCanValid(false);
32 }
33
34 // Token: 0x06001122 RID: 4386 RVA: 0x00077208 File Offset: 0x00075408
35 public override bool CanManualCancel()
36 {
37 return true;
38 }
39
40 // Token: 0x06001123 RID: 4387 RVA: 0x0007720B File Offset: 0x0007540B
41 public override IEnumerable<AIAct.Status> Run()
42 {
43 this.dest = new Point(this.dest);
44 List<Point> list = this.ListPoints();
45 for (;;)
46 {
47 TaskWater.<>c__DisplayClass5_0 CS$<>8__locals1 = new TaskWater.<>c__DisplayClass5_0();
48 if (list.Count == 0)
49 {
50 break;
51 }
52 list.Sort((Point a, Point b) => a.Distance(this.dest) - b.Distance(this.dest));
53 Point p = list[0];
54 this.dest.Set(p);
55 list.RemoveAt(0);
56 if (TaskWater.ShouldWater(p))
57 {
58 if (!this.IsWaterCanValid(true))
59 {
60 yield return this.Cancel();
61 }
62 CS$<>8__locals1.fail = false;
63 yield return base.DoGoto(p, 1, false, delegate()
64 {
65 CS$<>8__locals1.fail = true;
66 return AIAct.Status.Running;
67 });
68 if (!CS$<>8__locals1.fail)
69 {
70 if (!this.IsWaterCanValid(true))
71 {
72 yield return this.Cancel();
73 }
74 if (TaskWater.ShouldWater(p))
75 {
76 if (this.owner.Dist(this.dest) > 1)
77 {
78 yield return this.Cancel();
79 }
80 p.cell.isWatered = true;
81 if (!p.cell.blocked && EClass.rnd(5) == 0)
82 {
83 EClass._map.SetLiquid(p.x, p.z, 1, 1);
84 }
85 this.owner.PlaySound("water_farm", 1f, true);
86 this.owner.Say("water_farm", this.owner, p.cell.GetFloorName(), null);
87 this.waterCan.owner.ModCharge(-1, false);
88 this.owner.ModExp(286, 15);
89 if (!this.IsWaterCanValid(true))
90 {
91 yield return this.Cancel();
92 }
93 yield return base.KeepRunning();
94 CS$<>8__locals1 = null;
95 p = null;
96 }
97 }
98 }
99 }
100 yield break;
101 }
102
103 // Token: 0x06001124 RID: 4388 RVA: 0x0007721C File Offset: 0x0007541C
104 public static bool ShouldWater(Point p)
105 {
106 Cell cell = p.cell;
107 if (cell.isWatered || cell.IsTopWater || cell.IsSnowTile || !p.IsFarmField)
108 {
109 return false;
110 }
111 if (p.cell.detail != null)
112 {
113 using (List<Thing>.Enumerator enumerator = p.Things.GetEnumerator())
114 {
115 while (enumerator.MoveNext())
116 {
117 if (enumerator.Current.trait is TraitSeed)
118 {
119 return true;
120 }
121 }
122 }
123 }
124 return p.growth != null;
125 }
126
127 // Token: 0x06001125 RID: 4389 RVA: 0x000772B8 File Offset: 0x000754B8
128 public bool IsWaterCanValid(bool msg = true)
129 {
130 bool flag = this.waterCan != null && this.waterCan.owner.c_charges > 0;
131 if (!flag && msg)
132 {
133 Msg.Say("water_deplete");
134 }
135 return flag;
136 }
137
138 // Token: 0x06001126 RID: 4390 RVA: 0x000772EC File Offset: 0x000754EC
139 public List<Point> ListPoints()
140 {
141 List<Point> list = new List<Point>();
142 EClass._map.bounds.ForeachPoint(delegate(Point p)
143 {
144 if (TaskWater.ShouldWater(p))
145 {
146 list.Add(p.Copy());
147 }
148 });
149 return list;
150 }
151
152 // Token: 0x04000DE1 RID: 3553
153 public Point dest;
154}
Definition AIAct.cs:7
Definition Act.2.cs:7
Definition Card.cs:13
Definition Cell.cs:10
Definition Chara.cs:12
Definition Msg.cs:7
Definition Point.cs:11
Definition Task.cs:6