123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- using UnityEngine;
- namespace Pathfinding {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [HelpURL("http://arongranberg.com/astar/documentation/stable/class_pathfinding_1_1_single_node_blocker.php")]
- public class SingleNodeBlocker : VersionedMonoBehaviour {
- public GraphNode lastBlocked { get; private set; }
- public BlockManager manager;
-
-
-
-
-
- public void BlockAtCurrentPosition () {
- BlockAt(transform.position);
- }
-
-
-
-
-
- public void BlockAt (Vector3 position) {
- Unblock();
- var node = AstarPath.active.GetNearest(position, NNConstraint.None).node;
- if (node != null) {
- Block(node);
- }
- }
-
-
-
-
-
- public void Block (GraphNode node) {
- if (node == null)
- throw new System.ArgumentNullException("node");
- manager.InternalBlock(node, this);
- lastBlocked = node;
- }
-
- public void Unblock () {
- if (lastBlocked == null || lastBlocked.Destroyed) {
- lastBlocked = null;
- return;
- }
- manager.InternalUnblock(lastBlocked, this);
- lastBlocked = null;
- }
- }
- }
|