namespace Holo.Virtual.Rooms.Pathfinding { using Holo.Virtual.Rooms; using System; using System.Collections; public class Pathfinder { private ᙃ ᙄ; private Heap 00AAA; private Heap 10AA1; private ᙃ 20AAA; private ArrayList 40AAA; private ArrayList 50AA1; private virtualRoom.squareState[,] 7AAA1; private byte[,] 8AAAA; private bool[,] 9AAA1; private int BAAAA; private int CAAA1; public Pathfinder(virtualRoom.squareState[,] stateMap, byte[,] heightMap, bool[,] unitMap) { this.7AAA1 = stateMap; this.8AAAA = heightMap; this.9AAA1 = unitMap; this.BAAAA = unitMap.GetLength(1) - 1; this.CAAA1 = unitMap.GetLength(0) - 1; this.00AAA = new Heap(); this.10AA1 = new Heap(); this.40AAA = new ArrayList(); this.50AA1 = new ArrayList(); } public int[] getNext(int X, int Y, int goalX, int goalY) { if ((X == goalX) && (Y == goalY)) { return null; } int num = this.BAAAA * this.CAAA1; int num2 = 0; this.ᙄ = new ᙃ(goalX, goalY, 0.0, null, null, this); this.20AAA = new ᙃ(X, Y, 0.0, null, this.ᙄ, this); this.00AAA.Add(this.20AAA); while (this.00AAA.Count > 0) { if (num2 == num) { return null; } num2++; ᙃ parentNode = (ᙃ) this.00AAA.Pop(); if (parentNode.sameCoordsAs(this.ᙄ)) { while (parentNode != null) { this.40AAA.Insert(0, parentNode); parentNode = parentNode.parentNode; } break; } parentNode.getSuccessors(); this.50AA1 = parentNode.allSuccessors; foreach (ᙃ ᙃ2 in this.50AA1) { ᙃ ᙃ3 = null; if (this.00AAA.Contains(ᙃ2)) { ᙃ3 = (ᙃ) this.00AAA[this.00AAA.IndexOf(ᙃ2)]; if (ᙃ2.totalCost > ᙃ3.totalCost) { continue; } } ᙃ ᙃ4 = null; if (this.10AA1.Contains(ᙃ2)) { ᙃ4 = (ᙃ) this.10AA1[this.10AA1.IndexOf(ᙃ2)]; if (ᙃ2.totalCost > ᙃ4.totalCost) { continue; } } this.00AAA.Remove(ᙃ3); this.10AA1.Remove(ᙃ4); this.00AAA.Push(ᙃ2); } this.10AA1.Add(parentNode); } if (this.40AAA.Count == 0) { return null; } ᙃ ᙃ5 = (ᙃ) this.40AAA[1]; return new int[] { ᙃ5.X, ᙃ5.Y }; } private bool spotMoveHeightOK(int X, int Y, int goalX, int goalY) { try { int num = this.8AAAA[X, Y]; int num2 = this.8AAAA[goalX, goalY]; for (int i = -1; i <= 1; i++) { if (num == (num2 - i)) { return true; } } return false; } catch { return false; } } private bool spotOpen(int X, int Y) { try { if (this.9AAA1[X, Y]) { return false; } if ((this.7AAA1[X, Y] != virtualRoom.squareState.Open) && (this.7AAA1[X, Y] != virtualRoom.squareState.Rug)) { return false; } return true; } catch { return false; } } private class ᙃ : IComparable { private Pathfinder ᙅ; private Pathfinder.ᙃ ᙄ; private double 4AAAA; private double 5AAA1; private ArrayList 6AAAA; internal Pathfinder.ᙃ parentNode; internal int X; internal int Y; internal ᙃ(int X, int Y, double Cost, Pathfinder.ᙃ parentNode, Pathfinder.ᙃ goalNode, Pathfinder parentPathfinder) { this.X = X; this.Y = Y; this.parentNode = parentNode; this.ᙄ = goalNode; this.4AAAA = Cost; this.ᙅ = parentPathfinder; this.6AAAA = new ArrayList(); } private void addSuccessor(int X, int Y) { if (this.ᙅ.spotOpen(X, Y) && this.ᙅ.spotMoveHeightOK(this.X, this.Y, X, Y)) { Pathfinder.ᙃ ᙃ = new Pathfinder.ᙃ(X, Y, this.4AAAA, this, this.ᙄ, this.ᙅ); this.6AAAA.Add(ᙃ); } } internal void getSuccessors() { this.addSuccessor(this.X - 1, this.Y); this.addSuccessor(this.X + 1, this.Y); this.addSuccessor(this.X, this.Y - 1); this.addSuccessor(this.X, this.Y + 1); if (this.ᙅ.spotOpen(this.X, this.Y - 1)) { if (this.ᙅ.spotOpen(this.X - 1, this.Y)) { this.addSuccessor(this.X - 1, this.Y - 1); } if (this.ᙅ.spotOpen(this.X + 1, this.Y)) { this.addSuccessor(this.X + 1, this.Y - 1); } } if (this.ᙅ.spotOpen(this.X + 1, this.Y) && this.ᙅ.spotOpen(this.X, this.Y + 1)) { this.addSuccessor(this.X + 1, this.Y + 1); } if (this.ᙅ.spotOpen(this.X - 1, this.Y) && this.ᙅ.spotOpen(this.X, this.Y - 1)) { this.addSuccessor(this.X - 1, this.Y + 1); } } internal bool sameCoordsAs(Pathfinder.ᙃ Node) { return ((this.X == Node.X) && (this.Y == Node.Y)); } int IComparable.CompareTo(object obj) { return -this.totalCost.CompareTo(((Pathfinder.ᙃ) obj).totalCost); } internal ArrayList allSuccessors { get { return this.6AAAA; } } internal double Cost { get { return this.4AAAA; } set { this.4AAAA = value; } } internal double goalEstimate { get { if (this.ᙄ == null) { this.5AAA1 = 0.0; } else { double x = this.X - this.ᙄ.X; double num2 = this.Y - this.ᙄ.Y; this.5AAA1 = Math.Sqrt(Math.Pow(x, 2.0) + Math.Pow(num2, 2.0)); } return this.5AAA1; } set { this.5AAA1 = value; } } internal double totalCost { get { return (this.4AAAA + this.goalEstimate); } } } } }