Esempio n. 1
0
 // Token: 0x06008D13 RID: 36115 RVA: 0x00292B00 File Offset: 0x00290D00
 private WorldPathfinder.Node AllocateNode()
 {
     if (this.m_AllocateNodeCount >= this.m_NodePool.Count)
     {
         this.m_NodePool.Add(new WorldPathfinder.Node());
     }
     WorldPathfinder.Node node = this.m_NodePool[this.m_AllocateNodeCount++];
     node.Reinitialize();
     return(node);
 }
Esempio n. 2
0
 // Token: 0x06008D1B RID: 36123 RVA: 0x00292FF4 File Offset: 0x002911F4
 public WorldPathNode GetSolutionNext()
 {
     if (this.m_CurrentSolutionNode != null && this.m_CurrentSolutionNode.child != null)
     {
         WorldPathfinder.Node child = this.m_CurrentSolutionNode.child;
         this.m_CurrentSolutionNode = this.m_CurrentSolutionNode.child;
         return(child.m_UserState);
     }
     return(null);
 }
Esempio n. 3
0
        // Token: 0x06008D12 RID: 36114 RVA: 0x00292A94 File Offset: 0x00290C94
        private void SortedAddToOpenList(WorldPathfinder.Node node)
        {
            LinkedListNode <WorldPathfinder.Node> linkedListNode;

            for (linkedListNode = this.m_OpenList.First; linkedListNode != null; linkedListNode = linkedListNode.Next)
            {
                if (node.f < linkedListNode.Value.f)
                {
                    break;
                }
            }
            if (linkedListNode != null)
            {
                this.m_OpenList.AddBefore(linkedListNode, node);
            }
            else
            {
                this.m_OpenList.AddLast(node);
            }
        }
Esempio n. 4
0
 // Token: 0x06008D19 RID: 36121 RVA: 0x00292FA4 File Offset: 0x002911A4
 public void AddSuccessor(WorldPathNode state)
 {
     WorldPathfinder.Node node = this.AllocateNode();
     node.m_UserState = state;
     this.m_Successors.Add(node);
 }
Esempio n. 5
0
        // Token: 0x06008D18 RID: 36120 RVA: 0x00292C84 File Offset: 0x00290E84
        public WorldPathfinder.SearchState SearchStep()
        {
            if (this.m_State == WorldPathfinder.SearchState.NotInitialized || this.m_State == WorldPathfinder.SearchState.Succeeded || this.m_State == WorldPathfinder.SearchState.Failed)
            {
                return(this.m_State);
            }
            if (this.m_OpenList.Count == 0 || this.m_CancelRequest)
            {
                this.FreeSolutionNodes();
                this.m_State = WorldPathfinder.SearchState.Failed;
                return(this.m_State);
            }
            this.m_Steps++;
            WorldPathfinder.Node value = this.m_OpenList.First.Value;
            this.m_OpenList.RemoveFirst();
            if (value.m_UserState.IsSameState(this.m_Goal.m_UserState))
            {
                this.m_Goal.parent = value.parent;
                this.m_Goal.g      = value.g;
                if (!value.m_UserState.IsSameState(this.m_Start.m_UserState))
                {
                    WorldPathfinder.Node node   = this.m_Goal;
                    WorldPathfinder.Node parent = this.m_Goal.parent;
                    do
                    {
                        parent.child = node;
                        node         = parent;
                        parent       = parent.parent;
                    }while (node != this.m_Start);
                }
                this.m_State = WorldPathfinder.SearchState.Succeeded;
                return(this.m_State);
            }
            this.m_Successors.Clear();
            value.m_UserState.GetSuccessors(this, (value.parent == null) ? null : value.parent.m_UserState);
            WorldPathfinder.Node node2 = null;
            int count = this.m_Successors.Count;

            for (int i = 0; i < count; i++)
            {
                node2 = this.m_Successors[i];
                float num = value.g + value.m_UserState.GetCost(this, node2.m_UserState);
                WorldPathfinder.Node node3 = null;
                foreach (WorldPathfinder.Node node4 in this.m_OpenList)
                {
                    if (node4.m_UserState.IsSameState(node2.m_UserState))
                    {
                        node3 = node4;
                        break;
                    }
                }
                if (node3 == null || node3.g > num)
                {
                    int num2   = -1;
                    int count2 = this.m_ClosedList.Count;
                    for (int j = 0; j < count2; j++)
                    {
                        if (this.m_ClosedList[j].m_UserState.IsSameState(node2.m_UserState))
                        {
                            num2 = j;
                            break;
                        }
                    }
                    if (num2 < 0 || this.m_ClosedList[num2].g > num)
                    {
                        node2.parent = value;
                        node2.g      = num;
                        node2.h      = node2.m_UserState.GetGoalHeuristic(this);
                        node2.f      = node2.g + node2.h;
                        if (num2 >= 0)
                        {
                            this.m_ClosedList.RemoveAt(num2);
                        }
                        if (node3 != null)
                        {
                            this.m_OpenList.Remove(node3);
                        }
                        this.SortedAddToOpenList(node2);
                    }
                }
            }
            this.m_ClosedList.Add(value);
            return(this.m_State);
        }