Пример #1
0
        public static MultiTargetPath Construct(Vector3[] startPoints, Vector3 target, OnPathDelegate[] callbackDelegates, OnPathDelegate callback = null)
        {
            MultiTargetPath multiTargetPath = MultiTargetPath.Construct(target, startPoints, callbackDelegates, callback);

            multiTargetPath.inverted = true;
            return(multiTargetPath);
        }
Пример #2
0
        public static MultiTargetPath Construct(Vector3 start, Vector3[] targets, OnPathDelegate[] callbackDelegates, OnPathDelegate callback = null)
        {
            MultiTargetPath path = PathPool.GetPath <MultiTargetPath>();

            path.Setup(start, targets, callbackDelegates, callback);
            return(path);
        }
Пример #3
0
        // Token: 0x060021C7 RID: 8647 RVA: 0x001903CC File Offset: 0x0018E5CC
        private void StartPathInternal(Path p, OnPathDelegate callback)
        {
            MultiTargetPath multiTargetPath = p as MultiTargetPath;

            if (multiTargetPath != null)
            {
                OnPathDelegate[] array = new OnPathDelegate[multiTargetPath.targetPoints.Length];
                for (int i = 0; i < array.Length; i++)
                {
                    array[i] = this.onPartialPathDelegate;
                }
                multiTargetPath.callbacks = array;
                p.callback = (OnPathDelegate)Delegate.Combine(p.callback, new OnPathDelegate(this.OnMultiPathComplete));
            }
            else
            {
                p.callback = (OnPathDelegate)Delegate.Combine(p.callback, this.onPathDelegate);
            }
            p.enabledTags  = this.traversableTags;
            p.tagPenalties = this.tagPenalties;
            if (this.path != null && this.path.PipelineState <= PathState.Processing && this.path.CompleteState != PathCompleteState.Error && this.lastPathID == (uint)this.path.pathID)
            {
                this.path.FailWithError("Canceled path because a new one was requested.\nThis happens when a new path is requested from the seeker when one was already being calculated.\nFor example if a unit got a new order, you might request a new path directly instead of waiting for the now invalid path to be calculated. Which is probably what you want.\nIf you are getting this a lot, you might want to consider how you are scheduling path requests.");
            }
            this.path            = p;
            this.tmpPathCallback = callback;
            this.lastPathID      = (uint)this.path.pathID;
            this.RunModifiers(Seeker.ModifierPass.PreProcess, this.path);
            AstarPath.StartPath(this.path, false);
        }
Пример #4
0
        //Good Game
        //public static MultiTargetPath Construct (Vector3[] startPoints, Vector3 target, OnPathDelegate[] callbackDelegates, OnPathDelegate callback = null) {
        public static MultiTargetPath Construct(VInt3[] startPoints, VInt3 target, OnPathDelegate[] callbackDelegates, OnPathDelegate callback = null)
        {
            MultiTargetPath p = Construct(target, startPoints, callbackDelegates, callback);

            p.inverted = true;
            return(p);
        }
Пример #5
0
        public static MultiTargetPath Construct(Vector3[] startPoints, Vector3 target, OnPathDelegate[] callbackDelegates, [Optional, DefaultParameterValue(null)] OnPathDelegate callback)
        {
            MultiTargetPath path = Construct(target, startPoints, callbackDelegates, callback);

            path.inverted = true;
            return(path);
        }
Пример #6
0
        public static MultiTargetPath Construct(Vector3 start, Vector3[] targets, OnPathDelegate[] callbackDelegates, [Optional, DefaultParameterValue(null)] OnPathDelegate callback)
        {
            MultiTargetPath path = PathPool.GetPath <MultiTargetPath>();

            path.Setup(start, targets, callbackDelegates, callback);
            return(path);
        }
Пример #7
0
    /** Starts a path specified by PathTypesDemo::activeDemo */
    public void DemoPath()
    {
        Path p = null;

        if (activeDemo == 0) {
            p = new Path (start.position,end.position, OnPathComplete);
        } else if (activeDemo == 1) {
            MultiTargetPath mp = new MultiTargetPath (multipoints.ToArray (), end.position, null, OnPathComplete);
            p = mp;
        } else if (activeDemo == 2) {
            RandomPath rp = new RandomPath (start.position,searchLength, OnPathComplete);
            rp.spread = spread;
            rp.aimStrength = aimStrength;
            rp.aim = end.position;
            rp.replaceChance = replaceChance;

            p = rp;
        } else if (activeDemo == 3) {
            FleePath fp = new FleePath (start.position, end.position, searchLength, OnPathComplete);
            fp.fleeStrength = aimStrength;
            fp.replaceChance = replaceChance;
            fp.spread = spread;

            p = fp;
        } else if (activeDemo == 4) {
            ConstantPath constPath = new ConstantPath (start.position, searchLength, OnPathComplete);

            p = constPath;
        }

        if (p != null) AstarPath.StartPath (p);
    }
Пример #8
0
        // Token: 0x060021C9 RID: 8649 RVA: 0x00190514 File Offset: 0x0018E714
        public MultiTargetPath StartMultiTargetPath(Vector3[] startPoints, Vector3 end, bool pathsForAll, OnPathDelegate callback = null, int graphMask = -1)
        {
            MultiTargetPath multiTargetPath = MultiTargetPath.Construct(startPoints, end, null, null);

            multiTargetPath.pathsForAll = pathsForAll;
            this.StartPath(multiTargetPath, callback, graphMask);
            return(multiTargetPath);
        }
Пример #9
0
        /** Starts a Multi Target Path from multiple start points to a single target point.
         * A Multi Target Path will search from all start points to the target point in one search and will return all paths if \a pathsForAll is true, or only the shortest one if \a pathsForAll is false.\n
         *
         * \param startPoints	The start points of the path
         * \param end			The end point of the path
         * \param pathsForAll	Indicates whether or not a path from all start points should be searched for or only to the closest one
         * \param callback		The function to call when the path has been calculated
         * \param graphMask		Mask used to specify which graphs should be searched for close nodes. See Pathfinding.NNConstraint.graphMask.
         *
         * \a callback and #pathCallback will be called when the path has completed. \a Callback will not be called if the path is canceled (e.g when a new path is requested before the previous one has completed)
         * \astarpro
         * \see Pathfinding.MultiTargetPath
         * \see \ref MultiTargetPathExample.cs "Example of how to use multi-target-paths"
         */
        //Good Game
        //public MultiTargetPath StartMultiTargetPath (Vector3[] startPoints, Vector3 end, bool pathsForAll, OnPathDelegate callback = null, int graphMask = -1) {
        public MultiTargetPath StartMultiTargetPath(VInt3[] startPoints, VInt3 end, bool pathsForAll, OnPathDelegate callback = null, int graphMask = -1)
        {
            MultiTargetPath p = MultiTargetPath.Construct(startPoints, end, null, null);

            p.pathsForAll = pathsForAll;
            StartPath(p, callback, graphMask);
            return(p);
        }
Пример #10
0
	/** Starts a Multi Target Path. Takes a MultiTargetPath and wires everything up for it to send callbacks to the seeker for post-processing.\n
	 * \param p				The path to start calculating
	 * \param callback		The function to call when the path has been calculated
	 * \param graphMask	Mask used to specify which graphs should be searched for close nodes. See Pathfinding.NNConstraint.graphMask. \astarproParam
	 * 
	 * \a callback and #pathCallback will be called when the path has completed. \a Callback will not be called if the path is canceled (e.g when a new path is requested before the previous one has completed)
	 * \astarpro
	 * \see Pathfinding.MultiTargetPath
	 * \see \ref MultiTargetPathExample.cs "Example of how to use multi-target-paths"
	 */
	public MultiTargetPath StartMultiTargetPath (MultiTargetPath p, OnPathDelegate callback = null, int graphMask = -1) {
			
		//Cancel a previously requested path is it has not been processed yet and also make sure that it has not been recycled and used somewhere else
		if (path != null && path.GetState () <= PathState.Processing && lastPathID == path.pathID) {
			path.ForceLogError ("Canceled path because a new one was requested");
			//No callback should be sent for the canceled path
		}
		
		OnPathDelegate[] callbacks = new OnPathDelegate[p.targetPoints.Length];
		for (int i=0;i<callbacks.Length;i++) {
			callbacks[i] = onPartialPathDelegate;
		}
		
		p.callbacks = callbacks;
		p.callback += OnMultiPathComplete;
		p.nnConstraint.graphMask = graphMask;
		
		path = p;
		
		tmpPathCallback = callback;
		
		//Save the path id so we can make sure that if we cancel a path (see above) it should not have been recycled yet.
		lastPathID = path.pathID;
		
		//Delay the path call by one frame if it was sent the same frame as the previous call
		/*if (lastPathCall == Time.frameCount) {
			StartCoroutine (DelayPathStart (path));
			return p;
		}
		
		lastPathCall = Time.frameCount;*/
		
		//Pre process the path
		RunModifiers (ModifierPass.PreProcess, path);
		
		//Send the request to the pathfinder
		AstarPath.StartPath (path);
		
		return p;
	}
Пример #11
0
 public MultiTargetPath StartMultiTargetPath(MultiTargetPath p, OnPathDelegate callback = null, int graphMask = -1)
 {
     this.StartPath(p, callback, graphMask);
     return(p);
 }
Пример #12
0
	/** Starts a Multi Target Path.
	 * Takes a MultiTargetPath and wires everything up for it to send callbacks to the seeker for post-processing.\n
	 *
	 * \param p				The path to start calculating
	 * \param callback		The function to call when the path has been calculated
	 * \param graphMask	Mask used to specify which graphs should be searched for close nodes. See Pathfinding.NNConstraint.graphMask.
	 *
	 * \a callback and #pathCallback will be called when the path has completed. \a Callback will not be called if the path is canceled (e.g when a new path is requested before the previous one has completed)
	 * \astarpro
	 * \see Pathfinding.MultiTargetPath
	 * \see \ref MultiTargetPathExample.cs "Example of how to use multi-target-paths"
	 */
	public MultiTargetPath StartMultiTargetPath (MultiTargetPath p, OnPathDelegate callback = null, int graphMask = -1) {
		// TODO: Allocation, cache
		var callbacks = new OnPathDelegate[p.targetPoints.Length];

		for (int i = 0; i < callbacks.Length; i++) {
			callbacks[i] = onPartialPathDelegate;
		}

		// TODO: This method does not set the enabledTags or tagPenalties
		// as the StartPath method does... should this be changed?
		// Hard to do since the API has existed for a long time...

		p.callbacks = callbacks;
		p.callback += OnMultiPathComplete;
		p.nnConstraint.graphMask = graphMask;

		StartPathInternal(p, callback);
		return p;
	}
Пример #13
0
 public MultiTargetPath StartMultiTargetPath(MultiTargetPath p, OnPathDelegate callback = null, int graphMask = -1)
 {
     if (this.path != null && this.path.GetState() <= PathState.Processing && this.lastPathID == (uint)this.path.pathID)
     {
         this.path.ForceLogError("Canceled path because a new one was requested");
     }
     OnPathDelegate[] array = new OnPathDelegate[p.targetPoints.Length];
     for (int i = 0; i < array.Length; i++)
     {
         array[i] = this.onPartialPathDelegate;
     }
     p.callbacks = array;
     p.callback = (OnPathDelegate)Delegate.Combine(p.callback, new OnPathDelegate(this.OnMultiPathComplete));
     p.nnConstraint.graphMask = graphMask;
     this.path = p;
     this.tmpPathCallback = callback;
     this.lastPathID = (uint)this.path.pathID;
     this.RunModifiers(Seeker.ModifierPass.PreProcess, this.path);
     AstarPath.StartPath(this.path, false);
     return p;
 }
Пример #14
0
 /** Starts a Multi Target Path from multiple start points to a single target point. A Multi Target Path will search from all start points to the target point in one search and will return all paths if \a pathsForAll is true, or only the shortest one if \a pathsForAll is false.\n
  * \param startPoints	The start points of the path
  * \param end			The end point of the path
  * \param pathsForAll	Indicates whether or not a path from all start points should be searched for or only to the closest one
  * \param callback		The function to call when the path has been calculated
  * \param graphMask		Mask used to specify which graphs should be searched for close nodes. See Pathfinding::NNConstraint::graphMask. \astarproParam
  *
  * \a callback and #pathCallback will be called when the path has completed. \a Callback will not be called if the path is canceled (e.g when a new path is requested before the previous one has completed)
  * \astarpro
  * \see Pathfinding::MultiTargetPath
  * \see \ref MultiTargetPath.cs "Example of how to use multi-target-paths"
  */
 public MultiTargetPath StartMultiTargetPath(Vector3[] startPoints, Vector3 end, bool pathsForAll, OnPathDelegate callback = null, int graphMask = -1)
 {
     MultiTargetPath p = new MultiTargetPath (startPoints, end, null, null);
     p.pathsForAll = pathsForAll;
     return StartMultiTargetPath (p, callback, graphMask);
 }
Пример #15
0
    static int StartMultiTargetPath(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                Seeker obj = (Seeker)ToLua.CheckObject <Seeker>(L, 1);
                Pathfinding.MultiTargetPath arg0 = (Pathfinding.MultiTargetPath)ToLua.CheckObject <Pathfinding.MultiTargetPath>(L, 2);
                Pathfinding.MultiTargetPath o    = obj.StartMultiTargetPath(arg0);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 3)
            {
                Seeker obj = (Seeker)ToLua.CheckObject <Seeker>(L, 1);
                Pathfinding.MultiTargetPath arg0 = (Pathfinding.MultiTargetPath)ToLua.CheckObject <Pathfinding.MultiTargetPath>(L, 2);
                OnPathDelegate arg1           = (OnPathDelegate)ToLua.CheckDelegate <OnPathDelegate>(L, 3);
                Pathfinding.MultiTargetPath o = obj.StartMultiTargetPath(arg0, arg1);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 4 && TypeChecker.CheckTypes <UnityEngine.Vector3[], UnityEngine.Vector3, bool>(L, 2))
            {
                Seeker obj = (Seeker)ToLua.CheckObject <Seeker>(L, 1);
                UnityEngine.Vector3[] arg0 = ToLua.ToStructArray <UnityEngine.Vector3>(L, 2);
                UnityEngine.Vector3   arg1 = ToLua.ToVector3(L, 3);
                bool arg2 = LuaDLL.lua_toboolean(L, 4);
                Pathfinding.MultiTargetPath o = obj.StartMultiTargetPath(arg0, arg1, arg2);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 4 && TypeChecker.CheckTypes <Pathfinding.MultiTargetPath, OnPathDelegate, int>(L, 2))
            {
                Seeker obj = (Seeker)ToLua.CheckObject <Seeker>(L, 1);
                Pathfinding.MultiTargetPath arg0 = (Pathfinding.MultiTargetPath)ToLua.ToObject(L, 2);
                OnPathDelegate arg1           = (OnPathDelegate)ToLua.ToObject(L, 3);
                int            arg2           = (int)LuaDLL.lua_tonumber(L, 4);
                Pathfinding.MultiTargetPath o = obj.StartMultiTargetPath(arg0, arg1, arg2);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 4 && TypeChecker.CheckTypes <UnityEngine.Vector3, UnityEngine.Vector3[], bool>(L, 2))
            {
                Seeker obj = (Seeker)ToLua.CheckObject <Seeker>(L, 1);
                UnityEngine.Vector3   arg0 = ToLua.ToVector3(L, 2);
                UnityEngine.Vector3[] arg1 = ToLua.ToStructArray <UnityEngine.Vector3>(L, 3);
                bool arg2 = LuaDLL.lua_toboolean(L, 4);
                Pathfinding.MultiTargetPath o = obj.StartMultiTargetPath(arg0, arg1, arg2);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 5 && TypeChecker.CheckTypes <UnityEngine.Vector3, UnityEngine.Vector3[], bool, OnPathDelegate>(L, 2))
            {
                Seeker obj = (Seeker)ToLua.CheckObject <Seeker>(L, 1);
                UnityEngine.Vector3   arg0    = ToLua.ToVector3(L, 2);
                UnityEngine.Vector3[] arg1    = ToLua.ToStructArray <UnityEngine.Vector3>(L, 3);
                bool           arg2           = LuaDLL.lua_toboolean(L, 4);
                OnPathDelegate arg3           = (OnPathDelegate)ToLua.ToObject(L, 5);
                Pathfinding.MultiTargetPath o = obj.StartMultiTargetPath(arg0, arg1, arg2, arg3);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 5 && TypeChecker.CheckTypes <UnityEngine.Vector3[], UnityEngine.Vector3, bool, OnPathDelegate>(L, 2))
            {
                Seeker obj = (Seeker)ToLua.CheckObject <Seeker>(L, 1);
                UnityEngine.Vector3[] arg0    = ToLua.ToStructArray <UnityEngine.Vector3>(L, 2);
                UnityEngine.Vector3   arg1    = ToLua.ToVector3(L, 3);
                bool           arg2           = LuaDLL.lua_toboolean(L, 4);
                OnPathDelegate arg3           = (OnPathDelegate)ToLua.ToObject(L, 5);
                Pathfinding.MultiTargetPath o = obj.StartMultiTargetPath(arg0, arg1, arg2, arg3);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 6 && TypeChecker.CheckTypes <UnityEngine.Vector3, UnityEngine.Vector3[], bool, OnPathDelegate, int>(L, 2))
            {
                Seeker obj = (Seeker)ToLua.CheckObject <Seeker>(L, 1);
                UnityEngine.Vector3   arg0    = ToLua.ToVector3(L, 2);
                UnityEngine.Vector3[] arg1    = ToLua.ToStructArray <UnityEngine.Vector3>(L, 3);
                bool           arg2           = LuaDLL.lua_toboolean(L, 4);
                OnPathDelegate arg3           = (OnPathDelegate)ToLua.ToObject(L, 5);
                int            arg4           = (int)LuaDLL.lua_tonumber(L, 6);
                Pathfinding.MultiTargetPath o = obj.StartMultiTargetPath(arg0, arg1, arg2, arg3, arg4);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 6 && TypeChecker.CheckTypes <UnityEngine.Vector3[], UnityEngine.Vector3, bool, OnPathDelegate, int>(L, 2))
            {
                Seeker obj = (Seeker)ToLua.CheckObject <Seeker>(L, 1);
                UnityEngine.Vector3[] arg0    = ToLua.ToStructArray <UnityEngine.Vector3>(L, 2);
                UnityEngine.Vector3   arg1    = ToLua.ToVector3(L, 3);
                bool           arg2           = LuaDLL.lua_toboolean(L, 4);
                OnPathDelegate arg3           = (OnPathDelegate)ToLua.ToObject(L, 5);
                int            arg4           = (int)LuaDLL.lua_tonumber(L, 6);
                Pathfinding.MultiTargetPath o = obj.StartMultiTargetPath(arg0, arg1, arg2, arg3, arg4);
                ToLua.PushObject(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: Seeker.StartMultiTargetPath"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }