Files
Bubberstation/code/datums/components/simple_access.dm
John Willard aedc5bae7a allowed is now signals based instead of hardcoded slots (#94871)
## About The Pull Request

ID cards/MMI mech access/simple mob access/pAIs now use signals instead
of checking specific slots with mob checks. We do this through mob's
``get_access`` proc that collects all access a mob has with a
collect_access signal.

## Why It's Good For The Game

It looks cleaner and we no longer individually check `check_access` for
every single item that may have access. It's cleaner to put it all
together and check in one go with all the access we've got. This also
makes it easier to add items that hold access that aren't necessarily
IDs but you want to be able to open stuff with.

## Changelog

🆑
refactor: ID checking for access has been reworked, please make a bug
report if anything that's supposed to grant access is not working.
/🆑

---------

Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
2026-01-16 14:16:22 -07:00

28 lines
1021 B
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_RETRIEVE_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/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)