<commit_before>// transit tube construction

// normal transit tubes
/obj/structure/c_transit_tube
	name = "unattached transit tube"
	icon = 'icons/obj/atmospherics/pipes/transit_tube.dmi'
	icon_state = "straight"
	desc = "An unattached segment of transit tube."
	density = FALSE
	layer = LOW_ITEM_LAYER //same as the built tube
	anchored = FALSE
	var/const/time_to_unwrench = 2 SECONDS
	var/flipped = 0
	var/build_type = /obj/structure/transit_tube
	var/flipped_build_type
	var/base_icon


/obj/structure/c_transit_tube/ComponentInitialize()
	. = ..()
	AddComponent(/datum/component/simple_rotation,ROTATION_ALTCLICK | ROTATION_CLOCKWISE | ROTATION_FLIP | ROTATION_VERBS,null,null,CALLBACK(src,.proc/after_rot))

/obj/structure/c_transit_tube/proc/after_rot(mob/user,rotation_type)
	if(flipped_build_type && rotation_type == ROTATION_FLIP)
		setDir(turn(dir,-180)) //Turn back we don't actually flip
		flipped = !flipped
		var/cur_flip = initial(flipped) ? !flipped : flipped
		if(cur_flip)
			build_type = flipped_build_type
		else
			build_type = initial(build_type)
		icon_state = "[base_icon][flipped]"

/obj/structure/c_transit_tube/wrench_act(mob/living/user, obj/item/I)
	to_chat(user, "<span class='notice'>You start attaching the [name]...</span>")
	add_fingerprint(user)
	if(I.use_tool(src, user, time_to_unwrench, volume=50))
		to_chat(user, "<span class='notice'>You attach the [name].</span>")
		var/obj/structure/transit_tube/R = new build_type(loc, dir)
		transfer_fingerprints_to(R)
		qdel(src)
	return TRUE
<commit_msg>Ports "Fixes transit tube barricade spam"<commit_after>// transit tube construction

// normal transit tubes
/obj/structure/c_transit_tube
	name = "unattached transit tube"
	icon = 'icons/obj/atmospherics/pipes/transit_tube.dmi'
	icon_state = "straight"
	desc = "An unattached segment of transit tube."
	density = FALSE
	layer = LOW_ITEM_LAYER //same as the built tube
	anchored = FALSE
	var/const/time_to_unwrench = 2 SECONDS
	var/flipped = 0
	var/build_type = /obj/structure/transit_tube
	var/flipped_build_type
	var/base_icon

/obj/structure/c_transit_tube/proc/can_wrench_in_loc(mob/user)
	var/turf/source_turf = get_turf(loc)
	var/existing_tubes = 0
	for(var/obj/structure/transit_tube/tube in source_turf)
		existing_tubes++
		if(existing_tubes >= 2)
			to_chat(user, "<span class='warning'>You cannot wrench any more transit tubes!</span>")
			return FALSE
	return TRUE

/obj/structure/c_transit_tube/ComponentInitialize()
	. = ..()
	AddComponent(/datum/component/simple_rotation,ROTATION_ALTCLICK | ROTATION_CLOCKWISE | ROTATION_FLIP | ROTATION_VERBS,null,null,CALLBACK(src,.proc/after_rot))

/obj/structure/c_transit_tube/proc/after_rot(mob/user,rotation_type)
	if(flipped_build_type && rotation_type == ROTATION_FLIP)
		setDir(turn(dir,-180)) //Turn back we don't actually flip
		flipped = !flipped
		var/cur_flip = initial(flipped) ? !flipped : flipped
		if(cur_flip)
			build_type = flipped_build_type
		else
			build_type = initial(build_type)
		icon_state = "[base_icon][flipped]"

/obj/structure/c_transit_tube/wrench_act(mob/living/user, obj/item/I)
	if(!can_wrench_in_loc(user))
		return
	to_chat(user, "<span class='notice'>You start attaching the [name]...</span>")
	add_fingerprint(user)
	if(I.use_tool(src, user, time_to_unwrench, volume=50, extra_checks=CALLBACK(src, .proc/can_wrench_in_loc, user)))
		to_chat(user, "<span class='notice'>You attach the [name].</span>")
		var/obj/structure/transit_tube/R = new build_type(loc, dir)
		transfer_fingerprints_to(R)
		qdel(src)
	return TRUE

{'fraction_non_alphanumeric': 0.12179306456160136, 'fraction_numerical': 0.004510854243022272, 'mean_word_length': 5.36983842010772, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 14, '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': '6001443', 'n_tokens_mistral': 1412, 'n_tokens_neox': 1333, 'n_words': 237}