Ejemplo n.º 1
0
        private Job.WalkJob getWalkToJob(Job.BuildTunnelJob job, entities.Dwarf caller)
        {
            var walk = new Job.WalkJob(job.navigation, new Vector3(job.get_cell_pos().x * 2, job.get_cell_pos().y * 2, 0));

            walk.Personal = true;
            walk.Owner    = caller;
            return(walk);
        }
Ejemplo n.º 2
0
        private Job.AbstractJob[] _GetArrayOfConnectedTunnelJobs(Job.BuildTunnelJob startJob, entities.Dwarf caller)
        {
            GD.Print("_GetArrayOfConnectedTunnelJobs ", startJob, " ", caller);

            var startPos  = startJob.get_cell_pos();
            var direction = _GetTunnelDirection(startPos);

            GD.Print("Add jobs in direction: ", direction, " starting from: ", startPos);
            if (direction.Length() == 0)
            {
                return(new Job.BuildTunnelJob[] { startJob });
            }
            else
            {
                var jobs    = new List <Job.AbstractJob>();
                var nextPos = startPos + direction;
                var nextJob = get_tunnel_job_on_cell(nextPos);

                GD.Print("Add Jobs: ", nextPos, " -> ", nextJob);

                jobs.Add(startJob);
                int iteration = 0;
                while (nextJob != null)
                {
                    nextJob.Owner = caller;
                    jobs.Add(getWalkToJob(nextJob, caller));
                    jobs.Add(nextJob);

                    nextPos = nextPos + direction;
                    nextJob = get_tunnel_job_on_cell(nextPos);
                    GD.Print("(", iteration, ") Add Jobs: ", nextPos, " -> ", GD.Str(nextJob));
                    iteration++;
                    if (iteration > 10)
                    {
                        GD.PrintErr("Exceted iteration for tunnel jobs: ", iteration);
                        break;
                    }
                }
                return(jobs.ToArray());
            }
        }