public void UnsetPath()
 {
     ProfilerShort.Begin("UnsetPath");
     if (m_path != null)
     {
         m_path.Dispose();
     }
     m_path = null;
     UnsetTarget();
     PathFinished = true;
     ProfilerShort.End();
 }
Exemple #2
0
        public IMyPath FindPathGlobal(Vector3D begin, IMyDestinationShape end, MyEntity entity = null)
        {
            if (!MyPerGameSettings.EnablePathfinding)
            {
                return(null);
            }
            MySmartGoal goal  = new MySmartGoal(end, entity);
            MySmartPath path1 = new MySmartPath(this);

            path1.Init(begin, goal);
            return(path1);
        }
Exemple #3
0
        public MySmartPath FindPathGlobal(Vector3D begin, IMyDestinationShape end, MyEntity entity = null)
        {
            Debug.Assert(MyPerGameSettings.EnablePathfinding, "Pathfinding is not enabled!");
            if (!MyPerGameSettings.EnablePathfinding)
            {
                return(null);
            }

            ProfilerShort.Begin("MyPathfinding.FindPathGlobal");

            // CH: TODO: Use pooling
            MySmartPath newPath = new MySmartPath(this);
            MySmartGoal newGoal = new MySmartGoal(end, entity);

            newPath.Init(begin, newGoal);

            ProfilerShort.End();
            return(newPath);
        }
        // CH: TODO: Make a path pool and transfer ownership by calling this method (or any similar)
        public void SetPath(MySmartPath path, float weight = 1.0f)
        {
            if (path == null || !path.IsValid)
            {
                UnsetPath();
                return;
            }

            if (m_path != null)
            {
                m_path.Dispose();
            }

            m_path = path;
            m_weight = weight;

            PathFinished = false;

            SetNextTarget();
        }
 public void FollowPath(MySmartPath path)
 {
     m_path.SetPath(path);
     m_stuckDetection.Reset();
 }