<commit_before>/turf/space
	icon = 'icons/turf/space.dmi'
	name = "\proper space"
	icon_state = "0"
	intact = 0

	temperature = TCMB
	thermal_conductivity = OPEN_HEAT_TRANSFER_COEFFICIENT
	heat_capacity = 700000

	var/transition //These is used in transistions as a way to tell where on the "cube" of space you're transitioning from/to
	var/destination_x
	var/destination_y

/turf/space/New()
	if(!istype(src, /turf/space/transit))
		icon_state = "[((x + y) ^ ~(x * y) + z) % 25]"

/turf/space/attack_paw(mob/user as mob)
	return src.attack_hand(user)

/turf/space/attackby(obj/item/C, mob/user)
	if(istype(C, /obj/item/stack/rods))
		var/obj/item/stack/rods/R = C
		var/obj/structure/lattice/L = locate(/obj/structure/lattice, src)
		if(L)
			user << "<span class='warning'>There is already a lattice.</span>"
			return
		if(R.use(1))
			user << "<span class='notice'>Constructing support lattice...</span>"
			playsound(src, 'sound/weapons/Genhit.ogg', 50, 1)
			ReplaceWithLattice()
		else
			user << "<span class='warning'>You need one rod to build lattice.</span>"
		return
	if(istype(C, /obj/item/stack/tile/plasteel))
		var/obj/structure/lattice/L = locate(/obj/structure/lattice, src)
		if(L)
			var/obj/item/stack/tile/plasteel/S = C
			if(S.use(1))
				qdel(L)
				playsound(src, 'sound/weapons/Genhit.ogg', 50, 1)
				user << "<span class='notice'>You build a floor.</span>"
				S.build(src)
			else
				user << "<span class='warning'>You need one floor tile to build a floor.</span>"
		else
			user << "<span class='danger'>The plating is going to need some support. Place metal rods first.</span>"

/turf/space/Entered(atom/movable/A)
	..()
	if ((!(A) || src != A.loc))
		return

	inertial_drift(A)

	if(transition)

		if(destination_x)
			A.x = destination_x

		if(destination_y)
			A.y = destination_y

		A.z =  text2num(transition)

		if(isliving(A))
			var/mob/living/L = A
			if(L.pulling)
				var/turf/T = get_step(L.loc,turn(A.dir, 180))
				L.pulling.loc = T

/turf/space/proc/Sandbox_Spacemove(atom/movable/A)
	var/cur_x
	var/cur_y
	var/next_x = src.x
	var/next_y = src.y
	var/target_z
	var/list/y_arr
	var/list/cur_pos = src.get_global_map_pos()
	if(!cur_pos)
		return
	cur_x = cur_pos["x"]
	cur_y = cur_pos["y"]

	if(src.x <= 1)
		next_x = (--cur_x||global_map.len)
		y_arr = global_map[next_x]
		target_z = y_arr[cur_y]
		next_x = world.maxx - 2
	else if (src.x >= world.maxx)
		next_x = (++cur_x > global_map.len ? 1 : cur_x)
		y_arr = global_map[next_x]
		target_z = y_arr[cur_y]
		next_x = 3
	else if (src.y <= 1)
		y_arr = global_map[cur_x]
		next_y = (--cur_y||y_arr.len)
		target_z = y_arr[next_y]
		next_y = world.maxy - 2
	else if (src.y >= world.maxy)
		y_arr = global_map[cur_x]
		next_y = (++cur_y > y_arr.len ? 1 : cur_y)
		target_z = y_arr[next_y]
		next_y = 3

	var/turf/T = locate(next_x, next_y, target_z)
	A.Move(T)

/turf/space/handle_slip()
	return

/turf/space/proc/Assign_Destination()

	if(transition)
		if(x <= TRANSITIONEDGE) 							//west
			destination_x = world.maxx - TRANSITIONEDGE - 2
		else if (x >= (world.maxx - TRANSITIONEDGE - 1)) 	//east
			destination_x = TRANSITIONEDGE + 1
		else if (y <= TRANSITIONEDGE) 						//south
			destination_y = world.maxy - TRANSITIONEDGE - 2
		else if (y >= (world.maxy - TRANSITIONEDGE - 1)) 	//north
			destination_y = TRANSITIONEDGE + 1

/datum/controller/game_controller/proc/setup_map_transistions() //listamania
	var/list/unplaced_z_levels = 			accessable_z_levels
	var/list/free_zones = 					list("A", "B", "C", "D", "E", "F")
	var/list/zone_connections = 			list("D ","C ","B ","E ","A ","C ","F ","E ","A ","D ","F ","B ","A ","E ","F ","C ","A ","B ","F ","D ","D ","C ","B ","E") //This describes the borders of a cube based on free zones, really!
	var/text_zone_connections = 			list2text(zone_connections)
	var/list/final_zone_connections =		list()
	var/list/turfs_needing_transition =		list()
	var/list/turfs_needing_destinations = 	list()
	var/list/z_level_order = 				list()
	var/z_level
	var/placement

	for(var/turf/space/S in world) //Define the transistions of the z levels
		if (S.x == TRANSITIONEDGE || S.x == (world.maxx - TRANSITIONEDGE - 1) || S.y == TRANSITIONEDGE || S.y == (world.maxy - TRANSITIONEDGE - 1))
			turfs_needing_transition += S

	while(free_zones.len != 0) //Assign the sides of the cube
		if(!unplaced_z_levels) //if we're somehow unable to fill the cube, pad with deep space
			z_level =  6
		else
			z_level = pick(unplaced_z_levels)
		if(z_level >> world.maxz) //A safety if one of the unplaced_z_levels doesn't actually exist
			z_level =  6
		placement = pick(free_zones)
		text_zone_connections = replacetext(text_zone_connections, placement, "[z_level]")

		for(var/turf/space/S in turfs_needing_transition) //pass the identity zone to the relevent turfs
			if(S.transition && prob(50)) //In z = 6 (deep space) it's a bit of a crapshoot in terms of navigation
				continue
			if(S.z == z_level)
				S.transition = z_level
				if(!(S in turfs_needing_destinations))
					turfs_needing_destinations += S
				if(S.z != 6) //deep space turfs need to hang around in case they get reassigned a zone
					turfs_needing_transition -= S

		z_level_order += z_level
		unplaced_z_levels -= z_level<commit_msg>Whoops, made a dumb mistake<commit_after>/turf/space
	icon = 'icons/turf/space.dmi'
	name = "\proper space"
	icon_state = "0"
	intact = 0

	temperature = TCMB
	thermal_conductivity = OPEN_HEAT_TRANSFER_COEFFICIENT
	heat_capacity = 700000

	var/transition //These is used in transistions as a way to tell where on the "cube" of space you're transitioning from/to
	var/destination_x
	var/destination_y

/turf/space/New()
	if(!istype(src, /turf/space/transit))
		icon_state = "[((x + y) ^ ~(x * y) + z) % 25]"

/turf/space/attack_paw(mob/user as mob)
	return src.attack_hand(user)

/turf/space/attackby(obj/item/C, mob/user)
	if(istype(C, /obj/item/stack/rods))
		var/obj/item/stack/rods/R = C
		var/obj/structure/lattice/L = locate(/obj/structure/lattice, src)
		if(L)
			user << "<span class='warning'>There is already a lattice.</span>"
			return
		if(R.use(1))
			user << "<span class='notice'>Constructing support lattice...</span>"
			playsound(src, 'sound/weapons/Genhit.ogg', 50, 1)
			ReplaceWithLattice()
		else
			user << "<span class='warning'>You need one rod to build lattice.</span>"
		return
	if(istype(C, /obj/item/stack/tile/plasteel))
		var/obj/structure/lattice/L = locate(/obj/structure/lattice, src)
		if(L)
			var/obj/item/stack/tile/plasteel/S = C
			if(S.use(1))
				qdel(L)
				playsound(src, 'sound/weapons/Genhit.ogg', 50, 1)
				user << "<span class='notice'>You build a floor.</span>"
				S.build(src)
			else
				user << "<span class='warning'>You need one floor tile to build a floor.</span>"
		else
			user << "<span class='danger'>The plating is going to need some support. Place metal rods first.</span>"

/turf/space/Entered(atom/movable/A)
	..()
	if ((!(A) || src != A.loc))
		return

	inertial_drift(A)

	if(transition)

		if(destination_x)
			A.x = destination_x

		if(destination_y)
			A.y = destination_y

		A.z =  text2num(transition)

		if(isliving(A))
			var/mob/living/L = A
			if(L.pulling)
				var/turf/T = get_step(L.loc,turn(A.dir, 180))
				L.pulling.loc = T

/turf/space/proc/Sandbox_Spacemove(atom/movable/A)
	var/cur_x
	var/cur_y
	var/next_x = src.x
	var/next_y = src.y
	var/target_z
	var/list/y_arr
	var/list/cur_pos = src.get_global_map_pos()
	if(!cur_pos)
		return
	cur_x = cur_pos["x"]
	cur_y = cur_pos["y"]

	if(src.x <= 1)
		next_x = (--cur_x||global_map.len)
		y_arr = global_map[next_x]
		target_z = y_arr[cur_y]
		next_x = world.maxx - 2
	else if (src.x >= world.maxx)
		next_x = (++cur_x > global_map.len ? 1 : cur_x)
		y_arr = global_map[next_x]
		target_z = y_arr[cur_y]
		next_x = 3
	else if (src.y <= 1)
		y_arr = global_map[cur_x]
		next_y = (--cur_y||y_arr.len)
		target_z = y_arr[next_y]
		next_y = world.maxy - 2
	else if (src.y >= world.maxy)
		y_arr = global_map[cur_x]
		next_y = (++cur_y > y_arr.len ? 1 : cur_y)
		target_z = y_arr[next_y]
		next_y = 3

	var/turf/T = locate(next_x, next_y, target_z)
	A.Move(T)

/turf/space/handle_slip()
	return

/turf/space/proc/Assign_Destination()

	if(transition)
		if(x <= TRANSITIONEDGE) 							//west
			destination_x = world.maxx - TRANSITIONEDGE - 2
		else if (x >= (world.maxx - TRANSITIONEDGE - 1)) 	//east
			destination_x = TRANSITIONEDGE + 1
		else if (y <= TRANSITIONEDGE) 						//south
			destination_y = world.maxy - TRANSITIONEDGE - 2
		else if (y >= (world.maxy - TRANSITIONEDGE - 1)) 	//north
			destination_y = TRANSITIONEDGE + 1

/datum/controller/game_controller/proc/setup_map_transistions() //listamania
	var/list/unplaced_z_levels = 			accessable_z_levels
	var/list/free_zones = 					list("A", "B", "C", "D", "E", "F")
	var/list/zone_connections = 			list("D ","C ","B ","E ","A ","C ","F ","E ","A ","D ","F ","B ","A ","E ","F ","C ","A ","B ","F ","D ","D ","C ","B ","E") //This describes the borders of a cube based on free zones, really!
	var/text_zone_connections = 			list2text(zone_connections)
	var/list/final_zone_connections =		list()
	var/list/turfs_needing_transition =		list()
	var/list/turfs_needing_destinations = 	list()
	var/list/z_level_order = 				list()
	var/z_level
	var/placement

	for(var/turf/space/S in world) //Define the transistions of the z levels
		if (S.x == TRANSITIONEDGE || S.x == (world.maxx - TRANSITIONEDGE - 1) || S.y == TRANSITIONEDGE || S.y == (world.maxy - TRANSITIONEDGE - 1))
			turfs_needing_transition += S

	while(free_zones.len != 0) //Assign the sides of the cube
		if(!unplaced_z_levels) //if we're somehow unable to fill the cube, pad with deep space
			z_level =  6
		else
			z_level = pick(unplaced_z_levels)
		if(z_level > world.maxz) //A safety if one of the unplaced_z_levels doesn't actually exist
			z_level =  6
		placement = pick(free_zones)
		text_zone_connections = replacetext(text_zone_connections, placement, "[z_level]")

		for(var/turf/space/S in turfs_needing_transition) //pass the identity zone to the relevent turfs
			if(S.transition && prob(50)) //In z = 6 (deep space) it's a bit of a crapshoot in terms of navigation
				continue
			if(S.z == z_level)
				S.transition = z_level
				if(!(S in turfs_needing_destinations))
					turfs_needing_destinations += S
				if(S.z != 6) //deep space turfs need to hang around in case they get reassigned a zone
					turfs_needing_transition -= S

		z_level_order += z_level
		unplaced_z_levels -= z_level
{'fraction_non_alphanumeric': 0.14869888475836432, 'fraction_numerical': 0.008769421408826613, 'mean_word_length': 3.528269313767803, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 42, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '642094', 'n_tokens_mistral': 4715, 'n_tokens_neox': 4164, 'n_words': 949}