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());
        }
 // When the dijkstra is finished, set the bakemap's node to the parent array.
 void IPathfinderInfo.Finished() => _bakemap.Set(ActionSet, _builder.ParentArray.Get(), index: _nodeLoop.Value);