/// <summary> /// Query progress of a specific settler job at this location /// </summary> /// <param name="job">the job</param> /// <param name="progress">the progress</param> /// <returns>result of operation</returns> public PlayResult GetJobProgress__Turn(Job job, out JobProgress progress) { fixed(JobProgress *jobProgressData = new JobProgress[Protocol.nJob]) { PlayResult result = TheEmpire.Play(Protocol.sGetJobProgress, Id, jobProgressData); progress = jobProgressData[(int)job]; if (result.OK) { JobWorkRemaining[] workRemaining = new JobWorkRemaining[Protocol.nJob]; for (int j = 0; j < Protocol.nJob; j++) { workRemaining[j] = new JobWorkRemaining(jobProgressData[j].Required, jobProgressData[j].Done); } TheEmpire.Map.JobInfo[Id] = workRemaining; } return(result); } }
/// <summary> /// Gets the only easily cacheable value with regard to work done on a job here - how much is left to do. The /// list is indexed by the values of the Job enum. /// </summary> public PlayResult GetWorkRemaining(out IReadOnlyList <JobWorkRemaining> work) { if (TheEmpire.Map.JobInfo[Id] == null) { PlayResult result = GetJobProgress__Turn(Job.None, out JobProgress _); if (result.OK) { Debug.Assert(TheEmpire.Map.JobInfo[Id] != null); work = TheEmpire.Map.JobInfo[Id]; } else { work = new JobWorkRemaining[Protocol.nJob]; } return(result); } else { work = TheEmpire.Map.JobInfo[Id]; return(PlayResult.Success); } }
/// <summary> /// Gets the only easily cacheable value with regard to work done on a job here - how much is left to do. /// </summary> public PlayResult GetWorkRemaining(Job job, out JobWorkRemaining work) { if (TheEmpire.Map.JobInfo[Id] == null) { PlayResult result = GetJobProgress__Turn(Job.None, out JobProgress _); if (result.OK) { Debug.Assert(TheEmpire.Map.JobInfo[Id] != null); work = TheEmpire.Map.JobInfo[Id][(int)job]; } else { work = new JobWorkRemaining(); } return(result); } else { work = TheEmpire.Map.JobInfo[Id][(int)job]; return(PlayResult.Success); } }