<commit_before>/datum/star_system
	var/name = ""
	var/x = 0
	var/y = 0
	var/list/planets = list()
	var/alignment = "unaligned"
	var/visited = 0

	var/list/ships = list()

	var/danger_level = 0
	var/capital_planet = 0

	var/PathNode/PNode = null //for pathfinding

	var/datum/space_station/primary_station = null

/datum/star_system/proc/generate()
	name = generate_star_name()
	var/valid_coords = 0
	while(!valid_coords)
		generate_coords()
		valid_coords = 1
		for(var/datum/star_system/other in SSstarmap.star_systems)
			if(other == src)
				continue
			if(dist(other) <= 2)
				valid_coords = 0
				break

	for(var/I in 1 to rand(1, 9))
		var/datum/planet/P = new(src)
		P.generate(I)

	for(var/datum/planet/P in planets)
		//P.disp_dist = 0.1 * ((10 ^ (1/planets.len)) ^ P.disp_level)
		P.disp_dist = 0.25 * (4 ** (P.disp_level/planets.len))*1.3333 - 0.3333
		P.disp_x = cos(P.disp_angle) * P.disp_dist
		P.disp_y = sin(P.disp_angle) * P.disp_dist

/datum/star_system/proc/get_planet_for_z(z)
	for(var/datum/planet/P in planets)
		if(z in P.z_levels)
			return P

/datum/star_system/proc/generate_coords()
	x = rand(0, 1000) / 10
	y = rand(0, 1000) / 10

/datum/star_system/proc/dist(datum/star_system/other)
	var/dx = other.x - x
	var/dy = other.y - y
	return sqrt((dx * dx) + (dy * dy))

/datum/star_system/proc/lerp_x(datum/star_system/other, t)
	return x + (t * (other.x - x))

/datum/star_system/proc/lerp_y(datum/star_system/other, t)
	return y + (t * (other.y - y))

/datum/planet // Not necessarily a planet. If you don't like that it's called this, FUCK YOU.
	var/name = ""
	var/location_description = "In orbit around "
	var/goto_action = "Enter orbit"
	var/datum/star_system/parent_system
	var/list/rings_composition
	var/list/z_levels = list()
	var/list/docks = list()
	var/list/icon_layers = list()
	var/obj/docking_port/stationary/main_dock
	var/list/map_names = list("empty_space.dmm")
	var/spawn_ruins = 1
	var/planet_type = "Planet"
	var/disp_x = 0
	var/disp_y = 0
	var/disp_angle = 0
	var/disp_level = 0
	var/disp_dist = 0
	var/ringed = 0
	var/datum/space_station/station
	var/datum/board_ship/board
	var/keep_loaded = 0 // Adminbus var to keep planet loaded
	var/surface_area_type
	var/surface_turf_type
	var/resource_type
	var/nav_icon_name = "gas"
	var/no_unload_reason = ""

/datum/planet/New(p_system)
	parent_system = p_system
	parent_system.planets += src

/datum/planet/proc/do_unload()
	if(!main_dock)
		no_unload_reason = ""
		return 1

	// Active telecomms relays keep this z-level loaded.
	for(var/obj/machinery/telecomms/relay/R in GLOB.telecomms_list)
		if(!istype(R.loc.loc, /area/shuttle/ftl) && (R.z in z_levels) && R.on)
			no_unload_reason = "RELAY"
			return 0

	if(keep_loaded)
		no_unload_reason = ""
		return 0

	if(no_unload_reason == "FOB SHUTTLE")
		return 0

	no_unload_reason = ""
	return 1

/datum/planet/proc/generate(var/index, var/list/predefs)
	if(!predefs)
		predefs = list()
	name = "[parent_system.name] [index]"
	disp_level = index
	disp_angle = rand(0, 360)
	map_names = list()
	if(!predefs["norings"] && (prob(30) || predefs["rings"]))
		ringed = 1
		// Rings!
		map_names += "rings.dmm"
		icon_layers += "p_rings_under"

		// Composition of rings
		rings_composition = list()
		var/minerals_left = list(
			/turf/closed/mineral/uranium = 5, /turf/closed/mineral/diamond = 1, /turf/closed/mineral/gold = 10,
			/turf/closed/mineral/silver = 12, /turf/closed/mineral/plasma = 20, /turf/closed/mineral/iron = 40,
			/turf/closed/mineral/bscrystal = 1)
		var/chance_left = 100
		var/amount = 0
		while(chance_left > 0)
			amount++
			var/chance<commit_msg>Potential fix for the shuttle being unloaded. (#2832)<commit_after>/datum/star_system
	var/name = ""
	var/x = 0
	var/y = 0
	var/list/planets = list()
	var/alignment = "unaligned"
	var/visited = 0

	var/list/ships = list()

	var/danger_level = 0
	var/capital_planet = 0

	var/PathNode/PNode = null //for pathfinding

	var/datum/space_station/primary_station = null

/datum/star_system/proc/generate()
	name = generate_star_name()
	var/valid_coords = 0
	while(!valid_coords)
		generate_coords()
		valid_coords = 1
		for(var/datum/star_system/other in SSstarmap.star_systems)
			if(other == src)
				continue
			if(dist(other) <= 2)
				valid_coords = 0
				break

	for(var/I in 1 to rand(1, 9))
		var/datum/planet/P = new(src)
		P.generate(I)

	for(var/datum/planet/P in planets)
		//P.disp_dist = 0.1 * ((10 ^ (1/planets.len)) ^ P.disp_level)
		P.disp_dist = 0.25 * (4 ** (P.disp_level/planets.len))*1.3333 - 0.3333
		P.disp_x = cos(P.disp_angle) * P.disp_dist
		P.disp_y = sin(P.disp_angle) * P.disp_dist

/datum/star_system/proc/get_planet_for_z(z)
	for(var/datum/planet/P in planets)
		if(z in P.z_levels)
			return P

/datum/star_system/proc/generate_coords()
	x = rand(0, 1000) / 10
	y = rand(0, 1000) / 10

/datum/star_system/proc/dist(datum/star_system/other)
	var/dx = other.x - x
	var/dy = other.y - y
	return sqrt((dx * dx) + (dy * dy))

/datum/star_system/proc/lerp_x(datum/star_system/other, t)
	return x + (t * (other.x - x))

/datum/star_system/proc/lerp_y(datum/star_system/other, t)
	return y + (t * (other.y - y))

/datum/planet // Not necessarily a planet. If you don't like that it's called this, FUCK YOU.
	var/name = ""
	var/location_description = "In orbit around "
	var/goto_action = "Enter orbit"
	var/datum/star_system/parent_system
	var/list/rings_composition
	var/list/z_levels = list()
	var/list/docks = list()
	var/list/icon_layers = list()
	var/obj/docking_port/stationary/main_dock
	var/list/map_names = list("empty_space.dmm")
	var/spawn_ruins = 1
	var/planet_type = "Planet"
	var/disp_x = 0
	var/disp_y = 0
	var/disp_angle = 0
	var/disp_level = 0
	var/disp_dist = 0
	var/ringed = 0
	var/datum/space_station/station
	var/datum/board_ship/board
	var/keep_loaded = 0 // Adminbus var to keep planet loaded
	var/surface_area_type
	var/surface_turf_type
	var/resource_type
	var/nav_icon_name = "gas"
	var/no_unload_reason = ""

/datum/planet/New(p_system)
	parent_system = p_system
	parent_system.planets += src

/datum/planet/proc/do_unload()
	// Active telecomms relays keep this z-level loaded.
	for(var/obj/machinery/telecomms/relay/R in GLOB.telecomms_list)
		if(!istype(R.loc.loc, /area/shuttle/ftl) && (R.z in z_levels) && R.on && no_unload_reason == "")
			no_unload_reason = "RELAY"
			return 0

	if(keep_loaded)
		no_unload_reason = ""
		return 0

	if(no_unload_reason == "FOB SHUTTLE")
		return 0

	if(!main_dock)
		no_unload_reason = ""
		return 1

	no_unload_reason = ""
	return 1

/datum/planet/proc/generate(var/index, var/list/predefs)
	if(!predefs)
		predefs = list()
	name = "[parent_system.name] [index]"
	disp_level = index
	disp_angle = rand(0, 360)
	map_names = list()
	if(!predefs["norings"] && (prob(30) || predefs["rings"]))
		ringed = 1
		// Rings!
		map_names += "rings.dmm"
		icon_layers += "p_rings_under"

		// Composition of rings
		rings_composition = list()
		var/minerals_left = list(
			/turf/closed/mineral/uranium = 5, /turf/closed/mineral/diamond = 1, /turf/closed/mineral/gold = 10,
			/turf/closed/mineral/silver = 12, /turf/closed/mineral/plasma = 20, /turf/closed/mineral/iron = 40,
			/turf/closed/mineral/bscrystal = 1)
		var/chance_left = 100
		var/amount = 0
		while(chance_left > 0)
			amount++
			var/chance
{'fraction_non_alphanumeric': 0.14336622807017543, 'fraction_numerical': 0.02275219298245614, 'mean_word_length': 3.6037854889589904, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4512398', 'n_tokens_mistral': 3385, 'n_tokens_neox': 3032, 'n_words': 563}