/// <summary>
        /// Constructor.
        /// </summary>
        public Planner()
        {
            // Create the open and closed lists with a default capacity.  Every time that capacity is
            // exceeded, the capacity is doubled and we make allocations on the Heap.  This has the potential
            // to trigger a garbage collection, which we never want to happen during gameplay.
            // So make sure this default capacity is big enough!
            mOpenNodes   = new List <PathNode>(500);
            mClosedNodes = new List <PathNode>(500);

            // mUnusedNodes is a static used by all instances of the behavior.  We only want to allocate
            // it once.
            if (mUnusedNodes == null)
            {
                mUnusedNodes = new Stack <PathNode>(10000);
                for (Int32 i = 0; i < 100000; i++)
                {
                    PathNode temp = new PathNode();
                    mUnusedNodes.Push(temp);
                }
            }

            // Assume the path is not solved.
            mSolved          = false;
            mPathInvalidated = false;

            // Preallocate messages to avoid GC during gameplay.
            //
            mGetTileAtPositionMsg = new Level.GetTileAtPositionMessage();
            //mOnPathFindFailedMsg = new OnPathFindFailedMessage();
        }
        /// <summary>
        /// Call this to initialize a Behaviour with data supplied in a file.
        /// </summary>
        /// <param name="fileName">The file to load from.</param>
        public override void LoadContent(String fileName)
        {
            base.LoadContent(fileName);

            PathFindDefinition def = GameObjectManager.pInstance.pContentManager.Load <PathFindDefinition>(fileName);

            // TODO: This should be read in from the xml.
            mUpdateSourceAutomatically = false;

            mSearchPassLimit = def.mSearchPassLimit;
            mSearchPassCount = 0;

            mPlannerNavMesh = new Planner();
            mPlannerTileMap = new Planner();

            // Preallocate messages to avoid GC during gameplay.
            //
            mOnPathFindFailedMsg  = new OnPathFindFailedMessage();
            mGetTileAtPositionMsg = new Level.GetTileAtPositionMessage();
            mGetNavMeshMsg        = new Level.GetNavMeshMessage();
        }
Beispiel #3
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public Planner()
        {
            // Create the open and closed lists with a default capacity.  Every time that capacity is
            // exceeded, the capacity is doubled and we make allocations on the Heap.  This has the potential
            // to trigger a garbage collection, which we never want to happen during gameplay.
            // So make sure this default capacity is big enough!
            mOpenNodes = new List<PathNode>(500);
            mClosedNodes = new List<PathNode>(500);

            // mUnusedNodes is a static used by all instances of the behavior.  We only want to allocate
            // it once.
            if (mUnusedNodes == null)
            {
                mUnusedNodes = new Stack<PathNode>(10000);
                for (Int32 i = 0; i < 100000; i++)
                {
                    PathNode temp = new PathNode();
                    mUnusedNodes.Push(temp);
                }
            }

            // Assume the path is not solved.
            mSolved = false;
            mPathInvalidated = false;

            // Preallocate messages to avoid GC during gameplay.
            //
            mGetTileAtPositionMsg = new Level.GetTileAtPositionMessage();
            //mOnPathFindFailedMsg = new OnPathFindFailedMessage();
        }
Beispiel #4
0
        /// <summary>
        /// Call this to initialize a Behaviour with data supplied in a file.
        /// </summary>
        /// <param name="fileName">The file to load from.</param>
        public override void LoadContent(String fileName)
        {
            base.LoadContent(fileName);

            PathFindDefinition def = GameObjectManager.pInstance.pContentManager.Load<PathFindDefinition>(fileName);

            // TODO: This should be read in from the xml.
            mUpdateSourceAutomatically = false;

            mSearchPassLimit = def.mSearchPassLimit;
            mSearchPassCount = 0;

            mPlannerNavMesh = new Planner();
            mPlannerTileMap = new Planner();
            
            // Preallocate messages to avoid GC during gameplay.
            //
            mOnPathFindFailedMsg = new OnPathFindFailedMessage();
            mGetTileAtPositionMsg = new Level.GetTileAtPositionMessage();
            mGetNavMeshMsg = new Level.GetNavMeshMessage();
        }