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
|
using System;
using UnityEngine;
using UnityEngine.AI;
using XUtliPoolLib;
namespace XMainClient
{
internal class XAIMove : XSingleton<XAIMove>
{
private Vector3 _arena_center = Vector3.zero;
public bool NavToTarget(XEntity host, Vector3 oTargetPos, float speed)
{
bool flag = host == null || host.Nav == null;
return !flag && this.NavToPos(host, oTargetPos, speed);
}
public bool NavToPos(XEntity host, Vector3 targetpos, float speed)
{
bool flag = (host.EngineObject.Position - targetpos).magnitude <= 2f;
if (flag)
{
Vector3 vector = host.EngineObject.Position - targetpos;
vector.y = 0f;
host.Net.ReportMoveAction(targetpos, speed, false, false, false, XSingleton<XCommon>.singleton.AngleToFloat(-vector));
}
else
{
NavMeshHit navMeshHit;
bool flag2 = !NavMesh.SamplePosition(host.EngineObject.Position, out navMeshHit, 1f, -1);
if (flag2)
{
host.Net.ReportMoveAction(targetpos, speed, false, false, false, XSingleton<XCommon>.singleton.AngleToFloat(targetpos - host.EngineObject.Position));
}
else
{
XNavigationEventArgs @event = XEventPool<XNavigationEventArgs>.GetEvent();
@event.Firer = host;
@event.Dest = targetpos;
@event.CameraFollow = false;
XSingleton<XEventMgr>.singleton.FireEvent(@event);
bool flag3 = !host.Nav.IsOnNav;
if (flag3)
{
@event.Dest = targetpos + (host.EngineObject.Position - targetpos).normalized * 2f;
XSingleton<XEventMgr>.singleton.FireEvent(@event);
bool flag4 = !host.Nav.IsOnNav;
if (flag4)
{
host.Net.ReportMoveAction(targetpos, speed, false, false, false, XSingleton<XCommon>.singleton.AngleToFloat(targetpos - host.EngineObject.Position));
}
}
}
}
return true;
}
public bool RotateToTarget(XEntity entity, XEntity target)
{
Vector3 position = target.EngineObject.Position;
Vector3 position2 = entity.EngineObject.Position;
Vector3 dir = position - position2;
float magnitude = dir.magnitude;
entity.Net.ReportRotateAction(dir);
return true;
}
public bool FindNavPath(XEntity entity)
{
return entity.AI.RefreshNavTarget();
}
public bool ActionMove(XEntity entity, Vector3 dir, Vector3 dest, float speed)
{
bool flag = entity.Nav != null;
if (flag)
{
this.ActionNav(entity, dest, speed);
}
else
{
bool flag2 = entity.Fly != null;
if (flag2)
{
dest.y = entity.Fly.CurrentHeight + XSingleton<XScene>.singleton.TerrainY(dest);
}
entity.Net.ReportMoveAction(dest, speed * entity.AI.MoveSpeed, false, false, false, 0f);
XSecurityStatistics xsecurityStatistics = XSecurityStatistics.TryGetStatistics(entity);
}
return true;
}
public bool ActionNav(XEntity entity, Vector3 dest, float speedRatio = 1f)
{
XNavigationEventArgs @event = XEventPool<XNavigationEventArgs>.GetEvent();
@event.Firer = entity;
@event.Dest = dest;
@event.CameraFollow = false;
@event.SpeedRatio = speedRatio;
return XSingleton<XEventMgr>.singleton.FireEvent(@event);
}
public bool ActionRotate(XEntity entity, float degree, float speed, int type)
{
Vector3 dir = Quaternion.Euler(new Vector3(0f, degree, 0f)) * ((type == 0) ? entity.EngineObject.Forward : Vector3.forward);
entity.Net.ReportRotateAction(dir, speed, 0L);
return true;
}
public bool RotateToTarget(XEntity entity)
{
bool flag = entity.AI.Target == null;
bool result;
if (flag)
{
result = false;
}
else
{
entity.Net.ReportRotateAction(entity.AI.Target.EngineObject.Position - entity.EngineObject.Position, entity.Attributes.RotateSpeed, 0L);
result = true;
}
return result;
}
public bool UpdateNavigation(XEntity entity, int dir, int oldDir)
{
Vector3 vector = entity.AI.Patrol.GetCurNavigationPoint();
bool flag = vector == Vector3.zero;
bool result;
if (flag)
{
result = false;
}
else
{
bool flag2 = dir != oldDir;
if (flag2)
{
entity.AI.Patrol.ToggleNavDir();
vector = entity.AI.Patrol.GetNextNavPos();
}
else
{
bool flag3 = (entity.EngineObject.Position - vector).magnitude <= 0.5f || entity.AI.Patrol.IsInNavGap;
if (flag3)
{
bool isInNavGap = entity.AI.Patrol.IsInNavGap;
if (isInNavGap)
{
float num = Time.realtimeSinceStartup - entity.AI.Patrol.NavNodeFinishTime;
bool flag4 = num < entity.AI.Patrol.GetCurNavGap();
if (flag4)
{
return true;
}
vector = entity.AI.Patrol.GetNextNavPos();
}
else
{
bool flag5 = entity.AI.Patrol.GetCurNavGap() > 0f;
if (flag5)
{
entity.AI.Patrol.NavNodeFinishTime = Time.realtimeSinceStartup;
entity.AI.Patrol.IsInNavGap = true;
return true;
}
vector = entity.AI.Patrol.GetNextNavPos();
}
}
}
entity.AI.Patrol.IsInNavGap = false;
//(entity.EngineObject.Position - vector).y = 0f;
//!
//(entity.EngineObject.Position - vector).y = 0f;
Vector3 p = entity.EngineObject.Position;
p.y = vector.y;
entity.EngineObject.Position = p;
this.NavToPos(entity, vector, entity.AI.MoveSpeed);
result = true;
}
return result;
}
public bool IsPointInMap(Vector3 pos)
{
return XSingleton<XScene>.singleton.IsWalkable(pos);
}
}
}
|