Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
GoalManualMove.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using UnityEngine;
3
4public class GoalManualMove : Goal
5{
6 public static Point dest = new Point();
7
8 public static Point lastPoint = new Point();
9
10 public static Point lastlastPoint = new Point();
11
12 public static Vector2 lastMove;
13
14 public static bool hasMoved;
15
16 public override bool CancelWhenDamaged => false;
17
18 public override bool UseTurbo => false;
19
20 public override IEnumerable<Status> Run()
21 {
22 hasMoved = false;
23 bool willEnd = false;
24 while (true)
25 {
27 {
28 yield return Cancel();
29 }
30 if (EClass.player.nextMove == Vector2.zero)
31 {
33 {
34 willEnd = true;
35 EClass.player.nextMove = lastMove;
36 }
37 else
38 {
39 yield return Success();
40 }
41 }
43 {
47 }
49 dest.x += (int)EClass.player.nextMove.x;
50 dest.z += (int)EClass.player.nextMove.y;
51 if (!dest.IsValid)
52 {
53 EClass.player.nextMove = Vector2.zero;
55 yield return Success();
56 }
57 if (!TryMove((int)EClass.player.nextMove.x, (int)EClass.player.nextMove.y) && !TryAltMove())
58 {
59 EClass.player.nextMove = Vector2.zero;
61 yield return Success();
62 }
64 dest.x += (int)EClass.player.nextMove.x;
65 dest.z += (int)EClass.player.nextMove.y;
68 {
70 if (willEnd)
71 {
72 yield return Success();
73 }
74 hasMoved = true;
75 }
76 else
77 {
78 EClass.player.nextMove = Vector2.zero;
80 yield return Success();
81 }
83 {
86 }
87 yield return Status.Running;
88 }
89 }
90
91 public static bool CanMove()
92 {
93 Vector2 nextMove = EClass.player.nextMove;
94 Vector2 vector = lastMove;
95 Point point = lastPoint.Copy();
96 Point point2 = lastlastPoint.Copy();
98 {
102 }
103 if (!TryMove((int)EClass.player.nextMove.x, (int)EClass.player.nextMove.y) && !TryAltMove())
104 {
105 lastMove = vector;
106 lastPoint.Set(point);
107 lastlastPoint.Set(point2);
108 EClass.player.nextMove = nextMove;
109 return false;
110 }
112 dest.x += (int)EClass.player.nextMove.x;
113 dest.z += (int)EClass.player.nextMove.y;
115 lastMove = vector;
116 lastPoint.Set(point);
117 lastlastPoint.Set(point2);
118 EClass.player.nextMove = nextMove;
119 if (dest.IsInBounds && !dest.Equals(EClass.pc.pos) && !EClass.pc.IsEnemyOnPath(dest, cancelAI: false))
120 {
121 return true;
122 }
123 return false;
124 }
125
126 public static bool TryAltMove()
127 {
128 float x = EClass.player.nextMove.x;
129 float y = EClass.player.nextMove.y;
130 bool extraTurnaround = EClass.core.config.test.extraTurnaround;
131 if (y == 1f)
132 {
133 if (x == 1f)
134 {
135 if (!TryMove(1, 0) && !TryMove(0, 1))
136 {
137 if (extraTurnaround)
138 {
139 if (!TryMove(1, -1))
140 {
141 return TryMove(-1, 1);
142 }
143 return true;
144 }
145 return false;
146 }
147 return true;
148 }
149 if (x == 0f)
150 {
151 if (!TryMove(1, 1) && !TryMove(-1, 1))
152 {
153 if (extraTurnaround)
154 {
155 if (!TryMove(1, 0))
156 {
157 return TryMove(-1, 0);
158 }
159 return true;
160 }
161 return false;
162 }
163 return true;
164 }
165 if (!TryMove(0, 1) && !TryMove(-1, 0))
166 {
167 if (extraTurnaround)
168 {
169 if (!TryMove(1, 1))
170 {
171 return TryMove(-1, -1);
172 }
173 return true;
174 }
175 return false;
176 }
177 return true;
178 }
179 if (y == 0f)
180 {
181 if (x == 1f)
182 {
183 if (!TryMove(1, -1) && !TryMove(1, 1))
184 {
185 if (extraTurnaround)
186 {
187 if (!TryMove(0, -1))
188 {
189 return TryMove(0, 1);
190 }
191 return true;
192 }
193 return false;
194 }
195 return true;
196 }
197 if (!TryMove(-1, 1) && !TryMove(-1, -1))
198 {
199 if (extraTurnaround)
200 {
201 if (!TryMove(0, 1))
202 {
203 return TryMove(0, -1);
204 }
205 return true;
206 }
207 return false;
208 }
209 return true;
210 }
211 if (x == 1f)
212 {
213 if (!TryMove(0, -1) && !TryMove(1, 0))
214 {
215 if (extraTurnaround)
216 {
217 if (!TryMove(-1, -1))
218 {
219 return TryMove(1, 1);
220 }
221 return true;
222 }
223 return false;
224 }
225 return true;
226 }
227 if (x == 0f)
228 {
229 if (!TryMove(-1, -1) && !TryMove(1, -1))
230 {
231 if (extraTurnaround)
232 {
233 if (!TryMove(-1, 0))
234 {
235 return TryMove(1, 0);
236 }
237 return true;
238 }
239 return false;
240 }
241 return true;
242 }
243 if (!TryMove(-1, 0) && !TryMove(0, -1))
244 {
245 if (extraTurnaround)
246 {
247 if (!TryMove(-1, 1))
248 {
249 return TryMove(1, -1);
250 }
251 return true;
252 }
253 return false;
254 }
255 return true;
256 }
257
258 public static bool TryMove(int x, int z)
259 {
261 Point.shared.x += x;
262 Point.shared.z += z;
265 {
266 EClass.player.nextMove.x = x;
267 EClass.player.nextMove.y = z;
268 return true;
269 }
270 return false;
271 }
272}
virtual Status Cancel()
Definition: AIAct.cs:291
Status
Definition: AIAct.cs:8
Point pos
Definition: Card.cs:55
AIAct ai
Definition: Chara.cs:187
Point GetFirstStep(Point newPoint, PathManager.MoveType moveType=PathManager.MoveType.Default)
Definition: Chara.cs:2279
MoveResult TryMove(Point newPoint, bool allowDestroyPath=true)
Definition: Chara.cs:2422
bool IsEnemyOnPath(Point p, bool cancelAI=true)
Definition: Chara.cs:2202
bool extraMoveCancel
Definition: CoreConfig.cs:539
bool extraTurnaround
Definition: CoreConfig.cs:531
CoreConfig config
Definition: Core.cs:70
Definition: EClass.cs:5
static Core core
Definition: EClass.cs:6
static Player player
Definition: EClass.cs:12
static Chara pc
Definition: EClass.cs:14
static Vector2 lastMove
static bool hasMoved
override IEnumerable< Status > Run()
static Point lastlastPoint
static Point lastPoint
static bool TryAltMove()
static bool CanMove()
override bool CancelWhenDamaged
static Point dest
static bool TryMove(int x, int z)
override bool UseTurbo
Definition: Goal.cs:4
bool TooHeavyToMove()
Definition: Player.cs:2331
Vector2 nextMove
Definition: Player.cs:1014
Definition: Point.cs:9
static Point shared
Definition: Point.cs:20
static Point Invalid
Definition: Point.cs:28
Point Copy()
Definition: Point.cs:467
Point Set(int _x, int _z)
Definition: Point.cs:479
int z
Definition: Point.cs:39
bool Equals(int _x, int _z)
Definition: Point.cs:924
bool IsValid
Definition: Point.cs:88
bool IsInBounds
Definition: Point.cs:104