-
Notifications
You must be signed in to change notification settings - Fork 8
/
LocalSpaceRichAI.cs
48 lines (45 loc) · 1.47 KB
/
LocalSpaceRichAI.cs
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
using System;
using Pathfinding;
using UnityEngine;
public class LocalSpaceRichAI : RichAI
{
public override void UpdatePath()
{
this.canSearchPath = true;
this.waitingForPathCalc = false;
Path currentPath = this.seeker.GetCurrentPath();
if (currentPath != null && !this.seeker.IsDone())
{
currentPath.Error();
currentPath.Claim(this);
currentPath.Release(this);
}
this.waitingForPathCalc = true;
this.lastRepath = Time.time;
Matrix4x4 matrix = this.graph.GetMatrix();
this.seeker.StartPath(matrix.MultiplyPoint3x4(this.tr.position), matrix.MultiplyPoint3x4(this.target.position));
}
protected override Vector3 UpdateTarget(RichFunnel fn)
{
Matrix4x4 matrix = this.graph.GetMatrix();
Matrix4x4 inverse = matrix.inverse;
Debug.DrawRay(matrix.MultiplyPoint3x4(this.tr.position), Vector3.up * 2f, Color.red);
Debug.DrawRay(inverse.MultiplyPoint3x4(this.tr.position), Vector3.up * 2f, Color.green);
this.buffer.Clear();
Vector3 vector = this.tr.position;
bool flag;
vector = inverse.MultiplyPoint3x4(fn.Update(matrix.MultiplyPoint3x4(vector), this.buffer, 2, out this.lastCorner, out flag));
Debug.DrawRay(vector, Vector3.up * 3f, Color.black);
for (int i = 0; i < this.buffer.Count; i++)
{
this.buffer[i] = inverse.MultiplyPoint3x4(this.buffer[i]);
Debug.DrawRay(this.buffer[i], Vector3.up * 3f, Color.yellow);
}
if (flag && !this.waitingForPathCalc)
{
this.UpdatePath();
}
return vector;
}
public LocalSpaceGraph graph;
}