Fully implements the ID Card design document (#56910)

Co-authored-by: Rohesie <rohesie@gmail.com>
This commit is contained in:
Timberpoes
2021-02-28 19:26:45 -08:00
committed by GitHub
co-authored by Rohesie
parent 39db53e42d
commit 890615856e
154 changed files with 4820 additions and 1966 deletions
+44 -13
View File
@@ -42,27 +42,52 @@
/obj/item/storage/wallet/Exited(atom/movable/AM)
. = ..()
refreshID()
refreshID(removed = TRUE)
/obj/item/storage/wallet/proc/refreshID()
/**
* Calculates the new front ID.
*
* Picks the ID card that has the most combined command or higher tier accesses.
* Arguments:
* * removed - If this proc was called because a card was removed. There's a chance we don't need to calculate the new front ID if a card was removed.
*/
/obj/item/storage/wallet/proc/refreshID(removed = FALSE)
LAZYCLEARLIST(combined_access)
if(!(front_id in src))
front_id = null
for(var/obj/item/card/id/I in contents)
if(!front_id)
front_id = I
// If the front_id is still in our wallet an we removed a card, we can return early.
if((front_id in src) && removed)
return
front_id = null
var/winning_tally = 0
for(var/card in contents)
var/obj/item/card/id/id_card = card
if(!istype(id_card))
continue
var/card_tally = SSid_access.tally_access(id_card, ACCESS_FLAG_COMMAND)
if(card_tally > winning_tally)
winning_tally = card_tally
front_id = id_card
LAZYINITLIST(combined_access)
combined_access |= I.access
combined_access |= id_card.access
// If we didn't pick a front ID - Maybe none of our cards have any command accesses? Just grab the first card (if we even have one).
// We could also have no ID card in the wallet at all, which will mean we end up with a null front_id and that's fine too.
if(!front_id)
front_id = (locate(/obj/item/card/id) in contents)
if(ishuman(loc))
var/mob/living/carbon/human/H = loc
if(H.wear_id == src)
H.sec_hud_set_ID()
update_appearance()
var/mob/living/carbon/human/wearing_human = loc
if(wearing_human.wear_id == src)
wearing_human.sec_hud_set_ID()
update_label()
update_appearance(UPDATE_ICON)
update_slot_icon()
/obj/item/storage/wallet/Entered(atom/movable/AM)
. = ..()
refreshID()
refreshID(removed = FALSE)
/obj/item/storage/wallet/update_overlays()
. = ..()
@@ -94,6 +119,12 @@
if(front_id)
. += "<span class='notice'>Alt-click to remove the id.</span>"
/obj/item/storage/wallet/get_id_examine_strings(mob/user)
. = ..()
if(front_id)
. += "\The [src] is displaying [front_id]."
. += front_id.get_id_examine_strings(user)
/obj/item/storage/wallet/GetID()
return front_id