Elin Modding Docs Doc
Loading...
Searching...
No Matches
PathManager.cs
1using System;
2using System.Collections.Generic;
3using System.Threading;
4using Algorithms;
5using UnityEngine;
6
7// Token: 0x020000B9 RID: 185
8public class PathManager : MonoBehaviour
9{
10 // Token: 0x1700010A RID: 266
11 // (get) Token: 0x060004D9 RID: 1241 RVA: 0x00022099 File Offset: 0x00020299
12 public IPathfinder pathfinder
13 {
14 get
15 {
16 return this._pathfinder;
17 }
18 }
19
20 // Token: 0x060004DA RID: 1242 RVA: 0x000220A1 File Offset: 0x000202A1
21 private void Awake()
22 {
23 PathManager.Instance = this;
24 }
25
26 // Token: 0x060004DB RID: 1243 RVA: 0x000220A9 File Offset: 0x000202A9
27 public void RequestPath(PathProgress progress)
28 {
29 PathManager.requestCount++;
30 progress.state = PathProgress.State.Searching;
31 ThreadPool.QueueUserWorkItem(delegate(object a)
32 {
33 new PathThread().Start(progress);
34 });
35 }
36
37 // Token: 0x060004DC RID: 1244 RVA: 0x000220E0 File Offset: 0x000202E0
38 public void RequestPathImmediate(PathProgress progress)
39 {
40 PathManager.requestCount++;
41 this.pathfinder.FindPath(progress);
42 }
43
44 // Token: 0x060004DD RID: 1245 RVA: 0x000220FC File Offset: 0x000202FC
45 public bool IsPathClear(Point origin, Point dest, IPathfindWalker walker, int radius)
46 {
47 PathManager.tempProgress.walker = walker;
48 PathManager.tempProgress.moveType = PathManager.MoveType.Default;
49 PathManager.tempProgress.RequestPathImmediate(origin, dest, 0, false, -1);
50 return PathManager.tempProgress.nodes.Count > 0 && PathManager.tempProgress.nodes.Count < radius;
51 }
52
53 // Token: 0x060004DE RID: 1246 RVA: 0x00022155 File Offset: 0x00020355
54 public PathProgress RequestPathImmediate(Point origin, Point dest, IPathfindWalker walker, PathManager.MoveType moveType = PathManager.MoveType.Default, int searchLimit = -1, int destDist = 0)
55 {
56 PathManager.tempProgress.walker = walker;
57 PathManager.tempProgress.moveType = moveType;
58 PathManager.tempProgress.RequestPathImmediate(origin, dest, destDist, false, searchLimit);
59 return PathManager.tempProgress;
60 }
61
62 // Token: 0x060004DF RID: 1247 RVA: 0x00022184 File Offset: 0x00020384
63 public Point GetFirstStep(Point origin, Point _dest, IPathfindWalker walker, int maxDist = 20, PathManager.MoveType moveType = PathManager.MoveType.Default)
64 {
65 Point dest = _dest.Copy();
66 Point point = this._GetFirstStep(origin, dest, walker, maxDist, moveType);
67 if (point.IsValid)
68 {
69 return point;
70 }
71 return Point.Invalid;
72 }
73
74 // Token: 0x060004E0 RID: 1248 RVA: 0x000221B8 File Offset: 0x000203B8
75 public Point _GetFirstStep(Point origin, Point dest, IPathfindWalker walker, int maxDist = 20, PathManager.MoveType moveType = PathManager.MoveType.Default)
76 {
77 if (!dest.IsValid || (dest.cell.blocked && origin.Distance(dest) <= 1))
78 {
79 return Point.Invalid;
80 }
81 PathManager.tempProgress.walker = walker;
82 PathManager.tempProgress.moveType = moveType;
83 PathManager.tempProgress.RequestPathImmediate(origin, dest, (moveType == PathManager.MoveType.Combat) ? 1 : 0, false, maxDist);
84 if (!PathManager.tempProgress.HasPath)
85 {
86 return Point.Invalid;
87 }
88 List<PathFinderNode> nodes = PathManager.tempProgress.nodes;
89 if (nodes.Count <= 0)
90 {
91 return Point.Invalid;
92 }
93 PathFinderNode pathFinderNode = nodes[nodes.Count - 1];
94 if (pathFinderNode.X == origin.x && pathFinderNode.Z == origin.z && nodes.Count > 1)
95 {
96 pathFinderNode = nodes[nodes.Count - 2];
97 }
98 if (Mathf.Abs(pathFinderNode.X - origin.x) > 1 || Mathf.Abs(pathFinderNode.Z - origin.z) > 1)
99 {
100 return Point.Invalid;
101 }
102 Point point = new Point(pathFinderNode.X, pathFinderNode.Z);
103 if (point.x == origin.x && point.z == origin.z)
104 {
105 return Point.Invalid;
106 }
107 return point;
108 }
109
110 // Token: 0x060004E1 RID: 1249 RVA: 0x000222F0 File Offset: 0x000204F0
111 public void OnGridModified()
112 {
113 }
114
115 // Token: 0x04000652 RID: 1618
116 public static int requestCount;
117
118 // Token: 0x04000653 RID: 1619
119 public static PathManager Instance;
120
121 // Token: 0x04000654 RID: 1620
122 public static PathProgress tempProgress = new PathProgress();
123
124 // Token: 0x04000655 RID: 1621
125 public PathFinder _pathfinder;
126
127 // Token: 0x04000656 RID: 1622
128 public int searchLimit = 1000000;
129
130 // Token: 0x02000806 RID: 2054
131 public enum MoveType
132 {
133 // Token: 0x04002290 RID: 8848
134 Default,
135 // Token: 0x04002291 RID: 8849
136 Combat
137 }
138}
Definition Point.cs:11