mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-06-05 13:34:25 +01:00
f4bf017921
* Unit Test rework & Master/Ticker update * Fixes and working unit testing * Fixes * Test fixes and FA update * Fixed runtimes * Radio subsystem * move that glob wherever later * ident * CIBUILDING compile option * Fixed runtimes * Some changes to the workflow * CI Split * More split * Pathing * Linters and Annotators * ci dir fix * Missing undef fixed * Enable grep checks * More test conversions * More split * Correct file * Removes unneeded inputs * oop * More dependency changes * More conversions * Conversion fixes * Fixes * Some assert fixes * Corrects start gate * Converted some README.dms to README.mds * Removes duplicate proc * Removes unused defines * Example configs * fix dll access viol by double calling * Post-rebase fixes * Cleans up names global list * Undef restart counter * More code/game/ cleanup * Statpanel update * Skybox * add * Fix ticker * Roundend fix * Persistence dependency update * Reordering * Reordering * Reordering * Initstage fix * . * . * Reorder * Reorder * Circle * Mobs * Air * Test fix * CI Script Fix * Configs * More ticker stuff * This is now in 'reboot world' * Restart world announcements * no glob in PreInit * to define * Update * Removed old include * Make this file normal again * moved * test * shared unit testing objects * Updates batched_spritesheets and universal_icon * . * job data debug * rm that * init order * show us * . * i wonder * . * . * urg * do we not have a job ID? * . * rm sleep for now * updated rust-g linux binaries * binaries update 2 * binaries update 3 * testing something * change that * test something * . * . * . * locavar * test * move that * . * debug * don't run this test * strack trace it * cleaner * . * . * cras again * also comment this out * return to official rust g * Update robot_icons.dm * monitor the generation * . --------- Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
146 lines
4.9 KiB
Plaintext
146 lines
4.9 KiB
Plaintext
SUBSYSTEM_DEF(job)
|
|
name = "Job"
|
|
dependencies = list(
|
|
/datum/controller/subsystem/mapping,
|
|
)
|
|
flags = SS_NO_FIRE
|
|
|
|
var/list/occupations = list() //List of all jobs
|
|
var/list/datum/job/name_occupations = list() //Dict of all jobs, keys are titles
|
|
var/list/type_occupations = list() //Dict of all jobs, keys are types
|
|
|
|
var/list/department_datums = list()
|
|
var/debug_messages = FALSE
|
|
|
|
|
|
/datum/controller/subsystem/job/Initialize()
|
|
if(!department_datums.len)
|
|
setup_departments()
|
|
if(!occupations.len)
|
|
setup_occupations()
|
|
return SS_INIT_SUCCESS
|
|
|
|
/datum/controller/subsystem/job/proc/setup_occupations(faction = FACTION_STATION)
|
|
occupations = list()
|
|
var/list/all_jobs = subtypesof(/datum/job)
|
|
if(!all_jobs.len)
|
|
to_chat(world, span_warning("Error setting up jobs, no job datums found"))
|
|
return FALSE
|
|
|
|
for(var/J in all_jobs)
|
|
var/datum/job/job = new J()
|
|
if(!job)
|
|
continue
|
|
if(job.faction != faction)
|
|
continue
|
|
occupations += job
|
|
name_occupations[job.title] = job
|
|
type_occupations[J] = job
|
|
if(LAZYLEN(job.departments))
|
|
add_to_departments(job)
|
|
|
|
sortTim(occupations, GLOBAL_PROC_REF(cmp_job_datums))
|
|
for(var/D in department_datums)
|
|
var/datum/department/dept = department_datums[D]
|
|
sortTim(dept.jobs, GLOBAL_PROC_REF(cmp_job_datums), TRUE)
|
|
sortTim(dept.primary_jobs, GLOBAL_PROC_REF(cmp_job_datums), TRUE)
|
|
|
|
return TRUE
|
|
|
|
/datum/controller/subsystem/job/proc/add_to_departments(datum/job/J)
|
|
// Adds to the regular job lists in the departments, which allow multiple departments for a job.
|
|
for(var/D in J.departments)
|
|
var/datum/department/dept = LAZYACCESS(department_datums, D)
|
|
if(!istype(dept))
|
|
job_debug_message("Job '[J.title]' is defined as being inside department '[D]', but it does not exist.")
|
|
continue
|
|
dept.jobs[J.title] = J
|
|
|
|
// Now for the 'primary' department for a job, which is defined as being the first department in the list for a job.
|
|
// This results in no duplicates, which can be useful in some situations.
|
|
if(LAZYLEN(J.departments))
|
|
var/primary_department = J.departments[1]
|
|
var/datum/department/dept = LAZYACCESS(department_datums, primary_department)
|
|
if(!istype(dept))
|
|
job_debug_message("Job '[J.title]' has their primary department be '[primary_department]', but it does not exist.")
|
|
else
|
|
dept.primary_jobs[J.title] = J
|
|
|
|
/datum/controller/subsystem/job/proc/setup_departments()
|
|
for(var/t in subtypesof(/datum/department))
|
|
var/datum/department/D = new t()
|
|
department_datums[D.name] = D
|
|
|
|
sortTim(department_datums, GLOBAL_PROC_REF(cmp_department_datums), TRUE)
|
|
|
|
/datum/controller/subsystem/job/proc/get_all_department_datums()
|
|
var/list/dept_datums = list()
|
|
for(var/D in department_datums)
|
|
dept_datums += department_datums[D]
|
|
return dept_datums
|
|
|
|
/datum/controller/subsystem/job/proc/get_job(rank)
|
|
if(!occupations.len)
|
|
setup_occupations()
|
|
return name_occupations[rank]
|
|
|
|
/datum/controller/subsystem/job/proc/get_job_type(jobtype)
|
|
if(!occupations.len)
|
|
setup_occupations()
|
|
return type_occupations[jobtype]
|
|
|
|
// Determines if a job title is inside of a specific department.
|
|
// Useful to replace the old `if(job_title in command_positions)` code.
|
|
/datum/controller/subsystem/job/proc/is_job_in_department(rank, target_department_name)
|
|
var/datum/department/D = LAZYACCESS(department_datums, target_department_name)
|
|
if(istype(D))
|
|
return LAZYFIND(D.jobs, rank) ? TRUE : FALSE
|
|
return FALSE
|
|
|
|
// Returns a list of all job names in a specific department.
|
|
/datum/controller/subsystem/job/proc/get_job_titles_in_department(target_department_name)
|
|
var/datum/department/D = LAZYACCESS(department_datums, target_department_name)
|
|
if(istype(D))
|
|
var/list/job_titles = list()
|
|
for(var/J in D.jobs)
|
|
job_titles += J
|
|
return job_titles
|
|
|
|
job_debug_message("Was asked to get job titles for a non-existant department '[target_department_name]'.")
|
|
return list()
|
|
|
|
// Returns a reference to the primary department datum that a job is in.
|
|
// Can receive job datum refs, typepaths, or job title strings.
|
|
/datum/controller/subsystem/job/proc/get_primary_department_of_job(datum/job/J)
|
|
if(!istype(J, /datum/job))
|
|
if(ispath(J))
|
|
J = get_job_type(J)
|
|
else if(istext(J))
|
|
J = get_job(J)
|
|
|
|
if(!istype(J))
|
|
job_debug_message("Was asked to get department for job '[J]', but input could not be resolved into a job datum.")
|
|
return
|
|
|
|
if(!LAZYLEN(J.departments))
|
|
return
|
|
|
|
var/primary_department = J.departments[1]
|
|
var/datum/department/dept = LAZYACCESS(department_datums, primary_department)
|
|
if(!istype(dept))
|
|
job_debug_message("Job '[J.title]' has their primary department be '[primary_department]', but it does not exist.")
|
|
return
|
|
|
|
return department_datums[primary_department]
|
|
|
|
/datum/controller/subsystem/job/proc/get_ping_role(var/role)
|
|
var/datum/job/J = get_job(role)
|
|
if(J.requestable)
|
|
return get_primary_department_of_job(J)
|
|
|
|
// Someday it might be good to port code/game/jobs/job_controller.dm to here and clean it up.
|
|
|
|
/datum/controller/subsystem/job/proc/job_debug_message(message)
|
|
if(debug_messages)
|
|
log_debug("JOB DEBUG: [message]")
|