Files
Bubberstation/code/datums/components/simple_access.dm
LemonInTheDark ae5a4f955d Pulls apart the vestiges of components still hanging onto signals (#75914)
## About The Pull Request

Signals were initially only usable with component listeners, which while
no longer the case has lead to outdated documentation, names, and a
similar location in code.

This pr pulls the two apart. Partially because mso thinks we should, but
also because they really aren't directly linked anymore, and having them
in this midstate just confuses people.

[Renames comp_lookup to listen_lookup, since that's what it
does](102b79694f)

[Moves signal procs over to their own
file](33d07d01fd)

[Renames the PREQDELETING and QDELETING comsigs to drop the parent bit
since they can hook to more then just comps
now](335ea4ad08)

[Does something similar to the attackby comsigs (PARENT ->
ATOM)](210e57051d)

[And finally passes over the examine
signals](65917658fb)

## Why It's Good For The Game

Code makes more sense, things are better teased apart, s just good imo

## Changelog
🆑
refactor: Pulled apart the last vestiges of names/docs directly linking
signals to components
/🆑
2023-06-09 06:14:31 +00:00

34 lines
1.2 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))
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/on_donor_removed(datum/source)
SIGNAL_HANDLER
qdel(src)