Files
Bubberstation/code/datums/components/simple_access.dm
Ben10Omintrix 4aec21e180 jps movement can read accesses from the access component (#83384)
## About The Pull Request
jps movement can read accesses from the access component

## Why It's Good For The Game
i cant think of any mobs that need this now but it will be useful in the
future

## Changelog
🆑
/🆑
2024-05-22 19:07:15 -04:00

39 lines
1.4 KiB
Plaintext

///This component allows us to give a mob access without giving them an ID card.
/datum/component/simple_access
dupe_mode = COMPONENT_DUPE_ALLOWED
///list of accesses we are allowed to access via this component
var/list/access
/datum/component/simple_access/Initialize(list/new_access, atom/donor_atom)
. = ..()
if(!ismob(parent))
return COMPONENT_INCOMPATIBLE
access = new_access
RegisterSignal(parent, COMSIG_MOB_TRIED_ACCESS, PROC_REF(on_tried_access))
RegisterSignal(parent, COMSIG_MOB_RETRIEVE_SIMPLE_ACCESS, PROC_REF(retrieve_access))
if(!donor_atom)
return
if(isorgan(donor_atom))
RegisterSignal(donor_atom, COMSIG_ORGAN_REMOVED, PROC_REF(on_donor_removed))
else if(istype(donor_atom, /obj/item/implant))
RegisterSignal(donor_atom, COMSIG_IMPLANT_REMOVED, PROC_REF(on_donor_removed))
RegisterSignal(donor_atom, COMSIG_QDELETING, PROC_REF(on_donor_removed))
/datum/component/simple_access/proc/on_tried_access(datum/source, atom/locked_thing)
SIGNAL_HANDLER
if(!isobj(locked_thing))
return LOCKED_ATOM_INCOMPATIBLE
var/obj/locked_object = locked_thing
if(locked_object.check_access_list(access))
return ACCESS_ALLOWED
else
return ACCESS_DISALLOWED
/datum/component/simple_access/proc/retrieve_access(datum/source, list/access_list)
SIGNAL_HANDLER
access_list += access
/datum/component/simple_access/proc/on_donor_removed(datum/source)
SIGNAL_HANDLER
qdel(src)