<commit_before>var/global/list/body_accessory_by_name = list("None" = null)

/hook/startup/proc/initalize_body_accessories()

	__init_body_accessory(/datum/body_accessory/body)
	__init_body_accessory(/datum/body_accessory/tail)

	if(body_accessory_by_name.len)
		if(initialize_body_accessory_by_species())
			return 1

	return 0 //fail if no bodies are found

var/global/list/body_accessory_by_species = list("None" = null)

/proc/initialize_body_accessory_by_species()
	for(var/B in body_accessory_by_name)
		var/datum/body_accessory/accessory = body_accessory_by_name[B]
		if(!istype(accessory))	continue

		for(var/species in accessory.allowed_species)
			if(!body_accessory_by_species["[species]"])	body_accessory_by_species["[species]"] = list()
			body_accessory_by_species["[species]"] += accessory

	if(body_accessory_by_species.len)
		return 1
	return 0

/proc/__init_body_accessory(var/ba_path)
	if(ispath(ba_path))
		var/_added_counter = 0

		for(var/A in subtypesof(ba_path))
			var/datum/body_accessory/B = new A
			if(istype(B))
				body_accessory_by_name[B.name] += B
				++_added_counter

		if(_added_counter)
			return 1
	return 0


/datum/body_accessory
	var/name = "default"

	var/icon = null
	var/icon_state = ""

	var/animated_icon = null
	var/animated_icon_state = ""

	var/blend_mode = null

	var/list/pixel_offsets = list("x" = 0, "y" = 0)

	var/list/allowed_species = list()

/datum/body_accessory/proc/try_restrictions(var/mob/living/carbon/human/H)
	return 1

/datum/body_accessory/proc/get_pixel_x(var/mob/living/carbon/human/H)
	return pixel_offsets["x"]

/datum/body_accessory/proc/get_pixel_y(var/mob/living/carbon/human/H)
	return pixel_offsets["y"]

/datum/body_accessory/proc/get_animated_icon() //return animated if it has it, return static if it does not.
	if(animated_icon)
		return animated_icon

	else	return icon

/datum/body_accessory/proc/get_animated_icon_state()
	if(animated_icon_state)
		return animated_icon_state

	else	return icon_state


//Bodies
/datum/body_accessory/body
	blend_mode = ICON_MULTIPLY

/datum/body_accessory/body/snake
	name = "Snake"

	icon = 'icons/mob/body_accessory_64.dmi'
	icon_state = "naga"

	pixel_offsets = list("x" = -16, "y" = 0)

//Tails
/datum/body_accessory/tail
	icon = 'icons/mob/body_accessory.dmi'
	animated_icon = 'icons/mob/body_accessory.dmi'
	blend_mode = ICON_ADD

/datum/body_accessory/tail/try_restrictions(var/mob/living/carbon/human/H)
	if(!H.wear_suit || !(H.wear_suit.flags_inv & HIDETAIL) && !istype(H.wear_suit, /obj/item/clothing/suit/space))
		return 1
	return 0


//vulpakin
/datum/body_accessory/tail/vulpkanin_2
	name = "Vulpkanin Alt 1 (Bushy)"

	icon_state = "vulptail2"
	animated_icon_state = "vulptail2_a"
	allowed_species = list("Vulpkanin")

/datum/body_accessory/tail/vulpkanin_3
	name = "Vulpkanin Alt 2 (Straight)"

	icon_state = "vulptail3"
	animated_icon_state = "vulptail3_a"
	allowed_species = list("Vulpkanin")

/datum/body_accessory/tail/vulpkanin_4
	name = "Vulpkanin Alt 3 (Tiny)"

	icon_state = "vulptail4"
	animated_icon_state = "vulptail4_a"
	allowed_species = list("Vulpkanin")

/datum/body_accessory/tail/vulpkanin_5
	name = "Vulpkanin Alt 4 (Short)"

	icon_state = "vulptail5"
	animated_icon_state = "vulptail5_a"
	allowed_species = list("Vulpkanin")<commit_msg>Change pixel_offsets list into two variables for efficiency<commit_after>var/global/list/body_accessory_by_name = list("None" = null)

/hook/startup/proc/initalize_body_accessories()

	__init_body_accessory(/datum/body_accessory/body)
	__init_body_accessory(/datum/body_accessory/tail)

	if(body_accessory_by_name.len)
		if(initialize_body_accessory_by_species())
			return 1

	return 0 //fail if no bodies are found

var/global/list/body_accessory_by_species = list("None" = null)

/proc/initialize_body_accessory_by_species()
	for(var/B in body_accessory_by_name)
		var/datum/body_accessory/accessory = body_accessory_by_name[B]
		if(!istype(accessory))	continue

		for(var/species in accessory.allowed_species)
			if(!body_accessory_by_species["[species]"])	body_accessory_by_species["[species]"] = list()
			body_accessory_by_species["[species]"] += accessory

	if(body_accessory_by_species.len)
		return 1
	return 0

/proc/__init_body_accessory(var/ba_path)
	if(ispath(ba_path))
		var/_added_counter = 0

		for(var/A in subtypesof(ba_path))
			var/datum/body_accessory/B = new A
			if(istype(B))
				body_accessory_by_name[B.name] += B
				++_added_counter

		if(_added_counter)
			return 1
	return 0


/datum/body_accessory
	var/name = "default"

	var/icon = null
	var/icon_state = ""

	var/animated_icon = null
	var/animated_icon_state = ""

	var/blend_mode = null

	var/pixel_x_offset = 0
	var/pixel_y_offset = 0

	var/list/allowed_species = list()

/datum/body_accessory/proc/try_restrictions(var/mob/living/carbon/human/H)
	return 1

/datum/body_accessory/proc/get_pixel_x(var/mob/living/carbon/human/H)
	return pixel_x_offset

/datum/body_accessory/proc/get_pixel_y(var/mob/living/carbon/human/H)
	return pixel_y_offset

/datum/body_accessory/proc/get_animated_icon() //return animated if it has it, return static if it does not.
	if(animated_icon)
		return animated_icon

	else	return icon

/datum/body_accessory/proc/get_animated_icon_state()
	if(animated_icon_state)
		return animated_icon_state

	else	return icon_state


//Bodies
/datum/body_accessory/body
	blend_mode = ICON_MULTIPLY

/datum/body_accessory/body/snake
	name = "Snake"

	icon = 'icons/mob/body_accessory_64.dmi'
	icon_state = "naga"

	pixel_x_offset = -16

//Tails
/datum/body_accessory/tail
	icon = 'icons/mob/body_accessory.dmi'
	animated_icon = 'icons/mob/body_accessory.dmi'
	blend_mode = ICON_ADD

/datum/body_accessory/tail/try_restrictions(var/mob/living/carbon/human/H)
	if(!H.wear_suit || !(H.wear_suit.flags_inv & HIDETAIL) && !istype(H.wear_suit, /obj/item/clothing/suit/space))
		return 1
	return 0


//vulpakin
/datum/body_accessory/tail/vulpkanin_2
	name = "Vulpkanin Alt 1 (Bushy)"

	icon_state = "vulptail2"
	animated_icon_state = "vulptail2_a"
	allowed_species = list("Vulpkanin")

/datum/body_accessory/tail/vulpkanin_3
	name = "Vulpkanin Alt 2 (Straight)"

	icon_state = "vulptail3"
	animated_icon_state = "vulptail3_a"
	allowed_species = list("Vulpkanin")

/datum/body_accessory/tail/vulpkanin_4
	name = "Vulpkanin Alt 3 (Tiny)"

	icon_state = "vulptail4"
	animated_icon_state = "vulptail4_a"
	allowed_species = list("Vulpkanin")

/datum/body_accessory/tail/vulpkanin_5
	name = "Vulpkanin Alt 4 (Short)"

	icon_state = "vulptail5"
	animated_icon_state = "vulptail5_a"
	allowed_species = list("Vulpkanin")
{'fraction_non_alphanumeric': 0.11630022744503411, 'fraction_numerical': 0.009855951478392721, 'mean_word_length': 5.176029962546816, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3135996', 'n_tokens_mistral': 2847, 'n_tokens_neox': 2641, 'n_words': 396}