public Element Bake(Action <Element> progress)
        {
            if (_onLoop == null)
            {
                _bakeWait = ActionSet.VarCollection.Assign("bakeWait", ActionSet.IsGlobal, false);
                _bakeWait.Set(ActionSet, 0);
            }

            // Assign bakemap then set it to an empty array.
            _bakemap = ActionSet.VarCollection.Assign("bakemap", ActionSet.IsGlobal, false);
            _bakemap.Set(ActionSet, EmptyArray());

            // Loop through each node.
            _nodeLoop = new ForBuilder(ActionSet, "bakemapNode", NodeArrayLength);
            _builder  = new PathfindAlgorithmBuilder(this);
            progress(Progress);

            _nodeLoop.Init(); // Start the node loop.
            _builder.Get();   // Run pathfinder.
            _nodeLoop.End();  // End the node loop.

            // Create a new Bakemap class instance.
            var newBakemap = _bakemapClass.Instance.Create(ActionSet, ActionSet.Translate.DeltinScript.GetComponent <ClassData>());

            _bakemapClass.Pathmap.SetWithReference(ActionSet, newBakemap.Get(), _pathmapObject);
            _bakemapClass.NodeBake.SetWithReference(ActionSet, newBakemap.Get(), _bakemap.Get());
            return(newBakemap.Get());
        }
 public void Run()
 {
     Init();
     Builder = new PathfindAlgorithmBuilder(this);
     Builder.Get();
 }