From 2feb01fec854bcb2cf7bdbd8b7bd1ab9373e62cb Mon Sep 17 00:00:00 2001 From: Arkatos1 Date: Fri, 19 Apr 2019 20:00:31 +0200 Subject: [PATCH] Fixes a bug regarding hardhats and refactors them --- code/modules/clothing/head/hardhat.dm | 34 +++++++++++++++++++-------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/code/modules/clothing/head/hardhat.dm b/code/modules/clothing/head/hardhat.dm index 9a08a7ab68f..4a51349e165 100644 --- a/code/modules/clothing/head/hardhat.dm +++ b/code/modules/clothing/head/hardhat.dm @@ -16,25 +16,39 @@ "Grey" = 'icons/mob/species/grey/head.dmi' ) -/obj/item/clothing/head/hardhat/attack_self(mob/user) +/obj/item/clothing/head/hardhat/attack_self(mob/living/user) + toggle_helmet_light(user) + +/obj/item/clothing/head/hardhat/proc/toggle_helmet_light(mob/living/user) on = !on + if(on) + turn_on(user) + else + turn_off(user) + update_icon() + +/obj/item/clothing/head/hardhat/update_icon() icon_state = "hardhat[on]_[item_color]" item_state = "hardhat[on]_[item_color]" - if(on) - set_light(brightness_on) - else - set_light(0) - + if(ishuman(loc)) + var/mob/living/carbon/human/H = loc + H.update_inv_head() for(var/X in actions) var/datum/action/A = X A.UpdateButtonIcon() + ..() -/obj/item/clothing/head/hardhat/extinguish_light() +/obj/item/clothing/head/hardhat/proc/turn_on(mob/user) + set_light(brightness_on) + +/obj/item/clothing/head/hardhat/proc/turn_off(mob/user) + set_light(0) + +/obj/item/clothing/head/hardhat/extinguish_light(mob/living/user) if(on) on = FALSE - set_light(0) - icon_state = "hardhat0_[item_color]" - item_state = "hardhat0_[item_color]" + turn_off(user) + update_icon() visible_message("[src]'s light fades and turns off.") /obj/item/clothing/head/hardhat/orange