<commit_before>//Hoods for winter coats and chaplain hoodie etc

/obj/item/clothing/suit/hooded
	actions_types = list(/datum/action/item_action/toggle_hood)
	var/obj/item/clothing/head/hooded/hood
	var/hoodtype = /obj/item/clothing/head/hooded/winterhood //so the chaplain hoodie or other hoodies can override this

/obj/item/clothing/suit/hooded/New()
	hood = MakeHelmet()
	..()

/obj/item/clothing/suit/hooded/Destroy()
	. = ..()
	qdel(hood)
	hood = null

/obj/item/clothing/suit/proc/MakeHelmet(obj/item/clothing/head/H)
	SEND_SIGNAL(src, COMSIG_SUIT_MADE_HELMET, H)
	return H

/obj/item/clothing/suit/hooded/MakeHelmet(obj/item/clothing/head/hooded/H)
	if(!hood)
		H = new hoodtype(src)
		H.suit = src
		return ..()

/obj/item/clothing/suit/hooded/ui_action_click()
	ToggleHood()

/obj/item/clothing/suit/hooded/item_action_slot_check(slot, mob/user, datum/action/A)
	if(slot == SLOT_WEAR_SUIT || slot == SLOT_NECK)
		return 1

/obj/item/clothing/suit/hooded/equipped(mob/user, slot)
	if(slot != SLOT_WEAR_SUIT && slot != SLOT_NECK)
		RemoveHood()
	..()

/obj/item/clothing/suit/hooded/proc/RemoveHood()
	suittoggled = FALSE
	if(ishuman(hood.loc))
		var/mob/living/carbon/H = hood.loc
		H.transferItemToLoc(hood, src, TRUE)
		H.update_inv_wear_suit()
	else
		hood.forceMove(src)
	update_icon()

/obj/item/clothing/suit/hooded/update_icon_state()
	icon_state = "[initial(icon_state)]"
	if(ishuman(hood.loc))
		var/mob/living/carbon/human/H = hood.loc
		if(H.head == hood)
			icon_state += "_t"

/obj/item/clothing/suit/hooded/dropped(mob/user)
	..()
	RemoveHood()

/obj/item/clothing/suit/hooded/proc/ToggleHood()
	if(!suittoggled)
		if(ishuman(src.loc))
			var/mob/living/carbon/human/H = src.loc
			if(H.wear_suit != src)
				to_chat(H, "<span class='warning'>You must be wearing [src] to put up the hood!</span>")
				return
			if(H.head)
				to_chat(H, "<span class='warning'>You're already wearing something on your head!</span>")
				return
			else if(H.equip_to_slot_if_possible(hood,SLOT_HEAD,0,0,1))
				suittoggled = TRUE
				update_icon()
				H.update_inv_wear_suit()
	else
		RemoveHood()

/obj/item/clothing/head/hooded
	var/obj/item/clothing/suit/hooded/suit<commit_msg>Fixes hair falling out of hoodies<commit_after>//Hoods for winter coats and chaplain hoodie etc

/obj/item/clothing/suit/hooded
	actions_types = list(/datum/action/item_action/toggle_hood)
	var/obj/item/clothing/head/hooded/hood
	var/hoodtype = /obj/item/clothing/head/hooded/winterhood //so the chaplain hoodie or other hoodies can override this

/obj/item/clothing/suit/hooded/New()
	hood = MakeHelmet()
	..()

/obj/item/clothing/suit/hooded/Destroy()
	. = ..()
	qdel(hood)
	hood = null

/obj/item/clothing/suit/proc/MakeHelmet(obj/item/clothing/head/H)
	SEND_SIGNAL(src, COMSIG_SUIT_MADE_HELMET, H)
	return H

/obj/item/clothing/suit/hooded/MakeHelmet(obj/item/clothing/head/hooded/H)
	if(!hood)
		H = new hoodtype(src)
		H.suit = src
		return ..()

/obj/item/clothing/suit/hooded/ui_action_click()
	ToggleHood()

/obj/item/clothing/suit/hooded/item_action_slot_check(slot, mob/user, datum/action/A)
	if(slot == SLOT_WEAR_SUIT || slot == SLOT_NECK)
		return 1

/obj/item/clothing/suit/hooded/equipped(mob/user, slot)
	if(slot != SLOT_WEAR_SUIT && slot != SLOT_NECK)
		RemoveHood()
	..()

/obj/item/clothing/suit/hooded/proc/RemoveHood()
	suittoggled = FALSE
	if(ishuman(hood.loc))
		var/mob/living/carbon/H = hood.loc
		H.transferItemToLoc(hood, src, TRUE)
		H.update_inv_wear_suit()
	else
		hood.forceMove(src)
	update_icon()

/obj/item/clothing/suit/hooded/update_icon_state()
	icon_state = "[initial(icon_state)]"
	if(ishuman(hood.loc))
		var/mob/living/carbon/human/H = hood.loc
		if(H.head == hood)
			icon_state += "_t"

/obj/item/clothing/suit/hooded/dropped(mob/user)
	..()
	RemoveHood()

/obj/item/clothing/suit/hooded/proc/ToggleHood()
	if(!suittoggled)
		if(ishuman(src.loc))
			var/mob/living/carbon/human/H = src.loc
			if(H.wear_suit != src)
				to_chat(H, "<span class='warning'>You must be wearing [src] to put up the hood!</span>")
				return
			if(H.head)
				to_chat(H, "<span class='warning'>You're already wearing something on your head!</span>")
				return
			else if(H.equip_to_slot_if_possible(hood,SLOT_HEAD,0,0,1))
				suittoggled = TRUE
				update_icon()
				H.update_inv_wear_suit()
	else
		RemoveHood()

/obj/item/clothing/head/hooded
	var/obj/item/clothing/suit/hooded/suit
	dynamic_hair_suffix = ""
{'fraction_non_alphanumeric': 0.15323675871435039, 'fraction_numerical': 0.0018107741059302852, 'mean_word_length': 4.138372093023256, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4996492', 'n_tokens_mistral': 1915, 'n_tokens_neox': 1806, 'n_words': 263}