<commit_before>/atom/var/smooth = 0
/atom/var/top_left_corner
/atom/var/top_right_corner
/atom/var/bottom_left_corner
/atom/var/bottom_right_corner
/atom/var/can_be_unanchored = 0
/atom/var/list/canSmoothWith=list() // TYPE PATHS I CAN SMOOTH WITH~~~~~

//generic (by snowflake) tile smoothing code; smooth your icons with this!
/*
	Each tile is divided in 4 corners, each corner has an image associated to it; the tile is then overlayed by these 4 images
	To use this, just set your atom's 'smooth' var to 1. If your atom can be moved/unanchored, set its 'can_be_unanchored' var to 1.
	If you don't want your atom's icon to smooth with anything but atoms of the same type, set the list 'canSmoothWith' to null;
	Otherwise, put all types you want the atom icon to smooth with in 'canSmoothWith' INCLUDING THE TYPE OF THE ATOM ITSELF.

	Each atom has its own icon file with all the possible corner states. See 'smooth_wall.dmi' for a template.
*/

//Redefinitions of the diagonal directions so they can be stored in one var without conflicts
#define NORTH_EAST	16
#define NORTH_WEST	32
#define SOUTH_EAST	64
#define SOUTH_WEST	128

/proc/calculate_adjacencies(atom/A)
	var/adjacencies = 0

	if(A.can_be_unanchored)
		var/atom/movable/AM = A
		if(!AM.anchored)
			return 0

		for(var/direction in alldirs)
			AM = find_type_in_direction(A, direction)
			if(istype(AM))
				if(AM.anchored)
					adjacencies |= transform_dir(direction)
			else
				if(AM)
					adjacencies |= transform_dir(direction)
	else
		for(var/direction in alldirs)
			if(find_type_in_direction(A, direction))
				adjacencies |= transform_dir(direction)
	return adjacencies

/proc/smooth_icon(atom/A)
	if(A && A.smooth)
		var/adjacencies = calculate_adjacencies(A)

		clear_overlays(A)

		A.top_left_corner = make_nw_corner(adjacencies)
		A.top_right_corner = make_ne_corner(adjacencies)
		A.bottom_left_corner = make_sw_corner(adjacencies)
		A.bottom_right_corner = make_se_corner(adjacencies)

		A.overlays += A.top_left_corner
		A.overlays += A.top_right_corner
		A.overlays += A.bottom_right_corner
		A.overlays += A.bottom_left_corner


/proc/make_nw_corner(adjacencies)
	var/sdir = "i"
	if((adjacencies & NORTH) && (adjacencies & WEST))
		if(adjacencies & NORTH_WEST)
			sdir = "f"
		else
			sdir = "nw"
	else
		if(adjacencies & NORTH)
			sdir = "n"
		else if(adjacencies & WEST)
			sdir = "w"
		else
			sdir = "i"
	return "1-[sdir]"

/proc/make_ne_corner(adjacencies)
	var/sdir = "i"
	if((adjacencies & NORTH) && (adjacencies & EAST))
		if(adjacencies & NORTH_EAST)<commit_msg>Readds spawn() proc to icon smoothing code.<commit_after>/atom/var/smooth = 0
/atom/var/top_left_corner
/atom/var/top_right_corner
/atom/var/bottom_left_corner
/atom/var/bottom_right_corner
/atom/var/can_be_unanchored = 0
/atom/var/list/canSmoothWith=list() // TYPE PATHS I CAN SMOOTH WITH~~~~~

//generic (by snowflake) tile smoothing code; smooth your icons with this!
/*
	Each tile is divided in 4 corners, each corner has an image associated to it; the tile is then overlayed by these 4 images
	To use this, just set your atom's 'smooth' var to 1. If your atom can be moved/unanchored, set its 'can_be_unanchored' var to 1.
	If you don't want your atom's icon to smooth with anything but atoms of the same type, set the list 'canSmoothWith' to null;
	Otherwise, put all types you want the atom icon to smooth with in 'canSmoothWith' INCLUDING THE TYPE OF THE ATOM ITSELF.

	Each atom has its own icon file with all the possible corner states. See 'smooth_wall.dmi' for a template.
*/

//Redefinitions of the diagonal directions so they can be stored in one var without conflicts
#define NORTH_EAST	16
#define NORTH_WEST	32
#define SOUTH_EAST	64
#define SOUTH_WEST	128

/proc/calculate_adjacencies(atom/A)
	var/adjacencies = 0

	if(A.can_be_unanchored)
		var/atom/movable/AM = A
		if(!AM.anchored)
			return 0

		for(var/direction in alldirs)
			AM = find_type_in_direction(A, direction)
			if(istype(AM))
				if(AM.anchored)
					adjacencies |= transform_dir(direction)
			else
				if(AM)
					adjacencies |= transform_dir(direction)
	else
		for(var/direction in alldirs)
			if(find_type_in_direction(A, direction))
				adjacencies |= transform_dir(direction)
	return adjacencies

/proc/smooth_icon(atom/A)
	spawn(0) //don't remove this, otherwise smoothing breaks
		if(A && A.smooth)
			var/adjacencies = calculate_adjacencies(A)

			clear_overlays(A)

			A.top_left_corner = make_nw_corner(adjacencies)
			A.top_right_corner = make_ne_corner(adjacencies)
			A.bottom_left_corner = make_sw_corner(adjacencies)
			A.bottom_right_corner = make_se_corner(adjacencies)

			A.overlays += A.top_left_corner
			A.overlays += A.top_right_corner
			A.overlays += A.bottom_right_corner
			A.overlays += A.bottom_left_corner


/proc/make_nw_corner(adjacencies)
	var/sdir = "i"
	if((adjacencies & NORTH) && (adjacencies & WEST))
		if(adjacencies & NORTH_WEST)
			sdir = "f"
		else
			sdir = "nw"
	else
		if(adjacencies & NORTH)
			sdir = "n"
		else if(adjacencies & WEST)
			sdir = "w"
		else
			sdir = "i"
	return "1-[sdir]"

/proc/make_ne_corner(adjacencies)
	var/sdir = "i"
	if((adjacencies & NORTH) && (adjacencies & EAST))
		if(adjacencies & NORTH_EAST)
{'fraction_non_alphanumeric': 0.09782817605227753, 'fraction_numerical': 0.007111281952719585, 'mean_word_length': 4.198801198801199, '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': '3691166', 'n_tokens_mistral': 2164, 'n_tokens_neox': 1895, 'n_words': 522}