Example #1
0
        public void OnTick()
        {
            if (location == null)
            {
                FindClosestOre();
                return;
            }

            var token = new CancelToken();
            var map   = actions.AsyncMoveToLocation(location, token, MO);

            map.Completed += areaMap => {
                TaskCompleted();
            };
            map.Cancelled += (areaMap, cuboid) => {
                if (!token.stopped)
                {
                    token.Stop();
                    InvalidateBlock(location);
                    TaskCompleted();
                }
            };

            if (!map.Start())
            {
                if (!token.stopped)
                {
                    token.Stop();
                    InvalidateBlock(location);
                    TaskCompleted();
                }
            }
            else
            {
                busy = true;
            }
        }