23 public class Storage : IAStarStorage<Vector3> {
40 public class World : IAStarWorld<Vector3> {
60 float num = MathF.Abs(p1.
X - p2.
X);
61 float num2 = MathF.Abs(p1.
Z - p2.
Z);
63 return 1.41f * num2 + 1f * (num - num2);
65 return 1.41f * num + 1f * (num2 - num);
85 if (blockWalkingHeight > 0.5f
89 y = num3 + blockWalkingHeight;
90 num = num3 + blockWalkingHeight;
94 for (
int num6 = -1; num6 >= -4; num6--) {
95 int cellValue2 =
SubsystemTerrain.Terrain.GetCellValue(num2, num3 + num6, num4);
111 int num8 = dx == 0 || dz == 0 ? 2 : 3;
112 Vector3 vector =
new(p.
X, num + 0.01f, p.
Z);
113 Vector3 v =
new(num2 + 0.5f, num + 0.01f, num4 + 0.5f);
114 Vector3 v2 = 1f / num8 * (v - vector);
115 for (
int i = 1; i <= num8; i++) {
125 neighbors.
Add(
new Vector3(num2 + 0.5f, y, num4 + 0.5f));
135 for (
int i = 0; i < customCollisionBoxes.Length; i++) {
149 for (
int i = num; i <= num4; i++) {
150 for (
int j = num3; j <= num6; j++) {
152 if (chunkAtCell ==
null) {
157 while (num8 <= num5) {
168 for (
int k = 0; k < customCollisionBoxes.Length; k++) {
196 int maxPositionsToCheck,
200 result.IsCompleted =
false;
201 result.IsInProgress =
true;
206 MinDistance = minDistance,
208 IgnoreDoors = ignoreDoors,
209 MaxPositionsToCheck = maxPositionsToCheck,
216 result.IsCompleted =
true;
217 result.IsInProgress =
false;
219 result.PathCost = 0f;
220 result.PositionsChecked = 0;
228 m_astar.OpenStorage =
new Storage();
229 m_astar.ClosedStorage =
new Storage();
230 m_astar.World = world;
246#pragma warning disable CA1416
248#pragma warning restore CA1416
252 if (request ==
null) {
256 Task.Delay(250).Wait();
269 request.PathfindingResult.PathCost =
m_astar.PathCost;
270 request.PathfindingResult.PositionsChecked = ((
Storage)
m_astar.ClosedStorage).Dictionary.Count;
271 request.PathfindingResult.IsInProgress =
false;
272 request.PathfindingResult.IsCompleted =
true;
276 for (
int num = path.
Count - 2; num > 0; num--) {
284 Vector3 vector =
new(p1.
X, p1.Y + 0.5f, p1.
Z);
285 Vector3 vector2 =
new(p2.
X, p2.Y + 0.5f, p2.
Z);
297 vector +
new Vector3(0f, -1f, 0f),
298 vector2 +
new Vector3(0f, -1f, 0f),
307 vector +
new Vector3(0f, -1f, 0f) - v,
308 vector2 +
new Vector3(0f, -1f, 0f) - v,
317 vector +
new Vector3(0f, -1f, 0f) + v,
318 vector2 +
new Vector3(0f, -1f, 0f) + v,
Silk.NET.Windowing.Monitor Monitor
static int Min(int x1, int x2)
static int Max(int x1, int x2)
virtual bool ShouldAvoid(int value)
virtual bool IsCollidable_(int value)
virtual BoundingBox[] GetCustomCollisionBoxes(SubsystemTerrain terrain, int value)
DynamicArray< Vector3 > Path
PathfindingResult PathfindingResult
Dictionary< Vector3, object > Dictionary
void Set(Vector3 p, object data)
bool IsBlocked(BoundingBox box)
void AddNeighbor(DynamicArray< Vector3 > neighbors, Vector3 p, int dx, int dz)
void Neighbors(Vector3 p, DynamicArray< Vector3 > neighbors)
float GetBlockWalkingHeight(Block block, int value)
float Cost(Vector3 p1, Vector3 p2)
SubsystemTerrain SubsystemTerrain
float Heuristic(Vector3 p1, Vector3 p2)
override void Load(ValuesDictionary valuesDictionary)
Queue< Request > m_requests
void QueuePathSearch(Vector3 start, Vector3 end, float minDistance, Vector3 boxSize, bool ignoreDoors, int maxPositionsToCheck, PathfindingResult result)
static bool SmoothingRaycastFunction_Obstacle(int value, float distance)
static bool SmoothingRaycastFunction_Support(int value, float distance)
bool IsPassable(Vector3 p1, Vector3 p2, Vector3 boxSize)
void ProcessRequest(Request request)
void SmoothPath(DynamicArray< Vector3 > path, Vector3 boxSize)
SubsystemTerrain m_subsystemTerrain
static int CalculateCellIndex(int x, int y, int z)
virtual int GetCellValueFast(int index)
static int ExtractContents(int value)
static int ToCell(float x)
ValuesDictionary ValuesDictionary
bool Intersection(BoundingBox box)
static float DistanceSquared(Vector3 v1, Vector3 v2)
static Vector3 Cross(Vector3 v1, Vector3 v2)
static Vector3 Normalize(Vector3 v)
static readonly Vector3 UnitY
static float Dot(Vector3 v1, Vector3 v2)