[MODULAR] Off-Duty check proc (#22647)

* time clock integration

* actual proc

* Update off_duty_check.dm
This commit is contained in:
Pinta
2023-07-30 20:43:30 -04:00
committed by nevimer
parent 1180dcbcb1
commit 03b2bba982
4 changed files with 69 additions and 0 deletions
@@ -0,0 +1,54 @@
/**
* Checks is the parent mob is currently off duty. Returns `FALSE` if the mob isn't clocked out.
*
* Arguements
* * `whitelisted_deparments` - This list contains the paths of `/datum/job_department`s we want to check if the parent mob is part of.
* If present, we will only check if the mob is off-duty if they are a member of one of the departments in the list
* Otherwise, if we have nothing in the list, we will check all departments
* * `blacklisted_jobs` - This is a list that contains paths of the `/datum/job`s that we will always return `TRUE` for
* This typically applies for jobs like assistant where clock status probably wouldn't really matter.
*/
/mob/living/carbon/human/proc/check_if_off_duty(list/whitelisted_deparments = list(), list/blacklisted_jobs = list(/datum/job/assistant))
if(!mind?.assigned_role)
return TRUE //If someone lacks a job or mind, we probably don't need to worry about their clock status.
var/datum/job/job_datum = mind.assigned_role
if(!istype(job_datum))
return TRUE
var/need_to_check = FALSE
if(length(whitelisted_deparments))
for(var/department as anything in whitelisted_deparments)
if(is_path_in_list(department, job_datum.departments_list))
need_to_check = TRUE
if(blacklisted_jobs && need_to_check)
if(is_path_in_list(job_datum, blacklisted_jobs))
need_to_check = FALSE
if(!need_to_check)
return TRUE
return mind.clocked_out_of_job
/obj/item/duty_checker //Test item
name = "duty checker"
desc = "Checks if the mob this is used on is off-duty. You probably shouldn't see this in-game..."
icon = 'icons/obj/device.dmi'
icon_state = "gangtool-purple"
lefthand_file = 'icons/mob/inhands/items/devices_lefthand.dmi'
righthand_file = 'icons/mob/inhands/items/devices_righthand.dmi'
inhand_icon_state = "electronic"
/obj/item/duty_checker/attack(mob/living/carbon/human/target_human, mob/living/user, params)
. = ..()
if(!istype(target_human))
return FALSE
if(target_human.check_if_off_duty(list(/datum/job_department/security)))
to_chat(user, span_notice("[target_human] is off-duty!"))
return TRUE
to_chat(user, span_notice("[target_human] is not off-duty!"))
return FALSE
@@ -101,6 +101,11 @@
if(off_duty_check())
clock_in()
log_admin("[key_name(usr)] clocked in as \an [inserted_id.assignment].")
var/datum/mind/user_mind = usr.mind
if(user_mind)
user_mind.clocked_out_of_job = FALSE
else
log_admin("[key_name(usr)] clocked out as \an [inserted_id.assignment].")
clock_out()
@@ -108,6 +113,10 @@
if(human_user)
human_user.return_items_to_console(TIME_CLOCK_RETURN_ITEMS)
var/datum/mind/user_mind = usr.mind
if(user_mind)
user_mind.clocked_out_of_job = TRUE
if(important_job_check())
message_admins("[key_name(usr)] has clocked out as a head of staff. [ADMIN_JMP(src)]")
@@ -0,0 +1,4 @@
/datum/mind
/// Is our mind currently clocked out of their job?
var/clocked_out_of_job = FALSE
+2
View File
@@ -5722,6 +5722,7 @@
#include "modular_skyrat\master_files\code\modules\clothing\under\jobs\civilian\suits.dm"
#include "modular_skyrat\master_files\code\modules\events\_event.dm"
#include "modular_skyrat\master_files\code\modules\food_and_drinks\recipes\food_mixtures.dm"
#include "modular_skyrat\master_files\code\modules\jobs\off_duty_check.dm"
#include "modular_skyrat\master_files\code\modules\jobs\departments\departments.dm"
#include "modular_skyrat\master_files\code\modules\jobs\job_types\_job.dm"
#include "modular_skyrat\master_files\code\modules\jobs\job_types\_job_attire.dm"
@@ -7208,6 +7209,7 @@
#include "modular_skyrat\modules\ticket_counter\code\counter.dm"
#include "modular_skyrat\modules\time_clock\code\console.dm"
#include "modular_skyrat\modules\time_clock\code\console_tgui.dm"
#include "modular_skyrat\modules\time_clock\code\mind.dm"
#include "modular_skyrat\modules\time_clock\code\off_duty_component.dm"
#include "modular_skyrat\modules\title_screen\code\_title_screen_defines.dm"
#include "modular_skyrat\modules\title_screen\code\new_player.dm"