mirror of
https://github.com/Citadel-Station-13/Citadel-Station-13-RP.git
synced 2026-08-29 01:36:49 +01:00
Co-authored-by: silicons <no@you.cat> Co-authored-by: LordME <58342752+TheLordME@users.noreply.github.com>
38 lines
1.1 KiB
Plaintext
38 lines
1.1 KiB
Plaintext
/datum/element/hud_granter
|
|
id_arg_index = 2
|
|
element_flags = ELEMENT_BESPOKE | ELEMENT_DETACH
|
|
/// huds
|
|
var/list/huds
|
|
/// relevant slots
|
|
var/list/slots
|
|
|
|
/datum/element/hud_granter/Attach(datum/target, list/huds, list/slots)
|
|
. = ..()
|
|
if(. & ELEMENT_INCOMPATIBLE)
|
|
return
|
|
if(!isitem(target))
|
|
return ELEMENT_INCOMPATIBLE
|
|
src.huds = huds
|
|
src.slots = islist(slots)? slots : list(slots)
|
|
RegisterSignal(target, COMSIG_ITEM_EQUIPPED, PROC_REF(on_equip))
|
|
RegisterSignal(target, COMSIG_ITEM_UNEQUIPPED, PROC_REF(on_unequip))
|
|
|
|
/datum/element/hud_granter/Detach(datum/source)
|
|
. = ..()
|
|
UnregisterSignal(source, list(
|
|
COMSIG_ITEM_EQUIPPED,
|
|
COMSIG_ITEM_DROPPED
|
|
))
|
|
|
|
/datum/element/hud_granter/proc/on_equip(datum/source, mob/M, slot)
|
|
if(!(slot in slots))
|
|
return
|
|
for(var/hud in huds)
|
|
M.self_perspective.add_atom_hud(hud, ATOM_HUD_SOURCE_FOR_HUD_GRANTER_ON_EQUIPMENT_SLOT(slot))
|
|
|
|
/datum/element/hud_granter/proc/on_unequip(datum/source, mob/M, slot)
|
|
if(!(slot in slots))
|
|
return
|
|
for(var/hud in huds)
|
|
M.self_perspective.remove_atom_hud(hud, ATOM_HUD_SOURCE_FOR_HUD_GRANTER_ON_EQUIPMENT_SLOT(slot))
|