Exemple #1
0
        public PathFinder(Vector3Int start, Vector3Int target, World world, float range = 0.5f, int entityHeight = 1)
        {
            // Don't search the path if our target is too close
            if (start.Distance2(ref target) <= range * range)
            {
                return;
            }

            path   = new List <Vector3Int>();
            open   = new Dictionary <Vector3Int, Heuristics>();
            closed = new Dictionary <Vector3Int, Heuristics>();

            this.world        = world;
            this.range        = range;
            this.entityHeight = entityHeight;
            this.start        = start;
            this.target       = target;

            distanceFromStartToTarget = start.Distance2(ref target);
            open.Add(start, new Heuristics(0, distanceFromStartToTarget, start));
            status = Status.working;
            WorkPoolManager.Add(
                new ThreadPoolItem <PathFinder>(
                    Globals.WorkPool,
                    arg =>
            {
                arg.ComputePath();
            },
                    this
                    ),
                false);
        }
 void Update()
 {
     IOPoolManager.Commit();
     WorkPoolManager.Commit();
 }