1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
|
using System;
using System.Collections.Generic;
using UnityEngine;
using XUtliPoolLib;
namespace XMainClient
{
internal class XPatrol
{
private List<Vector3> nav_points
{
get
{
bool flag = this._nav_points == null;
if (flag)
{
this._nav_points = ListPool<Vector3>.Get();
}
return this._nav_points;
}
}
private List<float> nav_gap_time
{
get
{
bool flag = this._nav_gap_time == null;
if (flag)
{
this._nav_gap_time = ListPool<float>.Get();
}
return this._nav_gap_time;
}
}
public int PathIndex
{
get
{
return this._path_index;
}
set
{
this._path_index = value;
}
}
public int NavIndex
{
get
{
return this._nav_index;
}
set
{
this._nav_index = value;
}
}
public float NavGap
{
get
{
return this._nav_gap;
}
}
public float NavNodeFinishTime { get; set; }
public bool IsInNavGap { get; set; }
public bool IsPingpong { get; set; }
public bool IsLoop { get; set; }
private List<GameObject> _nav_path = null;
private int _path_index = 0;
private List<Vector3> _nav_points = null;
private List<float> _nav_gap_time = null;
private int _nav_index = 0;
private bool _is_reverse_nav = false;
private float _nav_gap = 0f;
public enum PathType
{
PT_PINGPONG = 1,
PT_LOOP = 0,
PT_NORMAL = 2
}
public void Destroy()
{
bool flag = this._nav_points != null;
if (flag)
{
ListPool<Vector3>.Release(this._nav_points);
}
bool flag2 = this._nav_gap_time != null;
if (flag2)
{
ListPool<float>.Release(this._nav_gap_time);
}
}
public void ToggleNavDir()
{
this._is_reverse_nav = !this._is_reverse_nav;
}
public Vector3 GetCurNavigationPoint()
{
bool flag = this.nav_points.Count == 0;
Vector3 result;
if (flag)
{
result = Vector3.zero;
}
else
{
bool flag2 = this._nav_index >= this.nav_points.Count;
if (flag2)
{
result = this.nav_points[this.nav_points.Count - 1];
}
else
{
result = this.nav_points[this._nav_index];
}
}
return result;
}
public float GetCurNavGap()
{
bool flag = this.nav_gap_time.Count == 0;
float result;
if (flag)
{
result = 0f;
}
else
{
bool flag2 = this._nav_index >= this.nav_gap_time.Count;
if (flag2)
{
result = this.nav_gap_time[this.nav_gap_time.Count - 1];
}
else
{
result = this.nav_gap_time[this._nav_index];
}
}
return result;
}
public Vector3 GetNextNavPos()
{
bool flag = this.nav_points.Count == 0;
Vector3 result;
if (flag)
{
result = Vector3.zero;
}
else
{
bool isPingpong = this.IsPingpong;
if (isPingpong)
{
bool is_reverse_nav = this._is_reverse_nav;
if (is_reverse_nav)
{
bool flag2 = this._nav_index == 0;
if (flag2)
{
this._is_reverse_nav = false;
this._nav_index = 1;
}
else
{
this._nav_index--;
}
}
else
{
bool flag3 = this._nav_index == this.nav_points.Count - 1;
if (flag3)
{
this._is_reverse_nav = true;
this._nav_index--;
}
else
{
this._nav_index++;
}
}
}
else
{
bool flag4 = !this._is_reverse_nav;
if (flag4)
{
bool flag5 = this._nav_index >= this.nav_points.Count - 1;
if (flag5)
{
bool isLoop = this.IsLoop;
if (isLoop)
{
this._nav_index = 0;
}
}
else
{
this._nav_index++;
}
}
else
{
bool flag6 = this._nav_index <= 0;
if (flag6)
{
bool isLoop2 = this.IsLoop;
if (isLoop2)
{
this._nav_index = this.nav_points.Count - 1;
}
}
else
{
this._nav_index--;
}
}
}
bool flag7 = this._nav_index < 0;
if (flag7)
{
this._nav_index = 0;
}
bool flag8 = this._nav_index >= this.nav_points.Count;
if (flag8)
{
this._nav_index = this.nav_points.Count - 1;
}
result = this.GetCurNavigationPoint();
}
return result;
}
public void InitNavPath(string path, XPatrol.PathType type)
{
this._nav_path = XSingleton<XLevelAIMgr>.singleton.PathList;
this._path_index = 0;
this.nav_points.Clear();
this.nav_gap_time.Clear();
string[] array = path.Split(XGlobalConfig.AllSeparators);
bool flag = array.Length % 4 != 0;
if (flag)
{
XSingleton<XDebug>.singleton.AddErrorLog("Format error: ", path, null, null, null, null);
}
else
{
for (int i = 0; i < array.Length; i += 4)
{
this.nav_points.Add(new Vector3(float.Parse(array[i]), float.Parse(array[i + 1]), float.Parse(array[i + 2])));
this.nav_gap_time.Add(float.Parse(array[i + 3]));
}
this.IsPingpong = (type == XPatrol.PathType.PT_PINGPONG);
this.IsLoop = (type == XPatrol.PathType.PT_LOOP);
this._nav_gap = float.Parse(XSingleton<XGlobalConfig>.singleton.GetValue("AINavGap"));
this.NavNodeFinishTime = 0f;
this.IsInNavGap = false;
}
}
public void InitNavPath(XEntityStatistics.RowData raw)
{
this._nav_path = XSingleton<XLevelAIMgr>.singleton.PathList;
this._path_index = 0;
this.nav_points.Clear();
this.nav_gap_time.Clear();
bool flag = raw != null;
if (flag)
{
this._nav_index = 0;
for (int i = 0; i < raw.navigation.Count; i++)
{
this.nav_points.Add(new Vector3(raw.navigation[i, 0], raw.navigation[i, 1], raw.navigation[i, 2]));
this.nav_gap_time.Add(raw.navigation[i, 3]);
}
this.IsPingpong = (raw.IsNavPingpong == 1);
this.IsLoop = (raw.IsNavPingpong == 0);
}
this._nav_gap = float.Parse(XSingleton<XGlobalConfig>.singleton.GetValue("AINavGap"));
this.NavNodeFinishTime = 0f;
this.IsInNavGap = false;
}
public Transform GetFromNavPath(int index)
{
bool flag = this._nav_path == null || this._nav_path.Count == 0;
Transform result;
if (flag)
{
result = null;
}
else
{
bool flag2 = index < 0;
if (flag2)
{
result = this._nav_path[0].transform;
}
else
{
bool flag3 = index >= this._nav_path.Count;
if (flag3)
{
result = this._nav_path[this._nav_path.Count - 1].transform;
}
else
{
result = this._nav_path[index].transform;
}
}
}
return result;
}
}
}
|