Elin Modding Docs Doc
Loading...
Searching...
No Matches
AI_Goto.cs
1using System;
2using System.Collections.Generic;
3using Algorithms;
4
5// Token: 0x020001DE RID: 478
6public class AI_Goto : AIAct
7{
8 // Token: 0x17000389 RID: 905
9 // (get) Token: 0x06000DC8 RID: 3528 RVA: 0x0006A168 File Offset: 0x00068368
10 public override bool UseTurbo
11 {
12 get
13 {
14 return false;
15 }
16 }
17
18 // Token: 0x1700038A RID: 906
19 // (get) Token: 0x06000DC9 RID: 3529 RVA: 0x0006A16B File Offset: 0x0006836B
20 public override bool CancelWhenDamaged
21 {
22 get
23 {
24 return !EClass._zone.IsRegion;
25 }
26 }
27
28 // Token: 0x1700038B RID: 907
29 // (get) Token: 0x06000DCA RID: 3530 RVA: 0x0006A17A File Offset: 0x0006837A
30 public override bool CancelWhenMoved
31 {
32 get
33 {
34 return true;
35 }
36 }
37
38 // Token: 0x1700038C RID: 908
39 // (get) Token: 0x06000DCB RID: 3531 RVA: 0x0006A17D File Offset: 0x0006837D
40 public override bool InformCancel
41 {
42 get
43 {
44 return false;
45 }
46 }
47
48 // Token: 0x06000DCC RID: 3532 RVA: 0x0006A180 File Offset: 0x00068380
49 public override bool CanManualCancel()
50 {
51 return true;
52 }
53
54 // Token: 0x1700038D RID: 909
55 // (get) Token: 0x06000DCD RID: 3533 RVA: 0x0006A183 File Offset: 0x00068383
56 public override bool PushChara
57 {
58 get
59 {
60 AIAct parent = this.parent;
61 return parent == null || parent.PushChara;
62 }
63 }
64
65 // Token: 0x06000DCE RID: 3534 RVA: 0x0006A196 File Offset: 0x00068396
66 public override Point GetDestination()
67 {
68 if (this.destCard != null)
69 {
70 return this.destCard.pos;
71 }
72 return this.dest;
73 }
74
75 // Token: 0x06000DCF RID: 3535 RVA: 0x0006A1B2 File Offset: 0x000683B2
76 public AI_Goto(Point _dest, int dist, bool _ignoreConnection = false, bool _interaction = false)
77 {
78 this.dest.Set(_dest);
79 this.destDist = dist;
80 this.ignoreConnection = _ignoreConnection;
81 this.interaction = _interaction;
82 }
83
84 // Token: 0x06000DD0 RID: 3536 RVA: 0x0006A1E8 File Offset: 0x000683E8
85 public AI_Goto(Card _card, int dist, bool _ignoreConnection = false, bool _interaction = false)
86 {
87 this.destCard = _card;
88 this.destDist = dist;
89 this.ignoreConnection = _ignoreConnection;
90 this.interaction = _interaction;
91 }
92
93 // Token: 0x06000DD1 RID: 3537 RVA: 0x0006A218 File Offset: 0x00068418
94 public override void OnReset()
95 {
96 this.owner.path.state = PathProgress.State.Idle;
97 }
98
99 // Token: 0x06000DD2 RID: 3538 RVA: 0x0006A22C File Offset: 0x0006842C
100 public AIAct.Status TryGoTo()
101 {
102 PathProgress path = this.owner.path;
103 Point pos = this.owner.pos;
104 if (this.owner.IsPC)
105 {
106 if (this.dest.x > EClass._map.bounds.maxX + 1)
107 {
108 this.dest.x = EClass._map.bounds.maxX + 1;
109 }
110 else if (this.dest.x < EClass._map.bounds.x - 1)
111 {
112 this.dest.x = EClass._map.bounds.x - 1;
113 }
114 if (this.dest.z > EClass._map.bounds.maxZ + 1)
115 {
116 this.dest.z = EClass._map.bounds.maxZ + 1;
117 }
118 else if (this.dest.z < EClass._map.bounds.z - 1)
119 {
120 this.dest.z = EClass._map.bounds.z - 1;
121 }
122 }
123 if ((this.repath || (this.owner.IsPC && ActionMode.IsAdv)) && path.state == PathProgress.State.Idle)
124 {
125 path.RequestPathImmediate(pos, this.dest, this.destDist, this.ignoreConnection, -1);
126 this.repath = false;
127 }
128 switch (path.state)
129 {
130 case PathProgress.State.Idle:
131 path.RequestPath(pos, this.dest, this.destDist, this.ignoreConnection, -1);
132 break;
133 case PathProgress.State.PathReady:
134 {
135 if (path.nodeIndex < 0)
136 {
137 return this.Cancel();
138 }
139 PathFinderNode pathFinderNode = path.nodes[path.nodeIndex];
140 if (this.owner.IsPC && ActionMode.IsAdv && path.nodeIndex > 2)
141 {
142 ActionMode.Adv.SetTurbo(-1);
143 }
144 Point shared = Point.GetShared(pathFinderNode.X, pathFinderNode.Z);
145 if (shared.x == this.owner.pos.x && shared.z == this.owner.pos.z && path.nodeIndex > 0 && !shared.cell.HasLadder && !this.owner.Cell.HasLadder)
146 {
147 path.nodeIndex--;
148 pathFinderNode = path.nodes[path.nodeIndex];
149 shared.Set(pathFinderNode.X, pathFinderNode.Z);
150 }
151 if (shared.HasChara && !this.owner.IsPC)
152 {
153 this.waitCount++;
154 if (this.waitCount < 3 || EClass.rnd(5) != 0)
155 {
156 return AIAct.Status.Running;
157 }
158 }
159 this.waitCount = 0;
160 Card.MoveResult moveResult = this.owner.TryMove(shared, true);
161 if (this.owner == null)
162 {
163 return AIAct.Status.Running;
164 }
165 if (moveResult == Card.MoveResult.Fail || moveResult == Card.MoveResult.Door)
166 {
167 if (this.owner.IsPC && ActionMode.IsAdv)
168 {
169 return this.Cancel();
170 }
171 return base.Restart();
172 }
173 else
174 {
175 if (!this.owner.pos.Equals(shared))
176 {
177 path.state = PathProgress.State.Idle;
178 this.repath = true;
179 }
180 path.nodeIndex--;
181 if (this.IsDestinationReached())
182 {
183 return base.Success(null);
184 }
185 }
186 break;
187 }
188 case PathProgress.State.Fail:
189 return this.Cancel();
190 }
191 return AIAct.Status.Running;
192 }
193
194 // Token: 0x06000DD3 RID: 3539 RVA: 0x0006A584 File Offset: 0x00068784
195 public bool IsDestinationReached()
196 {
197 if (this.destCard != null)
198 {
199 int num = this.destCard.pos.Distance(this.owner.pos);
200 return (this.interaction && num == 1 && this.owner.CanInteractTo(this.owner.pos)) || num <= this.destDist;
201 }
202 int num2 = Util.Distance(this.owner.pos.x, this.owner.pos.z, this.dest.x, this.dest.z);
203 return (this.interaction && num2 == 1 && this.owner.CanInteractTo(this.dest)) || num2 <= this.destDist;
204 }
205
206 // Token: 0x06000DD4 RID: 3540 RVA: 0x0006A651 File Offset: 0x00068851
207 public override IEnumerable<AIAct.Status> Run()
208 {
209 if (this.owner.host != null)
210 {
211 yield return this.Cancel();
212 }
213 for (;;)
214 {
215 if (this.destCard != null)
216 {
217 this.dest.Set(this.GetDestination());
218 }
219 while (this.owner.path.state == PathProgress.State.Searching)
220 {
221 yield return AIAct.Status.Running;
222 }
223 this.owner.path.state = PathProgress.State.Idle;
224 if (this.IsDestinationReached())
225 {
226 yield return base.Success(null);
227 }
228 EClass.player.enemySpotted = false;
229 for (;;)
230 {
231 if (this.owner.IsPC)
232 {
233 if (EClass.player.TooHeavyToMove())
234 {
235 yield return this.Cancel();
236 }
237 if (EClass.player.enemySpotted)
238 {
239 EClass.player.enemySpotted = false;
240 Msg.Say("enemy_spotted");
241 yield return this.Cancel();
242 }
243 }
244 yield return this.TryGoTo();
245 if (this.destCard != null)
246 {
247 Point destination = this.GetDestination();
248 int num = this.dest.Distance(destination);
249 if (num > 3 && num < 20)
250 {
251 break;
252 }
253 }
254 }
255 this.repath = true;
256 this.owner.path.state = PathProgress.State.Idle;
257 }
258 yield break;
259 }
260
261 // Token: 0x04000D1F RID: 3359
262 public Card destCard;
263
264 // Token: 0x04000D20 RID: 3360
265 public Point dest = new Point();
266
267 // Token: 0x04000D21 RID: 3361
268 public int destDist;
269
270 // Token: 0x04000D22 RID: 3362
271 public int waitCount;
272
273 // Token: 0x04000D23 RID: 3363
274 public bool ignoreConnection;
275
276 // Token: 0x04000D24 RID: 3364
277 public bool interaction;
278
279 // Token: 0x04000D25 RID: 3365
280 public bool repath;
281}
Definition AIAct.cs:7
Definition Card.cs:13
Definition Msg.cs:7
Definition Point.cs:11