public int GetOccupationMaxCount(JobType jobType) { GameObject jobObject = Occupations.Find(o => o.GetComponent <OccupationRoster>().Type == jobType); OccupationRoster job = jobObject.GetComponent <OccupationRoster>(); return(job.limit); }
// Attempts to request job else assigns random occupation in order of priority public JobType GetRandomFreeOccupation(JobType jobTypeRequest) { // Try to assign specific job if (jobTypeRequest != JobType.NULL) { foreach (GameObject jobObject in Occupations.Where(o => o.GetComponent <OccupationRoster>().Type == jobTypeRequest)) { OccupationRoster job = jobObject.GetComponent <OccupationRoster>(); if (job.limit != -1) { if (job.limit > GetOccupationsCount(job.Type)) { return(job.Type); } } if (job.limit == -1) { return(job.Type); } } } // No job found, get random via priority foreach (GameObject jobObject in Occupations.OrderBy(o => o.GetComponent <OccupationRoster>().priority)) { OccupationRoster job = jobObject.GetComponent <OccupationRoster>(); if (job.limit != -1) { if (job.limit > GetOccupationsCount(job.Type)) { return(job.Type); } } if (job.limit == -1) { return(job.Type); } } return(JobType.ASSISTANT); }